@toclocoinc/lattice-grid 1.115.1 → 1.115.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/angular/package.json +1 -1
- package/docs/API.html +4 -4
- 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 +1 -1
- package/docs/api/kanban.html +1 -1
- package/docs/api/kpi.html +1 -1
- package/docs/api/layout.html +1 -1
- package/docs/api/leaflet.html +1 -1
- package/docs/api/list.html +1 -1
- package/docs/api/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 +4 -4
- package/docs/warnings.json +1 -1
- package/lattice-grid.d.ts +1 -1
- package/lattice-grid.esm.min.js +2 -2
- package/lattice-grid.min.cjs +2 -2
- package/lattice-grid.min.js +2 -2
- package/locales/all.d.ts +1 -1
- package/locales/all.esm.min.js +1 -1
- package/locales/all.min.cjs +1 -1
- package/locales/all.min.js +1 -1
- package/locales/ar.d.ts +1 -1
- package/locales/ar.esm.min.js +1 -1
- package/locales/ar.min.cjs +1 -1
- package/locales/ar.min.js +1 -1
- package/locales/cs-CZ.d.ts +1 -1
- package/locales/cs-CZ.esm.min.js +1 -1
- package/locales/cs-CZ.min.cjs +1 -1
- package/locales/cs-CZ.min.js +1 -1
- package/locales/da-DK.d.ts +1 -1
- package/locales/da-DK.esm.min.js +1 -1
- package/locales/da-DK.min.cjs +1 -1
- package/locales/da-DK.min.js +1 -1
- package/locales/de-DE.d.ts +1 -1
- package/locales/de-DE.esm.min.js +1 -1
- package/locales/de-DE.min.cjs +1 -1
- package/locales/de-DE.min.js +1 -1
- package/locales/el-GR.d.ts +1 -1
- package/locales/el-GR.esm.min.js +1 -1
- package/locales/el-GR.min.cjs +1 -1
- package/locales/el-GR.min.js +1 -1
- package/locales/en-US.d.ts +1 -1
- package/locales/en-US.esm.min.js +1 -1
- package/locales/en-US.min.cjs +1 -1
- package/locales/en-US.min.js +1 -1
- package/locales/es-ES.d.ts +1 -1
- package/locales/es-ES.esm.min.js +1 -1
- package/locales/es-ES.min.cjs +1 -1
- package/locales/es-ES.min.js +1 -1
- package/locales/fi-FI.d.ts +1 -1
- package/locales/fi-FI.esm.min.js +1 -1
- package/locales/fi-FI.min.cjs +1 -1
- package/locales/fi-FI.min.js +1 -1
- package/locales/fr-CA.d.ts +1 -1
- package/locales/fr-CA.esm.min.js +1 -1
- package/locales/fr-CA.min.cjs +1 -1
- package/locales/fr-CA.min.js +1 -1
- package/locales/fr-FR.d.ts +1 -1
- package/locales/fr-FR.esm.min.js +1 -1
- package/locales/fr-FR.min.cjs +1 -1
- package/locales/fr-FR.min.js +1 -1
- package/locales/hu-HU.d.ts +1 -1
- package/locales/hu-HU.esm.min.js +1 -1
- package/locales/hu-HU.min.cjs +1 -1
- package/locales/hu-HU.min.js +1 -1
- package/locales/it-IT.d.ts +1 -1
- package/locales/it-IT.esm.min.js +1 -1
- package/locales/it-IT.min.cjs +1 -1
- package/locales/it-IT.min.js +1 -1
- package/locales/ja-JP.d.ts +1 -1
- package/locales/ja-JP.esm.min.js +1 -1
- package/locales/ja-JP.min.cjs +1 -1
- package/locales/ja-JP.min.js +1 -1
- package/locales/nb-NO.d.ts +1 -1
- package/locales/nb-NO.esm.min.js +1 -1
- package/locales/nb-NO.min.cjs +1 -1
- package/locales/nb-NO.min.js +1 -1
- package/locales/nl-NL.d.ts +1 -1
- package/locales/nl-NL.esm.min.js +1 -1
- package/locales/nl-NL.min.cjs +1 -1
- package/locales/nl-NL.min.js +1 -1
- package/locales/pl-PL.d.ts +1 -1
- package/locales/pl-PL.esm.min.js +1 -1
- package/locales/pl-PL.min.cjs +1 -1
- package/locales/pl-PL.min.js +1 -1
- package/locales/pt-BR.d.ts +1 -1
- package/locales/pt-BR.esm.min.js +1 -1
- package/locales/pt-BR.min.cjs +1 -1
- package/locales/pt-BR.min.js +1 -1
- package/locales/ro-RO.d.ts +1 -1
- package/locales/ro-RO.esm.min.js +1 -1
- package/locales/ro-RO.min.cjs +1 -1
- package/locales/ro-RO.min.js +1 -1
- package/locales/sv-SE.d.ts +1 -1
- package/locales/sv-SE.esm.min.js +1 -1
- package/locales/sv-SE.min.cjs +1 -1
- package/locales/sv-SE.min.js +1 -1
- package/locales/uk-UA.d.ts +1 -1
- package/locales/uk-UA.esm.min.js +1 -1
- package/locales/uk-UA.min.cjs +1 -1
- package/locales/uk-UA.min.js +1 -1
- package/modules/ai.d.ts +1 -1
- package/modules/ai.esm.min.js +1 -1
- package/modules/ai.min.cjs +1 -1
- package/modules/ai.min.js +1 -1
- package/modules/alarms.d.ts +1 -1
- package/modules/alarms.esm.min.js +1 -1
- package/modules/alarms.min.cjs +1 -1
- package/modules/alarms.min.js +1 -1
- package/modules/angular.d.ts +1 -1
- package/modules/angular.esm.min.js +1 -1
- package/modules/angular.min.cjs +1 -1
- package/modules/angular.min.js +1 -1
- package/modules/calendar.d.ts +1 -1
- package/modules/calendar.esm.min.js +1 -1
- package/modules/calendar.min.cjs +1 -1
- package/modules/calendar.min.js +1 -1
- package/modules/chart-alluvial.d.ts +1 -1
- package/modules/chart-alluvial.esm.min.js +1 -1
- package/modules/chart-alluvial.min.cjs +1 -1
- package/modules/chart-alluvial.min.js +1 -1
- package/modules/chart-arc.d.ts +1 -1
- package/modules/chart-arc.esm.min.js +1 -1
- package/modules/chart-arc.min.cjs +1 -1
- package/modules/chart-arc.min.js +1 -1
- package/modules/chart-barrace.d.ts +1 -1
- package/modules/chart-barrace.esm.min.js +1 -1
- package/modules/chart-barrace.min.cjs +1 -1
- package/modules/chart-barrace.min.js +1 -1
- package/modules/chart-bubblemap.d.ts +1 -1
- package/modules/chart-bubblemap.esm.min.js +1 -1
- package/modules/chart-bubblemap.min.cjs +1 -1
- package/modules/chart-bubblemap.min.js +1 -1
- package/modules/chart-bump.d.ts +1 -1
- package/modules/chart-bump.esm.min.js +1 -1
- package/modules/chart-bump.min.cjs +1 -1
- package/modules/chart-bump.min.js +1 -1
- package/modules/chart-calendar.d.ts +1 -1
- package/modules/chart-calendar.esm.min.js +1 -1
- package/modules/chart-calendar.min.cjs +1 -1
- package/modules/chart-calendar.min.js +1 -1
- package/modules/chart-choropleth.d.ts +1 -1
- package/modules/chart-choropleth.esm.min.js +1 -1
- package/modules/chart-choropleth.min.cjs +1 -1
- package/modules/chart-choropleth.min.js +1 -1
- package/modules/chart-decomposition.d.ts +1 -1
- package/modules/chart-decomposition.esm.min.js +1 -1
- package/modules/chart-decomposition.min.cjs +1 -1
- package/modules/chart-decomposition.min.js +1 -1
- package/modules/chart-diverging.d.ts +1 -1
- package/modules/chart-diverging.esm.min.js +1 -1
- package/modules/chart-diverging.min.cjs +1 -1
- package/modules/chart-diverging.min.js +1 -1
- package/modules/chart-dumbbell.d.ts +1 -1
- package/modules/chart-dumbbell.esm.min.js +1 -1
- package/modules/chart-dumbbell.min.cjs +1 -1
- package/modules/chart-dumbbell.min.js +1 -1
- package/modules/chart-fan.d.ts +1 -1
- package/modules/chart-fan.esm.min.js +1 -1
- package/modules/chart-fan.min.cjs +1 -1
- package/modules/chart-fan.min.js +1 -1
- package/modules/chart-forcetree.d.ts +1 -1
- package/modules/chart-forcetree.esm.min.js +1 -1
- package/modules/chart-forcetree.min.cjs +1 -1
- package/modules/chart-forcetree.min.js +1 -1
- package/modules/chart-hexbin.d.ts +1 -1
- package/modules/chart-hexbin.esm.min.js +1 -1
- package/modules/chart-hexbin.min.cjs +1 -1
- package/modules/chart-hexbin.min.js +1 -1
- package/modules/chart-hexmap.d.ts +1 -1
- package/modules/chart-hexmap.esm.min.js +1 -1
- package/modules/chart-hexmap.min.cjs +1 -1
- package/modules/chart-hexmap.min.js +1 -1
- package/modules/chart-icicle.d.ts +1 -1
- package/modules/chart-icicle.esm.min.js +1 -1
- package/modules/chart-icicle.min.cjs +1 -1
- package/modules/chart-icicle.min.js +1 -1
- package/modules/chart-markermap.d.ts +1 -1
- package/modules/chart-markermap.esm.min.js +1 -1
- package/modules/chart-markermap.min.cjs +1 -1
- package/modules/chart-markermap.min.js +1 -1
- package/modules/chart-motion.d.ts +1 -1
- package/modules/chart-motion.esm.min.js +1 -1
- package/modules/chart-motion.min.cjs +1 -1
- package/modules/chart-motion.min.js +1 -1
- package/modules/chart-pack.d.ts +1 -1
- package/modules/chart-pack.esm.min.js +1 -1
- package/modules/chart-pack.min.cjs +1 -1
- package/modules/chart-pack.min.js +1 -1
- package/modules/chart-parallel.d.ts +1 -1
- package/modules/chart-parallel.esm.min.js +1 -1
- package/modules/chart-parallel.min.cjs +1 -1
- package/modules/chart-parallel.min.js +1 -1
- package/modules/chart-pictorial.d.ts +1 -1
- package/modules/chart-pictorial.esm.min.js +1 -1
- package/modules/chart-pictorial.min.cjs +1 -1
- package/modules/chart-pictorial.min.js +1 -1
- package/modules/chart-polararea.d.ts +1 -1
- package/modules/chart-polararea.esm.min.js +1 -1
- package/modules/chart-polararea.min.cjs +1 -1
- package/modules/chart-polararea.min.js +1 -1
- package/modules/chart-polarscatter.d.ts +1 -1
- package/modules/chart-polarscatter.esm.min.js +1 -1
- package/modules/chart-polarscatter.min.cjs +1 -1
- package/modules/chart-polarscatter.min.js +1 -1
- package/modules/chart-pyramid.d.ts +1 -1
- package/modules/chart-pyramid.esm.min.js +1 -1
- package/modules/chart-pyramid.min.cjs +1 -1
- package/modules/chart-pyramid.min.js +1 -1
- package/modules/chart-radialbar.d.ts +1 -1
- package/modules/chart-radialbar.esm.min.js +1 -1
- package/modules/chart-radialbar.min.cjs +1 -1
- package/modules/chart-radialbar.min.js +1 -1
- package/modules/chart-ridgeline.d.ts +1 -1
- package/modules/chart-ridgeline.esm.min.js +1 -1
- package/modules/chart-ridgeline.min.cjs +1 -1
- package/modules/chart-ridgeline.min.js +1 -1
- package/modules/chart-roc.d.ts +1 -1
- package/modules/chart-roc.esm.min.js +1 -1
- package/modules/chart-roc.min.cjs +1 -1
- package/modules/chart-roc.min.js +1 -1
- package/modules/chart-scatter3d.d.ts +1 -1
- package/modules/chart-scatter3d.esm.min.js +1 -1
- package/modules/chart-scatter3d.min.cjs +1 -1
- package/modules/chart-scatter3d.min.js +1 -1
- package/modules/chart-serpentine.d.ts +1 -1
- package/modules/chart-serpentine.esm.min.js +1 -1
- package/modules/chart-serpentine.min.cjs +1 -1
- package/modules/chart-serpentine.min.js +1 -1
- package/modules/chart-slope.d.ts +1 -1
- package/modules/chart-slope.esm.min.js +1 -1
- package/modules/chart-slope.min.cjs +1 -1
- package/modules/chart-slope.min.js +1 -1
- package/modules/chart-spiral.d.ts +1 -1
- package/modules/chart-spiral.esm.min.js +1 -1
- package/modules/chart-spiral.min.cjs +1 -1
- package/modules/chart-spiral.min.js +1 -1
- package/modules/chart-splom.d.ts +1 -1
- package/modules/chart-splom.esm.min.js +1 -1
- package/modules/chart-splom.min.cjs +1 -1
- package/modules/chart-splom.min.js +1 -1
- package/modules/chart-tree.d.ts +1 -1
- package/modules/chart-tree.esm.min.js +1 -1
- package/modules/chart-tree.min.cjs +1 -1
- package/modules/chart-tree.min.js +1 -1
- package/modules/chart-venn.d.ts +1 -1
- package/modules/chart-venn.esm.min.js +1 -1
- package/modules/chart-venn.min.cjs +1 -1
- package/modules/chart-venn.min.js +1 -1
- package/modules/chart-voronoi.d.ts +1 -1
- package/modules/chart-voronoi.esm.min.js +1 -1
- package/modules/chart-voronoi.min.cjs +1 -1
- package/modules/chart-voronoi.min.js +1 -1
- package/modules/chart-waffle.d.ts +1 -1
- package/modules/chart-waffle.esm.min.js +1 -1
- package/modules/chart-waffle.min.cjs +1 -1
- package/modules/chart-waffle.min.js +1 -1
- package/modules/chart-wordcloud.d.ts +1 -1
- package/modules/chart-wordcloud.esm.min.js +1 -1
- package/modules/chart-wordcloud.min.cjs +1 -1
- package/modules/chart-wordcloud.min.js +1 -1
- package/modules/charts.d.ts +1 -1
- package/modules/charts.esm.min.js +1 -1
- package/modules/charts.min.cjs +1 -1
- package/modules/charts.min.js +1 -1
- package/modules/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 +1 -1
- package/modules/kanban.esm.min.js +7 -4
- package/modules/kanban.esm.min.js.map +1 -1
- package/modules/kanban.min.cjs +7 -4
- package/modules/kanban.min.js +7 -4
- package/modules/kanban.min.js.map +1 -1
- package/modules/kpi.d.ts +1 -1
- package/modules/kpi.esm.min.js +1 -1
- package/modules/kpi.min.cjs +1 -1
- package/modules/kpi.min.js +1 -1
- package/modules/layout.d.ts +1 -1
- package/modules/layout.esm.min.js +1 -1
- package/modules/layout.min.cjs +1 -1
- package/modules/layout.min.js +1 -1
- package/modules/leaflet.d.ts +1 -1
- package/modules/leaflet.esm.min.js +1 -1
- package/modules/leaflet.min.cjs +1 -1
- package/modules/leaflet.min.js +1 -1
- package/modules/list.d.ts +1 -1
- package/modules/list.esm.min.js +1 -1
- package/modules/list.min.cjs +1 -1
- package/modules/list.min.js +1 -1
- package/modules/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/lattice-grid.esm.min.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Lattice Grid 1.115.
|
|
2
|
+
* Lattice Grid 1.115.2, core + DOM renderer
|
|
3
3
|
* Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
|
|
4
4
|
* https://latticegrid.dev
|
|
5
5
|
*/
|
|
6
6
|
var Rr=Object.create(null),$r=Object.create(null);function Ue(e,B){Rr[e]=B}function or(e){var B=$r[e];if(B)return B;var re=Object.create(null);$r[e]=re;var T=Rr[e];if(!T)throw new Error("[lattice] missing module: "+e);return T(re,or),re}Ue("packages/core/src/internal/predicates.js",function(e,B){"use strict";Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return I}});function re(Z){return Z!==null&&typeof Z=="object"&&!Array.isArray(Z)}function T(Z){return typeof Z=="function"}function G(Z){return Z==null}function D(Z){return Z==null||Z===""}function I(Z){return typeof Z!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(Z))?!0:!!(Z.prototype&&Object.getOwnPropertyNames(Z.prototype).length>1)}}),Ue("packages/core/src/internal/warn.js",function(e,B){"use strict";Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return g}});const re=new Set,T=2e3;function G(a){if(re.add(a),re.size>T){const r=re.values().next().value;r!==void 0&&re.delete(r)}}const D=[],I=500;function Z(a,r,i){D.push({key:a,level:r,message:i.map(c=>typeof c=="string"?c:z(c)).join(" "),at:Date.now()}),D.length>I&&D.shift()}function z(a){if(a instanceof Error)return a.message;try{return JSON.stringify(a)}catch{return String(a)}}function L(){return D.map(a=>({...a}))}function X(a){if(a.length===0||typeof a[0]!="string")return a;const r=a[0].replace(/^\[lattice\]\s*/,"");return r===a[0]?a:[r,...a.slice(1)]}function $(a,...r){if(re.has(a))return;G(a);const i=X(r);Z(a,"warn",i),console.warn("[lattice]",...i)}function A(a,...r){if(re.has(a))return;G(a);const i=X(r);Z(a,"info",i),console.info("[lattice]",...i)}function k(){re.clear(),D.length=0}function y(a,r){const i=new Error(`[lattice] ${a}`);throw r!==void 0&&(i.cause=r),i}function f(a,r){a||y(r)}const g=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})()}),Ue("packages/core/src/formatting/rules.js",function(e,B){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return Y}});const T=B("packages/core/src/internal/predicates.js").isFunction,D=B("packages/core/src/internal/warn.js").warnOnce,I=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"]),z=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 L(C,S){const F=Number(C),P=Number(S);if(C!==null&&C!==""&&S!==null&&S!==""&&Number.isFinite(F)&&Number.isFinite(P))return F<P?-1:F>P?1:0;const x=String(C??"").toLowerCase(),U=String(S??"").toLowerCase();return x<U?-1:x>U?1:0}function X(C){return C==null||C===""}function $(C,S){if(!S||typeof S!="object")return!1;const{op:F}=S,P=S.value,M=S.value2;switch(F){case"blank":return X(C);case"notBlank":return!X(C);case"true":return C===!0;case"false":return C===!1;default:break}if(X(C))return!1;switch(F){case"eq":return L(C,P)===0;case"ne":return L(C,P)!==0;case"gt":return L(C,P)>0;case"gte":return L(C,P)>=0;case"lt":return L(C,P)<0;case"lte":return L(C,P)<=0;case"between":return L(C,P)>=0&&L(C,M)<=0;case"outside":return L(C,P)<0||L(C,M)>0;case"contains":return String(C).toLowerCase().includes(String(P??"").toLowerCase());case"notContains":return!String(C).toLowerCase().includes(String(P??"").toLowerCase());case"startsWith":return String(C).toLowerCase().startsWith(String(P??"").toLowerCase());case"endsWith":return String(C).toLowerCase().endsWith(String(P??"").toLowerCase());default:return!1}}function A(C,S,F){const P=J=>{const ee=String(J).replace("#",""),ne=ee.length===3?ee.split("").map(se=>se+se).join(""):ee;return[0,2,4].map(se=>parseInt(ne.slice(se,se+2),16)||0)},[M,x,U]=P(C),[_,W,q]=P(S),N=Math.max(0,Math.min(1,F)),Q=(J,ee)=>Math.round(J+(ee-J)*N);return`#${[Q(M,_),Q(x,W),Q(U,q)].map(J=>J.toString(16).padStart(2,"0")).join("")}`}function k(C){const S=[];for(const _ of C||[]){if(_==null||_==="")continue;const W=_ instanceof Date?_.getTime():Number(_);Number.isFinite(W)&&S.push(W)}if(!S.length)return null;S.sort((_,W)=>_-W);let F=0,P=0,M=0;for(const _ of S){F++;const W=_-P;P+=W/F,M+=W*(_-P)}const x=y(S,.25),U=y(S,.75);return{n:S.length,min:S[0],max:S[S.length-1],mean:P,stddev:S.length>1?Math.sqrt(M/(S.length-1)):0,median:y(S,.5),q1:x,q3:U,iqr:U-x,sorted:S}}function y(C,S){if(!C.length)return 0;const F=(C.length-1)*Math.max(0,Math.min(1,S)),P=Math.floor(F),M=Math.ceil(F);return P===M?C[P]:C[P]+(F-P)*(C[M]-C[P])}function f(C){for(const S of Array.isArray(C)?C:[])if(!(!S||typeof S!="object")&&(S.when&&Z.includes(S.when.op)||S.scale&&S.scale.from||S.dataBar&&!(Number.isFinite(Number(S.dataBar.min))&&Number.isFinite(Number(S.dataBar.max)))||S.iconSet&&!Array.isArray(S.iconSet.thresholds)))return!0;return!1}function g(C,S){const F=Number(C.value),P=M=>y(S.sorted,M);switch(C.op){case"topPercent":{const M=a(F,10);return{op:"gte",value:P(1-M)}}case"bottomPercent":{const M=a(F,10);return{op:"lte",value:P(M)}}case"topN":{const M=Math.max(1,Math.floor(F)||1),x=Math.max(0,S.sorted.length-M);return{op:"gte",value:S.sorted[x]}}case"bottomN":{const M=Math.max(1,Math.floor(F)||1),x=Math.min(S.sorted.length-1,M-1);return{op:"lte",value:S.sorted[x]}}case"aboveMean":return{op:"gt",value:S.mean};case"belowMean":return{op:"lt",value:S.mean};case"aboveMedian":return{op:"gt",value:S.median};case"belowMedian":return{op:"lt",value:S.median};case"zAbove":return S.stddev?{op:"gte",value:S.mean+(Number.isFinite(F)?F:2)*S.stddev}:null;case"zBelow":return S.stddev?{op:"lte",value:S.mean-(Number.isFinite(F)?F:2)*S.stddev}:null;case"outlier":{const M=(Number.isFinite(F)&&F>0?F:1.5)*S.iqr;return S.iqr?{op:"outside",value:S.q1-M,value2:S.q3+M}:null}default:return null}}function a(C,S){const F=Number.isFinite(C)?C:S,P=F>1?F/100:F;return Math.max(0,Math.min(1,P))}function r(C,S){if(C.from==="minmax")return{...C,min:S.min,max:S.max};if(C.from==="quantile")return{...C,min:y(S.sorted,a(Number(C.low),5)),max:y(S.sorted,a(Number(C.high),95))};if(C.from==="stddev"){const F=Number.isFinite(Number(C.deviations))?Number(C.deviations):2;return{...C,min:S.mean-F*S.stddev,max:S.mean+F*S.stddev}}return C}function i(C,S){const F=Array.isArray(C)?C:[];return!S||!S.n?F.map(P=>P&&f([P])?{...P,enabled:!1}:P):F.map(P=>{if(!P||typeof P!="object")return P;if(P.scale&&P.scale.from)return{...P,scale:r(P.scale,S)};if(P.dataBar)return{...P,dataBar:c(P.dataBar,S)};if(P.iconSet)return{...P,iconSet:u(P.iconSet,S)};if(!P.when||!Z.includes(P.when.op))return P;const M=g(P.when,S);return M?{...P,when:M}:{...P,enabled:!1}})}function c(C,S){const F=Number.isFinite(Number(C.min))?Number(C.min):void 0,P=Number.isFinite(Number(C.max))?Number(C.max):void 0;if(F!==void 0&&P!==void 0)return{...C,min:F,max:P};if(C.from==="quantile")return{...C,min:F??y(S.sorted,a(Number(C.low),5)),max:P??y(S.sorted,a(Number(C.high),95))};if(C.from==="stddev"){const M=Number.isFinite(Number(C.deviations))?Number(C.deviations):2;return{...C,min:F??S.mean-M*S.stddev,max:P??S.mean+M*S.stddev}}return{...C,min:F??S.min,max:P??S.max}}function u(C,S){if(Array.isArray(C.thresholds))return C;const F=n(C),P=[];for(let M=1;M<F;M++)P.push(y(S.sorted,M/F));return{...C,thresholds:P}}function n(C){if(Array.isArray(C.icons)&&C.icons.length>=2)return C.icons.length;if(Number.isFinite(Number(C.count))&&Number(C.count)>=2)return Math.floor(Number(C.count));const S=b[C.set];return S?S.length:3}function m(C){return`url("data:image/svg+xml,${encodeURIComponent(C)}")`}function t(C){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${C}"/></svg>`}function s(C,S){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${S==="up"?"8,2 14,13 2,13":S==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${C}"/></svg>`}function h(C,S){const F="M8 1l1.9 3.9 4.3.6-3.1 3 .7 4.3L8 13.8 4.2 15.8l.7-4.3-3.1-3 4.3-.6z";let P=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${S*16} 16">`;for(let M=0;M<S;M++){const x=M<C?"#f5a623":"#d0d0d0";P+=`<path transform="translate(${M*16},0)" d="${F}" fill="${x}"/>`}return`${P}</svg>`}const d=Object.freeze([s("#c0392b","down"),s("#e0a800","right"),s("#2e7d32","up")]),o=Object.freeze([t("#d13438"),t("#f5a623"),t("#2e9e44")]),b=Object.freeze({arrows:d,trafficLights:o,ratings:Object.freeze([1,2,3,4,5].map(C=>h(C,5)))}),l=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function p(C){if(Array.isArray(C.icons)&&C.icons.length>=2)return C.icons.map(P=>/^\s*(url\(|data:|<)/.test(String(P))&&String(P).trim().startsWith("<")?m(String(P)):String(P));const S=C.set||"arrows";if(S==="ratings"){const P=n(C),M=[];for(let x=1;x<=P;x++)M.push(m(h(x,P)));return M}const F=b[S];return F?F.map(m):(D(`iconSet:${S}`,`unknown icon set '${S}'; falling back to arrows.`),d.map(m))}function w(C){const S=Number(C.min),P=Number(C.max)-S,M=C.colour||C.color||"#5b9bd5",x=C.negativeColour||C.negativeColor||"#d13438",U=C.direction==="rtl"?"left":"right",_=q=>Math.max(0,Math.min(1,(q-S)/P))*100,W=P?Math.max(0,Math.min(100,(0-S)/P*100)):0;return q=>{if(X(q))return null;const N=Number(q);if(!Number.isFinite(N)||!P)return null;const Q=_(N),J=Math.min(Q,W),ee=Math.max(Q,W),ne=N>=0?M:x;return{backgroundImage:`linear-gradient(to ${U}, transparent ${J}%, ${ne} ${J}%, ${ne} ${ee}%, transparent ${ee}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function v(C){const S=p(C),F=C.reverse?[...S].reverse():S,P=(Array.isArray(C.thresholds)?C.thresholds:[]).map(Number).filter(Number.isFinite),M=Number.isFinite(Number(C.size))?Number(C.size):16,x=C.set==="ratings"?M*n(C):M;return U=>{if(X(U))return null;const _=Number(U);if(!Number.isFinite(_))return null;let W=0;for(const N of P)_>=N&&W++;const q=F[Math.min(W,F.length-1)];return q?{backgroundImage:q,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${x}px ${M}px`,paddingLeft:`${x+4}px`}:null}}function R(C){const S=Array.isArray(C.colours)&&C.colours.length>=2?C.colours:["#f8f9fa","#1a6bc7"],F=Number(C.min),P=Number(C.max),M=P-F,x=S.length-1,U=[];for(let W=0;W<=x;W++)U.push(x?W/x:0);const _=Number(C.mid);if(C.mid!==void 0&&C.mid!==null)if(S.length%2===0)D("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${S.length} were given, so "mid" was ignored.`);else if(Number.isFinite(_)&&M&&_>Math.min(F,P)&&_<Math.max(F,P)){const W=x/2,q=Math.max(0,Math.min(1,(_-F)/M));for(let N=0;N<=x;N++)U[N]=N<=W?W?N/W*q:q:q+(N-W)/(x-W)*(1-q)}else Number.isFinite(_)&&D("formatting.scale.mid.range",`a scale's "mid" (${_}) is outside its min..max range, so it was ignored.`);return W=>{const q=Number(W);if(!Number.isFinite(q)||!M)return null;const N=Math.max(0,Math.min(1,(q-F)/M));let Q=0;for(;Q<x-1&&N>U[Q+1];)Q++;const J=U[Q+1]-U[Q],ee=J>0?(N-U[Q])/J:0;return{background:A(S[Q],S[Q+1],Math.max(0,Math.min(1,ee)))}}}function Y(C,S=null){const F=f(C)?i(C,S):C,P=(Array.isArray(F)?F:[]).filter(U=>U&&typeof U=="object");if(!P.length)return()=>null;const M=P.map(U=>U.scale?{scale:R(U.scale),enabled:U.enabled!==!1}:U.dataBar?{scale:w(U.dataBar),enabled:U.enabled!==!1}:U.iconSet?{scale:v(U.iconSet),enabled:U.enabled!==!1}:{when:U.when,style:U.style,stop:U.stopIfTrue!==!1,enabled:U.enabled!==!1}),x=K(M)?O():null;return(U,_)=>{const W=U?U.value:void 0;let q=null;_&&(_.mode=0);for(const N of M){if(!N.enabled)continue;if(N.scale){const ee=N.scale(W);ee&&(q={...q||{},...ee});continue}if(!$(W,N.when))continue;let Q;const J=T(N.style);if(J?_&&x?(Q=N.style(x.enter(U)),x.mode>_.mode&&(_.mode=x.mode)):Q=N.style(U):Q=N.style,Q&&(q=q?{...q,...Q}:J?Q:{...Q}),N.stop)break}return q}}function K(C){return C.some(S=>S.enabled&&!S.scale&&T(S.style))}const V=new Set(["value","colId","column"]),E=new Set(["row","data","index"]);function O(){let C={};const S={mode:0,enter(M){return C=M||{},S.mode=0,P}},F=M=>{if(V.has(M))return;const x=E.has(M)?1:2;x>S.mode&&(S.mode=x)},P=new Proxy({},{get(M,x){return F(x),C[x]},has(M,x){return F(x),x in C},set(M,x,U){return S.mode=2,C[x]=U,!0},ownKeys(){return S.mode=2,Reflect.ownKeys(C)},getOwnPropertyDescriptor(M,x){S.mode=2;const U=Object.getOwnPropertyDescriptor(C,x);return U?{value:C[x],enumerable:U.enumerable,configurable:!0,writable:!0}:void 0}});return S}}),Ue("packages/core/src/formula/parse.js",function(e,B){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return i}});const re="num",T="str",G="ref",D="name",I="op",Z="end",z=["<=",">=","<>","!="],L="+-*/^%(),<>=";class X extends Error{constructor(u,n){super(u),this.name="FormulaError",this.at=n}}function $(c){const u=[];let n=0;for(;n<c.length;){const m=c[n];if(m===" "||m===" "||m===`
|
|
7
|
-
`||m==="\r"){n++;continue}if(m>="0"&&m<="9"){n=k(c,n,u);continue}if(m==="."&&c[n+1]>="0"&&c[n+1]<="9"){n=k(c,n,u);continue}if(m==='"'||m==="'"){n=y(c,n,u);continue}if(m==="["){const s=c.indexOf("]",n+1);if(s<0)throw new X("a [column reference] was opened and never closed",n);u.push({kind:G,value:c.slice(n+1,s).trim(),at:n}),n=s+1;continue}if(A(m)){n=f(c,n,u);continue}const t=c.slice(n,n+2);if(z.includes(t)){u.push({kind:I,value:t==="!="?"<>":t,at:n}),n+=2;continue}if(L.includes(m)){u.push({kind:I,value:m,at:n}),n++;continue}throw new X(`unexpected character ${JSON.stringify(m)}`,n)}return u.push({kind:Z,value:null,at:c.length}),u}function A(c){return/[A-Za-z_À-]/.test(c)}function k(c,u,n){let m=u,t=!1;for(;m<c.length;){const s=c[m];if(s>="0"&&s<="9"){m++;continue}if(s==="."&&!t){t=!0,m++;continue}if((s==="e"||s==="E")&&/[0-9+-]/.test(c[m+1]||"")){for(m+=2;m<c.length&&c[m]>="0"&&c[m]<="9";)m++;break}break}return n.push({kind:re,value:Number(c.slice(u,m)),at:u}),m}function y(c,u,n){const m=c[u];let t=u+1,s="";for(;t<c.length;){if(c[t]===m){if(c[t+1]===m){s+=m,t+=2;continue}return n.push({kind:T,value:s,at:u}),t+1}s+=c[t],t++}throw new X("a string was opened and never closed",u)}function f(c,u,n){let m=u;for(;m<c.length&&/[A-Za-z0-9_.À-]/.test(c[m]);)m++;const t=c.slice(u,m);let s=m;for(;s<c.length&&c[s]===" ";)s++;return n.push({kind:c[s]==="("?D:G,value:t,at:u}),m}const g={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function a(c){const u=String(c??"").replace(/^\s*=/,"");if(!u.trim())throw new X("the formula is empty");const n=$(u);let m=0;const t=()=>n[m],s=()=>n[m++],h=v=>{const R=t();if(R.kind!==I||R.value!==v)throw new X(`expected ${JSON.stringify(v)}`,R.at);m++},d=v=>{let R=o();for(;;){const Y=t();if(Y.kind!==I)break;const K=g[Y.value];if(!K||K<v)break;m++;const V=d(Y.value==="^"?K:K+1);R={kind:"bin",op:Y.value,left:R,right:V}}return R},o=()=>{const v=t();return v.kind===I&&(v.value==="-"||v.value==="+")?(m++,{kind:"unary",op:v.value,arg:o()}):b()},b=()=>{let v=l();for(;t().kind===I&&t().value==="%";)m++,v={kind:"unary",op:"%",arg:v};return v},l=()=>{const v=s();if(v.kind===re)return{kind:"num",value:v.value};if(v.kind===T)return{kind:"str",value:v.value};if(v.kind===G)return{kind:"ref",name:v.value};if(v.kind===D){h("(");const R=[];if(!(t().kind===I&&t().value===")"))for(;;){if(R.push(d(1)),t().kind===I&&t().value===","){m++;continue}break}return h(")"),{kind:"call",name:String(v.value).toUpperCase(),args:R}}if(v.kind===I&&v.value==="("){const R=d(1);return h(")"),R}throw v.kind===Z?new X("the formula ends unexpectedly",v.at):new X(`unexpected ${JSON.stringify(v.value)}`,v.at)},p=d(1),w=t();if(w.kind!==Z)throw new X(`unexpected ${JSON.stringify(w.value)}: is an operator missing?`,w.at);return p}function r(c){const u=new Set,n=m=>{if(!(!m||typeof m!="object")){if(m.kind==="ref"){u.add(String(m.name));return}if(m.kind==="bin"){n(m.left),n(m.right);return}if(m.kind==="unary"){n(m.arg);return}if(m.kind==="call")for(const t of m.args)n(t)}};return n(c),[...u]}function i(c){return typeof c=="string"&&/^\s*=/.test(c)&&c.trim()!=="="}}),Ue("packages/core/src/formula/evaluate.js",function(e,B){"use strict";Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return k}});const T=B("packages/core/src/formula/parse.js").FormulaError;function G(y){if(y==null||y==="")return 0;if(typeof y=="boolean")return y?1:0;if(y instanceof Date)return y.getTime();const f=typeof y=="number"?y:Number(String(y).replace(/[,\s]/g,""));if(!Number.isFinite(f))throw new T(`${JSON.stringify(y)} is not a number`);return f}function D(y){return y==null?"":String(y)}function I(y){if(typeof y=="boolean")return y;if(y==null||y==="")return!1;if(typeof y=="number")return y!==0;const f=String(y).trim().toLowerCase();return f==="false"||f==="no"||f==="0"?!1:f!==""}function Z(y){const f=[];for(const g of y){if(Array.isArray(g)){for(const a of g)a!=null&&a!==""&&f.push(G(a));continue}g==null||g===""||f.push(G(g))}return f}function z(y,f){const g=10**f,a=y*g;return Math.sign(a)*Math.round(Math.abs(a)+Number.EPSILON*Math.abs(a))/g}function L(y,f){if(!y.length)return 0;const g=y.slice().sort((c,u)=>c-u),a=(g.length-1)*Math.min(1,Math.max(0,f)),r=Math.floor(a),i=Math.ceil(a);return r===i?g[r]:g[r]+(a-r)*(g[i]-g[r])}function X(y,f){let g=0,a=0,r=0;for(const c of y){g++;const u=c-a;a+=u/g,r+=u*(c-a)}const i=f?g-1:g;return i>0?Math.sqrt(r/i):0}const $={SUM:y=>Z(y).reduce((f,g)=>f+g,0),AVERAGE:y=>{const f=Z(y);return f.length?f.reduce((g,a)=>g+a,0)/f.length:0},MIN:y=>{const f=Z(y);return f.length?Math.min(...f):0},MAX:y=>{const f=Z(y);return f.length?Math.max(...f):0},COUNT:y=>Z(y).length,PRODUCT:y=>Z(y).reduce((f,g)=>f*g,1),ROUND:y=>z(G(y[0]),y.length>1?G(y[1]):0),ROUNDDOWN:y=>{const f=10**(y.length>1?G(y[1]):0),g=G(y[0])*f;return(g<0?Math.ceil(g):Math.floor(g))/f},ROUNDUP:y=>{const f=10**(y.length>1?G(y[1]):0),g=G(y[0])*f;return(g<0?Math.floor(g):Math.ceil(g))/f},ABS:y=>Math.abs(G(y[0])),FLOOR:y=>Math.floor(G(y[0])),CEILING:y=>Math.ceil(G(y[0])),SQRT:y=>Math.sqrt(G(y[0])),POWER:y=>G(y[0])**G(y[1]),MOD:y=>{const f=G(y[1]);if(f===0)throw new T("MOD by zero");return(G(y[0])%f+f)%f},IF:y=>I(y[0])?y[1]:y.length>2?y[2]:!1,AND:y=>y.every(I),OR:y=>y.some(I),NOT:y=>!I(y[0]),COALESCE:y=>y.find(f=>f!=null&&f!=="")??null,CONCAT:y=>y.map(D).join(""),LEN:y=>D(y[0]).length,UPPER:y=>D(y[0]).toUpperCase(),LOWER:y=>D(y[0]).toLowerCase(),TRIM:y=>D(y[0]).trim(),LEFT:y=>D(y[0]).slice(0,y.length>1?G(y[1]):1),RIGHT:y=>{const f=y.length>1?G(y[1]):1;return f<=0?"":D(y[0]).slice(-f)},MEDIAN:y=>L(Z(y),.5),PERCENTILE:y=>{const f=G(y[y.length-1]);return L(Z(y.slice(0,-1)),f>1?f/100:f)},QUARTILE1:y=>L(Z(y),.25),QUARTILE3:y=>L(Z(y),.75),STDEV:y=>X(Z(y),!0),STDEVP:y=>X(Z(y),!1),VAR:y=>{const f=X(Z(y),!0);return f*f},VARP:y=>{const f=X(Z(y),!1);return f*f},COUNTDISTINCT:y=>{const f=new Set;for(const g of y){const a=Array.isArray(g)?g:[g];for(const r of a)r!=null&&r!==""&&f.add(r)}return f.size},IQR:y=>{const f=Z(y);return L(f,.75)-L(f,.25)}};$.AVG=$.AVERAGE,$.CEIL=$.CEILING,$.POW=$.POWER,$.STDEVS=$.STDEV,$.PERCENTILEINC=$.PERCENTILE;function A(y,f){const g=Number(y),a=Number(f);if(y!==null&&y!==""&&f!==null&&f!==""&&Number.isFinite(g)&&Number.isFinite(a))return g<a?-1:g>a?1:0;const i=D(y).toLowerCase(),c=D(f).toLowerCase();return i<c?-1:i>c?1:0}function k(y,f={}){const g=typeof f.lookup=="function"?f.lookup:null,a=f.functions?{...$,...f.functions}:$,r=i=>{switch(i.kind){case"num":return i.value;case"str":return i.value;case"ref":{if(!g)throw new T(`there is no column called ${JSON.stringify(i.name)} here`);const c=g(String(i.name));if(c===void 0)throw new T(`there is no column called ${JSON.stringify(i.name)}`);return c}case"unary":{if(i.op==="%")return G(r(i.arg))/100;const c=G(r(i.arg));return i.op==="-"?-c:c}case"bin":{const c=i.op;if(c==="=")return A(r(i.left),r(i.right))===0;if(c==="<>")return A(r(i.left),r(i.right))!==0;if(c==="<")return A(r(i.left),r(i.right))<0;if(c==="<=")return A(r(i.left),r(i.right))<=0;if(c===">")return A(r(i.left),r(i.right))>0;if(c===">=")return A(r(i.left),r(i.right))>=0;const u=G(r(i.left)),n=G(r(i.right));if(c==="+")return u+n;if(c==="-")return u-n;if(c==="*")return u*n;if(c==="^")return u**n;if(c==="/"){if(n===0)throw new T("division by zero");return u/n}throw new T(`unknown operator ${JSON.stringify(c)}`)}case"call":{const c=f.lazy&&f.lazy[i.name];if(typeof c=="function")return c(i.args,r,f);const u=a[i.name];if(typeof u!="function")throw new T(`there is no function called ${i.name}`);return u(i.args.map(r),f)}default:throw new T("the formula could not be read")}};return r(y)}}),Ue("packages/core/src/formula/index.js",function(e,B){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"rowLookup",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return A}});const re=B("packages/core/src/formula/parse.js"),T=re.parseFormula,G=re.referencesOf,D=re.looksLikeFormula,I=re.FormulaError,Z=re.tokenise,z=B("packages/core/src/formula/evaluate.js"),L=z.evaluateAst,X=z.FUNCTIONS;function $(k){const{grid:y,row:f,data:g}=k||{},a=n=>String(n).toLowerCase().replace(/[\s_-]/g,""),r=y&&y.columns&&typeof y.columns.all=="function"?y.columns.all():[],i=y&&y.permissions,c=i&&typeof i.isReadable=="function"?n=>i.isReadable(n):()=>!0,u=new Set;for(const n of r)c(n)||(u.add(a(n.id)),n.field&&u.add(a(n.field)),n.title&&u.add(a(n.title)));return n=>{const m=a(n);if(u.has(m))throw new I(`"${n}" cannot be read`);for(const t of r)if(a(t.id)===m||t.field&&a(t.field)===m||t.title&&a(t.title)===m)return f&&y.rows&&typeof y.rows.value=="function"?y.rows.value(f.key,t.id):g?g[t.field||t.id]:void 0;if(g&&typeof g=="object"){for(const t of Object.keys(g))if(a(t)===m){if(!c(t))throw new I(`"${n}" cannot be read`);return g[t]}}}}function A(k,y={}){try{const f=T(k);return{ok:!0,value:L(f,{lookup:$(y),functions:y.formulaFunctions}),references:G(f)}}catch(f){return{ok:!1,error:f instanceof I?f.message:"the formula could not be read",at:f instanceof I?f.at:void 0}}}}),Ue("packages/core/src/internal/version.js",function(e,B){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return G}});const re="1.115.1";async function T(){return re}const G="1.115.1"}),Ue("packages/core/src/internal/merge.js",function(e,B){"use strict";Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return z}});const T=B("packages/core/src/internal/predicates.js").isObject;function G(L,X,$){if(L!==void 0)return L===!0?{enabled:!0,...$}:L===!1?{enabled:!1}:T(L)?L:{[X]:L,enabled:!0}}function D(L){return L==null?[]:Array.isArray(L)?L:[L]}const I=Object.freeze(new Set(["__proto__","constructor","prototype"]));function Z(L,X){if(!T(L))return T(X)?{...X}:X;if(!T(X))return X===void 0?L:X;const $={...L};for(const A of Object.keys(X)){if(I.has(A))continue;const k=X[A];k!==void 0&&($[A]=T(k)&&T($[A])?Z($[A],k):k)}return $}function z(L,X){if(!T(L)||!T(X)||L===X)return X;const $=Object.create(Object.getPrototypeOf(L));return Object.assign($,L,X),$}}),Ue("packages/core/src/internal/schedule.js",function(e,B){"use strict";Object.defineProperty(e,"now",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return z}});function re(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const T=typeof requestAnimationFrame=="function";function G(L){return T?requestAnimationFrame(L):setTimeout(()=>L(re()),16)}function D(L){L!=null&&(T?cancelAnimationFrame(L):clearTimeout(L))}function I(L){let X=null,$=null;const A=()=>{X=null;const y=$;$=null,L(...y||[])},k=(...y)=>{$=y,X===null&&(X=G(A))};return k.cancel=()=>{D(X),X=null,$=null},k.flush=()=>{X!==null&&(D(X),A())},k}function Z(L,X){let $=null,A=null;const k=()=>{if($=null,A===null)return;const g=A;A=null,L(...g),y()},y=()=>{$=setTimeout(k,X),typeof $?.unref=="function"&&$.unref()},f=(...g)=>{$===null?(L(...g),y()):(A=g,clearTimeout($),y())};return f.flush=()=>{if($!==null&&clearTimeout($),$=null,A===null)return;const g=A;A=null,L(...g)},f.cancel=()=>{$!==null&&clearTimeout($),$=null,A=null},f.pending=()=>$!==null||A!==null,f}function z(L,X=50){return typeof requestIdleCallback=="function"?requestIdleCallback(L,{timeout:X}):setTimeout(()=>L({timeRemaining:()=>0,didTimeout:!0}),1)}}),Ue("packages/core/src/internal/paths.js",function(e,B){"use strict";Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return Z}});const re=new Map;function T(z){let L=re.get(z);if(L)return L;if(!z.includes("."))L=X=>X?.[z];else{const X=z.split("."),$=X.length;L=A=>{let k=A;for(let y=0;y<$;y++){if(k==null)return;k=k[X[y]]}return k}}return re.set(z,L),L}const G=new Map;function D(z){let L=G.get(z);if(L)return L;if(!z.includes("."))L=(X,$)=>{X!=null&&(X[z]=$)};else{const X=z.split("."),$=X.length-1;L=(A,k)=>{let y=A;for(let f=0;f<$;f++){if(y==null)return;const g=X[f];y[g]==null&&(y[g]={}),y=y[g]}y!=null&&(y[X[$]]=k)}}return G.set(z,L),L}function I(z,L){return T(L)(z)}function Z(z,L,X){D(L)(z,X)}}),Ue("packages/core/src/internal/compare.js",function(e,B){"use strict";Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return G}});const re=new Map;function T(D,I){const Z=`${D||""}|${I?JSON.stringify(I):""}`;let z=re.get(Z);return z||(z=new Intl.Collator(D||void 0,{numeric:!0,sensitivity:"variant",...I}),re.set(Z,z)),z}function G(D,I){if(D===I)return 0;if(D==null)return 1;if(I==null)return-1;if(typeof D=="number"&&typeof I=="number")return Number.isNaN(D)?Number.isNaN(I)?0:1:Number.isNaN(I)||D<I?-1:D>I?1:0;const Z=String(D),z=String(I);return Z<z?-1:Z>z?1:0}}),Ue("packages/core/src/defaults.js",function(e,B){"use strict";Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"applyDefaults",{enumerable:!0,get:function(){return A}});const T=B("packages/core/src/internal/predicates.js").isObject,D=B("packages/core/src/internal/merge.js").merge,Z=B("packages/core/src/internal/warn.js").warnOnce;let z=null;class L extends Error{}function X(k,y=new Set){if(Array.isArray(k)){if(y.has(k))throw new L;y.add(k);const g=k.map(a=>X(a,y));return y.delete(k),g}if(!T(k)||Object.getPrototypeOf(k)!==Object.prototype&&Object.getPrototypeOf(k)!==null)return k;if(y.has(k))throw new L;y.add(k);const f={};for(const[g,a]of Object.entries(k))f[g]=X(a,y);return y.delete(k),f}function $(k){if(k===void 0)return X(z??{});if(k===null)return z=null,{};if(!T(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(z??{});try{z=X(k)}catch(y){if(!(y instanceof L))throw y;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(z??{})}return X(z)}function A(k){return z===null?k:D(X(z),k)}}),Ue("packages/core/src/internal/uid.js",function(e,B){"use strict";Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return T}});let re=0;function T(G="l"){return`${G}${(++re).toString(36)}`}}),Ue("packages/core/src/events/names.js",function(e,B){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"isKnownEvent",{enumerable:!0,get:function(){return G}});const re=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"]),T=new Set(re);function G(D){return D==="*"||T.has(D)}}),Ue("packages/core/src/events/bus.js",function(e,B){"use strict";Object.defineProperty(e,"WILDCARD",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return g}});const re=B("packages/core/src/internal/warn.js"),T=re.warnOnce,G=re.DEV,I=B("packages/core/src/internal/uid.js").uid,z=B("packages/core/src/events/names.js").isKnownEvent,L="*";function X(a,r){!G||z(r)||T(`bus.unknown:${r}`,`${a}('${r}') subscribes to an event the grid never raises, so the handler will never fire. Check the name against the EventName list — a common cause is a near miss such as 'row:click' for 'row:clicked'.`)}const $=new Set(["api","user","init","ai"]),A=new WeakMap;function k(a){let r=A.get(a);return r||(r=I("h"),A.set(a,r)),r}function y(){return typeof performance=="object"&&performance?performance.now():Date.now()}function f(a){if(!a||typeof a!="object")return{};const r={};for(const[i,c]of Object.entries(a))i!=="grid"&&(c==null?r[i]=String(c):Array.isArray(c)?r[i]=`[${c.length}]`:typeof c=="object"?r[i]=c.key?`row ${c.key}`:"{…}":typeof c=="function"?r[i]="[function]":r[i]=String(c).slice(0,60));return r}class g{#e=new Map;#t=!1;#n=[];#r=200;#i=new Map;#s=null;#a=!1;#l=0;constructor(r=null){this.#s=r}attach(r){this.#s=r}get grid(){return this.#s}get destroyed(){return this.#a}on(r,i){if(typeof i!="function")return T(`bus.handler:${r}`,`on('${r}') needs a function; ignored.`),()=>{};X("on",r);let c=this.#e.get(r);return c||(c=[],this.#e.set(r,c)),c.push(i),()=>this.off(r,i)}once(r,i){if(typeof i!="function")return T(`bus.handler:${r}`,`once('${r}') needs a function; ignored.`),()=>{};X("once",r);const c=u=>{this.off(r,i),i(u)};return this.#i.set(i,c),this.on(r,c)}off(r,i){if(i===void 0){this.#e.delete(r);return}const c=this.#e.get(r);if(!c)return;const u=this.#i.get(i),n=u&&c.includes(u)?u:i,m=c.indexOf(n);m>=0&&c.splice(m,1),u&&n===u&&this.#i.delete(i),c.length===0&&this.#e.delete(r)}count(r){const i=this.#e.get(r),c=r===L?null:this.#e.get(L);return(i?i.length:0)+(c?c.length:0)}#o(r,i,c,u,n){this.#n.push({type:r,origin:i,listeners:(u?u.length:0)+(n?n.length:0),payload:f(c),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(r,i){this.#t=!!r,Number.isFinite(i)&&i>0&&(this.#r=Math.floor(i)),r||(this.#n=[])}eventLog(){return this.#n.map(r=>({...r}))}clearEventLog(){this.#n=[]}counts(){const r={};for(const[i,c]of this.#e)r[i]=c.length;return r}emit(r,i,c){const u=c??(i&&i.origin),n=$.has(u)?u:"api",m={...i||null,type:r,origin:n,grid:this.#s};if(this.#a)return m;const t=this.#e.get(r),s=r===L?void 0:this.#e.get(L);if(this.#t&&this.#o(r,n,i,t,s),!t&&!s)return m;const h=this.#t?y():0;this.#l++;try{t&&this.#c(t.slice(),m,r),s&&this.#c(s.slice(),m,L)}finally{this.#l--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=y()-h)}return m}emitBefore(r,i,c){const u=c??(i&&i.origin),n=$.has(u)?u:"user";let m=!1,t=null;const s=p=>{m=!0,p!=null&&t===null&&(t=String(p))},h={...i||null,type:r,origin:n,grid:this.#s,get defaultPrevented(){return m},get reason(){return t},preventDefault(p){s(p)}};if(this.#a)return!0;const d=this.#e.get(r);this.#t&&this.#o(r,n,i,d,void 0);const o=d?d.slice():[];if(o.length===0)return!0;const b=()=>(m&&t===null&&(t="prevented"),m&&i&&typeof i=="object"&&(i.reason=t),!m),l=[];for(const p of o)try{const w=p(h);w&&typeof w.then=="function"?l.push(w):w===!1&&s("prevented")}catch(w){s("error"),T(`bus.beforeThrow:${r}:${k(p)}`,`a '${r}' before-handler threw; the action was cancelled.`,w)}return l.length===0?b():Promise.allSettled(l).then(p=>{for(const w of p)w.status==="rejected"?(s("error"),T(`bus.beforeReject:${r}`,`a '${r}' before-handler rejected; the action was cancelled.`,w.reason)):w.value===!1&&s("prevented");return b()})}#c(r,i,c){for(let u=0;u<r.length;u++)try{r[u](i)}catch(n){T(`bus.throw:${c}:${k(r[u])}`,`a '${c}' handler threw; other handlers were unaffected.`,n)}}clear(){this.#e.clear(),this.#i.clear()}destroy(){this.clear(),this.#a=!0,this.#s=null}}}),Ue("packages/core/src/registry/free-tier-notice.js",function(e,B){"use strict";Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"WATERMARK_TEXT",{enumerable:!0,get:function(){return T}});const re="Free for non-commercial use: latticegrid.dev/free",T="Unlicensed: Lattice Grid trial"}),Ue("packages/core/src/registry/licence.js",function(e,B){"use strict";Object.defineProperty(e,"PRODUCT",{enumerable:!0,get:function(){return I}}),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 y}}),Object.defineProperty(e,"asciiBytes",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hasEd25519",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"currentHost",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return O}});const T=B("packages/core/src/internal/warn.js").warnOnce,G=B("packages/core/src/registry/free-tier-notice.js"),D=G.FREE_TIER_NOTICE;Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return G.FREE_TIER_NOTICE}});const I="lattice-grid",Z=1,z="LG1",L=64,X="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",$="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",A=(()=>{const C=new Int16Array(128).fill(-1);for(let S=0;S<$.length;S++)C[$.charCodeAt(S)]=S;return C[43]=62,C[47]=63,C})();function k(C){if(typeof C!="string")return null;let S="";for(let _=0;_<C.length;_++){const W=C.charCodeAt(_);if(W!==61){if(W>127||A[W]<0)return null;S+=C[_]}}const F=S.length;if(F%4===1)return null;const P=new Uint8Array(Math.floor(F*3/4));let M=0,x=0,U=0;for(let _=0;_<F;_++)M=M<<6|A[S.charCodeAt(_)],x+=6,x>=8&&(x-=8,P[U++]=M>>x&255);return U===P.length?P:P.subarray(0,U)}function y(C){let S="",F=0;for(;F+2<C.length;F+=3){const M=C[F]<<16|C[F+1]<<8|C[F+2];S+=$[M>>18&63]+$[M>>12&63]+$[M>>6&63]+$[M&63]}const P=C.length-F;if(P===1){const M=C[F]<<16;S+=$[M>>18&63]+$[M>>12&63]}else if(P===2){const M=C[F]<<16|C[F+1]<<8;S+=$[M>>18&63]+$[M>>12&63]+$[M>>6&63]}return S}function f(C){const S=new Uint8Array(C.length);for(let F=0;F<C.length;F++)S[F]=C.charCodeAt(F)&127;return S}function g(C){if(typeof TextDecoder=="function")return new TextDecoder().decode(C);let S="";for(let F=0;F<C.length;F++)S+=String.fromCharCode(C[F]);return S}function a(C){const S={ok:!1,reason:"malformed",product:null,issuedTo:null,expires:null,terms:null,features:[],deployments:[],version:0,message:null,signature:null,raw:typeof C=="string"?C:""};if(typeof C!="string"||C.length===0)return{...S,reason:"missing"};const F=C.trim(),P=F.split(".");if(P.length!==3)return S;const[M,x,U]=P;if(M!==z)return{...S,reason:"prefix"};const _=k(x),W=k(U);if(!_||!W)return S;let q;try{q=JSON.parse(g(_))}catch{return S}return q===null||typeof q!="object"?S:{ok:!0,reason:null,product:typeof q.p=="string"?q.p:null,issuedTo:typeof q.t=="string"?q.t:null,expires:typeof q.e=="string"?q.e:null,terms:typeof q.terms=="string"?q.terms:null,features:Array.isArray(q.f)?q.f.slice():[],deployments:Array.isArray(q.d)?q.d.slice():[],version:typeof q.v=="number"?q.v:0,message:f(x),signature:W,raw:F}}function r(C,S){if(!C)return!1;const F=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(C)?`${C}T23:59:59.999Z`:C);return Number.isNaN(F)?!0:S>F}function i(C){return C==="non-commercial"?"non-commercial":"commercial"}let c=null,u=null,n=null;function m(){const C=globalThis.crypto;return C&&C.subtle?C.subtle:null}async function t(C){if(c&&u===C)return c;const S=m();if(!S)return null;const F=k(C);if(!F)return null;try{const P=await S.importKey("raw",F,{name:"Ed25519"},!1,["verify"]);return c=P,u=C,P}catch{return null}}async function s(){return n!==null||(n=await t(X)!==null),n}async function h(C,S={}){const F=S.warn!==!1,P=S.product||I,M=S.publicKey||X,x=S.now??Date.now(),U=S.host??o(),_=d(U)?"":` ${D}`,W=a(C);if(!W.ok){const ee=W.reason==="missing"?"missing":"malformed";return F&&T(`licence.${ee}`,ee==="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.${_}`:`licence key could not be read. The grid will render with a watermark.${_}`),{valid:!1,reason:ee,terms:"commercial"}}const q={product:W.product||void 0,issuedTo:W.issuedTo||void 0,expires:W.expires||void 0,terms:i(W.terms)};if(W.product!==P)return F&&T("licence.product",`licence key is for '${W.product}', not '${P}'. The grid will render with a watermark.`),{valid:!1,...q,reason:"product"};if(r(W.expires,x))return F&&T("licence.expired",`licence expired on ${W.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...q,reason:"expired"};const N=W.deployments||[];if(N.length&&U&&!d(U)&&!b(U,N))return F&&T("licence.domain",`licence key is not valid for ${U}; it covers ${N.join(", ")}. The grid will render with a watermark.`),{valid:!1,...q,reason:"domain"};const Q=await t(M);if(!Q){const ee=!!W.signature&&W.signature.length===L;return F&&T("licence.algorithm","this host does not provide crypto.subtle Ed25519, so the licence signature could not be verified. A structural check was used instead."),ee?{valid:!0,...q,reason:"unverified"}:{valid:!1,...q,reason:"signature"}}let J=!1;try{J=await m().verify({name:"Ed25519"},Q,W.signature,W.message)}catch{J=!1}return J?{valid:!0,...q}:(F&&T("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...q,reason:"signature"})}function d(C){const S=String(C??o()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!S||S==="localhost"||S.endsWith(".localhost")||S==="::1"||S==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(S)}function o(){const C=globalThis.location;return C&&typeof C.hostname=="string"?C.hostname:null}function b(C,S){const F=l(C);return!F||!Array.isArray(S)?!1:S.some(P=>{const M=l(P);if(!M)return!1;if(M==="*")return!0;if(M.startsWith("*.")){const x=M.slice(2);return F===x||F.endsWith(`.${x}`)}return F===M})}function l(C){return String(C??"").trim().toLowerCase().replace(/\.$/,"")}class p{#e="";#t={valid:!1,reason:"missing",terms:"commercial"};#n=null;#r=null;#i;#s=new Set;constructor(S={}){this.#i=S}set(S){this.#e=typeof S=="string"?S.trim():"";const F=a(this.#e);return this.#t=F.ok?{valid:!r(F.expires,Date.now())&&F.product===(this.#i.product||I),product:F.product||void 0,issuedTo:F.issuedTo||void 0,expires:F.expires||void 0,terms:i(F.terms),reason:"pending"}:{valid:!1,reason:F.reason||"malformed",terms:"commercial"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const S=this.#e;return this.#n=h(S,this.#i).then(F=>{if(this.#e===S){this.#t=F;for(const P of this.#s)P(F)}return F}),this.#n}onSettled(S){return this.#s.add(S),()=>this.#s.delete(S)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!d(this.#r)}setHost(S){this.#r=S}state(){return this.#t.valid?"licensed":d(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing",terms:"commercial"},this.#n=null,this.#s.clear()}}const w=Symbol.for("lattice-grid/licence/holder");function v(){const C=globalThis,S=C&&C[w];if(S&&typeof S.set=="function"&&typeof S.watermark=="function")return S;const F=new p;if(C)try{C[w]=F}catch{}return F}const R=v();function Y(C){return R.set(C)}function K(){return R.info()}function V(){return R.watermark()}function E(){return R.state()}function O(){return R}}),Ue("packages/core/src/registry/registry.js",function(e,B){"use strict";Object.defineProperty(e,"KINDS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"REGIONS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return c}});const re=B("packages/core/src/internal/warn.js"),T=re.warnOnce,G=re.DEV,I=B("packages/core/src/internal/predicates.js").isFunction,Z=B("packages/core/src/registry/licence.js"),z=Z.LicenceHolder,L=Z.sharedLicence,X=["renderer","editor","filter","dataType","totalFn","pipe","component"],$=["all","header","body","totals","panels"];class A{#e=new Map;#t=new Map;#n=new Set;#r=new Set;#i;#s=null;#a=null;#l=new Set;#o=new Map;constructor(n={}){for(const m of X)this.#t.set(m,new Map);this.#i=n.holder||L(),this.#a=n.grid??null,this.#s=this.#i.onSettled(()=>{this.#f({reason:"licence",name:"licence",capabilities:this.capabilities(),regions:["all"]})}),n.licence&&this.setLicence(n.licence)}registerModules(n,m={}){m.licence&&this.setLicence(m.licence),m.grid!==void 0&&(this.#a=m.grid);const t=Array.isArray(n)?n:[n],s=[];for(const h of t){if(!h||typeof h!="object"||typeof h.name!="string"||!h.name){T("registry.module.shape","registerModules received something that is not a module; ignored.");continue}if(this.#e.has(h.name)){G&&this.#u(this.#e.get(h.name),h);continue}if(!I(h.install)){T(`registry.module.install:${h.name}`,`module '${h.name}' has no install() and was ignored.`);continue}const d={registry:this,grid:this.#a};try{h.install(d)}catch(o){T(`registry.module.throw:${h.name}`,`module '${h.name}' threw during install; it was not registered.`,o);continue}this.#e.set(h.name,h);for(const o of k(h))this.#n.add(o);s.push(h.name),this.#f({reason:"module",name:h.name,capabilities:this.capabilities(),regions:g(h)})}return s}unregisterModule(n){const m=this.#e.get(n);if(!m)return!1;if(I(m.uninstall))try{m.uninstall({registry:this,grid:this.#a})}catch(t){T(`registry.module.uninstall:${n}`,`module '${n}' threw during uninstall.`,t)}return this.#e.delete(n),this.#c(),this.#f({reason:"unmodule",name:n,capabilities:this.capabilities(),regions:g(m)}),!0}modules(){return[...this.#e.values()]}has(n){return this.#e.has(n)}#c(){this.#n.clear();for(const n of this.#e.values())for(const m of k(n))this.#n.add(m)}#u(n,m){!n||n===m||y(n,m)||T(`registry.module.reconfigure:${m.name}`,`module '${m.name}' was re-registered with different options; the first registration is kept and this call was ignored. Unregister it first if you mean to replace it.`)}capabilities(){return[...this.#n].sort()}can(n){return this.#n.has(n)}onChange(n){return I(n)?(this.#r.add(n),this.#o.set(n,this.#a),()=>{this.#r.delete(n),this.#o.delete(n)}):()=>{}}#f(n){for(const m of[...this.#r])try{m(n)}catch(t){T("registry.onChange.throw","a registry change handler threw.",t)}}register(n,m,t){const s=this.#t.get(n);if(!s){T(`registry.kind:${n}`,`unknown registry kind '${n}'; expected one of ${X.join(", ")}.`);return}if(!m||typeof m!="string"){T(`registry.name:${n}`,`register('${n}', ...) needs a name.`);return}s.has(m)&&s.get(m)!==t&&T(`registry.replace:${n}:${m}`,`'${m}' was already registered as a ${n} and has been replaced.`),s.set(m,t),this.#f({reason:"register",name:m,kind:n,capabilities:this.capabilities(),regions:a(n)})}registerAll(n,m){if(m)for(const t of Object.keys(m))this.register(n,t,m[t])}get(n,m){const t=this.#t.get(n);return t?t.get(m):void 0}names(n){const m=this.#t.get(n);return m?[...m.keys()]:[]}#d(n,m){const t=this.#t.get(n).get(m);return t!==void 0?t:this.#t.get("component").get(m)}renderer(n){return this.#d("renderer",n)}editor(n){return this.#d("editor",n)}filter(n){return this.#d("filter",n)}dataType(n){return this.get("dataType",n)}totalFn(n){return this.get("totalFn",n)}pipe(n){return this.get("pipe",n)}setLicence(n){return this.#i.set(n)}licence(){return this.#i.info()}licenceVerified(){return this.#i.verify()}watermark(){return this.#i.watermark()}attach(n){n!=null&&(this.#l.add(n),this.#a=n)}detach(n){if(n!=null){this.#l.delete(n);for(const[m,t]of[...this.#o])t===n&&(this.#r.delete(m),this.#o.delete(m));if(this.#a===n){const m=this.#l.size?[...this.#l][this.#l.size-1]:null;this.#a=m}this.#l.size===0&&this.#s&&(this.#s(),this.#s=null)}}destroy(n){if(n!=null){this.detach(n);return}for(const m of[...this.#e.keys()])this.unregisterModule(m);this.#r.clear(),this.#o.clear(),this.#l.clear(),this.#s&&this.#s(),this.#s=null,this.#a=null}}function k(u){const n=u.capabilities,m=Array.isArray(n)?n.filter(t=>typeof t=="string"):[];return[u.name,...m]}function y(u,n){return u.install!==n.install||u.uninstall!==n.uninstall||(u.version||"")!==(n.version||"")?!1:f(k(u),k(n))&&f(g(u),g(n))}function f(u,n){const m=new Set(u),t=new Set(n);if(m.size!==t.size)return!1;for(const s of m)if(!t.has(s))return!1;return!0}function g(u){const n=u.regions;return!Array.isArray(n)||n.length===0?["all"]:n.filter(m=>$.includes(m))}function a(u){switch(u){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const r=new A;function i(){return r}function c(u,n={}){return r.registerModules(u,n)}}),Ue("packages/core/src/internal/text.js",function(e,B){"use strict";Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return D}});function re(I){return I?(I.includes(".")?I.slice(I.lastIndexOf(".")+1):I).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(/^./,z=>z.toUpperCase()):""}const T={"&":"&","<":"<",">":">",'"':""","'":"'"};function G(I){const Z=I==null?"":String(I);return/[&<>"']/.test(Z)?Z.replace(/[&<>"']/g,z=>T[z]):Z}function D(I){return String(I).replace(/\w\S*/g,Z=>Z[0].toUpperCase()+Z.slice(1).toLowerCase())}}),Ue("packages/core/src/format/mask.js",function(e,B){"use strict";Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return Z}});const re=new Set(["0","#","?",",","."]),T="\0";function G(L){const X=[];let $="",A=!1;for(let k=0;k<L.length;k++){const y=L[k];if(y==="\\"){$+=y+(L[k+1]??""),k+=1;continue}if(y==='"'){A=!A,$+=y;continue}if(y===";"&&!A){X.push($),$="";continue}$+=y}return X.push($),X}function D(L){let X="",$="",A="",k=1,y=!1,f=!1;const g=s=>{f?$+=s:X+=s};for(let s=0;s<L.length;s++){const h=L[s];if(h==="\\"){g(L[s+1]??""),s+=1;continue}if(h==='"'){const d=L.indexOf('"',s+1);g(d===-1?L.slice(s+1):L.slice(s+1,d)),s=d===-1?L.length:d;continue}if(h==="%"){k*=100,g("%");continue}if(h==="@"){y=!0,g("\0");continue}if(re.has(h)){A+=h,f=!0;continue}g(h)}let a=-1;for(let s=A.length-1;s>=0;s--){const h=A[s];if(h==="0"||h==="#"||h==="?"){a=s;break}}let r=!1,i="";for(let s=0;s<A.length;s++){const h=A[s];if(h===","){s>a?k/=1e3:r=!0;continue}i+=h}const c=i.indexOf("."),u=c===-1?i:i.slice(0,c),n=c===-1?"":i.slice(c+1);let m=0;for(const s of u)s==="0"&&(m+=1);let t=0;for(const s of n)s==="0"&&(t+=1);return{prefix:X,suffix:$,minInt:m,minDec:t,maxDec:n.length,grouping:r,scale:k,hasNumber:a!==-1,isText:y}}function I(L,X){const $=new Intl.NumberFormat(X,{minimumIntegerDigits:Math.max(L.minInt,1),minimumFractionDigits:L.minDec,maximumFractionDigits:Math.max(L.maxDec,L.minDec),useGrouping:L.grouping}),{prefix:A,suffix:k,scale:y,hasNumber:f}=L;return g=>{if(!f)return A+k;const a=y===1?g:g*y;return A+$.format(a)+k}}function Z(L,X){const A=G(String(L)).map(D),k=A.map(i=>I(i,X)),y=0,f=A.length>1?1:-1,g=A.length>2?2:-1,a=A.length>3?3:-1,r=i=>{if(i==null||i==="")return"";if(typeof i!="number"||Number.isNaN(i)){const c=Number(i);if(Number.isNaN(c))return a===-1?String(i):(A[a].prefix+A[a].suffix).split("\0").join(String(i));i=c}return i===0&&g!==-1?k[g](0):i<0&&f!==-1?k[f](-i):k[y](i)};return r.spec={mask:L},{format:r,ooxml:z(String(L))}}function z(L){return L.trim()}}),Ue("packages/core/src/format/pattern.js",function(e,B){"use strict";Object.defineProperty(e,"parseNumberPattern",{enumerable:!0,get:function(){return I}});const T=B("packages/core/src/format/mask.js").splitSections;function G(Z){let z="",L="",X="",$="",A=!1,k=!1,y=!1,f=!1;const g=r=>{y?L+=r:z+=r};for(let r=0;r<Z.length;r++){const i=Z[r];if(i==="\\"){g(Z[r+1]??""),r+=1;continue}if(i==='"'){const c=Z.indexOf('"',r+1);g(c===-1?Z.slice(r+1):Z.slice(r+1,c)),r=c===-1?Z.length:c;continue}if(i==="%"){k=!0;continue}if(i==="0"||i==="#"){y=!0,f?$+=i:X+=i;continue}if(i===","){f||(A=!0);continue}if(i==="."&&!f){f=!0;continue}g(i)}if(!y)return{hasDigit:!1,prefix:z,suffix:L,minDec:0,maxDec:0,grouping:!1,percent:k};let a=0;for(const r of $)r==="0"&&(a+=1);return{hasDigit:!0,prefix:z,suffix:L,minDec:a,maxDec:$.length,grouping:A,percent:k}}function D(Z,z){const L=z.trim(),X=Z.trim();return L.startsWith("(")&&L.endsWith(")")&&L.slice(1,-1).trim()===X?"parentheses":L.endsWith("-")?"suffix":"minus"}function I(Z){if(typeof Z!="string")return null;const z=T(Z);if(z.length===0)return null;const L=G(z[0]);if(!L.hasDigit)return null;const X={style:L.percent?"percent":"decimal",prefix:L.prefix,suffix:L.suffix,minDecimals:L.minDec,maxDecimals:Math.max(L.maxDec,L.minDec),thousandsSeparator:L.grouping?void 0:!1};if(z.length>1&&(X.negative=D(z[0],z[1])),z.length>2){const $=G(z[2]);$.hasDigit||(X.zeroDisplay=$.prefix+$.suffix)}return X}}),Ue("packages/core/src/format/number.js",function(e,B){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return z}});const T=B("packages/core/src/internal/predicates.js").isNil,D=B("packages/core/src/internal/warn.js").warnOnce,Z=B("packages/core/src/format/pattern.js").parseNumberPattern;function z(L,X){const $=typeof L=="string"?{pattern:L}:L||{};let A=$;if(typeof $.pattern=="string"){const v=Z($.pattern);if(v){const{pattern:R,...Y}=$;A={...v,...Y}}else D(`format:pattern:${$.pattern}`,`invalid number format pattern "${$.pattern}"; the value will use the default number format`)}const k=A.locale||X||void 0,y=A.style||"decimal",f=typeof A.scale=="number"?A.scale:1,g=A.nullDisplay??"",a=A.zeroDisplay,r=A.prefix||"",i=A.suffix||"",c=A.negative||"minus",u=A.signed===!0,n={style:y,notation:A.notation||"standard"};y==="currency"&&(n.currency=A.currency||"USD",A.currencyDisplay&&(n.currencyDisplay=A.currencyDisplay)),typeof A.decimals=="number"?(n.minimumFractionDigits=A.decimals,n.maximumFractionDigits=A.decimals):(typeof A.minDecimals=="number"&&(n.minimumFractionDigits=A.minDecimals),typeof A.maxDecimals=="number"&&(n.maximumFractionDigits=A.maxDecimals),n.minimumFractionDigits>(n.maximumFractionDigits??20)&&(n.maximumFractionDigits=n.minimumFractionDigits)),A.thousandsSeparator===!1&&(n.useGrouping=!1),n.notation==="compact"&&(n.compactDisplay=A.compactDisplay||"short");const m=new Intl.NumberFormat(k,n),t=typeof A.thousandsSeparator=="string"?A.thousandsSeparator:null,s=typeof A.decimalSeparator=="string"?A.decimalSeparator:null;let h=",",d=".";if(t||s)for(const v of m.formatToParts(12345.6))v.type==="group"?h=v.value:v.type==="decimal"&&(d=v.value);const o=v=>{let R=v;return t&&(R=R.split(h).join("")),s&&(R=R.split(d).join("")),t&&(R=R.split("").join(t)),s&&(R=R.split("").join(s)),R},b=!!(t||s),l=r!==""&&y==="currency",p=v=>{let R;if(l){const Y=m.formatToParts(v);let K=!1;R="";for(const V of Y)R+=V.value,!K&&V.type==="currency"&&(R+=r,K=!0);K||(R=r+R)}else R=r+m.format(v);return b&&(R=o(R)),R+i},w=v=>{if(T(v)||v==="")return g;const R=typeof v=="number"?v:Number(v);if(Number.isNaN(R))return g;const Y=f===1?R:R*f;return Y===0&&a!==void 0?a:Y<0?c==="parentheses"?`(${p(-Y)})`:c==="suffix"?`${p(-Y)}-`:p(Y):u&&Y>0?`+${p(Y)}`:p(Y)};return w.negativeClass=A.negativeClass||null,w.spec=A,w}}),Ue("packages/core/src/format/date.js",function(e,B){"use strict";Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"toIsoDate",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"toIsoDateTime",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"compareIso",{enumerable:!0,get:function(){return i}});const T=B("packages/core/src/internal/predicates.js").isNil,D=B("packages/core/src/internal/warn.js").warnOnce,I=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function Z(c){const u=[];let n=0,m="";const t=()=>{m&&(u.push({token:null,text:m}),m="")};for(;n<c.length;){const s=c[n];if(s==="'"){if(c[n+1]==="'"){m+="'",n+=2;continue}const d=c.indexOf("'",n+1);if(d===-1){m+=c.slice(n+1),n=c.length;continue}m+=c.slice(n+1,d),n=d+1;continue}const h=I.find(d=>c.startsWith(d,n));if(h){t(),u.push({token:h,text:h}),n+=h.length;continue}/[A-Za-z]/.test(s)&&D(`date.pattern.token:${s}`,`the date pattern "${c}" contains '${s}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${I.join(" ")}.`),m+=s,n+=1}return t(),u}const z=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function L(c){if(T(c)||c==="")return null;if(c instanceof Date)return Number.isNaN(c.getTime())?null:c;if(typeof c=="number")return Number.isNaN(c)?null:new Date(c);if(typeof c=="string"){const u=z.exec(c.trim());if(u){const[,m,t,s,h="0",d="0",o="0"]=u;return new Date(+m,+t-1,+s,+h,+d,+o)}const n=new Date(c);return Number.isNaN(n.getTime())?null:n}return null}function X(c,u){return String(c).padStart(u,"0")}function $(c){if(!c)return m=>({year:m.getFullYear(),month:m.getMonth()+1,day:m.getDate(),hour:m.getHours(),minute:m.getMinutes(),second:m.getSeconds(),ms:m.getMilliseconds(),weekday:m.getDay()});const u=new Intl.DateTimeFormat("en-US",{timeZone:c,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),n={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return m=>{const t={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:m.getMilliseconds(),weekday:0};for(const s of u.formatToParts(m))switch(s.type){case"year":t.year=Number(s.value);break;case"month":t.month=Number(s.value);break;case"day":t.day=Number(s.value);break;case"hour":t.hour=Number(s.value)%24;break;case"minute":t.minute=Number(s.value);break;case"second":t.second=Number(s.value);break;case"weekday":t.weekday=n[s.value]??0;break;default:break}return t}}function A(c,u,n){const m=Z(c),t=$(n),s=new Set(m.filter(l=>l.token).map(l=>l.token)),h=s.has("MMM")?new Intl.DateTimeFormat(u,{month:"short",timeZone:n}):null,d=s.has("MMMM")?new Intl.DateTimeFormat(u,{month:"long",timeZone:n}):null,o=s.has("EEE")?new Intl.DateTimeFormat(u,{weekday:"short",timeZone:n}):null,b=s.has("EEEE")?new Intl.DateTimeFormat(u,{weekday:"long",timeZone:n}):null;return l=>{const p=t(l);let w="";for(const v of m){if(!v.token){w+=v.text;continue}switch(v.token){case"yyyy":w+=X(p.year,4);break;case"yy":w+=X(p.year%100,2);break;case"MMMM":w+=d.format(l);break;case"MMM":w+=h.format(l);break;case"MM":w+=X(p.month,2);break;case"M":w+=String(p.month);break;case"dd":w+=X(p.day,2);break;case"d":w+=String(p.day);break;case"EEEE":w+=b.format(l);break;case"EEE":w+=o.format(l);break;case"HH":w+=X(p.hour,2);break;case"H":w+=String(p.hour);break;case"hh":w+=X(p.hour%12===0?12:p.hour%12,2);break;case"h":w+=String(p.hour%12===0?12:p.hour%12);break;case"mm":w+=X(p.minute,2);break;case"m":w+=String(p.minute);break;case"ss":w+=X(p.second,2);break;case"s":w+=String(p.second);break;case"SSS":w+=X(p.ms,3);break;case"a":w+=p.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 y(c,u){const n=c||{},m=n.locale||u||void 0,t=n.nullDisplay??"",s=n.timeZone;let h;if(n.pattern)h=A(n.pattern,m,s);else if(n.dateStyle||n.timeStyle){const p={timeZone:s};n.dateStyle&&(p.dateStyle=n.dateStyle),n.timeStyle&&(p.timeStyle=n.timeStyle);const w=new Intl.DateTimeFormat(m,p);h=v=>w.format(v)}else{const p=new Intl.DateTimeFormat(m,{dateStyle:"medium",timeZone:s});h=w=>p.format(w)}const d=n.relative?new Intl.RelativeTimeFormat(m,{numeric:"auto"}):null,b=(typeof n.relative=="object"&&n.relative?n.relative.threshold??7:7)*24*36e5,l=(p,w)=>{const v=L(p);if(!v)return t;if(d){const R=w&&typeof w.now=="number"?w.now:Date.now(),Y=v.getTime()-R;if(Math.abs(Y)<b){for(const[K,V]of k)if(Math.abs(Y)>=V||K==="second")return d.format(Math.round(Y/V),K)}}return h(v)};return l.spec=n,l}function f(c){if(T(c)||c==="")return null;if(typeof c=="string"){const m=/^(\d{4}-\d{2}-\d{2})/.exec(c.trim());if(m)return m[1];const t=L(c);return t?f(t):null}const u=L(c);if(!u)return null;const n=m=>String(m).padStart(2,"0");return`${u.getFullYear()}-${n(u.getMonth()+1)}-${n(u.getDate())}`}function g(c,u){if(T(c)||c==="")return null;if(typeof c=="string"){const m=c.trim();if(a.test(m)){const h=L(m);return h?r(h,u):null}const t=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(m);if(t){const[,h,d,o,b]=t;return`${h}T${d}:${o}${b&&b!=="00"?`:${b}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(m))return`${m}T00:00`;const s=L(m);return s?g(s):null}const n=L(c);return n?r(n,u):null}const a=/(?:Z|[+-]\d{2}:?\d{2})$/i;function r(c,u){const n=h=>String(h).padStart(2,"0");if(u)try{const h=new Intl.DateTimeFormat("en-CA",{timeZone:u,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(c).reduce((b,l)=>(l.type!=="literal"&&(b[l.type]=l.value),b),{}),d=h.hour==="24"?"00":h.hour,o=Number(h.second);return`${h.year}-${h.month}-${h.day}T${d}:${h.minute}`+(o?`:${h.second}`:"")}catch{}const m=`${c.getFullYear()}-${n(c.getMonth()+1)}-${n(c.getDate())}`,t=c.getSeconds(),s=`${n(c.getHours())}:${n(c.getMinutes())}${t?`:${n(t)}`:""}`;return`${m}T${s}`}function i(c,u){const n=T(c)||c===""?null:String(c),m=T(u)||u===""?null:String(u);return n===null?m===null?0:1:m===null||n<m?-1:n>m?1:0}}),Ue("packages/core/src/format/boolean.js",function(e,B){"use strict";Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return Z}});const T=B("packages/core/src/internal/predicates.js").isNil,G={true:"☑",false:"☐",null:""},D={true:"◉",false:"◯",null:""};function I(z){if(T(z)||z==="")return null;if(typeof z=="boolean")return z;if(typeof z=="number")return z!==0;const L=String(z).trim().toLowerCase();return L==="true"||L==="yes"||L==="y"||L==="1"?!0:L==="false"||L==="no"||L==="n"||L==="0"?!1:null}function Z(z,L){const X=z||{},$=X.display||"text",A=X.trueLabel??"Yes",k=X.falseLabel??"No",y=X.nullLabel??"";let f=A,g=k;const a=y;$==="checkbox"?(f=G.true,g=G.false):$==="switch"?(f=D.true,g=D.false):$==="icon"&&(f=X.trueIcon??A,g=X.falseIcon??k);const r=i=>{const c=I(i);return c===null?a:c?f:g};return r.display=$,r.labels={true:A,false:k,null:y},r.locale=L,r.spec=X,r}}),Ue("packages/core/src/format/text.js",function(e,B){"use strict";Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return I}});const T=B("packages/core/src/internal/predicates.js").isNil,D=B("packages/core/src/internal/text.js").titleCase;function I(Z,z){const L=Z||{},X=L.locale||z||void 0,$=L.nullDisplay??"",A=L.emptyDisplay??"",k=L.transform||"none",y=typeof L.truncate=="number"?{chars:L.truncate}:L.truncate||null,f=y?y.chars:0,g=y?y.ellipsis??"…":"",a=i=>{switch(k){case"upper":return X?i.toLocaleUpperCase(X):i.toUpperCase();case"lower":return X?i.toLocaleLowerCase(X):i.toLowerCase();case"title":return D(i);default:return i}},r=i=>{if(T(i))return $;let c=typeof i=="string"?i:String(i);return c===""?A:(k!=="none"&&(c=a(c)),f>0&&c.length>f&&(c=c.slice(0,f)+g),c)};return r.spec=L,r}}),Ue("packages/core/src/format/shorthand.js",function(e,B){"use strict";Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return z}});const re=["currency","number","percent","date","boolean","text","relative"],T=/[#0?@;"\\]/,G=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function D(L){return typeof L!="string"||L===""||Z(L)?!1:T.test(L)}function I(L){return typeof L!="string"||L===""||Z(L)?!1:G.test(L)}function Z(L){const X=L.indexOf(":"),$=X===-1?L:L.slice(0,X);return re.includes($)?$:null}function z(L){const X=Z(L);if(!X)return null;const $=L.indexOf(":"),A=$===-1?"":L.slice($+1),k=A===""?[]:A.split(":");switch(X){case"currency":{const y={type:"number",style:"currency",currency:k[0]||"USD"};return k[1]!==void 0&&k[1]!==""&&(y.decimals=Number(k[1])),y}case"number":{const y={type:"number",style:"decimal"};return k[0]!==void 0&&k[0]!==""&&(y.decimals=Number(k[0])),y}case"percent":{const y={type:"number",style:"percent"};return k[0]!==void 0&&k[0]!==""&&(y.decimals=Number(k[0])),y}case"date":return{type:"date",pattern:A||void 0};case"relative":return{type:"date",relative:!0};case"boolean":{const y=A.split("/"),f={type:"boolean",display:"text"};return y[0]!==void 0&&y[0]!==""&&(f.trueLabel=y[0]),y[1]!==void 0&&y[1]!==""&&(f.falseLabel=y[1]),y[2]!==void 0&&(f.nullLabel=y[2]),f}case"text":{const y={type:"text"};return k[0]&&(y.transform=k[0]),k[1]!==void 0&&k[1]!==""&&(y.truncate=Number(k[1])),y}default:return null}}}),Ue("packages/core/src/format/index.js",function(e,B){"use strict";Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return R}});const re=B("packages/core/src/internal/predicates.js"),T=re.isFunction,G=re.isObject,I=B("packages/core/src/internal/warn.js").warnOnce,Z=B("packages/core/src/format/number.js"),z=Z.compileNumber,L=B("packages/core/src/format/date.js"),X=L.compileDate,$=L.scanPattern,A=B("packages/core/src/format/boolean.js"),k=A.compileBoolean,y=B("packages/core/src/format/text.js"),f=y.compileText,g=B("packages/core/src/format/mask.js"),a=g.compileMask,r=B("packages/core/src/format/shorthand.js"),i=r.parseShorthand,c=r.looksLikeMask,u=r.looksLikeDatePattern,m=B("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 L.compileDate}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return L.compilePattern}}),Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return L.scanPattern}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return L.toDate}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return A.compileBoolean}}),Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return A.toTriState}}),Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return y.compileText}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return g.compileMask}}),Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return g.splitSections}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return g.parseSection}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return r.parseShorthand}}),Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return r.looksLikeMask}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return r.looksLikeDatePattern}});const t=new Set(["decimal","currency","percent","unit"]),s=new Set(["type","locale"]),h={number:new Set(["style","currency","currencyDisplay","decimals","minDecimals","maxDecimals","thousandsSeparator","decimalSeparator","notation","compactDisplay","negative","negativeClass","signed","prefix","suffix","zeroDisplay","nullDisplay","messages","scale","pattern"]),date:new Set(["pattern","dateStyle","timeStyle","timeZone","relative","nullDisplay"]),boolean:new Set(["display","trueLabel","falseLabel","nullLabel","trueIcon","falseIcon"]),text:new Set(["transform","truncate","nullDisplay","emptyDisplay"])},d=new Set(["number","date","boolean","text"]);function o(E,O){const C=E.type;if(C===void 0||d.has(C)||!t.has(String(C)))return;const S=O?`"${O}"`:"with no id";I(`format:unknown-style-key:${O||""}:${C}`,`column ${S} has format: { type: "${C}" }, which is not a valid format type ("number", "date", "boolean" or "text") and is ignored; did you mean style: "${C}" instead?`)}function b(E,O,C){const S=h[O],F=C?`"${C}"`:"with no id";for(const P of E){if(s.has(P)||S.has(P))continue;const M=Object.keys(h).find(x=>x!==O&&h[x].has(P));M?I(`format:inapplicable:${C||""}:${P}`,`column ${F} has format key "${P}", which applies to a ${M} column, not the ${O} column it was applied to; it is ignored.`):I(`format:unknown:${C||""}:${P}`,`column ${F} has an unrecognised format key "${P}" for its ${O} format; it is ignored.`)}}function l(E){if(E.type==="number"||E.type==="date"||E.type==="boolean"||E.type==="text")return!0;const O=t.has(String(E.style));return!!(E.pattern||E.dateStyle||E.timeStyle||E.relative||E.timeZone||E.trueLabel||E.falseLabel||E.display||E.trueIcon||E.falseIcon||E.transform||E.truncate||E.emptyDisplay||O||E.currency||E.decimals!==void 0||E.minDecimals!==void 0||E.maxDecimals!==void 0||E.notation||E.negative||E.scale!==void 0||E.prefix||E.suffix||E.zeroDisplay!==void 0)}function p(E,O){if(E.type==="number"||E.type==="date"||E.type==="boolean"||E.type==="text")return E.type;if(E.pattern){if(c(E.pattern))return"number";if(u(E.pattern))return"date"}if(E.dateStyle||E.timeStyle||E.relative||E.timeZone)return"date";if(E.trueLabel||E.falseLabel||E.display||E.trueIcon||E.falseIcon)return"boolean";if(E.transform||E.truncate||E.emptyDisplay)return"text";if(E.style||E.currency||E.decimals!==void 0||E.minDecimals!==void 0||E.maxDecimals!==void 0||E.notation||E.negative||E.scale!==void 0||E.prefix||E.suffix||E.zeroDisplay!==void 0)return"number";const C=O&&O.base;return C==="number"?"number":C==="date"||C==="dateString"?"date":C==="boolean"?"boolean":"text"}function w(E,O=null,C=void 0,S=void 0,F=void 0){if(E==null||E==="")return null;const P=G(E)?Object.keys(E):null;if(typeof E=="function"){const U=(_,W)=>String(E({...W||{},value:_,locale:C})??"");return U.ooxml=O&&O.excel||"General",U}if(typeof E=="string"){if(c(E)){const{format:_,ooxml:W}=a(E,C);return _.ooxml=W,_}const U=i(E)||(u(E)?{type:"date",pattern:E}:null);return U?w(U,O,C,S,F):(I(`format:${E}`,`unrecognised format string "${E}"; the value will be stringified`),null)}if(!G(E))return I("format:shape","format must be a spec object or a string; ignoring",E),null;if(O&&T(O.format)&&!l(E)||O&&T(O.format)&&Array.isArray(O.formatPatterns)&&E.type===void 0)return null;const M=p(E,O);M==="date"&&S&&E.timeZone===void 0&&(E={...E,timeZone:S}),o(E,F),b(P||Object.keys(E),M,F);let x;switch(M){case"number":x=z(E,C);break;case"date":x=X(E,C);break;case"boolean":x=k(E,C);break;default:x=f(E,C);break}return x.ooxml=R(E,M,C,O),x.kind=M,x}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 R(E,O,C=void 0,S=null){if(O==="date"){if(E.pattern){let U="";for(const _ of $(E.pattern))U+=_.token?v[_.token]??_.text:_.text;return U}return S&&S.excel||"yyyy-mm-dd"}if(O==="boolean")return"General";if(O==="text")return"@";if(typeof E.pattern=="string"&&m(E.pattern))return String(E.pattern).trim();if(E.notation==="compact"||E.notation==="scientific")return"General";const F=typeof E.decimals=="number"?E.decimals:typeof E.minDecimals=="number"?E.minDecimals:E.style==="currency"?2:0;let M=`${E.thousandsSeparator===!1?"":"#,#"}#0${F>0?`.${"0".repeat(F)}`:""}`,x="";return E.style==="currency"&&(x+=Y(V(E.currency||"USD",C))),E.prefix&&(x+=Y(E.prefix)),M=x+M,E.style==="percent"&&(M=`${M}%`),E.suffix&&(M+=Y(E.suffix)),E.negative==="parentheses"?`${M};(${M})`:E.negative==="suffix"?`${M};${M}-`:M}function Y(E){return`"${String(E).split('"').join("")}"`}const K=new Map;function V(E,O){const C=`${E}|${O||""}`;let S=K.get(C);if(S!==void 0)return S;S=E;try{const P=new Intl.NumberFormat(O,{style:"currency",currency:E}).formatToParts(0).find(M=>M.type==="currency");P&&(S=P.value)}catch{}return K.set(C,S),S}}),Ue("packages/core/src/columns/types/temporal.js",function(e,B){"use strict";Object.defineProperty(e,"MS_SECOND",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"MS_MINUTE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"MS_HOUR",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"MS_DAY",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"MS_WEEK",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"toTimeMs",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"zonedParts",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"zoneOffsetAt",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"instantFromParts",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"toEpochMs",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(e,"toDurationMs",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"zoneAbbrev",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(e,"resolveZoneName",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(e,"timestampGroupProjector",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"TEMPORAL_INFERENCE_ORDER",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return He}});const re=B("packages/core/src/internal/predicates.js"),T=re.isNil,G=re.isFunction,D=B("packages/core/src/format/date.js"),I=D.toDate,Z=D.compilePattern,z=D.compileDate,L=D.toIsoDateTime,X=D.compareIso,$=864e5,A=Object.freeze({}),k=1e3,y=60*k,f=60*y,g=24*f,a=7*g,r=new WeakMap;function i(Me,Ke){const $e=Me&&Me.locale||"",Oe=Me&&Me.column;if(!Oe)return $e?{locale:$e}:A;const Se=r.get(Oe);if(Se&&Se.locale===$e)return Se.bag;const Pe=Oe.typeOptions||Oe[Ke]||(c(Oe.format)?Oe.format:null),Te={...Pe||A,locale:Pe&&Pe.locale||$e||void 0};return r.set(Oe,{locale:$e,bag:Te}),Te}function c(Me){return Me!==null&&typeof Me=="object"&&!Array.isArray(Me)&&!(Me instanceof Date)}function u(Me,Ke){const $e=Me===null||Number.isNaN(Me)?null:Me,Oe=Ke===null||Number.isNaN(Ke)?null:Ke;return $e===null?Oe===null?0:1:Oe===null||$e<Oe?-1:$e>Oe?1:0}const n=/^(\d{1,2})(?:\s*[:.h]\s*(\d{1,2})(?:\s*[:.]\s*(\d{1,2})(?:[.,](\d{1,3}))?)?)?\s*(a\.?m\.?|p\.?m\.?|a|p)?$/i,m=/^(\d{3,6})$/;function t(Me,Ke,$e,Oe){return!(Me>=0&&Me<=23)||!(Ke>=0&&Ke<=59)||!($e>=0&&$e<=59)||!(Oe>=0&&Oe<=999)?null:Me*f+Ke*y+$e*k+Oe}function s(Me){if(T(Me))return null;const Ke=String(Me).trim();if(Ke==="")return null;const $e=m.exec(Ke);if($e){const et=$e[1];if(et.length===5)return null;const Je=et.length===3?1:2;return t(Number(et.slice(0,Je)),Number(et.slice(Je,Je+2)),Number(et.slice(Je+2,Je+4)||0),0)}const Oe=n.exec(Ke);if(!Oe)return null;let Se=Number(Oe[1]);const Pe=Number(Oe[2]||0),Te=Number(Oe[3]||0),Be=Oe[4]?Number(Oe[4].padEnd(3,"0")):0,Ge=Oe[5]?Oe[5][0].toLowerCase():null;if(Ge){if(Se<1||Se>12)return null;Se=Se%12,Ge==="p"&&(Se+=12)}return t(Se,Pe,Te,Be)}function h(Me){return T(Me)||Me===""?null:typeof Me=="number"?Number.isFinite(Me)?(Me%g+g)%g:null:Me instanceof Date?Number.isNaN(Me.getTime())?null:Me.getHours()*f+Me.getMinutes()*y+Me.getSeconds()*k+Me.getMilliseconds():s(Me)}const d=new Map;function o(Me){const Ke=Me.pattern||"",$e=Me.timeStyle||(Me.seconds?"medium":"short"),Oe=`${Me.locale||""}|${Ke}|${$e}`;let Se=d.get(Oe);if(Se)return Se;if(Ke)Se=Z(Ke,Me.locale||void 0,"UTC");else{const Pe=new Intl.DateTimeFormat(Me.locale||void 0,{timeStyle:$e,timeZone:"UTC"});Se=Te=>Pe.format(Te)}return d.set(Oe,Se),Se}function b(Me,Ke){const $e=Ke||A;if(Me==null||typeof Me!="number"||!Number.isFinite(Me))return $e.nullDisplay??"";const Oe=(Me%g+g)%g;return o($e)(new Date(Oe))}function l(Me){return Me instanceof Date?!Number.isNaN(Me.getTime()):typeof Me=="number"?Number.isFinite(Me)&&Me>=0&&Me<g:typeof Me!="string"||!Me.includes(":")?!1:s(Me)!==null}function p(Me){const Ke=h(Me);return Ke==null?"":b(Ke,{pattern:Ke%k===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const w=new Map;function v(Me){const Ke=Me||"";let $e=w.get(Ke);return $e||($e=new Intl.DateTimeFormat("en-GB",{timeZone:Me||void 0,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),w.set(Ke,$e)),$e}function R(Me,Ke){const $e={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const Oe of v(Ke).formatToParts(new Date(Me)))Oe.type==="year"?$e.year=Number(Oe.value):Oe.type==="month"?$e.month=Number(Oe.value):Oe.type==="day"?$e.day=Number(Oe.value):Oe.type==="hour"?$e.hour=Number(Oe.value)%24:Oe.type==="minute"?$e.minute=Number(Oe.value):Oe.type==="second"&&($e.second=Number(Oe.value));return $e}function Y(Me,Ke){const $e=R(Me,Ke);return Date.UTC($e.year,$e.month-1,$e.day,$e.hour,$e.minute,$e.second,0)-Math.floor(Me/1e3)*1e3}function K(Me,Ke){const $e=Me.hour||0,Oe=Me.minute||0,Se=Me.second||0,Pe=Me.ms||0;if(!Ke)return new Date(Me.year,Me.month-1,Me.day,$e,Oe,Se,Pe).getTime();const Te=Date.UTC(Me.year,Me.month-1,Me.day,$e,Oe,Se,Pe);let Be=Te-Y(Te,Ke);return Be=Te-Y(Be,Ke),Be}const V=/(?:Z|[+-]\d{2}:?\d{2})$/i,E=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function O(Me,Ke){if(T(Me))return null;const $e=String(Me).trim();if($e==="")return null;const Oe=Ke&&Ke.timeZone||void 0;if(!V.test($e)){const Se=E.exec($e);if(Se){const Pe=(Se[4]||"").trim(),Te=Pe===""?0:s(Pe);if(Te===null)return null;const Be=K({year:Number(Se[1]),month:Number(Se[2]),day:Number(Se[3]),hour:Math.floor(Te/f),minute:Math.floor(Te/y)%60,second:Math.floor(Te/k)%60,ms:Te%k},Oe);return Number.isNaN(Be)?null:new Date(Be)}}return I($e)}function C(Me){if(typeof Me=="number")return Number.isFinite(Me)?Me:null;const Ke=I(Me);return Ke?Ke.getTime():null}const S=new Map;function F(Me){const Ke=[Me.locale||"",Me.pattern||"",Me.dateStyle||"",Me.timeStyle||"",Me.timeZone||"",Me.seconds?"1":""].join("|");let $e=S.get(Ke);if($e)return $e;const Oe=Me.pattern?{type:"date",pattern:Me.pattern,timeZone:Me.timeZone}:{type:"date",dateStyle:Me.dateStyle||"medium",timeStyle:Me.timeStyle||(Me.seconds?"medium":"short"),timeZone:Me.timeZone};return $e=z(Oe,Me.locale||void 0),S.set(Ke,$e),$e}function P(Me,Ke){const $e=Ke||A,Oe=C(Me);return Oe==null?$e.nullDisplay??"":F($e)(Oe)}function M(Me){return Me instanceof Date?!Number.isNaN(Me.getTime()):typeof Me!="string"||!E.test(Me.trim())?!1:O(Me)!==null}const x=Object.freeze([{key:"w",ms:a,intl:"week",long:["week","weeks"],names:["w","wk","wks","week","weeks"]},{key:"d",ms:g,intl:"day",long:["day","days"],names:["d","dy","day","days"]},{key:"h",ms:f,intl:"hour",long:["hour","hours"],names:["h","hr","hrs","hour","hours"]},{key:"m",ms:y,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"]}]),U=new Map;for(const Me of x)for(const Ke of Me.names)U.set(Ke,Me);const _=Object.freeze(x.filter(Me=>Me.key!=="w")),W=/^(\d+(?:\.\d+)?)\s*([a-z]+)\s*(?:,\s*)?/,q=/^\d+(?:\.\d+)?$/,N=/^(\d+):([0-5]?\d)(?::([0-5]?\d))?(?:\.(\d{1,3}))?$/;function Q(Me){const Ke=Me&&Me.defaultUnit?U.get(String(Me.defaultUnit).toLowerCase()):null;return Ke?Ke.ms:y}function J(Me){return(Me&&Me.defaultUnit?U.get(String(Me.defaultUnit).toLowerCase()):null)||U.get("m")}function ee(Me,Ke){if(T(Me))return null;let $e=String(Me).trim().toLowerCase();if($e==="")return null;let Oe=1;if($e[0]==="-"?(Oe=-1,$e=$e.slice(1).trim()):$e[0]==="+"&&($e=$e.slice(1).trim()),$e==="")return null;const Se=N.exec($e);if(Se){const Ge=Se[3]!==void 0,et=Number(Se[1])*f+Number(Se[2])*y+(Ge?Number(Se[3])*k:0)+(Se[4]?Number(Se[4].padEnd(3,"0")):0);return Oe*et}if(q.test($e))return Math.round(Oe*Number($e)*Q(Ke||A));let Pe=$e,Te=0,Be=0;for(;Pe!=="";){const Ge=W.exec(Pe);if(!Ge)return null;const et=U.get(Ge[2]);if(!et)return null;Te+=Number(Ge[1])*et.ms,Pe=Pe.slice(Ge[0].length),Be++}return Be===0?null:Math.round(Oe*Te)}function ne(Me){return T(Me)||Me===""?null:typeof Me=="number"?Number.isFinite(Me)?Me:null:ee(Me)}const se=new Map;function le(Me,Ke,$e){const Oe=`${$e||""}|${Ke.intl}`;let Se=se.get(Oe);if(Se===void 0){try{Se=new Intl.NumberFormat($e||void 0,{style:"unit",unit:Ke.intl,unitDisplay:"long"})}catch{Se=null}se.set(Oe,Se)}return Se?Se.format(Me):`${Me} ${Me===1?Ke.long[0]:Ke.long[1]}`}function ye(Me,Ke){return String(Me).padStart(Ke,"0")}function fe(Me,Ke){const $e=Ke||A;if(Me==null||typeof Me!="number"||!Number.isFinite(Me))return $e.nullDisplay??"";const Oe=$e.style||"short",Se=Me<0;let Pe=Math.round(Math.abs(Me));const Te=Se?"-":"";if(Pe===0&&$e.zeroDisplay!=null)return $e.zeroDisplay;if(Oe==="clock"){const Je=Math.floor(Pe/f),ft=Math.floor(Pe/y)%60,Et=Math.floor(Pe/k)%60;return`${Te}${ye(Je,2)}:${ye(ft,2)}:${ye(Et,2)}`}if(Pe===0){const Je=J($e);return Oe==="long"?le(0,Je,$e.locale):`0${Je.key}`}const Be=$e.weeks===!0?x:_,Ge=typeof $e.maxUnits=="number"&&$e.maxUnits>0?$e.maxUnits:$e.maxUnits===void 0?2:1/0,et=[];for(const Je of Be){if(et.length>=Ge)break;const ft=Math.floor(Pe/Je.ms);ft!==0&&(Pe-=ft*Je.ms,et.push(Oe==="long"?le(ft,Je,$e.locale):`${ft}${Je.key}`))}return Te+et.join(" ")}function we(Me){if(typeof Me!="string")return!1;const Ke=Me.trim();return Ke===""||N.test(Ke)||!/[a-z]/i.test(Ke)?!1:ee(Ke)!==null}const ke=Date.UTC(1899,11,30),Ce=new Map;function ce(Me,Ke){const $e=Me||"";let Oe=Ce.get($e);Oe||(Oe=new Intl.DateTimeFormat("en-GB",{timeZone:Me||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),Ce.set($e,Oe));const Se=typeof Ke=="number"?Ke:Date.now();for(const Pe of Oe.formatToParts(new Date(Se)))if(Pe.type==="timeZoneName")return Pe.value;return""}function ae(Me){if(Me)return Me;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function ge(Me,Ke){const $e=ae(Me),Oe=ce(Me,Ke);return Oe?`${$e} (${Oe})`:$e}function de(Me,Ke){if(Me&&Me.timeZone)return Me.timeZone;const $e=Ke&&Ke.grid;return($e&&G($e.get)?$e.get("timeZone"):void 0)||void 0}function me(Me,Ke){const $e=Ke||A,Oe=C(Me);if(Oe==null)return $e.nullDisplay??"";const Se=F($e)(Oe);if(!$e.showOrigin)return Se;const Pe=$e.originZone;return Pe?Pe===($e.timeZone||ae($e.timeZone))?Se:`${Se} (${ge(Pe,Oe)})`:`${Se} (no origin recorded)`}function ve(Me,Ke,$e,Oe){if(Ke==="instant"||!Ke)return Me;const Se=R(Me,$e);if(Ke==="month")return K({year:Se.year,month:Se.month,day:1},$e);if(Ke==="week"){const Pe=Oe>=1&&Oe<=7?Oe:1,Be=((new Date(Date.UTC(Se.year,Se.month-1,Se.day)).getUTCDay()+6)%7+1-Pe+7)%7,Ge=new Date(Date.UTC(Se.year,Se.month-1,Se.day-Be));return K({year:Ge.getUTCFullYear(),month:Ge.getUTCMonth()+1,day:Ge.getUTCDate()},$e)}return K({year:Se.year,month:Se.month,day:Se.day},$e)}function xe(Me,Ke){const $e=Me&&Me.group,Oe=$e&&$e.granularity||"day";if(Oe==="instant")return null;const Se=$e&&$e.weekStart;return Pe=>typeof Pe=="number"?ve(Pe,Oe,Ke,Se):Pe}const Ee={time:{base:"number",storage:"float64",matches:l,format:Me=>b(h(Me.value),i(Me,"time")),parse:Me=>s(Me.text),compare:(Me,Ke)=>u(h(Me),h(Ke)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:Me=>{const Ke=h(Me);return Ke===null?null:Ke/$},toStorage:Me=>h(Me),toClipboard:p,fromClipboard:s},datetime:{base:"dateString",storage:"dictionary",matches:M,format:Me=>P(Me.value,i(Me,"datetime")),parse:Me=>L(O(Me.text,i(Me,"datetime"))??Me.text),compare:X,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(Me,Ke)=>L(Me,Ke&&Ke.timeZone),toClipboard:Me=>T(Me)?"":String(Me),fromClipboard:Me=>L(Me)},duration:{base:"number",storage:"float64",matches:we,format:Me=>fe(ne(Me.value),i(Me,"duration")),parse:Me=>ee(Me.text,i(Me,"duration")),compare:(Me,Ke)=>u(ne(Me),ne(Ke)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:Me=>{const Ke=ne(Me);return Ke===null?null:Ke/$},toStorage:Me=>ne(Me),toClipboard:Me=>fe(ne(Me),{style:"short",maxUnits:-1}),fromClipboard:Me=>ee(Me)},timestamp:{base:"number",storage:"float64",format:Me=>{const Ke=i(Me,"timestamp");return me(Me.value,{...Ke,timeZone:de(Ke,Me)})},parse:Me=>{const Ke=i(Me,"timestamp"),$e=O(Me.text,{timeZone:de(Ke,Me)});return $e?$e.getTime():null},compare:(Me,Ke)=>u(C(Me),C(Ke)),groupProjector:(Me,Ke)=>xe(Me,Ke),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(Me,Ke)=>{const $e=C(Me);if($e==null)return null;const Oe=R($e,Ke&&Ke.timeZone||void 0);return(Date.UTC(Oe.year,Oe.month-1,Oe.day,Oe.hour,Oe.minute,Oe.second)-ke)/$},toStorage:Me=>C(Me),toClipboard:Me=>{const Ke=C(Me);return Ke==null?"":new Date(Ke).toISOString()},fromClipboard:Me=>C(Me)}},Le=["datetime","time","duration"],He=Ee}),Ue("packages/core/src/internal/lru.js",function(e,B){"use strict";Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return re}});class re{#e;#t=new Map;#n;constructor(G=256,D=null){this.#e=G,this.#n=D}get size(){return this.#t.size}get max(){return this.#e}set max(G){this.#e=G,this.#r()}has(G){return this.#t.has(G)}get(G){const D=this.#t;if(!D.has(G))return;const I=D.get(G);return D.delete(G),D.set(G,I),I}peek(G){return this.#t.get(G)}set(G,D){const I=this.#t;return I.has(G)&&I.delete(G),I.set(G,D),this.#r(),D}delete(G){const D=this.#t.get(G);return this.#t.delete(G)&&this.#n&&this.#n(D,G),D}clear(){if(this.#n)for(const[G,D]of this.#t)this.#n(D,G);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const G=this.#t;for(;G.size>this.#e;){const D=G.keys().next().value,I=G.get(D);G.delete(D),this.#n&&this.#n(I,D)}}}}),Ue("packages/core/src/columns/types/network.js",function(e,B){"use strict";Object.defineProperty(e,"toUint32",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"isIpv4",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"compareIpv4",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"packCidr",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"cidrParts",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isCidr",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"compareCidr",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"netmask",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"addressCount",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ipv6Groups",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"isIpv6",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return C}});const T=B("packages/core/src/internal/predicates.js").isNil,D=B("packages/core/src/internal/lru.js").Lru,I=4294967295,Z=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function z(S){if(T(S))return null;if(typeof S=="string")return L(S);const F=Number(S);return Number.isFinite(F)?F<0?F<-2147483648?null:F>>>0:F>I?null:Math.trunc(F)>>>0:null}function L(S){if(T(S))return null;const F=String(S).trim();if(F==="")return null;const P=Z.exec(F);if(!P)return null;let M=0;for(let x=1;x<=4;x++){const U=P[x];if(U.length>1&&U.charCodeAt(0)===48)return null;const _=Number(U);if(_>255)return null;M=M*256+_}return M}function X(S){const F=z(S);return F===null?"":`${F>>>24&255}.${F>>>16&255}.${F>>>8&255}.${F&255}`}function $(S){return typeof S=="string"&&L(S)!==null}function A(S,F){const P=z(S),M=z(F);return P===null?M===null?0:1:M===null||P<M?-1:P>M?1:0}const k=64,y=I*k+32,f=/^(?:0|[1-9]\d?)$/;function g(S,F){return S*k+F}function a(S){if(T(S))return null;if(typeof S=="string"){const M=r(S);return M===null?null:a(M)}if(typeof S=="object"){const M=z(S.address),x=Number(S.prefix);return M===null||!Number.isInteger(x)||x<0||x>32?null:{address:M,prefix:x}}const F=Number(S);if(!Number.isInteger(F)||F<0||F>y)return null;const P=F%k;return P>32?null:{address:(F-P)/k,prefix:P}}function r(S){if(T(S))return null;const F=String(S).trim();if(F==="")return null;const P=F.indexOf("/");if(P<0)return null;const M=L(F.slice(0,P));if(M===null)return null;const x=F.slice(P+1).trim();if(!f.test(x))return null;const U=Number(x);return U>32?null:g(M,U)}function i(S){const F=a(S);return F?`${X(F.address)}/${F.prefix}`:""}function c(S){return typeof S=="string"&&r(S)!==null}function u(S,F){const P=a(S),M=a(F);return P?M?P.address!==M.address?P.address<M.address?-1:1:P.prefix-M.prefix:-1:M?1:0}function n(S){return S===0?0:4294967295<<32-S>>>0}function m(S){const F=a(S);return F?(F.address&n(F.prefix))>>>0:null}function t(S){const F=a(S);return F?(F.address&n(F.prefix)|~n(F.prefix)>>>0)>>>0:null}function s(S){const F=a(S);return F?2**(32-F.prefix):null}function h(S){const F=a(S);return F?F.prefix===32?1:F.prefix===31?2:2**(32-F.prefix)-2:null}function d(S,F){const P=a(S);if(!P)return!1;const M=z(F);if(M===null)return!1;const x=n(P.prefix);return(M&x)>>>0===(P.address&x)>>>0}function o(S,F){const P=m(S),M=m(F);return P===null||M===null?!1:P<=t(F)&&M<=t(S)}const b=/^[0-9a-fA-F]{1,4}$/,l=new D(512);function p(S){if(T(S))return null;let F=String(S).trim();if(F==="")return null;const P=F.indexOf("%");if(P>=0&&(F=F.slice(0,P)),F==="")return null;if(F.indexOf(".")>=0){const q=F.lastIndexOf(":");if(q<0)return null;const N=L(F.slice(q+1));if(N===null)return null;F=`${F.slice(0,q+1)}${(N>>>16&65535).toString(16)}:${(N&65535).toString(16)}`}const M=F.split("::");if(M.length>2)return null;const x=w(M[0]);if(x===null)return null;if(M.length===1)return x.length===8?x:null;const U=w(M[1]);if(U===null)return null;const _=8-x.length-U.length;if(_<1)return null;const W=x.slice();for(let q=0;q<_;q++)W.push(0);for(const q of U)W.push(q);return W}function w(S){if(S==="")return[];const F=[];for(const P of S.split(":")){if(!b.test(P))return null;F.push(parseInt(P,16))}return F}function v(S){if(typeof S!="string")return p(S);if(l.has(S))return l.get(S);const F=p(S);return l.set(S,F),F}function R(S){if(S[0]===0&&S[1]===0&&S[2]===0&&S[3]===0&&S[4]===0&&S[5]===65535)return`::ffff:${X((S[6]<<16|S[7])>>>0)}`;let F=-1,P=0,M=-1,x=0;for(let W=0;W<8;W++)S[W]===0?(M<0?(M=W,x=1):x++,x>P&&(P=x,F=M)):(M=-1,x=0);if(P<2)return S.map(W=>W.toString(16)).join(":");const U=S.slice(0,F).map(W=>W.toString(16)).join(":"),_=S.slice(F+P).map(W=>W.toString(16)).join(":");return`${U}::${_}`}function Y(S){const F=p(S);return F===null?null:R(F)}function K(S){return Y(S)??""}function V(S){return typeof S=="string"&&S.indexOf(":")>=0&&p(S)!==null}function E(S,F){const P=v(S),M=v(F);if(!P)return M?1:0;if(!M)return-1;for(let x=0;x<8;x++)if(P[x]!==M[x])return P[x]<M[x]?-1:1;return 0}const O=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:$,parse:S=>L(S.text),compare:A,format:S=>X(S.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:S=>z(S),toClipboard:S=>X(S),fromClipboard:S=>L(S)},cidr:{base:"number",storage:"float64",matches:c,parse:S=>r(S.text),compare:u,format:S=>i(S.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:S=>{const F=a(S);return F===null?null:g(F.address,F.prefix)},toClipboard:S=>i(S),fromClipboard:S=>r(S)},ipv6:{base:"text",storage:"dictionary",matches:V,parse:S=>Y(S.text),compare:E,format:S=>K(S.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",toStorage:S=>Y(S),toClipboard:S=>K(S),fromClipboard:S=>Y(S)}}),C=O}),Ue("packages/core/src/i18n/catalogue.js",function(e,B){"use strict";Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return I}});const re=B("packages/core/src/registry/free-tier-notice.js"),T=re.FREE_TIER_NOTICE,G=re.WATERMARK_TEXT,D=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.column.hidden":"{column} hidden","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.unavailable":"Not available on this source","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.columnMenu":"Column menu","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; while editing, commit and open the cell below (Shift+Enter: above)","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":G,"licence.watermark.free":T,"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.order":"Order values","filter.orderAz":"A to Z","filter.orderCount":"Count","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"}),I=Object.freeze(Object.keys(D))}),Ue("packages/core/src/i18n/format.js",function(e,B){"use strict";Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"formatMessage",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"lookup",{enumerable:!0,get:function(){return k}});const T=B("packages/core/src/internal/predicates.js").isFunction,G=/\{(\w+)\}/g,D=new Map,I=new Map;function Z(y){const f=y||"";if(D.has(f))return D.get(f);let g=null;try{g=new Intl.PluralRules(y||void 0)}catch{g=null}return D.set(f,g),g}function z(y,f,g="conjunction"){const a=Array.isArray(y)?y.filter(c=>c!=null&&c!==""):[];if(a.length===0)return"";if(a.length===1)return String(a[0]);const r=`${f||""}|${g}`;let i=I.get(r);if(i===void 0){try{i=new Intl.ListFormat(f||void 0,{style:"long",type:g})}catch{i=null}I.set(r,i)}return i?i.format(a.map(String)):a.map(String).join(", ")}function L(y,f){return y==null?"":typeof y=="number"?Number.isFinite(y)?y.toLocaleString(f||void 0,{maximumFractionDigits:20}):"":String(y)}function X(y,f,g){if(typeof y=="string")return y;if(!y||typeof y!="object")return"";const a=f&&typeof f.count=="number"?f.count:null;if(a===null)return y.other??"";const r=Z(g),i=r?r.select(a):a===1?"one":"other";return y[i]??y.other??""}function $(y,f={},g){const a=X(y,f,g);return a?a.replace(G,(r,i)=>Object.prototype.hasOwnProperty.call(f,i)?L(f[i],g):r):""}function A(y,f,g="en-GB"){return typeof y=="string"&&y?y:typeof f=="string"&&f?f:g}function k(y,f){const g=y?y[f]:void 0;return g==null||T(g)?f:g}}),Ue("packages/core/src/i18n/registry.js",function(e,B){"use strict";Object.defineProperty(e,"registerLocale",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"localeCatalogue",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"registeredTags",{enumerable:!0,get:function(){return Z}});const T=B("packages/core/src/i18n/catalogue.js").EN_GB,G=new Map([["en-gb",T]]);function D(z,L){const X=typeof z=="string"?z.toLowerCase():"";return!X||!L||typeof L!="object"?!1:(G.set(X,L),!0)}function I(z){if(typeof z!="string"||!z)return null;const L=z.toLowerCase(),X=G.get(L);if(X)return X;const $=L.split("-")[0],A=G.get($);if(A)return A;for(const[k,y]of G)if(k.split("-")[0]===$)return y;return null}function Z(){return[...G.keys()]}}),Ue("packages/core/src/i18n/index.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"defaultMessages",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return u}});const re=B("packages/core/src/i18n/catalogue.js"),T=re.EN_GB,G=re.MESSAGE_KEYS,D=B("packages/core/src/i18n/format.js"),I=D.formatMessage,Z=D.formatList,z=D.lookup,L=D.resolveLocale,$=B("packages/core/src/internal/predicates.js").isFunction,k=B("packages/core/src/internal/warn.js").warnOnce,y=B("packages/core/src/i18n/registry.js"),f=y.registerLocale,g=y.localeCatalogue;Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return re.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return re.MESSAGE_KEYS}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return D.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return D.resolveLocale}}),Object.defineProperty(e,"registerLocale",{enumerable:!0,get:function(){return y.registerLocale}});const a="en-GB";class r{#e=a;#t=T;constructor(m={}){this.configure(m)}configure(m={}){this.#e=L(m.locale,m.declared,a);const t=m.messages,s=g(this.#e);if(!s&&this.#e.toLowerCase()!=="en-gb"&&(!t||typeof t!="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.`),!t||typeof t!="object"){this.#t=s?{...T,...s}:T;return}const d=Object.keys(t).filter(o=>!(o in T));d.length&&k(`i18n:unknown:${d[0]}`,`message keys not in the catalogue and so ignored: ${d.slice(0,5).join(", ")}${d.length>5?`, and ${d.length-5} more`:""}`),this.#t={...T,...s||{},...t}}get locale(){return this.#e}t(m,t){return I(z(this.#t,m),t||{},this.#e)}list(m,t){return Z(m,this.#e,t)}number(m,t){const s=Number(m);return Number.isFinite(s)?s.toLocaleString(this.#e,t||{maximumFractionDigits:20}):""}}const i=new r;function c(n){return n instanceof r?n:new r(n||{})}function u(n){const m=n&&typeof n=="object"?n:{},t=G.filter(h=>{const d=m[h];return d==null||d===""||$(d)}),s=Object.keys(m).filter(h=>!(h in T));return{missing:t,unknown:s}}}),Ue("packages/core/src/columns/types/structured.js",function(e,B){"use strict";Object.defineProperty(e,"MASK_DEFAULTS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"canonicalJson",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"parseJsonText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const re=B("packages/core/src/internal/predicates.js"),T=re.isNil,G=re.isObject,I=B("packages/core/src/i18n/index.js").defaultMessages,Z=Object.freeze({char:"•",length:8,fixedLength:!0,lastVisible:0,emptyDisplay:""});function z(r,i){const c=i||{},u=c.emptyDisplay??Z.emptyDisplay;if(T(r)||r==="")return u;const m=[...typeof c.char=="string"&&c.char!==""?c.char:Z.char][0]||Z.char,t=c.fixedLength??Z.fixedLength,s=Number.isFinite(c.length)&&Number(c.length)>0?Math.floor(Number(c.length)):Z.length,h=typeof r=="string"?r:typeof r=="number"||typeof r=="boolean"||typeof r=="bigint"?String(r):null;let d=0;if(h!==null){const o=Number.isFinite(c.lastVisible)?Math.floor(Number(c.lastVisible)):Z.lastVisible,b=[...h];if(d=o>0&&o<b.length?o:0,d>0){const l=b.slice(b.length-d).join(""),p=Math.max(1,(t?s:b.length)-d);return m.repeat(p)+l}return m.repeat(t?s:Math.max(1,b.length))}return m.repeat(s)}const L=48;function X(r){try{const i=JSON.stringify(r);return i===void 0?null:i}catch{return null}}function $(r,i){if(T(r))return"";const c=Number.isFinite(i&&i.inlineLimit)?Number(i.inlineLimit):L;if(typeof r=="string")return r.length>c?`${r.slice(0,c-1)}…`:r;if(typeof r!="object")return String(r);const u=X(r);if(u!==null&&u.length<=c)return u;if(Array.isArray(r)){const m=r.length;return`[${I.t("count.items",{count:m})}]`}const n=Object.keys(r).length;return`{${I.t("count.keys",{count:n})}}`}function A(r,i){if(r==null)return"null";const c=typeof r;if(c==="number"||c==="boolean"||c==="bigint")return String(r);if(c==="string")return JSON.stringify(r);if(c!=="object")return JSON.stringify(String(r));const u=i||new WeakSet;return u.has(r)?'"[circular]"':(u.add(r),r instanceof Date?JSON.stringify(r.toISOString()):Array.isArray(r)?`[${r.map(t=>A(t,u)).join(",")}]`:`{${Object.keys(r).sort().map(t=>`${JSON.stringify(t)}:${A(r[t],u)}`).join(",")}}`)}function k(r,i){if(T(r))return T(i)?0:1;if(T(i))return-1;const c=A(r),u=A(i);return c<u?-1:c>u?1:0}function y(r){if(T(r))return null;const i=String(r);if(i.trim()==="")return null;try{return JSON.parse(i)}catch{return i}}function f(r){const i=r&&r.cell&&r.cell.props;return G(i)?i:{}}const g=Object.freeze({json:{base:"object",storage:"object",format:r=>$(r&&r.value,f(r&&r.column)),parse:r=>y(r&&r.text),compare:k,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:r=>{if(T(r))return"";if(typeof r=="string")return r;try{const i=JSON.stringify(r,null,2);return i===void 0?String(r):i}catch{return String(r)}},fromClipboard:r=>y(r)},secret:{base:"text",storage:"object",format:r=>z(r&&r.value,f(r&&r.column)),parse:r=>{const i=r&&r.text;return T(i)||String(i)===""?null:String(i)},compare:(r,i)=>{const c=T(r)||r==="",u=T(i)||i==="";return c===u?0:c?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:r=>z(r),fromClipboard:r=>T(r)||String(r)===""?null:String(r)}}),a=g}),Ue("packages/core/src/columns/types/unit.js",function(e,B){"use strict";Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return M}});const T=B("packages/core/src/internal/predicates.js").isNil,D=B("packages/core/src/internal/warn.js").warnOnce;function I(x,U,_,W){return Object.freeze({symbol:x,factor:U,aliases:Object.freeze(_||[]),binary:!!(W&&W.binary),prefix:W&&W.prefix||null,auto:!(W&&W.auto===!1)})}function Z(x,U,_,W){return I(x,U,_,W)}const z=Object.freeze({data:Object.freeze([I("B",1,["byte","bytes"]),I("kB",1e3,["kilobyte","kilobytes"],{prefix:"k"}),I("KiB",1024,["kibibyte","kibibytes"],{binary:!0,prefix:"k"}),I("MB",1e6,["megabyte","megabytes"],{prefix:"m"}),I("MiB",1024**2,["mebibyte","mebibytes"],{binary:!0,prefix:"m"}),I("GB",1e9,["gigabyte","gigabytes"],{prefix:"g"}),I("GiB",1024**3,["gibibyte","gibibytes"],{binary:!0,prefix:"g"}),I("TB",1e12,["terabyte","terabytes"],{prefix:"t"}),I("TiB",1024**4,["tebibyte","tebibytes"],{binary:!0,prefix:"t"}),I("PB",1e15,["petabyte","petabytes"],{prefix:"p"})]),bitrate:Object.freeze([I("bps",1,["bit","bits","bit/s","b/s"]),I("kbps",1e3,["kbit","kbits","kbit/s","kb/s","kilobit","kilobits"],{prefix:"k"}),I("Mbps",1e6,["mbit","mbits","mbit/s","mb/s","megabit","megabits"],{prefix:"m"}),I("Gbps",1e9,["gbit","gbits","gbit/s","gb/s","gigabit","gigabits"],{prefix:"g"}),I("Tbps",1e12,["tbit","tbits","tbit/s","tb/s","terabit","terabits"],{prefix:"t"})]),length:Object.freeze([I("nm",1e-9,["nanometre","nanometres","nanometer","nanometers"]),I("µm",1e-6,["um","micrometre","micrometres","micrometer","micrometers","micron","microns"]),I("mm",.001,["millimetre","millimetres","millimeter","millimeters"]),I("cm",.01,["centimetre","centimetres","centimeter","centimeters"]),I("in",.0254,["inch","inches"],{auto:!1}),I("ft",.3048,["foot","feet"],{auto:!1}),I("yd",.9144,["yard","yards"],{auto:!1}),I("m",1,["metre","metres","meter","meters"]),I("km",1e3,["kilometre","kilometres","kilometer","kilometers"]),I("mi",1609.344,["mile","miles"],{auto:!1}),I("nmi",1852,["nauticalmile","nauticalmiles"],{auto:!1})]),mass:Object.freeze([I("mg",.001,["milligram","milligrams"]),I("g",1,["gram","grams"]),I("oz",28.349523125,["ounce","ounces"],{auto:!1}),I("lb",453.59237,["pound","pounds","lbs"],{auto:!1}),I("kg",1e3,["kilogram","kilograms"]),I("st",6350.29318,["stone"],{auto:!1}),I("t",1e6,["tonne","tonnes","ton"],{auto:!1}),I("ton (US)",907184.74,["ton","shortton"],{auto:!1}),I("ton (UK)",10160469088e-4,["ton","longton"],{auto:!1})]),duration:Object.freeze([I("ns",1e-9,["nsec","nsecs","nanosecond","nanoseconds"]),I("µs",1e-6,["us","usec","usecs","microsecond","microseconds"]),I("ms",.001,["msec","msecs","millisecond","milliseconds"]),I("s",1,["sec","secs","second","seconds"]),I("m",60,["min","mins","minute","minutes"]),I("h",3600,["hr","hrs","hour","hours"]),I("d",86400,["day","days"])]),speed:Object.freeze([I("mm/s",.001,["millimetre/s","millimeter/s"]),I("ft/s",.3048,["fps","foot/s","feet/s"],{auto:!1}),I("km/h",1/3.6,["kph","kmh","kilometre/h","kilometer/h"],{auto:!1}),I("mph",.44704,["mile/h","miles/h"],{auto:!1}),I("kn",1852/3600,["knot","knots"],{auto:!1}),I("m/s",1,["metre/s","meter/s","mps"]),I("km/s",1e3,["kilometre/s","kilometer/s"])]),acceleration:Object.freeze([I("mm/s²",.001,["mm/s2"]),I("ft/s²",.3048,["ft/s2"],{auto:!1}),I("m/s²",1,["m/s2","metre/s2","meter/s2"]),I("g",9.80665,["gee","gravity"],{auto:!1})]),area:Object.freeze([I("mm²",1e-6,["mm2"]),I("cm²",1e-4,["cm2"]),I("in²",64516e-8,["in2","sqin"],{auto:!1}),I("ft²",.09290304,["ft2","sqft"],{auto:!1}),I("yd²",.83612736,["yd2","sqyd"],{auto:!1}),I("m²",1,["m2","sqm"]),I("ha",1e4,["hectare","hectares"],{auto:!1}),I("ac",4046.8564224,["acre","acres"],{auto:!1}),I("km²",1e6,["km2","sqkm"])]),volume:Object.freeze([I("µL",1e-6,["ul","microlitre","microliter"]),I("mL",.001,["millilitre","milliliter"]),I("fl oz (US)",.0295735295625,["fl oz","usfloz"],{auto:!1}),I("fl oz (imp)",.0284130625,["fl oz","impfloz"],{auto:!1}),I("L",1,["litre","litres","liter","liters"]),I("gal (US)",3.785411784,["gal","usgal","usgallon"],{auto:!1}),I("gal (imp)",4.54609,["gal","impgal","impgallon"],{auto:!1}),I("m³",1e3,["m3","cubicmetre","cubicmeter","kl"],{auto:!1}),I("bbl",158.987294928,["barrel","barrels"],{auto:!1})]),energy:Object.freeze([I("eV",1602176634e-28,["electronvolt","electronvolts"],{auto:!1}),I("J",1,["joule","joules"]),I("cal",4.184,["calorie","calories"],{auto:!1}),I("kJ",1e3,["kilojoule","kilojoules"]),I("BTU",1055.05585262,["btu"],{auto:!1}),I("kcal",4184,["kilocalorie","kilocalories","Cal"],{auto:!1}),I("MJ",1e6,["megajoule","megajoules"]),I("kWh",36e5,["kilowatthour","kilowatthours"],{auto:!1}),I("GJ",1e9,["gigajoule","gigajoules"]),I("MWh",36e8,["megawatthour","megawatthours"],{auto:!1})]),power:Object.freeze([I("mW",.001,["milliwatt","milliwatts"]),I("W",1,["watt","watts"]),I("BTU/h",1055.05585262/3600,["btuh","btu/h"],{auto:!1}),I("kW",1e3,["kilowatt","kilowatts"]),I("hp",745.6998715822702,["horsepower"],{auto:!1}),I("MW",1e6,["megawatt","megawatts"]),I("GW",1e9,["gigawatt","gigawatts"])]),force:Object.freeze([I("mN",.001,["millinewton","millinewtons"]),I("N",1,["newton","newtons"]),I("lbf",4.4482216152605,["poundforce"],{auto:!1}),I("kgf",9.80665,["kilogramforce"],{auto:!1}),I("kN",1e3,["kilonewton","kilonewtons"]),I("MN",1e6,["meganewton","meganewtons"])]),pressure:Object.freeze([I("Pa",1,["pascal","pascals"]),I("mbar",100,["millibar"],{auto:!1}),I("inH₂O",249.0889,["inh2o"],{auto:!1}),I("mmHg",133.322387415,["torr"],{auto:!1}),I("kPa",1e3,["kilopascal","kilopascals"]),I("inHg",3386.388640341,["inhg"],{auto:!1}),I("psi",6894.757293168361,["lbf/in2"],{auto:!1}),I("bar",1e5,[],{auto:!1}),I("atm",101325,["atmosphere","atmospheres"],{auto:!1}),I("MPa",1e6,["megapascal","megapascals"]),I("GPa",1e9,["gigapascal","gigapascals"])]),torque:Object.freeze([I("N·m",1,["nm","n.m","newtonmetre","newtonmeter"]),I("lbf·ft",1.3558179483314003,["lbfft","lbf.ft","ftlb","ft-lb"],{auto:!1}),I("kN·m",1e3,["knm","kn.m"],{auto:!1}),I("MN·m",1e6,["mnm","mn.m"],{auto:!1})]),density:Object.freeze([I("kg/m³",1,["kg/m3"]),I("lb/ft³",16.01846337396014,["lb/ft3","pcf"],{auto:!1}),I("g/cm³",1e3,["g/cm3","g/ml","kg/l"],{auto:!1}),I("t/m³",1e3,["t/m3"],{auto:!1})]),flow:Object.freeze([I("L/min",1/6e4,["lpm","l/min"],{auto:!1}),I("m³/h",1/3600,["m3/h","cmh"],{auto:!1}),I("gpm (US)",.003785411784/60,["gpm","usgpm"],{auto:!1}),I("gpm (imp)",.00454609/60,["gpm","impgpm"],{auto:!1}),I("cfm",.0004719474432,["ft3/min"],{auto:!1}),I("L/s",.001,["lps","l/s"],{auto:!1}),I("m³/s",1,["m3/s","cms"])]),angle:Object.freeze([I("″",Math.PI/648e3,["arcsec","arcsecond","arcseconds"],{auto:!1}),I("′",Math.PI/10800,["arcmin","arcminute","arcminutes"],{auto:!1}),I("mrad",.001,["milliradian","milliradians"],{auto:!1}),I("mil",Math.PI/3200,["nato-mil"],{auto:!1}),I("°",Math.PI/180,["deg","degree","degrees"],{auto:!1}),I("gon",Math.PI/200,["grad","gradian","gradians"],{auto:!1}),I("rad",1,["radian","radians"]),I("turn",2*Math.PI,["rev","revolution","revolutions"],{auto:!1})]),angularVelocity:Object.freeze([I("°/s",Math.PI/180,["degps","deg/s","degrees/s"],{auto:!1}),I("rad/s",1,["radps","radians/s"]),I("rpm",2*Math.PI/60,["rev/min","r/min","revolutions/min"],{auto:!1}),I("rps",2*Math.PI,["rev/s","r/s","revolutions/s"],{auto:!1})]),fraction:Object.freeze([I("ppt",1e-12,["partspertrillion"],{auto:!1}),I("ppb",1e-9,["partsperbillion"]),I("ppm",1e-6,["partspermillion"]),I("bp",1e-4,["bps-finance","basispoint","basispoints","bips"],{auto:!1}),I("‰",.001,["permille","permil"],{auto:!1}),I("%",.01,["pct","percent"]),I("×",1,["x","ratio","times"])]),molarity:Object.freeze([I("pM",1e-12,["picomolar","picomolarity"]),I("nM",1e-9,["nanomolar","nanomolarity"]),I("µM",1e-6,["um-molar","micromolar","micromolarity"]),I("mM",.001,["millimolar","millimolarity"]),I("M",1,["molar","mol/l","mol/L","molarity"]),I("mol/m³",.001,["mol/m3"],{auto:!1})]),massFlow:Object.freeze([I("mg/s",1e-6,["milligrams/s"]),I("g/s",.001,["grams/s"]),I("kg/h",1/3600,["kilograms/h","kgph"],{auto:!1}),I("kg/s",1,["kilograms/s","kgps"]),I("t/h",1e3/3600,["tonnes/h","tph"],{auto:!1}),I("lb/h",.45359237/3600,["pounds/h","pph"],{auto:!1}),I("t/s",1e3,["tonnes/s"],{auto:!1})]),viscosity:Object.freeze([I("µPa·s",1e-6,["upas","micropascalsecond"]),I("cP",.001,["centipoise"],{auto:!1}),I("mPa·s",.001,["mpas","millipascalsecond"]),I("P",.1,["poise"],{auto:!1}),I("Pa·s",1,["pas","pascalsecond"])]),kinematicViscosity:Object.freeze([I("cSt",1e-6,["centistokes","centistoke"]),I("mm²/s",1e-6,["mm2/s"],{auto:!1}),I("St",1e-4,["stokes","stoke"],{auto:!1}),I("m²/s",1,["m2/s"])]),thermalConductivity:Object.freeze([I("mW/(m·K)",.001,["mw/mk"]),I("W/(m·K)",1,["w/mk","wmk"]),I("kW/(m·K)",1e3,["kw/mk"],{auto:!1}),I("BTU/(hr·ft·°F)",1.730734666,["btu/hrftf"],{auto:!1})]),specificHeat:Object.freeze([I("J/(kg·K)",1,["j/kgk","jkgk"]),I("kJ/(kg·K)",1e3,["kj/kgk"]),I("cal/(g·°C)",4184,["cal/gc"],{auto:!1})]),doseRate:Object.freeze([I("nSv/h",1e-9,["nsvh"]),I("µSv/h",1e-6,["usv/h","usvh"]),I("mSv/h",.001,["msvh"]),I("Sv/h",1,["svh"]),I("mSv/a",.001/8766,["msv/year","msvpa"],{auto:!1})])}),L=Symbol("ambiguous"),X=new Map,$=new Map;function A(x,U){const _=String(x||"").trim();if(!_)throw new Error("[lattice] a unit system needs a name");if(z[_]||$.has(_))throw new Error(`[lattice] unit system "${_}" already exists`);const W=[...U||[]];if(!W.length)throw new Error(`[lattice] unit system "${_}" has no units`);if(!W.some(N=>N.factor===1))throw new Error(`[lattice] unit system "${_}" has no base unit (none with factor 1)`);const q=new Set;for(const N of W){if(q.has(N.symbol))throw new Error(`[lattice] unit system "${_}" declares "${N.symbol}" twice`);q.add(N.symbol)}return $.set(_,Object.freeze(W)),X.delete(_),_}function k(){return[...Object.keys(z),...$.keys()]}function y(x){const U=f(x);return U?U.units:[]}function f(x){const U=String(x||""),_=X.get(U);if(_!==void 0)return _;const W=z[U]||$.get(U);if(!W)return X.set(U,null),null;const q=Object.freeze([...W].sort((ne,se)=>ne.factor-se.factor)),N=new Map,Q=new Map,J=(ne,se)=>{const le=N.get(ne);le===void 0?N.set(ne,se):le!==se&&N.set(ne,L)};for(const ne of q){J(ne.symbol.toLowerCase(),ne);for(const se of ne.aliases)J(se.toLowerCase(),ne);if(ne.prefix){const se=Q.get(ne.prefix)||[];se.push(ne),Q.set(ne.prefix,se)}}const ee={units:q,byToken:N,byPrefix:Q,decimal:q.filter(ne=>!ne.binary&&ne.auto),binary:q.some(ne=>ne.binary)?q.filter(ne=>(ne.binary||ne.factor===1)&&ne.auto):null};return X.set(U,ee),ee}function g(x,U){return U&&x.binary||x.decimal}function a(x,U){const _=f(x);if(!_||T(U))return null;const W=_.units.find(N=>N.symbol===String(U));if(W)return W;const q=_.byToken.get(String(U).trim().toLowerCase());return q&&q!==L?q:null}const r=new WeakMap;function i(x){const U=x||{};if(typeof U=="object"&&U!==null){const N=r.get(U);if(N!==void 0)return N}const _=U.system||"data",W=f(_);let q=null;if(!W)D(`unit:system:${_}`,`unknown unit system "${_}"; known systems are ${k().join(", ")}`);else{let N=U.unit?a(_,U.unit):null;N||(U.unit&&D(`unit:unit:${_}:${U.unit}`,`unknown unit "${U.unit}" in system "${_}"; falling back to ${W.units[0].symbol}`),N=W.units.find(Q=>Q.factor===1)||W.units[0]),q={index:W,base:N,binary:U.binary===!0}}return typeof U=="object"&&U!==null&&r.set(U,q),q}const c=new WeakMap;function u(x,U){if(!x||!U||!Array.isArray(x.compound)||x.compound.length===0)return null;const _=c.get(x);if(_!==void 0)return _;const W=new Set,q=[];for(const Q of x.compound){const J=a(x.system||"data",Q);if(!J){D(`unit:compound:${x.system}:${Q}`,`unknown compound unit "${Q}" in system "${x.system||"data"}"; ignoring it`);continue}W.has(J.symbol)||(W.add(J.symbol),q.push(J))}q.sort((Q,J)=>J.factor-Q.factor);const N=q.length>=2?q:null;return c.set(x,N),N}function n(x,U,_){return U===_||U.factor===_.factor?x:x*U.factor/_.factor}const m=new Map;function t(x){const U=x||"",_=m.get(U);if(_)return _;const W={group:",",decimal:"."};try{for(const q of new Intl.NumberFormat(x||void 0).formatToParts(12345.6))q.type==="group"?W.group=q.value:q.type==="decimal"&&(W.decimal=q.value)}catch{}return m.set(U,W),W}const s=/[\s ]/g,h=/^[+-]?[\d '’ .,]*(?:[eE][+-]?\d+)?/,d=/^[^\d+\-(.,\s]+\s*/,o=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function b(x,U){const{group:_,decimal:W}=t(U);let q=String(x).replace(s,"");if(q==="")return null;const N=W?q.indexOf(W):-1;if(_&&_!==W){if(N>=0&&q.indexOf(_,N+W.length)>=0)return null;q=q.split(_).join("")}if(W&&W!=="."&&(q=q.split(W).join(".")),!o.test(q))return null;const Q=Number(q);return Number.isFinite(Q)?Q:null}function l(x,U,_){const W=String(x).trim().replace(/\.$/,"");if(W==="")return null;const q=U.units.find(se=>se.symbol===W);if(q)return q;const N=W.toLowerCase(),Q=U.byToken.get(N);if(Q===L)return null;if(Q)return Q;const J=U.byPrefix.get(N);if(!J||!J.length)return null;const ee=g(U,_),ne=J.filter(se=>ee.includes(se));return ne.length===1?ne[0]:null}function p(x,U,_,W){let q=x,N=0,Q=!1,J=!1;for(;q!=="";){const ee=h.exec(q)[0];if(ee==="")return null;const ne=b(ee,W&&W.locale);if(ne===null)return null;q=q.slice(ee.length).trim();const se=q.search(/[+-]?[\d]/),le=(se>=0?q.slice(0,se):q).trim();if(q=se>=0?q.slice(se).trim():"",le===""){if(Q)return null;J=!0,N+=n(ne,_[0],U.base)}else{const ye=l(le,U.index,U.binary);if(!ye)return null;N+=n(ne,ye,U.base)}if(Q=!0,J&&q!=="")return null}return Q?N:null}function w(x,U){if(T(x))return null;if(typeof x=="number")return Number.isFinite(x)?x:null;const _=i(U);if(!_)return null;let W=String(x).trim();if(W==="")return null;let q=!1;W.startsWith("(")&&W.endsWith(")")&&(q=!0,W=W.slice(1,-1).trim());const N=u(U,_);if(N){W.startsWith("-")&&(q=!0,W=W.slice(1).trim());const fe=p(W,_,N,U);return fe===null?null:q?-fe:fe}let Q=null;const J=d.exec(W);if(J&&J[0]){const fe=l(J[0].trim(),_.index,_.binary);fe&&(Q=fe,W=W.slice(J[0].length).trim())}const ee=h.exec(W)[0],ne=b(ee,U&&U.locale);if(ne===null)return null;const se=W.slice(ee.length).trim();if(Q&&se!=="")return null;const le=Q||(se===""?_.base:l(se,_.index,_.binary));if(!le)return null;const ye=n(ne,le,_.base);return q?-ye:ye}const v=new Map;function R(x,U,_,W){const q=`${x||""}|${U}|${_}|${W?1:0}`;let N=v.get(q);return N||(N=new Intl.NumberFormat(x||void 0,{minimumFractionDigits:U,maximumFractionDigits:_,useGrouping:W}),v.set(q,N)),N}function Y(x,U){if(!Number.isFinite(x)||x===0)return Math.max(0,U-1);const _=Math.floor(Math.log10(Math.abs(x)));return Math.min(20,Math.max(0,U-1-_))}function K(x,U){if(!Number.isFinite(x)||x===0)return x;const _=Math.ceil(Math.log10(Math.abs(x))),W=10**(U-_);return Math.round(x*W)/W}function V(x,U,_){if(!_||_===U.base.symbol)return U.base;if(_!=="auto")return E(U,_);if(x===0||!Number.isFinite(x))return U.base;const W=Math.abs(x)*U.base.factor,q=g(U.index,U.binary);let N=q[0];for(const ee of q)W>=ee.factor&&(N=ee);if(W>=N.factor)return N;let Q=N;for(const ee of U.index.units)ee.binary!==U.binary&&ee.factor!==1||ee.factor<=W&&ee.factor>(Q===N?0:Q.factor)&&(Q=ee);if(Q!==N)return Q;let J=N;for(const ee of U.index.units)ee.binary!==U.binary&&ee.factor!==1||ee.factor<J.factor&&(J=ee);return J.factor<U.base.factor?J:U.base}function E(x,U){const _=x.index.units.find(q=>q.symbol===U);if(_)return _;const W=x.index.byToken.get(String(U).toLowerCase());return W&&W!==L?W:(D(`unit:display:${U}`,`unknown display unit "${U}"; rendering in ${x.base.symbol}`),x.base)}function O(x,U,_,W){const q=x<0;let N=Math.abs(x)*U.base.factor;const Q=typeof W.decimals=="number"?W.decimals:W.minDecimals??0,J=typeof W.decimals=="number"?W.decimals:W.maxDecimals??Math.max(Q,2),ee=W.space??" ",ne=[];for(let le=0;le<_.length;le++){const ye=_[le],fe=le===_.length-1;let we=fe?N/ye.factor:Math.floor(N/ye.factor);if(N-=we*ye.factor,fe){const Ce=10**J;we=Math.round(we*Ce)/Ce+0}const ke=fe?R(W.locale,Q,J,W.group!==!1):R(W.locale,0,0,W.group!==!1);ne.push(`${ke.format(we)}${ee}${ye.symbol}`)}const se=ne.join(" ");return q?`-${se}`:se}function C(x,U){const _=U||{},W=_.nullDisplay??"";if(T(x)||x==="")return W;const q=typeof x=="number"?x:Number(x);if(!Number.isFinite(q))return W;const N=i(_);if(!N)return String(q);const Q=u(_,N);if(Q)return O(q,N,Q,_);const J=typeof _.significantFigures=="number"&&_.significantFigures>0?_.significantFigures:0,ee=J?K(q,J):q,ne=V(ee,N,_.display),se=n(ee,N.base,ne);let le=typeof _.decimals=="number"?_.decimals:_.minDecimals??0,ye=typeof _.decimals=="number"?_.decimals:_.maxDecimals??Math.max(le,2);J&&(le=Y(se,J),ye=le);const fe=R(_.locale,le,ye,_.group!==!1).format(se),we=_.space??" ";return _.placement==="prefix"?`${ne.symbol}${_.space??""}${fe}`:`${fe}${we}${ne.symbol}`}function S(x,U){const _=T(x)||Number.isNaN(x)?null:Number(x),W=T(U)||Number.isNaN(U)?null:Number(U);return _===null||Number.isNaN(_)?W===null||Number.isNaN(W)?0:1:W===null||Number.isNaN(W)||_<W?-1:_>W?1:0}function F(x){const U=typeof x.decimals=="number"&&x.decimals>0?`.${"0".repeat(x.decimals)}`:"";return`${typeof x.decimals=="number"?`#,##0${U}`:"#,##0.##"}" ${x.symbol}"`}function P(x){const U={system:"data",...x||{}},_=i(U),W=_?_.base.symbol:String(U.unit||""),q=Object.freeze({...U,unit:W}),N=Object.freeze({...q,display:W,decimals:void 0,minDecimals:0,maxDecimals:20,group:!1}),Q=new Map([[q.locale||"",q]]),J=ee=>{const ne=ee||"";let se=Q.get(ne);return se||(se=Object.freeze({...q,locale:ee||void 0}),Q.set(ne,se)),se};return{base:"number",extends:"number",storage:"float64",unitConfig:q,format:ee=>C(ee.value,ee.locale?J(ee.locale):q),parse:ee=>w(ee.text,ee.locale?J(ee.locale):q),compare:S,defaults:{filter:"number",editor:"unit",align:"end",total:U.total||"sum"},...U.totals?{totals:U.totals}:{},excel:U.excel||F({decimals:U.decimals,symbol:W}),toStorage:ee=>typeof ee=="number"?Number.isFinite(ee)?ee:null:typeof ee=="string"?w(ee,q):T(ee)?null:w(String(ee),q),toClipboard:ee=>C(ee,N),fromClipboard:ee=>w(ee,q)}}const M=P}),Ue("packages/core/src/columns/types/engineering.js",function(e,B){"use strict";Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return I}});const T=B("packages/core/src/internal/predicates.js").isNil,D=B("packages/core/src/columns/types/unit.js").createUnitType;function I(L){const X=2*Math.PI/L;return $=>{let A=0,k=0,y=0;for(const g of $||[]){if(T(g))continue;const a=Number(g);Number.isFinite(a)&&(A+=Math.cos(a*X),k+=Math.sin(a*X),y+=1)}return!y||Math.hypot(A,k)/y<1e-12?null:(Math.atan2(k,A)/X%L+L)%L}}function Z(L){return{supported:["sum","avg","min","max","count","countValues"],implement:{avg:I(L)}}}const z=Object.freeze({metres:D({system:"length",unit:"m",display:"auto",maxDecimals:3}),millimetres:D({system:"length",unit:"mm",maxDecimals:2}),kilometres:D({system:"length",unit:"km",maxDecimals:3}),grams:D({system:"mass",unit:"g",display:"auto",maxDecimals:3}),kilograms:D({system:"mass",unit:"kg",maxDecimals:3}),tonnes:D({system:"mass",unit:"t",maxDecimals:3}),seconds:D({system:"duration",unit:"s",display:"auto",maxDecimals:3}),milliseconds:D({system:"duration",unit:"ms",maxDecimals:3}),hours:D({system:"duration",unit:"h",maxDecimals:2}),speed:D({system:"speed",unit:"m/s",display:"auto",maxDecimals:2}),kph:D({system:"speed",unit:"km/h",maxDecimals:1}),mph:D({system:"speed",unit:"mph",maxDecimals:1}),knots:D({system:"speed",unit:"kn",maxDecimals:1}),acceleration:D({system:"acceleration",unit:"m/s²",maxDecimals:3}),area:D({system:"area",unit:"m²",display:"auto",maxDecimals:2}),hectares:D({system:"area",unit:"ha",maxDecimals:4}),volume:D({system:"volume",unit:"L",display:"auto",maxDecimals:3}),cubicMetres:D({system:"volume",unit:"m³",maxDecimals:3}),energy:D({system:"energy",unit:"J",display:"auto",maxDecimals:3}),kilowattHours:D({system:"energy",unit:"kWh",maxDecimals:2}),power:D({system:"power",unit:"W",display:"auto",maxDecimals:2}),kilowatts:D({system:"power",unit:"kW",maxDecimals:2}),force:D({system:"force",unit:"N",display:"auto",maxDecimals:2}),pressure:D({system:"pressure",unit:"Pa",display:"auto",maxDecimals:2}),bar:D({system:"pressure",unit:"bar",maxDecimals:3}),psi:D({system:"pressure",unit:"psi",maxDecimals:1}),torque:D({system:"torque",unit:"N·m",maxDecimals:2}),density:D({system:"density",unit:"kg/m³",maxDecimals:2}),flow:D({system:"flow",unit:"m³/s",maxDecimals:4}),litresPerMinute:D({system:"flow",unit:"L/min",maxDecimals:1}),radians:D({system:"angle",unit:"rad",maxDecimals:4,totals:Z(2*Math.PI)}),degrees:D({system:"angle",unit:"°",maxDecimals:2,totals:Z(360)}),rpm:D({system:"angularVelocity",unit:"rpm",maxDecimals:0}),angularVelocity:D({system:"angularVelocity",unit:"rad/s",maxDecimals:3}),ppm:D({system:"fraction",unit:"ppm",maxDecimals:2}),ppb:D({system:"fraction",unit:"ppb",maxDecimals:2}),basisPoints:D({system:"fraction",unit:"bp",maxDecimals:1}),molarity:D({system:"molarity",unit:"M",display:"auto",maxDecimals:3}),massFlow:D({system:"massFlow",unit:"kg/s",maxDecimals:3}),tonnesPerHour:D({system:"massFlow",unit:"t/h",maxDecimals:2}),viscosity:D({system:"viscosity",unit:"Pa·s",display:"auto",maxDecimals:3}),kinematicViscosity:D({system:"kinematicViscosity",unit:"cSt",maxDecimals:2}),thermalConductivity:D({system:"thermalConductivity",unit:"W/(m·K)",maxDecimals:3}),specificHeat:D({system:"specificHeat",unit:"J/(kg·K)",maxDecimals:1}),doseRate:D({system:"doseRate",unit:"µSv/h",display:"auto",maxDecimals:2})})}),Ue("packages/core/src/columns/types/si.js",function(e,B){"use strict";Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return A}});const re=B("packages/core/src/columns/types/unit.js"),T=re.defineUnit,G=re.registerUnitSystem,D=re.createUnitType,I=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 z(k){const y=String(k.base),f=new Set([...k.prefixes||Z,""]),g=[];for(const a of I){if(!f.has(a.symbol))continue;const r=`${a.symbol}${y}`,i=[];if(k.name){i.push(`${a.name}${k.name}`,`${a.name}${k.name}s`);const c=a.name.slice(-1);if(c&&k.name.startsWith(c)){const u=`${a.name.slice(0,-1)}${k.name}`;i.push(u,`${u}s`)}}a.symbol==="µ"&&i.push(`u${y}`),a.factor===1&&k.aliases&&i.push(...k.aliases),g.push(T(r,a.factor,i))}for(const a of k.extra||[])g.push(a);return g}function L(k,y){const f=z(y);return G(k,f)}function X(k,y,f){return L(k,y),D({system:k,unit:y.base,display:"auto",maxDecimals:3,...f||{}})}const $=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:[T("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),T("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:[T("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:[T("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:X("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),A=X}),Ue("packages/core/src/columns/types/temperature.js",function(e,B){"use strict";Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return f}});const T=B("packages/core/src/internal/predicates.js").isNil,G=Object.freeze({C:Object.freeze({symbol:"°C",aliases:["c","°c","celsius","centigrade"],toKelvin:g=>g+273.15,fromKelvin:g=>g-273.15}),F:Object.freeze({symbol:"°F",aliases:["f","°f","fahrenheit"],toKelvin:g=>(g+459.67)*(5/9),fromKelvin:g=>g*(9/5)-459.67}),K:Object.freeze({symbol:"K",aliases:["k","kelvin"],toKelvin:g=>g,fromKelvin:g=>g}),R:Object.freeze({symbol:"°R",aliases:["r","°r","rankine"],toKelvin:g=>g*(5/9),fromKelvin:g=>g*(9/5)})});function D(g){if(T(g))return null;const a=String(g).trim();if(a==="")return null;for(const[i,c]of Object.entries(G))if(a===i||a===c.symbol)return{key:i,scale:c};const r=a.toLowerCase();for(const[i,c]of Object.entries(G))if(c.aliases.includes(r))return{key:i,scale:c};return null}function I(g,a,r){const i=D(a),c=D(r);return!i||!c||!Number.isFinite(Number(g))?null:i.key===c.key?Number(g):c.scale.fromKelvin(i.scale.toKelvin(Number(g)))}const Z=new Map;function z(g,a,r){const i=`${g||""}|${a}|${r}`;let c=Z.get(i);return c||(c=new Intl.NumberFormat(g||void 0,{minimumFractionDigits:a,maximumFractionDigits:r}),Z.set(i,c)),c}function L(g,a){const r=a||{},i=r.nullDisplay??"";if(T(g)||g==="")return i;const c=Number(g);if(!Number.isFinite(c))return i;const u=D(r.scale||"C");if(!u)return String(c);const n=D(r.display||r.scale||"C")||u,m=n.key===u.key?c:n.scale.fromKelvin(u.scale.toKelvin(c)),t=typeof r.decimals=="number"?r.decimals:null,s=t??r.minDecimals??0,h=t??r.maxDecimals??1;return`${z(r.locale,s,h).format(m)}${r.space??" "}${n.scale.symbol}`}const X=/^[+-]?[\d\s., ]*\d/;function $(g,a){const r=String(g).trim();if(r==="")return null;const i=new Intl.NumberFormat(a||void 0).formatToParts(1.1).find(m=>m.type==="decimal")?.value||".",c=i===","?".":",",u=r.split(c).join("").split(/[\s ]/).join("").replace(i,"."),n=Number(u);return Number.isFinite(n)?n:null}function A(g,a){if(T(g))return null;const r=a||{},i=D(r.scale||"C");if(!i)return null;if(typeof g=="number")return Number.isFinite(g)?g:null;let c=String(g).trim();if(c==="")return null;let u=!1;c.startsWith("(")&&c.endsWith(")")&&(u=!0,c=c.slice(1,-1).trim());const n=X.exec(c);if(!n)return null;const m=$(n[0],r.locale);if(m===null)return null;const t=c.slice(n[0].length).trim();if(t==="")return u?-m:m;const s=D(t);if(!s)return null;const h=s.key===i.key?m:i.scale.fromKelvin(s.scale.toKelvin(m));return u?-h:h}function k(g){const a=Object.freeze({scale:"C",...g||{}}),i=(D(a.scale)||D("C")).scale.symbol,c=Object.freeze({...a,display:a.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),u=new Map([[a.locale||"",a]]),n=m=>{const t=m||"";let s=u.get(t);return s||(s=Object.freeze({...a,locale:m||void 0}),u.set(t,s)),s};return{base:"number",extends:"number",storage:"float64",temperatureConfig:a,format:m=>L(m.value,m.locale?n(m.locale):a),parse:m=>A(m.text,m.locale?n(m.locale):a),defaults:{filter:"number",editor:"temperature",align:"end",total:"avg"},totals:{supported:["avg","min","max","count","countValues"]},excel:a.excel||`#,##0${typeof a.decimals=="number"&&a.decimals>0?`.${"0".repeat(a.decimals)}`:".#"}" ${i}"`,toStorage:m=>typeof m=="number"?Number.isFinite(m)?m:null:typeof m=="string"?A(m,a):T(m)?null:A(String(m),a),toClipboard:m=>L(m,c),fromClipboard:m=>A(m,a)}}const y=Object.freeze({celsius:k({scale:"C"}),fahrenheit:k({scale:"F"}),kelvin:k({scale:"K"})}),f=k}),Ue("packages/core/src/columns/types/radix.js",function(e,B){"use strict";Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"digitsForWidth",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"radixRange",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"radixName",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"normaliseRadixOptions",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"compileRadixFormat",{enumerable:!0,get:function(){return p}}),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 R}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return O}});const T=B("packages/core/src/internal/predicates.js").isNil,D=B("packages/core/src/internal/warn.js").warnOnce,I=Object.freeze({2:2,8:8,16:16,bin:2,binary:2,base2:2,oct:8,octal:8,base8:8,hex:16,hexadecimal:16,base16:16}),Z=Object.freeze({2:1,8:3,16:4}),z=Object.freeze({2:"0b",8:"0o",16:"0x"}),L=Object.freeze({2:4,8:3,16:2}),X=Object.freeze({2:/^[01]+$/,8:/^[0-7]+$/,16:/^[0-9a-f]+$/i}),$=Object.freeze({2:"binary",8:"octal",16:"hexadecimal"}),A=Object.freeze([[/^0x/i,16],[/^0b/i,2],[/^0o/i,8],[/^#/,16]]),k=/[\s\u00a0\u202f_,']/g,y=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,f=Object.freeze([8,16,32,53]),g=new WeakSet,a=new WeakMap,r=new Map,i=new WeakMap,c=new WeakMap,u=Object.freeze({hex:Object.freeze({radix:16}),hex8:Object.freeze({radix:16,bitWidth:8,pad:!0,signed:!1}),hex16:Object.freeze({radix:16,bitWidth:16,pad:!0,signed:!1}),hex32:Object.freeze({radix:16,bitWidth:32,pad:!0,signed:!1}),binary:Object.freeze({radix:2}),binary8:Object.freeze({radix:2,bitWidth:8,pad:!0,signed:!1,group:4}),octal:Object.freeze({radix:8})});function n(C){if(C==null)return 16;const S=typeof C=="string"?C.toLowerCase():C,F=I[S];return F||(D(`radix:base:${String(C)}`,`unsupported radix ${String(C)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function m(C,S){return Math.ceil(C/Z[S])}function t(C,S){if(!C)return S?{min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}:{min:0,max:Number.MAX_SAFE_INTEGER};if(!S)return{min:0,max:2**C-1};const F=2**(C-1);return{min:-F,max:F-1}}function s(C){return $[C]||"hexadecimal"}function h(C){if(typeof C=="string"){const S=u[C];return S||D(`radix:preset:${C}`,`unknown radix preset "${C}"; known presets are ${Object.keys(u).join(", ")}`),{...S||{}}}if(C&&typeof C.preset=="string"){const S=u[C.preset];return S||D(`radix:preset:${C.preset}`,`unknown radix preset "${C.preset}"; known presets are ${Object.keys(u).join(", ")}`),{...S||{},...C}}return C||{}}function d(C){const S=h(C),F=n(S.radix),P=Z[F];let M=null;if(S.bitWidth!==void 0&&S.bitWidth!==null&&S.bitWidth!==!1){const ee=Number(S.bitWidth);f.includes(ee)?M=ee:D(`radix:width:${String(S.bitWidth)}`,`unsupported bitWidth ${String(S.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let x=S.signed!==!1;!x&&M===null&&(D("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),M=32);const U=S.prefix===void 0||S.prefix===!0?z[F]:S.prefix===!1?"":String(S.prefix);let _=0;S.pad===!0?_=M?m(M,F):0:typeof S.pad=="number"&&S.pad>0&&(_=Math.floor(S.pad));let W=0;S.group===!0?W=L[F]:typeof S.group=="number"&&S.group>0&&(W=Math.floor(S.group));const q=t(M,x),N=typeof S.min=="number"?Math.max(q.min,S.min):q.min,Q=typeof S.max=="number"?Math.min(q.max,S.max):q.max,J=Object.freeze({radix:F,bits:P,prefix:U,uppercase:S.uppercase!==!1,pad:_,group:W,groupSeparator:typeof S.groupSeparator=="string"?S.groupSeparator:" ",bitWidth:M,signed:x,min:N,max:Q<N?N:Q,nullDisplay:typeof S.nullDisplay=="string"?S.nullDisplay:"",name:s(F)});return g.add(J),J}function o(C){if(C&&g.has(C))return C;if(typeof C=="string"){let S=r.get(C);return S||(S=d(C),r.set(C,S)),S}if(C&&typeof C=="object"){let S=a.get(C);return S||(S=d(C),a.set(C,S)),S}return o("hex")}function b(C){return C<0?-Math.round(-C):Math.round(C)}function l(C,S,F){if(S<=0||C.length<=S)return C;const P=C.length%S||S,M=[C.slice(0,P)];for(let x=P;x<C.length;x+=S)M.push(C.slice(x,x+S));return M.join(F)}function p(C){const S=o(C),{radix:F,prefix:P,uppercase:M,pad:x,group:U,groupSeparator:_,signed:W,bitWidth:q,nullDisplay:N}=S,Q=q?2**q:0,J=ee=>{if(T(ee)||ee==="")return N;const ne=typeof ee=="number"?ee:Number(ee);if(!Number.isFinite(ne))return N;const se=b(ne);let le="",ye=se;se<0&&(W?(le="-",ye=-se):ye=(se%Q+Q)%Q);let fe=ye.toString(F);return fe=M?fe.toUpperCase():fe.toLowerCase(),x>0&&fe.length<x&&(fe=fe.padStart(x,"0")),U>0&&(fe=l(fe,U,_)),le+P+fe};return J.options=S,J}function w(C,S){const F=o(S);let P=i.get(F);return P||(P=p(F),i.set(F,P)),P(C)}function v(C){const S=o(C),{radix:F,groupSeparator:P,signed:M,min:x,max:U}=S,_=X[F],W=q=>{if(T(q))return{ok:!0,value:null,reason:"blank"};let N=String(q);if(P&&P!==""&&(N=N.split(P).join("")),N=N.replace(k,""),N==="")return{ok:!0,value:null,reason:"blank"};let Q=!1;if((N[0]==="-"||N[0]==="+")&&(Q=N[0]==="-",N=N.slice(1)),N==="")return{ok:!1,value:null,reason:"digits"};let J=null;for(const[ne,se]of A){const le=ne.exec(N);if(!le)continue;const ye=N.slice(le[0].length);if(ye==="")break;if(!X[se].test(ye))return{ok:!1,value:null,reason:"digits"};J=parseInt(ye,se);break}if(J===null)if(_.test(N))J=parseInt(N,F);else if(y.test(N))J=Number(N);else return{ok:!1,value:null,reason:"digits"};if(!Number.isFinite(J))return{ok:!1,value:null,reason:"digits"};const ee=b(Q?-J:J);return!M&&ee<0?{ok:!1,value:ee,reason:"negative"}:ee<x||ee>U?{ok:!1,value:ee,reason:"range"}:{ok:!0,value:ee,reason:"ok"}};return W.options=S,W}function R(C,S){const F=o(S);let P=c.get(F);return P||(P=v(F),c.set(F,P)),P(C)}function Y(C,S){const F=R(C,S);return F.ok?F.value:null}function K(C,S){const F=T(C)||Number.isNaN(C)?null:Number(C),P=T(S)||Number.isNaN(S)?null:Number(S);return F===null?P===null?0:1:P===null||F<P?-1:F>P?1:0}function V(C){const S=C.min>=-2147483648&&C.max<=2147483647;return C.bitWidth&&S?"int32":"float64"}function E(C){const S=d(C),F=p(S),P=v(S);return{base:"number",extends:"number",storage:V(S),matches:null,format:M=>F(M.value),parse:M=>{const x=P(M.text);return x.ok?x.value:null},compare:K,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:M=>F(M),fromClipboard:M=>{const x=P(M);return x.ok?x.value:null},radix:S,formatValue:F,parseText:P}}const O=E}),Ue("packages/core/src/columns/types/aggregable.js",function(e,B){"use strict";Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return L}}),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 D}}),Object.defineProperty(e,"logarithmicMean",{enumerable:!0,get:function(){return I}});const T=B("packages/core/src/internal/predicates.js").isNil;function G($){const A=[];for(const k of $||[]){if(T(k))continue;const y=Number(k);Number.isFinite(y)&&A.push(y)}return A}function D($){return A=>{const k=G(A);if(!k.length)return null;let y=0;for(const f of k)y+=10**(f/$);return $*Math.log10(y)}}function I($){return A=>{const k=G(A);if(!k.length)return null;let y=0;for(const f of k)y+=10**(f/$);return $*Math.log10(y/k.length)}}function Z($,A){const k=A&&A.column,f=(k&&k.typeOptions||{}).weight,g=A&&A.valueAt;if(!f||typeof g!="function")return null;let a=0,r=0;for(let i=0;i<$.length;i++){if(T($[i]))continue;const c=Number($[i]);if(!Number.isFinite(c))continue;const u=g(f,i);if(T(u))continue;const n=Number(u);!Number.isFinite(n)||n<=0||(a+=c*n,r+=n)}return r===0?null:a/r}function z($={}){const A=$.factor===20?20:10,k=typeof $.suffix=="string"?$.suffix:"",y=Number.isInteger($.decimals)?$.decimals:1;return{base:"number",storage:"float64",name:$.name||"logarithmic",format:f=>{const g=f&&f.value;return T(g)||!Number.isFinite(Number(g))?"":`${Number(g).toFixed(y)}${k}`},parse:f=>{const g=String((f&&f.text)??"").replace(k,"").trim();if(!g)return null;const a=Number(g);return Number.isFinite(a)?a:null},defaults:{align:"end",filter:"number"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:{sum:D(A),avg:I(A)}}}}function L($={}){const A=Number.isInteger($.decimals)?$.decimals:1,k=$.percent===!0;return{base:"number",storage:"float64",name:$.name||"ratio",format:y=>{const f=y&&y.value;return T(f)||!Number.isFinite(Number(f))?"":k?`${Number(f).toFixed(A)}%`:Number(f).toFixed(A)},parse:y=>{const f=String((y&&y.text)??"").replace("%","").trim();if(!f)return null;const g=Number(f);return Number.isFinite(g)?g:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:Z}}}}const X=Object.freeze({decibel:z({name:"decibel",factor:10,suffix:" dB"}),decibelAmplitude:z({name:"decibelAmplitude",factor:20,suffix:" dB"}),ratio:L({name:"ratio"}),percentRate:L({name:"percentRate",percent:!0})})}),Ue("packages/core/src/columns/types/currency.js",function(e,B){"use strict";Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"moneyToText",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const T=B("packages/core/src/internal/predicates.js").isNil,G="⚠ no rate";function D(m){if(T(m))return null;const t=String(m).trim().toUpperCase();return t===""?null:t}function I(m){if(T(m))return null;if(typeof m=="object"&&!Array.isArray(m)){const t=Number(m.amount),s=D(m.code);return!s||!Number.isFinite(t)?null:{amount:t,code:s}}if(Array.isArray(m)&&m.length===2){const t=Number(m[0]),s=D(m[1]);return!s||!Number.isFinite(t)?null:{amount:t,code:s}}return null}const Z=Object.freeze({$:"USD","€":"EUR","£":"GBP","¥":"JPY","₹":"INR","₩":"KRW","₽":"RUB","₺":"TRY","₴":"UAH","₪":"ILS"}),z=Object.freeze({USD:"$",EUR:"€",GBP:"£",JPY:"¥",INR:"₹",KRW:"₩",RUB:"₽",TRY:"₺",UAH:"₴",ILS:"₪"}),L=/[+-]?[\d\s., ]*\d/;function X(m,t){const s=String(m).trim();if(s==="")return null;const h=new Intl.NumberFormat(t||void 0).formatToParts(1.1).find(l=>l.type==="decimal")?.value||".",d=h===","?".":",",o=s.split(d).join("").split(/[\s ]/).join("").replace(h,"."),b=Number(o);return Number.isFinite(b)?b:null}function $(m,t){const s=t||{},h=D(s.code);if(T(m))return null;const d=I(m);if(d)return d;if(typeof m=="number")return Number.isFinite(m)&&h?{amount:m,code:h}:null;let o=String(m).trim();if(o==="")return null;let b=!1;o.startsWith("(")&&o.endsWith(")")&&(b=!0,o=o.slice(1,-1).trim());let l=null;for(const[K,V]of Object.entries(Z)){if(o.startsWith(K)){l=V,o=o.slice(K.length).trim();break}if(o.endsWith(K)){l=V,o=o.slice(0,-K.length).trim();break}}const p=L.exec(o);if(!p)return null;const w=X(p[0],s.locale);if(w===null)return null;const v=(o.slice(0,p.index)+" "+o.slice(p.index+p[0].length)).trim();!l&&v!==""&&(l=D(v));const R=l||h;return R?{amount:b?-w:w,code:R}:null}function A(m,t){if(typeof m=="function")return(s,h)=>{if(s===h)return 1;const d=m(s,h);return typeof d=="number"&&Number.isFinite(d)&&d>0?d:null};if(m&&typeof m=="object"){const s=m;return(h,d)=>{if(h===d)return 1;const o=Number(s[h]),b=Number(s[d]);return!Number.isFinite(o)||!Number.isFinite(b)||o<=0||b<=0?null:b/o}}return(s,h)=>s===h?1:null}function k(m,t,s){if(!m)return null;if(m.code===t)return m.amount;const h=s(m.code,t);return h===null?null:m.amount*h}const y=new Map;function f(m,t,s){const h=`${m||""}|${t}|${s??""}`;let d=y.get(h);if(!d){const o={style:"currency",currency:t};typeof s=="number"&&(o.minimumFractionDigits=s,o.maximumFractionDigits=s);try{d={fmt:new Intl.NumberFormat(m||void 0,o),currency:!0}}catch{d={fmt:new Intl.NumberFormat(m||void 0,typeof s=="number"?{minimumFractionDigits:s,maximumFractionDigits:s}:{}),currency:!1}}y.set(h,d)}return d}function g(m,t){const s=t||{},h=s.nullDisplay??"",d=I(m);if(!d)return h;const o=D(s.display)||d.code;let b=d.amount,l=d.code;if(o!==d.code){const v=s.rateFn||A(s.rates,s.rateBase),R=k(d,o,v);if(R===null)return`${s.missingRate??G} ${d.code}→${o}`;b=R,l=o}const{fmt:p,currency:w}=f(s.locale,l,s.decimals);return w?p.format(b):`${p.format(b)} ${l}`}function a(m){const t=I(m);return t?`${t.amount} ${t.code}`:""}function r(m){const t=m||{},s=D(t.display),h=t.rateFn||A(t.rates,t.rateBase);return(d,o)=>{const b=I(d),l=I(o);if(!b&&!l)return 0;if(!b)return 1;if(!l)return-1;if(s){const p=k(b,s,h),w=k(l,s,h);if(p!==null&&w!==null)return p===w?0:p<w?-1:1}return b.code===l.code?b.amount===l.amount?0:b.amount<l.amount?-1:1:b.code<l.code?-1:1}}function i(m){const t=m||{},s=(d,o)=>{const b=[];for(const R of d||[]){const Y=I(R);Y&&b.push(Y)}if(!b.length)return null;if(new Set(b.map(R=>R.code)).size===1){const R=b[0].code;return{amount:o(b.map(Y=>Y.amount)),code:R}}const p=D(t.display);if(!p)return`${t.missingRate??G}: mixed currencies, no display currency set`;const w=t.rateFn||A(t.rates,t.rateBase),v=[];for(const R of b){const Y=k(R,p,w);if(Y===null)return`${t.missingRate??G}: ${R.code}→${p}`;v.push(Y)}return{amount:o(v),code:p}},h=d=>d.reduce((o,b)=>o+b,0);return{sum:d=>s(d,h),avg:d=>s(d,o=>h(o)/o.length),min:d=>s(d,o=>Math.min(...o)),max:d=>s(d,o=>Math.max(...o))}}function c(m){const t=Object.freeze({code:"USD",...m||{}}),s=A(t.rates,t.rateBase),h=Object.freeze({...t,rateFn:s}),d=i(h),o=r(h),b=new Map([[t.locale||"",h]]),l=v=>{const R=v||"";let Y=b.get(R);return Y||(Y=Object.freeze({...h,locale:v||void 0}),b.set(R,Y)),Y},p=z[D(t.display||t.code)]||"",w=typeof t.decimals=="number"&&t.decimals>0?`.${"0".repeat(t.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:h,format:v=>g(v.value,v.locale?l(v.locale):h),parse:v=>$(v.text,v.locale?l(v.locale):h),compare:o,defaults:{filter:"number",editor:"currency",align:"end",total:"sum"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:d},excel:t.excel||(p?`"${p}"#,##0${w}`:`#,##0${w}`),toStorage:v=>{const R=I(v);return R||(typeof v=="string"||typeof v=="number"?$(v,h):null)},toClipboard:v=>a(v),fromClipboard:v=>$(v,h)}}const u=Object.freeze({currency:c({code:"USD"}),usd:c({code:"USD"}),eur:c({code:"EUR"}),gbp:c({code:"GBP"}),jpy:c({code:"JPY",decimals:0})}),n=c}),Ue("packages/core/src/columns/types/index.js",function(e,B){"use strict";Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return K}});const re=B("packages/core/src/columns/types/temporal.js"),T=re.TEMPORAL_TYPES,G=B("packages/core/src/columns/types/network.js"),D=G.NETWORK_TYPES,I=B("packages/core/src/columns/types/structured.js"),Z=I.STRUCTURED_TYPES,z=B("packages/core/src/columns/types/unit.js"),L=z.createUnitType,X=z.UNIT_SYSTEMS,$=z.parseUnit,A=z.formatUnit,k=z.registerUnitSystem,y=z.unitSystemNames,f=z.unitsOf,g=z.defineUnit,a=B("packages/core/src/columns/types/engineering.js"),r=a.ENGINEERING_TYPES,i=B("packages/core/src/columns/types/si.js"),c=i.SI_TYPES,u=i.createSiType,n=i.createSiSystem,m=i.siUnits,t=i.SI_PREFIXES,s=B("packages/core/src/columns/types/temperature.js"),h=s.TEMPERATURE_TYPES,d=s.createTemperatureType,o=s.convertTemperature,b=s.formatTemperature,l=s.parseTemperature,p=s.TEMPERATURE_SCALES,w=B("packages/core/src/columns/types/radix.js"),v=w.createRadixType,R=w.RADIX_PRESETS,Y=w.parseRadix,K=w.formatRadix,V=B("packages/core/src/columns/types/aggregable.js"),E=V.AGGREGABLE_TYPES,O=B("packages/core/src/columns/types/currency.js"),C=O.CURRENCY_TYPES,S=O.createCurrencyType,F=O.parseMoney,P=O.formatMoney,M=O.convertMoney,x=O.toMoney,U=O.rateFunction,_=O.moneyComparator,W=O.normaliseCode,q=O.MISSING_RATE;Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return z.findUnit}}),Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return a.ENGINEERING_TYPES}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return a.circularMean}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return s.TEMPERATURE_TYPES}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return s.createTemperatureType}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return s.convertTemperature}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return s.formatTemperature}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return s.parseTemperature}}),Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return s.TEMPERATURE_SCALES}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return s.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 re.TEMPORAL_TYPES}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return G.NETWORK_TYPES}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return I.STRUCTURED_TYPES}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return V.AGGREGABLE_TYPES}}),Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return V.createLogarithmicType}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return V.createRatioType}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return re.parseTime}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return re.formatTime}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return re.parseDateTime}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return re.formatDateTime}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return re.parseDuration}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return re.formatDuration}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return G.parseIpv4}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return G.formatIpv4}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return G.parseCidr}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return G.formatCidr}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return G.parseIpv6}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return G.formatIpv6}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return G.networkAddress}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return G.broadcastAddress}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return G.hostCount}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return G.containsAddress}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return G.overlaps}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return I.maskValue}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return I.summariseJson}});const N=Object.freeze({...T,...D,...Z,...E,hex:v(R.hex),hex8:v(R.hex8),hex16:v(R.hex16),hex32:v(R.hex32),binary:v(R.binary),binary8:v(R.binary8),octal:v(R.octal),bytes:L({system:"data",unit:"B",display:"auto"}),megabytes:L({system:"data",unit:"MB"}),gigabytes:L({system:"data",unit:"GB"}),bitrate:L({system:"bitrate",unit:"Mbps"}),gigabits:L({system:"bitrate",unit:"Gbps"}),...r,...c,...h,...C});{const Q=new Set;for(const J of[T,D,Z,E,r,c,h,C])for(const ee of Object.keys(J)){if(Q.has(ee))throw new Error(`[lattice] data type "${ee}" is declared twice`);Q.add(ee)}}}),Ue("packages/core/src/compute/handle.js",function(e,B){"use strict";Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return c}});const re=B("packages/core/src/internal/compare.js"),T=re.collator,G=re.defaultCompare,I=B("packages/core/src/internal/warn.js").warnOnce;function Z(u){const n=new Uint32Array(u);for(let m=0;m<u;m++)n[m]=m;return n}function z(u,n){if(n&&typeof n.count=="number")return n.count;if(!u)return 0;if(typeof u.count=="number")return u.count;if(typeof u.length=="number")return u.length;const m=u.values;return u.kind==="multi"&&u.offsets?Math.max(0,u.offsets.length-1):m?u.kind==="bitset"?typeof m.size=="number"?m.size:u.presence&&typeof u.presence.size=="number"?u.presence.size:(I(`count:${u.id}`,`column "${u.id}" is bitset-backed with no declared row count; assuming ${m.length*8}`),m.length*8):m.length:u.presence&&typeof u.presence.size=="number"?u.presence.size:0}const L=new WeakMap;function X(u){const n=u.constructor;if(!n)return"unknown";const m=L.get(n);if(m)return m;let t="unknown";try{let s=null;typeof n.from=="function"?s=n.from([!1,!0]):(s=new n(8),s.set(1));const h=s&&s.words;h&&h.length&&(h[0]===2?t="lsb":h[0]===64&&(t="msb"))}catch{t="unknown"}return L.set(n,t),t}function $(u){if(!u)return()=>0;const n=u instanceof Uint8Array?u:u.words;if(n instanceof Uint8Array){const m=u instanceof Uint8Array?"lsb":X(u);if(m==="lsb")return t=>n[t>>>3]>>>(t&7)&1;if(m==="msb")return t=>n[t>>>3]>>>7-(t&7)&1}return typeof u.get=="function"?m=>u.get(m)?1:0:()=>0}function A(u){return!u||!u.presence?null:$(u.presence)}function k(u){return u?typeof u.size=="number"?u.size:typeof u.values=="function"?u.values().length:0:0}function y(u,n){return u?typeof u.valueOf=="function"?u.valueOf(n):typeof u.values=="function"?u.values()[n]:null:null}function f(u,n){const m=u.offsets,t=u.values;if(!m||!t)return[];const s=m[n],h=m[n+1];if(!(h>s))return[];const d=u.dict,o=new Array(h-s);for(let b=s;b<h;b++)o[b-s]=d?y(d,t[b]):t[b];return o}function g(u){if(!u)return()=>{};const n=u.values,m=A(u),t=u.kind;if(t==="dictionary"){const s=u.dict;return m?h=>m(h)?y(s,n[h]):null:h=>y(s,n[h])}if(t==="bitset"){const s=$(n);return m?h=>m(h)?s(h)===1:null:h=>s(h)===1}if(t==="multi")return m?s=>m(s)?f(u,s):null:s=>f(u,s);if(!n&&typeof u.get=="function"){const s=u.get.bind(u);return h=>{const d=s(h);return d===void 0?null:d}}return m?s=>{if(!m(s))return null;const h=n[s];return h===void 0?null:h}:s=>{const h=n[s];return h===void 0?null:h}}function a(u,n){if(u<n)return-1;if(u>n)return 1;if(u===n){const s=Object.is(u,-0),h=Object.is(n,-0);return s===h?0:s?-1:1}const m=Number.isNaN(u),t=Number.isNaN(n);return m&&t?0:m?1:-1}function r(u){const n=T(u);return(m,t)=>{if(m===t)return 0;const s=typeof m,h=typeof t;if(s==="string"&&h==="string")return n.compare(m,t);if(s==="number"&&h==="number")return a(m,t);if(s==="boolean"&&h==="boolean")return m===t?0:m?1:-1;if(m instanceof Date||t instanceof Date){const d=m instanceof Date?m.getTime():Number(m),o=t instanceof Date?t.getTime():Number(t);return a(d,o)}return G(m,t)}}function i(u,n){if(u&&typeof u.ranks=="function")return u.ranks(n);const m=u&&typeof u.values=="function"?u.values():[],t=m.length,s=r(n),h=new Array(t);for(let o=0;o<t;o++)h[o]=o;h.sort((o,b)=>s(m[o],m[b])||o-b);const d=new Uint32Array(t);for(let o=0;o<t;o++)d[h[o]]=o;return d}function c(u){return u==null||typeof u=="number"&&Number.isNaN(u)}}),Ue("packages/core/src/compute/filter.js",function(e,B){"use strict";Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"wallMs",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"itemwisePredicate",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"declareOperators",{enumerable:!0,get:function(){return le}}),Object.defineProperty(e,"declaredOperator",{enumerable:!0,get:function(){return ye}});const T=B("packages/core/src/internal/predicates.js").isBlank,D=B("packages/core/src/internal/merge.js").toArray,Z=B("packages/core/src/internal/warn.js").warnOnce,z=B("packages/core/src/format/date.js"),L=z.toDate,X=z.toIsoDate,$=B("packages/core/src/compute/handle.js"),A=$.bitReader,k=$.dictSize,y=$.dictValue,f=$.presenceReader,g=$.valueComparator,a=$.valueReader,r=/^\d{4}-\d{2}-\d{2}$/,i="\0null\0";function c(fe,we){const ke=fe&&fe.pool;if(ke){const Ce=ke.mask||ke.acquireMask||ke.acquire||ke.take;if(typeof Ce=="function"){const ce=Ce.call(ke,we);if(ce&&ce.length>=we)return ce}}return new Uint8Array(we)}function u(fe,we){const ke=fe&&fe.pool;if(!ke||!we)return;const Ce=ke.release||ke.releaseMask||ke.free||ke.recycle;typeof Ce=="function"&&Ce.call(ke,we)}function n(fe,we,ke){return fe.fill(ke,0,we),fe}function m(fe){return fe==null||typeof fe=="number"&&Number.isNaN(fe)}function t(fe,we){if(fe==null)return fe;if(we==="number")return typeof fe=="number"?fe:Number(fe);if(we==="date"||we==="dateString"){const ke=X(fe);return ke===null?s(fe):ke}return we==="boolean"?typeof fe=="boolean"?fe:fe==="true"||fe===1?!0:fe==="false"||fe===0?!1:!!fe:fe}function s(fe){return fe instanceof Date?fe.getTime():typeof fe=="number"?fe:Date.parse(String(fe))}function h(fe){return typeof fe=="number"?fe:fe instanceof Date?fe.getTime():fe==null||fe===""?NaN:Number(fe)}function d(fe,we){const ke=typeof fe=="string"?fe:String(fe);return we?ke:ke.toLowerCase()}function o(fe,we){return fe==null?i:typeof fe=="string"?we?fe:fe.toLowerCase():fe instanceof Date?fe.getTime():fe}function b(fe,we,ke){const Ce=new Set;for(const ce of D(fe)){const ae=t(ce,ke);Ce.add(o(ae,we)),typeof ae=="string"&&ae!==""&&Number.isFinite(Number(ae))?Ce.add(Number(ae)):typeof ae=="number"&&Number.isFinite(ae)&&Ce.add(o(String(ae),we))}return Ce}function l(fe,we,ke){if(fe==null||we===null||we===void 0)return fe==null&&we==null;const Ce=typeof fe,ce=typeof we;return Ce==="string"&&ce==="string"?ke?fe===we:fe.toLowerCase()===we.toLowerCase():fe instanceof Date||we instanceof Date?s(fe)===s(we):Ce==="number"&&ce==="number"?fe===we||Number.isNaN(fe)&&Number.isNaN(we):Ce==="number"&&ce==="string"?fe===Number(we):Ce==="string"&&ce==="number"?Number(fe)===we:Ce==="boolean"||ce==="boolean"?fe===we:Array.isArray(fe)&&Array.isArray(we)?fe.length===we.length&&fe.every((ae,ge)=>l(ae,we[ge],ke)):fe===we}function p(fe,we){try{if(fe instanceof RegExp){const ke=fe.flags.replace(/[gy]/g,"");return new RegExp(fe.source,we||ke.includes("i")?ke:`${ke}i`)}return new RegExp(String(fe),we?"":"i")}catch(ke){return Z(`regex:${String(fe)}`,`filter operator "matches" received an invalid pattern: ${String(fe)}`,ke),null}}function w(fe,we){if(fe&&fe.type==="datetime"&&v.has(fe.op))return E(fe,we);const ke=O(fe,we),Ce=fe&&fe.type;return Ce!=="date"&&Ce!=="dateString"?ke:ce=>ke(typeof ce=="string"&&r.test(ce)?ce:X(ce)??ce)}const v=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),R=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3})\d*)?)?)?$/,Y=new Map;function K(fe,we){let ke=Y.get(we);if(ke===void 0){try{ke=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{ke=null}Y.set(we,ke)}if(!ke)return null;const Ce={};for(const ce of ke.formatToParts(fe))ce.type!=="literal"&&(Ce[ce.type]=ce.value);return Ce}function V(fe,we){if(fe==null||fe==="")return null;if(typeof fe=="string"){const ae=R.exec(fe.trim());if(ae)return Date.UTC(+ae[1],+ae[2]-1,+ae[3],+(ae[4]||0),+(ae[5]||0),+(ae[6]||0),+(ae[7]||"0").padEnd(3,"0"))}const ke=L(fe);if(!ke)return null;const Ce=ke.getUTCMilliseconds(),ce=we?K(ke,we):null;return ce?Date.UTC(+ce.year,+ce.month-1,+ce.day,ce.hour==="24"?0:+ce.hour,+ce.minute,+ce.second,Ce):Date.UTC(ke.getFullYear(),ke.getMonth(),ke.getDate(),ke.getHours(),ke.getMinutes(),ke.getSeconds(),Ce)}function E(fe,we){const ke=typeof fe.timeZone=="string"&&fe.timeZone?fe.timeZone:void 0,Ce=ge=>V(ge,ke),ce=Array.isArray(fe.value)?fe.value.map(Ce):Ce(fe.value),ae=O({...fe,type:"number",value:ce},we);return ge=>ae(V(ge))}function O(fe,we){const ke=fe&&fe.op,Ce=!!(fe&&fe.caseSensitive),ce=fe&&fe.type,ae=g(we),ge=de=>me=>!de(me);switch(ke){case"eq":{const de=t(fe.value,ce);return me=>l(me,de,Ce)}case"ne":{const de=t(fe.value,ce);return me=>!l(me,de,Ce)}case"lt":case"lte":case"gt":case"gte":{const de=t(fe.value,ce);if(m(de))return()=>!1;const me=ke==="lt"?-1:ke==="lte"?0:ke==="gt"?1:2;return ve=>{if(m(ve))return!1;const xe=ae(ve,de);return me===-1?xe<0:me===0?xe<=0:me===1?xe>0:xe>=0}}case"between":case"notBetween":{const de=D(fe.value),me=t(de[0],ce),ve=t(de[1],ce),xe=fe.bounds||"[]",Ee=xe.charAt(0)!=="(",Le=xe.charAt(1)!==")";if(m(me)||m(ve))return ke==="between"?()=>!1:()=>!0;const He=Me=>{if(m(Me))return!1;const Ke=ae(Me,me),$e=ae(Me,ve);return(Ee?Ke>=0:Ke>0)&&(Le?$e<=0:$e<0)};return ke==="between"?He:ge(He)}case"in":case"notIn":{const de=b(fe.value,Ce,ce),me=ve=>de.has(o(ve,Ce));return ke==="in"?me:ge(me)}case"contains":case"notContains":{const de=d(t(fe.value,ce),Ce),me=ve=>ve==null?!1:d(ve,Ce).includes(de);return ke==="contains"?me:ge(me)}case"startsWith":{const de=d(t(fe.value,ce),Ce);return me=>me==null?!1:d(me,Ce).startsWith(de)}case"endsWith":{const de=d(t(fe.value,ce),Ce);return me=>me==null?!1:d(me,Ce).endsWith(de)}case"matches":{const de=p(fe.value,Ce);return de?me=>me==null?!1:de.test(String(me)):()=>!1}case"blank":case"notBlank":{const de=fe.trim===!0,me=ve=>T(ve)||Array.isArray(ve)&&ve.length===0||de&&typeof ve=="string"&&ve.trim()==="";return ke==="blank"?me:ve=>!me(ve)}case"containsAny":case"containsNone":{const de=b(fe.value,Ce,ce),me=ve=>{const xe=ve==null?[]:D(ve);for(let Ee=0;Ee<xe.length;Ee++)if(de.has(o(xe[Ee],Ce)))return!0;return!1};return ke==="containsAny"?me:ge(me)}case"containsAll":{const de=D(fe.value).map(me=>o(t(me,ce),Ce));return me=>{const ve=me==null?[]:D(me);if(de.length===0)return!0;const xe=new Set(ve.map(Ee=>o(Ee,Ce)));for(let Ee=0;Ee<de.length;Ee++)if(!xe.has(de[Ee]))return!1;return!0}}default:{const de=ye(ke);return de?de.compile(fe.value):(Z(`op:${String(ke)}`,`unknown filter operator "${String(ke)}"; the condition is refused rather than matching every row`),()=>!1)}}}function C(fe,we,ke){return w(we,ke)(fe)}const S=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),F=new Set(["containsAny","containsAll","containsNone"]);function P(fe,we,ke){const Ce=fe&&fe.op,ce=S[Ce]||Ce,ae=w({...fe,op:ce,type:we.type},ke),ge=we.items,de=me=>{const ve=ge(me);if(!ve)return!1;for(let xe=0;xe<ve.length;xe++)if(ae(ve[xe]))return!0;return!1};return S[Ce]?me=>!de(me):de}function M(fe,we,ke,Ce,ce){const ae=ce?null:f(fe);if(ae){const me=we?1:0;for(let ve=0;ve<Ce;ve++)ke[ve]=ae(ve)===me?1:0;return ke}const ge=fe.kind;if(ge==="float64"||ge==="int32"||ge==="bitset")return n(ke,Ce,we?1:0);const de=a(fe);for(let me=0;me<Ce;me++){const ve=de(me),xe=T(ve)||Array.isArray(ve)&&ve.length===0||ce&&typeof ve=="string"&&ve.trim()==="";ke[me]=xe===we?0:1}return ke}function x(fe,we,ke,Ce){const ce=fe.dict,ae=k(ce),ge=new Uint8Array(ae);for(let xe=0;xe<ae;xe++)ge[xe]=we(y(ce,xe))?1:0;const de=fe.values,me=f(fe);if(!me){for(let xe=0;xe<Ce;xe++)ke[xe]=ge[de[xe]];return ke}const ve=we(null)?1:0;for(let xe=0;xe<Ce;xe++)ke[xe]=me(xe)===1?ge[de[xe]]:ve;return ke}function U(fe,we,ke,Ce){const ce=A(fe.values),ae=we(!0)?1:0,ge=we(!1)?1:0,de=f(fe);if(!de){for(let ve=0;ve<Ce;ve++)ke[ve]=ce(ve)===1?ae:ge;return ke}const me=we(null)?1:0;for(let ve=0;ve<Ce;ve++)ke[ve]=de(ve)===0?me:ce(ve)===1?ae:ge;return ke}function _(fe,we,ke,Ce,ce){const ae=fe.values,ge=we.type,de=we.op;let me=!0;switch(de){case"eq":case"ne":{const xe=h(t(we.value,ge)),Ee=typeof we.value=="number"&&Number.isNaN(we.value),Le=de==="ne"?1:0;if(Ee)for(let He=0;He<ce;He++)Ce[He]=(Number.isNaN(ae[He])?1:0)^Le;else for(let He=0;He<ce;He++)Ce[He]=(ae[He]===xe?1:0)^Le;break}case"lt":{const xe=h(t(we.value,ge));for(let Ee=0;Ee<ce;Ee++)Ce[Ee]=ae[Ee]<xe?1:0;break}case"lte":{const xe=h(t(we.value,ge));for(let Ee=0;Ee<ce;Ee++)Ce[Ee]=ae[Ee]<=xe?1:0;break}case"gt":{const xe=h(t(we.value,ge));for(let Ee=0;Ee<ce;Ee++)Ce[Ee]=ae[Ee]>xe?1:0;break}case"gte":{const xe=h(t(we.value,ge));for(let Ee=0;Ee<ce;Ee++)Ce[Ee]=ae[Ee]>=xe?1:0;break}case"between":case"notBetween":{const xe=D(we.value),Ee=h(t(xe[0],ge)),Le=h(t(xe[1],ge)),He=we.bounds||"[]",Me=He.charAt(0)!=="(",Ke=He.charAt(1)!==")",$e=de==="notBetween"?1:0;if(Me&&Ke)for(let Oe=0;Oe<ce;Oe++)Ce[Oe]=(ae[Oe]>=Ee&ae[Oe]<=Le?1:0)^$e;else if(Me)for(let Oe=0;Oe<ce;Oe++)Ce[Oe]=(ae[Oe]>=Ee&ae[Oe]<Le?1:0)^$e;else if(Ke)for(let Oe=0;Oe<ce;Oe++)Ce[Oe]=(ae[Oe]>Ee&ae[Oe]<=Le?1:0)^$e;else for(let Oe=0;Oe<ce;Oe++)Ce[Oe]=(ae[Oe]>Ee&ae[Oe]<Le?1:0)^$e;break}case"in":case"notIn":{const xe=new Set;for(const Le of D(we.value)){const He=h(t(Le,ge));Number.isNaN(He)||xe.add(He)}const Ee=de==="notIn"?1:0;for(let Le=0;Le<ce;Le++)Ce[Le]=(xe.has(ae[Le])?1:0)^Ee;break}default:me=!1;break}if(!me)return!1;const ve=f(fe);if(ve){const xe=ke(null)?1:0;for(let Ee=0;Ee<ce;Ee++)ve(Ee)===0&&(Ce[Ee]=xe)}return!0}function W(fe,we,ke,Ce){const ce=a(fe);for(let ae=0;ae<Ce;ae++)ke[ae]=we(ce(ae))?1:0;return ke}function q(fe,we,ke){const Ce=we.count|0,ce=ke||c(we,Ce);if(!fe)return n(ce,Ce,1);const ae=typeof we.handle=="function"?we.handle(fe.col):void 0,ge=typeof we.custom=="function"?we.custom:null;if(!ae){if(ge){for(let xe=0;xe<Ce;xe++)ce[xe]=ge(fe,xe)?1:0;return ce}return Z(`filter:col:${String(fe.col)}`,`filter references unknown column "${String(fe.col)}"; the condition is refused rather than matching every row`),n(ce,Ce,0)}const de=fe.op;if(de==="blank"||de==="notBlank")return M(ae,de==="notBlank",ce,Ce,fe.trim===!0);const me=typeof we.itemwise=="function"?we.itemwise(fe.col):null;if(me&&!ye(de)&&!F.has(de))return W(ae,P(fe,me,we.locale),ce,Ce);const ve=w(fe,we.locale);switch(ae.kind){case"dictionary":return x(ae,ve,ce,Ce);case"bitset":return U(ae,ve,ce,Ce);case"float64":case"int32":return _(ae,fe,ve,ce,Ce)?ce:W(ae,ve,ce,Ce);default:return W(ae,ve,ce,Ce)}}function N(fe,we,ke){if(!fe)return n(c(we,ke),ke,1);if(Array.isArray(fe.conditions)){const Ce=fe.conditions.filter(ge=>ge!=null),ce=fe.op==="or"?"or":fe.op==="not"?"not":"and";if(Ce.length===0)return n(c(we,ke),ke,1);const ae=N(Ce[0],we,ke);for(let ge=1;ge<Ce.length;ge++){const de=N(Ce[ge],we,ke);if(ce==="or")for(let me=0;me<ke;me++)ae[me]|=de[me];else for(let me=0;me<ke;me++)ae[me]&=de[me];u(we,de)}if(ce==="not")for(let ge=0;ge<ke;ge++)ae[ge]^=1;return ae}return q(fe,we,c(we,ke))}function Q(fe,we){return N(fe,we,we.count|0)}function J(fe,we){if(!fe||!we)return fe||null;const ke=fe;if(Array.isArray(ke.conditions)){if((ke.op==="or"?"or":ke.op==="not"?"not":"and")!=="and")return ee(ke,we)?null:fe;const ce=[];for(const ae of ke.conditions){const ge=J(ae,we);ge&&ce.push(ge)}return ce.length?{...ke,op:"and",conditions:ce}:null}return ke.col===we?null:fe}function ee(fe,we){if(!fe||typeof fe!="object")return!1;const ke=fe;if(ke.col===we)return!0;if(Array.isArray(ke.conditions)){for(const Ce of ke.conditions)if(ee(Ce,we))return!0}return!1}function ne(fe,we,ke){if(ke&&ke.length>=we){let ge=0;for(let de=0;de<we;de++)fe[de]&&(ke[ge++]=de);return ke.subarray(0,ge)}let Ce=0;for(let ge=0;ge<we;ge++)Ce+=fe[ge]?1:0;const ce=new Uint32Array(Ce);let ae=0;for(let ge=0;ge<we;ge++)fe[ge]&&(ce[ae++]=ge);return ce}const se=new Map;function le(fe){if(!(!fe||typeof fe!="object"))for(const[we,ke]of Object.entries(fe))ke&&typeof ke.compile=="function"&&se.set(we,ke)}function ye(fe){return typeof fe=="string"?se.get(fe):void 0}}),Ue("packages/core/src/columns/datatypes.js",function(e,B){"use strict";Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"parseNumberText",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"BUILTIN_TYPES",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"INFERENCE_ORDER",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"createTypeRegistry",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"comparatorFor",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"storageKind",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"typeLabel",{enumerable:!0,get:function(){return M}});const re=B("packages/core/src/internal/compare.js"),T=re.collator,G=re.defaultCompare,D=B("packages/core/src/internal/predicates.js"),I=D.isNil,Z=D.isObject,z=D.isFunction,L=B("packages/core/src/internal/warn.js"),X=L.fail,$=L.infoOnce,k=B("packages/core/src/internal/text.js").titleCase,y=B("packages/core/src/format/date.js"),f=y.toDate,g=y.toIsoDate,a=y.compareIso,i=B("packages/core/src/format/boolean.js").toTriState,u=B("packages/core/src/columns/types/index.js").EXTENDED_TYPES,n=B("packages/core/src/formula/index.js"),m=n.evaluateFormula,t=n.looksLikeFormula,h=B("packages/core/src/compute/filter.js").declareOperators,d=/^\d{4}-\d{2}-\d{2}$/;function o(x){return x.getHours()===0&&x.getMinutes()===0&&x.getSeconds()===0&&x.getMilliseconds()===0}const b=new Map;function l(x){const U=x||"",_=b.get(U);if(_)return _;const W={group:",",decimal:"."};try{for(const q of new Intl.NumberFormat(x||void 0).formatToParts(12345.6))q.type==="group"?W.group=q.value:q.type==="decimal"&&(W.decimal=q.value)}catch{}return b.set(U,W),W}const p=/\d\s*[*/^]\s*[\d.(]/;function w(x,U){if(I(x))return null;let _=String(x).trim();if(_===""||_.startsWith("=")||p.test(_))return null;let W=1;_.startsWith("(")&&_.endsWith(")")&&(W=-1,_=_.slice(1,-1));const q=_.endsWith("%"),{group:N,decimal:Q}=l(U);if(_=_.replace(/[\s\u00a0\u202f\u2009']/g,""),N&&N!=="."&&N!==","&&(_=_.split(N).join("")),_=_.replace(/[^0-9eE+\-.,]/g,""),Q===","?_=_.split(".").join("").replace(",","."):_=_.split(",").join(""),_===""||_==="-"||_==="+")return null;const J=Number(_);return Number.isNaN(J)?null:W*(q?J/100:J)}function v(x,U){const _=I(x)||Number.isNaN(x)?null:Number(x),W=I(U)||Number.isNaN(U)?null:Number(U);return _===null?W===null?0:1:W===null||_<W?-1:_>W?1:0}function R(x,U){const _=i(x),W=i(U);return _===null?W===null?0:1:W===null?-1:_===W?0:_?1:-1}function Y(x,U){const _=f(x),W=f(U);if(!_)return W?1:0;if(!W)return-1;const q=_.getTime(),N=W.getTime();return q<N?-1:q>N?1:0}const K=new Map;function V(x){const U=f(x.value);if(!U)return"";const _=x.locale||"";let W=K.get(_);return W||(W=new Intl.DateTimeFormat(x.locale||void 0,{dateStyle:"medium"}),K.set(_,W)),W.format(U)}const E={boolean:{base:"boolean",storage:"bitset",matches:x=>typeof x=="boolean",parse:x=>i(x.text),compare:R,format:x=>i(x.value)===null?"":i(x.value)?"Yes":"No",defaults:{filter:"set",editor:"checkbox",align:"center"},excel:"General",toClipboard:x=>i(x)===null?"":String(i(x)),fromClipboard:x=>i(x)},number:{base:"number",storage:"float64",matches:x=>typeof x=="number"&&!Number.isNaN(x),parse:x=>{if(t(x.text)){const U=m(x.text,x);if(!U.ok)return null;const _=Number(U.value);return Number.isFinite(_)?_:null}return w(x.text,x.locale)},compare:v,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:x=>I(x)?"":String(x),fromClipboard:(x,U)=>w(x,U&&U.locale),toStorage:(x,U)=>{if(typeof x!="string")return x;const _=w(x,U&&U.locale);return _!==null?_:($(`type.number.unparsed.${U&&U.colId||""}`,`column "${U&&U.colId||"?"}" is declared type "number" but holds a value that is not a number in its locale; storing it as NaN, excluded from sorts and totals.`),NaN)}},date:{base:"dateString",storage:"dictionary",matches:x=>typeof x=="string"&&d.test(x)&&!Number.isNaN(Date.parse(x))||x instanceof Date&&!Number.isNaN(x.getTime())&&o(x),parse:x=>g(x.text),compare:a,format:V,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:x=>g(x),toClipboard:x=>I(x)?"":String(x),fromClipboard:x=>g(x)},dateString:{base:"dateString",storage:"dictionary",matches:x=>typeof x=="string"&&d.test(x)&&!Number.isNaN(Date.parse(x)),parse:x=>g(x.text),compare:a,format:V,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:x=>g(x),toClipboard:x=>I(x)?"":String(x),fromClipboard:x=>g(x)},text:{base:"text",storage:"dictionary",matches:x=>typeof x=="string",parse:x=>x.text===""?null:String(x.text),compare:(x,U)=>I(x)?I(U)?0:1:I(U)?-1:T().compare(String(x),String(U)),defaults:{filter:"text",editor:"text",align:"start"},excel:"@",toClipboard:x=>I(x)?"":String(x),fromClipboard:x=>x},image:{base:"text",storage:"dictionary",parse:x=>x.text===""||x.text==null?null:String(x.text).trim(),compare:(x,U)=>I(x)?I(U)?0:1:I(U)?-1:T().compare(String(x),String(U)),defaults:{filter:"text",editor:"text",align:"center",render:"image"},excel:"@",toClipboard:x=>I(x)?"":String(x),fromClipboard:x=>x},lookup:{base:"text",storage:"dictionary",parse:x=>{if(x.text===""||x.text==null)return null;const U=x.column&&x.column.lookup,_=U&&z(U.options)?U.options():null;if(!_)return x.text;const W=String(x.text),q=_.find(J=>String(J.id)===W);if(q)return q.id;const N=W.trim().toLowerCase(),Q=_.find(J=>String(J.label).toLowerCase()===N);return Q?Q.id:x.text},compare:G,defaults:{filter:"set",editor:"select",align:"start"},excel:"@",multiStorage:"multi",toClipboard:x=>I(x)?"":String(x),fromClipboard:x=>x},object:{base:"object",storage:"object",matches:x=>x!==null&&typeof x=="object"&&!(x instanceof Date),parse:x=>{try{return x.text===""?null:JSON.parse(x.text)}catch{return x.text}},compare:(x,U)=>G(x,U),format:x=>{const U=x.value;if(I(U))return"";if(typeof U=="string")return U;try{return JSON.stringify(U)}catch{return String(U)}},defaults:{filter:"none",editor:"none",align:"start"},excel:"@",toClipboard:x=>I(x)?"":typeof x=="string"?x:JSON.stringify(x),fromClipboard:x=>x}},O=["boolean","number","date","dateString","datetime","text","object"];function C(x,U,_,W){const q=_.get(x);if(q)return q;W.includes(x)&&X(`circular data type extends chain: ${[...W,x].join(" → ")}`);const N=U[x];N||X(`unknown data type "${x}"`);let Q=null;N.extends&&(Q=C(N.extends,U,_,[...W,x]));const J={...Q||{},...N,name:x,defaults:{...Q&&Q.defaults||{},...N.defaults||{}}};return J.base||(J.base=Q&&Q.base||"text"),J.storage||(J.storage=Q&&Q.storage||"object"),_.set(x,J),J}function S(x,U){const _={...E,...u};if(U&&typeof U.dataType=="function"&&typeof U.names=="function")for(const q of U.names("dataType")){const N=U.dataType(q);N&&(_[q]=N)}if(Z(x))for(const[q,N]of Object.entries(x))_[q]=N;const W=new Map;for(const q of O)C(q,_,W,[]);C("lookup",_,W,[]);for(const q of Object.keys(_))C(q,_,W,[]);for(const q of W.values())h(q.operators);return W}function F(x,U){if(x.base==="text"&&(!x.compare||x.compare===E.text.compare)){const _=T(U);return(W,q)=>I(W)?I(q)?0:1:I(q)?-1:_.compare(String(W),String(q))}return x.compare||G}function P(x,U){return U?x.multiStorage||"multi":x.storage||"object"}function M(x){return k(String(x).replace(/([a-z])([A-Z])/g,"$1 $2"))}}),Ue("packages/core/src/columns/infer.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_SAMPLE",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"inferFromValues",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"inferColumnType",{enumerable:!0,get:function(){return z}});const T=B("packages/core/src/internal/warn.js").infoOnce,D=B("packages/core/src/internal/predicates.js").isNil,I=100;function Z(L,X,$={}){const A=$.sampleSize??I,k=[];for(let y=0;y<L.length&&k.length<A;y++){const f=L[y];D(f)||typeof f=="number"&&Number.isNaN(f)||k.push(f)}if(k.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[y,f]of X){if(typeof f.matches!="function")continue;let g=!0;for(let a=0;a<k.length;a++)if(!f.matches(k[a])){g=!1;break}if(g)return{type:y,unanimous:!0,sampled:k.length}}return $.quiet||T(`infer:${$.colId||"?"}`,`column "${$.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 z(L,X,$,A,k={}){const y=k.sampleSize??I,f=[];for(let g=0;g<X.length&&f.length<y;g++){const a=$(X[g]);D(a)||typeof a=="number"&&Number.isNaN(a)||f.push(a)}return Z(f,A,{...k,colId:L}).type}}),Ue("packages/core/src/columns/graph.js",function(e,B){"use strict";Object.defineProperty(e,"WHOLE_ROW",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"declarationOf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"affectedBy",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return A}});const re=B("packages/core/src/internal/warn.js"),T=re.DEV,G=re.fail,D=re.warnOnce,Z=B("packages/core/src/internal/predicates.js").isFunction,z="*";function L(k){const y=k.value||{};if(!Z(y.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const g=y.pure!==!1;return y.deps===z?{computed:!0,wholeRow:!0,deps:[],pure:g}:Array.isArray(y.deps)?{computed:!0,wholeRow:!1,deps:y.deps.slice(),pure:g}:(D(`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:g})}function X(k){const y=new Map;for(const h of k)y.set(h.id,h);const f=new Map,g=new Map,a=new Set,r=new Set,i=new Set,c=new Set;for(const h of k){const d=L(h);if(!d.computed){f.set(h.id,[]);continue}r.add(h.id),(d.pure?i:c).add(h.id),d.wholeRow&&a.add(h.id);const o=[],b=[];for(const l of d.deps)(y.has(l)?o:b).push(l);f.set(h.id,o),b.length&&g.set(h.id,b)}for(const h of i)for(const d of f.get(h))c.has(d)&&G(`pure computed column "${h}" depends on impure column "${d}". Mark it \`value.pure: false\` or make the dependency pure.`);const u=[],n=new Map,m=[],t=h=>{const d=n.get(h);if(d!=="done"){if(d==="open"){const o=m.indexOf(h);G(`circular column dependency: ${[...m.slice(o),h].join(" → ")}`)}n.set(h,"open"),m.push(h);for(const o of f.get(h)||[])y.has(o)&&t(o);m.pop(),n.set(h,"done"),u.push(h)}};for(const h of k)t(h.id);const s=new Map;for(const h of k)s.set(h.id,[]);for(const h of k)for(const d of f.get(h.id)||[]){const o=s.get(d);o&&!o.includes(h.id)&&o.push(h.id)}if(a.size)for(const h of k){if(r.has(h.id))continue;const d=s.get(h.id);for(const o of a)d.includes(o)||d.push(o)}return{order:u,dependents:s,pure:i,impure:c,computed:r,deps:f,wholeRow:a,external:g,index:y}}function $(k,y){const f=Array.isArray(y)?y:[y],g=new Set,a=[...f];for(;a.length;){const r=a.shift();for(const i of k.dependents.get(r)||[])g.has(i)||(g.add(i),a.push(i))}for(const r of f)g.delete(r);return k.order.filter(r=>g.has(r))}function A(k,y,f){if(!T)return k;const g=y instanceof Set?y:new Set(y);return new Proxy(k,{get(a,r){return typeof r=="string"&&!g.has(r)&&!Object.hasOwn(a,r)&&D(`undeclared:${f}:${r}`,`computed column "${f}" read undeclared dependency "${r}". Add it to \`value.deps\` or the value will go stale.`),a[r]}})}}),Ue("packages/core/src/model/rowkey.js",function(e,B){"use strict";Object.defineProperty(e,"KEY_DEPENDENT_FEATURES",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"compositeKey",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"warnMissingKeys",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"groupPathKey",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"splitPathKey",{enumerable:!0,get:function(){return r}});const T=B("packages/core/src/internal/warn.js").warnOnce,D=B("packages/core/src/internal/paths.js").pathGetter,I=B("packages/core/src/internal/predicates.js"),Z=I.isFunction,z=I.isBlank,L=["changes (rows.apply / rows.queue)","streaming dedupe","selection persistence","remote reload","cell comments"],X="";function $(i){if(i===null)return"\0n";if(i===void 0)return"\0u";const c=typeof i;if(c==="string")return i;if(c==="number"||c==="bigint"||c==="boolean")return String(i);if(i instanceof Date)return`\0d${i.getTime()}`;try{return`\0o${JSON.stringify(i)}`}catch{return"\0o?"}}function A(i){if(i.length===1)return $(i[0]);let c="";for(let u=0;u<i.length;u++)u&&(c+=X),c+=$(i[u]);return c}function k(i,c={}){const u=c.warn!==!1;if(Z(i)){const n=i;return{stable:!0,fields:[],disabled:[],key(m,t){try{const s=n(m);return Array.isArray(s)?A(s):$(s)}catch(s){return T("rowKey.throw","rowKey function threw; falling back to index identity for the affected rows.",s),`#${t??-1}`}},keyEmpty(m){try{const t=n(m);return Array.isArray(t)?t.length===0||t.some(z):z(t)}catch{return!1}},missingFields(){return[]}}}if(Array.isArray(i)&&i.length>0){const n=i.filter(s=>typeof s=="string"),m=n.map(s=>D(s)),t=m.length;return{stable:!0,fields:n,disabled:[],key(s){const h=new Array(t);for(let d=0;d<t;d++)h[d]=m[d](s);return A(h)},keyEmpty(s){for(let h=0;h<t;h++)if(z(m[h](s)))return!0;return!1},missingFields(s){const h=[];for(let d=0;d<t;d++)z(m[d](s))&&h.push(n[d]);return h}}}if(typeof i=="string"&&i.length>0){const n=D(i);return{stable:!0,fields:[i],disabled:[],key(m){return $(n(m))},keyEmpty(m){return z(n(m))},missingFields(m){return z(n(m))?[i]:[]}}}return u&&T("rowKey.missing",`no rowKey configured, so rows are identified by object identity. This disables: ${L.join(", ")}. Set rowKey to a field name, an array of field names, or a function.`),{stable:!1,fields:[],disabled:L.slice(),key(n,m){if(n===null||typeof n!="object")return`#${m??0}:${String(n)}`;let t=y.get(n);return t===void 0&&(t=`#${f++}`,y.set(n,t)),t}}}const y=new WeakMap;let f=0;function g(i,c){if(!i||i.stable===!1||!Z(i.keyEmpty)||!Array.isArray(c)||c.length===0)return;let u=0,n=null,m;for(let d=0;d<c.length;d++){const o=c[d];i.keyEmpty(o)&&(u++,n===null&&(n=Z(i.missingFields)?i.missingFields(o):[],m=o))}if(u===0)return;const t=i.fields.length?i.fields.join(","):"(function)",s=n&&n.length?n.join(", "):i.fields.length?i.fields.join(", "):"the rowKey function",h=m!==null&&typeof m=="object"?Object.keys(m).join(", ")||"(no fields)":String(m);T(`rowKey.emptyValue:${t}`,`rowKey ${s} is missing on ${u} of ${c.length} rows; the first such row has: ${h}. Rows without a key value collapse onto one key, so selection, edits and rows.apply updates land on whichever row now shares it. Set rowKey to a field present on every row, or fix the source data.`)}function a(i){return A(i)}function r(i){return i.split(X)}}),Ue("packages/core/src/columns/lookup.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_SEPARATOR",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"normaliseOption",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"flattenOptions",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return i}});const re=B("packages/core/src/internal/compare.js"),T=re.collator,G=re.defaultCompare,D=B("packages/core/src/internal/predicates.js"),I=D.isFunction,Z=D.isNil,L=B("packages/core/src/internal/warn.js").warnOnce,$=B("packages/core/src/model/rowkey.js").compositeKey,A=", ",k="";function y(c,u,n,m){if(c===null||typeof c!="object")return{id:c,label:c==null?"":String(c)};const t=c[u],s=c[n],h={id:t,label:s==null?String(t??""):String(s)};c.disabled&&(h.disabled=!0),c.variant&&(h.variant=c.variant),c.icon&&(h.icon=c.icon);const d=m?c[m]:c.group;return d!==void 0&&(h.group=d),h}function f(c,u,n=0,m=[],t=[]){for(const s of c||[]){const h=s&&typeof s=="object"?s[u]:null;if(t.push({raw:s,depth:n,path:m}),Array.isArray(h)&&h.length){const d=String(s&&typeof s=="object"?s.label??s.name??s.id??"":s);f(h,u,n+1,[...m,d],t)}}return t}function g(c){return!!c&&typeof c=="object"&&!Array.isArray(c)&&I(c.router&&c.router.subscribe)}class a{#e;#t;#n;#r;#i=[];#s=new Map;#a=new Map;#l=0;#o="idle";#c=null;#u;#f=null;#d=new Map;constructor(u,n={}){this.#e=u||{},this.#t=n.colId||"?",this.#n=n.locale,this.#r=n.onChange||null,this.#u=T(this.#n),Array.isArray(this.#e.options)?this.#h(this.#e.options):this.#e.options===void 0&&(this.#o="ready")}get colId(){return this.#t}get version(){return this.#l}get state(){return this.#o}get ready(){return this.#o==="ready"}get multiple(){return this.#e.multiple===!0}get separator(){return this.#e.separator??A}get allowCustom(){return this.#e.allowCustom===!0}get sortBy(){return this.#e.sortBy||"label"}get spec(){return this.#e}options(){return this.#i}setLocale(u){this.#n=u,this.#u=T(u)}#h(u){const n=this.#e,m=n.valueKey||"id",t=n.labelKey||"label",s=n.childrenKey||"children";this.#i=f(u,s).map(h=>{const d=y(h.raw,m,t,n.groupKey);return h.depth&&(d.depth=h.depth,d.path=h.path),d}),this.#s=new Map,this.#a=new Map,this.#i.forEach((h,d)=>{this.#s.set(h.id,h),this.#a.set(h.id,d)}),this.#o="ready",this.#l+=1}load(){if(this.#c)return this.#c;const u=this.#e.options;if(Array.isArray(u)||u===void 0)return this.#c=Promise.resolve(this.#i),this.#c;if(g(u))return this.#c=this.#p(u),this.#c;if(!I(u))return L(`lookup:options:${this.#t}`,`column "${this.#t}" has an invalid \`lookup.options\`; expected an array, a function, or a router route`),this.#o="ready",this.#c=Promise.resolve([]),this.#c;this.#o="loading";let n;try{n=u()}catch(m){return this.#o="error",L(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,m),this.#c=Promise.resolve([]),this.#c}return!n||!I(n.then)?(this.#h(n),this.#c=Promise.resolve(this.#i),this.#r&&this.#r(this),this.#c):(this.#c=n.then(m=>(this.#h(m),this.#r&&this.#r(this),this.#i),m=>(this.#o="error",L(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,m),[])),this.#c)}refresh(){return this.#c=null,Array.isArray(this.#e.options)?(this.#h(this.#e.options),this.#r&&this.#r(this),Promise.resolve(this.#i)):this.load()}#p(u){if(this.#f)return Promise.resolve(this.#i);const n=this.#e,m=n.valueKey||"id",t=n.labelKey||"label",s=n.groupKey,h=I(u.map)?u.map:null,d=b=>y(h?h(b):b,m,t,s).id,o=b=>this.#m(b,h,m,t,s);return u.router.subscribe(u.predicate,o,{rowKey:d}),this.#f=()=>{I(u.router.detach)&&u.router.detach(o)},this.#o="ready",Promise.resolve(this.#i)}#m(u,n,m,t,s){const h=u&&u.add||[],d=u&&u.update||[],o=u&&u.remove||[];if(!(!h.length&&!d.length&&!o.length)){for(const b of h)this.#g(b,n,m,t,s);for(const b of d)this.#g(b,n,m,t,s);for(const b of o){if(!this.#d.has(b))continue;const l=this.#d.get(b);this.#d.delete(b),this.#s.delete(l);const p=this.#i.findIndex(w=>w.id===l);p>=0&&this.#i.splice(p,1)}this.#a=new Map(this.#i.map((b,l)=>[b.id,l])),this.#o="ready",this.#l+=1,this.#r&&this.#r(this)}}#g(u,n,m,t,s){const h=y(n?n(u):u,m,t,s);this.#d.set($([h.id]),h.id);const d=this.#i.findIndex(o=>o.id===h.id);d>=0?this.#i[d]=h:this.#i.push(h),this.#s.set(h.id,h)}destroy(){this.#f&&(this.#f(),this.#f=null)}search(u,n){const m=this.#e;if(!I(m.search)){const h=String(u||"").toLowerCase();return Promise.resolve(h===""?this.#i:this.#i.filter(d=>d.label.toLowerCase().includes(h)))}const t=m.valueKey||"id",s=m.labelKey||"label";return Promise.resolve(m.search(u,n)).then(h=>(h||[]).map(d=>y(d,t,s,m.groupKey)))}option(u){return this.#s.get(u)}has(u){return this.#s.has(u)}label(u){if(Z(u)||u==="")return"";const n=this.#s.get(u);if(n)return n.label;if(this.#o==="loading"||this.#o==="idle")return"";this.allowCustom||L(`lookup:unknown:${this.#t}`,`column "${this.#t}" holds value ${JSON.stringify(u)} which is not in its lookup options. Showing the raw value; set \`lookup.unknownLabel\` or \`lookup.allowCustom\` to change that.`);const m=this.#e.unknownLabel;return I(m)?String(m(u)??""):typeof m=="string"?m:String(u)}text(u){if(this.multiple){const n=r(u);return n.length===0?"":n.map(m=>this.label(m)).join(this.separator)}return this.label(u)}dictionary(){return this.#i.map(u=>u.id)}sorted(){const u=this.sortBy;if(u==="optionOrder"||u==="count")return this.#i.slice();if(u==="value")return this.#i.slice().sort((m,t)=>G(m.id,t.id));const n=this.#u;return this.#i.slice().sort((m,t)=>n.compare(m.label,t.label))}comparator(){const u=this.sortBy,n=this.multiple,m=this.#u,t=this.#a;if(n&&u==="count")return(h,d)=>r(h).length-r(d).length;const s=n?h=>r(h)[0]:h=>h;return u==="value"?(h,d)=>G(s(h),s(d)):u==="optionOrder"?(h,d)=>{const o=t.has(s(h))?t.get(s(h)):Number.MAX_SAFE_INTEGER,b=t.has(s(d))?t.get(s(d)):Number.MAX_SAFE_INTEGER;return o-b}:(h,d)=>{const o=s(h),b=s(d);return Z(o)?Z(b)?0:1:Z(b)?-1:m.compare(this.label(o),this.label(b))}}groupKey(u){return this.multiple?r(u).map(m=>String(m)).sort().join(k):Z(u)?"":String(u)}countValues(u){return this.multiple?r(u).length:Z(u)?0:1}contains(u,n,m){const t=this.multiple?r(u):Z(u)?[]:[u],s=Array.isArray(n)?n:[n];switch(m){case"containsAll":return s.every(h=>t.includes(h));case"containsNone":return!s.some(h=>t.includes(h));default:return s.some(h=>t.includes(h))}}exportText(u,n="label"){return n==="value"?this.multiple?r(u).join(this.separator):Z(u)?"":String(u):this.text(u)}exportColumns(){const u=this.multiple;return this.#i.map(n=>({id:n.id,label:n.label,has:m=>u?r(m).includes(n.id):m===n.id}))}}function r(c){return Array.isArray(c)?c:Z(c)||c===""?[]:[c]}function i(c,u={}){const n=c.lookup;if(!n)return null;const m=new a(n,{colId:c.id,locale:u.locale,onChange:u.onChange});return!Array.isArray(n.options)&&n.options!==void 0&&m.load(),m}}),Ue("packages/core/src/columns/value.js",function(e,B){"use strict";Object.defineProperty(e,"compileDisplay",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"warnImpureUse",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return c}});const T=B("packages/core/src/internal/paths.js").getPath,G=B("packages/core/src/internal/predicates.js"),D=G.isFunction,I=G.isNil,Z=G.isObject,L=B("packages/core/src/internal/lru.js").Lru,$=B("packages/core/src/internal/warn.js").warnOnce,k=B("packages/core/src/format/number.js").compileNumber,f=B("packages/core/src/columns/graph.js").depsProxy,g="\0";function a(t,s={}){const h=s.locale,d=s.grid??null,o=s.context,b=t.value&&t.value.format,l=t.formatter||null,p=t.dataType&&t.dataType.format,w=t.lookup||null,v=(R,Y,K)=>({value:R,data:K,row:Y,column:t,colId:t.id,grid:d,context:o,locale:h});if(D(b))return(R,Y,K)=>{const V=b(v(R,Y,K));return V==null?"":String(V)};if(l){if(w){const R=l.kind==="text";return(Y,K,V)=>l(R?w.text(Y):Y,v(Y,K,V))}return(R,Y,K)=>l(R,v(R,Y,K))}if(D(p))return(R,Y,K)=>{const V=p(v(R,Y,K));return V==null?"":String(V)};if(t.dataType&&t.dataType.base==="number"&&Z(t.typeOptions)&&typeof t.typeOptions.decimals=="number"){const R=k({decimals:t.typeOptions.decimals},h);return Y=>R(Y)}return w?R=>w.text(R):R=>I(R)?"":typeof R=="string"?R:String(R)}function r(t,s){!t||!t.value||t.value.pure!==!1||$(`impure:${s}:${t.id}`,`column "${t.id}" is an impure computed column (\`value.pure: false\`) and is being used to ${s}. The result is not stable across passes.`)}class i{#e;#t;#n;#r;#i;#s;#a=new L(4096);constructor(s){this.#e=s.columns instanceof Map?s.columns:new Map((s.columns||[]).map(h=>[h.id,h])),this.#t=s.graph,this.#n=s.grid??null,this.#r=s.context,this.#s=s.stored||null,this.#i=s.rowKey||c}get graph(){return this.#t}setGraph(s){this.#t=s,this.#a.clear()}beginPass(){this.#a.clear()}endPass(){this.#a.clear()}invalidate(s){if(this.#a.size===0)return;const h=s&&s.rows?new Set([...s.rows].map(String)):null,d=s&&s.columns?[...s.columns]:null;if(!h&&!d){this.#a.clear();return}const o=d?this.#l(d):null;for(const b of[...this.#a.keys()]){const l=String(b).split(g);l.length===3&&(h&&!h.has(l[0])||o&&!o.has(l[2])||this.#a.delete(b))}}#l(s){const h=new Set,d=this.#t,o=[...s];for(;o.length;){const b=o.pop();if(!h.has(b)){h.add(b);for(const l of d?d.dependents.get(b)||[]:[])o.push(l)}}return h}value(s,h,d){const o=typeof s=="string"?this.#e.get(s):s;if(!o)return;if(!o.computed)return this.#c(o,h,d);if(o.value.pure!==!1&&this.#s&&d&&d.physical!=null&&this.#s.has(o.id))return this.#s.get(o.id,d.physical);if(o.volatile)return this.compute(o,h,d);if(o.value.pure===!1)return this.compute(o,h,d);const b=`${this.#o(h,d)}${g}${o.id}`;if(this.#a.has(b))return this.#a.get(b);const l=this.compute(o,h,d);return this.#a.set(b,l),l}#o(s,h){return`${this.#i(s,h)}${g}${u(s)}`}#c(s,h,d){if(this.#s&&d&&d.physical!=null&&this.#s.has(s.id))return this.#s.get(s.id,d.physical);if(s.field)return s.read?s.read(h):T(h,s.field)}compute(s,h,d){const o=this.#t,b=o&&o.wholeRow.has(s.id);let l;if(b)l=h??{};else{l={};const w=o&&o.deps.get(s.id)||[];for(const R of w)l[R]=this.value(R,h,d);const v=o&&o.external.get(s.id)||[];for(const R of v)l[R]=T(h,R);l=f(l,[...w,...v],s.id)}const p={data:h,row:d,column:s,grid:this.#n,context:this.#r};return s.value.compute(l,p)}values(s,h){const d={},o=this.#t?this.#t.order:[...this.#e.keys()];for(const b of o)d[b]=this.value(b,s,h);return d}text(s,h,d){const o=typeof s=="string"?this.#e.get(s):s;return o?o.formatValue(this.value(o,h,d),d,h):""}key(s,h,d){const o=typeof s=="string"?this.#e.get(s):s;if(!o)return"";const b=this.value(o,h,d);return D(o.value.key)?String(o.value.key(this.#u(o,b,h,d))):o.lookup?o.lookup.groupKey(b):I(b)?"":String(b)}quickFilterText(s,h,d){const o=typeof s=="string"?this.#e.get(s):s;if(!o)return"";if(D(o.value.quickFilterText)){const b=this.value(o,h,d);return String(o.value.quickFilterText(this.#u(o,b,h,d))??"")}return this.text(o,h,d)}#u(s,h,d,o){return{value:h,data:d,row:o,column:s,colId:s.id,grid:this.#n,context:this.#r}}parse(s,h,d,o){const b=typeof s=="string"?this.#e.get(s):s;if(!b)return h;const l={text:h,value:this.value(b,d,o),data:d,row:o,column:b,grid:this.#n,context:this.#r,locale:this.#n&&D(this.#n.get)?this.#n.get("locale"):void 0,formulaFunctions:this.#n&&D(this.#n.get)?this.#n.get("formulaFunctions"):void 0};return D(b.value.parse)?b.value.parse(l):b.dataType&&D(b.dataType.parse)?b.dataType.parse(l):h}validate(s,h,d,o,b){const l=typeof s=="string"?this.#e.get(s):s;if(!l||!D(l.edit.validate))return!0;const p=l.edit.validate({value:h,oldValue:d,data:o,row:b,column:l,grid:this.#n,context:this.#r});return p===!0||p===void 0?!0:String(p)}apply(s,h,d,o){const b=typeof s=="string"?this.#e.get(s):s;if(!b)return!1;const l=this.value(b,d,o);if(D(b.value.apply)){const p=b.value.apply({value:h,oldValue:l,data:d,row:o,column:b,grid:this.#n,context:this.#r});return this.#f(b,d,o),p!==!1}return b.field?l===h?!1:(b.write(d,h),this.#f(b,d,o),!0):($(`apply:${b.id}`,`column "${b.id}" has no \`field\` and no \`value.apply\`, so an edit cannot be written back.`),!1)}commit(s,h,d,o){const b=typeof s=="string"?this.#e.get(s):s;if(!b)return{ok:!1,value:void 0,oldValue:void 0,changed:!1,error:"unknown column"};const l=this.value(b,d,o),p=this.parse(b,h,d,o),w=this.validate(b,p,l,d,o);if(w!==!0)return{ok:!1,value:p,oldValue:l,changed:!1,error:w};const v=this.apply(b,p,d,o);return{ok:!0,value:p,oldValue:l,changed:v}}#f(s,h,d){if(this.#a.size===0)return;const o=this.#o(h,d);this.#a.delete(`${o}${g}${s.id}`);for(const b of this.#t?this.#t.dependents.get(s.id)||[]:[])this.#a.delete(`${o}${g}${b}`)}}function c(t,s){return s&&s.key!=null?String(s.key):u(t)}function u(t){if(t&&typeof t=="object"){let s=n.get(t);return s===void 0&&(s=`#${m++}`,n.set(t,s)),s}return String(t)}const n=new WeakMap;let m=0}),Ue("packages/core/src/model/shadow.js",function(e,B){"use strict";Object.defineProperty(e,"MAX_TRACKED",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"DEFAULT_DEPTH",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"HISTORY_TICK_MAX_MS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"HISTORY_TICK_MIN_MS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"historyTickFor",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"SHADOW_KINDS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"ROLLING_KINDS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"FIT_SHADOW_KINDS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"CLUSTER_SHADOW_KINDS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"DEFAULT_ANOMALY_THRESHOLD",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"SPEC_STATUS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"POSITIONAL_KINDS",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"SHADOW_LABELS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"specStatusOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ShadowTracker",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"shadowsIn",{enumerable:!0,get:function(){return s}});const T=B("packages/core/src/internal/warn.js").warnOnce,G=2e5,D=20,I=1e3,Z=50;function z(h){return Math.min(I,Math.max(Z,Math.floor(h)))}const L=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"]),$=Object.freeze(["fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),A=Object.freeze(["cluster","clusterDistance"]),k=.6745,y=3.5,f=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),g=Object.freeze(["rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag"]),a=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 r(h,d){if(!d)return null;const o=Number.isFinite(Number(d.lower))?Number(d.lower):null,b=Number.isFinite(Number(d.upper))?Number(d.upper):null;if(o===null&&b===null||!Number.isFinite(h))return null;if(o!==null&&h<o||b!==null&&h>b)return f.FAIL;const l=Number.isFinite(Number(d.warnLower))?Number(d.warnLower):null,p=Number.isFinite(Number(d.warnUpper))?Number(d.warnUpper):null;return l!==null&&h<l||p!==null&&h>p?f.WARN:f.PASS}function i(h,d,o){if(!d||typeof d!="object")return null;if(d.kind!=="time")return d.kind!==void 0&&T(`shadow.history.window.kind:${h}`,`a 'history' shadow's 'window' only accepts {kind: 'time', span}; '${d.kind}' is not honoured (a plain count is already what 'depth' means, and a session has no span to divide into buckets), so it reported the original, unwindowed history.`),null;const b=d.minutes!=null?Number(d.minutes)*6e4:Number(d.span);if(!(b>0))return T(`shadow.history.window.span:${h}`,"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 l=Math.max(2,Math.floor(o)||D);return{span:b,bucketMs:Math.max(1,Math.floor(b/l))}}class c{#e;#t=new Map;#n=new Map;#r=new Map;#i=new Map;#s=new Map;#a=new Map;#l=0;#o;#c;#u;#f;#d=new Map;#h=null;#p=null;#m=null;constructor(d){this.#e=d.colId,this.#o=Math.max(2,d.depth||D),this.#c=Math.max(1,d.max||G),this.#u=d.now||(()=>Date.now()),this.#f=i(this.#e,d.historyWindow,this.#o),this.#f&&(this.#h=Math.floor(this.#u()/this.#f.bucketMs))}get colId(){return this.#e}get forgotten(){return this.#l}get size(){return this.#n.size}get historyWindow(){return this.#f}observe(d,o){const b=t(o);if(b===null)return;if(!this.#n.has(d)){this.#p=null,this.#m=null,this.#g(),this.#t.set(d,b),this.#n.set(d,b),this.#r.set(d,0),this.#i.set(d,this.#u()),this.#s.set(d,[b]),this.#f&&this.#d.set(d,[b]),this.#a.set(d,0);return}const l=this.#n.get(d);if(l===b)return;this.#p=null,this.#m=null,this.#n.set(d,b),this.#r.set(d,(this.#r.get(d)||0)+1),this.#i.set(d,this.#u());const p=this.#s.get(d)||[];p.push(b),p.length>this.#o&&p.splice(0,p.length-this.#o),this.#s.set(d,p);const w=Math.sign(b-l),v=this.#a.get(d)||0;this.#a.set(d,Math.sign(v)===w?v+w:w)}#g(){if(this.#n.size<this.#c)return;const d=this.#n.keys().next().value;d!==void 0&&(this.#t.delete(d),this.#n.delete(d),this.#r.delete(d),this.#i.delete(d),this.#s.delete(d),this.#d.delete(d),this.#a.delete(d),this.#l++)}rebase(){for(const[d,o]of this.#n)this.#t.set(d,o);this.#p=null,this.#m=null}reset(){this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#i.clear(),this.#s.clear(),this.#d.clear(),this.#a.clear(),this.#l=0,this.#p=null,this.#m=null,this.#f&&(this.#h=Math.floor(this.#u()/this.#f.bucketMs))}retain(d){const o=d instanceof Set?d:new Set(d);let b=0;for(const l of[...this.#n.keys()])o.has(l)||(this.#t.delete(l),this.#n.delete(l),this.#r.delete(l),this.#i.delete(l),this.#s.delete(l),this.#d.delete(l),this.#a.delete(l),b++);return b&&(this.#p=null,this.#m=null),b}advanceHistoryWindow(d=this.#u()){const o=this.#f;if(!o)return 0;const b=Math.floor(d/o.bucketMs),l=b-this.#h;if(!(l>0))return 0;const p=Math.min(l,this.#o);for(const[w,v]of this.#d){const R=this.#n.get(w);for(let Y=0;Y<p;Y++)v.push(R);v.length>this.#o&&v.splice(0,v.length-this.#o)}return this.#h=b,l}read(d,o,b,l){switch(d){case"updates":return this.#r.has(o)?this.#r.get(o):0;case"updatedAt":{const p=this.#i.get(o);return p===void 0?null:new Date(p)}case"sinceUpdate":{const p=this.#i.get(o);return p===void 0?null:this.#u()-p}case"firstValue":return this.#t.has(o)?this.#t.get(o):null;case"delta":return this.#n.has(o)?this.#n.get(o)-this.#t.get(o):null;case"deltaPercent":{if(!this.#n.has(o))return null;const p=this.#t.get(o);return p?(this.#n.get(o)-p)/Math.abs(p)*100:null}case"rate":{const p=this.#s.get(o),w=this.#i.get(o);if(!p||p.length<2||w===void 0)return null;const v=this.#u()-w,R=p[p.length-1]-p[p.length-2];return v>0?R/v*1e3:R}case"history":return this.#f?this.#d.has(o)?[...this.#d.get(o)]:null:this.#s.has(o)?[...this.#s.get(o)]:null;case"streak":return this.#a.has(o)?this.#a.get(o):0;case"specStatus":return this.#n.has(o)?r(this.#n.get(o),l):null;default:return g.includes(d)?this.#O(d,o,b,l):null}}#b(d){if(d){if(this.#m&&this.#m.only===d)return this.#m.view;const o=this.#y(d);return this.#m={only:d,view:o},o}return this.#p?this.#p:(this.#p=this.#y(null),this.#p)}#y(d){const o=[];for(const[E,O]of this.#n)d&&!d.has(E)||o.push(O);const b=o.sort((E,O)=>E-O);let l=0,p=0,w=0,v=0;for(const E of b){v+=E,l++;const O=E-p;p+=O/l,w+=O*(E-p)}const R=[];for(const[E,O]of this.#t)d&&!d.has(E)||R.push(O);const Y=l?u(b):0,K=b.map(E=>Math.abs(E-Y)).sort((E,O)=>E-O),V=l?u(K):0;return{sorted:b,baseline:R.sort((E,O)=>E-O),sum:v,mean:l?p:0,sd:l>1?Math.sqrt(w/(l-1)):0,median:Y,mad:V}}#O(d,o,b,l){if(!this.#n.has(o)||b&&!b.has(o))return null;const p=this.#n.get(o),w=this.#b(b),v=w.sorted.length;if(!v)return null;switch(d){case"rank":return v-m(w.sorted,p)+1;case"rankAsc":return n(w.sorted,p)+1;case"rankChange":{if(!this.#t.has(o)||!w.baseline.length)return null;const R=w.baseline.length-m(w.baseline,this.#t.get(o))+1,Y=v-m(w.sorted,p)+1;return R-Y}case"percentile":return m(w.sorted,p)/v*100;case"quartile":{const R=m(w.sorted,p)/v;return Math.min(4,Math.max(1,Math.ceil(R*4)))}case"zScore":return w.sd?(p-w.mean)/w.sd:null;case"anomalyScore":return w.mad?k*(p-w.median)/w.mad:null;case"anomalyFlag":{if(!w.mad)return null;const R=l&&Number.isFinite(Number(l.threshold))?Number(l.threshold):y;return Math.abs(k*(p-w.median)/w.mad)>R}case"shareOfTotal":return w.sum?p/w.sum*100:null;default:return null}}}function u(h){const d=h.length;if(!d)return 0;const o=(d-1)*.5,b=Math.floor(o),l=Math.ceil(o);return b===l?h[b]:h[b]+(o-b)*(h[l]-h[b])}function n(h,d){let o=0,b=h.length;for(;o<b;){const l=o+b>>1;h[l]<d?o=l+1:b=l}return o}function m(h,d){let o=0,b=h.length;for(;o<b;){const l=o+b>>1;h[l]<=d?o=l+1:b=l}return o}function t(h){if(h==null||h==="")return null;if(h instanceof Date){const o=h.getTime();return Number.isFinite(o)?o:null}const d=typeof h=="number"?h:Number(h);return Number.isFinite(d)?d:null}function s(h){const d=[];for(const o of h||[]){const b=o.shadow;if(!b)continue;const l=typeof b=="string"?{kind:b}:b,p=l.kind;L.includes(p)&&(X.includes(p)||$.includes(p)||A.includes(p)||d.push({colId:o.id||o.field,of:l.of||o.field||o.id,kind:p,depth:l.depth,historyWindow:p==="history"?l.window:void 0}))}return d}}),Ue("packages/core/src/columns/model.js",function(e,B){"use strict";Object.defineProperty(e,"BUILTIN_DEFAULTS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"normaliseAlign",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"normaliseVAlign",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"expandColumn",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return le}}),Object.defineProperty(e,"flattenTree",{enumerable:!0,get:function(){return ke}});const re=B("packages/core/src/internal/merge.js"),T=re.expand,G=re.merge,D=re.toArray,I=B("packages/core/src/internal/warn.js"),Z=I.fail,z=I.warnOnce,L=B("packages/core/src/internal/paths.js"),X=L.getPath,$=L.pathGetter,A=L.pathSetter,y=B("packages/core/src/internal/text.js").humanise,f=B("packages/core/src/internal/predicates.js"),g=f.isFunction,a=f.isObject,i=B("packages/core/src/internal/uid.js").uid,u=B("packages/core/src/format/index.js").compileFormat,n=B("packages/core/src/columns/datatypes.js"),m=n.comparatorFor,t=n.createTypeRegistry,s=n.storageKind,h=B("packages/core/src/columns/infer.js"),d=h.inferColumnType,o=h.DEFAULT_SAMPLE,b=B("packages/core/src/columns/graph.js"),l=b.buildGraph,p=b.affectedBy,v=B("packages/core/src/columns/lookup.js").createLookup,R=B("packages/core/src/columns/value.js"),Y=R.compileDisplay,K=R.ValuePipeline,V=R.warnImpureUse,E=B("packages/core/src/model/shadow.js"),O=E.FIT_SHADOW_KINDS,C=E.CLUSTER_SHADOW_KINDS,S=Object.freeze({geometry:"geometry",list:"list"}),F={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},P={centre:"center"},M=new Set(["start","center","end","left","right"]);function x(ce){if(typeof ce!="string")return;const ae=ce.toLowerCase();return P[ae]?P[ae]:M.has(ae)?ae:void 0}function U(ce){if(typeof ce!="string")return;const ae=ce.toLowerCase();return ae==="center"||ae==="centre"?"middle":ae==="top"||ae==="middle"||ae==="bottom"?ae:void 0}const _=["cell","layout","header"];function W(ce){if(!a(ce))return{};const ae={...ce},ge=(de,me)=>{if(ce[de]===void 0)return;const ve=T(ce[de],me);ve&&_.includes(de)&&!a(ce[de])&&delete ve.enabled,ae[de]=ve};return ge("sort","direction"),ge("filter","type"),ge("cell","render"),ge("edit","editor"),ge("layout","width"),ge("group","index"),ge("pivot","index"),ge("header","render"),ge("facet","strategy"),ae}function q(ce,ae){const ge={...ce||{}},de=a(ae)&&a(ae.layout)&&ae.layout.width!==void 0;return ge.fit==="content"&&!de&&delete ge.width,ge}const N=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"]),Q=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function J(ce,ae,ge,de){const me=ge==="columnGroup"?"column group":"column";for(const ve of Object.keys(ce))if(!ae.has(ve)){if(ve==="timeZone"&&ge==="column"){z("column.timeZone",`\`timeZone\` is not a column option, so it had no effect on column "${de}". A date column stores, displays, sorts and filters in the grid-level \`timeZone\` (else the viewer's); set \`timeZone\` on the grid, not the column.`);continue}z(`${ge}.unknown:${ve}`,`'${ve}' is not a configuration key this grid recognises, so it had no effect on ${me} "${de}". Check the spelling against the reference.`)}}function ee(ce){a(ce.cell)&&ce.cell.autoHeight!==void 0&&z("column.cell.autoHeight",`\`cell.autoHeight\` is not a column option, so it had no effect on column "${ce.id||ce.field||"(unnamed)"}". Rows grow to fit with the grid-level \`autoHeight\`; \`cell.wrap\` lets this column's text wrap.`)}function ne(ce,ae){const ge=ae&&g(ce.defaultsFor)?ce.defaultsFor(ae):null,de={...ce.defaults||{},...a(ge)?ge:{}},me={};return de.align&&(me.align=de.align,me.cell={align:de.align},me.header={align:de.align}),de.filter&&(me.filter=de.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:de.filter}),de.editor&&(me.edit=de.editor==="none"?{editor:null}:{editor:de.editor}),de.total&&(me.total=de.total),de.render&&(me.cell={...me.cell||{},render:de.render}),ce.export&&(me.export={...ce.export}),me}function se(ce){if(typeof ce=="string")return ce.trim()?[ce.trim()]:[];if(!Array.isArray(ce))return[];const ae=[];for(const ge of ce){if(typeof ge!="string")continue;const de=ge.trim();de&&!ae.includes(de)&&ae.push(de)}return ae}class le{#e=new Map;#t=[];#n=[];#r=new WeakMap;#i;#s;#a;#l;#o;#c;#u(ae,ge,de){if(ae&&typeof ae=="object"&&!g(ae)){const Ee=ae;return(typeof Ee.fn!="string"||!Ee.fn)&&Z(`column "${de}": a total given as an object needs a \`fn\` name, such as { fn: 'percentile', p: 0.9 }.`),Ee.fn==="percentile"&&!(typeof Ee.p=="number"&&Ee.p>=0&&Ee.p<=1)&&Z(`column "${de}": { fn: 'percentile' } needs \`p\`, a number from 0 to 1 (0.9 for the 90th percentile).`),this.#f(Ee.fn,ge,de),Object.freeze({...Ee})}const me=this.#f(ae,ge,de);if(typeof me!="string"||!this.#d)return me??null;const ve=ge&&ge.totals&&ge.totals.implement;if(ve&&g(ve[me])){const Ee=ve[me];return Ee.totalName=me,Ee}const xe=this.#d.totalFn?.(me);return g(xe)?xe:me}#f(ae,ge,de){if(typeof ae!="string")return ae;const me=ge&&ge.totals&&ge.totals.supported;if(!Array.isArray(me)||me.includes(ae))return ae;const ve=me.length?me.join(", "):"none";return Z(`column "${de}" is typed ${ge.name||"a type"}, for which the total "${ae}" is not meaningful. Supported: ${ve}. Aggregating it anyway would produce a confident wrong number.`),ae}#d;#h;#p;#m;#g;#b;#y=!1;#O;#w;constructor(ae={}){this.#s=W(ae.columnDefaults||{}),this.#a=ae.columnPresets||{},this.#o=ae.locale,this.#l=ae.timeZone,this.#c=U(ae.verticalAlign),this.#d=ae.registry||null,this.#h=ae.grid||null,this.#p=ae.context,this.#O=ae.sampleSize??o,this.#w=ae.onChange||null,this.#b=g(ae.rowKey)?ae.rowKey:void 0,this.#i=t(ae.dataTypes,this.#d);const{leaves:ge,groups:de}=ke(ae.columns||[]);this.#n=de;for(const me of ge){me.facet!==void 0&&this.#r.set(me.def,me.facet);const ve=this.#A(me.def,null);if(ve.groupPath=me.path,this.#e.has(ve.id)){z(`columns.duplicate:${ve.id}`,`two columns resolve to the id '${ve.id}', so the second is ignored. An id defaults to the column's field, so declare an explicit \`id\` when two columns read the same field.`);continue}me.column=ve,this.#e.set(ve.id,ve),this.#t.push(ve.id)}this.#C(ae.stored||null)}#A(ae,ge){J(ae,N,"column",ae.id||ae.field||"(unnamed)"),ee(ae);const de=W(ae),me=D(ae.preset),ve=me.map(Te=>{const Be=this.#a[Te];return Be?W(Be):(z(`preset:${Te}`,`unknown column preset "${Te}"; ignoring`),{})}),xe=this.#S(de,ve,ge),Ee=this.#i.get(xe)||this.#i.get("text");if(!this.#i.has(xe)&&ae.type){const Te=S[xe];z(`type:${xe}`,`unknown data type "${xe}"; falling back to "text"`+(Te?`. It is registered by importing '@toclocoinc/lattice-grid/modules/${Te}'.`:""))}const Le=g(Ee.items)?this.#P(de,ve,ae.id||ae.field||"(unnamed)"):null;let He=F;He=G(He,this.#s),ae.type!==!1&&(He=G(He,ne(Ee,Le)));for(const Te of ve)He=G(He,Te);this.#r.has(ae)&&(He=G(He,W({facet:this.#r.get(ae)}))),He=G(He,de);const Me=He.edit;Me&&Me.editor&&Me.enabled!==!0&&!g(Me.enabled)&&(ae.edit||{}).editor&&z(`column.editor-not-enabled:${ae.id||ae.field}`,`column '${ae.id||ae.field}' names the editor '${Me.editor}' but does not enable editing, so it stays read-only. Add \`enabled: true\`, or use \`edit: true\` and set \`editor\` alongside it.`);const Ke=ae.id||ae.field||i("col");if(ae.shadow&&!g(He.value&&He.value.compute)){const Te=typeof ae.shadow=="string"?{kind:ae.shadow}:ae.shadow,Be=Te.of||ae.field||Ke,Ge=O.includes(Te.kind),et=C.includes(Te.kind),Je=Ge?Te.model||Te:null,ft=Ge&&Je?[...Array.isArray(Je.predictors)?Je.predictors:[],Je.response].filter(Boolean):null,Et=et?(Array.isArray(Te.columns)?Te.columns:[]).filter(Boolean):null;He.value={...He.value||{},deps:Et&&Et.length?Et:ft&&ft.length?ft:Te.orderBy&&Te.orderBy!==Be?[Be,Te.orderBy]:[Be],pure:!1,compute:(Mt,rt)=>{const ot=rt.grid&&rt.grid.statistics;if(!ot)return null;const ut=rt.row&&rt.row.key||ot.keyOf(rt.data);if(!ut)return null;if(Ge){if(!g(ot.fitShadow))return null;const Tt=Te.model?{...Te.model,threshold:Te.threshold}:Te;return ot.fitShadow(Te.kind,ut,Tt)}return et?g(ot.clusterShadow)?ot.clusterShadow(Te.kind,ut,Te):null:ot.shadow(Be,Te.kind,ut,Te.scope,Te)}}}if(ae.running&&!g(He.value&&He.value.compute)){const Te=typeof ae.running=="string"?{kind:ae.running}:ae.running,Be=Te.of||ae.field||Ke;He.value={...He.value||{},deps:[Be],pure:!1,compute:(Ge,et)=>{const Je=et.grid&&et.grid.statistics;if(!Je||!g(Je.running))return null;const ft=et.row&&et.row.key||Je.keyOf(et.data);return ft?Je.running(Be,Te.kind||"total",ft):null}},ae.sort===void 0&&(He.sort={...He.sort||{},enabled:!1})}const $e=ae.field??(g(He.value&&He.value.compute)?null:ae.id??null),Oe=g(He.value&&He.value.compute),Se={id:Ke,field:$e,shadow:ae.shadow||null,running:ae.running||null,spec:ae.spec||null,validation:ae.validation||null,volatile:!!(ae.shadow||ae.running),title:He.title??y($e||Ke),type:Ee.name,dataType:Ee,itemType:Le,nullable:He.nullable!==!1,align:x(de.cell&&de.cell.align||de.align||He.cell&&He.cell.align||He.align||Ee.defaults&&Ee.defaults.align)||"start",verticalAlign:U(de.cell&&de.cell.verticalAlign||de.verticalAlign||He.cell&&He.cell.verticalAlign||He.verticalAlign)||this.#c,rowSpan:g(He.rowSpan)?He.rowSpan:null,colSpan:g(He.colSpan)?He.colSpan:null,value:{pure:!0,...He.value||{}},cell:{...He.cell||{}},edit:{...He.edit||{}},sort:{...He.sort||{}},filter:{...He.filter||{}},group:{enabled:!1,index:-1,explode:!1,...He.group||{}},pivot:{enabled:!1,index:-1,...He.pivot||{}},total:this.#u(He.total,Ee,ae.id||ae.field||"(unnamed)"),groupTotal:He.groupTotal===void 0?null:this.#u(He.groupTotal,Ee,ae.id||ae.field||"(unnamed)"),grandTotal:He.grandTotal===void 0?null:this.#u(He.grandTotal,Ee,ae.id||ae.field||"(unnamed)"),tags:se(He.tags),typeOptions:He.typeOptions??null,...a(He[xe])?{[xe]:He[xe]}:{},layout:q(He.layout,de),header:{...He.header||{}},contextMenu:He.contextMenu===void 0?null:He.contextMenu,facet:{...He.facet||{}},export:{...He.export||{}},allowGroup:He.allowGroup!==!1,allowPivot:He.allowPivot!==!1,allowTotal:He.allowTotal!==!1,quickFilter:He.quickFilter!==!1,def:ae,format:He.format,presets:me,inferred:ge!=null&&!ae.type,computed:Oe,diff:ae.diff===void 0?void 0:!!ae.diff,read:$e?$($e):null,write:$e?A($e):null};Se.cell.align=x(de.cell&&de.cell.align)||Se.align,Se.header.align=x(de.header&&de.header.align)||Se.align;const Pe=He.lookup||null;return Se.lookup=Pe?v({id:Ke,lookup:Pe},{locale:this.#o,onChange:()=>{this.#w&&this.#w("lookup",{colId:Ke})}}):null,Se.group.explode&&Se.lookup&&Se.lookup.multiple&&z(`explode:${Ke}`,`column "${Ke}" has \`group.explode\`, so rows appear under each of their values and totals double-count. Group footers should be annotated accordingly.`),this.#v(Se),Se}#v(ae){ae.formatter=u(ae.format,ae.dataType,this.#o,this.#l,ae.id),ae.formatValue=Y(ae,{locale:this.#o,grid:this.#h,context:this.#p}),ae.itemCompare=ae.itemType?m(ae.itemType,this.#o):null,ae.compare=g(ae.value.compare)?ae.value.compare:ae.lookup?ae.lookup.comparator():g(ae.dataType.compareFor)?ae.dataType.compareFor(ae):m(ae.dataType,this.#o),ae.excel=ae.formatter&&ae.formatter.ooxml||ae.dataType&&ae.dataType.excel||"General",ae.storeKind=s(ae.dataType,!!(ae.lookup&&ae.lookup.multiple))}#P(ae,ge,de){let me=a(ae.typeOptions)?ae.typeOptions:null;for(let Le=ge.length-1;!me&&Le>=0;Le--)a(ge[Le].typeOptions)&&(me=ge[Le].typeOptions);!me&&a(this.#s.typeOptions)&&(me=this.#s.typeOptions);const ve=me&&me.of!==void 0?me.of:"text",xe=typeof ve=="string"?this.#i.get(ve):void 0;return xe&&!g(xe.items)&&xe.storage!=="object"?xe:(z(`type:of:${String(ve)}`,`column "${de}" names "${String(ve)}" as its item type (typeOptions.of), which is not ${xe?"a scalar data type":"a known data type"}; its items are read as text.`),this.#i.get("text"))}#S(ae,ge,de){if(ae.type===!1)return"text";if(ae.type)return ae.type;for(let me=ge.length-1;me>=0;me--)if(ge[me].type)return ge[me].type;if(this.#s.type)return this.#s.type;if(ae.shadow){const me=typeof ae.shadow=="string"?ae.shadow:ae.shadow.kind;if(me==="fitInfluence")return"boolean";if(me==="fitPredicted"||me==="fitResidual"||me==="fitStdResidual"||me==="fitLeverage"||me==="fitCooksD"||me==="tsTrend"||me==="tsSeasonal"||me==="tsResidual"||me==="tsCoverage"||me==="tsSmoothed"||me==="tsSmoothingAlpha"||me==="tsSmoothingBeta"||me==="cluster"||me==="clusterDistance")return"number"}return de||(ae.lookup?"lookup":"text")}#C(ae){const ge=this.all();this.#m=l(ge),this.#g?this.#g.setGraph(this.#m):this.#g=new K({columns:this.#e,graph:this.#m,grid:this.#h,context:this.#p,stored:ae||null,rowKey:this.#b});const de=this.#g;for(const me of ge)me.getValue=(ve,xe)=>de.value(me,ve,xe)}all(){return this.#t.map(ae=>this.#e.get(ae))}visible(){return this.all().filter(ae=>!ae.layout.hidden)}get(ae){return this.#e.get(ae)}groups(){const ae=ge=>{const de=[];for(const me of ge)Array.isArray(me.columns)?de.push({...me,columns:ae(me.columns)}):me.column&&de.push(me.column);return de};return ae(this.#n)}graph(){return this.#m}pipeline(){return this.#g}types(){return this.#i}affectedBy(ae){return p(this.#m,ae)}value(ae,ge,de){return this.#g.value(ae,ge,de)}text(ae,ge,de){return this.#g.text(ae,ge,de)}checkImpure(ae,ge){V(this.#e.get(ae),ge)}setLocale(ae){this.#o=ae;for(const ge of this.all())ge.lookup&&ge.lookup.setLocale(ae),this.#v(ge);this.#w&&this.#w("locale",{locale:ae})}infer(ae){const ge={};if(this.#y||!Array.isArray(ae)||ae.length===0)return ge;this.#y=!0;let de=!1;for(const me of this.all()){const ve=me.def;if(ve.type!==void 0||!me.field||me.computed||me.lookup||this.#E(me))continue;const xe=me.read||(He=>X(He,me.field)),Ee=d(me.id,ae,xe,this.#i,{sampleSize:this.#O});if(Ee===me.type)continue;ge[me.id]=Ee;const Le=this.#A(ve,Ee);Le.groupPath=me.groupPath,Le.layout={...Le.layout,...ye(me.layout)},this.#e.set(me.id,Le),Ce(this.#n,me.id,Le),de=!0}return de&&this.#C(null),ge}redecorate(ae,ge,de={}){const me=this.#e.get(ae);if(!me){z(`redecorate:${ae}`,`columns.decorate('${ae}', …): no column with id '${ae}'.`);return}const ve=me.def||{},xe={...a(ve.cell)?ve.cell:{}};xe.decoration=ge??void 0,de&&"variant"in de&&(xe.variant=de.variant);const Ee={...ve,cell:xe};this.#r.has(ve)&&this.#r.set(Ee,this.#r.get(ve));const Le=this.#A(Ee,me.type);return Le.groupPath=me.groupPath,Le.layout={...Le.layout,...ye(me.layout)},me.lookup&&me.lookup!==Le.lookup&&g(me.lookup.destroy)&&me.lookup.destroy(),this.#e.set(ae,Le),Ce(this.#n,ae,Le),this.#C(null),this.#w&&this.#w("decorate",{colId:ae}),Le}destroy(){for(const ae of this.#e.values())ae.lookup&&g(ae.lookup.destroy)&&ae.lookup.destroy()}#E(ae){for(const ge of ae.presets){const de=this.#a[ge];if(de&&de.type)return!0}return!!this.#s.type}#T(ae){return!ae.computed&&g(ae.dataType&&ae.dataType.toStorage)}storeReader(ae){if(ae.computed)return ge=>this.#g.value(ae,ge,null);if(this.#T(ae)){const ge=ae.dataType.toStorage,de=ae.format&&typeof ae.format=="object"&&!Array.isArray(ae.format)?ae.format.locale:void 0,me={timeZone:this.#l,colId:ae.id,itemType:ae.itemType||null,locale:de||this.#o};return ve=>ge(ae.read(ve),me)}return ae.read}storeValue(ae,ge){if(!(!ae||ae.computed)&&g(ae.read))return this.storeReader(ae)(ge)}storeSchema(){const ae=[];for(const ge of this.all()){if(ge.computed&&ge.value.pure===!1||!ge.computed&&!ge.field)continue;const de=this.storeReader(ge);let me=null;!ge.computed&&!this.#T(ge)&&typeof ge.field=="string"&&!ge.lookup&&(me=ge.field);const ve={id:ge.id,kind:ge.storeKind,nullable:ge.nullable,read:de};me!==null&&(ve.field=me),ge.lookup&&(ve.dictionary=ge.lookup.dictionary()),ae.push(ve)}return ae}state(){return this.all().map(ae=>({id:ae.id,width:ae.layout.width,flex:ae.layout.flex||void 0,hidden:!!ae.layout.hidden,headerWrap:ae.header?.wrap===!0?!0:void 0,headerOrientation:ae.header?.orientation==="vertical"?"vertical":void 0,pin:ae.layout.pin??null,sort:ae.sort.direction??null,sortIndex:ae.sort.direction?ae.sort.order??0:null,groupIndex:ae.group.enabled?ae.group.index??0:null,pivotIndex:ae.pivot.enabled?ae.pivot.index??0:null,total:typeof ae.total=="string"?ae.total:null,groupTotal:typeof ae.groupTotal=="string"?ae.groupTotal:void 0,grandTotal:typeof ae.grandTotal=="string"?ae.grandTotal:void 0,decoration:ae.cell&&ae.cell.decoration!=null?fe(ae.cell.decoration):void 0,variant:ae.cell&&ae.cell.variant!=null?fe(ae.cell.variant):void 0}))}applyState(ae,ge={}){const de={applied:[],skipped:[]},me=Array.isArray(ae)?ae:ae&&ae.columns||[],ve=!Array.isArray(ae)&&ae&&ae.columnOrder||null;for(const Ee of me){if(!Ee||!Ee.id){de.skipped.push({key:"?",reason:"no id"});continue}let Le=this.#e.get(Ee.id);if(!Le){de.skipped.push({key:Ee.id,reason:"unknown column"});continue}if(Object.hasOwn(Ee,"decoration")||Object.hasOwn(Ee,"variant")){const He=Le.cell?Le.cell.decoration:void 0,Me=Ee.decoration??null,Ke=Object.hasOwn(Ee,"variant"),$e=Ke&&!we(Le.cell?Le.cell.variant:void 0,Ee.variant);(!we(He,Me)||$e)&&(this.redecorate(Ee.id,Me,Ke?{variant:Ee.variant??void 0}:{}),Le=this.#e.get(Ee.id)||Le)}Ee.width!=null&&(Le.layout.width=Ee.width),Ee.flex!=null&&(Le.layout.flex=Ee.flex),Ee.hidden!=null&&(Le.layout.hidden=!!Ee.hidden),Ee.headerWrap!==void 0&&(Le.header.wrap=!!Ee.headerWrap),Ee.headerOrientation!==void 0&&(Le.header.orientation=Ee.headerOrientation==="vertical"?"vertical":"horizontal"),Ee.pin!==void 0&&(Le.layout.pin=Ee.pin),Ee.sort!==void 0&&(Le.sort.direction=Ee.sort),Ee.sortIndex!=null&&(Le.sort.order=Ee.sortIndex),Ee.groupIndex!=null&&(Le.group.enabled=!0,Le.group.index=Ee.groupIndex),Ee.pivotIndex!=null&&(Le.pivot.enabled=!0,Le.pivot.index=Ee.pivotIndex),Ee.total!==void 0&&(Le.total=Ee.total),Ee.groupTotal!==void 0&&(Le.groupTotal=Ee.groupTotal),Ee.grandTotal!==void 0&&(Le.grandTotal=Ee.grandTotal),de.applied.push(Ee.id)}const xe=ve||(ge&&ge.keepOrder?[]:me.map(Ee=>Ee&&Ee.id).filter(Boolean));if(xe.length){const Ee=xe.filter(He=>this.#e.has(He)),Le=this.#t.filter(He=>!Ee.includes(He));this.#t=[...Ee,...Le]}return this.#w&&this.#w("state",de),de}move(ae,ge){this.#M(ae,ge)&&(this.#R(),this.#w&&this.#w("move",{id:ae,to:ge}))}reorder(ae){const ge={applied:[],skipped:[]},de=[];let me=0;for(const ve of Array.isArray(ae)?ae:[]){const xe=me++;this.#M(ve,xe)&&(ge.applied.push(ve),de.push({id:ve,to:xe}))}if(!de.length)return ge;if(this.#R(),this.#w)for(const ve of de)this.#w("move",ve);return ge}#M(ae,ge){const de=this.#t.indexOf(ae);if(de===-1||Math.max(0,Math.min(Number(ge)||0,this.#t.length-1))===de)return!1;const ve=this.#e.get(ae);if(ve.layout.movable===!1||ve.layout.lockPosition)return z(`move:${ae}`,`column "${ae}" is not movable; the move was ignored`),!1;const xe=this.#N(ae,ge);return xe?(z(`move.married:${xe}`,`band "${xe}" declares marryChildren, so its columns stay together; the move was ignored`),!1):(this.#t.splice(de,1),this.#t.splice(Math.max(0,Math.min(ge,this.#t.length)),0,ae),!0)}#N(ae,ge){if(!this.#n||!this.#n.length)return null;const de=this.#t.filter(Ee=>Ee!==ae),me=Math.max(0,Math.min(ge,de.length)),ve=(Ee,Le)=>{if(Array.isArray(Ee.columns)){for(const Me of Ee.columns)ve(Me,Le);return Le}const He=Ee.column?Ee.column.id:Ee.id;return He&&Le.push(He),Le},xe=Ee=>{for(const Le of Ee){if(!Array.isArray(Le.columns))continue;if(Le.marryChildren===!0){const Me=ve(Le,[]),Ke=Me.includes(ae),$e=Me.map(Oe=>de.indexOf(Oe)).filter(Oe=>Oe>=0);if($e.length){const Oe=Math.min(...$e),Se=Math.max(...$e);if(Ke?me<Oe||me>Se+1:me>Oe&&me<=Se)return Le.id}}const He=xe(Le.columns);if(He)return He}return null};return xe(this.#n)}#R(){const ae=new Map(this.#t.map((me,ve)=>[me,ve])),ge=me=>{if(!Array.isArray(me.columns)){const xe=me.column?me.column.id:me.id;return ae.has(xe)?ae.get(xe):1/0}let ve=1/0;for(const xe of me.columns)ve=Math.min(ve,ge(xe));return ve},de=me=>{me.sort((ve,xe)=>ge(ve)-ge(xe));for(const ve of me)Array.isArray(ve.columns)&&de(ve.columns)};de(this.#n)}#I(ae){const ge=de=>{for(let me=0;me<de.length;me++){const ve=de[me];if(Array.isArray(ve.columns)){const xe=ge(ve.columns);if(xe)return xe}else if(ve.column&&ve.column.id===ae)return de.splice(me,1)[0]}return null};return ge(this.#n)}#G(ae){const ge=[];for(let de=ae.length-1;de>=0;de--){const me=ae[de];Array.isArray(me.columns)&&(ge.push(...this.#G(me.columns)),me.columns.length===0&&(ge.push(me.id),ae.splice(de,1)))}return ge}#K(){const ae=(ge,de,me)=>{for(const ve of ge)Array.isArray(ve.columns)?ae(ve.columns,[...de,ve.id]):ve.column&&(ve.column.groupPath=de)};ae(this.#n,[])}#L(ae){const ge=new Set(ae),de=this.#t.filter(Ee=>ge.has(Ee));if(!de.length)return;const me=Math.min(...de.map(Ee=>this.#t.indexOf(Ee))),ve=this.#t.slice(0,me).filter(Ee=>!ge.has(Ee)),xe=this.#t.slice(me).filter(Ee=>!ge.has(Ee));this.#t=[...ve,...de,...xe]}#q(ae){const ge=[],de=me=>{if(Array.isArray(me.columns))for(const ve of me.columns)de(ve);else me.column&&ge.push(me.column.id)};return de(ae),ge}#U(ae){const ge=de=>{for(const me of de){if(!Array.isArray(me.columns))continue;if(me.id===ae)return{node:me,parent:de};const ve=ge(me.columns);if(ve)return ve}return null};return ge(this.#n)}groupColumns(ae,ge={}){const de=D(ae).filter(Le=>this.#e.has(Le));if(!de.length)return z("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const Le of de)if(this.#e.get(Le).layout.lockPosition)return z(`columns.group.locked:${Le}`,`column "${Le}" is position-locked and cannot be grouped.`),null;const me=ge.groupId?this.#U(ge.groupId):null;if(ge.groupId&&!me)return z(`columns.group.unknown:${ge.groupId}`,`no band "${ge.groupId}" to add to; nothing was grouped.`),null;let ve=null;if(!me&&ge.id!=null&&(ve=String(ge.id),this.#U(ve)||this.#e.has(ve)))return z(`columns.group.idtaken:${ve}`,`band id "${ve}" is already in use; nothing was grouped.`),null;const xe=de.map(Le=>this.#I(Le)).filter(Boolean);if(!xe.length)return null;let Ee;if(me)me.node.columns.push(...xe),Ee=me.node.id;else{const Le={id:ve||i("grp"),title:ge.title||"",collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!1,header:{},def:{},columns:xe},He=Number.isInteger(ge.at)?Math.max(0,Math.min(ge.at,this.#n.length)):this.#n.length;this.#n.splice(He,0,Le),Ee=Le.id}return this.#G(this.#n),this.#L(de),this.#K(),this.#R(),this.#w&&this.#w("columngroup",{action:"formed",groupId:Ee,ids:de}),Ee}ungroupColumn(ae){const ge=this.#e.get(ae);if(!ge){z(`columns.ungroup.unknown:${ae}`,`no column "${ae}" to ungroup.`);return}const de=ge.groupPath||[];if(!de.length)return;const me=de[de.length-1],ve=this.#U(me);if(!ve)return;const xe=this.#I(ae);if(!xe)return;const Ee=ve.parent.indexOf(ve.node);ve.parent.splice(Ee+1,0,xe);const Le=this.#G(this.#n),He=this.#q(ve.node);if(He.length){this.#L(He);const Me=Math.max(...He.map($e=>this.#t.indexOf($e))),Ke=this.#t.filter($e=>$e!==ae);Ke.splice(Me+1,0,ae),this.#t=Ke}this.#K(),this.#R(),this.#w&&this.#w("columngroup",{action:"removed",id:ae,dissolved:Le})}renameGroup(ae,ge){const de=this.#U(ae);if(!de){z(`columns.group.rename:${ae}`,`no band "${ae}" to rename.`);return}de.node.title=String(ge??""),this.#w&&this.#w("columngroup",{action:"renamed",groupId:ae,title:de.node.title})}dissolveGroup(ae){const ge=this.#U(ae);if(!ge){z(`columns.group.dissolve:${ae}`,`no band "${ae}" to dissolve.`);return}const de=ge.parent.indexOf(ge.node);ge.parent.splice(de,1,...ge.node.columns),this.#K(),this.#R(),this.#w&&this.#w("columngroup",{action:"dissolved",groupId:ae})}moveGroup(ae,ge){const de=this.#U(ae);if(!de){z(`columns.group.move:${ae}`,`no band "${ae}" to move.`);return}const me=de.parent,ve=me.indexOf(de.node);ve!==-1&&(me.splice(ve,1),me.splice(Math.max(0,Math.min(ge,me.length)),0,de.node),this.#Y(),this.#K(),this.#w&&this.#w("columngroup",{action:"moved",groupId:ae,to:ge}))}#Y(){const ae=[],ge=me=>{for(const ve of me)Array.isArray(ve.columns)?ge(ve.columns):ve.column&&ae.push(ve.column.id)};ge(this.#n);const de=new Set(ae);this.#t=[...ae,...this.#t.filter(me=>!de.has(me))]}groupTree(){const ae=de=>de.map(me=>Array.isArray(me.columns)?{id:me.id,title:me.title||"",collapsible:!!me.collapsible,openByDefault:me.openByDefault!==!1,columns:ae(me.columns)}:me.column?me.column.id:null).filter(me=>me!==null),ge=ae(this.#n);return ge.some(de=>de&&typeof de=="object")?ge:[]}applyGroupTree(ae){if(!Array.isArray(ae))return;const ge=new Set,de=ve=>{const xe=[];for(const Ee of ve)if(Ee&&typeof Ee=="object"&&Array.isArray(Ee.columns)){const Le=de(Ee.columns);if(!Le.length)continue;xe.push({id:Ee.id||i("grp"),title:Ee.title||"",collapsible:Ee.collapsible===!0,openByDefault:Ee.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Le})}else if(typeof Ee=="string"){const Le=this.#e.get(Ee);Le&&!ge.has(Ee)&&(ge.add(Ee),xe.push({column:Le,path:[]}))}return xe},me=de(ae);for(const ve of this.#t){if(ge.has(ve))continue;const xe=this.#e.get(ve);xe&&me.push({column:xe,path:[]})}this.#n=me,this.#K(),this.#R(),this.#w&&this.#w("columngroup",{action:"applied"})}show(ae){this.#z(ae,!1)}hide(ae){this.#z(ae,!0)}#z(ae,ge){const de=[];for(const me of D(ae)){const ve=this.#e.get(me);if(ve){if(ge&&ve.layout.lockVisible){z(`lockVisible:${me}`,`column "${me}" is \`layout.lockVisible\` and cannot be hidden`);continue}ve.layout.hidden!==ge&&(ve.layout.hidden=ge,de.push(me))}}de.length&&this.#w&&this.#w("visible",{ids:de,hidden:ge})}pin(ae,ge){const de=this.#e.get(ae);de&&(de.layout.pin=ge??null,this.#w&&this.#w("pin",{id:ae,side:de.layout.pin}))}pinMany(ae){const ge={};for(const[me,ve]of ae){const xe=this.#e.get(me);xe&&(xe.layout.pin=ve??null,ge[me]=xe.layout.pin)}const de=Object.keys(ge);de.length&&this.#w&&this.#w("pin",{ids:de,pins:ge})}#D(ae,ge){const de=ae.layout.min??0,me=ae.layout.max;let ve=Math.max(de,ge);return me!=null&&(ve=Math.min(me,ve)),ae.layout.width=ve,ae.layout.flex=0,ve}resize(ae,ge){const de=this.#e.get(ae);if(!de)return;if(de.layout.resizable===!1){z(`resize:${ae}`,`column "${ae}" is not resizable; the resize was ignored`);return}const me=this.#D(de,ge);this.#w&&this.#w("resize",{id:ae,width:me})}resizeMany(ae){const ge={};for(const[me,ve]of ae){const xe=this.#e.get(me);if(xe){if(xe.layout.resizable===!1){z(`resize:${me}`,`column "${me}" is not resizable; the resize was ignored`);continue}ge[me]=this.#D(xe,ve)}}const de=Object.keys(ge);de.length&&this.#w&&this.#w("resize",{ids:de,widths:ge})}}function ye(ce){const ae={};return ce.width!=null&&(ae.width=ce.width),ce.hidden!=null&&(ae.hidden=ce.hidden),ce.pin!==void 0&&(ae.pin=ce.pin),ae}function fe(ce){if(ce===null||typeof ce!="object")return ce;try{return structuredClone(ce)}catch{}try{return JSON.parse(JSON.stringify(ce))}catch{return ce}}function we(ce,ae){const ge=ce??null,de=ae??null;if(ge===de)return!0;if(ge===null||de===null)return!1;if(typeof ge!="object"||typeof de!="object")return ge===de;try{return JSON.stringify(ge)===JSON.stringify(de)}catch{return!1}}function ke(ce){const ae=[],ge=(me,ve,xe)=>{const Ee=[];for(const Le of me){if(!a(Le)){Z("a column definition must be an object");continue}if(Array.isArray(Le.columns)){J(Le,Q,"columnGroup",Le.title||Le.id||"(unnamed)");const He={id:Le.id||i("grp"),title:Le.title||"",collapsible:Le.collapsible===!0,openByDefault:Le.openByDefault!==!1,showWhen:Le.showWhen||"always",marryChildren:Le.marryChildren===!0,header:Le.header||{},def:Le,columns:[]};He.columns=ge(Le.columns,[...ve,He.id],Le.facet!==void 0?Le.facet:xe),Ee.push(He)}else{const He={def:Le,path:ve,facet:xe};ae.push(He),Ee.push(He)}}return Ee},de=ge(ce,[],void 0);return{leaves:ae,groups:de}}function Ce(ce,ae,ge){for(const de of ce){if(de.columns){if(Ce(de.columns,ae,ge))return!0;continue}if(de.column&&de.column.id===ae)return de.column=ge,!0}return!1}}),Ue("packages/core/src/columns/autogroup.js",function(e,B){"use strict";Object.defineProperty(e,"AUTO_GROUP_ID",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"createAutoGroupColumn",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"warnOnAbsurdGrouping",{enumerable:!0,get:function(){return X}});const T=B("packages/core/src/internal/warn.js").warnOnce,G="__lattice_group",D=240,I=.5;function Z($){const A=$.def&&$.def.layout;return(typeof A=="number"||A&&A.width!=null||$.def&&$.def.width!=null)&&Number.isFinite($.layout.width)?$.layout.width:null}function z($){const A=$.def&&$.def.layout;return!!(A&&A.min!=null)||$.def&&$.def.minWidth!=null}function L($){const{columns:A,groupBy:k}=$,y=k.map(c=>A.get(c)).filter(Boolean),f=y.length?y.map(c=>c.title||c.id).join(" > "):"Group",g=y.find(c=>Z(c)!=null),a=$.config&&$.config.autoGroupColumnWidth||(g?Z(g):D);let r=g&&z(g)?g.layout.min:120;g&&!z(g)&&(r=Math.min(r,a));const i=g&&g.layout.max!=null?g.layout.max:null;return{id:G,field:null,title:f,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:a,min:r,max:i,pin:$.config&&$.config.autoGroupColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(c,u){return u&&u.group?u.groupValue:null},formatValue(c,u){if(!u||!u.group)return"";if(u.grandTotal)return $.config&&$.config.grandTotalLabel||"Total";const n=y[Math.min(u.level||0,y.length-1)];return n&&typeof n.formatValue=="function"?n.formatValue(c,u):c==null?"":String(c)}}}function X($,A,k){!$.length||k<100||A<k*I||T(`grouping.cardinality:${$.join(",")}`,`grouping by ${$.join(", ")} produced ${A} 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.`)}}),Ue("packages/core/src/columns/selectcolumn.js",function(e,B){"use strict";Object.defineProperty(e,"SELECT_COLUMN_ID",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"createSelectionColumn",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return D}});const re="__lattice_select",T=44;function G(I){const Z=I.selection||{},z=I.config&&I.config.selectionColumnWidth||T;return{id:re,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:z,min:z,max:z,pin:I.config&&I.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(L,X){return X?X.selected:!1},formatValue(){return""}}}const D=G}),Ue("packages/core/src/columns/rownumbercolumn.js",function(e,B){"use strict";Object.defineProperty(e,"ROW_NUMBER_COLUMN_ID",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"createRowNumberColumn",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const T=B("packages/core/src/internal/predicates.js").isFunction,G="__lattice_rownumber",D=40,I=9,Z=22;function z($){const A=String(Math.max(1,Math.trunc(Math.abs($))||1)).length;return Math.max(D,A*I+Z)}function L($){const A=$.rowNumbers,k=A&&typeof A=="object"?A:{},y=Number.isFinite(k.start)?k.start:1,f=Number.isFinite(k.width)?k.width:z(($.maxNumber||0)+y),g=T($.rank)?$.rank:()=>null;return{id:G,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:f,min:f,max:f,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(a,r){const i=g(r);return i==null?null:i-1+y},formatValue(a){return a==null?"":String(a)}}}const X=L}),Ue("packages/core/src/model/detail.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_DETAIL_HEIGHT",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"DEFAULT_CACHE_LIMIT",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"resolveDetail",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"DetailModel",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const T=B("packages/core/src/internal/predicates.js").isFunction,D=B("packages/core/src/internal/warn.js").warnOnce,I=240,Z=10;function z($){if(!$)return null;const A=$===!0?{}:$;return A.enabled===!1?null:!T(A.rows)&&!A.render?(D("detail.rows","detail is enabled but neither `rows` nor `render` was supplied; expanding a master would show an empty region, so it stays off."),null):{render:A.render||null,config:A.config||null,rows:T(A.rows)?A.rows:null,height:A.height??I,maxHeight:A.maxHeight??null,cacheLimit:Number.isFinite(A.cacheLimit)?Math.max(0,A.cacheLimit):Z,isMaster:T(A.isMaster)?A.isMaster:null,target:A.target||null,onCreate:T(A.onCreate)?A.onCreate:null,path:typeof A.path=="string"?A.path:null}}class L{#e;#t=new Set;#n;#r=0;constructor(A){this.#e=A.config,this.#n=T(A.onChange)?A.onChange:()=>{}}get config(){return this.#e}get inline(){return!this.#e.target}isMaster(A){if(!A||A.group||A.detail)return!1;const k=this.#e.isMaster;return k?!!k(A.data,A):!0}isOpen(A){return this.#t.has(A)}keys(){return[...this.#t]}activeKey(){for(const A of this.#t)return A;return null}heightOf(A){const k=this.#e.height;return T(k)?Number(k(A))||I:k==="auto"?I:Number(k)||I}open(A){return this.#t.has(A)?!1:(this.inline||this.#t.clear(),this.#t.add(A),this.#i(),!0)}close(A){return this.#t.delete(A)?(this.#i(),!0):!1}toggle(A){return this.#t.has(A)?(this.close(A),!1):(this.open(A),!0)}closeAll(){this.#t.size&&(this.#t.clear(),this.#i())}prune(A){if(!this.#t.size||!T(A))return;let k=!1;for(const y of[...this.#t])A(y)||(this.#t.delete(y),k=!0);k&&this.#i()}signature(){return`${this.#r}`}set(A){this.#t.clear();const k=Array.isArray(A)?A:[];for(const y of this.inline?k:k.slice(0,1))this.#t.add(y);this.#i()}#i(){this.#r++,this.#n()}}const X=L}),Ue("packages/core/src/compute/special.js",function(e,B){"use strict";Object.defineProperty(e,"logGamma",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"incompleteBeta",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"normalQuantile",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"normalCdf",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"studentT",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"studentTQuantile",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"regularizedGammaP",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"chiSquareUpperTail",{enumerable:!0,get:function(){return a}});const re=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),T=3e-12,G=1e-300;function D(r){if(r<.5)return Math.log(Math.PI/Math.sin(Math.PI*r))-D(1-r);const i=r-1;let c=.9999999999998099;const u=i+7.5;for(let n=0;n<re.length;n++)c+=re[n]/(i+n+1);return .5*Math.log(2*Math.PI)+(i+.5)*Math.log(u)-u+Math.log(c)}function I(r,i,c){const u=r+i,n=r+1,m=r-1;let t=1,s=1-u*c/n;Math.abs(s)<G&&(s=G),s=1/s;let h=s;for(let d=1;d<=300;d++){const o=2*d;let b=d*(i-d)*c/((m+o)*(r+o));s=1+b*s,Math.abs(s)<G&&(s=G),t=1+b/t,Math.abs(t)<G&&(t=G),s=1/s,h*=s*t,b=-(r+d)*(u+d)*c/((r+o)*(n+o)),s=1+b*s,Math.abs(s)<G&&(s=G),t=1+b/t,Math.abs(t)<G&&(t=G),s=1/s;const l=s*t;if(h*=l,Math.abs(l-1)<T)break}return h}function Z(r,i,c){if(!(r>0)||!(i>0)||!Number.isFinite(c))return Number.NaN;if(c<=0)return 0;if(c>=1)return 1;const u=Math.exp(D(r+i)-D(r)-D(i)+r*Math.log(c)+i*Math.log(1-c));return c<(r+1)/(r+i+2)?u*I(r,i,c)/r:1-u*I(i,r,1-c)/i}function z(r){if(!(r>0)||!(r<1))return r===0?-1/0:r===1?1/0:Number.NaN;const i=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],c=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],u=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],n=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],m=.02425;let t,s,h;r<m?(t=Math.sqrt(-2*Math.log(r)),h=(((((u[0]*t+u[1])*t+u[2])*t+u[3])*t+u[4])*t+u[5])/((((n[0]*t+n[1])*t+n[2])*t+n[3])*t+1)):r<=1-m?(t=r-.5,s=t*t,h=(((((i[0]*s+i[1])*s+i[2])*s+i[3])*s+i[4])*s+i[5])*t/(((((c[0]*s+c[1])*s+c[2])*s+c[3])*s+c[4])*s+1)):(t=Math.sqrt(-2*Math.log(1-r)),h=-(((((u[0]*t+u[1])*t+u[2])*t+u[3])*t+u[4])*t+u[5])/((((n[0]*t+n[1])*t+n[2])*t+n[3])*t+1));const o=(.5*L(-h/Math.SQRT2)-r)*Math.sqrt(2*Math.PI)*Math.exp(h*h/2);return h-o/(1+h*o/2)}function L(r){const i=Math.abs(r),c=2/(2+i),u=4*c-2,n=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let m=0,t=0,s;for(let d=n.length-1;d>0;d--)s=t,t=u*t-m+n[d],m=s;const h=c*Math.exp(-i*i+.5*(n[0]+u*t)-m);return r>=0?h:2-h}function X(r){return .5*L(-r/Math.SQRT2)}function $(r,i){if(!(i>0)||!Number.isFinite(r))return Number.NaN;const c=.5*Z(i/2,.5,i/(i+r*r));return r>0?1-c:c}function A(r,i){if(!(r>0)||!(r<1)||!(i>0))return Number.NaN;if(i>1e7)return z(r);let c=-1e4,u=1e4,n=z(r);const m=D(i/2)+D(.5)-D((i+1)/2);for(let t=0;t<60;t++){const s=$(n,i);s<r?c=n:u=n;const h=Math.exp(-((i+1)/2)*Math.log(1+n*n/i)-m)/Math.sqrt(i),d=h>0?(s-r)/h:0;if(Math.abs(d)<1e-12)break;const o=n-d;if(n=o>c&&o<u&&Number.isFinite(o)?o:(c+u)/2,u-c<1e-12)break}return n}function k(r,i){let c=r,u=1/r,n=u;for(let m=0;m<300&&(c+=1,n*=i/c,u+=n,!(Math.abs(n)<Math.abs(u)*T));m++);return u*Math.exp(-i+r*Math.log(i)-D(r))}function y(r,i){let c=i+1-r,u=1/G,n=1/c,m=n;for(let t=1;t<=300;t++){const s=-t*(t-r);c+=2,n=s*n+c,Math.abs(n)<G&&(n=G),u=c+s/u,Math.abs(u)<G&&(u=G),n=1/n;const h=n*u;if(m*=h,Math.abs(h-1)<T)break}return Math.exp(-i+r*Math.log(i)-D(r))*m}function f(r,i){return!(r>0)||!(i>=0)||!Number.isFinite(i)?Number.NaN:i===0?0:i<r+1?k(r,i):1-y(r,i)}function g(r,i){return i>0?f(i/2,r/2):Number.NaN}function a(r,i){const c=g(r,i);return Number.isNaN(c)?Number.NaN:Math.min(1,Math.max(0,1-c))}}),Ue("packages/core/src/compute/linalg.js",function(e,B){"use strict";Object.defineProperty(e,"cholesky",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"choleskySolve",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"choleskyInverse",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"normalEquations",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"matVec",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"quadForm",{enumerable:!0,get:function(){return Z}});function re(z){const L=z.length,X=Array.from({length:L},()=>new Array(L).fill(0));for(let $=0;$<L;$++)for(let A=0;A<=$;A++){let k=z[$][A];for(let y=0;y<A;y++)k-=X[$][y]*X[A][y];if($===A){if(!(k>0))return null;X[$][A]=Math.sqrt(k)}else X[$][A]=k/X[A][A]}return X}function T(z,L){const X=z.length,$=new Array(X).fill(0);for(let k=0;k<X;k++){let y=L[k];for(let f=0;f<k;f++)y-=z[k][f]*$[f];$[k]=y/z[k][k]}const A=new Array(X).fill(0);for(let k=X-1;k>=0;k--){let y=$[k];for(let f=k+1;f<X;f++)y-=z[f][k]*A[f];A[k]=y/z[k][k]}return A}function G(z){const L=z.length,X=Array.from({length:L},()=>new Array(L).fill(0));for(let $=0;$<L;$++){const A=new Array(L).fill(0);A[$]=1;const k=T(z,A);for(let y=0;y<L;y++)X[y][$]=k[y]}return X}function D(z,L,X){const $=z.length,A=$?z[0].length:0,k=Array.from({length:A},()=>new Array(A).fill(0)),y=new Array(A).fill(0);for(let f=0;f<$;f++){const g=X?X[f]:1,a=z[f];for(let r=0;r<A;r++){const i=g*a[r];y[r]+=i*L[f];for(let c=r;c<A;c++)k[r][c]+=i*a[c]}}for(let f=0;f<A;f++)for(let g=0;g<f;g++)k[f][g]=k[g][f];return{xtwx:k,xtwy:y}}function I(z,L){return z.map(X=>X.reduce(($,A,k)=>$+A*L[k],0))}function Z(z,L){let X=0;for(let $=0;$<z.length;$++){let A=0;for(let k=0;k<z.length;k++)A+=L[$][k]*z[k];X+=z[$]*A}return X}}),Ue("packages/core/src/compute/sketch.js",function(e,B){"use strict";Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});class re{#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(f){if(!Number.isFinite(f))return;this.#e++;const g=f-this.#t;this.#t+=g/this.#e,this.#n+=g*(f-this.#t)}merge(f){if(f.#e===0)return;if(this.#e===0){this.#e=f.#e,this.#t=f.#t,this.#n=f.#n;return}const g=this.#e+f.#e,a=f.#t-this.#t;this.#t+=a*(f.#e/g),this.#n+=f.#n+a*a*(this.#e*f.#e/g),this.#e=g}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 f=this.variance();return f===null?null:Math.sqrt(f)}stddevP(){const f=this.varianceP();return f===null?null:Math.sqrt(f)}}class T{#e=[];#t=0;#n;#r;constructor(f,g=Math.random){if(!(f>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(f),this.#r=g}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(f){if(!Number.isFinite(f))return;if(this.#t++,this.#e.length<this.#n){this.#e.push(f);return}const g=Math.floor(this.#r()*this.#t);g<this.#n&&(this.#e[g]=f)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let f=0;for(const g of this.#e)f+=g;return f/this.#e.length}quantile(f){const g=this.#e.length;if(!g)return null;const a=this.#e.slice().sort((u,n)=>u-n);if(g===1)return a[0];const r=(g-1)*Math.min(1,Math.max(0,f)),i=Math.floor(r),c=Math.ceil(r);return i===c?a[i]:a[i]+(r-i)*(a[c]-a[i])}}function G(y){return y^=y>>>16,y=Math.imul(y,2246822507),y^=y>>>13,y=Math.imul(y,3266489909),y^=y>>>15,y>>>0}function D(y){if(typeof y=="number"){const a=new DataView(new ArrayBuffer(8));return a.setFloat64(0,y===0?0:y),G(a.getUint32(0)^a.getUint32(4))}const f=typeof y=="string"?y:String(y);let g=2166136261;for(let a=0;a<f.length;a++)g^=f.charCodeAt(a),g=Math.imul(g,16777619);return G(g)}class I{#e;#t;#n;constructor(f=14){const g=Math.floor(f);if(g<4||g>16)throw new RangeError("HLL precision must be 4..16");this.#e=g,this.#t=1<<g,this.#n=new Uint8Array(this.#t)}static errorBoundFor(f=14){const g=1<<Math.floor(f),a=1.04/Math.sqrt(g);return Object.freeze({kind:"probabilistic",metric:"relative",value:a,statement:`distinct count within ~${(a*100).toFixed(2)}% relative standard error (m=${g} buckets)`})}errorBound(){return I.errorBoundFor(this.#e)}add(f){const g=D(f),a=g&this.#t-1,r=g>>>this.#e|1<<32-this.#e;let i=1,c=r;for(;(c&1)===0;)i++,c>>>=1;i>this.#n[a]&&(this.#n[a]=i)}count(){const f=this.#t,g=32-this.#e,a=new Float64Array(g+2);for(let c=0;c<f;c++)a[this.#n[c]]++;let r=f*L(1-a[g+1]/f);for(let c=g;c>=1;c--)r=.5*(r+a[c]);r+=f*z(a[0]/f);const i=Z*f*f/r;return Math.round(i)}}const Z=.5/Math.log(2);function z(y){if(y===1)return 1/0;let f=1,g=y,a;do y*=y,a=g,g+=y*f,f+=f;while(g!==a);return g}function L(y){if(y===0||y===1)return 0;let f=1,g=1-y,a;do y=Math.sqrt(y),a=g,f*=.5,g-=(1-y)**2*f;while(g!==a);return g/3}class X{#e=new Map;#t;#n=0;constructor(f){if(!(f>0))throw new RangeError("Space-Saving capacity must be positive");this.#t=Math.floor(f)}errorBoundFor(f){const g=f/this.#t;return Object.freeze({kind:"deterministic",metric:"absolute",value:g,statement:`each count overestimates the truth by at most N/m = ${g.toFixed(2)} (N=${f}, m=${this.#t})`})}get seen(){return this.#n}add(f){this.#n++;const g=this.#e.get(f);if(g){g.count++;return}if(this.#e.size<this.#t){this.#e.set(f,{count:1,error:0});return}let a,r=1/0;for(const[i,c]of this.#e)c.count<r&&(r=c.count,a=i);this.#e.delete(a),this.#e.set(f,{count:r+1,error:r})}top(f=this.#t){return[...this.#e.entries()].map(([a,r])=>({item:a,count:r.count,error:r.error})).sort((a,r)=>r.count-a.count).slice(0,Math.max(0,Math.floor(f)))}}class ${#e;#t=[[]];#n=0;#r;#i;constructor(f=200,g=Math.random){this.#e=Math.max(8,Math.floor(f)),this.#r=g,this.#i=2/3}static errorBoundFor(f=200){const g=1/Math.max(8,Math.floor(f));return Object.freeze({kind:"probabilistic",metric:"rank",value:g,statement:`queried quantile's true rank within ~${(g*100).toFixed(2)}% of N of the requested rank (k=${f})`})}errorBound(){return $.errorBoundFor(this.#e)}get count(){return this.#n}#s(f){const a=this.#t.length-1-f,r=Math.ceil(this.#e*this.#i**a);return Math.max(2,r)}add(f){Number.isFinite(f)&&(this.#n++,this.#t[0].push(f),this.#t[0].length>=this.#s(0)&&this.#a(0))}#a(f){const g=this.#t[f];g.sort((i,c)=>i-c),f+1>=this.#t.length&&this.#t.push([]);const a=this.#t[f+1],r=this.#r()<.5?0:1;for(let i=r;i<g.length;i+=2)a.push(g[i]);this.#t[f]=[];for(let i=0;i<this.#t.length;i++)if(this.#t[i].length>=this.#s(i)){this.#a(i);return}}#l(){const f=[];for(let g=0;g<this.#t.length;g++){const a=1<<g;for(const r of this.#t[g])f.push({v:r,w:a})}return f}quantile(f){const g=this.#l();if(!g.length)return null;g.sort((c,u)=>c.v-u.v);let a=0;for(const c of g)a+=c.w;const r=Math.min(1,Math.max(0,f))*a;let i=0;for(const c of g)if(i+=c.w,i>=r)return c.v;return g[g.length-1].v}rank(f){let g=0;for(let a=0;a<this.#t.length;a++){const r=1<<a;for(const i of this.#t[a])i<=f&&(g+=r)}return g}}const A=Object.freeze({distinct:I.errorBoundFor(14),median:$.errorBoundFor(200),p25:$.errorBoundFor(200),p75:$.errorBoundFor(200),p90:$.errorBoundFor(200),p95:$.errorBoundFor(200),p99:$.errorBoundFor(200),iqr:$.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:re,Reservoir:T,HyperLogLog:I,SpaceSaving:X,KLL:$,hash32:D,SKETCH_BOUNDS:A}}),Ue("packages/core/src/compute/statistics.js",function(e,B){"use strict";Object.defineProperty(e,"KENDALL_LIMIT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"numbers",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"frequencies",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"entropy",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"evenness",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"topShare",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"gini",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"moments",{enumerable:!0,get:function(){return p}}),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 Y}}),Object.defineProperty(e,"STAT_LABELS",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"extremeRow",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"correlation",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"trimmedMean",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"winsorizedMean",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"modifiedZOutliers",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"jarqueBera",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"covariance",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"regression",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"fitLinearModel",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"kendall",{enumerable:!0,get:function(){return de}}),Object.defineProperty(e,"seriesStats",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"D2_N2",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(e,"D4_N2",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(e,"movingRanges",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"withinSigma",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return He}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(e,"controlViolations",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(e,"countOutside",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(e,"histogram",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(e,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(e,"meanInterval",{enumerable:!0,get:function(){return et}}),Object.defineProperty(e,"proportionInterval",{enumerable:!0,get:function(){return Je}}),Object.defineProperty(e,"slopeInterval",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(e,"capabilityInterval",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(e,"standardizedMeanDifference",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(e,"normalTotalVariation",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(e,"frequencyMap",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return ut}}),Object.defineProperty(e,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(e,"compareColumn",{enumerable:!0,get:function(){return xt}}),Object.defineProperty(e,"isNumericColumn",{enumerable:!0,get:function(){return It}}),Object.defineProperty(e,"populationRead",{enumerable:!0,get:function(){return dt}});const re=B("packages/core/src/compute/handle.js"),T=re.presenceReader,G=re.valueReader,D=B("packages/core/src/compute/special.js"),I=D.studentTQuantile,Z=D.studentT,z=D.normalQuantile,L=D.normalCdf,X=D.chiSquareUpperTail,$=B("packages/core/src/compute/linalg.js"),A=$.cholesky,k=$.choleskySolve,y=$.choleskyInverse,f=$.normalEquations,g=$.quadForm,r=B("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,i=5e3,c=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"}),u=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:r.distinct}),median:Object.freeze({sketch:"KLL",bound:r.median}),p25:Object.freeze({sketch:"KLL",bound:r.p25}),p75:Object.freeze({sketch:"KLL",bound:r.p75}),p90:Object.freeze({sketch:"KLL",bound:r.p90}),p95:Object.freeze({sketch:"KLL",bound:r.p95}),p99:Object.freeze({sketch:"KLL",bound:r.p99}),iqr:Object.freeze({sketch:"KLL",bound:r.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:r.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:r.topK})});function n(ie){const pe=ie==="sum"||ie==="avg"||ie==="countValues"||ie==="min"||ie==="max"?"maintained":Object.prototype.hasOwnProperty.call(c,ie)?c[ie]:null,be=Object.prototype.hasOwnProperty.call(u,ie)?u[ie]:null;return{stat:ie,exact:pe,approximate:be}}function m(ie,pe){const be=pe.length,Ae=new Float64Array(be);let je=0;if(ie&&(ie.kind==="float64"||ie.kind==="int32")){const Ie=ie.values,We=T(ie);for(let ze=0;ze<be;ze++){const Qe=pe[ze];if(We&&We(Qe)!==1)continue;const gt=Ie[Qe];Number.isNaN(gt)||(Ae[je++]=gt)}return Ae.subarray(0,je)}const _e=G(ie);for(let Ie=0;Ie<be;Ie++){const We=_e(pe[Ie]);if(We==null||We==="")continue;const ze=typeof We=="number"?We:Number(We);Number.isFinite(ze)&&(Ae[je++]=ze)}return Ae.subarray(0,je)}function t(ie,pe){const be=new Map,Ae=G(ie);let je=0;for(let _e=0;_e<pe.length;_e++){const Ie=Ae(pe[_e]);if(Ie==null||Ie===""||typeof Ie=="number"&&Number.isNaN(Ie))continue;const We=typeof Ie=="object"?String(Ie):Ie;be.set(We,(be.get(We)||0)+1),je++}const Ne=[...be.values()].sort((_e,Ie)=>Ie-_e);return{counts:Ne,total:je,distinct:Ne.length}}function s(ie){return ie.total>0?ie.counts.map(pe=>pe/ie.total):[]}function h(ie,pe){const be=t(ie,pe);if(!be.total)return null;let Ae=0;for(const je of s(be))Ae+=je*je;return Ae}function d(ie,pe){const be=t(ie,pe);if(!be.total)return null;let Ae=0;for(const je of s(be))je>0&&(Ae-=je*Math.log2(je));return Ae}function o(ie,pe){const be=t(ie,pe);if(!be.total||be.distinct<2)return be.total?1:null;let Ae=0;for(const je of s(be))je>0&&(Ae-=je*Math.log2(je));return Ae/Math.log2(be.distinct)}function b(ie,pe,be=3){const Ae=t(ie,pe);if(!Ae.total)return null;const je=Math.max(1,Math.floor(be));let Ne=0;for(let _e=0;_e<Math.min(je,Ae.counts.length);_e++)Ne+=Ae.counts[_e];return Ne/Ae.total}function l(ie,pe){const be=m(ie,pe),Ae=be.length;if(!Ae)return null;const je=be.slice().sort();if(je[0]<0)return null;let Ne=0,_e=0;for(let Ie=0;Ie<Ae;Ie++)Ne+=je[Ie],_e+=(Ie+1)*je[Ie];return Ne===0?0:2*_e/(Ae*Ne)-(Ae+1)/Ae}function p(ie){let pe=0,be=0,Ae=0;for(let je=0;je<ie.length;je++){const Ne=ie[je];pe++;const _e=Ne-be;be+=_e/pe,Ae+=_e*(Ne-be)}return{n:pe,mean:be,m2:Ae}}function w(ie,pe){const be=ie.length;if(!be)return NaN;if(be===1)return ie[0];const Ae=(be-1)*Math.min(1,Math.max(0,pe)),je=Math.floor(Ae),Ne=Math.ceil(Ae);return je===Ne?ie[je]:ie[je]+(Ae-je)*(ie[Ne]-ie[je])}function v(ie,pe){if(!ie.length)return NaN;const be=ie.slice().sort();return w(be,pe)}function R(ie,pe){const be=G(ie);let Ae=0,je=0,Ne=0;for(let _e=0;_e<pe.length;_e++){const Ie=be(pe[_e]);if(Ie==null||Ie==="")continue;const We=String(Ie).toUpperCase();We==="PASS"?Ae++:We==="FAIL"?je++:We==="WARN"&&Ne++}return{pass:Ae+Ne,fail:je,warn:Ne,judged:Ae+Ne+je}}const Y=Object.freeze({hhi:(ie,pe)=>h(ie,pe),entropy:(ie,pe)=>d(ie,pe),evenness:(ie,pe)=>o(ie,pe),top3Share:(ie,pe)=>b(ie,pe,3),top10Share:(ie,pe)=>b(ie,pe,10),gini:(ie,pe)=>l(ie,pe),trimmedMean:(ie,pe)=>C(m(ie,pe),.1),winsorizedMean:(ie,pe)=>S(m(ie,pe),.1),robustOutliers:(ie,pe)=>F(m(ie,pe),3.5),jarqueBera:(ie,pe)=>P(m(ie,pe)),variance:(ie,pe)=>{const{n:be,m2:Ae}=p(m(ie,pe));return be>1?Ae/(be-1):null},varianceP:(ie,pe)=>{const{n:be,m2:Ae}=p(m(ie,pe));return be>0?Ae/be:null},stddev:(ie,pe)=>{const{n:be,m2:Ae}=p(m(ie,pe));return be>1?Math.sqrt(Ae/(be-1)):null},stddevP:(ie,pe)=>{const{n:be,m2:Ae}=p(m(ie,pe));return be>0?Math.sqrt(Ae/be):null},median:(ie,pe)=>{const be=m(ie,pe);return be.length?v(be,.5):null},percentile:(ie,pe,be)=>{const Ae=be?be.p:void 0;if(typeof Ae!="number"||!(Ae>=0&&Ae<=1))return null;const je=m(ie,pe);return je.length?v(je,Ae):null},p25:(ie,pe)=>{const be=m(ie,pe);return be.length?v(be,.25):null},p75:(ie,pe)=>{const be=m(ie,pe);return be.length?v(be,.75):null},p90:(ie,pe)=>{const be=m(ie,pe);return be.length?v(be,.9):null},p95:(ie,pe)=>{const be=m(ie,pe);return be.length?v(be,.95):null},p99:(ie,pe)=>{const be=m(ie,pe);return be.length?v(be,.99):null},iqr:(ie,pe)=>{const be=m(ie,pe);if(!be.length)return null;const Ae=be.slice().sort();return w(Ae,.75)-w(Ae,.25)},mad:(ie,pe)=>{const be=m(ie,pe);if(!be.length)return null;const Ae=v(be,.5),je=new Float64Array(be.length);for(let Ne=0;Ne<be.length;Ne++)je[Ne]=Math.abs(be[Ne]-Ae);return v(je,.5)},range:(ie,pe)=>{const be=m(ie,pe);if(!be.length)return null;let Ae=1/0,je=-1/0;for(let Ne=0;Ne<be.length;Ne++)be[Ne]<Ae&&(Ae=be[Ne]),be[Ne]>je&&(je=be[Ne]);return je-Ae},distinct:(ie,pe)=>{const be=G(ie),Ae=new Set;for(let je=0;je<pe.length;je++){const Ne=be(pe[je]);Ne==null||Ne===""||Ae.add(Ne instanceof Date?Ne.getTime():Ne)}return Ae.size},mode:(ie,pe)=>{const be=G(ie),Ae=new Map;for(let _e=0;_e<pe.length;_e++){const Ie=be(pe[_e]);if(Ie==null||Ie==="")continue;const We=Ie instanceof Date?Ie.getTime():Ie;Ae.set(We,(Ae.get(We)||0)+1)}let je=null,Ne=1;for(const[_e,Ie]of Ae)Ie>Ne&&(Ne=Ie,je=_e);return je},skewness:(ie,pe)=>{const be=m(ie,pe),{n:Ae,mean:je,m2:Ne}=p(be);if(Ae<3||Ne<=0)return null;const _e=Math.sqrt(Ne/(Ae-1));let Ie=0;for(let We=0;We<be.length;We++)Ie+=((be[We]-je)/_e)**3;return Ae/((Ae-1)*(Ae-2))*Ie},kurtosis:(ie,pe)=>{const be=m(ie,pe),{n:Ae,mean:je,m2:Ne}=p(be);if(Ae<4||Ne<=0)return null;const _e=Math.sqrt(Ne/(Ae-1));let Ie=0;for(let Qe=0;Qe<be.length;Qe++)Ie+=((be[Qe]-je)/_e)**4;const We=Ae*(Ae+1)/((Ae-1)*(Ae-2)*(Ae-3)),ze=3*(Ae-1)**2/((Ae-2)*(Ae-3));return We*Ie-ze},geomean:(ie,pe)=>{const be=m(ie,pe);if(!be.length)return null;let Ae=0;for(let je=0;je<be.length;je++){if(be[je]<=0)return null;Ae+=Math.log(be[je])}return Math.exp(Ae/be.length)},harmean:(ie,pe)=>{const be=m(ie,pe);if(!be.length)return null;let Ae=0;for(let je=0;je<be.length;je++){if(be[je]===0)return null;Ae+=1/be[je]}return be.length/Ae},sumSquares:(ie,pe)=>{const be=m(ie,pe);let Ae=0;for(let je=0;je<be.length;je++)Ae+=be[je]*be[je];return Ae},passRate:(ie,pe)=>{const{pass:be,judged:Ae}=R(ie,pe);return Ae?be/Ae:null},failureCount:(ie,pe)=>R(ie,pe).fail}),K=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 V(ie,pe,be){const Ae=G(ie),je=G(pe);let Ne=0,_e=0;for(let Ie=0;Ie<be.length;Ie++){const We=be[Ie],ze=Number(Ae(We)),Qe=Number(je(We));!Number.isFinite(ze)||!Number.isFinite(Qe)||(Ne+=ze*Qe,_e+=Qe)}return _e===0?null:Ne/_e}function E(ie,pe,be){const Ae=G(ie);let je=null,Ne=be?-1/0:1/0;for(let _e=0;_e<pe.length;_e++){const Ie=pe[_e],We=Number(Ae(Ie));Number.isFinite(We)&&(be?We>Ne:We<Ne)&&(Ne=We,je=Ie)}return je}function O(ie,pe,be){const Ae=G(ie),je=G(pe);let Ne=0,_e=0,Ie=0,We=0,ze=0,Qe=0;for(let ht=0;ht<be.length;ht++){const Pt=be[ht],Lt=Number(Ae(Pt)),jt=Number(je(Pt));!Number.isFinite(Lt)||!Number.isFinite(jt)||(Ne++,_e+=Lt,Ie+=jt,We+=Lt*Lt,ze+=jt*jt,Qe+=Lt*jt)}if(Ne<2)return null;const gt=Ne*Qe-_e*Ie,Ot=Math.sqrt((Ne*We-_e*_e)*(Ne*ze-Ie*Ie));if(Ot===0)return null;const bt=gt/Ot;return Math.max(-1,Math.min(1,bt))}function C(ie,pe=.1){const be=ie.length;if(!be)return null;const Ae=Array.from(ie).sort((Ie,We)=>Ie-We),je=Math.floor(be*Math.min(.49,Math.max(0,pe))),Ne=Ae.slice(je,be-je);if(!Ne.length)return w(Ae,.5);let _e=0;for(const Ie of Ne)_e+=Ie;return _e/Ne.length}function S(ie,pe=.1){const be=ie.length;if(!be)return null;const Ae=Array.from(ie).sort((We,ze)=>We-ze),je=Math.floor(be*Math.min(.49,Math.max(0,pe))),Ne=Ae[je],_e=Ae[be-1-je];let Ie=0;for(const We of Ae)Ie+=Math.min(_e,Math.max(Ne,We));return Ie/be}function F(ie,pe=3.5){if(!ie.length)return null;const Ae=Array.from(ie).sort((We,ze)=>We-ze),je=w(Ae,.5),Ne=Ae.map(We=>Math.abs(We-je)).sort((We,ze)=>We-ze),_e=w(Ne,.5);if(_e===0)return null;let Ie=0;for(const We of Ae)Math.abs(.6745*(We-je)/_e)>pe&&Ie++;return Ie}function P(ie){const pe=ie.length;if(pe<8)return null;let be=0;for(const We of ie)be+=We;be/=pe;let Ae=0,je=0,Ne=0;for(const We of ie){const ze=We-be;Ae+=ze*ze,je+=ze*ze*ze,Ne+=ze*ze*ze*ze}if(Ae/=pe,je/=pe,Ne/=pe,Ae===0)return null;const _e=je/Ae**1.5,Ie=Ne/(Ae*Ae)-3;return pe/6*(_e*_e+Ie*Ie/4)}function M(ie,pe,be){const Ae=[];let je=0;for(let We=0;We<ie.length;We++){const ze=Number(ie[We]),Qe=Number(pe[We]);!Number.isFinite(ze)||!Number.isFinite(Qe)||Qe<=0||(Ae.push([ze,Qe]),je+=Qe)}if(!Ae.length||je<=0)return null;if(Ae.sort((We,ze)=>We[0]-ze[0]),Ae.length===1)return Ae[0][0];const Ne=[];let _e=0;for(const[,We]of Ae)Ne.push((_e+We/2)/je),_e+=We;const Ie=Math.max(0,Math.min(1,be));if(Ie<=Ne[0])return Ae[0][0];if(Ie>=Ne[Ne.length-1])return Ae[Ae.length-1][0];for(let We=1;We<Ne.length;We++){if(Ie>Ne[We])continue;const ze=Ne[We]-Ne[We-1],Qe=ze>0?(Ie-Ne[We-1])/ze:0;return Ae[We-1][0]+(Ae[We][0]-Ae[We-1][0])*Qe}return Ae[Ae.length-1][0]}function x(ie,pe,be){const Ae=G(ie),je=G(pe),Ne=new Float64Array(be.length),_e=new Float64Array(be.length);let Ie=0;for(let We=0;We<be.length;We++){const ze=be[We],Qe=Number(Ae(ze)),gt=Number(je(ze));!Number.isFinite(Qe)||!Number.isFinite(gt)||(Ne[Ie]=Qe,_e[Ie]=gt,Ie++)}return{xs:Ne.subarray(0,Ie),ys:_e.subarray(0,Ie),n:Ie}}function U(ie,pe,be,Ae=!1){const{xs:je,ys:Ne,n:_e}=x(ie,pe,be);if(_e<2)return null;let Ie=0,We=0;for(let Qe=0;Qe<_e;Qe++)Ie+=je[Qe],We+=Ne[Qe];Ie/=_e,We/=_e;let ze=0;for(let Qe=0;Qe<_e;Qe++)ze+=(je[Qe]-Ie)*(Ne[Qe]-We);return ze/(Ae?_e:_e-1)}function _(ie,pe,be){const{xs:Ae,ys:je,n:Ne}=x(ie,pe,be);if(Ne<2)return null;let _e=0,Ie=0;for(let Lt=0;Lt<Ne;Lt++)_e+=Ae[Lt],Ie+=je[Lt];_e/=Ne,Ie/=Ne;let We=0,ze=0,Qe=0;for(let Lt=0;Lt<Ne;Lt++){const jt=Ae[Lt]-_e,Ut=je[Lt]-Ie;We+=jt*jt,ze+=jt*Ut,Qe+=Ut*Ut}if(We===0)return null;const gt=ze/We,Ot=Ie-gt*_e,bt=Qe===0?1:Math.max(0,Math.min(1,ze*ze/(We*Qe))),ht=Math.max(0,Qe-gt*ze),Pt=Ne>2?Math.sqrt(ht/(Ne-2)/We):0;return{slope:gt,intercept:Ot,r2:bt,stdError:Pt,n:Ne}}const W=new Set(["ols","wls","robust"]),q=new Set(["quantile"]),N=new Set(["ridge","lasso","elasticnet","mixed","gls"]),Q=1.345;function J(ie,pe,be){const{xtwx:Ae,xtwy:je}=f(ie,pe,be),Ne=A(Ae);if(!Ne)return null;const _e=k(Ne,je),Ie=y(Ne),We=ee(ie,_e),ze=pe.map((Qe,gt)=>Qe-We[gt]);return{beta:_e,cov:Ie,fitted:We,residuals:ze}}function ee(ie,pe){return ie.map(be=>be.reduce((Ae,je,Ne)=>Ae+je*pe[Ne],0))}function ne(ie,pe){const be=ie.length,Ae=ie.map(ze=>ze[pe]),je=ie.map(ze=>[1,...ze.filter((Qe,gt)=>gt!==pe)]),Ne=J(je,Ae,null);if(!Ne)return 1;const _e=Ae.reduce((ze,Qe)=>ze+Qe,0)/be;let Ie=0,We=0;for(let ze=0;ze<be;ze++)Ie+=Ne.residuals[ze]**2,We+=(Ae[ze]-_e)**2;return We===0?1:Math.max(0,Math.min(1,1-Ie/We))}function se(ie){const pe=[...ie].sort((je,Ne)=>je-Ne),be=le(pe),Ae=ie.map(je=>Math.abs(je-be)).sort((je,Ne)=>je-Ne);return le(Ae)/.6745}function le(ie){const pe=ie.length;if(!pe)return 0;const be=Math.floor(pe/2);return pe%2?ie[be]:(ie[be-1]+ie[be])/2}function ye(ie,pe,be={}){const Ae=be.method||"ols";if(N.has(Ae))throw new Error(`[lattice] regression method "${Ae}" is out of scope; use ols, wls or robust.`);if(q.has(Ae))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!W.has(Ae))throw new Error(`[lattice] unknown regression method "${Ae}"; use ols, wls or robust.`);const je=Array.isArray(pe)?pe.length:0,Ne=je&&Array.isArray(ie[0])?ie[0].length:0,_e=Ne+1;if(!(je>_e))return null;for(let At=0;At<je;At++){if(!Number.isFinite(pe[At])||!Array.isArray(ie[At])||ie[At].length!==Ne)return null;for(let Rt=0;Rt<Ne;Rt++)if(!Number.isFinite(ie[At][Rt]))return null}let Ie=null;if(Ae==="wls"){if(Ie=be.weights,!Array.isArray(Ie)||Ie.length!==je)return null;for(let At=0;At<je;At++)if(!(Ie[At]>0)||!Number.isFinite(Ie[At]))return null}const We=ie.map(At=>[1,...At]);let ze,Qe=null;if(Ae==="robust"){if(ze=J(We,pe,null),!ze)return null;for(let At=0;At<50;At++){const Rt=se(ze.residuals);if(!(Rt>0))break;const Gt=ze.residuals.map(_t=>{const Kt=Math.abs(_t/Rt);return Kt<=Q?1:Q/Kt}),zt=J(We,pe,Gt);if(!zt)return null;const Vt=zt.beta.reduce((_t,Kt,Bt)=>Math.max(_t,Math.abs(Kt-ze.beta[Bt])),0);if(ze=zt,Qe=Gt,Vt<1e-10)break}}else if(ze=J(We,pe,Ie),!ze)return null;const gt=Ae==="robust"?Qe:Ie,{beta:Ot,cov:bt,fitted:ht,residuals:Pt}=ze;let Lt=0,jt=0,Ut=0;for(let At=0;At<je;At++){const Rt=gt?gt[At]:1;Lt+=Rt*Pt[At]**2,jt+=Rt,Ut+=Rt*pe[At]}const rn=Ut/jt;let Wt=0;for(let At=0;At<je;At++){const Rt=gt?gt[At]:1;Wt+=Rt*(pe[At]-rn)**2}const Qt=je-_e,Xe=Lt/Qt,at=Wt===0?1:Math.max(0,Math.min(1,1-Lt/Wt)),kt=1-(1-at)*(je-1)/Qt,mt=Array.isArray(be.names)&&be.names.length===Ne?be.names:ie[0].map((At,Rt)=>`x${Rt+1}`),wt=Ge(be.confidence),Ve=Qt>0?I(1-(1-wt)/2,Qt):1/0,lt=Ot.map((At,Rt)=>{const Gt=Math.sqrt(Math.max(0,Xe*bt[Rt][Rt])),zt=Gt>0?At/Gt:At===0?0:1/0,Vt=Number.isFinite(zt)?2*(1-Z(Math.abs(zt),Qt)):0,_t=Number.isFinite(Ve)?Ve*Gt:null;return{name:Rt===0?"(intercept)":mt[Rt-1],estimate:At,stdError:Gt,t:zt,p:Math.max(0,Math.min(1,Vt)),lower:_t===null?null:At-_t,upper:_t===null?null:At+_t}}),nt=new Array(je),ct=new Array(je);for(let At=0;At<je;At++){const Rt=gt?gt[At]:1,Gt=Math.max(0,Math.min(1,Rt*g(We[At],bt)));nt[At]=Gt;const zt=(1-Gt)**2;ct[At]=zt>0&&Xe>0?Pt[At]**2/(_e*Xe)*(Gt/zt):null}const $t=ie[0].map((At,Rt)=>{if(Ne<2)return 1;const Gt=ne(ie,Rt);return Gt>=1?1/0:1/(1-Gt)});let Ft=null;{const At=Pt.map(Gt=>Gt*Gt),Rt=J(We,At,null);if(Rt){const Gt=At.reduce((Jt,cn)=>Jt+cn,0)/je;let zt=0,Vt=0;for(let Jt=0;Jt<je;Jt++)zt+=Rt.residuals[Jt]**2,Vt+=(At[Jt]-Gt)**2;const _t=Vt===0?0:Math.max(0,Math.min(1,1-zt/Vt)),Kt=je*_t,Bt=X(Kt,Ne);Ft={statistic:Kt,df:Ne,p:Bt,heteroscedastic:Bt<.05}}}let yt=null;if(Ne===1){const At=ie.map((Rt,Gt)=>Gt).sort((Rt,Gt)=>ie[Rt][0]-ie[Gt][0]);yt={confidence:wt,points:At.map(Rt=>{const Gt=We[Rt],zt=Math.sqrt(Math.max(0,Xe*g(Gt,bt)));return{x:ie[Rt][0],yhat:ht[Rt],lower:ht[Rt]-Ve*zt,upper:ht[Rt]+Ve*zt}})}}return{method:Ae,coefficients:lt,r2:at,adjR2:kt,n:je,df:Qt,sigma2:Xe,fitted:ht,residuals:Pt,leverage:nt,cooksD:ct,vif:$t,heteroscedasticity:Ft,band:yt,weights:gt?[...gt]:null}}function fe(ie){const pe=ie.length,be=Array.from({length:pe},(Ne,_e)=>_e).sort((Ne,_e)=>ie[Ne]-ie[_e]),Ae=new Float64Array(pe);let je=0;for(;je<pe;){let Ne=je;for(;Ne+1<pe&&ie[be[Ne+1]]===ie[be[je]];)Ne++;const _e=(je+Ne)/2+1;for(let Ie=je;Ie<=Ne;Ie++)Ae[be[Ie]]=_e;je=Ne+1}return Ae}const we=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function ke(ie){const pe=[.01,.05,.1],be=[we["1%"],we["5%"],we["10%"]];if(ie<=be[0]){const Ne=(Math.log(pe[1])-Math.log(pe[0]))/(be[1]-be[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(pe[0])+Ne*(ie-be[0]))))}if(ie>=be[2]){const Ne=(Math.log(pe[2])-Math.log(pe[1]))/(be[2]-be[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(pe[2])+Ne*(ie-be[2]))))}const Ae=ie<be[1]?0:1,je=(ie-be[Ae])/(be[Ae+1]-be[Ae]);return Math.exp(Math.log(pe[Ae])+je*(Math.log(pe[Ae+1])-Math.log(pe[Ae])))}function Ce(ie,pe,be,Ae){const je=be-Ae,Ne=Ae+3,_e=new Array(je),Ie=new Array(je);let We=!0,ze=Ae;for(let ht=0;ht<je;ht++){const Pt=Ae+ht,Lt=new Float64Array(Ne);Lt[0]=1,Lt[1]=ht+1,Lt[2]=ie[Pt];for(let jt=1;jt<=Ae;jt++)Lt[2+jt]=pe[Pt-jt];for(let jt=1;jt<Ne;jt++)Number.isFinite(Lt[jt])||(ze=Math.min(ze,jt-3));_e[ht]=Lt,Ie[ht]=pe[Pt],Number.isFinite(Ie[ht])||(We=!1)}if(!We)return 0;const{xtwx:Qe,xtwy:gt}=f(_e,Ie,null);let Ot=0,bt=1/0;for(let ht=0;ht<=ze;ht++){const Pt=ht+3;if(!(je>Pt))continue;const Lt=new Array(Pt);for(let at=0;at<Pt;at++)Lt[at]=Qe[at].slice(0,Pt);const jt=A(Lt);if(!jt)continue;const Ut=k(jt,gt.slice(0,Pt));let rn=0;for(let at=0;at<je;at++){const kt=_e[at];let mt=0;for(let wt=0;wt<Pt;wt++)mt+=kt[wt]*Ut[wt];rn+=(Ie[at]-mt)**2}const Qt=rn/(je-Pt)*(je-Pt);if(!(Qt>0))continue;const Xe=je*Math.log(Qt/je)+2*Pt;Xe<bt&&(bt=Xe,Ot=ht)}return Ot}function ce(ie,pe={}){const be=[];for(let bt=0;bt<ie.length;bt++){const ht=Number(ie[bt]);Number.isFinite(ht)&&be.push(ht)}const Ae=be.length,je=Ae-1;if(Ae<8||je<6)return null;const Ne=new Array(je);for(let bt=0;bt<je;bt++)Ne[bt]=be[bt+1]-be[bt];let _e=Number.isFinite(pe.maxlag)?Math.floor(pe.maxlag):Math.ceil(12*(Ae/100)**.25);_e=Math.max(0,Math.min(_e,Math.floor((je-5)/2)));const Ie=(bt,ht)=>{const Pt=[],Lt=[];for(let jt=ht;jt<je;jt++){const Ut=[jt-ht+1,be[jt]];for(let rn=1;rn<=bt;rn++)Ut.push(Ne[jt-rn]);Pt.push(Ut),Lt.push(Ne[jt])}return ye(Pt,Lt,{method:"ols"})},We=Ce(be,Ne,je,_e),ze=Ie(We,We);if(!ze||!ze.coefficients[2])return null;const Qe=ze.coefficients[2].t,gt=ke(Qe),Ot=Qe<we["5%"];return{statistic:Qe,usedLag:We,nobs:je-We,criticalValues:{...we},pValue:gt,pApproximate:!0,stationary:Ot,verdict:Ot?"stationary":"non-stationary",regression:"ct"}}function ae(ie,pe={}){const be=[];for(let Ot=0;Ot<ie.length;Ot++){const bt=Number(ie[Ot]);Number.isFinite(bt)&&be.push(bt)}const Ae=be.length;if(Ae<3)return null;let je=Number.isFinite(pe.maxlag)?Math.floor(pe.maxlag):Math.min(10,Ae-1);je=Math.max(1,Math.min(je,Ae-1));let Ne=0;for(const Ot of be)Ne+=Ot;Ne/=Ae;const _e=be.map(Ot=>Ot-Ne);let Ie=0;for(const Ot of _e)Ie+=Ot*Ot;Ie/=Ae;const We=new Array(je+1).fill(0);We[0]=1;for(let Ot=1;Ot<=je;Ot++){let bt=0;for(let ht=Ot;ht<Ae;ht++)bt+=_e[ht]*_e[ht-Ot];We[Ot]=Ie>0?bt/Ae/Ie:0}const ze=new Array(je+1).fill(0);ze[0]=1;let Qe=[];for(let Ot=1;Ot<=je;Ot++){let bt=We[Ot];for(let jt=1;jt<Ot;jt++)bt-=Qe[jt-1]*We[Ot-jt];let ht=1;for(let jt=1;jt<Ot;jt++)ht-=Qe[jt-1]*We[jt];const Pt=ht!==0?bt/ht:0,Lt=new Array(Ot);for(let jt=1;jt<Ot;jt++)Lt[jt-1]=Qe[jt-1]-Pt*Qe[Ot-1-jt];Lt[Ot-1]=Pt,ze[Ot]=Pt,Qe=Lt}const gt=1.96/Math.sqrt(Ae);return{acf:We,pacf:ze,bounds:{upper:gt,lower:-gt},n:Ae,nlags:je,approximate:!0}}function ge(ie,pe,be){const{xs:Ae,ys:je,n:Ne}=x(ie,pe,be);if(Ne<2)return null;const _e=fe(Ae),Ie=fe(je);let We=0,ze=0;for(let bt=0;bt<Ne;bt++)We+=_e[bt],ze+=Ie[bt];We/=Ne,ze/=Ne;let Qe=0,gt=0,Ot=0;for(let bt=0;bt<Ne;bt++){const ht=_e[bt]-We,Pt=Ie[bt]-ze;Qe+=ht*Pt,gt+=ht*ht,Ot+=Pt*Pt}return gt===0||Ot===0?null:Math.max(-1,Math.min(1,Qe/Math.sqrt(gt*Ot)))}function de(ie,pe,be){const{xs:Ae,ys:je,n:Ne}=x(ie,pe,be);if(Ne<2||Ne>i)return null;let _e=0,Ie=0,We=0,ze=0;for(let Ot=0;Ot<Ne;Ot++)for(let bt=Ot+1;bt<Ne;bt++){const ht=Math.sign(Ae[Ot]-Ae[bt]),Pt=Math.sign(je[Ot]-je[bt]),Lt=ht*Pt;Lt>0?_e++:Lt<0?Ie++:ht===0&&Pt===0||(ht===0?We++:ze++)}const Qe=_e+Ie+ze,gt=_e+Ie+We;return Qe===0||gt===0?null:(_e-Ie)/Math.sqrt(Qe*gt)}function me(ie,pe={}){const be=ie.length;if(be<2)return null;const Ae=ie[0],je=ie[be-1],Ne=[];for(let jt=1;jt<be;jt++){const Ut=ie[jt-1];Ut!==0&&Ne.push((ie[jt]-Ut)/Math.abs(Ut))}let _e=null;if(Ne.length>1){let jt=0;for(const rn of Ne)jt+=rn;jt/=Ne.length;let Ut=0;for(const rn of Ne)Ut+=(rn-jt)**2;_e=Math.sqrt(Ut/(Ne.length-1))}const Ie=Number(pe.periodsPerYear)>0?Number(pe.periodsPerYear):null;let We=ie[0],ze=0,Qe=0,gt=0,Ot=0;for(let jt=1;jt<be;jt++){if(ie[jt]>We){We=ie[jt],ze=jt;continue}if(We<=0)continue;const Ut=(We-ie[jt])/We;Ut>Qe&&(Qe=Ut,gt=ze,Ot=jt)}let bt=null;if(be>2){let jt=0;for(let Wt=0;Wt<be;Wt++)jt+=ie[Wt];jt/=be;let Ut=0,rn=0;for(let Wt=0;Wt<be;Wt++){const Qt=ie[Wt]-jt;rn+=Qt*Qt,Wt>0&&(Ut+=Qt*(ie[Wt-1]-jt))}bt=rn>0?Ut/rn:null}let ht=0,Pt=0;for(const jt of Ne)jt>0?ht++:jt<0&&Pt++;let Lt=null;if(Ae>0&&je>0){const jt=(je/Ae)**(1/(be-1))-1;Lt=Ie?(1+jt)**Ie-1:jt}return{n:be,first:Ae,last:je,change:je-Ae,changePercent:Ae===0?null:(je-Ae)/Math.abs(Ae)*100,volatility:_e,annualisedVolatility:_e!==null&&Ie?_e*Math.sqrt(Ie):null,growth:Lt,maxDrawdown:Qe,maxDrawdownFrom:gt,maxDrawdownTo:Ot,autocorrelation:bt,upDays:ht,downDays:Pt}}const ve=1.128,xe=3.267;function Ee(ie){const pe=ie.length;if(pe<2)return null;const be=[];for(let je=1;je<pe;je++)be.push(Math.abs(ie[je]-ie[je-1]));const Ae=be.reduce((je,Ne)=>je+Ne,0)/be.length;return{ranges:be,centre:Ae,upper:xe*Ae,lower:0}}function Le(ie){const pe=ie.length;if(pe<2)return null;let be=0;for(let je=1;je<pe;je++)be+=Math.abs(ie[je]-ie[je-1]);const Ae=be/(pe-1);return{sigma:Ae/ve,meanRange:Ae}}function He(ie,pe){const be=ie.length;if(be<2||!pe)return null;const Ae=Number.isFinite(Number(pe.lower))?Number(pe.lower):null,je=Number.isFinite(Number(pe.upper))?Number(pe.upper):null;if(Ae===null&&je===null)return null;let Ne=0;for(let ht=0;ht<be;ht++)Ne+=ie[ht];Ne/=be;let _e=0;for(let ht=0;ht<be;ht++)_e+=(ie[ht]-Ne)**2;const Ie=Math.sqrt(_e/(be-1)),We=Le(ie),ze=We?We.sigma:null,Qe=ht=>{if(!ht||ht<=0)return{index:null,k:null};const Lt=Ae!==null&&je!==null?(je-Ae)/(6*ht):null,jt=je!==null?(je-Ne)/(3*ht):1/0,Ut=Ae!==null?(Ne-Ae)/(3*ht):1/0;return{index:Lt,k:Math.min(jt,Ut)}},gt=Qe(ze),Ot=Qe(Ie);let bt=0;for(let ht=0;ht<be;ht++){if(Ae!==null&&ie[ht]<Ae){bt++;continue}je!==null&&ie[ht]>je&&bt++}return{n:be,mean:Ne,lower:Ae,upper:je,target:Number.isFinite(Number(pe.target))?Number(pe.target):null,sigmaWithin:ze,sigmaOverall:Ie,cp:gt.index,cpk:gt.k,pp:Ot.index,ppk:Ot.k,outOfSpec:bt,defectRate:be?bt/be:null}}function Me(ie){const pe=ie.length;if(pe<2)return null;const be=Le(ie);if(!be||!(be.sigma>0))return null;let Ae=0;for(let je=0;je<pe;je++)Ae+=ie[je];return Ae/=pe,{centre:Ae,sigma:be.sigma,upper:Ae+3*be.sigma,lower:Ae-3*be.sigma}}function Ke(ie,pe){if(!pe||!(pe.sigma>0))return[];const be=ie.length,{centre:Ae,sigma:je}=pe,Ne=Ie=>(ie[Ie]-Ae)/je,_e=[];for(let Ie=0;Ie<be;Ie++){if(Math.abs(Ne(Ie))>3&&_e.push({index:Ie,rule:1,description:"beyond three sigma"}),Ie>=2)for(const We of[1,-1]){let ze=0;for(let Qe=Ie-2;Qe<=Ie;Qe++)Ne(Qe)*We>2&&ze++;if(ze>=2){_e.push({index:Ie,rule:2,description:"two of three past two sigma"});break}}if(Ie>=4)for(const We of[1,-1]){let ze=0;for(let Qe=Ie-4;Qe<=Ie;Qe++)Ne(Qe)*We>1&&ze++;if(ze>=4){_e.push({index:Ie,rule:3,description:"four of five past one sigma"});break}}if(Ie>=7)for(const We of[1,-1]){let ze=!0;for(let Qe=Ie-7;Qe<=Ie;Qe++)if(Ne(Qe)*We<=0){ze=!1;break}if(ze){_e.push({index:Ie,rule:4,description:"eight in a row on one side"});break}}}return _e}function $e(ie,pe){if(!pe||!(pe.sigma>0))return[];const be=ie.length,{centre:Ae,sigma:je}=pe,Ne=We=>(ie[We]-Ae)/je,_e=(We,ze,Qe,gt)=>{for(const Ot of[1,-1]){let bt=0;for(let ht=We;ht<=ze;ht++)Ne(ht)*Ot>Qe&&bt++;if(bt>=gt)return!0}return!1},Ie=[];for(let We=0;We<be;We++){if(Math.abs(Ne(We))>3&&Ie.push({index:We,rule:1,description:"beyond three sigma"}),We>=8)for(const ze of[1,-1]){let Qe=!0;for(let gt=We-8;gt<=We;gt++)if(Ne(gt)*ze<=0){Qe=!1;break}if(Qe){Ie.push({index:We,rule:2,description:"nine in a row on one side"});break}}if(We>=5)for(const ze of[1,-1]){let Qe=!0;for(let gt=We-4;gt<=We;gt++)if((ie[gt]-ie[gt-1])*ze<=0){Qe=!1;break}if(Qe){Ie.push({index:We,rule:3,description:ze>0?"six rising":"six falling"});break}}if(We>=13){let ze=!0;for(let Qe=We-12;Qe<=We;Qe++){const gt=ie[Qe]-ie[Qe-1],Ot=ie[Qe+1<=We?Qe+1:Qe]-ie[Qe];if(Qe+1>We)break;if(gt===0||Ot===0||gt>0==Ot>0){ze=!1;break}}ze&&Ie.push({index:We,rule:4,description:"fourteen alternating"})}if(We>=2&&_e(We-2,We,2,2)&&Ie.push({index:We,rule:5,description:"two of three past two sigma"}),We>=4&&_e(We-4,We,1,4)&&Ie.push({index:We,rule:6,description:"four of five past one sigma"}),We>=14){let ze=!0;for(let Qe=We-14;Qe<=We;Qe++)if(Math.abs(Ne(Qe))>=1){ze=!1;break}ze&&Ie.push({index:We,rule:7,description:"fifteen within one sigma"})}if(We>=7){let ze=!0;for(let Qe=We-7;Qe<=We;Qe++)if(Math.abs(Ne(Qe))<=1){ze=!1;break}ze&&Ie.push({index:We,rule:8,description:"eight beyond one sigma"})}}return Ie}const Oe=Object.freeze(["westernElectric","nelson"]);function Se(ie,pe,be="westernElectric"){return String(be)==="nelson"?$e(ie,pe):Ke(ie,pe)}function Pe(ie,pe,be){let Ae=0;for(let je=0;je<ie.length;je++)(ie[je]<pe||ie[je]>be)&&Ae++;return Ae}function Te(ie,pe,be,Ae=20){const je=ie.length;if(!je)return[];const Ne=ie[0],_e=ie[je-1];if(_e===Ne)return[{from:Ne,to:_e,count:je}];const Ie=be-pe,We=1.5*Ie;let ze=Ie>0?Math.max(Ne,pe-We):Ne,Qe=Ie>0?Math.min(_e,be+We):_e;Qe>ze||(ze=Ne,Qe=_e);const gt=Ie>0?2*Ie/Math.cbrt(je):(Qe-ze)/(Math.ceil(Math.log2(je))+1),Ot=gt>0?Math.min(Ae,Math.max(1,Math.ceil((Qe-ze)/gt))):1,bt=(Qe-ze)/Ot,ht=[];for(let Pt=0;Pt<Ot;Pt++)ht.push({from:ze+Pt*bt,to:ze+(Pt+1)*bt,count:0});for(let Pt=0;Pt<je;Pt++){const Lt=Math.min(Ot-1,Math.max(0,Math.floor((ie[Pt]-ze)/bt)));ht[Lt].count++}return ht[0].from=Ne,ht[Ot-1].to=_e,ht}const Be=.95;function Ge(ie){const pe=Number(ie);return Number.isFinite(pe)&&pe>0&&pe<1?pe:Be}function et(ie,pe=Be){const be=ie.length;if(be<2)return null;let Ae=0;for(let Qe=0;Qe<be;Qe++)Ae+=ie[Qe];const je=Ae/be;let Ne=0;for(let Qe=0;Qe<be;Qe++){const gt=ie[Qe]-je;Ne+=gt*gt}const _e=Math.sqrt(Ne/(be-1)),Ie=Ge(pe),ze=I(1-(1-Ie)/2,be-1)*_e/Math.sqrt(be);return{mean:je,lower:je-ze,upper:je+ze,margin:ze,n:be,confidence:Ie}}function Je(ie,pe,be=Be){const Ae=Number(ie),je=Number(pe);if(!(je>0)||!(Ae>=0)||Ae>je)return null;const Ne=Ge(be),_e=z(1-(1-Ne)/2),Ie=Ae/je,We=_e*_e,ze=1+We/je,Qe=(Ie+We/(2*je))/ze,gt=_e/ze*Math.sqrt(Ie*(1-Ie)/je+We/(4*je*je));return{proportion:Ie,lower:Math.max(0,Qe-gt),upper:Math.min(1,Qe+gt),n:je,confidence:Ne}}function ft(ie,pe=Be){if(!ie||!(ie.n>2)||!Number.isFinite(ie.stdError))return null;const be=Ge(pe),je=I(1-(1-be)/2,ie.n-2)*ie.stdError;return{slope:ie.slope,lower:ie.slope-je,upper:ie.slope+je,margin:je,confidence:be}}function Et(ie,pe,be=Be){const Ae=Number(ie),je=Number(pe);if(!Number.isFinite(Ae)||!(je>1))return null;const Ne=Ge(be),Ie=z(1-(1-Ne)/2)*Math.sqrt(1/(9*je)+Ae*Ae/(2*(je-1)));return{index:Ae,lower:Ae-Ie,upper:Ae+Ie,margin:Ie,n:je,confidence:Ne}}function Mt(ie,pe){return!ie||!(ie.sd>0)||!Number.isFinite(pe)||!Number.isFinite(ie.mean)?null:(pe-ie.mean)/ie.sd}function rt(ie){return Number.isFinite(ie)?Math.min(1,Math.max(0,2*L(Math.abs(ie)/2)-1)):0}function ot(ie,pe){const be=new Map,Ae=G(ie);let je=0;for(let Ne=0;Ne<pe.length;Ne++){const _e=Ae(pe[Ne]);if(_e==null||_e===""||typeof _e=="number"&&Number.isNaN(_e))continue;const Ie=_e instanceof Date?_e.getTime():typeof _e=="object"?String(_e):_e;be.set(Ie,(be.get(Ie)||0)+1),je++}return{map:be,total:je}}function ut(ie,pe,be,Ae){if(!(pe>0)||!(Ae>0))return null;let je=0;const Ne=new Set(ie.keys());for(const _e of be.keys())Ne.add(_e);for(const _e of Ne){const Ie=(ie.get(_e)||0)/pe,We=(be.get(_e)||0)/Ae;je+=Math.abs(Ie-We)}return je/2}const Tt=10;function xt(ie,pe,be){if(be&&be.numeric){const Ie=m(ie,pe),{n:We,mean:ze}=p(Ie),Qe=We>0?Mt({mean:be.mean,sd:be.sd},ze):null;return{measure:"standardizedMeanDifference",magnitude:Qe,distance:Qe===null?0:rt(Qe),direction:Qe===null?0:Math.sign(Qe),subsetN:We,populationN:be.n||0,reliable:We>=Tt}}const{map:je,total:Ne}=ot(ie,pe),_e=ut(je,Ne,be.map,be.total);return{measure:"categoricalTotalVariation",magnitude:_e,distance:_e===null?0:_e,direction:0,subsetN:Ne,populationN:be.total||0,reliable:Ne>=Tt}}function It(ie,pe){if(ie&&(ie.kind==="float64"||ie.kind==="int32"))return!0;const be=G(ie);let Ae=0,je=0;for(let Ne=0;Ne<pe.length&&Ae<200;Ne++){const _e=be(pe[Ne]);if(_e==null||_e==="")continue;if(_e instanceof Date)return!1;Ae++;const Ie=typeof _e=="number"?_e:Number(_e);Number.isFinite(Ie)&&je++}return Ae===0?!1:je/Ae>=.9}function dt(ie,pe){if(It(ie,pe)){const je=m(ie,pe),{n:Ne,mean:_e,m2:Ie}=p(je);return{numeric:!0,mean:_e,sd:Ne>0?Math.sqrt(Ie/Ne):0,n:Ne}}const{map:be,total:Ae}=ot(ie,pe);return{numeric:!1,map:be,total:Ae}}}),Ue("packages/core/src/compute/total.js",function(e,B){"use strict";Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"aggregatesFor",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"aggregateAllowed",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return p}});const T=B("packages/core/src/internal/predicates.js").isFunction,D=B("packages/core/src/internal/warn.js").warnOnce,I=B("packages/core/src/compute/handle.js"),Z=I.presenceReader,z=I.valueComparator,L=I.valueReader,X=B("packages/core/src/compute/statistics.js"),$=X.STAT_FNS,A=X.STAT_LABELS;function k(w){return!!w&&(w.kind==="float64"||w.kind==="int32")}function y(w,v){const R=v.length;let Y=0;if(k(w)){const V=w.values,E=Z(w);if(!E){for(let O=0;O<R;O++){const C=V[v[O]];Number.isNaN(C)||(Y+=C)}return Y}for(let O=0;O<R;O++){const C=v[O];if(E(C)===1){const S=V[C];Number.isNaN(S)||(Y+=S)}}return Y}const K=L(w);for(let V=0;V<R;V++){const E=m(K(v[V]));E!==null&&(Y+=E)}return Y}y.kernel=!0;function f(w,v){const R=v.length;let Y=0;if(k(w)){const V=w.values,E=Z(w);if(!E){for(let O=0;O<R;O++)Number.isNaN(V[v[O]])||Y++;return Y}for(let O=0;O<R;O++){const C=v[O];E(C)===1&&!Number.isNaN(V[C])&&Y++}return Y}const K=L(w);for(let V=0;V<R;V++){const E=K(v[V]);E!=null&&!(typeof E=="number"&&Number.isNaN(E))&&Y++}return Y}f.kernel=!0;function g(w,v){return v.length}g.kernel=!0;function a(w,v){const R=f(w,v);return R===0?null:y(w,v)/R}a.kernel=!0;function r(w,v,R,Y){const K=v.length;if(k(w)){const C=w.values,S=Z(w);let F=null;if(!S){for(let P=0;P<K;P++){const M=C[v[P]];Number.isNaN(M)||(F===null||(R<0?M<F:M>F))&&(F=M)}return F}for(let P=0;P<K;P++){const M=v[P];if(S(M)===0)continue;const x=C[M];Number.isNaN(x)||(F===null||(R<0?x<F:x>F))&&(F=x)}return F}const V=L(w),E=z(Y);let O=null;for(let C=0;C<K;C++){const S=V(v[C]);S==null||typeof S=="number"&&Number.isNaN(S)||(O===null||(R<0?E(S,O)<0:E(S,O)>0))&&(O=S)}return O}function i(w,v,R){return r(w,v,-1,R&&R.locale)}i.kernel=!0;function c(w,v,R){return r(w,v,1,R&&R.locale)}c.kernel=!0;function u(w,v){return v.length===0?null:L(w)(v[0])}u.kernel=!0;function n(w,v){return v.length===0?null:L(w)(v[v.length-1])}n.kernel=!0;function m(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 t={sum:y,min:i,max:c,avg:a,count:g,first:u,last:n,countValues:f,...$},s=Object.freeze({...A,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function h(w){return w?typeof w=="string"?s[w]||w:"Total":""}const d=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function o(w){const v=w&&w.dataType&&w.dataType.totals&&w.dataType.totals.supported;if(Array.isArray(v))return v.slice();const R=d.filter(Y=>Y in t);for(const Y of Object.keys(t))R.includes(Y)||R.push(Y);return R}function b(w,v){return typeof v!="string"?!0:o(w).includes(v)}function l(w,v){const R=L(w),Y=[];for(let K=0;K<v.length;K++){const V=R(v[K]);V!=null&&Y.push(V)}return Y}function p(w,v,R,Y){const K=v||[];if(R&&typeof R=="object"&&typeof R.fn=="string"){const{fn:V,...E}=R,O=t[V];return O?O(w,K,{...Y,...E}):(D(`total:${V}`,`unknown total function "${V}"; register it in config.totalFns`),null)}if(typeof R=="string"){const V=t[R];return V?V(w,K,Y):(D(`total:${R}`,`unknown total function "${R}"; register it in config.totalFns`),null)}return T(R)?R.kernel===!0?R(w,K,Y):R(l(w,K),Y||{}):null}}),Ue("packages/core/src/compute/windowed.js",function(e,B){"use strict";Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const T=B("packages/core/src/compute/sketch.js").Welford;class G{#e;#t;#n=[];#r;#i;constructor(L,X=0,$=Date.now){if(L!=="count"&&L!=="time"&&L!=="session")throw new RangeError(`unknown window kind: ${L}`);if((L==="count"||L==="time")&&!(X>0))throw new RangeError(`a ${L} window needs a positive span`);this.#e=L,this.#t=Math.floor(X),this.#r=$,this.#i=$()}get size(){return this.#n.length}push(L,X=this.#r()){Number.isFinite(L)&&(this.#n.push({t:X,v:L}),this.#s(X))}#s(L){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const X=L-this.#t;for(;this.#n.length&&this.#n[0].t<X;)this.#n.shift()}}spec(){const L=this.#e==="session"?this.#r()-this.#i:this.#t;return{kind:this.#e,span:L,size:this.#n.length}}values(){return this.#n.map(L=>L.v)}aggregate(){const L=this.spec();if(!this.#n.length)return{over:L,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const X=new T;let $=0,A=1/0,k=-1/0;for(const{v:y}of this.#n)$+=y,y<A&&(A=y),y>k&&(k=y),X.add(y);return{over:L,count:this.#n.length,sum:$,mean:X.mean(),min:A,max:k,variance:X.variance(),stddev:X.stddev()}}reduce(L){const X=this.aggregate(),$={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(!(L in $))throw new RangeError(`unknown windowed aggregate: ${L}`);return{value:$[L],over:X.over}}}const D=Object.freeze(["count","time","session"]);function I(z,L=Date.now){const X=z.kind==="time"&&z.minutes!=null?z.minutes*6e4:z.span??0;return new G(z.kind,X,L)}const Z={Window:G,WINDOW_KINDS:D,openWindow:I}}),Ue("packages/core/src/compute/rolling.js",function(e,B){"use strict";Object.defineProperty(e,"ROLLING_WINDOW_FIELDS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"rollingWindow",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"cumulativeToDate",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"periodOverPeriod",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"QUANTILE_SPAN_CAP",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"rollingQuantile",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"seasonalDecompose",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"exponentialSmoothing",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return m}});const T=B("packages/core/src/compute/windowed.js").openWindow,D=B("packages/core/src/compute/sketch.js").KLL,I=Object.freeze({rollingSum:"sum",rollingAvg:"avg",rollingMin:"min",rollingMax:"max"});function Z(t,s,h,d){if(t.kind==="count"){const o=Math.max(1,Math.floor(t.span||0));return{coverage:Math.min(1,s/o),partial:s<o}}if(t.kind==="time"){const o=t.minutes!=null?t.minutes*6e4:t.span||0;if(!(o>0))return{coverage:1,partial:!1};const b=h-d;return{coverage:Math.min(1,b/o),partial:b<o}}return{coverage:null,partial:!1}}function z(t,s){const h=T(s),d=new Map,o=t.length?t[0].at:0;for(let b=0;b<t.length;b++){const{key:l,at:p,value:w}=t[b];Number.isFinite(w)&&h.push(w,p);const v=h.aggregate(),R=Z(s,v.count,p,o);l!=null&&d.set(String(l),{sum:v.sum,avg:v.mean,min:v.min,max:v.max,count:v.count,coverage:R.coverage,partial:R.partial})}return d}function L(t){const s=new Map;let h=0;for(const{key:d,value:o}of t)Number.isFinite(o)&&(h+=o),d!=null&&s.set(String(d),h);return s}function X(t,s=1){const h=new Map,d=Math.max(1,Math.floor(s));for(let o=0;o<t.length;o++){const{key:b,value:l}=t[o];if(b==null)continue;const p=o>=d?t[o-d].value:null,w=Number.isFinite(l)?l:null,v=Number.isFinite(p)?p:null;h.set(String(b),w!==null&&v!==null?w-v:null)}return h}const $=4096;function A(t){let s=t>>>0;return()=>{s+=1831565813;let h=s;return h=Math.imul(h^h>>>15,h|1),h^=h+Math.imul(h^h>>>7,h|61),((h^h>>>14)>>>0)/4294967296}}function k(t,s){const h=t.length;if(h===1)return t[0];const d=(h-1)*s,o=Math.floor(d),b=Math.ceil(d);return o===b?t[o]:t[o]+(d-o)*(t[b]-t[o])}function y(t,s,h={}){const d=Math.min(1,Math.max(0,h.q==null?.5:h.q)),o=Math.max(1,Math.floor(h.cap==null?$:h.cap)),b=A(h.seed==null?2654435769:h.seed),l=new Map,p=t.length?t[0].at:0;if(s.kind==="session"){const v=new D(200,b);let R=0;for(const{key:Y,value:K}of t)Number.isFinite(K)&&(v.add(K),R++),Y!=null&&l.set(String(Y),{value:R?v.quantile(d):null,approx:R>0,count:R,coverage:null,partial:!1});return l}const w=T(s);for(const{key:v,at:R,value:Y}of t){Number.isFinite(Y)&&w.push(Y,R);const K=w.values(),V=K.length;let E=null,O=!1;if(V)if(V<=o)E=k([...K].sort((S,F)=>S-F),d);else{const S=new D(200,b);for(const F of K)S.add(F);E=S.quantile(d),O=!0}const C=Z(s,V,R,p);v!=null&&l.set(String(v),{value:E,approx:O,count:V,coverage:C.coverage,partial:C.partial})}return l}function f(t,s){const h=t.length,d=new Array(h).fill(null),o=Math.floor(s/2),b=s%2===0;for(let l=0;l<h;l++){if(l-o<0||l+o>=h)continue;let p=0,w=!0;if(b)for(let v=-o;v<=o;v++){const R=t[l+v];if(!Number.isFinite(R)){w=!1;break}p+=v===-o||v===o?R*.5:R}else for(let v=-o;v<=o;v++){const R=t[l+v];if(!Number.isFinite(R)){w=!1;break}p+=R}w&&(d[l]=p/s)}return d}function g(t,s){const h=new Map,d=Math.floor(Number(s&&s.period));if(!(d>=2))return h;const o=s&&s.model==="multiplicative",b=t.length,l=t.map(O=>Number.isFinite(O.value)?O.value:null),p=f(l,d),w=new Array(b).fill(null);for(let O=0;O<b;O++){const C=p[O],S=l[O];C===null||S===null||(o?C!==0&&(w[O]=S/C):w[O]=S-C)}const v=new Array(d).fill(0),R=new Array(d).fill(0);for(let O=0;O<b;O++){if(w[O]===null)continue;const C=O%d;v[C]+=w[O],R[C]+=1}const Y=o?1:0,K=v.map((O,C)=>R[C]?O/R[C]:Y),V=K.reduce((O,C)=>O+C,0)/d,E=o?K.map(O=>V!==0?O/V:1):K.map(O=>O-V);for(let O=0;O<b;O++){const{key:C}=t[O];if(C==null)continue;const S=p[O],F=E[O%d],P=l[O];let M=null;S!==null&&P!==null&&(M=o?S*F!==0?P/(S*F):null:P-S-F),h.set(String(C),{trend:S,seasonal:P===null?null:F,residual:M,coverage:S===null?0:1,partial:S===null})}return h}function a(t,s,h,d=80){const o=(Math.sqrt(5)-1)/2;let b=s,l=h,p=l-o*(l-b),w=b+o*(l-b),v=t(p),R=t(w);for(let Y=0;Y<d;Y++)v<R?(l=w,w=p,R=v,p=l-o*(l-b),v=t(p)):(b=p,p=w,v=R,w=b+o*(l-b),R=t(w));return(b+l)/2}const r=1e-4,i=1-1e-4;function c(t,s){const h=t.length,d=new Array(h).fill(null),o=new Array(h).fill(null);let b=null,l=0;for(let p=0;p<h;p++){const w=t[p];if(!Number.isFinite(w)){b!==null&&(o[p]=b,d[p]=b);continue}if(b===null){b=w,o[p]=w,d[p]=w;continue}o[p]=b,l+=(w-b)**2,b=s*w+(1-s)*b,d[p]=b}return{smoothed:d,fitted:o,sse:l}}function u(t,s,h){const d=t.length,o=new Array(d).fill(null),b=new Array(d).fill(null);let l=null,p=null,w=0;for(let v=0;v<d;v++){const R=t[v];if(!Number.isFinite(R)){l!==null&&(l+=p,o[v]=l);continue}if(l===null){l=R,o[v]=R;continue}if(p===null){p=R-l;const V=l+p;b[v]=V,w+=(R-V)**2;const E=l;l=s*R+(1-s)*(E+p),p=h*(l-E)+(1-h)*p,o[v]=l;continue}const Y=l+p;b[v]=Y,w+=(R-Y)**2;const K=l;l=s*R+(1-s)*(K+p),p=h*(l-K)+(1-h)*p,o[v]=l}return{smoothed:o,fitted:b,sse:w}}function n(t,s={}){const h=new Map,d=s.method==="holt",o=t.map(Y=>Number.isFinite(Y.value)?Y.value:null),b=o.filter(Y=>Y!==null).length,l=Y=>Math.min(i,Math.max(r,Y)),p=()=>{for(const{key:Y}of t)Y!=null&&h.set(String(Y),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return h};if(b<(d?2:1))return p();let w=Number.isFinite(s.alpha)?l(s.alpha):null,v=d&&Number.isFinite(s.beta)?l(s.beta):null;if(d){if(w===null||v===null){let Y=w===null?.5:w,K=v===null?.5:v;for(let V=0;V<6;V++)w===null&&(Y=a(E=>u(o,E,K).sse,r,i)),v===null&&(K=a(E=>u(o,Y,E).sse,r,i));w=w===null?Y:w,v=v===null?K:v}}else w===null&&(w=a(Y=>c(o,Y).sse,r,i));const R=d?u(o,w,v):c(o,w);for(let Y=0;Y<t.length;Y++){const{key:K}=t[Y];K!=null&&h.set(String(K),{smoothed:R.smoothed[Y],fitted:R.fitted[Y],alpha:w,beta:d?v:null,sse:R.sse})}return h}const m={ROLLING_WINDOW_FIELDS:I,QUANTILE_SPAN_CAP:$,rollingWindow:z,rollingQuantile:y,cumulativeToDate:L,periodOverPeriod:X,seasonalDecompose:g,exponentialSmoothing:n}}),Ue("packages/core/src/compute/cluster.js",function(e,B){"use strict";Object.defineProperty(e,"CLUSTER_ROW_CAP",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"DBSCAN_ROW_CAP",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"DEFAULT_K",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"DEFAULT_MIN_POINTS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"orderByCentre",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"kmeans",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"dbscan",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"autoK",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"standardise",{enumerable:!0,get:function(){return r}});const re=1e5,T=2e4,G=3,D=5,I=100;function Z(i){let c=i>>>0;return function(){c=c+1831565813|0;let n=Math.imul(c^c>>>15,1|c);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}function z(i,c){let u=0;for(let n=0;n<i.length;n++){const m=i[n]-c[n];u+=m*m}return u}function L(i,c){return Math.sqrt(z(i,c))}function X(i,c){let u=-1,n=1/0;for(let m=0;m<c.length;m++){const t=z(i,c[m]);t<n&&(n=t,u=m)}return u}function $(i,c,u){const n=Z(u),m=i.length,t=[Array.from(i[Math.floor(n()*m)])],s=new Float64Array(m).fill(1/0);for(let h=1;h<c;h++){let d=0;for(let p=0;p<m;p++){const w=z(i[p],t[t.length-1]);w<s[p]&&(s[p]=w),d+=s[p]}const o=n()*(d||m);let b=0,l=m-1;for(let p=0;p<m;p++)if(b+=d?s[p]:1,b>=o){l=p;break}t.push(Array.from(i[l]))}return t}function A(i,c){for(let u=0;u<i.length;u++){const n=i[u]-c[u];if(n!==0)return n}return 0}function k(i,c,u,n){const m=c.map((s,h)=>({centre:s,i:h})).sort((s,h)=>A(s.centre,h.centre)),t=new Int32Array(c.length);for(let s=0;s<m.length;s++)t[m[s].i]=s;for(let s=0;s<i.length;s++)i[s]>=0&&(i[s]=t[i[s]]);return{assignments:i,centres:m.map(s=>s.centre),sizes:m.map(s=>u[s.i]),distances:n}}function y(i,c={}){const u=i.length,n=u?i[0].length:0,m=Math.floor(c.k||G);if(!(u>=m)||m<1||n<1)return null;let t=$(i,m,c.seed===void 0?1:c.seed);const s=new Int32Array(u);let h=!0;for(let l=0;l<I&&h;l++){h=!1;for(let v=0;v<u;v++){const R=X(i[v],t);s[v]!==R&&(s[v]=R,h=!0)}const p=t.map(()=>new Float64Array(n)),w=new Array(m).fill(0);for(let v=0;v<u;v++){const R=s[v];for(let Y=0;Y<n;Y++)p[R][Y]+=i[v][Y];w[R]++}for(let v=0;v<m;v++)if(w[v])for(let R=0;R<n;R++)t[v][R]=p[v][R]/w[v];else{let R=0,Y=-1/0;for(let K=0;K<u;K++){const V=z(i[K],t[v]);V>Y&&(Y=V,R=K)}t[v]=Array.from(i[R]),h=!0}}const d=new Array(m).fill(0),o=new Float64Array(u);let b=0;for(let l=0;l<u;l++){const p=s[l];d[p]++;const w=z(i[l],t[p]);o[l]=Math.sqrt(w),b+=w}return{assignments:s,centres:t,sizes:d,inertia:b,distances:o}}function f(i,c={}){const u=i.length,n=u?i[0].length:0,m=Number(c.eps),t=Math.max(1,Math.floor(c.minPoints||D));if(!(m>0)||u===0||n<1)return null;const s=new Array(u);for(let w=0;w<u;w++){const v=[];for(let R=0;R<u;R++)w!==R&&L(i[w],i[R])<=m&&v.push(R);s[w]=v}const h=new Int32Array(u).fill(-1);let d=0;for(let w=0;w<u;w++){if(h[w]!==-1||s[w].length<t)continue;h[w]=d;const v=[...s[w]];for(let R=0;R<v.length;R++){const Y=v[R];h[Y]===-1&&(h[Y]=d,s[Y].length>=t&&v.push(...s[Y]))}d++}if(!d)return{assignments:h,centres:[],sizes:[],distances:new Float64Array(u).fill(NaN)};const o=[],b=new Array(d).fill(0),l=Array.from({length:d},()=>new Float64Array(n));for(let w=0;w<u;w++){const v=h[w];if(!(v<0)){b[v]++;for(let R=0;R<n;R++)l[v][R]+=i[w][R]}}for(let w=0;w<d;w++){const v=new Array(n);for(let R=0;R<n;R++)v[R]=l[w][R]/b[w];o.push(v)}const p=new Float64Array(u).fill(NaN);for(let w=0;w<u;w++){const v=h[w];v>=0&&(p[w]=L(i[w],o[v]))}return{assignments:h,centres:o,sizes:b,distances:p}}function g(i,c,u){const n=i.length;if(n===0)return 0;const m=new Int32Array(u);for(let s=0;s<n;s++)m[c[s]]++;let t=0;for(let s=0;s<n;s++){const h=c[s],d=new Float64Array(u);for(let l=0;l<n;l++)s!==l&&(d[c[l]]+=L(i[s],i[l]));const o=m[h]>1?d[h]/(m[h]-1):0;let b=1/0;for(let l=0;l<u;l++){if(l===h||m[l]===0)continue;const p=d[l]/m[l];p<b&&(b=p)}b!==1/0&&(t+=(b-o)/Math.max(o,b))}return t/n}function a(i,c={}){const u=i.length;if(!u)return null;const n=c.criterion==="silhouette"?"silhouette":"elbow",m=Math.max(2,Math.floor(c.maxK||8)),t=c.seed===void 0?1:c.seed;if(n==="silhouette"){const w=[],v=[];for(let Y=2;Y<=Math.min(m,u);Y++){const K=y(i,{k:Y,seed:t});K&&(w.push(Y),v.push(g(i,K.assignments,Y)))}if(!w.length)return null;let R=0;for(let Y=1;Y<v.length;Y++)v[Y]>v[R]&&(R=Y);return{k:w[R],criterion:n,scores:v,ks:w}}const s=[],h=[];for(let w=1;w<=Math.min(m,u);w++){const v=y(i,{k:w,seed:t});v&&(s.push(w),h.push(v.inertia))}if(h.length<2)return null;const d={k:s[0],y:h[0]},o={k:s[s.length-1],y:h[h.length-1]},b=Math.hypot(o.k-d.k,o.y-d.y)||1;let l=0,p=-1/0;for(let w=0;w<h.length;w++){const v=Math.abs((o.k-d.k)*(d.y-h[w])-(d.k-s[w])*(o.y-d.y))/b;v>p&&(p=v,l=w)}return{k:s[l],criterion:n,scores:h,ks:s}}function r(i){const c=i.length,u=c?i[0].length:0;if(!c||!u)return null;const n=new Array(u).fill(0);for(let t=0;t<c;t++)for(let s=0;s<u;s++)n[s]+=i[t][s];for(let t=0;t<u;t++)n[t]/=c;const m=new Array(u).fill(0);for(let t=0;t<c;t++)for(let s=0;s<u;s++){const h=i[t][s]-n[s];m[s]+=h*h}for(let t=0;t<u;t++)m[t]=c>1?Math.sqrt(m[t]/(c-1)):0;for(let t=0;t<c;t++)for(let s=0;s<u;s++)m[s]>0?i[t][s]=(i[t][s]-n[s])/m[s]:i[t][s]=i[t][s]-n[s];return{mean:n,sd:m}}}),Ue("packages/core/src/compute/compare.js",function(e,B){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"pooledStandardMeanDifference",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"numericSummary",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"bothNumeric",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"compareColumnAcross",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"compareDatasets",{enumerable:!0,get:function(){return f}});const re=B("packages/core/src/compute/statistics.js"),T=re.numbers,G=re.moments,D=re.frequencyMap,I=re.categoricalDistance,Z=re.normalTotalVariation,z=re.isNumericColumn,L=re.SUBSET_RELIABILITY_FLOOR,X=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function $(g,a){if(!g||!a||!(g.n>0)||!(a.n>0)||!Number.isFinite(g.mean)||!Number.isFinite(a.mean))return null;const r=(g.n*g.sd*g.sd+a.n*a.sd*a.sd)/(g.n+a.n);return r>0?(g.mean-a.mean)/Math.sqrt(r):null}function A(g,a){const r=T(g,a),{n:i,mean:c,m2:u}=G(r),n=i>0?Math.sqrt(u/i):0;return{mean:c,sd:n,n:i}}function k(g,a,r,i){return z(g,a)&&z(r,i)}function y(g,a,r,i){if(k(g,a,r,i)){const m=A(g,a),t=A(r,i),s=$(m,t);return{measure:X.numeric,magnitude:s,distance:s===null?0:Z(s),direction:s===null?0:Math.sign(s),nA:m.n,nB:t.n,meanA:m.mean,meanB:t.mean,reliable:m.n>=L&&t.n>=L}}const c=D(g,a),u=D(r,i),n=I(c.map,c.total,u.map,u.total);return{measure:X.categorical,magnitude:n,distance:n===null?0:n,direction:0,nA:c.total,nB:u.total,meanA:null,meanB:null,reliable:c.total>=L&&u.total>=L}}function f(g,a,r={}){const i=new Set(g.columns),c=new Set(a.columns),u=g.columns.filter(h=>c.has(h)),n=Array.isArray(r.columns)&&r.columns.length?u.filter(h=>r.columns.includes(h)):u,m=g.indices(),t=a.indices(),s=[];for(const h of n){const d=g.handle(h),o=a.handle(h);if(!d||!o)continue;const b=y(d,m,o,t);s.push({column:h,name:g.name&&g.name(h)||a.name&&a.name(h)||h,measure:b.measure,magnitude:b.magnitude,distance:b.distance,direction:b.direction,nA:b.nA,nB:b.nB,meanA:b.meanA,meanB:b.meanB,reliable:b.reliable})}return s.sort((h,d)=>d.distance-h.distance||Math.abs(d.magnitude||0)-Math.abs(h.magnitude||0)),{ranked:s,nA:m.length,nB:t.length,unmatched:{onlyA:g.columns.filter(h=>!c.has(h)),onlyB:a.columns.filter(h=>!i.has(h))},measures:X}}}),Ue("packages/core/src/compute/anomaly.js",function(e,B){"use strict";Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"robustSpread",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return m}});const T=B("packages/core/src/compute/statistics.js").quantileSorted,D=B("packages/core/src/compute/special.js").logGamma,I=.6745,Z=3.5,z=1.5,L=.975,X=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function $(t){if(!t.length)return null;const h=Array.from(t,Number).sort((l,p)=>l-p),d=T(h,.5),o=h.map(l=>Math.abs(l-d)).sort((l,p)=>l-p),b=T(o,.5);return{median:d,mad:b}}function A(t,s={}){const h=Number.isFinite(s.threshold)?s.threshold:Z,d=t.length,o=new Array(d).fill(null),b=new Array(d).fill(!1),l=[];for(let v=0;v<d;v++){const R=Number(t[v]);Number.isFinite(R)&&l.push(R)}if(!l.length)return{median:null,mad:null,threshold:h,scores:o,flags:b,flagged:0};const p=$(l);if(p.mad===0)return{median:p.median,mad:0,threshold:h,scores:o,flags:b,flagged:0};let w=0;for(let v=0;v<d;v++){const R=Number(t[v]);if(!Number.isFinite(R))continue;const Y=I*(R-p.median)/p.mad;o[v]=Y,Math.abs(Y)>h&&(b[v]=!0,w++)}return{median:p.median,mad:p.mad,threshold:h,scores:o,flags:b,flagged:w}}function k(t,s={}){const h=Number.isFinite(s.k)?s.k:z,d=[];for(let w=0;w<t.length;w++){const v=Number(t[w]);Number.isFinite(v)&&d.push(v)}if(!d.length)return null;const o=d.sort((w,v)=>w-v),b=T(o,.25),l=T(o,.75),p=l-b;return{q1:b,q3:l,iqr:p,lower:b-h*p,upper:l+h*p,k:h}}function y(t,s){if(s<=0)return 0;const h=D(t);if(s<t+1){let v=t,R=1/t,Y=R;for(let K=0;K<1e3&&(v+=1,Y*=s/v,R+=Y,!(Math.abs(Y)<Math.abs(R)*1e-15));K++);return R*Math.exp(-s+t*Math.log(s)-h)}const d=1e-300;let o=s+1-t,b=1/d,l=1/o,p=l;for(let v=1;v<1e3;v++){const R=-v*(v-t);o+=2,l=R*l+o,Math.abs(l)<d&&(l=d),b=o+R/b,Math.abs(b)<d&&(b=d),l=1/l;const Y=l*b;if(p*=Y,Math.abs(Y-1)<1e-15)break}return 1-Math.exp(-s+t*Math.log(s)-h)*p}function f(t,s){return t<=0?0:y(s/2,t/2)}function g(t,s=L){if(!(s>0)||!(s<1))return NaN;let h=0,d=Math.max(1,t);for(;f(d,t)<s;)d*=2;for(let o=0;o<200;o++){const b=(h+d)/2;if(f(b,t)<s?h=b:d=b,d-h<1e-10)break}return(h+d)/2}function a(t){const s=t.length,h=t.map((d,o)=>{const b=d.slice();for(let l=0;l<s;l++)b.push(o===l?1:0);return b});for(let d=0;d<s;d++){let o=d;for(let l=d+1;l<s;l++)Math.abs(h[l][d])>Math.abs(h[o][d])&&(o=l);if(Math.abs(h[o][d])<1e-12)return null;if(o!==d){const l=h[o];h[o]=h[d],h[d]=l}const b=h[d][d];for(let l=0;l<2*s;l++)h[d][l]/=b;for(let l=0;l<s;l++){if(l===d)continue;const p=h[l][d];if(p!==0)for(let w=0;w<2*s;w++)h[l][w]-=p*h[d][w]}}return h.map(d=>d.slice(s))}function r(t,s){const h=t.length,d=new Array(s).fill(0);for(const l of t)for(let p=0;p<s;p++)d[p]+=l[p];for(let l=0;l<s;l++)d[l]/=h;const o=Array.from({length:s},()=>new Array(s).fill(0));for(const l of t)for(let p=0;p<s;p++){const w=l[p]-d[p];for(let v=p;v<s;v++)o[p][v]+=w*(l[v]-d[v])}const b=h>1?h-1:1;for(let l=0;l<s;l++)for(let p=l;p<s;p++)o[l][p]/=b,o[p][l]=o[l][p];return{mean:d,cov:o}}function i(t,s={}){const h=Number.isFinite(s.p)?s.p:L,d=Number.isFinite(s.ridge)?s.ridge:1e-6,o=t.length;if(!o)return null;const b=t[0].length;if(!b)return null;const l=new Array(o).fill(null),p=new Array(o).fill(null),w=new Array(o).fill(!1),v=[],R=[];for(let F=0;F<o;F++){const P=t[F];let M=P.length===b;const x=new Array(b);for(let U=0;M&&U<b;U++){const _=Number(P[U]);Number.isFinite(_)?x[U]=_:M=!1}M&&(v.push(F),R.push(x))}const Y=b,K=g(Y,h);if(R.length<=b)return{center:[],df:Y,cutoff:K,singular:!0,used:R.length,distances:l,squared:p,flags:w,flagged:0};const{mean:V,cov:E}=r(R,b);let O=a(E),C=!1;if(!O){C=!0;let F=0;for(let x=0;x<b;x++)F+=E[x][x];const P=F/b*d||d,M=E.map((x,U)=>x.map((_,W)=>U===W?_+P:_));if(O=a(M),!O)return{center:V,df:Y,cutoff:K,singular:!0,used:R.length,distances:l,squared:p,flags:w,flagged:0}}let S=0;for(let F=0;F<R.length;F++){const P=R[F],M=new Array(b);for(let _=0;_<b;_++)M[_]=P[_]-V[_];let x=0;for(let _=0;_<b;_++){let W=0;for(let q=0;q<b;q++)W+=O[_][q]*M[q];x+=M[_]*W}x<0&&(x=0);const U=v[F];p[U]=x,l[U]=Math.sqrt(x),x>K&&(w[U]=!0,S++)}return{center:V,df:Y,cutoff:K,singular:C,used:R.length,distances:l,squared:p,flags:w,flagged:S}}const c=20,u=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function n(t,s={}){const h=s.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",d=Number.isFinite(s.windowLen)&&s.windowLen>=1?Math.floor(s.windowLen):c,o=Number.isFinite(s.threshold)?s.threshold:Z,b=Number.isFinite(s.k)?s.k:z,l=Number.isFinite(s.minPeriods)&&s.minPeriods>=1?Math.floor(s.minPeriods):d,p=t.length,w=new Array(p).fill(null),v=new Array(p).fill(!1);let R=0;for(let Y=0;Y<p;Y++){const K=Number(t[Y]);if(!Number.isFinite(K))continue;const V=Math.max(0,Y-d+1),E=[];for(let O=V;O<=Y;O++){const C=Number(t[O]);Number.isFinite(C)&&E.push(C)}if(!(E.length<l))if(h==="rollingIqr"){const O=k(E,{k:b});if(!O)continue;(K<O.lower||K>O.upper)&&(v[Y]=!0,R++)}else{const O=$(E);if(!O||O.mad===0)continue;const C=I*(K-O.median)/O.mad;w[Y]=C,Math.abs(C)>o&&(v[Y]=!0,R++)}}return{method:h,windowLen:d,minPeriods:l,threshold:o,k:b,scores:w,flags:v,flagged:R}}function m(t={}){const s=t||{},h=s.field;if(typeof h!="string"||!h)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const d=s.method||"modifiedZScore";if(!(X.includes(d)||u.includes(d))||d==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${d}'`);const b=typeof s.orderBy=="string"?s.orderBy:null,l=s.latest===!0,p=u.includes(d),w=v=>Number(v==null?NaN:v[h]);return v=>{const R=Array.isArray(v)?v.slice():[...v];b&&R.sort((O,C)=>{const S=O?.[b],F=C?.[b];return S===F?0:S==null?-1:F==null?1:S<F?-1:1});const Y=R.map(w);let K,V;if(p)({flags:K,scores:V}=n(Y,{method:d,windowLen:s.windowLen,threshold:s.threshold,k:s.k,minPeriods:s.minPeriods}));else if(d==="iqr"){const O=k(Y,{k:s.k});K=Y.map(C=>O?Number.isFinite(C)&&(C<O.lower||C>O.upper):!1),V=Y.map(()=>null)}else({flags:K,scores:V}=A(Y,{threshold:s.threshold}));if(l){const O=K.length-1;return O<0||!K[O]?!1:{method:d,field:h,flagged:[{row:R[O],score:V[O]}]}}const E=[];for(let O=0;O<K.length;O++)K[O]&&E.push({row:R[O],score:V[O]});return E.length?{method:d,field:h,flagged:E}:!1}}}),Ue("packages/core/src/compute/forecast.js",function(e,B){"use strict";Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const re=B("packages/core/src/compute/special.js"),T=re.normalQuantile,G=re.studentTQuantile,I=B("packages/core/src/internal/warn.js").warnOnce,Z=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),z=1e-4,L=1-1e-4;function X(s){const h=[];for(let d=0;d<s.length;d++){const o=s[d];if(o!==null&&typeof o=="object"){const b=Number.isFinite(o.at)?o.at:d,l=Number.isFinite(o.value)?o.value:null;h.push({at:b,value:l})}else h.push({at:d,value:Number.isFinite(o)?Number(o):null})}return h}function $(s){const h=s.filter(p=>p.value!==null),d=h[0],o=h[h.length-1],b=o.at-d.at,l=h.length>1&&b>0?b/(h.length-1):1;return{lastAt:o.at,step:l}}function A(s){return Math.min(L,Math.max(z,s))}function k(s,h=z,d=L,o=80){const b=(Math.sqrt(5)-1)/2;let l=h,p=d,w=p-b*(p-l),v=l+b*(p-l),R=s(w),Y=s(v);for(let K=0;K<o;K++)R<Y?(p=v,v=w,Y=R,w=p-b*(p-l),R=s(w)):(l=w,w=v,R=Y,v=l+b*(p-l),Y=s(v));return(l+p)/2}function y(s,h){let d=null,o=0,b=0;for(let l=0;l<s.length;l++){const p=s[l];if(p!==null){if(d===null){d=p;continue}o+=(p-d)**2,b+=1,d=h*p+(1-h)*d}}return{level:d,sse:o,m:b}}function f(s,h,d){let o=null,b=null,l=0,p=0;for(let w=0;w<s.length;w++){const v=s[w];if(v===null){o!==null&&b!==null&&(o+=b);continue}if(o===null){o=v;continue}b===null&&(b=v-o);const R=o+b;l+=(v-R)**2,p+=1;const Y=o;o=h*v+(1-h)*(Y+b),b=d*(o-Y)+(1-d)*b}return{level:o,trend:b,sse:l,m:p}}function g(s,h,d,o,b){const l=s.length;if(l<2*h)return null;const p=C=>{let S=0,F=0;for(let P=C;P<C+h&&P<l;P++)s[P]!==null&&(S+=s[P],F+=1);return F?S/F:null},w=p(0),v=p(h);if(w===null||v===null)return null;let R=w,Y=(v-w)/h;const K=new Array(h).fill(0);for(let C=0;C<h;C++)K[C]=s[C]===null?0:s[C]-R;const V=K.reduce((C,S)=>C+S,0)/h;for(let C=0;C<h;C++)K[C]-=V;let E=0,O=0;for(let C=h;C<l;C++){const S=C%h,F=K[S],P=s[C];if(P===null){R+=Y;continue}const M=R+Y+F;E+=(P-M)**2,O+=1;const x=R;R=d*(P-F)+(1-d)*(R+Y),Y=o*(R-x)+(1-o)*Y,K[S]=b*(P-R)+(1-b)*F}return{level:R,trend:Y,season:K,phase:(l-1)%h,sse:E,count:O}}function a(s,h,d){let o=1;for(const l of h)o+=l*l;const b=Math.sqrt(s*o);return{se:b,margin:d*b}}function r(s,h={}){if(!s||typeof s.length!="number"||s.length===0)return null;const d=Z.includes(h.method)?h.method:"linear",o=Math.max(1,Math.floor(Number(h.horizon)||1)),b=Number.isFinite(h.confidence)&&h.confidence>0&&h.confidence<1?h.confidence:.95,l=1-(1-b)/2,p=X(s),w=p.map(E=>E.value),v=w.filter(E=>E!==null),R=v.length,{lastAt:Y,step:K}=R?$(p):{lastAt:0,step:1},V=E=>Y+E*K;return d==="linear"?i(p,R,o,b,l,V):d==="movingAverage"?c(v,R,o,b,l,h,V):d==="ses"?u(w,R,o,b,l,h,V):d==="holt"?n(w,R,o,b,l,h,V):m(w,R,o,b,l,h,V)}function i(s,h,d,o,b,l){if(h<2)return null;let p=0,w=0;for(const P of s)P.value!==null&&(p+=P.at,w+=P.value);p/=h,w/=h;let v=0,R=0,Y=0;for(const P of s){if(P.value===null)continue;const M=P.at-p,x=P.value-w;v+=M*M,R+=M*x,Y+=x*x}if(v===0)return null;const K=R/v,V=w-K*p,E=Y===0?1:Math.max(0,Math.min(1,R*R/(v*Y))),O=Math.max(0,Y-K*R),C=h>2?Math.sqrt(O/(h-2)):null,S=h>2?G(b,h-2):null,F=[];for(let P=1;P<=d;P++){const M=l(P),x=V+K*M;let U=null,_=null,W=null,q=null,N=null;if(C!==null){const Q=1/h+(M-p)**2/v,J=C*Math.sqrt(1+Q),ee=C*Math.sqrt(Q);N=J,U=x-S*J,_=x+S*J,W=x-S*ee,q=x+S*ee}F.push({step:P,at:M,mean:x,lower:U,upper:_,lowerMean:W,upperMean:q,se:N})}return{method:"linear",horizon:d,confidence:o,n:h,sigma:C,r2:E,params:{slope:K,intercept:V},points:F}}function c(s,h,d,o,b,l,p){if(h<1)return null;const w=Math.max(1,Math.min(h,Math.floor(Number(l.windowLen)||h))),v=s.slice(h-w);let R=0;for(const C of v)R+=C;const Y=R/w;let K=null,V=null;if(w>1){let C=0;for(const F of v)C+=(F-Y)**2;K=Math.sqrt(C/(w-1))*Math.sqrt(1+1/w),V=G(b,w-1)}const E=K===null?null:V*K,O=[];for(let C=1;C<=d;C++)O.push({step:C,at:p(C),mean:Y,lower:E===null?null:Y-E,upper:E===null?null:Y+E,se:K});return{method:"movingAverage",horizon:d,confidence:o,n:h,sigma:K===null?null:K,params:{windowLen:w},points:O}}function u(s,h,d,o,b,l,p){if(h<1)return null;let w=Number.isFinite(l.alpha)?A(l.alpha):null;w===null&&(w=k(V=>y(s,V).sse));const v=y(s,w),R=T(b),Y=v.m>0?v.sse/v.m:null,K=[];for(let V=1;V<=d;V++){const E=v.level;let O=null,C=null,S=null;if(Y!==null){const F=[];for(let M=1;M<V;M++)F.push(w);const P=a(Y,F,R);S=P.se,O=E-P.margin,C=E+P.margin}K.push({step:V,at:p(V),mean:E,lower:O,upper:C,se:S})}return{method:"ses",horizon:d,confidence:o,n:h,sigma:Y===null?null:Math.sqrt(Y),params:{alpha:w},points:K}}function n(s,h,d,o,b,l,p){if(h<2)return null;let w=Number.isFinite(l.alpha)?A(l.alpha):null,v=Number.isFinite(l.beta)?A(l.beta):null;if(w===null||v===null){let O=w===null?.5:w,C=v===null?.5:v;for(let S=0;S<6;S++)w===null&&(O=k(F=>f(s,F,C).sse)),v===null&&(C=k(F=>f(s,O,F).sse));w=w===null?O:w,v=v===null?C:v}const R=f(s,w,v),Y=T(b),K=R.m>0?R.sse/R.m:null,V=w*v,E=[];for(let O=1;O<=d;O++){const C=R.level+O*R.trend;let S=null,F=null,P=null;if(K!==null){const M=[];for(let U=1;U<O;U++)M.push(w+U*V);const x=a(K,M,Y);P=x.se,S=C-x.margin,F=C+x.margin}E.push({step:O,at:p(O),mean:C,lower:S,upper:F,se:P})}return{method:"holt",horizon:d,confidence:o,n:h,sigma:K===null?null:Math.sqrt(K),params:{alpha:w,beta:v},points:E}}function m(s,h,d,o,b,l,p){const w=Math.floor(Number(l.period));if(!(w>=2))return I("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(h<2*w)return null;let v=Number.isFinite(l.alpha)?A(l.alpha):null,R=Number.isFinite(l.beta)?A(l.beta):null,Y=Number.isFinite(l.gamma)?A(l.gamma):null;const K=(P,M,x)=>{const U=g(s,w,P,M,x);return U?U.sse:1/0};if(v===null||R===null||Y===null){let P=v===null?.5:v,M=R===null?.5:R,x=Y===null?.5:Y;for(let U=0;U<8;U++)v===null&&(P=k(_=>K(_,M,x))),R===null&&(M=k(_=>K(P,_,x))),Y===null&&(x=k(_=>K(P,M,_)));v=v===null?P:v,R=R===null?M:R,Y=Y===null?x:Y}const V=g(s,w,v,R,Y);if(!V)return null;const E=T(b),O=V.count>0?V.sse/V.count:null,C=v*R,S=Y*(1-v),F=[];for(let P=1;P<=d;P++){const M=V.season[(V.phase+P)%w],x=V.level+P*V.trend+M;let U=null,_=null,W=null;if(O!==null){const q=[];for(let Q=1;Q<P;Q++)q.push(v+Q*C+(Q%w===0?S:0));const N=a(O,q,E);W=N.se,U=x-N.margin,_=x+N.margin}F.push({step:P,at:p(P),mean:x,lower:U,upper:_,se:W})}return{method:"holtWinters",horizon:d,confidence:o,n:h,sigma:O===null?null:Math.sqrt(O),params:{alpha:v,beta:R,gamma:Y,period:w},points:F}}const t={FORECAST_METHODS:Z,forecast:r}}),Ue("packages/core/src/compute/hypothesis.js",function(e,B){"use strict";Object.defineProperty(e,"GROUP_TESTS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"NORMALITY_ALPHA",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HL_PAIR_LIMIT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"welchTTest",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"mannWhitneyUTest",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"chiSquareTest",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"compareGroups",{enumerable:!0,get:function(){return E}});const T=B("packages/core/src/internal/warn.js").warnOnce,D=B("packages/core/src/compute/handle.js").valueReader,I=B("packages/core/src/compute/statistics.js"),Z=I.numbers,z=I.moments,L=I.frequencyMap,X=I.categoricalDistance,$=I.isNumericColumn,A=I.jarqueBera,k=I.proportionInterval,y=I.SUBSET_RELIABILITY_FLOOR,g=B("packages/core/src/compute/compare.js").pooledStandardMeanDifference,a=B("packages/core/src/compute/special.js"),r=a.studentT,i=a.studentTQuantile,c=a.normalCdf,u=a.normalQuantile,n=a.chiSquareUpperTail,m=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),t=.05,s=2e6;function h(O){const C=Number(O);return Number.isFinite(C)&&C>0&&C<1?C:.95}function d(O){const{n:C,mean:S,m2:F}=z(O);return{mean:S,sd:C>0?Math.sqrt(F/C):0,n:C}}function o(O,C){const S=O.length;if(S<2)return 0;let F=0;for(let P=0;P<S;P++){const M=O[P]-C;F+=M*M}return F/(S-1)}function b(O,C){return{name:"pooledStandardMeanDifference",value:g(d(O),d(C))}}function l(O,C,S){const F=O.length,P=C.length;if(F<2||P<2)return null;const M=h(S),{mean:x}=z(O),{mean:U}=z(C),_=o(O,x),W=o(C,U),q=_/F+W/P;if(!(q>0))return null;const N=Math.sqrt(q),Q=(x-U)/N,J=_/F*(_/F)/(F-1),ee=W/P*(W/P)/(P-1),ne=q*q/(J+ee),se=Math.min(1,Math.max(0,2*(1-r(Math.abs(Q),ne)))),le=x-U,ye=i(1-(1-M)/2,ne)*N;return{test:m.WELCH,statistic:Q,statisticName:"t",df:ne,pValue:se,interval:{estimate:le,lower:le-ye,upper:le+ye,confidence:M,method:"welch-t (difference of means)"},effectSize:b(O,C),nA:F,nB:P,reliable:F>=y&&P>=y,method:"Welch's t-test (unequal variances; Welch–Satterthwaite df)"}}function p(O){const C=O.length;if(C===0)return Number.NaN;const S=C>>1;return C%2?O[S]:(O[S-1]+O[S])/2}function w(O,C,S){const F=O.length,P=C.length,M=F*P;if(M===0||M>s)return null;const x=new Float64Array(M);let U=0;for(let J=0;J<F;J++)for(let ee=0;ee<P;ee++)x[U++]=O[J]-C[ee];x.sort();const _=p(x),W=Math.sqrt(F*P*(F+P+1)/12),q=u(1-(1-S)/2);let N=Math.round(M/2-q*W);N>=0||(N=0);const Q=Math.floor((M-1)/2);return N>Q&&(N=Q),{estimate:_,lower:x[N],upper:x[M-1-N],confidence:S,method:"hodges-lehmann (normal approximation)"}}function v(O,C,S){const F=O.length,P=C.length;if(F<1||P<1)return null;const M=h(S),x=F+P,U=new Array(x);for(let se=0;se<F;se++)U[se]={v:O[se],g:0};for(let se=0;se<P;se++)U[F+se]={v:C[se],g:1};U.sort((se,le)=>se.v-le.v);let _=0,W=0,q=0;for(;q<x;){let se=q;for(;se<x&&U[se].v===U[q].v;)se++;const le=se-q,ye=(q+1+se)/2;for(let fe=q;fe<se;fe++)U[fe].g===0&&(_+=ye);W+=le*le*le-le,q=se}const N=_-F*(F+1)/2,Q=F*P/2,J=F*P/12*(x+1-W/(x*(x-1)));let ee=1;if(J>0){const se=Math.max(0,Math.abs(N-Q)-.5);ee=Math.min(1,2*c(-se/Math.sqrt(J)))}const ne=w(O,C,M);return{test:m.MANN_WHITNEY,statistic:N,statisticName:"U",df:null,pValue:ee,interval:ne,effectSize:b(O,C),nA:F,nB:P,reliable:F>=y&&P>=y,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function R(O,C,S,F,P){const M=k(O,C,P),x=k(S,F,P);if(!M||!x)return null;const U=M.proportion-x.proportion,_=U-Math.sqrt((M.proportion-M.lower)**2+(x.upper-x.proportion)**2),W=U+Math.sqrt((M.upper-M.proportion)**2+(x.proportion-x.lower)**2);return{lower:_,upper:W}}function Y(O,C,S,F,P,M={}){if(!(C>0)||!(F>0))return null;const x=new Set([...O.keys(),...S.keys()]),U=x.size;if(U<2)return null;const _=C+F;let W=0;for(const ee of x){const ne=O.get(ee)||0,se=S.get(ee)||0,le=ne+se,ye=C*le/_,fe=F*le/_;ye>0&&(W+=(ne-ye)*(ne-ye)/ye),fe>0&&(W+=(se-fe)*(se-fe)/fe)}const q=U-1,N=n(W,q);let Q=null;M.category!==void 0&&x.has(M.category)?Q=M.category:U===2&&([Q]=[...x]);let J=null;if(Q!==null){const ee=R(O.get(Q)||0,C,S.get(Q)||0,F,h(P));ee&&(J={estimate:(O.get(Q)||0)/C-(S.get(Q)||0)/F,lower:ee.lower,upper:ee.upper,confidence:h(P),method:"newcombe (difference in this category's share)",category:Q})}return{test:m.CHI_SQUARE,statistic:W,statisticName:"chiSquare",df:q,pValue:N,interval:J,effectSize:{name:"categoricalTotalVariation",value:X(O,C,S,F)},nA:C,nB:F,reliable:C>=y&&F>=y,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function K(O){return O==null||O===""||typeof O=="number"&&Number.isNaN(O)?null:O instanceof Date?O.getTime():typeof O=="object"?String(O):O}function V(O,C,S){if(S===m.WELCH||S===m.MANN_WHITNEY)return{test:S,chosenBy:"override",reason:`caller override: ${S}`};const F=A(O),P=A(C),M=F===null?null:Math.exp(-F/2),x=P===null?null:Math.exp(-P/2);return M!==null&&M<t||x!==null&&x<t?{test:m.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${t})`}:{test:m.WELCH,chosenBy:"auto",reason:M!==null||x!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function E(O,C,S,F={}){if(!O||!C)return null;const P=h(F.confidence),M=D(C);let x;if(Array.isArray(F.groups)&&F.groups.length===2)x=[K(F.groups[0]),K(F.groups[1])];else{const{map:se}=L(C,S),le=[...se.entries()].sort((ye,fe)=>fe[1]-ye[1]).slice(0,2).map(ye=>ye[0]);if(le.length<2)return T("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;x=le}const[U,_]=x;if(U===null||_===null||U===_)return T("compareGroups:distinct","[lattice] compareGroups: the two groups must be two distinct, present values."),null;const W=[],q=[];for(let se=0;se<S.length;se++){const le=K(M(S[se]));le===U?W.push(S[se]):le===_&&q.push(S[se])}if(W.length===0||q.length===0)return T("compareGroups:empty","[lattice] compareGroups: one of the two groups has no rows in the current set."),null;const N=F.test&&F.test!=="auto"?String(F.test):null,Q=$(O,W.concat(q));let J,ee,ne;if(N===m.CHI_SQUARE||!N&&!Q){ee=N?"override":"auto",ne=N?"caller override: chiSquare":"column family: categorical";const se=L(O,W),le=L(O,q);J=Y(se.map,se.total,le.map,le.total,P,{category:F.category})}else{if((N===m.WELCH||N===m.MANN_WHITNEY)&&!Q)return T("compareGroups:numeric-override",`[lattice] compareGroups: ${N} needs a numeric column, but the column is not numeric.`),null;const se=Z(O,W),le=Z(O,q),ye=V(se,le,N);ee=ye.chosenBy,ne=ye.reason,J=ye.test===m.MANN_WHITNEY?v(se,le,P):l(se,le,P)}return J?{...J,chosenBy:ee,reason:ne,groups:[U,_]}:(T("compareGroups:degenerate","[lattice] compareGroups: the chosen test had too little to work with (too few values, or no variation)."),null)}}),Ue("packages/core/src/compute/significance.js",function(e,B){"use strict";Object.defineProperty(e,"COMPARE_TESTS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"compare",{enumerable:!0,get:function(){return we}});const T=B("packages/core/src/internal/warn.js").warnOnce,D=B("packages/core/src/compute/handle.js").valueReader,I=B("packages/core/src/compute/statistics.js"),Z=I.numbers,z=I.moments,L=I.frequencyMap,X=I.isNumericColumn,$=I.jarqueBera,A=I.proportionInterval,k=B("packages/core/src/compute/special.js"),y=k.studentT,f=k.studentTQuantile,g=k.normalCdf,a=k.normalQuantile,r=k.chiSquareUpperTail,i=k.incompleteBeta,c=Object.freeze({T:"t",WELCH:"welch",MANN_WHITNEY:"mannWhitney",ANOVA:"anova",KRUSKAL:"kruskal",CHI_SQUARE:"chiSquare",PROPORTIONS:"proportions"}),u=new Set([c.T,c.WELCH,c.MANN_WHITNEY]),n=new Set([c.ANOVA,c.KRUSKAL]),m=new Set([c.CHI_SQUARE,c.PROPORTIONS]),t=.05,s=[.2,.5,.8],h=[.147,.33,.474],d=[.01,.06,.14],o=[[.1,.3,.5],[.07,.21,.35],[.06,.17,.29],[.05,.15,.25]];function b(ce){const ae=Number(ce);return Number.isFinite(ae)&&ae>0&&ae<1?ae:.05}function l(ce){return ce==null||ce===""||typeof ce=="number"&&Number.isNaN(ce)?null:ce instanceof Date?ce.getTime():typeof ce=="object"?String(ce):ce}function p(ce,ae){const ge=D(ce),de=[],me=new Map;for(let ve=0;ve<ae.length;ve++){const xe=l(ge(ae[ve]));if(xe===null)continue;let Ee=me.get(xe);Ee||(Ee={value:xe,rows:[]},me.set(xe,Ee),de.push(Ee)),Ee.rows.push(ae[ve])}return de}function w(ce){const{n:ae,mean:ge,m2:de}=z(ce),me=ae>1?de/(ae-1):0;return{n:ae,mean:ge,sd:Math.sqrt(me),variance:me}}function v(ce,ae,ge){if(!(ae>0)||!(ge>0)||!(ce>=0)||!Number.isFinite(ce))return Number.NaN;if(ce===0)return 1;const de=ae*ce/(ae*ce+ge);return 1-i(ae/2,ge/2,de)}function R(ce,ae){const ge=Math.abs(ce);return Number.isFinite(ge)?ge>=ae[2]?"large":ge>=ae[1]?"medium":ge>=ae[0]?"small":"negligible":"negligible"}function Y(ce,ae,ge){if(ce==="cohensD")return R(ae,s);if(ce==="cliffsDelta")return R(ae,h);if(ce==="etaSquared")return R(ae,d);const de=Math.max(1,Math.min(o.length,Math.floor(ge||1)));return R(ae,o[de-1])}function K(ce,ae){if(!(ce.n>1)||!(ae.n>1))return null;const ge=((ce.n-1)*ce.variance+(ae.n-1)*ae.variance)/(ce.n+ae.n-2);return ge>0?(ce.mean-ae.mean)/Math.sqrt(ge):null}function V(ce,ae){const ge=ce.length,de=ae.length;if(!ge||!de)return null;const me=Array.from(ae).sort((Ee,Le)=>Ee-Le);let ve=0,xe=0;for(let Ee=0;Ee<ge;Ee++){const Le=ce[Ee];let He=0,Me=de;for(;He<Me;){const Se=He+Me>>1;me[Se]<Le?He=Se+1:Me=Se}const Ke=He;let $e=He;for(;$e<de&&me[$e]===Le;)$e++;const Oe=$e-He;ve+=Ke,xe+=de-$e}return(ve-xe)/(ge*de)}function E(ce,ae,ge,de){const me=Math.min(ge-1,de-1);return!(ae>0)||!(me>0)?null:Math.sqrt(ce/(ae*me))}function O(ce){return Number.isFinite(ce)?ce<.001?"p < 0.001":ce>=.995?"p > 0.995":`p = ${ce.toFixed(3)}`:"p = —"}function C(ce){if(!Number.isFinite(ce))return"0";const ae=Math.abs(ce);return ae===0?"0":ae>=1e3?String(Math.round(ce)):ae>=100?String(Number(ce.toFixed(0))):ae>=10?String(Number(ce.toFixed(1))):ae>=1?String(Number(ce.toFixed(2))):String(Number(ce.toPrecision(2)))}const S=new Set(["cohensD","cliffsDelta"]);function F(ce){if(ce.difference!=null&&Math.abs(ce.difference)>=1e-12)return Math.sign(ce.difference);const ae=ce.effectSize;if(ae&&S.has(ae.name)&&Number.isFinite(ae.value)&&Math.abs(ae.value)>=1e-12)return Math.sign(ae.value);const[ge,de]=ce.groups;return Number.isFinite(ge.mean)&&Number.isFinite(de.mean)&&ge.mean!==de.mean?Math.sign(ge.mean-de.mean):0}function P(ce){const ae=ce.measureName||"values";return{subject:ae.charAt(0).toUpperCase()+ae.slice(1),be:ae==="values"?"are":"is",name:ae}}function M(ce,ae){const ge=ae.unit?` ${ae.unit}`:"",{subject:de,be:me}=P(ae),ve=ce.groups[0].label,xe=ce.groups[1].label,Ee=ce.effectSize?ce.effectSize.label:"negligible",Le=ce.pValue<ce.alpha,He=Le?"unlikely to be chance":"consistent with chance";if(!Le&&Ee==="negligible")return`${de} ${me} essentially the same for ${ve} and ${xe} (${O(ce.pValue)}); the effect is ${Ee}.`;const Me=F(ce),Ke=`the difference is ${He} (${O(ce.pValue)}) and the effect is ${Ee}.`;if(Me===0)return`${de} ${me} different between ${ve} and ${xe}; ${Ke}`;const $e=Me>0?ve:xe,Oe=Me>0?xe:ve,Se=ce.difference!=null&&Math.abs(ce.difference)>=1e-12,Pe=Math.abs(ce.difference),Te=Se?typeof ae.formatValue=="function"?` by about ${ae.formatValue(Pe)}${ge}`:` by about ${C(Pe)}${ge}`:"";return`${de} ${me} higher for ${$e} than for ${Oe}${Te}; ${Ke}`}function x(ce,ae){const{name:ge}=P(ae),de=ce.effectSize?ce.effectSize.label:"negligible",me=O(ce.pValue);return ce.pValue<ce.alpha?`The groups differ in ${ge}; the difference is unlikely to be chance (${me}) and the effect is ${de}.`:de==="negligible"?`The groups are essentially the same in ${ge} (${me}); the effect is ${de}.`:`The groups show a ${de} effect in ${ge}, but the difference is consistent with chance (${me}).`}function U(ce,ae){const ge=ce.length;if(ge<2)return null;const{mean:de,m2:me}=z(ce),ve=me/(ge-1);if(!(ve>0))return null;const xe=Math.sqrt(ve),Ee=xe/Math.sqrt(ge),Le=de/Ee,He=ge-1,Me=Math.min(1,Math.max(0,2*(1-y(Math.abs(Le),He)))),Ke=f(1-ae/2,He)*Ee,$e=de/xe;return{test:c.T,statistic:Le,statisticName:"t",df:He,pValue:Me,difference:de,interval:{estimate:de,lower:de-Ke,upper:de+Ke,confidence:1-ae,method:"paired-t (mean of the pair differences)"},effectSize:{name:"cohensD",label:R($e,s),value:$e}}}function _(ce,ae){const ge=Array.from(ce).filter(Pe=>Pe!==0),de=ge.length;if(!de)return null;const me=Array.from({length:de},(Pe,Te)=>Te).sort((Pe,Te)=>Math.abs(ge[Pe])-Math.abs(ge[Te])),ve=new Array(de);let xe=0;for(;xe<de;){let Pe=xe;for(;Pe+1<de&&Math.abs(ge[me[Pe+1]])===Math.abs(ge[me[xe]]);)Pe++;const Te=(xe+Pe)/2+1;for(let Be=xe;Be<=Pe;Be++)ve[me[Be]]=Te;xe=Pe+1}let Ee=0,Le=0;for(let Pe=0;Pe<de;Pe++)Le+=ve[Pe],ge[Pe]>0&&(Ee+=ve[Pe]);const He=Le-Ee,Me=de*(de+1)/4,Ke=Math.sqrt(de*(de+1)*(2*de+1)/24),$e=Ke>0?(Math.abs(Ee-Me)-.5)/Ke:0,Oe=Math.min(1,Math.max(0,2*g(-Math.max(0,$e)))),Se=Le>0?(Ee-He)/Le:0;return{test:c.MANN_WHITNEY,statistic:Ee,statisticName:"W",df:null,pValue:Oe,difference:null,interval:null,effectSize:{name:"cliffsDelta",label:R(Se,h),value:Se}}}function W(ce,ae,ge){const de=w(ce),me=w(ae);if(de.n<2||me.n<2)return null;const ve=((de.n-1)*de.variance+(me.n-1)*me.variance)/(de.n+me.n-2);if(!(ve>0))return null;const xe=Math.sqrt(ve*(1/de.n+1/me.n)),Ee=(de.mean-me.mean)/xe,Le=de.n+me.n-2,He=Math.min(1,Math.max(0,2*(1-y(Math.abs(Ee),Le)))),Me=de.mean-me.mean,Ke=f(1-ge/2,Le)*xe,$e=K(de,me);return{test:c.T,statistic:Ee,statisticName:"t",df:Le,pValue:He,difference:Me,interval:{estimate:Me,lower:Me-Ke,upper:Me+Ke,confidence:1-ge,method:"student-t (pooled variance, difference of means)"},effectSize:{name:"cohensD",label:R($e,s),value:$e},summaries:[de,me]}}function q(ce,ae,ge){const de=w(ce),me=w(ae);if(de.n<2||me.n<2)return null;const ve=de.variance/de.n+me.variance/me.n;if(!(ve>0))return null;const xe=Math.sqrt(ve),Ee=(de.mean-me.mean)/xe,Le=de.variance/de.n*(de.variance/de.n)/(de.n-1),He=me.variance/me.n*(me.variance/me.n)/(me.n-1),Me=ve*ve/(Le+He),Ke=Math.min(1,Math.max(0,2*(1-y(Math.abs(Ee),Me)))),$e=de.mean-me.mean,Oe=f(1-ge/2,Me)*xe,Se=K(de,me);return{test:c.WELCH,statistic:Ee,statisticName:"t",df:Me,pValue:Ke,difference:$e,interval:{estimate:$e,lower:$e-Oe,upper:$e+Oe,confidence:1-ge,method:"welch-t (unequal variances, difference of means)"},effectSize:{name:"cohensD",label:R(Se,s),value:Se},summaries:[de,me]}}function N(ce,ae,ge){const de=ce.length,me=ae.length;if(de<1||me<1)return null;const ve=w(ce),xe=w(ae),Ee=de+me,Le=new Array(Ee);for(let Be=0;Be<de;Be++)Le[Be]={v:ce[Be],g:0};for(let Be=0;Be<me;Be++)Le[de+Be]={v:ae[Be],g:1};Le.sort((Be,Ge)=>Be.v-Ge.v);let He=0,Me=0,Ke=0;for(;Ke<Ee;){let Be=Ke;for(;Be<Ee&&Le[Be].v===Le[Ke].v;)Be++;const Ge=(Ke+1+Be)/2;for(let Je=Ke;Je<Be;Je++)Le[Je].g===0&&(He+=Ge);const et=Be-Ke;Me+=et*et*et-et,Ke=Be}const $e=He-de*(de+1)/2,Oe=de*me/2,Se=de*me/12*(Ee+1-Me/(Ee*(Ee-1)));let Pe=1;if(Se>0){const Be=Math.max(0,Math.abs($e-Oe)-.5);Pe=Math.min(1,2*g(-Be/Math.sqrt(Se)))}const Te=V(ce,ae);return{test:c.MANN_WHITNEY,statistic:$e,statisticName:"U",df:null,pValue:Pe,difference:null,interval:Q(ce,ae,1-ge),effectSize:{name:"cliffsDelta",label:R(Te,h),value:Te},summaries:[ve,xe]}}function Q(ce,ae,ge){const de=ce.length,me=ae.length,ve=de*me;if(ve===0||ve>2e6)return null;const xe=new Float64Array(ve);let Ee=0;for(let Se=0;Se<de;Se++)for(let Pe=0;Pe<me;Pe++)xe[Ee++]=ce[Se]-ae[Pe];xe.sort();const Le=ve>>1,He=ve%2?xe[Le]:(xe[Le-1]+xe[Le])/2,Me=Math.sqrt(de*me*(de+me+1)/12),Ke=a(1-(1-ge)/2);let $e=Math.round(ve/2-Ke*Me);$e>=0||($e=0);const Oe=Math.floor((ve-1)/2);return $e>Oe&&($e=Oe),{estimate:He,lower:xe[$e],upper:xe[ve-1-$e],confidence:ge,method:"hodges-lehmann (location shift)"}}function J(ce,ae){const ge=ce.length,de=ce.map(w);if(de.some(Pe=>Pe.n<2))return null;const me=de.reduce((Pe,Te)=>Pe+Te.n,0),ve=de.reduce((Pe,Te)=>Pe+Te.mean*Te.n,0)/me;let xe=0,Ee=0;for(let Pe=0;Pe<ge;Pe++)xe+=de[Pe].n*(de[Pe].mean-ve)**2,Ee+=(de[Pe].n-1)*de[Pe].variance;const Le=ge-1,He=me-ge;if(!(Ee>0)||He<1)return null;const Me=xe/Le,Ke=Ee/He,$e=Me/Ke,Oe=Math.min(1,Math.max(0,v($e,Le,He))),Se=xe/(xe+Ee);return{test:c.ANOVA,statistic:$e,statisticName:"F",df:{between:Le,within:He},pValue:Oe,difference:null,interval:null,effectSize:{name:"etaSquared",label:R(Se,d),value:Se},summaries:de}}function ee(ce,ae){const ge=ce.length,de=ce.map(w);if(ge<2)return null;const me=de.reduce((Te,Be)=>Te+Be.n,0),ve=[];for(let Te=0;Te<ge;Te++)for(let Be=0;Be<ce[Te].length;Be++)ve.push({v:ce[Te][Be],g:Te});ve.sort((Te,Be)=>Te.v-Be.v);const xe=new Array(ve.length);let Ee=0,Le=0;for(;Le<ve.length;){let Te=Le;for(;Te<ve.length&&ve[Te].v===ve[Le].v;)Te++;const Be=(Le+1+Te)/2;for(let et=Le;et<Te;et++)xe[et]=Be;const Ge=Te-Le;Ee+=Ge*Ge*Ge-Ge,Le=Te}const He=new Array(ge).fill(0);for(let Te=0;Te<ve.length;Te++)He[ve[Te].g]+=xe[Te];let Me=0;for(let Te=0;Te<ge;Te++)Me+=He[Te]*He[Te]/de[Te].n;Me=12/(me*(me+1))*Me-3*(me+1);const Ke=1-Ee/(me*me*me-me),$e=Ke>0?Me/Ke:Me,Oe=ge-1,Se=Math.min(1,Math.max(0,r($e,Oe))),Pe=($e-ge+1)/(me-ge);return{test:c.KRUSKAL,statistic:$e,statisticName:"H",df:Oe,pValue:Se,difference:null,interval:null,effectSize:{name:"etaSquared",label:R(Pe,d),value:Math.max(0,Pe)},summaries:de}}function ne(ce,ae,ge,de,me){const ve=A(ce,ae,me),xe=A(ge,de,me);if(!ve||!xe)return null;const Ee=ve.proportion-xe.proportion,Le=Ee-Math.sqrt((ve.proportion-ve.lower)**2+(xe.upper-xe.proportion)**2),He=Ee+Math.sqrt((ve.upper-ve.proportion)**2+(xe.proportion-xe.lower)**2);return{estimate:Ee,lower:Le,upper:He}}function se(ce,ae,ge,de){const me=D(ae),ve=new Set,xe=[];for(const Be of ce){const Ge=new Map;let et=0;for(const Je of Be.rows){const ft=l(me(Je));ft!==null&&(Ge.set(ft,(Ge.get(ft)||0)+1),et++,ve.add(ft))}xe.push(Ge),Be.total=et}const Ee=[...ve];if(Ee.length<2)return null;const Le=ce.reduce((Be,Ge)=>Be+Ge.total,0);if(!(Le>0))return null;let He=0;for(const Be of ce)for(const Ge of Ee){const et=xe[ce.indexOf(Be)].get(Ge)||0,Je=ce.reduce((Et,Mt)=>Et+(xe[ce.indexOf(Mt)].get(Ge)||0),0),ft=Be.total*Je/Le;ft>0&&(He+=(et-ft)*(et-ft)/ft)}const Me=ce.length,Ke=Ee.length,$e=(Me-1)*(Ke-1),Oe=Math.min(1,Math.max(0,r(He,$e))),Se=E(He,Le,Me,Ke);let Pe=null;if(Me===2&&Ke===2){const[Be]=Ee,Ge=xe[0].get(Be)||0,et=xe[1].get(Be)||0,Je=ne(Ge,ce[0].total,et,ce[1].total,de);Je&&(Pe={...Je,confidence:de,method:"newcombe (difference in this category's share)",category:Be})}const Te=ce.map((Be,Ge)=>{const et={};for(const Je of Ee)et[String(Je)]=(xe[Ge].get(Je)||0)/Be.total;return et});return{test:c.CHI_SQUARE,statistic:He,statisticName:"chiSquare",df:$e,pValue:Oe,difference:null,interval:Pe,effectSize:{name:"cramersV",label:Y("cramersV",Se,Math.min(Me-1,Ke-1)),value:Se},proportions:Te}}function le(ce,ae,ge,de){const me=D(ae),ve=new Set;for(const Je of ce)for(const ft of Je.rows){const Et=l(me(ft));Et!==null&&ve.add(Et)}if(ve.size!==2)return null;const[xe]=[...ve],Ee=ce[0].rows.reduce((Je,ft)=>Je+(l(me(ft))===xe?1:0),0),Le=ce[1].rows.reduce((Je,ft)=>Je+(l(me(ft))===xe?1:0),0),He=ce[0].rows.length,Me=ce[1].rows.length;if(!(He>0)||!(Me>0))return null;const Ke=Ee/He,$e=Le/Me,Oe=(Ee+Le)/(He+Me);if(!(Oe>0)||!(Oe<1))return null;const Se=Math.sqrt(Oe*(1-Oe)*(1/He+1/Me)),Pe=(Ke-$e)/Se,Te=Math.min(1,Math.max(0,2*g(-Math.abs(Pe)))),Be=Ke-$e,Ge=ne(Ee,He,Le,Me,de),et=E(Pe*Pe,He+Me,2,2);return{test:c.PROPORTIONS,statistic:Pe,statisticName:"z",df:null,pValue:Te,difference:Be,interval:Ge?{...Ge,confidence:de,method:"newcombe (difference in proportions)",category:xe}:null,effectSize:{name:"cramersV",label:Y("cramersV",et,1),value:et},proportions:[{[String(xe)]:Ke},{[String(xe)]:$e}],focalCategory:xe}}function ye(ce,ae,ge,de){if(ge&&u.has(ge))return{test:ge,reason:`caller override: ${ge}`};const me=$(ce),ve=$(ae),xe=me===null?null:Math.exp(-me/2),Ee=ve===null?null:Math.exp(-ve/2);if(xe!==null&&xe<t||Ee!==null&&Ee<t)return{test:c.MANN_WHITNEY,reason:"two numeric groups, non-normal by Jarque-Bera"};const Le=w(ce),He=w(ae);if(Le.n>=3&&He.n>=3&&Le.variance>0&&He.variance>0){const Me=Math.max(Le.variance,He.variance)/Math.min(Le.variance,He.variance),Ke=Le.variance>=He.variance?Le.n-1:He.n-1,$e=Le.variance>=He.variance?He.n-1:Le.n-1;if(2*Math.min(v(Me,Ke,$e),1-v(Me,Ke,$e))<de)return{test:c.WELCH,reason:"two numeric groups, unequal variances (F-test)"}}return{test:c.T,reason:xe!==null||Ee!==null?"two numeric groups, equal variances and no departure from normality":"two numeric groups (too few rows to screen normality)"}}function fe(ce,ae){if(ae&&n.has(ae))return{test:ae,reason:`caller override: ${ae}`};for(const ge of ce){const de=$(ge),me=de===null?null:Math.exp(-de/2);if(me!==null&&me<t)return{test:c.KRUSKAL,reason:"three or more numeric groups, non-normal by Jarque-Bera"}}return{test:c.ANOVA,reason:"three or more numeric groups, no departure from normality detected"}}function we(ce,ae,ge,de={},me=null){if(!ce||!ae)return null;const ve=b(de.alpha),xe=1-ve,Ee=de.test&&de.test!=="auto"?String(de.test):null,Le=p(ae,ge);if(Le.length<2)return T("compare:groups",'[lattice] statistics.compare: the "by" column has fewer than two distinct values to group by.'),null;let He;if(Array.isArray(de.groups)&&de.groups.length===2){const Ge=[l(de.groups[0]),l(de.groups[1])];if(Ge[0]===null||Ge[1]===null||Ge[0]===Ge[1])return T("compare:distinct","[lattice] statistics.compare: the two groups must be two distinct, present values."),null;if(He=Le.filter(et=>et.value===Ge[0]||et.value===Ge[1]),He.length!==2)return T("compare:empty","[lattice] statistics.compare: one of the two groups has no rows in the current set."),null;He.sort((et,Je)=>et.value===Ge[0]?-1:1)}else Le.length===2||Ee&&u.has(Ee)||Ee&&m.has(Ee)?He=Le.slice(0,2):(Ee&&n.has(Ee),He=Le);const Ke=X(ce,ge),$e=!!de.paired&&me&&He.length===2&&Ke;let Oe,Se,Pe;if(Ke)if(He.length===2&&!(Ee&&n.has(Ee))){const Ge=Z(ce,He[0].rows),et=Z(ce,He[1].rows);if(Ge.length<3||et.length<3)return T("compare:small","[lattice] statistics.compare: each group needs at least three readings to compare."),null;if(w(Ge).variance===0||w(et).variance===0)return T("compare:zero-variance","[lattice] statistics.compare: a group has zero variance, so the difference has no scale to test."),null;if($e){const ft=Ce(ce,me,He[0].rows,He[1].rows);return ft?(Se=Ee?"override":"auto",Pe=Ee?`caller override: ${Ee} (paired)`:"two numeric groups, paired",Oe=Ee===c.MANN_WHITNEY?_(ft.diffs,ve):U(ft.diffs,ve),Oe?(Oe.paired=!0,Oe.chosenBy=Se,Oe.reason=Pe,Oe.groups=[{value:He[0].value,label:String(He[0].value),n:ft.n},{value:He[1].value,label:String(He[1].value),n:ft.n}],Oe.alpha=ve,Oe.method=Oe.test===c.MANN_WHITNEY?"Wilcoxon signed-rank test (paired)":"Student's paired t-test (difference of pairs)",Oe.verdict=M(Oe,de),Oe.categorical=!1,Oe):(T("compare:degenerate","[lattice] statistics.compare: the paired test had too little to work with."),null)):(T("compare:paired","[lattice] statistics.compare: not enough matched pairs to run a paired test."),null)}const Je=ye(Ge,et,Ee,ve);Se=Ee?"override":"auto",Pe=Je.reason,Je.test===c.MANN_WHITNEY?Oe=N(Ge,et,ve):Je.test===c.WELCH?Oe=q(Ge,et,ve):Oe=W(Ge,et,ve),Oe&&Oe.interval&&Oe.difference===null&&(Oe.difference=Oe.interval.estimate)}else{const Ge=He.map(Je=>Z(ce,Je.rows));if(Ge.some(Je=>Je.length<3))return T("compare:small","[lattice] statistics.compare: each group needs at least three readings to compare."),null;const et=fe(Ge,Ee);Se=Ee?"override":"auto",Pe=et.reason,Oe=et.test===c.KRUSKAL?ee(Ge,ve):J(Ge,ve)}else if(He.length===2){const Ge=ke(ce,He).size===2;if(Ee===c.PROPORTIONS||Ge&&!Ee)Se=Ee?"override":"auto",Pe=Ee?"caller override: proportions":"categorical measure with two categories (binary)",Oe=le(He,ce,ve,xe);else if(Ee===c.CHI_SQUARE||!Ge&&!Ee)Se=Ee?"override":"auto",Pe=Ee?"caller override: chiSquare":`categorical measure with ${ke(ce,He).size} categories`,Oe=se(He,ce,ve,xe);else return T("compare:numeric-needed",`[lattice] statistics.compare: ${Ee} needs a numeric measure, but the column is categorical.`),null}else Se=Ee?"override":"auto",Pe=Ee?`caller override: ${Ee}`:`categorical measure with ${ke(ce,He).size} categories`,Oe=se(He,ce,ve,xe);if(!Oe)return T("compare:degenerate","[lattice] statistics.compare: the chosen test had too little to work with (too few values, or no variation)."),null;const Te=Oe.summaries,Be=Oe.proportions;return{test:Oe.test,chosenBy:Se,reason:Pe,statistic:Oe.statistic,statisticName:Oe.statisticName,df:Oe.df===void 0?null:Oe.df,pValue:Oe.pValue,alpha:ve,paired:!1,interval:Oe.interval||null,effectSize:Oe.effectSize,groups:He.map((Ge,et)=>({value:Ge.value,label:String(Ge.value),n:Te?Te[et].n:Ge.total,...Te?{mean:Te[et].mean,sd:Te[et].sd}:{},...Be?{proportions:Be[et]}:{}})),difference:Oe.difference===void 0?null:Oe.difference,method:Oe.test,categorical:!Ke,verdict:He.length===2?M({...Oe,alpha:ve,groups:[{value:He[0].value,label:String(He[0].value),mean:Te?Te[0].mean:void 0},{value:He[1].value,label:String(He[1].value),mean:Te?Te[1].mean:void 0}],categorical:!Ke,difference:Oe.difference===void 0?null:Oe.difference},de):x({...Oe,alpha:ve},de)}}function ke(ce,ae){const ge=D(ce),de=new Set;for(const me of ae)for(const ve of me.rows){const xe=l(ge(ve));xe!==null&&de.add(xe)}return de}function Ce(ce,ae,ge,de){const me=D(ae),ve=D(ce),xe=new Map;for(const Le of de){const He=l(me(Le));He!==null&&xe.set(He,ve(Le))}const Ee=[];for(const Le of ge){const He=l(me(Le));if(He===null||!xe.has(He))continue;const Me=Number(ve(Le)),Ke=Number(xe.get(He));!Number.isFinite(Me)||!Number.isFinite(Ke)||Ee.push(Me-Ke)}return Ee.length<2?null:{diffs:Float64Array.from(Ee),n:Ee.length}}}),Ue("packages/core/src/columns/detailcolumn.js",function(e,B){"use strict";Object.defineProperty(e,"DETAIL_COLUMN_ID",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"createDetailColumn",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return D}});const re="__lattice_detail",T=36;function G(I){const Z=I.config&&I.config.detailColumnWidth||T;return{id:re,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:I.config&&I.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(z,L){return!!(L&&L.expanded)},formatValue(){return""}}}const D=G}),Ue("packages/core/src/columns/treecolumn.js",function(e,B){"use strict";Object.defineProperty(e,"TREE_COLUMN_ID",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"createTreeColumn",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const T=B("packages/core/src/internal/predicates.js").isFunction,G="__lattice_tree",D=260;function I(z){const L=z.tree||{},X=z.config&&z.config.treeColumnWidth||D,$=!!(z.config&&z.config.treeColumnFlex),A=()=>(z.columns&&T(z.columns.visible)?z.columns.visible():[]).find(g=>!g.generated)||null,k=(f,g)=>{if(g&&g.group)return g.groupValue;if(T(L.label))return L.label(f,g);if(typeof L.label=="string")return f==null?null:f[L.label];const a=A();return a&&T(a.getValue)?a.getValue(f,g):null},y=()=>{if(L.title)return L.title;const f=typeof L.label=="string"?z.columns&&T(z.columns.get)?z.columns.get(L.label):null:A();return f&&(f.title||f.id)||"Hierarchy"};return{id:G,get title(){return y()},field:null,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group",props:{icon:L.icon,iconClass:L.iconClass,content:L.content,checkbox:L.checkbox,onCheck:L.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:$?{flex:1,min:0,pin:z.config&&z.config.treeColumnPin||null,hidden:!1,resizable:!1,movable:!1,lockPosition:!0}:{width:X,min:140,pin:z.config&&z.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(f,g){return k(f,g)},formatValue(f,g){if(g&&g.grandTotal)return z.config&&z.config.grandTotalLabel||"Total";if(f==null)return"";if(!L.label){const a=A();if(a&&T(a.formatValue))return a.formatValue(f,g)}return String(f)}}}const Z=I}),Ue("packages/core/src/columns/pivotcolumns.js",function(e,B){"use strict";Object.defineProperty(e,"PIVOT_PREFIX",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"createPivotColumns",{enumerable:!0,get:function(){return I}});const T=B("packages/core/src/internal/warn.js").warnOnce,G="__lattice_pivot",D=500;function I(X){const{pivot:$,valueColumns:A,config:k}=X,y=$&&$.paths||[],f=X.separator||k&&k.pivot&&k.pivot.separator||" | ",g=k&&k.pivot&&k.pivot.maxColumns||D;if(!y.length||!A.length)return{tree:[],leaves:[],error:null};const a=Z(k),r=y.length*A.length+(a?A.length:0);if(r>g){const u=`pivot would generate ${r} columns, above the limit of ${g}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return T(`pivot.maxColumns:${r}`,u),{tree:[],leaves:[],error:u}}const i=[],c=[];for(const u of y){const n=[];for(const m of A){const t=L(u,m,f);n.push(t),c.push(t)}n.length===1?(n[0].title=String(u),i.push(n[0])):i.push({id:`${G}:group:${u}`,title:String(u),columns:n,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(a){const u=A.map(m=>z(m,k));c.push(...u);const n=k&&k.pivot&&k.pivot.totalsLabel||"Total";if(u.length===1)u[0].title=n,a==="before"?i.unshift(u[0]):i.push(u[0]);else{const m={id:`${G}:group:__totals`,title:n,columns:u,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};a==="before"?i.unshift(m):i.push(m)}}return{tree:i,leaves:c,error:null}}function Z(X){const $=X&&X.pivot&&X.pivot.groupTotals;return $==="before"||$==="after"?$:null}function z(X,$){return{id:`${G}:__total${$&&$.pivot&&$.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(A,k){const y=k&&k.totals;return y&&Object.hasOwn(y,X.id)?y[X.id]:null},formatValue(A,k){return A==null?"":X.formatValue?X.formatValue(A,k):String(A)}}}function L(X,$,A){return{id:`${G}:${X}${A}${$.id}`,field:null,title:$.title||$.id,type:$.type,dataType:$.dataType,nullable:!0,align:$.align,generated:!0,pivot:{enabled:!1,index:0,path:X,sourceId:$.id},value:{pure:!0},cell:{align:$.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:$.total,lookup:null,layout:{width:$.layout&&$.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,y){return k==null?"":$.formatValue?$.formatValue(k,y):String(k)}}}}),Ue("packages/core/src/compute/group.js",function(e,B){"use strict";Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return k}});const re=B("packages/core/src/compute/handle.js"),T=re.dictSize,G=re.identity,D=re.presenceReader,I=re.rowCount,Z=re.valueReader,z="",L="\0",X=1<<20;function $(y,f,g,a){const r=y.length,i=y.map(s=>Z(s)),c=Array.isArray(a)&&a.some(Boolean),u=c?i.map((s,h)=>a[h]?d=>a[h](s(d)):s):i;if(!c&&r>0&&y.every(s=>s&&s.kind==="dictionary"&&s.dict)){const s=y.map(d=>T(d.dict)+1);let h=1;for(let d=0;d<r;d++)h*=s[d];if(h<=Number.MAX_SAFE_INTEGER){const d=y.map(p=>p.values),o=y.map(p=>D(p)),b=p=>{let w=0;for(let v=0;v<r;v++){const R=o[v],Y=R&&R(p)===0?s[v]-1:d[v][p];w=w*s[v]+Y}return w},l=new Float64Array(g);for(let p=0;p<g;p++)l[p]=b(f[p]);return{packed:l,strings:null,product:h,readers:u,keyOf:b}}}const m=s=>{let h="";for(let d=0;d<r;d++){const o=u[d](s);h+=(d===0?"":z)+(o==null?L:String(o))}return h},t=new Array(g);for(let s=0;s<g;s++)t[s]=m(f[s]);return{packed:null,strings:t,product:1/0,readers:u,keyOf:m}}function A(y,f,g,a){const r=new Uint32Array(a+1);for(let n=0;n<g;n++)r[f[n]+1]++;for(let n=0;n<a;n++)r[n+1]+=r[n];const i=new Uint32Array(g),c=r.slice(0,a);for(let n=0;n<g;n++)i[c[f[n]]++]=y[n];const u=new Array(a);for(let n=0;n<a;n++)u[n]=i.subarray(r[n],r[n+1]);return u}function k(y,f,g={}){const a=y||[],r=f||G(I(a[0],g)),i=r.length;if(a.length===0||i===0)return{keys:[],buckets:[]};const{packed:c,strings:u,product:n,readers:m}=$(a,r,i,g.project),t=new Uint32Array(i);let s=0,h=null;if(c&&n<=Math.max(1024,Math.min(X,i*4))){const l=n,p=new Int32Array(l).fill(-1);for(let w=0;w<i;w++)p[c[w]]=0;for(let w=0;w<l;w++)p[w]===0&&(p[w]=s++);for(let w=0;w<i;w++)t[w]=p[c[w]];h=new Float64Array(s);for(let w=0;w<l;w++)p[w]>=0&&(h[p[w]]=w)}else if(c){const l=new Map;for(let p=0;p<i;p++){const w=c[p];let v=l.get(w);v===void 0&&(v=s++,l.set(w,v)),t[p]=v}h=new Float64Array(s);for(const[p,w]of l)h[w]=p}else{const l=new Map;for(let p=0;p<i;p++){const w=u[p];let v=l.get(w);v===void 0&&(v=s++,l.set(w,v)),t[p]=v}}const d=A(r,t,i,s),o=new Array(s);for(let l=0;l<s;l++){const p=d[l][0],w=new Array(m.length);for(let v=0;v<m.length;v++)w[v]=m[v](p);o[l]=w}const b={keys:o,buckets:d};return h&&(b.packed=h),b}}),Ue("packages/core/src/compute/pivot.js",function(e,B){"use strict";Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return i}});const T=B("packages/core/src/internal/warn.js").warnOnce,D=B("packages/core/src/compute/handle.js").valueComparator,Z=B("packages/core/src/compute/group.js").packKeys,L=B("packages/core/src/compute/total.js").total,X="|",$="/",A=2e3;function k(n,m,t){return`${n}${X}${m}${X}${t}`}function y(n,m){let t="";for(let s=0;s<n.length;s++){const h=n[s];t+=(s===0?"":m)+(h==null?"":String(h))}return t}function f(n,m,t={}){const s=t.separator||$,h=m.length,{keyOf:d,readers:o}=Z(n,m,0),b=new Map,l=[],p=[];for(let E=0;E<h;E++){const O=m[E],C=d(O);if(b.has(C))continue;b.set(C,l.length),p.push(C);const S=new Array(o.length);for(let F=0;F<o.length;F++)S[F]=o[F](O);l.push(S)}const w=D(t.locale),v=l.map((E,O)=>O);v.sort((E,O)=>{const C=l[E],S=l[O];for(let F=0;F<C.length;F++){const P=g(C[F],S[F],w);if(P!==0)return P}return E-O});const R=new Array(v.length),Y=new Array(v.length),K=new Map;for(let E=0;E<v.length;E++){const O=v[E];R[E]=l[O],Y[E]=y(l[O],s),K.set(p[O],E)}return{keys:R,paths:Y,idOf:E=>{const O=K.get(d(E));return O===void 0?-1:O}}}function g(n,m,t){const s=n==null,h=m==null;return s||h?s&&h?0:s?1:-1:t(n,m)}function a(n){const m=n.values||n.totals||[];if(m.length&&typeof m[0]=="object"&&m[0]!==null)return m.filter(d=>d&&d.handle);const t=typeof n.handle=="function"?n.handle:null;if(!t)return m.length&&T("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 s=typeof n.totalOf=="function"?n.totalOf:null,h=[];for(const d of m){const o=t(d);o&&h.push({colId:d,handle:o,fn:s?s(d):"sum"})}return h}function r(n,m,t){if(Array.isArray(n)){const s=t||{};return{...s,pivotHandles:n,order:m||null,groups:s.groups||null}}return n||{}}function i(n,m,t){const s=r(n,m,t),h=s.separator||$,d=a(s),o=s.maxColumns===void 0?A:s.maxColumns,b=s.groups&&s.groups.buckets?s.groups:null,l=b?b.buckets:[s.order||new Uint32Array(0)],p=s.groupPaths||(b?b.keys.map(C=>y(C,h)):[""]),w=u(l),{keys:v,paths:R,idOf:Y}=f(s.pivotHandles||[],w,s),K=R.length*Math.max(1,d.length),V=c(R,d,h);if(o&&K>o){const C=new Map;return{keys:v,paths:R,fields:V,groupPaths:p,columns:K,values:C,cells:C,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${K} columns, above pivot.maxColumns of ${o}. Narrow the pivot columns or raise the limit.`,columns:K,maxColumns:o}}}const E=new Map,O=R.length;for(let C=0;C<l.length;C++){const S=l[C],F=p[C]===void 0?"":p[C],P=S.length;if(P===0)continue;const M=new Int32Array(P),x=new Uint32Array(O+1);for(let W=0;W<P;W++){const q=Y(S[W]);M[W]=q,q>=0&&x[q+1]++}for(let W=0;W<O;W++)x[W+1]+=x[W];const U=new Uint32Array(P),_=x.slice(0,O);for(let W=0;W<P;W++){const q=M[W];q>=0&&(U[_[q]++]=S[W])}for(let W=0;W<O;W++){const q=x[W],N=x[W+1];if(N===q)continue;const Q=U.subarray(q,N);for(let J=0;J<d.length;J++){const ee=d[J],ne=L(ee.handle,Q,ee.fn,s.totalContext||{locale:s.locale});E.set(k(F,R[W],ee.colId),ne)}}}return{keys:v,paths:R,fields:V,groupPaths:p,columns:K,values:E,cells:E,error:null}}function c(n,m,t){if(m.length===0)return n.slice();const s=[];for(const h of n)for(const d of m)s.push(`${h}${t}${d.colId}`);return s}function u(n){if(n.length===1)return n[0]||new Uint32Array(0);let m=0;for(const h of n)m+=h?h.length:0;const t=new Uint32Array(m);let s=0;for(const h of n)!h||h.length===0||(t.set(h,s),s+=h.length);return t}}),Ue("packages/core/src/compute/explain.js",function(e,B){"use strict";Object.defineProperty(e,"explainContributors",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"explainChange",{enumerable:!0,get:function(){return k}});const T=B("packages/core/src/compute/total.js").total,D=B("packages/core/src/compute/group.js").groupByColumns,I=new Set(["sum","count","countValues"]),Z=new Set(["min","max"]),z=new Set(["avg"]);function L(y){return typeof y=="string"?y:typeof y=="function"&&y.totalName?y.totalName:null}function X(y,f,g,a){return T(y,f,g,a||{})}function $(y,f){if(f)try{return f(y)}catch{}return y==null?"":String(y)}function A(y){const{handle:f,fn:g,leaves:a,by:r,labelOf:i,rowLabel:c}=y,u={locale:y.locale},n=a&&a.length?a:[],m=L(g),t=X(f,n,g,u),s=Z.has(m);let h;if(s){let b=-1;for(let l=0;l<n.length;l++){const p=X(f,[n[l]],g,u);if(Object.is(p,t)){b=n[l];break}}h=b<0?[]:[{key:b,indices:[b],label:c?c(b):String(b)}]}else if(r){const b=D([r],n);h=b.keys.map((l,p)=>({key:l[0],indices:b.buckets[p],label:$(l[0],i)}))}else h=Array.from({length:n.length},(b,l)=>{const p=n[l];return{key:p,indices:[p],label:c?c(p):String(p)}});const d=n.length,o=[];for(const b of h){const l=X(f,b.indices,g,u),p=b.indices.length;let w,v;if(m==="avg")w=((typeof l=="number"?l:0)-(typeof t=="number"?t:0))*p,v=d?p/d:0;else if(s)w=typeof l=="number"?l:0,v=1;else{w=typeof l=="number"?l:0;const R=typeof t=="number"?t:0;v=R?w/R:0}o.push({key:b.key,label:b.label,count:p,value:l,contribution:w,share:v})}return o.sort((b,l)=>Math.abs(l.contribution)-Math.abs(b.contribution)||(b.label<l.label?-1:b.label>l.label?1:0)),{total:t,fn:m,weighted:z.has(m),single:s,contributors:o}}function k(y){const f=A({...y,leaves:y.after}),g=A({...y,leaves:y.before}),a=typeof f.total=="number"?f.total:0,r=typeof g.total=="number"?g.total:0,i=new Map;for(const n of f.contributors)i.set(n.key,n);const c=[],u=new Set;for(const n of g.contributors){u.add(n.key);const m=i.get(n.key);if(m===void 0)c.push({key:n.key,label:n.label,before:n.value,after:null,effect:-n.contribution,kind:"dropped",count:n.count});else{const t=m.contribution-n.contribution;t!==0&&c.push({key:n.key,label:n.label,before:n.value,after:m.value,effect:t,kind:"changed",count:m.count})}}for(const n of f.contributors)u.has(n.key)||c.push({key:n.key,label:n.label,before:null,after:n.value,effect:n.contribution,kind:"new",count:n.count});return c.sort((n,m)=>Math.abs(m.effect)-Math.abs(n.effect)||(n.label<m.label?-1:n.label>m.label?1:0)),{before:g.total,after:f.total,delta:a-r,weighted:f.weighted||g.weighted,single:f.single||g.single,drivers:c}}}),Ue("packages/core/src/store/bitset.js",function(e,B){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return T}});const re=8;class T{static#e=new Uint8Array(256);static{for(let D=1;D<256;D++)T.#e[D]=T.#e[D>>1]+(D&1)}#t;#n;constructor(D=0){const I=Math.max(0,D|0);this.#n=I,this.#t=new Uint8Array(Math.ceil(I/re))}get size(){return this.#n}get words(){return this.#t}get bytes(){return this.#t?this.#t.byteLength:0}get(D){return D<0||D>=this.#n?0:this.#t[D>>3]>>(D&7)&1}set(D){return D>=0&&D<this.#n&&(this.#t[D>>3]|=1<<(D&7)),this}clear(D){return D>=0&&D<this.#n&&(this.#t[D>>3]&=~(1<<(D&7))),this}assign(D,I){return I?this.set(D):this.clear(D)}fill(D=!1){return this.#t.fill(D?255:0),D&&this.#r(),this}grow(D){const I=Math.max(0,D|0);if(I<=this.#n)return this;const Z=Math.ceil(I/re);if(Z>this.#t.length){const z=new Uint8Array(Z);z.set(this.#t),this.#t=z}return this.#n=I,this}count(){const D=this.#t,I=T.#e;let Z=0;for(let z=0;z<D.length;z++)Z+=I[D[z]];return Z}and(D){const I=D instanceof T?D.words:D,Z=this.#t,z=Math.min(Z.length,I.length);for(let L=0;L<z;L++)Z[L]&=I[L];for(let L=z;L<Z.length;L++)Z[L]=0;return this}or(D){const I=D instanceof T?D.words:D,Z=this.#t,z=Math.min(Z.length,I.length);for(let L=0;L<z;L++)Z[L]|=I[L];return this}not(){const D=this.#t;for(let I=0;I<D.length;I++)D[I]=~D[I]&255;return this.#r(),this}clone(){const D=new T(this.#n);return D.words.set(this.#t.subarray(0,D.words.length)),D}release(){this.#t=new Uint8Array(0),this.#n=0}#r(){const D=this.#n&7;if(D===0)return;const I=this.#n>>3;I<this.#t.length&&(this.#t[I]&=(1<<D)-1)}static from(D){const I=Array.isArray(D)?D:Array.from(D),Z=new T(I.length);for(let z=0;z<I.length;z++)I[z]&&Z.set(z);return Z}}}),Ue("packages/core/src/store/dictionary.js",function(e,B){"use strict";Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return D}});const re=B("packages/core/src/internal/compare.js"),T=re.collator,G=re.defaultCompare;class D{#e;#t=new Map;#n=0;#r=null;#i=-1;#s="\0";constructor(Z=[]){this.#e=[];for(let z=0;z<Z.length;z++){const L=Z[z];this.#t.has(L)||(this.#t.set(L,this.#e.length),this.#e.push(L))}}get size(){return this.#e.length}get version(){return this.#n}get bytes(){let Z=this.#e.length*8;for(let z=0;z<this.#e.length;z++){const L=this.#e[z];typeof L=="string"&&(Z+=L.length*2),Z+=16}return Z}codeOf(Z){const z=this.#t.get(Z);if(z!==void 0)return z;const L=this.#e.length;return this.#e.push(Z),this.#t.set(Z,L),this.#n++,L}lookup(Z){const z=this.#t.get(Z);return z===void 0?-1:z}has(Z){return this.#t.has(Z)}valueOf(Z){return this.#e[Z]}values(){return this.#e}ranks(Z){const z=Z||"";if(this.#r&&this.#i===this.#n&&this.#s===z)return this.#r;const L=this.#e.length,X=new Array(L);for(let y=0;y<L;y++)X[y]=y;const $=T(Z).compare,A=this.#e;X.sort((y,f)=>this.#a(A[y],A[f],$));const k=new Uint32Array(L);for(let y=0;y<L;y++)k[X[y]]=y;return this.#r=k,this.#i=this.#n,this.#s=z,k}#a(Z,z,L){return typeof Z=="string"&&typeof z=="string"?L(Z,z):G(Z,z)}}}),Ue("packages/core/src/store/multivalue.js",function(e,B){"use strict";Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return re}});class re{#e;#t;#n=0;#r=0;constructor(G={}){const D=Math.max(1,G.rows??16),I=Math.max(1,G.values??D);this.#e=new Int32Array(I),this.#t=new Uint32Array(D+1)}get values(){return this.#e}get offsets(){return this.#t}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#e.byteLength+this.#t.byteLength}count(G){return G<0||G>=this.#n?0:this.#t[G+1]-this.#t[G]}at(G){return G<0||G>=this.#n?this.#e.subarray(0,0):this.#e.subarray(this.#t[G],this.#t[G+1])}has(G,D){if(G<0||G>=this.#n)return!1;const I=this.#e,Z=this.#t[G+1];for(let z=this.#t[G];z<Z;z++)if(I[z]===D)return!0;return!1}hasAny(G,D){for(let I=0;I<D.length;I++)if(this.has(G,D[I]))return!0;return!1}hasAll(G,D){for(let I=0;I<D.length;I++)if(!this.has(G,D[I]))return!1;return!0}hasNone(G,D){return!this.hasAny(G,D)}push(G){const D=this.#n,I=G.length;this.#i(D+1),this.#s(this.#r+I);const Z=this.#r;for(let z=0;z<I;z++)this.#e[Z+z]=G[z]|0;return this.#r+=I,this.#n=D+1,this.#t[D]=Z,this.#t[D+1]=this.#r,D}write(G,D){if(G===this.#n){this.push(D);return}if(G<0||G>this.#n)return;const I=this.#t[G],Z=this.#t[G+1],z=D.length;if(Z-I===z){for(let L=0;L<z;L++)this.#e[I+L]=D[L]|0;return}this.#a(G,D)}compact(G,D,I){const Z=this.#e,z=this.#t,L=this.#n,X=new Int32Array(Math.max(1,this.#r)),$=new Uint32Array(D+1);let A=0;for(let k=0;k<L;k++){if(G[k]===I)continue;const y=z[k],f=z[k+1];$[G[k]]=A;for(let g=y;g<f;g++)X[A++]=Z[g];$[G[k]+1]=A}this.#e=X,this.#t=$,this.#n=D,this.#r=A}release(){this.#e=new Int32Array(0),this.#t=new Uint32Array(1),this.#n=0,this.#r=0}#i(G){if(G+1<=this.#t.length)return;let D=this.#t.length-1;for(;D<G;)D=D*2||16;const I=new Uint32Array(D+1);I.set(this.#t),this.#t=I}#s(G){if(G<=this.#e.length)return;let D=this.#e.length;for(;D<G;)D=D*2||16;const I=new Int32Array(D);I.set(this.#e),this.#e=I}#a(G,D){const I=this.#e,Z=this.#t,z=this.#n,L=D.length-(Z[G+1]-Z[G]),X=new Int32Array(Math.max(1,this.#r+L)),$=new Uint32Array(Z.length);let A=0;for(let k=0;k<z;k++){if($[k]=A,k===G)for(let y=0;y<D.length;y++)X[A++]=D[y]|0;else for(let y=Z[k];y<Z[k+1];y++)X[A++]=I[y];$[k+1]=A}this.#e=X,this.#t=$,this.#r=A}}}),Ue("packages/core/src/compute/sort.js",function(e,B){"use strict";Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return O}});const re=B("packages/core/src/compute/handle.js"),T=re.bitReader,G=re.dictRanks,D=re.dictSize,I=re.identity,Z=re.isMissing,z=re.presenceReader,L=re.rowCount,X=re.valueComparator,$=re.valueReader,A=new Uint32Array(0),k=new ArrayBuffer(8),y=new Float64Array(k),f=new Uint32Array(k),g=(y[0]=-1,(f[1]&2147483648)!==0?1:0),a=g===1?0:1;function r(S,F){y[0]=S;let P=f[g],M=f[a];(P&2147483648)!==0?(P=~P>>>0,M=~M>>>0):P=(P^2147483648)>>>0,F[0]=M,F[1]=P}function i(S,F,P,M){if(M<2)return S;const x=new Uint32Array(256*8);for(let ee=0;ee<M;ee++){const ne=F[ee],se=P[ee];x[ne&255]++,x[256+(ne>>>8&255)]++,x[512+(ne>>>16&255)]++,x[768+(ne>>>24&255)]++,x[1024+(se&255)]++,x[1280+(se>>>8&255)]++,x[1536+(se>>>16&255)]++,x[1792+(se>>>24&255)]++}let U=S,_=F,W=P,q=new Uint32Array(M),N=new Uint32Array(M),Q=new Uint32Array(M);const J=new Uint32Array(256);for(let ee=0;ee<8;ee++){const ne=ee<<8,se=(ee&3)<<3,le=ee>=4;let ye=!1;for(let ke=0;ke<256;ke++)if(x[ne+ke]===M){ye=!0;break}if(ye)continue;let fe=0;for(let ke=0;ke<256;ke++)J[ke]=fe,fe+=x[ne+ke];for(let ke=0;ke<M;ke++){const Ce=_[ke],ce=W[ke],ae=(le?ce:Ce)>>>se&255,ge=J[ae]++;q[ge]=U[ke],N[ge]=Ce,Q[ge]=ce}let we=U;U=q,q=we,we=_,_=N,N=we,we=W,W=Q,Q=we}return U}function c(S,F,P){if(P<2)return S;const M=new Uint32Array(256*4);for(let N=0;N<P;N++){const Q=F[N];M[Q&255]++,M[256+(Q>>>8&255)]++,M[512+(Q>>>16&255)]++,M[768+(Q>>>24&255)]++}let x=S,U=F,_=new Uint32Array(P),W=new Uint32Array(P);const q=new Uint32Array(256);for(let N=0;N<4;N++){const Q=N<<8,J=N<<3;let ee=!1;for(let le=0;le<256;le++)if(M[Q+le]===P){ee=!0;break}if(ee)continue;let ne=0;for(let le=0;le<256;le++)q[le]=ne,ne+=M[Q+le];for(let le=0;le<P;le++){const ye=U[le],fe=q[ye>>>J&255]++;_[fe]=x[le],W[fe]=ye}let se=x;x=_,_=se,se=U,U=W,W=se}return x}function u(S,F,P,M){const x=new Uint32Array(M+1);for(let W=0;W<P;W++)x[F[W]]++;let U=0;for(let W=0;W<=M;W++){const q=x[W];x[W]=U,U+=q}const _=new Uint32Array(P);for(let W=0;W<P;W++)_[x[F[W]]++]=S[W];return _}function n(S,F,P,M){return P<2?S:M<=65536||M<=P*2?u(S,F,P,M):c(S,F,P)}function m(S,F){return S.length===F&&S.byteOffset===0?S:Uint32Array.prototype.slice.call(S,0,F)}function t(S,F,P=!1){const M=F||I(S.length),x=M.length;if(x<2)return Uint32Array.from(M);const U=new Uint32Array(x),_=new Uint32Array(x),W=new Uint32Array(x),q=new Uint32Array(x),N=new Uint32Array(2);let Q=0,J=0;for(let se=0;se<x;se++){const le=M[se],ye=S[le];if(Number.isNaN(ye)){q[J++]=le;continue}r(ye,N),P?(_[Q]=~N[0]>>>0,W[Q]=~N[1]>>>0):(_[Q]=N[0],W[Q]=N[1]),U[Q++]=le}const ee=i(U.subarray(0,Q),_.subarray(0,Q),W.subarray(0,Q),Q);if(J===0)return m(ee,Q);const ne=new Uint32Array(x);return ne.set(ee.subarray(0,Q),0),ne.set(q.subarray(0,J),Q),ne}function s(S,F,P=!1){const M=F||I(S.length),x=M.length;if(x<2)return Uint32Array.from(M);const U=Uint32Array.from(M),_=new Uint32Array(x);for(let W=0;W<x;W++){const q=(S[U[W]]^2147483648)>>>0;_[W]=P?~q>>>0:q}return m(c(U,_,x),x)}function h(S,F,P={}){const M=F||I(L(S,P)),x=M.length;if(x<2)return Uint32Array.from(M);const U=G(S.dict,P.locale),_=S.values,W=z(S),q=Math.max(D(S.dict),U.length),N=q,Q=Uint32Array.from(M),J=new Uint32Array(x),ee=!!P.descending;for(let ne=0;ne<x;ne++){const se=Q[ne];let le=W&&W(se)===0?N:U[_[se]];le===void 0&&(le=N),J[ne]=ee?N-le:le}return m(n(Q,J,x,q+1),x)}function d(S,F,P){const M=F.length;let x=Uint32Array.from(F);if(M<2)return x;let U=new Uint32Array(M);for(let _=1;_<M;_<<=1){for(let q=0;q<M;q+=_<<1){const N=Math.min(q+_,M),Q=Math.min(q+(_<<1),M);let J=q,ee=N,ne=q;for(;J<N&&ee<Q;)U[ne++]=P(S[x[J]],S[x[ee]])<=0?x[J++]:x[ee++];for(;J<N;)U[ne++]=x[J++];for(;ee<Q;)U[ne++]=x[ee++]}const W=x;x=U,U=W}return x}function o(S,F,P){const M=T(S.values),x=F.length,U=new Uint32Array(x),_=P?1:0;let W=0;for(let q=0;q<x;q++)M(F[q])===_&&(U[W++]=F[q]);for(let q=0;q<x;q++)M(F[q])!==_&&(U[W++]=F[q]);return U}function b(S,F){const P=S.values,M=S.kind;if((M==="object"||M===void 0)&&(Array.isArray(P)||ArrayBuffer.isView(P))&&!S.presence)return P;const U=$(S),_=new Array(L(S)||0);for(let W=0;W<F.length;W++){const q=F[W];_[q]=U(q)}return _}function l(S,F){for(let P=0;P<F.length;P++)if(typeof S[F[P]]!="string")return!1;return!0}function p(S,F,P,M,x){const U=S.length,_=Uint32Array.from(S);if(U<2||M<1)return _;const W=new Uint32Array(U),q=M-1;for(let N=0;N<U;N++){const Q=P[F[N]];W[N]=x?q-Q:Q}return m(n(_,W,U,M),U)}function w(S,F,P){const M=X(P),x=new Array(F);for(let _=0;_<F;_++)x[_]=_;x.sort((_,W)=>M(S[_],S[W])||_-W);const U=new Uint32Array(F);for(let _=0;_<F;_++)U[x[_]]=_;return U}function v(S,F,P){const M=F.length,x=new Map,U=[],_=new Uint32Array(M);for(let N=0;N<M;N++){const Q=S[F[N]];let J=x.get(Q);J===void 0&&(J=U.length,x.set(Q,J),U.push(Q)),_[N]=J}const W=U.length,q=w(U,W,P.locale);return p(F,_,q,W,!!P.descending)}function R(S,F,P){const M=b(S,F);if(F.length>=2&&l(M,F)){const _=S.stringRank;return _&&_.version===S.version&&_.usable(F,M,P.locale)?_.sort(F,P):v(M,F,P)}const x=X(P.locale),U=P.descending?(_,W)=>x(W,_):x;return d(M,F,U)}function Y(S,F,P){const M=b(S,F),x=P.compare,_=!!P.descending?(W,q)=>-x(W,q,void 0,void 0,!0):(W,q)=>x(W,q,void 0,void 0,!1);return d(M,F,_)}function K(S,F){const P=F.length,M=z(S),x=S.values,U=S.kind==="float64"&&!!x,_=S.kind==="object"||S.kind==="multi"||S.kind===void 0;if(!M&&!U&&!_)return{present:F,absent:A};const W=new Uint32Array(P),q=new Uint32Array(P);let N=0,Q=0;if(M&&U)for(let J=0;J<P;J++){const ee=F[J];M(ee)===1&&!Number.isNaN(x[ee])?W[N++]=ee:q[Q++]=ee}else if(U&&!M)for(let J=0;J<P;J++){const ee=F[J];Number.isNaN(x[ee])?q[Q++]=ee:W[N++]=ee}else if(M&&!_)for(let J=0;J<P;J++){const ee=F[J];M(ee)===1?W[N++]=ee:q[Q++]=ee}else{const J=$(S);for(let ee=0;ee<P;ee++){const ne=F[ee];Z(J(ne))?q[Q++]=ne:W[N++]=ne}}return Q===0?{present:F,absent:A}:{present:W.subarray(0,N),absent:q.subarray(0,Q)}}function V(S,F,P){if(F.length===0)return S;const M=new Uint32Array(S.length+F.length);return P?(M.set(F,0),M.set(S,F.length)):(M.set(S,0),M.set(F,S.length)),M}function E(S,F,P={}){const M=F||I(L(S,P));if(!S||M.length<2)return Uint32Array.from(M);const{present:x,absent:U}=K(S,M);if(x.length===0)return Uint32Array.from(M);const _=!!P.descending;let W;if(typeof P.compare=="function")W=Y(S,x,P);else switch(S.kind){case"float64":W=t(S.values,x,_);break;case"int32":W=s(S.values,x,_);break;case"dictionary":W=h(S,x,P);break;case"bitset":W=o(S,x,_);break;default:W=R(S,x,P);break}return V(W,U,!!P.nullsFirst)}function O(S,F,P,M={}){const x=F||[],U=x.length&&(x[0].handle||C(S,x[0].col))||S&&S[0];let _=P||I(L(U,M));for(let W=x.length-1;W>=0;W--){const q=x[W],N=q.handle||C(S,q.col)||S&&S[W];N&&(_=E(N,_,{descending:q.descending!==void 0?!!q.descending:q.dir==="desc",nullsFirst:!!q.nullsFirst,locale:q.locale!==void 0?q.locale:M.locale,compare:q.compare}))}return _ instanceof Uint32Array?_:Uint32Array.from(_)}function C(S,F){if(!(!S||F===void 0)){for(let P=0;P<S.length;P++)if(S[P]&&S[P].id===F)return S[P]}}}),Ue("packages/core/src/store/stringrank.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"StringRankIndex",{enumerable:!0,get:function(){return I}});const re=B("packages/core/src/compute/sort.js"),T=re.collateStringRanks,G=re.rankSortStrings,D=1e5;class I{#e=[];#t=new Map;#n;#r=0;#i=0;#s=-1;#a;#l=!1;#o=null;#c=-1;#u="\0";constructor(z=D){this.#a=z>0?z:D,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(z){this.#s=z}get generation(){return this.#i}get size(){return this.#e.length}get capped(){return this.#l}get length(){return this.#r}get bytes(){let z=this.#n.byteLength;const L=this.#e;for(let X=0;X<L.length;X++)z+=L[X].length*2+24;return z}#f(z,L){const X=this.#t.get(z);if(X!==void 0)return X;if(this.#l)return-1;if(L&&this.#e.length>=this.#a)return this.#l=!0,-1;const $=this.#e.length;return this.#e.push(z),this.#t.set(z,$),this.#i++,$}build(z,L){const X=L|0;this.#e=[],this.#t=new Map,this.#i=0,this.#l=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(X);for(let $=0;$<X;$++){const A=z[$],k=typeof A=="string"?this.#f(A,!1):-1;this.#n[$]=k<0?0:k}this.#r=X}append(z,L,X){const $=(L|0)+(X|0);if($>this.#n.length){const A=new Uint32Array($);A.set(this.#n.subarray(0,this.#r)),this.#n=A}for(let A=L|0;A<$;A++){const k=z[A],y=typeof k=="string"?this.#f(k,!0):-1;this.#n[A]=y<0?0:y}this.#r=Math.max(this.#r,$)}ranks(z){const L=z||"";if(this.#o&&this.#c===this.#i&&this.#u===L)return this.#o;const X=T(this.#e,this.#e.length,z);return this.#o=X,this.#c=this.#i,this.#u=L,X}usable(z,L,X){if(this.#l||this.#e.length===0)return!1;const $=this.#n,A=this.#e,k=this.#r;for(let y=0;y<z.length;y++){const f=z[y];if(f>=k||A[$[f]]!==L[f])return!1}return!0}sort(z,L){const X=this.ranks(L.locale),$=this.#e.length,A=z.length,k=new Uint32Array(A),y=this.#n;for(let f=0;f<A;f++)k[f]=y[z[f]];return G(z,k,X,$,!!L.descending)}}}),Ue("packages/core/src/store/columnstore.js",function(e,B){"use strict";Object.defineProperty(e,"REMOVED",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toFloat",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ColumnHandle",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return o}});const T=B("packages/core/src/internal/warn.js").warnOnce,D=B("packages/core/src/internal/predicates.js").isFunction,Z=B("packages/core/src/internal/paths.js").pathGetter,L=B("packages/core/src/store/bitset.js").Bitset,$=B("packages/core/src/store/dictionary.js").Dictionary,k=B("packages/core/src/store/multivalue.js").MultiValue,f=B("packages/core/src/store/stringrank.js").StringRankIndex,g=4294967295,a=1024,r=5e3,i=.2,c=new Set(["float64","int32","bitset","dictionary","object","multi"]);function u(b){return b==null}function n(b){return typeof b=="number"?b:b instanceof Date?b.getTime():typeof b=="boolean"?b?1:0:Number(b)}function m(b){const l=n(b);return Number.isFinite(l)?l|0:0}function t(b){return u(b)?[]:Array.isArray(b)?b:[b]}function s(b,l){switch(b.kind){case"float64":case"int32":return b.buf[l];case"bitset":return b.bits.get(l)===1;case"dictionary":return b.dict.valueOf(b.buf[l]);case"multi":{const p=b.mv.at(l),w=new Array(p.length);for(let v=0;v<p.length;v++)w[v]=b.dict.valueOf(p[v]);return w}default:return b.buf[l]}}function h(b,l){switch(b.kind){case"float64":case"int32":return b.values[l];case"bitset":return(b.values[l>>3]&1<<(l&7))!==0;case"dictionary":return(b.table||[])[b.values[l]];case"multi":{const p=b.offsets[l],w=b.offsets[l+1],v=b.table||[],R=new Array(w-p);for(let Y=p;Y<w;Y++)R[Y-p]=v[b.values[Y]];return R}default:return b.values[l]}}class d{#e;#t;#n;#r;#i;#s;#a;#l=!1;#o=null;#c=null;#u=null;#f=null;#d=null;#h;#p;#m=-1;#g=null;#b=0;#y=0;#O=null;#w=null;#A=!1;constructor(l,p){this.#e=l.id;const w=c.has(l.kind)?l.kind:"object";l.kind&&!c.has(l.kind)&&T(`store.kind.${l.id}`,`column "${l.id}" declares unknown storage kind "${l.kind}"; falling back to object`),this.#n=w,this.#t=w,this.#r=l.nullable!==!1,this.#a=l.dictionary??null,this.#s=p,this.#i=D(l.read)?l.read:Z(l.field||l.id),this.#h=l.stringRankIndex!=="off",this.#p=typeof l.stringRankMaxDistinct=="number"?l.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.#o: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.#f:null}get stringRank(){if(this.#A||!this.#h||this.kind!=="object")return null;const l=this.values,p=this.#s.physical();if(!l||p===0)return null;if(this.#d===null){if(typeof l[0]!="string")return null;const w=new f(this.#v());return w.build(l,p),w.version=this.#y,this.#d=w,this.#m=this.#y,w.capped?null:w}return this.#d.length<p&&this.#d.append(l,this.#d.length,p-this.#d.length),this.#d.version=this.#y,this.#m=this.#y,this.#d.capped?null:this.#d}#v(){return this.#p}#P(){this.#d=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 l=0;return this.#o&&(l+=this.#o.byteLength??this.#o.length*8),this.#c&&(l+=this.#c.bytes),this.#u&&(l+=this.#u.bytes),this.#g&&(l+=this.#g.bytes),this.#f&&(l+=this.#f.bytes),this.#O&&(l+=this.#O.size*24),l}get(l){if(!this.#A&&!(l<0||l>=this.#s.physical())){if(!this.#l)return this.#E(l);if(this.#r&&this.#g.get(l)===0)return null;switch(this.#t){case"float64":case"int32":return this.#o[l];case"bitset":return this.#c.get(l)===1;case"dictionary":return this.#f.valueOf(this.#o[l]);case"multi":{const p=this.#u.at(l),w=new Array(p.length);for(let v=0;v<p.length;v++)w[v]=this.#f.valueOf(p[v]);return w}default:return this.#o[l]}}}set(l,p){this.#A||(this.#l?this.#C(l,p):this.#O.set(l,p===void 0?null:p),this.#d&&this.#P(),this.#y++)}read(l){return this.#i(l)}appendColumn(l,p,w){if(this.#A||w<=0)return;if(!this.#l){this.#y++;return}const v=this.#i,R=this.#r,Y=this.#g;let K=!1;switch(this.#t){case"float64":{const V=this.#o;for(let E=0;E<w;E++){const O=v(l[E]);if(typeof O=="number"){R&&Y.set(p+E),V[p+E]=O;continue}const C=O==null;R?Y.assign(p+E,!C):C&&(K=!0),V[p+E]=C?NaN:n(O)}break}case"int32":{const V=this.#o;for(let E=0;E<w;E++){const O=v(l[E]),C=O==null;R?Y.assign(p+E,!C):C&&(K=!0),V[p+E]=C?0:m(O)}break}case"bitset":{const V=this.#c;for(let E=0;E<w;E++){const O=v(l[E]),C=O==null;R?Y.assign(p+E,!C):C&&(K=!0),V.assign(p+E,!C&&!!O)}break}case"dictionary":{const V=this.#o,E=this.#f;for(let O=0;O<w;O++){const C=v(l[O]),S=C==null;R?Y.assign(p+O,!S):S&&(K=!0),V[p+O]=S?0:E.codeOf(C)}break}case"multi":{const V=this.#u,E=this.#f;for(let O=0;O<w;O++){const C=v(l[O]),S=C==null;R?Y.assign(p+O,!S):S&&(K=!0);const F=t(C),P=new Array(F.length);for(let M=0;M<F.length;M++)P[M]=E.codeOf(F[M]);V.write(p+O,P)}break}default:{const V=this.#o;for(let E=0;E<w;E++){const O=v(l[E]),C=O==null;R?Y.assign(p+E,!C):C&&(K=!0),V[p+E]=C?null:O}break}}K&&T(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#d&&this.#t==="object"&&(this.#d.append(this.#o,p,w),this.#d.version=this.#y+1,this.#m=this.#y+1),this.#y++}appendPacked(l,p,w){if(this.#A||w<=0||!l)return;if(!this.#l){this.#y++;return}const v=this.#g,R=l.presence;if(v)if(R)for(let K=0;K<w;K++)v.assign(p+K,(R[K>>3]&1<<(K&7))!==0);else for(let K=0;K<w;K++)v.set(p+K);const Y=l.kind===this.#t;if(Y&&(this.#t==="float64"||this.#t==="int32")){this.#o.set(l.values,p),this.#y++;return}if(Y&&this.#t==="bitset"){const K=l.values;for(let V=0;V<w;V++)this.#c.assign(p+V,(K[V>>3]&1<<(V&7))!==0);this.#y++;return}if(Y&&this.#t==="dictionary"){const K=l.table||[],V=new Uint32Array(K.length);for(let S=0;S<K.length;S++)V[S]=this.#f.codeOf(K[S]);const E=l.values,O=this.#o,C=v;for(let S=0;S<w;S++){if(C&&(R&&(R[S>>3]&1<<(S&7))===0)){O[p+S]=0;continue}O[p+S]=V[E[S]]??0}this.#y++;return}if(Y&&this.#t==="multi"){const K=l.table||[],V=new Uint32Array(K.length);for(let C=0;C<K.length;C++)V[C]=this.#f.codeOf(K[C]);const E=l.values,O=l.offsets;for(let C=0;C<w;C++){const S=O[C],F=O[C+1],P=new Array(F-S);for(let M=S;M<F;M++)P[M-S]=V[E[M]]??0;this.#u.write(p+C,P)}this.#y++;return}for(let K=0;K<w;K++){const V=R?(R[K>>3]&1<<(K&7))===0:l.kind==="object"?l.values[K]===null:!1;this.#C(p+K,V?null:h(l,K))}this.#y++}touch(){this.#y++}columnarise(l,p){if(this.#l||this.#A)return;const w=new Array(p);for(let v=0;v<p;v++)w[v]=this.#E(v);this.#t=this.#n,this.#l=!0,this.#S(l);for(let v=0;v<p;v++)this.#C(v,w[v]);this.#O.clear(),this.#w=null,this.#P(),this.#y++}grow(l){if(!(!this.#l||this.#A||l<=this.#b)){switch(this.#t){case"float64":case"int32":case"dictionary":{const p=new this.#o.constructor(l);p.set(this.#o),this.#o=p;break}case"bitset":this.#c.grow(l);break;case"multi":break;default:this.#o.length=l;break}this.#g&&this.#g.grow(l),this.#b=l,this.#y++}}convert(l){if(this.#A||!c.has(l)||(this.#n=l,!this.#l||l===this.#t))return!1;const p={kind:this.#t,buf:this.#o,bits:this.#c,mv:this.#u,dict:this.#f},w=this.#s.physical(),v=this.#g;this.#t=l,this.#S(this.#b);for(let R=0;R<w;R++){const Y=v!==null&&v.get(R)===0;Y&&l!=="multi"||this.#C(R,Y?null:s(p,R))}return this.#P(),this.#y++,!0}compact(l,p,w){if(!this.#A){if(this.#P(),!this.#l){const v=this.#O;if(v.size){const R=new Map;for(const[Y,K]of v)l[Y]!==g&&R.set(l[Y],K);this.#O=R}this.#w=null,this.#y++;return}switch(this.#t){case"float64":case"int32":case"dictionary":case"object":{const v=this.#o;for(let R=0;R<p;R++)l[R]!==g&&(v[l[R]]=v[R]);if(this.#t==="object")for(let R=w;R<p;R++)v[R]=void 0;break}case"bitset":{const v=this.#c;for(let R=0;R<p;R++)l[R]!==g&&v.assign(l[R],v.get(R)===1);for(let R=w;R<p;R++)v.clear(R);break}case"multi":this.#u.compact(l,w,g);break;default:break}if(this.#g){const v=this.#g;for(let R=0;R<p;R++)l[R]!==g&&v.assign(l[R],v.get(R)===1);for(let R=w;R<p;R++)v.clear(R)}this.#y++}}release(){this.#A||(this.#A=!0,this.#o=null,this.#c&&this.#c.release(),this.#c=null,this.#u&&this.#u.release(),this.#u=null,this.#g&&this.#g.release(),this.#g=null,this.#f=null,this.#d=null,this.#O=new Map,this.#w=null,this.#b=0,this.#y++)}#S(l){const p=Math.max(1,l);switch(this.#o=null,this.#c=null,this.#u=null,this.#t){case"float64":this.#o=new Float64Array(p);break;case"int32":this.#o=new Int32Array(p);break;case"bitset":this.#c=new L(p);break;case"dictionary":this.#o=new Uint32Array(p),this.#f=this.#f??new $(this.#a??[]);break;case"multi":this.#u=new k({rows:p,values:p}),this.#f=this.#f??new $(this.#a??[]);break;default:this.#o=new Array(p);break}this.#t!=="dictionary"&&this.#t!=="multi"&&(this.#f=null),this.#r&&(this.#g?this.#g.grow(p):this.#g=new L(p)),this.#b=p}#C(l,p){const w=u(p);switch(this.#r?this.#g.assign(l,!w):w&&T(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#t){case"float64":this.#o[l]=w?NaN:n(p);break;case"int32":this.#o[l]=w?0:m(p);break;case"bitset":this.#c.assign(l,!w&&!!p);break;case"dictionary":this.#o[l]=w?0:this.#f.codeOf(p);break;case"multi":{const v=t(p),R=new Array(v.length);for(let Y=0;Y<v.length;Y++)R[Y]=this.#f.codeOf(v[Y]);this.#u.write(l,R);break}default:this.#o[l]=w?null:p;break}}#E(l){if(this.#O.has(l))return this.#O.get(l);const p=this.#i(this.#s.rowAt(l));return p===void 0?null:p}#T(){if(this.#w&&this.#w.version===this.#y)return this.#w;const l=this.#s.physical(),p=new Array(l),w=this.#r?new L(l):null;for(let v=0;v<l;v++){const R=this.#E(v);p[v]=R,w&&!u(R)&&w.set(v)}return this.#w={version:this.#y,values:p,presence:w},this.#w}}class o{#e;#t=new Map;#n=[];#r=[];#i=0;#s=0;#a=0;#l=0;#o=new L(0);#c=!1;#u=!0;#f;#d;#h;#p=!1;constructor(l,p={}){this.#e=Array.isArray(l)?l:[],this.#d=Math.max(1,p.initialCapacity??a),this.#u=p.retainSource!==!1,this.#f=this.#u?p.columnarBelow??r:0,this.#h=p.compactRatio??i;const w={rowAt:v=>this.#r[v],physical:()=>this.#i};for(const v of this.#e){if(!v||!v.id)continue;if(this.#t.has(v.id)){T(`store.dup.${v.id}`,`duplicate column id "${v.id}" in the store schema; ignoring the second`);continue}const R=new d(v,w);this.#t.set(v.id,R),this.#n.push(R)}this.#f<=0&&this.#b()}get count(){return this.#a}get physical(){return this.#i}get capacity(){return this.#c?this.#s:this.#r.length}get tombstones(){return this.#l}get columnar(){return this.#c}get destroyed(){return this.#p}get bytes(){let l=this.#o.bytes+this.#r.length*8;for(const p of this.#n)l+=p.bytes;return l}append(l){const p=this.#i;if(this.#p||!l)return{from:p,to:p};const w=l.length|0;if(w===0)return{from:p,to:p};if(this.#u)for(let R=0;R<w;R++)this.#r[p+R]=l[R];if(this.#i=p+w,this.#a+=w,this.#o.grow(this.#i),!this.#c){if(this.#i>=this.#f)this.#b();else for(const R of this.#n)R.touch();return{from:p,to:this.#i}}this.#m(this.#i);const v=this.#n;for(let R=0;R<v.length;R++)v[R].appendColumn(l,p,w);return{from:p,to:this.#i}}appendPacked(l,p){const w=this.#i;if(this.#p||!l)return{from:w,to:w};const v=l.count|0;if(v===0)return{from:w,to:w};if(this.#u&&p)for(let Y=0;Y<v;Y++)this.#r[w+Y]=p[Y];this.#i=w+v,this.#a+=v,this.#o.grow(this.#i),this.#c||this.#b(),this.#m(this.#i);const R=new Map;for(const Y of l.columns)R.set(Y.id,Y);for(const Y of this.#n){const K=R.get(Y.id);K?Y.appendPacked(K,w,v):Y.grow(this.#s)}return{from:w,to:this.#i}}source(l){if(this.#u)return this.#r[l];if(!(l<0||l>=this.#i))return this.#g(l)}setSource(l,p){this.#p||l<0||l>=this.#i||this.#u&&(this.#r[l]=p)}get(l,p){const w=this.#t.get(l);return w?w.get(p):void 0}set(l,p,w){if(this.#p||p<0||p>=this.#i)return;const v=this.#t.get(l);if(!v){T(`store.set.${l}`,`set() on unknown column "${l}"`);return}v.set(p,w)}remove(l){return this.#p||l<0||l>=this.#i||this.#o.get(l)===1?!1:(this.#o.set(l),this.#l++,this.#a--,!0)}live(l){return l<0||l>=this.#i?!1:this.#o.get(l)===0}compact(l={}){if(this.#p||this.#l===0||!l.force&&this.#l/this.#i<this.#h)return null;const p=this.#i,w=new Uint32Array(p);let v=0;for(let R=0;R<p;R++)w[R]=this.#o.get(R)===1?g:v++;for(const R of this.#n)R.compact(w,p,v);if(this.#u){const R=this.#r;for(let Y=0;Y<p;Y++)w[Y]!==g&&(R[w[Y]]=R[Y]);R.length=v}return this.#i=v,this.#a=v,this.#l=0,this.#o=new L(Math.max(this.#s,v)),w}column(l){return this.#t.get(l)}columns(){return this.#n.slice()}liveIndices(){const l=new Uint32Array(this.#a);if(this.#l===0){for(let w=0;w<this.#i;w++)l[w]=w;return l}let p=0;for(let w=0;w<this.#i;w++)this.#o.get(w)===0&&(l[p++]=w);return l}convert(l,p){const w=this.#t.get(l);return w?w.convert(p):!1}destroy(){if(!this.#p){this.#p=!0;for(const l of this.#n)l.release();this.#t.clear(),this.#n.length=0,this.#r.length=0,this.#o.release(),this.#i=0,this.#a=0,this.#l=0,this.#s=0}}#m(l){if(l<=this.#s)return;let p=this.#s||this.#d;for(;p<l;)p*=2;for(const w of this.#n)w.grow(p);this.#o.grow(p),this.#s=p}#g(l){const p={};for(const w of this.#n)p[w.id]=w.get(l);return p}#b(){if(this.#c)return;let l=this.#d;for(;l<this.#i;)l*=2;this.#c=!0,this.#s=l,this.#o.grow(l);for(const p of this.#n)p.columnarise(l,this.#i)}}}),Ue("packages/core/src/store/pool.js",function(e,B){"use strict";Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"sharedPool",{enumerable:!0,get:function(){return I}});const re=64,T=8;function G(z){let L=re;for(;L<z;)L*=2;return L}class D{#e=new Map;#t=new WeakSet;#n;#r=0;#i={acquired:0,reused:0,released:0};constructor(L={}){this.#n=L.limit??T}get bytes(){return this.#r}mask(L){const X=new Uint8Array(this.#s(L),0,L);return X.fill(0),X}indices(L){return new Uint32Array(this.#s(L*4),0,L)}release(L){if(!L||!L.buffer)return!1;const X=L.buffer;if(!this.#t.has(X))return!1;this.#t.delete(X),this.#i.released++;const $=X.byteLength;let A=this.#e.get($);return A||this.#e.set($,A=[]),A.length>=this.#n||(A.push(X),this.#r+=$),!0}releaseAll(L){for(const X of L)this.release(X)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#i,retained:this.#r}}#s(L){const X=G(L),$=this.#e.get(X);this.#i.acquired++;let A;return $&&$.length?(A=$.pop(),this.#r-=X,this.#i.reused++):A=new ArrayBuffer(X),this.#t.add(A),A}}function I(){return Z??=new D,Z}let Z=null}),Ue("packages/core/src/compute/sortspec.js",function(e,B){"use strict";Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return I}});function re(Z){return{locale:Z===void 0?void 0:String(Z),numeric:!0,sensitivity:"variant"}}function T(Z){return!!Z&&typeof Z.compare!="function"}function G(Z){if(!Z)return!0;for(let z=0;z<Z.length;z++)if(!T(Z[z]))return!1;return!0}function D(Z,z){const L=Z.col!==void 0?Z.col:Z.handle&&Z.handle.id,X=Z.locale!==void 0?Z.locale:z;return{col:L,descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,collation:re(X)}}function I(Z,z){const L=Z||[],X=new Array(L.length);for(let $=0;$<L.length;$++)X[$]=D(L[$],z);return X}}),Ue("packages/core/src/compute/facet.js",function(e,B){"use strict";Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"orderedReader",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"toNumeric",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const re=B("packages/core/src/compute/handle.js"),T=re.presenceReader,G=re.valueReader,D=re.dictSize,I=re.dictValue,Z=Object.freeze(["equal","quantile","log"]),z=Object.freeze(["hour","day","week","month","quarter","year"]),L=20,X=50,$=1e4;function A(v,R){if(!v)return"none";const Y=R;if(Y&&(Y.multi===!0||typeof Y.items=="function"))return"category";const K=R&&R.base;if(K==="date"||K==="datetime"||K==="time"||K==="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 K==="number"?"numeric":K==="boolean"?"boolean":K==="text"?"category":"none"}}function k(v){const R=v.values,Y=v.kind;if((Y==="float64"||Y==="int32")&&R)return V=>R[V];const K=G(v);return V=>y(K(V))}function y(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 R=Number(v);if(Number.isFinite(R))return R;const Y=Date.parse(v);return Number.isFinite(Y)?Y:NaN}return NaN}function f(v,R,Y,K=X){if(!v)return{cardinality:0,exact:!0};if(v.dict)return{cardinality:D(v.dict),exact:!0};if(v.kind==="bitset")return{cardinality:2,exact:!0};const V=G(v),E=R?R.length:Y,O=new Set;for(let C=0;C<E;C++){const S=V(R?R[C]:C);if(S!=null&&(O.add(S),O.size>K))return{cardinality:O.size,exact:!1}}return{cardinality:O.size,exact:!0}}const g=36e5,a=864e5;function r(v,R=L){const Y=Number.isFinite(v)&&v>0?v:0,K=Math.max(1,R)*2;return Y/g<=K?"hour":Y/a<=K?"day":Y/(7*a)<=K?"week":Y/(30*a)<=K?"month":Y/(91*a)<=K?"quarter":"year"}function i(v,R){if(!Number.isFinite(v))return NaN;const Y=new Date(v);switch(R){case"hour":return Y.setMinutes(0,0,0),Y.getTime();case"day":return Y.setHours(0,0,0,0),Y.getTime();case"week":{Y.setHours(0,0,0,0);const K=(Y.getDay()+6)%7;return Y.setDate(Y.getDate()-K),Y.getTime()}case"month":return Y.setDate(1),Y.setHours(0,0,0,0),Y.getTime();case"quarter":return Y.setMonth(Math.floor(Y.getMonth()/3)*3,1),Y.setHours(0,0,0,0),Y.getTime();default:return Y.setMonth(0,1),Y.setHours(0,0,0,0),Y.getTime()}}function c(v,R){const Y=new Date(v);switch(R){case"hour":Y.setHours(Y.getHours()+1);break;case"day":Y.setDate(Y.getDate()+1);break;case"week":Y.setDate(Y.getDate()+7);break;case"month":Y.setMonth(Y.getMonth()+1);break;case"quarter":Y.setMonth(Y.getMonth()+3);break;default:Y.setFullYear(Y.getFullYear()+1);break}return Y.getTime()}function u(v,R,Y){const K=k(v),V=T(v),E=R?R.length:Y;let O=1/0,C=-1/0,S=0,F=0;for(let P=0;P<E;P++){const M=R?R[P]:P;if(V&&!V(M)){S++;continue}const x=K(M);if(!Number.isFinite(x)){S++;continue}x<O&&(O=x),x>C&&(C=x),F++}return{min:O,max:C,nulls:S,finite:F}}function n(v,R,Y,K){const V=k(v),E=T(v),O=R?R.length:Y,C=O>K?O/K:1,S=[];for(let P=0;P<O;P+=C){const M=R?R[Math.floor(P)]:Math.floor(P);if(E&&!E(M))continue;const x=V(M);Number.isFinite(x)&&S.push(x)}const F=Float64Array.from(S);return F.sort(),F}function m(v,R,Y,K={}){const V=K.kind||A(v,K.type);return V==="none"||!v?{kind:"none",buckets:[],suppressed:"type"}:V==="boolean"?t(v,R,Y,K):V==="category"?s(v,R,Y,K):d(v,R,Y,V,K)}function t(v,R,Y,K={}){const V=T(v);let E=0;if(V){const C=R?R.length:Y;for(let S=0;S<C;S++)V(R?R[S]:S)||E++}const O=[{value:!1,label:"false"},{value:!0,label:"true"}];return E>0&&K.blanks!==!1&&O.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:O}}function s(v,R,Y,K){const V=K.cardinalityLimit??X,{cardinality:E}=f(v,R,Y,V);if(E>V&&(K.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:E};const O=G(v),C=R?R.length:Y,S=new Map;let F=0;for(let _=0;_<C;_++){const W=O(R?R[_]:_);if(W==null||W===""){F++;continue}if(Array.isArray(W)){if(!W.length){F++;continue}for(const q of W)S.set(q,(S.get(q)||0)+1);continue}S.set(W,(S.get(W)||0)+1)}let P=[...S.entries()];K.order==="alpha"?P.sort((_,W)=>String(_[0]).localeCompare(String(W[0]))):P.sort((_,W)=>W[1]-_[1]);let M=0,x=0;if(P.length>V){x=P.length-V;for(let _=V;_<P.length;_++)M+=P[_][1];P=P.slice(0,V)}const U=P.map(([_])=>({value:_,label:String(_)}));return M>0&&U.push({remainder:!0,label:`Other (${x} values)`}),F>0&&K.blanks!==!1&&U.push({null:!0,label:"Empty"}),{kind:"category",buckets:U,cardinality:E}}function h(v,R,Y,K,V){const E=n(v,R,Y,$),O=E.length;if(O<100)return null;const C=E[Math.floor(.01*O)],S=E[Math.ceil(.99*O)-1];return!(S>C)||V-K<=2*(S-C)?null:{lo:C,hi:S}}function d(v,R,Y,K,V){const{min:E,max:O,nulls:C,finite:S}=u(v,R,Y);if(!S)return{kind:K,buckets:C&&V.blanks!==!1?[{null:!0,label:"Empty"}]:[],empty:!0};const F=Math.max(1,Math.floor(V.buckets||L));let P=[];if(K==="date"){const x=z.includes(V.granularity)?V.granularity:r(O-E,F);let U=i(E,x);for(;U<=O&&P.length<4096;){const _=c(U,x);if(!(_>U))break;P.push({from:U,to:_}),U=_}return{kind:K,buckets:o(P,V.blanks===!1?0:C),granularity:x}}const M=Z.includes(V.strategy)?V.strategy:"equal";if(M==="quantile"){const x=n(v,R,Y,$);if(x.length){const U=[x[0]];for(let _=1;_<F;_++){const W=x[Math.min(x.length-1,Math.floor(_/F*x.length))];W>U[U.length-1]&&U.push(W)}U.push(O);for(let _=0;_<U.length-1;_++)P.push({from:U[_],to:U[_+1]})}}else if(M==="log"&&E>0){const x=Math.log10(E),_=(Math.log10(O)-x)/F||1;for(let W=0;W<F;W++)P.push({from:10**(x+W*_),to:10**(x+(W+1)*_)})}if(!P.length&&M==="equal"){const x=h(v,R,Y,E,O);if(x){const U=(x.hi-x.lo)/F;x.lo>E&&P.push({from:E,to:x.lo,overflow:"low"});for(let _=0;_<F;_++)P.push({from:x.lo+_*U,to:x.lo+(_+1)*U});P[P.length-1].to=x.hi,x.hi<O&&P.push({from:x.hi,to:O,overflow:"high"})}}if(!P.length){const x=(O-E)/F||1;for(let U=0;U<F;U++)P.push({from:E+U*x,to:E+(U+1)*x})}return P[P.length-1].to=O,{kind:K,buckets:o(P,V.blanks===!1?0:C),strategy:M,min:E,max:O}}function o(v,R){return R>0?[...v,{null:!0,label:"Empty"}]:v}function b(v,R,Y,K,V){const E=K&&K.buckets||[],O=V&&V.length>=E.length?V.subarray(0,E.length):new Uint32Array(E.length);if(O.fill(0),!v||!E.length)return O;const C=E.length-1,S=!!E[C]&&E[C].null===!0,F=R?R.length:Y;if(K.kind==="boolean"){const _=G(v);for(let W=0;W<F;W++){const q=_(R?R[W]:W);if(q==null){S&&O[C]++;continue}O[q?1:0]++}return O}if(K.kind==="category"){const _=new Map;for(let N=0;N<E.length;N++)!E[N].null&&!E[N].remainder&&_.set(E[N].value,N);const W=E.findIndex(N=>N.remainder),q=G(v);for(let N=0;N<F;N++){const Q=q(R?R[N]:N);if(Q==null||Q===""){S&&O[C]++;continue}if(Array.isArray(Q)){if(!Q.length){S&&O[C]++;continue}for(const ee of Q){const ne=_.get(ee);ne!==void 0?O[ne]++:W>=0&&O[W]++}continue}const J=_.get(Q);J!==void 0?O[J]++:W>=0&&O[W]++}return O}const P=S?E.length-1:E.length,M=new Float64Array(P+1);for(let _=0;_<P;_++)M[_]=E[_].from;M[P]=P?E[P-1].to:0;const x=k(v),U=T(v);for(let _=0;_<F;_++){const W=R?R[_]:_;if(U&&!U(W)){S&&O[C]++;continue}const q=x(W);if(!Number.isFinite(q)){S&&O[C]++;continue}const N=l(M,P,q);N>=0&&O[N]++}return O}function l(v,R,Y){if(!R||Y<v[0])return-1;if(Y>=v[R])return Y===v[R]?R-1:-1;let K=0,V=R-1;for(;K<V;){const E=K+V+1>>>1;Y>=v[E]?K=E:V=E-1}return K}function p(v,R,Y,K={}){const V=K.bounds||m(v,K.boundsIndices??R,Y,K);return{bounds:V,counts:b(v,R,Y,V)}}const w=p}),Ue("packages/core/src/compute/pivotmatrix.js",function(e,B){"use strict";Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return i}});const T=B("packages/core/src/compute/handle.js").valueComparator,D=B("packages/core/src/compute/total.js").total,Z=B("packages/core/src/compute/group.js").packKeys,z=B("packages/core/src/compute/pivot.js"),L=z.joinPath,X=z.DEFAULT_PATH_SEPARATOR,$=z.DEFAULT_MAX_COLUMNS,A="";function k(c,u,n={}){const m=n.separator||X,t=c||[],s=u instanceof Uint32Array?u:Uint32Array.from(u||[]),h=s.length;if(t.length===0)return{tuples:[[]],paths:[A],buckets:[s]};const{keyOf:d,readers:o}=Z(t,s,0),b=new Map,l=[],p=[],w=[];for(let E=0;E<h;E++){const O=s[E],C=d(O);let S=b.get(C);if(S===void 0){S=l.length,b.set(C,S),p.push(C);const F=new Array(o.length);for(let P=0;P<o.length;P++)F[P]=o[P](O);l.push(F),w.push([])}w[S].push(O)}const v=T(n.locale),R=l.map((E,O)=>O);R.sort((E,O)=>{const C=l[E],S=l[O];for(let F=0;F<C.length;F++){const P=y(C[F],S[F],v);if(P!==0)return P}return E-O});const Y=new Array(R.length),K=new Array(R.length),V=new Array(R.length);for(let E=0;E<R.length;E++){const O=R[E];Y[E]=l[O],K[E]=L(l[O],m),V[E]=Uint32Array.from(w[O])}return{tuples:Y,paths:K,buckets:V}}function y(c,u,n){const m=c==null,t=u==null;return m||t?m&&t?0:m?1:-1:n(c,u)}function f(c,u,n){const m=[];for(let t=0;t<c.length;t++)n.has(c[t])&&m.push(c[t]);return Uint32Array.from(m)}function g(c,u,n,m){return{value:u.length?D(c,u,n,m):null,leaves:u,count:u.length}}function a(c){const u=c&&c.opts||{},n=u.separator||X,m=u.totalContext||{locale:u.locale},t=(c.measures||[]).filter(K=>K&&K.handle),s=c.leaves instanceof Uint32Array?c.leaves:Uint32Array.from(c.leaves||[]),h=k(c.rowHandles||[],s,{...u,separator:n}),d=k(c.columnHandles||[],s,{...u,separator:n}),o=u.maxColumns===void 0?$:u.maxColumns,b=d.paths.length*Math.max(1,t.length),l=new Map;if(o&&b>o)return{rowAxis:h,columnAxis:d,measures:t.map(K=>({colId:K.colId,fn:K.fn})),body:l,rowMargin:l,columnMargin:l,grand:l,columns:b,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${b} columns, above pivot.maxColumns of ${o}. Narrow the pivot columns or raise the limit.`,columns:b,maxColumns:o}};const p=new Map,w=new Map,v=new Map,R=new Map,Y=d.buckets.map(K=>new Set(K));for(let K=0;K<d.paths.length;K++){const V=d.buckets[K],E=d.paths[K];for(const O of t)v.set(i(E,O.colId),g(O.handle,V,O.fn,m))}for(let K=0;K<h.paths.length;K++){const V=h.buckets[K],E=h.paths[K];for(const O of t)w.set(i(E,O.colId),g(O.handle,V,O.fn,m));for(let O=0;O<d.paths.length;O++){const C=f(V,d.buckets[O],Y[O]);if(C.length===0)continue;const S=d.paths[O];for(const F of t)p.set(r(E,S,F.colId),g(F.handle,C,F.fn,m))}}for(const K of t)R.set(K.colId,g(K.handle,s,K.fn,m));return{rowAxis:h,columnAxis:d,measures:t.map(K=>({colId:K.colId,fn:K.fn})),body:p,rowMargin:w,columnMargin:v,grand:R,columns:b,error:null}}function r(c,u,n){return`${c}\0${u}\0${n}`}function i(c,u){return`${c}\0${u}`}}),Ue("packages/core/src/compute/reference.js",function(e,B){"use strict";Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return a}});const T=B("packages/core/src/internal/paths.js").getPath,G=B("packages/core/src/compute/handle.js"),D=G.isMissing,I=G.valueComparator,z=B("packages/core/src/compute/filter.js").testValue,L="",X="\0";function $(c,u){const n=u.includes(".")?T(c,u):c?.[u];return n===void 0?null:n}function A(c,u,n={}){const m=u||[];let t=c.map((s,h)=>h);if(m.length===0)return t;for(let s=m.length-1;s>=0;s--)t=k(c,t,m[s],n);return t}function k(c,u,n,m){const t=n.locale!==void 0?n.locale:m.locale,s=I(t),h=n.descending!==void 0?!!n.descending:n.dir==="desc",d=[],o=[];for(const p of u){const w=$(c[p],n.col);D(w)?o.push(p):d.push(p)}const b=new Map;for(let p=0;p<d.length;p++)b.set(d[p],p);const l=(p,w)=>{const v=$(c[p],n.col),R=$(c[w],n.col);let Y;return typeof n.compare=="function"?(Y=n.compare(v,R,c[p],c[w],h),h&&(Y=-Y)):Y=h?s(R,v):s(v,R),Y!==0?Y:b.get(p)-b.get(w)};return d.sort(l),n.nullsFirst?o.concat(d):d.concat(o)}function y(c,u,n={}){const m=[];for(let t=0;t<c.length;t++)f(c[t],u,n,t)&&m.push(t);return m}function f(c,u,n,m){if(!u)return!0;if(Array.isArray(u.conditions)){const t=u.conditions.filter(h=>h!=null);if(t.length===0)return!0;if(u.op==="or")return t.some(h=>f(c,h,n,m));const s=t.every(h=>f(c,h,n,m));return u.op==="not"?!s:s}return u.col===void 0&&typeof n.custom=="function"?!!n.custom(u,c,m):z($(c,u.col),u,n.locale)}function g(c,u,n,m){const t=n||c.map((o,b)=>b),s=new Map,h=[],d=[];for(const o of t){const b=u.map((w,v)=>{const R=$(c[o],w);return m&&m[v]?m[v](R):R}),l=b.map(w=>w==null?X:String(w)).join(L);let p=s.get(l);p===void 0&&(p=h.length,s.set(l,p),h.push(b),d.push([])),d[p].push(o)}return{keys:h,buckets:d}}function a(c,u,n={}){const m=I(n.locale),t=c.filter(h=>!D(h)),s=t.map(r).filter(h=>h!==null);switch(u){case"count":return c.length;case"countValues":return t.length;case"sum":return s.reduce((h,d)=>h+d,0);case"avg":return t.length===0?null:s.reduce((h,d)=>h+d,0)/t.length;case"min":return t.length===0?null:t.reduce((h,d)=>m(d,h)<0?d:h);case"max":return t.length===0?null:t.reduce((h,d)=>m(d,h)>0?d:h);case"first":return c.length===0?null:i(c[0]);case"last":return c.length===0?null:i(c[c.length-1]);default:return null}}function r(c){if(typeof c=="number")return Number.isNaN(c)?null:c;if(c==null||c===""||typeof c=="boolean")return null;if(c instanceof Date)return c.getTime();const u=Number(c);return Number.isNaN(u)?null:u}function i(c){return c===void 0?null:c}}),Ue("packages/core/src/compute/index.js",function(e,B){"use strict";const re=B("packages/core/src/compute/sort.js");Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return re.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return re.sortMulti}}),Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return re.radixSortFloat64}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return re.radixSortInt32}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return re.rankSortDictionary}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return re.mergeSortComparator}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return re.collateStringRanks}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return re.rankSortStrings}});const T=B("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return T.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return T.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return T.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return T.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return T.describeSort}});const G=B("packages/core/src/compute/filter.js");Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return G.evaluateFilters}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return G.evaluateCondition}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return G.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return G.testValue}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return G.compilePredicate}}),Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return G.releaseMask}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return G.pruneColumn}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return G.mentionsColumn}});const D=B("packages/core/src/compute/group.js");Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return D.groupByColumns}}),Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return D.packKeys}});const I=B("packages/core/src/compute/facet.js");Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return I.facet}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return I.computeBounds}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return I.countInto}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return I.bucketOf}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return I.facetKind}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return I.cardinalityOf}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return I.pickGranularity}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return I.floorTo}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return I.advance}}),Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return I.STRATEGIES}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return I.GRANULARITIES}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return I.DEFAULT_BUCKETS}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return I.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return I.QUANTILE_SAMPLE}});const Z=B("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 z=B("packages/core/src/compute/pivot.js");Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return z.pivot}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return z.resolvePivotKeys}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return z.pivotKey}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return z.joinPath}}),Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return z.KEY_DELIMITER}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return z.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return z.DEFAULT_MAX_COLUMNS}});const L=B("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return L.pivotMatrix}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return L.resolveAxis}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return L.cellKey}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return L.marginKey}}),Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return L.GRAND_PATH}});const X=B("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 $=B("packages/core/src/compute/handle.js");Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return $.identity}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return $.rowCount}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return $.presenceReader}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return $.bitReader}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return $.valueReader}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return $.valueComparator}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return $.numericTotalOrder}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return $.dictRanks}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return $.dictSize}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return $.dictValue}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return $.multiValue}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return $.isMissing}});const A=B("packages/core/src/compute/sketch.js");Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return A.Welford}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return A.Reservoir}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return A.HyperLogLog}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return A.SpaceSaving}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return A.KLL}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return A.hash32}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return A.SKETCH_BOUNDS}});const k=B("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 y=B("packages/core/src/compute/statistics.js");Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return y.MAINTENANCE}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return y.APPROXIMATE}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return y.maintenanceOf}});const f=B("packages/core/src/compute/anomaly.js");Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return f.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return f.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return f.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return f.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return f.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return f.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return f.anomalyCondition}});const g=B("packages/core/src/compute/forecast.js");Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return g.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return g.forecast}})}),Ue("packages/core/src/source/rows.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_ROW_HEIGHT",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"KEY_SEP",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"createRowFactory",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"RowFactory",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"pinnedRow",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"lazyRowView",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"groupPathElement",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"groupKey",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"groupPrefixKeys",{enumerable:!0,get:function(){return g}});const T=B("packages/core/src/internal/warn.js").warnOnce,D=B("packages/core/src/internal/predicates.js").isFunction,I=32,Z="\0";function z(a){return new L(a)}class L{#e;#t;constructor(r){this.#e=D(r&&r.rowKey)?r.rowKey:null;const i=r&&r.config?r.config.rowHeight:void 0;this.#t=typeof i=="number"||D(i)?i:I}get keyed(){return this.#e!==null}keyOf(r,i){if(this.#e){const c=this.#e(r);if(c!=null)return String(c)}else T("source.rowKey.missing","no config.rowKey; falling back to index identity.","Row changes, streaming dedupe, selection persistence and remote reload are disabled.");return`#${i}`}heightOf(r){return D(this.#t)?Number(this.#t(r))||I:this.#t}leaf(r,i,c=0,u=null){const n={key:this.keyOf(r,i),data:r,level:c,parent:u,group:!1,expanded:!1,leafCount:1,height:0,index:null,selected:!1,physical:i};return n.height=this.heightOf(n),n}group(r){const i={key:f(r.keyPath||r.path),data:null,level:r.level,parent:r.parent||null,children:[],group:!0,expanded:r.expanded!==!1,leafCount:r.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:r.column,groupValue:r.value,groupPath:r.path,hasChildren:r.hasChildren!==!1};return r.totals&&(i.totals=r.totals),i.height=this.heightOf(i),i}footer(r){const i={key:`${r.key}${Z}footer`,data:null,level:r.level,parent:r,group:!0,footer:!0,expanded:!1,leafCount:r.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:r.groupColumn,groupValue:r.groupValue,groupPath:r.groupPath,hasChildren:!1,totals:r.totals};return i.height=this.heightOf(i),i}detail(r,i){return{key:`${r.key}${Z}detail`,data:r.data,level:r.level+1,parent:r,group:!1,detail:!0,expanded:!1,leafCount:0,height:i,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:r.key}}grandTotal(r,i){const c={key:`${Z}grandTotal`,data:null,level:0,parent:null,group:!0,grandTotal:!0,expanded:!1,leafCount:i,height:0,index:null,selected:!1,physical:null,groupPath:[],hasChildren:!1,totals:r};return c.height=this.heightOf(c),c}skeleton(r,i=0,c=!1){const u={key:`${Z}pending${Z}${r}`,data:null,level:i,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:r,selected:!1,physical:null,pending:!0};return c&&(u.loadError=!0),u.height=this.heightOf(u),u}}function X(a,r,i,c){return{key:`${Z}pinned${Z}${i}${Z}${r}`,data:a,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:c,index:null,selected:!1,physical:null,hasChildren:!1,pinned:i}}function $(a,r){return new Proxy([],{get(i,c,u){if(c==="length")return a();if(typeof c=="string"){const n=Number(c);if(Number.isInteger(n)&&n>=0)return r(n)}return Reflect.get(i,c,u)},has(i,c){if(typeof c=="string"){const u=Number(c);if(Number.isInteger(u)&&u>=0)return u<a()}return Reflect.has(i,c)}})}function A(a){return a==null?"":String(a)}const k="";function y(a){if(a==null)return k;const r=String(a);return r.startsWith(k)?k+r:r}function f(a){const r=a||[];let i="g";for(let c=0;c<r.length;c++)i+=Z+y(r[c]);return i}function g(a){const r=new Array(a.length),i=[];for(let c=0;c<a.length;c++)i.push(a[c]),r[c]=f(i);return r}}),Ue("packages/core/src/source/handles.js",function(e,B){"use strict";Object.defineProperty(e,"HandleProvider",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"createHandleProvider",{enumerable:!0,get:function(){return Z}});const T=B("packages/core/src/internal/predicates.js").isFunction,D=B("packages/core/src/internal/warn.js").warnOnce;class I{#e;#t;#n;#r=new Map;#i=0;constructor(L,X,$){this.#e=L,this.#t=X,this.#n=T($)?$:()=>!1}get store(){const L=this.#e.store;return L&&T(L.column)?L:null}invalidate(){this.#i++}handle(L){const X=this.store;if(X){const y=X.column(L);if(y)return y}const $=this.#r.get(L);if($&&$.builtAt===this.#i)return $.handle;const A=this.#s(L);if(!A)return;if(X&&this.#n()){D(`source.dropped.${L}`,`column "${L}" 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.#a(A);return this.#r.set(L,{handle:k,builtAt:this.#i}),k}#s(L){const X=this.#e.columns;return X&&T(X.get)?X.get(L):void 0}#a(L){const X=this.#t()||[],$=X.length,A=new Array($),k=T(L.getValue)?f=>L.getValue(f):f=>f?.[L.field||L.id];for(let f=0;f<$;f++)A[f]=X[f]===void 0?void 0:k(X[f]);const y=this.#i;return{id:L.id,kind:"object",nullable:!1,values:A,presence:null,dict:null,offsets:null,get(f){return A[f]},version:y}}}function Z(z,L,X){return new I(z,L,X)}}),Ue("packages/core/src/compute/incremental.js",function(e,B){"use strict";Object.defineProperty(e,"INCREMENTAL_FNS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"INCREMENTAL_KINDS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"MAGNITUDE_LIMIT",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"isIncremental",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"RunningTotal",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const T=B("packages/core/src/store/columnstore.js").toFloat,G=Object.freeze(["sum","avg","countValues","min","max"]),D=Object.freeze(["float64"]),I=1e15;function Z($,A){return typeof $!="string"||!G.includes($)?!1:!!A&&D.includes(A.kind)}function z($){if($==null)return null;const A=T($);return Number.isNaN(A)?null:A}class L{#e;#t=0;#n=0;#r=0;#i=1/0;#s=-1/0;#a=!1;#l=!1;constructor(A){this.#e=A}get valid(){return this.#a&&!this.#l}get fn(){return this.#e}seed(A){this.#o();for(let k=0;k<A.length;k++){const y=z(A[k]);y!==null&&this.#c(y)}this.#a=!0}seedColumn(A,k,y){this.#o();for(let f=0;f<y.length;f++){const g=y[f];if(k&&k(g)===0)continue;const a=A[g];Number.isNaN(a)||this.#c(a)}this.#a=!0}#o(){this.#t=0,this.#n=0,this.#r=0,this.#i=1/0,this.#s=-1/0,this.#l=!1}#c(A){if(!Number.isFinite(A)){this.#l=!0;return}const k=this.#t+A;this.#n+=Math.abs(this.#t)>=Math.abs(A)?this.#t-k+A:A-k+this.#t,this.#t=k,this.#r++,A<this.#i&&(this.#i=A),A>this.#s&&(this.#s=A)}#u(A){const k=this.#t-A;this.#n+=Math.abs(this.#t)>=Math.abs(A)?this.#t-k-A:-A-k+this.#t,this.#t=k,this.#r--}update(A,k){if(!this.#a)return!1;const y=z(A),f=z(k);return y===null&&f===null?!0:y!==null&&!Number.isFinite(y)||f!==null&&!Number.isFinite(f)?!1:this.#e==="min"||this.#e==="max"?y===null||f===null?!1:this.#e==="min"?f<this.#i?(this.#i=f,!0):y>this.#i:f>this.#s?(this.#s=f,!0):y<this.#s:Math.abs(this.#t)>I?!1:(y!==null&&this.#u(y),f!==null&&this.#c(f),!0)}value(){switch(this.#e){case"countValues":return this.#r;case"avg":return this.#r?(this.#t+this.#n)/this.#r:null;case"min":return this.#r?this.#i:null;case"max":return this.#r?this.#s:null;default:return this.#t+this.#n}}invalidate(){this.#a=!1}}const X=L}),Ue("packages/core/src/source/filterwire.js",function(e,B){"use strict";Object.defineProperty(e,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"warnWherePageRelative",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"warnWhereNotApplied",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"warnWhereOverThreshold",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"parseRelativeToken",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"resolveRelativeRange",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"relativeTokenOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"relativeTokenHelp",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"isResolvableRelative",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"resolveRelativeCondition",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"isGroup",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"forEachCondition",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"mapConditions",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normaliseFilterSet",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"buildFilterSet",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"wireFilters",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"querySignature",{enumerable:!0,get:function(){return v}});const T=B("packages/core/src/internal/warn.js").warnOnce,G="source.remote.hostFilter",D="source.where.pageRelative";function I(K,V){!Array.isArray(K)||!K.length||T(D,`filters.where (${K.join(", ")}) runs over the rows the ${V} 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(K){const V=(K||{}).config;!V||!V.hostFilter||T(G,"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 z="source.where.notApplied";function L(K,V){T(`${z}:${K}`,`filters.where("${K}") is registered but the ${V} 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 $(K,V,E,O){!Array.isArray(K)||!K.length||T(`${X}:${V}`,`filters.where (${K.join(", ")}) is not applied to the ${V} pushdown source:`,E===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${E.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 A=new Map;function k(K){let V=A.get(K);return V||(V=new Intl.DateTimeFormat("en-US",{timeZone:K,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),A.set(K,V)),V}function y(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function f(K,V){const E=k(V).formatToParts(new Date(K)),O={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const C of E)C.type==="year"?O.y=+C.value:C.type==="month"?O.m=+C.value:C.type==="day"?O.d=+C.value:C.type==="hour"?O.h=+C.value%24:C.type==="minute"?O.mi=+C.value:C.type==="second"&&(O.s=+C.value);return O}function g(K,V){const E=f(K,V);return Date.UTC(E.y,E.m-1,E.d,E.h,E.mi,E.s)-Math.floor(K/1e3)*1e3}function a(K,V,E,O){const C=Date.UTC(K,V-1,E),S=C-g(C,O);return C-g(S,O)}function r(K,V,E){const O=new Date(Date.UTC(K.y,K.m-1,K.d+V));return a(O.getUTCFullYear(),O.getUTCMonth()+1,O.getUTCDate(),E)}const i=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function c(K,V){if(typeof K!="string")return null;const E=K.trim().toLowerCase().replace(/[\s_-]+/g,""),O=/^last(\d*|n)days?$/.exec(E);if(O){const C=O[1]==="n"?"":O[1],S=Number(C||V);return!Number.isFinite(S)||S<=0?null:{kind:"lastNDays",n:Math.floor(S)}}switch(E){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 u(K,V={}){const E=c(K,V.n);if(!E)return null;const O=V.tz||y(),C=V.now instanceof Date?V.now.getTime():typeof V.now=="number"?V.now:Date.now(),S=f(C,O),F=a(S.y,S.m,S.d,O),P=r(S,1,O);let M=F,x=P;switch(E.kind){case"today":break;case"yesterday":M=r(S,-1,O),x=F;break;case"lastNDays":x=V.includeToday?P:F,M=r(S,V.includeToday?-(E.n-1):-E.n,O);break;case"thisWeek":{const U=Number.isFinite(V.weekStartsOn)?Number(V.weekStartsOn):1,W=(new Date(Date.UTC(S.y,S.m-1,S.d)).getUTCDay()-U+7)%7;M=r(S,-W,O),x=r(S,-W+7,O);break}case"thisMonth":M=a(S.y,S.m,1,O),x=a(S.m===12?S.y+1:S.y,S.m===12?1:S.m+1,1,O);break;case"thisQuarter":case"quarterToDate":{const U=Math.floor((S.m-1)/3)*3+1;M=a(S.y,U,1,O),x=E.kind==="quarterToDate"?P:U===10?a(S.y+1,1,1,O):a(S.y,U+3,1,O);break}case"thisYear":case"yearToDate":M=a(S.y,1,1,O),x=E.kind==="yearToDate"?P:a(S.y+1,1,1,O);break;default:return null}return{from:new Date(M).toISOString(),to:new Date(x).toISOString(),bounds:"[)",tz:O,relative:E.kind==="lastNDays"?`last${E.n}Days`:E.kind,n:E.n}}function n(K){if(!K||typeof K!="object")return null;const V=K.value;if(V&&typeof V=="object"&&!Array.isArray(V)&&"relative"in V)return{token:String(V.relative),n:typeof V.n=="number"?V.n:void 0};if(K.op==="relative"&&typeof K.value=="string")return{token:K.value,n:void 0};const E=K.meta;return E&&typeof E.relative=="string"&&K.value===void 0?{token:E.relative,n:typeof E.n=="number"?E.n:void 0}:null}function m(){return`Known tokens: ${i.filter(V=>V!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function t(K){const V=n(K);return V?c(V.token,V.n)!==null:!1}function s(K,V={}){const E=n(K);if(!E)return K;const O=u(E.token,{...V,n:E.n});return O?{...K,type:K.type||"date",op:"between",value:[O.from,O.to],bounds:K.bounds||O.bounds,meta:{...K.meta||{},relative:O.relative,tz:O.tz}}:(T(`source.relative.${E.token}`,`unknown relative date token "${E.token}"; sending the condition unresolved.`,m()),K)}function h(K){return!!K&&typeof K=="object"&&Array.isArray(K.conditions)}function d(K,V){if(K){if(h(K)){for(const E of K.conditions)d(E,V);return}V(K)}}function o(K,V){if(!K)return null;if(!h(K))return V(K);const E=K;let O=!1;const C=[];for(const S of E.conditions){const F=o(S,V);F!==S&&(O=!0),F&&C.push(F)}return!O&&C.length===E.conditions.length?K:C.length?{...E,conditions:C}:null}function b(K){if(!K)return null;if(!h(K))return K;const V=K,E=[];for(const O of V.conditions){const C=b(O);C&&E.push(C)}return E.length?{op:V.op,conditions:E}:null}function l(K){const V=b(K);return V?h(V)&&V.op==="and"?V:{op:"and",conditions:[V]}:null}function p(K){const V=(K||[]).filter(Boolean);return V.length?{op:"and",conditions:V}:null}function w(K,V={}){const E=o(K,O=>s(O,V));return l(E)}function v(K){const V=R(K.filters??null);return JSON.stringify([V,K.sort??null,K.quick??"",K.groupBy??null,K.pivotBy??null,Y(K.context)])}function R(K){if(!K)return null;if(h(K)){const O=K;return{op:O.op,conditions:O.conditions.map(R)}}const V=K,E=V.meta&&typeof V.meta.relative=="string"?V.meta.relative:n(V)?.token;return{col:V.col,op:V.op,bounds:V.bounds??null,caseSensitive:V.caseSensitive??!1,value:E?`rel:${E}`:V.value??null}}function Y(K){if(K==null)return null;try{return JSON.parse(JSON.stringify(K))}catch{return T("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),Ue("packages/core/src/source/tree.js",function(e,B){"use strict";Object.defineProperty(e,"SYNTHETIC",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"buildFromPath",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"buildFromParentKey",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"assignLevels",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"resolveTree",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"buildTree",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return f}});const T=B("packages/core/src/internal/predicates.js").isFunction,D=B("packages/core/src/internal/warn.js").warnOnce,I="",Z="\0tree:";function z(g,a){return{physical:g,key:a,level:0,children:[],value:void 0}}function L(g,a){const r=[],i=new Map;for(let c=0;c<g.length;c++){const u=g[c],n=a.pathOf(u),m=Array.isArray(n)?n.map(s=>String(s)):[];if(!m.length){const s=z(u,a.keyOf(u));r.push(s);continue}let t=null;for(let s=0;s<m.length;s++){const h=m.slice(0,s+1).join(I),d=s===m.length-1;let o=i.get(h);o&&d&&o.physical===-1&&(o.physical=u,o.key=a.keyOf(u)),o||(o=z(d?u:-1,d?a.keyOf(u):Z+h),o.level=s,o.value=m[s],i.set(h,o),t?t.children.push(o):r.push(o)),t=o}}return{roots:r,nodes:i}}function X(g,a){const r=new Map,i=[];for(let m=0;m<g.length;m++){const t=g[m],s=a.keyOf(t),h=z(t,s);r.set(s,h);const d=a.parentOf(t);d!=null&&d!==""&&i.push({node:h,parent:String(d)})}let c=null;const u=new Map;for(const{node:m,parent:t}of i){const s=r.get(t);if(s){u.set(m.key,s);continue}a.orphans&&a.orphans!=="root"&&(c||(c=z(-1,`${Z}orphans`),c.value=a.orphans),u.set(m.key,c))}const n=[];for(const m of r.values()){const t=u.get(m.key);t?t.children.push(m):n.push(m)}return c&&c.children.length&&n.push(c),{roots:$(n,r,a.orphans,c),nodes:r}}function $(g,a,r,i){const c=new Set,u=[...g];for(;u.length;){const h=u.pop();if(!c.has(h.key)){c.add(h.key);for(const d of h.children)u.push(d)}}const n=[];for(const h of a.values())c.has(h.key)||n.push(h);if(!n.length)return g;const m=!!r&&r!=="root";D("tree.cycle",`tree.parentKey produced ${n.length} row(s) inside a parent cycle; `+(m?`they are shown under "${r}".`:"they are shown at the root."));for(const h of n)h.children=h.children.filter(d=>c.has(d.key));if(!m)return[...g,...n];let t=i;const s=[...g];return t||(t=z(-1,`${Z}orphans`),t.value=r,s.push(t)),t.children.push(...n),s}function A(g){let a=0;const r=(i,c)=>{for(const u of i)u.level=c,c>a&&(a=c),u.children.length&&r(u.children,c+1)};return r(g,0),a}function k(g,a){if(!g||typeof g!="object")return null;const r=g.path,i=g.parentKey,c=T(g.hasChildren)?u=>!!g.hasChildren(a.dataAt(u)):null;if(T(r))return{mode:"path",pathOf:u=>r(a.dataAt(u)),keyOf:a.keyOf,declaresChildren:c};if(i!=null){const u=T(i)?i:n=>n?.[i];return{mode:"parentKey",parentOf:n=>u(a.dataAt(n)),keyOf:a.keyOf,orphans:g.orphans||"root",declaresChildren:c}}return D("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function y(g,a){const r=a.mode==="path"?L(g,a):X(g,a),i=A(r.roots);return{...r,depth:i}}function f(g,a){const r=new Map,i=c=>{for(let u=0;u<c.length;u++){const n=c[u];if(n.physical>=0){const m=a?a(n.physical):!1,t=m&&n.children.length===0;r.set(n.physical,{level:n.level,posinset:u+1,setsize:c.length,hasChildren:n.children.length>0||m,lazy:t})}n.children.length&&i(n.children)}};return i(g),r}}),Ue("packages/core/src/source/settle.js",function(e,B){"use strict";Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"ARRIVAL_REASONS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"isArrival",{enumerable:!0,get:function(){return D}});const re=Object.freeze(["pipeline:sort","pipeline:sort:error"]);function T(I){const Z=I&&typeof I=="object"?I.reason:null;return typeof Z=="string"&&re.includes(Z)}const G=Object.freeze(["page","total"]);function D(I){const Z=I&&typeof I=="object"?I.reason:null;return typeof Z=="string"&&G.includes(Z)}}),Ue("packages/core/src/source/memory.js",function(e,B){"use strict";Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"quickMatcher",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"MemorySource",{enumerable:!0,get:function(){return W}});const T=B("packages/core/src/internal/lru.js").Lru,G=B("packages/core/src/internal/warn.js"),D=G.warnOnce,I=G.fail,z=B("packages/core/src/internal/predicates.js").isFunction,X=B("packages/core/src/internal/compare.js").defaultCompare,A=B("packages/core/src/internal/merge.js").mergeRow,k=B("packages/core/src/source/rows.js"),y=k.createRowFactory,f=k.groupKey,g=k.groupPathElement,a=k.groupPrefixKeys,r=k.lazyRowView,c=B("packages/core/src/source/handles.js").createHandleProvider,u=B("packages/core/src/compute/incremental.js"),n=u.RunningTotal,m=u.isIncremental,s=B("packages/core/src/compute/handle.js").presenceReader,h=B("packages/core/src/source/filterwire.js"),d=h.querySignature,o=h.mapConditions,b=h.resolveRelativeCondition,l=B("packages/core/src/source/tree.js"),p=l.buildTree,w=l.resolveTree,v=l.indexTree,R=B("packages/core/src/source/settle.js"),Y=R.PIPELINE_SETTLE_REASONS,K=R.isPipelineSettle,V=Object.freeze(["filter","sort","group","total","pivot","flatten"]),E=Object.freeze([]);function O(q,N){if(!q)return null;const Q=N==="grand"?q.grandTotal:q.groupTotal;return Q??q.total}function C(q){return!!q&&!q.running}function S(q){if(q)return q.value&&z(q.value.compare)?q.value.compare:z(q.compare)?q.compare:void 0}function F(q){const N=q&&q.dataType;return!N||!z(N.items)?null:{items:N.items,type:q.itemType&&q.itemType.name||"text"}}function P(q){return!!q&&(typeof q=="object"||typeof q=="function")&&z(q.then)}const M=new Uint32Array(0),x=4096;function U(q,N){return new W(q,N)}function _(q,N){if(N==="regex")try{const Q=new RegExp(q,"iu");return J=>Q.test(J)}catch{return Q=>Q.includes(q)}if(N==="fuzzy"){const Q=[...q].filter(J=>J!==" ");return Q.length?J=>{let ee=0;for(let ne=0;ne<J.length&&ee<Q.length;ne++)J[ne]===Q[ee]&&ee++;return ee===Q.length}:()=>!0}if(N==="words"){const Q=q.split(/\s+/).filter(Boolean);return Q.length?J=>Q.every(ee=>J.includes(ee)):()=>!0}return Q=>Q.includes(q)}class W{mode="memory";#e;#t;#n;#r=!1;#i=null;#s;#a;#l=new Map;#o=!1;#c=0;#u=0;#f=new Map;#d=new Map;#h;#p=null;#m=W.#g();static#g(){return{slots:[],groupHeadings:E,unnumbered:E,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;#I=null;#G=null;#K=Symbol("unset");#L=new Map;#q=null;get#U(){return this.#m.slots}set#U(N){this.#m.slots=N}get#Y(){return this.#m.inlineLeaves}set#Y(N){this.#m.inlineLeaves=N}get#z(){return this.#m.groupHeadings}set#z(N){this.#m.groupHeadings=N}get#D(){return this.#m.unnumbered}set#D(N){this.#m.unnumbered=N}get#V(){return this.#m.pivot}set#V(N){this.#m.pivot=N}constructor(N,Q){this.#t=N||{mode:"memory"},this.#e=Q||{};const J=this.#e.config||{};this.#n=this.#t.rows||J.rows||[],this.#s=y(this.#e),this.#a=c(this.#e,()=>this.#n,()=>this.#r),this.#h=new T(Number(J.rowCacheSize)||x);for(const ee of V)this.#l.set(ee,{key:null,result:null,id:0,computed:!1})}count(){this.#B();const N=this.#ge();return N?N.length:this.#U.length}#ge(){const N=Number(this.#_("pageSize",0))||0;if(N<=0)return null;const Q=this.#U.length,J=Math.max(1,Math.ceil(Q/N)),ne=Math.min(Math.max(0,Number(this.#_("page",0))||0),J-1)*N;return{offset:ne,length:Math.max(0,Math.min(N,Q-ne))}}pageInfo(){this.#B();const N=Number(this.#_("pageSize",0))||0,Q=this.#U.length;if(N<=0)return{page:0,pageSize:0,total:Q,pageCount:1};const J=Math.max(1,Math.ceil(Q/N));return{page:Math.min(Math.max(0,Number(this.#_("page",0))||0),J-1),pageSize:N,total:Q,pageCount:J}}totalCount(){return this.#et().length}matchCount(){return this.#B(),this.#m.matchCount}at(N){this.#B();const Q=this.#ge();if(Q)return N<0||N>=Q.length?void 0:this.#_e(Q.offset+N,N);if(!(N<0||N>=this.#U.length))return this.#_e(N,N)}byKey(N){this.#B(),this.#p||this.#Ae();const Q=this.#p.get(N);if(Q!==void 0)return this.#ce(Q);for(let J=0;J<this.#U.length;J++){const ee=this.#U[J];if(typeof ee!="number"&&ee&&ee.key===N)return this.#_e(J)}}loaded(N){return N>=0&&N<this.count()}hint(N,Q){}display(){return this.#B(),this.#q||(this.#q=this.#$e()),this.#q}invalidateQuickText(){this.#L.clear(),this.invalidate("filter")}invalidate(N){const Q=V.indexOf(N);Q<0&&I(`unknown pipeline stage "${N}"; expected one of ${V.join(", ")}`);for(let J=Q;J<V.length;J++){const ee=this.#l.get(V[J]);ee.key=null,ee.computed=!1}this.#q=null}apply(N){const Q=[],J={added:[],updated:[],removed:[],rejected:Q};if(!N)return J;let ee=!1;const ne=new Set;if(N.remove&&N.remove.length)for(const se of N.remove){const le=this.#Ce(se);if(le===void 0){Q.push({operation:"remove",id:this.#He(se),reason:"unknown-id"});continue}J.removed.push(this.#s.keyOf(this.#r?this.#Qe(le):this.#n[le],le)),this.#r||(this.#n[le]=void 0),this.#h.delete(le),this.#L.delete(le),ee=!0}if(N.update&&N.update.length){const se=this.#O.size||this.#at()?this.#Ke():null,le=this.#v.size?this.#ht():null,ye=le&&le.length?this.#Ke():null;for(const fe of N.update){const we=this.#Ce(fe);if(we===void 0){Q.push({operation:"update",id:this.#xe(fe),reason:"unknown-id"});continue}const ke=this.#r?this.#i&&this.#i.has(we)?this.#i.get(we):this.#Qe(we):this.#n[we],Ce=A(ke,fe);for(const ce of this.#le(ke,Ce))ne.add(ce);if(this.#r||(this.#n[we]=Ce),se&&this.#Je(se,we,ke,Ce),ye&&this.#We(le,ye,we,ke,Ce),this.#p){const ce=this.#s.keyOf(ke,we),ae=this.#s.keyOf(Ce,we);ce!==ae&&(this.#p.delete(ce),this.#p.set(ae,we))}this.#h.delete(we),this.#L.delete(we),J.updated.push(this.#ce(we))}}if(N.add&&N.add.length&&this.#r){typeof N.at=="number"&&N.at<this.#j()&&(this.#h.clear(),this.#L.clear()),this.#p=null;for(const se of N.add){const le=this.#ae(this.#xe(se));le!==void 0&&J.added.push(this.#ce(le))}ee=!0}else if(N.add&&N.add.length){let se=typeof N.at=="number"?N.at:this.#n.length;if(se<this.#n.length){let fe=0;for(let we=0;we<this.#n.length;we++)this.#n[we]!==void 0&&fe++;if(fe!==this.#n.length){let we=0;for(let ke=0;ke<this.#n.length;ke++)this.#n[ke]!==void 0&&(this.#n[we++]=this.#n[ke]);this.#n.length=we,this.#p=null,this.#h.clear(),this.#L.clear()}}const le=this.#n.length;se=Math.max(0,se);let ye=N.add===this.#n?N.add.slice():N.add;if(this.#s.keyed){const fe=[];for(const we of ye){const ke=this.#xe(we);if(this.#Ce(ke)!==void 0){Q.push({operation:"add",id:ke,reason:"duplicate-id"});continue}fe.push(we)}fe.length!==ye.length&&(ye=fe)}if(!ye.length)return J;if(se>=le)for(let fe=0;fe<ye.length;fe++)this.#n.push(ye[fe]);else this.#n.splice(se,0,...ye),this.#h.clear(),this.#L.clear();for(let fe=0;fe<ye.length;fe++)J.added.push(this.#ce(se>=le?le+fe:se+fe));ee=!0}return this.#c++,ee&&(this.#p=null,this.#lt()),this.#a.invalidate(),this.#q=null,ee||this.#ne(ne)?(this.#u++,this.invalidate("filter")):this.invalidate("total"),this.#bt("rows:changed",{companion:!0,added:J.added.length,updated:J.updated.length,removed:J.removed.length}),this.#i=null,J}groupHeadingsAt(N){this.#B();const Q=this.#z;if(!Q.length||!Number.isInteger(N)||N<0)return E;let J=0,ee=Q.length-1,ne=-1;for(;J<=ee;){const le=J+ee>>1;Q[le].at<=N?(ne=le,J=le+1):ee=le-1}if(ne<0)return E;const se=[];for(let le=Q[ne].row;le;le=le.parent)se.push(le);return se.reverse(),se}unnumberedRowCount(N){this.#B();const Q=this.#D;if(!Q.length||!Number.isInteger(N)||N<0)return 0;let J=0,ee=Q.length-1,ne=-1;for(;J<=ee;){const se=J+ee>>1;Q[se].at<=N?(ne=se,J=se+1):ee=se-1}return ne+1}moveRow(N,Q){if(this.#r)return D("source.moveRow.dropped","rows.move() is not supported under ingest.dropSourceRows: the source objects have been released and the store cannot reorder its columns in place. Enable retainSource (leave dropSourceRows off) to reorder rows."),!1;const J=this.#n;if(!Number.isInteger(N)||!Number.isInteger(Q))return!1;let ee=0;for(let le=0;le<J.length;le++)J[le]!==void 0&&ee++;if(N<0||N>=ee)return!1;const ne=Math.max(0,Math.min(ee-1,Q));if(ne===N)return!1;if(ee!==J.length){let le=0;for(let ye=0;ye<J.length;ye++)J[ye]!==void 0&&(J[le++]=J[ye]);J.length=le}const[se]=J.splice(N,1);return J.splice(ne,0,se),this.#c++,this.#u++,this.#p=null,this.#h.clear(),this.#L.clear(),this.#lt(),this.#a.invalidate(),this.#q=null,this.invalidate("filter"),this.#bt("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(N){this.#ue(),this.#c++,this.#u++,this.#p=null,this.#L.clear(),this.#h.clear(),this.#lt(),this.#a.invalidate(),this.invalidate("filter"),this.#bt("model:changed",{reason:"reload"})}destroy(){this.#ue(),this.#h.clear(),this.#L.clear(),this.#p=null,this.#U=[],this.#Y=null,this.#q=null,this.#lt();for(const N of V)this.#l.set(N,{key:null,result:null,id:0,computed:!1})}#se(N){const Q=this.#e.sortPending;z(Q)&&Q(N)}#ue(){this.#b.has("sort")&&this.#se(!1);for(const{controller:N}of this.#b.values())try{N.abort()}catch{}this.#b.clear()}setRows(N){this.#n=N||[],this.#r=!1,this.#c++,this.#u++,this.#p=null,this.#L.clear(),this.#h.clear(),this.#lt(),this.#a.invalidate(),this.invalidate("filter")}notePriorRows(N){this.#i=N||null}releaseSource(){this.#r=!0,this.#n=[],this.#p=null,this.#h.clear(),this.#L.clear(),this.#a.invalidate()}data(){if(!this.#r)return this.#n;const N=this.#e.store;if(!N||!z(N.source))return this.#n;const Q=N.physical||0,J=new Array(Q);for(let ee=0;ee<Q;ee++)J[ee]=N.live&&!N.live(ee)?void 0:N.source(ee);return J}#Me(){const N=this.#_("detail",null);return!N||!z(N.isOpen)||N.inline===!1?null:N}#fe(){const N=(this.#e.config||{}).tree;return this.#K!==N&&(this.#K=N,this.#G=w(N,{dataAt:Q=>this.#Qe(Q),keyOf:Q=>this.#s.keyOf(this.#Qe(Q),Q)})),this.#G}#oe(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#oe())return null;this.#B();const N=this.#m.grand;return N?this.#s.grandTotal(N,this.#te(this.#m.grandLeaves)):null}pivot(){return this.#B(),this.#V}pivotMatrix(){this.#B();const N=this.#m.groupLeaves,Q=(this.#e.compute||{}).pivotMatrix;if(!z(Q))return null;const J=this.#_("groupBy",[]),ee=this.#_("pivotBy",[]);if(!J.length&&!ee.length)return D("pivotView.no-dimension","pivotView is on but the grid has no pivot dimension, so there is no matrix to draw. Put a column on the pivot (its `pivot` setting, or `pivotBy` in the query) for the columns across the top, and group by a column for the rows down the side."),null;const ne=this.#Ke().map(le=>({colId:le.id,handle:this.#a.handle(le.id),fn:O(le,"group")})).filter(le=>le.handle&&le.fn),se=this.#e.config||{};return Q({rowHandles:J.map(le=>this.#a.handle(le)).filter(Boolean),columnHandles:ee.map(le=>this.#a.handle(le)).filter(Boolean),measures:ne,leaves:N||new Uint32Array(0),opts:{locale:se.locale,separator:(se.pivot||{}).separator,maxColumns:(se.pivot||{}).maxColumns}})}keysForLeaves(N){const Q=[];if(!N)return Q;for(let J=0;J<N.length;J++){const ee=this.#ce(N[J]);ee&&ee.key!=null&&Q.push(String(ee.key))}return Q}leavesOf(N){this.#B();const Q=this.#l.get("group"),J=Q&&Q.result;if(!J||!J.nodes)return[];const ee=J.nodes.get(N);if(!ee)return[];const ne=[],se=le=>{const ye=le.row&&le.row.children;if(ye&&ye.length){for(const fe of ye){const we=J.nodes.get(fe.key);we&&se(we)}return}if(le.leaves)for(let fe=0;fe<le.leaves.length;fe++)ne.push(this.#ce(le.leaves[fe]))};return se(ee),ne}#He(N){return typeof N=="string"?N:this.#xe(N)}#xe(N){try{return this.#s.keyOf(N,-1)}catch{return"(unkeyed)"}}#Ce(N){if(typeof N=="string")return this.#ae(N);if(this.#s.keyed){const J=this.#s.keyOf(N,-1),ee=this.#ae(J);if(ee!==void 0)return ee}if(this.#r)return;const Q=this.#n.indexOf(N);return Q>=0?Q:void 0}#ae(N){return this.#p||this.#Ae(),this.#p.get(N)}#Ae(){this.#p=new Map;const N=this.#j(),Q=this.#e.store,J=Q&&z(Q.live)?ee=>Q.live(ee):null;for(let ee=0;ee<N;ee++){if(J&&!J(ee))continue;const ne=this.#Qe(ee);ne!==void 0&&this.#p.set(this.#s.keyOf(ne,ee),ee)}}#le(N,Q){const J=[];for(const ee of this.#W())this.#Be(ee)&&this.#Z(ee,N,Q,new Set)&&J.push(ee);return J}#Z(N,Q,J,ee){if(ee.has(N))return!1;ee.add(N);const ne=this.#Be(N);if(!ne)return!1;const se=ne.value&&ne.value.deps;return Array.isArray(se)&&se.length?se.some(le=>this.#Z(String(le),Q,J,ee)):z(ne.getValue)?!Object.is(ne.getValue(Q),ne.getValue(J)):!1}#W(){const N=new Set;for(const J of this.#_("sort",[]))N.add(J.col);for(const J of this.#_("groupBy",[]))N.add(J);const Q=J=>{if(J){if(Array.isArray(J.conditions)){J.conditions.forEach(Q);return}J.col&&N.add(J.col)}};return Q(this.#_("filters",null)),[...N]}#ne(N){if(!N.size)return!1;if(this.#_("quick",""))return!0;for(const Q of this.#W())if(N.has(Q))return!0;return!1}#B(){if(!this.#o){this.#o=!0;try{this.#Ee()}finally{this.#o=!1}}}pipelineRunning(){return this.#o}#Ee(){const N=this.#de("filter",()=>this.#$(),()=>this.#Ve()),Q=this.#re(N),J=this.#de("group",()=>this.#F(),()=>this.#Fe(Q)),ee=this.#de("total",()=>this.#ke(),()=>this.#qe(J));this.#de("pivot",()=>this.#ee(),()=>this.#Ge(J)),this.#de("flatten",()=>this.#Le(),()=>this.#kt(J)),this.#ye(J,ee)}#re(N){const Q=this.#l.get("sort"),J=this.#H();if(Q.computed&&Q.key===J&&!this.#b.has("sort"))return Q.result;const ee=this.#b.get("sort");return ee&&ee.key===J?Q.result:Q.result&&this.#Te(N)?(this.#we(N,J),Q.result):this.#de("sort",()=>J,()=>this.#k(N))}#pe(){if(this.#y===null){const N=this.#e.pipelineWorker,Q=z(N)?N():null;this.#y=Q||!1}return this.#y||null}#be(){const N=this.#_("sort",[]);if(!Array.isArray(N)||!N.length)return null;const Q=(this.#e.config||{}).locale,J=[],ee=[];for(const ne of N){const se=this.#Be(ne.col);if(se&&se.running)continue;if(se&&se.value&&z(se.value.compare))return null;const le=this.#a.handle(ne.col);if(!le)return null;J.push({col:ne.col,descending:ne.dir==="desc",nullsFirst:!!ne.nullsFirst,locale:Q}),ee.push(le)}return J.length?{entries:J,handles:ee,locale:Q}:null}#Te(N){if(this.#he())return!1;const Q=this.#pe();if(!Q)return!1;const J=Number(Q.threshold);return Number.isFinite(J)&&N.length<J?!1:!!this.#be()}#we(N,Q){const J=this.#pe(),ee=J&&this.#be();if(!ee){this.#de("sort",()=>Q,()=>this.#k(N));return}const ne=new AbortController;this.#b.set("sort",{key:Q,controller:ne});const se=ee.entries.length===1?J.sortColumn(ee.handles[0],N,{descending:ee.entries[0].descending,nullsFirst:ee.entries[0].nullsFirst,locale:ee.locale,signal:ne.signal,key:"sort"}):J.sortMulti(ee.handles,ee.entries.map((le,ye)=>({...le,handle:ee.handles[ye]})),N,{signal:ne.signal,key:"sort"});if(!P(se)){this.#b.delete("sort"),this.#de("sort",()=>Q,()=>se),this.#se(!1);return}this.#se(!0),se.then(le=>this.#ve(Q,le),le=>this.#Se("sort",Q,le))}#ve(N,Q){const J=this.#b.get("sort");if(!(!J||J.key!==N)){if(this.#H()!==N){this.#b.delete("sort"),this.#se(!1);return}this.#b.delete("sort"),this.#de("sort",()=>N,()=>Q),this.#q=null,this.#B(),this.#bt("model:changed",{reason:Y[0]}),this.#se(!1)}}#Se(N,Q,J){const ee=this.#b.get(N);if(!(!ee||ee.key!==Q)){if(this.#b.delete(N),J&&J.name==="AbortError"){N==="sort"&&this.#se(!1);return}if(N==="sort"&&this.#H()===Q){const ne=this.#de("filter",()=>this.#$(),()=>this.#Ve());this.#de("sort",()=>Q,()=>this.#k(ne)),this.#q=null,this.#B(),D("source.pipeline.sort","off-thread sort failed; recomputed on the main thread.",J),this.#bt("model:changed",{reason:Y[1]})}N==="sort"&&this.#se(!1)}}#ye(N,Q){const J=N&&N.leaves?N.leaves.length:this.#m.slots.length;this.#m.matchCount=J,this.#m.grand=Q&&Q.grand||null,this.#m.grandLeaves=N&&N.leaves?N.leaves.length:0,this.#m.groupLeaves=N&&N.leaves?N.leaves:null}#de(N,Q,J){const ee=this.#l.get(N),ne=Q();return ee.computed&&ee.key===ne||(ee.result=J(),ee.key=ne,ee.computed=!0,ee.id++,N==="flatten"&&(this.#q=null)),ee.result}#J(N){return this.#l.get(N).id}#$(){const N=(this.#e.config||{}).hostFilter,Q=N&&z(N.active)&&N.active()?1:0,J=this.#_("where",null),ee=J?J.version:0,ne=this.#it("filter.sig",`${this.#St()}`,()=>d({filters:this.#_("filters",null),quick:this.#_("quick",""),quickMode:this.#_("quickMode","contains")}));return`${this.#u}|${ne}|${Q}|${ee}`}#H(){const N=this.#he();return`${this.#J("filter")}|${JSON.stringify(this.#_("sort",[]))}`+(N?`|manual:${N.version}`:"")}#he(){const N=this.#_("rowOrder",null);return N&&Array.isArray(N.keys)?N:null}#ie(N,Q){this.#p||this.#Ae();const J=this.#p,ee=this.#j(),ne=Q.keys.length,se=new Float64Array(ee);for(let le=0;le<ee;le++)se[le]=ne+le;for(let le=0;le<ne;le++){const ye=J.get(Q.keys[le]);ye!==void 0&&(se[ye]=le)}return Uint32Array.from(N).sort((le,ye)=>se[le]-se[ye])}orderedKeys(){this.#p||this.#Ae();const N=this.#p,Q=new Map;for(const[le,ye]of N)Q.set(ye,le);const J=Uint32Array.from([...Q.keys()]).sort(),ee=this.#he(),ne=ee?this.#ie(J,ee):this.#k(J),se=new Array(ne.length);for(let le=0;le<ne.length;le++)se[le]=Q.get(ne[le]);return se}#F(){const N=this.#_("pivotBy",[]).length>0?"p":"u";return`${this.#J("sort")}|${JSON.stringify(this.#_("groupBy",[]))}|${N}`}#ke(){const N=this.#rt()?"f":"a",Q=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#J("group")}|${JSON.stringify(this.#_("totals",[]))}|${N}${Q}|${this.#c}`}#ee(){return`${this.#J("group")}|${JSON.stringify(this.#_("pivotBy",[]))}`}#Le(){const Q=this.#je()||!this.#oe()?this.#J("total"):"x",J=`${this.#St()}`,ee=this.#it("flatten.keys",J,()=>{const se=this.#_("expanded",null);return se?[...se].sort().join(""):"*"}),ne=this.#it("flatten.detail",J,()=>{const se=this.#_("detail",null);return se&&z(se.signature)?se.signature():""});return`${Q}|${this.#J("pivot")}|${ee}|${ne}`}#je(){const N=this.#_("groupBy",[]);return Array.isArray(N)&&N.length>0}stageState(){const N=[];for(const[Q,J]of this.#l){const ee=J.result;N.push({stage:Q,materialised:!!J.computed,bytes:ee&&typeof ee.byteLength=="number"?ee.byteLength:null,rows:ee&&typeof ee.length=="number"?ee.length:null,rebuilds:J.id})}return N}facetIndices(N){return this.#Ve(N||null)}facetRows(N){const Q=this.facetIndices(N),J=[];for(let ee=0;ee<Q.length;ee++){const ne=this.#ce(Q[ee]);ne&&J.push(ne)}return J}invalidateRows(){this.#h.clear(),this.#L.clear(),this.#q=null}invalidateHandles(){this.#a.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#et()}filteredIndices(){const N=this.#l.get("filter");if(N&&N.computed&&N.key===this.#$())return N.result||this.#et();this.#B();const Q=this.#l.get("filter");return(Q&&Q.computed?Q.result:null)||this.#et()}unfilteredRows(){const N=this.#et(),Q=[];for(let J=0;J<N.length;J++){const ee=this.#ce(N[J]);ee&&Q.push(ee)}return Q}#Ve(N=null){const Q=this.#et(),J=this.#_("filters",null),ee=N?this.#ft("pruneColumn")(J,N):J,ne=this.#mt(ee),se=String(this.#_("quick","")||"").trim().toLowerCase(),le=se?_(se,String(this.#_("quickMode","contains")||"contains")):null,ye=(this.#e.config||{}).hostFilter,fe=!!(ye&&z(ye.active)&&ye.active()),we=this.#_("where",null),ke=!!(we&&we.active);if(!ne&&!se&&!fe&&!ke)return Q;let Ce=null;ne&&(Ce=this.#ft("evaluateFilters")(ne,{handle:de=>this.#a.handle(de),count:this.#j(),pool:this.#e.pool,locale:(this.#e.config||{}).locale,itemwise:de=>F(this.#Be(de))}));const ce=new Uint32Array(Q.length);let ae=0;for(let ge=0;ge<Q.length;ge++){const de=Q[ge];if(!(Ce&&!Ce[de])&&!(le&&!this.#De(de,le))){if(fe||ke){const me=this.#ce(de);if(fe&&!ye.passes(me)||ke&&!we.passes(me.data,me.key))continue}ce[ae++]=de}}if(Ce){const ge=(this.#e.compute||{}).releaseMask;z(ge)&&ge({pool:this.#e.pool},Ce)}return ce.subarray(0,ae)}handleFor(N){return this.#a.handle(N)}#k(N){const Q=this.#he();if(Q)return this.#ie(N,Q);const J=this.#_("sort",[]).filter(se=>{const le=this.#Be(se.col);return!le||!le.running?!0:(D(`source.sort.running.${se.col}`,`sort ignores "${se.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(!J.length)return N;const ee=(this.#e.config||{}).locale;if(J.length===1){const se=J[0],le=this.#a.handle(se.col);if(!le)return D(`source.sort.${se.col}`,`sort ignores unknown column "${se.col}".`),N;const ye=this.#Be(se.col);return this.#ft("sortColumn")(le,N,{descending:se.dir==="desc",nullsFirst:se.nullsFirst,locale:ee,compare:S(ye)})}const ne=[];for(const se of J){const le=this.#a.handle(se.col);if(!le){D(`source.sort.${se.col}`,`sort ignores unknown column "${se.col}".`);continue}ne.push({handle:le,descending:se.dir==="desc",nullsFirst:se.nullsFirst,locale:ee,compare:S(this.#Be(se.col))})}return ne.length?this.#ft("sortMulti")(ne.map(se=>se.handle),ne,N):N}#Fe(N){const Q=this.#_("groupBy",[]),J=this.#fe();if(J&&!Q.length){const ge=p(N,J);return this.#R=v(ge.roots,J.declaresChildren),{roots:null,leaves:N,nodes:new Map,tree:ge}}if(this.#R=null,J&&Q.length&&D("tree.grouped","grouping is active on a grid configured with `tree`; the grouping wins and the hierarchy is not shown."),!Q.length)return{roots:null,leaves:N,nodes:new Map};const ee=(this.#e.config||{}).timeZone,ne=[],se=[];let le=!1;for(const ge of Q){const de=this.#a.handle(ge);if(!de){D(`source.group.${ge}`,`grouping ignores unknown column "${ge}".`);continue}ne.push(de);const me=this.#Be(ge),ve=me&&me.dataType;if(ve&&z(ve.groupProjector)){const xe=me.typeOptions&&me.typeOptions.timeZone||ee||void 0,Ee=ve.groupProjector(me,xe);se.push(Ee||null),Ee&&(le=!0)}else se.push(null)}if(!ne.length)return{roots:null,leaves:N,nodes:new Map};const{keys:ye,buckets:fe}=this.#ft("groupByColumns")(ne,N,{locale:(this.#e.config||{}).locale,project:le?se:void 0}),we=this.#_("pivotBy",[]).length>0,ke=[],Ce=new Map;for(let ge=0;ge<fe.length;ge++){const de=ye[ge];let me=null;const ve=[];for(let xe=0;xe<de.length;xe++){ve.push(g(de[xe]));const Ee=f(ve),Le=xe===de.length-1;let He=Ce.get(Ee);if(!He){const Me=this.#s.group({path:[...ve],column:Q[xe],value:de[xe],level:xe,parent:me,expanded:we&&Le?!1:this.#gt(Ee,{key:Ee,column:Q[xe],value:de[xe],level:xe,path:[...ve]}),hasChildren:!(we&&Le)});He={row:Me,leaves:null},Ce.set(Ee,He),me?me.children.push(Me):ke.push(Me)}He.row.leafCount+=fe[ge].length,xe===de.length-1&&(He.leaves=fe[ge]),me=He.row}}const ce=this.#_("sort",[])||[],ae=(ge,de)=>{if(!ge||ge.length<2){if(ge)for(const Ee of ge)ae(Ee.children,de+1);return}const me=Q[de],ve=ce.find(Ee=>Ee.col===me),xe=ve&&ve.dir==="desc"?-1:1;ge.sort((Ee,Le)=>xe*X(Ee.groupValue,Le.groupValue));for(const Ee of ge)ae(Ee.children,de+1)};return ae(ke,0),{roots:ke,leaves:N,nodes:Ce,keys:ye,buckets:fe}}#Ye(N,Q){const J=new Map,ee=new Map,ne=se=>{const le=se.physical>=0?[se.physical]:[];for(const ye of se.children)le.push(...ne(ye));if(se.children.length){const ye=this.#Xe(Q,Uint32Array.from(le),null);se.physical>=0?J.set(se.physical,ye):ee.set(se.key,ye)}return le};for(const se of N.roots)ne(se);return{byPhysical:J,byKey:ee}}#qe(N){const Q=this.#Ke();if(!Q.length)return this.#E=null,this.#T=null,{grand:null};const J={id:this.#J("group"),columns:Q.map(ce=>ce.id).join("")},ee=this.#E&&this.#E.id===J.id&&this.#E.columns===J.columns,ne=this.#at()&&ee?this.#C:null,se=ne?Q.filter(ce=>ne.has(ce.id)):Q,le=ee?this.#T:null,ye=this.#rt()?null:this.#Tt(),fe=this.#Pe(Q),we=ce=>{const ae=N.nodes.get(ce.key);let ge=ae&&ae.leaves?ae.leaves:null;if(ce.children&&ce.children.length){const ve=ce.children.map(we);let xe=0;for(const He of ve)xe+=He.length;const Ee=new Uint32Array(xe);let Le=0;for(const He of ve)Ee.set(He,Le),Le+=He.length;ge=Ee}ge=ge||new Uint32Array(0);const de=ye?ye.get(ce.key)||M:ge,me=this.#Ze(ce,ne?se:Q,de,fe);return ce.totals=ne?{...ce.totals,...me}:me,ge};if(N.roots&&se.length)for(const ce of N.roots)we(ce);if(this.#I=N.tree?this.#Ye(N.tree,Q):null,this.#E=J,this.#C=this.#at()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#A.length=0,this.#T=null,{grand:null};const Ce=ye?this.#st():N.leaves;return this.#T=this.#Oe(Q,Ce,ne,le),{grand:this.#T}}#Oe(N,Q,J,ee){const ne={},se=this.#J("group");se!==this.#w&&(this.#ct(),this.#w=se);const le=this.#A;this.#A=[];for(const ye of N){if(!C(ye))continue;const fe=this.#a.handle(ye.id);if(!fe)continue;const we=O(ye,"grand");if(!m(we,fe)){if(J&&!J.has(ye.id)&&ee&&ye.id in ee){ne[ye.id]=ee[ye.id];continue}ne[ye.id]=this.#Xe([ye],Q,null,"grand")[ye.id];continue}let ke=this.#O.get(ye.id);if((!ke||ke.fn!==we)&&(ke=new n(we),this.#O.set(ye.id,ke)),ke.valid){let Ce=!0;for(const ce of le)if(ce.colId===ye.id&&!ke.update(ce.before,ce.after)){Ce=!1;break}if(Ce){ne[ye.id]=ke.value();continue}ke.invalidate()}ke.seedColumn(fe.values,s(fe),Q),ne[ye.id]=ke.valid?ke.value():this.#Xe([ye],Q,null,"grand")[ye.id]}return ne}#Pe(N){const Q=this.#J("group");Q!==this.#P&&(this.#v.clear(),this.#P=Q);const J=new Map;for(const ne of N){if(!C(ne))continue;const se=this.#a.handle(ne.id),le=O(ne,"group");m(le,se)&&J.set(ne.id,{fn:le})}if(!J.size)return this.#S.length=0,J;const ee=this.#S;this.#S=[];for(const ne of ee){const{beforeKeys:se,afterKeys:le,colDeltas:ye}=ne,fe=se.length?new Set(se):null,we=le.length?new Set(le):null;for(const{colId:ke,before:Ce,after:ce}of ye)if(J.has(ke)){for(const ae of se)we&&we.has(ae)||this.#dt(ae,ke,Ce,null);for(const ae of le)fe&&fe.has(ae)||this.#dt(ae,ke,null,ce);for(const ae of se)we&&!we.has(ae)||this.#dt(ae,ke,Ce,ce)}}return J}#dt(N,Q,J,ee){const ne=this.#v.get(N),se=ne&&ne.get(Q);!se||!se.valid||se.update(J,ee)||se.invalidate()}#Ze(N,Q,J,ee){if(!ee||!ee.size)return this.#Xe(Q,J,N);const ne={};let se=null,le=this.#v.get(N.key);for(const ye of Q){const fe=ee.get(ye.id);if(!fe){(se||(se=[])).push(ye);continue}const we=this.#a.handle(ye.id);if(!we)continue;le||(le=new Map,this.#v.set(N.key,le));let ke=le.get(ye.id);if((!ke||ke.fn!==fe.fn)&&(ke=new n(fe.fn),le.set(ye.id,ke)),ke.valid||ke.seedColumn(we.values,s(we),J),ke.valid){ne[ye.id]=ke.value();continue}(se||(se=[])).push(ye)}return se&&Object.assign(ne,this.#Xe(se,J,N)),ne}#Je(N,Q,J,ee){const ne=!this.#rt()||this.#Et(Q);for(const se of N){const le=se.getValue;if(!z(le))continue;const ye=le(J),fe=le(ee);Object.is(ye,fe)||(this.#C&&this.#C.add(se.id),ne&&this.#O.has(se.id)&&this.#A.push({colId:se.id,before:ye,after:fe}))}}#ht(){const N=this.#_("groupBy",[]),Q=[];for(const J of N){const ee=this.#Be(J);ee&&Q.push(ee)}return Q}#pt(N,Q){const J=new Array(N.length);for(let ee=0;ee<N.length;ee++){const ne=N[ee].getValue;J[ee]=g(z(ne)?ne(Q):void 0)}return J}#We(N,Q,J,ee,ne){if(this.#rt()&&!this.#Et(J))return;const se=a(this.#pt(N,ee)),le=a(this.#pt(N,ne)),ye=se.length!==le.length||se.some((we,ke)=>we!==le[ke]),fe=[];for(const we of Q){const ke=we.getValue;if(!z(ke))continue;const Ce=ke(ee),ce=ke(ne);!ye&&Object.is(Ce,ce)||fe.push({colId:we.id,before:Ce,after:ce})}!fe.length&&!ye||this.#S.push({beforeKeys:se,afterKeys:le,colDeltas:fe})}#Et(N){const Q=this.#l.get("filter"),J=Q&&Q.computed?Q.result:null;if(!J)return!0;let ee=0,ne=J.length-1;for(;ee<=ne;){const se=ee+ne>>1,le=J[se];if(le===N)return!0;le<N?ee=se+1:ne=se-1}return!1}#rt(){return(this.#e.config||{}).totalFilteredOnly!==!1}#te(N){return this.#rt()?N:this.#st().length}#st(){return(!this.#M||this.#M.version!==this.#u)&&(this.#M={version:this.#u,indices:this.#et()}),this.#M.indices}#Tt(){const N=this.#_("groupBy",[]),Q=`${this.#u}|${JSON.stringify(N)}`;if(this.#N&&this.#N.key===Q)return this.#N.map;const J=new Map,ee=[];for(const ne of N){const se=this.#a.handle(ne);se&&ee.push(se)}if(ee.length){const ne=this.#st(),{keys:se,buckets:le}=this.#ft("groupByColumns")(ee,ne,{locale:(this.#e.config||{}).locale}),ye=new Map;for(let fe=0;fe<le.length;fe++){const we=se[fe],ke=[];for(let Ce=0;Ce<we.length;Ce++){ke.push(g(we[Ce]));const ce=f(ke);let ae=ye.get(ce);ae||(ae=[],ye.set(ce,ae));for(let ge=0;ge<le[fe].length;ge++)ae.push(le[fe][ge])}}for(const[fe,we]of ye)J.set(fe,Uint32Array.from(we))}return this.#N={key:Q,map:J},J}#at(){return!!(this.#e.config||{}).totalOnlyChangedColumns}#lt(){this.#ct(),this.#vt(),this.#C=null,this.#E=null,this.#T=null}#ct(){this.#O.clear(),this.#A.length=0,this.#w=-1}#vt(){this.#v.clear(),this.#S.length=0,this.#P=-1}#Ge(N){const Q=this.#_("pivotBy",[]);if(!Q.length)return this.#V=null,null;const J=(this.#e.compute||{}).pivot;if(!z(J))return D("source.pivot.kernel","pivot requested but ctx.compute.pivot is not available; showing unpivoted rows."),this.#V=null,null;const ee=Q.map(se=>this.#a.handle(se)).filter(Boolean),ne=this.#Ke();return this.#V=J(ee,N.leaves,{groups:N.keys&&N.buckets?{keys:N.keys,buckets:N.buckets}:null,totals:ne.map(se=>se.id),handle:se=>this.#a.handle(se),totalOf:se=>O(ne.find(le=>le.id===se),"group"),separator:((this.#e.config||{}).pivot||{}).separator,maxColumns:((this.#e.config||{}).pivot||{}).maxColumns})||null,this.#V}#kt(N){const Q=this.#l.get("total").result,J=!!(this.#e.config||{}).groupFooter,ee=this.#Me();if(N.tree)return this.#Re(N,Q,ee);if(!N.roots&&!ee){if(Q&&Q.grand&&!this.#oe()){const we=this.#s.grandTotal(Q.grand,this.#te(N.leaves.length));if(this.#Y===N.leaves&&Array.isArray(this.#U))this.#U[this.#U.length-1]=we;else{const ke=Array.from(N.leaves);ke.push(we),this.#U=ke,this.#Y=N.leaves}this.#D=[{at:this.#U.length-1}]}else this.#Y=null,this.#U=N.leaves,this.#D=E;return this.#z=E,this.#U}const ne=[],se=[],le=[],ye=we=>{if(ne.push(we),!ee)return;const ke=this.#ce(we);!ke||!ee.isOpen(ke.key)||(ke.master=!0,ke.expanded=!0,le.push({at:ne.length}),ne.push(this.#s.detail(ke,ee.heightOf(ke))))};if(!N.roots){for(let we=0;we<N.leaves.length;we++)ye(N.leaves[we]);return Q&&Q.grand&&!this.#oe()&&(le.push({at:ne.length}),ne.push(this.#s.grandTotal(Q.grand,this.#te(N.leaves.length)))),this.#Y=null,this.#z=E,this.#D=le.length?le:E,this.#U=ne,ne}const fe=(we,ke,Ce)=>{if(we.expanded=we.hasChildren===!1?!1:this.#gt(we.key,{key:we.key,column:we.groupColumn,value:we.groupValue,level:we.level,path:we.groupPath}),we.posinset=ke+1,we.setsize=Ce,se.push({at:ne.length,row:we}),le.push({at:ne.length}),ne.push(we),!!we.expanded){if(we.children&&we.children.length)for(let ce=0;ce<we.children.length;ce++)fe(we.children[ce],ce,we.children.length);else{const ce=N.nodes.get(we.key),ae=ce&&ce.leaves?ce.leaves:null;if(ae)for(let ge=0;ge<ae.length;ge++)ye(ae[ge])}J&&we.totals&&(le.push({at:ne.length}),ne.push(this.#s.footer(we)))}};for(let we=0;we<N.roots.length;we++)fe(N.roots[we],we,N.roots.length);return Q&&Q.grand&&!this.#oe()&&(le.push({at:ne.length}),ne.push(this.#s.grandTotal(Q.grand,this.#te(N.leaves.length)))),this.#z=se,this.#D=le,this.#U=ne,ne}#et(){const N=this.#e.store;if(N&&z(N.liveIndices))return N.liveIndices();const Q=new Uint32Array(this.#n.length);let J=0;for(let ee=0;ee<this.#n.length;ee++)this.#n[ee]!==void 0&&(Q[J++]=ee);return Q.subarray(0,J)}#j(){const N=this.#e.store;return N&&typeof N.physical=="number"?N.physical:this.#n.length}#Qe(N){const Q=this.#e.store;return Q&&z(Q.source)?Q.source(N):this.#n[N]}#_e(N,Q=N){const J=this.#U[N];if(typeof J!="number")return J.index=Q,J;const ee=this.#ce(J);return ee.index=Q,ee}#ce(N){let Q=this.#h.get(N);Q||(Q=this.#s.leaf(this.#Qe(N),N),this.#h.set(N,Q));const J=this.#R?this.#R.get(N):null;if(J){Q.level=J.level,Q.posinset=J.posinset,Q.setsize=J.setsize,Q.hasChildren=J.hasChildren,Q.expanded=J.hasChildren&&!J.lazy&&this.#gt(Q.key);const ee=this.#I?this.#I.byPhysical.get(N):void 0;ee?Q.totals=ee:Q.totals&&(Q.totals=null)}else Q.hasChildren&&(Q.level=0,Q.hasChildren=!1,Q.expanded=!1,Q.posinset=void 0,Q.setsize=void 0);return Q}#Re(N,Q,J){const ee=[],ne=[],se=ye=>{if(ye.leafCount!==void 0)return ye.leafCount;let fe=ye.physical>=0?1:0;for(const we of ye.children)fe+=se(we);return ye.leafCount=fe,fe},le=ye=>{const fe=this.#gt(ye.key);if(ye.physical>=0){if(ee.push(ye.physical),J&&J.isOpen(this.#ce(ye.physical).key)){const we=this.#ce(ye.physical);ne.push({at:ee.length}),ee.push(this.#s.detail(we,J.heightOf(we)))}}else ee.push(this.#s.group({path:[ye.key],column:null,value:ye.value,level:ye.level,parent:null,expanded:fe,hasChildren:ye.children.length>0,leafCount:se(ye),totals:this.#I?this.#I.byKey.get(ye.key):void 0}));if(fe)for(const we of ye.children)le(we)};for(const ye of N.tree.roots)le(ye);return Q&&Q.grand&&!this.#oe()&&(ne.push({at:ee.length}),ee.push(this.#s.grandTotal(Q.grand,this.#te(N.leaves.length)))),this.#Y=null,this.#z=E,this.#D=ne.length?ne:E,this.#U=ee,ee}#$e(){return r(()=>this.count(),N=>this.at(N))}#De(N,Q){let J=this.#L.get(N);if(J===void 0){const ee=this.#Qe(N),ne=this.#At(),se=[],le=this.#e.columnHidden;for(const ye of ne){if(ye.quickFilter===!1||z(le)&&le(ye.id))continue;const fe=ye.value&&z(ye.value.quickFilterText)?ye.value.quickFilterText({value:void 0,data:ee,row:null,column:ye,colId:ye.id,grid:null,context:this.#_("context",null)}):null,we=fe??(z(ye.formatValue)?ye.formatValue(z(ye.getValue)?ye.getValue(ee):void 0):"");we!=null&&we!==""&&se.push(String(we))}J=se.join(" ").toLowerCase(),this.#L.set(N,J)}return Q(J)}#Ke(){const N=this.#_("totals",[]),Q=N&&N.length?new Set(N):null;return this.#At().filter(J=>Q?Q.has(J.id):!!(J.total||J.groupTotal||J.grandTotal))}#Xe(N,Q,J,ee="group"){const ne={},se=(this.#e.compute||{}).total;for(const le of N){if(!C(le))continue;const ye=this.#a.handle(le.id);if(!ye)continue;const fe=O(le,ee);if(fe)if(z(fe)){const we=new Array(Q.length);for(let ke=0;ke<Q.length;ke++)we[ke]=ye.get(Q[ke]);ne[le.id]=fe(we,{row:J,column:le,grid:this.#e.grid||null,context:this.#_("context",null),valueAt:(ke,Ce)=>{const ce=this.#a.handle(ke);return ce&&Ce>=0&&Ce<Q.length?ce.get(Q[Ce]):null}})}else z(se)&&(ne[le.id]=se(ye,Q,fe))}return ne}#mt(N){if(!N)return N;const Q=this.#e.config||{},J={tz:Q.timeZone,weekStartsOn:Q.weekStartsOn};return o(N,ee=>{const ne=b(ee,J),se=this.#Be(ne&&ne.col),le=se&&se.type==="datetime";if(ne&&ne.type)return ne.type==="datetime"&&!ne.timeZone&&se?{...ne,timeZone:Q.timeZone||void 0}:ne;if(le)return{...ne,type:"datetime",timeZone:Q.timeZone||void 0};const ye=se&&(se.dataType?.base||se.type);return ye?{...ne,type:ye}:ne})}#gt(N,Q){const J=this.#_("expanded",null);return J?z(J.has)?J.has(N,Q):Array.prototype.includes.call(J,N):!0}#_(N,Q){if(N==="context"||!z(this.#e.stateVersion))return this.#Ot(N,Q);const J=this.#Bt(N),ee=this.#f.get(N);if(ee&&ee.version===J)return ee.value;const ne=this.#Ot(N,Q);return this.#f.set(N,{version:J,value:ne}),ne}#Ot(N,Q){const J=this.#e.state;if(J&&z(J[N])){const ee=J[N]();return ee??Q}return Q}#St(){const N=this.#e.stateVersion;return z(N)?N():0}#ut(){const N=this.#e.columnsVersion,Q=this.#e.permissionsVersion;return`${z(N)?N():0}|${z(Q)?Q():0}`}#Bt(N){return N==="totals"?this.#ut():`${this.#St()}`}#it(N,Q,J){if(!z(this.#e.stateVersion))return J();const ee=this.#d.get(N);if(ee&&ee.version===Q)return ee.key;const ne=J();return this.#d.set(N,{version:Q,key:ne}),ne}#ft(N){const Q=(this.#e.compute||{})[N];return z(Q)||I(`ctx.compute.${N} is required by the memory source pipeline`),Q}#At(){const N=this.#e.columns;return N&&z(N.all)?N.all():[]}#Be(N){const Q=this.#e.columns;return Q&&z(Q.get)?Q.get(N):void 0}#bt(N,Q){const J=this.#e.emit;z(J)&&J(N,Q)}}}),Ue("packages/core/src/source/abort.js",function(e,B){"use strict";Object.defineProperty(e,"SupersededError",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"RequestToken",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"AbortScope",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"createAbortScope",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"isAbortError",{enumerable:!0,get:function(){return I}});class re extends Error{constructor(z,L="superseded"){super(`[lattice] request ${z?`"${z}" `:""}${L}`),this.name="SupersededError",this.superseded=!0,this.key=z}}class T{#e;constructor(z,L,X,$){this.#e=z,this.key=L,this.controller=X,this.signal=X.signal,this.seq=$}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(z){this.signal.aborted||this.controller.abort(new re(this.key,z)),this.#e.settle(this)}}class G{#e=new Map;#t=0;begin(z="",L="superseded"){const X=this.#e.get(z);X&&!X.signal.aborted&&X.controller.abort(new re(z,L));const $=new T(this,z,new AbortController,++this.#t);return this.#e.set(z,$),$}tokenFor(z){return this.#e.get(z)}pending(z=""){const L=this.#e.get(z);return!!L&&!L.signal.aborted}get size(){return this.#e.size}settle(z){this.#e.get(z.key)===z&&this.#e.delete(z.key)}abort(z="",L="superseded"){const X=this.#e.get(z);X&&X.abort(L)}abortAll(z="superseded"){for(const L of[...this.#e.values()])L.abort(z);this.#e.clear()}}function D(){return new G}function I(Z){if(!Z||typeof Z!="object")return!1;const z=Z;return z.superseded===!0||z.name==="AbortError"||z.name==="SupersededError"}}),Ue("packages/core/src/source/blockcache.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_PAGE_SIZE",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"DEFAULT_MAX_CACHED_PAGES",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return D}});const re=100,T=32;class G{constructor(Z){this.id=Z,this.rows=null,this.state="pending",this.token=null,this.error=null}}class D{#e=new Map;#t;#n;#r=0;#i=-1;constructor(Z={}){this.#t=Math.max(1,Math.floor(Number(Z.pageSize)||re)),this.#n=Math.max(1,Math.floor(Number(Z.maxCachedPages)||T))}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 z=this.#e.get(Z);return!!z&&z.state==="pending"}loaded(Z){const z=this.#e.get(Z);return!!z&&z.state==="loaded"}begin(Z,z){let L=this.#e.get(Z);return L||(L=new G(Z)),L.state="pending",L.token=z,L.error=null,this.#s(Z,L),L}fill(Z,z){const L=this.#e.get(Z)||new G(Z);L.rows=z,L.state="loaded",L.token=null,this.#s(Z,L)}failed(Z,z){const L=this.#e.get(Z)||new G(Z);L.state="error",L.error=z,L.token=null,this.#s(Z,L)}delete(Z){return this.#e.delete(Z)}rowAt(Z){const z=this.blockOf(Z),L=this.#e.get(z);if(!(!L||L.state!=="loaded"||!L.rows))return this.#s(z,L),L.rows[Z-z*this.#t]}rowLoaded(Z){const z=this.blockOf(Z),L=this.#e.get(z);return!!L&&L.state==="loaded"&&!!L.rows&&Z-z*this.#t<L.rows.length}erroredAt(Z){const z=this.#e.get(this.blockOf(Z));return!!z&&z.state==="error"}loadedExtent(){let Z=0;for(const z of this.#e.values()){if(z.state!=="loaded"||!z.rows)continue;const L=z.id*this.#t+z.rows.length;L>Z&&(Z=L)}return Z}fillOf(Z){const z=this.#e.get(Z);return z&&z.state==="loaded"&&z.rows?z.rows.length:null}protect(Z,z){this.#r=this.blockOf(Math.max(0,Z)),this.#i=this.blockOf(Math.max(0,z))}evict(){const Z=[];if(this.#e.size<=this.#n)return Z;for(const[z,L]of this.#e){if(this.#e.size-Z.length<=this.#n)break;z>=this.#r&&z<=this.#i||L.state!=="pending"&&Z.push(z)}for(const z of Z)this.#e.delete(z);return Z}ids(){return[...this.#e.keys()]}clear(){this.#e.clear()}#s(Z,z){this.#e.delete(Z),this.#e.set(Z,z)}}}),Ue("packages/core/src/source/pagewindow.js",function(e,B){"use strict";Object.defineProperty(e,"pageWindow",{enumerable:!0,get:function(){return re}});function re(T,G,D,I){const Z=Math.floor(Number(T)||0);if(Z<=0)return null;const z=Math.max(0,Math.floor(Number(G)||0)),L=Math.max(0,Math.floor(Number(D)||0));if(I){const X=Math.max(1,Math.ceil(L/Z)),$=Math.min(z,X-1),A=$*Z;return{page:$,pageSize:Z,offset:A,length:Math.max(0,Math.min(Z,L-A)),pageCount:X,total:L}}return{page:z,pageSize:Z,offset:z*Z,length:Z,pageCount:Math.max(z+2,Math.ceil(L/Z)),total:null}}}),Ue("packages/core/src/source/paged.js",function(e,B){"use strict";Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"PagedSource",{enumerable:!0,get:function(){return d}});const T=B("packages/core/src/internal/lru.js").Lru,D=B("packages/core/src/internal/predicates.js").isFunction,Z=B("packages/core/src/internal/warn.js").warnOnce,L=B("packages/core/src/internal/schedule.js").settleDebounce,X=B("packages/core/src/source/abort.js"),$=X.createAbortScope,A=X.isAbortError,k=B("packages/core/src/source/blockcache.js"),y=k.BlockCache,f=k.DEFAULT_PAGE_SIZE,g=k.DEFAULT_MAX_CACHED_PAGES,r=B("packages/core/src/source/rows.js").createRowFactory,i=B("packages/core/src/source/filterwire.js"),c=i.wireFilters,u=i.querySignature,n=i.warnHostFilterNotApplied,t=B("packages/core/src/source/pagewindow.js").pageWindow,s=120;function h(o,b){return new d(o,b)}class d{mode="paged";#e;#t;#n;#r=$();#i;#s;#a=new Map;#l=null;#o=null;#c=!1;#u=0;#f="";#d={start:0,end:0};#h;#p=!1;#m=0;#g="";constructor(b,l){this.#e=b||{mode:"paged"},this.#t=l||{},this.#n=new y({pageSize:this.#e.pageSize||f,maxCachedPages:this.#e.maxCachedPages||g}),this.#i=r(this.#t),this.#s=new T(this.#n.pageSize*4),this.#h=L((p,w)=>this.#w(p,w),s),this.#f=this.#C(),D(this.#e.fetch)||Z("source.paged.fetch",'source.mode "paged" requires a fetch function; the grid will stay empty.'),n(this.#t)}count(){const b=this.#y();return b?b.length:this.#b()}#b(){if(this.#P(),this.#l!==null)return this.#l;const b=Math.max(this.#u,this.#n.loadedExtent());return this.#c?b:b+this.#n.pageSize}matchCount(){return this.#b()}totalCount(){return this.#b()}pageInfo(){const b=this.#y();if(!b){const l=this.#b();return{page:0,pageSize:0,total:this.exact()?l:null,pageCount:1,counting:!1}}return{page:b.page,pageSize:b.pageSize,total:b.total,pageCount:b.pageCount,counting:b.total===null&&this.#r.size>0&&this.#u===0&&this.#n.loadedExtent()===0}}#y(){const b=this.#b(),l=t(this.#T("pageSize",0),this.#T("page",0),b,this.exact());if(!l)return this.#g="",null;const p=`${this.#m}:${l.offset}:${l.length}`;if(p!==this.#g&&!this.#p&&(this.#g=p,l.length>0)){const w=l.offset+l.length-1;this.#d={start:l.offset,end:w},this.#w(l.offset,w)}return l}at(b){const l=this.#y();if(l){if(b<0||b>=l.length)return;const p=this.#O(l.offset+b);return p&&(p.index=b),p}return this.#O(b)}#O(b){if(b<0||b>=this.#b())return;const l=this.#s.get(b);if(l&&(l.data!==null||!this.#n.rowLoaded(b)))return l;const p=this.#n.rowAt(b);if(p===void 0){const v=this.#i.skeleton(b,0,this.#n.erroredAt(b));return this.#s.set(b,v),v}const w=this.#i.leaf(p,b);return w.index=b,this.#s.set(b,w),this.#a.set(w.key,b),w}byKey(b){const l=this.#a.get(b);return l===void 0?void 0:this.#O(l)}loaded(b){const l=this.#y();return l?b>=0&&b<l.length&&this.#n.rowLoaded(l.offset+b):this.#n.rowLoaded(b)}loadedCount(){this.#P();let b=0;for(const l of this.#n.ids()){if(!this.#n.loaded(l))continue;const p=this.#n.fillOf(l);typeof p=="number"&&(b+=p)}return b}residentRows(){this.#P();const b=this.#y(),l=b?b.offset:0,p=b?b.offset+b.length:1/0,w=[],v=this.#n.ids().sort((R,Y)=>R-Y);for(const R of v){if(!this.#n.loaded(R))continue;const{start:Y}=this.#n.rangeOf(R),K=this.#n.fillOf(R)||0;for(let V=Y;V<Y+K;V++){if(V<l||V>=p)continue;const E=this.#s.peek(V);if(E&&E.data!==null&&E.data!==void 0){w.push(E);continue}const O=this.#n.rowAt(V);if(O===void 0)continue;const C=this.#i.leaf(O,V);C.index=V,this.#s.set(V,C),this.#a.set(C.key,V),w.push(C)}}return w}hint(b,l){if(this.#p)return;const p=this.#P();let w=Math.max(0,Math.floor(b)),v=Math.max(w,Math.floor(l));const R=this.#y();if(R){if(R.length===0)return;w=R.offset,v=R.offset+R.length-1}this.#d={start:w,end:v},this.#n.protect(w,v);for(const Y of this.#n.evict())this.#v(Y);this.#h(w,v),p&&this.#h.flush()}#w(b,l){if(this.#p)return;this.#n.protect(b,l);const p=this.#n.blockOf(b),w=this.#n.blockOf(l);for(let v=p;v<=w&&!(this.#l!==null&&v*this.#n.pageSize>=this.#l);v++)this.#n.has(v)||this.#A(v)}apply(b){const l={added:[],updated:[],removed:[]};if(!b)return l;if(b.update)for(const p of b.update){const w=this.#i.keyOf(p,-1),v=this.#a.get(w);if(v===void 0)continue;const R=this.#i.leaf(p,v);R.index=v,this.#s.set(v,R),l.updated.push(R)}return(b.add&&b.add.length||b.remove&&b.remove.length)&&this.reload(),l}reload(b){this.#S("reload"),this.#h.cancel(),this.hint(this.#d.start,this.#d.end)}destroy(){this.#p=!0,this.#h.cancel(),this.#r.abortAll("destroyed"),this.#n.clear(),this.#s.clear(),this.#a.clear()}exact(){return this.#l!==null||this.#c}pending(){return this.#r.size}async#A(b){if(!D(this.#e.fetch))return;const l=this.#r.begin(`block:${b}`);this.#n.begin(b,l);const{start:p,end:w}=this.#n.rangeOf(b),v=this.#f;try{const R=await this.#e.fetch({range:{start:p,end:w},sort:this.#T("sort",[]),filters:c(this.#T("filters",null),this.#E()),quick:this.#T("quick","")||void 0,context:this.#T("context",null),signal:l.signal});if(!l.current||v!==this.#f||this.#p)return;l.settle();const Y=R&&R.rows||[];this.#n.fill(b,Y);for(let V=0;V<Y.length;V++)this.#s.delete(p+V);const K=R&&typeof R.total=="number"?R.total:R&&typeof R.count=="number"?R.count:null;K!==null?(this.#l=K,this.#c=!0):Y.length<this.#n.pageSize?(this.#c=!0,this.#l=p+Y.length):this.#u=Math.max(this.#u,p+Y.length),this.#M("model:changed",{reason:"page",block:b,from:p,to:p+Y.length}),this.#M("rows:changed",{companion:!0,reason:"page",block:b,from:p,to:p+Y.length}),this.#l!==null&&this.#l!==this.#o&&(this.#o=this.#l,this.#M("source:total",{total:this.#l,groupPath:[]}))}catch(R){if(l.settle(),A(R))return;this.#n.failed(b,R);for(let Y=p;Y<w;Y++)this.#s.delete(Y);this.#M("model:changed",{reason:"page-error",block:b,range:{start:p,end:w}}),this.#M("source:error",{error:R,block:b,range:{start:p,end:w}})}}#v(b){const{start:l,end:p}=this.#n.rangeOf(b);for(let w=l;w<p;w++){const v=this.#s.peek(w);v&&this.#a.delete(v.key),this.#s.delete(w)}}#P(){const b=this.#C();return b===this.#f?!1:(this.#f=b,this.#S("query"),!0)}#S(b){this.#r.abortAll(b),this.#n.clear(),this.#s.clear(),this.#a.clear(),this.#l=null,this.#o=null,this.#c=!1,this.#u=0,this.#m++,this.#M("model:changed",{reason:b})}#C(){return u({filters:this.#T("filters",null),sort:this.#T("sort",[]),quick:this.#T("quick",""),context:this.#T("context",null)})}#E(){const b=this.#t.config||{};return{tz:b.timeZone,weekStartsOn:b.weekStartsOn}}#T(b,l){const p=this.#t.state;if(p&&D(p[b])){const w=p[b]();return w??l}return l}#M(b,l){const p=this.#t.emit;D(p)&&p(b,l)}}}),Ue("packages/core/src/source/aggregates.js",function(e,B){"use strict";Object.defineProperty(e,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"pushableAggregates",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"fillAggregateSql",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"aggregateP",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"resolveAggregatesConfig",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"routeAggregate",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"resolveAggregatePlan",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"groupKeysPushable",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"pushdownDocRows",{enumerable:!0,get:function(){return $}});const re=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 T(){const A=new Set;for(const[k,y]of Object.entries(re))y.pushable&&A.add(k);return A}function G(A,k,y,f="?"){let g=A.split("%c").join(k);return y!==void 0&&(g=g.split("%w").join(y)),g.split("%p").join(f)}function D(A){const k=A&&(A.p!==void 0?A.p:A.params&&A.params.p);return typeof k=="number"&&k>=0&&k<=1?k:void 0}function I(A){const k=A||{},y=k.default==="engine"||k.default==="engine-if-identical"?k.default:"client",f={};if(k.overrides&&typeof k.overrides=="object")for(const[g,a]of Object.entries(k.overrides))(a==="engine"||a==="client")&&(f[g]=a);return{default:y,overrides:f}}function Z(A,k){const y=re[A];if(!y||!y.pushable)return"client";const f=k.overrides[A];return f==="engine"||f==="client"?f:k.default==="client"?"client":k.default==="engine-if-identical"?y.class==="identical"?"engine":"client":"engine"}function z(A,k){const y=I(k),f=[],g=[];for(const a of A||[]){const r=re[a.fn],i=Z(a.fn,y),c={id:a.id,col:a.col,fn:a.fn,class:r?r.class:"fallback"};if(a.weight!==void 0&&(c.weight=a.weight),a.params!==void 0&&(c.params=a.params),r&&r.parametric){const u=D(a);u!==void 0&&(c.p=u)}if(i==="engine"&&r&&r.parametric&&c.p===void 0){g.push({...c,reason:`"${a.fn}" needs \`p\`, a number from 0 to 1`});continue}i==="engine"?f.push(c):(c.reason=r&&!r.pushable?r.note||"the engine cannot express this stat":"client by config",g.push(c))}return{engine:f,client:g,config:y}}const L=/^[A-Za-z_][A-Za-z0-9_$]*$/;function X(A,k=[]){return(A||[]).every(f=>{if(typeof f=="string")return L.test(f);if(!f||typeof f!="object")return!1;const g=f;return Array.isArray(k)&&k.includes(g.bucket)&&typeof g.col=="string"&&L.test(g.col)&&typeof g.size=="number"&&Number.isFinite(g.size)&&g.size>0})}function $(){return Object.entries(re).map(([A,k])=>({stat:A,class:k.class,sql:k.sql?G(k.sql,"col",k.twoColumn?"weight":void 0):"",note:k.note||(k.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),Ue("packages/core/src/source/pushdown.js",function(e,B){"use strict";Object.defineProperty(e,"FOREGROUND_WAIT_MS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"LEAF_COUNT_ID",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PIVOT_UNSUPPORTED",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"GROUP_UNSUPPORTED",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"UNGROUPED_LEVEL",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return J}});const T=B("packages/core/src/internal/compare.js").defaultCompare,D=B("packages/core/src/internal/predicates.js").isFunction,Z=B("packages/core/src/internal/merge.js").toArray,L=B("packages/core/src/internal/warn.js").warnOnce,X=B("packages/core/src/source/filterwire.js"),$=X.isGroup,A=X.warnWherePageRelative,k=X.warnWhereOverThreshold,y=X.wireFilters,f=B("packages/core/src/source/aggregates.js"),g=f.resolveAggregatePlan,a=f.groupKeysPushable,r=f.STAT_PUSHDOWN,i=f.aggregateP,c=f.fillAggregateSql,n=B("packages/core/src/source/abort.js").SupersededError,m=1e3;function t(ee){const ne=ee&&ee.signal;if(!ne||!ne.aborted)return;const se=ne.reason;throw se instanceof Error?se:new n("","superseded before it was sent")}const s=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,pivot:!1,mutate:!1});function h(ee){if(!ee||typeof ee!="object")return!1;const ne=ee.returning==="row"||ee.returning==="key"?ee.returning:"none";return{append:ee.append===!0,update:ee.update===!0,delete:ee.delete===!0,returning:ne}}function d(ee,ne){if(!ee||typeof ne!="string")return;if(!ne.includes("."))return ee[ne];let se=ee;for(const le of ne.split(".")){if(se===null||typeof se!="object")return;se=se[le]}return se}function o(ee){if(ee===!0)return!0;if(!ee||typeof ee!="object")return!1;const ne=ee;return ne.enabled===!1?!1:ne.enabled===!0||D(ne.commit)}function b(ee){const ne={...s,...ee||{}};return ne.operators=new Set(ne.operators||[]),ne.mutate=h(ne.mutate),ne}function l(ee,ne){return!ee||!ee.op||!ne.operators.size?!1:ne.operators.has(ee.op)}function p(ee,ne){if(!ee)return{pushed:null,residual:null};if(!ne.filter)return{pushed:null,residual:ee};if(ne.filter==="term"){if($(ee)){const fe=ee.conditions||[];if(String(ee.op)!=="and")return{pushed:null,residual:ee};const we=fe.findIndex(Ce=>!$(Ce)&&l(Ce,ne));if(we<0)return{pushed:null,residual:ee};const ke=fe.filter((Ce,ce)=>ce!==we);return{pushed:fe[we],residual:ke.length?{op:"and",conditions:ke}:null}}return l(ee,ne)?{pushed:ee,residual:null}:{pushed:null,residual:ee}}if(!$(ee))return l(ee,ne)?{pushed:ee,residual:null}:{pushed:null,residual:ee};if(String(ee.op)!=="and")return(ee.conditions||[]).every(we=>$(we)?p(we,ne).residual===null:l(we,ne))?{pushed:ee,residual:null}:{pushed:null,residual:ee};const se=[],le=[];for(const fe of ee.conditions||[]){if($(fe)){if(ne.filter==="flat"){le.push(fe);continue}const we=p(fe,ne);we.pushed&&se.push(we.pushed),we.residual&&le.push(we.residual);continue}(l(fe,ne)?se:le).push(fe)}const ye=fe=>fe.length===0?null:fe.length===1?fe[0]:{op:"and",conditions:fe};return{pushed:ye(se),residual:ye(le)}}const w="__lattice_leaves";function v(ee){return ee.aggregates?ee.aggregates instanceof Set?ee.aggregates:new Set(Z(ee.aggregates)):new Set}function R(ee){const ne=v(ee);return ne.size?ne.has("count")?ee.filter!=="tree"||!ee.operators||!ee.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 Y(ee,ne,se,le,ye,fe,we){const ke=Array.isArray(ee.groupBy)?ee.groupBy:[],Ce=Array.isArray(ee.groupPath)?ee.groupPath:[],ce=Array.isArray(ee.groupValues)?ee.groupValues:null;if(!ne.group){const ae=R(ne);if(ae)return ae}return a(ke)?se.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":le?ye?fe&&!fe.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":!ce||ce.length!==Ce.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 K="pushdown:pivot-unsupported",V="pushdown:group-unsupported",E=Symbol("lattice.remote.ungroupedLevel");function O(ee,ne,se,le,ye,fe){const we=Array.isArray(ee.pivotBy)?ee.pivotBy:[],ke=Array.isArray(ee.groupBy)?ee.groupBy:[],Ce=Array.isArray(ee.groupPath)?ee.groupPath:[],ce=Array.isArray(ee.groupValues)?ee.groupValues:null;return ne.pivot?a(we)?ke.length&&!a(ke)?"a grouping key is not a plain column the engine can name in a GROUP BY":se.residual?"the filter did not fully push, so the engine would pivot a superset of the matching rows":le?ye?fe&&!fe.conditioned?"a host `where` predicate can only run in the browser, over rows the engine pivoted":!ce||ce.length!==Ce.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 C(ee,ne,se=!1){const le=p(ee.filters||null,ne),ye=[];le.residual&&ye.push("filter");const fe=ee.sort||[],we=fe.length===0||ne.sort==="multi"&&fe.length>=1||ne.sort==="single"&&fe.length===1;!we&&fe.length&&ye.push("sort");const ke=ee.quick?String(ee.quick):"",Ce=!ke||!!ne.quick;Ce||ye.push("quick");const ce=ee.where&&ee.where.active?ee.where:null;ce&&ye.push("where");const ae={filters:le.residual,sort:we?null:fe,quick:Ce?"":ke,where:ce},ge=!!se,de=Array.isArray(ee.groupBy)&&ee.groupBy.length>0,me=de?Y(ee,ne,le,we,Ce,ce,ge):"",ve=ee.pivotMode!==!1&&Array.isArray(ee.pivotBy)&&ee.pivotBy.length>0,xe=ve?O(ee,ne,le,we,Ce,ce):"",Ee=ve&&xe==="";ve&&!Ee&&ye.push("pivot");const Le=ve?Ee&&de:de&&me==="";de&&!ve&&!Le&&ye.push("group");const He=(Le||Ee)&&Array.isArray(ee.groupValues)?ee.groupValues.length:0;ce&&ce.conditioned&&(Le||Ee)&&(ae.where=null,ye.splice(ye.indexOf("where"),1));const Me=Le||ve?!1:ge||!!(ae.filters||ae.sort||ae.quick||ae.where)||!ne.range;return{pushed:{...ee,filters:le.pushed,sort:we?fe:[],quick:Ce?ke:"",range:Me?null:ee.range},residual:ae,needsAll:Me,unpushed:ye,full:ge,grouped:Le,groupLevel:He,groupReason:ve?"":me,pivoted:Ee,pivotReason:xe}}function S(ee){const ne=Array.isArray(ee.totals)?ee.totals:[],se=ee.totalFns&&typeof ee.totalFns=="object"?ee.totalFns:{},le=[],ye=[];for(const fe of ne){const we=String(fe),ke=se[we],Ce=typeof ke=="string"?ke:ke&&typeof ke.fn=="string"?ke.fn:null,ce=ke&&typeof ke=="object"?i(ke):void 0,ae=Ce?r[Ce]:null;ae&&ae.parametric&&ce===void 0?ye.push({id:we,fn:Ce,class:ae.class,reason:`"${Ce}" needs \`p\`, a number from 0 to 1`}):Ce?!ae||!ae.pushable||!ae.sql?ye.push({id:we,fn:Ce,class:ae?ae.class:"fallback",reason:ae&&ae.note?ae.note:`the pushdown map cannot express "${Ce}"`}):ae.twoColumn?ye.push({id:we,fn:Ce,class:ae.class,reason:`"${Ce}" reduces two columns, and a grouped request carries no weight column`}):le.push({id:we,col:we,fn:Ce,class:ae.class,...ce!==void 0?{p:ce}:{}}):ye.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:le,client:ye}}function F(ee){return{...ee,engine:ee.engine.map(ne=>{const se=r[ne.fn];if(!se||!se.sql)return ne;const le=ye=>`"${ye}"`;return{...ne,sql:c(se.sql,le(ne.col),ne.weight!==void 0?le(ne.weight):void 0)}})}}const P=Object.freeze({items:ee=>ee==null?[]:Array.isArray(ee)?ee:[ee]});function M(ee,ne,se){if(!ne)return ee;let le=ee;if(ne.filters&&D(se.evaluateFilters)){const ye=le,fe={count:le.length,handle:Ce=>({id:Ce,get:ce=>d(ye[ce],Ce)}),itemwise:Ce=>ye.some(ce=>Array.isArray(d(ce,Ce)))?P:null},we=se.evaluateFilters(ne.filters,fe),ke=[];for(let Ce=0;Ce<le.length;Ce++)we[Ce]&&ke.push(le[Ce]);le=ke}if(ne.where&&ne.where.active&&(ne.whole||A(ne.where.names,"pushdown"),le=le.filter(ye=>ne.where.passes(ye))),ne.quick){const ye=ne.quick.toLowerCase();le=le.filter(fe=>{if(!fe||typeof fe!="object")return!1;for(const we of Object.values(fe))if(we!=null&&String(we).toLowerCase().includes(ye))return!0;return!1})}if(ne.sort&&ne.sort.length&&D(se.sortMulti)){const ye=[...new Set(ne.sort.map(Ce=>Ce.col))],fe=le,we=ye.map(Ce=>({id:Ce,get:ce=>d(fe[ce],Ce)})),ke=se.sortMulti(we,ne.sort.map(Ce=>({col:Ce.col,dir:Ce.dir})),Uint32Array.from({length:le.length},(Ce,ce)=>ce),{});le=Array.from(ke,Ce=>fe[Ce])}return le}function x(ee){return JSON.stringify({filters:ee.filters||null,sort:ee.sort||[],quick:ee.quick||"",groupBy:ee.groupBy||[],groupPath:ee.groupPath||[],context:ee.context??null})}function U(ee){if(!ee||typeof ee!="object")return 16;let ne="";try{ne=JSON.stringify(ee)}catch{return 200}return ne.length*2+64}function _(ee){const ne=ee||{};return{enabled:!!ne.enabled,maxRows:Number.isFinite(ne.maxRows)?ne.maxRows:1e6,maxBytesEstimate:Number.isFinite(ne.maxBytesEstimate)?ne.maxBytesEstimate:512*1024*1024}}const W=5e4;function q(ee){return Number.isFinite(ee)&&ee>=0?ee:W}function N(ee){return!!ee&&D(ee.then)}async function Q(ee){if(!ee||ee.total!==void 0||!N(ee.pendingTotal))return ee;const ne=await ee.pendingTotal,{pendingTotal:se,...le}=ee;return typeof ne=="number"?{...le,total:ne}:le}function J(ee={}){const ne=ee.adapter;if(!ne||!D(ne.execute))return L("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{...ee,mode:"remote",fetch:async()=>({rows:[],total:0})};const se=b(ne.capabilities),le=ne.capabilities&&Object.getOwnPropertyDescriptor(ne.capabilities,"operators");le&&D(le.get)&&Object.defineProperty(se,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(ne.capabilities.operators||[]),set:()=>{}});const ye=ne.name||"adapter";let fe=null;const we=()=>D(ne.ready)?(fe||(fe=Promise.resolve(ne.ready()).then(()=>{Object.assign(se,b(ne.capabilities))},Ne=>{throw fe=null,Ne})),fe):null,ke=_(ee.fullDataset),Ce=!!ee.allowPartialResults,ce=q(ee.whereRowLimit);let ae=null;const ge=ee.aggregates;let de=null,me=null,ve=null,xe=null,Ee=null,Le=null,He=0,Me=null;const Ke=()=>!ke.enabled||!de?null:(Me!==de.key&&(He++,Me=de.key),{rows:de.rows,version:He}),$e=async Ne=>{const _e=Ne.where&&Ne.where.active?Ne.where:null;if(!_e)return{request:Ne,probe:null};if(_e.conditioned){const Ot=C(Ne,se,ke.enabled);if(Ot.grouped||Ot.pivoted)return{request:Ne,probe:null}}const{where:Ie,...We}=Ne,ze=C(We,se,ke.enabled);if(ze.needsAll)return{request:Ne,probe:null};const Qe=x(ze.pushed);let gt=null;return(!ae||ae.key!==Qe)&&(se.total?(t(Ne),gt=await Q(await ne.execute(ze.pushed,Ne)),ae={key:Qe,size:gt&&typeof gt.total=="number"?gt.total:null}):ae={key:Qe,size:null}),ae.size!==null&&ae.size<ce?{request:Ne,probe:null}:(k(_e.names,ye,ae.size,ce),{request:We,probe:gt})},Oe=async(Ne,_e)=>{Le=null;const Ie=S(Ne.pushed);ve={engine:Ie.engine,client:Ie.client,groupBy:Ne.pushed.groupBy},Ie.client.length&&L(`source.pushdown.group.totals.${ye}.${Ie.client.map(Qe=>Qe.id).join(".")}`,`the ${ye} adapter cannot compute the group subtotal for ${Ie.client.map(Qe=>`"${Qe.id}" (${Qe.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 We=await ne.executeGroupLevel(Ne.pushed,Ie.engine,_e)||{};let ze=We.rows||[];return!se.range&&_e.range&&(ze=ze.slice(_e.range.start,_e.range.end)),Be(We),We.total===void 0?{rows:ze}:{rows:ze,total:We.total}},Se=new Map,Pe=64,Te=async(Ne,_e)=>{Le=null;const Ie=Ne.pushed,We=Ie.groupBy,ze=Array.isArray(Ie.groupValues)?Ie.groupValues:[],Qe=ze.length,gt=[...Ie.filters?[Ie.filters]:[],...We.slice(0,Qe).map((nt,ct)=>({col:nt,op:"eq",value:ze[ct]===void 0?null:ze[ct],caseSensitive:!0}))],Ot=gt.length===0?null:gt.length===1?gt[0]:{op:"and",conditions:gt},bt=_e.range?_e.range.start:0;if(Qe>=We.length){const nt={...Ie,filters:Ot,groupBy:[],groupPath:[],groupValues:[],totals:[],totalFns:{}},ct=await Q(await ne.execute(nt,_e))||{};let $t=ct.rows||[];return!se.range&&_e.range&&($t=$t.slice(_e.range.start,_e.range.end)),typeof ct.total=="number"?{rows:$t,total:ct.total}:{rows:$t}}const ht=We[Qe],Pt=S(Ie),Lt=v(se),jt=Pt.engine.filter(nt=>Lt.has(nt.fn)),Ut=[...Pt.engine.filter(nt=>!Lt.has(nt.fn)).map(nt=>({id:nt.id,fn:nt.fn,class:nt.class,reason:`the ${ye} adapter does not compute "${nt.fn}"`})),...Pt.client];ve={engine:jt,client:Ut,groupBy:We},Ut.length&&L(`source.pushdown.group.totals.${ye}.${Ut.map(nt=>nt.id).join(".")}`,`the ${ye} adapter cannot compute the group subtotal for ${Ut.map(nt=>`"${nt.id}" (${nt.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 rn=[...jt.map(nt=>({id:nt.id,col:nt.col,fn:nt.fn,...nt.p!==void 0?{p:nt.p}:{}})),{id:w,col:ht,fn:"count"}],Wt={...Ie,filters:Ot,range:null},Qt=JSON.stringify([x(Wt),ze,ht,rn]);let Xe=bt>0?Se.get(Qt):void 0;if(!Xe){for(Xe=Promise.resolve(ne.executeGroupedAggregates(Wt,[ht],rn)),Se.delete(Qt),Se.set(Qt,Xe);Se.size>Pe;)Se.delete(Se.keys().next().value);Xe.catch(()=>{Se.get(Qt)===Xe&&Se.delete(Qt)})}const at=await Xe||[];t(_e);const kt=nt=>{const ct={};for(const $t of jt)ct[$t.id]=nt?nt[$t.id]:void 0;return ct},mt=(Ie.sort||[]).find(nt=>nt&&nt.col===ht),wt=mt&&mt.dir==="desc"?-1:1,Ve=at.filter(nt=>nt&&nt.level===1).map(nt=>({[ht]:nt.keys[0]===void 0?null:nt.keys[0],leafCount:Number(nt.values&&nt.values[w])||0,totals:kt(nt.values)})).sort((nt,ct)=>wt*T(nt[ht],ct[ht]));if(Qe===0){const nt=at.find($t=>$t&&$t.level===0),ct=nt?Number(nt.values&&nt.values[w]):NaN;Be({matchCount:Number.isFinite(ct)?ct:Ve.reduce(($t,Ft)=>$t+Ft.leafCount,0),...nt?{grand:kt(nt.values)}:{}})}const lt=_e.range?_e.range.end:Ve.length;return{rows:Ve.slice(bt,lt),total:Ve.length}},Be=Ne=>{typeof Ne.matchCount=="number"&&(xe=Ne.matchCount,Ee=Ne.grand?{totals:Ne.grand,leafCount:Ne.matchCount}:null)},Ge=async(Ne,_e)=>{Le=null;const Ie=S(Ne.pushed);ve={engine:Ie.engine,client:Ie.client,groupBy:Ne.pushed.groupBy,pivotBy:Ne.pushed.pivotBy},Ie.client.length&&L(`source.pushdown.pivot.totals.${ye}.${Ie.client.map(Ot=>Ot.id).join(".")}`,`the ${ye} adapter cannot compute the pivot cells for ${Ie.client.map(Ot=>`"${Ot.id}" (${Ot.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 We=await ne.executePivotLevel(Ne.pushed,Ie.engine,_e)||{};let ze=We.rows||[];!se.range&&_e.range&&(ze=ze.slice(_e.range.start,_e.range.end)),Be(We);const Qe=We.pivot&&typeof We.pivot=="object"?We.pivot:{},gt={cells:Array.isArray(Qe.cells)?Qe.cells:[],...Array.isArray(Qe.axis)?{axis:Qe.axis}:{}};return We.total===void 0?{rows:ze,pivot:gt}:{rows:ze,total:We.total,pivot:gt}},et=Ne=>{L(`source.pushdown.pivot.${ye}.${Ne}`,`pushdown:pivot-unsupported: the ${ye} adapter cannot pivot this query because ${Ne}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);const _e=new Error(`[lattice] ${K}: the ${ye} adapter cannot pivot this query because ${Ne}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);throw _e.code=K,_e.reason=Ne,_e},Je=(Ne,_e)=>{const Ie={key:_e,state:"pending",value:null};return Le=Ie,Ne.then(We=>(Le===Ie&&(Le={key:_e,state:"settled",value:typeof We=="number"?We:null}),We),We=>{throw Le===Ie&&(Le={key:_e,state:"failed",value:null}),We})};let ft=0,Et=[];const Mt=()=>ft===0?null:new Promise(Ne=>{const _e=setTimeout(Ne,m);Et.push(()=>{clearTimeout(_e),Ne()})});let rt;const ot=async Ne=>{const _e=we();_e&&await _e;const We=Ne&&Ne.pivotMode!==!1&&Array.isArray(Ne.pivotBy)&&Ne.pivotBy.length>0?{request:Ne,probe:null}:await $e(Ne);t(Ne);let ze=C(We.request,se,ke.enabled);if(se.group&&ze.grouped&&!ze.pivoted&&!D(ne.executeGroupLevel)&&(L(`source.pushdown.group.method.${ye}`,`the ${ye} 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.`),ze=C(We.request,{...se,group:!1,aggregates:null},ke.enabled)),ze.pivoted&&!D(ne.executePivotLevel)&&(ze=C(We.request,{...se,pivot:!1},ke.enabled),ze.pivotReason="the adapter declares the `pivot` capability but has no `executePivotLevel(query, aggregates, request)`"),ze.grouped&&!ze.pivoted&&!se.group&&!D(ne.executeGroupedAggregates)&&(L(`source.pushdown.group.aggregates.method.${ye}`,`the ${ye} 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\`.`),ze=C(We.request,{...se,aggregates:null},ke.enabled)),me=ze,ze.pivoted)return Ge(ze,Ne);if(ze.pivotReason&&et(ze.pivotReason),ze.grouped)return se.group?Oe(ze,Ne):Te(ze,Ne);const gt=!!ze.groupReason&&!ze.full;gt?L(`source.pushdown.group-unsupported.${ye}.${ze.groupReason}`,`pushdown:group-unsupported: the ${ye} adapter was not asked to group this query because ${ze.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.`):ze.groupReason&&L(`source.pushdown.group.${ye}.${ze.groupReason}`,`the ${ye} adapter was not asked to group this query because ${ze.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 Ot=Wt=>gt?{...Wt,[E]:!0}:Wt;if(!ze.needsAll){const Wt=We.probe||await ne.execute(ze.pushed,Ne),Qt=Wt.rows||[];return N(Wt.pendingTotal)&&Wt.total===void 0?Ot({rows:Qt,pendingTotal:Je(Wt.pendingTotal,x(ze.pushed))}):(Le=null,!se.total&&Wt.total===void 0?Ot({rows:Qt}):Ot({rows:Qt,total:Wt.total??Qt.length}))}const bt=ze.unpushed.filter(Wt=>!(Wt==="where"&&ze.residual.where&&ze.residual.where.anyConditioned));bt.length&&L(`source.pushdown.residual.${ye}.${bt.join(".")}`,`the ${ye} adapter cannot push ${bt.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 ht=x(ze.pushed);if(!de||de.key!==ht){const Wt=await Q(await ne.execute(ze.pushed,Ne));Le=null;const Qt=Wt.rows||[];if(ze.full){const Xe=typeof Wt.total=="number"?Math.max(Wt.total,Qt.length):Qt.length;if(Xe>ke.maxRows)throw new Error(`[lattice] fullDataset refused: the ${ye} adapter's matching set is ${Xe.toLocaleString()} rows, past the configured maxRows of ${ke.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=Qt.length*U(Qt[0]);if(at>ke.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${ye} adapter's matching set is an estimated ${Math.round(at/(1024*1024)).toLocaleString()} MB across ${Qt.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(ke.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 Wt.total=="number"&&Qt.length<Wt.total){const Xe=!!(ze.residual.filters||ze.residual.quick||ze.residual.sort&&ze.residual.sort.length);if(Xe&&!Ce)throw new Error(`[lattice] the ${ye} adapter returned ${Qt.length} of ${Wt.total} matching rows when asked for the whole result, and the query has residual ${ze.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.`);Xe?L(`source.pushdown.partial.residual.${ye}`,`the ${ye} adapter returned ${Qt.length} of ${Wt.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.`):L(`source.pushdown.partial.${ye}`,`the ${ye} adapter returned ${Qt.length} of ${Wt.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}de={key:ht,rows:Qt,total:typeof Wt.total=="number"?Wt.total:null}}let Pt=ze;if(ze.residual.where){const Wt=de.total??de.rows.length;if(Wt>=ce){k(ze.residual.where.names,ye,Wt,ce);const{where:Qt,...Xe}=We.request;Pt=C(Xe,se,ke.enabled),me=Pt}}const Lt=de.total!==null&&de.rows.length>=de.total,jt=M(de.rows,{...Pt.residual,whole:Lt},ee.compute||{}),Ut=Ne.range?Ne.range.start:0,rn=Ne.range?Ne.range.end:jt.length;return Ot({rows:jt.slice(Ut,rn),total:jt.length})},ut=async(Ne,_e,Ie)=>{const ze=Ie&&Ie.waitForPage&&rt&&D(rt.pageForegroundIdle)?rt.pageForegroundIdle():Mt();ze&&await ze;const Qe=we();Qe&&await Qe;const gt=C(Ne,se,ke.enabled);me=gt;const Ot=g(_e,Ie&&Ie.engine?{default:"engine"}:ge),bt=Array.isArray(Ne.groupBy)?Ne.groupBy:[],ht=bt.length>0,Pt=!gt.residual.filters&&!gt.residual.quick,Lt=!ht||a(bt,se.buckets);let jt=Ot.engine,Ut=Ot.client;if(se.aggregates&&jt.length){const at=se.aggregates instanceof Set?se.aggregates:new Set(Z(se.aggregates)),kt=jt.filter(mt=>!at.has(mt.fn));kt.length&&(jt=jt.filter(mt=>at.has(mt.fn)),Ut=[...kt.map(mt=>({...mt,reason:`the ${ye} adapter does not compute "${mt.fn}"`})),...Ut])}const rn=at=>{Ut=[...jt.map(kt=>({...kt,reason:at})),...Ut],jt=[]};let Wt="";if(jt.length&&!Pt){const at=gt.residual.quick&&!gt.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)";rn(at),ht&&(Wt=at)}else if(jt.length&&!Lt){const at="a grouping key the engine cannot form forces all-client (no mixed provenance)";rn(at),Wt=at}let Qt={},Xe;if(jt.length&&(D(ht?ne.executeGroupedAggregates:ne.executeAggregates)?ht?Xe=await ne.executeGroupedAggregates(gt.pushed,bt,jt)||[]:Qt=await ne.executeAggregates(gt.pushed,jt)||{}:(L(`source.pushdown.aggregates.${ye}${ht?".grouped":""}`,`the ${ye} adapter cannot compute ${ht?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),rn(`adapter cannot compute ${ht?"grouped ":""}aggregates`),ht&&(Wt=`the ${ye} adapter cannot compute grouped aggregates`))),ht){const at=Xe!==void 0;at!==gt.grouped&&(me={...gt,grouped:at,groupReason:at?"":Wt||gt.groupReason,unpushed:at?gt.unpushed.filter(kt=>kt!=="group"):gt.unpushed.includes("group")?gt.unpushed:[...gt.unpushed,"group"]})}return ve={engine:jt,client:Ut,...ht?{groupBy:bt}:{}},{values:Qt,engine:jt,client:Ut,...Xe!==void 0?{groups:Xe}:{}}},Tt=async Ne=>{ft++;try{return await ot(Ne)}finally{if(ft--,ft===0&&Et.length){const _e=Et;Et=[];for(const Ie of _e)Ie()}}},xt=o(ee.edit),It=ee.edit&&typeof ee.edit=="object"&&D(ee.edit.commit);let dt=ee.edit;if(xt&&!It)if(se.mutate&&se.mutate.update){const Ne=_e=>{if(!se.mutate||!se.mutate.update)throw new Error(`[lattice] the ${ye} 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 Ie={kind:"update",key:String(_e.key),patch:{[_e.colId]:_e.value}};return ne.mutate(Ie,_e.request||{})};dt={...ee.edit===!0?{}:ee.edit,commit:Ne}}else L(`source.pushdown.readonly.${ye}`,`edit is enabled but the ${ye} adapter declares mutate: ${se.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 ie=xt&&se.mutate&&(se.mutate.append||se.mutate.delete)?{append:se.mutate.append===!0,remove:se.mutate.delete===!0,returning:se.mutate.returning,mutate:(Ne,_e)=>ne.mutate(Ne,_e||{})}:null,pe=async Ne=>{const _e=we();_e&&await _e;const{range:Ie,signal:We,export:ze,...Qe}=Ne||{},gt={...Qe,groupBy:[],groupPath:[],groupValues:[],pivotBy:[],pivotMode:!1,totals:[]};return{plan:C(gt,se,ke.enabled),signal:We}};async function*be(Ne,_e={}){const{plan:Ie,signal:We}=await pe(Ne),ze=Math.max(1,Math.floor(Number(_e.pageSize))||5e3),Qe={signal:We,stream:!0},gt=Ne&&Ne.range&&Number.isFinite(Number(Ne.range.start))&&Number.isFinite(Number(Ne.range.end))?{start:Math.max(0,Number(Ne.range.start)),end:Math.max(0,Number(Ne.range.end))}:null;if(!Ie.needsAll){const ht=gt?gt.start:0,Pt=gt?gt.end:1/0;for(let Lt=ht;Lt<Pt;Lt+=ze){t(Qe);const jt=Math.min(Lt+ze,Pt),Ut=await ne.execute({...Ie.pushed,range:{start:Lt,end:jt}},Qe);Ut&&N(Ut.pendingTotal)&&Ut.pendingTotal.then(null,()=>{});const rn=Ut&&Ut.rows||[];if(rn.length&&(yield rn),rn.length<jt-Lt)return}return}t(Qe);const Ot=await Q(await ne.execute({...Ie.pushed,range:void 0},Qe));let bt=M(Ot&&Ot.rows||[],{...Ie.residual,whole:!0},ee.compute||{});gt&&(bt=bt.slice(gt.start,gt.end));for(let ht=0;ht<bt.length;ht+=ze)yield bt.slice(ht,ht+ze)}const Ae=async Ne=>{const{plan:_e,signal:Ie}=await pe(Ne);if(!_e.needsAll&&se.total){t({signal:Ie});const ze=await Q(await ne.execute({..._e.pushed,range:{start:0,end:0}},{signal:Ie}));if(ze&&typeof ze.total=="number")return ze.total}let We=0;for await(const ze of be({...Ne,range:void 0}))We+=ze.length;return We},je=async Ne=>{await we();const _e=y(Ne.filters||null,{tz:ee.timeZone,weekStartsOn:ee.weekStartsOn}),Ie=Ne.quick?String(Ne.quick):"";return p(_e,se).residual||Ie&&!se.quick?null:ne.facets({...Ne,filters:_e,quick:Ie})};return rt={...ee,edit:dt,rowMutate:ie,mode:"remote",fetch:Tt,foregroundIdle:Mt,facetProvider:D(ne.facets)?je:void 0,aggregate:ut,countMatching:Ae,streamMatching:be,capabilitiesOf:b,planQuery:C,wireFilters:y,resolveAggregatePlan:(Ne,_e)=>g(Ne,_e&&_e.engine?{default:"engine"}:ge),STAT_PUSHDOWN:r,lastPlan:()=>me?{...me,...ve?{aggregates:F(ve)}:{},...Le?{total:{deferred:!0,state:Le.state,value:Le.value}}:{}}:null,fullFrame:Ke,counts:()=>({match:xe,total:xe,pending:!!Le&&Le.state==="pending"}),grandTotals:()=>Ee},rt}}),Ue("packages/core/src/source/remote.js",function(e,B){"use strict";Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return F}});const T=B("packages/core/src/internal/lru.js").Lru,D=B("packages/core/src/internal/predicates.js").isFunction,Z=B("packages/core/src/internal/warn.js").warnOnce,L=B("packages/core/src/internal/schedule.js").settleDebounce,X=B("packages/core/src/source/abort.js"),$=X.createAbortScope,A=X.isAbortError,k=B("packages/core/src/source/blockcache.js"),y=k.BlockCache,f=k.DEFAULT_PAGE_SIZE,g=k.DEFAULT_MAX_CACHED_PAGES,a=B("packages/core/src/source/rows.js"),r=a.createRowFactory,i=a.groupKey,c=B("packages/core/src/source/filterwire.js"),u=c.wireFilters,n=c.querySignature,m=c.warnHostFilterNotApplied,s=B("packages/core/src/source/pagewindow.js").pageWindow,d=B("packages/core/src/source/memory.js").MemorySource,b=B("packages/core/src/compute/handle.js").valueComparator,l=B("packages/core/src/compute/pivot.js"),p=l.pivotKey,w=l.joinPath,v=l.DEFAULT_PATH_SEPARATOR,Y=B("packages/core/src/source/pushdown.js").UNGROUPED_LEVEL,K=1,V=120,E=1e3;function O(P,M,x){for(let U=0;U<Math.max(P.length,M.length);U++){const _=P[U],W=M[U],q=_==null,N=W==null;if(q||N){if(q&&N)continue;return q?1:-1}const Q=x(_,W);if(Q!==0)return Q}return 0}function C(P,M){return new F(P,M)}class S{constructor(M,x,U,_){this.path=M,this.keyPath=_||M,this.values=[],this.level=x,this.key=i(this.keyPath),this.cache=new y(U),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 F{mode="remote";#e;#t;#n;#r;#i=new Map;#s=new Set;#a=$();#l;#o;#c=new Map;#u=[];#f=null;#d="";#h;#p=!1;#m=!1;#g=[];#b=!1;#y=0;#O="";#w=null;#A=-1;constructor(M,x){this.#e=M||{mode:"remote"},this.#t=x||{},D(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#I(),this.unfilteredIndices=()=>this.#G(),this.handleFor=Q=>this.#K(Q),this.display=()=>this.#L(),this.grandTotalRow=()=>this.#U(),this.unfilteredRows=()=>this.#D(),this.facetIndices=Q=>this.#q(Q));const U=this.#e.counts;D(U)&&(this.matchCount=()=>this.#Y("match"),this.totalCount=()=>this.#Y("total"));const _=this.#e.grandTotals;D(_)&&(this.grandTotalRow=()=>this.#z());const W=this.#e.foregroundIdle;D(W)&&(this.foregroundIdle=()=>this.#oe(W),this.#e.pageForegroundIdle=()=>this.#b?this.#oe(W):null);const q=this.#e.facetProvider;D(q)&&(this.facetProvider=q);const N=this.#e;D(N.countMatching)&&D(N.streamMatching)&&(this.selectionQuery=()=>this.#V(),this.countMatching=Q=>N.countMatching(Q),this.streamMatching=(Q,J)=>N.streamMatching(Q,J),this.loadedRows=()=>this.#ge(),this.resident=()=>this.#N()!==null),this.#n={pageSize:this.#e.pageSize||f,maxCachedPages:this.#e.maxCachedPages||g},this.#l=r(this.#t),this.#o=new T(this.#n.pageSize*4),this.#h=L((Q,J)=>this.#T(Q,J),V),this.#r=new S([],0,this.#n),this.#i.set(this.#r.key,this.#r),this.#d=this.#be(),D(this.#e.fetch)||Z("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#de()}count(){const M=this.#S();return M?M.length:this.#v()}#v(){const M=this.#N();return M?M.count():(this.#re(),this.#Ae(this.#r))}#P(){if(this.#N())return!0;const M=x=>{if(x.count===null&&!x.complete)return!1;for(const U of x.children.values())if(this.#Te(U.key,this.#we(U))&&!M(U))return!1;return!0};return M(this.#r)}pageInfo(){const M=this.#S(),x=this.totalPending();if(!M){const U=this.#v();return{page:0,pageSize:0,total:this.#P()?U:null,pageCount:1,counting:x}}return{page:M.page,pageSize:M.pageSize,total:M.total,pageCount:M.pageCount,counting:x||M.total===null&&this.#a.size>0&&this.#r.cache.loadedExtent()===0}}#S(){const M=this.#v(),x=s(this.#$("pageSize",0),this.#$("page",0),M,this.#P());if(!x)return this.#O="",null;const U=`${this.#y}:${x.offset}:${x.length}`;return U!==this.#O&&!this.#p&&(this.#O=U,x.length>0&&!this.#N()&&this.#T(x.offset,x.offset+x.length-1)),x}at(M){const x=this.#S();if(x){if(M<0||M>=x.length)return;const U=this.#C(x.offset+M);return U&&(U.index=M),U}return this.#C(M)}#C(M){const x=this.#N();if(x)return x.at(M);if(this.#re(),M<0||M>=this.#v())return;const U=this.#Z(this.#r,M);if(!U)return;const _=this.#W(U.node,U.local);return _&&(_.index=M),_||this.#l.skeleton(M,U.node.level,U.node.cache.erroredAt(U.local))}byKey(M){const x=this.#N();if(x)return x.byKey(M);const U=this.#c.get(M);if(!U)return;const _=U.lastIndexOf(":"),W=this.#i.get(U.slice(0,_));return W&&this.#W(W,Number(U.slice(_+1)))||void 0}loaded(M){const x=this.#S();if(x){if(M<0||M>=x.length)return!1;M+=x.offset}const U=this.#N();if(U)return U.loaded(M);if(M<0||M>=this.#v())return!1;const _=this.#Z(this.#r,M);return!!_&&_.node.cache.rowLoaded(_.local)}hint(M,x){if(this.#p)return;this.#b=!0;const U=this.#re();let _=Math.max(0,Math.floor(M)),W=Math.max(_,Math.floor(x));const q=this.#S();if(q){if(q.length===0)return;_=q.offset,W=q.offset+q.length-1}for(const[N,Q]of this.#E(_,W)){N.cache.protect(Q.min,Q.max);for(const J of N.cache.evict())this.#Ee(N,J)}this.#h(_,W),U&&this.#h.flush()}#E(M,x){const U=this.#v(),_=new Map;for(let W=M;W<=x&&W<U;W++){const q=this.#Z(this.#r,W);if(!q)continue;const N=_.get(q.node);N?(N.min=Math.min(N.min,q.local),N.max=Math.max(N.max,q.local)):_.set(q.node,{min:q.local,max:q.local})}return _.size||_.set(this.#r,{min:M,max:M}),_}#T(M,x){if(!this.#p)for(const[U,_]of this.#E(M,x)){U.cache.protect(_.min,_.max);const W=U.cache.blockOf(_.min),q=U.cache.blockOf(_.max);for(let N=W;N<=q&&!(U.count!==null&&N*U.cache.pageSize>=U.count);N++)U.cache.has(N)||this.#ue(U,N)}}apply(M){const x={added:[],updated:[],removed:[]};if(!M)return x;if(M.update)for(const U of M.update){const _=this.#c.get(this.#l.keyOf(U,-1));if(!_)continue;this.#o.delete(_);const W=_.lastIndexOf(":"),q=this.#i.get(_.slice(0,W));if(!q)continue;const N=Number(_.slice(W+1)),Q=q.cache.blockOf(N);if(!q.cache.loaded(Q))continue;const{start:J}=q.cache.rangeOf(Q),ee=[];for(let se=J;se<J+q.cache.pageSize;se++){const le=q.cache.rowAt(se);if(le===void 0)break;ee.push(se===N?U:le)}q.cache.fill(Q,ee);const ne=this.#W(q,N);ne&&x.updated.push(ne)}return(M.add&&M.add.length||M.remove&&M.remove.length)&&this.reload({keepExpanded:!0}),x}reload(M){this.#a.abortAll("reload"),this.#h.cancel(),M&&M.keepExpanded===!1&&this.#s.clear(),this.#pe(),this.#H("model:changed",{reason:"reload"})}destroy(){this.#p=!0,this.#h.cancel(),this.#a.abortAll("destroyed"),this.#pe(),this.#i.clear(),this.#s.clear(),this.#w&&D(this.#w.destroy)&&this.#w.destroy(),this.#w=null}expand(M){this.#s.has(M)||(this.#s.add(M),this.#H("group:toggled",{key:M,expanded:!0}),this.#H("model:changed",{reason:"expand",key:M}))}collapse(M){this.#s.delete(M)&&(this.#H("group:toggled",{key:M,expanded:!1}),this.#H("model:changed",{reason:"collapse",key:M}))}expandedKeys(){return[...this.#s]}pivotFields(){return this.#u}pivot(){this.#re();const M=this.#f;if(!M||!M.keys.size||!this.#$("pivotBy",[]).length)return null;if(!M.result){const x=b((this.#t.config||{}).locale),U=[...M.keys.entries()].sort((W,q)=>O(W[1],q[1],x)),_=U.map(([W])=>W);M.result={keys:U.map(([,W])=>W),paths:_,fields:this.#Ce(_),groupPaths:[],columns:_.length*Math.max(1,this.#ve().length),values:M.cells,cells:M.cells,error:null}}return M.result}invalidateHandles(){this.#w&&(D(this.#w.invalidateHandles)&&this.#w.invalidateHandles(),D(this.#w.invalidate)&&this.#w.invalidate("filter"))}#M(){const M=this.#e.fullFrame;return D(M)?M():null}#N(){const M=this.#M();return M?(this.#w||(this.#w=new d({mode:"memory"},this.#R())),M.version!==this.#A&&(this.#w.setRows(M.rows),this.#A=M.version),this.#w):null}#R(){const M=this.#t,x=M.state||{};return{...M,state:{...x,page:()=>0,pageSize:()=>0}}}#I(){const M=this.#N();return M?M.filteredIndices():new Uint32Array(0)}#G(){const M=this.#N();return M?M.unfilteredIndices():new Uint32Array(0)}#K(M){const x=this.#N();return x?x.handleFor(M):void 0}#L(){const M=this.#N();return M?M.display():[]}#q(M){const x=this.#N();return x&&D(x.facetIndices)?x.facetIndices(M):new Uint32Array(0)}#U(){const M=this.#N();return M&&D(M.grandTotalRow)?M.grandTotalRow():null}#Y(M){const x=this.#N();if(x){const q=M==="match"?x.matchCount:x.totalCount;if(D(q))return q.call(x)}const U=this.#e.counts,_=D(U)?U():null,W=_?_[M]:null;return typeof W=="number"?W:this.#v()}#z(){const M=this.#N();if(M&&D(M.grandTotalRow))return M.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const U=this.#e.grandTotals,_=D(U)?U():null;return!_||!_.totals?null:this.#l.grandTotal(_.totals,_.leafCount||0)}#D(){const M=this.#N();if(M&&D(M.unfilteredRows))return M.unfilteredRows();const x=[],U=this.count();for(let _=0;_<U;_++){const W=this.at(_);W&&x.push(W)}return x}#V(){const M=this.#$("quick",""),x={protocol:K,groupPath:[],groupValues:[],groupBy:[],totals:[],totalFns:{},pivotBy:[],pivotMode:!1,filters:u(this.#$("filters",null),this.#J()),sort:this.#$("sort",[]),context:this.#$("context",null)};M&&(x.quick=M);const U=this.#$("where",null);return U&&U.active&&(x.where=U),x}#ge(){const M=this.#$("groupBy",[]).length,x=[];for(const U of this.#i.values())if(!(U.level!==M&&!U.flat))for(const _ of U.cache.ids()){if(!U.cache.loaded(_))continue;const{start:W,end:q}=U.cache.rangeOf(_);for(let N=W;N<q&&U.cache.rowLoaded(N);N++){const Q=this.#W(U,N);Q&&!Q.group&&x.push(Q)}}return x}loadedCount(){const M=this.#N();if(M){const _=M.matchCount();return typeof _=="number"?_:M.count()}this.#re();const x=this.#$("groupBy",[]).length;let U=0;for(const _ of this.#i.values())if(!(_.level!==x&&!_.flat))for(const W of _.cache.ids()){if(!_.cache.loaded(W))continue;const q=_.cache.fillOf(W);typeof q=="number"&&(U+=q)}return U}residentRows(){const M=this.#N();return M?M.display():this.#$("groupBy",[]).length>0?null:(this.#re(),this.#ge())}#se(M,x,U){const{start:_,end:W}=M.cache.rangeOf(x),q=this.#$("groupBy",[]),N=this.#$("pivotBy",[]),Q=this.#$("quick",""),J=this.#ve(),ee={protocol:K,range:{start:_,end:W},groupPath:M.path,groupValues:M.values,groupBy:q,totals:J,totalFns:this.#Se(J),pivotBy:N,pivotMode:N.length>0,filters:u(this.#$("filters",null),this.#J()),sort:this.#$("sort",[]),context:this.#$("context",null),signal:U};Q&&(ee.quick=Q);const ne=this.#$("where",null);return ne&&ne.active&&(ee.where=ne),ee}async#ue(M,x){if(!D(this.#e.fetch))return;if(!this.#m){this.#m=!0;const q=this.#g;this.#g=[],queueMicrotask(()=>{for(const N of q)N()})}const U=this.#a.begin(`${M.key}:${x}`);M.cache.begin(x,U);const _=this.#d,{start:W}=M.cache.rangeOf(x);try{const q=await this.#e.fetch(this.#se(M,x,U.signal));if(!U.current||_!==this.#d||this.#p)return;U.settle();const N=q&&q.rows||[];if(!!(q&&q[Y])&&!M.flat){M.flat=!0,M.children.clear();for(const[ne,se]of[...this.#c])se.startsWith(`${M.key}:`)&&(this.#o.delete(se),this.#c.delete(ne))}M.cache.fill(x,N),M.failed=!1;for(let ne=0;ne<N.length;ne++)this.#o.delete(`${M.key}:${W+ne}`);const J=q&&typeof q.count=="number"?q.count:q&&typeof q.total=="number"?q.total:null,ee=q&&D(q.pendingTotal?.then)?q.pendingTotal:null;J!==null?(M.count=J,M.complete=!0):N.length<M.cache.pageSize?(M.count=W+N.length,M.complete=!0):ee&&(M.counting=!0,M.announced=null),q&&Array.isArray(q.pivotFields)&&this.#He(q.pivotFields),q&&q.pivot&&typeof q.pivot=="object"&&this.#ae(q.pivot),this.#H("model:changed",{reason:"page",groupPath:M.path,block:x}),this.#H("rows:changed",{companion:!0,reason:"page",groupPath:M.path,block:x}),this.#fe(M),ee&&this.#Me(M,ee,_)}catch(q){if(U.settle(),A(q))return;M.cache.failed(x,q),M.failed=!0;const{end:N}=M.cache.rangeOf(x);for(let Q=W;Q<N;Q++)this.#o.delete(`${M.key}:${Q}`);this.#H("model:changed",{reason:"page-error",groupPath:M.path,block:x}),this.#H("source:error",{error:q,groupPath:M.path,block:x})}}async#Me(M,x,U){let _;try{_=await x}catch(W){if(U!==this.#d||this.#p)return;M.counting=!1,A(W)||(M.failed=!0),A(W)||this.#H("source:error",{error:W,groupPath:M.path});return}U!==this.#d||this.#p||(M.counting=!1,typeof _=="number"&&(M.count=_,M.complete=!0,this.#fe(M),this.#H("model:changed",{reason:"total",count:_,groupPath:M.path})))}#fe(M){typeof M.count!="number"||!M.complete||M.announced!==M.count&&(M.announced=M.count,this.#H("source:total",{total:M.count,groupPath:M.path}))}#oe(M){if(this.#p)return null;this.#re();const x=this.#m?null:new Promise(N=>{this.#g.push(N),setTimeout(N,E)}),U=M();if(!x&&!U)return null;const _=(async()=>{x&&await x;for(let N=M();N;N=M())await N})();let W;const q=new Promise(N=>{W=setTimeout(N,E)});return Promise.race([_,q]).then(()=>clearTimeout(W))}totalPending(){if(this.#r.failed)return!1;if(this.#r.counting===!0)return!0;if(this.#N())return!1;this.#re();const M=this.#r;return M.count===null&&!M.complete&&M.cache.loadedExtent()===0}totalFailed(){return this.#r.failed===!0}#He(M){M.length===this.#u.length&&M.every((x,U)=>x===this.#u[U])||(this.#u=M,this.#H("column:pivoted",{pivotFields:M,remote:!0}))}#xe(){const M=this.#t.config||{};return M.pivot&&M.pivot.separator||v}#Ce(M){const x=this.#xe(),U=this.#ve();if(!U.length)return M.slice();const _=[];for(const W of M)for(const q of U)_.push(`${W}${x}${q}`);return _}#ae(M){const x=this.#xe();this.#f||(this.#f={keys:new Map,cells:new Map,result:null});const U=this.#f;let _=!1;const W=N=>{const Q=Array.isArray(N)?N:[N],J=w(Q,x);return U.keys.has(J)||(U.keys.set(J,Q),_=!0),J},q=this.#$("groupBy",[]).length>0;for(const N of Array.isArray(M.axis)?M.axis:[])W(N);for(const N of Array.isArray(M.cells)?M.cells:[]){if(!N||typeof N!="object")continue;const Q=W(N.pivot);if(q&&!(Array.isArray(N.group)&&N.group.length))continue;const J=w(Array.isArray(N.group)?N.group:[],x);for(const[ee,ne]of Object.entries(N.values||{}))U.cells.set(p(J,Q,ee),ne)}U.result=null,_&&this.#He((this.pivot()||{fields:[]}).fields)}#Ae(M){let x=this.#le(M);for(const U of M.children.values())this.#Te(U.key,this.#we(U))&&(x+=this.#Ae(U));return x}#le(M){if(M.count!==null)return M.count;const x=M.cache.loadedExtent();return M.complete?x:M.row&&M.row.leafCount>0?M.level>=this.#$("groupBy",[]).length?Math.max(x,M.row.leafCount):x===0?1:Math.min(x+M.cache.pageSize,Math.max(x,M.row.leafCount)):x+M.cache.pageSize}#Z(M,x){let U=x,_=0;const W=[...M.children.entries()].filter(([,N])=>this.#Te(N.key,this.#we(N))).sort((N,Q)=>N[0]-Q[0]);for(const[N,Q]of W){const J=N-_+1;if(U<J)return{node:M,local:_+U};U-=J,_=N+1;const ee=this.#Ae(Q);if(U<ee)return this.#Z(Q,U);U-=ee}const q=this.#le(M);return _+U<q?{node:M,local:_+U}:null}#W(M,x){const U=`${M.key}:${x}`,_=this.#o.get(U);if(_)return _.group===!0?this.#B(_):_;const W=M.cache.rowAt(x);if(W===void 0)return null;const q=this.#$("groupBy",[]);let N;if(M.level<q.length&&!M.flat){const Q=q[M.level],J=this.#f!==null&&M.level===q.length-1&&this.#$("pivotBy",[]).length>0,ee=this.#ye(W,Q),ne=ee==null,se=[...M.path,ne?"":String(ee)],le=[...M.keyPath,ne?null:String(ee)];if(N=this.#l.group({path:se,keyPath:le,column:Q,value:ee,level:M.level,parent:M.row,leafCount:Number(W.leafCount)||0,expanded:J?!1:this.#Te(i(le),{key:i(le),column:Q,value:ee,level:M.level,path:se}),...J?{hasChildren:!1}:{}}),N.totals=this.#ne(W),N.data=W,!J){let ye=this.#i.get(N.key);ye?ye.row=N:(ye=new S(se,M.level+1,this.#n,le),ye.row=N,this.#i.set(ye.key,ye)),ye.values=[...M.values,ee],M.children.set(x,ye)}}else N=this.#l.leaf(W,x,M.level,M.row);return this.#o.set(U,N),this.#c.set(N.key,U),N}#ne(M){const x=M||{};if(x.totals&&typeof x.totals=="object")return x.totals;const U={};for(const _ of this.#ve())Object.hasOwn(x,_)&&(U[_]=x[_]);return U}#B(M){const x=this.#i.get(M.key);if(!x||x.row!==M||M.hasChildren===!1)return M;const U=this.#Te(M.key,this.#we(x));return M.expanded!==U&&(M.expanded=U),M}#Ee(M,x){const{start:U,end:_}=M.cache.rangeOf(x);for(let W=U;W<_;W++){const q=`${M.key}:${W}`,N=this.#o.peek(q);N&&this.#c.delete(N.key),this.#o.delete(q)}}#re(){const M=this.#be();return M===this.#d?!1:(this.#d=M,this.#a.abortAll("query"),this.#pe(),this.#m=!1,this.#H("model:changed",{reason:"query"}),!0)}#pe(){for(const M of this.#i.values())M.cache.clear(),M.count=null,M.complete=!1,M.announced=null,M.counting=!1,M.failed=!1,M.children.clear(),M.flat=!1;this.#o.clear(),this.#c.clear(),this.#y++,this.#f=null}#be(){const M=this.#$("where",null);return`${n({filters:this.#$("filters",null),sort:this.#$("sort",[]),quick:this.#$("quick",""),groupBy:this.#$("groupBy",[]),pivotBy:this.#$("pivotBy",[]),context:this.#$("context",null)})}|${M?M.version:0}`}#Te(M,x){const U=this.#$("expanded",null);return U?D(U.has)?U.has(M,x):Array.prototype.includes.call(U,M):this.#s.has(M)}#we(M){if(M.row)return{key:M.key,column:M.row.column,value:M.row.value,level:M.level-1,path:M.path}}#ve(){const M=this.#$("totals",[]);if(M&&M.length)return[...M];const x=this.#t.columns;return!x||!D(x.all)?[]:x.all().filter(U=>!!U.total).map(U=>U.id)}#Se(M){const x=this.#t.columns,U={};if(!x||!D(x.get))return U;for(const _ of M){const W=x.get(_);if(!W)continue;const q=W.groupTotal!=null?W.groupTotal:W.total;typeof q=="string"?U[_]=q:q&&typeof q=="object"&&typeof q.fn=="string"&&(U[_]={...q})}return U}#ye(M,x){const U=this.#t.columns,_=U&&D(U.get)?U.get(x):void 0;return _&&D(_.getValue)?_.getValue(M):M?.[x]}#de(){m(this.#t)}#J(){const M=this.#t.config||{};return{tz:M.timeZone,weekStartsOn:M.weekStartsOn}}#$(M,x){const U=this.#t.state;if(U&&D(U[M])){const _=U[M]();return _??x}return x}#H(M,x){const U=this.#t.emit;D(U)&&U(M,x)}}}),Ue("packages/core/src/source/gapbuffer.js",function(e,B){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return T}});const re=64;class T{#e;#t=0;#n=0;constructor(D=re){this.#e=new Uint32Array(Math.max(1,D)),this.#n=this.#e.length}static from(D,I=re){const Z=new T(D.length+Math.max(1,I));return Z.#e.set(D,0),Z.#t=D.length,Z.#n=Z.#e.length,Z}get length(){return this.#t+(this.#e.length-this.#n)}get capacity(){return this.#e.length}at(D){return D<0||D>=this.length?0:D<this.#t?this.#e[D]:this.#e[D+(this.#n-this.#t)]}insert(D,I){const Z=D<0?0:D>this.length?this.length:D;this.#r(Z),this.#t===this.#n&&this.#i(),this.#e[this.#t++]=I}push(D){this.insert(this.length,D)}removeAt(D){return!Number.isInteger(D)||D<0||D>=this.length?!1:(this.#r(D),this.#n++,!0)}toArray(){const D=new Uint32Array(this.length);return D.set(this.#e.subarray(0,this.#t),0),D.set(this.#e.subarray(this.#n),this.#t),D}clear(){this.#t=0,this.#n=this.#e.length}#r(D){if(D!==this.#t)if(D<this.#t){const I=this.#t-D;this.#e.copyWithin(this.#n-I,D,this.#t),this.#t=D,this.#n-=I}else{const I=D-this.#t;this.#e.copyWithin(this.#t,this.#n,this.#n+I),this.#t=D,this.#n+=I}}#i(){const D=this.#e.length-this.#n,I=new Uint32Array(Math.max(this.#e.length*2,this.#e.length+re));I.set(this.#e.subarray(0,this.#t),0),I.set(this.#e.subarray(this.#n),I.length-D),this.#e=I,this.#n=I.length-D}}}),Ue("packages/core/src/store/ingest.js",function(e,B){"use strict";Object.defineProperty(e,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"inferKind",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"decideText",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"createReaders",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"Ingest",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return u}});const re=B("packages/core/src/internal/schedule.js"),T=re.now,G=re.nextFrame,D=B("packages/core/src/internal/warn.js"),I=D.infoOnce,Z=D.warnOnce,L=B("packages/core/src/internal/predicates.js").isFunction,$=B("packages/core/src/internal/paths.js").pathGetter,k=B("packages/core/src/store/columnstore.js").ColumnStore,y=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function f(n,m={}){if(m.multi)return"multi";if(n.length===0)return"object";let t=0,s=0,h=0,d=0,o=0;for(let l=0;l<n.length;l++){const p=n[l];typeof p=="number"?t++:typeof p=="boolean"?s++:typeof p=="string"?h++:p instanceof Date?d++:Array.isArray(p)&&o++}const b=n.length;return t===b?"float64":s===b?"bitset":d===b?"float64":h===b?"text":o===b?"multi":"object"}function g(n,m,t){return m<=0||n<t*m?"dictionary":"object"}function a(n,m,t){const s=new Map,h=new Map;for(const K of n){if(K.computed)continue;const V=L(K.read)?K.read:$(K.field||K.id);h.set(K.id,V),s.set(K.id,V)}const d=m?.order??[],o=m?.fns??{},b=m?.deps??{},l=m?.wrapDeps??null,p=d.filter(K=>L(o[K])),w=p.some(K=>b[K]==="*");let v=new WeakMap;const R=K=>{const V={};if(w)for(const[E,O]of h)V[E]=O(K);for(const E of p){const O=b[E];let C;if(O==="*")C=V;else{C={};const S=O||[];for(let F=0;F<S.length;F++){const P=S[F];C[P]=P in V?V[P]:h.get(P)?.(K)}}V[E]=o[E](l?l(C,E):C,{data:K,row:null,column:null,grid:null,context:t})}return V},Y=K=>{if(K===null||typeof K!="object"&&typeof K!="function")return R(K);let V=v.get(K);return V===void 0&&(V=R(K),v.set(K,V)),V};for(const K of p)s.set(K,V=>Y(V)[K]);return{readers:s,reset(){v=new WeakMap}}}class r{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(m,t){this.spec=m,this.read=t,this.kind="object",this.inferred=!1,this.nullable=m.nullable!==!1}}class i{#e;#t=[];#n=null;#r;#i=0;#s;#a=!1;#l=!1;#o=0;#c;constructor(m,t={},s={}){this.#e=Array.isArray(m)?m:Array.from(m||[]),this.#s={...y,...s};const h=t.columns??[];this.#r=a(h,t.computed??null,t.context),this.#c=this.#e.length>=this.#s.columnarBelow,this.#u(h,t.computed??null),this.#n=new k(this.#t.map(d=>({id:d.spec.id,kind:d.kind,nullable:d.nullable,read:d.read,dictionary:d.spec.dictionary})),{initialCapacity:this.#s.initialCapacity,columnarBelow:this.#s.columnarBelow})}get store(){return this.#n}get done(){return this.#a||this.#l}get progress(){return this.#i}slice(){if(this.done)return!1;if(this.#s.signal?.aborted)return this.#l=!0,!1;const m=T(),{chunkMs:t,chunkRows:s}=this.#s,h=this.#e.length;do{const d=Math.min(this.#i+s,h);this.#n.append(this.#e.slice(this.#i,d)),this.#f(this.#i,d),this.#i=d,this.#r.reset(),this.#h(!1)}while(this.#i<h&&T()-m<t);return this.#o+=T()-m,this.#s.onProgress?.({loaded:this.#i,total:h}),this.#i>=h?(this.#h(!0),this.#a=!0,!1):!0}cancel(){this.#l=!0}result(){return{store:this.#n,schema:this.#t.map(m=>({id:m.spec.id,kind:m.kind,nullable:m.nullable,read:m.read,dictionary:m.spec.dictionary})),decisions:this.#t.map(m=>({id:m.spec.id,kind:m.kind,nullable:m.nullable,inferred:m.inferred,distinct:m.candidate||m.change?this.#d(m):null,change:m.change,reason:m.reason})),count:this.#n.count,elapsed:this.#o,cancelled:this.#l}}#u(m,t){const s=this.#e,h=Math.min(this.#s.sampleSize,s.length),d=this.#s.dictionaryRatio,o=t?.pure instanceof Set?t.pure:new Set(t?.pure??t?.order??[]);for(const b of m){if(!b||!b.id)continue;if(b.computed&&(b.pure===!1||t&&!o.has(b.id))){Z(`ingest.impure.${b.id}`,`column "${b.id}" is an impure computed column and is not materialised into the store`);continue}const l=this.#r.readers.get(b.id)??(L(b.read)?b.read:$(b.field||b.id)),p=new r(b,l);if(b.kind)p.kind=b.kind,p.reason="declared by the caller";else if(b.dictionary)p.kind=b.multi?"multi":"dictionary",p.reason="value table supplied (lookup column)";else{const w=[];for(let R=0;R<h&&w.length<this.#s.sampleSize;R++){const Y=l(s[R]);Y!=null&&w.push(Y)}p.inferred=!0;const v=f(w,{multi:b.multi});if(v==="text"){const R=new Set(w).size;p.kind=g(R,w.length,d),p.candidate=this.#c,p.reason=`sampled ${R} distinct in ${w.length}`}else p.kind=v,p.reason=`inferred from ${w.length} sampled values`,v==="object"&&w.length&&I(`ingest.mixed.${b.id}`,`column "${b.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);p.kind==="object"&&p.candidate&&(p.distinct=new Set(w))}this.#t.push(p)}}#f(m,t){const s=this.#e;for(const h of this.#t){if(!h.candidate||!h.distinct)continue;const d=h.distinct;for(let o=m;o<t;o++){const b=h.read(s[o]);b!=null&&d.add(b)}}}#d(m){if(m.distinct)return m.distinct.size;const t=this.#n.column(m.spec.id);return t?.dict?t.dict.size:0}#h(m){const t=this.#s.dictionaryRatio,s=this.#e.length;for(const h of this.#t){if(!h.candidate)continue;const d=this.#d(h);if(h.kind==="dictionary"&&d>=t*s){const o=this.#n.column(h.spec.id);h.distinct=new Set(o?.dict?o.dict.values():[]),this.#n.convert(h.spec.id,"object"),h.kind="object",h.change="demoted",h.reason=`${d} distinct values is at or above ${t*100}% of ${s} rows`;continue}if(h.kind==="object"&&d>=t*s){h.candidate=!1,h.distinct=null,h.reason=`${d} distinct values is at or above ${t*100}% of ${s} rows`;continue}m&&h.kind==="object"&&d<t*s&&(this.#n.convert(h.spec.id,"dictionary"),h.kind="dictionary",h.change=h.change==="demoted"?null:"promoted",h.reason=`${d} distinct values is below ${t*100}% of ${s} rows`,h.distinct=null),m&&(h.candidate=!1)}}}async function c(n,m={},t={}){const s=new i(n,m,t),h=t.scheduler?.frame??G;for(;s.slice();)await new Promise(d=>{h(d)});return s.result()}function u(n,m={},t={}){const s=new i(n,m,{...t,chunkMs:1/0});for(;s.slice(););return s.result()}}),Ue("packages/core/src/store/columnpack.js",function(e,B){"use strict";Object.defineProperty(e,"isPortableSchema",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"packChunk",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"packedTransfers",{enumerable:!0,get:function(){return g}});const T=B("packages/core/src/internal/paths.js").pathGetter,G=B("packages/core/src/store/ingest.js"),D=G.inferKind,I=G.decideText,Z=G.INGEST_DEFAULTS,L=B("packages/core/src/store/columnstore.js").toFloat,X=new Set(["float64","int32","bitset","dictionary","object","multi"]);function $(a){if(!Array.isArray(a)||a.length===0)return!1;for(const r of a)if(!r||typeof r.id!="string"||typeof r.field!="string"||r.field===""||r.kind&&!X.has(r.kind))return!1;return!0}function A(a){const r=L(a);return Number.isFinite(r)?r|0:0}function k(a){return a==null?[]:Array.isArray(a)?a:[a]}function y(a,r,i,c){if(a.kind)return a.kind;const u=[];for(let t=0;t<r.length&&u.length<Z.sampleSize;t++){const s=r[t];s!=null&&u.push(s)}const n=D(u,{multi:a.multi});if(n!=="text")return n;const m=new Set(u).size;return I(m,u.length,c)}function f(a,r,i={}){const c=r.length|0,u=i.dictionaryRatio??Z.dictionaryRatio,n=[];for(const m of a){const t=T(m.field||m.id),s=m.nullable!==!1,h=new Array(c);for(let p=0;p<c;p++){const w=t(r[p]);h[p]=w===void 0?null:w}const d=y(m,h,c,u),o=s?new Uint8Array(c+7>>3):null,b=p=>{o&&(o[p>>3]|=1<<(p&7))};let l;switch(d){case"float64":{const p=new Float64Array(c);for(let w=0;w<c;w++){const v=h[w],R=v===null;R||b(w),p[w]=R?NaN:L(v)}l={id:m.id,kind:d,nullable:s,values:p,presence:o,offsets:null,table:null};break}case"int32":{const p=new Int32Array(c);for(let w=0;w<c;w++){const v=h[w],R=v===null;R||b(w),p[w]=R?0:A(v)}l={id:m.id,kind:d,nullable:s,values:p,presence:o,offsets:null,table:null};break}case"bitset":{const p=new Uint8Array(c+7>>3);for(let w=0;w<c;w++){const v=h[w],R=v===null;R||b(w),!R&&v&&(p[w>>3]|=1<<(w&7))}l={id:m.id,kind:d,nullable:s,values:p,presence:o,offsets:null,table:null};break}case"dictionary":{const p=new Uint32Array(c),w=[],v=new Map;for(let R=0;R<c;R++){const Y=h[R];if(Y===null){p[R]=0;continue}b(R);let K=v.get(Y);K===void 0&&(K=w.length,w.push(Y),v.set(Y,K)),p[R]=K}l={id:m.id,kind:d,nullable:s,values:p,presence:o,offsets:null,table:w};break}case"multi":{const p=[],w=new Map,v=new Uint32Array(c+1),R=[];for(let Y=0;Y<c;Y++){const K=h[Y];v[Y]=R.length,K===null||b(Y);const E=k(K);for(let O=0;O<E.length;O++){const C=E[O];let S=w.get(C);S===void 0&&(S=p.length,p.push(C),w.set(C,S)),R.push(S)}}v[c]=R.length,l={id:m.id,kind:d,nullable:s,values:Int32Array.from(R),presence:o,offsets:v,table:p};break}default:{const p=new Array(c);for(let w=0;w<c;w++){const v=h[w];v!==null&&b(w),p[w]=v}l={id:m.id,kind:"object",nullable:s,values:p,presence:o,offsets:null,table:null};break}}n.push(l)}return{count:c,columns:n}}function g(a){const r=[];if(!a||!Array.isArray(a.columns))return r;const i=c=>{ArrayBuffer.isView(c)&&c.buffer&&!r.includes(c.buffer)&&r.push(c.buffer)};for(const c of a.columns)i(c.values),i(c.presence),i(c.offsets);return r}}),Ue("packages/core/src/source/stream.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_PROMOTE_BELOW",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"StreamSource",{enumerable:!0,get:function(){return S}});const T=B("packages/core/src/internal/lru.js").Lru,D=B("packages/core/src/internal/predicates.js").isFunction,I=B("packages/core/src/internal/schedule.js"),Z=I.now,z=I.nextFrame,L=I.cancelFrame,X=I.whenIdle,A=B("packages/core/src/internal/compare.js").defaultCompare,k=B("packages/core/src/internal/warn.js"),y=k.warnOnce,f=k.infoOnce,a=B("packages/core/src/internal/paths.js").getPath,r=B("packages/core/src/source/abort.js"),i=r.createAbortScope,c=r.isAbortError,u=B("packages/core/src/source/rows.js"),n=u.createRowFactory,m=u.lazyRowView,s=B("packages/core/src/source/gapbuffer.js").GapBuffer,d=B("packages/core/src/source/memory.js").createMemorySource,b=B("packages/core/src/source/filterwire.js").querySignature,p=B("packages/core/src/store/columnpack.js").isPortableSchema,w=25e4,v=Symbol("lattice.stream.storeBacked"),R=8,Y=.1,K=1e3,V=50;function E(F){return Math.min(K,Math.max(V,Math.floor(F/4)))}function O(F){if(F instanceof Date)return F.getTime();if(typeof F=="number")return Number.isFinite(F)?F:NaN;if(typeof F=="string"){const P=F.trim();if(!P)return NaN;const M=Date.parse(P);return Number.isNaN(M)?Number(P):M}return NaN}function C(F,P){return new S(F,P)}class S{mode="stream";writesStore=!0;#e;#t;#n=[];#r=null;#i=[];#s=null;#a;#l;#o=new Map;#c=i();#u={loaded:0,estimated:void 0};#f=null;#d=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;#I=null;#G=null;#K=null;#L=!1;#q=0;#U=0;#Y=!1;constructor(P,M){this.#e=P||{mode:"stream"},this.#t=M||{},this.#a=n(this.#t),this.#l=new T(4096),this.#P=this.#qe();const x=(this.#t.config||{}).ingest;this.#L=!!x&&x.retainSource===!1,D(this.#e.open)||y("source.stream.open",'source.mode "stream" requires an open function; the grid will stay empty.'),this.#e.autoStart!==!1&&queueMicrotask(()=>this.start());const U=Number(this.#e.poll);Number.isFinite(U)&&U>0&&(this.#K=setInterval(()=>{this.#v||this.reload()},U),this.#K&&D(this.#K.unref)&&this.#K.unref()),this.#D()}#z(){const P=Number(this.#e.maxAge);return Number.isFinite(P)&&P>0?P:0}#D(){const P=this.#z();if(!P)return;const M=this.#e.ageBy;D(M)?this.#I=M:typeof M=="string"&&M?this.#I=x=>a(x,M):this.#I=null,this.#T=[],this.#R=setInterval(()=>{this.#v||this.#V()&&(this.#Ee(),this.#H())},E(P)),this.#R&&D(this.#R.unref)&&this.#R.unref()}#V(){const P=this.#z();return!P||!this.#T?!1:this.#N?!0:this.#M<Date.now()-P*(1+Y)}#ge(P,M){if(!this.#T)return;const x=this.#I?O(this.#I(M)):Date.now();this.#T[P]=x,Number.isNaN(x)||(x<this.#M&&(this.#M=x),x<Date.now()-this.#z()&&(this.#N=!0))}#se(){return this.#Oe("groupBy",[]).length>0?!0:!!this.#Oe("pivotMode",!1)&&this.#Oe("pivotBy",[]).length>0}#ue(){if(this.#g||this.#v)return;const P=this.#se();if(P&&!this.#b){this.#b=d({mode:"memory",rows:this.#n},this.#Me()),this.#O=!1;return}!P&&this.#b&&(this.#b.destroy(),this.#b=null)}#Me(){if(this.#y)return this.#y;const P=this,M={liveIndices:()=>P.#fe(),live:x=>P.#n[x]!==void 0,source:x=>P.#ee(x),get physical(){return P.#n.length}};return this.#L&&(M.column=x=>{const U=P.#t.store;return U&&D(U.column)?U.column(x):void 0}),this.#y=Object.create(this.#t,{store:{value:M,enumerable:!0,configurable:!0}}),this.#y}#fe(){const P=new Uint32Array(this.#n.length);let M=0;for(let x=0;x<this.#n.length;x++)this.#n[x]!==void 0&&(P[M++]=x);return P.subarray(0,M)}#oe(){return this.#g?this.#g:this.#b?(this.#O&&(this.#O=!1,this.#b.setRows(this.#n)),this.#b):null}invalidate(P="filter"){if(this.#g){this.#g.invalidate(P);return}this.#ue(),this.#b&&this.#b.invalidate(P),(P==="filter"||P==="sort")&&this.#Te()}count(){const P=this.#oe();return P?P.count():this.#r?this.#r.length:this.#S}matchCount(){const P=this.#oe();return P&&D(P.matchCount)?P.matchCount():this.#r?this.#r.length:this.#S}totalCount(){const P=this.#oe();return P&&D(P.totalCount)?P.totalCount():this.#S}unfilteredRows(){const P=this.#oe();if(P&&D(P.unfilteredRows))return P.unfilteredRows();const M=[];for(let x=0;x<this.#n.length;x++){if(!this.#n[x])continue;const U=this.#je(x);U&&M.push(U)}return M}at(P){const M=this.#oe();if(M)return M.at(P);if(P<0||P>=this.count())return;const x=this.#r?this.#r.at(P):P,U=this.#je(x);return U.index=P,U}byKey(P){const M=this.#oe();if(M)return M.byKey(P);const x=this.#o.get(P);return x===void 0?void 0:this.#je(x)}leavesOf(P){const M=this.#oe();return M&&D(M.leavesOf)?M.leavesOf(P):[]}loaded(P){return P>=0&&P<this.count()}hint(P,M){if(this.#g){this.#g.hint(P,M);return}this.#He(),this.#p=Math.max(0,Math.floor(P))}#He(){this.#v||this.#qe()===this.#P||this.reload()}display(){const P=this.#oe();return P?P.display():m(()=>this.count(),M=>this.at(M))}apply(P){if(this.#g)return this.#g.apply(P);const M={added:[],updated:[],removed:[]};if(!P)return M;if(P.update){let x=!1;for(const U of P.update){const _=this.#o.get(this.#a.keyOf(U,-1));if(_===void 0)continue;const W=this.#Se(_);this.#L?this.#Le(_,U):this.#n[_]=U,this.#l.delete(_),this.#ye(_,W),this.#T&&(this.#ge(_,U),x=!0),this.#O=!0,M.updated.push(this.#je(_))}x&&this.#Ee()}if(P.add&&P.add.length){const x=this.#ne(P.add);for(const U of x)M.added.push(this.#je(U))}return P.remove&&P.remove.length&&y("source.stream.remove","removing rows from a live stream is not supported; reload instead."),this.#H(),M}reload(P){this.#c.abortAll("reload"),this.#Ye(),this.#b&&(this.#b.destroy(),this.#b=null),this.#O=!1,this.#n=[],this.#r=null,this.#o.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.#qe(),this.#Pe("model:changed",{reason:"reload"}),this.start()}destroy(){this.#v=!0,this.#K!==null&&(clearInterval(this.#K),this.#K=null),this.#R!==null&&(clearInterval(this.#R),this.#R=null),this.#T=null,this.#c.abortAll("destroyed"),this.#Ye(),this.#f!==null&&(this.#ke(this.#f),this.#f=null),this.#b&&(this.#b.destroy(),this.#b=null),this.#g&&this.#g.destroy(),this.#n=[],this.#r=null,this.#o.clear(),this.#l.clear()}async start(){if(this.#A||this.#v||!D(this.#e.open))return;this.#A=!0;const P=this.#c.begin("stream");this.#Te(),this.#ue();let M;try{M=this.#e.open({sort:this.#Oe("sort",[]),filters:this.#Oe("filters",null),quick:this.#Oe("quick","")||void 0,context:this.#Oe("context",null),signal:P.signal})}catch(U){this.#Pe("source:error",{error:U});return}const x=D(M[Symbol.asyncIterator])?M[Symbol.asyncIterator]():M[Symbol.iterator]();this.#G=x;try{for(;;){const U=await x.next();if(!P.current||this.#v)return;if(U.done){this.#$();return}if(await this.#xe(U.value,P),!P.current||this.#v)return;if(U.value&&U.value.done){this.#$();return}if(await this.#he(),!P.current||this.#v)return}}catch(U){if(c(U))return;this.#Pe("source:error",{error:U})}finally{P.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 P=this.#oe();P&&(D(P.invalidateHandles)&&P.invalidateHandles(),D(P.invalidate)&&P.invalidate("sort"))}renderCount(){return this.#d}ingestStats(){return{worker:this.#q,inline:this.#U,storeBacked:this.#L}}#xe(P,M){if(!P)return;const x=P.rows;if(x&&x.length&&this.#ae(x))return this.#le(P,M);const U=Z();x&&x.length&&(this.#ne(x),this.#U++),this.#Ce(P),this.#h+=Z()-U,this.#H()}#Ce(P){this.#u.loaded=P.progress&&typeof P.progress.loaded=="number"?P.progress.loaded:this.#n.length,P.progress&&typeof P.progress.estimated=="number"&&(this.#u.estimated=P.progress.estimated)}#ae(P){if(this.#Y||this.#g)return!1;const M=this.#Z();if(!M)return!1;const x=this.#t.store;if(!x||!D(x.appendPacked))return!1;const U=this.#W();return!U||!p(U)?(this.#Y=!0,f("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):P.length<M.threshold?!1:!this.#Ae(P)}#Ae(P){if(!this.#a.keyed)return!1;const M=new Set;for(let x=0;x<P.length;x++){const U=this.#a.keyOf(P[x],this.#n.length+x);if(U!=null){if(M.has(U)||this.#o.has(U))return!0;M.add(U)}}return!1}async#le(P,M){const x=P.rows,U=this.#Z(),_=this.#W();let W;try{W=await U.columnize(_,x,{key:"ingest:stream",signal:M&&M.signal})}catch(ee){if(c(ee)||(y("source.stream.columnize","worker columnization failed; columnizing on the main thread",ee),this.#Y=!0,M&&(!M.current||this.#v)))return;this.#ne(x),this.#U++,this.#Ce(P),this.#H();return}if(M&&(!M.current||this.#v))return;const q=this.#t.store,N=this.#L?void 0:x,{from:Q}=q.appendPacked(W,N),J=W.count|0;for(let ee=0;ee<J;ee++){const ne=Q+ee,se=x[ee],le=this.#a.keyed?this.#a.keyOf(se,ne):null;if(this.#n[ne]=this.#L?v:se,this.#S++,this.#ge(ne,se),le!==null&&this.#o.set(le,ne),!this.#r||!this.#we(ne))continue;const ye=this.#de(ne);this.#r.insert(ye,ne),ye<=this.#p&&this.#m++}this.#O=!0,this.#Ee(),this.#q++,this.#Ce(P),this.#H()}#Z(){const P=this.#t.ingestWorker;return D(P)?P():null}#W(){const P=this.#t.storeSchema;return D(P)?P():null}#ne(P){const M=[],x=this.#t.store,U=new Array(P.length),_=[],W=new Set;for(let N=0;N<P.length;N++){const Q=this.#a.keyed?this.#a.keyOf(P[N],this.#n.length+_.length):null;U[N]=Q,!(Q!==null&&(this.#o.has(Q)||W.has(Q)))&&(Q!==null&&W.add(Q),_.push(P[N]))}let q=_.length&&x&&D(x.append)?x.append(_).from:this.#n.length;for(let N=0;N<P.length;N++){const Q=P[N],J=U[N];if(J!==null&&this.#o.has(J)){const se=this.#o.get(J),le=this.#Se(se);this.#L||(this.#n[se]=Q,x&&D(x.setSource)&&x.setSource(se,Q)),this.#Le(se,Q),this.#l.delete(se),this.#ge(se,Q),this.#ye(se,le);continue}const ee=q++;if(this.#n[ee]=this.#L?v:Q,this.#S++,this.#ge(ee,Q),J!==null&&this.#o.set(J,ee),M.push(ee),!this.#r||!this.#we(ee))continue;const ne=this.#de(ee);this.#r.insert(ne,ee),ne<=this.#p&&this.#m++}return this.#O=!0,this.#Ee(),M}#B(P){const M=this.#n[P];let x=!1;if(this.#r){const q=this.#be(P);q>=0&&q<=this.#p&&(x=!0)}else P<=this.#p&&(x=!0);const U=M===v?this.#ee(P):M,_=this.#a.keyed?this.#a.keyOf(U,P):null;_!==null&&this.#o.get(_)===P&&this.#o.delete(_),this.#n[P]=void 0,this.#T&&(this.#T[P]=NaN),this.#l.delete(P);const W=this.#t.store;return W&&D(W.remove)&&W.remove(P),this.#S--,x}#Ee(){let P=0,M=0;const x=this.#pe();P+=x.dropped,M+=x.aboveAnchor;const U=this.#re();P+=U.dropped,M+=U.aboveAnchor,P&&(this.#O=!0,this.#C+=P,this.#Te(),this.#m-=M,this.#Pe("stream:evicted",{evicted:P,total:this.#C,live:this.#S}))}#re(){const P=this.#e.maxRows;if(!Number.isFinite(P)||P<=0||this.#S<=P)return{dropped:0,aboveAnchor:0};const M=Math.max(1,Math.floor(P*(1-Y)));let x=0,U=0;for(;this.#S>M&&this.#E<this.#n.length;){const _=this.#E++;this.#n[_]!==void 0&&(this.#B(_)&&U++,x++)}return{dropped:x,aboveAnchor:U}}#pe(){const P=this.#z();if(!P||!this.#T||!this.#V())return{dropped:0,aboveAnchor:0};const M=Date.now()-P;let x=0,U=0,_=1/0;for(let W=this.#E;W<this.#n.length;W++){if(this.#n[W]===void 0)continue;const q=this.#T[W];if(!(Number.isNaN(q)||q===void 0)){if(q>=M){q<_&&(_=q);continue}this.#B(W)&&U++,x++}}for(this.#M=_,this.#N=!1;this.#E<this.#n.length&&this.#n[this.#E]===void 0;)this.#E++;return{dropped:x,aboveAnchor:U}}#be(P){if(!this.#r)return P;for(let M=0;M<this.#r.length;M++)if(this.#r.at(M)===P)return M;return-1}#Te(){this.#i=this.#Oe("sort",[]),this.#s=this.#Oe("filters",null);const P=Number.isFinite(this.#e.maxRows)&&this.#e.maxRows>0||this.#z()>0,M=this.#Oe("where",null),x=(this.#t.config||{}).hostFilter,U=!!(M&&M.active)||!!(x&&D(x.active)&&x.active());if(!(P||this.#i.length>0||!!this.#s||!!this.#Oe("quick","")||U)){this.#r=null;return}this.#r=new s(Math.max(64,this.#n.length+64));for(let W=0;W<this.#n.length;W++)this.#n[W]!==void 0&&this.#we(W)&&this.#r.insert(this.#de(W),W)}#we(P){const M=this.#ee(P);if(this.#s&&!this.#ve(this.#s,M))return!1;const x=String(this.#Oe("quick","")||"").toLowerCase();if(x&&!this.#k(M).includes(x))return!1;const U=(this.#t.config||{}).hostFilter;if(U&&D(U.active)&&U.active()&&!U.passes(this.#je(P)))return!1;const _=this.#Oe("where",null);if(_&&_.active){const W=this.#je(P);if(!_.passes(W.data,W.key))return!1}return!0}#ve(P,M){if(!P)return!0;const x=P;if(Array.isArray(x.conditions))return x.op==="or"?x.conditions.some(W=>this.#ve(W,M)):x.op==="not"?!x.conditions.some(W=>this.#ve(W,M)):x.conditions.every(W=>this.#ve(W,M));const U=P,_=(this.#t.compute||{}).testValue;return D(_)?!!_(this.#Ve(M,U.col),U,(this.#t.config||{}).locale):(y("source.stream.testValue","ctx.compute.testValue is unavailable; streamed rows are not filtered client-side."),!0)}#Se(P){if(!this.#r)return-1;if(!this.#i.length)return this.#be(P);let M=0,x=this.#r.length;for(;M<x;){const U=M+x>>>1;this.#J(this.#r.at(U),P)<0?M=U+1:x=U}for(let U=M;U<this.#r.length;U++){const _=this.#r.at(U);if(_===P)return U;if(this.#J(_,P)>0)break}return this.#be(P)}#ye(P,M){if(!this.#r||!this.#i.length)return;const x=this.#we(P);if(M>=0&&this.#r.at(M)===P)this.#r.removeAt(M),M<=this.#p&&this.#m--;else if(M>=0)return;if(!x)return;const U=this.#de(P);this.#r.insert(U,P),U<=this.#p&&this.#m++}#de(P){if(!this.#r||!this.#i.length)return this.#r?this.#r.length:0;let M=0,x=this.#r.length;for(;M<x;){const U=M+x>>>1;this.#J(P,this.#r.at(U))<0?x=U:M=U+1}return M}#J(P,M){const x=this.#ee(P),U=this.#ee(M);for(const _ of this.#i){const W=this.#Fe(_.col),q=this.#Ve(x,_.col),N=this.#Ve(U,_.col),J=(W&&W.value&&D(W.value.compare)?W.value.compare:A)(q,N);if(J!==0)return _.dir==="desc"?-J:J}return 0}#$(){this.#w=!0,this.#u.loaded=this.#u.loaded||this.#n.length;const P=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:w;!this.#L&&this.#n.length<P&&(this.#g=d({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.#H(),this.#Pe("stream:end",{loaded:this.#n.length,promoted:this.#g!==null,threshold:P})}#H(){this.#f!==null||this.#v||(this.#f=this.#F(()=>{this.#f=null,this.#d++;const P=this.#m;this.#m=0,this.#h=0,this.#Pe("stream:chunk",{loaded:this.#u.loaded,estimated:this.#u.estimated,count:this.count(),renders:this.#d}),this.#Pe("model:changed",{reason:"stream",shiftAboveViewport:P,anchor:this.#p}),this.#Pe("rows:changed",{companion:!0,reason:"stream"})}))}#he(){return this.#d===0||this.#h<this.#ie()?Promise.resolve():(this.#h=0,new Promise(P=>{const M=(this.#t.scheduler||{}).idle;D(M)?M(()=>P()):X(()=>P())}))}#ie(){return typeof this.#e.coalesceMs=="number"&&this.#e.coalesceMs>0?this.#e.coalesceMs:R}#F(P){const M=this.#t.scheduler||{};return D(M.frame)?M.frame(P):z(P)}#ke(P){const M=this.#t.scheduler||{};D(M.cancel)?M.cancel(P):L(P)}#ee(P){const M=this.#n[P];if(M!==void 0&&M!==v)return M;if(M===void 0)return;const x=this.#t.store;return x&&D(x.source)?x.source(P):void 0}#Le(P,M){const x=this.#t.store;if(!x||!D(x.set))return;const U=this.#W();if(Array.isArray(U))for(const _ of U){if(!_||!_.id)continue;const W=D(_.read)?_.read:q=>a(q,_.field||_.id);x.set(_.id,P,W(M))}}#je(P){let M=this.#l.get(P);return M||(M=this.#a.leaf(this.#ee(P),P),this.#l.set(P,M)),M}#Ve(P,M){const x=this.#Fe(M);return x&&D(x.getValue)?x.getValue(P):P?.[M]}#k(P){const M=this.#t.columns,x=M&&D(M.all)?M.all():[],U=[];for(const _ of x){const W=D(_.getValue)?_.getValue(P):void 0;W!=null&&W!==""&&U.push(String(W))}return U.join(" ").toLowerCase()}#Fe(P){const M=this.#t.columns;return M&&D(M.get)?M.get(P):void 0}#Ye(){const P=this.#G;if(this.#G=null,P&&D(P.return))try{P.return()}catch{}}#qe(){return b({context:this.#Oe("context",null)})}#Oe(P,M){const x=this.#t.state;if(x&&D(x[P])){const U=x[P]();return U??M}return M}#Pe(P,M){const x=this.#t.emit;D(x)&&x(P,M)}}}),Ue("packages/core/src/source/url.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_URL_BATCH",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return y}});const T=B("packages/core/src/internal/warn.js").warnOnce,G=B("packages/core/src/internal/predicates.js"),D=G.isObject,I=G.isFunction,z=B("packages/core/src/internal/paths.js").getPath,X=B("packages/core/src/source/abort.js").isAbortError,$=500,A=new Set(["application/x-ndjson","application/ndjson","application/jsonlines","application/jsonl","application/x-jsonlines","text/x-ndjson"]),k=Symbol("lattice.url.skip");function y(o,b={}){const l=D(b)?b:{},p=I(l.fetch)?l.fetch:typeof globalThis<"u"&&I(globalThis.fetch)?globalThis.fetch:null,w=l.format==="json"||l.format==="ndjson"?l.format:void 0,v=typeof l.rowsPath=="string"&&l.rowsPath?l.rowsPath:void 0,R=I(l.map)?l.map:void 0,Y=D(l.headers)?l.headers:void 0,K=Number.isFinite(l.batchSize)&&l.batchSize>0?Math.floor(l.batchSize):$,V=l.lenient===!0,E=Number.isFinite(l.poll)&&l.poll>0?Math.floor(l.poll):void 0,O=typeof o=="string"&&o.length>0;O||T("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*C(F={}){if(!O)return;if(!p)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const P=F&&F.signal;let M;try{M=await p(o,Y?{signal:P,headers:Y}:{signal:P})}catch(_){throw X(_)?_:new Error(`[lattice] createUrlSource: request to ${o} failed — ${_&&_.message||_}`)}if(!M||!M.ok){const _=M?M.status:"no response";throw new Error(`[lattice] createUrlSource: ${_} for ${o}`)}const x=f(o,w,M),U=M.body&&I(M.body.getReader)?M.body.getReader():null;try{if(!U){const q=await M.text();(x||r(q,o))==="ndjson"?yield*t(null,null,q,0,M,o,K,V):yield*m(q,o,v,R);return}const _=new TextDecoder("utf-8");if(x==="json"){yield*m(await n(U,_,""),o,v,R);return}if(x==="ndjson"){yield*t(U,_,"",0,M,o,K,V);return}const W=await i(U,_,o);W.format==="json"?yield*m(await n(U,_,W.seed),o,v,R):yield*t(U,_,W.seed,W.bytes,M,o,K,V)}finally{if(U&&I(U.cancel))try{await U.cancel()}catch{}}}const S={mode:"stream",open:C,autoStart:l.autoStart!==!1};return E!==void 0&&(S.poll=E),Number.isFinite(l.maxRows)&&(S.maxRows=l.maxRows),Number.isFinite(l.maxAge)&&(S.maxAge=l.maxAge),(typeof l.ageBy=="string"||I(l.ageBy))&&(S.ageBy=l.ageBy),Number.isFinite(l.coalesceMs)&&(S.coalesceMs=l.coalesceMs),Number.isFinite(l.promoteToMemoryBelow)&&(S.promoteToMemoryBelow=l.promoteToMemoryBelow),S}function f(o,b,l){if(b)return b;const p=g(o);if(p)return p;const w=l&&l.headers&&I(l.headers.get)?l.headers.get("content-type"):null;return a(w)}function g(o){const b=String(o).split(/[?#]/)[0].toLowerCase();if(b.endsWith(".ndjson")||b.endsWith(".jsonl"))return"ndjson";if(b.endsWith(".json"))return"json"}function a(o){if(!o)return;const b=o.split(";")[0].trim().toLowerCase();if(A.has(b))return"ndjson";if(b==="application/json"||b==="text/json"||b.endsWith("+json"))return"json"}function r(o,b){const l=o.replace(/^\s+/,""),p=c(l);if(p==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${b} — pass opts.format: 'json' | 'ndjson'.`);return p}async function i(o,b,l){let p="",w=0;for(;;){const{value:R,done:Y}=await o.read();if(R&&(w+=R.byteLength,p+=b.decode(R,{stream:!0})),Y){p+=b.decode();break}const K=p.replace(/^\s+/,"");if(K){if(K[0]==="[")return{format:"json",seed:p,bytes:w};if(K[0]!=="{"||p.indexOf(`
|
|
7
|
+
`||m==="\r"){n++;continue}if(m>="0"&&m<="9"){n=k(c,n,u);continue}if(m==="."&&c[n+1]>="0"&&c[n+1]<="9"){n=k(c,n,u);continue}if(m==='"'||m==="'"){n=y(c,n,u);continue}if(m==="["){const s=c.indexOf("]",n+1);if(s<0)throw new X("a [column reference] was opened and never closed",n);u.push({kind:G,value:c.slice(n+1,s).trim(),at:n}),n=s+1;continue}if(A(m)){n=f(c,n,u);continue}const t=c.slice(n,n+2);if(z.includes(t)){u.push({kind:I,value:t==="!="?"<>":t,at:n}),n+=2;continue}if(L.includes(m)){u.push({kind:I,value:m,at:n}),n++;continue}throw new X(`unexpected character ${JSON.stringify(m)}`,n)}return u.push({kind:Z,value:null,at:c.length}),u}function A(c){return/[A-Za-z_À-]/.test(c)}function k(c,u,n){let m=u,t=!1;for(;m<c.length;){const s=c[m];if(s>="0"&&s<="9"){m++;continue}if(s==="."&&!t){t=!0,m++;continue}if((s==="e"||s==="E")&&/[0-9+-]/.test(c[m+1]||"")){for(m+=2;m<c.length&&c[m]>="0"&&c[m]<="9";)m++;break}break}return n.push({kind:re,value:Number(c.slice(u,m)),at:u}),m}function y(c,u,n){const m=c[u];let t=u+1,s="";for(;t<c.length;){if(c[t]===m){if(c[t+1]===m){s+=m,t+=2;continue}return n.push({kind:T,value:s,at:u}),t+1}s+=c[t],t++}throw new X("a string was opened and never closed",u)}function f(c,u,n){let m=u;for(;m<c.length&&/[A-Za-z0-9_.À-]/.test(c[m]);)m++;const t=c.slice(u,m);let s=m;for(;s<c.length&&c[s]===" ";)s++;return n.push({kind:c[s]==="("?D:G,value:t,at:u}),m}const g={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function a(c){const u=String(c??"").replace(/^\s*=/,"");if(!u.trim())throw new X("the formula is empty");const n=$(u);let m=0;const t=()=>n[m],s=()=>n[m++],h=v=>{const R=t();if(R.kind!==I||R.value!==v)throw new X(`expected ${JSON.stringify(v)}`,R.at);m++},d=v=>{let R=o();for(;;){const Y=t();if(Y.kind!==I)break;const K=g[Y.value];if(!K||K<v)break;m++;const V=d(Y.value==="^"?K:K+1);R={kind:"bin",op:Y.value,left:R,right:V}}return R},o=()=>{const v=t();return v.kind===I&&(v.value==="-"||v.value==="+")?(m++,{kind:"unary",op:v.value,arg:o()}):b()},b=()=>{let v=l();for(;t().kind===I&&t().value==="%";)m++,v={kind:"unary",op:"%",arg:v};return v},l=()=>{const v=s();if(v.kind===re)return{kind:"num",value:v.value};if(v.kind===T)return{kind:"str",value:v.value};if(v.kind===G)return{kind:"ref",name:v.value};if(v.kind===D){h("(");const R=[];if(!(t().kind===I&&t().value===")"))for(;;){if(R.push(d(1)),t().kind===I&&t().value===","){m++;continue}break}return h(")"),{kind:"call",name:String(v.value).toUpperCase(),args:R}}if(v.kind===I&&v.value==="("){const R=d(1);return h(")"),R}throw v.kind===Z?new X("the formula ends unexpectedly",v.at):new X(`unexpected ${JSON.stringify(v.value)}`,v.at)},p=d(1),w=t();if(w.kind!==Z)throw new X(`unexpected ${JSON.stringify(w.value)}: is an operator missing?`,w.at);return p}function r(c){const u=new Set,n=m=>{if(!(!m||typeof m!="object")){if(m.kind==="ref"){u.add(String(m.name));return}if(m.kind==="bin"){n(m.left),n(m.right);return}if(m.kind==="unary"){n(m.arg);return}if(m.kind==="call")for(const t of m.args)n(t)}};return n(c),[...u]}function i(c){return typeof c=="string"&&/^\s*=/.test(c)&&c.trim()!=="="}}),Ue("packages/core/src/formula/evaluate.js",function(e,B){"use strict";Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return k}});const T=B("packages/core/src/formula/parse.js").FormulaError;function G(y){if(y==null||y==="")return 0;if(typeof y=="boolean")return y?1:0;if(y instanceof Date)return y.getTime();const f=typeof y=="number"?y:Number(String(y).replace(/[,\s]/g,""));if(!Number.isFinite(f))throw new T(`${JSON.stringify(y)} is not a number`);return f}function D(y){return y==null?"":String(y)}function I(y){if(typeof y=="boolean")return y;if(y==null||y==="")return!1;if(typeof y=="number")return y!==0;const f=String(y).trim().toLowerCase();return f==="false"||f==="no"||f==="0"?!1:f!==""}function Z(y){const f=[];for(const g of y){if(Array.isArray(g)){for(const a of g)a!=null&&a!==""&&f.push(G(a));continue}g==null||g===""||f.push(G(g))}return f}function z(y,f){const g=10**f,a=y*g;return Math.sign(a)*Math.round(Math.abs(a)+Number.EPSILON*Math.abs(a))/g}function L(y,f){if(!y.length)return 0;const g=y.slice().sort((c,u)=>c-u),a=(g.length-1)*Math.min(1,Math.max(0,f)),r=Math.floor(a),i=Math.ceil(a);return r===i?g[r]:g[r]+(a-r)*(g[i]-g[r])}function X(y,f){let g=0,a=0,r=0;for(const c of y){g++;const u=c-a;a+=u/g,r+=u*(c-a)}const i=f?g-1:g;return i>0?Math.sqrt(r/i):0}const $={SUM:y=>Z(y).reduce((f,g)=>f+g,0),AVERAGE:y=>{const f=Z(y);return f.length?f.reduce((g,a)=>g+a,0)/f.length:0},MIN:y=>{const f=Z(y);return f.length?Math.min(...f):0},MAX:y=>{const f=Z(y);return f.length?Math.max(...f):0},COUNT:y=>Z(y).length,PRODUCT:y=>Z(y).reduce((f,g)=>f*g,1),ROUND:y=>z(G(y[0]),y.length>1?G(y[1]):0),ROUNDDOWN:y=>{const f=10**(y.length>1?G(y[1]):0),g=G(y[0])*f;return(g<0?Math.ceil(g):Math.floor(g))/f},ROUNDUP:y=>{const f=10**(y.length>1?G(y[1]):0),g=G(y[0])*f;return(g<0?Math.floor(g):Math.ceil(g))/f},ABS:y=>Math.abs(G(y[0])),FLOOR:y=>Math.floor(G(y[0])),CEILING:y=>Math.ceil(G(y[0])),SQRT:y=>Math.sqrt(G(y[0])),POWER:y=>G(y[0])**G(y[1]),MOD:y=>{const f=G(y[1]);if(f===0)throw new T("MOD by zero");return(G(y[0])%f+f)%f},IF:y=>I(y[0])?y[1]:y.length>2?y[2]:!1,AND:y=>y.every(I),OR:y=>y.some(I),NOT:y=>!I(y[0]),COALESCE:y=>y.find(f=>f!=null&&f!=="")??null,CONCAT:y=>y.map(D).join(""),LEN:y=>D(y[0]).length,UPPER:y=>D(y[0]).toUpperCase(),LOWER:y=>D(y[0]).toLowerCase(),TRIM:y=>D(y[0]).trim(),LEFT:y=>D(y[0]).slice(0,y.length>1?G(y[1]):1),RIGHT:y=>{const f=y.length>1?G(y[1]):1;return f<=0?"":D(y[0]).slice(-f)},MEDIAN:y=>L(Z(y),.5),PERCENTILE:y=>{const f=G(y[y.length-1]);return L(Z(y.slice(0,-1)),f>1?f/100:f)},QUARTILE1:y=>L(Z(y),.25),QUARTILE3:y=>L(Z(y),.75),STDEV:y=>X(Z(y),!0),STDEVP:y=>X(Z(y),!1),VAR:y=>{const f=X(Z(y),!0);return f*f},VARP:y=>{const f=X(Z(y),!1);return f*f},COUNTDISTINCT:y=>{const f=new Set;for(const g of y){const a=Array.isArray(g)?g:[g];for(const r of a)r!=null&&r!==""&&f.add(r)}return f.size},IQR:y=>{const f=Z(y);return L(f,.75)-L(f,.25)}};$.AVG=$.AVERAGE,$.CEIL=$.CEILING,$.POW=$.POWER,$.STDEVS=$.STDEV,$.PERCENTILEINC=$.PERCENTILE;function A(y,f){const g=Number(y),a=Number(f);if(y!==null&&y!==""&&f!==null&&f!==""&&Number.isFinite(g)&&Number.isFinite(a))return g<a?-1:g>a?1:0;const i=D(y).toLowerCase(),c=D(f).toLowerCase();return i<c?-1:i>c?1:0}function k(y,f={}){const g=typeof f.lookup=="function"?f.lookup:null,a=f.functions?{...$,...f.functions}:$,r=i=>{switch(i.kind){case"num":return i.value;case"str":return i.value;case"ref":{if(!g)throw new T(`there is no column called ${JSON.stringify(i.name)} here`);const c=g(String(i.name));if(c===void 0)throw new T(`there is no column called ${JSON.stringify(i.name)}`);return c}case"unary":{if(i.op==="%")return G(r(i.arg))/100;const c=G(r(i.arg));return i.op==="-"?-c:c}case"bin":{const c=i.op;if(c==="=")return A(r(i.left),r(i.right))===0;if(c==="<>")return A(r(i.left),r(i.right))!==0;if(c==="<")return A(r(i.left),r(i.right))<0;if(c==="<=")return A(r(i.left),r(i.right))<=0;if(c===">")return A(r(i.left),r(i.right))>0;if(c===">=")return A(r(i.left),r(i.right))>=0;const u=G(r(i.left)),n=G(r(i.right));if(c==="+")return u+n;if(c==="-")return u-n;if(c==="*")return u*n;if(c==="^")return u**n;if(c==="/"){if(n===0)throw new T("division by zero");return u/n}throw new T(`unknown operator ${JSON.stringify(c)}`)}case"call":{const c=f.lazy&&f.lazy[i.name];if(typeof c=="function")return c(i.args,r,f);const u=a[i.name];if(typeof u!="function")throw new T(`there is no function called ${i.name}`);return u(i.args.map(r),f)}default:throw new T("the formula could not be read")}};return r(y)}}),Ue("packages/core/src/formula/index.js",function(e,B){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"rowLookup",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return A}});const re=B("packages/core/src/formula/parse.js"),T=re.parseFormula,G=re.referencesOf,D=re.looksLikeFormula,I=re.FormulaError,Z=re.tokenise,z=B("packages/core/src/formula/evaluate.js"),L=z.evaluateAst,X=z.FUNCTIONS;function $(k){const{grid:y,row:f,data:g}=k||{},a=n=>String(n).toLowerCase().replace(/[\s_-]/g,""),r=y&&y.columns&&typeof y.columns.all=="function"?y.columns.all():[],i=y&&y.permissions,c=i&&typeof i.isReadable=="function"?n=>i.isReadable(n):()=>!0,u=new Set;for(const n of r)c(n)||(u.add(a(n.id)),n.field&&u.add(a(n.field)),n.title&&u.add(a(n.title)));return n=>{const m=a(n);if(u.has(m))throw new I(`"${n}" cannot be read`);for(const t of r)if(a(t.id)===m||t.field&&a(t.field)===m||t.title&&a(t.title)===m)return f&&y.rows&&typeof y.rows.value=="function"?y.rows.value(f.key,t.id):g?g[t.field||t.id]:void 0;if(g&&typeof g=="object"){for(const t of Object.keys(g))if(a(t)===m){if(!c(t))throw new I(`"${n}" cannot be read`);return g[t]}}}}function A(k,y={}){try{const f=T(k);return{ok:!0,value:L(f,{lookup:$(y),functions:y.formulaFunctions}),references:G(f)}}catch(f){return{ok:!1,error:f instanceof I?f.message:"the formula could not be read",at:f instanceof I?f.at:void 0}}}}),Ue("packages/core/src/internal/version.js",function(e,B){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return G}});const re="1.115.2";async function T(){return re}const G="1.115.2"}),Ue("packages/core/src/internal/merge.js",function(e,B){"use strict";Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return z}});const T=B("packages/core/src/internal/predicates.js").isObject;function G(L,X,$){if(L!==void 0)return L===!0?{enabled:!0,...$}:L===!1?{enabled:!1}:T(L)?L:{[X]:L,enabled:!0}}function D(L){return L==null?[]:Array.isArray(L)?L:[L]}const I=Object.freeze(new Set(["__proto__","constructor","prototype"]));function Z(L,X){if(!T(L))return T(X)?{...X}:X;if(!T(X))return X===void 0?L:X;const $={...L};for(const A of Object.keys(X)){if(I.has(A))continue;const k=X[A];k!==void 0&&($[A]=T(k)&&T($[A])?Z($[A],k):k)}return $}function z(L,X){if(!T(L)||!T(X)||L===X)return X;const $=Object.create(Object.getPrototypeOf(L));return Object.assign($,L,X),$}}),Ue("packages/core/src/internal/schedule.js",function(e,B){"use strict";Object.defineProperty(e,"now",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return z}});function re(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const T=typeof requestAnimationFrame=="function";function G(L){return T?requestAnimationFrame(L):setTimeout(()=>L(re()),16)}function D(L){L!=null&&(T?cancelAnimationFrame(L):clearTimeout(L))}function I(L){let X=null,$=null;const A=()=>{X=null;const y=$;$=null,L(...y||[])},k=(...y)=>{$=y,X===null&&(X=G(A))};return k.cancel=()=>{D(X),X=null,$=null},k.flush=()=>{X!==null&&(D(X),A())},k}function Z(L,X){let $=null,A=null;const k=()=>{if($=null,A===null)return;const g=A;A=null,L(...g),y()},y=()=>{$=setTimeout(k,X),typeof $?.unref=="function"&&$.unref()},f=(...g)=>{$===null?(L(...g),y()):(A=g,clearTimeout($),y())};return f.flush=()=>{if($!==null&&clearTimeout($),$=null,A===null)return;const g=A;A=null,L(...g)},f.cancel=()=>{$!==null&&clearTimeout($),$=null,A=null},f.pending=()=>$!==null||A!==null,f}function z(L,X=50){return typeof requestIdleCallback=="function"?requestIdleCallback(L,{timeout:X}):setTimeout(()=>L({timeRemaining:()=>0,didTimeout:!0}),1)}}),Ue("packages/core/src/internal/paths.js",function(e,B){"use strict";Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return Z}});const re=new Map;function T(z){let L=re.get(z);if(L)return L;if(!z.includes("."))L=X=>X?.[z];else{const X=z.split("."),$=X.length;L=A=>{let k=A;for(let y=0;y<$;y++){if(k==null)return;k=k[X[y]]}return k}}return re.set(z,L),L}const G=new Map;function D(z){let L=G.get(z);if(L)return L;if(!z.includes("."))L=(X,$)=>{X!=null&&(X[z]=$)};else{const X=z.split("."),$=X.length-1;L=(A,k)=>{let y=A;for(let f=0;f<$;f++){if(y==null)return;const g=X[f];y[g]==null&&(y[g]={}),y=y[g]}y!=null&&(y[X[$]]=k)}}return G.set(z,L),L}function I(z,L){return T(L)(z)}function Z(z,L,X){D(L)(z,X)}}),Ue("packages/core/src/internal/compare.js",function(e,B){"use strict";Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return G}});const re=new Map;function T(D,I){const Z=`${D||""}|${I?JSON.stringify(I):""}`;let z=re.get(Z);return z||(z=new Intl.Collator(D||void 0,{numeric:!0,sensitivity:"variant",...I}),re.set(Z,z)),z}function G(D,I){if(D===I)return 0;if(D==null)return 1;if(I==null)return-1;if(typeof D=="number"&&typeof I=="number")return Number.isNaN(D)?Number.isNaN(I)?0:1:Number.isNaN(I)||D<I?-1:D>I?1:0;const Z=String(D),z=String(I);return Z<z?-1:Z>z?1:0}}),Ue("packages/core/src/defaults.js",function(e,B){"use strict";Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"applyDefaults",{enumerable:!0,get:function(){return A}});const T=B("packages/core/src/internal/predicates.js").isObject,D=B("packages/core/src/internal/merge.js").merge,Z=B("packages/core/src/internal/warn.js").warnOnce;let z=null;class L extends Error{}function X(k,y=new Set){if(Array.isArray(k)){if(y.has(k))throw new L;y.add(k);const g=k.map(a=>X(a,y));return y.delete(k),g}if(!T(k)||Object.getPrototypeOf(k)!==Object.prototype&&Object.getPrototypeOf(k)!==null)return k;if(y.has(k))throw new L;y.add(k);const f={};for(const[g,a]of Object.entries(k))f[g]=X(a,y);return y.delete(k),f}function $(k){if(k===void 0)return X(z??{});if(k===null)return z=null,{};if(!T(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(z??{});try{z=X(k)}catch(y){if(!(y instanceof L))throw y;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(z??{})}return X(z)}function A(k){return z===null?k:D(X(z),k)}}),Ue("packages/core/src/internal/uid.js",function(e,B){"use strict";Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return T}});let re=0;function T(G="l"){return`${G}${(++re).toString(36)}`}}),Ue("packages/core/src/events/names.js",function(e,B){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"isKnownEvent",{enumerable:!0,get:function(){return G}});const re=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"]),T=new Set(re);function G(D){return D==="*"||T.has(D)}}),Ue("packages/core/src/events/bus.js",function(e,B){"use strict";Object.defineProperty(e,"WILDCARD",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return g}});const re=B("packages/core/src/internal/warn.js"),T=re.warnOnce,G=re.DEV,I=B("packages/core/src/internal/uid.js").uid,z=B("packages/core/src/events/names.js").isKnownEvent,L="*";function X(a,r){!G||z(r)||T(`bus.unknown:${r}`,`${a}('${r}') subscribes to an event the grid never raises, so the handler will never fire. Check the name against the EventName list — a common cause is a near miss such as 'row:click' for 'row:clicked'.`)}const $=new Set(["api","user","init","ai"]),A=new WeakMap;function k(a){let r=A.get(a);return r||(r=I("h"),A.set(a,r)),r}function y(){return typeof performance=="object"&&performance?performance.now():Date.now()}function f(a){if(!a||typeof a!="object")return{};const r={};for(const[i,c]of Object.entries(a))i!=="grid"&&(c==null?r[i]=String(c):Array.isArray(c)?r[i]=`[${c.length}]`:typeof c=="object"?r[i]=c.key?`row ${c.key}`:"{…}":typeof c=="function"?r[i]="[function]":r[i]=String(c).slice(0,60));return r}class g{#e=new Map;#t=!1;#n=[];#r=200;#i=new Map;#s=null;#a=!1;#l=0;constructor(r=null){this.#s=r}attach(r){this.#s=r}get grid(){return this.#s}get destroyed(){return this.#a}on(r,i){if(typeof i!="function")return T(`bus.handler:${r}`,`on('${r}') needs a function; ignored.`),()=>{};X("on",r);let c=this.#e.get(r);return c||(c=[],this.#e.set(r,c)),c.push(i),()=>this.off(r,i)}once(r,i){if(typeof i!="function")return T(`bus.handler:${r}`,`once('${r}') needs a function; ignored.`),()=>{};X("once",r);const c=u=>{this.off(r,i),i(u)};return this.#i.set(i,c),this.on(r,c)}off(r,i){if(i===void 0){this.#e.delete(r);return}const c=this.#e.get(r);if(!c)return;const u=this.#i.get(i),n=u&&c.includes(u)?u:i,m=c.indexOf(n);m>=0&&c.splice(m,1),u&&n===u&&this.#i.delete(i),c.length===0&&this.#e.delete(r)}count(r){const i=this.#e.get(r),c=r===L?null:this.#e.get(L);return(i?i.length:0)+(c?c.length:0)}#o(r,i,c,u,n){this.#n.push({type:r,origin:i,listeners:(u?u.length:0)+(n?n.length:0),payload:f(c),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(r,i){this.#t=!!r,Number.isFinite(i)&&i>0&&(this.#r=Math.floor(i)),r||(this.#n=[])}eventLog(){return this.#n.map(r=>({...r}))}clearEventLog(){this.#n=[]}counts(){const r={};for(const[i,c]of this.#e)r[i]=c.length;return r}emit(r,i,c){const u=c??(i&&i.origin),n=$.has(u)?u:"api",m={...i||null,type:r,origin:n,grid:this.#s};if(this.#a)return m;const t=this.#e.get(r),s=r===L?void 0:this.#e.get(L);if(this.#t&&this.#o(r,n,i,t,s),!t&&!s)return m;const h=this.#t?y():0;this.#l++;try{t&&this.#c(t.slice(),m,r),s&&this.#c(s.slice(),m,L)}finally{this.#l--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=y()-h)}return m}emitBefore(r,i,c){const u=c??(i&&i.origin),n=$.has(u)?u:"user";let m=!1,t=null;const s=p=>{m=!0,p!=null&&t===null&&(t=String(p))},h={...i||null,type:r,origin:n,grid:this.#s,get defaultPrevented(){return m},get reason(){return t},preventDefault(p){s(p)}};if(this.#a)return!0;const d=this.#e.get(r);this.#t&&this.#o(r,n,i,d,void 0);const o=d?d.slice():[];if(o.length===0)return!0;const b=()=>(m&&t===null&&(t="prevented"),m&&i&&typeof i=="object"&&(i.reason=t),!m),l=[];for(const p of o)try{const w=p(h);w&&typeof w.then=="function"?l.push(w):w===!1&&s("prevented")}catch(w){s("error"),T(`bus.beforeThrow:${r}:${k(p)}`,`a '${r}' before-handler threw; the action was cancelled.`,w)}return l.length===0?b():Promise.allSettled(l).then(p=>{for(const w of p)w.status==="rejected"?(s("error"),T(`bus.beforeReject:${r}`,`a '${r}' before-handler rejected; the action was cancelled.`,w.reason)):w.value===!1&&s("prevented");return b()})}#c(r,i,c){for(let u=0;u<r.length;u++)try{r[u](i)}catch(n){T(`bus.throw:${c}:${k(r[u])}`,`a '${c}' handler threw; other handlers were unaffected.`,n)}}clear(){this.#e.clear(),this.#i.clear()}destroy(){this.clear(),this.#a=!0,this.#s=null}}}),Ue("packages/core/src/registry/free-tier-notice.js",function(e,B){"use strict";Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"WATERMARK_TEXT",{enumerable:!0,get:function(){return T}});const re="Free for non-commercial use: latticegrid.dev/free",T="Unlicensed: Lattice Grid trial"}),Ue("packages/core/src/registry/licence.js",function(e,B){"use strict";Object.defineProperty(e,"PRODUCT",{enumerable:!0,get:function(){return I}}),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 y}}),Object.defineProperty(e,"asciiBytes",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hasEd25519",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"currentHost",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return O}});const T=B("packages/core/src/internal/warn.js").warnOnce,G=B("packages/core/src/registry/free-tier-notice.js"),D=G.FREE_TIER_NOTICE;Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return G.FREE_TIER_NOTICE}});const I="lattice-grid",Z=1,z="LG1",L=64,X="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",$="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",A=(()=>{const C=new Int16Array(128).fill(-1);for(let S=0;S<$.length;S++)C[$.charCodeAt(S)]=S;return C[43]=62,C[47]=63,C})();function k(C){if(typeof C!="string")return null;let S="";for(let _=0;_<C.length;_++){const W=C.charCodeAt(_);if(W!==61){if(W>127||A[W]<0)return null;S+=C[_]}}const F=S.length;if(F%4===1)return null;const P=new Uint8Array(Math.floor(F*3/4));let M=0,x=0,U=0;for(let _=0;_<F;_++)M=M<<6|A[S.charCodeAt(_)],x+=6,x>=8&&(x-=8,P[U++]=M>>x&255);return U===P.length?P:P.subarray(0,U)}function y(C){let S="",F=0;for(;F+2<C.length;F+=3){const M=C[F]<<16|C[F+1]<<8|C[F+2];S+=$[M>>18&63]+$[M>>12&63]+$[M>>6&63]+$[M&63]}const P=C.length-F;if(P===1){const M=C[F]<<16;S+=$[M>>18&63]+$[M>>12&63]}else if(P===2){const M=C[F]<<16|C[F+1]<<8;S+=$[M>>18&63]+$[M>>12&63]+$[M>>6&63]}return S}function f(C){const S=new Uint8Array(C.length);for(let F=0;F<C.length;F++)S[F]=C.charCodeAt(F)&127;return S}function g(C){if(typeof TextDecoder=="function")return new TextDecoder().decode(C);let S="";for(let F=0;F<C.length;F++)S+=String.fromCharCode(C[F]);return S}function a(C){const S={ok:!1,reason:"malformed",product:null,issuedTo:null,expires:null,terms:null,features:[],deployments:[],version:0,message:null,signature:null,raw:typeof C=="string"?C:""};if(typeof C!="string"||C.length===0)return{...S,reason:"missing"};const F=C.trim(),P=F.split(".");if(P.length!==3)return S;const[M,x,U]=P;if(M!==z)return{...S,reason:"prefix"};const _=k(x),W=k(U);if(!_||!W)return S;let q;try{q=JSON.parse(g(_))}catch{return S}return q===null||typeof q!="object"?S:{ok:!0,reason:null,product:typeof q.p=="string"?q.p:null,issuedTo:typeof q.t=="string"?q.t:null,expires:typeof q.e=="string"?q.e:null,terms:typeof q.terms=="string"?q.terms:null,features:Array.isArray(q.f)?q.f.slice():[],deployments:Array.isArray(q.d)?q.d.slice():[],version:typeof q.v=="number"?q.v:0,message:f(x),signature:W,raw:F}}function r(C,S){if(!C)return!1;const F=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(C)?`${C}T23:59:59.999Z`:C);return Number.isNaN(F)?!0:S>F}function i(C){return C==="non-commercial"?"non-commercial":"commercial"}let c=null,u=null,n=null;function m(){const C=globalThis.crypto;return C&&C.subtle?C.subtle:null}async function t(C){if(c&&u===C)return c;const S=m();if(!S)return null;const F=k(C);if(!F)return null;try{const P=await S.importKey("raw",F,{name:"Ed25519"},!1,["verify"]);return c=P,u=C,P}catch{return null}}async function s(){return n!==null||(n=await t(X)!==null),n}async function h(C,S={}){const F=S.warn!==!1,P=S.product||I,M=S.publicKey||X,x=S.now??Date.now(),U=S.host??o(),_=d(U)?"":` ${D}`,W=a(C);if(!W.ok){const ee=W.reason==="missing"?"missing":"malformed";return F&&T(`licence.${ee}`,ee==="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.${_}`:`licence key could not be read. The grid will render with a watermark.${_}`),{valid:!1,reason:ee,terms:"commercial"}}const q={product:W.product||void 0,issuedTo:W.issuedTo||void 0,expires:W.expires||void 0,terms:i(W.terms)};if(W.product!==P)return F&&T("licence.product",`licence key is for '${W.product}', not '${P}'. The grid will render with a watermark.`),{valid:!1,...q,reason:"product"};if(r(W.expires,x))return F&&T("licence.expired",`licence expired on ${W.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...q,reason:"expired"};const N=W.deployments||[];if(N.length&&U&&!d(U)&&!b(U,N))return F&&T("licence.domain",`licence key is not valid for ${U}; it covers ${N.join(", ")}. The grid will render with a watermark.`),{valid:!1,...q,reason:"domain"};const Q=await t(M);if(!Q){const ee=!!W.signature&&W.signature.length===L;return F&&T("licence.algorithm","this host does not provide crypto.subtle Ed25519, so the licence signature could not be verified. A structural check was used instead."),ee?{valid:!0,...q,reason:"unverified"}:{valid:!1,...q,reason:"signature"}}let J=!1;try{J=await m().verify({name:"Ed25519"},Q,W.signature,W.message)}catch{J=!1}return J?{valid:!0,...q}:(F&&T("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...q,reason:"signature"})}function d(C){const S=String(C??o()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!S||S==="localhost"||S.endsWith(".localhost")||S==="::1"||S==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(S)}function o(){const C=globalThis.location;return C&&typeof C.hostname=="string"?C.hostname:null}function b(C,S){const F=l(C);return!F||!Array.isArray(S)?!1:S.some(P=>{const M=l(P);if(!M)return!1;if(M==="*")return!0;if(M.startsWith("*.")){const x=M.slice(2);return F===x||F.endsWith(`.${x}`)}return F===M})}function l(C){return String(C??"").trim().toLowerCase().replace(/\.$/,"")}class p{#e="";#t={valid:!1,reason:"missing",terms:"commercial"};#n=null;#r=null;#i;#s=new Set;constructor(S={}){this.#i=S}set(S){this.#e=typeof S=="string"?S.trim():"";const F=a(this.#e);return this.#t=F.ok?{valid:!r(F.expires,Date.now())&&F.product===(this.#i.product||I),product:F.product||void 0,issuedTo:F.issuedTo||void 0,expires:F.expires||void 0,terms:i(F.terms),reason:"pending"}:{valid:!1,reason:F.reason||"malformed",terms:"commercial"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const S=this.#e;return this.#n=h(S,this.#i).then(F=>{if(this.#e===S){this.#t=F;for(const P of this.#s)P(F)}return F}),this.#n}onSettled(S){return this.#s.add(S),()=>this.#s.delete(S)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!d(this.#r)}setHost(S){this.#r=S}state(){return this.#t.valid?"licensed":d(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing",terms:"commercial"},this.#n=null,this.#s.clear()}}const w=Symbol.for("lattice-grid/licence/holder");function v(){const C=globalThis,S=C&&C[w];if(S&&typeof S.set=="function"&&typeof S.watermark=="function")return S;const F=new p;if(C)try{C[w]=F}catch{}return F}const R=v();function Y(C){return R.set(C)}function K(){return R.info()}function V(){return R.watermark()}function E(){return R.state()}function O(){return R}}),Ue("packages/core/src/registry/registry.js",function(e,B){"use strict";Object.defineProperty(e,"KINDS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"REGIONS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return c}});const re=B("packages/core/src/internal/warn.js"),T=re.warnOnce,G=re.DEV,I=B("packages/core/src/internal/predicates.js").isFunction,Z=B("packages/core/src/registry/licence.js"),z=Z.LicenceHolder,L=Z.sharedLicence,X=["renderer","editor","filter","dataType","totalFn","pipe","component"],$=["all","header","body","totals","panels"];class A{#e=new Map;#t=new Map;#n=new Set;#r=new Set;#i;#s=null;#a=null;#l=new Set;#o=new Map;constructor(n={}){for(const m of X)this.#t.set(m,new Map);this.#i=n.holder||L(),this.#a=n.grid??null,this.#s=this.#i.onSettled(()=>{this.#f({reason:"licence",name:"licence",capabilities:this.capabilities(),regions:["all"]})}),n.licence&&this.setLicence(n.licence)}registerModules(n,m={}){m.licence&&this.setLicence(m.licence),m.grid!==void 0&&(this.#a=m.grid);const t=Array.isArray(n)?n:[n],s=[];for(const h of t){if(!h||typeof h!="object"||typeof h.name!="string"||!h.name){T("registry.module.shape","registerModules received something that is not a module; ignored.");continue}if(this.#e.has(h.name)){G&&this.#u(this.#e.get(h.name),h);continue}if(!I(h.install)){T(`registry.module.install:${h.name}`,`module '${h.name}' has no install() and was ignored.`);continue}const d={registry:this,grid:this.#a};try{h.install(d)}catch(o){T(`registry.module.throw:${h.name}`,`module '${h.name}' threw during install; it was not registered.`,o);continue}this.#e.set(h.name,h);for(const o of k(h))this.#n.add(o);s.push(h.name),this.#f({reason:"module",name:h.name,capabilities:this.capabilities(),regions:g(h)})}return s}unregisterModule(n){const m=this.#e.get(n);if(!m)return!1;if(I(m.uninstall))try{m.uninstall({registry:this,grid:this.#a})}catch(t){T(`registry.module.uninstall:${n}`,`module '${n}' threw during uninstall.`,t)}return this.#e.delete(n),this.#c(),this.#f({reason:"unmodule",name:n,capabilities:this.capabilities(),regions:g(m)}),!0}modules(){return[...this.#e.values()]}has(n){return this.#e.has(n)}#c(){this.#n.clear();for(const n of this.#e.values())for(const m of k(n))this.#n.add(m)}#u(n,m){!n||n===m||y(n,m)||T(`registry.module.reconfigure:${m.name}`,`module '${m.name}' was re-registered with different options; the first registration is kept and this call was ignored. Unregister it first if you mean to replace it.`)}capabilities(){return[...this.#n].sort()}can(n){return this.#n.has(n)}onChange(n){return I(n)?(this.#r.add(n),this.#o.set(n,this.#a),()=>{this.#r.delete(n),this.#o.delete(n)}):()=>{}}#f(n){for(const m of[...this.#r])try{m(n)}catch(t){T("registry.onChange.throw","a registry change handler threw.",t)}}register(n,m,t){const s=this.#t.get(n);if(!s){T(`registry.kind:${n}`,`unknown registry kind '${n}'; expected one of ${X.join(", ")}.`);return}if(!m||typeof m!="string"){T(`registry.name:${n}`,`register('${n}', ...) needs a name.`);return}s.has(m)&&s.get(m)!==t&&T(`registry.replace:${n}:${m}`,`'${m}' was already registered as a ${n} and has been replaced.`),s.set(m,t),this.#f({reason:"register",name:m,kind:n,capabilities:this.capabilities(),regions:a(n)})}registerAll(n,m){if(m)for(const t of Object.keys(m))this.register(n,t,m[t])}get(n,m){const t=this.#t.get(n);return t?t.get(m):void 0}names(n){const m=this.#t.get(n);return m?[...m.keys()]:[]}#d(n,m){const t=this.#t.get(n).get(m);return t!==void 0?t:this.#t.get("component").get(m)}renderer(n){return this.#d("renderer",n)}editor(n){return this.#d("editor",n)}filter(n){return this.#d("filter",n)}dataType(n){return this.get("dataType",n)}totalFn(n){return this.get("totalFn",n)}pipe(n){return this.get("pipe",n)}setLicence(n){return this.#i.set(n)}licence(){return this.#i.info()}licenceVerified(){return this.#i.verify()}watermark(){return this.#i.watermark()}attach(n){n!=null&&(this.#l.add(n),this.#a=n)}detach(n){if(n!=null){this.#l.delete(n);for(const[m,t]of[...this.#o])t===n&&(this.#r.delete(m),this.#o.delete(m));if(this.#a===n){const m=this.#l.size?[...this.#l][this.#l.size-1]:null;this.#a=m}this.#l.size===0&&this.#s&&(this.#s(),this.#s=null)}}destroy(n){if(n!=null){this.detach(n);return}for(const m of[...this.#e.keys()])this.unregisterModule(m);this.#r.clear(),this.#o.clear(),this.#l.clear(),this.#s&&this.#s(),this.#s=null,this.#a=null}}function k(u){const n=u.capabilities,m=Array.isArray(n)?n.filter(t=>typeof t=="string"):[];return[u.name,...m]}function y(u,n){return u.install!==n.install||u.uninstall!==n.uninstall||(u.version||"")!==(n.version||"")?!1:f(k(u),k(n))&&f(g(u),g(n))}function f(u,n){const m=new Set(u),t=new Set(n);if(m.size!==t.size)return!1;for(const s of m)if(!t.has(s))return!1;return!0}function g(u){const n=u.regions;return!Array.isArray(n)||n.length===0?["all"]:n.filter(m=>$.includes(m))}function a(u){switch(u){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const r=new A;function i(){return r}function c(u,n={}){return r.registerModules(u,n)}}),Ue("packages/core/src/internal/text.js",function(e,B){"use strict";Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return D}});function re(I){return I?(I.includes(".")?I.slice(I.lastIndexOf(".")+1):I).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(/^./,z=>z.toUpperCase()):""}const T={"&":"&","<":"<",">":">",'"':""","'":"'"};function G(I){const Z=I==null?"":String(I);return/[&<>"']/.test(Z)?Z.replace(/[&<>"']/g,z=>T[z]):Z}function D(I){return String(I).replace(/\w\S*/g,Z=>Z[0].toUpperCase()+Z.slice(1).toLowerCase())}}),Ue("packages/core/src/format/mask.js",function(e,B){"use strict";Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return Z}});const re=new Set(["0","#","?",",","."]),T="\0";function G(L){const X=[];let $="",A=!1;for(let k=0;k<L.length;k++){const y=L[k];if(y==="\\"){$+=y+(L[k+1]??""),k+=1;continue}if(y==='"'){A=!A,$+=y;continue}if(y===";"&&!A){X.push($),$="";continue}$+=y}return X.push($),X}function D(L){let X="",$="",A="",k=1,y=!1,f=!1;const g=s=>{f?$+=s:X+=s};for(let s=0;s<L.length;s++){const h=L[s];if(h==="\\"){g(L[s+1]??""),s+=1;continue}if(h==='"'){const d=L.indexOf('"',s+1);g(d===-1?L.slice(s+1):L.slice(s+1,d)),s=d===-1?L.length:d;continue}if(h==="%"){k*=100,g("%");continue}if(h==="@"){y=!0,g("\0");continue}if(re.has(h)){A+=h,f=!0;continue}g(h)}let a=-1;for(let s=A.length-1;s>=0;s--){const h=A[s];if(h==="0"||h==="#"||h==="?"){a=s;break}}let r=!1,i="";for(let s=0;s<A.length;s++){const h=A[s];if(h===","){s>a?k/=1e3:r=!0;continue}i+=h}const c=i.indexOf("."),u=c===-1?i:i.slice(0,c),n=c===-1?"":i.slice(c+1);let m=0;for(const s of u)s==="0"&&(m+=1);let t=0;for(const s of n)s==="0"&&(t+=1);return{prefix:X,suffix:$,minInt:m,minDec:t,maxDec:n.length,grouping:r,scale:k,hasNumber:a!==-1,isText:y}}function I(L,X){const $=new Intl.NumberFormat(X,{minimumIntegerDigits:Math.max(L.minInt,1),minimumFractionDigits:L.minDec,maximumFractionDigits:Math.max(L.maxDec,L.minDec),useGrouping:L.grouping}),{prefix:A,suffix:k,scale:y,hasNumber:f}=L;return g=>{if(!f)return A+k;const a=y===1?g:g*y;return A+$.format(a)+k}}function Z(L,X){const A=G(String(L)).map(D),k=A.map(i=>I(i,X)),y=0,f=A.length>1?1:-1,g=A.length>2?2:-1,a=A.length>3?3:-1,r=i=>{if(i==null||i==="")return"";if(typeof i!="number"||Number.isNaN(i)){const c=Number(i);if(Number.isNaN(c))return a===-1?String(i):(A[a].prefix+A[a].suffix).split("\0").join(String(i));i=c}return i===0&&g!==-1?k[g](0):i<0&&f!==-1?k[f](-i):k[y](i)};return r.spec={mask:L},{format:r,ooxml:z(String(L))}}function z(L){return L.trim()}}),Ue("packages/core/src/format/pattern.js",function(e,B){"use strict";Object.defineProperty(e,"parseNumberPattern",{enumerable:!0,get:function(){return I}});const T=B("packages/core/src/format/mask.js").splitSections;function G(Z){let z="",L="",X="",$="",A=!1,k=!1,y=!1,f=!1;const g=r=>{y?L+=r:z+=r};for(let r=0;r<Z.length;r++){const i=Z[r];if(i==="\\"){g(Z[r+1]??""),r+=1;continue}if(i==='"'){const c=Z.indexOf('"',r+1);g(c===-1?Z.slice(r+1):Z.slice(r+1,c)),r=c===-1?Z.length:c;continue}if(i==="%"){k=!0;continue}if(i==="0"||i==="#"){y=!0,f?$+=i:X+=i;continue}if(i===","){f||(A=!0);continue}if(i==="."&&!f){f=!0;continue}g(i)}if(!y)return{hasDigit:!1,prefix:z,suffix:L,minDec:0,maxDec:0,grouping:!1,percent:k};let a=0;for(const r of $)r==="0"&&(a+=1);return{hasDigit:!0,prefix:z,suffix:L,minDec:a,maxDec:$.length,grouping:A,percent:k}}function D(Z,z){const L=z.trim(),X=Z.trim();return L.startsWith("(")&&L.endsWith(")")&&L.slice(1,-1).trim()===X?"parentheses":L.endsWith("-")?"suffix":"minus"}function I(Z){if(typeof Z!="string")return null;const z=T(Z);if(z.length===0)return null;const L=G(z[0]);if(!L.hasDigit)return null;const X={style:L.percent?"percent":"decimal",prefix:L.prefix,suffix:L.suffix,minDecimals:L.minDec,maxDecimals:Math.max(L.maxDec,L.minDec),thousandsSeparator:L.grouping?void 0:!1};if(z.length>1&&(X.negative=D(z[0],z[1])),z.length>2){const $=G(z[2]);$.hasDigit||(X.zeroDisplay=$.prefix+$.suffix)}return X}}),Ue("packages/core/src/format/number.js",function(e,B){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return z}});const T=B("packages/core/src/internal/predicates.js").isNil,D=B("packages/core/src/internal/warn.js").warnOnce,Z=B("packages/core/src/format/pattern.js").parseNumberPattern;function z(L,X){const $=typeof L=="string"?{pattern:L}:L||{};let A=$;if(typeof $.pattern=="string"){const v=Z($.pattern);if(v){const{pattern:R,...Y}=$;A={...v,...Y}}else D(`format:pattern:${$.pattern}`,`invalid number format pattern "${$.pattern}"; the value will use the default number format`)}const k=A.locale||X||void 0,y=A.style||"decimal",f=typeof A.scale=="number"?A.scale:1,g=A.nullDisplay??"",a=A.zeroDisplay,r=A.prefix||"",i=A.suffix||"",c=A.negative||"minus",u=A.signed===!0,n={style:y,notation:A.notation||"standard"};y==="currency"&&(n.currency=A.currency||"USD",A.currencyDisplay&&(n.currencyDisplay=A.currencyDisplay)),typeof A.decimals=="number"?(n.minimumFractionDigits=A.decimals,n.maximumFractionDigits=A.decimals):(typeof A.minDecimals=="number"&&(n.minimumFractionDigits=A.minDecimals),typeof A.maxDecimals=="number"&&(n.maximumFractionDigits=A.maxDecimals),n.minimumFractionDigits>(n.maximumFractionDigits??20)&&(n.maximumFractionDigits=n.minimumFractionDigits)),A.thousandsSeparator===!1&&(n.useGrouping=!1),n.notation==="compact"&&(n.compactDisplay=A.compactDisplay||"short");const m=new Intl.NumberFormat(k,n),t=typeof A.thousandsSeparator=="string"?A.thousandsSeparator:null,s=typeof A.decimalSeparator=="string"?A.decimalSeparator:null;let h=",",d=".";if(t||s)for(const v of m.formatToParts(12345.6))v.type==="group"?h=v.value:v.type==="decimal"&&(d=v.value);const o=v=>{let R=v;return t&&(R=R.split(h).join("")),s&&(R=R.split(d).join("")),t&&(R=R.split("").join(t)),s&&(R=R.split("").join(s)),R},b=!!(t||s),l=r!==""&&y==="currency",p=v=>{let R;if(l){const Y=m.formatToParts(v);let K=!1;R="";for(const V of Y)R+=V.value,!K&&V.type==="currency"&&(R+=r,K=!0);K||(R=r+R)}else R=r+m.format(v);return b&&(R=o(R)),R+i},w=v=>{if(T(v)||v==="")return g;const R=typeof v=="number"?v:Number(v);if(Number.isNaN(R))return g;const Y=f===1?R:R*f;return Y===0&&a!==void 0?a:Y<0?c==="parentheses"?`(${p(-Y)})`:c==="suffix"?`${p(-Y)}-`:p(Y):u&&Y>0?`+${p(Y)}`:p(Y)};return w.negativeClass=A.negativeClass||null,w.spec=A,w}}),Ue("packages/core/src/format/date.js",function(e,B){"use strict";Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"toIsoDate",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"toIsoDateTime",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"compareIso",{enumerable:!0,get:function(){return i}});const T=B("packages/core/src/internal/predicates.js").isNil,D=B("packages/core/src/internal/warn.js").warnOnce,I=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function Z(c){const u=[];let n=0,m="";const t=()=>{m&&(u.push({token:null,text:m}),m="")};for(;n<c.length;){const s=c[n];if(s==="'"){if(c[n+1]==="'"){m+="'",n+=2;continue}const d=c.indexOf("'",n+1);if(d===-1){m+=c.slice(n+1),n=c.length;continue}m+=c.slice(n+1,d),n=d+1;continue}const h=I.find(d=>c.startsWith(d,n));if(h){t(),u.push({token:h,text:h}),n+=h.length;continue}/[A-Za-z]/.test(s)&&D(`date.pattern.token:${s}`,`the date pattern "${c}" contains '${s}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${I.join(" ")}.`),m+=s,n+=1}return t(),u}const z=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function L(c){if(T(c)||c==="")return null;if(c instanceof Date)return Number.isNaN(c.getTime())?null:c;if(typeof c=="number")return Number.isNaN(c)?null:new Date(c);if(typeof c=="string"){const u=z.exec(c.trim());if(u){const[,m,t,s,h="0",d="0",o="0"]=u;return new Date(+m,+t-1,+s,+h,+d,+o)}const n=new Date(c);return Number.isNaN(n.getTime())?null:n}return null}function X(c,u){return String(c).padStart(u,"0")}function $(c){if(!c)return m=>({year:m.getFullYear(),month:m.getMonth()+1,day:m.getDate(),hour:m.getHours(),minute:m.getMinutes(),second:m.getSeconds(),ms:m.getMilliseconds(),weekday:m.getDay()});const u=new Intl.DateTimeFormat("en-US",{timeZone:c,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),n={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return m=>{const t={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:m.getMilliseconds(),weekday:0};for(const s of u.formatToParts(m))switch(s.type){case"year":t.year=Number(s.value);break;case"month":t.month=Number(s.value);break;case"day":t.day=Number(s.value);break;case"hour":t.hour=Number(s.value)%24;break;case"minute":t.minute=Number(s.value);break;case"second":t.second=Number(s.value);break;case"weekday":t.weekday=n[s.value]??0;break;default:break}return t}}function A(c,u,n){const m=Z(c),t=$(n),s=new Set(m.filter(l=>l.token).map(l=>l.token)),h=s.has("MMM")?new Intl.DateTimeFormat(u,{month:"short",timeZone:n}):null,d=s.has("MMMM")?new Intl.DateTimeFormat(u,{month:"long",timeZone:n}):null,o=s.has("EEE")?new Intl.DateTimeFormat(u,{weekday:"short",timeZone:n}):null,b=s.has("EEEE")?new Intl.DateTimeFormat(u,{weekday:"long",timeZone:n}):null;return l=>{const p=t(l);let w="";for(const v of m){if(!v.token){w+=v.text;continue}switch(v.token){case"yyyy":w+=X(p.year,4);break;case"yy":w+=X(p.year%100,2);break;case"MMMM":w+=d.format(l);break;case"MMM":w+=h.format(l);break;case"MM":w+=X(p.month,2);break;case"M":w+=String(p.month);break;case"dd":w+=X(p.day,2);break;case"d":w+=String(p.day);break;case"EEEE":w+=b.format(l);break;case"EEE":w+=o.format(l);break;case"HH":w+=X(p.hour,2);break;case"H":w+=String(p.hour);break;case"hh":w+=X(p.hour%12===0?12:p.hour%12,2);break;case"h":w+=String(p.hour%12===0?12:p.hour%12);break;case"mm":w+=X(p.minute,2);break;case"m":w+=String(p.minute);break;case"ss":w+=X(p.second,2);break;case"s":w+=String(p.second);break;case"SSS":w+=X(p.ms,3);break;case"a":w+=p.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 y(c,u){const n=c||{},m=n.locale||u||void 0,t=n.nullDisplay??"",s=n.timeZone;let h;if(n.pattern)h=A(n.pattern,m,s);else if(n.dateStyle||n.timeStyle){const p={timeZone:s};n.dateStyle&&(p.dateStyle=n.dateStyle),n.timeStyle&&(p.timeStyle=n.timeStyle);const w=new Intl.DateTimeFormat(m,p);h=v=>w.format(v)}else{const p=new Intl.DateTimeFormat(m,{dateStyle:"medium",timeZone:s});h=w=>p.format(w)}const d=n.relative?new Intl.RelativeTimeFormat(m,{numeric:"auto"}):null,b=(typeof n.relative=="object"&&n.relative?n.relative.threshold??7:7)*24*36e5,l=(p,w)=>{const v=L(p);if(!v)return t;if(d){const R=w&&typeof w.now=="number"?w.now:Date.now(),Y=v.getTime()-R;if(Math.abs(Y)<b){for(const[K,V]of k)if(Math.abs(Y)>=V||K==="second")return d.format(Math.round(Y/V),K)}}return h(v)};return l.spec=n,l}function f(c){if(T(c)||c==="")return null;if(typeof c=="string"){const m=/^(\d{4}-\d{2}-\d{2})/.exec(c.trim());if(m)return m[1];const t=L(c);return t?f(t):null}const u=L(c);if(!u)return null;const n=m=>String(m).padStart(2,"0");return`${u.getFullYear()}-${n(u.getMonth()+1)}-${n(u.getDate())}`}function g(c,u){if(T(c)||c==="")return null;if(typeof c=="string"){const m=c.trim();if(a.test(m)){const h=L(m);return h?r(h,u):null}const t=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(m);if(t){const[,h,d,o,b]=t;return`${h}T${d}:${o}${b&&b!=="00"?`:${b}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(m))return`${m}T00:00`;const s=L(m);return s?g(s):null}const n=L(c);return n?r(n,u):null}const a=/(?:Z|[+-]\d{2}:?\d{2})$/i;function r(c,u){const n=h=>String(h).padStart(2,"0");if(u)try{const h=new Intl.DateTimeFormat("en-CA",{timeZone:u,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(c).reduce((b,l)=>(l.type!=="literal"&&(b[l.type]=l.value),b),{}),d=h.hour==="24"?"00":h.hour,o=Number(h.second);return`${h.year}-${h.month}-${h.day}T${d}:${h.minute}`+(o?`:${h.second}`:"")}catch{}const m=`${c.getFullYear()}-${n(c.getMonth()+1)}-${n(c.getDate())}`,t=c.getSeconds(),s=`${n(c.getHours())}:${n(c.getMinutes())}${t?`:${n(t)}`:""}`;return`${m}T${s}`}function i(c,u){const n=T(c)||c===""?null:String(c),m=T(u)||u===""?null:String(u);return n===null?m===null?0:1:m===null||n<m?-1:n>m?1:0}}),Ue("packages/core/src/format/boolean.js",function(e,B){"use strict";Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return Z}});const T=B("packages/core/src/internal/predicates.js").isNil,G={true:"☑",false:"☐",null:""},D={true:"◉",false:"◯",null:""};function I(z){if(T(z)||z==="")return null;if(typeof z=="boolean")return z;if(typeof z=="number")return z!==0;const L=String(z).trim().toLowerCase();return L==="true"||L==="yes"||L==="y"||L==="1"?!0:L==="false"||L==="no"||L==="n"||L==="0"?!1:null}function Z(z,L){const X=z||{},$=X.display||"text",A=X.trueLabel??"Yes",k=X.falseLabel??"No",y=X.nullLabel??"";let f=A,g=k;const a=y;$==="checkbox"?(f=G.true,g=G.false):$==="switch"?(f=D.true,g=D.false):$==="icon"&&(f=X.trueIcon??A,g=X.falseIcon??k);const r=i=>{const c=I(i);return c===null?a:c?f:g};return r.display=$,r.labels={true:A,false:k,null:y},r.locale=L,r.spec=X,r}}),Ue("packages/core/src/format/text.js",function(e,B){"use strict";Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return I}});const T=B("packages/core/src/internal/predicates.js").isNil,D=B("packages/core/src/internal/text.js").titleCase;function I(Z,z){const L=Z||{},X=L.locale||z||void 0,$=L.nullDisplay??"",A=L.emptyDisplay??"",k=L.transform||"none",y=typeof L.truncate=="number"?{chars:L.truncate}:L.truncate||null,f=y?y.chars:0,g=y?y.ellipsis??"…":"",a=i=>{switch(k){case"upper":return X?i.toLocaleUpperCase(X):i.toUpperCase();case"lower":return X?i.toLocaleLowerCase(X):i.toLowerCase();case"title":return D(i);default:return i}},r=i=>{if(T(i))return $;let c=typeof i=="string"?i:String(i);return c===""?A:(k!=="none"&&(c=a(c)),f>0&&c.length>f&&(c=c.slice(0,f)+g),c)};return r.spec=L,r}}),Ue("packages/core/src/format/shorthand.js",function(e,B){"use strict";Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return z}});const re=["currency","number","percent","date","boolean","text","relative"],T=/[#0?@;"\\]/,G=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function D(L){return typeof L!="string"||L===""||Z(L)?!1:T.test(L)}function I(L){return typeof L!="string"||L===""||Z(L)?!1:G.test(L)}function Z(L){const X=L.indexOf(":"),$=X===-1?L:L.slice(0,X);return re.includes($)?$:null}function z(L){const X=Z(L);if(!X)return null;const $=L.indexOf(":"),A=$===-1?"":L.slice($+1),k=A===""?[]:A.split(":");switch(X){case"currency":{const y={type:"number",style:"currency",currency:k[0]||"USD"};return k[1]!==void 0&&k[1]!==""&&(y.decimals=Number(k[1])),y}case"number":{const y={type:"number",style:"decimal"};return k[0]!==void 0&&k[0]!==""&&(y.decimals=Number(k[0])),y}case"percent":{const y={type:"number",style:"percent"};return k[0]!==void 0&&k[0]!==""&&(y.decimals=Number(k[0])),y}case"date":return{type:"date",pattern:A||void 0};case"relative":return{type:"date",relative:!0};case"boolean":{const y=A.split("/"),f={type:"boolean",display:"text"};return y[0]!==void 0&&y[0]!==""&&(f.trueLabel=y[0]),y[1]!==void 0&&y[1]!==""&&(f.falseLabel=y[1]),y[2]!==void 0&&(f.nullLabel=y[2]),f}case"text":{const y={type:"text"};return k[0]&&(y.transform=k[0]),k[1]!==void 0&&k[1]!==""&&(y.truncate=Number(k[1])),y}default:return null}}}),Ue("packages/core/src/format/index.js",function(e,B){"use strict";Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return R}});const re=B("packages/core/src/internal/predicates.js"),T=re.isFunction,G=re.isObject,I=B("packages/core/src/internal/warn.js").warnOnce,Z=B("packages/core/src/format/number.js"),z=Z.compileNumber,L=B("packages/core/src/format/date.js"),X=L.compileDate,$=L.scanPattern,A=B("packages/core/src/format/boolean.js"),k=A.compileBoolean,y=B("packages/core/src/format/text.js"),f=y.compileText,g=B("packages/core/src/format/mask.js"),a=g.compileMask,r=B("packages/core/src/format/shorthand.js"),i=r.parseShorthand,c=r.looksLikeMask,u=r.looksLikeDatePattern,m=B("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 L.compileDate}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return L.compilePattern}}),Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return L.scanPattern}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return L.toDate}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return A.compileBoolean}}),Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return A.toTriState}}),Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return y.compileText}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return g.compileMask}}),Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return g.splitSections}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return g.parseSection}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return r.parseShorthand}}),Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return r.looksLikeMask}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return r.looksLikeDatePattern}});const t=new Set(["decimal","currency","percent","unit"]),s=new Set(["type","locale"]),h={number:new Set(["style","currency","currencyDisplay","decimals","minDecimals","maxDecimals","thousandsSeparator","decimalSeparator","notation","compactDisplay","negative","negativeClass","signed","prefix","suffix","zeroDisplay","nullDisplay","messages","scale","pattern"]),date:new Set(["pattern","dateStyle","timeStyle","timeZone","relative","nullDisplay"]),boolean:new Set(["display","trueLabel","falseLabel","nullLabel","trueIcon","falseIcon"]),text:new Set(["transform","truncate","nullDisplay","emptyDisplay"])},d=new Set(["number","date","boolean","text"]);function o(E,O){const C=E.type;if(C===void 0||d.has(C)||!t.has(String(C)))return;const S=O?`"${O}"`:"with no id";I(`format:unknown-style-key:${O||""}:${C}`,`column ${S} has format: { type: "${C}" }, which is not a valid format type ("number", "date", "boolean" or "text") and is ignored; did you mean style: "${C}" instead?`)}function b(E,O,C){const S=h[O],F=C?`"${C}"`:"with no id";for(const P of E){if(s.has(P)||S.has(P))continue;const M=Object.keys(h).find(x=>x!==O&&h[x].has(P));M?I(`format:inapplicable:${C||""}:${P}`,`column ${F} has format key "${P}", which applies to a ${M} column, not the ${O} column it was applied to; it is ignored.`):I(`format:unknown:${C||""}:${P}`,`column ${F} has an unrecognised format key "${P}" for its ${O} format; it is ignored.`)}}function l(E){if(E.type==="number"||E.type==="date"||E.type==="boolean"||E.type==="text")return!0;const O=t.has(String(E.style));return!!(E.pattern||E.dateStyle||E.timeStyle||E.relative||E.timeZone||E.trueLabel||E.falseLabel||E.display||E.trueIcon||E.falseIcon||E.transform||E.truncate||E.emptyDisplay||O||E.currency||E.decimals!==void 0||E.minDecimals!==void 0||E.maxDecimals!==void 0||E.notation||E.negative||E.scale!==void 0||E.prefix||E.suffix||E.zeroDisplay!==void 0)}function p(E,O){if(E.type==="number"||E.type==="date"||E.type==="boolean"||E.type==="text")return E.type;if(E.pattern){if(c(E.pattern))return"number";if(u(E.pattern))return"date"}if(E.dateStyle||E.timeStyle||E.relative||E.timeZone)return"date";if(E.trueLabel||E.falseLabel||E.display||E.trueIcon||E.falseIcon)return"boolean";if(E.transform||E.truncate||E.emptyDisplay)return"text";if(E.style||E.currency||E.decimals!==void 0||E.minDecimals!==void 0||E.maxDecimals!==void 0||E.notation||E.negative||E.scale!==void 0||E.prefix||E.suffix||E.zeroDisplay!==void 0)return"number";const C=O&&O.base;return C==="number"?"number":C==="date"||C==="dateString"?"date":C==="boolean"?"boolean":"text"}function w(E,O=null,C=void 0,S=void 0,F=void 0){if(E==null||E==="")return null;const P=G(E)?Object.keys(E):null;if(typeof E=="function"){const U=(_,W)=>String(E({...W||{},value:_,locale:C})??"");return U.ooxml=O&&O.excel||"General",U}if(typeof E=="string"){if(c(E)){const{format:_,ooxml:W}=a(E,C);return _.ooxml=W,_}const U=i(E)||(u(E)?{type:"date",pattern:E}:null);return U?w(U,O,C,S,F):(I(`format:${E}`,`unrecognised format string "${E}"; the value will be stringified`),null)}if(!G(E))return I("format:shape","format must be a spec object or a string; ignoring",E),null;if(O&&T(O.format)&&!l(E)||O&&T(O.format)&&Array.isArray(O.formatPatterns)&&E.type===void 0)return null;const M=p(E,O);M==="date"&&S&&E.timeZone===void 0&&(E={...E,timeZone:S}),o(E,F),b(P||Object.keys(E),M,F);let x;switch(M){case"number":x=z(E,C);break;case"date":x=X(E,C);break;case"boolean":x=k(E,C);break;default:x=f(E,C);break}return x.ooxml=R(E,M,C,O),x.kind=M,x}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 R(E,O,C=void 0,S=null){if(O==="date"){if(E.pattern){let U="";for(const _ of $(E.pattern))U+=_.token?v[_.token]??_.text:_.text;return U}return S&&S.excel||"yyyy-mm-dd"}if(O==="boolean")return"General";if(O==="text")return"@";if(typeof E.pattern=="string"&&m(E.pattern))return String(E.pattern).trim();if(E.notation==="compact"||E.notation==="scientific")return"General";const F=typeof E.decimals=="number"?E.decimals:typeof E.minDecimals=="number"?E.minDecimals:E.style==="currency"?2:0;let M=`${E.thousandsSeparator===!1?"":"#,#"}#0${F>0?`.${"0".repeat(F)}`:""}`,x="";return E.style==="currency"&&(x+=Y(V(E.currency||"USD",C))),E.prefix&&(x+=Y(E.prefix)),M=x+M,E.style==="percent"&&(M=`${M}%`),E.suffix&&(M+=Y(E.suffix)),E.negative==="parentheses"?`${M};(${M})`:E.negative==="suffix"?`${M};${M}-`:M}function Y(E){return`"${String(E).split('"').join("")}"`}const K=new Map;function V(E,O){const C=`${E}|${O||""}`;let S=K.get(C);if(S!==void 0)return S;S=E;try{const P=new Intl.NumberFormat(O,{style:"currency",currency:E}).formatToParts(0).find(M=>M.type==="currency");P&&(S=P.value)}catch{}return K.set(C,S),S}}),Ue("packages/core/src/columns/types/temporal.js",function(e,B){"use strict";Object.defineProperty(e,"MS_SECOND",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"MS_MINUTE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"MS_HOUR",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"MS_DAY",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"MS_WEEK",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"toTimeMs",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"zonedParts",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"zoneOffsetAt",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"instantFromParts",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"toEpochMs",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(e,"toDurationMs",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"zoneAbbrev",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(e,"resolveZoneName",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(e,"timestampGroupProjector",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"TEMPORAL_INFERENCE_ORDER",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return He}});const re=B("packages/core/src/internal/predicates.js"),T=re.isNil,G=re.isFunction,D=B("packages/core/src/format/date.js"),I=D.toDate,Z=D.compilePattern,z=D.compileDate,L=D.toIsoDateTime,X=D.compareIso,$=864e5,A=Object.freeze({}),k=1e3,y=60*k,f=60*y,g=24*f,a=7*g,r=new WeakMap;function i(Me,Ke){const $e=Me&&Me.locale||"",Oe=Me&&Me.column;if(!Oe)return $e?{locale:$e}:A;const Se=r.get(Oe);if(Se&&Se.locale===$e)return Se.bag;const Pe=Oe.typeOptions||Oe[Ke]||(c(Oe.format)?Oe.format:null),Te={...Pe||A,locale:Pe&&Pe.locale||$e||void 0};return r.set(Oe,{locale:$e,bag:Te}),Te}function c(Me){return Me!==null&&typeof Me=="object"&&!Array.isArray(Me)&&!(Me instanceof Date)}function u(Me,Ke){const $e=Me===null||Number.isNaN(Me)?null:Me,Oe=Ke===null||Number.isNaN(Ke)?null:Ke;return $e===null?Oe===null?0:1:Oe===null||$e<Oe?-1:$e>Oe?1:0}const n=/^(\d{1,2})(?:\s*[:.h]\s*(\d{1,2})(?:\s*[:.]\s*(\d{1,2})(?:[.,](\d{1,3}))?)?)?\s*(a\.?m\.?|p\.?m\.?|a|p)?$/i,m=/^(\d{3,6})$/;function t(Me,Ke,$e,Oe){return!(Me>=0&&Me<=23)||!(Ke>=0&&Ke<=59)||!($e>=0&&$e<=59)||!(Oe>=0&&Oe<=999)?null:Me*f+Ke*y+$e*k+Oe}function s(Me){if(T(Me))return null;const Ke=String(Me).trim();if(Ke==="")return null;const $e=m.exec(Ke);if($e){const et=$e[1];if(et.length===5)return null;const Je=et.length===3?1:2;return t(Number(et.slice(0,Je)),Number(et.slice(Je,Je+2)),Number(et.slice(Je+2,Je+4)||0),0)}const Oe=n.exec(Ke);if(!Oe)return null;let Se=Number(Oe[1]);const Pe=Number(Oe[2]||0),Te=Number(Oe[3]||0),Be=Oe[4]?Number(Oe[4].padEnd(3,"0")):0,Ge=Oe[5]?Oe[5][0].toLowerCase():null;if(Ge){if(Se<1||Se>12)return null;Se=Se%12,Ge==="p"&&(Se+=12)}return t(Se,Pe,Te,Be)}function h(Me){return T(Me)||Me===""?null:typeof Me=="number"?Number.isFinite(Me)?(Me%g+g)%g:null:Me instanceof Date?Number.isNaN(Me.getTime())?null:Me.getHours()*f+Me.getMinutes()*y+Me.getSeconds()*k+Me.getMilliseconds():s(Me)}const d=new Map;function o(Me){const Ke=Me.pattern||"",$e=Me.timeStyle||(Me.seconds?"medium":"short"),Oe=`${Me.locale||""}|${Ke}|${$e}`;let Se=d.get(Oe);if(Se)return Se;if(Ke)Se=Z(Ke,Me.locale||void 0,"UTC");else{const Pe=new Intl.DateTimeFormat(Me.locale||void 0,{timeStyle:$e,timeZone:"UTC"});Se=Te=>Pe.format(Te)}return d.set(Oe,Se),Se}function b(Me,Ke){const $e=Ke||A;if(Me==null||typeof Me!="number"||!Number.isFinite(Me))return $e.nullDisplay??"";const Oe=(Me%g+g)%g;return o($e)(new Date(Oe))}function l(Me){return Me instanceof Date?!Number.isNaN(Me.getTime()):typeof Me=="number"?Number.isFinite(Me)&&Me>=0&&Me<g:typeof Me!="string"||!Me.includes(":")?!1:s(Me)!==null}function p(Me){const Ke=h(Me);return Ke==null?"":b(Ke,{pattern:Ke%k===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const w=new Map;function v(Me){const Ke=Me||"";let $e=w.get(Ke);return $e||($e=new Intl.DateTimeFormat("en-GB",{timeZone:Me||void 0,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),w.set(Ke,$e)),$e}function R(Me,Ke){const $e={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const Oe of v(Ke).formatToParts(new Date(Me)))Oe.type==="year"?$e.year=Number(Oe.value):Oe.type==="month"?$e.month=Number(Oe.value):Oe.type==="day"?$e.day=Number(Oe.value):Oe.type==="hour"?$e.hour=Number(Oe.value)%24:Oe.type==="minute"?$e.minute=Number(Oe.value):Oe.type==="second"&&($e.second=Number(Oe.value));return $e}function Y(Me,Ke){const $e=R(Me,Ke);return Date.UTC($e.year,$e.month-1,$e.day,$e.hour,$e.minute,$e.second,0)-Math.floor(Me/1e3)*1e3}function K(Me,Ke){const $e=Me.hour||0,Oe=Me.minute||0,Se=Me.second||0,Pe=Me.ms||0;if(!Ke)return new Date(Me.year,Me.month-1,Me.day,$e,Oe,Se,Pe).getTime();const Te=Date.UTC(Me.year,Me.month-1,Me.day,$e,Oe,Se,Pe);let Be=Te-Y(Te,Ke);return Be=Te-Y(Be,Ke),Be}const V=/(?:Z|[+-]\d{2}:?\d{2})$/i,E=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function O(Me,Ke){if(T(Me))return null;const $e=String(Me).trim();if($e==="")return null;const Oe=Ke&&Ke.timeZone||void 0;if(!V.test($e)){const Se=E.exec($e);if(Se){const Pe=(Se[4]||"").trim(),Te=Pe===""?0:s(Pe);if(Te===null)return null;const Be=K({year:Number(Se[1]),month:Number(Se[2]),day:Number(Se[3]),hour:Math.floor(Te/f),minute:Math.floor(Te/y)%60,second:Math.floor(Te/k)%60,ms:Te%k},Oe);return Number.isNaN(Be)?null:new Date(Be)}}return I($e)}function C(Me){if(typeof Me=="number")return Number.isFinite(Me)?Me:null;const Ke=I(Me);return Ke?Ke.getTime():null}const S=new Map;function F(Me){const Ke=[Me.locale||"",Me.pattern||"",Me.dateStyle||"",Me.timeStyle||"",Me.timeZone||"",Me.seconds?"1":""].join("|");let $e=S.get(Ke);if($e)return $e;const Oe=Me.pattern?{type:"date",pattern:Me.pattern,timeZone:Me.timeZone}:{type:"date",dateStyle:Me.dateStyle||"medium",timeStyle:Me.timeStyle||(Me.seconds?"medium":"short"),timeZone:Me.timeZone};return $e=z(Oe,Me.locale||void 0),S.set(Ke,$e),$e}function P(Me,Ke){const $e=Ke||A,Oe=C(Me);return Oe==null?$e.nullDisplay??"":F($e)(Oe)}function M(Me){return Me instanceof Date?!Number.isNaN(Me.getTime()):typeof Me!="string"||!E.test(Me.trim())?!1:O(Me)!==null}const x=Object.freeze([{key:"w",ms:a,intl:"week",long:["week","weeks"],names:["w","wk","wks","week","weeks"]},{key:"d",ms:g,intl:"day",long:["day","days"],names:["d","dy","day","days"]},{key:"h",ms:f,intl:"hour",long:["hour","hours"],names:["h","hr","hrs","hour","hours"]},{key:"m",ms:y,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"]}]),U=new Map;for(const Me of x)for(const Ke of Me.names)U.set(Ke,Me);const _=Object.freeze(x.filter(Me=>Me.key!=="w")),W=/^(\d+(?:\.\d+)?)\s*([a-z]+)\s*(?:,\s*)?/,q=/^\d+(?:\.\d+)?$/,N=/^(\d+):([0-5]?\d)(?::([0-5]?\d))?(?:\.(\d{1,3}))?$/;function Q(Me){const Ke=Me&&Me.defaultUnit?U.get(String(Me.defaultUnit).toLowerCase()):null;return Ke?Ke.ms:y}function J(Me){return(Me&&Me.defaultUnit?U.get(String(Me.defaultUnit).toLowerCase()):null)||U.get("m")}function ee(Me,Ke){if(T(Me))return null;let $e=String(Me).trim().toLowerCase();if($e==="")return null;let Oe=1;if($e[0]==="-"?(Oe=-1,$e=$e.slice(1).trim()):$e[0]==="+"&&($e=$e.slice(1).trim()),$e==="")return null;const Se=N.exec($e);if(Se){const Ge=Se[3]!==void 0,et=Number(Se[1])*f+Number(Se[2])*y+(Ge?Number(Se[3])*k:0)+(Se[4]?Number(Se[4].padEnd(3,"0")):0);return Oe*et}if(q.test($e))return Math.round(Oe*Number($e)*Q(Ke||A));let Pe=$e,Te=0,Be=0;for(;Pe!=="";){const Ge=W.exec(Pe);if(!Ge)return null;const et=U.get(Ge[2]);if(!et)return null;Te+=Number(Ge[1])*et.ms,Pe=Pe.slice(Ge[0].length),Be++}return Be===0?null:Math.round(Oe*Te)}function ne(Me){return T(Me)||Me===""?null:typeof Me=="number"?Number.isFinite(Me)?Me:null:ee(Me)}const se=new Map;function le(Me,Ke,$e){const Oe=`${$e||""}|${Ke.intl}`;let Se=se.get(Oe);if(Se===void 0){try{Se=new Intl.NumberFormat($e||void 0,{style:"unit",unit:Ke.intl,unitDisplay:"long"})}catch{Se=null}se.set(Oe,Se)}return Se?Se.format(Me):`${Me} ${Me===1?Ke.long[0]:Ke.long[1]}`}function ye(Me,Ke){return String(Me).padStart(Ke,"0")}function fe(Me,Ke){const $e=Ke||A;if(Me==null||typeof Me!="number"||!Number.isFinite(Me))return $e.nullDisplay??"";const Oe=$e.style||"short",Se=Me<0;let Pe=Math.round(Math.abs(Me));const Te=Se?"-":"";if(Pe===0&&$e.zeroDisplay!=null)return $e.zeroDisplay;if(Oe==="clock"){const Je=Math.floor(Pe/f),ft=Math.floor(Pe/y)%60,Et=Math.floor(Pe/k)%60;return`${Te}${ye(Je,2)}:${ye(ft,2)}:${ye(Et,2)}`}if(Pe===0){const Je=J($e);return Oe==="long"?le(0,Je,$e.locale):`0${Je.key}`}const Be=$e.weeks===!0?x:_,Ge=typeof $e.maxUnits=="number"&&$e.maxUnits>0?$e.maxUnits:$e.maxUnits===void 0?2:1/0,et=[];for(const Je of Be){if(et.length>=Ge)break;const ft=Math.floor(Pe/Je.ms);ft!==0&&(Pe-=ft*Je.ms,et.push(Oe==="long"?le(ft,Je,$e.locale):`${ft}${Je.key}`))}return Te+et.join(" ")}function we(Me){if(typeof Me!="string")return!1;const Ke=Me.trim();return Ke===""||N.test(Ke)||!/[a-z]/i.test(Ke)?!1:ee(Ke)!==null}const ke=Date.UTC(1899,11,30),Ce=new Map;function ce(Me,Ke){const $e=Me||"";let Oe=Ce.get($e);Oe||(Oe=new Intl.DateTimeFormat("en-GB",{timeZone:Me||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),Ce.set($e,Oe));const Se=typeof Ke=="number"?Ke:Date.now();for(const Pe of Oe.formatToParts(new Date(Se)))if(Pe.type==="timeZoneName")return Pe.value;return""}function ae(Me){if(Me)return Me;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function ge(Me,Ke){const $e=ae(Me),Oe=ce(Me,Ke);return Oe?`${$e} (${Oe})`:$e}function de(Me,Ke){if(Me&&Me.timeZone)return Me.timeZone;const $e=Ke&&Ke.grid;return($e&&G($e.get)?$e.get("timeZone"):void 0)||void 0}function me(Me,Ke){const $e=Ke||A,Oe=C(Me);if(Oe==null)return $e.nullDisplay??"";const Se=F($e)(Oe);if(!$e.showOrigin)return Se;const Pe=$e.originZone;return Pe?Pe===($e.timeZone||ae($e.timeZone))?Se:`${Se} (${ge(Pe,Oe)})`:`${Se} (no origin recorded)`}function ve(Me,Ke,$e,Oe){if(Ke==="instant"||!Ke)return Me;const Se=R(Me,$e);if(Ke==="month")return K({year:Se.year,month:Se.month,day:1},$e);if(Ke==="week"){const Pe=Oe>=1&&Oe<=7?Oe:1,Be=((new Date(Date.UTC(Se.year,Se.month-1,Se.day)).getUTCDay()+6)%7+1-Pe+7)%7,Ge=new Date(Date.UTC(Se.year,Se.month-1,Se.day-Be));return K({year:Ge.getUTCFullYear(),month:Ge.getUTCMonth()+1,day:Ge.getUTCDate()},$e)}return K({year:Se.year,month:Se.month,day:Se.day},$e)}function xe(Me,Ke){const $e=Me&&Me.group,Oe=$e&&$e.granularity||"day";if(Oe==="instant")return null;const Se=$e&&$e.weekStart;return Pe=>typeof Pe=="number"?ve(Pe,Oe,Ke,Se):Pe}const Ee={time:{base:"number",storage:"float64",matches:l,format:Me=>b(h(Me.value),i(Me,"time")),parse:Me=>s(Me.text),compare:(Me,Ke)=>u(h(Me),h(Ke)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:Me=>{const Ke=h(Me);return Ke===null?null:Ke/$},toStorage:Me=>h(Me),toClipboard:p,fromClipboard:s},datetime:{base:"dateString",storage:"dictionary",matches:M,format:Me=>P(Me.value,i(Me,"datetime")),parse:Me=>L(O(Me.text,i(Me,"datetime"))??Me.text),compare:X,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(Me,Ke)=>L(Me,Ke&&Ke.timeZone),toClipboard:Me=>T(Me)?"":String(Me),fromClipboard:Me=>L(Me)},duration:{base:"number",storage:"float64",matches:we,format:Me=>fe(ne(Me.value),i(Me,"duration")),parse:Me=>ee(Me.text,i(Me,"duration")),compare:(Me,Ke)=>u(ne(Me),ne(Ke)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:Me=>{const Ke=ne(Me);return Ke===null?null:Ke/$},toStorage:Me=>ne(Me),toClipboard:Me=>fe(ne(Me),{style:"short",maxUnits:-1}),fromClipboard:Me=>ee(Me)},timestamp:{base:"number",storage:"float64",format:Me=>{const Ke=i(Me,"timestamp");return me(Me.value,{...Ke,timeZone:de(Ke,Me)})},parse:Me=>{const Ke=i(Me,"timestamp"),$e=O(Me.text,{timeZone:de(Ke,Me)});return $e?$e.getTime():null},compare:(Me,Ke)=>u(C(Me),C(Ke)),groupProjector:(Me,Ke)=>xe(Me,Ke),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(Me,Ke)=>{const $e=C(Me);if($e==null)return null;const Oe=R($e,Ke&&Ke.timeZone||void 0);return(Date.UTC(Oe.year,Oe.month-1,Oe.day,Oe.hour,Oe.minute,Oe.second)-ke)/$},toStorage:Me=>C(Me),toClipboard:Me=>{const Ke=C(Me);return Ke==null?"":new Date(Ke).toISOString()},fromClipboard:Me=>C(Me)}},Le=["datetime","time","duration"],He=Ee}),Ue("packages/core/src/internal/lru.js",function(e,B){"use strict";Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return re}});class re{#e;#t=new Map;#n;constructor(G=256,D=null){this.#e=G,this.#n=D}get size(){return this.#t.size}get max(){return this.#e}set max(G){this.#e=G,this.#r()}has(G){return this.#t.has(G)}get(G){const D=this.#t;if(!D.has(G))return;const I=D.get(G);return D.delete(G),D.set(G,I),I}peek(G){return this.#t.get(G)}set(G,D){const I=this.#t;return I.has(G)&&I.delete(G),I.set(G,D),this.#r(),D}delete(G){const D=this.#t.get(G);return this.#t.delete(G)&&this.#n&&this.#n(D,G),D}clear(){if(this.#n)for(const[G,D]of this.#t)this.#n(D,G);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const G=this.#t;for(;G.size>this.#e;){const D=G.keys().next().value,I=G.get(D);G.delete(D),this.#n&&this.#n(I,D)}}}}),Ue("packages/core/src/columns/types/network.js",function(e,B){"use strict";Object.defineProperty(e,"toUint32",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"isIpv4",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"compareIpv4",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"packCidr",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"cidrParts",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isCidr",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"compareCidr",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"netmask",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"addressCount",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ipv6Groups",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"isIpv6",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return C}});const T=B("packages/core/src/internal/predicates.js").isNil,D=B("packages/core/src/internal/lru.js").Lru,I=4294967295,Z=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function z(S){if(T(S))return null;if(typeof S=="string")return L(S);const F=Number(S);return Number.isFinite(F)?F<0?F<-2147483648?null:F>>>0:F>I?null:Math.trunc(F)>>>0:null}function L(S){if(T(S))return null;const F=String(S).trim();if(F==="")return null;const P=Z.exec(F);if(!P)return null;let M=0;for(let x=1;x<=4;x++){const U=P[x];if(U.length>1&&U.charCodeAt(0)===48)return null;const _=Number(U);if(_>255)return null;M=M*256+_}return M}function X(S){const F=z(S);return F===null?"":`${F>>>24&255}.${F>>>16&255}.${F>>>8&255}.${F&255}`}function $(S){return typeof S=="string"&&L(S)!==null}function A(S,F){const P=z(S),M=z(F);return P===null?M===null?0:1:M===null||P<M?-1:P>M?1:0}const k=64,y=I*k+32,f=/^(?:0|[1-9]\d?)$/;function g(S,F){return S*k+F}function a(S){if(T(S))return null;if(typeof S=="string"){const M=r(S);return M===null?null:a(M)}if(typeof S=="object"){const M=z(S.address),x=Number(S.prefix);return M===null||!Number.isInteger(x)||x<0||x>32?null:{address:M,prefix:x}}const F=Number(S);if(!Number.isInteger(F)||F<0||F>y)return null;const P=F%k;return P>32?null:{address:(F-P)/k,prefix:P}}function r(S){if(T(S))return null;const F=String(S).trim();if(F==="")return null;const P=F.indexOf("/");if(P<0)return null;const M=L(F.slice(0,P));if(M===null)return null;const x=F.slice(P+1).trim();if(!f.test(x))return null;const U=Number(x);return U>32?null:g(M,U)}function i(S){const F=a(S);return F?`${X(F.address)}/${F.prefix}`:""}function c(S){return typeof S=="string"&&r(S)!==null}function u(S,F){const P=a(S),M=a(F);return P?M?P.address!==M.address?P.address<M.address?-1:1:P.prefix-M.prefix:-1:M?1:0}function n(S){return S===0?0:4294967295<<32-S>>>0}function m(S){const F=a(S);return F?(F.address&n(F.prefix))>>>0:null}function t(S){const F=a(S);return F?(F.address&n(F.prefix)|~n(F.prefix)>>>0)>>>0:null}function s(S){const F=a(S);return F?2**(32-F.prefix):null}function h(S){const F=a(S);return F?F.prefix===32?1:F.prefix===31?2:2**(32-F.prefix)-2:null}function d(S,F){const P=a(S);if(!P)return!1;const M=z(F);if(M===null)return!1;const x=n(P.prefix);return(M&x)>>>0===(P.address&x)>>>0}function o(S,F){const P=m(S),M=m(F);return P===null||M===null?!1:P<=t(F)&&M<=t(S)}const b=/^[0-9a-fA-F]{1,4}$/,l=new D(512);function p(S){if(T(S))return null;let F=String(S).trim();if(F==="")return null;const P=F.indexOf("%");if(P>=0&&(F=F.slice(0,P)),F==="")return null;if(F.indexOf(".")>=0){const q=F.lastIndexOf(":");if(q<0)return null;const N=L(F.slice(q+1));if(N===null)return null;F=`${F.slice(0,q+1)}${(N>>>16&65535).toString(16)}:${(N&65535).toString(16)}`}const M=F.split("::");if(M.length>2)return null;const x=w(M[0]);if(x===null)return null;if(M.length===1)return x.length===8?x:null;const U=w(M[1]);if(U===null)return null;const _=8-x.length-U.length;if(_<1)return null;const W=x.slice();for(let q=0;q<_;q++)W.push(0);for(const q of U)W.push(q);return W}function w(S){if(S==="")return[];const F=[];for(const P of S.split(":")){if(!b.test(P))return null;F.push(parseInt(P,16))}return F}function v(S){if(typeof S!="string")return p(S);if(l.has(S))return l.get(S);const F=p(S);return l.set(S,F),F}function R(S){if(S[0]===0&&S[1]===0&&S[2]===0&&S[3]===0&&S[4]===0&&S[5]===65535)return`::ffff:${X((S[6]<<16|S[7])>>>0)}`;let F=-1,P=0,M=-1,x=0;for(let W=0;W<8;W++)S[W]===0?(M<0?(M=W,x=1):x++,x>P&&(P=x,F=M)):(M=-1,x=0);if(P<2)return S.map(W=>W.toString(16)).join(":");const U=S.slice(0,F).map(W=>W.toString(16)).join(":"),_=S.slice(F+P).map(W=>W.toString(16)).join(":");return`${U}::${_}`}function Y(S){const F=p(S);return F===null?null:R(F)}function K(S){return Y(S)??""}function V(S){return typeof S=="string"&&S.indexOf(":")>=0&&p(S)!==null}function E(S,F){const P=v(S),M=v(F);if(!P)return M?1:0;if(!M)return-1;for(let x=0;x<8;x++)if(P[x]!==M[x])return P[x]<M[x]?-1:1;return 0}const O=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:$,parse:S=>L(S.text),compare:A,format:S=>X(S.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:S=>z(S),toClipboard:S=>X(S),fromClipboard:S=>L(S)},cidr:{base:"number",storage:"float64",matches:c,parse:S=>r(S.text),compare:u,format:S=>i(S.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:S=>{const F=a(S);return F===null?null:g(F.address,F.prefix)},toClipboard:S=>i(S),fromClipboard:S=>r(S)},ipv6:{base:"text",storage:"dictionary",matches:V,parse:S=>Y(S.text),compare:E,format:S=>K(S.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",toStorage:S=>Y(S),toClipboard:S=>K(S),fromClipboard:S=>Y(S)}}),C=O}),Ue("packages/core/src/i18n/catalogue.js",function(e,B){"use strict";Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return I}});const re=B("packages/core/src/registry/free-tier-notice.js"),T=re.FREE_TIER_NOTICE,G=re.WATERMARK_TEXT,D=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.column.hidden":"{column} hidden","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.unavailable":"Not available on this source","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.columnMenu":"Column menu","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; while editing, commit and open the cell below (Shift+Enter: above)","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":G,"licence.watermark.free":T,"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.order":"Order values","filter.orderAz":"A to Z","filter.orderCount":"Count","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"}),I=Object.freeze(Object.keys(D))}),Ue("packages/core/src/i18n/format.js",function(e,B){"use strict";Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"formatMessage",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"lookup",{enumerable:!0,get:function(){return k}});const T=B("packages/core/src/internal/predicates.js").isFunction,G=/\{(\w+)\}/g,D=new Map,I=new Map;function Z(y){const f=y||"";if(D.has(f))return D.get(f);let g=null;try{g=new Intl.PluralRules(y||void 0)}catch{g=null}return D.set(f,g),g}function z(y,f,g="conjunction"){const a=Array.isArray(y)?y.filter(c=>c!=null&&c!==""):[];if(a.length===0)return"";if(a.length===1)return String(a[0]);const r=`${f||""}|${g}`;let i=I.get(r);if(i===void 0){try{i=new Intl.ListFormat(f||void 0,{style:"long",type:g})}catch{i=null}I.set(r,i)}return i?i.format(a.map(String)):a.map(String).join(", ")}function L(y,f){return y==null?"":typeof y=="number"?Number.isFinite(y)?y.toLocaleString(f||void 0,{maximumFractionDigits:20}):"":String(y)}function X(y,f,g){if(typeof y=="string")return y;if(!y||typeof y!="object")return"";const a=f&&typeof f.count=="number"?f.count:null;if(a===null)return y.other??"";const r=Z(g),i=r?r.select(a):a===1?"one":"other";return y[i]??y.other??""}function $(y,f={},g){const a=X(y,f,g);return a?a.replace(G,(r,i)=>Object.prototype.hasOwnProperty.call(f,i)?L(f[i],g):r):""}function A(y,f,g="en-GB"){return typeof y=="string"&&y?y:typeof f=="string"&&f?f:g}function k(y,f){const g=y?y[f]:void 0;return g==null||T(g)?f:g}}),Ue("packages/core/src/i18n/registry.js",function(e,B){"use strict";Object.defineProperty(e,"registerLocale",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"localeCatalogue",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"registeredTags",{enumerable:!0,get:function(){return Z}});const T=B("packages/core/src/i18n/catalogue.js").EN_GB,G=new Map([["en-gb",T]]);function D(z,L){const X=typeof z=="string"?z.toLowerCase():"";return!X||!L||typeof L!="object"?!1:(G.set(X,L),!0)}function I(z){if(typeof z!="string"||!z)return null;const L=z.toLowerCase(),X=G.get(L);if(X)return X;const $=L.split("-")[0],A=G.get($);if(A)return A;for(const[k,y]of G)if(k.split("-")[0]===$)return y;return null}function Z(){return[...G.keys()]}}),Ue("packages/core/src/i18n/index.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"defaultMessages",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return u}});const re=B("packages/core/src/i18n/catalogue.js"),T=re.EN_GB,G=re.MESSAGE_KEYS,D=B("packages/core/src/i18n/format.js"),I=D.formatMessage,Z=D.formatList,z=D.lookup,L=D.resolveLocale,$=B("packages/core/src/internal/predicates.js").isFunction,k=B("packages/core/src/internal/warn.js").warnOnce,y=B("packages/core/src/i18n/registry.js"),f=y.registerLocale,g=y.localeCatalogue;Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return re.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return re.MESSAGE_KEYS}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return D.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return D.resolveLocale}}),Object.defineProperty(e,"registerLocale",{enumerable:!0,get:function(){return y.registerLocale}});const a="en-GB";class r{#e=a;#t=T;constructor(m={}){this.configure(m)}configure(m={}){this.#e=L(m.locale,m.declared,a);const t=m.messages,s=g(this.#e);if(!s&&this.#e.toLowerCase()!=="en-gb"&&(!t||typeof t!="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.`),!t||typeof t!="object"){this.#t=s?{...T,...s}:T;return}const d=Object.keys(t).filter(o=>!(o in T));d.length&&k(`i18n:unknown:${d[0]}`,`message keys not in the catalogue and so ignored: ${d.slice(0,5).join(", ")}${d.length>5?`, and ${d.length-5} more`:""}`),this.#t={...T,...s||{},...t}}get locale(){return this.#e}t(m,t){return I(z(this.#t,m),t||{},this.#e)}list(m,t){return Z(m,this.#e,t)}number(m,t){const s=Number(m);return Number.isFinite(s)?s.toLocaleString(this.#e,t||{maximumFractionDigits:20}):""}}const i=new r;function c(n){return n instanceof r?n:new r(n||{})}function u(n){const m=n&&typeof n=="object"?n:{},t=G.filter(h=>{const d=m[h];return d==null||d===""||$(d)}),s=Object.keys(m).filter(h=>!(h in T));return{missing:t,unknown:s}}}),Ue("packages/core/src/columns/types/structured.js",function(e,B){"use strict";Object.defineProperty(e,"MASK_DEFAULTS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"canonicalJson",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"parseJsonText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const re=B("packages/core/src/internal/predicates.js"),T=re.isNil,G=re.isObject,I=B("packages/core/src/i18n/index.js").defaultMessages,Z=Object.freeze({char:"•",length:8,fixedLength:!0,lastVisible:0,emptyDisplay:""});function z(r,i){const c=i||{},u=c.emptyDisplay??Z.emptyDisplay;if(T(r)||r==="")return u;const m=[...typeof c.char=="string"&&c.char!==""?c.char:Z.char][0]||Z.char,t=c.fixedLength??Z.fixedLength,s=Number.isFinite(c.length)&&Number(c.length)>0?Math.floor(Number(c.length)):Z.length,h=typeof r=="string"?r:typeof r=="number"||typeof r=="boolean"||typeof r=="bigint"?String(r):null;let d=0;if(h!==null){const o=Number.isFinite(c.lastVisible)?Math.floor(Number(c.lastVisible)):Z.lastVisible,b=[...h];if(d=o>0&&o<b.length?o:0,d>0){const l=b.slice(b.length-d).join(""),p=Math.max(1,(t?s:b.length)-d);return m.repeat(p)+l}return m.repeat(t?s:Math.max(1,b.length))}return m.repeat(s)}const L=48;function X(r){try{const i=JSON.stringify(r);return i===void 0?null:i}catch{return null}}function $(r,i){if(T(r))return"";const c=Number.isFinite(i&&i.inlineLimit)?Number(i.inlineLimit):L;if(typeof r=="string")return r.length>c?`${r.slice(0,c-1)}…`:r;if(typeof r!="object")return String(r);const u=X(r);if(u!==null&&u.length<=c)return u;if(Array.isArray(r)){const m=r.length;return`[${I.t("count.items",{count:m})}]`}const n=Object.keys(r).length;return`{${I.t("count.keys",{count:n})}}`}function A(r,i){if(r==null)return"null";const c=typeof r;if(c==="number"||c==="boolean"||c==="bigint")return String(r);if(c==="string")return JSON.stringify(r);if(c!=="object")return JSON.stringify(String(r));const u=i||new WeakSet;return u.has(r)?'"[circular]"':(u.add(r),r instanceof Date?JSON.stringify(r.toISOString()):Array.isArray(r)?`[${r.map(t=>A(t,u)).join(",")}]`:`{${Object.keys(r).sort().map(t=>`${JSON.stringify(t)}:${A(r[t],u)}`).join(",")}}`)}function k(r,i){if(T(r))return T(i)?0:1;if(T(i))return-1;const c=A(r),u=A(i);return c<u?-1:c>u?1:0}function y(r){if(T(r))return null;const i=String(r);if(i.trim()==="")return null;try{return JSON.parse(i)}catch{return i}}function f(r){const i=r&&r.cell&&r.cell.props;return G(i)?i:{}}const g=Object.freeze({json:{base:"object",storage:"object",format:r=>$(r&&r.value,f(r&&r.column)),parse:r=>y(r&&r.text),compare:k,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:r=>{if(T(r))return"";if(typeof r=="string")return r;try{const i=JSON.stringify(r,null,2);return i===void 0?String(r):i}catch{return String(r)}},fromClipboard:r=>y(r)},secret:{base:"text",storage:"object",format:r=>z(r&&r.value,f(r&&r.column)),parse:r=>{const i=r&&r.text;return T(i)||String(i)===""?null:String(i)},compare:(r,i)=>{const c=T(r)||r==="",u=T(i)||i==="";return c===u?0:c?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:r=>z(r),fromClipboard:r=>T(r)||String(r)===""?null:String(r)}}),a=g}),Ue("packages/core/src/columns/types/unit.js",function(e,B){"use strict";Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return M}});const T=B("packages/core/src/internal/predicates.js").isNil,D=B("packages/core/src/internal/warn.js").warnOnce;function I(x,U,_,W){return Object.freeze({symbol:x,factor:U,aliases:Object.freeze(_||[]),binary:!!(W&&W.binary),prefix:W&&W.prefix||null,auto:!(W&&W.auto===!1)})}function Z(x,U,_,W){return I(x,U,_,W)}const z=Object.freeze({data:Object.freeze([I("B",1,["byte","bytes"]),I("kB",1e3,["kilobyte","kilobytes"],{prefix:"k"}),I("KiB",1024,["kibibyte","kibibytes"],{binary:!0,prefix:"k"}),I("MB",1e6,["megabyte","megabytes"],{prefix:"m"}),I("MiB",1024**2,["mebibyte","mebibytes"],{binary:!0,prefix:"m"}),I("GB",1e9,["gigabyte","gigabytes"],{prefix:"g"}),I("GiB",1024**3,["gibibyte","gibibytes"],{binary:!0,prefix:"g"}),I("TB",1e12,["terabyte","terabytes"],{prefix:"t"}),I("TiB",1024**4,["tebibyte","tebibytes"],{binary:!0,prefix:"t"}),I("PB",1e15,["petabyte","petabytes"],{prefix:"p"})]),bitrate:Object.freeze([I("bps",1,["bit","bits","bit/s","b/s"]),I("kbps",1e3,["kbit","kbits","kbit/s","kb/s","kilobit","kilobits"],{prefix:"k"}),I("Mbps",1e6,["mbit","mbits","mbit/s","mb/s","megabit","megabits"],{prefix:"m"}),I("Gbps",1e9,["gbit","gbits","gbit/s","gb/s","gigabit","gigabits"],{prefix:"g"}),I("Tbps",1e12,["tbit","tbits","tbit/s","tb/s","terabit","terabits"],{prefix:"t"})]),length:Object.freeze([I("nm",1e-9,["nanometre","nanometres","nanometer","nanometers"]),I("µm",1e-6,["um","micrometre","micrometres","micrometer","micrometers","micron","microns"]),I("mm",.001,["millimetre","millimetres","millimeter","millimeters"]),I("cm",.01,["centimetre","centimetres","centimeter","centimeters"]),I("in",.0254,["inch","inches"],{auto:!1}),I("ft",.3048,["foot","feet"],{auto:!1}),I("yd",.9144,["yard","yards"],{auto:!1}),I("m",1,["metre","metres","meter","meters"]),I("km",1e3,["kilometre","kilometres","kilometer","kilometers"]),I("mi",1609.344,["mile","miles"],{auto:!1}),I("nmi",1852,["nauticalmile","nauticalmiles"],{auto:!1})]),mass:Object.freeze([I("mg",.001,["milligram","milligrams"]),I("g",1,["gram","grams"]),I("oz",28.349523125,["ounce","ounces"],{auto:!1}),I("lb",453.59237,["pound","pounds","lbs"],{auto:!1}),I("kg",1e3,["kilogram","kilograms"]),I("st",6350.29318,["stone"],{auto:!1}),I("t",1e6,["tonne","tonnes","ton"],{auto:!1}),I("ton (US)",907184.74,["ton","shortton"],{auto:!1}),I("ton (UK)",10160469088e-4,["ton","longton"],{auto:!1})]),duration:Object.freeze([I("ns",1e-9,["nsec","nsecs","nanosecond","nanoseconds"]),I("µs",1e-6,["us","usec","usecs","microsecond","microseconds"]),I("ms",.001,["msec","msecs","millisecond","milliseconds"]),I("s",1,["sec","secs","second","seconds"]),I("m",60,["min","mins","minute","minutes"]),I("h",3600,["hr","hrs","hour","hours"]),I("d",86400,["day","days"])]),speed:Object.freeze([I("mm/s",.001,["millimetre/s","millimeter/s"]),I("ft/s",.3048,["fps","foot/s","feet/s"],{auto:!1}),I("km/h",1/3.6,["kph","kmh","kilometre/h","kilometer/h"],{auto:!1}),I("mph",.44704,["mile/h","miles/h"],{auto:!1}),I("kn",1852/3600,["knot","knots"],{auto:!1}),I("m/s",1,["metre/s","meter/s","mps"]),I("km/s",1e3,["kilometre/s","kilometer/s"])]),acceleration:Object.freeze([I("mm/s²",.001,["mm/s2"]),I("ft/s²",.3048,["ft/s2"],{auto:!1}),I("m/s²",1,["m/s2","metre/s2","meter/s2"]),I("g",9.80665,["gee","gravity"],{auto:!1})]),area:Object.freeze([I("mm²",1e-6,["mm2"]),I("cm²",1e-4,["cm2"]),I("in²",64516e-8,["in2","sqin"],{auto:!1}),I("ft²",.09290304,["ft2","sqft"],{auto:!1}),I("yd²",.83612736,["yd2","sqyd"],{auto:!1}),I("m²",1,["m2","sqm"]),I("ha",1e4,["hectare","hectares"],{auto:!1}),I("ac",4046.8564224,["acre","acres"],{auto:!1}),I("km²",1e6,["km2","sqkm"])]),volume:Object.freeze([I("µL",1e-6,["ul","microlitre","microliter"]),I("mL",.001,["millilitre","milliliter"]),I("fl oz (US)",.0295735295625,["fl oz","usfloz"],{auto:!1}),I("fl oz (imp)",.0284130625,["fl oz","impfloz"],{auto:!1}),I("L",1,["litre","litres","liter","liters"]),I("gal (US)",3.785411784,["gal","usgal","usgallon"],{auto:!1}),I("gal (imp)",4.54609,["gal","impgal","impgallon"],{auto:!1}),I("m³",1e3,["m3","cubicmetre","cubicmeter","kl"],{auto:!1}),I("bbl",158.987294928,["barrel","barrels"],{auto:!1})]),energy:Object.freeze([I("eV",1602176634e-28,["electronvolt","electronvolts"],{auto:!1}),I("J",1,["joule","joules"]),I("cal",4.184,["calorie","calories"],{auto:!1}),I("kJ",1e3,["kilojoule","kilojoules"]),I("BTU",1055.05585262,["btu"],{auto:!1}),I("kcal",4184,["kilocalorie","kilocalories","Cal"],{auto:!1}),I("MJ",1e6,["megajoule","megajoules"]),I("kWh",36e5,["kilowatthour","kilowatthours"],{auto:!1}),I("GJ",1e9,["gigajoule","gigajoules"]),I("MWh",36e8,["megawatthour","megawatthours"],{auto:!1})]),power:Object.freeze([I("mW",.001,["milliwatt","milliwatts"]),I("W",1,["watt","watts"]),I("BTU/h",1055.05585262/3600,["btuh","btu/h"],{auto:!1}),I("kW",1e3,["kilowatt","kilowatts"]),I("hp",745.6998715822702,["horsepower"],{auto:!1}),I("MW",1e6,["megawatt","megawatts"]),I("GW",1e9,["gigawatt","gigawatts"])]),force:Object.freeze([I("mN",.001,["millinewton","millinewtons"]),I("N",1,["newton","newtons"]),I("lbf",4.4482216152605,["poundforce"],{auto:!1}),I("kgf",9.80665,["kilogramforce"],{auto:!1}),I("kN",1e3,["kilonewton","kilonewtons"]),I("MN",1e6,["meganewton","meganewtons"])]),pressure:Object.freeze([I("Pa",1,["pascal","pascals"]),I("mbar",100,["millibar"],{auto:!1}),I("inH₂O",249.0889,["inh2o"],{auto:!1}),I("mmHg",133.322387415,["torr"],{auto:!1}),I("kPa",1e3,["kilopascal","kilopascals"]),I("inHg",3386.388640341,["inhg"],{auto:!1}),I("psi",6894.757293168361,["lbf/in2"],{auto:!1}),I("bar",1e5,[],{auto:!1}),I("atm",101325,["atmosphere","atmospheres"],{auto:!1}),I("MPa",1e6,["megapascal","megapascals"]),I("GPa",1e9,["gigapascal","gigapascals"])]),torque:Object.freeze([I("N·m",1,["nm","n.m","newtonmetre","newtonmeter"]),I("lbf·ft",1.3558179483314003,["lbfft","lbf.ft","ftlb","ft-lb"],{auto:!1}),I("kN·m",1e3,["knm","kn.m"],{auto:!1}),I("MN·m",1e6,["mnm","mn.m"],{auto:!1})]),density:Object.freeze([I("kg/m³",1,["kg/m3"]),I("lb/ft³",16.01846337396014,["lb/ft3","pcf"],{auto:!1}),I("g/cm³",1e3,["g/cm3","g/ml","kg/l"],{auto:!1}),I("t/m³",1e3,["t/m3"],{auto:!1})]),flow:Object.freeze([I("L/min",1/6e4,["lpm","l/min"],{auto:!1}),I("m³/h",1/3600,["m3/h","cmh"],{auto:!1}),I("gpm (US)",.003785411784/60,["gpm","usgpm"],{auto:!1}),I("gpm (imp)",.00454609/60,["gpm","impgpm"],{auto:!1}),I("cfm",.0004719474432,["ft3/min"],{auto:!1}),I("L/s",.001,["lps","l/s"],{auto:!1}),I("m³/s",1,["m3/s","cms"])]),angle:Object.freeze([I("″",Math.PI/648e3,["arcsec","arcsecond","arcseconds"],{auto:!1}),I("′",Math.PI/10800,["arcmin","arcminute","arcminutes"],{auto:!1}),I("mrad",.001,["milliradian","milliradians"],{auto:!1}),I("mil",Math.PI/3200,["nato-mil"],{auto:!1}),I("°",Math.PI/180,["deg","degree","degrees"],{auto:!1}),I("gon",Math.PI/200,["grad","gradian","gradians"],{auto:!1}),I("rad",1,["radian","radians"]),I("turn",2*Math.PI,["rev","revolution","revolutions"],{auto:!1})]),angularVelocity:Object.freeze([I("°/s",Math.PI/180,["degps","deg/s","degrees/s"],{auto:!1}),I("rad/s",1,["radps","radians/s"]),I("rpm",2*Math.PI/60,["rev/min","r/min","revolutions/min"],{auto:!1}),I("rps",2*Math.PI,["rev/s","r/s","revolutions/s"],{auto:!1})]),fraction:Object.freeze([I("ppt",1e-12,["partspertrillion"],{auto:!1}),I("ppb",1e-9,["partsperbillion"]),I("ppm",1e-6,["partspermillion"]),I("bp",1e-4,["bps-finance","basispoint","basispoints","bips"],{auto:!1}),I("‰",.001,["permille","permil"],{auto:!1}),I("%",.01,["pct","percent"]),I("×",1,["x","ratio","times"])]),molarity:Object.freeze([I("pM",1e-12,["picomolar","picomolarity"]),I("nM",1e-9,["nanomolar","nanomolarity"]),I("µM",1e-6,["um-molar","micromolar","micromolarity"]),I("mM",.001,["millimolar","millimolarity"]),I("M",1,["molar","mol/l","mol/L","molarity"]),I("mol/m³",.001,["mol/m3"],{auto:!1})]),massFlow:Object.freeze([I("mg/s",1e-6,["milligrams/s"]),I("g/s",.001,["grams/s"]),I("kg/h",1/3600,["kilograms/h","kgph"],{auto:!1}),I("kg/s",1,["kilograms/s","kgps"]),I("t/h",1e3/3600,["tonnes/h","tph"],{auto:!1}),I("lb/h",.45359237/3600,["pounds/h","pph"],{auto:!1}),I("t/s",1e3,["tonnes/s"],{auto:!1})]),viscosity:Object.freeze([I("µPa·s",1e-6,["upas","micropascalsecond"]),I("cP",.001,["centipoise"],{auto:!1}),I("mPa·s",.001,["mpas","millipascalsecond"]),I("P",.1,["poise"],{auto:!1}),I("Pa·s",1,["pas","pascalsecond"])]),kinematicViscosity:Object.freeze([I("cSt",1e-6,["centistokes","centistoke"]),I("mm²/s",1e-6,["mm2/s"],{auto:!1}),I("St",1e-4,["stokes","stoke"],{auto:!1}),I("m²/s",1,["m2/s"])]),thermalConductivity:Object.freeze([I("mW/(m·K)",.001,["mw/mk"]),I("W/(m·K)",1,["w/mk","wmk"]),I("kW/(m·K)",1e3,["kw/mk"],{auto:!1}),I("BTU/(hr·ft·°F)",1.730734666,["btu/hrftf"],{auto:!1})]),specificHeat:Object.freeze([I("J/(kg·K)",1,["j/kgk","jkgk"]),I("kJ/(kg·K)",1e3,["kj/kgk"]),I("cal/(g·°C)",4184,["cal/gc"],{auto:!1})]),doseRate:Object.freeze([I("nSv/h",1e-9,["nsvh"]),I("µSv/h",1e-6,["usv/h","usvh"]),I("mSv/h",.001,["msvh"]),I("Sv/h",1,["svh"]),I("mSv/a",.001/8766,["msv/year","msvpa"],{auto:!1})])}),L=Symbol("ambiguous"),X=new Map,$=new Map;function A(x,U){const _=String(x||"").trim();if(!_)throw new Error("[lattice] a unit system needs a name");if(z[_]||$.has(_))throw new Error(`[lattice] unit system "${_}" already exists`);const W=[...U||[]];if(!W.length)throw new Error(`[lattice] unit system "${_}" has no units`);if(!W.some(N=>N.factor===1))throw new Error(`[lattice] unit system "${_}" has no base unit (none with factor 1)`);const q=new Set;for(const N of W){if(q.has(N.symbol))throw new Error(`[lattice] unit system "${_}" declares "${N.symbol}" twice`);q.add(N.symbol)}return $.set(_,Object.freeze(W)),X.delete(_),_}function k(){return[...Object.keys(z),...$.keys()]}function y(x){const U=f(x);return U?U.units:[]}function f(x){const U=String(x||""),_=X.get(U);if(_!==void 0)return _;const W=z[U]||$.get(U);if(!W)return X.set(U,null),null;const q=Object.freeze([...W].sort((ne,se)=>ne.factor-se.factor)),N=new Map,Q=new Map,J=(ne,se)=>{const le=N.get(ne);le===void 0?N.set(ne,se):le!==se&&N.set(ne,L)};for(const ne of q){J(ne.symbol.toLowerCase(),ne);for(const se of ne.aliases)J(se.toLowerCase(),ne);if(ne.prefix){const se=Q.get(ne.prefix)||[];se.push(ne),Q.set(ne.prefix,se)}}const ee={units:q,byToken:N,byPrefix:Q,decimal:q.filter(ne=>!ne.binary&&ne.auto),binary:q.some(ne=>ne.binary)?q.filter(ne=>(ne.binary||ne.factor===1)&&ne.auto):null};return X.set(U,ee),ee}function g(x,U){return U&&x.binary||x.decimal}function a(x,U){const _=f(x);if(!_||T(U))return null;const W=_.units.find(N=>N.symbol===String(U));if(W)return W;const q=_.byToken.get(String(U).trim().toLowerCase());return q&&q!==L?q:null}const r=new WeakMap;function i(x){const U=x||{};if(typeof U=="object"&&U!==null){const N=r.get(U);if(N!==void 0)return N}const _=U.system||"data",W=f(_);let q=null;if(!W)D(`unit:system:${_}`,`unknown unit system "${_}"; known systems are ${k().join(", ")}`);else{let N=U.unit?a(_,U.unit):null;N||(U.unit&&D(`unit:unit:${_}:${U.unit}`,`unknown unit "${U.unit}" in system "${_}"; falling back to ${W.units[0].symbol}`),N=W.units.find(Q=>Q.factor===1)||W.units[0]),q={index:W,base:N,binary:U.binary===!0}}return typeof U=="object"&&U!==null&&r.set(U,q),q}const c=new WeakMap;function u(x,U){if(!x||!U||!Array.isArray(x.compound)||x.compound.length===0)return null;const _=c.get(x);if(_!==void 0)return _;const W=new Set,q=[];for(const Q of x.compound){const J=a(x.system||"data",Q);if(!J){D(`unit:compound:${x.system}:${Q}`,`unknown compound unit "${Q}" in system "${x.system||"data"}"; ignoring it`);continue}W.has(J.symbol)||(W.add(J.symbol),q.push(J))}q.sort((Q,J)=>J.factor-Q.factor);const N=q.length>=2?q:null;return c.set(x,N),N}function n(x,U,_){return U===_||U.factor===_.factor?x:x*U.factor/_.factor}const m=new Map;function t(x){const U=x||"",_=m.get(U);if(_)return _;const W={group:",",decimal:"."};try{for(const q of new Intl.NumberFormat(x||void 0).formatToParts(12345.6))q.type==="group"?W.group=q.value:q.type==="decimal"&&(W.decimal=q.value)}catch{}return m.set(U,W),W}const s=/[\s ]/g,h=/^[+-]?[\d '’ .,]*(?:[eE][+-]?\d+)?/,d=/^[^\d+\-(.,\s]+\s*/,o=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function b(x,U){const{group:_,decimal:W}=t(U);let q=String(x).replace(s,"");if(q==="")return null;const N=W?q.indexOf(W):-1;if(_&&_!==W){if(N>=0&&q.indexOf(_,N+W.length)>=0)return null;q=q.split(_).join("")}if(W&&W!=="."&&(q=q.split(W).join(".")),!o.test(q))return null;const Q=Number(q);return Number.isFinite(Q)?Q:null}function l(x,U,_){const W=String(x).trim().replace(/\.$/,"");if(W==="")return null;const q=U.units.find(se=>se.symbol===W);if(q)return q;const N=W.toLowerCase(),Q=U.byToken.get(N);if(Q===L)return null;if(Q)return Q;const J=U.byPrefix.get(N);if(!J||!J.length)return null;const ee=g(U,_),ne=J.filter(se=>ee.includes(se));return ne.length===1?ne[0]:null}function p(x,U,_,W){let q=x,N=0,Q=!1,J=!1;for(;q!=="";){const ee=h.exec(q)[0];if(ee==="")return null;const ne=b(ee,W&&W.locale);if(ne===null)return null;q=q.slice(ee.length).trim();const se=q.search(/[+-]?[\d]/),le=(se>=0?q.slice(0,se):q).trim();if(q=se>=0?q.slice(se).trim():"",le===""){if(Q)return null;J=!0,N+=n(ne,_[0],U.base)}else{const ye=l(le,U.index,U.binary);if(!ye)return null;N+=n(ne,ye,U.base)}if(Q=!0,J&&q!=="")return null}return Q?N:null}function w(x,U){if(T(x))return null;if(typeof x=="number")return Number.isFinite(x)?x:null;const _=i(U);if(!_)return null;let W=String(x).trim();if(W==="")return null;let q=!1;W.startsWith("(")&&W.endsWith(")")&&(q=!0,W=W.slice(1,-1).trim());const N=u(U,_);if(N){W.startsWith("-")&&(q=!0,W=W.slice(1).trim());const fe=p(W,_,N,U);return fe===null?null:q?-fe:fe}let Q=null;const J=d.exec(W);if(J&&J[0]){const fe=l(J[0].trim(),_.index,_.binary);fe&&(Q=fe,W=W.slice(J[0].length).trim())}const ee=h.exec(W)[0],ne=b(ee,U&&U.locale);if(ne===null)return null;const se=W.slice(ee.length).trim();if(Q&&se!=="")return null;const le=Q||(se===""?_.base:l(se,_.index,_.binary));if(!le)return null;const ye=n(ne,le,_.base);return q?-ye:ye}const v=new Map;function R(x,U,_,W){const q=`${x||""}|${U}|${_}|${W?1:0}`;let N=v.get(q);return N||(N=new Intl.NumberFormat(x||void 0,{minimumFractionDigits:U,maximumFractionDigits:_,useGrouping:W}),v.set(q,N)),N}function Y(x,U){if(!Number.isFinite(x)||x===0)return Math.max(0,U-1);const _=Math.floor(Math.log10(Math.abs(x)));return Math.min(20,Math.max(0,U-1-_))}function K(x,U){if(!Number.isFinite(x)||x===0)return x;const _=Math.ceil(Math.log10(Math.abs(x))),W=10**(U-_);return Math.round(x*W)/W}function V(x,U,_){if(!_||_===U.base.symbol)return U.base;if(_!=="auto")return E(U,_);if(x===0||!Number.isFinite(x))return U.base;const W=Math.abs(x)*U.base.factor,q=g(U.index,U.binary);let N=q[0];for(const ee of q)W>=ee.factor&&(N=ee);if(W>=N.factor)return N;let Q=N;for(const ee of U.index.units)ee.binary!==U.binary&&ee.factor!==1||ee.factor<=W&&ee.factor>(Q===N?0:Q.factor)&&(Q=ee);if(Q!==N)return Q;let J=N;for(const ee of U.index.units)ee.binary!==U.binary&&ee.factor!==1||ee.factor<J.factor&&(J=ee);return J.factor<U.base.factor?J:U.base}function E(x,U){const _=x.index.units.find(q=>q.symbol===U);if(_)return _;const W=x.index.byToken.get(String(U).toLowerCase());return W&&W!==L?W:(D(`unit:display:${U}`,`unknown display unit "${U}"; rendering in ${x.base.symbol}`),x.base)}function O(x,U,_,W){const q=x<0;let N=Math.abs(x)*U.base.factor;const Q=typeof W.decimals=="number"?W.decimals:W.minDecimals??0,J=typeof W.decimals=="number"?W.decimals:W.maxDecimals??Math.max(Q,2),ee=W.space??" ",ne=[];for(let le=0;le<_.length;le++){const ye=_[le],fe=le===_.length-1;let we=fe?N/ye.factor:Math.floor(N/ye.factor);if(N-=we*ye.factor,fe){const Ce=10**J;we=Math.round(we*Ce)/Ce+0}const ke=fe?R(W.locale,Q,J,W.group!==!1):R(W.locale,0,0,W.group!==!1);ne.push(`${ke.format(we)}${ee}${ye.symbol}`)}const se=ne.join(" ");return q?`-${se}`:se}function C(x,U){const _=U||{},W=_.nullDisplay??"";if(T(x)||x==="")return W;const q=typeof x=="number"?x:Number(x);if(!Number.isFinite(q))return W;const N=i(_);if(!N)return String(q);const Q=u(_,N);if(Q)return O(q,N,Q,_);const J=typeof _.significantFigures=="number"&&_.significantFigures>0?_.significantFigures:0,ee=J?K(q,J):q,ne=V(ee,N,_.display),se=n(ee,N.base,ne);let le=typeof _.decimals=="number"?_.decimals:_.minDecimals??0,ye=typeof _.decimals=="number"?_.decimals:_.maxDecimals??Math.max(le,2);J&&(le=Y(se,J),ye=le);const fe=R(_.locale,le,ye,_.group!==!1).format(se),we=_.space??" ";return _.placement==="prefix"?`${ne.symbol}${_.space??""}${fe}`:`${fe}${we}${ne.symbol}`}function S(x,U){const _=T(x)||Number.isNaN(x)?null:Number(x),W=T(U)||Number.isNaN(U)?null:Number(U);return _===null||Number.isNaN(_)?W===null||Number.isNaN(W)?0:1:W===null||Number.isNaN(W)||_<W?-1:_>W?1:0}function F(x){const U=typeof x.decimals=="number"&&x.decimals>0?`.${"0".repeat(x.decimals)}`:"";return`${typeof x.decimals=="number"?`#,##0${U}`:"#,##0.##"}" ${x.symbol}"`}function P(x){const U={system:"data",...x||{}},_=i(U),W=_?_.base.symbol:String(U.unit||""),q=Object.freeze({...U,unit:W}),N=Object.freeze({...q,display:W,decimals:void 0,minDecimals:0,maxDecimals:20,group:!1}),Q=new Map([[q.locale||"",q]]),J=ee=>{const ne=ee||"";let se=Q.get(ne);return se||(se=Object.freeze({...q,locale:ee||void 0}),Q.set(ne,se)),se};return{base:"number",extends:"number",storage:"float64",unitConfig:q,format:ee=>C(ee.value,ee.locale?J(ee.locale):q),parse:ee=>w(ee.text,ee.locale?J(ee.locale):q),compare:S,defaults:{filter:"number",editor:"unit",align:"end",total:U.total||"sum"},...U.totals?{totals:U.totals}:{},excel:U.excel||F({decimals:U.decimals,symbol:W}),toStorage:ee=>typeof ee=="number"?Number.isFinite(ee)?ee:null:typeof ee=="string"?w(ee,q):T(ee)?null:w(String(ee),q),toClipboard:ee=>C(ee,N),fromClipboard:ee=>w(ee,q)}}const M=P}),Ue("packages/core/src/columns/types/engineering.js",function(e,B){"use strict";Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return I}});const T=B("packages/core/src/internal/predicates.js").isNil,D=B("packages/core/src/columns/types/unit.js").createUnitType;function I(L){const X=2*Math.PI/L;return $=>{let A=0,k=0,y=0;for(const g of $||[]){if(T(g))continue;const a=Number(g);Number.isFinite(a)&&(A+=Math.cos(a*X),k+=Math.sin(a*X),y+=1)}return!y||Math.hypot(A,k)/y<1e-12?null:(Math.atan2(k,A)/X%L+L)%L}}function Z(L){return{supported:["sum","avg","min","max","count","countValues"],implement:{avg:I(L)}}}const z=Object.freeze({metres:D({system:"length",unit:"m",display:"auto",maxDecimals:3}),millimetres:D({system:"length",unit:"mm",maxDecimals:2}),kilometres:D({system:"length",unit:"km",maxDecimals:3}),grams:D({system:"mass",unit:"g",display:"auto",maxDecimals:3}),kilograms:D({system:"mass",unit:"kg",maxDecimals:3}),tonnes:D({system:"mass",unit:"t",maxDecimals:3}),seconds:D({system:"duration",unit:"s",display:"auto",maxDecimals:3}),milliseconds:D({system:"duration",unit:"ms",maxDecimals:3}),hours:D({system:"duration",unit:"h",maxDecimals:2}),speed:D({system:"speed",unit:"m/s",display:"auto",maxDecimals:2}),kph:D({system:"speed",unit:"km/h",maxDecimals:1}),mph:D({system:"speed",unit:"mph",maxDecimals:1}),knots:D({system:"speed",unit:"kn",maxDecimals:1}),acceleration:D({system:"acceleration",unit:"m/s²",maxDecimals:3}),area:D({system:"area",unit:"m²",display:"auto",maxDecimals:2}),hectares:D({system:"area",unit:"ha",maxDecimals:4}),volume:D({system:"volume",unit:"L",display:"auto",maxDecimals:3}),cubicMetres:D({system:"volume",unit:"m³",maxDecimals:3}),energy:D({system:"energy",unit:"J",display:"auto",maxDecimals:3}),kilowattHours:D({system:"energy",unit:"kWh",maxDecimals:2}),power:D({system:"power",unit:"W",display:"auto",maxDecimals:2}),kilowatts:D({system:"power",unit:"kW",maxDecimals:2}),force:D({system:"force",unit:"N",display:"auto",maxDecimals:2}),pressure:D({system:"pressure",unit:"Pa",display:"auto",maxDecimals:2}),bar:D({system:"pressure",unit:"bar",maxDecimals:3}),psi:D({system:"pressure",unit:"psi",maxDecimals:1}),torque:D({system:"torque",unit:"N·m",maxDecimals:2}),density:D({system:"density",unit:"kg/m³",maxDecimals:2}),flow:D({system:"flow",unit:"m³/s",maxDecimals:4}),litresPerMinute:D({system:"flow",unit:"L/min",maxDecimals:1}),radians:D({system:"angle",unit:"rad",maxDecimals:4,totals:Z(2*Math.PI)}),degrees:D({system:"angle",unit:"°",maxDecimals:2,totals:Z(360)}),rpm:D({system:"angularVelocity",unit:"rpm",maxDecimals:0}),angularVelocity:D({system:"angularVelocity",unit:"rad/s",maxDecimals:3}),ppm:D({system:"fraction",unit:"ppm",maxDecimals:2}),ppb:D({system:"fraction",unit:"ppb",maxDecimals:2}),basisPoints:D({system:"fraction",unit:"bp",maxDecimals:1}),molarity:D({system:"molarity",unit:"M",display:"auto",maxDecimals:3}),massFlow:D({system:"massFlow",unit:"kg/s",maxDecimals:3}),tonnesPerHour:D({system:"massFlow",unit:"t/h",maxDecimals:2}),viscosity:D({system:"viscosity",unit:"Pa·s",display:"auto",maxDecimals:3}),kinematicViscosity:D({system:"kinematicViscosity",unit:"cSt",maxDecimals:2}),thermalConductivity:D({system:"thermalConductivity",unit:"W/(m·K)",maxDecimals:3}),specificHeat:D({system:"specificHeat",unit:"J/(kg·K)",maxDecimals:1}),doseRate:D({system:"doseRate",unit:"µSv/h",display:"auto",maxDecimals:2})})}),Ue("packages/core/src/columns/types/si.js",function(e,B){"use strict";Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return A}});const re=B("packages/core/src/columns/types/unit.js"),T=re.defineUnit,G=re.registerUnitSystem,D=re.createUnitType,I=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 z(k){const y=String(k.base),f=new Set([...k.prefixes||Z,""]),g=[];for(const a of I){if(!f.has(a.symbol))continue;const r=`${a.symbol}${y}`,i=[];if(k.name){i.push(`${a.name}${k.name}`,`${a.name}${k.name}s`);const c=a.name.slice(-1);if(c&&k.name.startsWith(c)){const u=`${a.name.slice(0,-1)}${k.name}`;i.push(u,`${u}s`)}}a.symbol==="µ"&&i.push(`u${y}`),a.factor===1&&k.aliases&&i.push(...k.aliases),g.push(T(r,a.factor,i))}for(const a of k.extra||[])g.push(a);return g}function L(k,y){const f=z(y);return G(k,f)}function X(k,y,f){return L(k,y),D({system:k,unit:y.base,display:"auto",maxDecimals:3,...f||{}})}const $=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:[T("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),T("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:[T("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:[T("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:X("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),A=X}),Ue("packages/core/src/columns/types/temperature.js",function(e,B){"use strict";Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return f}});const T=B("packages/core/src/internal/predicates.js").isNil,G=Object.freeze({C:Object.freeze({symbol:"°C",aliases:["c","°c","celsius","centigrade"],toKelvin:g=>g+273.15,fromKelvin:g=>g-273.15}),F:Object.freeze({symbol:"°F",aliases:["f","°f","fahrenheit"],toKelvin:g=>(g+459.67)*(5/9),fromKelvin:g=>g*(9/5)-459.67}),K:Object.freeze({symbol:"K",aliases:["k","kelvin"],toKelvin:g=>g,fromKelvin:g=>g}),R:Object.freeze({symbol:"°R",aliases:["r","°r","rankine"],toKelvin:g=>g*(5/9),fromKelvin:g=>g*(9/5)})});function D(g){if(T(g))return null;const a=String(g).trim();if(a==="")return null;for(const[i,c]of Object.entries(G))if(a===i||a===c.symbol)return{key:i,scale:c};const r=a.toLowerCase();for(const[i,c]of Object.entries(G))if(c.aliases.includes(r))return{key:i,scale:c};return null}function I(g,a,r){const i=D(a),c=D(r);return!i||!c||!Number.isFinite(Number(g))?null:i.key===c.key?Number(g):c.scale.fromKelvin(i.scale.toKelvin(Number(g)))}const Z=new Map;function z(g,a,r){const i=`${g||""}|${a}|${r}`;let c=Z.get(i);return c||(c=new Intl.NumberFormat(g||void 0,{minimumFractionDigits:a,maximumFractionDigits:r}),Z.set(i,c)),c}function L(g,a){const r=a||{},i=r.nullDisplay??"";if(T(g)||g==="")return i;const c=Number(g);if(!Number.isFinite(c))return i;const u=D(r.scale||"C");if(!u)return String(c);const n=D(r.display||r.scale||"C")||u,m=n.key===u.key?c:n.scale.fromKelvin(u.scale.toKelvin(c)),t=typeof r.decimals=="number"?r.decimals:null,s=t??r.minDecimals??0,h=t??r.maxDecimals??1;return`${z(r.locale,s,h).format(m)}${r.space??" "}${n.scale.symbol}`}const X=/^[+-]?[\d\s., ]*\d/;function $(g,a){const r=String(g).trim();if(r==="")return null;const i=new Intl.NumberFormat(a||void 0).formatToParts(1.1).find(m=>m.type==="decimal")?.value||".",c=i===","?".":",",u=r.split(c).join("").split(/[\s ]/).join("").replace(i,"."),n=Number(u);return Number.isFinite(n)?n:null}function A(g,a){if(T(g))return null;const r=a||{},i=D(r.scale||"C");if(!i)return null;if(typeof g=="number")return Number.isFinite(g)?g:null;let c=String(g).trim();if(c==="")return null;let u=!1;c.startsWith("(")&&c.endsWith(")")&&(u=!0,c=c.slice(1,-1).trim());const n=X.exec(c);if(!n)return null;const m=$(n[0],r.locale);if(m===null)return null;const t=c.slice(n[0].length).trim();if(t==="")return u?-m:m;const s=D(t);if(!s)return null;const h=s.key===i.key?m:i.scale.fromKelvin(s.scale.toKelvin(m));return u?-h:h}function k(g){const a=Object.freeze({scale:"C",...g||{}}),i=(D(a.scale)||D("C")).scale.symbol,c=Object.freeze({...a,display:a.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),u=new Map([[a.locale||"",a]]),n=m=>{const t=m||"";let s=u.get(t);return s||(s=Object.freeze({...a,locale:m||void 0}),u.set(t,s)),s};return{base:"number",extends:"number",storage:"float64",temperatureConfig:a,format:m=>L(m.value,m.locale?n(m.locale):a),parse:m=>A(m.text,m.locale?n(m.locale):a),defaults:{filter:"number",editor:"temperature",align:"end",total:"avg"},totals:{supported:["avg","min","max","count","countValues"]},excel:a.excel||`#,##0${typeof a.decimals=="number"&&a.decimals>0?`.${"0".repeat(a.decimals)}`:".#"}" ${i}"`,toStorage:m=>typeof m=="number"?Number.isFinite(m)?m:null:typeof m=="string"?A(m,a):T(m)?null:A(String(m),a),toClipboard:m=>L(m,c),fromClipboard:m=>A(m,a)}}const y=Object.freeze({celsius:k({scale:"C"}),fahrenheit:k({scale:"F"}),kelvin:k({scale:"K"})}),f=k}),Ue("packages/core/src/columns/types/radix.js",function(e,B){"use strict";Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"digitsForWidth",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"radixRange",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"radixName",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"normaliseRadixOptions",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"compileRadixFormat",{enumerable:!0,get:function(){return p}}),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 R}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return O}});const T=B("packages/core/src/internal/predicates.js").isNil,D=B("packages/core/src/internal/warn.js").warnOnce,I=Object.freeze({2:2,8:8,16:16,bin:2,binary:2,base2:2,oct:8,octal:8,base8:8,hex:16,hexadecimal:16,base16:16}),Z=Object.freeze({2:1,8:3,16:4}),z=Object.freeze({2:"0b",8:"0o",16:"0x"}),L=Object.freeze({2:4,8:3,16:2}),X=Object.freeze({2:/^[01]+$/,8:/^[0-7]+$/,16:/^[0-9a-f]+$/i}),$=Object.freeze({2:"binary",8:"octal",16:"hexadecimal"}),A=Object.freeze([[/^0x/i,16],[/^0b/i,2],[/^0o/i,8],[/^#/,16]]),k=/[\s\u00a0\u202f_,']/g,y=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,f=Object.freeze([8,16,32,53]),g=new WeakSet,a=new WeakMap,r=new Map,i=new WeakMap,c=new WeakMap,u=Object.freeze({hex:Object.freeze({radix:16}),hex8:Object.freeze({radix:16,bitWidth:8,pad:!0,signed:!1}),hex16:Object.freeze({radix:16,bitWidth:16,pad:!0,signed:!1}),hex32:Object.freeze({radix:16,bitWidth:32,pad:!0,signed:!1}),binary:Object.freeze({radix:2}),binary8:Object.freeze({radix:2,bitWidth:8,pad:!0,signed:!1,group:4}),octal:Object.freeze({radix:8})});function n(C){if(C==null)return 16;const S=typeof C=="string"?C.toLowerCase():C,F=I[S];return F||(D(`radix:base:${String(C)}`,`unsupported radix ${String(C)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function m(C,S){return Math.ceil(C/Z[S])}function t(C,S){if(!C)return S?{min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}:{min:0,max:Number.MAX_SAFE_INTEGER};if(!S)return{min:0,max:2**C-1};const F=2**(C-1);return{min:-F,max:F-1}}function s(C){return $[C]||"hexadecimal"}function h(C){if(typeof C=="string"){const S=u[C];return S||D(`radix:preset:${C}`,`unknown radix preset "${C}"; known presets are ${Object.keys(u).join(", ")}`),{...S||{}}}if(C&&typeof C.preset=="string"){const S=u[C.preset];return S||D(`radix:preset:${C.preset}`,`unknown radix preset "${C.preset}"; known presets are ${Object.keys(u).join(", ")}`),{...S||{},...C}}return C||{}}function d(C){const S=h(C),F=n(S.radix),P=Z[F];let M=null;if(S.bitWidth!==void 0&&S.bitWidth!==null&&S.bitWidth!==!1){const ee=Number(S.bitWidth);f.includes(ee)?M=ee:D(`radix:width:${String(S.bitWidth)}`,`unsupported bitWidth ${String(S.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let x=S.signed!==!1;!x&&M===null&&(D("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),M=32);const U=S.prefix===void 0||S.prefix===!0?z[F]:S.prefix===!1?"":String(S.prefix);let _=0;S.pad===!0?_=M?m(M,F):0:typeof S.pad=="number"&&S.pad>0&&(_=Math.floor(S.pad));let W=0;S.group===!0?W=L[F]:typeof S.group=="number"&&S.group>0&&(W=Math.floor(S.group));const q=t(M,x),N=typeof S.min=="number"?Math.max(q.min,S.min):q.min,Q=typeof S.max=="number"?Math.min(q.max,S.max):q.max,J=Object.freeze({radix:F,bits:P,prefix:U,uppercase:S.uppercase!==!1,pad:_,group:W,groupSeparator:typeof S.groupSeparator=="string"?S.groupSeparator:" ",bitWidth:M,signed:x,min:N,max:Q<N?N:Q,nullDisplay:typeof S.nullDisplay=="string"?S.nullDisplay:"",name:s(F)});return g.add(J),J}function o(C){if(C&&g.has(C))return C;if(typeof C=="string"){let S=r.get(C);return S||(S=d(C),r.set(C,S)),S}if(C&&typeof C=="object"){let S=a.get(C);return S||(S=d(C),a.set(C,S)),S}return o("hex")}function b(C){return C<0?-Math.round(-C):Math.round(C)}function l(C,S,F){if(S<=0||C.length<=S)return C;const P=C.length%S||S,M=[C.slice(0,P)];for(let x=P;x<C.length;x+=S)M.push(C.slice(x,x+S));return M.join(F)}function p(C){const S=o(C),{radix:F,prefix:P,uppercase:M,pad:x,group:U,groupSeparator:_,signed:W,bitWidth:q,nullDisplay:N}=S,Q=q?2**q:0,J=ee=>{if(T(ee)||ee==="")return N;const ne=typeof ee=="number"?ee:Number(ee);if(!Number.isFinite(ne))return N;const se=b(ne);let le="",ye=se;se<0&&(W?(le="-",ye=-se):ye=(se%Q+Q)%Q);let fe=ye.toString(F);return fe=M?fe.toUpperCase():fe.toLowerCase(),x>0&&fe.length<x&&(fe=fe.padStart(x,"0")),U>0&&(fe=l(fe,U,_)),le+P+fe};return J.options=S,J}function w(C,S){const F=o(S);let P=i.get(F);return P||(P=p(F),i.set(F,P)),P(C)}function v(C){const S=o(C),{radix:F,groupSeparator:P,signed:M,min:x,max:U}=S,_=X[F],W=q=>{if(T(q))return{ok:!0,value:null,reason:"blank"};let N=String(q);if(P&&P!==""&&(N=N.split(P).join("")),N=N.replace(k,""),N==="")return{ok:!0,value:null,reason:"blank"};let Q=!1;if((N[0]==="-"||N[0]==="+")&&(Q=N[0]==="-",N=N.slice(1)),N==="")return{ok:!1,value:null,reason:"digits"};let J=null;for(const[ne,se]of A){const le=ne.exec(N);if(!le)continue;const ye=N.slice(le[0].length);if(ye==="")break;if(!X[se].test(ye))return{ok:!1,value:null,reason:"digits"};J=parseInt(ye,se);break}if(J===null)if(_.test(N))J=parseInt(N,F);else if(y.test(N))J=Number(N);else return{ok:!1,value:null,reason:"digits"};if(!Number.isFinite(J))return{ok:!1,value:null,reason:"digits"};const ee=b(Q?-J:J);return!M&&ee<0?{ok:!1,value:ee,reason:"negative"}:ee<x||ee>U?{ok:!1,value:ee,reason:"range"}:{ok:!0,value:ee,reason:"ok"}};return W.options=S,W}function R(C,S){const F=o(S);let P=c.get(F);return P||(P=v(F),c.set(F,P)),P(C)}function Y(C,S){const F=R(C,S);return F.ok?F.value:null}function K(C,S){const F=T(C)||Number.isNaN(C)?null:Number(C),P=T(S)||Number.isNaN(S)?null:Number(S);return F===null?P===null?0:1:P===null||F<P?-1:F>P?1:0}function V(C){const S=C.min>=-2147483648&&C.max<=2147483647;return C.bitWidth&&S?"int32":"float64"}function E(C){const S=d(C),F=p(S),P=v(S);return{base:"number",extends:"number",storage:V(S),matches:null,format:M=>F(M.value),parse:M=>{const x=P(M.text);return x.ok?x.value:null},compare:K,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:M=>F(M),fromClipboard:M=>{const x=P(M);return x.ok?x.value:null},radix:S,formatValue:F,parseText:P}}const O=E}),Ue("packages/core/src/columns/types/aggregable.js",function(e,B){"use strict";Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return L}}),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 D}}),Object.defineProperty(e,"logarithmicMean",{enumerable:!0,get:function(){return I}});const T=B("packages/core/src/internal/predicates.js").isNil;function G($){const A=[];for(const k of $||[]){if(T(k))continue;const y=Number(k);Number.isFinite(y)&&A.push(y)}return A}function D($){return A=>{const k=G(A);if(!k.length)return null;let y=0;for(const f of k)y+=10**(f/$);return $*Math.log10(y)}}function I($){return A=>{const k=G(A);if(!k.length)return null;let y=0;for(const f of k)y+=10**(f/$);return $*Math.log10(y/k.length)}}function Z($,A){const k=A&&A.column,f=(k&&k.typeOptions||{}).weight,g=A&&A.valueAt;if(!f||typeof g!="function")return null;let a=0,r=0;for(let i=0;i<$.length;i++){if(T($[i]))continue;const c=Number($[i]);if(!Number.isFinite(c))continue;const u=g(f,i);if(T(u))continue;const n=Number(u);!Number.isFinite(n)||n<=0||(a+=c*n,r+=n)}return r===0?null:a/r}function z($={}){const A=$.factor===20?20:10,k=typeof $.suffix=="string"?$.suffix:"",y=Number.isInteger($.decimals)?$.decimals:1;return{base:"number",storage:"float64",name:$.name||"logarithmic",format:f=>{const g=f&&f.value;return T(g)||!Number.isFinite(Number(g))?"":`${Number(g).toFixed(y)}${k}`},parse:f=>{const g=String((f&&f.text)??"").replace(k,"").trim();if(!g)return null;const a=Number(g);return Number.isFinite(a)?a:null},defaults:{align:"end",filter:"number"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:{sum:D(A),avg:I(A)}}}}function L($={}){const A=Number.isInteger($.decimals)?$.decimals:1,k=$.percent===!0;return{base:"number",storage:"float64",name:$.name||"ratio",format:y=>{const f=y&&y.value;return T(f)||!Number.isFinite(Number(f))?"":k?`${Number(f).toFixed(A)}%`:Number(f).toFixed(A)},parse:y=>{const f=String((y&&y.text)??"").replace("%","").trim();if(!f)return null;const g=Number(f);return Number.isFinite(g)?g:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:Z}}}}const X=Object.freeze({decibel:z({name:"decibel",factor:10,suffix:" dB"}),decibelAmplitude:z({name:"decibelAmplitude",factor:20,suffix:" dB"}),ratio:L({name:"ratio"}),percentRate:L({name:"percentRate",percent:!0})})}),Ue("packages/core/src/columns/types/currency.js",function(e,B){"use strict";Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"moneyToText",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const T=B("packages/core/src/internal/predicates.js").isNil,G="⚠ no rate";function D(m){if(T(m))return null;const t=String(m).trim().toUpperCase();return t===""?null:t}function I(m){if(T(m))return null;if(typeof m=="object"&&!Array.isArray(m)){const t=Number(m.amount),s=D(m.code);return!s||!Number.isFinite(t)?null:{amount:t,code:s}}if(Array.isArray(m)&&m.length===2){const t=Number(m[0]),s=D(m[1]);return!s||!Number.isFinite(t)?null:{amount:t,code:s}}return null}const Z=Object.freeze({$:"USD","€":"EUR","£":"GBP","¥":"JPY","₹":"INR","₩":"KRW","₽":"RUB","₺":"TRY","₴":"UAH","₪":"ILS"}),z=Object.freeze({USD:"$",EUR:"€",GBP:"£",JPY:"¥",INR:"₹",KRW:"₩",RUB:"₽",TRY:"₺",UAH:"₴",ILS:"₪"}),L=/[+-]?[\d\s., ]*\d/;function X(m,t){const s=String(m).trim();if(s==="")return null;const h=new Intl.NumberFormat(t||void 0).formatToParts(1.1).find(l=>l.type==="decimal")?.value||".",d=h===","?".":",",o=s.split(d).join("").split(/[\s ]/).join("").replace(h,"."),b=Number(o);return Number.isFinite(b)?b:null}function $(m,t){const s=t||{},h=D(s.code);if(T(m))return null;const d=I(m);if(d)return d;if(typeof m=="number")return Number.isFinite(m)&&h?{amount:m,code:h}:null;let o=String(m).trim();if(o==="")return null;let b=!1;o.startsWith("(")&&o.endsWith(")")&&(b=!0,o=o.slice(1,-1).trim());let l=null;for(const[K,V]of Object.entries(Z)){if(o.startsWith(K)){l=V,o=o.slice(K.length).trim();break}if(o.endsWith(K)){l=V,o=o.slice(0,-K.length).trim();break}}const p=L.exec(o);if(!p)return null;const w=X(p[0],s.locale);if(w===null)return null;const v=(o.slice(0,p.index)+" "+o.slice(p.index+p[0].length)).trim();!l&&v!==""&&(l=D(v));const R=l||h;return R?{amount:b?-w:w,code:R}:null}function A(m,t){if(typeof m=="function")return(s,h)=>{if(s===h)return 1;const d=m(s,h);return typeof d=="number"&&Number.isFinite(d)&&d>0?d:null};if(m&&typeof m=="object"){const s=m;return(h,d)=>{if(h===d)return 1;const o=Number(s[h]),b=Number(s[d]);return!Number.isFinite(o)||!Number.isFinite(b)||o<=0||b<=0?null:b/o}}return(s,h)=>s===h?1:null}function k(m,t,s){if(!m)return null;if(m.code===t)return m.amount;const h=s(m.code,t);return h===null?null:m.amount*h}const y=new Map;function f(m,t,s){const h=`${m||""}|${t}|${s??""}`;let d=y.get(h);if(!d){const o={style:"currency",currency:t};typeof s=="number"&&(o.minimumFractionDigits=s,o.maximumFractionDigits=s);try{d={fmt:new Intl.NumberFormat(m||void 0,o),currency:!0}}catch{d={fmt:new Intl.NumberFormat(m||void 0,typeof s=="number"?{minimumFractionDigits:s,maximumFractionDigits:s}:{}),currency:!1}}y.set(h,d)}return d}function g(m,t){const s=t||{},h=s.nullDisplay??"",d=I(m);if(!d)return h;const o=D(s.display)||d.code;let b=d.amount,l=d.code;if(o!==d.code){const v=s.rateFn||A(s.rates,s.rateBase),R=k(d,o,v);if(R===null)return`${s.missingRate??G} ${d.code}→${o}`;b=R,l=o}const{fmt:p,currency:w}=f(s.locale,l,s.decimals);return w?p.format(b):`${p.format(b)} ${l}`}function a(m){const t=I(m);return t?`${t.amount} ${t.code}`:""}function r(m){const t=m||{},s=D(t.display),h=t.rateFn||A(t.rates,t.rateBase);return(d,o)=>{const b=I(d),l=I(o);if(!b&&!l)return 0;if(!b)return 1;if(!l)return-1;if(s){const p=k(b,s,h),w=k(l,s,h);if(p!==null&&w!==null)return p===w?0:p<w?-1:1}return b.code===l.code?b.amount===l.amount?0:b.amount<l.amount?-1:1:b.code<l.code?-1:1}}function i(m){const t=m||{},s=(d,o)=>{const b=[];for(const R of d||[]){const Y=I(R);Y&&b.push(Y)}if(!b.length)return null;if(new Set(b.map(R=>R.code)).size===1){const R=b[0].code;return{amount:o(b.map(Y=>Y.amount)),code:R}}const p=D(t.display);if(!p)return`${t.missingRate??G}: mixed currencies, no display currency set`;const w=t.rateFn||A(t.rates,t.rateBase),v=[];for(const R of b){const Y=k(R,p,w);if(Y===null)return`${t.missingRate??G}: ${R.code}→${p}`;v.push(Y)}return{amount:o(v),code:p}},h=d=>d.reduce((o,b)=>o+b,0);return{sum:d=>s(d,h),avg:d=>s(d,o=>h(o)/o.length),min:d=>s(d,o=>Math.min(...o)),max:d=>s(d,o=>Math.max(...o))}}function c(m){const t=Object.freeze({code:"USD",...m||{}}),s=A(t.rates,t.rateBase),h=Object.freeze({...t,rateFn:s}),d=i(h),o=r(h),b=new Map([[t.locale||"",h]]),l=v=>{const R=v||"";let Y=b.get(R);return Y||(Y=Object.freeze({...h,locale:v||void 0}),b.set(R,Y)),Y},p=z[D(t.display||t.code)]||"",w=typeof t.decimals=="number"&&t.decimals>0?`.${"0".repeat(t.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:h,format:v=>g(v.value,v.locale?l(v.locale):h),parse:v=>$(v.text,v.locale?l(v.locale):h),compare:o,defaults:{filter:"number",editor:"currency",align:"end",total:"sum"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:d},excel:t.excel||(p?`"${p}"#,##0${w}`:`#,##0${w}`),toStorage:v=>{const R=I(v);return R||(typeof v=="string"||typeof v=="number"?$(v,h):null)},toClipboard:v=>a(v),fromClipboard:v=>$(v,h)}}const u=Object.freeze({currency:c({code:"USD"}),usd:c({code:"USD"}),eur:c({code:"EUR"}),gbp:c({code:"GBP"}),jpy:c({code:"JPY",decimals:0})}),n=c}),Ue("packages/core/src/columns/types/index.js",function(e,B){"use strict";Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return K}});const re=B("packages/core/src/columns/types/temporal.js"),T=re.TEMPORAL_TYPES,G=B("packages/core/src/columns/types/network.js"),D=G.NETWORK_TYPES,I=B("packages/core/src/columns/types/structured.js"),Z=I.STRUCTURED_TYPES,z=B("packages/core/src/columns/types/unit.js"),L=z.createUnitType,X=z.UNIT_SYSTEMS,$=z.parseUnit,A=z.formatUnit,k=z.registerUnitSystem,y=z.unitSystemNames,f=z.unitsOf,g=z.defineUnit,a=B("packages/core/src/columns/types/engineering.js"),r=a.ENGINEERING_TYPES,i=B("packages/core/src/columns/types/si.js"),c=i.SI_TYPES,u=i.createSiType,n=i.createSiSystem,m=i.siUnits,t=i.SI_PREFIXES,s=B("packages/core/src/columns/types/temperature.js"),h=s.TEMPERATURE_TYPES,d=s.createTemperatureType,o=s.convertTemperature,b=s.formatTemperature,l=s.parseTemperature,p=s.TEMPERATURE_SCALES,w=B("packages/core/src/columns/types/radix.js"),v=w.createRadixType,R=w.RADIX_PRESETS,Y=w.parseRadix,K=w.formatRadix,V=B("packages/core/src/columns/types/aggregable.js"),E=V.AGGREGABLE_TYPES,O=B("packages/core/src/columns/types/currency.js"),C=O.CURRENCY_TYPES,S=O.createCurrencyType,F=O.parseMoney,P=O.formatMoney,M=O.convertMoney,x=O.toMoney,U=O.rateFunction,_=O.moneyComparator,W=O.normaliseCode,q=O.MISSING_RATE;Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return z.findUnit}}),Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return a.ENGINEERING_TYPES}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return a.circularMean}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return s.TEMPERATURE_TYPES}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return s.createTemperatureType}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return s.convertTemperature}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return s.formatTemperature}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return s.parseTemperature}}),Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return s.TEMPERATURE_SCALES}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return s.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 re.TEMPORAL_TYPES}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return G.NETWORK_TYPES}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return I.STRUCTURED_TYPES}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return V.AGGREGABLE_TYPES}}),Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return V.createLogarithmicType}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return V.createRatioType}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return re.parseTime}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return re.formatTime}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return re.parseDateTime}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return re.formatDateTime}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return re.parseDuration}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return re.formatDuration}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return G.parseIpv4}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return G.formatIpv4}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return G.parseCidr}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return G.formatCidr}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return G.parseIpv6}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return G.formatIpv6}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return G.networkAddress}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return G.broadcastAddress}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return G.hostCount}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return G.containsAddress}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return G.overlaps}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return I.maskValue}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return I.summariseJson}});const N=Object.freeze({...T,...D,...Z,...E,hex:v(R.hex),hex8:v(R.hex8),hex16:v(R.hex16),hex32:v(R.hex32),binary:v(R.binary),binary8:v(R.binary8),octal:v(R.octal),bytes:L({system:"data",unit:"B",display:"auto"}),megabytes:L({system:"data",unit:"MB"}),gigabytes:L({system:"data",unit:"GB"}),bitrate:L({system:"bitrate",unit:"Mbps"}),gigabits:L({system:"bitrate",unit:"Gbps"}),...r,...c,...h,...C});{const Q=new Set;for(const J of[T,D,Z,E,r,c,h,C])for(const ee of Object.keys(J)){if(Q.has(ee))throw new Error(`[lattice] data type "${ee}" is declared twice`);Q.add(ee)}}}),Ue("packages/core/src/compute/handle.js",function(e,B){"use strict";Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return c}});const re=B("packages/core/src/internal/compare.js"),T=re.collator,G=re.defaultCompare,I=B("packages/core/src/internal/warn.js").warnOnce;function Z(u){const n=new Uint32Array(u);for(let m=0;m<u;m++)n[m]=m;return n}function z(u,n){if(n&&typeof n.count=="number")return n.count;if(!u)return 0;if(typeof u.count=="number")return u.count;if(typeof u.length=="number")return u.length;const m=u.values;return u.kind==="multi"&&u.offsets?Math.max(0,u.offsets.length-1):m?u.kind==="bitset"?typeof m.size=="number"?m.size:u.presence&&typeof u.presence.size=="number"?u.presence.size:(I(`count:${u.id}`,`column "${u.id}" is bitset-backed with no declared row count; assuming ${m.length*8}`),m.length*8):m.length:u.presence&&typeof u.presence.size=="number"?u.presence.size:0}const L=new WeakMap;function X(u){const n=u.constructor;if(!n)return"unknown";const m=L.get(n);if(m)return m;let t="unknown";try{let s=null;typeof n.from=="function"?s=n.from([!1,!0]):(s=new n(8),s.set(1));const h=s&&s.words;h&&h.length&&(h[0]===2?t="lsb":h[0]===64&&(t="msb"))}catch{t="unknown"}return L.set(n,t),t}function $(u){if(!u)return()=>0;const n=u instanceof Uint8Array?u:u.words;if(n instanceof Uint8Array){const m=u instanceof Uint8Array?"lsb":X(u);if(m==="lsb")return t=>n[t>>>3]>>>(t&7)&1;if(m==="msb")return t=>n[t>>>3]>>>7-(t&7)&1}return typeof u.get=="function"?m=>u.get(m)?1:0:()=>0}function A(u){return!u||!u.presence?null:$(u.presence)}function k(u){return u?typeof u.size=="number"?u.size:typeof u.values=="function"?u.values().length:0:0}function y(u,n){return u?typeof u.valueOf=="function"?u.valueOf(n):typeof u.values=="function"?u.values()[n]:null:null}function f(u,n){const m=u.offsets,t=u.values;if(!m||!t)return[];const s=m[n],h=m[n+1];if(!(h>s))return[];const d=u.dict,o=new Array(h-s);for(let b=s;b<h;b++)o[b-s]=d?y(d,t[b]):t[b];return o}function g(u){if(!u)return()=>{};const n=u.values,m=A(u),t=u.kind;if(t==="dictionary"){const s=u.dict;return m?h=>m(h)?y(s,n[h]):null:h=>y(s,n[h])}if(t==="bitset"){const s=$(n);return m?h=>m(h)?s(h)===1:null:h=>s(h)===1}if(t==="multi")return m?s=>m(s)?f(u,s):null:s=>f(u,s);if(!n&&typeof u.get=="function"){const s=u.get.bind(u);return h=>{const d=s(h);return d===void 0?null:d}}return m?s=>{if(!m(s))return null;const h=n[s];return h===void 0?null:h}:s=>{const h=n[s];return h===void 0?null:h}}function a(u,n){if(u<n)return-1;if(u>n)return 1;if(u===n){const s=Object.is(u,-0),h=Object.is(n,-0);return s===h?0:s?-1:1}const m=Number.isNaN(u),t=Number.isNaN(n);return m&&t?0:m?1:-1}function r(u){const n=T(u);return(m,t)=>{if(m===t)return 0;const s=typeof m,h=typeof t;if(s==="string"&&h==="string")return n.compare(m,t);if(s==="number"&&h==="number")return a(m,t);if(s==="boolean"&&h==="boolean")return m===t?0:m?1:-1;if(m instanceof Date||t instanceof Date){const d=m instanceof Date?m.getTime():Number(m),o=t instanceof Date?t.getTime():Number(t);return a(d,o)}return G(m,t)}}function i(u,n){if(u&&typeof u.ranks=="function")return u.ranks(n);const m=u&&typeof u.values=="function"?u.values():[],t=m.length,s=r(n),h=new Array(t);for(let o=0;o<t;o++)h[o]=o;h.sort((o,b)=>s(m[o],m[b])||o-b);const d=new Uint32Array(t);for(let o=0;o<t;o++)d[h[o]]=o;return d}function c(u){return u==null||typeof u=="number"&&Number.isNaN(u)}}),Ue("packages/core/src/compute/filter.js",function(e,B){"use strict";Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"wallMs",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"itemwisePredicate",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"declareOperators",{enumerable:!0,get:function(){return le}}),Object.defineProperty(e,"declaredOperator",{enumerable:!0,get:function(){return ye}});const T=B("packages/core/src/internal/predicates.js").isBlank,D=B("packages/core/src/internal/merge.js").toArray,Z=B("packages/core/src/internal/warn.js").warnOnce,z=B("packages/core/src/format/date.js"),L=z.toDate,X=z.toIsoDate,$=B("packages/core/src/compute/handle.js"),A=$.bitReader,k=$.dictSize,y=$.dictValue,f=$.presenceReader,g=$.valueComparator,a=$.valueReader,r=/^\d{4}-\d{2}-\d{2}$/,i="\0null\0";function c(fe,we){const ke=fe&&fe.pool;if(ke){const Ce=ke.mask||ke.acquireMask||ke.acquire||ke.take;if(typeof Ce=="function"){const ce=Ce.call(ke,we);if(ce&&ce.length>=we)return ce}}return new Uint8Array(we)}function u(fe,we){const ke=fe&&fe.pool;if(!ke||!we)return;const Ce=ke.release||ke.releaseMask||ke.free||ke.recycle;typeof Ce=="function"&&Ce.call(ke,we)}function n(fe,we,ke){return fe.fill(ke,0,we),fe}function m(fe){return fe==null||typeof fe=="number"&&Number.isNaN(fe)}function t(fe,we){if(fe==null)return fe;if(we==="number")return typeof fe=="number"?fe:Number(fe);if(we==="date"||we==="dateString"){const ke=X(fe);return ke===null?s(fe):ke}return we==="boolean"?typeof fe=="boolean"?fe:fe==="true"||fe===1?!0:fe==="false"||fe===0?!1:!!fe:fe}function s(fe){return fe instanceof Date?fe.getTime():typeof fe=="number"?fe:Date.parse(String(fe))}function h(fe){return typeof fe=="number"?fe:fe instanceof Date?fe.getTime():fe==null||fe===""?NaN:Number(fe)}function d(fe,we){const ke=typeof fe=="string"?fe:String(fe);return we?ke:ke.toLowerCase()}function o(fe,we){return fe==null?i:typeof fe=="string"?we?fe:fe.toLowerCase():fe instanceof Date?fe.getTime():fe}function b(fe,we,ke){const Ce=new Set;for(const ce of D(fe)){const ae=t(ce,ke);Ce.add(o(ae,we)),typeof ae=="string"&&ae!==""&&Number.isFinite(Number(ae))?Ce.add(Number(ae)):typeof ae=="number"&&Number.isFinite(ae)&&Ce.add(o(String(ae),we))}return Ce}function l(fe,we,ke){if(fe==null||we===null||we===void 0)return fe==null&&we==null;const Ce=typeof fe,ce=typeof we;return Ce==="string"&&ce==="string"?ke?fe===we:fe.toLowerCase()===we.toLowerCase():fe instanceof Date||we instanceof Date?s(fe)===s(we):Ce==="number"&&ce==="number"?fe===we||Number.isNaN(fe)&&Number.isNaN(we):Ce==="number"&&ce==="string"?fe===Number(we):Ce==="string"&&ce==="number"?Number(fe)===we:Ce==="boolean"||ce==="boolean"?fe===we:Array.isArray(fe)&&Array.isArray(we)?fe.length===we.length&&fe.every((ae,ge)=>l(ae,we[ge],ke)):fe===we}function p(fe,we){try{if(fe instanceof RegExp){const ke=fe.flags.replace(/[gy]/g,"");return new RegExp(fe.source,we||ke.includes("i")?ke:`${ke}i`)}return new RegExp(String(fe),we?"":"i")}catch(ke){return Z(`regex:${String(fe)}`,`filter operator "matches" received an invalid pattern: ${String(fe)}`,ke),null}}function w(fe,we){if(fe&&fe.type==="datetime"&&v.has(fe.op))return E(fe,we);const ke=O(fe,we),Ce=fe&&fe.type;return Ce!=="date"&&Ce!=="dateString"?ke:ce=>ke(typeof ce=="string"&&r.test(ce)?ce:X(ce)??ce)}const v=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),R=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3})\d*)?)?)?$/,Y=new Map;function K(fe,we){let ke=Y.get(we);if(ke===void 0){try{ke=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{ke=null}Y.set(we,ke)}if(!ke)return null;const Ce={};for(const ce of ke.formatToParts(fe))ce.type!=="literal"&&(Ce[ce.type]=ce.value);return Ce}function V(fe,we){if(fe==null||fe==="")return null;if(typeof fe=="string"){const ae=R.exec(fe.trim());if(ae)return Date.UTC(+ae[1],+ae[2]-1,+ae[3],+(ae[4]||0),+(ae[5]||0),+(ae[6]||0),+(ae[7]||"0").padEnd(3,"0"))}const ke=L(fe);if(!ke)return null;const Ce=ke.getUTCMilliseconds(),ce=we?K(ke,we):null;return ce?Date.UTC(+ce.year,+ce.month-1,+ce.day,ce.hour==="24"?0:+ce.hour,+ce.minute,+ce.second,Ce):Date.UTC(ke.getFullYear(),ke.getMonth(),ke.getDate(),ke.getHours(),ke.getMinutes(),ke.getSeconds(),Ce)}function E(fe,we){const ke=typeof fe.timeZone=="string"&&fe.timeZone?fe.timeZone:void 0,Ce=ge=>V(ge,ke),ce=Array.isArray(fe.value)?fe.value.map(Ce):Ce(fe.value),ae=O({...fe,type:"number",value:ce},we);return ge=>ae(V(ge))}function O(fe,we){const ke=fe&&fe.op,Ce=!!(fe&&fe.caseSensitive),ce=fe&&fe.type,ae=g(we),ge=de=>me=>!de(me);switch(ke){case"eq":{const de=t(fe.value,ce);return me=>l(me,de,Ce)}case"ne":{const de=t(fe.value,ce);return me=>!l(me,de,Ce)}case"lt":case"lte":case"gt":case"gte":{const de=t(fe.value,ce);if(m(de))return()=>!1;const me=ke==="lt"?-1:ke==="lte"?0:ke==="gt"?1:2;return ve=>{if(m(ve))return!1;const xe=ae(ve,de);return me===-1?xe<0:me===0?xe<=0:me===1?xe>0:xe>=0}}case"between":case"notBetween":{const de=D(fe.value),me=t(de[0],ce),ve=t(de[1],ce),xe=fe.bounds||"[]",Ee=xe.charAt(0)!=="(",Le=xe.charAt(1)!==")";if(m(me)||m(ve))return ke==="between"?()=>!1:()=>!0;const He=Me=>{if(m(Me))return!1;const Ke=ae(Me,me),$e=ae(Me,ve);return(Ee?Ke>=0:Ke>0)&&(Le?$e<=0:$e<0)};return ke==="between"?He:ge(He)}case"in":case"notIn":{const de=b(fe.value,Ce,ce),me=ve=>de.has(o(ve,Ce));return ke==="in"?me:ge(me)}case"contains":case"notContains":{const de=d(t(fe.value,ce),Ce),me=ve=>ve==null?!1:d(ve,Ce).includes(de);return ke==="contains"?me:ge(me)}case"startsWith":{const de=d(t(fe.value,ce),Ce);return me=>me==null?!1:d(me,Ce).startsWith(de)}case"endsWith":{const de=d(t(fe.value,ce),Ce);return me=>me==null?!1:d(me,Ce).endsWith(de)}case"matches":{const de=p(fe.value,Ce);return de?me=>me==null?!1:de.test(String(me)):()=>!1}case"blank":case"notBlank":{const de=fe.trim===!0,me=ve=>T(ve)||Array.isArray(ve)&&ve.length===0||de&&typeof ve=="string"&&ve.trim()==="";return ke==="blank"?me:ve=>!me(ve)}case"containsAny":case"containsNone":{const de=b(fe.value,Ce,ce),me=ve=>{const xe=ve==null?[]:D(ve);for(let Ee=0;Ee<xe.length;Ee++)if(de.has(o(xe[Ee],Ce)))return!0;return!1};return ke==="containsAny"?me:ge(me)}case"containsAll":{const de=D(fe.value).map(me=>o(t(me,ce),Ce));return me=>{const ve=me==null?[]:D(me);if(de.length===0)return!0;const xe=new Set(ve.map(Ee=>o(Ee,Ce)));for(let Ee=0;Ee<de.length;Ee++)if(!xe.has(de[Ee]))return!1;return!0}}default:{const de=ye(ke);return de?de.compile(fe.value):(Z(`op:${String(ke)}`,`unknown filter operator "${String(ke)}"; the condition is refused rather than matching every row`),()=>!1)}}}function C(fe,we,ke){return w(we,ke)(fe)}const S=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),F=new Set(["containsAny","containsAll","containsNone"]);function P(fe,we,ke){const Ce=fe&&fe.op,ce=S[Ce]||Ce,ae=w({...fe,op:ce,type:we.type},ke),ge=we.items,de=me=>{const ve=ge(me);if(!ve)return!1;for(let xe=0;xe<ve.length;xe++)if(ae(ve[xe]))return!0;return!1};return S[Ce]?me=>!de(me):de}function M(fe,we,ke,Ce,ce){const ae=ce?null:f(fe);if(ae){const me=we?1:0;for(let ve=0;ve<Ce;ve++)ke[ve]=ae(ve)===me?1:0;return ke}const ge=fe.kind;if(ge==="float64"||ge==="int32"||ge==="bitset")return n(ke,Ce,we?1:0);const de=a(fe);for(let me=0;me<Ce;me++){const ve=de(me),xe=T(ve)||Array.isArray(ve)&&ve.length===0||ce&&typeof ve=="string"&&ve.trim()==="";ke[me]=xe===we?0:1}return ke}function x(fe,we,ke,Ce){const ce=fe.dict,ae=k(ce),ge=new Uint8Array(ae);for(let xe=0;xe<ae;xe++)ge[xe]=we(y(ce,xe))?1:0;const de=fe.values,me=f(fe);if(!me){for(let xe=0;xe<Ce;xe++)ke[xe]=ge[de[xe]];return ke}const ve=we(null)?1:0;for(let xe=0;xe<Ce;xe++)ke[xe]=me(xe)===1?ge[de[xe]]:ve;return ke}function U(fe,we,ke,Ce){const ce=A(fe.values),ae=we(!0)?1:0,ge=we(!1)?1:0,de=f(fe);if(!de){for(let ve=0;ve<Ce;ve++)ke[ve]=ce(ve)===1?ae:ge;return ke}const me=we(null)?1:0;for(let ve=0;ve<Ce;ve++)ke[ve]=de(ve)===0?me:ce(ve)===1?ae:ge;return ke}function _(fe,we,ke,Ce,ce){const ae=fe.values,ge=we.type,de=we.op;let me=!0;switch(de){case"eq":case"ne":{const xe=h(t(we.value,ge)),Ee=typeof we.value=="number"&&Number.isNaN(we.value),Le=de==="ne"?1:0;if(Ee)for(let He=0;He<ce;He++)Ce[He]=(Number.isNaN(ae[He])?1:0)^Le;else for(let He=0;He<ce;He++)Ce[He]=(ae[He]===xe?1:0)^Le;break}case"lt":{const xe=h(t(we.value,ge));for(let Ee=0;Ee<ce;Ee++)Ce[Ee]=ae[Ee]<xe?1:0;break}case"lte":{const xe=h(t(we.value,ge));for(let Ee=0;Ee<ce;Ee++)Ce[Ee]=ae[Ee]<=xe?1:0;break}case"gt":{const xe=h(t(we.value,ge));for(let Ee=0;Ee<ce;Ee++)Ce[Ee]=ae[Ee]>xe?1:0;break}case"gte":{const xe=h(t(we.value,ge));for(let Ee=0;Ee<ce;Ee++)Ce[Ee]=ae[Ee]>=xe?1:0;break}case"between":case"notBetween":{const xe=D(we.value),Ee=h(t(xe[0],ge)),Le=h(t(xe[1],ge)),He=we.bounds||"[]",Me=He.charAt(0)!=="(",Ke=He.charAt(1)!==")",$e=de==="notBetween"?1:0;if(Me&&Ke)for(let Oe=0;Oe<ce;Oe++)Ce[Oe]=(ae[Oe]>=Ee&ae[Oe]<=Le?1:0)^$e;else if(Me)for(let Oe=0;Oe<ce;Oe++)Ce[Oe]=(ae[Oe]>=Ee&ae[Oe]<Le?1:0)^$e;else if(Ke)for(let Oe=0;Oe<ce;Oe++)Ce[Oe]=(ae[Oe]>Ee&ae[Oe]<=Le?1:0)^$e;else for(let Oe=0;Oe<ce;Oe++)Ce[Oe]=(ae[Oe]>Ee&ae[Oe]<Le?1:0)^$e;break}case"in":case"notIn":{const xe=new Set;for(const Le of D(we.value)){const He=h(t(Le,ge));Number.isNaN(He)||xe.add(He)}const Ee=de==="notIn"?1:0;for(let Le=0;Le<ce;Le++)Ce[Le]=(xe.has(ae[Le])?1:0)^Ee;break}default:me=!1;break}if(!me)return!1;const ve=f(fe);if(ve){const xe=ke(null)?1:0;for(let Ee=0;Ee<ce;Ee++)ve(Ee)===0&&(Ce[Ee]=xe)}return!0}function W(fe,we,ke,Ce){const ce=a(fe);for(let ae=0;ae<Ce;ae++)ke[ae]=we(ce(ae))?1:0;return ke}function q(fe,we,ke){const Ce=we.count|0,ce=ke||c(we,Ce);if(!fe)return n(ce,Ce,1);const ae=typeof we.handle=="function"?we.handle(fe.col):void 0,ge=typeof we.custom=="function"?we.custom:null;if(!ae){if(ge){for(let xe=0;xe<Ce;xe++)ce[xe]=ge(fe,xe)?1:0;return ce}return Z(`filter:col:${String(fe.col)}`,`filter references unknown column "${String(fe.col)}"; the condition is refused rather than matching every row`),n(ce,Ce,0)}const de=fe.op;if(de==="blank"||de==="notBlank")return M(ae,de==="notBlank",ce,Ce,fe.trim===!0);const me=typeof we.itemwise=="function"?we.itemwise(fe.col):null;if(me&&!ye(de)&&!F.has(de))return W(ae,P(fe,me,we.locale),ce,Ce);const ve=w(fe,we.locale);switch(ae.kind){case"dictionary":return x(ae,ve,ce,Ce);case"bitset":return U(ae,ve,ce,Ce);case"float64":case"int32":return _(ae,fe,ve,ce,Ce)?ce:W(ae,ve,ce,Ce);default:return W(ae,ve,ce,Ce)}}function N(fe,we,ke){if(!fe)return n(c(we,ke),ke,1);if(Array.isArray(fe.conditions)){const Ce=fe.conditions.filter(ge=>ge!=null),ce=fe.op==="or"?"or":fe.op==="not"?"not":"and";if(Ce.length===0)return n(c(we,ke),ke,1);const ae=N(Ce[0],we,ke);for(let ge=1;ge<Ce.length;ge++){const de=N(Ce[ge],we,ke);if(ce==="or")for(let me=0;me<ke;me++)ae[me]|=de[me];else for(let me=0;me<ke;me++)ae[me]&=de[me];u(we,de)}if(ce==="not")for(let ge=0;ge<ke;ge++)ae[ge]^=1;return ae}return q(fe,we,c(we,ke))}function Q(fe,we){return N(fe,we,we.count|0)}function J(fe,we){if(!fe||!we)return fe||null;const ke=fe;if(Array.isArray(ke.conditions)){if((ke.op==="or"?"or":ke.op==="not"?"not":"and")!=="and")return ee(ke,we)?null:fe;const ce=[];for(const ae of ke.conditions){const ge=J(ae,we);ge&&ce.push(ge)}return ce.length?{...ke,op:"and",conditions:ce}:null}return ke.col===we?null:fe}function ee(fe,we){if(!fe||typeof fe!="object")return!1;const ke=fe;if(ke.col===we)return!0;if(Array.isArray(ke.conditions)){for(const Ce of ke.conditions)if(ee(Ce,we))return!0}return!1}function ne(fe,we,ke){if(ke&&ke.length>=we){let ge=0;for(let de=0;de<we;de++)fe[de]&&(ke[ge++]=de);return ke.subarray(0,ge)}let Ce=0;for(let ge=0;ge<we;ge++)Ce+=fe[ge]?1:0;const ce=new Uint32Array(Ce);let ae=0;for(let ge=0;ge<we;ge++)fe[ge]&&(ce[ae++]=ge);return ce}const se=new Map;function le(fe){if(!(!fe||typeof fe!="object"))for(const[we,ke]of Object.entries(fe))ke&&typeof ke.compile=="function"&&se.set(we,ke)}function ye(fe){return typeof fe=="string"?se.get(fe):void 0}}),Ue("packages/core/src/columns/datatypes.js",function(e,B){"use strict";Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"parseNumberText",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"BUILTIN_TYPES",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"INFERENCE_ORDER",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"createTypeRegistry",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"comparatorFor",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"storageKind",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"typeLabel",{enumerable:!0,get:function(){return M}});const re=B("packages/core/src/internal/compare.js"),T=re.collator,G=re.defaultCompare,D=B("packages/core/src/internal/predicates.js"),I=D.isNil,Z=D.isObject,z=D.isFunction,L=B("packages/core/src/internal/warn.js"),X=L.fail,$=L.infoOnce,k=B("packages/core/src/internal/text.js").titleCase,y=B("packages/core/src/format/date.js"),f=y.toDate,g=y.toIsoDate,a=y.compareIso,i=B("packages/core/src/format/boolean.js").toTriState,u=B("packages/core/src/columns/types/index.js").EXTENDED_TYPES,n=B("packages/core/src/formula/index.js"),m=n.evaluateFormula,t=n.looksLikeFormula,h=B("packages/core/src/compute/filter.js").declareOperators,d=/^\d{4}-\d{2}-\d{2}$/;function o(x){return x.getHours()===0&&x.getMinutes()===0&&x.getSeconds()===0&&x.getMilliseconds()===0}const b=new Map;function l(x){const U=x||"",_=b.get(U);if(_)return _;const W={group:",",decimal:"."};try{for(const q of new Intl.NumberFormat(x||void 0).formatToParts(12345.6))q.type==="group"?W.group=q.value:q.type==="decimal"&&(W.decimal=q.value)}catch{}return b.set(U,W),W}const p=/\d\s*[*/^]\s*[\d.(]/;function w(x,U){if(I(x))return null;let _=String(x).trim();if(_===""||_.startsWith("=")||p.test(_))return null;let W=1;_.startsWith("(")&&_.endsWith(")")&&(W=-1,_=_.slice(1,-1));const q=_.endsWith("%"),{group:N,decimal:Q}=l(U);if(_=_.replace(/[\s\u00a0\u202f\u2009']/g,""),N&&N!=="."&&N!==","&&(_=_.split(N).join("")),_=_.replace(/[^0-9eE+\-.,]/g,""),Q===","?_=_.split(".").join("").replace(",","."):_=_.split(",").join(""),_===""||_==="-"||_==="+")return null;const J=Number(_);return Number.isNaN(J)?null:W*(q?J/100:J)}function v(x,U){const _=I(x)||Number.isNaN(x)?null:Number(x),W=I(U)||Number.isNaN(U)?null:Number(U);return _===null?W===null?0:1:W===null||_<W?-1:_>W?1:0}function R(x,U){const _=i(x),W=i(U);return _===null?W===null?0:1:W===null?-1:_===W?0:_?1:-1}function Y(x,U){const _=f(x),W=f(U);if(!_)return W?1:0;if(!W)return-1;const q=_.getTime(),N=W.getTime();return q<N?-1:q>N?1:0}const K=new Map;function V(x){const U=f(x.value);if(!U)return"";const _=x.locale||"";let W=K.get(_);return W||(W=new Intl.DateTimeFormat(x.locale||void 0,{dateStyle:"medium"}),K.set(_,W)),W.format(U)}const E={boolean:{base:"boolean",storage:"bitset",matches:x=>typeof x=="boolean",parse:x=>i(x.text),compare:R,format:x=>i(x.value)===null?"":i(x.value)?"Yes":"No",defaults:{filter:"set",editor:"checkbox",align:"center"},excel:"General",toClipboard:x=>i(x)===null?"":String(i(x)),fromClipboard:x=>i(x)},number:{base:"number",storage:"float64",matches:x=>typeof x=="number"&&!Number.isNaN(x),parse:x=>{if(t(x.text)){const U=m(x.text,x);if(!U.ok)return null;const _=Number(U.value);return Number.isFinite(_)?_:null}return w(x.text,x.locale)},compare:v,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:x=>I(x)?"":String(x),fromClipboard:(x,U)=>w(x,U&&U.locale),toStorage:(x,U)=>{if(typeof x!="string")return x;const _=w(x,U&&U.locale);return _!==null?_:($(`type.number.unparsed.${U&&U.colId||""}`,`column "${U&&U.colId||"?"}" is declared type "number" but holds a value that is not a number in its locale; storing it as NaN, excluded from sorts and totals.`),NaN)}},date:{base:"dateString",storage:"dictionary",matches:x=>typeof x=="string"&&d.test(x)&&!Number.isNaN(Date.parse(x))||x instanceof Date&&!Number.isNaN(x.getTime())&&o(x),parse:x=>g(x.text),compare:a,format:V,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:x=>g(x),toClipboard:x=>I(x)?"":String(x),fromClipboard:x=>g(x)},dateString:{base:"dateString",storage:"dictionary",matches:x=>typeof x=="string"&&d.test(x)&&!Number.isNaN(Date.parse(x)),parse:x=>g(x.text),compare:a,format:V,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:x=>g(x),toClipboard:x=>I(x)?"":String(x),fromClipboard:x=>g(x)},text:{base:"text",storage:"dictionary",matches:x=>typeof x=="string",parse:x=>x.text===""?null:String(x.text),compare:(x,U)=>I(x)?I(U)?0:1:I(U)?-1:T().compare(String(x),String(U)),defaults:{filter:"text",editor:"text",align:"start"},excel:"@",toClipboard:x=>I(x)?"":String(x),fromClipboard:x=>x},image:{base:"text",storage:"dictionary",parse:x=>x.text===""||x.text==null?null:String(x.text).trim(),compare:(x,U)=>I(x)?I(U)?0:1:I(U)?-1:T().compare(String(x),String(U)),defaults:{filter:"text",editor:"text",align:"center",render:"image"},excel:"@",toClipboard:x=>I(x)?"":String(x),fromClipboard:x=>x},lookup:{base:"text",storage:"dictionary",parse:x=>{if(x.text===""||x.text==null)return null;const U=x.column&&x.column.lookup,_=U&&z(U.options)?U.options():null;if(!_)return x.text;const W=String(x.text),q=_.find(J=>String(J.id)===W);if(q)return q.id;const N=W.trim().toLowerCase(),Q=_.find(J=>String(J.label).toLowerCase()===N);return Q?Q.id:x.text},compare:G,defaults:{filter:"set",editor:"select",align:"start"},excel:"@",multiStorage:"multi",toClipboard:x=>I(x)?"":String(x),fromClipboard:x=>x},object:{base:"object",storage:"object",matches:x=>x!==null&&typeof x=="object"&&!(x instanceof Date),parse:x=>{try{return x.text===""?null:JSON.parse(x.text)}catch{return x.text}},compare:(x,U)=>G(x,U),format:x=>{const U=x.value;if(I(U))return"";if(typeof U=="string")return U;try{return JSON.stringify(U)}catch{return String(U)}},defaults:{filter:"none",editor:"none",align:"start"},excel:"@",toClipboard:x=>I(x)?"":typeof x=="string"?x:JSON.stringify(x),fromClipboard:x=>x}},O=["boolean","number","date","dateString","datetime","text","object"];function C(x,U,_,W){const q=_.get(x);if(q)return q;W.includes(x)&&X(`circular data type extends chain: ${[...W,x].join(" → ")}`);const N=U[x];N||X(`unknown data type "${x}"`);let Q=null;N.extends&&(Q=C(N.extends,U,_,[...W,x]));const J={...Q||{},...N,name:x,defaults:{...Q&&Q.defaults||{},...N.defaults||{}}};return J.base||(J.base=Q&&Q.base||"text"),J.storage||(J.storage=Q&&Q.storage||"object"),_.set(x,J),J}function S(x,U){const _={...E,...u};if(U&&typeof U.dataType=="function"&&typeof U.names=="function")for(const q of U.names("dataType")){const N=U.dataType(q);N&&(_[q]=N)}if(Z(x))for(const[q,N]of Object.entries(x))_[q]=N;const W=new Map;for(const q of O)C(q,_,W,[]);C("lookup",_,W,[]);for(const q of Object.keys(_))C(q,_,W,[]);for(const q of W.values())h(q.operators);return W}function F(x,U){if(x.base==="text"&&(!x.compare||x.compare===E.text.compare)){const _=T(U);return(W,q)=>I(W)?I(q)?0:1:I(q)?-1:_.compare(String(W),String(q))}return x.compare||G}function P(x,U){return U?x.multiStorage||"multi":x.storage||"object"}function M(x){return k(String(x).replace(/([a-z])([A-Z])/g,"$1 $2"))}}),Ue("packages/core/src/columns/infer.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_SAMPLE",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"inferFromValues",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"inferColumnType",{enumerable:!0,get:function(){return z}});const T=B("packages/core/src/internal/warn.js").infoOnce,D=B("packages/core/src/internal/predicates.js").isNil,I=100;function Z(L,X,$={}){const A=$.sampleSize??I,k=[];for(let y=0;y<L.length&&k.length<A;y++){const f=L[y];D(f)||typeof f=="number"&&Number.isNaN(f)||k.push(f)}if(k.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[y,f]of X){if(typeof f.matches!="function")continue;let g=!0;for(let a=0;a<k.length;a++)if(!f.matches(k[a])){g=!1;break}if(g)return{type:y,unanimous:!0,sampled:k.length}}return $.quiet||T(`infer:${$.colId||"?"}`,`column "${$.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 z(L,X,$,A,k={}){const y=k.sampleSize??I,f=[];for(let g=0;g<X.length&&f.length<y;g++){const a=$(X[g]);D(a)||typeof a=="number"&&Number.isNaN(a)||f.push(a)}return Z(f,A,{...k,colId:L}).type}}),Ue("packages/core/src/columns/graph.js",function(e,B){"use strict";Object.defineProperty(e,"WHOLE_ROW",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"declarationOf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"affectedBy",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return A}});const re=B("packages/core/src/internal/warn.js"),T=re.DEV,G=re.fail,D=re.warnOnce,Z=B("packages/core/src/internal/predicates.js").isFunction,z="*";function L(k){const y=k.value||{};if(!Z(y.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const g=y.pure!==!1;return y.deps===z?{computed:!0,wholeRow:!0,deps:[],pure:g}:Array.isArray(y.deps)?{computed:!0,wholeRow:!1,deps:y.deps.slice(),pure:g}:(D(`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:g})}function X(k){const y=new Map;for(const h of k)y.set(h.id,h);const f=new Map,g=new Map,a=new Set,r=new Set,i=new Set,c=new Set;for(const h of k){const d=L(h);if(!d.computed){f.set(h.id,[]);continue}r.add(h.id),(d.pure?i:c).add(h.id),d.wholeRow&&a.add(h.id);const o=[],b=[];for(const l of d.deps)(y.has(l)?o:b).push(l);f.set(h.id,o),b.length&&g.set(h.id,b)}for(const h of i)for(const d of f.get(h))c.has(d)&&G(`pure computed column "${h}" depends on impure column "${d}". Mark it \`value.pure: false\` or make the dependency pure.`);const u=[],n=new Map,m=[],t=h=>{const d=n.get(h);if(d!=="done"){if(d==="open"){const o=m.indexOf(h);G(`circular column dependency: ${[...m.slice(o),h].join(" → ")}`)}n.set(h,"open"),m.push(h);for(const o of f.get(h)||[])y.has(o)&&t(o);m.pop(),n.set(h,"done"),u.push(h)}};for(const h of k)t(h.id);const s=new Map;for(const h of k)s.set(h.id,[]);for(const h of k)for(const d of f.get(h.id)||[]){const o=s.get(d);o&&!o.includes(h.id)&&o.push(h.id)}if(a.size)for(const h of k){if(r.has(h.id))continue;const d=s.get(h.id);for(const o of a)d.includes(o)||d.push(o)}return{order:u,dependents:s,pure:i,impure:c,computed:r,deps:f,wholeRow:a,external:g,index:y}}function $(k,y){const f=Array.isArray(y)?y:[y],g=new Set,a=[...f];for(;a.length;){const r=a.shift();for(const i of k.dependents.get(r)||[])g.has(i)||(g.add(i),a.push(i))}for(const r of f)g.delete(r);return k.order.filter(r=>g.has(r))}function A(k,y,f){if(!T)return k;const g=y instanceof Set?y:new Set(y);return new Proxy(k,{get(a,r){return typeof r=="string"&&!g.has(r)&&!Object.hasOwn(a,r)&&D(`undeclared:${f}:${r}`,`computed column "${f}" read undeclared dependency "${r}". Add it to \`value.deps\` or the value will go stale.`),a[r]}})}}),Ue("packages/core/src/model/rowkey.js",function(e,B){"use strict";Object.defineProperty(e,"KEY_DEPENDENT_FEATURES",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"compositeKey",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"warnMissingKeys",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"groupPathKey",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"splitPathKey",{enumerable:!0,get:function(){return r}});const T=B("packages/core/src/internal/warn.js").warnOnce,D=B("packages/core/src/internal/paths.js").pathGetter,I=B("packages/core/src/internal/predicates.js"),Z=I.isFunction,z=I.isBlank,L=["changes (rows.apply / rows.queue)","streaming dedupe","selection persistence","remote reload","cell comments"],X="";function $(i){if(i===null)return"\0n";if(i===void 0)return"\0u";const c=typeof i;if(c==="string")return i;if(c==="number"||c==="bigint"||c==="boolean")return String(i);if(i instanceof Date)return`\0d${i.getTime()}`;try{return`\0o${JSON.stringify(i)}`}catch{return"\0o?"}}function A(i){if(i.length===1)return $(i[0]);let c="";for(let u=0;u<i.length;u++)u&&(c+=X),c+=$(i[u]);return c}function k(i,c={}){const u=c.warn!==!1;if(Z(i)){const n=i;return{stable:!0,fields:[],disabled:[],key(m,t){try{const s=n(m);return Array.isArray(s)?A(s):$(s)}catch(s){return T("rowKey.throw","rowKey function threw; falling back to index identity for the affected rows.",s),`#${t??-1}`}},keyEmpty(m){try{const t=n(m);return Array.isArray(t)?t.length===0||t.some(z):z(t)}catch{return!1}},missingFields(){return[]}}}if(Array.isArray(i)&&i.length>0){const n=i.filter(s=>typeof s=="string"),m=n.map(s=>D(s)),t=m.length;return{stable:!0,fields:n,disabled:[],key(s){const h=new Array(t);for(let d=0;d<t;d++)h[d]=m[d](s);return A(h)},keyEmpty(s){for(let h=0;h<t;h++)if(z(m[h](s)))return!0;return!1},missingFields(s){const h=[];for(let d=0;d<t;d++)z(m[d](s))&&h.push(n[d]);return h}}}if(typeof i=="string"&&i.length>0){const n=D(i);return{stable:!0,fields:[i],disabled:[],key(m){return $(n(m))},keyEmpty(m){return z(n(m))},missingFields(m){return z(n(m))?[i]:[]}}}return u&&T("rowKey.missing",`no rowKey configured, so rows are identified by object identity. This disables: ${L.join(", ")}. Set rowKey to a field name, an array of field names, or a function.`),{stable:!1,fields:[],disabled:L.slice(),key(n,m){if(n===null||typeof n!="object")return`#${m??0}:${String(n)}`;let t=y.get(n);return t===void 0&&(t=`#${f++}`,y.set(n,t)),t}}}const y=new WeakMap;let f=0;function g(i,c){if(!i||i.stable===!1||!Z(i.keyEmpty)||!Array.isArray(c)||c.length===0)return;let u=0,n=null,m;for(let d=0;d<c.length;d++){const o=c[d];i.keyEmpty(o)&&(u++,n===null&&(n=Z(i.missingFields)?i.missingFields(o):[],m=o))}if(u===0)return;const t=i.fields.length?i.fields.join(","):"(function)",s=n&&n.length?n.join(", "):i.fields.length?i.fields.join(", "):"the rowKey function",h=m!==null&&typeof m=="object"?Object.keys(m).join(", ")||"(no fields)":String(m);T(`rowKey.emptyValue:${t}`,`rowKey ${s} is missing on ${u} of ${c.length} rows; the first such row has: ${h}. Rows without a key value collapse onto one key, so selection, edits and rows.apply updates land on whichever row now shares it. Set rowKey to a field present on every row, or fix the source data.`)}function a(i){return A(i)}function r(i){return i.split(X)}}),Ue("packages/core/src/columns/lookup.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_SEPARATOR",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"normaliseOption",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"flattenOptions",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return i}});const re=B("packages/core/src/internal/compare.js"),T=re.collator,G=re.defaultCompare,D=B("packages/core/src/internal/predicates.js"),I=D.isFunction,Z=D.isNil,L=B("packages/core/src/internal/warn.js").warnOnce,$=B("packages/core/src/model/rowkey.js").compositeKey,A=", ",k="";function y(c,u,n,m){if(c===null||typeof c!="object")return{id:c,label:c==null?"":String(c)};const t=c[u],s=c[n],h={id:t,label:s==null?String(t??""):String(s)};c.disabled&&(h.disabled=!0),c.variant&&(h.variant=c.variant),c.icon&&(h.icon=c.icon);const d=m?c[m]:c.group;return d!==void 0&&(h.group=d),h}function f(c,u,n=0,m=[],t=[]){for(const s of c||[]){const h=s&&typeof s=="object"?s[u]:null;if(t.push({raw:s,depth:n,path:m}),Array.isArray(h)&&h.length){const d=String(s&&typeof s=="object"?s.label??s.name??s.id??"":s);f(h,u,n+1,[...m,d],t)}}return t}function g(c){return!!c&&typeof c=="object"&&!Array.isArray(c)&&I(c.router&&c.router.subscribe)}class a{#e;#t;#n;#r;#i=[];#s=new Map;#a=new Map;#l=0;#o="idle";#c=null;#u;#f=null;#d=new Map;constructor(u,n={}){this.#e=u||{},this.#t=n.colId||"?",this.#n=n.locale,this.#r=n.onChange||null,this.#u=T(this.#n),Array.isArray(this.#e.options)?this.#h(this.#e.options):this.#e.options===void 0&&(this.#o="ready")}get colId(){return this.#t}get version(){return this.#l}get state(){return this.#o}get ready(){return this.#o==="ready"}get multiple(){return this.#e.multiple===!0}get separator(){return this.#e.separator??A}get allowCustom(){return this.#e.allowCustom===!0}get sortBy(){return this.#e.sortBy||"label"}get spec(){return this.#e}options(){return this.#i}setLocale(u){this.#n=u,this.#u=T(u)}#h(u){const n=this.#e,m=n.valueKey||"id",t=n.labelKey||"label",s=n.childrenKey||"children";this.#i=f(u,s).map(h=>{const d=y(h.raw,m,t,n.groupKey);return h.depth&&(d.depth=h.depth,d.path=h.path),d}),this.#s=new Map,this.#a=new Map,this.#i.forEach((h,d)=>{this.#s.set(h.id,h),this.#a.set(h.id,d)}),this.#o="ready",this.#l+=1}load(){if(this.#c)return this.#c;const u=this.#e.options;if(Array.isArray(u)||u===void 0)return this.#c=Promise.resolve(this.#i),this.#c;if(g(u))return this.#c=this.#p(u),this.#c;if(!I(u))return L(`lookup:options:${this.#t}`,`column "${this.#t}" has an invalid \`lookup.options\`; expected an array, a function, or a router route`),this.#o="ready",this.#c=Promise.resolve([]),this.#c;this.#o="loading";let n;try{n=u()}catch(m){return this.#o="error",L(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,m),this.#c=Promise.resolve([]),this.#c}return!n||!I(n.then)?(this.#h(n),this.#c=Promise.resolve(this.#i),this.#r&&this.#r(this),this.#c):(this.#c=n.then(m=>(this.#h(m),this.#r&&this.#r(this),this.#i),m=>(this.#o="error",L(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,m),[])),this.#c)}refresh(){return this.#c=null,Array.isArray(this.#e.options)?(this.#h(this.#e.options),this.#r&&this.#r(this),Promise.resolve(this.#i)):this.load()}#p(u){if(this.#f)return Promise.resolve(this.#i);const n=this.#e,m=n.valueKey||"id",t=n.labelKey||"label",s=n.groupKey,h=I(u.map)?u.map:null,d=b=>y(h?h(b):b,m,t,s).id,o=b=>this.#m(b,h,m,t,s);return u.router.subscribe(u.predicate,o,{rowKey:d}),this.#f=()=>{I(u.router.detach)&&u.router.detach(o)},this.#o="ready",Promise.resolve(this.#i)}#m(u,n,m,t,s){const h=u&&u.add||[],d=u&&u.update||[],o=u&&u.remove||[];if(!(!h.length&&!d.length&&!o.length)){for(const b of h)this.#g(b,n,m,t,s);for(const b of d)this.#g(b,n,m,t,s);for(const b of o){if(!this.#d.has(b))continue;const l=this.#d.get(b);this.#d.delete(b),this.#s.delete(l);const p=this.#i.findIndex(w=>w.id===l);p>=0&&this.#i.splice(p,1)}this.#a=new Map(this.#i.map((b,l)=>[b.id,l])),this.#o="ready",this.#l+=1,this.#r&&this.#r(this)}}#g(u,n,m,t,s){const h=y(n?n(u):u,m,t,s);this.#d.set($([h.id]),h.id);const d=this.#i.findIndex(o=>o.id===h.id);d>=0?this.#i[d]=h:this.#i.push(h),this.#s.set(h.id,h)}destroy(){this.#f&&(this.#f(),this.#f=null)}search(u,n){const m=this.#e;if(!I(m.search)){const h=String(u||"").toLowerCase();return Promise.resolve(h===""?this.#i:this.#i.filter(d=>d.label.toLowerCase().includes(h)))}const t=m.valueKey||"id",s=m.labelKey||"label";return Promise.resolve(m.search(u,n)).then(h=>(h||[]).map(d=>y(d,t,s,m.groupKey)))}option(u){return this.#s.get(u)}has(u){return this.#s.has(u)}label(u){if(Z(u)||u==="")return"";const n=this.#s.get(u);if(n)return n.label;if(this.#o==="loading"||this.#o==="idle")return"";this.allowCustom||L(`lookup:unknown:${this.#t}`,`column "${this.#t}" holds value ${JSON.stringify(u)} which is not in its lookup options. Showing the raw value; set \`lookup.unknownLabel\` or \`lookup.allowCustom\` to change that.`);const m=this.#e.unknownLabel;return I(m)?String(m(u)??""):typeof m=="string"?m:String(u)}text(u){if(this.multiple){const n=r(u);return n.length===0?"":n.map(m=>this.label(m)).join(this.separator)}return this.label(u)}dictionary(){return this.#i.map(u=>u.id)}sorted(){const u=this.sortBy;if(u==="optionOrder"||u==="count")return this.#i.slice();if(u==="value")return this.#i.slice().sort((m,t)=>G(m.id,t.id));const n=this.#u;return this.#i.slice().sort((m,t)=>n.compare(m.label,t.label))}comparator(){const u=this.sortBy,n=this.multiple,m=this.#u,t=this.#a;if(n&&u==="count")return(h,d)=>r(h).length-r(d).length;const s=n?h=>r(h)[0]:h=>h;return u==="value"?(h,d)=>G(s(h),s(d)):u==="optionOrder"?(h,d)=>{const o=t.has(s(h))?t.get(s(h)):Number.MAX_SAFE_INTEGER,b=t.has(s(d))?t.get(s(d)):Number.MAX_SAFE_INTEGER;return o-b}:(h,d)=>{const o=s(h),b=s(d);return Z(o)?Z(b)?0:1:Z(b)?-1:m.compare(this.label(o),this.label(b))}}groupKey(u){return this.multiple?r(u).map(m=>String(m)).sort().join(k):Z(u)?"":String(u)}countValues(u){return this.multiple?r(u).length:Z(u)?0:1}contains(u,n,m){const t=this.multiple?r(u):Z(u)?[]:[u],s=Array.isArray(n)?n:[n];switch(m){case"containsAll":return s.every(h=>t.includes(h));case"containsNone":return!s.some(h=>t.includes(h));default:return s.some(h=>t.includes(h))}}exportText(u,n="label"){return n==="value"?this.multiple?r(u).join(this.separator):Z(u)?"":String(u):this.text(u)}exportColumns(){const u=this.multiple;return this.#i.map(n=>({id:n.id,label:n.label,has:m=>u?r(m).includes(n.id):m===n.id}))}}function r(c){return Array.isArray(c)?c:Z(c)||c===""?[]:[c]}function i(c,u={}){const n=c.lookup;if(!n)return null;const m=new a(n,{colId:c.id,locale:u.locale,onChange:u.onChange});return!Array.isArray(n.options)&&n.options!==void 0&&m.load(),m}}),Ue("packages/core/src/columns/value.js",function(e,B){"use strict";Object.defineProperty(e,"compileDisplay",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"warnImpureUse",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return c}});const T=B("packages/core/src/internal/paths.js").getPath,G=B("packages/core/src/internal/predicates.js"),D=G.isFunction,I=G.isNil,Z=G.isObject,L=B("packages/core/src/internal/lru.js").Lru,$=B("packages/core/src/internal/warn.js").warnOnce,k=B("packages/core/src/format/number.js").compileNumber,f=B("packages/core/src/columns/graph.js").depsProxy,g="\0";function a(t,s={}){const h=s.locale,d=s.grid??null,o=s.context,b=t.value&&t.value.format,l=t.formatter||null,p=t.dataType&&t.dataType.format,w=t.lookup||null,v=(R,Y,K)=>({value:R,data:K,row:Y,column:t,colId:t.id,grid:d,context:o,locale:h});if(D(b))return(R,Y,K)=>{const V=b(v(R,Y,K));return V==null?"":String(V)};if(l){if(w){const R=l.kind==="text";return(Y,K,V)=>l(R?w.text(Y):Y,v(Y,K,V))}return(R,Y,K)=>l(R,v(R,Y,K))}if(D(p))return(R,Y,K)=>{const V=p(v(R,Y,K));return V==null?"":String(V)};if(t.dataType&&t.dataType.base==="number"&&Z(t.typeOptions)&&typeof t.typeOptions.decimals=="number"){const R=k({decimals:t.typeOptions.decimals},h);return Y=>R(Y)}return w?R=>w.text(R):R=>I(R)?"":typeof R=="string"?R:String(R)}function r(t,s){!t||!t.value||t.value.pure!==!1||$(`impure:${s}:${t.id}`,`column "${t.id}" is an impure computed column (\`value.pure: false\`) and is being used to ${s}. The result is not stable across passes.`)}class i{#e;#t;#n;#r;#i;#s;#a=new L(4096);constructor(s){this.#e=s.columns instanceof Map?s.columns:new Map((s.columns||[]).map(h=>[h.id,h])),this.#t=s.graph,this.#n=s.grid??null,this.#r=s.context,this.#s=s.stored||null,this.#i=s.rowKey||c}get graph(){return this.#t}setGraph(s){this.#t=s,this.#a.clear()}beginPass(){this.#a.clear()}endPass(){this.#a.clear()}invalidate(s){if(this.#a.size===0)return;const h=s&&s.rows?new Set([...s.rows].map(String)):null,d=s&&s.columns?[...s.columns]:null;if(!h&&!d){this.#a.clear();return}const o=d?this.#l(d):null;for(const b of[...this.#a.keys()]){const l=String(b).split(g);l.length===3&&(h&&!h.has(l[0])||o&&!o.has(l[2])||this.#a.delete(b))}}#l(s){const h=new Set,d=this.#t,o=[...s];for(;o.length;){const b=o.pop();if(!h.has(b)){h.add(b);for(const l of d?d.dependents.get(b)||[]:[])o.push(l)}}return h}value(s,h,d){const o=typeof s=="string"?this.#e.get(s):s;if(!o)return;if(!o.computed)return this.#c(o,h,d);if(o.value.pure!==!1&&this.#s&&d&&d.physical!=null&&this.#s.has(o.id))return this.#s.get(o.id,d.physical);if(o.volatile)return this.compute(o,h,d);if(o.value.pure===!1)return this.compute(o,h,d);const b=`${this.#o(h,d)}${g}${o.id}`;if(this.#a.has(b))return this.#a.get(b);const l=this.compute(o,h,d);return this.#a.set(b,l),l}#o(s,h){return`${this.#i(s,h)}${g}${u(s)}`}#c(s,h,d){if(this.#s&&d&&d.physical!=null&&this.#s.has(s.id))return this.#s.get(s.id,d.physical);if(s.field)return s.read?s.read(h):T(h,s.field)}compute(s,h,d){const o=this.#t,b=o&&o.wholeRow.has(s.id);let l;if(b)l=h??{};else{l={};const w=o&&o.deps.get(s.id)||[];for(const R of w)l[R]=this.value(R,h,d);const v=o&&o.external.get(s.id)||[];for(const R of v)l[R]=T(h,R);l=f(l,[...w,...v],s.id)}const p={data:h,row:d,column:s,grid:this.#n,context:this.#r};return s.value.compute(l,p)}values(s,h){const d={},o=this.#t?this.#t.order:[...this.#e.keys()];for(const b of o)d[b]=this.value(b,s,h);return d}text(s,h,d){const o=typeof s=="string"?this.#e.get(s):s;return o?o.formatValue(this.value(o,h,d),d,h):""}key(s,h,d){const o=typeof s=="string"?this.#e.get(s):s;if(!o)return"";const b=this.value(o,h,d);return D(o.value.key)?String(o.value.key(this.#u(o,b,h,d))):o.lookup?o.lookup.groupKey(b):I(b)?"":String(b)}quickFilterText(s,h,d){const o=typeof s=="string"?this.#e.get(s):s;if(!o)return"";if(D(o.value.quickFilterText)){const b=this.value(o,h,d);return String(o.value.quickFilterText(this.#u(o,b,h,d))??"")}return this.text(o,h,d)}#u(s,h,d,o){return{value:h,data:d,row:o,column:s,colId:s.id,grid:this.#n,context:this.#r}}parse(s,h,d,o){const b=typeof s=="string"?this.#e.get(s):s;if(!b)return h;const l={text:h,value:this.value(b,d,o),data:d,row:o,column:b,grid:this.#n,context:this.#r,locale:this.#n&&D(this.#n.get)?this.#n.get("locale"):void 0,formulaFunctions:this.#n&&D(this.#n.get)?this.#n.get("formulaFunctions"):void 0};return D(b.value.parse)?b.value.parse(l):b.dataType&&D(b.dataType.parse)?b.dataType.parse(l):h}validate(s,h,d,o,b){const l=typeof s=="string"?this.#e.get(s):s;if(!l||!D(l.edit.validate))return!0;const p=l.edit.validate({value:h,oldValue:d,data:o,row:b,column:l,grid:this.#n,context:this.#r});return p===!0||p===void 0?!0:String(p)}apply(s,h,d,o){const b=typeof s=="string"?this.#e.get(s):s;if(!b)return!1;const l=this.value(b,d,o);if(D(b.value.apply)){const p=b.value.apply({value:h,oldValue:l,data:d,row:o,column:b,grid:this.#n,context:this.#r});return this.#f(b,d,o),p!==!1}return b.field?l===h?!1:(b.write(d,h),this.#f(b,d,o),!0):($(`apply:${b.id}`,`column "${b.id}" has no \`field\` and no \`value.apply\`, so an edit cannot be written back.`),!1)}commit(s,h,d,o){const b=typeof s=="string"?this.#e.get(s):s;if(!b)return{ok:!1,value:void 0,oldValue:void 0,changed:!1,error:"unknown column"};const l=this.value(b,d,o),p=this.parse(b,h,d,o),w=this.validate(b,p,l,d,o);if(w!==!0)return{ok:!1,value:p,oldValue:l,changed:!1,error:w};const v=this.apply(b,p,d,o);return{ok:!0,value:p,oldValue:l,changed:v}}#f(s,h,d){if(this.#a.size===0)return;const o=this.#o(h,d);this.#a.delete(`${o}${g}${s.id}`);for(const b of this.#t?this.#t.dependents.get(s.id)||[]:[])this.#a.delete(`${o}${g}${b}`)}}function c(t,s){return s&&s.key!=null?String(s.key):u(t)}function u(t){if(t&&typeof t=="object"){let s=n.get(t);return s===void 0&&(s=`#${m++}`,n.set(t,s)),s}return String(t)}const n=new WeakMap;let m=0}),Ue("packages/core/src/model/shadow.js",function(e,B){"use strict";Object.defineProperty(e,"MAX_TRACKED",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"DEFAULT_DEPTH",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"HISTORY_TICK_MAX_MS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"HISTORY_TICK_MIN_MS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"historyTickFor",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"SHADOW_KINDS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"ROLLING_KINDS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"FIT_SHADOW_KINDS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"CLUSTER_SHADOW_KINDS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"DEFAULT_ANOMALY_THRESHOLD",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"SPEC_STATUS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"POSITIONAL_KINDS",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"SHADOW_LABELS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"specStatusOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ShadowTracker",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"shadowsIn",{enumerable:!0,get:function(){return s}});const T=B("packages/core/src/internal/warn.js").warnOnce,G=2e5,D=20,I=1e3,Z=50;function z(h){return Math.min(I,Math.max(Z,Math.floor(h)))}const L=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"]),$=Object.freeze(["fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),A=Object.freeze(["cluster","clusterDistance"]),k=.6745,y=3.5,f=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),g=Object.freeze(["rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag"]),a=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 r(h,d){if(!d)return null;const o=Number.isFinite(Number(d.lower))?Number(d.lower):null,b=Number.isFinite(Number(d.upper))?Number(d.upper):null;if(o===null&&b===null||!Number.isFinite(h))return null;if(o!==null&&h<o||b!==null&&h>b)return f.FAIL;const l=Number.isFinite(Number(d.warnLower))?Number(d.warnLower):null,p=Number.isFinite(Number(d.warnUpper))?Number(d.warnUpper):null;return l!==null&&h<l||p!==null&&h>p?f.WARN:f.PASS}function i(h,d,o){if(!d||typeof d!="object")return null;if(d.kind!=="time")return d.kind!==void 0&&T(`shadow.history.window.kind:${h}`,`a 'history' shadow's 'window' only accepts {kind: 'time', span}; '${d.kind}' is not honoured (a plain count is already what 'depth' means, and a session has no span to divide into buckets), so it reported the original, unwindowed history.`),null;const b=d.minutes!=null?Number(d.minutes)*6e4:Number(d.span);if(!(b>0))return T(`shadow.history.window.span:${h}`,"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 l=Math.max(2,Math.floor(o)||D);return{span:b,bucketMs:Math.max(1,Math.floor(b/l))}}class c{#e;#t=new Map;#n=new Map;#r=new Map;#i=new Map;#s=new Map;#a=new Map;#l=0;#o;#c;#u;#f;#d=new Map;#h=null;#p=null;#m=null;constructor(d){this.#e=d.colId,this.#o=Math.max(2,d.depth||D),this.#c=Math.max(1,d.max||G),this.#u=d.now||(()=>Date.now()),this.#f=i(this.#e,d.historyWindow,this.#o),this.#f&&(this.#h=Math.floor(this.#u()/this.#f.bucketMs))}get colId(){return this.#e}get forgotten(){return this.#l}get size(){return this.#n.size}get historyWindow(){return this.#f}observe(d,o){const b=t(o);if(b===null)return;if(!this.#n.has(d)){this.#p=null,this.#m=null,this.#g(),this.#t.set(d,b),this.#n.set(d,b),this.#r.set(d,0),this.#i.set(d,this.#u()),this.#s.set(d,[b]),this.#f&&this.#d.set(d,[b]),this.#a.set(d,0);return}const l=this.#n.get(d);if(l===b)return;this.#p=null,this.#m=null,this.#n.set(d,b),this.#r.set(d,(this.#r.get(d)||0)+1),this.#i.set(d,this.#u());const p=this.#s.get(d)||[];p.push(b),p.length>this.#o&&p.splice(0,p.length-this.#o),this.#s.set(d,p);const w=Math.sign(b-l),v=this.#a.get(d)||0;this.#a.set(d,Math.sign(v)===w?v+w:w)}#g(){if(this.#n.size<this.#c)return;const d=this.#n.keys().next().value;d!==void 0&&(this.#t.delete(d),this.#n.delete(d),this.#r.delete(d),this.#i.delete(d),this.#s.delete(d),this.#d.delete(d),this.#a.delete(d),this.#l++)}rebase(){for(const[d,o]of this.#n)this.#t.set(d,o);this.#p=null,this.#m=null}reset(){this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#i.clear(),this.#s.clear(),this.#d.clear(),this.#a.clear(),this.#l=0,this.#p=null,this.#m=null,this.#f&&(this.#h=Math.floor(this.#u()/this.#f.bucketMs))}retain(d){const o=d instanceof Set?d:new Set(d);let b=0;for(const l of[...this.#n.keys()])o.has(l)||(this.#t.delete(l),this.#n.delete(l),this.#r.delete(l),this.#i.delete(l),this.#s.delete(l),this.#d.delete(l),this.#a.delete(l),b++);return b&&(this.#p=null,this.#m=null),b}advanceHistoryWindow(d=this.#u()){const o=this.#f;if(!o)return 0;const b=Math.floor(d/o.bucketMs),l=b-this.#h;if(!(l>0))return 0;const p=Math.min(l,this.#o);for(const[w,v]of this.#d){const R=this.#n.get(w);for(let Y=0;Y<p;Y++)v.push(R);v.length>this.#o&&v.splice(0,v.length-this.#o)}return this.#h=b,l}read(d,o,b,l){switch(d){case"updates":return this.#r.has(o)?this.#r.get(o):0;case"updatedAt":{const p=this.#i.get(o);return p===void 0?null:new Date(p)}case"sinceUpdate":{const p=this.#i.get(o);return p===void 0?null:this.#u()-p}case"firstValue":return this.#t.has(o)?this.#t.get(o):null;case"delta":return this.#n.has(o)?this.#n.get(o)-this.#t.get(o):null;case"deltaPercent":{if(!this.#n.has(o))return null;const p=this.#t.get(o);return p?(this.#n.get(o)-p)/Math.abs(p)*100:null}case"rate":{const p=this.#s.get(o),w=this.#i.get(o);if(!p||p.length<2||w===void 0)return null;const v=this.#u()-w,R=p[p.length-1]-p[p.length-2];return v>0?R/v*1e3:R}case"history":return this.#f?this.#d.has(o)?[...this.#d.get(o)]:null:this.#s.has(o)?[...this.#s.get(o)]:null;case"streak":return this.#a.has(o)?this.#a.get(o):0;case"specStatus":return this.#n.has(o)?r(this.#n.get(o),l):null;default:return g.includes(d)?this.#O(d,o,b,l):null}}#b(d){if(d){if(this.#m&&this.#m.only===d)return this.#m.view;const o=this.#y(d);return this.#m={only:d,view:o},o}return this.#p?this.#p:(this.#p=this.#y(null),this.#p)}#y(d){const o=[];for(const[E,O]of this.#n)d&&!d.has(E)||o.push(O);const b=o.sort((E,O)=>E-O);let l=0,p=0,w=0,v=0;for(const E of b){v+=E,l++;const O=E-p;p+=O/l,w+=O*(E-p)}const R=[];for(const[E,O]of this.#t)d&&!d.has(E)||R.push(O);const Y=l?u(b):0,K=b.map(E=>Math.abs(E-Y)).sort((E,O)=>E-O),V=l?u(K):0;return{sorted:b,baseline:R.sort((E,O)=>E-O),sum:v,mean:l?p:0,sd:l>1?Math.sqrt(w/(l-1)):0,median:Y,mad:V}}#O(d,o,b,l){if(!this.#n.has(o)||b&&!b.has(o))return null;const p=this.#n.get(o),w=this.#b(b),v=w.sorted.length;if(!v)return null;switch(d){case"rank":return v-m(w.sorted,p)+1;case"rankAsc":return n(w.sorted,p)+1;case"rankChange":{if(!this.#t.has(o)||!w.baseline.length)return null;const R=w.baseline.length-m(w.baseline,this.#t.get(o))+1,Y=v-m(w.sorted,p)+1;return R-Y}case"percentile":return m(w.sorted,p)/v*100;case"quartile":{const R=m(w.sorted,p)/v;return Math.min(4,Math.max(1,Math.ceil(R*4)))}case"zScore":return w.sd?(p-w.mean)/w.sd:null;case"anomalyScore":return w.mad?k*(p-w.median)/w.mad:null;case"anomalyFlag":{if(!w.mad)return null;const R=l&&Number.isFinite(Number(l.threshold))?Number(l.threshold):y;return Math.abs(k*(p-w.median)/w.mad)>R}case"shareOfTotal":return w.sum?p/w.sum*100:null;default:return null}}}function u(h){const d=h.length;if(!d)return 0;const o=(d-1)*.5,b=Math.floor(o),l=Math.ceil(o);return b===l?h[b]:h[b]+(o-b)*(h[l]-h[b])}function n(h,d){let o=0,b=h.length;for(;o<b;){const l=o+b>>1;h[l]<d?o=l+1:b=l}return o}function m(h,d){let o=0,b=h.length;for(;o<b;){const l=o+b>>1;h[l]<=d?o=l+1:b=l}return o}function t(h){if(h==null||h==="")return null;if(h instanceof Date){const o=h.getTime();return Number.isFinite(o)?o:null}const d=typeof h=="number"?h:Number(h);return Number.isFinite(d)?d:null}function s(h){const d=[];for(const o of h||[]){const b=o.shadow;if(!b)continue;const l=typeof b=="string"?{kind:b}:b,p=l.kind;L.includes(p)&&(X.includes(p)||$.includes(p)||A.includes(p)||d.push({colId:o.id||o.field,of:l.of||o.field||o.id,kind:p,depth:l.depth,historyWindow:p==="history"?l.window:void 0}))}return d}}),Ue("packages/core/src/columns/model.js",function(e,B){"use strict";Object.defineProperty(e,"BUILTIN_DEFAULTS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"normaliseAlign",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"normaliseVAlign",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"expandColumn",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return le}}),Object.defineProperty(e,"flattenTree",{enumerable:!0,get:function(){return ke}});const re=B("packages/core/src/internal/merge.js"),T=re.expand,G=re.merge,D=re.toArray,I=B("packages/core/src/internal/warn.js"),Z=I.fail,z=I.warnOnce,L=B("packages/core/src/internal/paths.js"),X=L.getPath,$=L.pathGetter,A=L.pathSetter,y=B("packages/core/src/internal/text.js").humanise,f=B("packages/core/src/internal/predicates.js"),g=f.isFunction,a=f.isObject,i=B("packages/core/src/internal/uid.js").uid,u=B("packages/core/src/format/index.js").compileFormat,n=B("packages/core/src/columns/datatypes.js"),m=n.comparatorFor,t=n.createTypeRegistry,s=n.storageKind,h=B("packages/core/src/columns/infer.js"),d=h.inferColumnType,o=h.DEFAULT_SAMPLE,b=B("packages/core/src/columns/graph.js"),l=b.buildGraph,p=b.affectedBy,v=B("packages/core/src/columns/lookup.js").createLookup,R=B("packages/core/src/columns/value.js"),Y=R.compileDisplay,K=R.ValuePipeline,V=R.warnImpureUse,E=B("packages/core/src/model/shadow.js"),O=E.FIT_SHADOW_KINDS,C=E.CLUSTER_SHADOW_KINDS,S=Object.freeze({geometry:"geometry",list:"list"}),F={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},P={centre:"center"},M=new Set(["start","center","end","left","right"]);function x(ce){if(typeof ce!="string")return;const ae=ce.toLowerCase();return P[ae]?P[ae]:M.has(ae)?ae:void 0}function U(ce){if(typeof ce!="string")return;const ae=ce.toLowerCase();return ae==="center"||ae==="centre"?"middle":ae==="top"||ae==="middle"||ae==="bottom"?ae:void 0}const _=["cell","layout","header"];function W(ce){if(!a(ce))return{};const ae={...ce},ge=(de,me)=>{if(ce[de]===void 0)return;const ve=T(ce[de],me);ve&&_.includes(de)&&!a(ce[de])&&delete ve.enabled,ae[de]=ve};return ge("sort","direction"),ge("filter","type"),ge("cell","render"),ge("edit","editor"),ge("layout","width"),ge("group","index"),ge("pivot","index"),ge("header","render"),ge("facet","strategy"),ae}function q(ce,ae){const ge={...ce||{}},de=a(ae)&&a(ae.layout)&&ae.layout.width!==void 0;return ge.fit==="content"&&!de&&delete ge.width,ge}const N=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"]),Q=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function J(ce,ae,ge,de){const me=ge==="columnGroup"?"column group":"column";for(const ve of Object.keys(ce))if(!ae.has(ve)){if(ve==="timeZone"&&ge==="column"){z("column.timeZone",`\`timeZone\` is not a column option, so it had no effect on column "${de}". A date column stores, displays, sorts and filters in the grid-level \`timeZone\` (else the viewer's); set \`timeZone\` on the grid, not the column.`);continue}z(`${ge}.unknown:${ve}`,`'${ve}' is not a configuration key this grid recognises, so it had no effect on ${me} "${de}". Check the spelling against the reference.`)}}function ee(ce){a(ce.cell)&&ce.cell.autoHeight!==void 0&&z("column.cell.autoHeight",`\`cell.autoHeight\` is not a column option, so it had no effect on column "${ce.id||ce.field||"(unnamed)"}". Rows grow to fit with the grid-level \`autoHeight\`; \`cell.wrap\` lets this column's text wrap.`)}function ne(ce,ae){const ge=ae&&g(ce.defaultsFor)?ce.defaultsFor(ae):null,de={...ce.defaults||{},...a(ge)?ge:{}},me={};return de.align&&(me.align=de.align,me.cell={align:de.align},me.header={align:de.align}),de.filter&&(me.filter=de.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:de.filter}),de.editor&&(me.edit=de.editor==="none"?{editor:null}:{editor:de.editor}),de.total&&(me.total=de.total),de.render&&(me.cell={...me.cell||{},render:de.render}),ce.export&&(me.export={...ce.export}),me}function se(ce){if(typeof ce=="string")return ce.trim()?[ce.trim()]:[];if(!Array.isArray(ce))return[];const ae=[];for(const ge of ce){if(typeof ge!="string")continue;const de=ge.trim();de&&!ae.includes(de)&&ae.push(de)}return ae}class le{#e=new Map;#t=[];#n=[];#r=new WeakMap;#i;#s;#a;#l;#o;#c;#u(ae,ge,de){if(ae&&typeof ae=="object"&&!g(ae)){const Ee=ae;return(typeof Ee.fn!="string"||!Ee.fn)&&Z(`column "${de}": a total given as an object needs a \`fn\` name, such as { fn: 'percentile', p: 0.9 }.`),Ee.fn==="percentile"&&!(typeof Ee.p=="number"&&Ee.p>=0&&Ee.p<=1)&&Z(`column "${de}": { fn: 'percentile' } needs \`p\`, a number from 0 to 1 (0.9 for the 90th percentile).`),this.#f(Ee.fn,ge,de),Object.freeze({...Ee})}const me=this.#f(ae,ge,de);if(typeof me!="string"||!this.#d)return me??null;const ve=ge&&ge.totals&&ge.totals.implement;if(ve&&g(ve[me])){const Ee=ve[me];return Ee.totalName=me,Ee}const xe=this.#d.totalFn?.(me);return g(xe)?xe:me}#f(ae,ge,de){if(typeof ae!="string")return ae;const me=ge&&ge.totals&&ge.totals.supported;if(!Array.isArray(me)||me.includes(ae))return ae;const ve=me.length?me.join(", "):"none";return Z(`column "${de}" is typed ${ge.name||"a type"}, for which the total "${ae}" is not meaningful. Supported: ${ve}. Aggregating it anyway would produce a confident wrong number.`),ae}#d;#h;#p;#m;#g;#b;#y=!1;#O;#w;constructor(ae={}){this.#s=W(ae.columnDefaults||{}),this.#a=ae.columnPresets||{},this.#o=ae.locale,this.#l=ae.timeZone,this.#c=U(ae.verticalAlign),this.#d=ae.registry||null,this.#h=ae.grid||null,this.#p=ae.context,this.#O=ae.sampleSize??o,this.#w=ae.onChange||null,this.#b=g(ae.rowKey)?ae.rowKey:void 0,this.#i=t(ae.dataTypes,this.#d);const{leaves:ge,groups:de}=ke(ae.columns||[]);this.#n=de;for(const me of ge){me.facet!==void 0&&this.#r.set(me.def,me.facet);const ve=this.#A(me.def,null);if(ve.groupPath=me.path,this.#e.has(ve.id)){z(`columns.duplicate:${ve.id}`,`two columns resolve to the id '${ve.id}', so the second is ignored. An id defaults to the column's field, so declare an explicit \`id\` when two columns read the same field.`);continue}me.column=ve,this.#e.set(ve.id,ve),this.#t.push(ve.id)}this.#C(ae.stored||null)}#A(ae,ge){J(ae,N,"column",ae.id||ae.field||"(unnamed)"),ee(ae);const de=W(ae),me=D(ae.preset),ve=me.map(Te=>{const Be=this.#a[Te];return Be?W(Be):(z(`preset:${Te}`,`unknown column preset "${Te}"; ignoring`),{})}),xe=this.#S(de,ve,ge),Ee=this.#i.get(xe)||this.#i.get("text");if(!this.#i.has(xe)&&ae.type){const Te=S[xe];z(`type:${xe}`,`unknown data type "${xe}"; falling back to "text"`+(Te?`. It is registered by importing '@toclocoinc/lattice-grid/modules/${Te}'.`:""))}const Le=g(Ee.items)?this.#P(de,ve,ae.id||ae.field||"(unnamed)"):null;let He=F;He=G(He,this.#s),ae.type!==!1&&(He=G(He,ne(Ee,Le)));for(const Te of ve)He=G(He,Te);this.#r.has(ae)&&(He=G(He,W({facet:this.#r.get(ae)}))),He=G(He,de);const Me=He.edit;Me&&Me.editor&&Me.enabled!==!0&&!g(Me.enabled)&&(ae.edit||{}).editor&&z(`column.editor-not-enabled:${ae.id||ae.field}`,`column '${ae.id||ae.field}' names the editor '${Me.editor}' but does not enable editing, so it stays read-only. Add \`enabled: true\`, or use \`edit: true\` and set \`editor\` alongside it.`);const Ke=ae.id||ae.field||i("col");if(ae.shadow&&!g(He.value&&He.value.compute)){const Te=typeof ae.shadow=="string"?{kind:ae.shadow}:ae.shadow,Be=Te.of||ae.field||Ke,Ge=O.includes(Te.kind),et=C.includes(Te.kind),Je=Ge?Te.model||Te:null,ft=Ge&&Je?[...Array.isArray(Je.predictors)?Je.predictors:[],Je.response].filter(Boolean):null,Et=et?(Array.isArray(Te.columns)?Te.columns:[]).filter(Boolean):null;He.value={...He.value||{},deps:Et&&Et.length?Et:ft&&ft.length?ft:Te.orderBy&&Te.orderBy!==Be?[Be,Te.orderBy]:[Be],pure:!1,compute:(Mt,rt)=>{const ot=rt.grid&&rt.grid.statistics;if(!ot)return null;const ut=rt.row&&rt.row.key||ot.keyOf(rt.data);if(!ut)return null;if(Ge){if(!g(ot.fitShadow))return null;const Tt=Te.model?{...Te.model,threshold:Te.threshold}:Te;return ot.fitShadow(Te.kind,ut,Tt)}return et?g(ot.clusterShadow)?ot.clusterShadow(Te.kind,ut,Te):null:ot.shadow(Be,Te.kind,ut,Te.scope,Te)}}}if(ae.running&&!g(He.value&&He.value.compute)){const Te=typeof ae.running=="string"?{kind:ae.running}:ae.running,Be=Te.of||ae.field||Ke;He.value={...He.value||{},deps:[Be],pure:!1,compute:(Ge,et)=>{const Je=et.grid&&et.grid.statistics;if(!Je||!g(Je.running))return null;const ft=et.row&&et.row.key||Je.keyOf(et.data);return ft?Je.running(Be,Te.kind||"total",ft):null}},ae.sort===void 0&&(He.sort={...He.sort||{},enabled:!1})}const $e=ae.field??(g(He.value&&He.value.compute)?null:ae.id??null),Oe=g(He.value&&He.value.compute),Se={id:Ke,field:$e,shadow:ae.shadow||null,running:ae.running||null,spec:ae.spec||null,validation:ae.validation||null,volatile:!!(ae.shadow||ae.running),title:He.title??y($e||Ke),type:Ee.name,dataType:Ee,itemType:Le,nullable:He.nullable!==!1,align:x(de.cell&&de.cell.align||de.align||He.cell&&He.cell.align||He.align||Ee.defaults&&Ee.defaults.align)||"start",verticalAlign:U(de.cell&&de.cell.verticalAlign||de.verticalAlign||He.cell&&He.cell.verticalAlign||He.verticalAlign)||this.#c,rowSpan:g(He.rowSpan)?He.rowSpan:null,colSpan:g(He.colSpan)?He.colSpan:null,value:{pure:!0,...He.value||{}},cell:{...He.cell||{}},edit:{...He.edit||{}},sort:{...He.sort||{}},filter:{...He.filter||{}},group:{enabled:!1,index:-1,explode:!1,...He.group||{}},pivot:{enabled:!1,index:-1,...He.pivot||{}},total:this.#u(He.total,Ee,ae.id||ae.field||"(unnamed)"),groupTotal:He.groupTotal===void 0?null:this.#u(He.groupTotal,Ee,ae.id||ae.field||"(unnamed)"),grandTotal:He.grandTotal===void 0?null:this.#u(He.grandTotal,Ee,ae.id||ae.field||"(unnamed)"),tags:se(He.tags),typeOptions:He.typeOptions??null,...a(He[xe])?{[xe]:He[xe]}:{},layout:q(He.layout,de),header:{...He.header||{}},contextMenu:He.contextMenu===void 0?null:He.contextMenu,facet:{...He.facet||{}},export:{...He.export||{}},allowGroup:He.allowGroup!==!1,allowPivot:He.allowPivot!==!1,allowTotal:He.allowTotal!==!1,quickFilter:He.quickFilter!==!1,def:ae,format:He.format,presets:me,inferred:ge!=null&&!ae.type,computed:Oe,diff:ae.diff===void 0?void 0:!!ae.diff,read:$e?$($e):null,write:$e?A($e):null};Se.cell.align=x(de.cell&&de.cell.align)||Se.align,Se.header.align=x(de.header&&de.header.align)||Se.align;const Pe=He.lookup||null;return Se.lookup=Pe?v({id:Ke,lookup:Pe},{locale:this.#o,onChange:()=>{this.#w&&this.#w("lookup",{colId:Ke})}}):null,Se.group.explode&&Se.lookup&&Se.lookup.multiple&&z(`explode:${Ke}`,`column "${Ke}" has \`group.explode\`, so rows appear under each of their values and totals double-count. Group footers should be annotated accordingly.`),this.#v(Se),Se}#v(ae){ae.formatter=u(ae.format,ae.dataType,this.#o,this.#l,ae.id),ae.formatValue=Y(ae,{locale:this.#o,grid:this.#h,context:this.#p}),ae.itemCompare=ae.itemType?m(ae.itemType,this.#o):null,ae.compare=g(ae.value.compare)?ae.value.compare:ae.lookup?ae.lookup.comparator():g(ae.dataType.compareFor)?ae.dataType.compareFor(ae):m(ae.dataType,this.#o),ae.excel=ae.formatter&&ae.formatter.ooxml||ae.dataType&&ae.dataType.excel||"General",ae.storeKind=s(ae.dataType,!!(ae.lookup&&ae.lookup.multiple))}#P(ae,ge,de){let me=a(ae.typeOptions)?ae.typeOptions:null;for(let Le=ge.length-1;!me&&Le>=0;Le--)a(ge[Le].typeOptions)&&(me=ge[Le].typeOptions);!me&&a(this.#s.typeOptions)&&(me=this.#s.typeOptions);const ve=me&&me.of!==void 0?me.of:"text",xe=typeof ve=="string"?this.#i.get(ve):void 0;return xe&&!g(xe.items)&&xe.storage!=="object"?xe:(z(`type:of:${String(ve)}`,`column "${de}" names "${String(ve)}" as its item type (typeOptions.of), which is not ${xe?"a scalar data type":"a known data type"}; its items are read as text.`),this.#i.get("text"))}#S(ae,ge,de){if(ae.type===!1)return"text";if(ae.type)return ae.type;for(let me=ge.length-1;me>=0;me--)if(ge[me].type)return ge[me].type;if(this.#s.type)return this.#s.type;if(ae.shadow){const me=typeof ae.shadow=="string"?ae.shadow:ae.shadow.kind;if(me==="fitInfluence")return"boolean";if(me==="fitPredicted"||me==="fitResidual"||me==="fitStdResidual"||me==="fitLeverage"||me==="fitCooksD"||me==="tsTrend"||me==="tsSeasonal"||me==="tsResidual"||me==="tsCoverage"||me==="tsSmoothed"||me==="tsSmoothingAlpha"||me==="tsSmoothingBeta"||me==="cluster"||me==="clusterDistance")return"number"}return de||(ae.lookup?"lookup":"text")}#C(ae){const ge=this.all();this.#m=l(ge),this.#g?this.#g.setGraph(this.#m):this.#g=new K({columns:this.#e,graph:this.#m,grid:this.#h,context:this.#p,stored:ae||null,rowKey:this.#b});const de=this.#g;for(const me of ge)me.getValue=(ve,xe)=>de.value(me,ve,xe)}all(){return this.#t.map(ae=>this.#e.get(ae))}visible(){return this.all().filter(ae=>!ae.layout.hidden)}get(ae){return this.#e.get(ae)}groups(){const ae=ge=>{const de=[];for(const me of ge)Array.isArray(me.columns)?de.push({...me,columns:ae(me.columns)}):me.column&&de.push(me.column);return de};return ae(this.#n)}graph(){return this.#m}pipeline(){return this.#g}types(){return this.#i}affectedBy(ae){return p(this.#m,ae)}value(ae,ge,de){return this.#g.value(ae,ge,de)}text(ae,ge,de){return this.#g.text(ae,ge,de)}checkImpure(ae,ge){V(this.#e.get(ae),ge)}setLocale(ae){this.#o=ae;for(const ge of this.all())ge.lookup&&ge.lookup.setLocale(ae),this.#v(ge);this.#w&&this.#w("locale",{locale:ae})}infer(ae){const ge={};if(this.#y||!Array.isArray(ae)||ae.length===0)return ge;this.#y=!0;let de=!1;for(const me of this.all()){const ve=me.def;if(ve.type!==void 0||!me.field||me.computed||me.lookup||this.#E(me))continue;const xe=me.read||(He=>X(He,me.field)),Ee=d(me.id,ae,xe,this.#i,{sampleSize:this.#O});if(Ee===me.type)continue;ge[me.id]=Ee;const Le=this.#A(ve,Ee);Le.groupPath=me.groupPath,Le.layout={...Le.layout,...ye(me.layout)},this.#e.set(me.id,Le),Ce(this.#n,me.id,Le),de=!0}return de&&this.#C(null),ge}redecorate(ae,ge,de={}){const me=this.#e.get(ae);if(!me){z(`redecorate:${ae}`,`columns.decorate('${ae}', …): no column with id '${ae}'.`);return}const ve=me.def||{},xe={...a(ve.cell)?ve.cell:{}};xe.decoration=ge??void 0,de&&"variant"in de&&(xe.variant=de.variant);const Ee={...ve,cell:xe};this.#r.has(ve)&&this.#r.set(Ee,this.#r.get(ve));const Le=this.#A(Ee,me.type);return Le.groupPath=me.groupPath,Le.layout={...Le.layout,...ye(me.layout)},me.lookup&&me.lookup!==Le.lookup&&g(me.lookup.destroy)&&me.lookup.destroy(),this.#e.set(ae,Le),Ce(this.#n,ae,Le),this.#C(null),this.#w&&this.#w("decorate",{colId:ae}),Le}destroy(){for(const ae of this.#e.values())ae.lookup&&g(ae.lookup.destroy)&&ae.lookup.destroy()}#E(ae){for(const ge of ae.presets){const de=this.#a[ge];if(de&&de.type)return!0}return!!this.#s.type}#T(ae){return!ae.computed&&g(ae.dataType&&ae.dataType.toStorage)}storeReader(ae){if(ae.computed)return ge=>this.#g.value(ae,ge,null);if(this.#T(ae)){const ge=ae.dataType.toStorage,de=ae.format&&typeof ae.format=="object"&&!Array.isArray(ae.format)?ae.format.locale:void 0,me={timeZone:this.#l,colId:ae.id,itemType:ae.itemType||null,locale:de||this.#o};return ve=>ge(ae.read(ve),me)}return ae.read}storeValue(ae,ge){if(!(!ae||ae.computed)&&g(ae.read))return this.storeReader(ae)(ge)}storeSchema(){const ae=[];for(const ge of this.all()){if(ge.computed&&ge.value.pure===!1||!ge.computed&&!ge.field)continue;const de=this.storeReader(ge);let me=null;!ge.computed&&!this.#T(ge)&&typeof ge.field=="string"&&!ge.lookup&&(me=ge.field);const ve={id:ge.id,kind:ge.storeKind,nullable:ge.nullable,read:de};me!==null&&(ve.field=me),ge.lookup&&(ve.dictionary=ge.lookup.dictionary()),ae.push(ve)}return ae}state(){return this.all().map(ae=>({id:ae.id,width:ae.layout.width,flex:ae.layout.flex||void 0,hidden:!!ae.layout.hidden,headerWrap:ae.header?.wrap===!0?!0:void 0,headerOrientation:ae.header?.orientation==="vertical"?"vertical":void 0,pin:ae.layout.pin??null,sort:ae.sort.direction??null,sortIndex:ae.sort.direction?ae.sort.order??0:null,groupIndex:ae.group.enabled?ae.group.index??0:null,pivotIndex:ae.pivot.enabled?ae.pivot.index??0:null,total:typeof ae.total=="string"?ae.total:null,groupTotal:typeof ae.groupTotal=="string"?ae.groupTotal:void 0,grandTotal:typeof ae.grandTotal=="string"?ae.grandTotal:void 0,decoration:ae.cell&&ae.cell.decoration!=null?fe(ae.cell.decoration):void 0,variant:ae.cell&&ae.cell.variant!=null?fe(ae.cell.variant):void 0}))}applyState(ae,ge={}){const de={applied:[],skipped:[]},me=Array.isArray(ae)?ae:ae&&ae.columns||[],ve=!Array.isArray(ae)&&ae&&ae.columnOrder||null;for(const Ee of me){if(!Ee||!Ee.id){de.skipped.push({key:"?",reason:"no id"});continue}let Le=this.#e.get(Ee.id);if(!Le){de.skipped.push({key:Ee.id,reason:"unknown column"});continue}if(Object.hasOwn(Ee,"decoration")||Object.hasOwn(Ee,"variant")){const He=Le.cell?Le.cell.decoration:void 0,Me=Ee.decoration??null,Ke=Object.hasOwn(Ee,"variant"),$e=Ke&&!we(Le.cell?Le.cell.variant:void 0,Ee.variant);(!we(He,Me)||$e)&&(this.redecorate(Ee.id,Me,Ke?{variant:Ee.variant??void 0}:{}),Le=this.#e.get(Ee.id)||Le)}Ee.width!=null&&(Le.layout.width=Ee.width),Ee.flex!=null&&(Le.layout.flex=Ee.flex),Ee.hidden!=null&&(Le.layout.hidden=!!Ee.hidden),Ee.headerWrap!==void 0&&(Le.header.wrap=!!Ee.headerWrap),Ee.headerOrientation!==void 0&&(Le.header.orientation=Ee.headerOrientation==="vertical"?"vertical":"horizontal"),Ee.pin!==void 0&&(Le.layout.pin=Ee.pin),Ee.sort!==void 0&&(Le.sort.direction=Ee.sort),Ee.sortIndex!=null&&(Le.sort.order=Ee.sortIndex),Ee.groupIndex!=null&&(Le.group.enabled=!0,Le.group.index=Ee.groupIndex),Ee.pivotIndex!=null&&(Le.pivot.enabled=!0,Le.pivot.index=Ee.pivotIndex),Ee.total!==void 0&&(Le.total=Ee.total),Ee.groupTotal!==void 0&&(Le.groupTotal=Ee.groupTotal),Ee.grandTotal!==void 0&&(Le.grandTotal=Ee.grandTotal),de.applied.push(Ee.id)}const xe=ve||(ge&&ge.keepOrder?[]:me.map(Ee=>Ee&&Ee.id).filter(Boolean));if(xe.length){const Ee=xe.filter(He=>this.#e.has(He)),Le=this.#t.filter(He=>!Ee.includes(He));this.#t=[...Ee,...Le]}return this.#w&&this.#w("state",de),de}move(ae,ge){this.#M(ae,ge)&&(this.#R(),this.#w&&this.#w("move",{id:ae,to:ge}))}reorder(ae){const ge={applied:[],skipped:[]},de=[];let me=0;for(const ve of Array.isArray(ae)?ae:[]){const xe=me++;this.#M(ve,xe)&&(ge.applied.push(ve),de.push({id:ve,to:xe}))}if(!de.length)return ge;if(this.#R(),this.#w)for(const ve of de)this.#w("move",ve);return ge}#M(ae,ge){const de=this.#t.indexOf(ae);if(de===-1||Math.max(0,Math.min(Number(ge)||0,this.#t.length-1))===de)return!1;const ve=this.#e.get(ae);if(ve.layout.movable===!1||ve.layout.lockPosition)return z(`move:${ae}`,`column "${ae}" is not movable; the move was ignored`),!1;const xe=this.#N(ae,ge);return xe?(z(`move.married:${xe}`,`band "${xe}" declares marryChildren, so its columns stay together; the move was ignored`),!1):(this.#t.splice(de,1),this.#t.splice(Math.max(0,Math.min(ge,this.#t.length)),0,ae),!0)}#N(ae,ge){if(!this.#n||!this.#n.length)return null;const de=this.#t.filter(Ee=>Ee!==ae),me=Math.max(0,Math.min(ge,de.length)),ve=(Ee,Le)=>{if(Array.isArray(Ee.columns)){for(const Me of Ee.columns)ve(Me,Le);return Le}const He=Ee.column?Ee.column.id:Ee.id;return He&&Le.push(He),Le},xe=Ee=>{for(const Le of Ee){if(!Array.isArray(Le.columns))continue;if(Le.marryChildren===!0){const Me=ve(Le,[]),Ke=Me.includes(ae),$e=Me.map(Oe=>de.indexOf(Oe)).filter(Oe=>Oe>=0);if($e.length){const Oe=Math.min(...$e),Se=Math.max(...$e);if(Ke?me<Oe||me>Se+1:me>Oe&&me<=Se)return Le.id}}const He=xe(Le.columns);if(He)return He}return null};return xe(this.#n)}#R(){const ae=new Map(this.#t.map((me,ve)=>[me,ve])),ge=me=>{if(!Array.isArray(me.columns)){const xe=me.column?me.column.id:me.id;return ae.has(xe)?ae.get(xe):1/0}let ve=1/0;for(const xe of me.columns)ve=Math.min(ve,ge(xe));return ve},de=me=>{me.sort((ve,xe)=>ge(ve)-ge(xe));for(const ve of me)Array.isArray(ve.columns)&&de(ve.columns)};de(this.#n)}#I(ae){const ge=de=>{for(let me=0;me<de.length;me++){const ve=de[me];if(Array.isArray(ve.columns)){const xe=ge(ve.columns);if(xe)return xe}else if(ve.column&&ve.column.id===ae)return de.splice(me,1)[0]}return null};return ge(this.#n)}#G(ae){const ge=[];for(let de=ae.length-1;de>=0;de--){const me=ae[de];Array.isArray(me.columns)&&(ge.push(...this.#G(me.columns)),me.columns.length===0&&(ge.push(me.id),ae.splice(de,1)))}return ge}#K(){const ae=(ge,de,me)=>{for(const ve of ge)Array.isArray(ve.columns)?ae(ve.columns,[...de,ve.id]):ve.column&&(ve.column.groupPath=de)};ae(this.#n,[])}#L(ae){const ge=new Set(ae),de=this.#t.filter(Ee=>ge.has(Ee));if(!de.length)return;const me=Math.min(...de.map(Ee=>this.#t.indexOf(Ee))),ve=this.#t.slice(0,me).filter(Ee=>!ge.has(Ee)),xe=this.#t.slice(me).filter(Ee=>!ge.has(Ee));this.#t=[...ve,...de,...xe]}#q(ae){const ge=[],de=me=>{if(Array.isArray(me.columns))for(const ve of me.columns)de(ve);else me.column&&ge.push(me.column.id)};return de(ae),ge}#U(ae){const ge=de=>{for(const me of de){if(!Array.isArray(me.columns))continue;if(me.id===ae)return{node:me,parent:de};const ve=ge(me.columns);if(ve)return ve}return null};return ge(this.#n)}groupColumns(ae,ge={}){const de=D(ae).filter(Le=>this.#e.has(Le));if(!de.length)return z("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const Le of de)if(this.#e.get(Le).layout.lockPosition)return z(`columns.group.locked:${Le}`,`column "${Le}" is position-locked and cannot be grouped.`),null;const me=ge.groupId?this.#U(ge.groupId):null;if(ge.groupId&&!me)return z(`columns.group.unknown:${ge.groupId}`,`no band "${ge.groupId}" to add to; nothing was grouped.`),null;let ve=null;if(!me&&ge.id!=null&&(ve=String(ge.id),this.#U(ve)||this.#e.has(ve)))return z(`columns.group.idtaken:${ve}`,`band id "${ve}" is already in use; nothing was grouped.`),null;const xe=de.map(Le=>this.#I(Le)).filter(Boolean);if(!xe.length)return null;let Ee;if(me)me.node.columns.push(...xe),Ee=me.node.id;else{const Le={id:ve||i("grp"),title:ge.title||"",collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!1,header:{},def:{},columns:xe},He=Number.isInteger(ge.at)?Math.max(0,Math.min(ge.at,this.#n.length)):this.#n.length;this.#n.splice(He,0,Le),Ee=Le.id}return this.#G(this.#n),this.#L(de),this.#K(),this.#R(),this.#w&&this.#w("columngroup",{action:"formed",groupId:Ee,ids:de}),Ee}ungroupColumn(ae){const ge=this.#e.get(ae);if(!ge){z(`columns.ungroup.unknown:${ae}`,`no column "${ae}" to ungroup.`);return}const de=ge.groupPath||[];if(!de.length)return;const me=de[de.length-1],ve=this.#U(me);if(!ve)return;const xe=this.#I(ae);if(!xe)return;const Ee=ve.parent.indexOf(ve.node);ve.parent.splice(Ee+1,0,xe);const Le=this.#G(this.#n),He=this.#q(ve.node);if(He.length){this.#L(He);const Me=Math.max(...He.map($e=>this.#t.indexOf($e))),Ke=this.#t.filter($e=>$e!==ae);Ke.splice(Me+1,0,ae),this.#t=Ke}this.#K(),this.#R(),this.#w&&this.#w("columngroup",{action:"removed",id:ae,dissolved:Le})}renameGroup(ae,ge){const de=this.#U(ae);if(!de){z(`columns.group.rename:${ae}`,`no band "${ae}" to rename.`);return}de.node.title=String(ge??""),this.#w&&this.#w("columngroup",{action:"renamed",groupId:ae,title:de.node.title})}dissolveGroup(ae){const ge=this.#U(ae);if(!ge){z(`columns.group.dissolve:${ae}`,`no band "${ae}" to dissolve.`);return}const de=ge.parent.indexOf(ge.node);ge.parent.splice(de,1,...ge.node.columns),this.#K(),this.#R(),this.#w&&this.#w("columngroup",{action:"dissolved",groupId:ae})}moveGroup(ae,ge){const de=this.#U(ae);if(!de){z(`columns.group.move:${ae}`,`no band "${ae}" to move.`);return}const me=de.parent,ve=me.indexOf(de.node);ve!==-1&&(me.splice(ve,1),me.splice(Math.max(0,Math.min(ge,me.length)),0,de.node),this.#Y(),this.#K(),this.#w&&this.#w("columngroup",{action:"moved",groupId:ae,to:ge}))}#Y(){const ae=[],ge=me=>{for(const ve of me)Array.isArray(ve.columns)?ge(ve.columns):ve.column&&ae.push(ve.column.id)};ge(this.#n);const de=new Set(ae);this.#t=[...ae,...this.#t.filter(me=>!de.has(me))]}groupTree(){const ae=de=>de.map(me=>Array.isArray(me.columns)?{id:me.id,title:me.title||"",collapsible:!!me.collapsible,openByDefault:me.openByDefault!==!1,columns:ae(me.columns)}:me.column?me.column.id:null).filter(me=>me!==null),ge=ae(this.#n);return ge.some(de=>de&&typeof de=="object")?ge:[]}applyGroupTree(ae){if(!Array.isArray(ae))return;const ge=new Set,de=ve=>{const xe=[];for(const Ee of ve)if(Ee&&typeof Ee=="object"&&Array.isArray(Ee.columns)){const Le=de(Ee.columns);if(!Le.length)continue;xe.push({id:Ee.id||i("grp"),title:Ee.title||"",collapsible:Ee.collapsible===!0,openByDefault:Ee.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Le})}else if(typeof Ee=="string"){const Le=this.#e.get(Ee);Le&&!ge.has(Ee)&&(ge.add(Ee),xe.push({column:Le,path:[]}))}return xe},me=de(ae);for(const ve of this.#t){if(ge.has(ve))continue;const xe=this.#e.get(ve);xe&&me.push({column:xe,path:[]})}this.#n=me,this.#K(),this.#R(),this.#w&&this.#w("columngroup",{action:"applied"})}show(ae){this.#z(ae,!1)}hide(ae){this.#z(ae,!0)}#z(ae,ge){const de=[];for(const me of D(ae)){const ve=this.#e.get(me);if(ve){if(ge&&ve.layout.lockVisible){z(`lockVisible:${me}`,`column "${me}" is \`layout.lockVisible\` and cannot be hidden`);continue}ve.layout.hidden!==ge&&(ve.layout.hidden=ge,de.push(me))}}de.length&&this.#w&&this.#w("visible",{ids:de,hidden:ge})}pin(ae,ge){const de=this.#e.get(ae);de&&(de.layout.pin=ge??null,this.#w&&this.#w("pin",{id:ae,side:de.layout.pin}))}pinMany(ae){const ge={};for(const[me,ve]of ae){const xe=this.#e.get(me);xe&&(xe.layout.pin=ve??null,ge[me]=xe.layout.pin)}const de=Object.keys(ge);de.length&&this.#w&&this.#w("pin",{ids:de,pins:ge})}#D(ae,ge){const de=ae.layout.min??0,me=ae.layout.max;let ve=Math.max(de,ge);return me!=null&&(ve=Math.min(me,ve)),ae.layout.width=ve,ae.layout.flex=0,ve}resize(ae,ge){const de=this.#e.get(ae);if(!de)return;if(de.layout.resizable===!1){z(`resize:${ae}`,`column "${ae}" is not resizable; the resize was ignored`);return}const me=this.#D(de,ge);this.#w&&this.#w("resize",{id:ae,width:me})}resizeMany(ae){const ge={};for(const[me,ve]of ae){const xe=this.#e.get(me);if(xe){if(xe.layout.resizable===!1){z(`resize:${me}`,`column "${me}" is not resizable; the resize was ignored`);continue}ge[me]=this.#D(xe,ve)}}const de=Object.keys(ge);de.length&&this.#w&&this.#w("resize",{ids:de,widths:ge})}}function ye(ce){const ae={};return ce.width!=null&&(ae.width=ce.width),ce.hidden!=null&&(ae.hidden=ce.hidden),ce.pin!==void 0&&(ae.pin=ce.pin),ae}function fe(ce){if(ce===null||typeof ce!="object")return ce;try{return structuredClone(ce)}catch{}try{return JSON.parse(JSON.stringify(ce))}catch{return ce}}function we(ce,ae){const ge=ce??null,de=ae??null;if(ge===de)return!0;if(ge===null||de===null)return!1;if(typeof ge!="object"||typeof de!="object")return ge===de;try{return JSON.stringify(ge)===JSON.stringify(de)}catch{return!1}}function ke(ce){const ae=[],ge=(me,ve,xe)=>{const Ee=[];for(const Le of me){if(!a(Le)){Z("a column definition must be an object");continue}if(Array.isArray(Le.columns)){J(Le,Q,"columnGroup",Le.title||Le.id||"(unnamed)");const He={id:Le.id||i("grp"),title:Le.title||"",collapsible:Le.collapsible===!0,openByDefault:Le.openByDefault!==!1,showWhen:Le.showWhen||"always",marryChildren:Le.marryChildren===!0,header:Le.header||{},def:Le,columns:[]};He.columns=ge(Le.columns,[...ve,He.id],Le.facet!==void 0?Le.facet:xe),Ee.push(He)}else{const He={def:Le,path:ve,facet:xe};ae.push(He),Ee.push(He)}}return Ee},de=ge(ce,[],void 0);return{leaves:ae,groups:de}}function Ce(ce,ae,ge){for(const de of ce){if(de.columns){if(Ce(de.columns,ae,ge))return!0;continue}if(de.column&&de.column.id===ae)return de.column=ge,!0}return!1}}),Ue("packages/core/src/columns/autogroup.js",function(e,B){"use strict";Object.defineProperty(e,"AUTO_GROUP_ID",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"createAutoGroupColumn",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"warnOnAbsurdGrouping",{enumerable:!0,get:function(){return X}});const T=B("packages/core/src/internal/warn.js").warnOnce,G="__lattice_group",D=240,I=.5;function Z($){const A=$.def&&$.def.layout;return(typeof A=="number"||A&&A.width!=null||$.def&&$.def.width!=null)&&Number.isFinite($.layout.width)?$.layout.width:null}function z($){const A=$.def&&$.def.layout;return!!(A&&A.min!=null)||$.def&&$.def.minWidth!=null}function L($){const{columns:A,groupBy:k}=$,y=k.map(c=>A.get(c)).filter(Boolean),f=y.length?y.map(c=>c.title||c.id).join(" > "):"Group",g=y.find(c=>Z(c)!=null),a=$.config&&$.config.autoGroupColumnWidth||(g?Z(g):D);let r=g&&z(g)?g.layout.min:120;g&&!z(g)&&(r=Math.min(r,a));const i=g&&g.layout.max!=null?g.layout.max:null;return{id:G,field:null,title:f,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:a,min:r,max:i,pin:$.config&&$.config.autoGroupColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(c,u){return u&&u.group?u.groupValue:null},formatValue(c,u){if(!u||!u.group)return"";if(u.grandTotal)return $.config&&$.config.grandTotalLabel||"Total";const n=y[Math.min(u.level||0,y.length-1)];return n&&typeof n.formatValue=="function"?n.formatValue(c,u):c==null?"":String(c)}}}function X($,A,k){!$.length||k<100||A<k*I||T(`grouping.cardinality:${$.join(",")}`,`grouping by ${$.join(", ")} produced ${A} 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.`)}}),Ue("packages/core/src/columns/selectcolumn.js",function(e,B){"use strict";Object.defineProperty(e,"SELECT_COLUMN_ID",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"createSelectionColumn",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return D}});const re="__lattice_select",T=44;function G(I){const Z=I.selection||{},z=I.config&&I.config.selectionColumnWidth||T;return{id:re,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:z,min:z,max:z,pin:I.config&&I.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(L,X){return X?X.selected:!1},formatValue(){return""}}}const D=G}),Ue("packages/core/src/columns/rownumbercolumn.js",function(e,B){"use strict";Object.defineProperty(e,"ROW_NUMBER_COLUMN_ID",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"createRowNumberColumn",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const T=B("packages/core/src/internal/predicates.js").isFunction,G="__lattice_rownumber",D=40,I=9,Z=22;function z($){const A=String(Math.max(1,Math.trunc(Math.abs($))||1)).length;return Math.max(D,A*I+Z)}function L($){const A=$.rowNumbers,k=A&&typeof A=="object"?A:{},y=Number.isFinite(k.start)?k.start:1,f=Number.isFinite(k.width)?k.width:z(($.maxNumber||0)+y),g=T($.rank)?$.rank:()=>null;return{id:G,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:f,min:f,max:f,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(a,r){const i=g(r);return i==null?null:i-1+y},formatValue(a){return a==null?"":String(a)}}}const X=L}),Ue("packages/core/src/model/detail.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_DETAIL_HEIGHT",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"DEFAULT_CACHE_LIMIT",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"resolveDetail",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"DetailModel",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const T=B("packages/core/src/internal/predicates.js").isFunction,D=B("packages/core/src/internal/warn.js").warnOnce,I=240,Z=10;function z($){if(!$)return null;const A=$===!0?{}:$;return A.enabled===!1?null:!T(A.rows)&&!A.render?(D("detail.rows","detail is enabled but neither `rows` nor `render` was supplied; expanding a master would show an empty region, so it stays off."),null):{render:A.render||null,config:A.config||null,rows:T(A.rows)?A.rows:null,height:A.height??I,maxHeight:A.maxHeight??null,cacheLimit:Number.isFinite(A.cacheLimit)?Math.max(0,A.cacheLimit):Z,isMaster:T(A.isMaster)?A.isMaster:null,target:A.target||null,onCreate:T(A.onCreate)?A.onCreate:null,path:typeof A.path=="string"?A.path:null}}class L{#e;#t=new Set;#n;#r=0;constructor(A){this.#e=A.config,this.#n=T(A.onChange)?A.onChange:()=>{}}get config(){return this.#e}get inline(){return!this.#e.target}isMaster(A){if(!A||A.group||A.detail)return!1;const k=this.#e.isMaster;return k?!!k(A.data,A):!0}isOpen(A){return this.#t.has(A)}keys(){return[...this.#t]}activeKey(){for(const A of this.#t)return A;return null}heightOf(A){const k=this.#e.height;return T(k)?Number(k(A))||I:k==="auto"?I:Number(k)||I}open(A){return this.#t.has(A)?!1:(this.inline||this.#t.clear(),this.#t.add(A),this.#i(),!0)}close(A){return this.#t.delete(A)?(this.#i(),!0):!1}toggle(A){return this.#t.has(A)?(this.close(A),!1):(this.open(A),!0)}closeAll(){this.#t.size&&(this.#t.clear(),this.#i())}prune(A){if(!this.#t.size||!T(A))return;let k=!1;for(const y of[...this.#t])A(y)||(this.#t.delete(y),k=!0);k&&this.#i()}signature(){return`${this.#r}`}set(A){this.#t.clear();const k=Array.isArray(A)?A:[];for(const y of this.inline?k:k.slice(0,1))this.#t.add(y);this.#i()}#i(){this.#r++,this.#n()}}const X=L}),Ue("packages/core/src/compute/special.js",function(e,B){"use strict";Object.defineProperty(e,"logGamma",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"incompleteBeta",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"normalQuantile",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"normalCdf",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"studentT",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"studentTQuantile",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"regularizedGammaP",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"chiSquareUpperTail",{enumerable:!0,get:function(){return a}});const re=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),T=3e-12,G=1e-300;function D(r){if(r<.5)return Math.log(Math.PI/Math.sin(Math.PI*r))-D(1-r);const i=r-1;let c=.9999999999998099;const u=i+7.5;for(let n=0;n<re.length;n++)c+=re[n]/(i+n+1);return .5*Math.log(2*Math.PI)+(i+.5)*Math.log(u)-u+Math.log(c)}function I(r,i,c){const u=r+i,n=r+1,m=r-1;let t=1,s=1-u*c/n;Math.abs(s)<G&&(s=G),s=1/s;let h=s;for(let d=1;d<=300;d++){const o=2*d;let b=d*(i-d)*c/((m+o)*(r+o));s=1+b*s,Math.abs(s)<G&&(s=G),t=1+b/t,Math.abs(t)<G&&(t=G),s=1/s,h*=s*t,b=-(r+d)*(u+d)*c/((r+o)*(n+o)),s=1+b*s,Math.abs(s)<G&&(s=G),t=1+b/t,Math.abs(t)<G&&(t=G),s=1/s;const l=s*t;if(h*=l,Math.abs(l-1)<T)break}return h}function Z(r,i,c){if(!(r>0)||!(i>0)||!Number.isFinite(c))return Number.NaN;if(c<=0)return 0;if(c>=1)return 1;const u=Math.exp(D(r+i)-D(r)-D(i)+r*Math.log(c)+i*Math.log(1-c));return c<(r+1)/(r+i+2)?u*I(r,i,c)/r:1-u*I(i,r,1-c)/i}function z(r){if(!(r>0)||!(r<1))return r===0?-1/0:r===1?1/0:Number.NaN;const i=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],c=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],u=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],n=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],m=.02425;let t,s,h;r<m?(t=Math.sqrt(-2*Math.log(r)),h=(((((u[0]*t+u[1])*t+u[2])*t+u[3])*t+u[4])*t+u[5])/((((n[0]*t+n[1])*t+n[2])*t+n[3])*t+1)):r<=1-m?(t=r-.5,s=t*t,h=(((((i[0]*s+i[1])*s+i[2])*s+i[3])*s+i[4])*s+i[5])*t/(((((c[0]*s+c[1])*s+c[2])*s+c[3])*s+c[4])*s+1)):(t=Math.sqrt(-2*Math.log(1-r)),h=-(((((u[0]*t+u[1])*t+u[2])*t+u[3])*t+u[4])*t+u[5])/((((n[0]*t+n[1])*t+n[2])*t+n[3])*t+1));const o=(.5*L(-h/Math.SQRT2)-r)*Math.sqrt(2*Math.PI)*Math.exp(h*h/2);return h-o/(1+h*o/2)}function L(r){const i=Math.abs(r),c=2/(2+i),u=4*c-2,n=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let m=0,t=0,s;for(let d=n.length-1;d>0;d--)s=t,t=u*t-m+n[d],m=s;const h=c*Math.exp(-i*i+.5*(n[0]+u*t)-m);return r>=0?h:2-h}function X(r){return .5*L(-r/Math.SQRT2)}function $(r,i){if(!(i>0)||!Number.isFinite(r))return Number.NaN;const c=.5*Z(i/2,.5,i/(i+r*r));return r>0?1-c:c}function A(r,i){if(!(r>0)||!(r<1)||!(i>0))return Number.NaN;if(i>1e7)return z(r);let c=-1e4,u=1e4,n=z(r);const m=D(i/2)+D(.5)-D((i+1)/2);for(let t=0;t<60;t++){const s=$(n,i);s<r?c=n:u=n;const h=Math.exp(-((i+1)/2)*Math.log(1+n*n/i)-m)/Math.sqrt(i),d=h>0?(s-r)/h:0;if(Math.abs(d)<1e-12)break;const o=n-d;if(n=o>c&&o<u&&Number.isFinite(o)?o:(c+u)/2,u-c<1e-12)break}return n}function k(r,i){let c=r,u=1/r,n=u;for(let m=0;m<300&&(c+=1,n*=i/c,u+=n,!(Math.abs(n)<Math.abs(u)*T));m++);return u*Math.exp(-i+r*Math.log(i)-D(r))}function y(r,i){let c=i+1-r,u=1/G,n=1/c,m=n;for(let t=1;t<=300;t++){const s=-t*(t-r);c+=2,n=s*n+c,Math.abs(n)<G&&(n=G),u=c+s/u,Math.abs(u)<G&&(u=G),n=1/n;const h=n*u;if(m*=h,Math.abs(h-1)<T)break}return Math.exp(-i+r*Math.log(i)-D(r))*m}function f(r,i){return!(r>0)||!(i>=0)||!Number.isFinite(i)?Number.NaN:i===0?0:i<r+1?k(r,i):1-y(r,i)}function g(r,i){return i>0?f(i/2,r/2):Number.NaN}function a(r,i){const c=g(r,i);return Number.isNaN(c)?Number.NaN:Math.min(1,Math.max(0,1-c))}}),Ue("packages/core/src/compute/linalg.js",function(e,B){"use strict";Object.defineProperty(e,"cholesky",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"choleskySolve",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"choleskyInverse",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"normalEquations",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"matVec",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"quadForm",{enumerable:!0,get:function(){return Z}});function re(z){const L=z.length,X=Array.from({length:L},()=>new Array(L).fill(0));for(let $=0;$<L;$++)for(let A=0;A<=$;A++){let k=z[$][A];for(let y=0;y<A;y++)k-=X[$][y]*X[A][y];if($===A){if(!(k>0))return null;X[$][A]=Math.sqrt(k)}else X[$][A]=k/X[A][A]}return X}function T(z,L){const X=z.length,$=new Array(X).fill(0);for(let k=0;k<X;k++){let y=L[k];for(let f=0;f<k;f++)y-=z[k][f]*$[f];$[k]=y/z[k][k]}const A=new Array(X).fill(0);for(let k=X-1;k>=0;k--){let y=$[k];for(let f=k+1;f<X;f++)y-=z[f][k]*A[f];A[k]=y/z[k][k]}return A}function G(z){const L=z.length,X=Array.from({length:L},()=>new Array(L).fill(0));for(let $=0;$<L;$++){const A=new Array(L).fill(0);A[$]=1;const k=T(z,A);for(let y=0;y<L;y++)X[y][$]=k[y]}return X}function D(z,L,X){const $=z.length,A=$?z[0].length:0,k=Array.from({length:A},()=>new Array(A).fill(0)),y=new Array(A).fill(0);for(let f=0;f<$;f++){const g=X?X[f]:1,a=z[f];for(let r=0;r<A;r++){const i=g*a[r];y[r]+=i*L[f];for(let c=r;c<A;c++)k[r][c]+=i*a[c]}}for(let f=0;f<A;f++)for(let g=0;g<f;g++)k[f][g]=k[g][f];return{xtwx:k,xtwy:y}}function I(z,L){return z.map(X=>X.reduce(($,A,k)=>$+A*L[k],0))}function Z(z,L){let X=0;for(let $=0;$<z.length;$++){let A=0;for(let k=0;k<z.length;k++)A+=L[$][k]*z[k];X+=z[$]*A}return X}}),Ue("packages/core/src/compute/sketch.js",function(e,B){"use strict";Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});class re{#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(f){if(!Number.isFinite(f))return;this.#e++;const g=f-this.#t;this.#t+=g/this.#e,this.#n+=g*(f-this.#t)}merge(f){if(f.#e===0)return;if(this.#e===0){this.#e=f.#e,this.#t=f.#t,this.#n=f.#n;return}const g=this.#e+f.#e,a=f.#t-this.#t;this.#t+=a*(f.#e/g),this.#n+=f.#n+a*a*(this.#e*f.#e/g),this.#e=g}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 f=this.variance();return f===null?null:Math.sqrt(f)}stddevP(){const f=this.varianceP();return f===null?null:Math.sqrt(f)}}class T{#e=[];#t=0;#n;#r;constructor(f,g=Math.random){if(!(f>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(f),this.#r=g}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(f){if(!Number.isFinite(f))return;if(this.#t++,this.#e.length<this.#n){this.#e.push(f);return}const g=Math.floor(this.#r()*this.#t);g<this.#n&&(this.#e[g]=f)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let f=0;for(const g of this.#e)f+=g;return f/this.#e.length}quantile(f){const g=this.#e.length;if(!g)return null;const a=this.#e.slice().sort((u,n)=>u-n);if(g===1)return a[0];const r=(g-1)*Math.min(1,Math.max(0,f)),i=Math.floor(r),c=Math.ceil(r);return i===c?a[i]:a[i]+(r-i)*(a[c]-a[i])}}function G(y){return y^=y>>>16,y=Math.imul(y,2246822507),y^=y>>>13,y=Math.imul(y,3266489909),y^=y>>>15,y>>>0}function D(y){if(typeof y=="number"){const a=new DataView(new ArrayBuffer(8));return a.setFloat64(0,y===0?0:y),G(a.getUint32(0)^a.getUint32(4))}const f=typeof y=="string"?y:String(y);let g=2166136261;for(let a=0;a<f.length;a++)g^=f.charCodeAt(a),g=Math.imul(g,16777619);return G(g)}class I{#e;#t;#n;constructor(f=14){const g=Math.floor(f);if(g<4||g>16)throw new RangeError("HLL precision must be 4..16");this.#e=g,this.#t=1<<g,this.#n=new Uint8Array(this.#t)}static errorBoundFor(f=14){const g=1<<Math.floor(f),a=1.04/Math.sqrt(g);return Object.freeze({kind:"probabilistic",metric:"relative",value:a,statement:`distinct count within ~${(a*100).toFixed(2)}% relative standard error (m=${g} buckets)`})}errorBound(){return I.errorBoundFor(this.#e)}add(f){const g=D(f),a=g&this.#t-1,r=g>>>this.#e|1<<32-this.#e;let i=1,c=r;for(;(c&1)===0;)i++,c>>>=1;i>this.#n[a]&&(this.#n[a]=i)}count(){const f=this.#t,g=32-this.#e,a=new Float64Array(g+2);for(let c=0;c<f;c++)a[this.#n[c]]++;let r=f*L(1-a[g+1]/f);for(let c=g;c>=1;c--)r=.5*(r+a[c]);r+=f*z(a[0]/f);const i=Z*f*f/r;return Math.round(i)}}const Z=.5/Math.log(2);function z(y){if(y===1)return 1/0;let f=1,g=y,a;do y*=y,a=g,g+=y*f,f+=f;while(g!==a);return g}function L(y){if(y===0||y===1)return 0;let f=1,g=1-y,a;do y=Math.sqrt(y),a=g,f*=.5,g-=(1-y)**2*f;while(g!==a);return g/3}class X{#e=new Map;#t;#n=0;constructor(f){if(!(f>0))throw new RangeError("Space-Saving capacity must be positive");this.#t=Math.floor(f)}errorBoundFor(f){const g=f/this.#t;return Object.freeze({kind:"deterministic",metric:"absolute",value:g,statement:`each count overestimates the truth by at most N/m = ${g.toFixed(2)} (N=${f}, m=${this.#t})`})}get seen(){return this.#n}add(f){this.#n++;const g=this.#e.get(f);if(g){g.count++;return}if(this.#e.size<this.#t){this.#e.set(f,{count:1,error:0});return}let a,r=1/0;for(const[i,c]of this.#e)c.count<r&&(r=c.count,a=i);this.#e.delete(a),this.#e.set(f,{count:r+1,error:r})}top(f=this.#t){return[...this.#e.entries()].map(([a,r])=>({item:a,count:r.count,error:r.error})).sort((a,r)=>r.count-a.count).slice(0,Math.max(0,Math.floor(f)))}}class ${#e;#t=[[]];#n=0;#r;#i;constructor(f=200,g=Math.random){this.#e=Math.max(8,Math.floor(f)),this.#r=g,this.#i=2/3}static errorBoundFor(f=200){const g=1/Math.max(8,Math.floor(f));return Object.freeze({kind:"probabilistic",metric:"rank",value:g,statement:`queried quantile's true rank within ~${(g*100).toFixed(2)}% of N of the requested rank (k=${f})`})}errorBound(){return $.errorBoundFor(this.#e)}get count(){return this.#n}#s(f){const a=this.#t.length-1-f,r=Math.ceil(this.#e*this.#i**a);return Math.max(2,r)}add(f){Number.isFinite(f)&&(this.#n++,this.#t[0].push(f),this.#t[0].length>=this.#s(0)&&this.#a(0))}#a(f){const g=this.#t[f];g.sort((i,c)=>i-c),f+1>=this.#t.length&&this.#t.push([]);const a=this.#t[f+1],r=this.#r()<.5?0:1;for(let i=r;i<g.length;i+=2)a.push(g[i]);this.#t[f]=[];for(let i=0;i<this.#t.length;i++)if(this.#t[i].length>=this.#s(i)){this.#a(i);return}}#l(){const f=[];for(let g=0;g<this.#t.length;g++){const a=1<<g;for(const r of this.#t[g])f.push({v:r,w:a})}return f}quantile(f){const g=this.#l();if(!g.length)return null;g.sort((c,u)=>c.v-u.v);let a=0;for(const c of g)a+=c.w;const r=Math.min(1,Math.max(0,f))*a;let i=0;for(const c of g)if(i+=c.w,i>=r)return c.v;return g[g.length-1].v}rank(f){let g=0;for(let a=0;a<this.#t.length;a++){const r=1<<a;for(const i of this.#t[a])i<=f&&(g+=r)}return g}}const A=Object.freeze({distinct:I.errorBoundFor(14),median:$.errorBoundFor(200),p25:$.errorBoundFor(200),p75:$.errorBoundFor(200),p90:$.errorBoundFor(200),p95:$.errorBoundFor(200),p99:$.errorBoundFor(200),iqr:$.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:re,Reservoir:T,HyperLogLog:I,SpaceSaving:X,KLL:$,hash32:D,SKETCH_BOUNDS:A}}),Ue("packages/core/src/compute/statistics.js",function(e,B){"use strict";Object.defineProperty(e,"KENDALL_LIMIT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"numbers",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"frequencies",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"entropy",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"evenness",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"topShare",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"gini",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"moments",{enumerable:!0,get:function(){return p}}),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 Y}}),Object.defineProperty(e,"STAT_LABELS",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"extremeRow",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"correlation",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"trimmedMean",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"winsorizedMean",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"modifiedZOutliers",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"jarqueBera",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"covariance",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"regression",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"fitLinearModel",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"kendall",{enumerable:!0,get:function(){return de}}),Object.defineProperty(e,"seriesStats",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"D2_N2",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(e,"D4_N2",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(e,"movingRanges",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"withinSigma",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return He}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(e,"controlViolations",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(e,"countOutside",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(e,"histogram",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(e,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(e,"meanInterval",{enumerable:!0,get:function(){return et}}),Object.defineProperty(e,"proportionInterval",{enumerable:!0,get:function(){return Je}}),Object.defineProperty(e,"slopeInterval",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(e,"capabilityInterval",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(e,"standardizedMeanDifference",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(e,"normalTotalVariation",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(e,"frequencyMap",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return ut}}),Object.defineProperty(e,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(e,"compareColumn",{enumerable:!0,get:function(){return xt}}),Object.defineProperty(e,"isNumericColumn",{enumerable:!0,get:function(){return It}}),Object.defineProperty(e,"populationRead",{enumerable:!0,get:function(){return dt}});const re=B("packages/core/src/compute/handle.js"),T=re.presenceReader,G=re.valueReader,D=B("packages/core/src/compute/special.js"),I=D.studentTQuantile,Z=D.studentT,z=D.normalQuantile,L=D.normalCdf,X=D.chiSquareUpperTail,$=B("packages/core/src/compute/linalg.js"),A=$.cholesky,k=$.choleskySolve,y=$.choleskyInverse,f=$.normalEquations,g=$.quadForm,r=B("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,i=5e3,c=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"}),u=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:r.distinct}),median:Object.freeze({sketch:"KLL",bound:r.median}),p25:Object.freeze({sketch:"KLL",bound:r.p25}),p75:Object.freeze({sketch:"KLL",bound:r.p75}),p90:Object.freeze({sketch:"KLL",bound:r.p90}),p95:Object.freeze({sketch:"KLL",bound:r.p95}),p99:Object.freeze({sketch:"KLL",bound:r.p99}),iqr:Object.freeze({sketch:"KLL",bound:r.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:r.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:r.topK})});function n(ie){const pe=ie==="sum"||ie==="avg"||ie==="countValues"||ie==="min"||ie==="max"?"maintained":Object.prototype.hasOwnProperty.call(c,ie)?c[ie]:null,be=Object.prototype.hasOwnProperty.call(u,ie)?u[ie]:null;return{stat:ie,exact:pe,approximate:be}}function m(ie,pe){const be=pe.length,Ae=new Float64Array(be);let je=0;if(ie&&(ie.kind==="float64"||ie.kind==="int32")){const Ie=ie.values,We=T(ie);for(let ze=0;ze<be;ze++){const Qe=pe[ze];if(We&&We(Qe)!==1)continue;const gt=Ie[Qe];Number.isNaN(gt)||(Ae[je++]=gt)}return Ae.subarray(0,je)}const _e=G(ie);for(let Ie=0;Ie<be;Ie++){const We=_e(pe[Ie]);if(We==null||We==="")continue;const ze=typeof We=="number"?We:Number(We);Number.isFinite(ze)&&(Ae[je++]=ze)}return Ae.subarray(0,je)}function t(ie,pe){const be=new Map,Ae=G(ie);let je=0;for(let _e=0;_e<pe.length;_e++){const Ie=Ae(pe[_e]);if(Ie==null||Ie===""||typeof Ie=="number"&&Number.isNaN(Ie))continue;const We=typeof Ie=="object"?String(Ie):Ie;be.set(We,(be.get(We)||0)+1),je++}const Ne=[...be.values()].sort((_e,Ie)=>Ie-_e);return{counts:Ne,total:je,distinct:Ne.length}}function s(ie){return ie.total>0?ie.counts.map(pe=>pe/ie.total):[]}function h(ie,pe){const be=t(ie,pe);if(!be.total)return null;let Ae=0;for(const je of s(be))Ae+=je*je;return Ae}function d(ie,pe){const be=t(ie,pe);if(!be.total)return null;let Ae=0;for(const je of s(be))je>0&&(Ae-=je*Math.log2(je));return Ae}function o(ie,pe){const be=t(ie,pe);if(!be.total||be.distinct<2)return be.total?1:null;let Ae=0;for(const je of s(be))je>0&&(Ae-=je*Math.log2(je));return Ae/Math.log2(be.distinct)}function b(ie,pe,be=3){const Ae=t(ie,pe);if(!Ae.total)return null;const je=Math.max(1,Math.floor(be));let Ne=0;for(let _e=0;_e<Math.min(je,Ae.counts.length);_e++)Ne+=Ae.counts[_e];return Ne/Ae.total}function l(ie,pe){const be=m(ie,pe),Ae=be.length;if(!Ae)return null;const je=be.slice().sort();if(je[0]<0)return null;let Ne=0,_e=0;for(let Ie=0;Ie<Ae;Ie++)Ne+=je[Ie],_e+=(Ie+1)*je[Ie];return Ne===0?0:2*_e/(Ae*Ne)-(Ae+1)/Ae}function p(ie){let pe=0,be=0,Ae=0;for(let je=0;je<ie.length;je++){const Ne=ie[je];pe++;const _e=Ne-be;be+=_e/pe,Ae+=_e*(Ne-be)}return{n:pe,mean:be,m2:Ae}}function w(ie,pe){const be=ie.length;if(!be)return NaN;if(be===1)return ie[0];const Ae=(be-1)*Math.min(1,Math.max(0,pe)),je=Math.floor(Ae),Ne=Math.ceil(Ae);return je===Ne?ie[je]:ie[je]+(Ae-je)*(ie[Ne]-ie[je])}function v(ie,pe){if(!ie.length)return NaN;const be=ie.slice().sort();return w(be,pe)}function R(ie,pe){const be=G(ie);let Ae=0,je=0,Ne=0;for(let _e=0;_e<pe.length;_e++){const Ie=be(pe[_e]);if(Ie==null||Ie==="")continue;const We=String(Ie).toUpperCase();We==="PASS"?Ae++:We==="FAIL"?je++:We==="WARN"&&Ne++}return{pass:Ae+Ne,fail:je,warn:Ne,judged:Ae+Ne+je}}const Y=Object.freeze({hhi:(ie,pe)=>h(ie,pe),entropy:(ie,pe)=>d(ie,pe),evenness:(ie,pe)=>o(ie,pe),top3Share:(ie,pe)=>b(ie,pe,3),top10Share:(ie,pe)=>b(ie,pe,10),gini:(ie,pe)=>l(ie,pe),trimmedMean:(ie,pe)=>C(m(ie,pe),.1),winsorizedMean:(ie,pe)=>S(m(ie,pe),.1),robustOutliers:(ie,pe)=>F(m(ie,pe),3.5),jarqueBera:(ie,pe)=>P(m(ie,pe)),variance:(ie,pe)=>{const{n:be,m2:Ae}=p(m(ie,pe));return be>1?Ae/(be-1):null},varianceP:(ie,pe)=>{const{n:be,m2:Ae}=p(m(ie,pe));return be>0?Ae/be:null},stddev:(ie,pe)=>{const{n:be,m2:Ae}=p(m(ie,pe));return be>1?Math.sqrt(Ae/(be-1)):null},stddevP:(ie,pe)=>{const{n:be,m2:Ae}=p(m(ie,pe));return be>0?Math.sqrt(Ae/be):null},median:(ie,pe)=>{const be=m(ie,pe);return be.length?v(be,.5):null},percentile:(ie,pe,be)=>{const Ae=be?be.p:void 0;if(typeof Ae!="number"||!(Ae>=0&&Ae<=1))return null;const je=m(ie,pe);return je.length?v(je,Ae):null},p25:(ie,pe)=>{const be=m(ie,pe);return be.length?v(be,.25):null},p75:(ie,pe)=>{const be=m(ie,pe);return be.length?v(be,.75):null},p90:(ie,pe)=>{const be=m(ie,pe);return be.length?v(be,.9):null},p95:(ie,pe)=>{const be=m(ie,pe);return be.length?v(be,.95):null},p99:(ie,pe)=>{const be=m(ie,pe);return be.length?v(be,.99):null},iqr:(ie,pe)=>{const be=m(ie,pe);if(!be.length)return null;const Ae=be.slice().sort();return w(Ae,.75)-w(Ae,.25)},mad:(ie,pe)=>{const be=m(ie,pe);if(!be.length)return null;const Ae=v(be,.5),je=new Float64Array(be.length);for(let Ne=0;Ne<be.length;Ne++)je[Ne]=Math.abs(be[Ne]-Ae);return v(je,.5)},range:(ie,pe)=>{const be=m(ie,pe);if(!be.length)return null;let Ae=1/0,je=-1/0;for(let Ne=0;Ne<be.length;Ne++)be[Ne]<Ae&&(Ae=be[Ne]),be[Ne]>je&&(je=be[Ne]);return je-Ae},distinct:(ie,pe)=>{const be=G(ie),Ae=new Set;for(let je=0;je<pe.length;je++){const Ne=be(pe[je]);Ne==null||Ne===""||Ae.add(Ne instanceof Date?Ne.getTime():Ne)}return Ae.size},mode:(ie,pe)=>{const be=G(ie),Ae=new Map;for(let _e=0;_e<pe.length;_e++){const Ie=be(pe[_e]);if(Ie==null||Ie==="")continue;const We=Ie instanceof Date?Ie.getTime():Ie;Ae.set(We,(Ae.get(We)||0)+1)}let je=null,Ne=1;for(const[_e,Ie]of Ae)Ie>Ne&&(Ne=Ie,je=_e);return je},skewness:(ie,pe)=>{const be=m(ie,pe),{n:Ae,mean:je,m2:Ne}=p(be);if(Ae<3||Ne<=0)return null;const _e=Math.sqrt(Ne/(Ae-1));let Ie=0;for(let We=0;We<be.length;We++)Ie+=((be[We]-je)/_e)**3;return Ae/((Ae-1)*(Ae-2))*Ie},kurtosis:(ie,pe)=>{const be=m(ie,pe),{n:Ae,mean:je,m2:Ne}=p(be);if(Ae<4||Ne<=0)return null;const _e=Math.sqrt(Ne/(Ae-1));let Ie=0;for(let Qe=0;Qe<be.length;Qe++)Ie+=((be[Qe]-je)/_e)**4;const We=Ae*(Ae+1)/((Ae-1)*(Ae-2)*(Ae-3)),ze=3*(Ae-1)**2/((Ae-2)*(Ae-3));return We*Ie-ze},geomean:(ie,pe)=>{const be=m(ie,pe);if(!be.length)return null;let Ae=0;for(let je=0;je<be.length;je++){if(be[je]<=0)return null;Ae+=Math.log(be[je])}return Math.exp(Ae/be.length)},harmean:(ie,pe)=>{const be=m(ie,pe);if(!be.length)return null;let Ae=0;for(let je=0;je<be.length;je++){if(be[je]===0)return null;Ae+=1/be[je]}return be.length/Ae},sumSquares:(ie,pe)=>{const be=m(ie,pe);let Ae=0;for(let je=0;je<be.length;je++)Ae+=be[je]*be[je];return Ae},passRate:(ie,pe)=>{const{pass:be,judged:Ae}=R(ie,pe);return Ae?be/Ae:null},failureCount:(ie,pe)=>R(ie,pe).fail}),K=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 V(ie,pe,be){const Ae=G(ie),je=G(pe);let Ne=0,_e=0;for(let Ie=0;Ie<be.length;Ie++){const We=be[Ie],ze=Number(Ae(We)),Qe=Number(je(We));!Number.isFinite(ze)||!Number.isFinite(Qe)||(Ne+=ze*Qe,_e+=Qe)}return _e===0?null:Ne/_e}function E(ie,pe,be){const Ae=G(ie);let je=null,Ne=be?-1/0:1/0;for(let _e=0;_e<pe.length;_e++){const Ie=pe[_e],We=Number(Ae(Ie));Number.isFinite(We)&&(be?We>Ne:We<Ne)&&(Ne=We,je=Ie)}return je}function O(ie,pe,be){const Ae=G(ie),je=G(pe);let Ne=0,_e=0,Ie=0,We=0,ze=0,Qe=0;for(let ht=0;ht<be.length;ht++){const Pt=be[ht],Lt=Number(Ae(Pt)),jt=Number(je(Pt));!Number.isFinite(Lt)||!Number.isFinite(jt)||(Ne++,_e+=Lt,Ie+=jt,We+=Lt*Lt,ze+=jt*jt,Qe+=Lt*jt)}if(Ne<2)return null;const gt=Ne*Qe-_e*Ie,Ot=Math.sqrt((Ne*We-_e*_e)*(Ne*ze-Ie*Ie));if(Ot===0)return null;const bt=gt/Ot;return Math.max(-1,Math.min(1,bt))}function C(ie,pe=.1){const be=ie.length;if(!be)return null;const Ae=Array.from(ie).sort((Ie,We)=>Ie-We),je=Math.floor(be*Math.min(.49,Math.max(0,pe))),Ne=Ae.slice(je,be-je);if(!Ne.length)return w(Ae,.5);let _e=0;for(const Ie of Ne)_e+=Ie;return _e/Ne.length}function S(ie,pe=.1){const be=ie.length;if(!be)return null;const Ae=Array.from(ie).sort((We,ze)=>We-ze),je=Math.floor(be*Math.min(.49,Math.max(0,pe))),Ne=Ae[je],_e=Ae[be-1-je];let Ie=0;for(const We of Ae)Ie+=Math.min(_e,Math.max(Ne,We));return Ie/be}function F(ie,pe=3.5){if(!ie.length)return null;const Ae=Array.from(ie).sort((We,ze)=>We-ze),je=w(Ae,.5),Ne=Ae.map(We=>Math.abs(We-je)).sort((We,ze)=>We-ze),_e=w(Ne,.5);if(_e===0)return null;let Ie=0;for(const We of Ae)Math.abs(.6745*(We-je)/_e)>pe&&Ie++;return Ie}function P(ie){const pe=ie.length;if(pe<8)return null;let be=0;for(const We of ie)be+=We;be/=pe;let Ae=0,je=0,Ne=0;for(const We of ie){const ze=We-be;Ae+=ze*ze,je+=ze*ze*ze,Ne+=ze*ze*ze*ze}if(Ae/=pe,je/=pe,Ne/=pe,Ae===0)return null;const _e=je/Ae**1.5,Ie=Ne/(Ae*Ae)-3;return pe/6*(_e*_e+Ie*Ie/4)}function M(ie,pe,be){const Ae=[];let je=0;for(let We=0;We<ie.length;We++){const ze=Number(ie[We]),Qe=Number(pe[We]);!Number.isFinite(ze)||!Number.isFinite(Qe)||Qe<=0||(Ae.push([ze,Qe]),je+=Qe)}if(!Ae.length||je<=0)return null;if(Ae.sort((We,ze)=>We[0]-ze[0]),Ae.length===1)return Ae[0][0];const Ne=[];let _e=0;for(const[,We]of Ae)Ne.push((_e+We/2)/je),_e+=We;const Ie=Math.max(0,Math.min(1,be));if(Ie<=Ne[0])return Ae[0][0];if(Ie>=Ne[Ne.length-1])return Ae[Ae.length-1][0];for(let We=1;We<Ne.length;We++){if(Ie>Ne[We])continue;const ze=Ne[We]-Ne[We-1],Qe=ze>0?(Ie-Ne[We-1])/ze:0;return Ae[We-1][0]+(Ae[We][0]-Ae[We-1][0])*Qe}return Ae[Ae.length-1][0]}function x(ie,pe,be){const Ae=G(ie),je=G(pe),Ne=new Float64Array(be.length),_e=new Float64Array(be.length);let Ie=0;for(let We=0;We<be.length;We++){const ze=be[We],Qe=Number(Ae(ze)),gt=Number(je(ze));!Number.isFinite(Qe)||!Number.isFinite(gt)||(Ne[Ie]=Qe,_e[Ie]=gt,Ie++)}return{xs:Ne.subarray(0,Ie),ys:_e.subarray(0,Ie),n:Ie}}function U(ie,pe,be,Ae=!1){const{xs:je,ys:Ne,n:_e}=x(ie,pe,be);if(_e<2)return null;let Ie=0,We=0;for(let Qe=0;Qe<_e;Qe++)Ie+=je[Qe],We+=Ne[Qe];Ie/=_e,We/=_e;let ze=0;for(let Qe=0;Qe<_e;Qe++)ze+=(je[Qe]-Ie)*(Ne[Qe]-We);return ze/(Ae?_e:_e-1)}function _(ie,pe,be){const{xs:Ae,ys:je,n:Ne}=x(ie,pe,be);if(Ne<2)return null;let _e=0,Ie=0;for(let Lt=0;Lt<Ne;Lt++)_e+=Ae[Lt],Ie+=je[Lt];_e/=Ne,Ie/=Ne;let We=0,ze=0,Qe=0;for(let Lt=0;Lt<Ne;Lt++){const jt=Ae[Lt]-_e,Ut=je[Lt]-Ie;We+=jt*jt,ze+=jt*Ut,Qe+=Ut*Ut}if(We===0)return null;const gt=ze/We,Ot=Ie-gt*_e,bt=Qe===0?1:Math.max(0,Math.min(1,ze*ze/(We*Qe))),ht=Math.max(0,Qe-gt*ze),Pt=Ne>2?Math.sqrt(ht/(Ne-2)/We):0;return{slope:gt,intercept:Ot,r2:bt,stdError:Pt,n:Ne}}const W=new Set(["ols","wls","robust"]),q=new Set(["quantile"]),N=new Set(["ridge","lasso","elasticnet","mixed","gls"]),Q=1.345;function J(ie,pe,be){const{xtwx:Ae,xtwy:je}=f(ie,pe,be),Ne=A(Ae);if(!Ne)return null;const _e=k(Ne,je),Ie=y(Ne),We=ee(ie,_e),ze=pe.map((Qe,gt)=>Qe-We[gt]);return{beta:_e,cov:Ie,fitted:We,residuals:ze}}function ee(ie,pe){return ie.map(be=>be.reduce((Ae,je,Ne)=>Ae+je*pe[Ne],0))}function ne(ie,pe){const be=ie.length,Ae=ie.map(ze=>ze[pe]),je=ie.map(ze=>[1,...ze.filter((Qe,gt)=>gt!==pe)]),Ne=J(je,Ae,null);if(!Ne)return 1;const _e=Ae.reduce((ze,Qe)=>ze+Qe,0)/be;let Ie=0,We=0;for(let ze=0;ze<be;ze++)Ie+=Ne.residuals[ze]**2,We+=(Ae[ze]-_e)**2;return We===0?1:Math.max(0,Math.min(1,1-Ie/We))}function se(ie){const pe=[...ie].sort((je,Ne)=>je-Ne),be=le(pe),Ae=ie.map(je=>Math.abs(je-be)).sort((je,Ne)=>je-Ne);return le(Ae)/.6745}function le(ie){const pe=ie.length;if(!pe)return 0;const be=Math.floor(pe/2);return pe%2?ie[be]:(ie[be-1]+ie[be])/2}function ye(ie,pe,be={}){const Ae=be.method||"ols";if(N.has(Ae))throw new Error(`[lattice] regression method "${Ae}" is out of scope; use ols, wls or robust.`);if(q.has(Ae))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!W.has(Ae))throw new Error(`[lattice] unknown regression method "${Ae}"; use ols, wls or robust.`);const je=Array.isArray(pe)?pe.length:0,Ne=je&&Array.isArray(ie[0])?ie[0].length:0,_e=Ne+1;if(!(je>_e))return null;for(let At=0;At<je;At++){if(!Number.isFinite(pe[At])||!Array.isArray(ie[At])||ie[At].length!==Ne)return null;for(let Rt=0;Rt<Ne;Rt++)if(!Number.isFinite(ie[At][Rt]))return null}let Ie=null;if(Ae==="wls"){if(Ie=be.weights,!Array.isArray(Ie)||Ie.length!==je)return null;for(let At=0;At<je;At++)if(!(Ie[At]>0)||!Number.isFinite(Ie[At]))return null}const We=ie.map(At=>[1,...At]);let ze,Qe=null;if(Ae==="robust"){if(ze=J(We,pe,null),!ze)return null;for(let At=0;At<50;At++){const Rt=se(ze.residuals);if(!(Rt>0))break;const Gt=ze.residuals.map(_t=>{const Kt=Math.abs(_t/Rt);return Kt<=Q?1:Q/Kt}),zt=J(We,pe,Gt);if(!zt)return null;const Vt=zt.beta.reduce((_t,Kt,Bt)=>Math.max(_t,Math.abs(Kt-ze.beta[Bt])),0);if(ze=zt,Qe=Gt,Vt<1e-10)break}}else if(ze=J(We,pe,Ie),!ze)return null;const gt=Ae==="robust"?Qe:Ie,{beta:Ot,cov:bt,fitted:ht,residuals:Pt}=ze;let Lt=0,jt=0,Ut=0;for(let At=0;At<je;At++){const Rt=gt?gt[At]:1;Lt+=Rt*Pt[At]**2,jt+=Rt,Ut+=Rt*pe[At]}const rn=Ut/jt;let Wt=0;for(let At=0;At<je;At++){const Rt=gt?gt[At]:1;Wt+=Rt*(pe[At]-rn)**2}const Qt=je-_e,Xe=Lt/Qt,at=Wt===0?1:Math.max(0,Math.min(1,1-Lt/Wt)),kt=1-(1-at)*(je-1)/Qt,mt=Array.isArray(be.names)&&be.names.length===Ne?be.names:ie[0].map((At,Rt)=>`x${Rt+1}`),wt=Ge(be.confidence),Ve=Qt>0?I(1-(1-wt)/2,Qt):1/0,lt=Ot.map((At,Rt)=>{const Gt=Math.sqrt(Math.max(0,Xe*bt[Rt][Rt])),zt=Gt>0?At/Gt:At===0?0:1/0,Vt=Number.isFinite(zt)?2*(1-Z(Math.abs(zt),Qt)):0,_t=Number.isFinite(Ve)?Ve*Gt:null;return{name:Rt===0?"(intercept)":mt[Rt-1],estimate:At,stdError:Gt,t:zt,p:Math.max(0,Math.min(1,Vt)),lower:_t===null?null:At-_t,upper:_t===null?null:At+_t}}),nt=new Array(je),ct=new Array(je);for(let At=0;At<je;At++){const Rt=gt?gt[At]:1,Gt=Math.max(0,Math.min(1,Rt*g(We[At],bt)));nt[At]=Gt;const zt=(1-Gt)**2;ct[At]=zt>0&&Xe>0?Pt[At]**2/(_e*Xe)*(Gt/zt):null}const $t=ie[0].map((At,Rt)=>{if(Ne<2)return 1;const Gt=ne(ie,Rt);return Gt>=1?1/0:1/(1-Gt)});let Ft=null;{const At=Pt.map(Gt=>Gt*Gt),Rt=J(We,At,null);if(Rt){const Gt=At.reduce((Jt,cn)=>Jt+cn,0)/je;let zt=0,Vt=0;for(let Jt=0;Jt<je;Jt++)zt+=Rt.residuals[Jt]**2,Vt+=(At[Jt]-Gt)**2;const _t=Vt===0?0:Math.max(0,Math.min(1,1-zt/Vt)),Kt=je*_t,Bt=X(Kt,Ne);Ft={statistic:Kt,df:Ne,p:Bt,heteroscedastic:Bt<.05}}}let yt=null;if(Ne===1){const At=ie.map((Rt,Gt)=>Gt).sort((Rt,Gt)=>ie[Rt][0]-ie[Gt][0]);yt={confidence:wt,points:At.map(Rt=>{const Gt=We[Rt],zt=Math.sqrt(Math.max(0,Xe*g(Gt,bt)));return{x:ie[Rt][0],yhat:ht[Rt],lower:ht[Rt]-Ve*zt,upper:ht[Rt]+Ve*zt}})}}return{method:Ae,coefficients:lt,r2:at,adjR2:kt,n:je,df:Qt,sigma2:Xe,fitted:ht,residuals:Pt,leverage:nt,cooksD:ct,vif:$t,heteroscedasticity:Ft,band:yt,weights:gt?[...gt]:null}}function fe(ie){const pe=ie.length,be=Array.from({length:pe},(Ne,_e)=>_e).sort((Ne,_e)=>ie[Ne]-ie[_e]),Ae=new Float64Array(pe);let je=0;for(;je<pe;){let Ne=je;for(;Ne+1<pe&&ie[be[Ne+1]]===ie[be[je]];)Ne++;const _e=(je+Ne)/2+1;for(let Ie=je;Ie<=Ne;Ie++)Ae[be[Ie]]=_e;je=Ne+1}return Ae}const we=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function ke(ie){const pe=[.01,.05,.1],be=[we["1%"],we["5%"],we["10%"]];if(ie<=be[0]){const Ne=(Math.log(pe[1])-Math.log(pe[0]))/(be[1]-be[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(pe[0])+Ne*(ie-be[0]))))}if(ie>=be[2]){const Ne=(Math.log(pe[2])-Math.log(pe[1]))/(be[2]-be[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(pe[2])+Ne*(ie-be[2]))))}const Ae=ie<be[1]?0:1,je=(ie-be[Ae])/(be[Ae+1]-be[Ae]);return Math.exp(Math.log(pe[Ae])+je*(Math.log(pe[Ae+1])-Math.log(pe[Ae])))}function Ce(ie,pe,be,Ae){const je=be-Ae,Ne=Ae+3,_e=new Array(je),Ie=new Array(je);let We=!0,ze=Ae;for(let ht=0;ht<je;ht++){const Pt=Ae+ht,Lt=new Float64Array(Ne);Lt[0]=1,Lt[1]=ht+1,Lt[2]=ie[Pt];for(let jt=1;jt<=Ae;jt++)Lt[2+jt]=pe[Pt-jt];for(let jt=1;jt<Ne;jt++)Number.isFinite(Lt[jt])||(ze=Math.min(ze,jt-3));_e[ht]=Lt,Ie[ht]=pe[Pt],Number.isFinite(Ie[ht])||(We=!1)}if(!We)return 0;const{xtwx:Qe,xtwy:gt}=f(_e,Ie,null);let Ot=0,bt=1/0;for(let ht=0;ht<=ze;ht++){const Pt=ht+3;if(!(je>Pt))continue;const Lt=new Array(Pt);for(let at=0;at<Pt;at++)Lt[at]=Qe[at].slice(0,Pt);const jt=A(Lt);if(!jt)continue;const Ut=k(jt,gt.slice(0,Pt));let rn=0;for(let at=0;at<je;at++){const kt=_e[at];let mt=0;for(let wt=0;wt<Pt;wt++)mt+=kt[wt]*Ut[wt];rn+=(Ie[at]-mt)**2}const Qt=rn/(je-Pt)*(je-Pt);if(!(Qt>0))continue;const Xe=je*Math.log(Qt/je)+2*Pt;Xe<bt&&(bt=Xe,Ot=ht)}return Ot}function ce(ie,pe={}){const be=[];for(let bt=0;bt<ie.length;bt++){const ht=Number(ie[bt]);Number.isFinite(ht)&&be.push(ht)}const Ae=be.length,je=Ae-1;if(Ae<8||je<6)return null;const Ne=new Array(je);for(let bt=0;bt<je;bt++)Ne[bt]=be[bt+1]-be[bt];let _e=Number.isFinite(pe.maxlag)?Math.floor(pe.maxlag):Math.ceil(12*(Ae/100)**.25);_e=Math.max(0,Math.min(_e,Math.floor((je-5)/2)));const Ie=(bt,ht)=>{const Pt=[],Lt=[];for(let jt=ht;jt<je;jt++){const Ut=[jt-ht+1,be[jt]];for(let rn=1;rn<=bt;rn++)Ut.push(Ne[jt-rn]);Pt.push(Ut),Lt.push(Ne[jt])}return ye(Pt,Lt,{method:"ols"})},We=Ce(be,Ne,je,_e),ze=Ie(We,We);if(!ze||!ze.coefficients[2])return null;const Qe=ze.coefficients[2].t,gt=ke(Qe),Ot=Qe<we["5%"];return{statistic:Qe,usedLag:We,nobs:je-We,criticalValues:{...we},pValue:gt,pApproximate:!0,stationary:Ot,verdict:Ot?"stationary":"non-stationary",regression:"ct"}}function ae(ie,pe={}){const be=[];for(let Ot=0;Ot<ie.length;Ot++){const bt=Number(ie[Ot]);Number.isFinite(bt)&&be.push(bt)}const Ae=be.length;if(Ae<3)return null;let je=Number.isFinite(pe.maxlag)?Math.floor(pe.maxlag):Math.min(10,Ae-1);je=Math.max(1,Math.min(je,Ae-1));let Ne=0;for(const Ot of be)Ne+=Ot;Ne/=Ae;const _e=be.map(Ot=>Ot-Ne);let Ie=0;for(const Ot of _e)Ie+=Ot*Ot;Ie/=Ae;const We=new Array(je+1).fill(0);We[0]=1;for(let Ot=1;Ot<=je;Ot++){let bt=0;for(let ht=Ot;ht<Ae;ht++)bt+=_e[ht]*_e[ht-Ot];We[Ot]=Ie>0?bt/Ae/Ie:0}const ze=new Array(je+1).fill(0);ze[0]=1;let Qe=[];for(let Ot=1;Ot<=je;Ot++){let bt=We[Ot];for(let jt=1;jt<Ot;jt++)bt-=Qe[jt-1]*We[Ot-jt];let ht=1;for(let jt=1;jt<Ot;jt++)ht-=Qe[jt-1]*We[jt];const Pt=ht!==0?bt/ht:0,Lt=new Array(Ot);for(let jt=1;jt<Ot;jt++)Lt[jt-1]=Qe[jt-1]-Pt*Qe[Ot-1-jt];Lt[Ot-1]=Pt,ze[Ot]=Pt,Qe=Lt}const gt=1.96/Math.sqrt(Ae);return{acf:We,pacf:ze,bounds:{upper:gt,lower:-gt},n:Ae,nlags:je,approximate:!0}}function ge(ie,pe,be){const{xs:Ae,ys:je,n:Ne}=x(ie,pe,be);if(Ne<2)return null;const _e=fe(Ae),Ie=fe(je);let We=0,ze=0;for(let bt=0;bt<Ne;bt++)We+=_e[bt],ze+=Ie[bt];We/=Ne,ze/=Ne;let Qe=0,gt=0,Ot=0;for(let bt=0;bt<Ne;bt++){const ht=_e[bt]-We,Pt=Ie[bt]-ze;Qe+=ht*Pt,gt+=ht*ht,Ot+=Pt*Pt}return gt===0||Ot===0?null:Math.max(-1,Math.min(1,Qe/Math.sqrt(gt*Ot)))}function de(ie,pe,be){const{xs:Ae,ys:je,n:Ne}=x(ie,pe,be);if(Ne<2||Ne>i)return null;let _e=0,Ie=0,We=0,ze=0;for(let Ot=0;Ot<Ne;Ot++)for(let bt=Ot+1;bt<Ne;bt++){const ht=Math.sign(Ae[Ot]-Ae[bt]),Pt=Math.sign(je[Ot]-je[bt]),Lt=ht*Pt;Lt>0?_e++:Lt<0?Ie++:ht===0&&Pt===0||(ht===0?We++:ze++)}const Qe=_e+Ie+ze,gt=_e+Ie+We;return Qe===0||gt===0?null:(_e-Ie)/Math.sqrt(Qe*gt)}function me(ie,pe={}){const be=ie.length;if(be<2)return null;const Ae=ie[0],je=ie[be-1],Ne=[];for(let jt=1;jt<be;jt++){const Ut=ie[jt-1];Ut!==0&&Ne.push((ie[jt]-Ut)/Math.abs(Ut))}let _e=null;if(Ne.length>1){let jt=0;for(const rn of Ne)jt+=rn;jt/=Ne.length;let Ut=0;for(const rn of Ne)Ut+=(rn-jt)**2;_e=Math.sqrt(Ut/(Ne.length-1))}const Ie=Number(pe.periodsPerYear)>0?Number(pe.periodsPerYear):null;let We=ie[0],ze=0,Qe=0,gt=0,Ot=0;for(let jt=1;jt<be;jt++){if(ie[jt]>We){We=ie[jt],ze=jt;continue}if(We<=0)continue;const Ut=(We-ie[jt])/We;Ut>Qe&&(Qe=Ut,gt=ze,Ot=jt)}let bt=null;if(be>2){let jt=0;for(let Wt=0;Wt<be;Wt++)jt+=ie[Wt];jt/=be;let Ut=0,rn=0;for(let Wt=0;Wt<be;Wt++){const Qt=ie[Wt]-jt;rn+=Qt*Qt,Wt>0&&(Ut+=Qt*(ie[Wt-1]-jt))}bt=rn>0?Ut/rn:null}let ht=0,Pt=0;for(const jt of Ne)jt>0?ht++:jt<0&&Pt++;let Lt=null;if(Ae>0&&je>0){const jt=(je/Ae)**(1/(be-1))-1;Lt=Ie?(1+jt)**Ie-1:jt}return{n:be,first:Ae,last:je,change:je-Ae,changePercent:Ae===0?null:(je-Ae)/Math.abs(Ae)*100,volatility:_e,annualisedVolatility:_e!==null&&Ie?_e*Math.sqrt(Ie):null,growth:Lt,maxDrawdown:Qe,maxDrawdownFrom:gt,maxDrawdownTo:Ot,autocorrelation:bt,upDays:ht,downDays:Pt}}const ve=1.128,xe=3.267;function Ee(ie){const pe=ie.length;if(pe<2)return null;const be=[];for(let je=1;je<pe;je++)be.push(Math.abs(ie[je]-ie[je-1]));const Ae=be.reduce((je,Ne)=>je+Ne,0)/be.length;return{ranges:be,centre:Ae,upper:xe*Ae,lower:0}}function Le(ie){const pe=ie.length;if(pe<2)return null;let be=0;for(let je=1;je<pe;je++)be+=Math.abs(ie[je]-ie[je-1]);const Ae=be/(pe-1);return{sigma:Ae/ve,meanRange:Ae}}function He(ie,pe){const be=ie.length;if(be<2||!pe)return null;const Ae=Number.isFinite(Number(pe.lower))?Number(pe.lower):null,je=Number.isFinite(Number(pe.upper))?Number(pe.upper):null;if(Ae===null&&je===null)return null;let Ne=0;for(let ht=0;ht<be;ht++)Ne+=ie[ht];Ne/=be;let _e=0;for(let ht=0;ht<be;ht++)_e+=(ie[ht]-Ne)**2;const Ie=Math.sqrt(_e/(be-1)),We=Le(ie),ze=We?We.sigma:null,Qe=ht=>{if(!ht||ht<=0)return{index:null,k:null};const Lt=Ae!==null&&je!==null?(je-Ae)/(6*ht):null,jt=je!==null?(je-Ne)/(3*ht):1/0,Ut=Ae!==null?(Ne-Ae)/(3*ht):1/0;return{index:Lt,k:Math.min(jt,Ut)}},gt=Qe(ze),Ot=Qe(Ie);let bt=0;for(let ht=0;ht<be;ht++){if(Ae!==null&&ie[ht]<Ae){bt++;continue}je!==null&&ie[ht]>je&&bt++}return{n:be,mean:Ne,lower:Ae,upper:je,target:Number.isFinite(Number(pe.target))?Number(pe.target):null,sigmaWithin:ze,sigmaOverall:Ie,cp:gt.index,cpk:gt.k,pp:Ot.index,ppk:Ot.k,outOfSpec:bt,defectRate:be?bt/be:null}}function Me(ie){const pe=ie.length;if(pe<2)return null;const be=Le(ie);if(!be||!(be.sigma>0))return null;let Ae=0;for(let je=0;je<pe;je++)Ae+=ie[je];return Ae/=pe,{centre:Ae,sigma:be.sigma,upper:Ae+3*be.sigma,lower:Ae-3*be.sigma}}function Ke(ie,pe){if(!pe||!(pe.sigma>0))return[];const be=ie.length,{centre:Ae,sigma:je}=pe,Ne=Ie=>(ie[Ie]-Ae)/je,_e=[];for(let Ie=0;Ie<be;Ie++){if(Math.abs(Ne(Ie))>3&&_e.push({index:Ie,rule:1,description:"beyond three sigma"}),Ie>=2)for(const We of[1,-1]){let ze=0;for(let Qe=Ie-2;Qe<=Ie;Qe++)Ne(Qe)*We>2&&ze++;if(ze>=2){_e.push({index:Ie,rule:2,description:"two of three past two sigma"});break}}if(Ie>=4)for(const We of[1,-1]){let ze=0;for(let Qe=Ie-4;Qe<=Ie;Qe++)Ne(Qe)*We>1&&ze++;if(ze>=4){_e.push({index:Ie,rule:3,description:"four of five past one sigma"});break}}if(Ie>=7)for(const We of[1,-1]){let ze=!0;for(let Qe=Ie-7;Qe<=Ie;Qe++)if(Ne(Qe)*We<=0){ze=!1;break}if(ze){_e.push({index:Ie,rule:4,description:"eight in a row on one side"});break}}}return _e}function $e(ie,pe){if(!pe||!(pe.sigma>0))return[];const be=ie.length,{centre:Ae,sigma:je}=pe,Ne=We=>(ie[We]-Ae)/je,_e=(We,ze,Qe,gt)=>{for(const Ot of[1,-1]){let bt=0;for(let ht=We;ht<=ze;ht++)Ne(ht)*Ot>Qe&&bt++;if(bt>=gt)return!0}return!1},Ie=[];for(let We=0;We<be;We++){if(Math.abs(Ne(We))>3&&Ie.push({index:We,rule:1,description:"beyond three sigma"}),We>=8)for(const ze of[1,-1]){let Qe=!0;for(let gt=We-8;gt<=We;gt++)if(Ne(gt)*ze<=0){Qe=!1;break}if(Qe){Ie.push({index:We,rule:2,description:"nine in a row on one side"});break}}if(We>=5)for(const ze of[1,-1]){let Qe=!0;for(let gt=We-4;gt<=We;gt++)if((ie[gt]-ie[gt-1])*ze<=0){Qe=!1;break}if(Qe){Ie.push({index:We,rule:3,description:ze>0?"six rising":"six falling"});break}}if(We>=13){let ze=!0;for(let Qe=We-12;Qe<=We;Qe++){const gt=ie[Qe]-ie[Qe-1],Ot=ie[Qe+1<=We?Qe+1:Qe]-ie[Qe];if(Qe+1>We)break;if(gt===0||Ot===0||gt>0==Ot>0){ze=!1;break}}ze&&Ie.push({index:We,rule:4,description:"fourteen alternating"})}if(We>=2&&_e(We-2,We,2,2)&&Ie.push({index:We,rule:5,description:"two of three past two sigma"}),We>=4&&_e(We-4,We,1,4)&&Ie.push({index:We,rule:6,description:"four of five past one sigma"}),We>=14){let ze=!0;for(let Qe=We-14;Qe<=We;Qe++)if(Math.abs(Ne(Qe))>=1){ze=!1;break}ze&&Ie.push({index:We,rule:7,description:"fifteen within one sigma"})}if(We>=7){let ze=!0;for(let Qe=We-7;Qe<=We;Qe++)if(Math.abs(Ne(Qe))<=1){ze=!1;break}ze&&Ie.push({index:We,rule:8,description:"eight beyond one sigma"})}}return Ie}const Oe=Object.freeze(["westernElectric","nelson"]);function Se(ie,pe,be="westernElectric"){return String(be)==="nelson"?$e(ie,pe):Ke(ie,pe)}function Pe(ie,pe,be){let Ae=0;for(let je=0;je<ie.length;je++)(ie[je]<pe||ie[je]>be)&&Ae++;return Ae}function Te(ie,pe,be,Ae=20){const je=ie.length;if(!je)return[];const Ne=ie[0],_e=ie[je-1];if(_e===Ne)return[{from:Ne,to:_e,count:je}];const Ie=be-pe,We=1.5*Ie;let ze=Ie>0?Math.max(Ne,pe-We):Ne,Qe=Ie>0?Math.min(_e,be+We):_e;Qe>ze||(ze=Ne,Qe=_e);const gt=Ie>0?2*Ie/Math.cbrt(je):(Qe-ze)/(Math.ceil(Math.log2(je))+1),Ot=gt>0?Math.min(Ae,Math.max(1,Math.ceil((Qe-ze)/gt))):1,bt=(Qe-ze)/Ot,ht=[];for(let Pt=0;Pt<Ot;Pt++)ht.push({from:ze+Pt*bt,to:ze+(Pt+1)*bt,count:0});for(let Pt=0;Pt<je;Pt++){const Lt=Math.min(Ot-1,Math.max(0,Math.floor((ie[Pt]-ze)/bt)));ht[Lt].count++}return ht[0].from=Ne,ht[Ot-1].to=_e,ht}const Be=.95;function Ge(ie){const pe=Number(ie);return Number.isFinite(pe)&&pe>0&&pe<1?pe:Be}function et(ie,pe=Be){const be=ie.length;if(be<2)return null;let Ae=0;for(let Qe=0;Qe<be;Qe++)Ae+=ie[Qe];const je=Ae/be;let Ne=0;for(let Qe=0;Qe<be;Qe++){const gt=ie[Qe]-je;Ne+=gt*gt}const _e=Math.sqrt(Ne/(be-1)),Ie=Ge(pe),ze=I(1-(1-Ie)/2,be-1)*_e/Math.sqrt(be);return{mean:je,lower:je-ze,upper:je+ze,margin:ze,n:be,confidence:Ie}}function Je(ie,pe,be=Be){const Ae=Number(ie),je=Number(pe);if(!(je>0)||!(Ae>=0)||Ae>je)return null;const Ne=Ge(be),_e=z(1-(1-Ne)/2),Ie=Ae/je,We=_e*_e,ze=1+We/je,Qe=(Ie+We/(2*je))/ze,gt=_e/ze*Math.sqrt(Ie*(1-Ie)/je+We/(4*je*je));return{proportion:Ie,lower:Math.max(0,Qe-gt),upper:Math.min(1,Qe+gt),n:je,confidence:Ne}}function ft(ie,pe=Be){if(!ie||!(ie.n>2)||!Number.isFinite(ie.stdError))return null;const be=Ge(pe),je=I(1-(1-be)/2,ie.n-2)*ie.stdError;return{slope:ie.slope,lower:ie.slope-je,upper:ie.slope+je,margin:je,confidence:be}}function Et(ie,pe,be=Be){const Ae=Number(ie),je=Number(pe);if(!Number.isFinite(Ae)||!(je>1))return null;const Ne=Ge(be),Ie=z(1-(1-Ne)/2)*Math.sqrt(1/(9*je)+Ae*Ae/(2*(je-1)));return{index:Ae,lower:Ae-Ie,upper:Ae+Ie,margin:Ie,n:je,confidence:Ne}}function Mt(ie,pe){return!ie||!(ie.sd>0)||!Number.isFinite(pe)||!Number.isFinite(ie.mean)?null:(pe-ie.mean)/ie.sd}function rt(ie){return Number.isFinite(ie)?Math.min(1,Math.max(0,2*L(Math.abs(ie)/2)-1)):0}function ot(ie,pe){const be=new Map,Ae=G(ie);let je=0;for(let Ne=0;Ne<pe.length;Ne++){const _e=Ae(pe[Ne]);if(_e==null||_e===""||typeof _e=="number"&&Number.isNaN(_e))continue;const Ie=_e instanceof Date?_e.getTime():typeof _e=="object"?String(_e):_e;be.set(Ie,(be.get(Ie)||0)+1),je++}return{map:be,total:je}}function ut(ie,pe,be,Ae){if(!(pe>0)||!(Ae>0))return null;let je=0;const Ne=new Set(ie.keys());for(const _e of be.keys())Ne.add(_e);for(const _e of Ne){const Ie=(ie.get(_e)||0)/pe,We=(be.get(_e)||0)/Ae;je+=Math.abs(Ie-We)}return je/2}const Tt=10;function xt(ie,pe,be){if(be&&be.numeric){const Ie=m(ie,pe),{n:We,mean:ze}=p(Ie),Qe=We>0?Mt({mean:be.mean,sd:be.sd},ze):null;return{measure:"standardizedMeanDifference",magnitude:Qe,distance:Qe===null?0:rt(Qe),direction:Qe===null?0:Math.sign(Qe),subsetN:We,populationN:be.n||0,reliable:We>=Tt}}const{map:je,total:Ne}=ot(ie,pe),_e=ut(je,Ne,be.map,be.total);return{measure:"categoricalTotalVariation",magnitude:_e,distance:_e===null?0:_e,direction:0,subsetN:Ne,populationN:be.total||0,reliable:Ne>=Tt}}function It(ie,pe){if(ie&&(ie.kind==="float64"||ie.kind==="int32"))return!0;const be=G(ie);let Ae=0,je=0;for(let Ne=0;Ne<pe.length&&Ae<200;Ne++){const _e=be(pe[Ne]);if(_e==null||_e==="")continue;if(_e instanceof Date)return!1;Ae++;const Ie=typeof _e=="number"?_e:Number(_e);Number.isFinite(Ie)&&je++}return Ae===0?!1:je/Ae>=.9}function dt(ie,pe){if(It(ie,pe)){const je=m(ie,pe),{n:Ne,mean:_e,m2:Ie}=p(je);return{numeric:!0,mean:_e,sd:Ne>0?Math.sqrt(Ie/Ne):0,n:Ne}}const{map:be,total:Ae}=ot(ie,pe);return{numeric:!1,map:be,total:Ae}}}),Ue("packages/core/src/compute/total.js",function(e,B){"use strict";Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"aggregatesFor",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"aggregateAllowed",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return p}});const T=B("packages/core/src/internal/predicates.js").isFunction,D=B("packages/core/src/internal/warn.js").warnOnce,I=B("packages/core/src/compute/handle.js"),Z=I.presenceReader,z=I.valueComparator,L=I.valueReader,X=B("packages/core/src/compute/statistics.js"),$=X.STAT_FNS,A=X.STAT_LABELS;function k(w){return!!w&&(w.kind==="float64"||w.kind==="int32")}function y(w,v){const R=v.length;let Y=0;if(k(w)){const V=w.values,E=Z(w);if(!E){for(let O=0;O<R;O++){const C=V[v[O]];Number.isNaN(C)||(Y+=C)}return Y}for(let O=0;O<R;O++){const C=v[O];if(E(C)===1){const S=V[C];Number.isNaN(S)||(Y+=S)}}return Y}const K=L(w);for(let V=0;V<R;V++){const E=m(K(v[V]));E!==null&&(Y+=E)}return Y}y.kernel=!0;function f(w,v){const R=v.length;let Y=0;if(k(w)){const V=w.values,E=Z(w);if(!E){for(let O=0;O<R;O++)Number.isNaN(V[v[O]])||Y++;return Y}for(let O=0;O<R;O++){const C=v[O];E(C)===1&&!Number.isNaN(V[C])&&Y++}return Y}const K=L(w);for(let V=0;V<R;V++){const E=K(v[V]);E!=null&&!(typeof E=="number"&&Number.isNaN(E))&&Y++}return Y}f.kernel=!0;function g(w,v){return v.length}g.kernel=!0;function a(w,v){const R=f(w,v);return R===0?null:y(w,v)/R}a.kernel=!0;function r(w,v,R,Y){const K=v.length;if(k(w)){const C=w.values,S=Z(w);let F=null;if(!S){for(let P=0;P<K;P++){const M=C[v[P]];Number.isNaN(M)||(F===null||(R<0?M<F:M>F))&&(F=M)}return F}for(let P=0;P<K;P++){const M=v[P];if(S(M)===0)continue;const x=C[M];Number.isNaN(x)||(F===null||(R<0?x<F:x>F))&&(F=x)}return F}const V=L(w),E=z(Y);let O=null;for(let C=0;C<K;C++){const S=V(v[C]);S==null||typeof S=="number"&&Number.isNaN(S)||(O===null||(R<0?E(S,O)<0:E(S,O)>0))&&(O=S)}return O}function i(w,v,R){return r(w,v,-1,R&&R.locale)}i.kernel=!0;function c(w,v,R){return r(w,v,1,R&&R.locale)}c.kernel=!0;function u(w,v){return v.length===0?null:L(w)(v[0])}u.kernel=!0;function n(w,v){return v.length===0?null:L(w)(v[v.length-1])}n.kernel=!0;function m(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 t={sum:y,min:i,max:c,avg:a,count:g,first:u,last:n,countValues:f,...$},s=Object.freeze({...A,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function h(w){return w?typeof w=="string"?s[w]||w:"Total":""}const d=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function o(w){const v=w&&w.dataType&&w.dataType.totals&&w.dataType.totals.supported;if(Array.isArray(v))return v.slice();const R=d.filter(Y=>Y in t);for(const Y of Object.keys(t))R.includes(Y)||R.push(Y);return R}function b(w,v){return typeof v!="string"?!0:o(w).includes(v)}function l(w,v){const R=L(w),Y=[];for(let K=0;K<v.length;K++){const V=R(v[K]);V!=null&&Y.push(V)}return Y}function p(w,v,R,Y){const K=v||[];if(R&&typeof R=="object"&&typeof R.fn=="string"){const{fn:V,...E}=R,O=t[V];return O?O(w,K,{...Y,...E}):(D(`total:${V}`,`unknown total function "${V}"; register it in config.totalFns`),null)}if(typeof R=="string"){const V=t[R];return V?V(w,K,Y):(D(`total:${R}`,`unknown total function "${R}"; register it in config.totalFns`),null)}return T(R)?R.kernel===!0?R(w,K,Y):R(l(w,K),Y||{}):null}}),Ue("packages/core/src/compute/windowed.js",function(e,B){"use strict";Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const T=B("packages/core/src/compute/sketch.js").Welford;class G{#e;#t;#n=[];#r;#i;constructor(L,X=0,$=Date.now){if(L!=="count"&&L!=="time"&&L!=="session")throw new RangeError(`unknown window kind: ${L}`);if((L==="count"||L==="time")&&!(X>0))throw new RangeError(`a ${L} window needs a positive span`);this.#e=L,this.#t=Math.floor(X),this.#r=$,this.#i=$()}get size(){return this.#n.length}push(L,X=this.#r()){Number.isFinite(L)&&(this.#n.push({t:X,v:L}),this.#s(X))}#s(L){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const X=L-this.#t;for(;this.#n.length&&this.#n[0].t<X;)this.#n.shift()}}spec(){const L=this.#e==="session"?this.#r()-this.#i:this.#t;return{kind:this.#e,span:L,size:this.#n.length}}values(){return this.#n.map(L=>L.v)}aggregate(){const L=this.spec();if(!this.#n.length)return{over:L,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const X=new T;let $=0,A=1/0,k=-1/0;for(const{v:y}of this.#n)$+=y,y<A&&(A=y),y>k&&(k=y),X.add(y);return{over:L,count:this.#n.length,sum:$,mean:X.mean(),min:A,max:k,variance:X.variance(),stddev:X.stddev()}}reduce(L){const X=this.aggregate(),$={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(!(L in $))throw new RangeError(`unknown windowed aggregate: ${L}`);return{value:$[L],over:X.over}}}const D=Object.freeze(["count","time","session"]);function I(z,L=Date.now){const X=z.kind==="time"&&z.minutes!=null?z.minutes*6e4:z.span??0;return new G(z.kind,X,L)}const Z={Window:G,WINDOW_KINDS:D,openWindow:I}}),Ue("packages/core/src/compute/rolling.js",function(e,B){"use strict";Object.defineProperty(e,"ROLLING_WINDOW_FIELDS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"rollingWindow",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"cumulativeToDate",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"periodOverPeriod",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"QUANTILE_SPAN_CAP",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"rollingQuantile",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"seasonalDecompose",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"exponentialSmoothing",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return m}});const T=B("packages/core/src/compute/windowed.js").openWindow,D=B("packages/core/src/compute/sketch.js").KLL,I=Object.freeze({rollingSum:"sum",rollingAvg:"avg",rollingMin:"min",rollingMax:"max"});function Z(t,s,h,d){if(t.kind==="count"){const o=Math.max(1,Math.floor(t.span||0));return{coverage:Math.min(1,s/o),partial:s<o}}if(t.kind==="time"){const o=t.minutes!=null?t.minutes*6e4:t.span||0;if(!(o>0))return{coverage:1,partial:!1};const b=h-d;return{coverage:Math.min(1,b/o),partial:b<o}}return{coverage:null,partial:!1}}function z(t,s){const h=T(s),d=new Map,o=t.length?t[0].at:0;for(let b=0;b<t.length;b++){const{key:l,at:p,value:w}=t[b];Number.isFinite(w)&&h.push(w,p);const v=h.aggregate(),R=Z(s,v.count,p,o);l!=null&&d.set(String(l),{sum:v.sum,avg:v.mean,min:v.min,max:v.max,count:v.count,coverage:R.coverage,partial:R.partial})}return d}function L(t){const s=new Map;let h=0;for(const{key:d,value:o}of t)Number.isFinite(o)&&(h+=o),d!=null&&s.set(String(d),h);return s}function X(t,s=1){const h=new Map,d=Math.max(1,Math.floor(s));for(let o=0;o<t.length;o++){const{key:b,value:l}=t[o];if(b==null)continue;const p=o>=d?t[o-d].value:null,w=Number.isFinite(l)?l:null,v=Number.isFinite(p)?p:null;h.set(String(b),w!==null&&v!==null?w-v:null)}return h}const $=4096;function A(t){let s=t>>>0;return()=>{s+=1831565813;let h=s;return h=Math.imul(h^h>>>15,h|1),h^=h+Math.imul(h^h>>>7,h|61),((h^h>>>14)>>>0)/4294967296}}function k(t,s){const h=t.length;if(h===1)return t[0];const d=(h-1)*s,o=Math.floor(d),b=Math.ceil(d);return o===b?t[o]:t[o]+(d-o)*(t[b]-t[o])}function y(t,s,h={}){const d=Math.min(1,Math.max(0,h.q==null?.5:h.q)),o=Math.max(1,Math.floor(h.cap==null?$:h.cap)),b=A(h.seed==null?2654435769:h.seed),l=new Map,p=t.length?t[0].at:0;if(s.kind==="session"){const v=new D(200,b);let R=0;for(const{key:Y,value:K}of t)Number.isFinite(K)&&(v.add(K),R++),Y!=null&&l.set(String(Y),{value:R?v.quantile(d):null,approx:R>0,count:R,coverage:null,partial:!1});return l}const w=T(s);for(const{key:v,at:R,value:Y}of t){Number.isFinite(Y)&&w.push(Y,R);const K=w.values(),V=K.length;let E=null,O=!1;if(V)if(V<=o)E=k([...K].sort((S,F)=>S-F),d);else{const S=new D(200,b);for(const F of K)S.add(F);E=S.quantile(d),O=!0}const C=Z(s,V,R,p);v!=null&&l.set(String(v),{value:E,approx:O,count:V,coverage:C.coverage,partial:C.partial})}return l}function f(t,s){const h=t.length,d=new Array(h).fill(null),o=Math.floor(s/2),b=s%2===0;for(let l=0;l<h;l++){if(l-o<0||l+o>=h)continue;let p=0,w=!0;if(b)for(let v=-o;v<=o;v++){const R=t[l+v];if(!Number.isFinite(R)){w=!1;break}p+=v===-o||v===o?R*.5:R}else for(let v=-o;v<=o;v++){const R=t[l+v];if(!Number.isFinite(R)){w=!1;break}p+=R}w&&(d[l]=p/s)}return d}function g(t,s){const h=new Map,d=Math.floor(Number(s&&s.period));if(!(d>=2))return h;const o=s&&s.model==="multiplicative",b=t.length,l=t.map(O=>Number.isFinite(O.value)?O.value:null),p=f(l,d),w=new Array(b).fill(null);for(let O=0;O<b;O++){const C=p[O],S=l[O];C===null||S===null||(o?C!==0&&(w[O]=S/C):w[O]=S-C)}const v=new Array(d).fill(0),R=new Array(d).fill(0);for(let O=0;O<b;O++){if(w[O]===null)continue;const C=O%d;v[C]+=w[O],R[C]+=1}const Y=o?1:0,K=v.map((O,C)=>R[C]?O/R[C]:Y),V=K.reduce((O,C)=>O+C,0)/d,E=o?K.map(O=>V!==0?O/V:1):K.map(O=>O-V);for(let O=0;O<b;O++){const{key:C}=t[O];if(C==null)continue;const S=p[O],F=E[O%d],P=l[O];let M=null;S!==null&&P!==null&&(M=o?S*F!==0?P/(S*F):null:P-S-F),h.set(String(C),{trend:S,seasonal:P===null?null:F,residual:M,coverage:S===null?0:1,partial:S===null})}return h}function a(t,s,h,d=80){const o=(Math.sqrt(5)-1)/2;let b=s,l=h,p=l-o*(l-b),w=b+o*(l-b),v=t(p),R=t(w);for(let Y=0;Y<d;Y++)v<R?(l=w,w=p,R=v,p=l-o*(l-b),v=t(p)):(b=p,p=w,v=R,w=b+o*(l-b),R=t(w));return(b+l)/2}const r=1e-4,i=1-1e-4;function c(t,s){const h=t.length,d=new Array(h).fill(null),o=new Array(h).fill(null);let b=null,l=0;for(let p=0;p<h;p++){const w=t[p];if(!Number.isFinite(w)){b!==null&&(o[p]=b,d[p]=b);continue}if(b===null){b=w,o[p]=w,d[p]=w;continue}o[p]=b,l+=(w-b)**2,b=s*w+(1-s)*b,d[p]=b}return{smoothed:d,fitted:o,sse:l}}function u(t,s,h){const d=t.length,o=new Array(d).fill(null),b=new Array(d).fill(null);let l=null,p=null,w=0;for(let v=0;v<d;v++){const R=t[v];if(!Number.isFinite(R)){l!==null&&(l+=p,o[v]=l);continue}if(l===null){l=R,o[v]=R;continue}if(p===null){p=R-l;const V=l+p;b[v]=V,w+=(R-V)**2;const E=l;l=s*R+(1-s)*(E+p),p=h*(l-E)+(1-h)*p,o[v]=l;continue}const Y=l+p;b[v]=Y,w+=(R-Y)**2;const K=l;l=s*R+(1-s)*(K+p),p=h*(l-K)+(1-h)*p,o[v]=l}return{smoothed:o,fitted:b,sse:w}}function n(t,s={}){const h=new Map,d=s.method==="holt",o=t.map(Y=>Number.isFinite(Y.value)?Y.value:null),b=o.filter(Y=>Y!==null).length,l=Y=>Math.min(i,Math.max(r,Y)),p=()=>{for(const{key:Y}of t)Y!=null&&h.set(String(Y),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return h};if(b<(d?2:1))return p();let w=Number.isFinite(s.alpha)?l(s.alpha):null,v=d&&Number.isFinite(s.beta)?l(s.beta):null;if(d){if(w===null||v===null){let Y=w===null?.5:w,K=v===null?.5:v;for(let V=0;V<6;V++)w===null&&(Y=a(E=>u(o,E,K).sse,r,i)),v===null&&(K=a(E=>u(o,Y,E).sse,r,i));w=w===null?Y:w,v=v===null?K:v}}else w===null&&(w=a(Y=>c(o,Y).sse,r,i));const R=d?u(o,w,v):c(o,w);for(let Y=0;Y<t.length;Y++){const{key:K}=t[Y];K!=null&&h.set(String(K),{smoothed:R.smoothed[Y],fitted:R.fitted[Y],alpha:w,beta:d?v:null,sse:R.sse})}return h}const m={ROLLING_WINDOW_FIELDS:I,QUANTILE_SPAN_CAP:$,rollingWindow:z,rollingQuantile:y,cumulativeToDate:L,periodOverPeriod:X,seasonalDecompose:g,exponentialSmoothing:n}}),Ue("packages/core/src/compute/cluster.js",function(e,B){"use strict";Object.defineProperty(e,"CLUSTER_ROW_CAP",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"DBSCAN_ROW_CAP",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"DEFAULT_K",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"DEFAULT_MIN_POINTS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"orderByCentre",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"kmeans",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"dbscan",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"autoK",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"standardise",{enumerable:!0,get:function(){return r}});const re=1e5,T=2e4,G=3,D=5,I=100;function Z(i){let c=i>>>0;return function(){c=c+1831565813|0;let n=Math.imul(c^c>>>15,1|c);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}function z(i,c){let u=0;for(let n=0;n<i.length;n++){const m=i[n]-c[n];u+=m*m}return u}function L(i,c){return Math.sqrt(z(i,c))}function X(i,c){let u=-1,n=1/0;for(let m=0;m<c.length;m++){const t=z(i,c[m]);t<n&&(n=t,u=m)}return u}function $(i,c,u){const n=Z(u),m=i.length,t=[Array.from(i[Math.floor(n()*m)])],s=new Float64Array(m).fill(1/0);for(let h=1;h<c;h++){let d=0;for(let p=0;p<m;p++){const w=z(i[p],t[t.length-1]);w<s[p]&&(s[p]=w),d+=s[p]}const o=n()*(d||m);let b=0,l=m-1;for(let p=0;p<m;p++)if(b+=d?s[p]:1,b>=o){l=p;break}t.push(Array.from(i[l]))}return t}function A(i,c){for(let u=0;u<i.length;u++){const n=i[u]-c[u];if(n!==0)return n}return 0}function k(i,c,u,n){const m=c.map((s,h)=>({centre:s,i:h})).sort((s,h)=>A(s.centre,h.centre)),t=new Int32Array(c.length);for(let s=0;s<m.length;s++)t[m[s].i]=s;for(let s=0;s<i.length;s++)i[s]>=0&&(i[s]=t[i[s]]);return{assignments:i,centres:m.map(s=>s.centre),sizes:m.map(s=>u[s.i]),distances:n}}function y(i,c={}){const u=i.length,n=u?i[0].length:0,m=Math.floor(c.k||G);if(!(u>=m)||m<1||n<1)return null;let t=$(i,m,c.seed===void 0?1:c.seed);const s=new Int32Array(u);let h=!0;for(let l=0;l<I&&h;l++){h=!1;for(let v=0;v<u;v++){const R=X(i[v],t);s[v]!==R&&(s[v]=R,h=!0)}const p=t.map(()=>new Float64Array(n)),w=new Array(m).fill(0);for(let v=0;v<u;v++){const R=s[v];for(let Y=0;Y<n;Y++)p[R][Y]+=i[v][Y];w[R]++}for(let v=0;v<m;v++)if(w[v])for(let R=0;R<n;R++)t[v][R]=p[v][R]/w[v];else{let R=0,Y=-1/0;for(let K=0;K<u;K++){const V=z(i[K],t[v]);V>Y&&(Y=V,R=K)}t[v]=Array.from(i[R]),h=!0}}const d=new Array(m).fill(0),o=new Float64Array(u);let b=0;for(let l=0;l<u;l++){const p=s[l];d[p]++;const w=z(i[l],t[p]);o[l]=Math.sqrt(w),b+=w}return{assignments:s,centres:t,sizes:d,inertia:b,distances:o}}function f(i,c={}){const u=i.length,n=u?i[0].length:0,m=Number(c.eps),t=Math.max(1,Math.floor(c.minPoints||D));if(!(m>0)||u===0||n<1)return null;const s=new Array(u);for(let w=0;w<u;w++){const v=[];for(let R=0;R<u;R++)w!==R&&L(i[w],i[R])<=m&&v.push(R);s[w]=v}const h=new Int32Array(u).fill(-1);let d=0;for(let w=0;w<u;w++){if(h[w]!==-1||s[w].length<t)continue;h[w]=d;const v=[...s[w]];for(let R=0;R<v.length;R++){const Y=v[R];h[Y]===-1&&(h[Y]=d,s[Y].length>=t&&v.push(...s[Y]))}d++}if(!d)return{assignments:h,centres:[],sizes:[],distances:new Float64Array(u).fill(NaN)};const o=[],b=new Array(d).fill(0),l=Array.from({length:d},()=>new Float64Array(n));for(let w=0;w<u;w++){const v=h[w];if(!(v<0)){b[v]++;for(let R=0;R<n;R++)l[v][R]+=i[w][R]}}for(let w=0;w<d;w++){const v=new Array(n);for(let R=0;R<n;R++)v[R]=l[w][R]/b[w];o.push(v)}const p=new Float64Array(u).fill(NaN);for(let w=0;w<u;w++){const v=h[w];v>=0&&(p[w]=L(i[w],o[v]))}return{assignments:h,centres:o,sizes:b,distances:p}}function g(i,c,u){const n=i.length;if(n===0)return 0;const m=new Int32Array(u);for(let s=0;s<n;s++)m[c[s]]++;let t=0;for(let s=0;s<n;s++){const h=c[s],d=new Float64Array(u);for(let l=0;l<n;l++)s!==l&&(d[c[l]]+=L(i[s],i[l]));const o=m[h]>1?d[h]/(m[h]-1):0;let b=1/0;for(let l=0;l<u;l++){if(l===h||m[l]===0)continue;const p=d[l]/m[l];p<b&&(b=p)}b!==1/0&&(t+=(b-o)/Math.max(o,b))}return t/n}function a(i,c={}){const u=i.length;if(!u)return null;const n=c.criterion==="silhouette"?"silhouette":"elbow",m=Math.max(2,Math.floor(c.maxK||8)),t=c.seed===void 0?1:c.seed;if(n==="silhouette"){const w=[],v=[];for(let Y=2;Y<=Math.min(m,u);Y++){const K=y(i,{k:Y,seed:t});K&&(w.push(Y),v.push(g(i,K.assignments,Y)))}if(!w.length)return null;let R=0;for(let Y=1;Y<v.length;Y++)v[Y]>v[R]&&(R=Y);return{k:w[R],criterion:n,scores:v,ks:w}}const s=[],h=[];for(let w=1;w<=Math.min(m,u);w++){const v=y(i,{k:w,seed:t});v&&(s.push(w),h.push(v.inertia))}if(h.length<2)return null;const d={k:s[0],y:h[0]},o={k:s[s.length-1],y:h[h.length-1]},b=Math.hypot(o.k-d.k,o.y-d.y)||1;let l=0,p=-1/0;for(let w=0;w<h.length;w++){const v=Math.abs((o.k-d.k)*(d.y-h[w])-(d.k-s[w])*(o.y-d.y))/b;v>p&&(p=v,l=w)}return{k:s[l],criterion:n,scores:h,ks:s}}function r(i){const c=i.length,u=c?i[0].length:0;if(!c||!u)return null;const n=new Array(u).fill(0);for(let t=0;t<c;t++)for(let s=0;s<u;s++)n[s]+=i[t][s];for(let t=0;t<u;t++)n[t]/=c;const m=new Array(u).fill(0);for(let t=0;t<c;t++)for(let s=0;s<u;s++){const h=i[t][s]-n[s];m[s]+=h*h}for(let t=0;t<u;t++)m[t]=c>1?Math.sqrt(m[t]/(c-1)):0;for(let t=0;t<c;t++)for(let s=0;s<u;s++)m[s]>0?i[t][s]=(i[t][s]-n[s])/m[s]:i[t][s]=i[t][s]-n[s];return{mean:n,sd:m}}}),Ue("packages/core/src/compute/compare.js",function(e,B){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"pooledStandardMeanDifference",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"numericSummary",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"bothNumeric",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"compareColumnAcross",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"compareDatasets",{enumerable:!0,get:function(){return f}});const re=B("packages/core/src/compute/statistics.js"),T=re.numbers,G=re.moments,D=re.frequencyMap,I=re.categoricalDistance,Z=re.normalTotalVariation,z=re.isNumericColumn,L=re.SUBSET_RELIABILITY_FLOOR,X=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function $(g,a){if(!g||!a||!(g.n>0)||!(a.n>0)||!Number.isFinite(g.mean)||!Number.isFinite(a.mean))return null;const r=(g.n*g.sd*g.sd+a.n*a.sd*a.sd)/(g.n+a.n);return r>0?(g.mean-a.mean)/Math.sqrt(r):null}function A(g,a){const r=T(g,a),{n:i,mean:c,m2:u}=G(r),n=i>0?Math.sqrt(u/i):0;return{mean:c,sd:n,n:i}}function k(g,a,r,i){return z(g,a)&&z(r,i)}function y(g,a,r,i){if(k(g,a,r,i)){const m=A(g,a),t=A(r,i),s=$(m,t);return{measure:X.numeric,magnitude:s,distance:s===null?0:Z(s),direction:s===null?0:Math.sign(s),nA:m.n,nB:t.n,meanA:m.mean,meanB:t.mean,reliable:m.n>=L&&t.n>=L}}const c=D(g,a),u=D(r,i),n=I(c.map,c.total,u.map,u.total);return{measure:X.categorical,magnitude:n,distance:n===null?0:n,direction:0,nA:c.total,nB:u.total,meanA:null,meanB:null,reliable:c.total>=L&&u.total>=L}}function f(g,a,r={}){const i=new Set(g.columns),c=new Set(a.columns),u=g.columns.filter(h=>c.has(h)),n=Array.isArray(r.columns)&&r.columns.length?u.filter(h=>r.columns.includes(h)):u,m=g.indices(),t=a.indices(),s=[];for(const h of n){const d=g.handle(h),o=a.handle(h);if(!d||!o)continue;const b=y(d,m,o,t);s.push({column:h,name:g.name&&g.name(h)||a.name&&a.name(h)||h,measure:b.measure,magnitude:b.magnitude,distance:b.distance,direction:b.direction,nA:b.nA,nB:b.nB,meanA:b.meanA,meanB:b.meanB,reliable:b.reliable})}return s.sort((h,d)=>d.distance-h.distance||Math.abs(d.magnitude||0)-Math.abs(h.magnitude||0)),{ranked:s,nA:m.length,nB:t.length,unmatched:{onlyA:g.columns.filter(h=>!c.has(h)),onlyB:a.columns.filter(h=>!i.has(h))},measures:X}}}),Ue("packages/core/src/compute/anomaly.js",function(e,B){"use strict";Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"robustSpread",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return m}});const T=B("packages/core/src/compute/statistics.js").quantileSorted,D=B("packages/core/src/compute/special.js").logGamma,I=.6745,Z=3.5,z=1.5,L=.975,X=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function $(t){if(!t.length)return null;const h=Array.from(t,Number).sort((l,p)=>l-p),d=T(h,.5),o=h.map(l=>Math.abs(l-d)).sort((l,p)=>l-p),b=T(o,.5);return{median:d,mad:b}}function A(t,s={}){const h=Number.isFinite(s.threshold)?s.threshold:Z,d=t.length,o=new Array(d).fill(null),b=new Array(d).fill(!1),l=[];for(let v=0;v<d;v++){const R=Number(t[v]);Number.isFinite(R)&&l.push(R)}if(!l.length)return{median:null,mad:null,threshold:h,scores:o,flags:b,flagged:0};const p=$(l);if(p.mad===0)return{median:p.median,mad:0,threshold:h,scores:o,flags:b,flagged:0};let w=0;for(let v=0;v<d;v++){const R=Number(t[v]);if(!Number.isFinite(R))continue;const Y=I*(R-p.median)/p.mad;o[v]=Y,Math.abs(Y)>h&&(b[v]=!0,w++)}return{median:p.median,mad:p.mad,threshold:h,scores:o,flags:b,flagged:w}}function k(t,s={}){const h=Number.isFinite(s.k)?s.k:z,d=[];for(let w=0;w<t.length;w++){const v=Number(t[w]);Number.isFinite(v)&&d.push(v)}if(!d.length)return null;const o=d.sort((w,v)=>w-v),b=T(o,.25),l=T(o,.75),p=l-b;return{q1:b,q3:l,iqr:p,lower:b-h*p,upper:l+h*p,k:h}}function y(t,s){if(s<=0)return 0;const h=D(t);if(s<t+1){let v=t,R=1/t,Y=R;for(let K=0;K<1e3&&(v+=1,Y*=s/v,R+=Y,!(Math.abs(Y)<Math.abs(R)*1e-15));K++);return R*Math.exp(-s+t*Math.log(s)-h)}const d=1e-300;let o=s+1-t,b=1/d,l=1/o,p=l;for(let v=1;v<1e3;v++){const R=-v*(v-t);o+=2,l=R*l+o,Math.abs(l)<d&&(l=d),b=o+R/b,Math.abs(b)<d&&(b=d),l=1/l;const Y=l*b;if(p*=Y,Math.abs(Y-1)<1e-15)break}return 1-Math.exp(-s+t*Math.log(s)-h)*p}function f(t,s){return t<=0?0:y(s/2,t/2)}function g(t,s=L){if(!(s>0)||!(s<1))return NaN;let h=0,d=Math.max(1,t);for(;f(d,t)<s;)d*=2;for(let o=0;o<200;o++){const b=(h+d)/2;if(f(b,t)<s?h=b:d=b,d-h<1e-10)break}return(h+d)/2}function a(t){const s=t.length,h=t.map((d,o)=>{const b=d.slice();for(let l=0;l<s;l++)b.push(o===l?1:0);return b});for(let d=0;d<s;d++){let o=d;for(let l=d+1;l<s;l++)Math.abs(h[l][d])>Math.abs(h[o][d])&&(o=l);if(Math.abs(h[o][d])<1e-12)return null;if(o!==d){const l=h[o];h[o]=h[d],h[d]=l}const b=h[d][d];for(let l=0;l<2*s;l++)h[d][l]/=b;for(let l=0;l<s;l++){if(l===d)continue;const p=h[l][d];if(p!==0)for(let w=0;w<2*s;w++)h[l][w]-=p*h[d][w]}}return h.map(d=>d.slice(s))}function r(t,s){const h=t.length,d=new Array(s).fill(0);for(const l of t)for(let p=0;p<s;p++)d[p]+=l[p];for(let l=0;l<s;l++)d[l]/=h;const o=Array.from({length:s},()=>new Array(s).fill(0));for(const l of t)for(let p=0;p<s;p++){const w=l[p]-d[p];for(let v=p;v<s;v++)o[p][v]+=w*(l[v]-d[v])}const b=h>1?h-1:1;for(let l=0;l<s;l++)for(let p=l;p<s;p++)o[l][p]/=b,o[p][l]=o[l][p];return{mean:d,cov:o}}function i(t,s={}){const h=Number.isFinite(s.p)?s.p:L,d=Number.isFinite(s.ridge)?s.ridge:1e-6,o=t.length;if(!o)return null;const b=t[0].length;if(!b)return null;const l=new Array(o).fill(null),p=new Array(o).fill(null),w=new Array(o).fill(!1),v=[],R=[];for(let F=0;F<o;F++){const P=t[F];let M=P.length===b;const x=new Array(b);for(let U=0;M&&U<b;U++){const _=Number(P[U]);Number.isFinite(_)?x[U]=_:M=!1}M&&(v.push(F),R.push(x))}const Y=b,K=g(Y,h);if(R.length<=b)return{center:[],df:Y,cutoff:K,singular:!0,used:R.length,distances:l,squared:p,flags:w,flagged:0};const{mean:V,cov:E}=r(R,b);let O=a(E),C=!1;if(!O){C=!0;let F=0;for(let x=0;x<b;x++)F+=E[x][x];const P=F/b*d||d,M=E.map((x,U)=>x.map((_,W)=>U===W?_+P:_));if(O=a(M),!O)return{center:V,df:Y,cutoff:K,singular:!0,used:R.length,distances:l,squared:p,flags:w,flagged:0}}let S=0;for(let F=0;F<R.length;F++){const P=R[F],M=new Array(b);for(let _=0;_<b;_++)M[_]=P[_]-V[_];let x=0;for(let _=0;_<b;_++){let W=0;for(let q=0;q<b;q++)W+=O[_][q]*M[q];x+=M[_]*W}x<0&&(x=0);const U=v[F];p[U]=x,l[U]=Math.sqrt(x),x>K&&(w[U]=!0,S++)}return{center:V,df:Y,cutoff:K,singular:C,used:R.length,distances:l,squared:p,flags:w,flagged:S}}const c=20,u=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function n(t,s={}){const h=s.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",d=Number.isFinite(s.windowLen)&&s.windowLen>=1?Math.floor(s.windowLen):c,o=Number.isFinite(s.threshold)?s.threshold:Z,b=Number.isFinite(s.k)?s.k:z,l=Number.isFinite(s.minPeriods)&&s.minPeriods>=1?Math.floor(s.minPeriods):d,p=t.length,w=new Array(p).fill(null),v=new Array(p).fill(!1);let R=0;for(let Y=0;Y<p;Y++){const K=Number(t[Y]);if(!Number.isFinite(K))continue;const V=Math.max(0,Y-d+1),E=[];for(let O=V;O<=Y;O++){const C=Number(t[O]);Number.isFinite(C)&&E.push(C)}if(!(E.length<l))if(h==="rollingIqr"){const O=k(E,{k:b});if(!O)continue;(K<O.lower||K>O.upper)&&(v[Y]=!0,R++)}else{const O=$(E);if(!O||O.mad===0)continue;const C=I*(K-O.median)/O.mad;w[Y]=C,Math.abs(C)>o&&(v[Y]=!0,R++)}}return{method:h,windowLen:d,minPeriods:l,threshold:o,k:b,scores:w,flags:v,flagged:R}}function m(t={}){const s=t||{},h=s.field;if(typeof h!="string"||!h)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const d=s.method||"modifiedZScore";if(!(X.includes(d)||u.includes(d))||d==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${d}'`);const b=typeof s.orderBy=="string"?s.orderBy:null,l=s.latest===!0,p=u.includes(d),w=v=>Number(v==null?NaN:v[h]);return v=>{const R=Array.isArray(v)?v.slice():[...v];b&&R.sort((O,C)=>{const S=O?.[b],F=C?.[b];return S===F?0:S==null?-1:F==null?1:S<F?-1:1});const Y=R.map(w);let K,V;if(p)({flags:K,scores:V}=n(Y,{method:d,windowLen:s.windowLen,threshold:s.threshold,k:s.k,minPeriods:s.minPeriods}));else if(d==="iqr"){const O=k(Y,{k:s.k});K=Y.map(C=>O?Number.isFinite(C)&&(C<O.lower||C>O.upper):!1),V=Y.map(()=>null)}else({flags:K,scores:V}=A(Y,{threshold:s.threshold}));if(l){const O=K.length-1;return O<0||!K[O]?!1:{method:d,field:h,flagged:[{row:R[O],score:V[O]}]}}const E=[];for(let O=0;O<K.length;O++)K[O]&&E.push({row:R[O],score:V[O]});return E.length?{method:d,field:h,flagged:E}:!1}}}),Ue("packages/core/src/compute/forecast.js",function(e,B){"use strict";Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const re=B("packages/core/src/compute/special.js"),T=re.normalQuantile,G=re.studentTQuantile,I=B("packages/core/src/internal/warn.js").warnOnce,Z=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),z=1e-4,L=1-1e-4;function X(s){const h=[];for(let d=0;d<s.length;d++){const o=s[d];if(o!==null&&typeof o=="object"){const b=Number.isFinite(o.at)?o.at:d,l=Number.isFinite(o.value)?o.value:null;h.push({at:b,value:l})}else h.push({at:d,value:Number.isFinite(o)?Number(o):null})}return h}function $(s){const h=s.filter(p=>p.value!==null),d=h[0],o=h[h.length-1],b=o.at-d.at,l=h.length>1&&b>0?b/(h.length-1):1;return{lastAt:o.at,step:l}}function A(s){return Math.min(L,Math.max(z,s))}function k(s,h=z,d=L,o=80){const b=(Math.sqrt(5)-1)/2;let l=h,p=d,w=p-b*(p-l),v=l+b*(p-l),R=s(w),Y=s(v);for(let K=0;K<o;K++)R<Y?(p=v,v=w,Y=R,w=p-b*(p-l),R=s(w)):(l=w,w=v,R=Y,v=l+b*(p-l),Y=s(v));return(l+p)/2}function y(s,h){let d=null,o=0,b=0;for(let l=0;l<s.length;l++){const p=s[l];if(p!==null){if(d===null){d=p;continue}o+=(p-d)**2,b+=1,d=h*p+(1-h)*d}}return{level:d,sse:o,m:b}}function f(s,h,d){let o=null,b=null,l=0,p=0;for(let w=0;w<s.length;w++){const v=s[w];if(v===null){o!==null&&b!==null&&(o+=b);continue}if(o===null){o=v;continue}b===null&&(b=v-o);const R=o+b;l+=(v-R)**2,p+=1;const Y=o;o=h*v+(1-h)*(Y+b),b=d*(o-Y)+(1-d)*b}return{level:o,trend:b,sse:l,m:p}}function g(s,h,d,o,b){const l=s.length;if(l<2*h)return null;const p=C=>{let S=0,F=0;for(let P=C;P<C+h&&P<l;P++)s[P]!==null&&(S+=s[P],F+=1);return F?S/F:null},w=p(0),v=p(h);if(w===null||v===null)return null;let R=w,Y=(v-w)/h;const K=new Array(h).fill(0);for(let C=0;C<h;C++)K[C]=s[C]===null?0:s[C]-R;const V=K.reduce((C,S)=>C+S,0)/h;for(let C=0;C<h;C++)K[C]-=V;let E=0,O=0;for(let C=h;C<l;C++){const S=C%h,F=K[S],P=s[C];if(P===null){R+=Y;continue}const M=R+Y+F;E+=(P-M)**2,O+=1;const x=R;R=d*(P-F)+(1-d)*(R+Y),Y=o*(R-x)+(1-o)*Y,K[S]=b*(P-R)+(1-b)*F}return{level:R,trend:Y,season:K,phase:(l-1)%h,sse:E,count:O}}function a(s,h,d){let o=1;for(const l of h)o+=l*l;const b=Math.sqrt(s*o);return{se:b,margin:d*b}}function r(s,h={}){if(!s||typeof s.length!="number"||s.length===0)return null;const d=Z.includes(h.method)?h.method:"linear",o=Math.max(1,Math.floor(Number(h.horizon)||1)),b=Number.isFinite(h.confidence)&&h.confidence>0&&h.confidence<1?h.confidence:.95,l=1-(1-b)/2,p=X(s),w=p.map(E=>E.value),v=w.filter(E=>E!==null),R=v.length,{lastAt:Y,step:K}=R?$(p):{lastAt:0,step:1},V=E=>Y+E*K;return d==="linear"?i(p,R,o,b,l,V):d==="movingAverage"?c(v,R,o,b,l,h,V):d==="ses"?u(w,R,o,b,l,h,V):d==="holt"?n(w,R,o,b,l,h,V):m(w,R,o,b,l,h,V)}function i(s,h,d,o,b,l){if(h<2)return null;let p=0,w=0;for(const P of s)P.value!==null&&(p+=P.at,w+=P.value);p/=h,w/=h;let v=0,R=0,Y=0;for(const P of s){if(P.value===null)continue;const M=P.at-p,x=P.value-w;v+=M*M,R+=M*x,Y+=x*x}if(v===0)return null;const K=R/v,V=w-K*p,E=Y===0?1:Math.max(0,Math.min(1,R*R/(v*Y))),O=Math.max(0,Y-K*R),C=h>2?Math.sqrt(O/(h-2)):null,S=h>2?G(b,h-2):null,F=[];for(let P=1;P<=d;P++){const M=l(P),x=V+K*M;let U=null,_=null,W=null,q=null,N=null;if(C!==null){const Q=1/h+(M-p)**2/v,J=C*Math.sqrt(1+Q),ee=C*Math.sqrt(Q);N=J,U=x-S*J,_=x+S*J,W=x-S*ee,q=x+S*ee}F.push({step:P,at:M,mean:x,lower:U,upper:_,lowerMean:W,upperMean:q,se:N})}return{method:"linear",horizon:d,confidence:o,n:h,sigma:C,r2:E,params:{slope:K,intercept:V},points:F}}function c(s,h,d,o,b,l,p){if(h<1)return null;const w=Math.max(1,Math.min(h,Math.floor(Number(l.windowLen)||h))),v=s.slice(h-w);let R=0;for(const C of v)R+=C;const Y=R/w;let K=null,V=null;if(w>1){let C=0;for(const F of v)C+=(F-Y)**2;K=Math.sqrt(C/(w-1))*Math.sqrt(1+1/w),V=G(b,w-1)}const E=K===null?null:V*K,O=[];for(let C=1;C<=d;C++)O.push({step:C,at:p(C),mean:Y,lower:E===null?null:Y-E,upper:E===null?null:Y+E,se:K});return{method:"movingAverage",horizon:d,confidence:o,n:h,sigma:K===null?null:K,params:{windowLen:w},points:O}}function u(s,h,d,o,b,l,p){if(h<1)return null;let w=Number.isFinite(l.alpha)?A(l.alpha):null;w===null&&(w=k(V=>y(s,V).sse));const v=y(s,w),R=T(b),Y=v.m>0?v.sse/v.m:null,K=[];for(let V=1;V<=d;V++){const E=v.level;let O=null,C=null,S=null;if(Y!==null){const F=[];for(let M=1;M<V;M++)F.push(w);const P=a(Y,F,R);S=P.se,O=E-P.margin,C=E+P.margin}K.push({step:V,at:p(V),mean:E,lower:O,upper:C,se:S})}return{method:"ses",horizon:d,confidence:o,n:h,sigma:Y===null?null:Math.sqrt(Y),params:{alpha:w},points:K}}function n(s,h,d,o,b,l,p){if(h<2)return null;let w=Number.isFinite(l.alpha)?A(l.alpha):null,v=Number.isFinite(l.beta)?A(l.beta):null;if(w===null||v===null){let O=w===null?.5:w,C=v===null?.5:v;for(let S=0;S<6;S++)w===null&&(O=k(F=>f(s,F,C).sse)),v===null&&(C=k(F=>f(s,O,F).sse));w=w===null?O:w,v=v===null?C:v}const R=f(s,w,v),Y=T(b),K=R.m>0?R.sse/R.m:null,V=w*v,E=[];for(let O=1;O<=d;O++){const C=R.level+O*R.trend;let S=null,F=null,P=null;if(K!==null){const M=[];for(let U=1;U<O;U++)M.push(w+U*V);const x=a(K,M,Y);P=x.se,S=C-x.margin,F=C+x.margin}E.push({step:O,at:p(O),mean:C,lower:S,upper:F,se:P})}return{method:"holt",horizon:d,confidence:o,n:h,sigma:K===null?null:Math.sqrt(K),params:{alpha:w,beta:v},points:E}}function m(s,h,d,o,b,l,p){const w=Math.floor(Number(l.period));if(!(w>=2))return I("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(h<2*w)return null;let v=Number.isFinite(l.alpha)?A(l.alpha):null,R=Number.isFinite(l.beta)?A(l.beta):null,Y=Number.isFinite(l.gamma)?A(l.gamma):null;const K=(P,M,x)=>{const U=g(s,w,P,M,x);return U?U.sse:1/0};if(v===null||R===null||Y===null){let P=v===null?.5:v,M=R===null?.5:R,x=Y===null?.5:Y;for(let U=0;U<8;U++)v===null&&(P=k(_=>K(_,M,x))),R===null&&(M=k(_=>K(P,_,x))),Y===null&&(x=k(_=>K(P,M,_)));v=v===null?P:v,R=R===null?M:R,Y=Y===null?x:Y}const V=g(s,w,v,R,Y);if(!V)return null;const E=T(b),O=V.count>0?V.sse/V.count:null,C=v*R,S=Y*(1-v),F=[];for(let P=1;P<=d;P++){const M=V.season[(V.phase+P)%w],x=V.level+P*V.trend+M;let U=null,_=null,W=null;if(O!==null){const q=[];for(let Q=1;Q<P;Q++)q.push(v+Q*C+(Q%w===0?S:0));const N=a(O,q,E);W=N.se,U=x-N.margin,_=x+N.margin}F.push({step:P,at:p(P),mean:x,lower:U,upper:_,se:W})}return{method:"holtWinters",horizon:d,confidence:o,n:h,sigma:O===null?null:Math.sqrt(O),params:{alpha:v,beta:R,gamma:Y,period:w},points:F}}const t={FORECAST_METHODS:Z,forecast:r}}),Ue("packages/core/src/compute/hypothesis.js",function(e,B){"use strict";Object.defineProperty(e,"GROUP_TESTS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"NORMALITY_ALPHA",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HL_PAIR_LIMIT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"welchTTest",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"mannWhitneyUTest",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"chiSquareTest",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"compareGroups",{enumerable:!0,get:function(){return E}});const T=B("packages/core/src/internal/warn.js").warnOnce,D=B("packages/core/src/compute/handle.js").valueReader,I=B("packages/core/src/compute/statistics.js"),Z=I.numbers,z=I.moments,L=I.frequencyMap,X=I.categoricalDistance,$=I.isNumericColumn,A=I.jarqueBera,k=I.proportionInterval,y=I.SUBSET_RELIABILITY_FLOOR,g=B("packages/core/src/compute/compare.js").pooledStandardMeanDifference,a=B("packages/core/src/compute/special.js"),r=a.studentT,i=a.studentTQuantile,c=a.normalCdf,u=a.normalQuantile,n=a.chiSquareUpperTail,m=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),t=.05,s=2e6;function h(O){const C=Number(O);return Number.isFinite(C)&&C>0&&C<1?C:.95}function d(O){const{n:C,mean:S,m2:F}=z(O);return{mean:S,sd:C>0?Math.sqrt(F/C):0,n:C}}function o(O,C){const S=O.length;if(S<2)return 0;let F=0;for(let P=0;P<S;P++){const M=O[P]-C;F+=M*M}return F/(S-1)}function b(O,C){return{name:"pooledStandardMeanDifference",value:g(d(O),d(C))}}function l(O,C,S){const F=O.length,P=C.length;if(F<2||P<2)return null;const M=h(S),{mean:x}=z(O),{mean:U}=z(C),_=o(O,x),W=o(C,U),q=_/F+W/P;if(!(q>0))return null;const N=Math.sqrt(q),Q=(x-U)/N,J=_/F*(_/F)/(F-1),ee=W/P*(W/P)/(P-1),ne=q*q/(J+ee),se=Math.min(1,Math.max(0,2*(1-r(Math.abs(Q),ne)))),le=x-U,ye=i(1-(1-M)/2,ne)*N;return{test:m.WELCH,statistic:Q,statisticName:"t",df:ne,pValue:se,interval:{estimate:le,lower:le-ye,upper:le+ye,confidence:M,method:"welch-t (difference of means)"},effectSize:b(O,C),nA:F,nB:P,reliable:F>=y&&P>=y,method:"Welch's t-test (unequal variances; Welch–Satterthwaite df)"}}function p(O){const C=O.length;if(C===0)return Number.NaN;const S=C>>1;return C%2?O[S]:(O[S-1]+O[S])/2}function w(O,C,S){const F=O.length,P=C.length,M=F*P;if(M===0||M>s)return null;const x=new Float64Array(M);let U=0;for(let J=0;J<F;J++)for(let ee=0;ee<P;ee++)x[U++]=O[J]-C[ee];x.sort();const _=p(x),W=Math.sqrt(F*P*(F+P+1)/12),q=u(1-(1-S)/2);let N=Math.round(M/2-q*W);N>=0||(N=0);const Q=Math.floor((M-1)/2);return N>Q&&(N=Q),{estimate:_,lower:x[N],upper:x[M-1-N],confidence:S,method:"hodges-lehmann (normal approximation)"}}function v(O,C,S){const F=O.length,P=C.length;if(F<1||P<1)return null;const M=h(S),x=F+P,U=new Array(x);for(let se=0;se<F;se++)U[se]={v:O[se],g:0};for(let se=0;se<P;se++)U[F+se]={v:C[se],g:1};U.sort((se,le)=>se.v-le.v);let _=0,W=0,q=0;for(;q<x;){let se=q;for(;se<x&&U[se].v===U[q].v;)se++;const le=se-q,ye=(q+1+se)/2;for(let fe=q;fe<se;fe++)U[fe].g===0&&(_+=ye);W+=le*le*le-le,q=se}const N=_-F*(F+1)/2,Q=F*P/2,J=F*P/12*(x+1-W/(x*(x-1)));let ee=1;if(J>0){const se=Math.max(0,Math.abs(N-Q)-.5);ee=Math.min(1,2*c(-se/Math.sqrt(J)))}const ne=w(O,C,M);return{test:m.MANN_WHITNEY,statistic:N,statisticName:"U",df:null,pValue:ee,interval:ne,effectSize:b(O,C),nA:F,nB:P,reliable:F>=y&&P>=y,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function R(O,C,S,F,P){const M=k(O,C,P),x=k(S,F,P);if(!M||!x)return null;const U=M.proportion-x.proportion,_=U-Math.sqrt((M.proportion-M.lower)**2+(x.upper-x.proportion)**2),W=U+Math.sqrt((M.upper-M.proportion)**2+(x.proportion-x.lower)**2);return{lower:_,upper:W}}function Y(O,C,S,F,P,M={}){if(!(C>0)||!(F>0))return null;const x=new Set([...O.keys(),...S.keys()]),U=x.size;if(U<2)return null;const _=C+F;let W=0;for(const ee of x){const ne=O.get(ee)||0,se=S.get(ee)||0,le=ne+se,ye=C*le/_,fe=F*le/_;ye>0&&(W+=(ne-ye)*(ne-ye)/ye),fe>0&&(W+=(se-fe)*(se-fe)/fe)}const q=U-1,N=n(W,q);let Q=null;M.category!==void 0&&x.has(M.category)?Q=M.category:U===2&&([Q]=[...x]);let J=null;if(Q!==null){const ee=R(O.get(Q)||0,C,S.get(Q)||0,F,h(P));ee&&(J={estimate:(O.get(Q)||0)/C-(S.get(Q)||0)/F,lower:ee.lower,upper:ee.upper,confidence:h(P),method:"newcombe (difference in this category's share)",category:Q})}return{test:m.CHI_SQUARE,statistic:W,statisticName:"chiSquare",df:q,pValue:N,interval:J,effectSize:{name:"categoricalTotalVariation",value:X(O,C,S,F)},nA:C,nB:F,reliable:C>=y&&F>=y,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function K(O){return O==null||O===""||typeof O=="number"&&Number.isNaN(O)?null:O instanceof Date?O.getTime():typeof O=="object"?String(O):O}function V(O,C,S){if(S===m.WELCH||S===m.MANN_WHITNEY)return{test:S,chosenBy:"override",reason:`caller override: ${S}`};const F=A(O),P=A(C),M=F===null?null:Math.exp(-F/2),x=P===null?null:Math.exp(-P/2);return M!==null&&M<t||x!==null&&x<t?{test:m.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${t})`}:{test:m.WELCH,chosenBy:"auto",reason:M!==null||x!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function E(O,C,S,F={}){if(!O||!C)return null;const P=h(F.confidence),M=D(C);let x;if(Array.isArray(F.groups)&&F.groups.length===2)x=[K(F.groups[0]),K(F.groups[1])];else{const{map:se}=L(C,S),le=[...se.entries()].sort((ye,fe)=>fe[1]-ye[1]).slice(0,2).map(ye=>ye[0]);if(le.length<2)return T("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;x=le}const[U,_]=x;if(U===null||_===null||U===_)return T("compareGroups:distinct","[lattice] compareGroups: the two groups must be two distinct, present values."),null;const W=[],q=[];for(let se=0;se<S.length;se++){const le=K(M(S[se]));le===U?W.push(S[se]):le===_&&q.push(S[se])}if(W.length===0||q.length===0)return T("compareGroups:empty","[lattice] compareGroups: one of the two groups has no rows in the current set."),null;const N=F.test&&F.test!=="auto"?String(F.test):null,Q=$(O,W.concat(q));let J,ee,ne;if(N===m.CHI_SQUARE||!N&&!Q){ee=N?"override":"auto",ne=N?"caller override: chiSquare":"column family: categorical";const se=L(O,W),le=L(O,q);J=Y(se.map,se.total,le.map,le.total,P,{category:F.category})}else{if((N===m.WELCH||N===m.MANN_WHITNEY)&&!Q)return T("compareGroups:numeric-override",`[lattice] compareGroups: ${N} needs a numeric column, but the column is not numeric.`),null;const se=Z(O,W),le=Z(O,q),ye=V(se,le,N);ee=ye.chosenBy,ne=ye.reason,J=ye.test===m.MANN_WHITNEY?v(se,le,P):l(se,le,P)}return J?{...J,chosenBy:ee,reason:ne,groups:[U,_]}:(T("compareGroups:degenerate","[lattice] compareGroups: the chosen test had too little to work with (too few values, or no variation)."),null)}}),Ue("packages/core/src/compute/significance.js",function(e,B){"use strict";Object.defineProperty(e,"COMPARE_TESTS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"compare",{enumerable:!0,get:function(){return we}});const T=B("packages/core/src/internal/warn.js").warnOnce,D=B("packages/core/src/compute/handle.js").valueReader,I=B("packages/core/src/compute/statistics.js"),Z=I.numbers,z=I.moments,L=I.frequencyMap,X=I.isNumericColumn,$=I.jarqueBera,A=I.proportionInterval,k=B("packages/core/src/compute/special.js"),y=k.studentT,f=k.studentTQuantile,g=k.normalCdf,a=k.normalQuantile,r=k.chiSquareUpperTail,i=k.incompleteBeta,c=Object.freeze({T:"t",WELCH:"welch",MANN_WHITNEY:"mannWhitney",ANOVA:"anova",KRUSKAL:"kruskal",CHI_SQUARE:"chiSquare",PROPORTIONS:"proportions"}),u=new Set([c.T,c.WELCH,c.MANN_WHITNEY]),n=new Set([c.ANOVA,c.KRUSKAL]),m=new Set([c.CHI_SQUARE,c.PROPORTIONS]),t=.05,s=[.2,.5,.8],h=[.147,.33,.474],d=[.01,.06,.14],o=[[.1,.3,.5],[.07,.21,.35],[.06,.17,.29],[.05,.15,.25]];function b(ce){const ae=Number(ce);return Number.isFinite(ae)&&ae>0&&ae<1?ae:.05}function l(ce){return ce==null||ce===""||typeof ce=="number"&&Number.isNaN(ce)?null:ce instanceof Date?ce.getTime():typeof ce=="object"?String(ce):ce}function p(ce,ae){const ge=D(ce),de=[],me=new Map;for(let ve=0;ve<ae.length;ve++){const xe=l(ge(ae[ve]));if(xe===null)continue;let Ee=me.get(xe);Ee||(Ee={value:xe,rows:[]},me.set(xe,Ee),de.push(Ee)),Ee.rows.push(ae[ve])}return de}function w(ce){const{n:ae,mean:ge,m2:de}=z(ce),me=ae>1?de/(ae-1):0;return{n:ae,mean:ge,sd:Math.sqrt(me),variance:me}}function v(ce,ae,ge){if(!(ae>0)||!(ge>0)||!(ce>=0)||!Number.isFinite(ce))return Number.NaN;if(ce===0)return 1;const de=ae*ce/(ae*ce+ge);return 1-i(ae/2,ge/2,de)}function R(ce,ae){const ge=Math.abs(ce);return Number.isFinite(ge)?ge>=ae[2]?"large":ge>=ae[1]?"medium":ge>=ae[0]?"small":"negligible":"negligible"}function Y(ce,ae,ge){if(ce==="cohensD")return R(ae,s);if(ce==="cliffsDelta")return R(ae,h);if(ce==="etaSquared")return R(ae,d);const de=Math.max(1,Math.min(o.length,Math.floor(ge||1)));return R(ae,o[de-1])}function K(ce,ae){if(!(ce.n>1)||!(ae.n>1))return null;const ge=((ce.n-1)*ce.variance+(ae.n-1)*ae.variance)/(ce.n+ae.n-2);return ge>0?(ce.mean-ae.mean)/Math.sqrt(ge):null}function V(ce,ae){const ge=ce.length,de=ae.length;if(!ge||!de)return null;const me=Array.from(ae).sort((Ee,Le)=>Ee-Le);let ve=0,xe=0;for(let Ee=0;Ee<ge;Ee++){const Le=ce[Ee];let He=0,Me=de;for(;He<Me;){const Se=He+Me>>1;me[Se]<Le?He=Se+1:Me=Se}const Ke=He;let $e=He;for(;$e<de&&me[$e]===Le;)$e++;const Oe=$e-He;ve+=Ke,xe+=de-$e}return(ve-xe)/(ge*de)}function E(ce,ae,ge,de){const me=Math.min(ge-1,de-1);return!(ae>0)||!(me>0)?null:Math.sqrt(ce/(ae*me))}function O(ce){return Number.isFinite(ce)?ce<.001?"p < 0.001":ce>=.995?"p > 0.995":`p = ${ce.toFixed(3)}`:"p = —"}function C(ce){if(!Number.isFinite(ce))return"0";const ae=Math.abs(ce);return ae===0?"0":ae>=1e3?String(Math.round(ce)):ae>=100?String(Number(ce.toFixed(0))):ae>=10?String(Number(ce.toFixed(1))):ae>=1?String(Number(ce.toFixed(2))):String(Number(ce.toPrecision(2)))}const S=new Set(["cohensD","cliffsDelta"]);function F(ce){if(ce.difference!=null&&Math.abs(ce.difference)>=1e-12)return Math.sign(ce.difference);const ae=ce.effectSize;if(ae&&S.has(ae.name)&&Number.isFinite(ae.value)&&Math.abs(ae.value)>=1e-12)return Math.sign(ae.value);const[ge,de]=ce.groups;return Number.isFinite(ge.mean)&&Number.isFinite(de.mean)&&ge.mean!==de.mean?Math.sign(ge.mean-de.mean):0}function P(ce){const ae=ce.measureName||"values";return{subject:ae.charAt(0).toUpperCase()+ae.slice(1),be:ae==="values"?"are":"is",name:ae}}function M(ce,ae){const ge=ae.unit?` ${ae.unit}`:"",{subject:de,be:me}=P(ae),ve=ce.groups[0].label,xe=ce.groups[1].label,Ee=ce.effectSize?ce.effectSize.label:"negligible",Le=ce.pValue<ce.alpha,He=Le?"unlikely to be chance":"consistent with chance";if(!Le&&Ee==="negligible")return`${de} ${me} essentially the same for ${ve} and ${xe} (${O(ce.pValue)}); the effect is ${Ee}.`;const Me=F(ce),Ke=`the difference is ${He} (${O(ce.pValue)}) and the effect is ${Ee}.`;if(Me===0)return`${de} ${me} different between ${ve} and ${xe}; ${Ke}`;const $e=Me>0?ve:xe,Oe=Me>0?xe:ve,Se=ce.difference!=null&&Math.abs(ce.difference)>=1e-12,Pe=Math.abs(ce.difference),Te=Se?typeof ae.formatValue=="function"?` by about ${ae.formatValue(Pe)}${ge}`:` by about ${C(Pe)}${ge}`:"";return`${de} ${me} higher for ${$e} than for ${Oe}${Te}; ${Ke}`}function x(ce,ae){const{name:ge}=P(ae),de=ce.effectSize?ce.effectSize.label:"negligible",me=O(ce.pValue);return ce.pValue<ce.alpha?`The groups differ in ${ge}; the difference is unlikely to be chance (${me}) and the effect is ${de}.`:de==="negligible"?`The groups are essentially the same in ${ge} (${me}); the effect is ${de}.`:`The groups show a ${de} effect in ${ge}, but the difference is consistent with chance (${me}).`}function U(ce,ae){const ge=ce.length;if(ge<2)return null;const{mean:de,m2:me}=z(ce),ve=me/(ge-1);if(!(ve>0))return null;const xe=Math.sqrt(ve),Ee=xe/Math.sqrt(ge),Le=de/Ee,He=ge-1,Me=Math.min(1,Math.max(0,2*(1-y(Math.abs(Le),He)))),Ke=f(1-ae/2,He)*Ee,$e=de/xe;return{test:c.T,statistic:Le,statisticName:"t",df:He,pValue:Me,difference:de,interval:{estimate:de,lower:de-Ke,upper:de+Ke,confidence:1-ae,method:"paired-t (mean of the pair differences)"},effectSize:{name:"cohensD",label:R($e,s),value:$e}}}function _(ce,ae){const ge=Array.from(ce).filter(Pe=>Pe!==0),de=ge.length;if(!de)return null;const me=Array.from({length:de},(Pe,Te)=>Te).sort((Pe,Te)=>Math.abs(ge[Pe])-Math.abs(ge[Te])),ve=new Array(de);let xe=0;for(;xe<de;){let Pe=xe;for(;Pe+1<de&&Math.abs(ge[me[Pe+1]])===Math.abs(ge[me[xe]]);)Pe++;const Te=(xe+Pe)/2+1;for(let Be=xe;Be<=Pe;Be++)ve[me[Be]]=Te;xe=Pe+1}let Ee=0,Le=0;for(let Pe=0;Pe<de;Pe++)Le+=ve[Pe],ge[Pe]>0&&(Ee+=ve[Pe]);const He=Le-Ee,Me=de*(de+1)/4,Ke=Math.sqrt(de*(de+1)*(2*de+1)/24),$e=Ke>0?(Math.abs(Ee-Me)-.5)/Ke:0,Oe=Math.min(1,Math.max(0,2*g(-Math.max(0,$e)))),Se=Le>0?(Ee-He)/Le:0;return{test:c.MANN_WHITNEY,statistic:Ee,statisticName:"W",df:null,pValue:Oe,difference:null,interval:null,effectSize:{name:"cliffsDelta",label:R(Se,h),value:Se}}}function W(ce,ae,ge){const de=w(ce),me=w(ae);if(de.n<2||me.n<2)return null;const ve=((de.n-1)*de.variance+(me.n-1)*me.variance)/(de.n+me.n-2);if(!(ve>0))return null;const xe=Math.sqrt(ve*(1/de.n+1/me.n)),Ee=(de.mean-me.mean)/xe,Le=de.n+me.n-2,He=Math.min(1,Math.max(0,2*(1-y(Math.abs(Ee),Le)))),Me=de.mean-me.mean,Ke=f(1-ge/2,Le)*xe,$e=K(de,me);return{test:c.T,statistic:Ee,statisticName:"t",df:Le,pValue:He,difference:Me,interval:{estimate:Me,lower:Me-Ke,upper:Me+Ke,confidence:1-ge,method:"student-t (pooled variance, difference of means)"},effectSize:{name:"cohensD",label:R($e,s),value:$e},summaries:[de,me]}}function q(ce,ae,ge){const de=w(ce),me=w(ae);if(de.n<2||me.n<2)return null;const ve=de.variance/de.n+me.variance/me.n;if(!(ve>0))return null;const xe=Math.sqrt(ve),Ee=(de.mean-me.mean)/xe,Le=de.variance/de.n*(de.variance/de.n)/(de.n-1),He=me.variance/me.n*(me.variance/me.n)/(me.n-1),Me=ve*ve/(Le+He),Ke=Math.min(1,Math.max(0,2*(1-y(Math.abs(Ee),Me)))),$e=de.mean-me.mean,Oe=f(1-ge/2,Me)*xe,Se=K(de,me);return{test:c.WELCH,statistic:Ee,statisticName:"t",df:Me,pValue:Ke,difference:$e,interval:{estimate:$e,lower:$e-Oe,upper:$e+Oe,confidence:1-ge,method:"welch-t (unequal variances, difference of means)"},effectSize:{name:"cohensD",label:R(Se,s),value:Se},summaries:[de,me]}}function N(ce,ae,ge){const de=ce.length,me=ae.length;if(de<1||me<1)return null;const ve=w(ce),xe=w(ae),Ee=de+me,Le=new Array(Ee);for(let Be=0;Be<de;Be++)Le[Be]={v:ce[Be],g:0};for(let Be=0;Be<me;Be++)Le[de+Be]={v:ae[Be],g:1};Le.sort((Be,Ge)=>Be.v-Ge.v);let He=0,Me=0,Ke=0;for(;Ke<Ee;){let Be=Ke;for(;Be<Ee&&Le[Be].v===Le[Ke].v;)Be++;const Ge=(Ke+1+Be)/2;for(let Je=Ke;Je<Be;Je++)Le[Je].g===0&&(He+=Ge);const et=Be-Ke;Me+=et*et*et-et,Ke=Be}const $e=He-de*(de+1)/2,Oe=de*me/2,Se=de*me/12*(Ee+1-Me/(Ee*(Ee-1)));let Pe=1;if(Se>0){const Be=Math.max(0,Math.abs($e-Oe)-.5);Pe=Math.min(1,2*g(-Be/Math.sqrt(Se)))}const Te=V(ce,ae);return{test:c.MANN_WHITNEY,statistic:$e,statisticName:"U",df:null,pValue:Pe,difference:null,interval:Q(ce,ae,1-ge),effectSize:{name:"cliffsDelta",label:R(Te,h),value:Te},summaries:[ve,xe]}}function Q(ce,ae,ge){const de=ce.length,me=ae.length,ve=de*me;if(ve===0||ve>2e6)return null;const xe=new Float64Array(ve);let Ee=0;for(let Se=0;Se<de;Se++)for(let Pe=0;Pe<me;Pe++)xe[Ee++]=ce[Se]-ae[Pe];xe.sort();const Le=ve>>1,He=ve%2?xe[Le]:(xe[Le-1]+xe[Le])/2,Me=Math.sqrt(de*me*(de+me+1)/12),Ke=a(1-(1-ge)/2);let $e=Math.round(ve/2-Ke*Me);$e>=0||($e=0);const Oe=Math.floor((ve-1)/2);return $e>Oe&&($e=Oe),{estimate:He,lower:xe[$e],upper:xe[ve-1-$e],confidence:ge,method:"hodges-lehmann (location shift)"}}function J(ce,ae){const ge=ce.length,de=ce.map(w);if(de.some(Pe=>Pe.n<2))return null;const me=de.reduce((Pe,Te)=>Pe+Te.n,0),ve=de.reduce((Pe,Te)=>Pe+Te.mean*Te.n,0)/me;let xe=0,Ee=0;for(let Pe=0;Pe<ge;Pe++)xe+=de[Pe].n*(de[Pe].mean-ve)**2,Ee+=(de[Pe].n-1)*de[Pe].variance;const Le=ge-1,He=me-ge;if(!(Ee>0)||He<1)return null;const Me=xe/Le,Ke=Ee/He,$e=Me/Ke,Oe=Math.min(1,Math.max(0,v($e,Le,He))),Se=xe/(xe+Ee);return{test:c.ANOVA,statistic:$e,statisticName:"F",df:{between:Le,within:He},pValue:Oe,difference:null,interval:null,effectSize:{name:"etaSquared",label:R(Se,d),value:Se},summaries:de}}function ee(ce,ae){const ge=ce.length,de=ce.map(w);if(ge<2)return null;const me=de.reduce((Te,Be)=>Te+Be.n,0),ve=[];for(let Te=0;Te<ge;Te++)for(let Be=0;Be<ce[Te].length;Be++)ve.push({v:ce[Te][Be],g:Te});ve.sort((Te,Be)=>Te.v-Be.v);const xe=new Array(ve.length);let Ee=0,Le=0;for(;Le<ve.length;){let Te=Le;for(;Te<ve.length&&ve[Te].v===ve[Le].v;)Te++;const Be=(Le+1+Te)/2;for(let et=Le;et<Te;et++)xe[et]=Be;const Ge=Te-Le;Ee+=Ge*Ge*Ge-Ge,Le=Te}const He=new Array(ge).fill(0);for(let Te=0;Te<ve.length;Te++)He[ve[Te].g]+=xe[Te];let Me=0;for(let Te=0;Te<ge;Te++)Me+=He[Te]*He[Te]/de[Te].n;Me=12/(me*(me+1))*Me-3*(me+1);const Ke=1-Ee/(me*me*me-me),$e=Ke>0?Me/Ke:Me,Oe=ge-1,Se=Math.min(1,Math.max(0,r($e,Oe))),Pe=($e-ge+1)/(me-ge);return{test:c.KRUSKAL,statistic:$e,statisticName:"H",df:Oe,pValue:Se,difference:null,interval:null,effectSize:{name:"etaSquared",label:R(Pe,d),value:Math.max(0,Pe)},summaries:de}}function ne(ce,ae,ge,de,me){const ve=A(ce,ae,me),xe=A(ge,de,me);if(!ve||!xe)return null;const Ee=ve.proportion-xe.proportion,Le=Ee-Math.sqrt((ve.proportion-ve.lower)**2+(xe.upper-xe.proportion)**2),He=Ee+Math.sqrt((ve.upper-ve.proportion)**2+(xe.proportion-xe.lower)**2);return{estimate:Ee,lower:Le,upper:He}}function se(ce,ae,ge,de){const me=D(ae),ve=new Set,xe=[];for(const Be of ce){const Ge=new Map;let et=0;for(const Je of Be.rows){const ft=l(me(Je));ft!==null&&(Ge.set(ft,(Ge.get(ft)||0)+1),et++,ve.add(ft))}xe.push(Ge),Be.total=et}const Ee=[...ve];if(Ee.length<2)return null;const Le=ce.reduce((Be,Ge)=>Be+Ge.total,0);if(!(Le>0))return null;let He=0;for(const Be of ce)for(const Ge of Ee){const et=xe[ce.indexOf(Be)].get(Ge)||0,Je=ce.reduce((Et,Mt)=>Et+(xe[ce.indexOf(Mt)].get(Ge)||0),0),ft=Be.total*Je/Le;ft>0&&(He+=(et-ft)*(et-ft)/ft)}const Me=ce.length,Ke=Ee.length,$e=(Me-1)*(Ke-1),Oe=Math.min(1,Math.max(0,r(He,$e))),Se=E(He,Le,Me,Ke);let Pe=null;if(Me===2&&Ke===2){const[Be]=Ee,Ge=xe[0].get(Be)||0,et=xe[1].get(Be)||0,Je=ne(Ge,ce[0].total,et,ce[1].total,de);Je&&(Pe={...Je,confidence:de,method:"newcombe (difference in this category's share)",category:Be})}const Te=ce.map((Be,Ge)=>{const et={};for(const Je of Ee)et[String(Je)]=(xe[Ge].get(Je)||0)/Be.total;return et});return{test:c.CHI_SQUARE,statistic:He,statisticName:"chiSquare",df:$e,pValue:Oe,difference:null,interval:Pe,effectSize:{name:"cramersV",label:Y("cramersV",Se,Math.min(Me-1,Ke-1)),value:Se},proportions:Te}}function le(ce,ae,ge,de){const me=D(ae),ve=new Set;for(const Je of ce)for(const ft of Je.rows){const Et=l(me(ft));Et!==null&&ve.add(Et)}if(ve.size!==2)return null;const[xe]=[...ve],Ee=ce[0].rows.reduce((Je,ft)=>Je+(l(me(ft))===xe?1:0),0),Le=ce[1].rows.reduce((Je,ft)=>Je+(l(me(ft))===xe?1:0),0),He=ce[0].rows.length,Me=ce[1].rows.length;if(!(He>0)||!(Me>0))return null;const Ke=Ee/He,$e=Le/Me,Oe=(Ee+Le)/(He+Me);if(!(Oe>0)||!(Oe<1))return null;const Se=Math.sqrt(Oe*(1-Oe)*(1/He+1/Me)),Pe=(Ke-$e)/Se,Te=Math.min(1,Math.max(0,2*g(-Math.abs(Pe)))),Be=Ke-$e,Ge=ne(Ee,He,Le,Me,de),et=E(Pe*Pe,He+Me,2,2);return{test:c.PROPORTIONS,statistic:Pe,statisticName:"z",df:null,pValue:Te,difference:Be,interval:Ge?{...Ge,confidence:de,method:"newcombe (difference in proportions)",category:xe}:null,effectSize:{name:"cramersV",label:Y("cramersV",et,1),value:et},proportions:[{[String(xe)]:Ke},{[String(xe)]:$e}],focalCategory:xe}}function ye(ce,ae,ge,de){if(ge&&u.has(ge))return{test:ge,reason:`caller override: ${ge}`};const me=$(ce),ve=$(ae),xe=me===null?null:Math.exp(-me/2),Ee=ve===null?null:Math.exp(-ve/2);if(xe!==null&&xe<t||Ee!==null&&Ee<t)return{test:c.MANN_WHITNEY,reason:"two numeric groups, non-normal by Jarque-Bera"};const Le=w(ce),He=w(ae);if(Le.n>=3&&He.n>=3&&Le.variance>0&&He.variance>0){const Me=Math.max(Le.variance,He.variance)/Math.min(Le.variance,He.variance),Ke=Le.variance>=He.variance?Le.n-1:He.n-1,$e=Le.variance>=He.variance?He.n-1:Le.n-1;if(2*Math.min(v(Me,Ke,$e),1-v(Me,Ke,$e))<de)return{test:c.WELCH,reason:"two numeric groups, unequal variances (F-test)"}}return{test:c.T,reason:xe!==null||Ee!==null?"two numeric groups, equal variances and no departure from normality":"two numeric groups (too few rows to screen normality)"}}function fe(ce,ae){if(ae&&n.has(ae))return{test:ae,reason:`caller override: ${ae}`};for(const ge of ce){const de=$(ge),me=de===null?null:Math.exp(-de/2);if(me!==null&&me<t)return{test:c.KRUSKAL,reason:"three or more numeric groups, non-normal by Jarque-Bera"}}return{test:c.ANOVA,reason:"three or more numeric groups, no departure from normality detected"}}function we(ce,ae,ge,de={},me=null){if(!ce||!ae)return null;const ve=b(de.alpha),xe=1-ve,Ee=de.test&&de.test!=="auto"?String(de.test):null,Le=p(ae,ge);if(Le.length<2)return T("compare:groups",'[lattice] statistics.compare: the "by" column has fewer than two distinct values to group by.'),null;let He;if(Array.isArray(de.groups)&&de.groups.length===2){const Ge=[l(de.groups[0]),l(de.groups[1])];if(Ge[0]===null||Ge[1]===null||Ge[0]===Ge[1])return T("compare:distinct","[lattice] statistics.compare: the two groups must be two distinct, present values."),null;if(He=Le.filter(et=>et.value===Ge[0]||et.value===Ge[1]),He.length!==2)return T("compare:empty","[lattice] statistics.compare: one of the two groups has no rows in the current set."),null;He.sort((et,Je)=>et.value===Ge[0]?-1:1)}else Le.length===2||Ee&&u.has(Ee)||Ee&&m.has(Ee)?He=Le.slice(0,2):(Ee&&n.has(Ee),He=Le);const Ke=X(ce,ge),$e=!!de.paired&&me&&He.length===2&&Ke;let Oe,Se,Pe;if(Ke)if(He.length===2&&!(Ee&&n.has(Ee))){const Ge=Z(ce,He[0].rows),et=Z(ce,He[1].rows);if(Ge.length<3||et.length<3)return T("compare:small","[lattice] statistics.compare: each group needs at least three readings to compare."),null;if(w(Ge).variance===0||w(et).variance===0)return T("compare:zero-variance","[lattice] statistics.compare: a group has zero variance, so the difference has no scale to test."),null;if($e){const ft=Ce(ce,me,He[0].rows,He[1].rows);return ft?(Se=Ee?"override":"auto",Pe=Ee?`caller override: ${Ee} (paired)`:"two numeric groups, paired",Oe=Ee===c.MANN_WHITNEY?_(ft.diffs,ve):U(ft.diffs,ve),Oe?(Oe.paired=!0,Oe.chosenBy=Se,Oe.reason=Pe,Oe.groups=[{value:He[0].value,label:String(He[0].value),n:ft.n},{value:He[1].value,label:String(He[1].value),n:ft.n}],Oe.alpha=ve,Oe.method=Oe.test===c.MANN_WHITNEY?"Wilcoxon signed-rank test (paired)":"Student's paired t-test (difference of pairs)",Oe.verdict=M(Oe,de),Oe.categorical=!1,Oe):(T("compare:degenerate","[lattice] statistics.compare: the paired test had too little to work with."),null)):(T("compare:paired","[lattice] statistics.compare: not enough matched pairs to run a paired test."),null)}const Je=ye(Ge,et,Ee,ve);Se=Ee?"override":"auto",Pe=Je.reason,Je.test===c.MANN_WHITNEY?Oe=N(Ge,et,ve):Je.test===c.WELCH?Oe=q(Ge,et,ve):Oe=W(Ge,et,ve),Oe&&Oe.interval&&Oe.difference===null&&(Oe.difference=Oe.interval.estimate)}else{const Ge=He.map(Je=>Z(ce,Je.rows));if(Ge.some(Je=>Je.length<3))return T("compare:small","[lattice] statistics.compare: each group needs at least three readings to compare."),null;const et=fe(Ge,Ee);Se=Ee?"override":"auto",Pe=et.reason,Oe=et.test===c.KRUSKAL?ee(Ge,ve):J(Ge,ve)}else if(He.length===2){const Ge=ke(ce,He).size===2;if(Ee===c.PROPORTIONS||Ge&&!Ee)Se=Ee?"override":"auto",Pe=Ee?"caller override: proportions":"categorical measure with two categories (binary)",Oe=le(He,ce,ve,xe);else if(Ee===c.CHI_SQUARE||!Ge&&!Ee)Se=Ee?"override":"auto",Pe=Ee?"caller override: chiSquare":`categorical measure with ${ke(ce,He).size} categories`,Oe=se(He,ce,ve,xe);else return T("compare:numeric-needed",`[lattice] statistics.compare: ${Ee} needs a numeric measure, but the column is categorical.`),null}else Se=Ee?"override":"auto",Pe=Ee?`caller override: ${Ee}`:`categorical measure with ${ke(ce,He).size} categories`,Oe=se(He,ce,ve,xe);if(!Oe)return T("compare:degenerate","[lattice] statistics.compare: the chosen test had too little to work with (too few values, or no variation)."),null;const Te=Oe.summaries,Be=Oe.proportions;return{test:Oe.test,chosenBy:Se,reason:Pe,statistic:Oe.statistic,statisticName:Oe.statisticName,df:Oe.df===void 0?null:Oe.df,pValue:Oe.pValue,alpha:ve,paired:!1,interval:Oe.interval||null,effectSize:Oe.effectSize,groups:He.map((Ge,et)=>({value:Ge.value,label:String(Ge.value),n:Te?Te[et].n:Ge.total,...Te?{mean:Te[et].mean,sd:Te[et].sd}:{},...Be?{proportions:Be[et]}:{}})),difference:Oe.difference===void 0?null:Oe.difference,method:Oe.test,categorical:!Ke,verdict:He.length===2?M({...Oe,alpha:ve,groups:[{value:He[0].value,label:String(He[0].value),mean:Te?Te[0].mean:void 0},{value:He[1].value,label:String(He[1].value),mean:Te?Te[1].mean:void 0}],categorical:!Ke,difference:Oe.difference===void 0?null:Oe.difference},de):x({...Oe,alpha:ve},de)}}function ke(ce,ae){const ge=D(ce),de=new Set;for(const me of ae)for(const ve of me.rows){const xe=l(ge(ve));xe!==null&&de.add(xe)}return de}function Ce(ce,ae,ge,de){const me=D(ae),ve=D(ce),xe=new Map;for(const Le of de){const He=l(me(Le));He!==null&&xe.set(He,ve(Le))}const Ee=[];for(const Le of ge){const He=l(me(Le));if(He===null||!xe.has(He))continue;const Me=Number(ve(Le)),Ke=Number(xe.get(He));!Number.isFinite(Me)||!Number.isFinite(Ke)||Ee.push(Me-Ke)}return Ee.length<2?null:{diffs:Float64Array.from(Ee),n:Ee.length}}}),Ue("packages/core/src/columns/detailcolumn.js",function(e,B){"use strict";Object.defineProperty(e,"DETAIL_COLUMN_ID",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"createDetailColumn",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return D}});const re="__lattice_detail",T=36;function G(I){const Z=I.config&&I.config.detailColumnWidth||T;return{id:re,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:I.config&&I.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(z,L){return!!(L&&L.expanded)},formatValue(){return""}}}const D=G}),Ue("packages/core/src/columns/treecolumn.js",function(e,B){"use strict";Object.defineProperty(e,"TREE_COLUMN_ID",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"createTreeColumn",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const T=B("packages/core/src/internal/predicates.js").isFunction,G="__lattice_tree",D=260;function I(z){const L=z.tree||{},X=z.config&&z.config.treeColumnWidth||D,$=!!(z.config&&z.config.treeColumnFlex),A=()=>(z.columns&&T(z.columns.visible)?z.columns.visible():[]).find(g=>!g.generated)||null,k=(f,g)=>{if(g&&g.group)return g.groupValue;if(T(L.label))return L.label(f,g);if(typeof L.label=="string")return f==null?null:f[L.label];const a=A();return a&&T(a.getValue)?a.getValue(f,g):null},y=()=>{if(L.title)return L.title;const f=typeof L.label=="string"?z.columns&&T(z.columns.get)?z.columns.get(L.label):null:A();return f&&(f.title||f.id)||"Hierarchy"};return{id:G,get title(){return y()},field:null,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group",props:{icon:L.icon,iconClass:L.iconClass,content:L.content,checkbox:L.checkbox,onCheck:L.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:$?{flex:1,min:0,pin:z.config&&z.config.treeColumnPin||null,hidden:!1,resizable:!1,movable:!1,lockPosition:!0}:{width:X,min:140,pin:z.config&&z.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(f,g){return k(f,g)},formatValue(f,g){if(g&&g.grandTotal)return z.config&&z.config.grandTotalLabel||"Total";if(f==null)return"";if(!L.label){const a=A();if(a&&T(a.formatValue))return a.formatValue(f,g)}return String(f)}}}const Z=I}),Ue("packages/core/src/columns/pivotcolumns.js",function(e,B){"use strict";Object.defineProperty(e,"PIVOT_PREFIX",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"createPivotColumns",{enumerable:!0,get:function(){return I}});const T=B("packages/core/src/internal/warn.js").warnOnce,G="__lattice_pivot",D=500;function I(X){const{pivot:$,valueColumns:A,config:k}=X,y=$&&$.paths||[],f=X.separator||k&&k.pivot&&k.pivot.separator||" | ",g=k&&k.pivot&&k.pivot.maxColumns||D;if(!y.length||!A.length)return{tree:[],leaves:[],error:null};const a=Z(k),r=y.length*A.length+(a?A.length:0);if(r>g){const u=`pivot would generate ${r} columns, above the limit of ${g}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return T(`pivot.maxColumns:${r}`,u),{tree:[],leaves:[],error:u}}const i=[],c=[];for(const u of y){const n=[];for(const m of A){const t=L(u,m,f);n.push(t),c.push(t)}n.length===1?(n[0].title=String(u),i.push(n[0])):i.push({id:`${G}:group:${u}`,title:String(u),columns:n,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(a){const u=A.map(m=>z(m,k));c.push(...u);const n=k&&k.pivot&&k.pivot.totalsLabel||"Total";if(u.length===1)u[0].title=n,a==="before"?i.unshift(u[0]):i.push(u[0]);else{const m={id:`${G}:group:__totals`,title:n,columns:u,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};a==="before"?i.unshift(m):i.push(m)}}return{tree:i,leaves:c,error:null}}function Z(X){const $=X&&X.pivot&&X.pivot.groupTotals;return $==="before"||$==="after"?$:null}function z(X,$){return{id:`${G}:__total${$&&$.pivot&&$.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(A,k){const y=k&&k.totals;return y&&Object.hasOwn(y,X.id)?y[X.id]:null},formatValue(A,k){return A==null?"":X.formatValue?X.formatValue(A,k):String(A)}}}function L(X,$,A){return{id:`${G}:${X}${A}${$.id}`,field:null,title:$.title||$.id,type:$.type,dataType:$.dataType,nullable:!0,align:$.align,generated:!0,pivot:{enabled:!1,index:0,path:X,sourceId:$.id},value:{pure:!0},cell:{align:$.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:$.total,lookup:null,layout:{width:$.layout&&$.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,y){return k==null?"":$.formatValue?$.formatValue(k,y):String(k)}}}}),Ue("packages/core/src/compute/group.js",function(e,B){"use strict";Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return k}});const re=B("packages/core/src/compute/handle.js"),T=re.dictSize,G=re.identity,D=re.presenceReader,I=re.rowCount,Z=re.valueReader,z="",L="\0",X=1<<20;function $(y,f,g,a){const r=y.length,i=y.map(s=>Z(s)),c=Array.isArray(a)&&a.some(Boolean),u=c?i.map((s,h)=>a[h]?d=>a[h](s(d)):s):i;if(!c&&r>0&&y.every(s=>s&&s.kind==="dictionary"&&s.dict)){const s=y.map(d=>T(d.dict)+1);let h=1;for(let d=0;d<r;d++)h*=s[d];if(h<=Number.MAX_SAFE_INTEGER){const d=y.map(p=>p.values),o=y.map(p=>D(p)),b=p=>{let w=0;for(let v=0;v<r;v++){const R=o[v],Y=R&&R(p)===0?s[v]-1:d[v][p];w=w*s[v]+Y}return w},l=new Float64Array(g);for(let p=0;p<g;p++)l[p]=b(f[p]);return{packed:l,strings:null,product:h,readers:u,keyOf:b}}}const m=s=>{let h="";for(let d=0;d<r;d++){const o=u[d](s);h+=(d===0?"":z)+(o==null?L:String(o))}return h},t=new Array(g);for(let s=0;s<g;s++)t[s]=m(f[s]);return{packed:null,strings:t,product:1/0,readers:u,keyOf:m}}function A(y,f,g,a){const r=new Uint32Array(a+1);for(let n=0;n<g;n++)r[f[n]+1]++;for(let n=0;n<a;n++)r[n+1]+=r[n];const i=new Uint32Array(g),c=r.slice(0,a);for(let n=0;n<g;n++)i[c[f[n]]++]=y[n];const u=new Array(a);for(let n=0;n<a;n++)u[n]=i.subarray(r[n],r[n+1]);return u}function k(y,f,g={}){const a=y||[],r=f||G(I(a[0],g)),i=r.length;if(a.length===0||i===0)return{keys:[],buckets:[]};const{packed:c,strings:u,product:n,readers:m}=$(a,r,i,g.project),t=new Uint32Array(i);let s=0,h=null;if(c&&n<=Math.max(1024,Math.min(X,i*4))){const l=n,p=new Int32Array(l).fill(-1);for(let w=0;w<i;w++)p[c[w]]=0;for(let w=0;w<l;w++)p[w]===0&&(p[w]=s++);for(let w=0;w<i;w++)t[w]=p[c[w]];h=new Float64Array(s);for(let w=0;w<l;w++)p[w]>=0&&(h[p[w]]=w)}else if(c){const l=new Map;for(let p=0;p<i;p++){const w=c[p];let v=l.get(w);v===void 0&&(v=s++,l.set(w,v)),t[p]=v}h=new Float64Array(s);for(const[p,w]of l)h[w]=p}else{const l=new Map;for(let p=0;p<i;p++){const w=u[p];let v=l.get(w);v===void 0&&(v=s++,l.set(w,v)),t[p]=v}}const d=A(r,t,i,s),o=new Array(s);for(let l=0;l<s;l++){const p=d[l][0],w=new Array(m.length);for(let v=0;v<m.length;v++)w[v]=m[v](p);o[l]=w}const b={keys:o,buckets:d};return h&&(b.packed=h),b}}),Ue("packages/core/src/compute/pivot.js",function(e,B){"use strict";Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return i}});const T=B("packages/core/src/internal/warn.js").warnOnce,D=B("packages/core/src/compute/handle.js").valueComparator,Z=B("packages/core/src/compute/group.js").packKeys,L=B("packages/core/src/compute/total.js").total,X="|",$="/",A=2e3;function k(n,m,t){return`${n}${X}${m}${X}${t}`}function y(n,m){let t="";for(let s=0;s<n.length;s++){const h=n[s];t+=(s===0?"":m)+(h==null?"":String(h))}return t}function f(n,m,t={}){const s=t.separator||$,h=m.length,{keyOf:d,readers:o}=Z(n,m,0),b=new Map,l=[],p=[];for(let E=0;E<h;E++){const O=m[E],C=d(O);if(b.has(C))continue;b.set(C,l.length),p.push(C);const S=new Array(o.length);for(let F=0;F<o.length;F++)S[F]=o[F](O);l.push(S)}const w=D(t.locale),v=l.map((E,O)=>O);v.sort((E,O)=>{const C=l[E],S=l[O];for(let F=0;F<C.length;F++){const P=g(C[F],S[F],w);if(P!==0)return P}return E-O});const R=new Array(v.length),Y=new Array(v.length),K=new Map;for(let E=0;E<v.length;E++){const O=v[E];R[E]=l[O],Y[E]=y(l[O],s),K.set(p[O],E)}return{keys:R,paths:Y,idOf:E=>{const O=K.get(d(E));return O===void 0?-1:O}}}function g(n,m,t){const s=n==null,h=m==null;return s||h?s&&h?0:s?1:-1:t(n,m)}function a(n){const m=n.values||n.totals||[];if(m.length&&typeof m[0]=="object"&&m[0]!==null)return m.filter(d=>d&&d.handle);const t=typeof n.handle=="function"?n.handle:null;if(!t)return m.length&&T("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 s=typeof n.totalOf=="function"?n.totalOf:null,h=[];for(const d of m){const o=t(d);o&&h.push({colId:d,handle:o,fn:s?s(d):"sum"})}return h}function r(n,m,t){if(Array.isArray(n)){const s=t||{};return{...s,pivotHandles:n,order:m||null,groups:s.groups||null}}return n||{}}function i(n,m,t){const s=r(n,m,t),h=s.separator||$,d=a(s),o=s.maxColumns===void 0?A:s.maxColumns,b=s.groups&&s.groups.buckets?s.groups:null,l=b?b.buckets:[s.order||new Uint32Array(0)],p=s.groupPaths||(b?b.keys.map(C=>y(C,h)):[""]),w=u(l),{keys:v,paths:R,idOf:Y}=f(s.pivotHandles||[],w,s),K=R.length*Math.max(1,d.length),V=c(R,d,h);if(o&&K>o){const C=new Map;return{keys:v,paths:R,fields:V,groupPaths:p,columns:K,values:C,cells:C,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${K} columns, above pivot.maxColumns of ${o}. Narrow the pivot columns or raise the limit.`,columns:K,maxColumns:o}}}const E=new Map,O=R.length;for(let C=0;C<l.length;C++){const S=l[C],F=p[C]===void 0?"":p[C],P=S.length;if(P===0)continue;const M=new Int32Array(P),x=new Uint32Array(O+1);for(let W=0;W<P;W++){const q=Y(S[W]);M[W]=q,q>=0&&x[q+1]++}for(let W=0;W<O;W++)x[W+1]+=x[W];const U=new Uint32Array(P),_=x.slice(0,O);for(let W=0;W<P;W++){const q=M[W];q>=0&&(U[_[q]++]=S[W])}for(let W=0;W<O;W++){const q=x[W],N=x[W+1];if(N===q)continue;const Q=U.subarray(q,N);for(let J=0;J<d.length;J++){const ee=d[J],ne=L(ee.handle,Q,ee.fn,s.totalContext||{locale:s.locale});E.set(k(F,R[W],ee.colId),ne)}}}return{keys:v,paths:R,fields:V,groupPaths:p,columns:K,values:E,cells:E,error:null}}function c(n,m,t){if(m.length===0)return n.slice();const s=[];for(const h of n)for(const d of m)s.push(`${h}${t}${d.colId}`);return s}function u(n){if(n.length===1)return n[0]||new Uint32Array(0);let m=0;for(const h of n)m+=h?h.length:0;const t=new Uint32Array(m);let s=0;for(const h of n)!h||h.length===0||(t.set(h,s),s+=h.length);return t}}),Ue("packages/core/src/compute/explain.js",function(e,B){"use strict";Object.defineProperty(e,"explainContributors",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"explainChange",{enumerable:!0,get:function(){return k}});const T=B("packages/core/src/compute/total.js").total,D=B("packages/core/src/compute/group.js").groupByColumns,I=new Set(["sum","count","countValues"]),Z=new Set(["min","max"]),z=new Set(["avg"]);function L(y){return typeof y=="string"?y:typeof y=="function"&&y.totalName?y.totalName:null}function X(y,f,g,a){return T(y,f,g,a||{})}function $(y,f){if(f)try{return f(y)}catch{}return y==null?"":String(y)}function A(y){const{handle:f,fn:g,leaves:a,by:r,labelOf:i,rowLabel:c}=y,u={locale:y.locale},n=a&&a.length?a:[],m=L(g),t=X(f,n,g,u),s=Z.has(m);let h;if(s){let b=-1;for(let l=0;l<n.length;l++){const p=X(f,[n[l]],g,u);if(Object.is(p,t)){b=n[l];break}}h=b<0?[]:[{key:b,indices:[b],label:c?c(b):String(b)}]}else if(r){const b=D([r],n);h=b.keys.map((l,p)=>({key:l[0],indices:b.buckets[p],label:$(l[0],i)}))}else h=Array.from({length:n.length},(b,l)=>{const p=n[l];return{key:p,indices:[p],label:c?c(p):String(p)}});const d=n.length,o=[];for(const b of h){const l=X(f,b.indices,g,u),p=b.indices.length;let w,v;if(m==="avg")w=((typeof l=="number"?l:0)-(typeof t=="number"?t:0))*p,v=d?p/d:0;else if(s)w=typeof l=="number"?l:0,v=1;else{w=typeof l=="number"?l:0;const R=typeof t=="number"?t:0;v=R?w/R:0}o.push({key:b.key,label:b.label,count:p,value:l,contribution:w,share:v})}return o.sort((b,l)=>Math.abs(l.contribution)-Math.abs(b.contribution)||(b.label<l.label?-1:b.label>l.label?1:0)),{total:t,fn:m,weighted:z.has(m),single:s,contributors:o}}function k(y){const f=A({...y,leaves:y.after}),g=A({...y,leaves:y.before}),a=typeof f.total=="number"?f.total:0,r=typeof g.total=="number"?g.total:0,i=new Map;for(const n of f.contributors)i.set(n.key,n);const c=[],u=new Set;for(const n of g.contributors){u.add(n.key);const m=i.get(n.key);if(m===void 0)c.push({key:n.key,label:n.label,before:n.value,after:null,effect:-n.contribution,kind:"dropped",count:n.count});else{const t=m.contribution-n.contribution;t!==0&&c.push({key:n.key,label:n.label,before:n.value,after:m.value,effect:t,kind:"changed",count:m.count})}}for(const n of f.contributors)u.has(n.key)||c.push({key:n.key,label:n.label,before:null,after:n.value,effect:n.contribution,kind:"new",count:n.count});return c.sort((n,m)=>Math.abs(m.effect)-Math.abs(n.effect)||(n.label<m.label?-1:n.label>m.label?1:0)),{before:g.total,after:f.total,delta:a-r,weighted:f.weighted||g.weighted,single:f.single||g.single,drivers:c}}}),Ue("packages/core/src/store/bitset.js",function(e,B){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return T}});const re=8;class T{static#e=new Uint8Array(256);static{for(let D=1;D<256;D++)T.#e[D]=T.#e[D>>1]+(D&1)}#t;#n;constructor(D=0){const I=Math.max(0,D|0);this.#n=I,this.#t=new Uint8Array(Math.ceil(I/re))}get size(){return this.#n}get words(){return this.#t}get bytes(){return this.#t?this.#t.byteLength:0}get(D){return D<0||D>=this.#n?0:this.#t[D>>3]>>(D&7)&1}set(D){return D>=0&&D<this.#n&&(this.#t[D>>3]|=1<<(D&7)),this}clear(D){return D>=0&&D<this.#n&&(this.#t[D>>3]&=~(1<<(D&7))),this}assign(D,I){return I?this.set(D):this.clear(D)}fill(D=!1){return this.#t.fill(D?255:0),D&&this.#r(),this}grow(D){const I=Math.max(0,D|0);if(I<=this.#n)return this;const Z=Math.ceil(I/re);if(Z>this.#t.length){const z=new Uint8Array(Z);z.set(this.#t),this.#t=z}return this.#n=I,this}count(){const D=this.#t,I=T.#e;let Z=0;for(let z=0;z<D.length;z++)Z+=I[D[z]];return Z}and(D){const I=D instanceof T?D.words:D,Z=this.#t,z=Math.min(Z.length,I.length);for(let L=0;L<z;L++)Z[L]&=I[L];for(let L=z;L<Z.length;L++)Z[L]=0;return this}or(D){const I=D instanceof T?D.words:D,Z=this.#t,z=Math.min(Z.length,I.length);for(let L=0;L<z;L++)Z[L]|=I[L];return this}not(){const D=this.#t;for(let I=0;I<D.length;I++)D[I]=~D[I]&255;return this.#r(),this}clone(){const D=new T(this.#n);return D.words.set(this.#t.subarray(0,D.words.length)),D}release(){this.#t=new Uint8Array(0),this.#n=0}#r(){const D=this.#n&7;if(D===0)return;const I=this.#n>>3;I<this.#t.length&&(this.#t[I]&=(1<<D)-1)}static from(D){const I=Array.isArray(D)?D:Array.from(D),Z=new T(I.length);for(let z=0;z<I.length;z++)I[z]&&Z.set(z);return Z}}}),Ue("packages/core/src/store/dictionary.js",function(e,B){"use strict";Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return D}});const re=B("packages/core/src/internal/compare.js"),T=re.collator,G=re.defaultCompare;class D{#e;#t=new Map;#n=0;#r=null;#i=-1;#s="\0";constructor(Z=[]){this.#e=[];for(let z=0;z<Z.length;z++){const L=Z[z];this.#t.has(L)||(this.#t.set(L,this.#e.length),this.#e.push(L))}}get size(){return this.#e.length}get version(){return this.#n}get bytes(){let Z=this.#e.length*8;for(let z=0;z<this.#e.length;z++){const L=this.#e[z];typeof L=="string"&&(Z+=L.length*2),Z+=16}return Z}codeOf(Z){const z=this.#t.get(Z);if(z!==void 0)return z;const L=this.#e.length;return this.#e.push(Z),this.#t.set(Z,L),this.#n++,L}lookup(Z){const z=this.#t.get(Z);return z===void 0?-1:z}has(Z){return this.#t.has(Z)}valueOf(Z){return this.#e[Z]}values(){return this.#e}ranks(Z){const z=Z||"";if(this.#r&&this.#i===this.#n&&this.#s===z)return this.#r;const L=this.#e.length,X=new Array(L);for(let y=0;y<L;y++)X[y]=y;const $=T(Z).compare,A=this.#e;X.sort((y,f)=>this.#a(A[y],A[f],$));const k=new Uint32Array(L);for(let y=0;y<L;y++)k[X[y]]=y;return this.#r=k,this.#i=this.#n,this.#s=z,k}#a(Z,z,L){return typeof Z=="string"&&typeof z=="string"?L(Z,z):G(Z,z)}}}),Ue("packages/core/src/store/multivalue.js",function(e,B){"use strict";Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return re}});class re{#e;#t;#n=0;#r=0;constructor(G={}){const D=Math.max(1,G.rows??16),I=Math.max(1,G.values??D);this.#e=new Int32Array(I),this.#t=new Uint32Array(D+1)}get values(){return this.#e}get offsets(){return this.#t}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#e.byteLength+this.#t.byteLength}count(G){return G<0||G>=this.#n?0:this.#t[G+1]-this.#t[G]}at(G){return G<0||G>=this.#n?this.#e.subarray(0,0):this.#e.subarray(this.#t[G],this.#t[G+1])}has(G,D){if(G<0||G>=this.#n)return!1;const I=this.#e,Z=this.#t[G+1];for(let z=this.#t[G];z<Z;z++)if(I[z]===D)return!0;return!1}hasAny(G,D){for(let I=0;I<D.length;I++)if(this.has(G,D[I]))return!0;return!1}hasAll(G,D){for(let I=0;I<D.length;I++)if(!this.has(G,D[I]))return!1;return!0}hasNone(G,D){return!this.hasAny(G,D)}push(G){const D=this.#n,I=G.length;this.#i(D+1),this.#s(this.#r+I);const Z=this.#r;for(let z=0;z<I;z++)this.#e[Z+z]=G[z]|0;return this.#r+=I,this.#n=D+1,this.#t[D]=Z,this.#t[D+1]=this.#r,D}write(G,D){if(G===this.#n){this.push(D);return}if(G<0||G>this.#n)return;const I=this.#t[G],Z=this.#t[G+1],z=D.length;if(Z-I===z){for(let L=0;L<z;L++)this.#e[I+L]=D[L]|0;return}this.#a(G,D)}compact(G,D,I){const Z=this.#e,z=this.#t,L=this.#n,X=new Int32Array(Math.max(1,this.#r)),$=new Uint32Array(D+1);let A=0;for(let k=0;k<L;k++){if(G[k]===I)continue;const y=z[k],f=z[k+1];$[G[k]]=A;for(let g=y;g<f;g++)X[A++]=Z[g];$[G[k]+1]=A}this.#e=X,this.#t=$,this.#n=D,this.#r=A}release(){this.#e=new Int32Array(0),this.#t=new Uint32Array(1),this.#n=0,this.#r=0}#i(G){if(G+1<=this.#t.length)return;let D=this.#t.length-1;for(;D<G;)D=D*2||16;const I=new Uint32Array(D+1);I.set(this.#t),this.#t=I}#s(G){if(G<=this.#e.length)return;let D=this.#e.length;for(;D<G;)D=D*2||16;const I=new Int32Array(D);I.set(this.#e),this.#e=I}#a(G,D){const I=this.#e,Z=this.#t,z=this.#n,L=D.length-(Z[G+1]-Z[G]),X=new Int32Array(Math.max(1,this.#r+L)),$=new Uint32Array(Z.length);let A=0;for(let k=0;k<z;k++){if($[k]=A,k===G)for(let y=0;y<D.length;y++)X[A++]=D[y]|0;else for(let y=Z[k];y<Z[k+1];y++)X[A++]=I[y];$[k+1]=A}this.#e=X,this.#t=$,this.#r=A}}}),Ue("packages/core/src/compute/sort.js",function(e,B){"use strict";Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return O}});const re=B("packages/core/src/compute/handle.js"),T=re.bitReader,G=re.dictRanks,D=re.dictSize,I=re.identity,Z=re.isMissing,z=re.presenceReader,L=re.rowCount,X=re.valueComparator,$=re.valueReader,A=new Uint32Array(0),k=new ArrayBuffer(8),y=new Float64Array(k),f=new Uint32Array(k),g=(y[0]=-1,(f[1]&2147483648)!==0?1:0),a=g===1?0:1;function r(S,F){y[0]=S;let P=f[g],M=f[a];(P&2147483648)!==0?(P=~P>>>0,M=~M>>>0):P=(P^2147483648)>>>0,F[0]=M,F[1]=P}function i(S,F,P,M){if(M<2)return S;const x=new Uint32Array(256*8);for(let ee=0;ee<M;ee++){const ne=F[ee],se=P[ee];x[ne&255]++,x[256+(ne>>>8&255)]++,x[512+(ne>>>16&255)]++,x[768+(ne>>>24&255)]++,x[1024+(se&255)]++,x[1280+(se>>>8&255)]++,x[1536+(se>>>16&255)]++,x[1792+(se>>>24&255)]++}let U=S,_=F,W=P,q=new Uint32Array(M),N=new Uint32Array(M),Q=new Uint32Array(M);const J=new Uint32Array(256);for(let ee=0;ee<8;ee++){const ne=ee<<8,se=(ee&3)<<3,le=ee>=4;let ye=!1;for(let ke=0;ke<256;ke++)if(x[ne+ke]===M){ye=!0;break}if(ye)continue;let fe=0;for(let ke=0;ke<256;ke++)J[ke]=fe,fe+=x[ne+ke];for(let ke=0;ke<M;ke++){const Ce=_[ke],ce=W[ke],ae=(le?ce:Ce)>>>se&255,ge=J[ae]++;q[ge]=U[ke],N[ge]=Ce,Q[ge]=ce}let we=U;U=q,q=we,we=_,_=N,N=we,we=W,W=Q,Q=we}return U}function c(S,F,P){if(P<2)return S;const M=new Uint32Array(256*4);for(let N=0;N<P;N++){const Q=F[N];M[Q&255]++,M[256+(Q>>>8&255)]++,M[512+(Q>>>16&255)]++,M[768+(Q>>>24&255)]++}let x=S,U=F,_=new Uint32Array(P),W=new Uint32Array(P);const q=new Uint32Array(256);for(let N=0;N<4;N++){const Q=N<<8,J=N<<3;let ee=!1;for(let le=0;le<256;le++)if(M[Q+le]===P){ee=!0;break}if(ee)continue;let ne=0;for(let le=0;le<256;le++)q[le]=ne,ne+=M[Q+le];for(let le=0;le<P;le++){const ye=U[le],fe=q[ye>>>J&255]++;_[fe]=x[le],W[fe]=ye}let se=x;x=_,_=se,se=U,U=W,W=se}return x}function u(S,F,P,M){const x=new Uint32Array(M+1);for(let W=0;W<P;W++)x[F[W]]++;let U=0;for(let W=0;W<=M;W++){const q=x[W];x[W]=U,U+=q}const _=new Uint32Array(P);for(let W=0;W<P;W++)_[x[F[W]]++]=S[W];return _}function n(S,F,P,M){return P<2?S:M<=65536||M<=P*2?u(S,F,P,M):c(S,F,P)}function m(S,F){return S.length===F&&S.byteOffset===0?S:Uint32Array.prototype.slice.call(S,0,F)}function t(S,F,P=!1){const M=F||I(S.length),x=M.length;if(x<2)return Uint32Array.from(M);const U=new Uint32Array(x),_=new Uint32Array(x),W=new Uint32Array(x),q=new Uint32Array(x),N=new Uint32Array(2);let Q=0,J=0;for(let se=0;se<x;se++){const le=M[se],ye=S[le];if(Number.isNaN(ye)){q[J++]=le;continue}r(ye,N),P?(_[Q]=~N[0]>>>0,W[Q]=~N[1]>>>0):(_[Q]=N[0],W[Q]=N[1]),U[Q++]=le}const ee=i(U.subarray(0,Q),_.subarray(0,Q),W.subarray(0,Q),Q);if(J===0)return m(ee,Q);const ne=new Uint32Array(x);return ne.set(ee.subarray(0,Q),0),ne.set(q.subarray(0,J),Q),ne}function s(S,F,P=!1){const M=F||I(S.length),x=M.length;if(x<2)return Uint32Array.from(M);const U=Uint32Array.from(M),_=new Uint32Array(x);for(let W=0;W<x;W++){const q=(S[U[W]]^2147483648)>>>0;_[W]=P?~q>>>0:q}return m(c(U,_,x),x)}function h(S,F,P={}){const M=F||I(L(S,P)),x=M.length;if(x<2)return Uint32Array.from(M);const U=G(S.dict,P.locale),_=S.values,W=z(S),q=Math.max(D(S.dict),U.length),N=q,Q=Uint32Array.from(M),J=new Uint32Array(x),ee=!!P.descending;for(let ne=0;ne<x;ne++){const se=Q[ne];let le=W&&W(se)===0?N:U[_[se]];le===void 0&&(le=N),J[ne]=ee?N-le:le}return m(n(Q,J,x,q+1),x)}function d(S,F,P){const M=F.length;let x=Uint32Array.from(F);if(M<2)return x;let U=new Uint32Array(M);for(let _=1;_<M;_<<=1){for(let q=0;q<M;q+=_<<1){const N=Math.min(q+_,M),Q=Math.min(q+(_<<1),M);let J=q,ee=N,ne=q;for(;J<N&&ee<Q;)U[ne++]=P(S[x[J]],S[x[ee]])<=0?x[J++]:x[ee++];for(;J<N;)U[ne++]=x[J++];for(;ee<Q;)U[ne++]=x[ee++]}const W=x;x=U,U=W}return x}function o(S,F,P){const M=T(S.values),x=F.length,U=new Uint32Array(x),_=P?1:0;let W=0;for(let q=0;q<x;q++)M(F[q])===_&&(U[W++]=F[q]);for(let q=0;q<x;q++)M(F[q])!==_&&(U[W++]=F[q]);return U}function b(S,F){const P=S.values,M=S.kind;if((M==="object"||M===void 0)&&(Array.isArray(P)||ArrayBuffer.isView(P))&&!S.presence)return P;const U=$(S),_=new Array(L(S)||0);for(let W=0;W<F.length;W++){const q=F[W];_[q]=U(q)}return _}function l(S,F){for(let P=0;P<F.length;P++)if(typeof S[F[P]]!="string")return!1;return!0}function p(S,F,P,M,x){const U=S.length,_=Uint32Array.from(S);if(U<2||M<1)return _;const W=new Uint32Array(U),q=M-1;for(let N=0;N<U;N++){const Q=P[F[N]];W[N]=x?q-Q:Q}return m(n(_,W,U,M),U)}function w(S,F,P){const M=X(P),x=new Array(F);for(let _=0;_<F;_++)x[_]=_;x.sort((_,W)=>M(S[_],S[W])||_-W);const U=new Uint32Array(F);for(let _=0;_<F;_++)U[x[_]]=_;return U}function v(S,F,P){const M=F.length,x=new Map,U=[],_=new Uint32Array(M);for(let N=0;N<M;N++){const Q=S[F[N]];let J=x.get(Q);J===void 0&&(J=U.length,x.set(Q,J),U.push(Q)),_[N]=J}const W=U.length,q=w(U,W,P.locale);return p(F,_,q,W,!!P.descending)}function R(S,F,P){const M=b(S,F);if(F.length>=2&&l(M,F)){const _=S.stringRank;return _&&_.version===S.version&&_.usable(F,M,P.locale)?_.sort(F,P):v(M,F,P)}const x=X(P.locale),U=P.descending?(_,W)=>x(W,_):x;return d(M,F,U)}function Y(S,F,P){const M=b(S,F),x=P.compare,_=!!P.descending?(W,q)=>-x(W,q,void 0,void 0,!0):(W,q)=>x(W,q,void 0,void 0,!1);return d(M,F,_)}function K(S,F){const P=F.length,M=z(S),x=S.values,U=S.kind==="float64"&&!!x,_=S.kind==="object"||S.kind==="multi"||S.kind===void 0;if(!M&&!U&&!_)return{present:F,absent:A};const W=new Uint32Array(P),q=new Uint32Array(P);let N=0,Q=0;if(M&&U)for(let J=0;J<P;J++){const ee=F[J];M(ee)===1&&!Number.isNaN(x[ee])?W[N++]=ee:q[Q++]=ee}else if(U&&!M)for(let J=0;J<P;J++){const ee=F[J];Number.isNaN(x[ee])?q[Q++]=ee:W[N++]=ee}else if(M&&!_)for(let J=0;J<P;J++){const ee=F[J];M(ee)===1?W[N++]=ee:q[Q++]=ee}else{const J=$(S);for(let ee=0;ee<P;ee++){const ne=F[ee];Z(J(ne))?q[Q++]=ne:W[N++]=ne}}return Q===0?{present:F,absent:A}:{present:W.subarray(0,N),absent:q.subarray(0,Q)}}function V(S,F,P){if(F.length===0)return S;const M=new Uint32Array(S.length+F.length);return P?(M.set(F,0),M.set(S,F.length)):(M.set(S,0),M.set(F,S.length)),M}function E(S,F,P={}){const M=F||I(L(S,P));if(!S||M.length<2)return Uint32Array.from(M);const{present:x,absent:U}=K(S,M);if(x.length===0)return Uint32Array.from(M);const _=!!P.descending;let W;if(typeof P.compare=="function")W=Y(S,x,P);else switch(S.kind){case"float64":W=t(S.values,x,_);break;case"int32":W=s(S.values,x,_);break;case"dictionary":W=h(S,x,P);break;case"bitset":W=o(S,x,_);break;default:W=R(S,x,P);break}return V(W,U,!!P.nullsFirst)}function O(S,F,P,M={}){const x=F||[],U=x.length&&(x[0].handle||C(S,x[0].col))||S&&S[0];let _=P||I(L(U,M));for(let W=x.length-1;W>=0;W--){const q=x[W],N=q.handle||C(S,q.col)||S&&S[W];N&&(_=E(N,_,{descending:q.descending!==void 0?!!q.descending:q.dir==="desc",nullsFirst:!!q.nullsFirst,locale:q.locale!==void 0?q.locale:M.locale,compare:q.compare}))}return _ instanceof Uint32Array?_:Uint32Array.from(_)}function C(S,F){if(!(!S||F===void 0)){for(let P=0;P<S.length;P++)if(S[P]&&S[P].id===F)return S[P]}}}),Ue("packages/core/src/store/stringrank.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"StringRankIndex",{enumerable:!0,get:function(){return I}});const re=B("packages/core/src/compute/sort.js"),T=re.collateStringRanks,G=re.rankSortStrings,D=1e5;class I{#e=[];#t=new Map;#n;#r=0;#i=0;#s=-1;#a;#l=!1;#o=null;#c=-1;#u="\0";constructor(z=D){this.#a=z>0?z:D,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(z){this.#s=z}get generation(){return this.#i}get size(){return this.#e.length}get capped(){return this.#l}get length(){return this.#r}get bytes(){let z=this.#n.byteLength;const L=this.#e;for(let X=0;X<L.length;X++)z+=L[X].length*2+24;return z}#f(z,L){const X=this.#t.get(z);if(X!==void 0)return X;if(this.#l)return-1;if(L&&this.#e.length>=this.#a)return this.#l=!0,-1;const $=this.#e.length;return this.#e.push(z),this.#t.set(z,$),this.#i++,$}build(z,L){const X=L|0;this.#e=[],this.#t=new Map,this.#i=0,this.#l=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(X);for(let $=0;$<X;$++){const A=z[$],k=typeof A=="string"?this.#f(A,!1):-1;this.#n[$]=k<0?0:k}this.#r=X}append(z,L,X){const $=(L|0)+(X|0);if($>this.#n.length){const A=new Uint32Array($);A.set(this.#n.subarray(0,this.#r)),this.#n=A}for(let A=L|0;A<$;A++){const k=z[A],y=typeof k=="string"?this.#f(k,!0):-1;this.#n[A]=y<0?0:y}this.#r=Math.max(this.#r,$)}ranks(z){const L=z||"";if(this.#o&&this.#c===this.#i&&this.#u===L)return this.#o;const X=T(this.#e,this.#e.length,z);return this.#o=X,this.#c=this.#i,this.#u=L,X}usable(z,L,X){if(this.#l||this.#e.length===0)return!1;const $=this.#n,A=this.#e,k=this.#r;for(let y=0;y<z.length;y++){const f=z[y];if(f>=k||A[$[f]]!==L[f])return!1}return!0}sort(z,L){const X=this.ranks(L.locale),$=this.#e.length,A=z.length,k=new Uint32Array(A),y=this.#n;for(let f=0;f<A;f++)k[f]=y[z[f]];return G(z,k,X,$,!!L.descending)}}}),Ue("packages/core/src/store/columnstore.js",function(e,B){"use strict";Object.defineProperty(e,"REMOVED",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toFloat",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ColumnHandle",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return o}});const T=B("packages/core/src/internal/warn.js").warnOnce,D=B("packages/core/src/internal/predicates.js").isFunction,Z=B("packages/core/src/internal/paths.js").pathGetter,L=B("packages/core/src/store/bitset.js").Bitset,$=B("packages/core/src/store/dictionary.js").Dictionary,k=B("packages/core/src/store/multivalue.js").MultiValue,f=B("packages/core/src/store/stringrank.js").StringRankIndex,g=4294967295,a=1024,r=5e3,i=.2,c=new Set(["float64","int32","bitset","dictionary","object","multi"]);function u(b){return b==null}function n(b){return typeof b=="number"?b:b instanceof Date?b.getTime():typeof b=="boolean"?b?1:0:Number(b)}function m(b){const l=n(b);return Number.isFinite(l)?l|0:0}function t(b){return u(b)?[]:Array.isArray(b)?b:[b]}function s(b,l){switch(b.kind){case"float64":case"int32":return b.buf[l];case"bitset":return b.bits.get(l)===1;case"dictionary":return b.dict.valueOf(b.buf[l]);case"multi":{const p=b.mv.at(l),w=new Array(p.length);for(let v=0;v<p.length;v++)w[v]=b.dict.valueOf(p[v]);return w}default:return b.buf[l]}}function h(b,l){switch(b.kind){case"float64":case"int32":return b.values[l];case"bitset":return(b.values[l>>3]&1<<(l&7))!==0;case"dictionary":return(b.table||[])[b.values[l]];case"multi":{const p=b.offsets[l],w=b.offsets[l+1],v=b.table||[],R=new Array(w-p);for(let Y=p;Y<w;Y++)R[Y-p]=v[b.values[Y]];return R}default:return b.values[l]}}class d{#e;#t;#n;#r;#i;#s;#a;#l=!1;#o=null;#c=null;#u=null;#f=null;#d=null;#h;#p;#m=-1;#g=null;#b=0;#y=0;#O=null;#w=null;#A=!1;constructor(l,p){this.#e=l.id;const w=c.has(l.kind)?l.kind:"object";l.kind&&!c.has(l.kind)&&T(`store.kind.${l.id}`,`column "${l.id}" declares unknown storage kind "${l.kind}"; falling back to object`),this.#n=w,this.#t=w,this.#r=l.nullable!==!1,this.#a=l.dictionary??null,this.#s=p,this.#i=D(l.read)?l.read:Z(l.field||l.id),this.#h=l.stringRankIndex!=="off",this.#p=typeof l.stringRankMaxDistinct=="number"?l.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.#o: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.#f:null}get stringRank(){if(this.#A||!this.#h||this.kind!=="object")return null;const l=this.values,p=this.#s.physical();if(!l||p===0)return null;if(this.#d===null){if(typeof l[0]!="string")return null;const w=new f(this.#v());return w.build(l,p),w.version=this.#y,this.#d=w,this.#m=this.#y,w.capped?null:w}return this.#d.length<p&&this.#d.append(l,this.#d.length,p-this.#d.length),this.#d.version=this.#y,this.#m=this.#y,this.#d.capped?null:this.#d}#v(){return this.#p}#P(){this.#d=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 l=0;return this.#o&&(l+=this.#o.byteLength??this.#o.length*8),this.#c&&(l+=this.#c.bytes),this.#u&&(l+=this.#u.bytes),this.#g&&(l+=this.#g.bytes),this.#f&&(l+=this.#f.bytes),this.#O&&(l+=this.#O.size*24),l}get(l){if(!this.#A&&!(l<0||l>=this.#s.physical())){if(!this.#l)return this.#E(l);if(this.#r&&this.#g.get(l)===0)return null;switch(this.#t){case"float64":case"int32":return this.#o[l];case"bitset":return this.#c.get(l)===1;case"dictionary":return this.#f.valueOf(this.#o[l]);case"multi":{const p=this.#u.at(l),w=new Array(p.length);for(let v=0;v<p.length;v++)w[v]=this.#f.valueOf(p[v]);return w}default:return this.#o[l]}}}set(l,p){this.#A||(this.#l?this.#C(l,p):this.#O.set(l,p===void 0?null:p),this.#d&&this.#P(),this.#y++)}read(l){return this.#i(l)}appendColumn(l,p,w){if(this.#A||w<=0)return;if(!this.#l){this.#y++;return}const v=this.#i,R=this.#r,Y=this.#g;let K=!1;switch(this.#t){case"float64":{const V=this.#o;for(let E=0;E<w;E++){const O=v(l[E]);if(typeof O=="number"){R&&Y.set(p+E),V[p+E]=O;continue}const C=O==null;R?Y.assign(p+E,!C):C&&(K=!0),V[p+E]=C?NaN:n(O)}break}case"int32":{const V=this.#o;for(let E=0;E<w;E++){const O=v(l[E]),C=O==null;R?Y.assign(p+E,!C):C&&(K=!0),V[p+E]=C?0:m(O)}break}case"bitset":{const V=this.#c;for(let E=0;E<w;E++){const O=v(l[E]),C=O==null;R?Y.assign(p+E,!C):C&&(K=!0),V.assign(p+E,!C&&!!O)}break}case"dictionary":{const V=this.#o,E=this.#f;for(let O=0;O<w;O++){const C=v(l[O]),S=C==null;R?Y.assign(p+O,!S):S&&(K=!0),V[p+O]=S?0:E.codeOf(C)}break}case"multi":{const V=this.#u,E=this.#f;for(let O=0;O<w;O++){const C=v(l[O]),S=C==null;R?Y.assign(p+O,!S):S&&(K=!0);const F=t(C),P=new Array(F.length);for(let M=0;M<F.length;M++)P[M]=E.codeOf(F[M]);V.write(p+O,P)}break}default:{const V=this.#o;for(let E=0;E<w;E++){const O=v(l[E]),C=O==null;R?Y.assign(p+E,!C):C&&(K=!0),V[p+E]=C?null:O}break}}K&&T(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#d&&this.#t==="object"&&(this.#d.append(this.#o,p,w),this.#d.version=this.#y+1,this.#m=this.#y+1),this.#y++}appendPacked(l,p,w){if(this.#A||w<=0||!l)return;if(!this.#l){this.#y++;return}const v=this.#g,R=l.presence;if(v)if(R)for(let K=0;K<w;K++)v.assign(p+K,(R[K>>3]&1<<(K&7))!==0);else for(let K=0;K<w;K++)v.set(p+K);const Y=l.kind===this.#t;if(Y&&(this.#t==="float64"||this.#t==="int32")){this.#o.set(l.values,p),this.#y++;return}if(Y&&this.#t==="bitset"){const K=l.values;for(let V=0;V<w;V++)this.#c.assign(p+V,(K[V>>3]&1<<(V&7))!==0);this.#y++;return}if(Y&&this.#t==="dictionary"){const K=l.table||[],V=new Uint32Array(K.length);for(let S=0;S<K.length;S++)V[S]=this.#f.codeOf(K[S]);const E=l.values,O=this.#o,C=v;for(let S=0;S<w;S++){if(C&&(R&&(R[S>>3]&1<<(S&7))===0)){O[p+S]=0;continue}O[p+S]=V[E[S]]??0}this.#y++;return}if(Y&&this.#t==="multi"){const K=l.table||[],V=new Uint32Array(K.length);for(let C=0;C<K.length;C++)V[C]=this.#f.codeOf(K[C]);const E=l.values,O=l.offsets;for(let C=0;C<w;C++){const S=O[C],F=O[C+1],P=new Array(F-S);for(let M=S;M<F;M++)P[M-S]=V[E[M]]??0;this.#u.write(p+C,P)}this.#y++;return}for(let K=0;K<w;K++){const V=R?(R[K>>3]&1<<(K&7))===0:l.kind==="object"?l.values[K]===null:!1;this.#C(p+K,V?null:h(l,K))}this.#y++}touch(){this.#y++}columnarise(l,p){if(this.#l||this.#A)return;const w=new Array(p);for(let v=0;v<p;v++)w[v]=this.#E(v);this.#t=this.#n,this.#l=!0,this.#S(l);for(let v=0;v<p;v++)this.#C(v,w[v]);this.#O.clear(),this.#w=null,this.#P(),this.#y++}grow(l){if(!(!this.#l||this.#A||l<=this.#b)){switch(this.#t){case"float64":case"int32":case"dictionary":{const p=new this.#o.constructor(l);p.set(this.#o),this.#o=p;break}case"bitset":this.#c.grow(l);break;case"multi":break;default:this.#o.length=l;break}this.#g&&this.#g.grow(l),this.#b=l,this.#y++}}convert(l){if(this.#A||!c.has(l)||(this.#n=l,!this.#l||l===this.#t))return!1;const p={kind:this.#t,buf:this.#o,bits:this.#c,mv:this.#u,dict:this.#f},w=this.#s.physical(),v=this.#g;this.#t=l,this.#S(this.#b);for(let R=0;R<w;R++){const Y=v!==null&&v.get(R)===0;Y&&l!=="multi"||this.#C(R,Y?null:s(p,R))}return this.#P(),this.#y++,!0}compact(l,p,w){if(!this.#A){if(this.#P(),!this.#l){const v=this.#O;if(v.size){const R=new Map;for(const[Y,K]of v)l[Y]!==g&&R.set(l[Y],K);this.#O=R}this.#w=null,this.#y++;return}switch(this.#t){case"float64":case"int32":case"dictionary":case"object":{const v=this.#o;for(let R=0;R<p;R++)l[R]!==g&&(v[l[R]]=v[R]);if(this.#t==="object")for(let R=w;R<p;R++)v[R]=void 0;break}case"bitset":{const v=this.#c;for(let R=0;R<p;R++)l[R]!==g&&v.assign(l[R],v.get(R)===1);for(let R=w;R<p;R++)v.clear(R);break}case"multi":this.#u.compact(l,w,g);break;default:break}if(this.#g){const v=this.#g;for(let R=0;R<p;R++)l[R]!==g&&v.assign(l[R],v.get(R)===1);for(let R=w;R<p;R++)v.clear(R)}this.#y++}}release(){this.#A||(this.#A=!0,this.#o=null,this.#c&&this.#c.release(),this.#c=null,this.#u&&this.#u.release(),this.#u=null,this.#g&&this.#g.release(),this.#g=null,this.#f=null,this.#d=null,this.#O=new Map,this.#w=null,this.#b=0,this.#y++)}#S(l){const p=Math.max(1,l);switch(this.#o=null,this.#c=null,this.#u=null,this.#t){case"float64":this.#o=new Float64Array(p);break;case"int32":this.#o=new Int32Array(p);break;case"bitset":this.#c=new L(p);break;case"dictionary":this.#o=new Uint32Array(p),this.#f=this.#f??new $(this.#a??[]);break;case"multi":this.#u=new k({rows:p,values:p}),this.#f=this.#f??new $(this.#a??[]);break;default:this.#o=new Array(p);break}this.#t!=="dictionary"&&this.#t!=="multi"&&(this.#f=null),this.#r&&(this.#g?this.#g.grow(p):this.#g=new L(p)),this.#b=p}#C(l,p){const w=u(p);switch(this.#r?this.#g.assign(l,!w):w&&T(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#t){case"float64":this.#o[l]=w?NaN:n(p);break;case"int32":this.#o[l]=w?0:m(p);break;case"bitset":this.#c.assign(l,!w&&!!p);break;case"dictionary":this.#o[l]=w?0:this.#f.codeOf(p);break;case"multi":{const v=t(p),R=new Array(v.length);for(let Y=0;Y<v.length;Y++)R[Y]=this.#f.codeOf(v[Y]);this.#u.write(l,R);break}default:this.#o[l]=w?null:p;break}}#E(l){if(this.#O.has(l))return this.#O.get(l);const p=this.#i(this.#s.rowAt(l));return p===void 0?null:p}#T(){if(this.#w&&this.#w.version===this.#y)return this.#w;const l=this.#s.physical(),p=new Array(l),w=this.#r?new L(l):null;for(let v=0;v<l;v++){const R=this.#E(v);p[v]=R,w&&!u(R)&&w.set(v)}return this.#w={version:this.#y,values:p,presence:w},this.#w}}class o{#e;#t=new Map;#n=[];#r=[];#i=0;#s=0;#a=0;#l=0;#o=new L(0);#c=!1;#u=!0;#f;#d;#h;#p=!1;constructor(l,p={}){this.#e=Array.isArray(l)?l:[],this.#d=Math.max(1,p.initialCapacity??a),this.#u=p.retainSource!==!1,this.#f=this.#u?p.columnarBelow??r:0,this.#h=p.compactRatio??i;const w={rowAt:v=>this.#r[v],physical:()=>this.#i};for(const v of this.#e){if(!v||!v.id)continue;if(this.#t.has(v.id)){T(`store.dup.${v.id}`,`duplicate column id "${v.id}" in the store schema; ignoring the second`);continue}const R=new d(v,w);this.#t.set(v.id,R),this.#n.push(R)}this.#f<=0&&this.#b()}get count(){return this.#a}get physical(){return this.#i}get capacity(){return this.#c?this.#s:this.#r.length}get tombstones(){return this.#l}get columnar(){return this.#c}get destroyed(){return this.#p}get bytes(){let l=this.#o.bytes+this.#r.length*8;for(const p of this.#n)l+=p.bytes;return l}append(l){const p=this.#i;if(this.#p||!l)return{from:p,to:p};const w=l.length|0;if(w===0)return{from:p,to:p};if(this.#u)for(let R=0;R<w;R++)this.#r[p+R]=l[R];if(this.#i=p+w,this.#a+=w,this.#o.grow(this.#i),!this.#c){if(this.#i>=this.#f)this.#b();else for(const R of this.#n)R.touch();return{from:p,to:this.#i}}this.#m(this.#i);const v=this.#n;for(let R=0;R<v.length;R++)v[R].appendColumn(l,p,w);return{from:p,to:this.#i}}appendPacked(l,p){const w=this.#i;if(this.#p||!l)return{from:w,to:w};const v=l.count|0;if(v===0)return{from:w,to:w};if(this.#u&&p)for(let Y=0;Y<v;Y++)this.#r[w+Y]=p[Y];this.#i=w+v,this.#a+=v,this.#o.grow(this.#i),this.#c||this.#b(),this.#m(this.#i);const R=new Map;for(const Y of l.columns)R.set(Y.id,Y);for(const Y of this.#n){const K=R.get(Y.id);K?Y.appendPacked(K,w,v):Y.grow(this.#s)}return{from:w,to:this.#i}}source(l){if(this.#u)return this.#r[l];if(!(l<0||l>=this.#i))return this.#g(l)}setSource(l,p){this.#p||l<0||l>=this.#i||this.#u&&(this.#r[l]=p)}get(l,p){const w=this.#t.get(l);return w?w.get(p):void 0}set(l,p,w){if(this.#p||p<0||p>=this.#i)return;const v=this.#t.get(l);if(!v){T(`store.set.${l}`,`set() on unknown column "${l}"`);return}v.set(p,w)}remove(l){return this.#p||l<0||l>=this.#i||this.#o.get(l)===1?!1:(this.#o.set(l),this.#l++,this.#a--,!0)}live(l){return l<0||l>=this.#i?!1:this.#o.get(l)===0}compact(l={}){if(this.#p||this.#l===0||!l.force&&this.#l/this.#i<this.#h)return null;const p=this.#i,w=new Uint32Array(p);let v=0;for(let R=0;R<p;R++)w[R]=this.#o.get(R)===1?g:v++;for(const R of this.#n)R.compact(w,p,v);if(this.#u){const R=this.#r;for(let Y=0;Y<p;Y++)w[Y]!==g&&(R[w[Y]]=R[Y]);R.length=v}return this.#i=v,this.#a=v,this.#l=0,this.#o=new L(Math.max(this.#s,v)),w}column(l){return this.#t.get(l)}columns(){return this.#n.slice()}liveIndices(){const l=new Uint32Array(this.#a);if(this.#l===0){for(let w=0;w<this.#i;w++)l[w]=w;return l}let p=0;for(let w=0;w<this.#i;w++)this.#o.get(w)===0&&(l[p++]=w);return l}convert(l,p){const w=this.#t.get(l);return w?w.convert(p):!1}destroy(){if(!this.#p){this.#p=!0;for(const l of this.#n)l.release();this.#t.clear(),this.#n.length=0,this.#r.length=0,this.#o.release(),this.#i=0,this.#a=0,this.#l=0,this.#s=0}}#m(l){if(l<=this.#s)return;let p=this.#s||this.#d;for(;p<l;)p*=2;for(const w of this.#n)w.grow(p);this.#o.grow(p),this.#s=p}#g(l){const p={};for(const w of this.#n)p[w.id]=w.get(l);return p}#b(){if(this.#c)return;let l=this.#d;for(;l<this.#i;)l*=2;this.#c=!0,this.#s=l,this.#o.grow(l);for(const p of this.#n)p.columnarise(l,this.#i)}}}),Ue("packages/core/src/store/pool.js",function(e,B){"use strict";Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"sharedPool",{enumerable:!0,get:function(){return I}});const re=64,T=8;function G(z){let L=re;for(;L<z;)L*=2;return L}class D{#e=new Map;#t=new WeakSet;#n;#r=0;#i={acquired:0,reused:0,released:0};constructor(L={}){this.#n=L.limit??T}get bytes(){return this.#r}mask(L){const X=new Uint8Array(this.#s(L),0,L);return X.fill(0),X}indices(L){return new Uint32Array(this.#s(L*4),0,L)}release(L){if(!L||!L.buffer)return!1;const X=L.buffer;if(!this.#t.has(X))return!1;this.#t.delete(X),this.#i.released++;const $=X.byteLength;let A=this.#e.get($);return A||this.#e.set($,A=[]),A.length>=this.#n||(A.push(X),this.#r+=$),!0}releaseAll(L){for(const X of L)this.release(X)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#i,retained:this.#r}}#s(L){const X=G(L),$=this.#e.get(X);this.#i.acquired++;let A;return $&&$.length?(A=$.pop(),this.#r-=X,this.#i.reused++):A=new ArrayBuffer(X),this.#t.add(A),A}}function I(){return Z??=new D,Z}let Z=null}),Ue("packages/core/src/compute/sortspec.js",function(e,B){"use strict";Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return I}});function re(Z){return{locale:Z===void 0?void 0:String(Z),numeric:!0,sensitivity:"variant"}}function T(Z){return!!Z&&typeof Z.compare!="function"}function G(Z){if(!Z)return!0;for(let z=0;z<Z.length;z++)if(!T(Z[z]))return!1;return!0}function D(Z,z){const L=Z.col!==void 0?Z.col:Z.handle&&Z.handle.id,X=Z.locale!==void 0?Z.locale:z;return{col:L,descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,collation:re(X)}}function I(Z,z){const L=Z||[],X=new Array(L.length);for(let $=0;$<L.length;$++)X[$]=D(L[$],z);return X}}),Ue("packages/core/src/compute/facet.js",function(e,B){"use strict";Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"orderedReader",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"toNumeric",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const re=B("packages/core/src/compute/handle.js"),T=re.presenceReader,G=re.valueReader,D=re.dictSize,I=re.dictValue,Z=Object.freeze(["equal","quantile","log"]),z=Object.freeze(["hour","day","week","month","quarter","year"]),L=20,X=50,$=1e4;function A(v,R){if(!v)return"none";const Y=R;if(Y&&(Y.multi===!0||typeof Y.items=="function"))return"category";const K=R&&R.base;if(K==="date"||K==="datetime"||K==="time"||K==="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 K==="number"?"numeric":K==="boolean"?"boolean":K==="text"?"category":"none"}}function k(v){const R=v.values,Y=v.kind;if((Y==="float64"||Y==="int32")&&R)return V=>R[V];const K=G(v);return V=>y(K(V))}function y(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 R=Number(v);if(Number.isFinite(R))return R;const Y=Date.parse(v);return Number.isFinite(Y)?Y:NaN}return NaN}function f(v,R,Y,K=X){if(!v)return{cardinality:0,exact:!0};if(v.dict)return{cardinality:D(v.dict),exact:!0};if(v.kind==="bitset")return{cardinality:2,exact:!0};const V=G(v),E=R?R.length:Y,O=new Set;for(let C=0;C<E;C++){const S=V(R?R[C]:C);if(S!=null&&(O.add(S),O.size>K))return{cardinality:O.size,exact:!1}}return{cardinality:O.size,exact:!0}}const g=36e5,a=864e5;function r(v,R=L){const Y=Number.isFinite(v)&&v>0?v:0,K=Math.max(1,R)*2;return Y/g<=K?"hour":Y/a<=K?"day":Y/(7*a)<=K?"week":Y/(30*a)<=K?"month":Y/(91*a)<=K?"quarter":"year"}function i(v,R){if(!Number.isFinite(v))return NaN;const Y=new Date(v);switch(R){case"hour":return Y.setMinutes(0,0,0),Y.getTime();case"day":return Y.setHours(0,0,0,0),Y.getTime();case"week":{Y.setHours(0,0,0,0);const K=(Y.getDay()+6)%7;return Y.setDate(Y.getDate()-K),Y.getTime()}case"month":return Y.setDate(1),Y.setHours(0,0,0,0),Y.getTime();case"quarter":return Y.setMonth(Math.floor(Y.getMonth()/3)*3,1),Y.setHours(0,0,0,0),Y.getTime();default:return Y.setMonth(0,1),Y.setHours(0,0,0,0),Y.getTime()}}function c(v,R){const Y=new Date(v);switch(R){case"hour":Y.setHours(Y.getHours()+1);break;case"day":Y.setDate(Y.getDate()+1);break;case"week":Y.setDate(Y.getDate()+7);break;case"month":Y.setMonth(Y.getMonth()+1);break;case"quarter":Y.setMonth(Y.getMonth()+3);break;default:Y.setFullYear(Y.getFullYear()+1);break}return Y.getTime()}function u(v,R,Y){const K=k(v),V=T(v),E=R?R.length:Y;let O=1/0,C=-1/0,S=0,F=0;for(let P=0;P<E;P++){const M=R?R[P]:P;if(V&&!V(M)){S++;continue}const x=K(M);if(!Number.isFinite(x)){S++;continue}x<O&&(O=x),x>C&&(C=x),F++}return{min:O,max:C,nulls:S,finite:F}}function n(v,R,Y,K){const V=k(v),E=T(v),O=R?R.length:Y,C=O>K?O/K:1,S=[];for(let P=0;P<O;P+=C){const M=R?R[Math.floor(P)]:Math.floor(P);if(E&&!E(M))continue;const x=V(M);Number.isFinite(x)&&S.push(x)}const F=Float64Array.from(S);return F.sort(),F}function m(v,R,Y,K={}){const V=K.kind||A(v,K.type);return V==="none"||!v?{kind:"none",buckets:[],suppressed:"type"}:V==="boolean"?t(v,R,Y,K):V==="category"?s(v,R,Y,K):d(v,R,Y,V,K)}function t(v,R,Y,K={}){const V=T(v);let E=0;if(V){const C=R?R.length:Y;for(let S=0;S<C;S++)V(R?R[S]:S)||E++}const O=[{value:!1,label:"false"},{value:!0,label:"true"}];return E>0&&K.blanks!==!1&&O.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:O}}function s(v,R,Y,K){const V=K.cardinalityLimit??X,{cardinality:E}=f(v,R,Y,V);if(E>V&&(K.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:E};const O=G(v),C=R?R.length:Y,S=new Map;let F=0;for(let _=0;_<C;_++){const W=O(R?R[_]:_);if(W==null||W===""){F++;continue}if(Array.isArray(W)){if(!W.length){F++;continue}for(const q of W)S.set(q,(S.get(q)||0)+1);continue}S.set(W,(S.get(W)||0)+1)}let P=[...S.entries()];K.order==="alpha"?P.sort((_,W)=>String(_[0]).localeCompare(String(W[0]))):P.sort((_,W)=>W[1]-_[1]);let M=0,x=0;if(P.length>V){x=P.length-V;for(let _=V;_<P.length;_++)M+=P[_][1];P=P.slice(0,V)}const U=P.map(([_])=>({value:_,label:String(_)}));return M>0&&U.push({remainder:!0,label:`Other (${x} values)`}),F>0&&K.blanks!==!1&&U.push({null:!0,label:"Empty"}),{kind:"category",buckets:U,cardinality:E}}function h(v,R,Y,K,V){const E=n(v,R,Y,$),O=E.length;if(O<100)return null;const C=E[Math.floor(.01*O)],S=E[Math.ceil(.99*O)-1];return!(S>C)||V-K<=2*(S-C)?null:{lo:C,hi:S}}function d(v,R,Y,K,V){const{min:E,max:O,nulls:C,finite:S}=u(v,R,Y);if(!S)return{kind:K,buckets:C&&V.blanks!==!1?[{null:!0,label:"Empty"}]:[],empty:!0};const F=Math.max(1,Math.floor(V.buckets||L));let P=[];if(K==="date"){const x=z.includes(V.granularity)?V.granularity:r(O-E,F);let U=i(E,x);for(;U<=O&&P.length<4096;){const _=c(U,x);if(!(_>U))break;P.push({from:U,to:_}),U=_}return{kind:K,buckets:o(P,V.blanks===!1?0:C),granularity:x}}const M=Z.includes(V.strategy)?V.strategy:"equal";if(M==="quantile"){const x=n(v,R,Y,$);if(x.length){const U=[x[0]];for(let _=1;_<F;_++){const W=x[Math.min(x.length-1,Math.floor(_/F*x.length))];W>U[U.length-1]&&U.push(W)}U.push(O);for(let _=0;_<U.length-1;_++)P.push({from:U[_],to:U[_+1]})}}else if(M==="log"&&E>0){const x=Math.log10(E),_=(Math.log10(O)-x)/F||1;for(let W=0;W<F;W++)P.push({from:10**(x+W*_),to:10**(x+(W+1)*_)})}if(!P.length&&M==="equal"){const x=h(v,R,Y,E,O);if(x){const U=(x.hi-x.lo)/F;x.lo>E&&P.push({from:E,to:x.lo,overflow:"low"});for(let _=0;_<F;_++)P.push({from:x.lo+_*U,to:x.lo+(_+1)*U});P[P.length-1].to=x.hi,x.hi<O&&P.push({from:x.hi,to:O,overflow:"high"})}}if(!P.length){const x=(O-E)/F||1;for(let U=0;U<F;U++)P.push({from:E+U*x,to:E+(U+1)*x})}return P[P.length-1].to=O,{kind:K,buckets:o(P,V.blanks===!1?0:C),strategy:M,min:E,max:O}}function o(v,R){return R>0?[...v,{null:!0,label:"Empty"}]:v}function b(v,R,Y,K,V){const E=K&&K.buckets||[],O=V&&V.length>=E.length?V.subarray(0,E.length):new Uint32Array(E.length);if(O.fill(0),!v||!E.length)return O;const C=E.length-1,S=!!E[C]&&E[C].null===!0,F=R?R.length:Y;if(K.kind==="boolean"){const _=G(v);for(let W=0;W<F;W++){const q=_(R?R[W]:W);if(q==null){S&&O[C]++;continue}O[q?1:0]++}return O}if(K.kind==="category"){const _=new Map;for(let N=0;N<E.length;N++)!E[N].null&&!E[N].remainder&&_.set(E[N].value,N);const W=E.findIndex(N=>N.remainder),q=G(v);for(let N=0;N<F;N++){const Q=q(R?R[N]:N);if(Q==null||Q===""){S&&O[C]++;continue}if(Array.isArray(Q)){if(!Q.length){S&&O[C]++;continue}for(const ee of Q){const ne=_.get(ee);ne!==void 0?O[ne]++:W>=0&&O[W]++}continue}const J=_.get(Q);J!==void 0?O[J]++:W>=0&&O[W]++}return O}const P=S?E.length-1:E.length,M=new Float64Array(P+1);for(let _=0;_<P;_++)M[_]=E[_].from;M[P]=P?E[P-1].to:0;const x=k(v),U=T(v);for(let _=0;_<F;_++){const W=R?R[_]:_;if(U&&!U(W)){S&&O[C]++;continue}const q=x(W);if(!Number.isFinite(q)){S&&O[C]++;continue}const N=l(M,P,q);N>=0&&O[N]++}return O}function l(v,R,Y){if(!R||Y<v[0])return-1;if(Y>=v[R])return Y===v[R]?R-1:-1;let K=0,V=R-1;for(;K<V;){const E=K+V+1>>>1;Y>=v[E]?K=E:V=E-1}return K}function p(v,R,Y,K={}){const V=K.bounds||m(v,K.boundsIndices??R,Y,K);return{bounds:V,counts:b(v,R,Y,V)}}const w=p}),Ue("packages/core/src/compute/pivotmatrix.js",function(e,B){"use strict";Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return i}});const T=B("packages/core/src/compute/handle.js").valueComparator,D=B("packages/core/src/compute/total.js").total,Z=B("packages/core/src/compute/group.js").packKeys,z=B("packages/core/src/compute/pivot.js"),L=z.joinPath,X=z.DEFAULT_PATH_SEPARATOR,$=z.DEFAULT_MAX_COLUMNS,A="";function k(c,u,n={}){const m=n.separator||X,t=c||[],s=u instanceof Uint32Array?u:Uint32Array.from(u||[]),h=s.length;if(t.length===0)return{tuples:[[]],paths:[A],buckets:[s]};const{keyOf:d,readers:o}=Z(t,s,0),b=new Map,l=[],p=[],w=[];for(let E=0;E<h;E++){const O=s[E],C=d(O);let S=b.get(C);if(S===void 0){S=l.length,b.set(C,S),p.push(C);const F=new Array(o.length);for(let P=0;P<o.length;P++)F[P]=o[P](O);l.push(F),w.push([])}w[S].push(O)}const v=T(n.locale),R=l.map((E,O)=>O);R.sort((E,O)=>{const C=l[E],S=l[O];for(let F=0;F<C.length;F++){const P=y(C[F],S[F],v);if(P!==0)return P}return E-O});const Y=new Array(R.length),K=new Array(R.length),V=new Array(R.length);for(let E=0;E<R.length;E++){const O=R[E];Y[E]=l[O],K[E]=L(l[O],m),V[E]=Uint32Array.from(w[O])}return{tuples:Y,paths:K,buckets:V}}function y(c,u,n){const m=c==null,t=u==null;return m||t?m&&t?0:m?1:-1:n(c,u)}function f(c,u,n){const m=[];for(let t=0;t<c.length;t++)n.has(c[t])&&m.push(c[t]);return Uint32Array.from(m)}function g(c,u,n,m){return{value:u.length?D(c,u,n,m):null,leaves:u,count:u.length}}function a(c){const u=c&&c.opts||{},n=u.separator||X,m=u.totalContext||{locale:u.locale},t=(c.measures||[]).filter(K=>K&&K.handle),s=c.leaves instanceof Uint32Array?c.leaves:Uint32Array.from(c.leaves||[]),h=k(c.rowHandles||[],s,{...u,separator:n}),d=k(c.columnHandles||[],s,{...u,separator:n}),o=u.maxColumns===void 0?$:u.maxColumns,b=d.paths.length*Math.max(1,t.length),l=new Map;if(o&&b>o)return{rowAxis:h,columnAxis:d,measures:t.map(K=>({colId:K.colId,fn:K.fn})),body:l,rowMargin:l,columnMargin:l,grand:l,columns:b,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${b} columns, above pivot.maxColumns of ${o}. Narrow the pivot columns or raise the limit.`,columns:b,maxColumns:o}};const p=new Map,w=new Map,v=new Map,R=new Map,Y=d.buckets.map(K=>new Set(K));for(let K=0;K<d.paths.length;K++){const V=d.buckets[K],E=d.paths[K];for(const O of t)v.set(i(E,O.colId),g(O.handle,V,O.fn,m))}for(let K=0;K<h.paths.length;K++){const V=h.buckets[K],E=h.paths[K];for(const O of t)w.set(i(E,O.colId),g(O.handle,V,O.fn,m));for(let O=0;O<d.paths.length;O++){const C=f(V,d.buckets[O],Y[O]);if(C.length===0)continue;const S=d.paths[O];for(const F of t)p.set(r(E,S,F.colId),g(F.handle,C,F.fn,m))}}for(const K of t)R.set(K.colId,g(K.handle,s,K.fn,m));return{rowAxis:h,columnAxis:d,measures:t.map(K=>({colId:K.colId,fn:K.fn})),body:p,rowMargin:w,columnMargin:v,grand:R,columns:b,error:null}}function r(c,u,n){return`${c}\0${u}\0${n}`}function i(c,u){return`${c}\0${u}`}}),Ue("packages/core/src/compute/reference.js",function(e,B){"use strict";Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return a}});const T=B("packages/core/src/internal/paths.js").getPath,G=B("packages/core/src/compute/handle.js"),D=G.isMissing,I=G.valueComparator,z=B("packages/core/src/compute/filter.js").testValue,L="",X="\0";function $(c,u){const n=u.includes(".")?T(c,u):c?.[u];return n===void 0?null:n}function A(c,u,n={}){const m=u||[];let t=c.map((s,h)=>h);if(m.length===0)return t;for(let s=m.length-1;s>=0;s--)t=k(c,t,m[s],n);return t}function k(c,u,n,m){const t=n.locale!==void 0?n.locale:m.locale,s=I(t),h=n.descending!==void 0?!!n.descending:n.dir==="desc",d=[],o=[];for(const p of u){const w=$(c[p],n.col);D(w)?o.push(p):d.push(p)}const b=new Map;for(let p=0;p<d.length;p++)b.set(d[p],p);const l=(p,w)=>{const v=$(c[p],n.col),R=$(c[w],n.col);let Y;return typeof n.compare=="function"?(Y=n.compare(v,R,c[p],c[w],h),h&&(Y=-Y)):Y=h?s(R,v):s(v,R),Y!==0?Y:b.get(p)-b.get(w)};return d.sort(l),n.nullsFirst?o.concat(d):d.concat(o)}function y(c,u,n={}){const m=[];for(let t=0;t<c.length;t++)f(c[t],u,n,t)&&m.push(t);return m}function f(c,u,n,m){if(!u)return!0;if(Array.isArray(u.conditions)){const t=u.conditions.filter(h=>h!=null);if(t.length===0)return!0;if(u.op==="or")return t.some(h=>f(c,h,n,m));const s=t.every(h=>f(c,h,n,m));return u.op==="not"?!s:s}return u.col===void 0&&typeof n.custom=="function"?!!n.custom(u,c,m):z($(c,u.col),u,n.locale)}function g(c,u,n,m){const t=n||c.map((o,b)=>b),s=new Map,h=[],d=[];for(const o of t){const b=u.map((w,v)=>{const R=$(c[o],w);return m&&m[v]?m[v](R):R}),l=b.map(w=>w==null?X:String(w)).join(L);let p=s.get(l);p===void 0&&(p=h.length,s.set(l,p),h.push(b),d.push([])),d[p].push(o)}return{keys:h,buckets:d}}function a(c,u,n={}){const m=I(n.locale),t=c.filter(h=>!D(h)),s=t.map(r).filter(h=>h!==null);switch(u){case"count":return c.length;case"countValues":return t.length;case"sum":return s.reduce((h,d)=>h+d,0);case"avg":return t.length===0?null:s.reduce((h,d)=>h+d,0)/t.length;case"min":return t.length===0?null:t.reduce((h,d)=>m(d,h)<0?d:h);case"max":return t.length===0?null:t.reduce((h,d)=>m(d,h)>0?d:h);case"first":return c.length===0?null:i(c[0]);case"last":return c.length===0?null:i(c[c.length-1]);default:return null}}function r(c){if(typeof c=="number")return Number.isNaN(c)?null:c;if(c==null||c===""||typeof c=="boolean")return null;if(c instanceof Date)return c.getTime();const u=Number(c);return Number.isNaN(u)?null:u}function i(c){return c===void 0?null:c}}),Ue("packages/core/src/compute/index.js",function(e,B){"use strict";const re=B("packages/core/src/compute/sort.js");Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return re.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return re.sortMulti}}),Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return re.radixSortFloat64}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return re.radixSortInt32}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return re.rankSortDictionary}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return re.mergeSortComparator}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return re.collateStringRanks}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return re.rankSortStrings}});const T=B("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return T.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return T.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return T.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return T.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return T.describeSort}});const G=B("packages/core/src/compute/filter.js");Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return G.evaluateFilters}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return G.evaluateCondition}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return G.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return G.testValue}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return G.compilePredicate}}),Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return G.releaseMask}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return G.pruneColumn}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return G.mentionsColumn}});const D=B("packages/core/src/compute/group.js");Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return D.groupByColumns}}),Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return D.packKeys}});const I=B("packages/core/src/compute/facet.js");Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return I.facet}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return I.computeBounds}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return I.countInto}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return I.bucketOf}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return I.facetKind}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return I.cardinalityOf}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return I.pickGranularity}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return I.floorTo}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return I.advance}}),Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return I.STRATEGIES}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return I.GRANULARITIES}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return I.DEFAULT_BUCKETS}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return I.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return I.QUANTILE_SAMPLE}});const Z=B("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 z=B("packages/core/src/compute/pivot.js");Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return z.pivot}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return z.resolvePivotKeys}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return z.pivotKey}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return z.joinPath}}),Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return z.KEY_DELIMITER}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return z.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return z.DEFAULT_MAX_COLUMNS}});const L=B("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return L.pivotMatrix}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return L.resolveAxis}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return L.cellKey}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return L.marginKey}}),Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return L.GRAND_PATH}});const X=B("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 $=B("packages/core/src/compute/handle.js");Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return $.identity}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return $.rowCount}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return $.presenceReader}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return $.bitReader}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return $.valueReader}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return $.valueComparator}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return $.numericTotalOrder}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return $.dictRanks}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return $.dictSize}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return $.dictValue}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return $.multiValue}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return $.isMissing}});const A=B("packages/core/src/compute/sketch.js");Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return A.Welford}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return A.Reservoir}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return A.HyperLogLog}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return A.SpaceSaving}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return A.KLL}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return A.hash32}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return A.SKETCH_BOUNDS}});const k=B("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 y=B("packages/core/src/compute/statistics.js");Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return y.MAINTENANCE}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return y.APPROXIMATE}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return y.maintenanceOf}});const f=B("packages/core/src/compute/anomaly.js");Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return f.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return f.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return f.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return f.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return f.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return f.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return f.anomalyCondition}});const g=B("packages/core/src/compute/forecast.js");Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return g.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return g.forecast}})}),Ue("packages/core/src/source/rows.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_ROW_HEIGHT",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"KEY_SEP",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"createRowFactory",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"RowFactory",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"pinnedRow",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"lazyRowView",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"groupPathElement",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"groupKey",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"groupPrefixKeys",{enumerable:!0,get:function(){return g}});const T=B("packages/core/src/internal/warn.js").warnOnce,D=B("packages/core/src/internal/predicates.js").isFunction,I=32,Z="\0";function z(a){return new L(a)}class L{#e;#t;constructor(r){this.#e=D(r&&r.rowKey)?r.rowKey:null;const i=r&&r.config?r.config.rowHeight:void 0;this.#t=typeof i=="number"||D(i)?i:I}get keyed(){return this.#e!==null}keyOf(r,i){if(this.#e){const c=this.#e(r);if(c!=null)return String(c)}else T("source.rowKey.missing","no config.rowKey; falling back to index identity.","Row changes, streaming dedupe, selection persistence and remote reload are disabled.");return`#${i}`}heightOf(r){return D(this.#t)?Number(this.#t(r))||I:this.#t}leaf(r,i,c=0,u=null){const n={key:this.keyOf(r,i),data:r,level:c,parent:u,group:!1,expanded:!1,leafCount:1,height:0,index:null,selected:!1,physical:i};return n.height=this.heightOf(n),n}group(r){const i={key:f(r.keyPath||r.path),data:null,level:r.level,parent:r.parent||null,children:[],group:!0,expanded:r.expanded!==!1,leafCount:r.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:r.column,groupValue:r.value,groupPath:r.path,hasChildren:r.hasChildren!==!1};return r.totals&&(i.totals=r.totals),i.height=this.heightOf(i),i}footer(r){const i={key:`${r.key}${Z}footer`,data:null,level:r.level,parent:r,group:!0,footer:!0,expanded:!1,leafCount:r.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:r.groupColumn,groupValue:r.groupValue,groupPath:r.groupPath,hasChildren:!1,totals:r.totals};return i.height=this.heightOf(i),i}detail(r,i){return{key:`${r.key}${Z}detail`,data:r.data,level:r.level+1,parent:r,group:!1,detail:!0,expanded:!1,leafCount:0,height:i,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:r.key}}grandTotal(r,i){const c={key:`${Z}grandTotal`,data:null,level:0,parent:null,group:!0,grandTotal:!0,expanded:!1,leafCount:i,height:0,index:null,selected:!1,physical:null,groupPath:[],hasChildren:!1,totals:r};return c.height=this.heightOf(c),c}skeleton(r,i=0,c=!1){const u={key:`${Z}pending${Z}${r}`,data:null,level:i,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:r,selected:!1,physical:null,pending:!0};return c&&(u.loadError=!0),u.height=this.heightOf(u),u}}function X(a,r,i,c){return{key:`${Z}pinned${Z}${i}${Z}${r}`,data:a,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:c,index:null,selected:!1,physical:null,hasChildren:!1,pinned:i}}function $(a,r){return new Proxy([],{get(i,c,u){if(c==="length")return a();if(typeof c=="string"){const n=Number(c);if(Number.isInteger(n)&&n>=0)return r(n)}return Reflect.get(i,c,u)},has(i,c){if(typeof c=="string"){const u=Number(c);if(Number.isInteger(u)&&u>=0)return u<a()}return Reflect.has(i,c)}})}function A(a){return a==null?"":String(a)}const k="";function y(a){if(a==null)return k;const r=String(a);return r.startsWith(k)?k+r:r}function f(a){const r=a||[];let i="g";for(let c=0;c<r.length;c++)i+=Z+y(r[c]);return i}function g(a){const r=new Array(a.length),i=[];for(let c=0;c<a.length;c++)i.push(a[c]),r[c]=f(i);return r}}),Ue("packages/core/src/source/handles.js",function(e,B){"use strict";Object.defineProperty(e,"HandleProvider",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"createHandleProvider",{enumerable:!0,get:function(){return Z}});const T=B("packages/core/src/internal/predicates.js").isFunction,D=B("packages/core/src/internal/warn.js").warnOnce;class I{#e;#t;#n;#r=new Map;#i=0;constructor(L,X,$){this.#e=L,this.#t=X,this.#n=T($)?$:()=>!1}get store(){const L=this.#e.store;return L&&T(L.column)?L:null}invalidate(){this.#i++}handle(L){const X=this.store;if(X){const y=X.column(L);if(y)return y}const $=this.#r.get(L);if($&&$.builtAt===this.#i)return $.handle;const A=this.#s(L);if(!A)return;if(X&&this.#n()){D(`source.dropped.${L}`,`column "${L}" 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.#a(A);return this.#r.set(L,{handle:k,builtAt:this.#i}),k}#s(L){const X=this.#e.columns;return X&&T(X.get)?X.get(L):void 0}#a(L){const X=this.#t()||[],$=X.length,A=new Array($),k=T(L.getValue)?f=>L.getValue(f):f=>f?.[L.field||L.id];for(let f=0;f<$;f++)A[f]=X[f]===void 0?void 0:k(X[f]);const y=this.#i;return{id:L.id,kind:"object",nullable:!1,values:A,presence:null,dict:null,offsets:null,get(f){return A[f]},version:y}}}function Z(z,L,X){return new I(z,L,X)}}),Ue("packages/core/src/compute/incremental.js",function(e,B){"use strict";Object.defineProperty(e,"INCREMENTAL_FNS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"INCREMENTAL_KINDS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"MAGNITUDE_LIMIT",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"isIncremental",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"RunningTotal",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const T=B("packages/core/src/store/columnstore.js").toFloat,G=Object.freeze(["sum","avg","countValues","min","max"]),D=Object.freeze(["float64"]),I=1e15;function Z($,A){return typeof $!="string"||!G.includes($)?!1:!!A&&D.includes(A.kind)}function z($){if($==null)return null;const A=T($);return Number.isNaN(A)?null:A}class L{#e;#t=0;#n=0;#r=0;#i=1/0;#s=-1/0;#a=!1;#l=!1;constructor(A){this.#e=A}get valid(){return this.#a&&!this.#l}get fn(){return this.#e}seed(A){this.#o();for(let k=0;k<A.length;k++){const y=z(A[k]);y!==null&&this.#c(y)}this.#a=!0}seedColumn(A,k,y){this.#o();for(let f=0;f<y.length;f++){const g=y[f];if(k&&k(g)===0)continue;const a=A[g];Number.isNaN(a)||this.#c(a)}this.#a=!0}#o(){this.#t=0,this.#n=0,this.#r=0,this.#i=1/0,this.#s=-1/0,this.#l=!1}#c(A){if(!Number.isFinite(A)){this.#l=!0;return}const k=this.#t+A;this.#n+=Math.abs(this.#t)>=Math.abs(A)?this.#t-k+A:A-k+this.#t,this.#t=k,this.#r++,A<this.#i&&(this.#i=A),A>this.#s&&(this.#s=A)}#u(A){const k=this.#t-A;this.#n+=Math.abs(this.#t)>=Math.abs(A)?this.#t-k-A:-A-k+this.#t,this.#t=k,this.#r--}update(A,k){if(!this.#a)return!1;const y=z(A),f=z(k);return y===null&&f===null?!0:y!==null&&!Number.isFinite(y)||f!==null&&!Number.isFinite(f)?!1:this.#e==="min"||this.#e==="max"?y===null||f===null?!1:this.#e==="min"?f<this.#i?(this.#i=f,!0):y>this.#i:f>this.#s?(this.#s=f,!0):y<this.#s:Math.abs(this.#t)>I?!1:(y!==null&&this.#u(y),f!==null&&this.#c(f),!0)}value(){switch(this.#e){case"countValues":return this.#r;case"avg":return this.#r?(this.#t+this.#n)/this.#r:null;case"min":return this.#r?this.#i:null;case"max":return this.#r?this.#s:null;default:return this.#t+this.#n}}invalidate(){this.#a=!1}}const X=L}),Ue("packages/core/src/source/filterwire.js",function(e,B){"use strict";Object.defineProperty(e,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"warnWherePageRelative",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"warnWhereNotApplied",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"warnWhereOverThreshold",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"parseRelativeToken",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"resolveRelativeRange",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"relativeTokenOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"relativeTokenHelp",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"isResolvableRelative",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"resolveRelativeCondition",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"isGroup",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"forEachCondition",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"mapConditions",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normaliseFilterSet",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"buildFilterSet",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"wireFilters",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"querySignature",{enumerable:!0,get:function(){return v}});const T=B("packages/core/src/internal/warn.js").warnOnce,G="source.remote.hostFilter",D="source.where.pageRelative";function I(K,V){!Array.isArray(K)||!K.length||T(D,`filters.where (${K.join(", ")}) runs over the rows the ${V} 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(K){const V=(K||{}).config;!V||!V.hostFilter||T(G,"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 z="source.where.notApplied";function L(K,V){T(`${z}:${K}`,`filters.where("${K}") is registered but the ${V} 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 $(K,V,E,O){!Array.isArray(K)||!K.length||T(`${X}:${V}`,`filters.where (${K.join(", ")}) is not applied to the ${V} pushdown source:`,E===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${E.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 A=new Map;function k(K){let V=A.get(K);return V||(V=new Intl.DateTimeFormat("en-US",{timeZone:K,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),A.set(K,V)),V}function y(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function f(K,V){const E=k(V).formatToParts(new Date(K)),O={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const C of E)C.type==="year"?O.y=+C.value:C.type==="month"?O.m=+C.value:C.type==="day"?O.d=+C.value:C.type==="hour"?O.h=+C.value%24:C.type==="minute"?O.mi=+C.value:C.type==="second"&&(O.s=+C.value);return O}function g(K,V){const E=f(K,V);return Date.UTC(E.y,E.m-1,E.d,E.h,E.mi,E.s)-Math.floor(K/1e3)*1e3}function a(K,V,E,O){const C=Date.UTC(K,V-1,E),S=C-g(C,O);return C-g(S,O)}function r(K,V,E){const O=new Date(Date.UTC(K.y,K.m-1,K.d+V));return a(O.getUTCFullYear(),O.getUTCMonth()+1,O.getUTCDate(),E)}const i=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function c(K,V){if(typeof K!="string")return null;const E=K.trim().toLowerCase().replace(/[\s_-]+/g,""),O=/^last(\d*|n)days?$/.exec(E);if(O){const C=O[1]==="n"?"":O[1],S=Number(C||V);return!Number.isFinite(S)||S<=0?null:{kind:"lastNDays",n:Math.floor(S)}}switch(E){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 u(K,V={}){const E=c(K,V.n);if(!E)return null;const O=V.tz||y(),C=V.now instanceof Date?V.now.getTime():typeof V.now=="number"?V.now:Date.now(),S=f(C,O),F=a(S.y,S.m,S.d,O),P=r(S,1,O);let M=F,x=P;switch(E.kind){case"today":break;case"yesterday":M=r(S,-1,O),x=F;break;case"lastNDays":x=V.includeToday?P:F,M=r(S,V.includeToday?-(E.n-1):-E.n,O);break;case"thisWeek":{const U=Number.isFinite(V.weekStartsOn)?Number(V.weekStartsOn):1,W=(new Date(Date.UTC(S.y,S.m-1,S.d)).getUTCDay()-U+7)%7;M=r(S,-W,O),x=r(S,-W+7,O);break}case"thisMonth":M=a(S.y,S.m,1,O),x=a(S.m===12?S.y+1:S.y,S.m===12?1:S.m+1,1,O);break;case"thisQuarter":case"quarterToDate":{const U=Math.floor((S.m-1)/3)*3+1;M=a(S.y,U,1,O),x=E.kind==="quarterToDate"?P:U===10?a(S.y+1,1,1,O):a(S.y,U+3,1,O);break}case"thisYear":case"yearToDate":M=a(S.y,1,1,O),x=E.kind==="yearToDate"?P:a(S.y+1,1,1,O);break;default:return null}return{from:new Date(M).toISOString(),to:new Date(x).toISOString(),bounds:"[)",tz:O,relative:E.kind==="lastNDays"?`last${E.n}Days`:E.kind,n:E.n}}function n(K){if(!K||typeof K!="object")return null;const V=K.value;if(V&&typeof V=="object"&&!Array.isArray(V)&&"relative"in V)return{token:String(V.relative),n:typeof V.n=="number"?V.n:void 0};if(K.op==="relative"&&typeof K.value=="string")return{token:K.value,n:void 0};const E=K.meta;return E&&typeof E.relative=="string"&&K.value===void 0?{token:E.relative,n:typeof E.n=="number"?E.n:void 0}:null}function m(){return`Known tokens: ${i.filter(V=>V!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function t(K){const V=n(K);return V?c(V.token,V.n)!==null:!1}function s(K,V={}){const E=n(K);if(!E)return K;const O=u(E.token,{...V,n:E.n});return O?{...K,type:K.type||"date",op:"between",value:[O.from,O.to],bounds:K.bounds||O.bounds,meta:{...K.meta||{},relative:O.relative,tz:O.tz}}:(T(`source.relative.${E.token}`,`unknown relative date token "${E.token}"; sending the condition unresolved.`,m()),K)}function h(K){return!!K&&typeof K=="object"&&Array.isArray(K.conditions)}function d(K,V){if(K){if(h(K)){for(const E of K.conditions)d(E,V);return}V(K)}}function o(K,V){if(!K)return null;if(!h(K))return V(K);const E=K;let O=!1;const C=[];for(const S of E.conditions){const F=o(S,V);F!==S&&(O=!0),F&&C.push(F)}return!O&&C.length===E.conditions.length?K:C.length?{...E,conditions:C}:null}function b(K){if(!K)return null;if(!h(K))return K;const V=K,E=[];for(const O of V.conditions){const C=b(O);C&&E.push(C)}return E.length?{op:V.op,conditions:E}:null}function l(K){const V=b(K);return V?h(V)&&V.op==="and"?V:{op:"and",conditions:[V]}:null}function p(K){const V=(K||[]).filter(Boolean);return V.length?{op:"and",conditions:V}:null}function w(K,V={}){const E=o(K,O=>s(O,V));return l(E)}function v(K){const V=R(K.filters??null);return JSON.stringify([V,K.sort??null,K.quick??"",K.groupBy??null,K.pivotBy??null,Y(K.context)])}function R(K){if(!K)return null;if(h(K)){const O=K;return{op:O.op,conditions:O.conditions.map(R)}}const V=K,E=V.meta&&typeof V.meta.relative=="string"?V.meta.relative:n(V)?.token;return{col:V.col,op:V.op,bounds:V.bounds??null,caseSensitive:V.caseSensitive??!1,value:E?`rel:${E}`:V.value??null}}function Y(K){if(K==null)return null;try{return JSON.parse(JSON.stringify(K))}catch{return T("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),Ue("packages/core/src/source/tree.js",function(e,B){"use strict";Object.defineProperty(e,"SYNTHETIC",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"buildFromPath",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"buildFromParentKey",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"assignLevels",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"resolveTree",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"buildTree",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return f}});const T=B("packages/core/src/internal/predicates.js").isFunction,D=B("packages/core/src/internal/warn.js").warnOnce,I="",Z="\0tree:";function z(g,a){return{physical:g,key:a,level:0,children:[],value:void 0}}function L(g,a){const r=[],i=new Map;for(let c=0;c<g.length;c++){const u=g[c],n=a.pathOf(u),m=Array.isArray(n)?n.map(s=>String(s)):[];if(!m.length){const s=z(u,a.keyOf(u));r.push(s);continue}let t=null;for(let s=0;s<m.length;s++){const h=m.slice(0,s+1).join(I),d=s===m.length-1;let o=i.get(h);o&&d&&o.physical===-1&&(o.physical=u,o.key=a.keyOf(u)),o||(o=z(d?u:-1,d?a.keyOf(u):Z+h),o.level=s,o.value=m[s],i.set(h,o),t?t.children.push(o):r.push(o)),t=o}}return{roots:r,nodes:i}}function X(g,a){const r=new Map,i=[];for(let m=0;m<g.length;m++){const t=g[m],s=a.keyOf(t),h=z(t,s);r.set(s,h);const d=a.parentOf(t);d!=null&&d!==""&&i.push({node:h,parent:String(d)})}let c=null;const u=new Map;for(const{node:m,parent:t}of i){const s=r.get(t);if(s){u.set(m.key,s);continue}a.orphans&&a.orphans!=="root"&&(c||(c=z(-1,`${Z}orphans`),c.value=a.orphans),u.set(m.key,c))}const n=[];for(const m of r.values()){const t=u.get(m.key);t?t.children.push(m):n.push(m)}return c&&c.children.length&&n.push(c),{roots:$(n,r,a.orphans,c),nodes:r}}function $(g,a,r,i){const c=new Set,u=[...g];for(;u.length;){const h=u.pop();if(!c.has(h.key)){c.add(h.key);for(const d of h.children)u.push(d)}}const n=[];for(const h of a.values())c.has(h.key)||n.push(h);if(!n.length)return g;const m=!!r&&r!=="root";D("tree.cycle",`tree.parentKey produced ${n.length} row(s) inside a parent cycle; `+(m?`they are shown under "${r}".`:"they are shown at the root."));for(const h of n)h.children=h.children.filter(d=>c.has(d.key));if(!m)return[...g,...n];let t=i;const s=[...g];return t||(t=z(-1,`${Z}orphans`),t.value=r,s.push(t)),t.children.push(...n),s}function A(g){let a=0;const r=(i,c)=>{for(const u of i)u.level=c,c>a&&(a=c),u.children.length&&r(u.children,c+1)};return r(g,0),a}function k(g,a){if(!g||typeof g!="object")return null;const r=g.path,i=g.parentKey,c=T(g.hasChildren)?u=>!!g.hasChildren(a.dataAt(u)):null;if(T(r))return{mode:"path",pathOf:u=>r(a.dataAt(u)),keyOf:a.keyOf,declaresChildren:c};if(i!=null){const u=T(i)?i:n=>n?.[i];return{mode:"parentKey",parentOf:n=>u(a.dataAt(n)),keyOf:a.keyOf,orphans:g.orphans||"root",declaresChildren:c}}return D("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function y(g,a){const r=a.mode==="path"?L(g,a):X(g,a),i=A(r.roots);return{...r,depth:i}}function f(g,a){const r=new Map,i=c=>{for(let u=0;u<c.length;u++){const n=c[u];if(n.physical>=0){const m=a?a(n.physical):!1,t=m&&n.children.length===0;r.set(n.physical,{level:n.level,posinset:u+1,setsize:c.length,hasChildren:n.children.length>0||m,lazy:t})}n.children.length&&i(n.children)}};return i(g),r}}),Ue("packages/core/src/source/settle.js",function(e,B){"use strict";Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"ARRIVAL_REASONS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"isArrival",{enumerable:!0,get:function(){return D}});const re=Object.freeze(["pipeline:sort","pipeline:sort:error"]);function T(I){const Z=I&&typeof I=="object"?I.reason:null;return typeof Z=="string"&&re.includes(Z)}const G=Object.freeze(["page","total"]);function D(I){const Z=I&&typeof I=="object"?I.reason:null;return typeof Z=="string"&&G.includes(Z)}}),Ue("packages/core/src/source/memory.js",function(e,B){"use strict";Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"quickMatcher",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"MemorySource",{enumerable:!0,get:function(){return W}});const T=B("packages/core/src/internal/lru.js").Lru,G=B("packages/core/src/internal/warn.js"),D=G.warnOnce,I=G.fail,z=B("packages/core/src/internal/predicates.js").isFunction,X=B("packages/core/src/internal/compare.js").defaultCompare,A=B("packages/core/src/internal/merge.js").mergeRow,k=B("packages/core/src/source/rows.js"),y=k.createRowFactory,f=k.groupKey,g=k.groupPathElement,a=k.groupPrefixKeys,r=k.lazyRowView,c=B("packages/core/src/source/handles.js").createHandleProvider,u=B("packages/core/src/compute/incremental.js"),n=u.RunningTotal,m=u.isIncremental,s=B("packages/core/src/compute/handle.js").presenceReader,h=B("packages/core/src/source/filterwire.js"),d=h.querySignature,o=h.mapConditions,b=h.resolveRelativeCondition,l=B("packages/core/src/source/tree.js"),p=l.buildTree,w=l.resolveTree,v=l.indexTree,R=B("packages/core/src/source/settle.js"),Y=R.PIPELINE_SETTLE_REASONS,K=R.isPipelineSettle,V=Object.freeze(["filter","sort","group","total","pivot","flatten"]),E=Object.freeze([]);function O(q,N){if(!q)return null;const Q=N==="grand"?q.grandTotal:q.groupTotal;return Q??q.total}function C(q){return!!q&&!q.running}function S(q){if(q)return q.value&&z(q.value.compare)?q.value.compare:z(q.compare)?q.compare:void 0}function F(q){const N=q&&q.dataType;return!N||!z(N.items)?null:{items:N.items,type:q.itemType&&q.itemType.name||"text"}}function P(q){return!!q&&(typeof q=="object"||typeof q=="function")&&z(q.then)}const M=new Uint32Array(0),x=4096;function U(q,N){return new W(q,N)}function _(q,N){if(N==="regex")try{const Q=new RegExp(q,"iu");return J=>Q.test(J)}catch{return Q=>Q.includes(q)}if(N==="fuzzy"){const Q=[...q].filter(J=>J!==" ");return Q.length?J=>{let ee=0;for(let ne=0;ne<J.length&&ee<Q.length;ne++)J[ne]===Q[ee]&&ee++;return ee===Q.length}:()=>!0}if(N==="words"){const Q=q.split(/\s+/).filter(Boolean);return Q.length?J=>Q.every(ee=>J.includes(ee)):()=>!0}return Q=>Q.includes(q)}class W{mode="memory";#e;#t;#n;#r=!1;#i=null;#s;#a;#l=new Map;#o=!1;#c=0;#u=0;#f=new Map;#d=new Map;#h;#p=null;#m=W.#g();static#g(){return{slots:[],groupHeadings:E,unnumbered:E,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;#I=null;#G=null;#K=Symbol("unset");#L=new Map;#q=null;get#U(){return this.#m.slots}set#U(N){this.#m.slots=N}get#Y(){return this.#m.inlineLeaves}set#Y(N){this.#m.inlineLeaves=N}get#z(){return this.#m.groupHeadings}set#z(N){this.#m.groupHeadings=N}get#D(){return this.#m.unnumbered}set#D(N){this.#m.unnumbered=N}get#V(){return this.#m.pivot}set#V(N){this.#m.pivot=N}constructor(N,Q){this.#t=N||{mode:"memory"},this.#e=Q||{};const J=this.#e.config||{};this.#n=this.#t.rows||J.rows||[],this.#s=y(this.#e),this.#a=c(this.#e,()=>this.#n,()=>this.#r),this.#h=new T(Number(J.rowCacheSize)||x);for(const ee of V)this.#l.set(ee,{key:null,result:null,id:0,computed:!1})}count(){this.#B();const N=this.#ge();return N?N.length:this.#U.length}#ge(){const N=Number(this.#_("pageSize",0))||0;if(N<=0)return null;const Q=this.#U.length,J=Math.max(1,Math.ceil(Q/N)),ne=Math.min(Math.max(0,Number(this.#_("page",0))||0),J-1)*N;return{offset:ne,length:Math.max(0,Math.min(N,Q-ne))}}pageInfo(){this.#B();const N=Number(this.#_("pageSize",0))||0,Q=this.#U.length;if(N<=0)return{page:0,pageSize:0,total:Q,pageCount:1};const J=Math.max(1,Math.ceil(Q/N));return{page:Math.min(Math.max(0,Number(this.#_("page",0))||0),J-1),pageSize:N,total:Q,pageCount:J}}totalCount(){return this.#et().length}matchCount(){return this.#B(),this.#m.matchCount}at(N){this.#B();const Q=this.#ge();if(Q)return N<0||N>=Q.length?void 0:this.#_e(Q.offset+N,N);if(!(N<0||N>=this.#U.length))return this.#_e(N,N)}byKey(N){this.#B(),this.#p||this.#Ae();const Q=this.#p.get(N);if(Q!==void 0)return this.#ce(Q);for(let J=0;J<this.#U.length;J++){const ee=this.#U[J];if(typeof ee!="number"&&ee&&ee.key===N)return this.#_e(J)}}loaded(N){return N>=0&&N<this.count()}hint(N,Q){}display(){return this.#B(),this.#q||(this.#q=this.#$e()),this.#q}invalidateQuickText(){this.#L.clear(),this.invalidate("filter")}invalidate(N){const Q=V.indexOf(N);Q<0&&I(`unknown pipeline stage "${N}"; expected one of ${V.join(", ")}`);for(let J=Q;J<V.length;J++){const ee=this.#l.get(V[J]);ee.key=null,ee.computed=!1}this.#q=null}apply(N){const Q=[],J={added:[],updated:[],removed:[],rejected:Q};if(!N)return J;let ee=!1;const ne=new Set;if(N.remove&&N.remove.length)for(const se of N.remove){const le=this.#Ce(se);if(le===void 0){Q.push({operation:"remove",id:this.#He(se),reason:"unknown-id"});continue}J.removed.push(this.#s.keyOf(this.#r?this.#Qe(le):this.#n[le],le)),this.#r||(this.#n[le]=void 0),this.#h.delete(le),this.#L.delete(le),ee=!0}if(N.update&&N.update.length){const se=this.#O.size||this.#at()?this.#Ke():null,le=this.#v.size?this.#ht():null,ye=le&&le.length?this.#Ke():null;for(const fe of N.update){const we=this.#Ce(fe);if(we===void 0){Q.push({operation:"update",id:this.#xe(fe),reason:"unknown-id"});continue}const ke=this.#r?this.#i&&this.#i.has(we)?this.#i.get(we):this.#Qe(we):this.#n[we],Ce=A(ke,fe);for(const ce of this.#le(ke,Ce))ne.add(ce);if(this.#r||(this.#n[we]=Ce),se&&this.#Je(se,we,ke,Ce),ye&&this.#We(le,ye,we,ke,Ce),this.#p){const ce=this.#s.keyOf(ke,we),ae=this.#s.keyOf(Ce,we);ce!==ae&&(this.#p.delete(ce),this.#p.set(ae,we))}this.#h.delete(we),this.#L.delete(we),J.updated.push(this.#ce(we))}}if(N.add&&N.add.length&&this.#r){typeof N.at=="number"&&N.at<this.#j()&&(this.#h.clear(),this.#L.clear()),this.#p=null;for(const se of N.add){const le=this.#ae(this.#xe(se));le!==void 0&&J.added.push(this.#ce(le))}ee=!0}else if(N.add&&N.add.length){let se=typeof N.at=="number"?N.at:this.#n.length;if(se<this.#n.length){let fe=0;for(let we=0;we<this.#n.length;we++)this.#n[we]!==void 0&&fe++;if(fe!==this.#n.length){let we=0;for(let ke=0;ke<this.#n.length;ke++)this.#n[ke]!==void 0&&(this.#n[we++]=this.#n[ke]);this.#n.length=we,this.#p=null,this.#h.clear(),this.#L.clear()}}const le=this.#n.length;se=Math.max(0,se);let ye=N.add===this.#n?N.add.slice():N.add;if(this.#s.keyed){const fe=[];for(const we of ye){const ke=this.#xe(we);if(this.#Ce(ke)!==void 0){Q.push({operation:"add",id:ke,reason:"duplicate-id"});continue}fe.push(we)}fe.length!==ye.length&&(ye=fe)}if(!ye.length)return J;if(se>=le)for(let fe=0;fe<ye.length;fe++)this.#n.push(ye[fe]);else this.#n.splice(se,0,...ye),this.#h.clear(),this.#L.clear();for(let fe=0;fe<ye.length;fe++)J.added.push(this.#ce(se>=le?le+fe:se+fe));ee=!0}return this.#c++,ee&&(this.#p=null,this.#lt()),this.#a.invalidate(),this.#q=null,ee||this.#ne(ne)?(this.#u++,this.invalidate("filter")):this.invalidate("total"),this.#bt("rows:changed",{companion:!0,added:J.added.length,updated:J.updated.length,removed:J.removed.length}),this.#i=null,J}groupHeadingsAt(N){this.#B();const Q=this.#z;if(!Q.length||!Number.isInteger(N)||N<0)return E;let J=0,ee=Q.length-1,ne=-1;for(;J<=ee;){const le=J+ee>>1;Q[le].at<=N?(ne=le,J=le+1):ee=le-1}if(ne<0)return E;const se=[];for(let le=Q[ne].row;le;le=le.parent)se.push(le);return se.reverse(),se}unnumberedRowCount(N){this.#B();const Q=this.#D;if(!Q.length||!Number.isInteger(N)||N<0)return 0;let J=0,ee=Q.length-1,ne=-1;for(;J<=ee;){const se=J+ee>>1;Q[se].at<=N?(ne=se,J=se+1):ee=se-1}return ne+1}moveRow(N,Q){if(this.#r)return D("source.moveRow.dropped","rows.move() is not supported under ingest.dropSourceRows: the source objects have been released and the store cannot reorder its columns in place. Enable retainSource (leave dropSourceRows off) to reorder rows."),!1;const J=this.#n;if(!Number.isInteger(N)||!Number.isInteger(Q))return!1;let ee=0;for(let le=0;le<J.length;le++)J[le]!==void 0&&ee++;if(N<0||N>=ee)return!1;const ne=Math.max(0,Math.min(ee-1,Q));if(ne===N)return!1;if(ee!==J.length){let le=0;for(let ye=0;ye<J.length;ye++)J[ye]!==void 0&&(J[le++]=J[ye]);J.length=le}const[se]=J.splice(N,1);return J.splice(ne,0,se),this.#c++,this.#u++,this.#p=null,this.#h.clear(),this.#L.clear(),this.#lt(),this.#a.invalidate(),this.#q=null,this.invalidate("filter"),this.#bt("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(N){this.#ue(),this.#c++,this.#u++,this.#p=null,this.#L.clear(),this.#h.clear(),this.#lt(),this.#a.invalidate(),this.invalidate("filter"),this.#bt("model:changed",{reason:"reload"})}destroy(){this.#ue(),this.#h.clear(),this.#L.clear(),this.#p=null,this.#U=[],this.#Y=null,this.#q=null,this.#lt();for(const N of V)this.#l.set(N,{key:null,result:null,id:0,computed:!1})}#se(N){const Q=this.#e.sortPending;z(Q)&&Q(N)}#ue(){this.#b.has("sort")&&this.#se(!1);for(const{controller:N}of this.#b.values())try{N.abort()}catch{}this.#b.clear()}setRows(N){this.#n=N||[],this.#r=!1,this.#c++,this.#u++,this.#p=null,this.#L.clear(),this.#h.clear(),this.#lt(),this.#a.invalidate(),this.invalidate("filter")}notePriorRows(N){this.#i=N||null}releaseSource(){this.#r=!0,this.#n=[],this.#p=null,this.#h.clear(),this.#L.clear(),this.#a.invalidate()}data(){if(!this.#r)return this.#n;const N=this.#e.store;if(!N||!z(N.source))return this.#n;const Q=N.physical||0,J=new Array(Q);for(let ee=0;ee<Q;ee++)J[ee]=N.live&&!N.live(ee)?void 0:N.source(ee);return J}#Me(){const N=this.#_("detail",null);return!N||!z(N.isOpen)||N.inline===!1?null:N}#fe(){const N=(this.#e.config||{}).tree;return this.#K!==N&&(this.#K=N,this.#G=w(N,{dataAt:Q=>this.#Qe(Q),keyOf:Q=>this.#s.keyOf(this.#Qe(Q),Q)})),this.#G}#oe(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#oe())return null;this.#B();const N=this.#m.grand;return N?this.#s.grandTotal(N,this.#te(this.#m.grandLeaves)):null}pivot(){return this.#B(),this.#V}pivotMatrix(){this.#B();const N=this.#m.groupLeaves,Q=(this.#e.compute||{}).pivotMatrix;if(!z(Q))return null;const J=this.#_("groupBy",[]),ee=this.#_("pivotBy",[]);if(!J.length&&!ee.length)return D("pivotView.no-dimension","pivotView is on but the grid has no pivot dimension, so there is no matrix to draw. Put a column on the pivot (its `pivot` setting, or `pivotBy` in the query) for the columns across the top, and group by a column for the rows down the side."),null;const ne=this.#Ke().map(le=>({colId:le.id,handle:this.#a.handle(le.id),fn:O(le,"group")})).filter(le=>le.handle&&le.fn),se=this.#e.config||{};return Q({rowHandles:J.map(le=>this.#a.handle(le)).filter(Boolean),columnHandles:ee.map(le=>this.#a.handle(le)).filter(Boolean),measures:ne,leaves:N||new Uint32Array(0),opts:{locale:se.locale,separator:(se.pivot||{}).separator,maxColumns:(se.pivot||{}).maxColumns}})}keysForLeaves(N){const Q=[];if(!N)return Q;for(let J=0;J<N.length;J++){const ee=this.#ce(N[J]);ee&&ee.key!=null&&Q.push(String(ee.key))}return Q}leavesOf(N){this.#B();const Q=this.#l.get("group"),J=Q&&Q.result;if(!J||!J.nodes)return[];const ee=J.nodes.get(N);if(!ee)return[];const ne=[],se=le=>{const ye=le.row&&le.row.children;if(ye&&ye.length){for(const fe of ye){const we=J.nodes.get(fe.key);we&&se(we)}return}if(le.leaves)for(let fe=0;fe<le.leaves.length;fe++)ne.push(this.#ce(le.leaves[fe]))};return se(ee),ne}#He(N){return typeof N=="string"?N:this.#xe(N)}#xe(N){try{return this.#s.keyOf(N,-1)}catch{return"(unkeyed)"}}#Ce(N){if(typeof N=="string")return this.#ae(N);if(this.#s.keyed){const J=this.#s.keyOf(N,-1),ee=this.#ae(J);if(ee!==void 0)return ee}if(this.#r)return;const Q=this.#n.indexOf(N);return Q>=0?Q:void 0}#ae(N){return this.#p||this.#Ae(),this.#p.get(N)}#Ae(){this.#p=new Map;const N=this.#j(),Q=this.#e.store,J=Q&&z(Q.live)?ee=>Q.live(ee):null;for(let ee=0;ee<N;ee++){if(J&&!J(ee))continue;const ne=this.#Qe(ee);ne!==void 0&&this.#p.set(this.#s.keyOf(ne,ee),ee)}}#le(N,Q){const J=[];for(const ee of this.#W())this.#Be(ee)&&this.#Z(ee,N,Q,new Set)&&J.push(ee);return J}#Z(N,Q,J,ee){if(ee.has(N))return!1;ee.add(N);const ne=this.#Be(N);if(!ne)return!1;const se=ne.value&&ne.value.deps;return Array.isArray(se)&&se.length?se.some(le=>this.#Z(String(le),Q,J,ee)):z(ne.getValue)?!Object.is(ne.getValue(Q),ne.getValue(J)):!1}#W(){const N=new Set;for(const J of this.#_("sort",[]))N.add(J.col);for(const J of this.#_("groupBy",[]))N.add(J);const Q=J=>{if(J){if(Array.isArray(J.conditions)){J.conditions.forEach(Q);return}J.col&&N.add(J.col)}};return Q(this.#_("filters",null)),[...N]}#ne(N){if(!N.size)return!1;if(this.#_("quick",""))return!0;for(const Q of this.#W())if(N.has(Q))return!0;return!1}#B(){if(!this.#o){this.#o=!0;try{this.#Ee()}finally{this.#o=!1}}}pipelineRunning(){return this.#o}#Ee(){const N=this.#de("filter",()=>this.#$(),()=>this.#Ve()),Q=this.#re(N),J=this.#de("group",()=>this.#F(),()=>this.#Fe(Q)),ee=this.#de("total",()=>this.#ke(),()=>this.#qe(J));this.#de("pivot",()=>this.#ee(),()=>this.#Ge(J)),this.#de("flatten",()=>this.#Le(),()=>this.#kt(J)),this.#ye(J,ee)}#re(N){const Q=this.#l.get("sort"),J=this.#H();if(Q.computed&&Q.key===J&&!this.#b.has("sort"))return Q.result;const ee=this.#b.get("sort");return ee&&ee.key===J?Q.result:Q.result&&this.#Te(N)?(this.#we(N,J),Q.result):this.#de("sort",()=>J,()=>this.#k(N))}#pe(){if(this.#y===null){const N=this.#e.pipelineWorker,Q=z(N)?N():null;this.#y=Q||!1}return this.#y||null}#be(){const N=this.#_("sort",[]);if(!Array.isArray(N)||!N.length)return null;const Q=(this.#e.config||{}).locale,J=[],ee=[];for(const ne of N){const se=this.#Be(ne.col);if(se&&se.running)continue;if(se&&se.value&&z(se.value.compare))return null;const le=this.#a.handle(ne.col);if(!le)return null;J.push({col:ne.col,descending:ne.dir==="desc",nullsFirst:!!ne.nullsFirst,locale:Q}),ee.push(le)}return J.length?{entries:J,handles:ee,locale:Q}:null}#Te(N){if(this.#he())return!1;const Q=this.#pe();if(!Q)return!1;const J=Number(Q.threshold);return Number.isFinite(J)&&N.length<J?!1:!!this.#be()}#we(N,Q){const J=this.#pe(),ee=J&&this.#be();if(!ee){this.#de("sort",()=>Q,()=>this.#k(N));return}const ne=new AbortController;this.#b.set("sort",{key:Q,controller:ne});const se=ee.entries.length===1?J.sortColumn(ee.handles[0],N,{descending:ee.entries[0].descending,nullsFirst:ee.entries[0].nullsFirst,locale:ee.locale,signal:ne.signal,key:"sort"}):J.sortMulti(ee.handles,ee.entries.map((le,ye)=>({...le,handle:ee.handles[ye]})),N,{signal:ne.signal,key:"sort"});if(!P(se)){this.#b.delete("sort"),this.#de("sort",()=>Q,()=>se),this.#se(!1);return}this.#se(!0),se.then(le=>this.#ve(Q,le),le=>this.#Se("sort",Q,le))}#ve(N,Q){const J=this.#b.get("sort");if(!(!J||J.key!==N)){if(this.#H()!==N){this.#b.delete("sort"),this.#se(!1);return}this.#b.delete("sort"),this.#de("sort",()=>N,()=>Q),this.#q=null,this.#B(),this.#bt("model:changed",{reason:Y[0]}),this.#se(!1)}}#Se(N,Q,J){const ee=this.#b.get(N);if(!(!ee||ee.key!==Q)){if(this.#b.delete(N),J&&J.name==="AbortError"){N==="sort"&&this.#se(!1);return}if(N==="sort"&&this.#H()===Q){const ne=this.#de("filter",()=>this.#$(),()=>this.#Ve());this.#de("sort",()=>Q,()=>this.#k(ne)),this.#q=null,this.#B(),D("source.pipeline.sort","off-thread sort failed; recomputed on the main thread.",J),this.#bt("model:changed",{reason:Y[1]})}N==="sort"&&this.#se(!1)}}#ye(N,Q){const J=N&&N.leaves?N.leaves.length:this.#m.slots.length;this.#m.matchCount=J,this.#m.grand=Q&&Q.grand||null,this.#m.grandLeaves=N&&N.leaves?N.leaves.length:0,this.#m.groupLeaves=N&&N.leaves?N.leaves:null}#de(N,Q,J){const ee=this.#l.get(N),ne=Q();return ee.computed&&ee.key===ne||(ee.result=J(),ee.key=ne,ee.computed=!0,ee.id++,N==="flatten"&&(this.#q=null)),ee.result}#J(N){return this.#l.get(N).id}#$(){const N=(this.#e.config||{}).hostFilter,Q=N&&z(N.active)&&N.active()?1:0,J=this.#_("where",null),ee=J?J.version:0,ne=this.#it("filter.sig",`${this.#St()}`,()=>d({filters:this.#_("filters",null),quick:this.#_("quick",""),quickMode:this.#_("quickMode","contains")}));return`${this.#u}|${ne}|${Q}|${ee}`}#H(){const N=this.#he();return`${this.#J("filter")}|${JSON.stringify(this.#_("sort",[]))}`+(N?`|manual:${N.version}`:"")}#he(){const N=this.#_("rowOrder",null);return N&&Array.isArray(N.keys)?N:null}#ie(N,Q){this.#p||this.#Ae();const J=this.#p,ee=this.#j(),ne=Q.keys.length,se=new Float64Array(ee);for(let le=0;le<ee;le++)se[le]=ne+le;for(let le=0;le<ne;le++){const ye=J.get(Q.keys[le]);ye!==void 0&&(se[ye]=le)}return Uint32Array.from(N).sort((le,ye)=>se[le]-se[ye])}orderedKeys(){this.#p||this.#Ae();const N=this.#p,Q=new Map;for(const[le,ye]of N)Q.set(ye,le);const J=Uint32Array.from([...Q.keys()]).sort(),ee=this.#he(),ne=ee?this.#ie(J,ee):this.#k(J),se=new Array(ne.length);for(let le=0;le<ne.length;le++)se[le]=Q.get(ne[le]);return se}#F(){const N=this.#_("pivotBy",[]).length>0?"p":"u";return`${this.#J("sort")}|${JSON.stringify(this.#_("groupBy",[]))}|${N}`}#ke(){const N=this.#rt()?"f":"a",Q=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#J("group")}|${JSON.stringify(this.#_("totals",[]))}|${N}${Q}|${this.#c}`}#ee(){return`${this.#J("group")}|${JSON.stringify(this.#_("pivotBy",[]))}`}#Le(){const Q=this.#je()||!this.#oe()?this.#J("total"):"x",J=`${this.#St()}`,ee=this.#it("flatten.keys",J,()=>{const se=this.#_("expanded",null);return se?[...se].sort().join(""):"*"}),ne=this.#it("flatten.detail",J,()=>{const se=this.#_("detail",null);return se&&z(se.signature)?se.signature():""});return`${Q}|${this.#J("pivot")}|${ee}|${ne}`}#je(){const N=this.#_("groupBy",[]);return Array.isArray(N)&&N.length>0}stageState(){const N=[];for(const[Q,J]of this.#l){const ee=J.result;N.push({stage:Q,materialised:!!J.computed,bytes:ee&&typeof ee.byteLength=="number"?ee.byteLength:null,rows:ee&&typeof ee.length=="number"?ee.length:null,rebuilds:J.id})}return N}facetIndices(N){return this.#Ve(N||null)}facetRows(N){const Q=this.facetIndices(N),J=[];for(let ee=0;ee<Q.length;ee++){const ne=this.#ce(Q[ee]);ne&&J.push(ne)}return J}invalidateRows(){this.#h.clear(),this.#L.clear(),this.#q=null}invalidateHandles(){this.#a.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#et()}filteredIndices(){const N=this.#l.get("filter");if(N&&N.computed&&N.key===this.#$())return N.result||this.#et();this.#B();const Q=this.#l.get("filter");return(Q&&Q.computed?Q.result:null)||this.#et()}unfilteredRows(){const N=this.#et(),Q=[];for(let J=0;J<N.length;J++){const ee=this.#ce(N[J]);ee&&Q.push(ee)}return Q}#Ve(N=null){const Q=this.#et(),J=this.#_("filters",null),ee=N?this.#ft("pruneColumn")(J,N):J,ne=this.#mt(ee),se=String(this.#_("quick","")||"").trim().toLowerCase(),le=se?_(se,String(this.#_("quickMode","contains")||"contains")):null,ye=(this.#e.config||{}).hostFilter,fe=!!(ye&&z(ye.active)&&ye.active()),we=this.#_("where",null),ke=!!(we&&we.active);if(!ne&&!se&&!fe&&!ke)return Q;let Ce=null;ne&&(Ce=this.#ft("evaluateFilters")(ne,{handle:de=>this.#a.handle(de),count:this.#j(),pool:this.#e.pool,locale:(this.#e.config||{}).locale,itemwise:de=>F(this.#Be(de))}));const ce=new Uint32Array(Q.length);let ae=0;for(let ge=0;ge<Q.length;ge++){const de=Q[ge];if(!(Ce&&!Ce[de])&&!(le&&!this.#De(de,le))){if(fe||ke){const me=this.#ce(de);if(fe&&!ye.passes(me)||ke&&!we.passes(me.data,me.key))continue}ce[ae++]=de}}if(Ce){const ge=(this.#e.compute||{}).releaseMask;z(ge)&&ge({pool:this.#e.pool},Ce)}return ce.subarray(0,ae)}handleFor(N){return this.#a.handle(N)}#k(N){const Q=this.#he();if(Q)return this.#ie(N,Q);const J=this.#_("sort",[]).filter(se=>{const le=this.#Be(se.col);return!le||!le.running?!0:(D(`source.sort.running.${se.col}`,`sort ignores "${se.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(!J.length)return N;const ee=(this.#e.config||{}).locale;if(J.length===1){const se=J[0],le=this.#a.handle(se.col);if(!le)return D(`source.sort.${se.col}`,`sort ignores unknown column "${se.col}".`),N;const ye=this.#Be(se.col);return this.#ft("sortColumn")(le,N,{descending:se.dir==="desc",nullsFirst:se.nullsFirst,locale:ee,compare:S(ye)})}const ne=[];for(const se of J){const le=this.#a.handle(se.col);if(!le){D(`source.sort.${se.col}`,`sort ignores unknown column "${se.col}".`);continue}ne.push({handle:le,descending:se.dir==="desc",nullsFirst:se.nullsFirst,locale:ee,compare:S(this.#Be(se.col))})}return ne.length?this.#ft("sortMulti")(ne.map(se=>se.handle),ne,N):N}#Fe(N){const Q=this.#_("groupBy",[]),J=this.#fe();if(J&&!Q.length){const ge=p(N,J);return this.#R=v(ge.roots,J.declaresChildren),{roots:null,leaves:N,nodes:new Map,tree:ge}}if(this.#R=null,J&&Q.length&&D("tree.grouped","grouping is active on a grid configured with `tree`; the grouping wins and the hierarchy is not shown."),!Q.length)return{roots:null,leaves:N,nodes:new Map};const ee=(this.#e.config||{}).timeZone,ne=[],se=[];let le=!1;for(const ge of Q){const de=this.#a.handle(ge);if(!de){D(`source.group.${ge}`,`grouping ignores unknown column "${ge}".`);continue}ne.push(de);const me=this.#Be(ge),ve=me&&me.dataType;if(ve&&z(ve.groupProjector)){const xe=me.typeOptions&&me.typeOptions.timeZone||ee||void 0,Ee=ve.groupProjector(me,xe);se.push(Ee||null),Ee&&(le=!0)}else se.push(null)}if(!ne.length)return{roots:null,leaves:N,nodes:new Map};const{keys:ye,buckets:fe}=this.#ft("groupByColumns")(ne,N,{locale:(this.#e.config||{}).locale,project:le?se:void 0}),we=this.#_("pivotBy",[]).length>0,ke=[],Ce=new Map;for(let ge=0;ge<fe.length;ge++){const de=ye[ge];let me=null;const ve=[];for(let xe=0;xe<de.length;xe++){ve.push(g(de[xe]));const Ee=f(ve),Le=xe===de.length-1;let He=Ce.get(Ee);if(!He){const Me=this.#s.group({path:[...ve],column:Q[xe],value:de[xe],level:xe,parent:me,expanded:we&&Le?!1:this.#gt(Ee,{key:Ee,column:Q[xe],value:de[xe],level:xe,path:[...ve]}),hasChildren:!(we&&Le)});He={row:Me,leaves:null},Ce.set(Ee,He),me?me.children.push(Me):ke.push(Me)}He.row.leafCount+=fe[ge].length,xe===de.length-1&&(He.leaves=fe[ge]),me=He.row}}const ce=this.#_("sort",[])||[],ae=(ge,de)=>{if(!ge||ge.length<2){if(ge)for(const Ee of ge)ae(Ee.children,de+1);return}const me=Q[de],ve=ce.find(Ee=>Ee.col===me),xe=ve&&ve.dir==="desc"?-1:1;ge.sort((Ee,Le)=>xe*X(Ee.groupValue,Le.groupValue));for(const Ee of ge)ae(Ee.children,de+1)};return ae(ke,0),{roots:ke,leaves:N,nodes:Ce,keys:ye,buckets:fe}}#Ye(N,Q){const J=new Map,ee=new Map,ne=se=>{const le=se.physical>=0?[se.physical]:[];for(const ye of se.children)le.push(...ne(ye));if(se.children.length){const ye=this.#Xe(Q,Uint32Array.from(le),null);se.physical>=0?J.set(se.physical,ye):ee.set(se.key,ye)}return le};for(const se of N.roots)ne(se);return{byPhysical:J,byKey:ee}}#qe(N){const Q=this.#Ke();if(!Q.length)return this.#E=null,this.#T=null,{grand:null};const J={id:this.#J("group"),columns:Q.map(ce=>ce.id).join("")},ee=this.#E&&this.#E.id===J.id&&this.#E.columns===J.columns,ne=this.#at()&&ee?this.#C:null,se=ne?Q.filter(ce=>ne.has(ce.id)):Q,le=ee?this.#T:null,ye=this.#rt()?null:this.#Tt(),fe=this.#Pe(Q),we=ce=>{const ae=N.nodes.get(ce.key);let ge=ae&&ae.leaves?ae.leaves:null;if(ce.children&&ce.children.length){const ve=ce.children.map(we);let xe=0;for(const He of ve)xe+=He.length;const Ee=new Uint32Array(xe);let Le=0;for(const He of ve)Ee.set(He,Le),Le+=He.length;ge=Ee}ge=ge||new Uint32Array(0);const de=ye?ye.get(ce.key)||M:ge,me=this.#Ze(ce,ne?se:Q,de,fe);return ce.totals=ne?{...ce.totals,...me}:me,ge};if(N.roots&&se.length)for(const ce of N.roots)we(ce);if(this.#I=N.tree?this.#Ye(N.tree,Q):null,this.#E=J,this.#C=this.#at()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#A.length=0,this.#T=null,{grand:null};const Ce=ye?this.#st():N.leaves;return this.#T=this.#Oe(Q,Ce,ne,le),{grand:this.#T}}#Oe(N,Q,J,ee){const ne={},se=this.#J("group");se!==this.#w&&(this.#ct(),this.#w=se);const le=this.#A;this.#A=[];for(const ye of N){if(!C(ye))continue;const fe=this.#a.handle(ye.id);if(!fe)continue;const we=O(ye,"grand");if(!m(we,fe)){if(J&&!J.has(ye.id)&&ee&&ye.id in ee){ne[ye.id]=ee[ye.id];continue}ne[ye.id]=this.#Xe([ye],Q,null,"grand")[ye.id];continue}let ke=this.#O.get(ye.id);if((!ke||ke.fn!==we)&&(ke=new n(we),this.#O.set(ye.id,ke)),ke.valid){let Ce=!0;for(const ce of le)if(ce.colId===ye.id&&!ke.update(ce.before,ce.after)){Ce=!1;break}if(Ce){ne[ye.id]=ke.value();continue}ke.invalidate()}ke.seedColumn(fe.values,s(fe),Q),ne[ye.id]=ke.valid?ke.value():this.#Xe([ye],Q,null,"grand")[ye.id]}return ne}#Pe(N){const Q=this.#J("group");Q!==this.#P&&(this.#v.clear(),this.#P=Q);const J=new Map;for(const ne of N){if(!C(ne))continue;const se=this.#a.handle(ne.id),le=O(ne,"group");m(le,se)&&J.set(ne.id,{fn:le})}if(!J.size)return this.#S.length=0,J;const ee=this.#S;this.#S=[];for(const ne of ee){const{beforeKeys:se,afterKeys:le,colDeltas:ye}=ne,fe=se.length?new Set(se):null,we=le.length?new Set(le):null;for(const{colId:ke,before:Ce,after:ce}of ye)if(J.has(ke)){for(const ae of se)we&&we.has(ae)||this.#dt(ae,ke,Ce,null);for(const ae of le)fe&&fe.has(ae)||this.#dt(ae,ke,null,ce);for(const ae of se)we&&!we.has(ae)||this.#dt(ae,ke,Ce,ce)}}return J}#dt(N,Q,J,ee){const ne=this.#v.get(N),se=ne&&ne.get(Q);!se||!se.valid||se.update(J,ee)||se.invalidate()}#Ze(N,Q,J,ee){if(!ee||!ee.size)return this.#Xe(Q,J,N);const ne={};let se=null,le=this.#v.get(N.key);for(const ye of Q){const fe=ee.get(ye.id);if(!fe){(se||(se=[])).push(ye);continue}const we=this.#a.handle(ye.id);if(!we)continue;le||(le=new Map,this.#v.set(N.key,le));let ke=le.get(ye.id);if((!ke||ke.fn!==fe.fn)&&(ke=new n(fe.fn),le.set(ye.id,ke)),ke.valid||ke.seedColumn(we.values,s(we),J),ke.valid){ne[ye.id]=ke.value();continue}(se||(se=[])).push(ye)}return se&&Object.assign(ne,this.#Xe(se,J,N)),ne}#Je(N,Q,J,ee){const ne=!this.#rt()||this.#Et(Q);for(const se of N){const le=se.getValue;if(!z(le))continue;const ye=le(J),fe=le(ee);Object.is(ye,fe)||(this.#C&&this.#C.add(se.id),ne&&this.#O.has(se.id)&&this.#A.push({colId:se.id,before:ye,after:fe}))}}#ht(){const N=this.#_("groupBy",[]),Q=[];for(const J of N){const ee=this.#Be(J);ee&&Q.push(ee)}return Q}#pt(N,Q){const J=new Array(N.length);for(let ee=0;ee<N.length;ee++){const ne=N[ee].getValue;J[ee]=g(z(ne)?ne(Q):void 0)}return J}#We(N,Q,J,ee,ne){if(this.#rt()&&!this.#Et(J))return;const se=a(this.#pt(N,ee)),le=a(this.#pt(N,ne)),ye=se.length!==le.length||se.some((we,ke)=>we!==le[ke]),fe=[];for(const we of Q){const ke=we.getValue;if(!z(ke))continue;const Ce=ke(ee),ce=ke(ne);!ye&&Object.is(Ce,ce)||fe.push({colId:we.id,before:Ce,after:ce})}!fe.length&&!ye||this.#S.push({beforeKeys:se,afterKeys:le,colDeltas:fe})}#Et(N){const Q=this.#l.get("filter"),J=Q&&Q.computed?Q.result:null;if(!J)return!0;let ee=0,ne=J.length-1;for(;ee<=ne;){const se=ee+ne>>1,le=J[se];if(le===N)return!0;le<N?ee=se+1:ne=se-1}return!1}#rt(){return(this.#e.config||{}).totalFilteredOnly!==!1}#te(N){return this.#rt()?N:this.#st().length}#st(){return(!this.#M||this.#M.version!==this.#u)&&(this.#M={version:this.#u,indices:this.#et()}),this.#M.indices}#Tt(){const N=this.#_("groupBy",[]),Q=`${this.#u}|${JSON.stringify(N)}`;if(this.#N&&this.#N.key===Q)return this.#N.map;const J=new Map,ee=[];for(const ne of N){const se=this.#a.handle(ne);se&&ee.push(se)}if(ee.length){const ne=this.#st(),{keys:se,buckets:le}=this.#ft("groupByColumns")(ee,ne,{locale:(this.#e.config||{}).locale}),ye=new Map;for(let fe=0;fe<le.length;fe++){const we=se[fe],ke=[];for(let Ce=0;Ce<we.length;Ce++){ke.push(g(we[Ce]));const ce=f(ke);let ae=ye.get(ce);ae||(ae=[],ye.set(ce,ae));for(let ge=0;ge<le[fe].length;ge++)ae.push(le[fe][ge])}}for(const[fe,we]of ye)J.set(fe,Uint32Array.from(we))}return this.#N={key:Q,map:J},J}#at(){return!!(this.#e.config||{}).totalOnlyChangedColumns}#lt(){this.#ct(),this.#vt(),this.#C=null,this.#E=null,this.#T=null}#ct(){this.#O.clear(),this.#A.length=0,this.#w=-1}#vt(){this.#v.clear(),this.#S.length=0,this.#P=-1}#Ge(N){const Q=this.#_("pivotBy",[]);if(!Q.length)return this.#V=null,null;const J=(this.#e.compute||{}).pivot;if(!z(J))return D("source.pivot.kernel","pivot requested but ctx.compute.pivot is not available; showing unpivoted rows."),this.#V=null,null;const ee=Q.map(se=>this.#a.handle(se)).filter(Boolean),ne=this.#Ke();return this.#V=J(ee,N.leaves,{groups:N.keys&&N.buckets?{keys:N.keys,buckets:N.buckets}:null,totals:ne.map(se=>se.id),handle:se=>this.#a.handle(se),totalOf:se=>O(ne.find(le=>le.id===se),"group"),separator:((this.#e.config||{}).pivot||{}).separator,maxColumns:((this.#e.config||{}).pivot||{}).maxColumns})||null,this.#V}#kt(N){const Q=this.#l.get("total").result,J=!!(this.#e.config||{}).groupFooter,ee=this.#Me();if(N.tree)return this.#Re(N,Q,ee);if(!N.roots&&!ee){if(Q&&Q.grand&&!this.#oe()){const we=this.#s.grandTotal(Q.grand,this.#te(N.leaves.length));if(this.#Y===N.leaves&&Array.isArray(this.#U))this.#U[this.#U.length-1]=we;else{const ke=Array.from(N.leaves);ke.push(we),this.#U=ke,this.#Y=N.leaves}this.#D=[{at:this.#U.length-1}]}else this.#Y=null,this.#U=N.leaves,this.#D=E;return this.#z=E,this.#U}const ne=[],se=[],le=[],ye=we=>{if(ne.push(we),!ee)return;const ke=this.#ce(we);!ke||!ee.isOpen(ke.key)||(ke.master=!0,ke.expanded=!0,le.push({at:ne.length}),ne.push(this.#s.detail(ke,ee.heightOf(ke))))};if(!N.roots){for(let we=0;we<N.leaves.length;we++)ye(N.leaves[we]);return Q&&Q.grand&&!this.#oe()&&(le.push({at:ne.length}),ne.push(this.#s.grandTotal(Q.grand,this.#te(N.leaves.length)))),this.#Y=null,this.#z=E,this.#D=le.length?le:E,this.#U=ne,ne}const fe=(we,ke,Ce)=>{if(we.expanded=we.hasChildren===!1?!1:this.#gt(we.key,{key:we.key,column:we.groupColumn,value:we.groupValue,level:we.level,path:we.groupPath}),we.posinset=ke+1,we.setsize=Ce,se.push({at:ne.length,row:we}),le.push({at:ne.length}),ne.push(we),!!we.expanded){if(we.children&&we.children.length)for(let ce=0;ce<we.children.length;ce++)fe(we.children[ce],ce,we.children.length);else{const ce=N.nodes.get(we.key),ae=ce&&ce.leaves?ce.leaves:null;if(ae)for(let ge=0;ge<ae.length;ge++)ye(ae[ge])}J&&we.totals&&(le.push({at:ne.length}),ne.push(this.#s.footer(we)))}};for(let we=0;we<N.roots.length;we++)fe(N.roots[we],we,N.roots.length);return Q&&Q.grand&&!this.#oe()&&(le.push({at:ne.length}),ne.push(this.#s.grandTotal(Q.grand,this.#te(N.leaves.length)))),this.#z=se,this.#D=le,this.#U=ne,ne}#et(){const N=this.#e.store;if(N&&z(N.liveIndices))return N.liveIndices();const Q=new Uint32Array(this.#n.length);let J=0;for(let ee=0;ee<this.#n.length;ee++)this.#n[ee]!==void 0&&(Q[J++]=ee);return Q.subarray(0,J)}#j(){const N=this.#e.store;return N&&typeof N.physical=="number"?N.physical:this.#n.length}#Qe(N){const Q=this.#e.store;return Q&&z(Q.source)?Q.source(N):this.#n[N]}#_e(N,Q=N){const J=this.#U[N];if(typeof J!="number")return J.index=Q,J;const ee=this.#ce(J);return ee.index=Q,ee}#ce(N){let Q=this.#h.get(N);Q||(Q=this.#s.leaf(this.#Qe(N),N),this.#h.set(N,Q));const J=this.#R?this.#R.get(N):null;if(J){Q.level=J.level,Q.posinset=J.posinset,Q.setsize=J.setsize,Q.hasChildren=J.hasChildren,Q.expanded=J.hasChildren&&!J.lazy&&this.#gt(Q.key);const ee=this.#I?this.#I.byPhysical.get(N):void 0;ee?Q.totals=ee:Q.totals&&(Q.totals=null)}else Q.hasChildren&&(Q.level=0,Q.hasChildren=!1,Q.expanded=!1,Q.posinset=void 0,Q.setsize=void 0);return Q}#Re(N,Q,J){const ee=[],ne=[],se=ye=>{if(ye.leafCount!==void 0)return ye.leafCount;let fe=ye.physical>=0?1:0;for(const we of ye.children)fe+=se(we);return ye.leafCount=fe,fe},le=ye=>{const fe=this.#gt(ye.key);if(ye.physical>=0){if(ee.push(ye.physical),J&&J.isOpen(this.#ce(ye.physical).key)){const we=this.#ce(ye.physical);ne.push({at:ee.length}),ee.push(this.#s.detail(we,J.heightOf(we)))}}else ee.push(this.#s.group({path:[ye.key],column:null,value:ye.value,level:ye.level,parent:null,expanded:fe,hasChildren:ye.children.length>0,leafCount:se(ye),totals:this.#I?this.#I.byKey.get(ye.key):void 0}));if(fe)for(const we of ye.children)le(we)};for(const ye of N.tree.roots)le(ye);return Q&&Q.grand&&!this.#oe()&&(ne.push({at:ee.length}),ee.push(this.#s.grandTotal(Q.grand,this.#te(N.leaves.length)))),this.#Y=null,this.#z=E,this.#D=ne.length?ne:E,this.#U=ee,ee}#$e(){return r(()=>this.count(),N=>this.at(N))}#De(N,Q){let J=this.#L.get(N);if(J===void 0){const ee=this.#Qe(N),ne=this.#At(),se=[],le=this.#e.columnHidden;for(const ye of ne){if(ye.quickFilter===!1||z(le)&&le(ye.id))continue;const fe=ye.value&&z(ye.value.quickFilterText)?ye.value.quickFilterText({value:void 0,data:ee,row:null,column:ye,colId:ye.id,grid:null,context:this.#_("context",null)}):null,we=fe??(z(ye.formatValue)?ye.formatValue(z(ye.getValue)?ye.getValue(ee):void 0):"");we!=null&&we!==""&&se.push(String(we))}J=se.join(" ").toLowerCase(),this.#L.set(N,J)}return Q(J)}#Ke(){const N=this.#_("totals",[]),Q=N&&N.length?new Set(N):null;return this.#At().filter(J=>Q?Q.has(J.id):!!(J.total||J.groupTotal||J.grandTotal))}#Xe(N,Q,J,ee="group"){const ne={},se=(this.#e.compute||{}).total;for(const le of N){if(!C(le))continue;const ye=this.#a.handle(le.id);if(!ye)continue;const fe=O(le,ee);if(fe)if(z(fe)){const we=new Array(Q.length);for(let ke=0;ke<Q.length;ke++)we[ke]=ye.get(Q[ke]);ne[le.id]=fe(we,{row:J,column:le,grid:this.#e.grid||null,context:this.#_("context",null),valueAt:(ke,Ce)=>{const ce=this.#a.handle(ke);return ce&&Ce>=0&&Ce<Q.length?ce.get(Q[Ce]):null}})}else z(se)&&(ne[le.id]=se(ye,Q,fe))}return ne}#mt(N){if(!N)return N;const Q=this.#e.config||{},J={tz:Q.timeZone,weekStartsOn:Q.weekStartsOn};return o(N,ee=>{const ne=b(ee,J),se=this.#Be(ne&&ne.col),le=se&&se.type==="datetime";if(ne&&ne.type)return ne.type==="datetime"&&!ne.timeZone&&se?{...ne,timeZone:Q.timeZone||void 0}:ne;if(le)return{...ne,type:"datetime",timeZone:Q.timeZone||void 0};const ye=se&&(se.dataType?.base||se.type);return ye?{...ne,type:ye}:ne})}#gt(N,Q){const J=this.#_("expanded",null);return J?z(J.has)?J.has(N,Q):Array.prototype.includes.call(J,N):!0}#_(N,Q){if(N==="context"||!z(this.#e.stateVersion))return this.#Ot(N,Q);const J=this.#Bt(N),ee=this.#f.get(N);if(ee&&ee.version===J)return ee.value;const ne=this.#Ot(N,Q);return this.#f.set(N,{version:J,value:ne}),ne}#Ot(N,Q){const J=this.#e.state;if(J&&z(J[N])){const ee=J[N]();return ee??Q}return Q}#St(){const N=this.#e.stateVersion;return z(N)?N():0}#ut(){const N=this.#e.columnsVersion,Q=this.#e.permissionsVersion;return`${z(N)?N():0}|${z(Q)?Q():0}`}#Bt(N){return N==="totals"?this.#ut():`${this.#St()}`}#it(N,Q,J){if(!z(this.#e.stateVersion))return J();const ee=this.#d.get(N);if(ee&&ee.version===Q)return ee.key;const ne=J();return this.#d.set(N,{version:Q,key:ne}),ne}#ft(N){const Q=(this.#e.compute||{})[N];return z(Q)||I(`ctx.compute.${N} is required by the memory source pipeline`),Q}#At(){const N=this.#e.columns;return N&&z(N.all)?N.all():[]}#Be(N){const Q=this.#e.columns;return Q&&z(Q.get)?Q.get(N):void 0}#bt(N,Q){const J=this.#e.emit;z(J)&&J(N,Q)}}}),Ue("packages/core/src/source/abort.js",function(e,B){"use strict";Object.defineProperty(e,"SupersededError",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"RequestToken",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"AbortScope",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"createAbortScope",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"isAbortError",{enumerable:!0,get:function(){return I}});class re extends Error{constructor(z,L="superseded"){super(`[lattice] request ${z?`"${z}" `:""}${L}`),this.name="SupersededError",this.superseded=!0,this.key=z}}class T{#e;constructor(z,L,X,$){this.#e=z,this.key=L,this.controller=X,this.signal=X.signal,this.seq=$}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(z){this.signal.aborted||this.controller.abort(new re(this.key,z)),this.#e.settle(this)}}class G{#e=new Map;#t=0;begin(z="",L="superseded"){const X=this.#e.get(z);X&&!X.signal.aborted&&X.controller.abort(new re(z,L));const $=new T(this,z,new AbortController,++this.#t);return this.#e.set(z,$),$}tokenFor(z){return this.#e.get(z)}pending(z=""){const L=this.#e.get(z);return!!L&&!L.signal.aborted}get size(){return this.#e.size}settle(z){this.#e.get(z.key)===z&&this.#e.delete(z.key)}abort(z="",L="superseded"){const X=this.#e.get(z);X&&X.abort(L)}abortAll(z="superseded"){for(const L of[...this.#e.values()])L.abort(z);this.#e.clear()}}function D(){return new G}function I(Z){if(!Z||typeof Z!="object")return!1;const z=Z;return z.superseded===!0||z.name==="AbortError"||z.name==="SupersededError"}}),Ue("packages/core/src/source/blockcache.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_PAGE_SIZE",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"DEFAULT_MAX_CACHED_PAGES",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return D}});const re=100,T=32;class G{constructor(Z){this.id=Z,this.rows=null,this.state="pending",this.token=null,this.error=null}}class D{#e=new Map;#t;#n;#r=0;#i=-1;constructor(Z={}){this.#t=Math.max(1,Math.floor(Number(Z.pageSize)||re)),this.#n=Math.max(1,Math.floor(Number(Z.maxCachedPages)||T))}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 z=this.#e.get(Z);return!!z&&z.state==="pending"}loaded(Z){const z=this.#e.get(Z);return!!z&&z.state==="loaded"}begin(Z,z){let L=this.#e.get(Z);return L||(L=new G(Z)),L.state="pending",L.token=z,L.error=null,this.#s(Z,L),L}fill(Z,z){const L=this.#e.get(Z)||new G(Z);L.rows=z,L.state="loaded",L.token=null,this.#s(Z,L)}failed(Z,z){const L=this.#e.get(Z)||new G(Z);L.state="error",L.error=z,L.token=null,this.#s(Z,L)}delete(Z){return this.#e.delete(Z)}rowAt(Z){const z=this.blockOf(Z),L=this.#e.get(z);if(!(!L||L.state!=="loaded"||!L.rows))return this.#s(z,L),L.rows[Z-z*this.#t]}rowLoaded(Z){const z=this.blockOf(Z),L=this.#e.get(z);return!!L&&L.state==="loaded"&&!!L.rows&&Z-z*this.#t<L.rows.length}erroredAt(Z){const z=this.#e.get(this.blockOf(Z));return!!z&&z.state==="error"}loadedExtent(){let Z=0;for(const z of this.#e.values()){if(z.state!=="loaded"||!z.rows)continue;const L=z.id*this.#t+z.rows.length;L>Z&&(Z=L)}return Z}fillOf(Z){const z=this.#e.get(Z);return z&&z.state==="loaded"&&z.rows?z.rows.length:null}protect(Z,z){this.#r=this.blockOf(Math.max(0,Z)),this.#i=this.blockOf(Math.max(0,z))}evict(){const Z=[];if(this.#e.size<=this.#n)return Z;for(const[z,L]of this.#e){if(this.#e.size-Z.length<=this.#n)break;z>=this.#r&&z<=this.#i||L.state!=="pending"&&Z.push(z)}for(const z of Z)this.#e.delete(z);return Z}ids(){return[...this.#e.keys()]}clear(){this.#e.clear()}#s(Z,z){this.#e.delete(Z),this.#e.set(Z,z)}}}),Ue("packages/core/src/source/pagewindow.js",function(e,B){"use strict";Object.defineProperty(e,"pageWindow",{enumerable:!0,get:function(){return re}});function re(T,G,D,I){const Z=Math.floor(Number(T)||0);if(Z<=0)return null;const z=Math.max(0,Math.floor(Number(G)||0)),L=Math.max(0,Math.floor(Number(D)||0));if(I){const X=Math.max(1,Math.ceil(L/Z)),$=Math.min(z,X-1),A=$*Z;return{page:$,pageSize:Z,offset:A,length:Math.max(0,Math.min(Z,L-A)),pageCount:X,total:L}}return{page:z,pageSize:Z,offset:z*Z,length:Z,pageCount:Math.max(z+2,Math.ceil(L/Z)),total:null}}}),Ue("packages/core/src/source/paged.js",function(e,B){"use strict";Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"PagedSource",{enumerable:!0,get:function(){return d}});const T=B("packages/core/src/internal/lru.js").Lru,D=B("packages/core/src/internal/predicates.js").isFunction,Z=B("packages/core/src/internal/warn.js").warnOnce,L=B("packages/core/src/internal/schedule.js").settleDebounce,X=B("packages/core/src/source/abort.js"),$=X.createAbortScope,A=X.isAbortError,k=B("packages/core/src/source/blockcache.js"),y=k.BlockCache,f=k.DEFAULT_PAGE_SIZE,g=k.DEFAULT_MAX_CACHED_PAGES,r=B("packages/core/src/source/rows.js").createRowFactory,i=B("packages/core/src/source/filterwire.js"),c=i.wireFilters,u=i.querySignature,n=i.warnHostFilterNotApplied,t=B("packages/core/src/source/pagewindow.js").pageWindow,s=120;function h(o,b){return new d(o,b)}class d{mode="paged";#e;#t;#n;#r=$();#i;#s;#a=new Map;#l=null;#o=null;#c=!1;#u=0;#f="";#d={start:0,end:0};#h;#p=!1;#m=0;#g="";constructor(b,l){this.#e=b||{mode:"paged"},this.#t=l||{},this.#n=new y({pageSize:this.#e.pageSize||f,maxCachedPages:this.#e.maxCachedPages||g}),this.#i=r(this.#t),this.#s=new T(this.#n.pageSize*4),this.#h=L((p,w)=>this.#w(p,w),s),this.#f=this.#C(),D(this.#e.fetch)||Z("source.paged.fetch",'source.mode "paged" requires a fetch function; the grid will stay empty.'),n(this.#t)}count(){const b=this.#y();return b?b.length:this.#b()}#b(){if(this.#P(),this.#l!==null)return this.#l;const b=Math.max(this.#u,this.#n.loadedExtent());return this.#c?b:b+this.#n.pageSize}matchCount(){return this.#b()}totalCount(){return this.#b()}pageInfo(){const b=this.#y();if(!b){const l=this.#b();return{page:0,pageSize:0,total:this.exact()?l:null,pageCount:1,counting:!1}}return{page:b.page,pageSize:b.pageSize,total:b.total,pageCount:b.pageCount,counting:b.total===null&&this.#r.size>0&&this.#u===0&&this.#n.loadedExtent()===0}}#y(){const b=this.#b(),l=t(this.#T("pageSize",0),this.#T("page",0),b,this.exact());if(!l)return this.#g="",null;const p=`${this.#m}:${l.offset}:${l.length}`;if(p!==this.#g&&!this.#p&&(this.#g=p,l.length>0)){const w=l.offset+l.length-1;this.#d={start:l.offset,end:w},this.#w(l.offset,w)}return l}at(b){const l=this.#y();if(l){if(b<0||b>=l.length)return;const p=this.#O(l.offset+b);return p&&(p.index=b),p}return this.#O(b)}#O(b){if(b<0||b>=this.#b())return;const l=this.#s.get(b);if(l&&(l.data!==null||!this.#n.rowLoaded(b)))return l;const p=this.#n.rowAt(b);if(p===void 0){const v=this.#i.skeleton(b,0,this.#n.erroredAt(b));return this.#s.set(b,v),v}const w=this.#i.leaf(p,b);return w.index=b,this.#s.set(b,w),this.#a.set(w.key,b),w}byKey(b){const l=this.#a.get(b);return l===void 0?void 0:this.#O(l)}loaded(b){const l=this.#y();return l?b>=0&&b<l.length&&this.#n.rowLoaded(l.offset+b):this.#n.rowLoaded(b)}loadedCount(){this.#P();let b=0;for(const l of this.#n.ids()){if(!this.#n.loaded(l))continue;const p=this.#n.fillOf(l);typeof p=="number"&&(b+=p)}return b}residentRows(){this.#P();const b=this.#y(),l=b?b.offset:0,p=b?b.offset+b.length:1/0,w=[],v=this.#n.ids().sort((R,Y)=>R-Y);for(const R of v){if(!this.#n.loaded(R))continue;const{start:Y}=this.#n.rangeOf(R),K=this.#n.fillOf(R)||0;for(let V=Y;V<Y+K;V++){if(V<l||V>=p)continue;const E=this.#s.peek(V);if(E&&E.data!==null&&E.data!==void 0){w.push(E);continue}const O=this.#n.rowAt(V);if(O===void 0)continue;const C=this.#i.leaf(O,V);C.index=V,this.#s.set(V,C),this.#a.set(C.key,V),w.push(C)}}return w}hint(b,l){if(this.#p)return;const p=this.#P();let w=Math.max(0,Math.floor(b)),v=Math.max(w,Math.floor(l));const R=this.#y();if(R){if(R.length===0)return;w=R.offset,v=R.offset+R.length-1}this.#d={start:w,end:v},this.#n.protect(w,v);for(const Y of this.#n.evict())this.#v(Y);this.#h(w,v),p&&this.#h.flush()}#w(b,l){if(this.#p)return;this.#n.protect(b,l);const p=this.#n.blockOf(b),w=this.#n.blockOf(l);for(let v=p;v<=w&&!(this.#l!==null&&v*this.#n.pageSize>=this.#l);v++)this.#n.has(v)||this.#A(v)}apply(b){const l={added:[],updated:[],removed:[]};if(!b)return l;if(b.update)for(const p of b.update){const w=this.#i.keyOf(p,-1),v=this.#a.get(w);if(v===void 0)continue;const R=this.#i.leaf(p,v);R.index=v,this.#s.set(v,R),l.updated.push(R)}return(b.add&&b.add.length||b.remove&&b.remove.length)&&this.reload(),l}reload(b){this.#S("reload"),this.#h.cancel(),this.hint(this.#d.start,this.#d.end)}destroy(){this.#p=!0,this.#h.cancel(),this.#r.abortAll("destroyed"),this.#n.clear(),this.#s.clear(),this.#a.clear()}exact(){return this.#l!==null||this.#c}pending(){return this.#r.size}async#A(b){if(!D(this.#e.fetch))return;const l=this.#r.begin(`block:${b}`);this.#n.begin(b,l);const{start:p,end:w}=this.#n.rangeOf(b),v=this.#f;try{const R=await this.#e.fetch({range:{start:p,end:w},sort:this.#T("sort",[]),filters:c(this.#T("filters",null),this.#E()),quick:this.#T("quick","")||void 0,context:this.#T("context",null),signal:l.signal});if(!l.current||v!==this.#f||this.#p)return;l.settle();const Y=R&&R.rows||[];this.#n.fill(b,Y);for(let V=0;V<Y.length;V++)this.#s.delete(p+V);const K=R&&typeof R.total=="number"?R.total:R&&typeof R.count=="number"?R.count:null;K!==null?(this.#l=K,this.#c=!0):Y.length<this.#n.pageSize?(this.#c=!0,this.#l=p+Y.length):this.#u=Math.max(this.#u,p+Y.length),this.#M("model:changed",{reason:"page",block:b,from:p,to:p+Y.length}),this.#M("rows:changed",{companion:!0,reason:"page",block:b,from:p,to:p+Y.length}),this.#l!==null&&this.#l!==this.#o&&(this.#o=this.#l,this.#M("source:total",{total:this.#l,groupPath:[]}))}catch(R){if(l.settle(),A(R))return;this.#n.failed(b,R);for(let Y=p;Y<w;Y++)this.#s.delete(Y);this.#M("model:changed",{reason:"page-error",block:b,range:{start:p,end:w}}),this.#M("source:error",{error:R,block:b,range:{start:p,end:w}})}}#v(b){const{start:l,end:p}=this.#n.rangeOf(b);for(let w=l;w<p;w++){const v=this.#s.peek(w);v&&this.#a.delete(v.key),this.#s.delete(w)}}#P(){const b=this.#C();return b===this.#f?!1:(this.#f=b,this.#S("query"),!0)}#S(b){this.#r.abortAll(b),this.#n.clear(),this.#s.clear(),this.#a.clear(),this.#l=null,this.#o=null,this.#c=!1,this.#u=0,this.#m++,this.#M("model:changed",{reason:b})}#C(){return u({filters:this.#T("filters",null),sort:this.#T("sort",[]),quick:this.#T("quick",""),context:this.#T("context",null)})}#E(){const b=this.#t.config||{};return{tz:b.timeZone,weekStartsOn:b.weekStartsOn}}#T(b,l){const p=this.#t.state;if(p&&D(p[b])){const w=p[b]();return w??l}return l}#M(b,l){const p=this.#t.emit;D(p)&&p(b,l)}}}),Ue("packages/core/src/source/aggregates.js",function(e,B){"use strict";Object.defineProperty(e,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"pushableAggregates",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"fillAggregateSql",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"aggregateP",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"resolveAggregatesConfig",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"routeAggregate",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"resolveAggregatePlan",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"groupKeysPushable",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"pushdownDocRows",{enumerable:!0,get:function(){return $}});const re=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 T(){const A=new Set;for(const[k,y]of Object.entries(re))y.pushable&&A.add(k);return A}function G(A,k,y,f="?"){let g=A.split("%c").join(k);return y!==void 0&&(g=g.split("%w").join(y)),g.split("%p").join(f)}function D(A){const k=A&&(A.p!==void 0?A.p:A.params&&A.params.p);return typeof k=="number"&&k>=0&&k<=1?k:void 0}function I(A){const k=A||{},y=k.default==="engine"||k.default==="engine-if-identical"?k.default:"client",f={};if(k.overrides&&typeof k.overrides=="object")for(const[g,a]of Object.entries(k.overrides))(a==="engine"||a==="client")&&(f[g]=a);return{default:y,overrides:f}}function Z(A,k){const y=re[A];if(!y||!y.pushable)return"client";const f=k.overrides[A];return f==="engine"||f==="client"?f:k.default==="client"?"client":k.default==="engine-if-identical"?y.class==="identical"?"engine":"client":"engine"}function z(A,k){const y=I(k),f=[],g=[];for(const a of A||[]){const r=re[a.fn],i=Z(a.fn,y),c={id:a.id,col:a.col,fn:a.fn,class:r?r.class:"fallback"};if(a.weight!==void 0&&(c.weight=a.weight),a.params!==void 0&&(c.params=a.params),r&&r.parametric){const u=D(a);u!==void 0&&(c.p=u)}if(i==="engine"&&r&&r.parametric&&c.p===void 0){g.push({...c,reason:`"${a.fn}" needs \`p\`, a number from 0 to 1`});continue}i==="engine"?f.push(c):(c.reason=r&&!r.pushable?r.note||"the engine cannot express this stat":"client by config",g.push(c))}return{engine:f,client:g,config:y}}const L=/^[A-Za-z_][A-Za-z0-9_$]*$/;function X(A,k=[]){return(A||[]).every(f=>{if(typeof f=="string")return L.test(f);if(!f||typeof f!="object")return!1;const g=f;return Array.isArray(k)&&k.includes(g.bucket)&&typeof g.col=="string"&&L.test(g.col)&&typeof g.size=="number"&&Number.isFinite(g.size)&&g.size>0})}function $(){return Object.entries(re).map(([A,k])=>({stat:A,class:k.class,sql:k.sql?G(k.sql,"col",k.twoColumn?"weight":void 0):"",note:k.note||(k.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),Ue("packages/core/src/source/pushdown.js",function(e,B){"use strict";Object.defineProperty(e,"FOREGROUND_WAIT_MS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"LEAF_COUNT_ID",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PIVOT_UNSUPPORTED",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"GROUP_UNSUPPORTED",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"UNGROUPED_LEVEL",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return J}});const T=B("packages/core/src/internal/compare.js").defaultCompare,D=B("packages/core/src/internal/predicates.js").isFunction,Z=B("packages/core/src/internal/merge.js").toArray,L=B("packages/core/src/internal/warn.js").warnOnce,X=B("packages/core/src/source/filterwire.js"),$=X.isGroup,A=X.warnWherePageRelative,k=X.warnWhereOverThreshold,y=X.wireFilters,f=B("packages/core/src/source/aggregates.js"),g=f.resolveAggregatePlan,a=f.groupKeysPushable,r=f.STAT_PUSHDOWN,i=f.aggregateP,c=f.fillAggregateSql,n=B("packages/core/src/source/abort.js").SupersededError,m=1e3;function t(ee){const ne=ee&&ee.signal;if(!ne||!ne.aborted)return;const se=ne.reason;throw se instanceof Error?se:new n("","superseded before it was sent")}const s=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,pivot:!1,mutate:!1});function h(ee){if(!ee||typeof ee!="object")return!1;const ne=ee.returning==="row"||ee.returning==="key"?ee.returning:"none";return{append:ee.append===!0,update:ee.update===!0,delete:ee.delete===!0,returning:ne}}function d(ee,ne){if(!ee||typeof ne!="string")return;if(!ne.includes("."))return ee[ne];let se=ee;for(const le of ne.split(".")){if(se===null||typeof se!="object")return;se=se[le]}return se}function o(ee){if(ee===!0)return!0;if(!ee||typeof ee!="object")return!1;const ne=ee;return ne.enabled===!1?!1:ne.enabled===!0||D(ne.commit)}function b(ee){const ne={...s,...ee||{}};return ne.operators=new Set(ne.operators||[]),ne.mutate=h(ne.mutate),ne}function l(ee,ne){return!ee||!ee.op||!ne.operators.size?!1:ne.operators.has(ee.op)}function p(ee,ne){if(!ee)return{pushed:null,residual:null};if(!ne.filter)return{pushed:null,residual:ee};if(ne.filter==="term"){if($(ee)){const fe=ee.conditions||[];if(String(ee.op)!=="and")return{pushed:null,residual:ee};const we=fe.findIndex(Ce=>!$(Ce)&&l(Ce,ne));if(we<0)return{pushed:null,residual:ee};const ke=fe.filter((Ce,ce)=>ce!==we);return{pushed:fe[we],residual:ke.length?{op:"and",conditions:ke}:null}}return l(ee,ne)?{pushed:ee,residual:null}:{pushed:null,residual:ee}}if(!$(ee))return l(ee,ne)?{pushed:ee,residual:null}:{pushed:null,residual:ee};if(String(ee.op)!=="and")return(ee.conditions||[]).every(we=>$(we)?p(we,ne).residual===null:l(we,ne))?{pushed:ee,residual:null}:{pushed:null,residual:ee};const se=[],le=[];for(const fe of ee.conditions||[]){if($(fe)){if(ne.filter==="flat"){le.push(fe);continue}const we=p(fe,ne);we.pushed&&se.push(we.pushed),we.residual&&le.push(we.residual);continue}(l(fe,ne)?se:le).push(fe)}const ye=fe=>fe.length===0?null:fe.length===1?fe[0]:{op:"and",conditions:fe};return{pushed:ye(se),residual:ye(le)}}const w="__lattice_leaves";function v(ee){return ee.aggregates?ee.aggregates instanceof Set?ee.aggregates:new Set(Z(ee.aggregates)):new Set}function R(ee){const ne=v(ee);return ne.size?ne.has("count")?ee.filter!=="tree"||!ee.operators||!ee.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 Y(ee,ne,se,le,ye,fe,we){const ke=Array.isArray(ee.groupBy)?ee.groupBy:[],Ce=Array.isArray(ee.groupPath)?ee.groupPath:[],ce=Array.isArray(ee.groupValues)?ee.groupValues:null;if(!ne.group){const ae=R(ne);if(ae)return ae}return a(ke)?se.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":le?ye?fe&&!fe.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":!ce||ce.length!==Ce.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 K="pushdown:pivot-unsupported",V="pushdown:group-unsupported",E=Symbol("lattice.remote.ungroupedLevel");function O(ee,ne,se,le,ye,fe){const we=Array.isArray(ee.pivotBy)?ee.pivotBy:[],ke=Array.isArray(ee.groupBy)?ee.groupBy:[],Ce=Array.isArray(ee.groupPath)?ee.groupPath:[],ce=Array.isArray(ee.groupValues)?ee.groupValues:null;return ne.pivot?a(we)?ke.length&&!a(ke)?"a grouping key is not a plain column the engine can name in a GROUP BY":se.residual?"the filter did not fully push, so the engine would pivot a superset of the matching rows":le?ye?fe&&!fe.conditioned?"a host `where` predicate can only run in the browser, over rows the engine pivoted":!ce||ce.length!==Ce.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 C(ee,ne,se=!1){const le=p(ee.filters||null,ne),ye=[];le.residual&&ye.push("filter");const fe=ee.sort||[],we=fe.length===0||ne.sort==="multi"&&fe.length>=1||ne.sort==="single"&&fe.length===1;!we&&fe.length&&ye.push("sort");const ke=ee.quick?String(ee.quick):"",Ce=!ke||!!ne.quick;Ce||ye.push("quick");const ce=ee.where&&ee.where.active?ee.where:null;ce&&ye.push("where");const ae={filters:le.residual,sort:we?null:fe,quick:Ce?"":ke,where:ce},ge=!!se,de=Array.isArray(ee.groupBy)&&ee.groupBy.length>0,me=de?Y(ee,ne,le,we,Ce,ce,ge):"",ve=ee.pivotMode!==!1&&Array.isArray(ee.pivotBy)&&ee.pivotBy.length>0,xe=ve?O(ee,ne,le,we,Ce,ce):"",Ee=ve&&xe==="";ve&&!Ee&&ye.push("pivot");const Le=ve?Ee&&de:de&&me==="";de&&!ve&&!Le&&ye.push("group");const He=(Le||Ee)&&Array.isArray(ee.groupValues)?ee.groupValues.length:0;ce&&ce.conditioned&&(Le||Ee)&&(ae.where=null,ye.splice(ye.indexOf("where"),1));const Me=Le||ve?!1:ge||!!(ae.filters||ae.sort||ae.quick||ae.where)||!ne.range;return{pushed:{...ee,filters:le.pushed,sort:we?fe:[],quick:Ce?ke:"",range:Me?null:ee.range},residual:ae,needsAll:Me,unpushed:ye,full:ge,grouped:Le,groupLevel:He,groupReason:ve?"":me,pivoted:Ee,pivotReason:xe}}function S(ee){const ne=Array.isArray(ee.totals)?ee.totals:[],se=ee.totalFns&&typeof ee.totalFns=="object"?ee.totalFns:{},le=[],ye=[];for(const fe of ne){const we=String(fe),ke=se[we],Ce=typeof ke=="string"?ke:ke&&typeof ke.fn=="string"?ke.fn:null,ce=ke&&typeof ke=="object"?i(ke):void 0,ae=Ce?r[Ce]:null;ae&&ae.parametric&&ce===void 0?ye.push({id:we,fn:Ce,class:ae.class,reason:`"${Ce}" needs \`p\`, a number from 0 to 1`}):Ce?!ae||!ae.pushable||!ae.sql?ye.push({id:we,fn:Ce,class:ae?ae.class:"fallback",reason:ae&&ae.note?ae.note:`the pushdown map cannot express "${Ce}"`}):ae.twoColumn?ye.push({id:we,fn:Ce,class:ae.class,reason:`"${Ce}" reduces two columns, and a grouped request carries no weight column`}):le.push({id:we,col:we,fn:Ce,class:ae.class,...ce!==void 0?{p:ce}:{}}):ye.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:le,client:ye}}function F(ee){return{...ee,engine:ee.engine.map(ne=>{const se=r[ne.fn];if(!se||!se.sql)return ne;const le=ye=>`"${ye}"`;return{...ne,sql:c(se.sql,le(ne.col),ne.weight!==void 0?le(ne.weight):void 0)}})}}const P=Object.freeze({items:ee=>ee==null?[]:Array.isArray(ee)?ee:[ee]});function M(ee,ne,se){if(!ne)return ee;let le=ee;if(ne.filters&&D(se.evaluateFilters)){const ye=le,fe={count:le.length,handle:Ce=>({id:Ce,get:ce=>d(ye[ce],Ce)}),itemwise:Ce=>ye.some(ce=>Array.isArray(d(ce,Ce)))?P:null},we=se.evaluateFilters(ne.filters,fe),ke=[];for(let Ce=0;Ce<le.length;Ce++)we[Ce]&&ke.push(le[Ce]);le=ke}if(ne.where&&ne.where.active&&(ne.whole||A(ne.where.names,"pushdown"),le=le.filter(ye=>ne.where.passes(ye))),ne.quick){const ye=ne.quick.toLowerCase();le=le.filter(fe=>{if(!fe||typeof fe!="object")return!1;for(const we of Object.values(fe))if(we!=null&&String(we).toLowerCase().includes(ye))return!0;return!1})}if(ne.sort&&ne.sort.length&&D(se.sortMulti)){const ye=[...new Set(ne.sort.map(Ce=>Ce.col))],fe=le,we=ye.map(Ce=>({id:Ce,get:ce=>d(fe[ce],Ce)})),ke=se.sortMulti(we,ne.sort.map(Ce=>({col:Ce.col,dir:Ce.dir})),Uint32Array.from({length:le.length},(Ce,ce)=>ce),{});le=Array.from(ke,Ce=>fe[Ce])}return le}function x(ee){return JSON.stringify({filters:ee.filters||null,sort:ee.sort||[],quick:ee.quick||"",groupBy:ee.groupBy||[],groupPath:ee.groupPath||[],context:ee.context??null})}function U(ee){if(!ee||typeof ee!="object")return 16;let ne="";try{ne=JSON.stringify(ee)}catch{return 200}return ne.length*2+64}function _(ee){const ne=ee||{};return{enabled:!!ne.enabled,maxRows:Number.isFinite(ne.maxRows)?ne.maxRows:1e6,maxBytesEstimate:Number.isFinite(ne.maxBytesEstimate)?ne.maxBytesEstimate:512*1024*1024}}const W=5e4;function q(ee){return Number.isFinite(ee)&&ee>=0?ee:W}function N(ee){return!!ee&&D(ee.then)}async function Q(ee){if(!ee||ee.total!==void 0||!N(ee.pendingTotal))return ee;const ne=await ee.pendingTotal,{pendingTotal:se,...le}=ee;return typeof ne=="number"?{...le,total:ne}:le}function J(ee={}){const ne=ee.adapter;if(!ne||!D(ne.execute))return L("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{...ee,mode:"remote",fetch:async()=>({rows:[],total:0})};const se=b(ne.capabilities),le=ne.capabilities&&Object.getOwnPropertyDescriptor(ne.capabilities,"operators");le&&D(le.get)&&Object.defineProperty(se,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(ne.capabilities.operators||[]),set:()=>{}});const ye=ne.name||"adapter";let fe=null;const we=()=>D(ne.ready)?(fe||(fe=Promise.resolve(ne.ready()).then(()=>{Object.assign(se,b(ne.capabilities))},Ne=>{throw fe=null,Ne})),fe):null,ke=_(ee.fullDataset),Ce=!!ee.allowPartialResults,ce=q(ee.whereRowLimit);let ae=null;const ge=ee.aggregates;let de=null,me=null,ve=null,xe=null,Ee=null,Le=null,He=0,Me=null;const Ke=()=>!ke.enabled||!de?null:(Me!==de.key&&(He++,Me=de.key),{rows:de.rows,version:He}),$e=async Ne=>{const _e=Ne.where&&Ne.where.active?Ne.where:null;if(!_e)return{request:Ne,probe:null};if(_e.conditioned){const Ot=C(Ne,se,ke.enabled);if(Ot.grouped||Ot.pivoted)return{request:Ne,probe:null}}const{where:Ie,...We}=Ne,ze=C(We,se,ke.enabled);if(ze.needsAll)return{request:Ne,probe:null};const Qe=x(ze.pushed);let gt=null;return(!ae||ae.key!==Qe)&&(se.total?(t(Ne),gt=await Q(await ne.execute(ze.pushed,Ne)),ae={key:Qe,size:gt&&typeof gt.total=="number"?gt.total:null}):ae={key:Qe,size:null}),ae.size!==null&&ae.size<ce?{request:Ne,probe:null}:(k(_e.names,ye,ae.size,ce),{request:We,probe:gt})},Oe=async(Ne,_e)=>{Le=null;const Ie=S(Ne.pushed);ve={engine:Ie.engine,client:Ie.client,groupBy:Ne.pushed.groupBy},Ie.client.length&&L(`source.pushdown.group.totals.${ye}.${Ie.client.map(Qe=>Qe.id).join(".")}`,`the ${ye} adapter cannot compute the group subtotal for ${Ie.client.map(Qe=>`"${Qe.id}" (${Qe.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 We=await ne.executeGroupLevel(Ne.pushed,Ie.engine,_e)||{};let ze=We.rows||[];return!se.range&&_e.range&&(ze=ze.slice(_e.range.start,_e.range.end)),Be(We),We.total===void 0?{rows:ze}:{rows:ze,total:We.total}},Se=new Map,Pe=64,Te=async(Ne,_e)=>{Le=null;const Ie=Ne.pushed,We=Ie.groupBy,ze=Array.isArray(Ie.groupValues)?Ie.groupValues:[],Qe=ze.length,gt=[...Ie.filters?[Ie.filters]:[],...We.slice(0,Qe).map((nt,ct)=>({col:nt,op:"eq",value:ze[ct]===void 0?null:ze[ct],caseSensitive:!0}))],Ot=gt.length===0?null:gt.length===1?gt[0]:{op:"and",conditions:gt},bt=_e.range?_e.range.start:0;if(Qe>=We.length){const nt={...Ie,filters:Ot,groupBy:[],groupPath:[],groupValues:[],totals:[],totalFns:{}},ct=await Q(await ne.execute(nt,_e))||{};let $t=ct.rows||[];return!se.range&&_e.range&&($t=$t.slice(_e.range.start,_e.range.end)),typeof ct.total=="number"?{rows:$t,total:ct.total}:{rows:$t}}const ht=We[Qe],Pt=S(Ie),Lt=v(se),jt=Pt.engine.filter(nt=>Lt.has(nt.fn)),Ut=[...Pt.engine.filter(nt=>!Lt.has(nt.fn)).map(nt=>({id:nt.id,fn:nt.fn,class:nt.class,reason:`the ${ye} adapter does not compute "${nt.fn}"`})),...Pt.client];ve={engine:jt,client:Ut,groupBy:We},Ut.length&&L(`source.pushdown.group.totals.${ye}.${Ut.map(nt=>nt.id).join(".")}`,`the ${ye} adapter cannot compute the group subtotal for ${Ut.map(nt=>`"${nt.id}" (${nt.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 rn=[...jt.map(nt=>({id:nt.id,col:nt.col,fn:nt.fn,...nt.p!==void 0?{p:nt.p}:{}})),{id:w,col:ht,fn:"count"}],Wt={...Ie,filters:Ot,range:null},Qt=JSON.stringify([x(Wt),ze,ht,rn]);let Xe=bt>0?Se.get(Qt):void 0;if(!Xe){for(Xe=Promise.resolve(ne.executeGroupedAggregates(Wt,[ht],rn)),Se.delete(Qt),Se.set(Qt,Xe);Se.size>Pe;)Se.delete(Se.keys().next().value);Xe.catch(()=>{Se.get(Qt)===Xe&&Se.delete(Qt)})}const at=await Xe||[];t(_e);const kt=nt=>{const ct={};for(const $t of jt)ct[$t.id]=nt?nt[$t.id]:void 0;return ct},mt=(Ie.sort||[]).find(nt=>nt&&nt.col===ht),wt=mt&&mt.dir==="desc"?-1:1,Ve=at.filter(nt=>nt&&nt.level===1).map(nt=>({[ht]:nt.keys[0]===void 0?null:nt.keys[0],leafCount:Number(nt.values&&nt.values[w])||0,totals:kt(nt.values)})).sort((nt,ct)=>wt*T(nt[ht],ct[ht]));if(Qe===0){const nt=at.find($t=>$t&&$t.level===0),ct=nt?Number(nt.values&&nt.values[w]):NaN;Be({matchCount:Number.isFinite(ct)?ct:Ve.reduce(($t,Ft)=>$t+Ft.leafCount,0),...nt?{grand:kt(nt.values)}:{}})}const lt=_e.range?_e.range.end:Ve.length;return{rows:Ve.slice(bt,lt),total:Ve.length}},Be=Ne=>{typeof Ne.matchCount=="number"&&(xe=Ne.matchCount,Ee=Ne.grand?{totals:Ne.grand,leafCount:Ne.matchCount}:null)},Ge=async(Ne,_e)=>{Le=null;const Ie=S(Ne.pushed);ve={engine:Ie.engine,client:Ie.client,groupBy:Ne.pushed.groupBy,pivotBy:Ne.pushed.pivotBy},Ie.client.length&&L(`source.pushdown.pivot.totals.${ye}.${Ie.client.map(Ot=>Ot.id).join(".")}`,`the ${ye} adapter cannot compute the pivot cells for ${Ie.client.map(Ot=>`"${Ot.id}" (${Ot.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 We=await ne.executePivotLevel(Ne.pushed,Ie.engine,_e)||{};let ze=We.rows||[];!se.range&&_e.range&&(ze=ze.slice(_e.range.start,_e.range.end)),Be(We);const Qe=We.pivot&&typeof We.pivot=="object"?We.pivot:{},gt={cells:Array.isArray(Qe.cells)?Qe.cells:[],...Array.isArray(Qe.axis)?{axis:Qe.axis}:{}};return We.total===void 0?{rows:ze,pivot:gt}:{rows:ze,total:We.total,pivot:gt}},et=Ne=>{L(`source.pushdown.pivot.${ye}.${Ne}`,`pushdown:pivot-unsupported: the ${ye} adapter cannot pivot this query because ${Ne}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);const _e=new Error(`[lattice] ${K}: the ${ye} adapter cannot pivot this query because ${Ne}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);throw _e.code=K,_e.reason=Ne,_e},Je=(Ne,_e)=>{const Ie={key:_e,state:"pending",value:null};return Le=Ie,Ne.then(We=>(Le===Ie&&(Le={key:_e,state:"settled",value:typeof We=="number"?We:null}),We),We=>{throw Le===Ie&&(Le={key:_e,state:"failed",value:null}),We})};let ft=0,Et=[];const Mt=()=>ft===0?null:new Promise(Ne=>{const _e=setTimeout(Ne,m);Et.push(()=>{clearTimeout(_e),Ne()})});let rt;const ot=async Ne=>{const _e=we();_e&&await _e;const We=Ne&&Ne.pivotMode!==!1&&Array.isArray(Ne.pivotBy)&&Ne.pivotBy.length>0?{request:Ne,probe:null}:await $e(Ne);t(Ne);let ze=C(We.request,se,ke.enabled);if(se.group&&ze.grouped&&!ze.pivoted&&!D(ne.executeGroupLevel)&&(L(`source.pushdown.group.method.${ye}`,`the ${ye} 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.`),ze=C(We.request,{...se,group:!1,aggregates:null},ke.enabled)),ze.pivoted&&!D(ne.executePivotLevel)&&(ze=C(We.request,{...se,pivot:!1},ke.enabled),ze.pivotReason="the adapter declares the `pivot` capability but has no `executePivotLevel(query, aggregates, request)`"),ze.grouped&&!ze.pivoted&&!se.group&&!D(ne.executeGroupedAggregates)&&(L(`source.pushdown.group.aggregates.method.${ye}`,`the ${ye} 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\`.`),ze=C(We.request,{...se,aggregates:null},ke.enabled)),me=ze,ze.pivoted)return Ge(ze,Ne);if(ze.pivotReason&&et(ze.pivotReason),ze.grouped)return se.group?Oe(ze,Ne):Te(ze,Ne);const gt=!!ze.groupReason&&!ze.full;gt?L(`source.pushdown.group-unsupported.${ye}.${ze.groupReason}`,`pushdown:group-unsupported: the ${ye} adapter was not asked to group this query because ${ze.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.`):ze.groupReason&&L(`source.pushdown.group.${ye}.${ze.groupReason}`,`the ${ye} adapter was not asked to group this query because ${ze.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 Ot=Wt=>gt?{...Wt,[E]:!0}:Wt;if(!ze.needsAll){const Wt=We.probe||await ne.execute(ze.pushed,Ne),Qt=Wt.rows||[];return N(Wt.pendingTotal)&&Wt.total===void 0?Ot({rows:Qt,pendingTotal:Je(Wt.pendingTotal,x(ze.pushed))}):(Le=null,!se.total&&Wt.total===void 0?Ot({rows:Qt}):Ot({rows:Qt,total:Wt.total??Qt.length}))}const bt=ze.unpushed.filter(Wt=>!(Wt==="where"&&ze.residual.where&&ze.residual.where.anyConditioned));bt.length&&L(`source.pushdown.residual.${ye}.${bt.join(".")}`,`the ${ye} adapter cannot push ${bt.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 ht=x(ze.pushed);if(!de||de.key!==ht){const Wt=await Q(await ne.execute(ze.pushed,Ne));Le=null;const Qt=Wt.rows||[];if(ze.full){const Xe=typeof Wt.total=="number"?Math.max(Wt.total,Qt.length):Qt.length;if(Xe>ke.maxRows)throw new Error(`[lattice] fullDataset refused: the ${ye} adapter's matching set is ${Xe.toLocaleString()} rows, past the configured maxRows of ${ke.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=Qt.length*U(Qt[0]);if(at>ke.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${ye} adapter's matching set is an estimated ${Math.round(at/(1024*1024)).toLocaleString()} MB across ${Qt.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(ke.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 Wt.total=="number"&&Qt.length<Wt.total){const Xe=!!(ze.residual.filters||ze.residual.quick||ze.residual.sort&&ze.residual.sort.length);if(Xe&&!Ce)throw new Error(`[lattice] the ${ye} adapter returned ${Qt.length} of ${Wt.total} matching rows when asked for the whole result, and the query has residual ${ze.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.`);Xe?L(`source.pushdown.partial.residual.${ye}`,`the ${ye} adapter returned ${Qt.length} of ${Wt.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.`):L(`source.pushdown.partial.${ye}`,`the ${ye} adapter returned ${Qt.length} of ${Wt.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}de={key:ht,rows:Qt,total:typeof Wt.total=="number"?Wt.total:null}}let Pt=ze;if(ze.residual.where){const Wt=de.total??de.rows.length;if(Wt>=ce){k(ze.residual.where.names,ye,Wt,ce);const{where:Qt,...Xe}=We.request;Pt=C(Xe,se,ke.enabled),me=Pt}}const Lt=de.total!==null&&de.rows.length>=de.total,jt=M(de.rows,{...Pt.residual,whole:Lt},ee.compute||{}),Ut=Ne.range?Ne.range.start:0,rn=Ne.range?Ne.range.end:jt.length;return Ot({rows:jt.slice(Ut,rn),total:jt.length})},ut=async(Ne,_e,Ie)=>{const ze=Ie&&Ie.waitForPage&&rt&&D(rt.pageForegroundIdle)?rt.pageForegroundIdle():Mt();ze&&await ze;const Qe=we();Qe&&await Qe;const gt=C(Ne,se,ke.enabled);me=gt;const Ot=g(_e,Ie&&Ie.engine?{default:"engine"}:ge),bt=Array.isArray(Ne.groupBy)?Ne.groupBy:[],ht=bt.length>0,Pt=!gt.residual.filters&&!gt.residual.quick,Lt=!ht||a(bt,se.buckets);let jt=Ot.engine,Ut=Ot.client;if(se.aggregates&&jt.length){const at=se.aggregates instanceof Set?se.aggregates:new Set(Z(se.aggregates)),kt=jt.filter(mt=>!at.has(mt.fn));kt.length&&(jt=jt.filter(mt=>at.has(mt.fn)),Ut=[...kt.map(mt=>({...mt,reason:`the ${ye} adapter does not compute "${mt.fn}"`})),...Ut])}const rn=at=>{Ut=[...jt.map(kt=>({...kt,reason:at})),...Ut],jt=[]};let Wt="";if(jt.length&&!Pt){const at=gt.residual.quick&&!gt.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)";rn(at),ht&&(Wt=at)}else if(jt.length&&!Lt){const at="a grouping key the engine cannot form forces all-client (no mixed provenance)";rn(at),Wt=at}let Qt={},Xe;if(jt.length&&(D(ht?ne.executeGroupedAggregates:ne.executeAggregates)?ht?Xe=await ne.executeGroupedAggregates(gt.pushed,bt,jt)||[]:Qt=await ne.executeAggregates(gt.pushed,jt)||{}:(L(`source.pushdown.aggregates.${ye}${ht?".grouped":""}`,`the ${ye} adapter cannot compute ${ht?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),rn(`adapter cannot compute ${ht?"grouped ":""}aggregates`),ht&&(Wt=`the ${ye} adapter cannot compute grouped aggregates`))),ht){const at=Xe!==void 0;at!==gt.grouped&&(me={...gt,grouped:at,groupReason:at?"":Wt||gt.groupReason,unpushed:at?gt.unpushed.filter(kt=>kt!=="group"):gt.unpushed.includes("group")?gt.unpushed:[...gt.unpushed,"group"]})}return ve={engine:jt,client:Ut,...ht?{groupBy:bt}:{}},{values:Qt,engine:jt,client:Ut,...Xe!==void 0?{groups:Xe}:{}}},Tt=async Ne=>{ft++;try{return await ot(Ne)}finally{if(ft--,ft===0&&Et.length){const _e=Et;Et=[];for(const Ie of _e)Ie()}}},xt=o(ee.edit),It=ee.edit&&typeof ee.edit=="object"&&D(ee.edit.commit);let dt=ee.edit;if(xt&&!It)if(se.mutate&&se.mutate.update){const Ne=_e=>{if(!se.mutate||!se.mutate.update)throw new Error(`[lattice] the ${ye} 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 Ie={kind:"update",key:String(_e.key),patch:{[_e.colId]:_e.value}};return ne.mutate(Ie,_e.request||{})};dt={...ee.edit===!0?{}:ee.edit,commit:Ne}}else L(`source.pushdown.readonly.${ye}`,`edit is enabled but the ${ye} adapter declares mutate: ${se.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 ie=xt&&se.mutate&&(se.mutate.append||se.mutate.delete)?{append:se.mutate.append===!0,remove:se.mutate.delete===!0,returning:se.mutate.returning,mutate:(Ne,_e)=>ne.mutate(Ne,_e||{})}:null,pe=async Ne=>{const _e=we();_e&&await _e;const{range:Ie,signal:We,export:ze,...Qe}=Ne||{},gt={...Qe,groupBy:[],groupPath:[],groupValues:[],pivotBy:[],pivotMode:!1,totals:[]};return{plan:C(gt,se,ke.enabled),signal:We}};async function*be(Ne,_e={}){const{plan:Ie,signal:We}=await pe(Ne),ze=Math.max(1,Math.floor(Number(_e.pageSize))||5e3),Qe={signal:We,stream:!0},gt=Ne&&Ne.range&&Number.isFinite(Number(Ne.range.start))&&Number.isFinite(Number(Ne.range.end))?{start:Math.max(0,Number(Ne.range.start)),end:Math.max(0,Number(Ne.range.end))}:null;if(!Ie.needsAll){const ht=gt?gt.start:0,Pt=gt?gt.end:1/0;for(let Lt=ht;Lt<Pt;Lt+=ze){t(Qe);const jt=Math.min(Lt+ze,Pt),Ut=await ne.execute({...Ie.pushed,range:{start:Lt,end:jt}},Qe);Ut&&N(Ut.pendingTotal)&&Ut.pendingTotal.then(null,()=>{});const rn=Ut&&Ut.rows||[];if(rn.length&&(yield rn),rn.length<jt-Lt)return}return}t(Qe);const Ot=await Q(await ne.execute({...Ie.pushed,range:void 0},Qe));let bt=M(Ot&&Ot.rows||[],{...Ie.residual,whole:!0},ee.compute||{});gt&&(bt=bt.slice(gt.start,gt.end));for(let ht=0;ht<bt.length;ht+=ze)yield bt.slice(ht,ht+ze)}const Ae=async Ne=>{const{plan:_e,signal:Ie}=await pe(Ne);if(!_e.needsAll&&se.total){t({signal:Ie});const ze=await Q(await ne.execute({..._e.pushed,range:{start:0,end:0}},{signal:Ie}));if(ze&&typeof ze.total=="number")return ze.total}let We=0;for await(const ze of be({...Ne,range:void 0}))We+=ze.length;return We},je=async Ne=>{await we();const _e=y(Ne.filters||null,{tz:ee.timeZone,weekStartsOn:ee.weekStartsOn}),Ie=Ne.quick?String(Ne.quick):"";return p(_e,se).residual||Ie&&!se.quick?null:ne.facets({...Ne,filters:_e,quick:Ie})};return rt={...ee,edit:dt,rowMutate:ie,mode:"remote",fetch:Tt,foregroundIdle:Mt,facetProvider:D(ne.facets)?je:void 0,aggregate:ut,countMatching:Ae,streamMatching:be,capabilitiesOf:b,planQuery:C,wireFilters:y,resolveAggregatePlan:(Ne,_e)=>g(Ne,_e&&_e.engine?{default:"engine"}:ge),STAT_PUSHDOWN:r,lastPlan:()=>me?{...me,...ve?{aggregates:F(ve)}:{},...Le?{total:{deferred:!0,state:Le.state,value:Le.value}}:{}}:null,fullFrame:Ke,counts:()=>({match:xe,total:xe,pending:!!Le&&Le.state==="pending"}),grandTotals:()=>Ee},rt}}),Ue("packages/core/src/source/remote.js",function(e,B){"use strict";Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return F}});const T=B("packages/core/src/internal/lru.js").Lru,D=B("packages/core/src/internal/predicates.js").isFunction,Z=B("packages/core/src/internal/warn.js").warnOnce,L=B("packages/core/src/internal/schedule.js").settleDebounce,X=B("packages/core/src/source/abort.js"),$=X.createAbortScope,A=X.isAbortError,k=B("packages/core/src/source/blockcache.js"),y=k.BlockCache,f=k.DEFAULT_PAGE_SIZE,g=k.DEFAULT_MAX_CACHED_PAGES,a=B("packages/core/src/source/rows.js"),r=a.createRowFactory,i=a.groupKey,c=B("packages/core/src/source/filterwire.js"),u=c.wireFilters,n=c.querySignature,m=c.warnHostFilterNotApplied,s=B("packages/core/src/source/pagewindow.js").pageWindow,d=B("packages/core/src/source/memory.js").MemorySource,b=B("packages/core/src/compute/handle.js").valueComparator,l=B("packages/core/src/compute/pivot.js"),p=l.pivotKey,w=l.joinPath,v=l.DEFAULT_PATH_SEPARATOR,Y=B("packages/core/src/source/pushdown.js").UNGROUPED_LEVEL,K=1,V=120,E=1e3;function O(P,M,x){for(let U=0;U<Math.max(P.length,M.length);U++){const _=P[U],W=M[U],q=_==null,N=W==null;if(q||N){if(q&&N)continue;return q?1:-1}const Q=x(_,W);if(Q!==0)return Q}return 0}function C(P,M){return new F(P,M)}class S{constructor(M,x,U,_){this.path=M,this.keyPath=_||M,this.values=[],this.level=x,this.key=i(this.keyPath),this.cache=new y(U),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 F{mode="remote";#e;#t;#n;#r;#i=new Map;#s=new Set;#a=$();#l;#o;#c=new Map;#u=[];#f=null;#d="";#h;#p=!1;#m=!1;#g=[];#b=!1;#y=0;#O="";#w=null;#A=-1;constructor(M,x){this.#e=M||{mode:"remote"},this.#t=x||{},D(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#I(),this.unfilteredIndices=()=>this.#G(),this.handleFor=Q=>this.#K(Q),this.display=()=>this.#L(),this.grandTotalRow=()=>this.#U(),this.unfilteredRows=()=>this.#D(),this.facetIndices=Q=>this.#q(Q));const U=this.#e.counts;D(U)&&(this.matchCount=()=>this.#Y("match"),this.totalCount=()=>this.#Y("total"));const _=this.#e.grandTotals;D(_)&&(this.grandTotalRow=()=>this.#z());const W=this.#e.foregroundIdle;D(W)&&(this.foregroundIdle=()=>this.#oe(W),this.#e.pageForegroundIdle=()=>this.#b?this.#oe(W):null);const q=this.#e.facetProvider;D(q)&&(this.facetProvider=q);const N=this.#e;D(N.countMatching)&&D(N.streamMatching)&&(this.selectionQuery=()=>this.#V(),this.countMatching=Q=>N.countMatching(Q),this.streamMatching=(Q,J)=>N.streamMatching(Q,J),this.loadedRows=()=>this.#ge(),this.resident=()=>this.#N()!==null),this.#n={pageSize:this.#e.pageSize||f,maxCachedPages:this.#e.maxCachedPages||g},this.#l=r(this.#t),this.#o=new T(this.#n.pageSize*4),this.#h=L((Q,J)=>this.#T(Q,J),V),this.#r=new S([],0,this.#n),this.#i.set(this.#r.key,this.#r),this.#d=this.#be(),D(this.#e.fetch)||Z("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#de()}count(){const M=this.#S();return M?M.length:this.#v()}#v(){const M=this.#N();return M?M.count():(this.#re(),this.#Ae(this.#r))}#P(){if(this.#N())return!0;const M=x=>{if(x.count===null&&!x.complete)return!1;for(const U of x.children.values())if(this.#Te(U.key,this.#we(U))&&!M(U))return!1;return!0};return M(this.#r)}pageInfo(){const M=this.#S(),x=this.totalPending();if(!M){const U=this.#v();return{page:0,pageSize:0,total:this.#P()?U:null,pageCount:1,counting:x}}return{page:M.page,pageSize:M.pageSize,total:M.total,pageCount:M.pageCount,counting:x||M.total===null&&this.#a.size>0&&this.#r.cache.loadedExtent()===0}}#S(){const M=this.#v(),x=s(this.#$("pageSize",0),this.#$("page",0),M,this.#P());if(!x)return this.#O="",null;const U=`${this.#y}:${x.offset}:${x.length}`;return U!==this.#O&&!this.#p&&(this.#O=U,x.length>0&&!this.#N()&&this.#T(x.offset,x.offset+x.length-1)),x}at(M){const x=this.#S();if(x){if(M<0||M>=x.length)return;const U=this.#C(x.offset+M);return U&&(U.index=M),U}return this.#C(M)}#C(M){const x=this.#N();if(x)return x.at(M);if(this.#re(),M<0||M>=this.#v())return;const U=this.#Z(this.#r,M);if(!U)return;const _=this.#W(U.node,U.local);return _&&(_.index=M),_||this.#l.skeleton(M,U.node.level,U.node.cache.erroredAt(U.local))}byKey(M){const x=this.#N();if(x)return x.byKey(M);const U=this.#c.get(M);if(!U)return;const _=U.lastIndexOf(":"),W=this.#i.get(U.slice(0,_));return W&&this.#W(W,Number(U.slice(_+1)))||void 0}loaded(M){const x=this.#S();if(x){if(M<0||M>=x.length)return!1;M+=x.offset}const U=this.#N();if(U)return U.loaded(M);if(M<0||M>=this.#v())return!1;const _=this.#Z(this.#r,M);return!!_&&_.node.cache.rowLoaded(_.local)}hint(M,x){if(this.#p)return;this.#b=!0;const U=this.#re();let _=Math.max(0,Math.floor(M)),W=Math.max(_,Math.floor(x));const q=this.#S();if(q){if(q.length===0)return;_=q.offset,W=q.offset+q.length-1}for(const[N,Q]of this.#E(_,W)){N.cache.protect(Q.min,Q.max);for(const J of N.cache.evict())this.#Ee(N,J)}this.#h(_,W),U&&this.#h.flush()}#E(M,x){const U=this.#v(),_=new Map;for(let W=M;W<=x&&W<U;W++){const q=this.#Z(this.#r,W);if(!q)continue;const N=_.get(q.node);N?(N.min=Math.min(N.min,q.local),N.max=Math.max(N.max,q.local)):_.set(q.node,{min:q.local,max:q.local})}return _.size||_.set(this.#r,{min:M,max:M}),_}#T(M,x){if(!this.#p)for(const[U,_]of this.#E(M,x)){U.cache.protect(_.min,_.max);const W=U.cache.blockOf(_.min),q=U.cache.blockOf(_.max);for(let N=W;N<=q&&!(U.count!==null&&N*U.cache.pageSize>=U.count);N++)U.cache.has(N)||this.#ue(U,N)}}apply(M){const x={added:[],updated:[],removed:[]};if(!M)return x;if(M.update)for(const U of M.update){const _=this.#c.get(this.#l.keyOf(U,-1));if(!_)continue;this.#o.delete(_);const W=_.lastIndexOf(":"),q=this.#i.get(_.slice(0,W));if(!q)continue;const N=Number(_.slice(W+1)),Q=q.cache.blockOf(N);if(!q.cache.loaded(Q))continue;const{start:J}=q.cache.rangeOf(Q),ee=[];for(let se=J;se<J+q.cache.pageSize;se++){const le=q.cache.rowAt(se);if(le===void 0)break;ee.push(se===N?U:le)}q.cache.fill(Q,ee);const ne=this.#W(q,N);ne&&x.updated.push(ne)}return(M.add&&M.add.length||M.remove&&M.remove.length)&&this.reload({keepExpanded:!0}),x}reload(M){this.#a.abortAll("reload"),this.#h.cancel(),M&&M.keepExpanded===!1&&this.#s.clear(),this.#pe(),this.#H("model:changed",{reason:"reload"})}destroy(){this.#p=!0,this.#h.cancel(),this.#a.abortAll("destroyed"),this.#pe(),this.#i.clear(),this.#s.clear(),this.#w&&D(this.#w.destroy)&&this.#w.destroy(),this.#w=null}expand(M){this.#s.has(M)||(this.#s.add(M),this.#H("group:toggled",{key:M,expanded:!0}),this.#H("model:changed",{reason:"expand",key:M}))}collapse(M){this.#s.delete(M)&&(this.#H("group:toggled",{key:M,expanded:!1}),this.#H("model:changed",{reason:"collapse",key:M}))}expandedKeys(){return[...this.#s]}pivotFields(){return this.#u}pivot(){this.#re();const M=this.#f;if(!M||!M.keys.size||!this.#$("pivotBy",[]).length)return null;if(!M.result){const x=b((this.#t.config||{}).locale),U=[...M.keys.entries()].sort((W,q)=>O(W[1],q[1],x)),_=U.map(([W])=>W);M.result={keys:U.map(([,W])=>W),paths:_,fields:this.#Ce(_),groupPaths:[],columns:_.length*Math.max(1,this.#ve().length),values:M.cells,cells:M.cells,error:null}}return M.result}invalidateHandles(){this.#w&&(D(this.#w.invalidateHandles)&&this.#w.invalidateHandles(),D(this.#w.invalidate)&&this.#w.invalidate("filter"))}#M(){const M=this.#e.fullFrame;return D(M)?M():null}#N(){const M=this.#M();return M?(this.#w||(this.#w=new d({mode:"memory"},this.#R())),M.version!==this.#A&&(this.#w.setRows(M.rows),this.#A=M.version),this.#w):null}#R(){const M=this.#t,x=M.state||{};return{...M,state:{...x,page:()=>0,pageSize:()=>0}}}#I(){const M=this.#N();return M?M.filteredIndices():new Uint32Array(0)}#G(){const M=this.#N();return M?M.unfilteredIndices():new Uint32Array(0)}#K(M){const x=this.#N();return x?x.handleFor(M):void 0}#L(){const M=this.#N();return M?M.display():[]}#q(M){const x=this.#N();return x&&D(x.facetIndices)?x.facetIndices(M):new Uint32Array(0)}#U(){const M=this.#N();return M&&D(M.grandTotalRow)?M.grandTotalRow():null}#Y(M){const x=this.#N();if(x){const q=M==="match"?x.matchCount:x.totalCount;if(D(q))return q.call(x)}const U=this.#e.counts,_=D(U)?U():null,W=_?_[M]:null;return typeof W=="number"?W:this.#v()}#z(){const M=this.#N();if(M&&D(M.grandTotalRow))return M.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const U=this.#e.grandTotals,_=D(U)?U():null;return!_||!_.totals?null:this.#l.grandTotal(_.totals,_.leafCount||0)}#D(){const M=this.#N();if(M&&D(M.unfilteredRows))return M.unfilteredRows();const x=[],U=this.count();for(let _=0;_<U;_++){const W=this.at(_);W&&x.push(W)}return x}#V(){const M=this.#$("quick",""),x={protocol:K,groupPath:[],groupValues:[],groupBy:[],totals:[],totalFns:{},pivotBy:[],pivotMode:!1,filters:u(this.#$("filters",null),this.#J()),sort:this.#$("sort",[]),context:this.#$("context",null)};M&&(x.quick=M);const U=this.#$("where",null);return U&&U.active&&(x.where=U),x}#ge(){const M=this.#$("groupBy",[]).length,x=[];for(const U of this.#i.values())if(!(U.level!==M&&!U.flat))for(const _ of U.cache.ids()){if(!U.cache.loaded(_))continue;const{start:W,end:q}=U.cache.rangeOf(_);for(let N=W;N<q&&U.cache.rowLoaded(N);N++){const Q=this.#W(U,N);Q&&!Q.group&&x.push(Q)}}return x}loadedCount(){const M=this.#N();if(M){const _=M.matchCount();return typeof _=="number"?_:M.count()}this.#re();const x=this.#$("groupBy",[]).length;let U=0;for(const _ of this.#i.values())if(!(_.level!==x&&!_.flat))for(const W of _.cache.ids()){if(!_.cache.loaded(W))continue;const q=_.cache.fillOf(W);typeof q=="number"&&(U+=q)}return U}residentRows(){const M=this.#N();return M?M.display():this.#$("groupBy",[]).length>0?null:(this.#re(),this.#ge())}#se(M,x,U){const{start:_,end:W}=M.cache.rangeOf(x),q=this.#$("groupBy",[]),N=this.#$("pivotBy",[]),Q=this.#$("quick",""),J=this.#ve(),ee={protocol:K,range:{start:_,end:W},groupPath:M.path,groupValues:M.values,groupBy:q,totals:J,totalFns:this.#Se(J),pivotBy:N,pivotMode:N.length>0,filters:u(this.#$("filters",null),this.#J()),sort:this.#$("sort",[]),context:this.#$("context",null),signal:U};Q&&(ee.quick=Q);const ne=this.#$("where",null);return ne&&ne.active&&(ee.where=ne),ee}async#ue(M,x){if(!D(this.#e.fetch))return;if(!this.#m){this.#m=!0;const q=this.#g;this.#g=[],queueMicrotask(()=>{for(const N of q)N()})}const U=this.#a.begin(`${M.key}:${x}`);M.cache.begin(x,U);const _=this.#d,{start:W}=M.cache.rangeOf(x);try{const q=await this.#e.fetch(this.#se(M,x,U.signal));if(!U.current||_!==this.#d||this.#p)return;U.settle();const N=q&&q.rows||[];if(!!(q&&q[Y])&&!M.flat){M.flat=!0,M.children.clear();for(const[ne,se]of[...this.#c])se.startsWith(`${M.key}:`)&&(this.#o.delete(se),this.#c.delete(ne))}M.cache.fill(x,N),M.failed=!1;for(let ne=0;ne<N.length;ne++)this.#o.delete(`${M.key}:${W+ne}`);const J=q&&typeof q.count=="number"?q.count:q&&typeof q.total=="number"?q.total:null,ee=q&&D(q.pendingTotal?.then)?q.pendingTotal:null;J!==null?(M.count=J,M.complete=!0):N.length<M.cache.pageSize?(M.count=W+N.length,M.complete=!0):ee&&(M.counting=!0,M.announced=null),q&&Array.isArray(q.pivotFields)&&this.#He(q.pivotFields),q&&q.pivot&&typeof q.pivot=="object"&&this.#ae(q.pivot),this.#H("model:changed",{reason:"page",groupPath:M.path,block:x}),this.#H("rows:changed",{companion:!0,reason:"page",groupPath:M.path,block:x}),this.#fe(M),ee&&this.#Me(M,ee,_)}catch(q){if(U.settle(),A(q))return;M.cache.failed(x,q),M.failed=!0;const{end:N}=M.cache.rangeOf(x);for(let Q=W;Q<N;Q++)this.#o.delete(`${M.key}:${Q}`);this.#H("model:changed",{reason:"page-error",groupPath:M.path,block:x}),this.#H("source:error",{error:q,groupPath:M.path,block:x})}}async#Me(M,x,U){let _;try{_=await x}catch(W){if(U!==this.#d||this.#p)return;M.counting=!1,A(W)||(M.failed=!0),A(W)||this.#H("source:error",{error:W,groupPath:M.path});return}U!==this.#d||this.#p||(M.counting=!1,typeof _=="number"&&(M.count=_,M.complete=!0,this.#fe(M),this.#H("model:changed",{reason:"total",count:_,groupPath:M.path})))}#fe(M){typeof M.count!="number"||!M.complete||M.announced!==M.count&&(M.announced=M.count,this.#H("source:total",{total:M.count,groupPath:M.path}))}#oe(M){if(this.#p)return null;this.#re();const x=this.#m?null:new Promise(N=>{this.#g.push(N),setTimeout(N,E)}),U=M();if(!x&&!U)return null;const _=(async()=>{x&&await x;for(let N=M();N;N=M())await N})();let W;const q=new Promise(N=>{W=setTimeout(N,E)});return Promise.race([_,q]).then(()=>clearTimeout(W))}totalPending(){if(this.#r.failed)return!1;if(this.#r.counting===!0)return!0;if(this.#N())return!1;this.#re();const M=this.#r;return M.count===null&&!M.complete&&M.cache.loadedExtent()===0}totalFailed(){return this.#r.failed===!0}#He(M){M.length===this.#u.length&&M.every((x,U)=>x===this.#u[U])||(this.#u=M,this.#H("column:pivoted",{pivotFields:M,remote:!0}))}#xe(){const M=this.#t.config||{};return M.pivot&&M.pivot.separator||v}#Ce(M){const x=this.#xe(),U=this.#ve();if(!U.length)return M.slice();const _=[];for(const W of M)for(const q of U)_.push(`${W}${x}${q}`);return _}#ae(M){const x=this.#xe();this.#f||(this.#f={keys:new Map,cells:new Map,result:null});const U=this.#f;let _=!1;const W=N=>{const Q=Array.isArray(N)?N:[N],J=w(Q,x);return U.keys.has(J)||(U.keys.set(J,Q),_=!0),J},q=this.#$("groupBy",[]).length>0;for(const N of Array.isArray(M.axis)?M.axis:[])W(N);for(const N of Array.isArray(M.cells)?M.cells:[]){if(!N||typeof N!="object")continue;const Q=W(N.pivot);if(q&&!(Array.isArray(N.group)&&N.group.length))continue;const J=w(Array.isArray(N.group)?N.group:[],x);for(const[ee,ne]of Object.entries(N.values||{}))U.cells.set(p(J,Q,ee),ne)}U.result=null,_&&this.#He((this.pivot()||{fields:[]}).fields)}#Ae(M){let x=this.#le(M);for(const U of M.children.values())this.#Te(U.key,this.#we(U))&&(x+=this.#Ae(U));return x}#le(M){if(M.count!==null)return M.count;const x=M.cache.loadedExtent();return M.complete?x:M.row&&M.row.leafCount>0?M.level>=this.#$("groupBy",[]).length?Math.max(x,M.row.leafCount):x===0?1:Math.min(x+M.cache.pageSize,Math.max(x,M.row.leafCount)):x+M.cache.pageSize}#Z(M,x){let U=x,_=0;const W=[...M.children.entries()].filter(([,N])=>this.#Te(N.key,this.#we(N))).sort((N,Q)=>N[0]-Q[0]);for(const[N,Q]of W){const J=N-_+1;if(U<J)return{node:M,local:_+U};U-=J,_=N+1;const ee=this.#Ae(Q);if(U<ee)return this.#Z(Q,U);U-=ee}const q=this.#le(M);return _+U<q?{node:M,local:_+U}:null}#W(M,x){const U=`${M.key}:${x}`,_=this.#o.get(U);if(_)return _.group===!0?this.#B(_):_;const W=M.cache.rowAt(x);if(W===void 0)return null;const q=this.#$("groupBy",[]);let N;if(M.level<q.length&&!M.flat){const Q=q[M.level],J=this.#f!==null&&M.level===q.length-1&&this.#$("pivotBy",[]).length>0,ee=this.#ye(W,Q),ne=ee==null,se=[...M.path,ne?"":String(ee)],le=[...M.keyPath,ne?null:String(ee)];if(N=this.#l.group({path:se,keyPath:le,column:Q,value:ee,level:M.level,parent:M.row,leafCount:Number(W.leafCount)||0,expanded:J?!1:this.#Te(i(le),{key:i(le),column:Q,value:ee,level:M.level,path:se}),...J?{hasChildren:!1}:{}}),N.totals=this.#ne(W),N.data=W,!J){let ye=this.#i.get(N.key);ye?ye.row=N:(ye=new S(se,M.level+1,this.#n,le),ye.row=N,this.#i.set(ye.key,ye)),ye.values=[...M.values,ee],M.children.set(x,ye)}}else N=this.#l.leaf(W,x,M.level,M.row);return this.#o.set(U,N),this.#c.set(N.key,U),N}#ne(M){const x=M||{};if(x.totals&&typeof x.totals=="object")return x.totals;const U={};for(const _ of this.#ve())Object.hasOwn(x,_)&&(U[_]=x[_]);return U}#B(M){const x=this.#i.get(M.key);if(!x||x.row!==M||M.hasChildren===!1)return M;const U=this.#Te(M.key,this.#we(x));return M.expanded!==U&&(M.expanded=U),M}#Ee(M,x){const{start:U,end:_}=M.cache.rangeOf(x);for(let W=U;W<_;W++){const q=`${M.key}:${W}`,N=this.#o.peek(q);N&&this.#c.delete(N.key),this.#o.delete(q)}}#re(){const M=this.#be();return M===this.#d?!1:(this.#d=M,this.#a.abortAll("query"),this.#pe(),this.#m=!1,this.#H("model:changed",{reason:"query"}),!0)}#pe(){for(const M of this.#i.values())M.cache.clear(),M.count=null,M.complete=!1,M.announced=null,M.counting=!1,M.failed=!1,M.children.clear(),M.flat=!1;this.#o.clear(),this.#c.clear(),this.#y++,this.#f=null}#be(){const M=this.#$("where",null);return`${n({filters:this.#$("filters",null),sort:this.#$("sort",[]),quick:this.#$("quick",""),groupBy:this.#$("groupBy",[]),pivotBy:this.#$("pivotBy",[]),context:this.#$("context",null)})}|${M?M.version:0}`}#Te(M,x){const U=this.#$("expanded",null);return U?D(U.has)?U.has(M,x):Array.prototype.includes.call(U,M):this.#s.has(M)}#we(M){if(M.row)return{key:M.key,column:M.row.column,value:M.row.value,level:M.level-1,path:M.path}}#ve(){const M=this.#$("totals",[]);if(M&&M.length)return[...M];const x=this.#t.columns;return!x||!D(x.all)?[]:x.all().filter(U=>!!U.total).map(U=>U.id)}#Se(M){const x=this.#t.columns,U={};if(!x||!D(x.get))return U;for(const _ of M){const W=x.get(_);if(!W)continue;const q=W.groupTotal!=null?W.groupTotal:W.total;typeof q=="string"?U[_]=q:q&&typeof q=="object"&&typeof q.fn=="string"&&(U[_]={...q})}return U}#ye(M,x){const U=this.#t.columns,_=U&&D(U.get)?U.get(x):void 0;return _&&D(_.getValue)?_.getValue(M):M?.[x]}#de(){m(this.#t)}#J(){const M=this.#t.config||{};return{tz:M.timeZone,weekStartsOn:M.weekStartsOn}}#$(M,x){const U=this.#t.state;if(U&&D(U[M])){const _=U[M]();return _??x}return x}#H(M,x){const U=this.#t.emit;D(U)&&U(M,x)}}}),Ue("packages/core/src/source/gapbuffer.js",function(e,B){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return T}});const re=64;class T{#e;#t=0;#n=0;constructor(D=re){this.#e=new Uint32Array(Math.max(1,D)),this.#n=this.#e.length}static from(D,I=re){const Z=new T(D.length+Math.max(1,I));return Z.#e.set(D,0),Z.#t=D.length,Z.#n=Z.#e.length,Z}get length(){return this.#t+(this.#e.length-this.#n)}get capacity(){return this.#e.length}at(D){return D<0||D>=this.length?0:D<this.#t?this.#e[D]:this.#e[D+(this.#n-this.#t)]}insert(D,I){const Z=D<0?0:D>this.length?this.length:D;this.#r(Z),this.#t===this.#n&&this.#i(),this.#e[this.#t++]=I}push(D){this.insert(this.length,D)}removeAt(D){return!Number.isInteger(D)||D<0||D>=this.length?!1:(this.#r(D),this.#n++,!0)}toArray(){const D=new Uint32Array(this.length);return D.set(this.#e.subarray(0,this.#t),0),D.set(this.#e.subarray(this.#n),this.#t),D}clear(){this.#t=0,this.#n=this.#e.length}#r(D){if(D!==this.#t)if(D<this.#t){const I=this.#t-D;this.#e.copyWithin(this.#n-I,D,this.#t),this.#t=D,this.#n-=I}else{const I=D-this.#t;this.#e.copyWithin(this.#t,this.#n,this.#n+I),this.#t=D,this.#n+=I}}#i(){const D=this.#e.length-this.#n,I=new Uint32Array(Math.max(this.#e.length*2,this.#e.length+re));I.set(this.#e.subarray(0,this.#t),0),I.set(this.#e.subarray(this.#n),I.length-D),this.#e=I,this.#n=I.length-D}}}),Ue("packages/core/src/store/ingest.js",function(e,B){"use strict";Object.defineProperty(e,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"inferKind",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"decideText",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"createReaders",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"Ingest",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return u}});const re=B("packages/core/src/internal/schedule.js"),T=re.now,G=re.nextFrame,D=B("packages/core/src/internal/warn.js"),I=D.infoOnce,Z=D.warnOnce,L=B("packages/core/src/internal/predicates.js").isFunction,$=B("packages/core/src/internal/paths.js").pathGetter,k=B("packages/core/src/store/columnstore.js").ColumnStore,y=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function f(n,m={}){if(m.multi)return"multi";if(n.length===0)return"object";let t=0,s=0,h=0,d=0,o=0;for(let l=0;l<n.length;l++){const p=n[l];typeof p=="number"?t++:typeof p=="boolean"?s++:typeof p=="string"?h++:p instanceof Date?d++:Array.isArray(p)&&o++}const b=n.length;return t===b?"float64":s===b?"bitset":d===b?"float64":h===b?"text":o===b?"multi":"object"}function g(n,m,t){return m<=0||n<t*m?"dictionary":"object"}function a(n,m,t){const s=new Map,h=new Map;for(const K of n){if(K.computed)continue;const V=L(K.read)?K.read:$(K.field||K.id);h.set(K.id,V),s.set(K.id,V)}const d=m?.order??[],o=m?.fns??{},b=m?.deps??{},l=m?.wrapDeps??null,p=d.filter(K=>L(o[K])),w=p.some(K=>b[K]==="*");let v=new WeakMap;const R=K=>{const V={};if(w)for(const[E,O]of h)V[E]=O(K);for(const E of p){const O=b[E];let C;if(O==="*")C=V;else{C={};const S=O||[];for(let F=0;F<S.length;F++){const P=S[F];C[P]=P in V?V[P]:h.get(P)?.(K)}}V[E]=o[E](l?l(C,E):C,{data:K,row:null,column:null,grid:null,context:t})}return V},Y=K=>{if(K===null||typeof K!="object"&&typeof K!="function")return R(K);let V=v.get(K);return V===void 0&&(V=R(K),v.set(K,V)),V};for(const K of p)s.set(K,V=>Y(V)[K]);return{readers:s,reset(){v=new WeakMap}}}class r{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(m,t){this.spec=m,this.read=t,this.kind="object",this.inferred=!1,this.nullable=m.nullable!==!1}}class i{#e;#t=[];#n=null;#r;#i=0;#s;#a=!1;#l=!1;#o=0;#c;constructor(m,t={},s={}){this.#e=Array.isArray(m)?m:Array.from(m||[]),this.#s={...y,...s};const h=t.columns??[];this.#r=a(h,t.computed??null,t.context),this.#c=this.#e.length>=this.#s.columnarBelow,this.#u(h,t.computed??null),this.#n=new k(this.#t.map(d=>({id:d.spec.id,kind:d.kind,nullable:d.nullable,read:d.read,dictionary:d.spec.dictionary})),{initialCapacity:this.#s.initialCapacity,columnarBelow:this.#s.columnarBelow})}get store(){return this.#n}get done(){return this.#a||this.#l}get progress(){return this.#i}slice(){if(this.done)return!1;if(this.#s.signal?.aborted)return this.#l=!0,!1;const m=T(),{chunkMs:t,chunkRows:s}=this.#s,h=this.#e.length;do{const d=Math.min(this.#i+s,h);this.#n.append(this.#e.slice(this.#i,d)),this.#f(this.#i,d),this.#i=d,this.#r.reset(),this.#h(!1)}while(this.#i<h&&T()-m<t);return this.#o+=T()-m,this.#s.onProgress?.({loaded:this.#i,total:h}),this.#i>=h?(this.#h(!0),this.#a=!0,!1):!0}cancel(){this.#l=!0}result(){return{store:this.#n,schema:this.#t.map(m=>({id:m.spec.id,kind:m.kind,nullable:m.nullable,read:m.read,dictionary:m.spec.dictionary})),decisions:this.#t.map(m=>({id:m.spec.id,kind:m.kind,nullable:m.nullable,inferred:m.inferred,distinct:m.candidate||m.change?this.#d(m):null,change:m.change,reason:m.reason})),count:this.#n.count,elapsed:this.#o,cancelled:this.#l}}#u(m,t){const s=this.#e,h=Math.min(this.#s.sampleSize,s.length),d=this.#s.dictionaryRatio,o=t?.pure instanceof Set?t.pure:new Set(t?.pure??t?.order??[]);for(const b of m){if(!b||!b.id)continue;if(b.computed&&(b.pure===!1||t&&!o.has(b.id))){Z(`ingest.impure.${b.id}`,`column "${b.id}" is an impure computed column and is not materialised into the store`);continue}const l=this.#r.readers.get(b.id)??(L(b.read)?b.read:$(b.field||b.id)),p=new r(b,l);if(b.kind)p.kind=b.kind,p.reason="declared by the caller";else if(b.dictionary)p.kind=b.multi?"multi":"dictionary",p.reason="value table supplied (lookup column)";else{const w=[];for(let R=0;R<h&&w.length<this.#s.sampleSize;R++){const Y=l(s[R]);Y!=null&&w.push(Y)}p.inferred=!0;const v=f(w,{multi:b.multi});if(v==="text"){const R=new Set(w).size;p.kind=g(R,w.length,d),p.candidate=this.#c,p.reason=`sampled ${R} distinct in ${w.length}`}else p.kind=v,p.reason=`inferred from ${w.length} sampled values`,v==="object"&&w.length&&I(`ingest.mixed.${b.id}`,`column "${b.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);p.kind==="object"&&p.candidate&&(p.distinct=new Set(w))}this.#t.push(p)}}#f(m,t){const s=this.#e;for(const h of this.#t){if(!h.candidate||!h.distinct)continue;const d=h.distinct;for(let o=m;o<t;o++){const b=h.read(s[o]);b!=null&&d.add(b)}}}#d(m){if(m.distinct)return m.distinct.size;const t=this.#n.column(m.spec.id);return t?.dict?t.dict.size:0}#h(m){const t=this.#s.dictionaryRatio,s=this.#e.length;for(const h of this.#t){if(!h.candidate)continue;const d=this.#d(h);if(h.kind==="dictionary"&&d>=t*s){const o=this.#n.column(h.spec.id);h.distinct=new Set(o?.dict?o.dict.values():[]),this.#n.convert(h.spec.id,"object"),h.kind="object",h.change="demoted",h.reason=`${d} distinct values is at or above ${t*100}% of ${s} rows`;continue}if(h.kind==="object"&&d>=t*s){h.candidate=!1,h.distinct=null,h.reason=`${d} distinct values is at or above ${t*100}% of ${s} rows`;continue}m&&h.kind==="object"&&d<t*s&&(this.#n.convert(h.spec.id,"dictionary"),h.kind="dictionary",h.change=h.change==="demoted"?null:"promoted",h.reason=`${d} distinct values is below ${t*100}% of ${s} rows`,h.distinct=null),m&&(h.candidate=!1)}}}async function c(n,m={},t={}){const s=new i(n,m,t),h=t.scheduler?.frame??G;for(;s.slice();)await new Promise(d=>{h(d)});return s.result()}function u(n,m={},t={}){const s=new i(n,m,{...t,chunkMs:1/0});for(;s.slice(););return s.result()}}),Ue("packages/core/src/store/columnpack.js",function(e,B){"use strict";Object.defineProperty(e,"isPortableSchema",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"packChunk",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"packedTransfers",{enumerable:!0,get:function(){return g}});const T=B("packages/core/src/internal/paths.js").pathGetter,G=B("packages/core/src/store/ingest.js"),D=G.inferKind,I=G.decideText,Z=G.INGEST_DEFAULTS,L=B("packages/core/src/store/columnstore.js").toFloat,X=new Set(["float64","int32","bitset","dictionary","object","multi"]);function $(a){if(!Array.isArray(a)||a.length===0)return!1;for(const r of a)if(!r||typeof r.id!="string"||typeof r.field!="string"||r.field===""||r.kind&&!X.has(r.kind))return!1;return!0}function A(a){const r=L(a);return Number.isFinite(r)?r|0:0}function k(a){return a==null?[]:Array.isArray(a)?a:[a]}function y(a,r,i,c){if(a.kind)return a.kind;const u=[];for(let t=0;t<r.length&&u.length<Z.sampleSize;t++){const s=r[t];s!=null&&u.push(s)}const n=D(u,{multi:a.multi});if(n!=="text")return n;const m=new Set(u).size;return I(m,u.length,c)}function f(a,r,i={}){const c=r.length|0,u=i.dictionaryRatio??Z.dictionaryRatio,n=[];for(const m of a){const t=T(m.field||m.id),s=m.nullable!==!1,h=new Array(c);for(let p=0;p<c;p++){const w=t(r[p]);h[p]=w===void 0?null:w}const d=y(m,h,c,u),o=s?new Uint8Array(c+7>>3):null,b=p=>{o&&(o[p>>3]|=1<<(p&7))};let l;switch(d){case"float64":{const p=new Float64Array(c);for(let w=0;w<c;w++){const v=h[w],R=v===null;R||b(w),p[w]=R?NaN:L(v)}l={id:m.id,kind:d,nullable:s,values:p,presence:o,offsets:null,table:null};break}case"int32":{const p=new Int32Array(c);for(let w=0;w<c;w++){const v=h[w],R=v===null;R||b(w),p[w]=R?0:A(v)}l={id:m.id,kind:d,nullable:s,values:p,presence:o,offsets:null,table:null};break}case"bitset":{const p=new Uint8Array(c+7>>3);for(let w=0;w<c;w++){const v=h[w],R=v===null;R||b(w),!R&&v&&(p[w>>3]|=1<<(w&7))}l={id:m.id,kind:d,nullable:s,values:p,presence:o,offsets:null,table:null};break}case"dictionary":{const p=new Uint32Array(c),w=[],v=new Map;for(let R=0;R<c;R++){const Y=h[R];if(Y===null){p[R]=0;continue}b(R);let K=v.get(Y);K===void 0&&(K=w.length,w.push(Y),v.set(Y,K)),p[R]=K}l={id:m.id,kind:d,nullable:s,values:p,presence:o,offsets:null,table:w};break}case"multi":{const p=[],w=new Map,v=new Uint32Array(c+1),R=[];for(let Y=0;Y<c;Y++){const K=h[Y];v[Y]=R.length,K===null||b(Y);const E=k(K);for(let O=0;O<E.length;O++){const C=E[O];let S=w.get(C);S===void 0&&(S=p.length,p.push(C),w.set(C,S)),R.push(S)}}v[c]=R.length,l={id:m.id,kind:d,nullable:s,values:Int32Array.from(R),presence:o,offsets:v,table:p};break}default:{const p=new Array(c);for(let w=0;w<c;w++){const v=h[w];v!==null&&b(w),p[w]=v}l={id:m.id,kind:"object",nullable:s,values:p,presence:o,offsets:null,table:null};break}}n.push(l)}return{count:c,columns:n}}function g(a){const r=[];if(!a||!Array.isArray(a.columns))return r;const i=c=>{ArrayBuffer.isView(c)&&c.buffer&&!r.includes(c.buffer)&&r.push(c.buffer)};for(const c of a.columns)i(c.values),i(c.presence),i(c.offsets);return r}}),Ue("packages/core/src/source/stream.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_PROMOTE_BELOW",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"StreamSource",{enumerable:!0,get:function(){return S}});const T=B("packages/core/src/internal/lru.js").Lru,D=B("packages/core/src/internal/predicates.js").isFunction,I=B("packages/core/src/internal/schedule.js"),Z=I.now,z=I.nextFrame,L=I.cancelFrame,X=I.whenIdle,A=B("packages/core/src/internal/compare.js").defaultCompare,k=B("packages/core/src/internal/warn.js"),y=k.warnOnce,f=k.infoOnce,a=B("packages/core/src/internal/paths.js").getPath,r=B("packages/core/src/source/abort.js"),i=r.createAbortScope,c=r.isAbortError,u=B("packages/core/src/source/rows.js"),n=u.createRowFactory,m=u.lazyRowView,s=B("packages/core/src/source/gapbuffer.js").GapBuffer,d=B("packages/core/src/source/memory.js").createMemorySource,b=B("packages/core/src/source/filterwire.js").querySignature,p=B("packages/core/src/store/columnpack.js").isPortableSchema,w=25e4,v=Symbol("lattice.stream.storeBacked"),R=8,Y=.1,K=1e3,V=50;function E(F){return Math.min(K,Math.max(V,Math.floor(F/4)))}function O(F){if(F instanceof Date)return F.getTime();if(typeof F=="number")return Number.isFinite(F)?F:NaN;if(typeof F=="string"){const P=F.trim();if(!P)return NaN;const M=Date.parse(P);return Number.isNaN(M)?Number(P):M}return NaN}function C(F,P){return new S(F,P)}class S{mode="stream";writesStore=!0;#e;#t;#n=[];#r=null;#i=[];#s=null;#a;#l;#o=new Map;#c=i();#u={loaded:0,estimated:void 0};#f=null;#d=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;#I=null;#G=null;#K=null;#L=!1;#q=0;#U=0;#Y=!1;constructor(P,M){this.#e=P||{mode:"stream"},this.#t=M||{},this.#a=n(this.#t),this.#l=new T(4096),this.#P=this.#qe();const x=(this.#t.config||{}).ingest;this.#L=!!x&&x.retainSource===!1,D(this.#e.open)||y("source.stream.open",'source.mode "stream" requires an open function; the grid will stay empty.'),this.#e.autoStart!==!1&&queueMicrotask(()=>this.start());const U=Number(this.#e.poll);Number.isFinite(U)&&U>0&&(this.#K=setInterval(()=>{this.#v||this.reload()},U),this.#K&&D(this.#K.unref)&&this.#K.unref()),this.#D()}#z(){const P=Number(this.#e.maxAge);return Number.isFinite(P)&&P>0?P:0}#D(){const P=this.#z();if(!P)return;const M=this.#e.ageBy;D(M)?this.#I=M:typeof M=="string"&&M?this.#I=x=>a(x,M):this.#I=null,this.#T=[],this.#R=setInterval(()=>{this.#v||this.#V()&&(this.#Ee(),this.#H())},E(P)),this.#R&&D(this.#R.unref)&&this.#R.unref()}#V(){const P=this.#z();return!P||!this.#T?!1:this.#N?!0:this.#M<Date.now()-P*(1+Y)}#ge(P,M){if(!this.#T)return;const x=this.#I?O(this.#I(M)):Date.now();this.#T[P]=x,Number.isNaN(x)||(x<this.#M&&(this.#M=x),x<Date.now()-this.#z()&&(this.#N=!0))}#se(){return this.#Oe("groupBy",[]).length>0?!0:!!this.#Oe("pivotMode",!1)&&this.#Oe("pivotBy",[]).length>0}#ue(){if(this.#g||this.#v)return;const P=this.#se();if(P&&!this.#b){this.#b=d({mode:"memory",rows:this.#n},this.#Me()),this.#O=!1;return}!P&&this.#b&&(this.#b.destroy(),this.#b=null)}#Me(){if(this.#y)return this.#y;const P=this,M={liveIndices:()=>P.#fe(),live:x=>P.#n[x]!==void 0,source:x=>P.#ee(x),get physical(){return P.#n.length}};return this.#L&&(M.column=x=>{const U=P.#t.store;return U&&D(U.column)?U.column(x):void 0}),this.#y=Object.create(this.#t,{store:{value:M,enumerable:!0,configurable:!0}}),this.#y}#fe(){const P=new Uint32Array(this.#n.length);let M=0;for(let x=0;x<this.#n.length;x++)this.#n[x]!==void 0&&(P[M++]=x);return P.subarray(0,M)}#oe(){return this.#g?this.#g:this.#b?(this.#O&&(this.#O=!1,this.#b.setRows(this.#n)),this.#b):null}invalidate(P="filter"){if(this.#g){this.#g.invalidate(P);return}this.#ue(),this.#b&&this.#b.invalidate(P),(P==="filter"||P==="sort")&&this.#Te()}count(){const P=this.#oe();return P?P.count():this.#r?this.#r.length:this.#S}matchCount(){const P=this.#oe();return P&&D(P.matchCount)?P.matchCount():this.#r?this.#r.length:this.#S}totalCount(){const P=this.#oe();return P&&D(P.totalCount)?P.totalCount():this.#S}unfilteredRows(){const P=this.#oe();if(P&&D(P.unfilteredRows))return P.unfilteredRows();const M=[];for(let x=0;x<this.#n.length;x++){if(!this.#n[x])continue;const U=this.#je(x);U&&M.push(U)}return M}at(P){const M=this.#oe();if(M)return M.at(P);if(P<0||P>=this.count())return;const x=this.#r?this.#r.at(P):P,U=this.#je(x);return U.index=P,U}byKey(P){const M=this.#oe();if(M)return M.byKey(P);const x=this.#o.get(P);return x===void 0?void 0:this.#je(x)}leavesOf(P){const M=this.#oe();return M&&D(M.leavesOf)?M.leavesOf(P):[]}loaded(P){return P>=0&&P<this.count()}hint(P,M){if(this.#g){this.#g.hint(P,M);return}this.#He(),this.#p=Math.max(0,Math.floor(P))}#He(){this.#v||this.#qe()===this.#P||this.reload()}display(){const P=this.#oe();return P?P.display():m(()=>this.count(),M=>this.at(M))}apply(P){if(this.#g)return this.#g.apply(P);const M={added:[],updated:[],removed:[]};if(!P)return M;if(P.update){let x=!1;for(const U of P.update){const _=this.#o.get(this.#a.keyOf(U,-1));if(_===void 0)continue;const W=this.#Se(_);this.#L?this.#Le(_,U):this.#n[_]=U,this.#l.delete(_),this.#ye(_,W),this.#T&&(this.#ge(_,U),x=!0),this.#O=!0,M.updated.push(this.#je(_))}x&&this.#Ee()}if(P.add&&P.add.length){const x=this.#ne(P.add);for(const U of x)M.added.push(this.#je(U))}return P.remove&&P.remove.length&&y("source.stream.remove","removing rows from a live stream is not supported; reload instead."),this.#H(),M}reload(P){this.#c.abortAll("reload"),this.#Ye(),this.#b&&(this.#b.destroy(),this.#b=null),this.#O=!1,this.#n=[],this.#r=null,this.#o.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.#qe(),this.#Pe("model:changed",{reason:"reload"}),this.start()}destroy(){this.#v=!0,this.#K!==null&&(clearInterval(this.#K),this.#K=null),this.#R!==null&&(clearInterval(this.#R),this.#R=null),this.#T=null,this.#c.abortAll("destroyed"),this.#Ye(),this.#f!==null&&(this.#ke(this.#f),this.#f=null),this.#b&&(this.#b.destroy(),this.#b=null),this.#g&&this.#g.destroy(),this.#n=[],this.#r=null,this.#o.clear(),this.#l.clear()}async start(){if(this.#A||this.#v||!D(this.#e.open))return;this.#A=!0;const P=this.#c.begin("stream");this.#Te(),this.#ue();let M;try{M=this.#e.open({sort:this.#Oe("sort",[]),filters:this.#Oe("filters",null),quick:this.#Oe("quick","")||void 0,context:this.#Oe("context",null),signal:P.signal})}catch(U){this.#Pe("source:error",{error:U});return}const x=D(M[Symbol.asyncIterator])?M[Symbol.asyncIterator]():M[Symbol.iterator]();this.#G=x;try{for(;;){const U=await x.next();if(!P.current||this.#v)return;if(U.done){this.#$();return}if(await this.#xe(U.value,P),!P.current||this.#v)return;if(U.value&&U.value.done){this.#$();return}if(await this.#he(),!P.current||this.#v)return}}catch(U){if(c(U))return;this.#Pe("source:error",{error:U})}finally{P.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 P=this.#oe();P&&(D(P.invalidateHandles)&&P.invalidateHandles(),D(P.invalidate)&&P.invalidate("sort"))}renderCount(){return this.#d}ingestStats(){return{worker:this.#q,inline:this.#U,storeBacked:this.#L}}#xe(P,M){if(!P)return;const x=P.rows;if(x&&x.length&&this.#ae(x))return this.#le(P,M);const U=Z();x&&x.length&&(this.#ne(x),this.#U++),this.#Ce(P),this.#h+=Z()-U,this.#H()}#Ce(P){this.#u.loaded=P.progress&&typeof P.progress.loaded=="number"?P.progress.loaded:this.#n.length,P.progress&&typeof P.progress.estimated=="number"&&(this.#u.estimated=P.progress.estimated)}#ae(P){if(this.#Y||this.#g)return!1;const M=this.#Z();if(!M)return!1;const x=this.#t.store;if(!x||!D(x.appendPacked))return!1;const U=this.#W();return!U||!p(U)?(this.#Y=!0,f("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):P.length<M.threshold?!1:!this.#Ae(P)}#Ae(P){if(!this.#a.keyed)return!1;const M=new Set;for(let x=0;x<P.length;x++){const U=this.#a.keyOf(P[x],this.#n.length+x);if(U!=null){if(M.has(U)||this.#o.has(U))return!0;M.add(U)}}return!1}async#le(P,M){const x=P.rows,U=this.#Z(),_=this.#W();let W;try{W=await U.columnize(_,x,{key:"ingest:stream",signal:M&&M.signal})}catch(ee){if(c(ee)||(y("source.stream.columnize","worker columnization failed; columnizing on the main thread",ee),this.#Y=!0,M&&(!M.current||this.#v)))return;this.#ne(x),this.#U++,this.#Ce(P),this.#H();return}if(M&&(!M.current||this.#v))return;const q=this.#t.store,N=this.#L?void 0:x,{from:Q}=q.appendPacked(W,N),J=W.count|0;for(let ee=0;ee<J;ee++){const ne=Q+ee,se=x[ee],le=this.#a.keyed?this.#a.keyOf(se,ne):null;if(this.#n[ne]=this.#L?v:se,this.#S++,this.#ge(ne,se),le!==null&&this.#o.set(le,ne),!this.#r||!this.#we(ne))continue;const ye=this.#de(ne);this.#r.insert(ye,ne),ye<=this.#p&&this.#m++}this.#O=!0,this.#Ee(),this.#q++,this.#Ce(P),this.#H()}#Z(){const P=this.#t.ingestWorker;return D(P)?P():null}#W(){const P=this.#t.storeSchema;return D(P)?P():null}#ne(P){const M=[],x=this.#t.store,U=new Array(P.length),_=[],W=new Set;for(let N=0;N<P.length;N++){const Q=this.#a.keyed?this.#a.keyOf(P[N],this.#n.length+_.length):null;U[N]=Q,!(Q!==null&&(this.#o.has(Q)||W.has(Q)))&&(Q!==null&&W.add(Q),_.push(P[N]))}let q=_.length&&x&&D(x.append)?x.append(_).from:this.#n.length;for(let N=0;N<P.length;N++){const Q=P[N],J=U[N];if(J!==null&&this.#o.has(J)){const se=this.#o.get(J),le=this.#Se(se);this.#L||(this.#n[se]=Q,x&&D(x.setSource)&&x.setSource(se,Q)),this.#Le(se,Q),this.#l.delete(se),this.#ge(se,Q),this.#ye(se,le);continue}const ee=q++;if(this.#n[ee]=this.#L?v:Q,this.#S++,this.#ge(ee,Q),J!==null&&this.#o.set(J,ee),M.push(ee),!this.#r||!this.#we(ee))continue;const ne=this.#de(ee);this.#r.insert(ne,ee),ne<=this.#p&&this.#m++}return this.#O=!0,this.#Ee(),M}#B(P){const M=this.#n[P];let x=!1;if(this.#r){const q=this.#be(P);q>=0&&q<=this.#p&&(x=!0)}else P<=this.#p&&(x=!0);const U=M===v?this.#ee(P):M,_=this.#a.keyed?this.#a.keyOf(U,P):null;_!==null&&this.#o.get(_)===P&&this.#o.delete(_),this.#n[P]=void 0,this.#T&&(this.#T[P]=NaN),this.#l.delete(P);const W=this.#t.store;return W&&D(W.remove)&&W.remove(P),this.#S--,x}#Ee(){let P=0,M=0;const x=this.#pe();P+=x.dropped,M+=x.aboveAnchor;const U=this.#re();P+=U.dropped,M+=U.aboveAnchor,P&&(this.#O=!0,this.#C+=P,this.#Te(),this.#m-=M,this.#Pe("stream:evicted",{evicted:P,total:this.#C,live:this.#S}))}#re(){const P=this.#e.maxRows;if(!Number.isFinite(P)||P<=0||this.#S<=P)return{dropped:0,aboveAnchor:0};const M=Math.max(1,Math.floor(P*(1-Y)));let x=0,U=0;for(;this.#S>M&&this.#E<this.#n.length;){const _=this.#E++;this.#n[_]!==void 0&&(this.#B(_)&&U++,x++)}return{dropped:x,aboveAnchor:U}}#pe(){const P=this.#z();if(!P||!this.#T||!this.#V())return{dropped:0,aboveAnchor:0};const M=Date.now()-P;let x=0,U=0,_=1/0;for(let W=this.#E;W<this.#n.length;W++){if(this.#n[W]===void 0)continue;const q=this.#T[W];if(!(Number.isNaN(q)||q===void 0)){if(q>=M){q<_&&(_=q);continue}this.#B(W)&&U++,x++}}for(this.#M=_,this.#N=!1;this.#E<this.#n.length&&this.#n[this.#E]===void 0;)this.#E++;return{dropped:x,aboveAnchor:U}}#be(P){if(!this.#r)return P;for(let M=0;M<this.#r.length;M++)if(this.#r.at(M)===P)return M;return-1}#Te(){this.#i=this.#Oe("sort",[]),this.#s=this.#Oe("filters",null);const P=Number.isFinite(this.#e.maxRows)&&this.#e.maxRows>0||this.#z()>0,M=this.#Oe("where",null),x=(this.#t.config||{}).hostFilter,U=!!(M&&M.active)||!!(x&&D(x.active)&&x.active());if(!(P||this.#i.length>0||!!this.#s||!!this.#Oe("quick","")||U)){this.#r=null;return}this.#r=new s(Math.max(64,this.#n.length+64));for(let W=0;W<this.#n.length;W++)this.#n[W]!==void 0&&this.#we(W)&&this.#r.insert(this.#de(W),W)}#we(P){const M=this.#ee(P);if(this.#s&&!this.#ve(this.#s,M))return!1;const x=String(this.#Oe("quick","")||"").toLowerCase();if(x&&!this.#k(M).includes(x))return!1;const U=(this.#t.config||{}).hostFilter;if(U&&D(U.active)&&U.active()&&!U.passes(this.#je(P)))return!1;const _=this.#Oe("where",null);if(_&&_.active){const W=this.#je(P);if(!_.passes(W.data,W.key))return!1}return!0}#ve(P,M){if(!P)return!0;const x=P;if(Array.isArray(x.conditions))return x.op==="or"?x.conditions.some(W=>this.#ve(W,M)):x.op==="not"?!x.conditions.some(W=>this.#ve(W,M)):x.conditions.every(W=>this.#ve(W,M));const U=P,_=(this.#t.compute||{}).testValue;return D(_)?!!_(this.#Ve(M,U.col),U,(this.#t.config||{}).locale):(y("source.stream.testValue","ctx.compute.testValue is unavailable; streamed rows are not filtered client-side."),!0)}#Se(P){if(!this.#r)return-1;if(!this.#i.length)return this.#be(P);let M=0,x=this.#r.length;for(;M<x;){const U=M+x>>>1;this.#J(this.#r.at(U),P)<0?M=U+1:x=U}for(let U=M;U<this.#r.length;U++){const _=this.#r.at(U);if(_===P)return U;if(this.#J(_,P)>0)break}return this.#be(P)}#ye(P,M){if(!this.#r||!this.#i.length)return;const x=this.#we(P);if(M>=0&&this.#r.at(M)===P)this.#r.removeAt(M),M<=this.#p&&this.#m--;else if(M>=0)return;if(!x)return;const U=this.#de(P);this.#r.insert(U,P),U<=this.#p&&this.#m++}#de(P){if(!this.#r||!this.#i.length)return this.#r?this.#r.length:0;let M=0,x=this.#r.length;for(;M<x;){const U=M+x>>>1;this.#J(P,this.#r.at(U))<0?x=U:M=U+1}return M}#J(P,M){const x=this.#ee(P),U=this.#ee(M);for(const _ of this.#i){const W=this.#Fe(_.col),q=this.#Ve(x,_.col),N=this.#Ve(U,_.col),J=(W&&W.value&&D(W.value.compare)?W.value.compare:A)(q,N);if(J!==0)return _.dir==="desc"?-J:J}return 0}#$(){this.#w=!0,this.#u.loaded=this.#u.loaded||this.#n.length;const P=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:w;!this.#L&&this.#n.length<P&&(this.#g=d({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.#H(),this.#Pe("stream:end",{loaded:this.#n.length,promoted:this.#g!==null,threshold:P})}#H(){this.#f!==null||this.#v||(this.#f=this.#F(()=>{this.#f=null,this.#d++;const P=this.#m;this.#m=0,this.#h=0,this.#Pe("stream:chunk",{loaded:this.#u.loaded,estimated:this.#u.estimated,count:this.count(),renders:this.#d}),this.#Pe("model:changed",{reason:"stream",shiftAboveViewport:P,anchor:this.#p}),this.#Pe("rows:changed",{companion:!0,reason:"stream"})}))}#he(){return this.#d===0||this.#h<this.#ie()?Promise.resolve():(this.#h=0,new Promise(P=>{const M=(this.#t.scheduler||{}).idle;D(M)?M(()=>P()):X(()=>P())}))}#ie(){return typeof this.#e.coalesceMs=="number"&&this.#e.coalesceMs>0?this.#e.coalesceMs:R}#F(P){const M=this.#t.scheduler||{};return D(M.frame)?M.frame(P):z(P)}#ke(P){const M=this.#t.scheduler||{};D(M.cancel)?M.cancel(P):L(P)}#ee(P){const M=this.#n[P];if(M!==void 0&&M!==v)return M;if(M===void 0)return;const x=this.#t.store;return x&&D(x.source)?x.source(P):void 0}#Le(P,M){const x=this.#t.store;if(!x||!D(x.set))return;const U=this.#W();if(Array.isArray(U))for(const _ of U){if(!_||!_.id)continue;const W=D(_.read)?_.read:q=>a(q,_.field||_.id);x.set(_.id,P,W(M))}}#je(P){let M=this.#l.get(P);return M||(M=this.#a.leaf(this.#ee(P),P),this.#l.set(P,M)),M}#Ve(P,M){const x=this.#Fe(M);return x&&D(x.getValue)?x.getValue(P):P?.[M]}#k(P){const M=this.#t.columns,x=M&&D(M.all)?M.all():[],U=[];for(const _ of x){const W=D(_.getValue)?_.getValue(P):void 0;W!=null&&W!==""&&U.push(String(W))}return U.join(" ").toLowerCase()}#Fe(P){const M=this.#t.columns;return M&&D(M.get)?M.get(P):void 0}#Ye(){const P=this.#G;if(this.#G=null,P&&D(P.return))try{P.return()}catch{}}#qe(){return b({context:this.#Oe("context",null)})}#Oe(P,M){const x=this.#t.state;if(x&&D(x[P])){const U=x[P]();return U??M}return M}#Pe(P,M){const x=this.#t.emit;D(x)&&x(P,M)}}}),Ue("packages/core/src/source/url.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_URL_BATCH",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return y}});const T=B("packages/core/src/internal/warn.js").warnOnce,G=B("packages/core/src/internal/predicates.js"),D=G.isObject,I=G.isFunction,z=B("packages/core/src/internal/paths.js").getPath,X=B("packages/core/src/source/abort.js").isAbortError,$=500,A=new Set(["application/x-ndjson","application/ndjson","application/jsonlines","application/jsonl","application/x-jsonlines","text/x-ndjson"]),k=Symbol("lattice.url.skip");function y(o,b={}){const l=D(b)?b:{},p=I(l.fetch)?l.fetch:typeof globalThis<"u"&&I(globalThis.fetch)?globalThis.fetch:null,w=l.format==="json"||l.format==="ndjson"?l.format:void 0,v=typeof l.rowsPath=="string"&&l.rowsPath?l.rowsPath:void 0,R=I(l.map)?l.map:void 0,Y=D(l.headers)?l.headers:void 0,K=Number.isFinite(l.batchSize)&&l.batchSize>0?Math.floor(l.batchSize):$,V=l.lenient===!0,E=Number.isFinite(l.poll)&&l.poll>0?Math.floor(l.poll):void 0,O=typeof o=="string"&&o.length>0;O||T("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*C(F={}){if(!O)return;if(!p)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const P=F&&F.signal;let M;try{M=await p(o,Y?{signal:P,headers:Y}:{signal:P})}catch(_){throw X(_)?_:new Error(`[lattice] createUrlSource: request to ${o} failed — ${_&&_.message||_}`)}if(!M||!M.ok){const _=M?M.status:"no response";throw new Error(`[lattice] createUrlSource: ${_} for ${o}`)}const x=f(o,w,M),U=M.body&&I(M.body.getReader)?M.body.getReader():null;try{if(!U){const q=await M.text();(x||r(q,o))==="ndjson"?yield*t(null,null,q,0,M,o,K,V):yield*m(q,o,v,R);return}const _=new TextDecoder("utf-8");if(x==="json"){yield*m(await n(U,_,""),o,v,R);return}if(x==="ndjson"){yield*t(U,_,"",0,M,o,K,V);return}const W=await i(U,_,o);W.format==="json"?yield*m(await n(U,_,W.seed),o,v,R):yield*t(U,_,W.seed,W.bytes,M,o,K,V)}finally{if(U&&I(U.cancel))try{await U.cancel()}catch{}}}const S={mode:"stream",open:C,autoStart:l.autoStart!==!1};return E!==void 0&&(S.poll=E),Number.isFinite(l.maxRows)&&(S.maxRows=l.maxRows),Number.isFinite(l.maxAge)&&(S.maxAge=l.maxAge),(typeof l.ageBy=="string"||I(l.ageBy))&&(S.ageBy=l.ageBy),Number.isFinite(l.coalesceMs)&&(S.coalesceMs=l.coalesceMs),Number.isFinite(l.promoteToMemoryBelow)&&(S.promoteToMemoryBelow=l.promoteToMemoryBelow),S}function f(o,b,l){if(b)return b;const p=g(o);if(p)return p;const w=l&&l.headers&&I(l.headers.get)?l.headers.get("content-type"):null;return a(w)}function g(o){const b=String(o).split(/[?#]/)[0].toLowerCase();if(b.endsWith(".ndjson")||b.endsWith(".jsonl"))return"ndjson";if(b.endsWith(".json"))return"json"}function a(o){if(!o)return;const b=o.split(";")[0].trim().toLowerCase();if(A.has(b))return"ndjson";if(b==="application/json"||b==="text/json"||b.endsWith("+json"))return"json"}function r(o,b){const l=o.replace(/^\s+/,""),p=c(l);if(p==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${b} — pass opts.format: 'json' | 'ndjson'.`);return p}async function i(o,b,l){let p="",w=0;for(;;){const{value:R,done:Y}=await o.read();if(R&&(w+=R.byteLength,p+=b.decode(R,{stream:!0})),Y){p+=b.decode();break}const K=p.replace(/^\s+/,"");if(K){if(K[0]==="[")return{format:"json",seed:p,bytes:w};if(K[0]!=="{"||p.indexOf(`
|
|
8
8
|
`)!==-1)break}}const v=c(p.replace(/^\s+/,""));if(v==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${l} — pass opts.format: 'json' | 'ndjson'.`);return{format:v,seed:p,bytes:w}}function c(o){if(!o||o[0]==="[")return"json";if(o[0]!=="{")return"error";const b=o.indexOf(`
|
|
9
9
|
`);if(b===-1)return"json";let l=o.slice(0,b);return l.endsWith("\r")&&(l=l.slice(0,-1)),u(l)?"ndjson":"json"}function u(o){try{return JSON.parse(o),!0}catch{return!1}}async function n(o,b,l){let p=l;for(;;){const{value:w,done:v}=await o.read();if(w&&(p+=b.decode(w,{stream:!0})),v)break}return p+=b.decode(),p}function*m(o,b,l,p){let w;try{w=JSON.parse(o)}catch(R){throw new Error(`[lattice] createUrlSource: ${b} is not valid JSON — ${R.message}`)}let v=l!==void 0?z(w,l):w;if(p&&(v=p(v)),!Array.isArray(v)){const R=l!==void 0||p?"":"; pass opts.rowsPath or opts.map to select the array";throw new Error(`[lattice] createUrlSource: ${b} did not resolve to an array${R}.`)}yield{rows:v,progress:{loaded:v.length,estimated:v.length}}}async function*t(o,b,l,p,w,v,R,Y){const K=d(w);let V=l||"",E=p||0,O=0,C=0,S=[];function*F(){let M;for(;(M=V.indexOf(`
|
|
10
10
|
`))!==-1;){const x=V.slice(0,M);V=V.slice(M+1),C++;const U=s(x,C,v,Y);U!==k&&(S.push(U),S.length>=R&&(O+=S.length,yield h(S,O,K,E),S=[]))}}if(o){for(;;){const{value:M,done:x}=await o.read();if(M&&(E+=M.byteLength,V+=b.decode(M,{stream:!0}),yield*F()),x)break}V+=b.decode()}yield*F(),C++;const P=s(V,C,v,Y);P!==k&&S.push(P),S.length&&(O+=S.length,yield h(S,O,K,E))}function s(o,b,l,p){let w=o;if(w.endsWith("\r")&&(w=w.slice(0,-1)),!w.trim())return k;try{return JSON.parse(w)}catch(v){if(p)return T(`source.url.badline.${l}`,`skipping a malformed NDJSON line (line ${b}) from ${l} — ${v.message}`),k;throw new Error(`[lattice] createUrlSource: malformed NDJSON at line ${b} of ${l} — ${v.message}`)}}function h(o,b,l,p){const w=l&&p>0&&b>0?Math.max(b,Math.round(l/(p/b))):void 0;return{rows:o,progress:{loaded:b,estimated:w}}}function d(o){const b=o&&o.headers&&I(o.headers.get)?o.headers.get("content-length"):null,l=b!=null?Number(b):NaN;return Number.isFinite(l)&&l>0?l:void 0}}),Ue("packages/core/src/source/derive.js",function(e,B){"use strict";Object.defineProperty(e,"FOLLOW_MODES",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"BUCKETS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"DERIVED_ROW_KEY",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"DERIVED_SOURCE_KEY",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"UNION_KEY_SEP",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"readPath",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"unnest",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"reduceValues",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"applyLimit",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"applyCumulative",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"groupRows",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"finishGroups",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"derive",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"normalizeUnionSource",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"namespaceUnionKeys",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"joinRows",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"preGroup",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"buildJoinIndex",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"joinOne",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"joinKeyOf",{enumerable:!0,get:function(){return w}});const re=B("packages/core/src/internal/predicates.js"),T=re.isFunction,G=re.isObject,I=B("packages/core/src/compute/total.js").TOTAL_FNS,Z=Object.freeze(["filtered","all","selected","grouped"]),z=Object.freeze(["day","week","month","quarter","year"]),L="__key",X="__source",$="";function A(v,R){if(!G(v)||typeof R!="string")return;if(!R.includes("."))return v[R];let Y=v;for(const K of R.split(".")){if(!G(Y))return;Y=Y[K]}return Y}function k(v,R){const Y=[];for(const K of v){const V=A(K,R);if(!(!Array.isArray(V)||!V.length))for(const E of V)Y.push({...K,[R]:E})}return Y}function y(v,R){const Y=v instanceof Date?v:new Date(v),K=Y.getTime();if(!Number.isFinite(K))return null;const V=Y.getUTCFullYear(),E=Y.getUTCMonth(),O=Y.getUTCDate(),C=S=>S.toISOString().slice(0,10);switch(R){case"year":return C(new Date(Date.UTC(V,0,1)));case"quarter":return C(new Date(Date.UTC(V,Math.floor(E/3)*3,1)));case"month":return C(new Date(Date.UTC(V,E,1)));case"week":{const S=(Y.getUTCDay()+6)%7;return C(new Date(Date.UTC(V,E,O-S)))}default:return C(new Date(Date.UTC(V,E,O)))}}function f(v,R,Y){const K=R.map(V=>Y&&Y.of===V?y(A(v,V),Y.by):A(v,V));return{key:K.map(V=>V==null?"\0":String(V)).join(""),values:K}}function g(v,R){const Y=I[R];return Y?Y({get:K=>v[K]},i(v.length)):null}function a(v,R){return!R||typeof R.of!="string"||R.of===""||v&&v.includes(R.of)?v:[R.of,...v||[]]}function r(v,R){const Y={},K=i(v.length);for(const[V,E]of Object.entries(R)){const O=E.fn||"count",C=I[O];if(!C){Y[V]=null;continue}const S=E.of?v.map(F=>A(F,E.of)):[];Y[V]=C({get:F=>S[F]},K)}return Y}const i=(()=>{const v=new Map;return R=>{let Y=v.get(R);if(!Y){Y=new Uint32Array(R);for(let K=0;K<R;K++)Y[K]=K;v.size<512&&v.set(R,Y)}return Y}})();function c(v,R,Y){if(!Number.isFinite(R)||R<=0)return v;if(!Y)return v.slice(0,R);const K=new Map,V=[];for(const E of v){const O=String(A(E,Y)),C=K.get(O)||0;C>=R||(K.set(O,C+1),V.push(E))}return V}function u(v,R){const Y=v.reduce((O,C)=>O+(Number(A(C,R.of))||0),0);if(!Y)return v;const K=Y*R.upTo;let V=0;const E=[];for(const O of v)if(E.push(O),V+=Number(A(O,R.of))||0,V>=K)break;return E}function n(v,R){return!Array.isArray(R)||!R.length?v:[...v].sort((Y,K)=>{for(const V of R){const E=A(Y,V.col),O=A(K,V.col);if(E===O)continue;return E==null?1:O==null?-1:((typeof E=="number"&&typeof O=="number"?E<O:String(E)<String(O))?-1:1)*(V.dir==="desc"?-1:1)}return 0})}function m(v,R,Y){const K=R.groupBy?Array.isArray(R.groupBy)?R.groupBy:[R.groupBy]:null,V=G(R.bucket)?R.bucket:null,E=a(K,V),O=new Map,C=new Map;if(!E)return{groups:O,rowGroup:C};for(const S of v){const{key:F,values:P}=f(S,E,V);let M=O.get(F);M||(M={values:P,rows:new Map},O.set(F,M));const x=Y(S);M.rows.set(x,S),C.set(x,F)}return{groups:O,rowGroup:C}}function t(v,R,Y=null,K=null){const V=R.groupBy?Array.isArray(R.groupBy)?R.groupBy:[R.groupBy]:null,E=G(R.bucket)?R.bucket:null,O=a(V,E);let C=[...v.entries()].map(([S,F])=>{if(Y&&K&&!K.has(S)){const M=Y.get(S);if(M)return M}const P={[L]:S};return O.forEach((M,x)=>{P[M.includes(".")?M.split(".").pop():M]=F.values[x]}),Object.assign(P,r([...F.rows.values()],R.select||{})),Y&&Y.set(S,P),P});return C=n(C,R.sort),G(R.cumulative)&&(C=u(C,R.cumulative)),c(C,R.limit,R.limitPer||null)}function s(v,R){const Y=b(v,R),K=R.groupBy?Array.isArray(R.groupBy)?R.groupBy:[R.groupBy]:null,V=G(R.bucket)?R.bucket:null,E=a(K,V);let O;if(!E)O=Y.map((C,S)=>({...C,[L]:String(A(C,R.rowKey||"id")??S)}));else{const C=new Map;for(const S of Y){const{key:F,values:P}=f(S,E,V);let M=C.get(F);M||(M={values:P,rows:[]},C.set(F,M)),M.rows.push(S)}O=[...C.entries()].map(([S,F])=>{const P={[L]:S};return E.forEach((M,x)=>{P[M.includes(".")?M.split(".").pop():M]=F.values[x]}),Object.assign(P,r(F.rows,R.select||{})),P})}return O=n(O,R.sort),G(R.cumulative)&&(O=u(O,R.cumulative)),c(O,R.limit,R.limitPer||null)}function h(v,R){const K=G(v)&&G(v.grid)?v:{grid:v};return{grid:G(K.grid)?K.grid:null,label:K.label!=null&&K.label!==""?String(K.label):String(R),follow:typeof K.follow=="string"?K.follow:void 0,map:T(K.map)?K.map:null}}function d(v){for(const R of v){const Y=R[X];Y!==void 0&&(R[L]=`${Y}${$}${R[L]}`)}return v}function o(v,R){const Y=R.on,K=G(Y)?String(Y.left||Y.right||""):String(Y||""),V=G(Y)?String(Y.right||Y.left||""):String(Y||"");if(!K||!V)return v;const E=R.index instanceof Map?R.index:l(Array.isArray(R.rows)?R.rows:[],V),O=Array.isArray(R.select)?R.select.map(String):null,C=R.prefix?String(R.prefix):"",S=String(R.type||"inner")==="left",F=[];for(const P of v){const M=A(P,K),x=M==null?void 0:E.get(String(M));if(!x){S&&F.push(P);continue}const U={...P},_=O||Object.keys(x);for(const W of _)!C&&W===K||(U[C?C+W:W]=A(x,W));F.push(U)}return F}function b(v,R){let Y=Array.isArray(v)?v:[];return R.unnest&&(Y=k(Y,R.unnest)),G(R.join)&&(Array.isArray(R.join.rows)||R.join.index instanceof Map)&&(Y=o(Y,R.join)),T(R.where)&&(Y=Y.filter(K=>!!R.where(K))),Y}function l(v,R){const Y=new Map;for(const K of v){const V=A(K,R);if(V==null)continue;const E=String(V);Y.has(E)||Y.set(E,K)}return Y}function p(v,R){const Y=R.on,K=G(Y)?String(Y.left||Y.right||""):String(Y||""),V=G(Y)?String(Y.right||Y.left||""):String(Y||"");if(!K||!V)return v;const E=R.index instanceof Map?R.index:new Map,O=A(v,K),C=O==null?void 0:E.get(String(O));if(!C)return String(R.type||"inner")==="left"?v:null;const S=Array.isArray(R.select)?R.select.map(String):null,F=R.prefix?String(R.prefix):"",P={...v};for(const M of S||Object.keys(C))!F&&M===K||(P[F?F+M:M]=A(C,M));return P}function w(v,R){const Y=A(v,R);return Y==null?null:String(Y)}}),Ue("packages/core/src/source/derived.js",function(e,B){"use strict";Object.defineProperty(e,"IDLE_REFRESH_MS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PROFILE_FIELDS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ALERT_THRESHOLDS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"STATISTICS_FNS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SERIES_METRICS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"PRODUCER_IGNORED_KEYS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"profileAlerts",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"DerivedSource",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"createDerivedSource",{enumerable:!0,get:function(){return V}});const re=B("packages/core/src/internal/predicates.js"),T=re.isFunction,G=re.isObject,I=B("packages/core/src/internal/warn.js").warnOnce,z=B("packages/core/src/source/memory.js").MemorySource,X=B("packages/core/src/source/settle.js").isPipelineSettle,$=B("packages/core/src/source/derive.js"),A=$.derive,k=$.preGroup,y=$.groupRows,f=$.finishGroups,g=$.readPath,a=$.buildJoinIndex,r=$.joinOne,i=$.joinKeyOf,c=$.FOLLOW_MODES,u=$.DERIVED_ROW_KEY,n=$.DERIVED_SOURCE_KEY,m=$.normalizeUnionSource,t=$.namespaceUnionKeys,s=16,h=Object.freeze(["column","rows","present","missing","numeric","distinct","min","max","mean","median","q1","q3","iqr","stddev","outliers","alerts","alertCount"]),d=Object.freeze({missing:.2,cardinality:.9,skew:1,outliers:.05}),o=Object.freeze(["correlation","series","datasetVsDataset"]),b=Object.freeze(["n","first","last","change","changePercent","volatility","annualisedVolatility","growth","maxDrawdown","maxDrawdownFrom","maxDrawdownTo","autocorrelation","upDays","downDays"]),l=Object.freeze(["unnest","join","where","bucket","groupBy","select","sort","limit","limitPer","cumulative"]);function p(E,O={}){const C={...d,...G(O)?O:{}},S=J=>typeof J=="number"&&Number.isFinite(J)?J:null,F=S(E.rows)??0,P=S(E.numeric)??0,M=S(E.missing)??0,x=S(E.distinct),U=S(E.mean),_=S(E.median),W=S(E.stddev),q=S(Array.isArray(E.outliers)?E.outliers.length:E.outliers),N=P>0,Q=[];return x===0?["empty"]:(x===1&&Q.push("constant"),F>0&&M/F>=C.missing&&Q.push("high-missing"),!N&&x!==null&&F>1&&x===F&&M===0?Q.push("unique"):x!==null&&F>0&&x/F>=C.cardinality&&Q.push("high-cardinality"),N&&U!==null&&_!==null&&W!==null&&W>0&&Math.abs(3*(U-_)/W)>=C.skew&&Q.push("skewed"),N&&q!==null&&q/P>=C.outliers&&Q.push("outliers"),Q)}class w extends z{#e=null;#t={};#n=[];#r=null;#i=!1;#s={};#a=!1;#l=null;#o=null;#c=!1;#u=null;#f=!1;#d=null;constructor(O,C){super({mode:"memory",rows:[]},C),this.#s=C||{},this.#t=G(O)?O:{};const S=this.#t.from;if(Array.isArray(S)){if(this.#e=null,this.#d=this.#g(S),!this.#d.length){I("source.derived.from",'source.mode "derived" needs `from`: at least one grid to derive from.');return}this.#t.follow!==void 0&&I("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&&I("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&&(I("source.derived.union.statistics",'source.mode "derived": `statistics` is not supported when `from` is a union of several grids (BACKLOG-0001046) — a relational statistic reduces one grid\'s own columns, and a union has no single set of them. Derive the statistics of a single grid instead.'),this.#f=!0),this.#m(),this.#b(),this.refresh();return}if(this.#e=S||null,!this.#e){I("source.derived.from",'source.mode "derived" needs `from`: the grid to derive from.');return}this.#t.follow&&!c.includes(String(this.#t.follow))&&I(`source.derived.follow.${this.#t.follow}`,`unknown follow "${this.#t.follow}"; using "filtered". Known: ${c.join(", ")}.`),this.#h()||(this.#f=!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 I("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(!G(O))return I("source.derived.statistics.shape",`source.mode "derived": \`statistics\` needs an object naming the statistic, e.g. \`{ fn: 'correlation', columns: ['a', 'b'] }\`. Known fn: ${o.join(", ")}.`),!1;const C=String(O.fn||"");return o.includes(C)?this.#p(C,O):(I(`source.derived.statistics.fn.${C}`,`source.mode "derived": unknown \`statistics.fn\` "${C}". Known: ${o.join(", ")}. Every *single-column* statistic is reached through \`select\` instead, e.g. \`select: { p95: { of: 'amount', fn: 'p95' } }\`.`),!1)}#p(O,C){if(O==="correlation"){if((Array.isArray(C.columns)?C.columns.filter(Boolean):[]).length<2)return I("source.derived.statistics.columns","source.mode \"derived\": `statistics: { fn: 'correlation' }` needs `columns`: at least two column ids to correlate pairwise."),!1;const F=C.orient===void 0?"pairs":String(C.orient);return F!=="pairs"&&F!=="matrix"&&I(`source.derived.statistics.orient.${F}`,`source.mode "derived": unknown \`statistics.orient\` "${F}" for \`fn: 'correlation'\`; using "pairs". Known: pairs, matrix.`),!0}return O==="series"?!C.of||!C.by?(I("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:G(C.with)?!0:(I("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 C=l.filter(S=>this.#t[S]!==void 0);C.length&&I(`source.derived.producer.ignored.${O}`,`source.mode "derived": \`${O}\` is a terminal producer and replaces the pipeline, so ${C.map(S=>`\`${S}\``).join(", ")} ${C.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 C=this.#s&&this.#s.grid,S=new Set,F=[];return O.forEach((P,M)=>{const x=m(P,M);if(S.has(x.label)&&I(`source.derived.union.label.${x.label}`,`source.mode "derived": two union sources share the label "${x.label}"; give each a distinct \`label\` or __source/__key will not distinguish them.`),S.add(x.label),!x.grid){I(`source.derived.union.missing.${x.label}`,`source.mode "derived": union source "${x.label}" has no grid and was skipped.`),F.push(x);return}if(C&&T(x.grid.on)){const U=R(C,x.grid,[x.label]);if(U){I(`source.derived.union.cycle.${x.label}`,`source.mode "derived": union source "${x.label}" was refused — it derives from the grid being derived, directly or through a chain (${U.join(" → ")}). Remove it from \`from\`.`),F.push({...x,grid:null});return}}F.push(x)}),F}#b(){if(this.#d){this.#O(),this.#w();return}const O=this.#e;if(!O||!T(O.on))return;const C=String(this.#t.follow||"filtered"),S=["rows:changed"];(C==="filtered"||C==="grouped")&&S.push("filter:changed","model:changed"),C==="selected"&&S.push("selection:changed"),C==="grouped"&&S.push("column:grouped");for(const F of S){const P=M=>{F==="rows:changed"&&v(M)||F==="model:changed"&&!X(M)||this.schedule(F==="rows:changed"?M:null)};O.on(F,P),this.#n.push(()=>T(O.off)&&O.off(F,P))}this.#w(),this.#y()}#y(){const O=this.#t.statistics,C=G(O)?O.with:null;if(!G(C)||!T(C.on))return;const S=C;for(const F of["rows:changed","filter:changed","model:changed"]){const P=M=>{F==="rows:changed"&&v(M)||F==="model:changed"&&!X(M)||this.schedule(null)};S.on(F,P),this.#n.push(()=>T(S.off)&&S.off(F,P))}}#O(){for(const O of this.#d){const C=O.grid;if(!C||!T(C.on))continue;const S=c.includes(String(O.follow))?String(O.follow):"filtered",F=["rows:changed"];(S==="filtered"||S==="grouped")&&F.push("filter:changed","model:changed"),S==="selected"&&F.push("selection:changed"),S==="grouped"&&F.push("column:grouped");for(const P of F){const M=x=>{P==="rows:changed"&&v(x)||P==="model:changed"&&!X(x)||this.schedule(null)};C.on(P,M),this.#n.push(()=>T(C.off)&&C.off(P,M))}}}#w(){const O=this.#t.join,C=O&&O.with;if(!C||!T(C.on))return;const F=String(O.follow||"all")==="all"?["rows:changed"]:["rows:changed","filter:changed","model:changed"];for(const P of F){const M=x=>{P==="rows:changed"&&v(x)||P==="model:changed"&&!X(x)||this.schedule({partner:!0})};C.on(P,M),this.#n.push(()=>T(C.off)&&C.off(P,M))}}#A(){const O=this.#t.join;if(!O||!O.with)return null;const C=O.on,S=G(C)?String(C.left||C.right||""):String(C||""),F=G(C)?String(C.right||C.left||""):String(C||"");return S&&F?{left:S,right:F}:null}#v(){const O=this.#A();if(!O)return this.#u=null,null;const C=this.#u;if(this.#u=a(this.#C(),O.right),!C)return null;const S=this.#t.join||{},F=Array.isArray(S.select)?S.select.map(String):null,P=U=>U?(F||Object.keys(U)).map(W=>String(g(U,W))).join(""):null,M=new Set,x=new Set;for(const[U,_]of this.#u)P(_)!==P(C.get(U))&&(M.add(U),C.has(U)||x.add(U));for(const U of C.keys())this.#u.has(U)||M.add(U);return{affected:M,gained:x}}#P(O,C){const S=this.#l;if(!S||!S.leftByJoinKey)return null;const F=[];for(const P of O){const M=S.leftByJoinKey.get(P);if(M)for(const x of M){const U=S.rowData.get(x);U!==void 0&&F.push({key:x,data:U})}}return this.#M({updated:F,added:[],removed:[]},C)}#S(O,C){if(!this.#l||!this.#l.leftByJoinKey||O.unnest||O.where||String(O.follow||"filtered")==="grouped")return!1;const S=O.join||{};return String(S.type||"inner")==="left"?!0:C.size===0}#C(){const O=this.#t.join,C=O&&O.with;if(!C||!C.rows)return[];const S=[],F=P=>{P.group||S.push(Y(P))};return String(O.follow||"all")==="filtered"&&T(C.rows.forEach)?C.rows.forEach(F):T(C.rows.forEachAll)&&C.rows.forEachAll(F),S}schedule(O){const C=this.#t.refresh===void 0?"idle":this.#t.refresh;if(C==="manual")return;if(C==="live"){this.refresh(O);return}const S=typeof C=="number"&&Number.isFinite(C)?C:s;if(this.#r){this.#c=!0;return}this.#c=!1,this.#r=setTimeout(()=>{this.#r=null,this.refresh(this.#c?null:O)},S)}refresh(O){if(!(this.#i||!this.#e&&!this.#d)){if(this.#a){I("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.#a=!0;try{const C=this.#f?[]:this.#d?this.#t.profile?this.#q():this.#L():this.#t.statistics!==void 0?this.#ge():this.#t.profile?this.#fe():this.#E(O);this.setRows(C),this.invalidate("filter"),T(this.#s.emit)&&this.#s.emit("rows:changed",{derived:!0},"derived")}finally{this.#a=!1}}}#E(O){const S=G(O)&&O.partner===!0?this.#v():null,F=this.#I();if(S&&this.#l){if(!S.affected.size)return f(this.#l.groups,F,this.#l.reduced,new Set);if(this.#S(F,S.gained)){const ee=this.#P(S.affected,F);if(ee)return f(this.#l.groups,F,this.#l.reduced,ee)}}const P=this.#T(F,O);if(P&&this.#l){const ee=this.#M(P,F);return f(this.#l.groups,F,this.#l.reduced,ee)}const M=k(this.#U(),F);if(this.#o=this.#R(),!F.groupBy)return this.#l=null,A(M,F);const x=this.#N(),{groups:U,rowGroup:_}=y(M,F,x),W=new Map;for(const[ee,ne]of _){const se=U.get(ne);se&&W.set(ee,se.rows.get(ee))}const q=new Map,N=this.#A(),Q=new Map,J=new Map;if(N)for(const[ee,ne]of W){const se=i(ne,N.left);if(se===null)continue;Q.set(ee,se);let le=J.get(se);le||(le=new Set,J.set(se,le)),le.add(ee)}return this.#l={groups:U,rowGroup:_,rowData:W,reduced:q,leftJoinKey:Q,leftByJoinKey:J},f(U,F,q,null)}#T(O,C){if(!this.#l||!O.groupBy||O.unnest||O.where||String(O.follow||"filtered")==="grouped"||G(O.join)&&O.join.with&&!(O.join.index instanceof Map)||!G(C))return null;const S=Array.isArray(C.updated)?C.updated:null,F=Array.isArray(C.added)?C.added:null,P=Array.isArray(C.removed)?C.removed:null;if(!S&&!F&&!P)return null;const M=this.#o;if(M&&M.size&&String(O.follow||"filtered")!=="all"){if(C.edit===!0&&Array.isArray(C.columns)){for(const x of C.columns)if(M.has(String(x)))return null}for(const x of S||[]){const U=x&&x.key,_=U===void 0?void 0:this.#l.rowData.get(String(U)),W=Y(x);for(const q of M)if(g(_,q)!==g(W,q))return null}}return{updated:S||[],added:F||[],removed:P||[]}}#M(O,C){const S=this.#l,F=this.#N(),P=new Set,M=G(C.join)&&C.join.index instanceof Map?C.join:null,x=this.#A(),U=W=>{const q=S.rowGroup.get(W);if(q===void 0)return;P.add(q);const N=S.groups.get(q);if(N&&(N.rows.delete(W),N.rows.size||S.groups.delete(q)),S.rowGroup.delete(W),S.rowData.delete(W),S.leftJoinKey){const Q=S.leftJoinKey.get(W);if(Q!==void 0){const J=S.leftByJoinKey.get(Q);J&&(J.delete(W),J.size||S.leftByJoinKey.delete(Q)),S.leftJoinKey.delete(W)}}},_=W=>{const q=M?r(W,M):W;if(!q)return;const N=F(q),Q=y([q],C,F);for(const[J,ee]of Q.groups){let ne=S.groups.get(J);ne||(ne={values:ee.values,rows:new Map},S.groups.set(J,ne)),ne.rows.set(N,q),S.rowGroup.set(N,J),P.add(J)}if(S.rowData.set(N,q),x&&S.leftByJoinKey){const J=i(q,x.left);if(J!==null){S.leftJoinKey.set(N,J);let ee=S.leftByJoinKey.get(J);ee||(ee=new Set,S.leftByJoinKey.set(J,ee)),ee.add(N)}}};for(const W of O.removed)U(String(W));for(const W of O.updated)U(String(W.key)),_(Y(W));for(const W of O.added)_(Y(W));return P}#N(){const O=this.#e,C=O&&O.config&&O.config.rowKey||"id";return S=>String(g(S,typeof C=="string"?C:"id")??"")}#R(){const O=this.#e,C=O&&O.state&&T(O.state.get)?O.state.get():null,S=new Set,F=P=>{if(P){if(Array.isArray(P.conditions)){P.conditions.forEach(F);return}P.col&&S.add(String(P.col))}};return C&&F(C.filters),S}#I(){let O=this.#t;if(O.join&&O.join.with&&(this.#u||this.#v(),O={...O,join:{...O.join,index:this.#u}}),this.#d||String(O.follow||"filtered")!=="grouped")return O;const C=this.#e,S=C&&C.state&&T(C.state.get)?C.state.get():null,F=S&&Array.isArray(S.group)?S.group:[];return F.length?{...O,groupBy:[...F]}:O}#G(){const O=[];for(const C of this.#d)if(C.grid)try{const S=c.includes(String(C.follow))?String(C.follow):"filtered",F=this.#K(C.grid,S);for(const P of F){const M=C.map?C.map(P):P;G(M)&&O.push({...M,[n]:C.label})}}catch(S){I(`source.derived.union.failed.${C.label}`,`source.mode "derived": union source "${C.label}" failed to read (${S&&S.message?S.message:S}) and was skipped this pass.`)}return O}#K(O,C){if(!O||!O.rows)return[];if(C==="all"){const F=[];return T(O.rows.forEachAll)&&O.rows.forEachAll(P=>{P.group||F.push(Y(P))}),F}if(C==="selected")return(O.selection&&T(O.selection.rows)?O.selection.rows():[]).filter(Boolean).map(Y);const S=[];return T(O.rows.forEach)&&O.rows.forEach(F=>{F.group||S.push(Y(F))}),S}#L(){const O=this.#I(),C=this.#G(),S=A(C,O);return O.groupBy?S:t(S)}#q(){return I("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.'),[]}#U(){const O=this.#e,C=String(this.#t.follow||"filtered");if(!O||!O.rows)return[];if(C==="all"){const P=[];return T(O.rows.forEachAll)&&O.rows.forEachAll(M=>{M.group||P.push(Y(M))}),P}if(C==="selected")return(O.selection&&T(O.selection.rows)?O.selection.rows():[]).filter(Boolean).map(Y);const S=this.#Y(),F=[];return S&&this.#z().length&&T(O.rows.forEachExcept)?(O.rows.forEachExcept(S,P=>{P.group||F.push(Y(P))}),F):(T(O.rows.forEach)&&O.rows.forEach(P=>{P.group||F.push(Y(P))}),F)}#Y(){const O=this.#t.crossFilter;if(!O||this.#d)return null;if(typeof O=="string")return O;if(O.col)return String(O.col);const C=this.#t.groupBy,S=Array.isArray(C)?C[0]:C;return S?String(S):null}#z(){const O=this.#Y(),C=this.#e;if(!O||!C||!C.filters||!T(C.filters.get))return[];const S=K(C.filters.get(),O);return S?S.op==="in"&&Array.isArray(S.value)?S.value.map(String):S.op==="eq"&&S.value!==void 0?[String(S.value)]:[]:[]}#D(O){const C=this.#Y(),S=this.#e;if(!C||!S||!S.filters||!T(S.filters.set))return;const F=this.#s.compute||{},P=T(S.filters.get)?S.filters.get():null,M=T(F.pruneColumn)?F.pruneColumn(P,C):null;if(!O.length){S.filters.set(M||null);return}const x=O.length===1?{col:C,op:"eq",value:O[0]}:{col:C,op:"in",value:O.slice()},U=M?M.conditions&&M.op?M.conditions:[M]:[];S.filters.set(U.length?{op:"and",conditions:[...U,x]}:x)}crossFilter(){const O=this;return{enabled(){return!!O.#Y()},column(){return O.#Y()},get(){return O.#z()},set(C){const S=C==null?[]:(Array.isArray(C)?C:[C]).map(F=>String(F));O.#D(S)},toggle(C){const S=String(C),F=O.#z(),M=F.indexOf(S)>=0?F.filter(x=>x!==S):[...F,S];O.#D(M)},clear(){O.#D([])}}}#V(O){const C=O&&O.rows;if(C&&T(C.matchCount)){const S=C.matchCount(),F=Number(S);if(S!==null&&Number.isFinite(F))return F}if(C&&T(C.count)){const S=Number(C.count());if(Number.isFinite(S))return S}return 0}#ge(){const O=this.#e,C=this.#t.statistics;if(!O||!O.statistics||!G(C))return[];switch(String(C.fn)){case"correlation":return this.#se(O,C);case"series":return this.#ue(O,C);case"datasetVsDataset":return this.#Me(O,C);default:return[]}}#se(O,C){const S=C.columns.filter(Boolean).map(String),F=this.#V(O),P=(M,x)=>{const U=O.statistics.correlation(M,x);return typeof U=="number"&&Number.isFinite(U)?U:null};if(String(C.orient||"pairs")!=="matrix"){const M=[];for(let x=0;x<S.length;x++)for(let U=x+1;U<S.length;U++)M.push({[u]:`${S[x]}${S[U]}`,a:S[x],b:S[U],coefficient:P(S[x],S[U]),n:F});return M}return S.map(M=>{const x={[u]:M,column:M};for(const U of S)x[U]=M===U?1:P(M,U);return x.n=F,x})}#ue(O,C){const S=this.#V(O),F={by:String(C.by)};C.periodsPerYear!==void 0&&(F.periodsPerYear=Number(C.periodsPerYear));const P=O.statistics.series(String(C.of),F)||{};return b.map(M=>({[u]:M,metric:M,value:P[M]??null,n:S}))}#Me(O,C){const S=C.with,F=Array.isArray(C.columns)?{columns:C.columns.map(String)}:void 0,P=O.statistics.datasetVsDataset(S,F);if(!G(P))return[];const x=(Array.isArray(P.ranked)?P.ranked:[]).map(W=>({[u]:String(W.column),column:W.column,measure:W.measure??null,magnitude:W.magnitude??null,distance:W.distance??null,direction:W.direction??null,nA:W.nA??null,nB:W.nB??null,meanA:W.meanA??null,meanB:W.meanB??null,reliable:W.reliable??null,unmatched:""})),U=P.unmatched,_=[["A",U&&U.onlyA],["B",U&&U.onlyB]];for(const[W,q]of _)for(const N of q||[])x.push({[u]:`${W}${N}`,column:N,measure:null,magnitude:null,distance:null,direction:null,nA:null,nB:null,meanA:null,meanB:null,reliable:!1,unmatched:W});return x}#fe(){const O=this.#e;if(!O||!O.statistics||!T(O.statistics.profile))return[];const S=(Array.isArray(this.#t.profile)?this.#t.profile:[this.#t.profile]).filter(Boolean).map(P=>{const M=O.statistics.profile(String(P))||{},x={[u]:String(P)};for(const _ of h)x[_]=_==="column"?String(P):M[_]??null;x.outliers=Array.isArray(M.outliers)?M.outliers.length:M.outliers??null;const U=p({...M,rows:x.rows,outliers:x.outliers,numeric:M.numeric},this.#t.alerts);return x.alerts=U.join(", "),x.alertCount=U.length,x});if(this.#t.orient!=="metrics")return S;const F=S[0];return F?h.filter(P=>P!=="column").map(P=>({[u]:P,metric:P,value:F[P]})):[]}apply(O){const C=["add","update","remove"],S=[];for(const F of C)for(const P of O&&O[F]||[])S.push({operation:F,id:P&&P.id,reason:"derived-read-only"});return S.length&&I("source.derived.readonly","a derived grid is read-only: its rows are computed from another grid. Write to the source grid instead, and the derived one follows."),{added:[],updated:[],removed:[],rejected:S}}destroy(){this.#i=!0,this.#r&&(clearTimeout(this.#r),this.#r=null),this.#Y()&&this.#z().length&&this.#D([]);for(const O of this.#n)try{O()}catch{}this.#n=[],this.#e=null,this.#d=null,super.destroy()}}function v(E){return G(E)&&E.companion===!0}function R(E,O,C,S=new Set){if(O===E)return C;if(S.has(O))return null;S.add(O);let F=null;try{F=T(O.config)?O.config():null}catch{F=null}const P=F&&G(F.source)?F.source:null;if(!P||P.mode!=="derived")return null;const M=P.from;if(Array.isArray(M)){for(let x=0;x<M.length;x++){const U=m(M[x],x);if(!U.grid||!T(U.grid.on))continue;const _=R(E,U.grid,[...C,U.label],S);if(_)return _}return null}return G(M)&&T(M.on)?R(E,M,[...C,"(from)"],S):null}function Y(E){return G(E)&&"data"in E?E.data:E}function K(E,O){if(!E||typeof E!="object")return null;if(Array.isArray(E.conditions)){for(const S of E.conditions){const F=K(S,O);if(F)return F}return null}return E.col===O?E:null}function V(E,O){return new w(E,O)}}),Ue("packages/core/src/source/adapters/odata.js",function(e,B){"use strict";Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return h}});const T=B("packages/core/src/internal/warn.js").warnOnce,D=B("packages/core/src/source/filterwire.js").isGroup,I=Object.freeze(["eq","ne","gt","gte","lt","lte","contains","startsWith","endsWith","blank","notBlank","between","notBetween"]),Z=/^\d{4}-\d{2}-\d{2}$/,z=/^\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/,L=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/;function X(d){const o=d instanceof Date?d:typeof d=="number"&&Number.isFinite(d)?new Date(d):typeof d=="string"&&L.test(d)?new Date(d):null;return o&&!Number.isNaN(o.getTime())?o:null}const $=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/;function A(d,o){throw typeof o=="string"&&$.test(o)?new Error(`odataAdapter: "${o}" needs a zone designator to be used as a ${d} 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(o)}" is not a usable ${d} value`)}function k(d){const o=X(d);return o||A("DateTimeOffset",d),o.toISOString()}function y(d){if(typeof d=="string"&&Z.test(d))return d;const o=X(d);return o||A("Date",d),o.toISOString().slice(0,10)}function f(d){if(typeof d=="string"&&z.test(d))return d.length===5?`${d}:00`:d;if(typeof d=="number"&&Number.isFinite(d)&&d>=0&&d<864e5){const o=Math.floor(d),b=l=>String(l).padStart(2,"0");return`${b(Math.floor(o/36e5))}:${b(Math.floor(o%36e5/6e4))}:${b(Math.floor(o%6e4/1e3))}`}throw new Error(`odataAdapter: "${String(d)}" is not a usable TimeOfDay value`)}const g=Object.freeze({timestamp:k,datetime:k,date:y,dateString:y,time:f}),a=200,r=1e3,i=Object.freeze({eq:"eq",ne:"ne",gt:"gt",gte:"ge",lt:"lt",lte:"le"});function c(d,o){if(d==null)return"null";const b=o&&g[String(o)];return b?b(d):typeof d=="number"||typeof d=="boolean"?String(d):d instanceof Date?d.toISOString():`'${String(d).replace(/'/g,"''")}'`}function u(d){const o=String(d),b=/^[A-Za-z_][A-Za-z0-9_]*$/;if(!o||!o.split("/").every(l=>b.test(l)))throw new Error(`odataAdapter: "${o}" is not a usable column name`);return o}const n=Object.freeze({lo:{incl:"ge",excl:"gt"},hi:{incl:"le",excl:"lt"}});function m(d){const o=u(d.col),b=String(d.op),l=d.type;if(i[b])return`${o} ${i[b]} ${c(d.value,l)}`;if(b==="contains")return`contains(${o},${c(d.value,l)})`;if(b==="startsWith")return`startswith(${o},${c(d.value,l)})`;if(b==="endsWith")return`endswith(${o},${c(d.value,l)})`;if(b==="blank")return`(${o} eq null)`;if(b==="notBlank")return`(${o} ne null)`;if(b==="between"||b==="notBetween"){const p=Array.isArray(d.value)?d.value:[d.value,d.value],w=String(d.bounds||"[]"),v=w.charAt(0)==="("?n.lo.excl:n.lo.incl,R=w.charAt(1)===")"?n.hi.excl:n.hi.incl,Y=`(${o} ${v} ${c(p[0],l)} and ${o} ${R} ${c(p[1],l)})`;return b==="between"?Y:`(${o} eq null or not ${Y})`}return null}function t(d){const o=String(d&&d.op);throw T(`source.odata.filter.refuse.${o}`,`a "${o}" 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 "${o}" filter condition cannot be expressed in OData and was refused`)}function s(d){if(!d)return"";if(!D(d)){const l=m(d);return l===null?t(d):l}const o=String(d.op)==="or"?" or ":" and ",b=(d.conditions||[]).map(l=>{if(D(l))return s(l);const p=m(l);return p===null?t(l):p}).filter(Boolean);return b.length?b.length===1?b[0]:`(${b.join(o)})`:""}function h(d={}){const o=String(d.url||""),b=d.fetch||(typeof fetch=="function"?fetch:null),l=d.count!==!1,p=u(d.key||"id"),w=d.edit===!0;return{name:"odata",capabilities:{filter:"tree",operators:I,sort:"multi",quick:d.search===!0,range:!0,total:l,mutate:w?{update:!0,delete:!0,append:!0,returning:"row"}:!1},urlFor(v){const R=[],Y=(V,E)=>R.push(`${V}=${encodeURIComponent(E)}`),K=s(v.filters);return K&&Y("$filter",K),v.sort&&v.sort.length&&Y("$orderby",v.sort.map(V=>`${u(V.col)}${V.dir==="desc"?" desc":" asc"}`).join(",")),v.range&&(Y("$skip",String(v.range.start)),Y("$top",String(v.range.end-v.range.start))),v.quick&&Y("$search",`"${String(v.quick).replace(/"/g,"")}"`),l&&Y("$count","true"),R.length?`${o}?${R.join("&")}`:o},async execute(v,R){if(!b)throw new Error("odataAdapter needs a fetch implementation");const Y={Accept:"application/json",...d.headers||{}},K=R&&R.signal,V=async S=>{const F=await b(S,{headers:Y,signal:K});if(!F.ok)throw new Error(`OData request failed: ${F.status}`);return F.json()};let E=await V(this.urlFor(v)),O=E.value||E.rows||[];const C=E["@odata.count"]??E.count;if(!v.range){let S=E["@odata.nextLink"];for(;S&&O.length<a*r;)E=await V(S),O=O.concat(E.value||E.rows||[]),S=E["@odata.nextLink"]}return C==null?(l&&T("source.odata.nocount",`${o} 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(C)}},urlForKey(v){return`${o}(${c(v)})`},async mutate(v,R){if(!b)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 Y={Accept:"application/json","Content-Type":"application/json",...d.headers||{}},K=R&&R.signal;if(v.kind==="delete"){const S=Array.isArray(v.keys)&&v.keys.length?v.keys[0]:v.key;if(S==null)throw new Error("odataAdapter: a delete needs a row key");const F=await b(this.urlForKey(S),{method:"DELETE",headers:Y,signal:K});if(!F.ok)throw new Error(`OData delete failed: ${F.status}`);return{ok:!0}}if(v.kind==="append"){const S=Array.isArray(v.rows)?v.rows.filter(U=>U&&typeof U=="object"):[];if(S.length!==1)throw new Error("odataAdapter: an append needs exactly one row object (OData creates one entity per POST)");const F=await b(o,{method:"POST",headers:Y,signal:K,body:JSON.stringify(S[0])});if(!F.ok)throw new Error(`OData add-row failed: ${F.status}`);const P=F.status===204?null:await F.json().catch(()=>null),M=P&&typeof P=="object"&&"value"in P?P.value:P;if(!M||typeof M!="object")throw new Error("odataAdapter: the POST returned no created entity to rekey the appended row by. Have the service return the created entity (Prefer: return=representation).");const x=M[p];if(x==null)throw new Error(`odataAdapter: the created entity carried no ${p} to rekey the appended row by.`);return{ok:!0,keys:[String(x)],rows:[M]}}const V=this.urlForKey(v.key),E=await b(V,{method:"PATCH",headers:Y,signal:K,body:JSON.stringify(v.patch||{})});if(!E.ok)throw new Error(`OData update failed: ${E.status}`);if(E.status===204)return{ok:!0};const O=await E.json(),C=O&&typeof O=="object"&&"value"in O?O.value:O;return C==null?{ok:!0}:{ok:!0,rows:[C]}}}}}),Ue("packages/core/src/source/adapters/rest.js",function(e,B){"use strict";Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"DEFAULT_VERBS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return G}});const re=Object.freeze({offset:"offset",limit:"limit",sort:"sort",order:"order",filter:"filter",search:"q"}),T=Object.freeze({update:"PATCH",delete:"DELETE",append:"POST"});function G(D={}){const I=String(D.url||""),Z=D.fetch||(typeof fetch=="function"?fetch:null),z={...re,...D.params||{}},L=D.encodeFilter||(r=>JSON.stringify(r)),X=D.rows||(r=>Array.isArray(r)?r:r.rows||r.data||[]),$=D.total||((r,i)=>Array.isArray(r)?i.length:r.total??r.count??i.length),A=D.edit===!0,k=D.returning==="row"?"row":D.returning==="key"?"key":"none",y=D.keyField||"id",f=D.writeUrlFor||(r=>`${I}/${encodeURIComponent(String(r.key??(r.keys&&r.keys[0])))}`),g=D.encodeMutation||(r=>{const i=T[r.kind];if(r.kind==="update")return{method:i,url:f(r),headers:{"Content-Type":"application/json"},body:JSON.stringify(r.patch||{})};if(r.kind==="append"){const c=Array.isArray(r.rows)?r.rows:r.rows?[r.rows]:[];return{method:i,url:I,headers:{"Content-Type":"application/json"},body:JSON.stringify(c.length===1?c[0]:c)}}return{method:i,url:f(r)}}),a=D.writeRow||(r=>{if(r===null||typeof r!="object")return null;if(Array.isArray(r))return r.length?r[0]:null;const i=r;return i.row??i.data??r});return{name:"rest",capabilities:{range:!0,total:!0,sort:"multi",filter:!1,quick:!1,mutate:A?{update:!0,delete:!0,append:!0,returning:k}:!1,...D.capabilities||{},...D.operators?{filter:"tree",operators:D.operators}:{}},urlFor(r){const i=new URLSearchParams;r.range&&(i.set(z.offset,String(r.range.start)),i.set(z.limit,String(r.range.end-r.range.start))),r.sort&&r.sort.length&&(i.set(z.sort,r.sort.map(u=>u.col).join(",")),i.set(z.order,r.sort.map(u=>u.dir||"asc").join(","))),r.filters&&i.set(z.filter,L(r.filters)),r.quick&&i.set(z.search,String(r.quick));const c=i.toString();return c?`${I}?${c}`:I},async execute(r,i){if(!Z)throw new Error("restAdapter needs a fetch implementation");const c=await Z(this.urlFor(r),{headers:{Accept:"application/json",...D.headers||{}},signal:i&&i.signal});if(!c.ok)throw new Error(`request failed: ${c.status}`);const u=await c.json(),n=X(u);return{rows:n,total:$(u,n)}},writeUrlFor(r){return f(r)},encodeMutation(r){return g(r)},async mutate(r,i){if(!Z)throw new Error("restAdapter needs a fetch implementation");if(!r||r.kind!=="update"&&r.kind!=="delete"&&r.kind!=="append")throw new Error(`restAdapter: mutation kind "${r&&r.kind}" is not supported (update, delete and append are wired)`);const c=g(r);if(!c||!c.url||!c.method)throw new Error("restAdapter: encodeMutation must return { method, url }");const u={Accept:"application/json",...D.headers||{},...c.headers||{}},n=await Z(c.url,{method:c.method,headers:u,signal:i&&i.signal,...c.body!==void 0?{body:c.body}:{}});if(!n.ok)throw new Error(`REST ${r.kind} failed: ${n.status}`);if(r.kind==="append"){if(k==="none")return{ok:!0};if(n.status===204)throw new Error("restAdapter: the add-row POST returned 204 with no body, so the appended row has no server key to rekey by. Declare returning: 'row'/'key' and have the endpoint return the created row.");const s=await n.json(),h=a(s),d=h&&typeof h=="object"?h[y]:void 0;if(d==null)throw new Error(`restAdapter: the add-row response carried no ${y} 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(d)],rows:[h]}:{ok:!0,keys:[String(d)]}}if(k!=="row"||n.status===204)return{ok:!0};const m=await n.json(),t=a(m);return t==null?{ok:!0}:{ok:!0,rows:[t]}}}}}),Ue("packages/core/src/source/adapters/dfql.js",function(e,B){"use strict";Object.defineProperty(e,"DFQL_BASE",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"DFQL_WRITE_URL",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return A}});const T=B("packages/core/src/internal/predicates.js").isFunction,D=B("packages/core/src/internal/warn.js").warnOnce,I="https://rest.demandflow.com",Z="https://stream.demandflow.com/dfql",z=Object.freeze(["id","created","updated","ownerId","entity"]);function L(k){const y={},f=[];for(const[g,a]of Object.entries(k||{})){if(z.includes(g)){f.push(g);continue}y[g]=a}return f.length&&D("source.dfql.protected",`a DFQL update tried to write protected field(s) ${f.join(", ")}; they are server-assigned and immutable, so they were dropped from the PATCH.`),y}function X(k){if(!k||typeof k!="object"||Array.isArray(k))return["fields (must be an object)"];const y=k,f=[];return(typeof y.entity!="string"||!y.entity)&&f.push("entity (uppercase code)"),Number.isFinite(Number(y.level))||f.push("level (numeric)"),(typeof y.comboKey!="string"||!y.comboKey.endsWith("|ENT:"))&&f.push("comboKey (a string ending '|ENT:')"),f}async function $(k){const y=[],f=i=>{const c=i.trim();if(c)try{y.push(JSON.parse(c))}catch{}};if(!k.body||typeof k.body.getReader!="function")return(await k.text()).split(`
|