@toclocoinc/lattice-grid 1.86.4 → 1.86.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -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/deckgl.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/mapview.html +1 -1
- package/docs/api/mock-socket.html +1 -1
- package/docs/api/presets.html +1 -1
- package/docs/api/tabs.html +1 -1
- package/docs/api/types.html +1 -1
- package/docs/api-detail.html +4 -4
- package/docs/warnings.json +1 -1
- package/lattice-grid.d.ts +1 -1
- package/lattice-grid.esm.min.js +3 -3
- package/lattice-grid.min.cjs +3 -3
- package/lattice-grid.min.css +1 -1
- package/lattice-grid.min.js +3 -3
- package/modules/ai.d.ts +1 -1
- package/modules/ai.esm.min.js +2 -2
- package/modules/ai.min.cjs +2 -2
- package/modules/ai.min.js +2 -2
- package/modules/alarms.d.ts +1 -1
- package/modules/alarms.esm.min.js +2 -2
- package/modules/alarms.min.cjs +2 -2
- package/modules/alarms.min.js +2 -2
- package/modules/angular.d.ts +1 -1
- package/modules/angular.esm.min.js +2 -2
- package/modules/angular.min.cjs +2 -2
- package/modules/angular.min.js +2 -2
- package/modules/calendar.d.ts +1 -1
- package/modules/calendar.esm.min.js +2 -2
- package/modules/calendar.min.cjs +2 -2
- package/modules/calendar.min.js +2 -2
- 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 +2 -2
- package/modules/chart-forcetree.esm.min.js.map +2 -2
- package/modules/chart-forcetree.min.cjs +2 -2
- package/modules/chart-forcetree.min.js +2 -2
- package/modules/chart-forcetree.min.js.map +2 -2
- package/modules/chart-hexbin.d.ts +1 -1
- package/modules/chart-hexbin.esm.min.js +2 -2
- package/modules/chart-hexbin.esm.min.js.map +1 -1
- package/modules/chart-hexbin.min.cjs +2 -2
- package/modules/chart-hexbin.min.js +2 -2
- package/modules/chart-hexbin.min.js.map +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-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 +2 -2
- package/modules/chart-tree.esm.min.js.map +2 -2
- package/modules/chart-tree.min.cjs +2 -2
- package/modules/chart-tree.min.js +2 -2
- package/modules/chart-tree.min.js.map +2 -2
- 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 +235 -235
- package/modules/charts.esm.min.js.map +2 -2
- package/modules/charts.min.cjs +235 -235
- package/modules/charts.min.js +235 -235
- package/modules/charts.min.js.map +2 -2
- package/modules/dashboard.d.ts +1 -1
- package/modules/dashboard.esm.min.js +2 -2
- package/modules/dashboard.min.cjs +2 -2
- package/modules/dashboard.min.js +2 -2
- package/modules/data-router.d.ts +1 -1
- package/modules/data-router.esm.min.js +2 -2
- package/modules/data-router.min.cjs +2 -2
- package/modules/data-router.min.js +2 -2
- package/modules/deckgl.d.ts +1 -1
- package/modules/deckgl.esm.min.js +2 -2
- package/modules/deckgl.min.cjs +2 -2
- package/modules/deckgl.min.js +2 -2
- 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 +2 -2
- package/modules/dhtmlx-compat.min.cjs +2 -2
- package/modules/dhtmlx-compat.min.js +2 -2
- package/modules/gantt.d.ts +1 -1
- package/modules/gantt.esm.min.js +2 -2
- package/modules/gantt.min.cjs +2 -2
- package/modules/gantt.min.js +2 -2
- 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 +2 -2
- package/modules/geometry.min.cjs +2 -2
- package/modules/geometry.min.js +2 -2
- package/modules/htmx.d.ts +1 -1
- package/modules/htmx.esm.min.js +3 -3
- package/modules/htmx.min.cjs +3 -3
- package/modules/htmx.min.js +3 -3
- package/modules/kanban.d.ts +1 -1
- package/modules/kanban.esm.min.js +2 -2
- package/modules/kanban.min.cjs +2 -2
- package/modules/kanban.min.js +2 -2
- package/modules/kpi.d.ts +1 -1
- package/modules/kpi.esm.min.js +2 -2
- package/modules/kpi.min.cjs +2 -2
- package/modules/kpi.min.js +2 -2
- package/modules/layout.d.ts +1 -1
- package/modules/layout.esm.min.js +2 -2
- package/modules/layout.min.cjs +2 -2
- package/modules/layout.min.js +2 -2
- package/modules/leaflet.d.ts +1 -1
- package/modules/leaflet.esm.min.js +2 -2
- package/modules/leaflet.min.cjs +2 -2
- package/modules/leaflet.min.js +2 -2
- package/modules/list.d.ts +1 -1
- package/modules/list.esm.min.js +2 -2
- package/modules/list.min.cjs +2 -2
- package/modules/list.min.js +2 -2
- package/modules/mapview.d.ts +1 -1
- package/modules/mapview.esm.min.js +2 -2
- package/modules/mapview.min.cjs +2 -2
- package/modules/mapview.min.js +2 -2
- 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 +2 -2
- package/modules/presets.min.cjs +2 -2
- package/modules/presets.min.js +2 -2
- package/modules/react.d.ts +1 -1
- package/modules/react.esm.min.js +2 -2
- package/modules/react.min.cjs +2 -2
- package/modules/react.min.js +2 -2
- package/modules/svelte.d.ts +1 -1
- package/modules/svelte.esm.min.js +2 -2
- package/modules/svelte.min.cjs +2 -2
- package/modules/svelte.min.js +2 -2
- package/modules/tabs.d.ts +1 -1
- package/modules/tabs.esm.min.js +2 -2
- package/modules/tabs.min.cjs +2 -2
- package/modules/tabs.min.js +2 -2
- package/modules/vue.d.ts +1 -1
- package/modules/vue.esm.min.js +2 -2
- package/modules/vue.min.cjs +2 -2
- package/modules/vue.min.js +2 -2
- package/modules/webcomponent.d.ts +1 -1
- package/modules/webcomponent.esm.min.js +3 -3
- package/modules/webcomponent.min.cjs +3 -3
- package/modules/webcomponent.min.js +3 -3
- package/package.json +1 -1
package/lattice-grid.esm.min.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Lattice Grid 1.86.
|
|
2
|
+
* Lattice Grid 1.86.5, core + DOM renderer
|
|
3
3
|
* Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
|
|
4
4
|
* https://latticegrid.dev
|
|
5
5
|
*/
|
|
6
|
-
var dr=Object.create(null),hr=Object.create(null);function Fe(e,K){dr[e]=K}function Kn(e){var K=hr[e];if(K)return K;var Q=Object.create(null);hr[e]=Q;var $=dr[e];if(!$)throw new Error("[lattice] missing module: "+e);return $(Q,Kn),Q}Fe("packages/core/src/internal/util.js",function(e,K){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return ne}});const Q="1.86.4";async function $(){return Q}const B="1.86.4",I=new Set,_=2e3;function X(ie){if(I.add(ie),I.size>_){const se=I.values().next().value;se!==void 0&&I.delete(se)}}const W=[],H=500;function V(ie,se,he){W.push({key:ie,level:se,message:he.map(ce=>typeof ce=="string"?ce:z(ce)).join(" "),at:Date.now()}),W.length>H&&W.shift()}function z(ie){if(ie instanceof Error)return ie.message;try{return JSON.stringify(ie)}catch{return String(ie)}}function w(){return W.map(ie=>({...ie}))}function A(ie){if(ie.length===0||typeof ie[0]!="string")return ie;const se=ie[0].replace(/^\[lattice\]\s*/,"");return se===ie[0]?ie:[se,...ie.slice(1)]}function g(ie,...se){if(I.has(ie))return;X(ie);const he=A(se);V(ie,"warn",he),console.warn("[lattice]",...he)}function l(ie,...se){if(I.has(ie))return;X(ie);const he=A(se);V(ie,"info",he),console.info("[lattice]",...he)}function d(){I.clear(),W.length=0}function o(ie,se){const he=new Error(`[lattice] ${ie}`);throw se!==void 0&&(he.cause=se),he}function n(ie,se){ie||o(se)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function r(ie){return ie!==null&&typeof ie=="object"&&!Array.isArray(ie)}function s(ie){return typeof ie=="function"}function h(ie){return ie==null}function u(ie){return ie==null||ie===""}function i(ie){return typeof ie!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(ie))?!0:!!(ie.prototype&&Object.getOwnPropertyNames(ie.prototype).length>1)}const m=new Map;function c(ie){let se=m.get(ie);if(se)return se;if(!ie.includes("."))se=he=>he?.[ie];else{const he=ie.split("."),ce=he.length;se=te=>{let oe=te;for(let fe=0;fe<ce;fe++){if(oe==null)return;oe=oe[he[fe]]}return oe}}return m.set(ie,se),se}const f=new Map;function a(ie){let se=f.get(ie);if(se)return se;if(!ie.includes("."))se=(he,ce)=>{he!=null&&(he[ie]=ce)};else{const he=ie.split("."),ce=he.length-1;se=(te,oe)=>{let fe=te;for(let de=0;de<ce;de++){if(fe==null)return;const ve=he[de];fe[ve]==null&&(fe[ve]={}),fe=fe[ve]}fe!=null&&(fe[he[ce]]=oe)}}return f.set(ie,se),se}function p(ie,se){return c(se)(ie)}function b(ie,se,he){a(se)(ie,he)}function O(ie){return ie?(ie.includes(".")?ie.slice(ie.lastIndexOf(".")+1):ie).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(/^./,he=>he.toUpperCase()):""}const k={"&":"&","<":"<",">":">",'"':""","'":"'"};function y(ie){const se=ie==null?"":String(ie);return/[&<>"']/.test(se)?se.replace(/[&<>"']/g,he=>k[he]):se}function v(ie){return String(ie).replace(/\w\S*/g,se=>se[0].toUpperCase()+se.slice(1).toLowerCase())}function R(ie,se,he){if(ie!==void 0)return ie===!0?{enabled:!0,...he}:ie===!1?{enabled:!1}:r(ie)?ie:{[se]:ie,enabled:!0}}function S(ie){return ie==null?[]:Array.isArray(ie)?ie:[ie]}const x=Object.freeze(new Set(["__proto__","constructor","prototype"]));function C(ie,se){if(!r(ie))return r(se)?{...se}:se;if(!r(se))return se===void 0?ie:se;const he={...ie};for(const ce of Object.keys(se)){if(x.has(ce))continue;const te=se[ce];te!==void 0&&(he[ce]=r(te)&&r(he[ce])?C(he[ce],te):te)}return he}function P(ie,se){if(!r(ie)||!r(se)||ie===se)return se;const he=Object.create(Object.getPrototypeOf(ie));return Object.assign(he,ie,se),he}class F{#e;#t=new Map;#n;constructor(se=256,he=null){this.#e=se,this.#n=he}get size(){return this.#t.size}get max(){return this.#e}set max(se){this.#e=se,this.#r()}has(se){return this.#t.has(se)}get(se){const he=this.#t;if(!he.has(se))return;const ce=he.get(se);return he.delete(se),he.set(se,ce),ce}peek(se){return this.#t.get(se)}set(se,he){const ce=this.#t;return ce.has(se)&&ce.delete(se),ce.set(se,he),this.#r(),he}delete(se){const he=this.#t.get(se);return this.#t.delete(se)&&this.#n&&this.#n(he,se),he}clear(){if(this.#n)for(const[se,he]of this.#t)this.#n(he,se);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const se=this.#t;for(;se.size>this.#e;){const he=se.keys().next().value,ce=se.get(he);se.delete(he),this.#n&&this.#n(ce,he)}}}const E=new Map;function D(ie,se){const he=`${ie||""}|${se?JSON.stringify(se):""}`;let ce=E.get(he);return ce||(ce=new Intl.Collator(ie||void 0,{numeric:!0,sensitivity:"variant",...se}),E.set(he,ce)),ce}function N(ie,se){if(ie===se)return 0;if(ie==null)return 1;if(se==null)return-1;if(typeof ie=="number"&&typeof se=="number")return Number.isNaN(ie)?Number.isNaN(se)?0:1:Number.isNaN(se)||ie<se?-1:ie>se?1:0;const he=String(ie),ce=String(se);return he<ce?-1:he>ce?1:0}function M(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const j=typeof requestAnimationFrame=="function";function L(ie){return j?requestAnimationFrame(ie):setTimeout(()=>ie(M()),16)}function G(ie){ie!=null&&(j?cancelAnimationFrame(ie):clearTimeout(ie))}function q(ie){let se=null,he=null;const ce=()=>{se=null;const oe=he;he=null,ie(...oe||[])},te=(...oe)=>{he=oe,se===null&&(se=L(ce))};return te.cancel=()=>{G(se),se=null,he=null},te.flush=()=>{se!==null&&(G(se),ce())},te}function Y(ie,se){let he=null,ce=null;const te=()=>{if(he=null,ce===null)return;const de=ce;ce=null,ie(...de),oe()},oe=()=>{he=setTimeout(te,se),typeof he?.unref=="function"&&he.unref()},fe=(...de)=>{he===null?(ie(...de),oe()):(ce=de,clearTimeout(he),oe())};return fe.flush=()=>{if(he!==null&&clearTimeout(he),he=null,ce===null)return;const de=ce;ce=null,ie(...de)},fe.cancel=()=>{he!==null&&clearTimeout(he),he=null,ce=null},fe.pending=()=>he!==null||ce!==null,fe}function J(ie,se=50){return typeof requestIdleCallback=="function"?requestIdleCallback(ie,{timeout:se}):setTimeout(()=>ie({timeRemaining:()=>0,didTimeout:!0}),1)}let ee=0;function ne(ie="l"){return`${ie}${(++ee).toString(36)}`}}),Fe("packages/core/src/formatting/rules.js",function(e,K){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return v}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,I=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),_=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),X=Object.freeze({topPercent:"In the top %",bottomPercent:"In the bottom %",topN:"In the top N",bottomN:"In the bottom N",aboveMean:"Above average",belowMean:"Below average",aboveMedian:"Above the median",belowMedian:"Below the median",zAbove:"Standard deviations above the mean",zBelow:"Standard deviations below the mean",outlier:"An outlier"});function W(R,S){const x=Number(R),C=Number(S);if(R!==null&&R!==""&&S!==null&&S!==""&&Number.isFinite(x)&&Number.isFinite(C))return x<C?-1:x>C?1:0;const F=String(R??"").toLowerCase(),E=String(S??"").toLowerCase();return F<E?-1:F>E?1:0}function H(R){return R==null||R===""}function V(R,S){if(!S||typeof S!="object")return!1;const{op:x}=S,C=S.value,P=S.value2;switch(x){case"blank":return H(R);case"notBlank":return!H(R);case"true":return R===!0;case"false":return R===!1;default:break}if(H(R))return!1;switch(x){case"eq":return W(R,C)===0;case"ne":return W(R,C)!==0;case"gt":return W(R,C)>0;case"gte":return W(R,C)>=0;case"lt":return W(R,C)<0;case"lte":return W(R,C)<=0;case"between":return W(R,C)>=0&&W(R,P)<=0;case"outside":return W(R,C)<0||W(R,P)>0;case"contains":return String(R).toLowerCase().includes(String(C??"").toLowerCase());case"notContains":return!String(R).toLowerCase().includes(String(C??"").toLowerCase());case"startsWith":return String(R).toLowerCase().startsWith(String(C??"").toLowerCase());case"endsWith":return String(R).toLowerCase().endsWith(String(C??"").toLowerCase());default:return!1}}function z(R,S,x){const C=G=>{const q=String(G).replace("#",""),Y=q.length===3?q.split("").map(J=>J+J).join(""):q;return[0,2,4].map(J=>parseInt(Y.slice(J,J+2),16)||0)},[P,F,E]=C(R),[D,N,M]=C(S),j=Math.max(0,Math.min(1,x)),L=(G,q)=>Math.round(G+(q-G)*j);return`#${[L(P,D),L(F,N),L(E,M)].map(G=>G.toString(16).padStart(2,"0")).join("")}`}function w(R){const S=[];for(const D of R||[]){if(D==null||D==="")continue;const N=D instanceof Date?D.getTime():Number(D);Number.isFinite(N)&&S.push(N)}if(!S.length)return null;S.sort((D,N)=>D-N);let x=0,C=0,P=0;for(const D of S){x++;const N=D-C;C+=N/x,P+=N*(D-C)}const F=A(S,.25),E=A(S,.75);return{n:S.length,min:S[0],max:S[S.length-1],mean:C,stddev:S.length>1?Math.sqrt(P/(S.length-1)):0,median:A(S,.5),q1:F,q3:E,iqr:E-F,sorted:S}}function A(R,S){if(!R.length)return 0;const x=(R.length-1)*Math.max(0,Math.min(1,S)),C=Math.floor(x),P=Math.ceil(x);return C===P?R[C]:R[C]+(x-C)*(R[P]-R[C])}function g(R){for(const S of Array.isArray(R)?R:[])if(!(!S||typeof S!="object")&&(S.when&&_.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 l(R,S){const x=Number(R.value),C=P=>A(S.sorted,P);switch(R.op){case"topPercent":{const P=d(x,10);return{op:"gte",value:C(1-P)}}case"bottomPercent":{const P=d(x,10);return{op:"lte",value:C(P)}}case"topN":{const P=Math.max(1,Math.floor(x)||1),F=Math.max(0,S.sorted.length-P);return{op:"gte",value:S.sorted[F]}}case"bottomN":{const P=Math.max(1,Math.floor(x)||1),F=Math.min(S.sorted.length-1,P-1);return{op:"lte",value:S.sorted[F]}}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(x)?x:2)*S.stddev}:null;case"zBelow":return S.stddev?{op:"lte",value:S.mean-(Number.isFinite(x)?x:2)*S.stddev}:null;case"outlier":{const P=(Number.isFinite(x)&&x>0?x:1.5)*S.iqr;return S.iqr?{op:"outside",value:S.q1-P,value2:S.q3+P}:null}default:return null}}function d(R,S){const x=Number.isFinite(R)?R:S,C=x>1?x/100:x;return Math.max(0,Math.min(1,C))}function o(R,S){if(R.from==="minmax")return{...R,min:S.min,max:S.max};if(R.from==="quantile")return{...R,min:A(S.sorted,d(Number(R.low),5)),max:A(S.sorted,d(Number(R.high),95))};if(R.from==="stddev"){const x=Number.isFinite(Number(R.deviations))?Number(R.deviations):2;return{...R,min:S.mean-x*S.stddev,max:S.mean+x*S.stddev}}return R}function n(R,S){const x=Array.isArray(R)?R:[];return!S||!S.n?x.map(C=>C&&g([C])?{...C,enabled:!1}:C):x.map(C=>{if(!C||typeof C!="object")return C;if(C.scale&&C.scale.from)return{...C,scale:o(C.scale,S)};if(C.dataBar)return{...C,dataBar:t(C.dataBar,S)};if(C.iconSet)return{...C,iconSet:r(C.iconSet,S)};if(!C.when||!_.includes(C.when.op))return C;const P=l(C.when,S);return P?{...C,when:P}:{...C,enabled:!1}})}function t(R,S){const x=Number.isFinite(Number(R.min))?Number(R.min):void 0,C=Number.isFinite(Number(R.max))?Number(R.max):void 0;if(x!==void 0&&C!==void 0)return{...R,min:x,max:C};if(R.from==="quantile")return{...R,min:x??A(S.sorted,d(Number(R.low),5)),max:C??A(S.sorted,d(Number(R.high),95))};if(R.from==="stddev"){const P=Number.isFinite(Number(R.deviations))?Number(R.deviations):2;return{...R,min:x??S.mean-P*S.stddev,max:C??S.mean+P*S.stddev}}return{...R,min:x??S.min,max:C??S.max}}function r(R,S){if(Array.isArray(R.thresholds))return R;const x=s(R),C=[];for(let P=1;P<x;P++)C.push(A(S.sorted,P/x));return{...R,thresholds:C}}function s(R){if(Array.isArray(R.icons)&&R.icons.length>=2)return R.icons.length;if(Number.isFinite(Number(R.count))&&Number(R.count)>=2)return Math.floor(Number(R.count));const S=a[R.set];return S?S.length:3}function h(R){return`url("data:image/svg+xml,${encodeURIComponent(R)}")`}function u(R){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${R}"/></svg>`}function i(R,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="${R}"/></svg>`}function m(R,S){const x="M8 1l1.9 3.9 4.3.6-3.1 3 .7 4.3L8 13.8 4.2 15.8l.7-4.3-3.1-3 4.3-.6z";let C=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${S*16} 16">`;for(let P=0;P<S;P++){const F=P<R?"#f5a623":"#d0d0d0";C+=`<path transform="translate(${P*16},0)" d="${x}" fill="${F}"/>`}return`${C}</svg>`}const c=Object.freeze([i("#c0392b","down"),i("#e0a800","right"),i("#2e7d32","up")]),f=Object.freeze([u("#d13438"),u("#f5a623"),u("#2e9e44")]),a=Object.freeze({arrows:c,trafficLights:f,ratings:Object.freeze([1,2,3,4,5].map(R=>m(R,5)))}),p=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function b(R){if(Array.isArray(R.icons)&&R.icons.length>=2)return R.icons.map(C=>/^\s*(url\(|data:|<)/.test(String(C))&&String(C).trim().startsWith("<")?h(String(C)):String(C));const S=R.set||"arrows";if(S==="ratings"){const C=s(R),P=[];for(let F=1;F<=C;F++)P.push(h(m(F,C)));return P}const x=a[S];return x?x.map(h):(B(`iconSet:${S}`,`unknown icon set '${S}'; falling back to arrows.`),c.map(h))}function O(R){const S=Number(R.min),C=Number(R.max)-S,P=R.colour||R.color||"#5b9bd5",F=R.negativeColour||R.negativeColor||"#d13438",E=R.direction==="rtl"?"left":"right",D=M=>Math.max(0,Math.min(1,(M-S)/C))*100,N=C?Math.max(0,Math.min(100,(0-S)/C*100)):0;return M=>{if(H(M))return null;const j=Number(M);if(!Number.isFinite(j)||!C)return null;const L=D(j),G=Math.min(L,N),q=Math.max(L,N),Y=j>=0?P:F;return{backgroundImage:`linear-gradient(to ${E}, transparent ${G}%, ${Y} ${G}%, ${Y} ${q}%, transparent ${q}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function k(R){const S=b(R),x=R.reverse?[...S].reverse():S,C=(Array.isArray(R.thresholds)?R.thresholds:[]).map(Number).filter(Number.isFinite),P=Number.isFinite(Number(R.size))?Number(R.size):16,F=R.set==="ratings"?P*s(R):P;return E=>{if(H(E))return null;const D=Number(E);if(!Number.isFinite(D))return null;let N=0;for(const j of C)D>=j&&N++;const M=x[Math.min(N,x.length-1)];return M?{backgroundImage:M,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${F}px ${P}px`,paddingLeft:`${F+4}px`}:null}}function y(R){const S=Array.isArray(R.colours)&&R.colours.length>=2?R.colours:["#f8f9fa","#1a6bc7"],x=Number(R.min),C=Number(R.max),P=C-x,F=S.length-1,E=[];for(let N=0;N<=F;N++)E.push(F?N/F:0);const D=Number(R.mid);if(R.mid!==void 0&&R.mid!==null)if(S.length%2===0)B("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${S.length} were given, so "mid" was ignored.`);else if(Number.isFinite(D)&&P&&D>Math.min(x,C)&&D<Math.max(x,C)){const N=F/2,M=Math.max(0,Math.min(1,(D-x)/P));for(let j=0;j<=F;j++)E[j]=j<=N?N?j/N*M:M:M+(j-N)/(F-N)*(1-M)}else Number.isFinite(D)&&B("formatting.scale.mid.range",`a scale's "mid" (${D}) is outside its min..max range, so it was ignored.`);return N=>{const M=Number(N);if(!Number.isFinite(M)||!P)return null;const j=Math.max(0,Math.min(1,(M-x)/P));let L=0;for(;L<F-1&&j>E[L+1];)L++;const G=E[L+1]-E[L],q=G>0?(j-E[L])/G:0;return{background:z(S[L],S[L+1],Math.max(0,Math.min(1,q)))}}}function v(R,S=null){const x=g(R)?n(R,S):R,C=(Array.isArray(x)?x:[]).filter(F=>F&&typeof F=="object");if(!C.length)return()=>null;const P=C.map(F=>F.scale?{scale:y(F.scale),enabled:F.enabled!==!1}:F.dataBar?{scale:O(F.dataBar),enabled:F.enabled!==!1}:F.iconSet?{scale:k(F.iconSet),enabled:F.enabled!==!1}:{when:F.when,style:F.style,stop:F.stopIfTrue!==!1,enabled:F.enabled!==!1});return F=>{const E=F?F.value:void 0;let D=null;for(const N of P){if(!N.enabled)continue;if(N.scale){const j=N.scale(E);j&&(D={...D||{},...j});continue}if(!V(E,N.when))continue;const M=$(N.style)?N.style(F):N.style;if(M&&(D={...D||{},...M}),N.stop)break}return D}}}),Fe("packages/core/src/formula/parse.js",function(e,K){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return t}});const Q="num",$="str",B="ref",I="name",_="op",X="end",W=["<=",">=","<>","!="],H="+-*/^%(),<>=";class V extends Error{constructor(s,h){super(s),this.name="FormulaError",this.at=h}}function z(r){const s=[];let h=0;for(;h<r.length;){const u=r[h];if(u===" "||u===" "||u===`
|
|
6
|
+
var dr=Object.create(null),hr=Object.create(null);function Fe(e,K){dr[e]=K}function Kn(e){var K=hr[e];if(K)return K;var Q=Object.create(null);hr[e]=Q;var $=dr[e];if(!$)throw new Error("[lattice] missing module: "+e);return $(Q,Kn),Q}Fe("packages/core/src/internal/util.js",function(e,K){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return ne}});const Q="1.86.5";async function $(){return Q}const B="1.86.5",I=new Set,_=2e3;function X(ie){if(I.add(ie),I.size>_){const se=I.values().next().value;se!==void 0&&I.delete(se)}}const W=[],H=500;function V(ie,se,he){W.push({key:ie,level:se,message:he.map(ce=>typeof ce=="string"?ce:z(ce)).join(" "),at:Date.now()}),W.length>H&&W.shift()}function z(ie){if(ie instanceof Error)return ie.message;try{return JSON.stringify(ie)}catch{return String(ie)}}function w(){return W.map(ie=>({...ie}))}function A(ie){if(ie.length===0||typeof ie[0]!="string")return ie;const se=ie[0].replace(/^\[lattice\]\s*/,"");return se===ie[0]?ie:[se,...ie.slice(1)]}function g(ie,...se){if(I.has(ie))return;X(ie);const he=A(se);V(ie,"warn",he),console.warn("[lattice]",...he)}function l(ie,...se){if(I.has(ie))return;X(ie);const he=A(se);V(ie,"info",he),console.info("[lattice]",...he)}function d(){I.clear(),W.length=0}function o(ie,se){const he=new Error(`[lattice] ${ie}`);throw se!==void 0&&(he.cause=se),he}function n(ie,se){ie||o(se)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function r(ie){return ie!==null&&typeof ie=="object"&&!Array.isArray(ie)}function s(ie){return typeof ie=="function"}function h(ie){return ie==null}function u(ie){return ie==null||ie===""}function i(ie){return typeof ie!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(ie))?!0:!!(ie.prototype&&Object.getOwnPropertyNames(ie.prototype).length>1)}const m=new Map;function c(ie){let se=m.get(ie);if(se)return se;if(!ie.includes("."))se=he=>he?.[ie];else{const he=ie.split("."),ce=he.length;se=te=>{let oe=te;for(let fe=0;fe<ce;fe++){if(oe==null)return;oe=oe[he[fe]]}return oe}}return m.set(ie,se),se}const f=new Map;function a(ie){let se=f.get(ie);if(se)return se;if(!ie.includes("."))se=(he,ce)=>{he!=null&&(he[ie]=ce)};else{const he=ie.split("."),ce=he.length-1;se=(te,oe)=>{let fe=te;for(let de=0;de<ce;de++){if(fe==null)return;const ve=he[de];fe[ve]==null&&(fe[ve]={}),fe=fe[ve]}fe!=null&&(fe[he[ce]]=oe)}}return f.set(ie,se),se}function p(ie,se){return c(se)(ie)}function b(ie,se,he){a(se)(ie,he)}function O(ie){return ie?(ie.includes(".")?ie.slice(ie.lastIndexOf(".")+1):ie).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(/^./,he=>he.toUpperCase()):""}const k={"&":"&","<":"<",">":">",'"':""","'":"'"};function y(ie){const se=ie==null?"":String(ie);return/[&<>"']/.test(se)?se.replace(/[&<>"']/g,he=>k[he]):se}function v(ie){return String(ie).replace(/\w\S*/g,se=>se[0].toUpperCase()+se.slice(1).toLowerCase())}function R(ie,se,he){if(ie!==void 0)return ie===!0?{enabled:!0,...he}:ie===!1?{enabled:!1}:r(ie)?ie:{[se]:ie,enabled:!0}}function S(ie){return ie==null?[]:Array.isArray(ie)?ie:[ie]}const x=Object.freeze(new Set(["__proto__","constructor","prototype"]));function C(ie,se){if(!r(ie))return r(se)?{...se}:se;if(!r(se))return se===void 0?ie:se;const he={...ie};for(const ce of Object.keys(se)){if(x.has(ce))continue;const te=se[ce];te!==void 0&&(he[ce]=r(te)&&r(he[ce])?C(he[ce],te):te)}return he}function P(ie,se){if(!r(ie)||!r(se)||ie===se)return se;const he=Object.create(Object.getPrototypeOf(ie));return Object.assign(he,ie,se),he}class F{#e;#t=new Map;#n;constructor(se=256,he=null){this.#e=se,this.#n=he}get size(){return this.#t.size}get max(){return this.#e}set max(se){this.#e=se,this.#r()}has(se){return this.#t.has(se)}get(se){const he=this.#t;if(!he.has(se))return;const ce=he.get(se);return he.delete(se),he.set(se,ce),ce}peek(se){return this.#t.get(se)}set(se,he){const ce=this.#t;return ce.has(se)&&ce.delete(se),ce.set(se,he),this.#r(),he}delete(se){const he=this.#t.get(se);return this.#t.delete(se)&&this.#n&&this.#n(he,se),he}clear(){if(this.#n)for(const[se,he]of this.#t)this.#n(he,se);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const se=this.#t;for(;se.size>this.#e;){const he=se.keys().next().value,ce=se.get(he);se.delete(he),this.#n&&this.#n(ce,he)}}}const E=new Map;function D(ie,se){const he=`${ie||""}|${se?JSON.stringify(se):""}`;let ce=E.get(he);return ce||(ce=new Intl.Collator(ie||void 0,{numeric:!0,sensitivity:"variant",...se}),E.set(he,ce)),ce}function N(ie,se){if(ie===se)return 0;if(ie==null)return 1;if(se==null)return-1;if(typeof ie=="number"&&typeof se=="number")return Number.isNaN(ie)?Number.isNaN(se)?0:1:Number.isNaN(se)||ie<se?-1:ie>se?1:0;const he=String(ie),ce=String(se);return he<ce?-1:he>ce?1:0}function M(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const j=typeof requestAnimationFrame=="function";function L(ie){return j?requestAnimationFrame(ie):setTimeout(()=>ie(M()),16)}function G(ie){ie!=null&&(j?cancelAnimationFrame(ie):clearTimeout(ie))}function q(ie){let se=null,he=null;const ce=()=>{se=null;const oe=he;he=null,ie(...oe||[])},te=(...oe)=>{he=oe,se===null&&(se=L(ce))};return te.cancel=()=>{G(se),se=null,he=null},te.flush=()=>{se!==null&&(G(se),ce())},te}function Y(ie,se){let he=null,ce=null;const te=()=>{if(he=null,ce===null)return;const de=ce;ce=null,ie(...de),oe()},oe=()=>{he=setTimeout(te,se),typeof he?.unref=="function"&&he.unref()},fe=(...de)=>{he===null?(ie(...de),oe()):(ce=de,clearTimeout(he),oe())};return fe.flush=()=>{if(he!==null&&clearTimeout(he),he=null,ce===null)return;const de=ce;ce=null,ie(...de)},fe.cancel=()=>{he!==null&&clearTimeout(he),he=null,ce=null},fe.pending=()=>he!==null||ce!==null,fe}function J(ie,se=50){return typeof requestIdleCallback=="function"?requestIdleCallback(ie,{timeout:se}):setTimeout(()=>ie({timeRemaining:()=>0,didTimeout:!0}),1)}let ee=0;function ne(ie="l"){return`${ie}${(++ee).toString(36)}`}}),Fe("packages/core/src/formatting/rules.js",function(e,K){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return v}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,I=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),_=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),X=Object.freeze({topPercent:"In the top %",bottomPercent:"In the bottom %",topN:"In the top N",bottomN:"In the bottom N",aboveMean:"Above average",belowMean:"Below average",aboveMedian:"Above the median",belowMedian:"Below the median",zAbove:"Standard deviations above the mean",zBelow:"Standard deviations below the mean",outlier:"An outlier"});function W(R,S){const x=Number(R),C=Number(S);if(R!==null&&R!==""&&S!==null&&S!==""&&Number.isFinite(x)&&Number.isFinite(C))return x<C?-1:x>C?1:0;const F=String(R??"").toLowerCase(),E=String(S??"").toLowerCase();return F<E?-1:F>E?1:0}function H(R){return R==null||R===""}function V(R,S){if(!S||typeof S!="object")return!1;const{op:x}=S,C=S.value,P=S.value2;switch(x){case"blank":return H(R);case"notBlank":return!H(R);case"true":return R===!0;case"false":return R===!1;default:break}if(H(R))return!1;switch(x){case"eq":return W(R,C)===0;case"ne":return W(R,C)!==0;case"gt":return W(R,C)>0;case"gte":return W(R,C)>=0;case"lt":return W(R,C)<0;case"lte":return W(R,C)<=0;case"between":return W(R,C)>=0&&W(R,P)<=0;case"outside":return W(R,C)<0||W(R,P)>0;case"contains":return String(R).toLowerCase().includes(String(C??"").toLowerCase());case"notContains":return!String(R).toLowerCase().includes(String(C??"").toLowerCase());case"startsWith":return String(R).toLowerCase().startsWith(String(C??"").toLowerCase());case"endsWith":return String(R).toLowerCase().endsWith(String(C??"").toLowerCase());default:return!1}}function z(R,S,x){const C=G=>{const q=String(G).replace("#",""),Y=q.length===3?q.split("").map(J=>J+J).join(""):q;return[0,2,4].map(J=>parseInt(Y.slice(J,J+2),16)||0)},[P,F,E]=C(R),[D,N,M]=C(S),j=Math.max(0,Math.min(1,x)),L=(G,q)=>Math.round(G+(q-G)*j);return`#${[L(P,D),L(F,N),L(E,M)].map(G=>G.toString(16).padStart(2,"0")).join("")}`}function w(R){const S=[];for(const D of R||[]){if(D==null||D==="")continue;const N=D instanceof Date?D.getTime():Number(D);Number.isFinite(N)&&S.push(N)}if(!S.length)return null;S.sort((D,N)=>D-N);let x=0,C=0,P=0;for(const D of S){x++;const N=D-C;C+=N/x,P+=N*(D-C)}const F=A(S,.25),E=A(S,.75);return{n:S.length,min:S[0],max:S[S.length-1],mean:C,stddev:S.length>1?Math.sqrt(P/(S.length-1)):0,median:A(S,.5),q1:F,q3:E,iqr:E-F,sorted:S}}function A(R,S){if(!R.length)return 0;const x=(R.length-1)*Math.max(0,Math.min(1,S)),C=Math.floor(x),P=Math.ceil(x);return C===P?R[C]:R[C]+(x-C)*(R[P]-R[C])}function g(R){for(const S of Array.isArray(R)?R:[])if(!(!S||typeof S!="object")&&(S.when&&_.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 l(R,S){const x=Number(R.value),C=P=>A(S.sorted,P);switch(R.op){case"topPercent":{const P=d(x,10);return{op:"gte",value:C(1-P)}}case"bottomPercent":{const P=d(x,10);return{op:"lte",value:C(P)}}case"topN":{const P=Math.max(1,Math.floor(x)||1),F=Math.max(0,S.sorted.length-P);return{op:"gte",value:S.sorted[F]}}case"bottomN":{const P=Math.max(1,Math.floor(x)||1),F=Math.min(S.sorted.length-1,P-1);return{op:"lte",value:S.sorted[F]}}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(x)?x:2)*S.stddev}:null;case"zBelow":return S.stddev?{op:"lte",value:S.mean-(Number.isFinite(x)?x:2)*S.stddev}:null;case"outlier":{const P=(Number.isFinite(x)&&x>0?x:1.5)*S.iqr;return S.iqr?{op:"outside",value:S.q1-P,value2:S.q3+P}:null}default:return null}}function d(R,S){const x=Number.isFinite(R)?R:S,C=x>1?x/100:x;return Math.max(0,Math.min(1,C))}function o(R,S){if(R.from==="minmax")return{...R,min:S.min,max:S.max};if(R.from==="quantile")return{...R,min:A(S.sorted,d(Number(R.low),5)),max:A(S.sorted,d(Number(R.high),95))};if(R.from==="stddev"){const x=Number.isFinite(Number(R.deviations))?Number(R.deviations):2;return{...R,min:S.mean-x*S.stddev,max:S.mean+x*S.stddev}}return R}function n(R,S){const x=Array.isArray(R)?R:[];return!S||!S.n?x.map(C=>C&&g([C])?{...C,enabled:!1}:C):x.map(C=>{if(!C||typeof C!="object")return C;if(C.scale&&C.scale.from)return{...C,scale:o(C.scale,S)};if(C.dataBar)return{...C,dataBar:t(C.dataBar,S)};if(C.iconSet)return{...C,iconSet:r(C.iconSet,S)};if(!C.when||!_.includes(C.when.op))return C;const P=l(C.when,S);return P?{...C,when:P}:{...C,enabled:!1}})}function t(R,S){const x=Number.isFinite(Number(R.min))?Number(R.min):void 0,C=Number.isFinite(Number(R.max))?Number(R.max):void 0;if(x!==void 0&&C!==void 0)return{...R,min:x,max:C};if(R.from==="quantile")return{...R,min:x??A(S.sorted,d(Number(R.low),5)),max:C??A(S.sorted,d(Number(R.high),95))};if(R.from==="stddev"){const P=Number.isFinite(Number(R.deviations))?Number(R.deviations):2;return{...R,min:x??S.mean-P*S.stddev,max:C??S.mean+P*S.stddev}}return{...R,min:x??S.min,max:C??S.max}}function r(R,S){if(Array.isArray(R.thresholds))return R;const x=s(R),C=[];for(let P=1;P<x;P++)C.push(A(S.sorted,P/x));return{...R,thresholds:C}}function s(R){if(Array.isArray(R.icons)&&R.icons.length>=2)return R.icons.length;if(Number.isFinite(Number(R.count))&&Number(R.count)>=2)return Math.floor(Number(R.count));const S=a[R.set];return S?S.length:3}function h(R){return`url("data:image/svg+xml,${encodeURIComponent(R)}")`}function u(R){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${R}"/></svg>`}function i(R,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="${R}"/></svg>`}function m(R,S){const x="M8 1l1.9 3.9 4.3.6-3.1 3 .7 4.3L8 13.8 4.2 15.8l.7-4.3-3.1-3 4.3-.6z";let C=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${S*16} 16">`;for(let P=0;P<S;P++){const F=P<R?"#f5a623":"#d0d0d0";C+=`<path transform="translate(${P*16},0)" d="${x}" fill="${F}"/>`}return`${C}</svg>`}const c=Object.freeze([i("#c0392b","down"),i("#e0a800","right"),i("#2e7d32","up")]),f=Object.freeze([u("#d13438"),u("#f5a623"),u("#2e9e44")]),a=Object.freeze({arrows:c,trafficLights:f,ratings:Object.freeze([1,2,3,4,5].map(R=>m(R,5)))}),p=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function b(R){if(Array.isArray(R.icons)&&R.icons.length>=2)return R.icons.map(C=>/^\s*(url\(|data:|<)/.test(String(C))&&String(C).trim().startsWith("<")?h(String(C)):String(C));const S=R.set||"arrows";if(S==="ratings"){const C=s(R),P=[];for(let F=1;F<=C;F++)P.push(h(m(F,C)));return P}const x=a[S];return x?x.map(h):(B(`iconSet:${S}`,`unknown icon set '${S}'; falling back to arrows.`),c.map(h))}function O(R){const S=Number(R.min),C=Number(R.max)-S,P=R.colour||R.color||"#5b9bd5",F=R.negativeColour||R.negativeColor||"#d13438",E=R.direction==="rtl"?"left":"right",D=M=>Math.max(0,Math.min(1,(M-S)/C))*100,N=C?Math.max(0,Math.min(100,(0-S)/C*100)):0;return M=>{if(H(M))return null;const j=Number(M);if(!Number.isFinite(j)||!C)return null;const L=D(j),G=Math.min(L,N),q=Math.max(L,N),Y=j>=0?P:F;return{backgroundImage:`linear-gradient(to ${E}, transparent ${G}%, ${Y} ${G}%, ${Y} ${q}%, transparent ${q}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function k(R){const S=b(R),x=R.reverse?[...S].reverse():S,C=(Array.isArray(R.thresholds)?R.thresholds:[]).map(Number).filter(Number.isFinite),P=Number.isFinite(Number(R.size))?Number(R.size):16,F=R.set==="ratings"?P*s(R):P;return E=>{if(H(E))return null;const D=Number(E);if(!Number.isFinite(D))return null;let N=0;for(const j of C)D>=j&&N++;const M=x[Math.min(N,x.length-1)];return M?{backgroundImage:M,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${F}px ${P}px`,paddingLeft:`${F+4}px`}:null}}function y(R){const S=Array.isArray(R.colours)&&R.colours.length>=2?R.colours:["#f8f9fa","#1a6bc7"],x=Number(R.min),C=Number(R.max),P=C-x,F=S.length-1,E=[];for(let N=0;N<=F;N++)E.push(F?N/F:0);const D=Number(R.mid);if(R.mid!==void 0&&R.mid!==null)if(S.length%2===0)B("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${S.length} were given, so "mid" was ignored.`);else if(Number.isFinite(D)&&P&&D>Math.min(x,C)&&D<Math.max(x,C)){const N=F/2,M=Math.max(0,Math.min(1,(D-x)/P));for(let j=0;j<=F;j++)E[j]=j<=N?N?j/N*M:M:M+(j-N)/(F-N)*(1-M)}else Number.isFinite(D)&&B("formatting.scale.mid.range",`a scale's "mid" (${D}) is outside its min..max range, so it was ignored.`);return N=>{const M=Number(N);if(!Number.isFinite(M)||!P)return null;const j=Math.max(0,Math.min(1,(M-x)/P));let L=0;for(;L<F-1&&j>E[L+1];)L++;const G=E[L+1]-E[L],q=G>0?(j-E[L])/G:0;return{background:z(S[L],S[L+1],Math.max(0,Math.min(1,q)))}}}function v(R,S=null){const x=g(R)?n(R,S):R,C=(Array.isArray(x)?x:[]).filter(F=>F&&typeof F=="object");if(!C.length)return()=>null;const P=C.map(F=>F.scale?{scale:y(F.scale),enabled:F.enabled!==!1}:F.dataBar?{scale:O(F.dataBar),enabled:F.enabled!==!1}:F.iconSet?{scale:k(F.iconSet),enabled:F.enabled!==!1}:{when:F.when,style:F.style,stop:F.stopIfTrue!==!1,enabled:F.enabled!==!1});return F=>{const E=F?F.value:void 0;let D=null;for(const N of P){if(!N.enabled)continue;if(N.scale){const j=N.scale(E);j&&(D={...D||{},...j});continue}if(!V(E,N.when))continue;const M=$(N.style)?N.style(F):N.style;if(M&&(D={...D||{},...M}),N.stop)break}return D}}}),Fe("packages/core/src/formula/parse.js",function(e,K){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return t}});const Q="num",$="str",B="ref",I="name",_="op",X="end",W=["<=",">=","<>","!="],H="+-*/^%(),<>=";class V extends Error{constructor(s,h){super(s),this.name="FormulaError",this.at=h}}function z(r){const s=[];let h=0;for(;h<r.length;){const u=r[h];if(u===" "||u===" "||u===`
|
|
7
7
|
`||u==="\r"){h++;continue}if(u>="0"&&u<="9"){h=A(r,h,s);continue}if(u==="."&&r[h+1]>="0"&&r[h+1]<="9"){h=A(r,h,s);continue}if(u==='"'||u==="'"){h=g(r,h,s);continue}if(u==="["){const m=r.indexOf("]",h+1);if(m<0)throw new V("a [column reference] was opened and never closed",h);s.push({kind:B,value:r.slice(h+1,m).trim(),at:h}),h=m+1;continue}if(w(u)){h=l(r,h,s);continue}const i=r.slice(h,h+2);if(W.includes(i)){s.push({kind:_,value:i==="!="?"<>":i,at:h}),h+=2;continue}if(H.includes(u)){s.push({kind:_,value:u,at:h}),h++;continue}throw new V(`unexpected character ${JSON.stringify(u)}`,h)}return s.push({kind:X,value:null,at:r.length}),s}function w(r){return/[A-Za-z_À-]/.test(r)}function A(r,s,h){let u=s,i=!1;for(;u<r.length;){const m=r[u];if(m>="0"&&m<="9"){u++;continue}if(m==="."&&!i){i=!0,u++;continue}if((m==="e"||m==="E")&&/[0-9+-]/.test(r[u+1]||"")){for(u+=2;u<r.length&&r[u]>="0"&&r[u]<="9";)u++;break}break}return h.push({kind:Q,value:Number(r.slice(s,u)),at:s}),u}function g(r,s,h){const u=r[s];let i=s+1,m="";for(;i<r.length;){if(r[i]===u){if(r[i+1]===u){m+=u,i+=2;continue}return h.push({kind:$,value:m,at:s}),i+1}m+=r[i],i++}throw new V("a string was opened and never closed",s)}function l(r,s,h){let u=s;for(;u<r.length&&/[A-Za-z0-9_.À-]/.test(r[u]);)u++;const i=r.slice(s,u);let m=u;for(;m<r.length&&r[m]===" ";)m++;return h.push({kind:r[m]==="("?I:B,value:i,at:s}),u}const d={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function o(r){const s=String(r??"").replace(/^\s*=/,"");if(!s.trim())throw new V("the formula is empty");const h=z(s);let u=0;const i=()=>h[u],m=()=>h[u++],c=y=>{const v=i();if(v.kind!==_||v.value!==y)throw new V(`expected ${JSON.stringify(y)}`,v.at);u++},f=y=>{let v=a();for(;;){const R=i();if(R.kind!==_)break;const S=d[R.value];if(!S||S<y)break;u++;const x=f(R.value==="^"?S:S+1);v={kind:"bin",op:R.value,left:v,right:x}}return v},a=()=>{const y=i();return y.kind===_&&(y.value==="-"||y.value==="+")?(u++,{kind:"unary",op:y.value,arg:a()}):p()},p=()=>{let y=b();for(;i().kind===_&&i().value==="%";)u++,y={kind:"unary",op:"%",arg:y};return y},b=()=>{const y=m();if(y.kind===Q)return{kind:"num",value:y.value};if(y.kind===$)return{kind:"str",value:y.value};if(y.kind===B)return{kind:"ref",name:y.value};if(y.kind===I){c("(");const v=[];if(!(i().kind===_&&i().value===")"))for(;;){if(v.push(f(1)),i().kind===_&&i().value===","){u++;continue}break}return c(")"),{kind:"call",name:String(y.value).toUpperCase(),args:v}}if(y.kind===_&&y.value==="("){const v=f(1);return c(")"),v}throw y.kind===X?new V("the formula ends unexpectedly",y.at):new V(`unexpected ${JSON.stringify(y.value)}`,y.at)},O=f(1),k=i();if(k.kind!==X)throw new V(`unexpected ${JSON.stringify(k.value)}: is an operator missing?`,k.at);return O}function n(r){const s=new Set,h=u=>{if(!(!u||typeof u!="object")){if(u.kind==="ref"){s.add(String(u.name));return}if(u.kind==="bin"){h(u.left),h(u.right);return}if(u.kind==="unary"){h(u.arg);return}if(u.kind==="call")for(const i of u.args)h(i)}};return h(r),[...s]}function t(r){return typeof r=="string"&&/^\s*=/.test(r)&&r.trim()!=="="}}),Fe("packages/core/src/formula/evaluate.js",function(e,K){"use strict";Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return A}});const $=K("packages/core/src/formula/parse.js").FormulaError;function B(g){if(g==null||g==="")return 0;if(typeof g=="boolean")return g?1:0;if(g instanceof Date)return g.getTime();const l=typeof g=="number"?g:Number(String(g).replace(/[,\s]/g,""));if(!Number.isFinite(l))throw new $(`${JSON.stringify(g)} is not a number`);return l}function I(g){return g==null?"":String(g)}function _(g){if(typeof g=="boolean")return g;if(g==null||g==="")return!1;if(typeof g=="number")return g!==0;const l=String(g).trim().toLowerCase();return l==="false"||l==="no"||l==="0"?!1:l!==""}function X(g){const l=[];for(const d of g){if(Array.isArray(d)){for(const o of d)o!=null&&o!==""&&l.push(B(o));continue}d==null||d===""||l.push(B(d))}return l}function W(g,l){const d=10**l,o=g*d;return Math.sign(o)*Math.round(Math.abs(o)+Number.EPSILON*Math.abs(o))/d}function H(g,l){if(!g.length)return 0;const d=g.slice().sort((r,s)=>r-s),o=(d.length-1)*Math.min(1,Math.max(0,l)),n=Math.floor(o),t=Math.ceil(o);return n===t?d[n]:d[n]+(o-n)*(d[t]-d[n])}function V(g,l){let d=0,o=0,n=0;for(const r of g){d++;const s=r-o;o+=s/d,n+=s*(r-o)}const t=l?d-1:d;return t>0?Math.sqrt(n/t):0}const z={SUM:g=>X(g).reduce((l,d)=>l+d,0),AVERAGE:g=>{const l=X(g);return l.length?l.reduce((d,o)=>d+o,0)/l.length:0},MIN:g=>{const l=X(g);return l.length?Math.min(...l):0},MAX:g=>{const l=X(g);return l.length?Math.max(...l):0},COUNT:g=>X(g).length,PRODUCT:g=>X(g).reduce((l,d)=>l*d,1),ROUND:g=>W(B(g[0]),g.length>1?B(g[1]):0),ROUNDDOWN:g=>{const l=10**(g.length>1?B(g[1]):0),d=B(g[0])*l;return(d<0?Math.ceil(d):Math.floor(d))/l},ROUNDUP:g=>{const l=10**(g.length>1?B(g[1]):0),d=B(g[0])*l;return(d<0?Math.floor(d):Math.ceil(d))/l},ABS:g=>Math.abs(B(g[0])),FLOOR:g=>Math.floor(B(g[0])),CEILING:g=>Math.ceil(B(g[0])),SQRT:g=>Math.sqrt(B(g[0])),POWER:g=>B(g[0])**B(g[1]),MOD:g=>{const l=B(g[1]);if(l===0)throw new $("MOD by zero");return(B(g[0])%l+l)%l},IF:g=>_(g[0])?g[1]:g.length>2?g[2]:!1,AND:g=>g.every(_),OR:g=>g.some(_),NOT:g=>!_(g[0]),COALESCE:g=>g.find(l=>l!=null&&l!=="")??null,CONCAT:g=>g.map(I).join(""),LEN:g=>I(g[0]).length,UPPER:g=>I(g[0]).toUpperCase(),LOWER:g=>I(g[0]).toLowerCase(),TRIM:g=>I(g[0]).trim(),LEFT:g=>I(g[0]).slice(0,g.length>1?B(g[1]):1),RIGHT:g=>{const l=g.length>1?B(g[1]):1;return l<=0?"":I(g[0]).slice(-l)},MEDIAN:g=>H(X(g),.5),PERCENTILE:g=>{const l=B(g[g.length-1]);return H(X(g.slice(0,-1)),l>1?l/100:l)},QUARTILE1:g=>H(X(g),.25),QUARTILE3:g=>H(X(g),.75),STDEV:g=>V(X(g),!0),STDEVP:g=>V(X(g),!1),VAR:g=>{const l=V(X(g),!0);return l*l},VARP:g=>{const l=V(X(g),!1);return l*l},COUNTDISTINCT:g=>{const l=new Set;for(const d of g){const o=Array.isArray(d)?d:[d];for(const n of o)n!=null&&n!==""&&l.add(n)}return l.size},IQR:g=>{const l=X(g);return H(l,.75)-H(l,.25)}};z.AVG=z.AVERAGE,z.CEIL=z.CEILING,z.POW=z.POWER,z.STDEVS=z.STDEV,z.PERCENTILEINC=z.PERCENTILE;function w(g,l){const d=Number(g),o=Number(l);if(g!==null&&g!==""&&l!==null&&l!==""&&Number.isFinite(d)&&Number.isFinite(o))return d<o?-1:d>o?1:0;const t=I(g).toLowerCase(),r=I(l).toLowerCase();return t<r?-1:t>r?1:0}function A(g,l={}){const d=typeof l.lookup=="function"?l.lookup:null,o=l.functions?{...z,...l.functions}:z,n=t=>{switch(t.kind){case"num":return t.value;case"str":return t.value;case"ref":{if(!d)throw new $(`there is no column called ${JSON.stringify(t.name)} here`);const r=d(String(t.name));if(r===void 0)throw new $(`there is no column called ${JSON.stringify(t.name)}`);return r}case"unary":{if(t.op==="%")return B(n(t.arg))/100;const r=B(n(t.arg));return t.op==="-"?-r:r}case"bin":{const r=t.op;if(r==="=")return w(n(t.left),n(t.right))===0;if(r==="<>")return w(n(t.left),n(t.right))!==0;if(r==="<")return w(n(t.left),n(t.right))<0;if(r==="<=")return w(n(t.left),n(t.right))<=0;if(r===">")return w(n(t.left),n(t.right))>0;if(r===">=")return w(n(t.left),n(t.right))>=0;const s=B(n(t.left)),h=B(n(t.right));if(r==="+")return s+h;if(r==="-")return s-h;if(r==="*")return s*h;if(r==="^")return s**h;if(r==="/"){if(h===0)throw new $("division by zero");return s/h}throw new $(`unknown operator ${JSON.stringify(r)}`)}case"call":{const r=o[t.name];if(typeof r!="function")throw new $(`there is no function called ${t.name}`);return r(t.args.map(n),l)}default:throw new $("the formula could not be read")}};return n(g)}}),Fe("packages/core/src/formula/index.js",function(e,K){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"rowLookup",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return w}});const Q=K("packages/core/src/formula/parse.js"),$=Q.parseFormula,B=Q.referencesOf,I=Q.looksLikeFormula,_=Q.FormulaError,X=Q.tokenise,W=K("packages/core/src/formula/evaluate.js"),H=W.evaluateAst,V=W.FUNCTIONS;function z(A){const{grid:g,row:l,data:d}=A||{},o=h=>String(h).toLowerCase().replace(/[\s_-]/g,""),n=g&&g.columns&&typeof g.columns.all=="function"?g.columns.all():[],t=g&&g.permissions,r=t&&typeof t.isReadable=="function"?h=>t.isReadable(h):()=>!0,s=new Set;for(const h of n)r(h)||(s.add(o(h.id)),h.field&&s.add(o(h.field)),h.title&&s.add(o(h.title)));return h=>{const u=o(h);if(s.has(u))throw new _(`"${h}" cannot be read`);for(const i of n)if(o(i.id)===u||i.field&&o(i.field)===u||i.title&&o(i.title)===u)return l&&g.rows&&typeof g.rows.value=="function"?g.rows.value(l.key,i.id):d?d[i.field||i.id]:void 0;if(d&&typeof d=="object"){for(const i of Object.keys(d))if(o(i)===u){if(!r(i))throw new _(`"${h}" cannot be read`);return d[i]}}}}function w(A,g={}){try{const l=$(A);return{ok:!0,value:H(l,{lookup:z(g),functions:g.formulaFunctions}),references:B(l)}}catch(l){return{ok:!1,error:l instanceof _?l.message:"the formula could not be read",at:l instanceof _?l.at:void 0}}}}),Fe("packages/core/src/defaults.js",function(e,K){"use strict";Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"applyDefaults",{enumerable:!0,get:function(){return V}});const Q=K("packages/core/src/internal/util.js"),$=Q.isObject,B=Q.merge,I=Q.warnOnce;let _=null;class X extends Error{}function W(z,w=new Set){if(Array.isArray(z)){if(w.has(z))throw new X;w.add(z);const g=z.map(l=>W(l,w));return w.delete(z),g}if(!$(z)||Object.getPrototypeOf(z)!==Object.prototype&&Object.getPrototypeOf(z)!==null)return z;if(w.has(z))throw new X;w.add(z);const A={};for(const[g,l]of Object.entries(z))A[g]=W(l,w);return w.delete(z),A}function H(z){if(z===void 0)return W(_??{});if(z===null)return _=null,{};if(!$(z))return I("defaults:type",`defaults() expects a configuration object, or null to clear it, but got ${Array.isArray(z)?"an array":typeof z}. The call was ignored and the defaults are unchanged.`),W(_??{});try{_=W(z)}catch(w){if(!(w instanceof X))throw w;return I("defaults:cyclic","defaults() expects a configuration object with no circular references, but the object passed refers back to itself. The call was ignored and the defaults are unchanged."),W(_??{})}return W(_)}function V(z){return _===null?z:B(W(_),z)}}),Fe("packages/core/src/events/names.js",function(e,K){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"isKnownEvent",{enumerable:!0,get:function(){return B}});const Q=Object.freeze(["ready","destroy","render:first","render:done","config:changed","licence:changed","model:changed","rows:changed","rows:queued","rows:deferred","rows:paused","rows:resumed","row:received","row:sent","row:copied","row:moved","source:error","source:total","stream:chunk","stream:end","stream:evicted","rowDrag:started","rowDrag:moved","rowDrag:left","rowDrag:ended","cell:changed","cell:pending","cell:confirmed","cell:reverted","cell:conflict","cell:clicked","cell:dblclicked","cell:contextmenu","cell:mouseover","cell:mouseout","cell:mousedown","cell:mouseup","cell:edit:start","cell:edit:end","row:edit:start","row:edit:end","row:clicked","row:dblclicked","row:pending","row:confirmed","row:reverted","row:conflict","form:opened","form:closed","form:saved","form:error","sort:changed","filter:changed","group:toggled","facet:computed","facet:filtered","facet:expanded","facet:failed","column:moved","column:resized","column:visible","column:pinned","column:grouped","column:pivoted","column:filter:open","column:profile:open","column:menu:open","columns:changed","columns:tagged","columngroup:changed","header:contextmenu","pivot:drill","selection:changed","range:changed","clipboard:copy","page:changed","scroll","scroll:end","size:changed","detail:toggled","detail:cell:edit:start","detail:cell:edit:end","detail:row:edit:start","detail:row:edit:end","detail:cell:changed","toolpanel:focus","highlight:changed","find:changed","tree:loading","tree:loaded","tree:loadFailed","tree:loadAborted","state:changed","state:reset","history:changed","history:applied","views:changed","view:applied","view:saved","view:removed","view:renamed","view:default","validation:failed","validation:cleared","formatting:changed","redaction:changed","permissions:changed","presentation:changed","presentation:started","presentation:ended","presentation:view","presentation:scale","presentation:spotlight","presentation:captured","comment:added","comment:edited","comment:deleted","comment:failed","comment:resolved","comment:unresolved","comment:threadOpened","comment:threadClosed","comment:indexLoaded","presence:published","presence:joined","presence:updated","presence:left","presence:failed","presence:lockRefused","diff:changed","diff:swapped","timeline:attached","timeline:detached","timeline:seek","timeline:seeking","annotation:changed","export:progress","export:request","export:done","shortcuts:opened","shortcuts:closed","print:before","print:after","beforeEdit","beforeSort","beforeFilter","beforeColumnMove","beforeColumnResize","beforeColumnHide","beforeSelect","beforeRowAdd","beforeDelete","beforeRowMove","beforeGroup","beforeRowReceive","edit:cancelled","sort:cancelled","filter:cancelled","columnMove:cancelled","columnResize:cancelled","columnHide:cancelled","selection:cancelled","rowAdd:cancelled","delete:cancelled","rowMove:cancelled","group:cancelled","rowReceive:cancelled"]),$=new Set(Q);function B(I){return I==="*"||$.has(I)}}),Fe("packages/core/src/events/bus.js",function(e,K){"use strict";Object.defineProperty(e,"WILDCARD",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return l}});const Q=K("packages/core/src/internal/util.js"),$=Q.warnOnce,B=Q.uid,I=Q.DEV,X=K("packages/core/src/events/names.js").isKnownEvent,W="*";function H(d,o){!I||X(o)||$(`bus.unknown:${o}`,`${d}('${o}') subscribes to an event the grid never raises, so the handler will never fire. Check the name against the EventName list — a common cause is a near miss such as 'row:click' for 'row:clicked'.`)}const V=new Set(["api","user","init","ai"]),z=new WeakMap;function w(d){let o=z.get(d);return o||(o=B("h"),z.set(d,o)),o}function A(){return typeof performance=="object"&&performance?performance.now():Date.now()}function g(d){if(!d||typeof d!="object")return{};const o={};for(const[n,t]of Object.entries(d))n!=="grid"&&(t==null?o[n]=String(t):Array.isArray(t)?o[n]=`[${t.length}]`:typeof t=="object"?o[n]=t.key?`row ${t.key}`:"{…}":typeof t=="function"?o[n]="[function]":o[n]=String(t).slice(0,60));return o}class l{#e=new Map;#t=!1;#n=[];#r=200;#o=new Map;#i=null;#s=!1;#l=0;constructor(o=null){this.#i=o}attach(o){this.#i=o}get grid(){return this.#i}get destroyed(){return this.#s}on(o,n){if(typeof n!="function")return $(`bus.handler:${o}`,`on('${o}') needs a function; ignored.`),()=>{};H("on",o);let t=this.#e.get(o);return t||(t=[],this.#e.set(o,t)),t.push(n),()=>this.off(o,n)}once(o,n){if(typeof n!="function")return $(`bus.handler:${o}`,`once('${o}') needs a function; ignored.`),()=>{};H("once",o);const t=r=>{this.off(o,n),n(r)};return this.#o.set(n,t),this.on(o,t)}off(o,n){if(n===void 0){this.#e.delete(o);return}const t=this.#e.get(o);if(!t)return;const r=this.#o.get(n),s=r&&t.includes(r)?r:n,h=t.indexOf(s);h>=0&&t.splice(h,1),r&&s===r&&this.#o.delete(n),t.length===0&&this.#e.delete(o)}count(o){const n=this.#e.get(o),t=o===W?null:this.#e.get(W);return(n?n.length:0)+(t?t.length:0)}#a(o,n,t,r,s){this.#n.push({type:o,origin:n,listeners:(r?r.length:0)+(s?s.length:0),payload:g(t),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(o,n){this.#t=!!o,Number.isFinite(n)&&n>0&&(this.#r=Math.floor(n)),o||(this.#n=[])}eventLog(){return this.#n.map(o=>({...o}))}clearEventLog(){this.#n=[]}counts(){const o={};for(const[n,t]of this.#e)o[n]=t.length;return o}emit(o,n,t){const r=t??(n&&n.origin),s=V.has(r)?r:"api",h={...n||null,type:o,origin:s,grid:this.#i};if(this.#s)return h;const u=this.#e.get(o),i=o===W?void 0:this.#e.get(W);if(this.#t&&this.#a(o,s,n,u,i),!u&&!i)return h;const m=this.#t?A():0;this.#l++;try{u&&this.#u(u.slice(),h,o),i&&this.#u(i.slice(),h,W)}finally{this.#l--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=A()-m)}return h}emitBefore(o,n,t){const r=t??(n&&n.origin),s=V.has(r)?r:"user";let h=!1,u=null;const i=b=>{h=!0,b!=null&&u===null&&(u=String(b))},m={...n||null,type:o,origin:s,grid:this.#i,get defaultPrevented(){return h},get reason(){return u},preventDefault(b){i(b)}};if(this.#s)return!0;const c=this.#e.get(o);this.#t&&this.#a(o,s,n,c,void 0);const f=c?c.slice():[];if(f.length===0)return!0;const a=()=>(h&&u===null&&(u="prevented"),h&&n&&typeof n=="object"&&(n.reason=u),!h),p=[];for(const b of f)try{const O=b(m);O&&typeof O.then=="function"?p.push(O):O===!1&&i("prevented")}catch(O){i("error"),$(`bus.beforeThrow:${o}:${w(b)}`,`a '${o}' before-handler threw; the action was cancelled.`,O)}return p.length===0?a():Promise.allSettled(p).then(b=>{for(const O of b)O.status==="rejected"?(i("error"),$(`bus.beforeReject:${o}`,`a '${o}' before-handler rejected; the action was cancelled.`,O.reason)):O.value===!1&&i("prevented");return a()})}#u(o,n,t){for(let r=0;r<o.length;r++)try{o[r](n)}catch(s){$(`bus.throw:${t}:${w(o[r])}`,`a '${t}' handler threw; other handlers were unaffected.`,s)}}clear(){this.#e.clear(),this.#o.clear()}destroy(){this.clear(),this.#s=!0,this.#i=null}}}),Fe("packages/core/src/registry/free-tier-notice.js",function(e,K){"use strict";Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return Q}});const Q="Free for non-commercial use: latticegrid.dev/free"}),Fe("packages/core/src/registry/licence.js",function(e,K){"use strict";Object.defineProperty(e,"PRODUCT",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"LICENCE_VERSION",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"PUBLIC_KEY",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"fromBase64Url",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"toBase64Url",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"asciiBytes",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"hasEd25519",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"currentHost",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return x}});const $=K("packages/core/src/internal/util.js").warnOnce,B=K("packages/core/src/registry/free-tier-notice.js"),I=B.FREE_TIER_NOTICE;Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return B.FREE_TIER_NOTICE}});const _="lattice-grid",X=1,W="LG1",H=64,V="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",w=(()=>{const C=new Int16Array(128).fill(-1);for(let P=0;P<z.length;P++)C[z.charCodeAt(P)]=P;return C[43]=62,C[47]=63,C})();function A(C){if(typeof C!="string")return null;let P="";for(let j=0;j<C.length;j++){const L=C.charCodeAt(j);if(L!==61){if(L>127||w[L]<0)return null;P+=C[j]}}const F=P.length;if(F%4===1)return null;const E=new Uint8Array(Math.floor(F*3/4));let D=0,N=0,M=0;for(let j=0;j<F;j++)D=D<<6|w[P.charCodeAt(j)],N+=6,N>=8&&(N-=8,E[M++]=D>>N&255);return M===E.length?E:E.subarray(0,M)}function g(C){let P="",F=0;for(;F+2<C.length;F+=3){const D=C[F]<<16|C[F+1]<<8|C[F+2];P+=z[D>>18&63]+z[D>>12&63]+z[D>>6&63]+z[D&63]}const E=C.length-F;if(E===1){const D=C[F]<<16;P+=z[D>>18&63]+z[D>>12&63]}else if(E===2){const D=C[F]<<16|C[F+1]<<8;P+=z[D>>18&63]+z[D>>12&63]+z[D>>6&63]}return P}function l(C){const P=new Uint8Array(C.length);for(let F=0;F<C.length;F++)P[F]=C.charCodeAt(F)&127;return P}function d(C){if(typeof TextDecoder=="function")return new TextDecoder().decode(C);let P="";for(let F=0;F<C.length;F++)P+=String.fromCharCode(C[F]);return P}function o(C){const P={ok:!1,reason:"malformed",product:null,issuedTo:null,expires:null,terms:null,features:[],deployments:[],version:0,message:null,signature:null,raw:typeof C=="string"?C:""};if(typeof C!="string"||C.length===0)return{...P,reason:"missing"};const F=C.trim(),E=F.split(".");if(E.length!==3)return P;const[D,N,M]=E;if(D!==W)return{...P,reason:"prefix"};const j=A(N),L=A(M);if(!j||!L)return P;let G;try{G=JSON.parse(d(j))}catch{return P}return G===null||typeof G!="object"?P:{ok:!0,reason:null,product:typeof G.p=="string"?G.p:null,issuedTo:typeof G.t=="string"?G.t:null,expires:typeof G.e=="string"?G.e:null,terms:typeof G.terms=="string"?G.terms:null,features:Array.isArray(G.f)?G.f.slice():[],deployments:Array.isArray(G.d)?G.d.slice():[],version:typeof G.v=="number"?G.v:0,message:l(N),signature:L,raw:F}}function n(C,P){if(!C)return!1;const F=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(C)?`${C}T23:59:59.999Z`:C);return Number.isNaN(F)?!0:P>F}function t(C){return C==="non-commercial"?"non-commercial":"commercial"}let r=null,s=null,h=null;function u(){const C=globalThis.crypto;return C&&C.subtle?C.subtle:null}async function i(C){if(r&&s===C)return r;const P=u();if(!P)return null;const F=A(C);if(!F)return null;try{const E=await P.importKey("raw",F,{name:"Ed25519"},!1,["verify"]);return r=E,s=C,E}catch{return null}}async function m(){return h!==null||(h=await i(V)!==null),h}async function c(C,P={}){const F=P.warn!==!1,E=P.product||_,D=P.publicKey||V,N=P.now??Date.now(),M=P.host??a(),j=f(M)?"":` ${I}`,L=o(C);if(!L.ok){const ee=L.reason==="missing"?"missing":"malformed";return F&&$(`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.${j}`:`licence key could not be read. The grid will render with a watermark.${j}`),{valid:!1,reason:ee,terms:"commercial"}}const G={product:L.product||void 0,issuedTo:L.issuedTo||void 0,expires:L.expires||void 0,terms:t(L.terms)};if(L.product!==E)return F&&$("licence.product",`licence key is for '${L.product}', not '${E}'. The grid will render with a watermark.`),{valid:!1,...G,reason:"product"};if(n(L.expires,N))return F&&$("licence.expired",`licence expired on ${L.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...G,reason:"expired"};const q=L.deployments||[];if(q.length&&M&&!f(M)&&!p(M,q))return F&&$("licence.domain",`licence key is not valid for ${M}; it covers ${q.join(", ")}. The grid will render with a watermark.`),{valid:!1,...G,reason:"domain"};const Y=await i(D);if(!Y){const ee=!!L.signature&&L.signature.length===H;return F&&$("licence.algorithm","this host does not provide crypto.subtle Ed25519, so the licence signature could not be verified. A structural check was used instead."),ee?{valid:!0,...G,reason:"unverified"}:{valid:!1,...G,reason:"signature"}}let J=!1;try{J=await u().verify({name:"Ed25519"},Y,L.signature,L.message)}catch{J=!1}return J?{valid:!0,...G}:(F&&$("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...G,reason:"signature"})}function f(C){const P=String(C??a()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!P||P==="localhost"||P.endsWith(".localhost")||P==="::1"||P==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(P)}function a(){const C=globalThis.location;return C&&typeof C.hostname=="string"?C.hostname:null}function p(C,P){const F=b(C);return!F||!Array.isArray(P)?!1:P.some(E=>{const D=b(E);if(!D)return!1;if(D==="*")return!0;if(D.startsWith("*.")){const N=D.slice(2);return F===N||F.endsWith(`.${N}`)}return F===D})}function b(C){return String(C??"").trim().toLowerCase().replace(/\.$/,"")}class O{#e="";#t={valid:!1,reason:"missing",terms:"commercial"};#n=null;#r=null;#o;#i=new Set;constructor(P={}){this.#o=P}set(P){this.#e=typeof P=="string"?P.trim():"";const F=o(this.#e);return this.#t=F.ok?{valid:!n(F.expires,Date.now())&&F.product===(this.#o.product||_),product:F.product||void 0,issuedTo:F.issuedTo||void 0,expires:F.expires||void 0,terms:t(F.terms),reason:"pending"}:{valid:!1,reason:F.reason||"malformed",terms:"commercial"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const P=this.#e;return this.#n=c(P,this.#o).then(F=>{if(this.#e===P){this.#t=F;for(const E of this.#i)E(F)}return F}),this.#n}onSettled(P){return this.#i.add(P),()=>this.#i.delete(P)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!f(this.#r)}setHost(P){this.#r=P}state(){return this.#t.valid?"licensed":f(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing",terms:"commercial"},this.#n=null,this.#i.clear()}}const k=new O;function y(C){return k.set(C)}function v(){return k.info()}function R(){return k.watermark()}function S(){return k.state()}function x(){return k}}),Fe("packages/core/src/registry/registry.js",function(e,K){"use strict";Object.defineProperty(e,"KINDS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"REGIONS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return t}});const Q=K("packages/core/src/internal/util.js"),$=Q.warnOnce,B=Q.isFunction,I=Q.DEV,_=K("packages/core/src/registry/licence.js"),X=_.LicenceHolder,W=_.sharedLicence,H=["renderer","editor","filter","dataType","totalFn","pipe","component"],V=["all","header","body","totals","panels"];class z{#e=new Map;#t=new Map;#n=new Set;#r=new Set;#o;#i=null;#s=null;#l=new Set;#a=new Map;constructor(s={}){for(const h of H)this.#t.set(h,new Map);this.#o=s.holder||W(),this.#s=s.grid??null,this.#i=this.#o.onSettled(()=>{this.#d({reason:"licence",name:"licence",capabilities:this.capabilities(),regions:["all"]})}),s.licence&&this.setLicence(s.licence)}registerModules(s,h={}){h.licence&&this.setLicence(h.licence),h.grid!==void 0&&(this.#s=h.grid);const u=Array.isArray(s)?s:[s],i=[];for(const m of u){if(!m||typeof m!="object"||typeof m.name!="string"||!m.name){$("registry.module.shape","registerModules received something that is not a module; ignored.");continue}if(this.#e.has(m.name)){I&&this.#c(this.#e.get(m.name),m);continue}if(!B(m.install)){$(`registry.module.install:${m.name}`,`module '${m.name}' has no install() and was ignored.`);continue}const c={registry:this,grid:this.#s};try{m.install(c)}catch(f){$(`registry.module.throw:${m.name}`,`module '${m.name}' threw during install; it was not registered.`,f);continue}this.#e.set(m.name,m);for(const f of w(m))this.#n.add(f);i.push(m.name),this.#d({reason:"module",name:m.name,capabilities:this.capabilities(),regions:l(m)})}return i}unregisterModule(s){const h=this.#e.get(s);if(!h)return!1;if(B(h.uninstall))try{h.uninstall({registry:this,grid:this.#s})}catch(u){$(`registry.module.uninstall:${s}`,`module '${s}' threw during uninstall.`,u)}return this.#e.delete(s),this.#u(),this.#d({reason:"unmodule",name:s,capabilities:this.capabilities(),regions:l(h)}),!0}modules(){return[...this.#e.values()]}has(s){return this.#e.has(s)}#u(){this.#n.clear();for(const s of this.#e.values())for(const h of w(s))this.#n.add(h)}#c(s,h){!s||s===h||A(s,h)||$(`registry.module.reconfigure:${h.name}`,`module '${h.name}' was re-registered with different options; the first registration is kept and this call was ignored. Unregister it first if you mean to replace it.`)}capabilities(){return[...this.#n].sort()}can(s){return this.#n.has(s)}onChange(s){return B(s)?(this.#r.add(s),this.#a.set(s,this.#s),()=>{this.#r.delete(s),this.#a.delete(s)}):()=>{}}#d(s){for(const h of[...this.#r])try{h(s)}catch(u){$("registry.onChange.throw","a registry change handler threw.",u)}}register(s,h,u){const i=this.#t.get(s);if(!i){$(`registry.kind:${s}`,`unknown registry kind '${s}'; expected one of ${H.join(", ")}.`);return}if(!h||typeof h!="string"){$(`registry.name:${s}`,`register('${s}', ...) needs a name.`);return}i.has(h)&&i.get(h)!==u&&$(`registry.replace:${s}:${h}`,`'${h}' was already registered as a ${s} and has been replaced.`),i.set(h,u),this.#d({reason:"register",name:h,kind:s,capabilities:this.capabilities(),regions:d(s)})}registerAll(s,h){if(h)for(const u of Object.keys(h))this.register(s,u,h[u])}get(s,h){const u=this.#t.get(s);return u?u.get(h):void 0}names(s){const h=this.#t.get(s);return h?[...h.keys()]:[]}#h(s,h){const u=this.#t.get(s).get(h);return u!==void 0?u:this.#t.get("component").get(h)}renderer(s){return this.#h("renderer",s)}editor(s){return this.#h("editor",s)}filter(s){return this.#h("filter",s)}dataType(s){return this.get("dataType",s)}totalFn(s){return this.get("totalFn",s)}pipe(s){return this.get("pipe",s)}setLicence(s){return this.#o.set(s)}licence(){return this.#o.info()}licenceVerified(){return this.#o.verify()}watermark(){return this.#o.watermark()}attach(s){s!=null&&(this.#l.add(s),this.#s=s)}detach(s){if(s!=null){this.#l.delete(s);for(const[h,u]of[...this.#a])u===s&&(this.#r.delete(h),this.#a.delete(h));if(this.#s===s){const h=this.#l.size?[...this.#l][this.#l.size-1]:null;this.#s=h}this.#l.size===0&&this.#i&&(this.#i(),this.#i=null)}}destroy(s){if(s!=null){this.detach(s);return}for(const h of[...this.#e.keys()])this.unregisterModule(h);this.#r.clear(),this.#a.clear(),this.#l.clear(),this.#i&&this.#i(),this.#i=null,this.#s=null}}function w(r){const s=r.capabilities,h=Array.isArray(s)?s.filter(u=>typeof u=="string"):[];return[r.name,...h]}function A(r,s){return r.install!==s.install||r.uninstall!==s.uninstall||(r.version||"")!==(s.version||"")?!1:g(w(r),w(s))&&g(l(r),l(s))}function g(r,s){const h=new Set(r),u=new Set(s);if(h.size!==u.size)return!1;for(const i of h)if(!u.has(i))return!1;return!0}function l(r){const s=r.regions;return!Array.isArray(s)||s.length===0?["all"]:s.filter(h=>V.includes(h))}function d(r){switch(r){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const o=new z;function n(){return o}function t(r,s={}){return o.registerModules(r,s)}}),Fe("packages/core/src/format/number.js",function(e,K){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return B}});const $=K("packages/core/src/internal/util.js").isNil;function B(I,_){const X=I||{},W=X.locale||_||void 0,H=X.style||"decimal",V=typeof X.scale=="number"?X.scale:1,z=X.nullDisplay??"",w=X.zeroDisplay,A=X.prefix||"",g=X.suffix||"",l=X.negative||"minus",d=X.signed===!0,o={style:H,notation:X.notation||"standard"};H==="currency"&&(o.currency=X.currency||"USD",X.currencyDisplay&&(o.currencyDisplay=X.currencyDisplay)),typeof X.decimals=="number"?(o.minimumFractionDigits=X.decimals,o.maximumFractionDigits=X.decimals):(typeof X.minDecimals=="number"&&(o.minimumFractionDigits=X.minDecimals),typeof X.maxDecimals=="number"&&(o.maximumFractionDigits=X.maxDecimals),o.minimumFractionDigits>(o.maximumFractionDigits??20)&&(o.maximumFractionDigits=o.minimumFractionDigits)),X.thousandsSeparator===!1&&(o.useGrouping=!1),o.notation==="compact"&&(o.compactDisplay=X.compactDisplay||"short");const n=new Intl.NumberFormat(W,o),t=typeof X.thousandsSeparator=="string"?X.thousandsSeparator:null,r=typeof X.decimalSeparator=="string"?X.decimalSeparator:null;let s=",",h=".";if(t||r)for(const a of n.formatToParts(12345.6))a.type==="group"?s=a.value:a.type==="decimal"&&(h=a.value);const u=a=>{let p=a;return t&&(p=p.split(s).join("")),r&&(p=p.split(h).join("")),t&&(p=p.split("").join(t)),r&&(p=p.split("").join(r)),p},i=!!(t||r),m=A!==""&&H==="currency",c=a=>{let p;if(m){const b=n.formatToParts(a);let O=!1;p="";for(const k of b)p+=k.value,!O&&k.type==="currency"&&(p+=A,O=!0);O||(p=A+p)}else p=A+n.format(a);return i&&(p=u(p)),p+g},f=a=>{if($(a)||a==="")return z;const p=typeof a=="number"?a:Number(a);if(Number.isNaN(p))return z;const b=V===1?p:p*V;return b===0&&w!==void 0?w:b<0?l==="parentheses"?`(${c(-b)})`:l==="suffix"?`${c(-b)}-`:c(b):d&&b>0?`+${c(b)}`:c(b)};return f.negativeClass=X.negativeClass||null,f.spec=X,f}}),Fe("packages/core/src/format/date.js",function(e,K){"use strict";Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"toIsoDate",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toIsoDateTime",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"compareIso",{enumerable:!0,get:function(){return n}});const Q=K("packages/core/src/internal/util.js"),$=Q.isNil,B=Q.warnOnce,I=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function _(t){const r=[];let s=0,h="";const u=()=>{h&&(r.push({token:null,text:h}),h="")};for(;s<t.length;){const i=t[s];if(i==="'"){if(t[s+1]==="'"){h+="'",s+=2;continue}const c=t.indexOf("'",s+1);if(c===-1){h+=t.slice(s+1),s=t.length;continue}h+=t.slice(s+1,c),s=c+1;continue}const m=I.find(c=>t.startsWith(c,s));if(m){u(),r.push({token:m,text:m}),s+=m.length;continue}/[A-Za-z]/.test(i)&&B(`date.pattern.token:${i}`,`the date pattern "${t}" contains '${i}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${I.join(" ")}.`),h+=i,s+=1}return u(),r}const X=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function W(t){if($(t)||t==="")return null;if(t instanceof Date)return Number.isNaN(t.getTime())?null:t;if(typeof t=="number")return Number.isNaN(t)?null:new Date(t);if(typeof t=="string"){const r=X.exec(t.trim());if(r){const[,h,u,i,m="0",c="0",f="0"]=r;return new Date(+h,+u-1,+i,+m,+c,+f)}const s=new Date(t);return Number.isNaN(s.getTime())?null:s}return null}function H(t,r){return String(t).padStart(r,"0")}function V(t){if(!t)return h=>({year:h.getFullYear(),month:h.getMonth()+1,day:h.getDate(),hour:h.getHours(),minute:h.getMinutes(),second:h.getSeconds(),ms:h.getMilliseconds(),weekday:h.getDay()});const r=new Intl.DateTimeFormat("en-US",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),s={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return h=>{const u={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:h.getMilliseconds(),weekday:0};for(const i of r.formatToParts(h))switch(i.type){case"year":u.year=Number(i.value);break;case"month":u.month=Number(i.value);break;case"day":u.day=Number(i.value);break;case"hour":u.hour=Number(i.value)%24;break;case"minute":u.minute=Number(i.value);break;case"second":u.second=Number(i.value);break;case"weekday":u.weekday=s[i.value]??0;break;default:break}return u}}function z(t,r,s){const h=_(t),u=V(s),i=new Set(h.filter(p=>p.token).map(p=>p.token)),m=i.has("MMM")?new Intl.DateTimeFormat(r,{month:"short",timeZone:s}):null,c=i.has("MMMM")?new Intl.DateTimeFormat(r,{month:"long",timeZone:s}):null,f=i.has("EEE")?new Intl.DateTimeFormat(r,{weekday:"short",timeZone:s}):null,a=i.has("EEEE")?new Intl.DateTimeFormat(r,{weekday:"long",timeZone:s}):null;return p=>{const b=u(p);let O="";for(const k of h){if(!k.token){O+=k.text;continue}switch(k.token){case"yyyy":O+=H(b.year,4);break;case"yy":O+=H(b.year%100,2);break;case"MMMM":O+=c.format(p);break;case"MMM":O+=m.format(p);break;case"MM":O+=H(b.month,2);break;case"M":O+=String(b.month);break;case"dd":O+=H(b.day,2);break;case"d":O+=String(b.day);break;case"EEEE":O+=a.format(p);break;case"EEE":O+=f.format(p);break;case"HH":O+=H(b.hour,2);break;case"H":O+=String(b.hour);break;case"hh":O+=H(b.hour%12===0?12:b.hour%12,2);break;case"h":O+=String(b.hour%12===0?12:b.hour%12);break;case"mm":O+=H(b.minute,2);break;case"m":O+=String(b.minute);break;case"ss":O+=H(b.second,2);break;case"s":O+=String(b.second);break;case"SSS":O+=H(b.ms,3);break;case"a":O+=b.hour<12?"AM":"PM";break;default:O+=k.text;break}}return O}}const w=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function A(t,r){const s=t||{},h=s.locale||r||void 0,u=s.nullDisplay??"",i=s.timeZone;let m;if(s.pattern)m=z(s.pattern,h,i);else if(s.dateStyle||s.timeStyle){const b={timeZone:i};s.dateStyle&&(b.dateStyle=s.dateStyle),s.timeStyle&&(b.timeStyle=s.timeStyle);const O=new Intl.DateTimeFormat(h,b);m=k=>O.format(k)}else{const b=new Intl.DateTimeFormat(h,{dateStyle:"medium",timeZone:i});m=O=>b.format(O)}const c=s.relative?new Intl.RelativeTimeFormat(h,{numeric:"auto"}):null,a=(typeof s.relative=="object"&&s.relative?s.relative.threshold??7:7)*24*36e5,p=(b,O)=>{const k=W(b);if(!k)return u;if(c){const y=O&&typeof O.now=="number"?O.now:Date.now(),v=k.getTime()-y;if(Math.abs(v)<a){for(const[R,S]of w)if(Math.abs(v)>=S||R==="second")return c.format(Math.round(v/S),R)}}return m(k)};return p.spec=s,p}function g(t){if($(t)||t==="")return null;if(typeof t=="string"){const h=/^(\d{4}-\d{2}-\d{2})/.exec(t.trim());if(h)return h[1];const u=W(t);return u?g(u):null}const r=W(t);if(!r)return null;const s=h=>String(h).padStart(2,"0");return`${r.getFullYear()}-${s(r.getMonth()+1)}-${s(r.getDate())}`}function l(t,r){if($(t)||t==="")return null;if(typeof t=="string"){const h=t.trim();if(d.test(h)){const m=W(h);return m?o(m,r):null}const u=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(h);if(u){const[,m,c,f,a]=u;return`${m}T${c}:${f}${a&&a!=="00"?`:${a}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(h))return`${h}T00:00`;const i=W(h);return i?l(i):null}const s=W(t);return s?o(s,r):null}const d=/(?:Z|[+-]\d{2}:?\d{2})$/i;function o(t,r){const s=m=>String(m).padStart(2,"0");if(r)try{const m=new Intl.DateTimeFormat("en-CA",{timeZone:r,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(t).reduce((a,p)=>(p.type!=="literal"&&(a[p.type]=p.value),a),{}),c=m.hour==="24"?"00":m.hour,f=Number(m.second);return`${m.year}-${m.month}-${m.day}T${c}:${m.minute}`+(f?`:${m.second}`:"")}catch{}const h=`${t.getFullYear()}-${s(t.getMonth()+1)}-${s(t.getDate())}`,u=t.getSeconds(),i=`${s(t.getHours())}:${s(t.getMinutes())}${u?`:${s(u)}`:""}`;return`${h}T${i}`}function n(t,r){const s=$(t)||t===""?null:String(t),h=$(r)||r===""?null:String(r);return s===null?h===null?0:1:h===null||s<h?-1:s>h?1:0}}),Fe("packages/core/src/format/boolean.js",function(e,K){"use strict";Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return X}});const $=K("packages/core/src/internal/util.js").isNil,B={true:"☑",false:"☐",null:""},I={true:"◉",false:"◯",null:""};function _(W){if($(W)||W==="")return null;if(typeof W=="boolean")return W;if(typeof W=="number")return W!==0;const H=String(W).trim().toLowerCase();return H==="true"||H==="yes"||H==="y"||H==="1"?!0:H==="false"||H==="no"||H==="n"||H==="0"?!1:null}function X(W,H){const V=W||{},z=V.display||"text",w=V.trueLabel??"Yes",A=V.falseLabel??"No",g=V.nullLabel??"";let l=w,d=A;const o=g;z==="checkbox"?(l=B.true,d=B.false):z==="switch"?(l=I.true,d=I.false):z==="icon"&&(l=V.trueIcon??w,d=V.falseIcon??A);const n=t=>{const r=_(t);return r===null?o:r?l:d};return n.display=z,n.labels={true:w,false:A,null:g},n.locale=H,n.spec=V,n}}),Fe("packages/core/src/format/text.js",function(e,K){"use strict";Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return I}});const Q=K("packages/core/src/internal/util.js"),$=Q.isNil,B=Q.titleCase;function I(_,X){const W=_||{},H=W.locale||X||void 0,V=W.nullDisplay??"",z=W.emptyDisplay??"",w=W.transform||"none",A=typeof W.truncate=="number"?{chars:W.truncate}:W.truncate||null,g=A?A.chars:0,l=A?A.ellipsis??"…":"",d=n=>{switch(w){case"upper":return H?n.toLocaleUpperCase(H):n.toUpperCase();case"lower":return H?n.toLocaleLowerCase(H):n.toLowerCase();case"title":return B(n);default:return n}},o=n=>{if($(n))return V;let t=typeof n=="string"?n:String(n);return t===""?z:(w!=="none"&&(t=d(t)),g>0&&t.length>g&&(t=t.slice(0,g)+l),t)};return o.spec=W,o}}),Fe("packages/core/src/format/mask.js",function(e,K){"use strict";Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return X}});const Q=new Set(["0","#","?",",","."]),$="\0";function B(H){const V=[];let z="",w=!1;for(let A=0;A<H.length;A++){const g=H[A];if(g==="\\"){z+=g+(H[A+1]??""),A+=1;continue}if(g==='"'){w=!w,z+=g;continue}if(g===";"&&!w){V.push(z),z="";continue}z+=g}return V.push(z),V}function I(H){let V="",z="",w="",A=1,g=!1,l=!1;const d=m=>{l?z+=m:V+=m};for(let m=0;m<H.length;m++){const c=H[m];if(c==="\\"){d(H[m+1]??""),m+=1;continue}if(c==='"'){const f=H.indexOf('"',m+1);d(f===-1?H.slice(m+1):H.slice(m+1,f)),m=f===-1?H.length:f;continue}if(c==="%"){A*=100,d("%");continue}if(c==="@"){g=!0,d("\0");continue}if(Q.has(c)){w+=c,l=!0;continue}d(c)}let o=-1;for(let m=w.length-1;m>=0;m--){const c=w[m];if(c==="0"||c==="#"||c==="?"){o=m;break}}let n=!1,t="";for(let m=0;m<w.length;m++){const c=w[m];if(c===","){m>o?A/=1e3:n=!0;continue}t+=c}const r=t.indexOf("."),s=r===-1?t:t.slice(0,r),h=r===-1?"":t.slice(r+1);let u=0;for(const m of s)m==="0"&&(u+=1);let i=0;for(const m of h)m==="0"&&(i+=1);return{prefix:V,suffix:z,minInt:u,minDec:i,maxDec:h.length,grouping:n,scale:A,hasNumber:o!==-1,isText:g}}function _(H,V){const z=new Intl.NumberFormat(V,{minimumIntegerDigits:Math.max(H.minInt,1),minimumFractionDigits:H.minDec,maximumFractionDigits:Math.max(H.maxDec,H.minDec),useGrouping:H.grouping}),{prefix:w,suffix:A,scale:g,hasNumber:l}=H;return d=>{if(!l)return w+A;const o=g===1?d:d*g;return w+z.format(o)+A}}function X(H,V){const w=B(String(H)).map(I),A=w.map(t=>_(t,V)),g=0,l=w.length>1?1:-1,d=w.length>2?2:-1,o=w.length>3?3:-1,n=t=>{if(t==null||t==="")return"";if(typeof t!="number"||Number.isNaN(t)){const r=Number(t);if(Number.isNaN(r))return o===-1?String(t):(w[o].prefix+w[o].suffix).split("\0").join(String(t));t=r}return t===0&&d!==-1?A[d](0):t<0&&l!==-1?A[l](-t):A[g](t)};return n.spec={mask:H},{format:n,ooxml:W(String(H))}}function W(H){return H.trim()}}),Fe("packages/core/src/format/shorthand.js",function(e,K){"use strict";Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return W}});const Q=["currency","number","percent","date","boolean","text","relative"],$=/[#0?@;"\\]/,B=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function I(H){return typeof H!="string"||H===""||X(H)?!1:$.test(H)}function _(H){return typeof H!="string"||H===""||X(H)?!1:B.test(H)}function X(H){const V=H.indexOf(":"),z=V===-1?H:H.slice(0,V);return Q.includes(z)?z:null}function W(H){const V=X(H);if(!V)return null;const z=H.indexOf(":"),w=z===-1?"":H.slice(z+1),A=w===""?[]:w.split(":");switch(V){case"currency":{const g={type:"number",style:"currency",currency:A[0]||"USD"};return A[1]!==void 0&&A[1]!==""&&(g.decimals=Number(A[1])),g}case"number":{const g={type:"number",style:"decimal"};return A[0]!==void 0&&A[0]!==""&&(g.decimals=Number(A[0])),g}case"percent":{const g={type:"number",style:"percent"};return A[0]!==void 0&&A[0]!==""&&(g.decimals=Number(A[0])),g}case"date":return{type:"date",pattern:w||void 0};case"relative":return{type:"date",relative:!0};case"boolean":{const g=w.split("/"),l={type:"boolean",display:"text"};return g[0]!==void 0&&g[0]!==""&&(l.trueLabel=g[0]),g[1]!==void 0&&g[1]!==""&&(l.falseLabel=g[1]),g[2]!==void 0&&(l.nullLabel=g[2]),l}case"text":{const g={type:"text"};return A[0]&&(g.transform=A[0]),A[1]!==void 0&&A[1]!==""&&(g.truncate=Number(A[1])),g}default:return null}}}),Fe("packages/core/src/format/index.js",function(e,K){"use strict";Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return O}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.isObject,I=Q.warnOnce,_=K("packages/core/src/format/number.js"),X=_.compileNumber,W=K("packages/core/src/format/date.js"),H=W.compileDate,V=W.scanPattern,z=K("packages/core/src/format/boolean.js"),w=z.compileBoolean,A=K("packages/core/src/format/text.js"),g=A.compileText,l=K("packages/core/src/format/mask.js"),d=l.compileMask,o=K("packages/core/src/format/shorthand.js"),n=o.parseShorthand,t=o.looksLikeMask,r=o.looksLikeDatePattern;Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return _.compileNumber}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return W.compileDate}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return W.compilePattern}}),Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return W.scanPattern}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return W.toDate}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return z.compileBoolean}}),Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return z.toTriState}}),Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return A.compileText}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return l.compileMask}}),Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return l.splitSections}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return l.parseSection}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return o.parseShorthand}}),Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return o.looksLikeMask}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return o.looksLikeDatePattern}});const s=new Set(["decimal","currency","percent","unit"]),h=new Set(["type","locale"]),u={number:new Set(["style","currency","currencyDisplay","decimals","minDecimals","maxDecimals","thousandsSeparator","decimalSeparator","notation","compactDisplay","negative","negativeClass","signed","prefix","suffix","zeroDisplay","nullDisplay","messages","scale"]),date:new Set(["pattern","dateStyle","timeStyle","timeZone","relative","nullDisplay"]),boolean:new Set(["display","trueLabel","falseLabel","nullLabel","trueIcon","falseIcon"]),text:new Set(["transform","truncate","nullDisplay","emptyDisplay"])},i=new Set(["number","date","boolean","text"]);function m(R,S){const x=R.type;if(x===void 0||i.has(x)||!s.has(String(x)))return;const C=S?`"${S}"`:"with no id";I(`format:unknown-style-key:${S||""}:${x}`,`column ${C} has format: { type: "${x}" }, which is not a valid format type ("number", "date", "boolean" or "text") and is ignored; did you mean style: "${x}" instead?`)}function c(R,S,x){const C=u[S],P=x?`"${x}"`:"with no id";for(const F of R){if(h.has(F)||C.has(F))continue;const E=Object.keys(u).find(D=>D!==S&&u[D].has(F));E?I(`format:inapplicable:${x||""}:${F}`,`column ${P} has format key "${F}", which applies to a ${E} column, not the ${S} column it was applied to; it is ignored.`):I(`format:unknown:${x||""}:${F}`,`column ${P} has an unrecognised format key "${F}" for its ${S} format; it is ignored.`)}}function f(R){if(R.type==="number"||R.type==="date"||R.type==="boolean"||R.type==="text")return!0;const S=s.has(String(R.style));return!!(R.pattern||R.dateStyle||R.timeStyle||R.relative||R.timeZone||R.trueLabel||R.falseLabel||R.display||R.trueIcon||R.falseIcon||R.transform||R.truncate||R.emptyDisplay||S||R.currency||R.decimals!==void 0||R.minDecimals!==void 0||R.maxDecimals!==void 0||R.notation||R.negative||R.scale!==void 0||R.prefix||R.suffix||R.zeroDisplay!==void 0)}function a(R,S){if(R.type==="number"||R.type==="date"||R.type==="boolean"||R.type==="text")return R.type;if(R.pattern||R.dateStyle||R.timeStyle||R.relative||R.timeZone)return"date";if(R.trueLabel||R.falseLabel||R.display||R.trueIcon||R.falseIcon)return"boolean";if(R.transform||R.truncate||R.emptyDisplay)return"text";if(R.style||R.currency||R.decimals!==void 0||R.minDecimals!==void 0||R.maxDecimals!==void 0||R.notation||R.negative||R.scale!==void 0||R.prefix||R.suffix||R.zeroDisplay!==void 0)return"number";const x=S&&S.base;return x==="number"?"number":x==="date"||x==="dateString"?"date":x==="boolean"?"boolean":"text"}function p(R,S=null,x=void 0,C=void 0,P=void 0){if(R==null||R==="")return null;const F=B(R)?Object.keys(R):null;if(typeof R=="function"){const N=(M,j)=>String(R({...j||{},value:M,locale:x})??"");return N.ooxml=S&&S.excel||"General",N}if(typeof R=="string"){if(t(R)){const{format:M,ooxml:j}=d(R,x);return M.ooxml=j,M}const N=n(R)||(r(R)?{type:"date",pattern:R}:null);return N?p(N,S,x,C,P):(I(`format:${R}`,`unrecognised format string "${R}"; the value will be stringified`),null)}if(!B(R))return I("format:shape","format must be a spec object or a string; ignoring",R),null;if(S&&$(S.format)&&!f(R)||S&&$(S.format)&&Array.isArray(S.formatPatterns)&&R.type===void 0)return null;const E=a(R,S);E==="date"&&C&&R.timeZone===void 0&&(R={...R,timeZone:C}),m(R,P),c(F||Object.keys(R),E,P);let D;switch(E){case"number":D=X(R,x);break;case"date":D=H(R,x);break;case"boolean":D=w(R,x);break;default:D=g(R,x);break}return D.ooxml=O(R,E,x,S),D.kind=E,D}const b={yyyy:"yyyy",yy:"yy",MMMM:"mmmm",MMM:"mmm",MM:"mm",M:"m",dd:"dd",d:"d",EEEE:"dddd",EEE:"ddd",HH:"hh",H:"h",hh:"hh",h:"h",mm:"mm",m:"m",ss:"ss",s:"s",SSS:"000",a:"AM/PM"};function O(R,S,x=void 0,C=null){if(S==="date"){if(R.pattern){let N="";for(const M of V(R.pattern))N+=M.token?b[M.token]??M.text:M.text;return N}return C&&C.excel||"yyyy-mm-dd"}if(S==="boolean")return"General";if(S==="text")return"@";if(R.notation==="compact"||R.notation==="scientific")return"General";const P=typeof R.decimals=="number"?R.decimals:typeof R.minDecimals=="number"?R.minDecimals:R.style==="currency"?2:0;let E=`${R.thousandsSeparator===!1?"":"#,#"}#0${P>0?`.${"0".repeat(P)}`:""}`,D="";return R.style==="currency"&&(D+=k(v(R.currency||"USD",x))),R.prefix&&(D+=k(R.prefix)),E=D+E,R.style==="percent"&&(E=`${E}%`),R.suffix&&(E+=k(R.suffix)),R.negative==="parentheses"?`${E};(${E})`:R.negative==="suffix"?`${E};${E}-`:E}function k(R){return`"${String(R).split('"').join("")}"`}const y=new Map;function v(R,S){const x=`${R}|${S||""}`;let C=y.get(x);if(C!==void 0)return C;C=R;try{const F=new Intl.NumberFormat(S,{style:"currency",currency:R}).formatToParts(0).find(E=>E.type==="currency");F&&(C=F.value)}catch{}return y.set(x,C),C}}),Fe("packages/core/src/columns/types/temporal.js",function(e,K){"use strict";Object.defineProperty(e,"MS_SECOND",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"MS_MINUTE",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"MS_HOUR",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"MS_DAY",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"MS_WEEK",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"toTimeMs",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"zonedParts",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"zoneOffsetAt",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"instantFromParts",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"toEpochMs",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(e,"toDurationMs",{enumerable:!0,get:function(){return se}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"zoneAbbrev",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(e,"resolveZoneName",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"timestampGroupProjector",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"TEMPORAL_INFERENCE_ORDER",{enumerable:!0,get:function(){return He}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return qe}});const Q=K("packages/core/src/internal/util.js"),$=Q.isNil,B=Q.isFunction,I=K("packages/core/src/format/date.js"),_=I.toDate,X=I.compilePattern,W=I.compileDate,H=I.toIsoDateTime,V=I.compareIso,z=864e5,w=Object.freeze({}),A=1e3,g=60*A,l=60*g,d=24*l,o=7*d,n=new WeakMap;function t(Ae,Ge){const Ze=Ae&&Ae.locale||"",nt=Ae&&Ae.column;if(!nt)return Ze?{locale:Ze}:w;const lt=n.get(nt);if(lt&<.locale===Ze)return lt.bag;const ft=nt.typeOptions||nt[Ge]||(r(nt.format)?nt.format:null),gt={...ft||w,locale:ft&&ft.locale||Ze||void 0};return n.set(nt,{locale:Ze,bag:gt}),gt}function r(Ae){return Ae!==null&&typeof Ae=="object"&&!Array.isArray(Ae)&&!(Ae instanceof Date)}function s(Ae,Ge){const Ze=Ae===null||Number.isNaN(Ae)?null:Ae,nt=Ge===null||Number.isNaN(Ge)?null:Ge;return Ze===null?nt===null?0:1:nt===null||Ze<nt?-1:Ze>nt?1:0}const h=/^(\d{1,2})(?:\s*[:.h]\s*(\d{1,2})(?:\s*[:.]\s*(\d{1,2})(?:[.,](\d{1,3}))?)?)?\s*(a\.?m\.?|p\.?m\.?|a|p)?$/i,u=/^(\d{3,6})$/;function i(Ae,Ge,Ze,nt){return!(Ae>=0&&Ae<=23)||!(Ge>=0&&Ge<=59)||!(Ze>=0&&Ze<=59)||!(nt>=0&&nt<=999)?null:Ae*l+Ge*g+Ze*A+nt}function m(Ae){if($(Ae))return null;const Ge=String(Ae).trim();if(Ge==="")return null;const Ze=u.exec(Ge);if(Ze){const Ct=Ze[1];if(Ct.length===5)return null;const Mt=Ct.length===3?1:2;return i(Number(Ct.slice(0,Mt)),Number(Ct.slice(Mt,Mt+2)),Number(Ct.slice(Mt+2,Mt+4)||0),0)}const nt=h.exec(Ge);if(!nt)return null;let lt=Number(nt[1]);const ft=Number(nt[2]||0),gt=Number(nt[3]||0),At=nt[4]?Number(nt[4].padEnd(3,"0")):0,Pt=nt[5]?nt[5][0].toLowerCase():null;if(Pt){if(lt<1||lt>12)return null;lt=lt%12,Pt==="p"&&(lt+=12)}return i(lt,ft,gt,At)}function c(Ae){return $(Ae)||Ae===""?null:typeof Ae=="number"?Number.isFinite(Ae)?(Ae%d+d)%d:null:Ae instanceof Date?Number.isNaN(Ae.getTime())?null:Ae.getHours()*l+Ae.getMinutes()*g+Ae.getSeconds()*A+Ae.getMilliseconds():m(Ae)}const f=new Map;function a(Ae){const Ge=Ae.pattern||"",Ze=Ae.timeStyle||(Ae.seconds?"medium":"short"),nt=`${Ae.locale||""}|${Ge}|${Ze}`;let lt=f.get(nt);if(lt)return lt;if(Ge)lt=X(Ge,Ae.locale||void 0,"UTC");else{const ft=new Intl.DateTimeFormat(Ae.locale||void 0,{timeStyle:Ze,timeZone:"UTC"});lt=gt=>ft.format(gt)}return f.set(nt,lt),lt}function p(Ae,Ge){const Ze=Ge||w;if(Ae==null||typeof Ae!="number"||!Number.isFinite(Ae))return Ze.nullDisplay??"";const nt=(Ae%d+d)%d;return a(Ze)(new Date(nt))}function b(Ae){return Ae instanceof Date?!Number.isNaN(Ae.getTime()):typeof Ae=="number"?Number.isFinite(Ae)&&Ae>=0&&Ae<d:typeof Ae!="string"||!Ae.includes(":")?!1:m(Ae)!==null}function O(Ae){const Ge=c(Ae);return Ge==null?"":p(Ge,{pattern:Ge%A===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const k=new Map;function y(Ae){const Ge=Ae||"";let Ze=k.get(Ge);return Ze||(Ze=new Intl.DateTimeFormat("en-GB",{timeZone:Ae||void 0,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),k.set(Ge,Ze)),Ze}function v(Ae,Ge){const Ze={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const nt of y(Ge).formatToParts(new Date(Ae)))nt.type==="year"?Ze.year=Number(nt.value):nt.type==="month"?Ze.month=Number(nt.value):nt.type==="day"?Ze.day=Number(nt.value):nt.type==="hour"?Ze.hour=Number(nt.value)%24:nt.type==="minute"?Ze.minute=Number(nt.value):nt.type==="second"&&(Ze.second=Number(nt.value));return Ze}function R(Ae,Ge){const Ze=v(Ae,Ge);return Date.UTC(Ze.year,Ze.month-1,Ze.day,Ze.hour,Ze.minute,Ze.second,0)-Math.floor(Ae/1e3)*1e3}function S(Ae,Ge){const Ze=Ae.hour||0,nt=Ae.minute||0,lt=Ae.second||0,ft=Ae.ms||0;if(!Ge)return new Date(Ae.year,Ae.month-1,Ae.day,Ze,nt,lt,ft).getTime();const gt=Date.UTC(Ae.year,Ae.month-1,Ae.day,Ze,nt,lt,ft);let At=gt-R(gt,Ge);return At=gt-R(At,Ge),At}const x=/(?:Z|[+-]\d{2}:?\d{2})$/i,C=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function P(Ae,Ge){if($(Ae))return null;const Ze=String(Ae).trim();if(Ze==="")return null;const nt=Ge&&Ge.timeZone||void 0;if(!x.test(Ze)){const lt=C.exec(Ze);if(lt){const ft=(lt[4]||"").trim(),gt=ft===""?0:m(ft);if(gt===null)return null;const At=S({year:Number(lt[1]),month:Number(lt[2]),day:Number(lt[3]),hour:Math.floor(gt/l),minute:Math.floor(gt/g)%60,second:Math.floor(gt/A)%60,ms:gt%A},nt);return Number.isNaN(At)?null:new Date(At)}}return _(Ze)}function F(Ae){if(typeof Ae=="number")return Number.isFinite(Ae)?Ae:null;const Ge=_(Ae);return Ge?Ge.getTime():null}const E=new Map;function D(Ae){const Ge=[Ae.locale||"",Ae.pattern||"",Ae.dateStyle||"",Ae.timeStyle||"",Ae.timeZone||"",Ae.seconds?"1":""].join("|");let Ze=E.get(Ge);if(Ze)return Ze;const nt=Ae.pattern?{type:"date",pattern:Ae.pattern,timeZone:Ae.timeZone}:{type:"date",dateStyle:Ae.dateStyle||"medium",timeStyle:Ae.timeStyle||(Ae.seconds?"medium":"short"),timeZone:Ae.timeZone};return Ze=W(nt,Ae.locale||void 0),E.set(Ge,Ze),Ze}function N(Ae,Ge){const Ze=Ge||w,nt=F(Ae);return nt==null?Ze.nullDisplay??"":D(Ze)(nt)}function M(Ae){return Ae instanceof Date?!Number.isNaN(Ae.getTime()):typeof Ae!="string"||!C.test(Ae.trim())?!1:P(Ae)!==null}const j=Object.freeze([{key:"w",ms:o,intl:"week",long:["week","weeks"],names:["w","wk","wks","week","weeks"]},{key:"d",ms:d,intl:"day",long:["day","days"],names:["d","dy","day","days"]},{key:"h",ms:l,intl:"hour",long:["hour","hours"],names:["h","hr","hrs","hour","hours"]},{key:"m",ms:g,intl:"minute",long:["minute","minutes"],names:["m","min","mins","minute","minutes"]},{key:"s",ms:A,intl:"second",long:["second","seconds"],names:["s","sec","secs","second","seconds"]},{key:"ms",ms:1,intl:"millisecond",long:["millisecond","milliseconds"],names:["ms","msec","msecs","milli","millis","millisecond","milliseconds"]}]),L=new Map;for(const Ae of j)for(const Ge of Ae.names)L.set(Ge,Ae);const G=Object.freeze(j.filter(Ae=>Ae.key!=="w")),q=/^(\d+(?:\.\d+)?)\s*([a-z]+)\s*(?:,\s*)?/,Y=/^\d+(?:\.\d+)?$/,J=/^(\d+):([0-5]?\d)(?::([0-5]?\d))?(?:\.(\d{1,3}))?$/;function ee(Ae){const Ge=Ae&&Ae.defaultUnit?L.get(String(Ae.defaultUnit).toLowerCase()):null;return Ge?Ge.ms:g}function ne(Ae){return(Ae&&Ae.defaultUnit?L.get(String(Ae.defaultUnit).toLowerCase()):null)||L.get("m")}function ie(Ae,Ge){if($(Ae))return null;let Ze=String(Ae).trim().toLowerCase();if(Ze==="")return null;let nt=1;if(Ze[0]==="-"?(nt=-1,Ze=Ze.slice(1).trim()):Ze[0]==="+"&&(Ze=Ze.slice(1).trim()),Ze==="")return null;const lt=J.exec(Ze);if(lt){const Pt=lt[3]!==void 0,Ct=Number(lt[1])*l+Number(lt[2])*g+(Pt?Number(lt[3])*A:0)+(lt[4]?Number(lt[4].padEnd(3,"0")):0);return nt*Ct}if(Y.test(Ze))return Math.round(nt*Number(Ze)*ee(Ge||w));let ft=Ze,gt=0,At=0;for(;ft!=="";){const Pt=q.exec(ft);if(!Pt)return null;const Ct=L.get(Pt[2]);if(!Ct)return null;gt+=Number(Pt[1])*Ct.ms,ft=ft.slice(Pt[0].length),At++}return At===0?null:Math.round(nt*gt)}function se(Ae){return $(Ae)||Ae===""?null:typeof Ae=="number"?Number.isFinite(Ae)?Ae:null:ie(Ae)}const he=new Map;function ce(Ae,Ge,Ze){const nt=`${Ze||""}|${Ge.intl}`;let lt=he.get(nt);if(lt===void 0){try{lt=new Intl.NumberFormat(Ze||void 0,{style:"unit",unit:Ge.intl,unitDisplay:"long"})}catch{lt=null}he.set(nt,lt)}return lt?lt.format(Ae):`${Ae} ${Ae===1?Ge.long[0]:Ge.long[1]}`}function te(Ae,Ge){return String(Ae).padStart(Ge,"0")}function oe(Ae,Ge){const Ze=Ge||w;if(Ae==null||typeof Ae!="number"||!Number.isFinite(Ae))return Ze.nullDisplay??"";const nt=Ze.style||"short",lt=Ae<0;let ft=Math.round(Math.abs(Ae));const gt=lt?"-":"";if(ft===0&&Ze.zeroDisplay!=null)return Ze.zeroDisplay;if(nt==="clock"){const Mt=Math.floor(ft/l),Dt=Math.floor(ft/g)%60,Bt=Math.floor(ft/A)%60;return`${gt}${te(Mt,2)}:${te(Dt,2)}:${te(Bt,2)}`}if(ft===0){const Mt=ne(Ze);return nt==="long"?ce(0,Mt,Ze.locale):`0${Mt.key}`}const At=Ze.weeks===!0?j:G,Pt=typeof Ze.maxUnits=="number"&&Ze.maxUnits>0?Ze.maxUnits:Ze.maxUnits===void 0?2:1/0,Ct=[];for(const Mt of At){if(Ct.length>=Pt)break;const Dt=Math.floor(ft/Mt.ms);Dt!==0&&(ft-=Dt*Mt.ms,Ct.push(nt==="long"?ce(Dt,Mt,Ze.locale):`${Dt}${Mt.key}`))}return gt+Ct.join(" ")}function fe(Ae){if(typeof Ae!="string")return!1;const Ge=Ae.trim();return Ge===""||J.test(Ge)||!/[a-z]/i.test(Ge)?!1:ie(Ge)!==null}const de=Date.UTC(1899,11,30),ve=new Map;function Me(Ae,Ge){const Ze=Ae||"";let nt=ve.get(Ze);nt||(nt=new Intl.DateTimeFormat("en-GB",{timeZone:Ae||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),ve.set(Ze,nt));const lt=typeof Ge=="number"?Ge:Date.now();for(const ft of nt.formatToParts(new Date(lt)))if(ft.type==="timeZoneName")return ft.value;return""}function Oe(Ae){if(Ae)return Ae;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function Ce(Ae,Ge){const Ze=Oe(Ae),nt=Me(Ae,Ge);return nt?`${Ze} (${nt})`:Ze}function pe(Ae,Ge){if(Ae&&Ae.timeZone)return Ae.timeZone;const Ze=Ge&&Ge.grid;return(Ze&&B(Ze.get)?Ze.get("timeZone"):void 0)||void 0}function we(Ae,Ge){const Ze=Ge||w,nt=F(Ae);if(nt==null)return Ze.nullDisplay??"";const lt=D(Ze)(nt);if(!Ze.showOrigin)return lt;const ft=Ze.originZone;return ft?ft===(Ze.timeZone||Oe(Ze.timeZone))?lt:`${lt} (${Ce(ft,nt)})`:`${lt} (no origin recorded)`}function me(Ae,Ge,Ze,nt){if(Ge==="instant"||!Ge)return Ae;const lt=v(Ae,Ze);if(Ge==="month")return S({year:lt.year,month:lt.month,day:1},Ze);if(Ge==="week"){const ft=nt>=1&&nt<=7?nt:1,At=((new Date(Date.UTC(lt.year,lt.month-1,lt.day)).getUTCDay()+6)%7+1-ft+7)%7,Pt=new Date(Date.UTC(lt.year,lt.month-1,lt.day-At));return S({year:Pt.getUTCFullYear(),month:Pt.getUTCMonth()+1,day:Pt.getUTCDate()},Ze)}return S({year:lt.year,month:lt.month,day:lt.day},Ze)}function Ne(Ae,Ge){const Ze=Ae&&Ae.group,nt=Ze&&Ze.granularity||"day";if(nt==="instant")return null;const lt=Ze&&Ze.weekStart;return ft=>typeof ft=="number"?me(ft,nt,Ge,lt):ft}const $e={time:{base:"number",storage:"float64",matches:b,format:Ae=>p(c(Ae.value),t(Ae,"time")),parse:Ae=>m(Ae.text),compare:(Ae,Ge)=>s(c(Ae),c(Ge)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:Ae=>{const Ge=c(Ae);return Ge===null?null:Ge/z},toStorage:Ae=>c(Ae),toClipboard:O,fromClipboard:m},datetime:{base:"dateString",storage:"dictionary",matches:M,format:Ae=>N(Ae.value,t(Ae,"datetime")),parse:Ae=>H(P(Ae.text,t(Ae,"datetime"))??Ae.text),compare:V,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(Ae,Ge)=>H(Ae,Ge&&Ge.timeZone),toClipboard:Ae=>$(Ae)?"":String(Ae),fromClipboard:Ae=>H(Ae)},duration:{base:"number",storage:"float64",matches:fe,format:Ae=>oe(se(Ae.value),t(Ae,"duration")),parse:Ae=>ie(Ae.text,t(Ae,"duration")),compare:(Ae,Ge)=>s(se(Ae),se(Ge)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:Ae=>{const Ge=se(Ae);return Ge===null?null:Ge/z},toStorage:Ae=>se(Ae),toClipboard:Ae=>oe(se(Ae),{style:"short",maxUnits:-1}),fromClipboard:Ae=>ie(Ae)},timestamp:{base:"number",storage:"float64",format:Ae=>{const Ge=t(Ae,"timestamp");return we(Ae.value,{...Ge,timeZone:pe(Ge,Ae)})},parse:Ae=>{const Ge=t(Ae,"timestamp"),Ze=P(Ae.text,{timeZone:pe(Ge,Ae)});return Ze?Ze.getTime():null},compare:(Ae,Ge)=>s(F(Ae),F(Ge)),groupProjector:(Ae,Ge)=>Ne(Ae,Ge),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(Ae,Ge)=>{const Ze=F(Ae);if(Ze==null)return null;const nt=v(Ze,Ge&&Ge.timeZone||void 0);return(Date.UTC(nt.year,nt.month-1,nt.day,nt.hour,nt.minute,nt.second)-de)/z},toStorage:Ae=>F(Ae),toClipboard:Ae=>{const Ge=F(Ae);return Ge==null?"":new Date(Ge).toISOString()},fromClipboard:Ae=>F(Ae)}},He=["datetime","time","duration"],qe=$e}),Fe("packages/core/src/columns/types/network.js",function(e,K){"use strict";Object.defineProperty(e,"toUint32",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"isIpv4",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"compareIpv4",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"packCidr",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"cidrParts",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isCidr",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"compareCidr",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"netmask",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"addressCount",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"ipv6Groups",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"isIpv6",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return P}});const Q=K("packages/core/src/internal/util.js"),$=Q.isNil,B=Q.Lru,I=4294967295,_=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function X(F){if($(F))return null;if(typeof F=="string")return W(F);const E=Number(F);return Number.isFinite(E)?E<0?E<-2147483648?null:E>>>0:E>I?null:Math.trunc(E)>>>0:null}function W(F){if($(F))return null;const E=String(F).trim();if(E==="")return null;const D=_.exec(E);if(!D)return null;let N=0;for(let M=1;M<=4;M++){const j=D[M];if(j.length>1&&j.charCodeAt(0)===48)return null;const L=Number(j);if(L>255)return null;N=N*256+L}return N}function H(F){const E=X(F);return E===null?"":`${E>>>24&255}.${E>>>16&255}.${E>>>8&255}.${E&255}`}function V(F){return typeof F=="string"&&W(F)!==null}function z(F,E){const D=X(F),N=X(E);return D===null?N===null?0:1:N===null||D<N?-1:D>N?1:0}const w=64,A=I*w+32,g=/^(?:0|[1-9]\d?)$/;function l(F,E){return F*w+E}function d(F){if($(F))return null;if(typeof F=="string"){const N=o(F);return N===null?null:d(N)}if(typeof F=="object"){const N=X(F.address),M=Number(F.prefix);return N===null||!Number.isInteger(M)||M<0||M>32?null:{address:N,prefix:M}}const E=Number(F);if(!Number.isInteger(E)||E<0||E>A)return null;const D=E%w;return D>32?null:{address:(E-D)/w,prefix:D}}function o(F){if($(F))return null;const E=String(F).trim();if(E==="")return null;const D=E.indexOf("/");if(D<0)return null;const N=W(E.slice(0,D));if(N===null)return null;const M=E.slice(D+1).trim();if(!g.test(M))return null;const j=Number(M);return j>32?null:l(N,j)}function n(F){const E=d(F);return E?`${H(E.address)}/${E.prefix}`:""}function t(F){return typeof F=="string"&&o(F)!==null}function r(F,E){const D=d(F),N=d(E);return D?N?D.address!==N.address?D.address<N.address?-1:1:D.prefix-N.prefix:-1:N?1:0}function s(F){return F===0?0:4294967295<<32-F>>>0}function h(F){const E=d(F);return E?(E.address&s(E.prefix))>>>0:null}function u(F){const E=d(F);return E?(E.address&s(E.prefix)|~s(E.prefix)>>>0)>>>0:null}function i(F){const E=d(F);return E?2**(32-E.prefix):null}function m(F){const E=d(F);return E?E.prefix===32?1:E.prefix===31?2:2**(32-E.prefix)-2:null}function c(F,E){const D=d(F);if(!D)return!1;const N=X(E);if(N===null)return!1;const M=s(D.prefix);return(N&M)>>>0===(D.address&M)>>>0}function f(F,E){const D=h(F),N=h(E);return D===null||N===null?!1:D<=u(E)&&N<=u(F)}const a=/^[0-9a-fA-F]{1,4}$/,p=new B(512);function b(F){if($(F))return null;let E=String(F).trim();if(E==="")return null;const D=E.indexOf("%");if(D>=0&&(E=E.slice(0,D)),E==="")return null;if(E.indexOf(".")>=0){const q=E.lastIndexOf(":");if(q<0)return null;const Y=W(E.slice(q+1));if(Y===null)return null;E=`${E.slice(0,q+1)}${(Y>>>16&65535).toString(16)}:${(Y&65535).toString(16)}`}const N=E.split("::");if(N.length>2)return null;const M=O(N[0]);if(M===null)return null;if(N.length===1)return M.length===8?M:null;const j=O(N[1]);if(j===null)return null;const L=8-M.length-j.length;if(L<1)return null;const G=M.slice();for(let q=0;q<L;q++)G.push(0);for(const q of j)G.push(q);return G}function O(F){if(F==="")return[];const E=[];for(const D of F.split(":")){if(!a.test(D))return null;E.push(parseInt(D,16))}return E}function k(F){if(typeof F!="string")return b(F);if(p.has(F))return p.get(F);const E=b(F);return p.set(F,E),E}function y(F){if(F[0]===0&&F[1]===0&&F[2]===0&&F[3]===0&&F[4]===0&&F[5]===65535)return`::ffff:${H((F[6]<<16|F[7])>>>0)}`;let E=-1,D=0,N=-1,M=0;for(let G=0;G<8;G++)F[G]===0?(N<0?(N=G,M=1):M++,M>D&&(D=M,E=N)):(N=-1,M=0);if(D<2)return F.map(G=>G.toString(16)).join(":");const j=F.slice(0,E).map(G=>G.toString(16)).join(":"),L=F.slice(E+D).map(G=>G.toString(16)).join(":");return`${j}::${L}`}function v(F){const E=b(F);return E===null?null:y(E)}function R(F){return v(F)??""}function S(F){return typeof F=="string"&&F.indexOf(":")>=0&&b(F)!==null}function x(F,E){const D=k(F),N=k(E);if(!D)return N?1:0;if(!N)return-1;for(let M=0;M<8;M++)if(D[M]!==N[M])return D[M]<N[M]?-1:1;return 0}const C=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:V,parse:F=>W(F.text),compare:z,format:F=>H(F.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:F=>X(F),toClipboard:F=>H(F),fromClipboard:F=>W(F)},cidr:{base:"number",storage:"float64",matches:t,parse:F=>o(F.text),compare:r,format:F=>n(F.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:F=>{const E=d(F);return E===null?null:l(E.address,E.prefix)},toClipboard:F=>n(F),fromClipboard:F=>o(F)},ipv6:{base:"text",storage:"dictionary",matches:S,parse:F=>v(F.text),compare:x,format:F=>R(F.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",toStorage:F=>v(F),toClipboard:F=>R(F),fromClipboard:F=>v(F)}}),P=C}),Fe("packages/core/src/i18n/catalogue.js",function(e,K){"use strict";Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return I}});const $=K("packages/core/src/registry/free-tier-notice.js").FREE_TIER_NOTICE,B=Object.freeze({"count.rows":{one:"{count} row",other:"{count} rows"},"count.comments":{one:"{count} comment",other:"{count} comments"},"comments.someUnresolved":"{comments}, {unresolved} unresolved","comments.allResolved":"{comments}, all resolved","count.unresolvedComments":{one:"{count} unresolved comment",other:"{count} unresolved comments"},"count.items":{one:"{count} item",other:"{count} items"},"count.keys":{one:"{count} key",other:"{count} keys"},"count.values":{one:"value",other:"values"},"count.waiting":{one:"{count} waiting",other:"{count} waiting"},"count.rowsAdded":{one:"{count} row added",other:"{count} rows added"},"count.rowsRemoved":{one:"{count} row removed",other:"{count} rows removed"},"value.empty":"empty","a11y.sort.cleared":"Sort cleared","a11y.sort.by":"Sorted by {columns}","a11y.sort.column":"{column} {direction}","a11y.sort.ascending":"ascending","a11y.sort.descending":"descending","a11y.filter.cleared":"Filter cleared, {rows}","a11y.filter.applied":"Filtered to {shown} of {total}","a11y.find.count":{one:"{current} of {count} match",other:"{current} of {count} matches"},"a11y.find.countLoaded":{one:"{current} of {count} match in loaded rows",other:"{current} of {count} matches in loaded rows"},"a11y.find.none":"No matches","a11y.find.noneLoaded":"No matches in loaded rows","a11y.selection.cleared":"Selection cleared","a11y.selection.count":{one:"{count} row selected",other:"{count} rows selected"},"tabs.tablist":"Tabs","a11y.tabs.selected":"{label} tab selected","a11y.scrollbar.horizontal":"Horizontal scrollbar","a11y.scrollbar.vertical":"Vertical scrollbar","layout.region":"Dashboard layout","layout.move":"Move {title}","layout.resize":"Resize {title}","layout.close":"Close {title}","a11y.layout.grabbed":"{title} grabbed, column {x} of {columns}, row {y}","a11y.layout.position":"{title}, column {x} of {columns}, row {y}","a11y.layout.dropped":"{title} dropped, column {x} of {columns}, row {y}","a11y.layout.cancelled":"{title} move cancelled","a11y.layout.resizeCancelled":"{title} resize cancelled","a11y.layout.reverted":"{title} returned to column {x}, row {y}","a11y.layout.resizeGrabbed":"{title} resize grabbed, {w} by {h} cells","a11y.layout.resizeStep":"{title}, {w} by {h} cells","a11y.layout.resized":"{title} resized to {w} by {h} cells","a11y.layout.closed":"{title} closed","layout.maximise":"Maximise {title}","layout.minimise":"Minimise {title}","layout.restore":"Restore {title}","a11y.layout.maximised":"{title} maximised, filling the dashboard; press Escape to restore it","a11y.layout.minimised":"{title} minimised","a11y.layout.restored":"{title} restored to column {x}, row {y}","a11y.group.cleared":"Grouping cleared","a11y.group.by":"Grouped by {columns}","a11y.group.expanded":"{label} expanded, {rows} shown","a11y.group.collapsed":"{label} collapsed, {rows} shown","a11y.page.position":"Page {page} of {pages}","a11y.updates.paused":"Updates paused","a11y.updates.resumed":"Updates resumed","a11y.edit.refusedOne":"Edit to {column} was refused and put back to {value}{reason}","a11y.edit.refusedMany":{one:"{count} edit was refused and put back{reason}",other:"{count} edits were refused and put back{reason}"},"a11y.edit.reason":", {reason}","a11y.history.undo":"Undid {label}","a11y.history.redo":"Redid {label}","a11y.history.undoLast":"Undid the last change","a11y.history.redoLast":"Redid the last change","a11y.column.cannotResize":"{column} cannot be resized","a11y.column.resized":"{column} is {width} pixels wide","a11y.column.atMinimum":"{column} is at its narrowest, {width} pixels","a11y.column.atMaximum":"{column} is at its widest, {width} pixels","a11y.column.cannotMove":"{column} cannot be moved","a11y.column.alreadyFirst":"{column} is already first in its group","a11y.column.alreadyLast":"{column} is already last in its group","a11y.column.cannotMoveThere":"{column} cannot be moved there","a11y.column.moved":"{column} moved to position {at} of {of}","a11y.group.formed":"{column} grouped with {other} in a new band","a11y.group.dissolved":"band {group} dissolved","a11y.group.renamed":"band renamed to {group}","a11y.group.moved":"band {group} moved to position {at} of {of}","a11y.column.addedToGroup":"{column} added to band {group}","a11y.column.removedFromGroup":"{column} removed from its band","a11y.column.notInGroup":"{column} is not in a band","a11y.column.cannotGroup":"{column} cannot be grouped","a11y.group.cannotMove":"band {group} cannot be moved there","columngroup.newGroup":"New group","columngroup.rename":"Rename band","columngroup.dissolve":"Dissolve band","columngroup.group":"Group with adjacent column","columngroup.untitled":"Untitled band","panel.bandCollapse":"Collapse band {band}","panel.bandExpand":"Expand band {band}","panel.bandVisible":"Show or hide every column in band {band}","panel.bandRenameFor":"Rename band {band}","panel.bandDissolveFor":"Dissolve band {band}","header.filter":"Filter {column}","header.menu":"Column menu for {column}","header.toggleGroup":"Toggle {group}","header.dragHint":"Drag {column} to reorder, or onto another column to group","header.dragRole":"draggable column header","header.group":"group","header.selectAllRows":"Select all rows","header.clearSelection":"Clear selection","cell.selectRow":"Select row","cell.detail.show":"Show detail","cell.detail.hide":"Hide detail","cell.detail.showInPane":"Show in the detail pane","cell.detail.showingInPane":"Showing in the detail pane","cell.group.expand":"Expand","cell.group.collapse":"Collapse","cell.delta.up":"up","cell.delta.down":"down","cell.delta.unchanged":"unchanged","cell.delta.moved":"{direction} {magnitude}","cell.delta.describedUnchanged":"{label}, unchanged","cell.delta.described":"{label}, {direction} by {magnitude}","cell.qr.of":"QR code for {text}","cell.qr.empty":"No QR code","cell.rating.of":"{rating} of {max}","cell.rating.empty":"Not rated","a11y.panel.cannotMove":"{column} cannot be moved","a11y.panel.alreadyFirst":"{column} is already first","a11y.panel.alreadyLast":"{column} is already last","a11y.panel.moved":"{column} moved to position {at} of {of}","a11y.panel.removedFrom":"{column} removed from {list}","a11y.panel.addedTo":"{column} added to {list}","a11y.panel.cannotAddTo":"{column} cannot be added to {list}","a11y.annotate.erased":"Annotation removed","a11y.annotate.noMarks":"No annotations to erase","a11y.annotate.focusedMark":"Mark {at} of {of} selected","a11y.annotate.confirmClear":"Clear all annotations? Choose Clear or Keep.","a11y.annotate.cleared":"All annotations cleared","a11y.range.written":{one:"{count} cell updated",other:"{count} cells updated"},"a11y.range.cleared":{one:"{count} cell cleared",other:"{count} cells cleared"},"paste.preview.title":"Review paste","paste.preview.summary":{one:"{changes} cell will change, {rejected} rejected.",other:"{changes} cells will change, {rejected} rejected."},"paste.preview.changesHeading":{one:"{count} change",other:"{count} changes"},"paste.preview.rejectedHeading":{one:"{count} rejected",other:"{count} rejected"},"paste.preview.colOld":"Current","paste.preview.colNew":"New","paste.preview.colCell":"Cell","paste.preview.colReason":"Reason","paste.preview.empty":"This paste would change nothing.","paste.preview.confirm":"Apply","paste.preview.cancel":"Cancel","paste.preview.reason.permission":"Not permitted","paste.preview.reason.readOnly":"Read-only","paste.preview.reason.validation":"Invalid value","paste.preview.reason.locked":"Being edited","paste.preview.reason.missing":"No such cell","a11y.paste.previewOpened":{one:"Paste preview: {changes} cell changes, {rejected} rejected. Review, then apply or cancel.",other:"Paste preview: {changes} cell changes, {rejected} rejected. Review, then apply or cancel."},"a11y.paste.cancelled":"Paste cancelled; nothing changed","status.total":"{rows}","status.counting":"Counting rows…","status.shownOfTotal":"{shown} of {total}","status.selected":"{count} selected","status.selectedAcrossSource":"{count} selected across the source","status.selectedAcrossSourceCounting":"All matching rows selected, counting…","status.count":"Count {count}","status.loading":"Loading {count}…","status.loadingOf":"Loading {loaded} of {total} ({percent}%)","status.stat.sum":"Sum","status.stat.min":"Min","status.stat.max":"Max","status.stat.avg":"Avg","status.paused":"Paused","status.pausedWaiting":"Paused · {waiting}","status.coalesced":"{count} coalesced","status.hiddenComments":"{comments} on hidden rows","pagination.label":"Pagination","pagination.first":"First page","pagination.previous":"Previous page","pagination.next":"Next page","pagination.last":"Last page","pagination.page":"Page","pagination.ofPages":"of {pages}","pagination.summary":"{from}–{to} of {total}","pagination.pageSize":"Rows per page","pagination.range":"{from}–{to}","pagination.counting":"{from}–{to}, counting…","pagination.jump":"Page number, press Enter to jump","pagination.jumpBounded":"Page number, 1 to {pages}, press Enter to jump","panel.columns":"Columns","panel.filters":"Filters","panel.views":"Views","panel.quickFilter":"Quick filter","find.label":"Find in grid","find.placeholder":"Find in grid","find.next":"Next match","find.previous":"Previous match","find.close":"Close find","find.matchCase":"Match case","find.wholeCell":"Whole cell","find.columnScope":"Search in","find.allColumns":"All columns","find.count":"{current} of {total}","find.countPartial":"{current} of {total} so far","find.none":"No matches","find.searching":"Searching…","find.loadedRows":"in loaded rows","panel.formatting":"Formatting","panel.statistics":"Statistics","stat.noData":"No data","stat.tone.good":"good","stat.tone.bad":"bad","stat.tone.flat":"flat","panel.regression":"Regression","panel.compare":"Compare","panel.insights":"Insights","insights.subset":"Filtered subset vs whole","insights.dataset":"This grid vs another dataset","insights.groups":"Group comparison","insights.noFilter":"Filter the grid to compare the subset against the whole.","insights.by":"Group by","insights.test":"Test","insights.effect":"Effect size","insights.interval":"Confidence interval","insights.pValue":"p-value","insights.smallSample":"small sample — interpret with care","insights.needGroups":"Choose two columns with groups to compare.","insights.empty":"No columns to analyse.","insights.anomalies":"Anomalies","insights.anomalyCount":"{count} flagged of {n}","insights.anomalyMethod":"Method","insights.anomalyThreshold":"Threshold","anomaly.chip":"{count} anomalies flagged","anomaly.chipActive":"Showing {count} anomalies — clear","compare.first":"First column","compare.second":"Second column","compare.needTwo":"Two numeric columns are needed to compare","compare.noPairs":"No rows have a value in both","compare.pairs":"{count} pairs","compare.pearson":"Correlation (Pearson)","compare.spearman":"Rank correlation (Spearman)","compare.kendall":"Kendall’s tau","compare.covariance":"Covariance","compare.slope":"Slope","compare.intercept":"Intercept","compare.r2":"R²","compare.stdError":"Standard error","compare.weighted":"Weighted average","panel.zone.group":"row groups","panel.zone.values":"values","panel.zone.pivot":"pivot columns","groupZone.label":"Row groups","groupZone.title":"Group by","groupZone.hint":"Drag a column here to group rows by its values","groupZone.chip":"{column}, group {at} of {of}","groupZone.remove":"Stop grouping by {column}","groupZone.add":"Add a group","total.sum":"Sum","total.avg":"Average","total.min":"Min","total.max":"Max","total.count":"Count","total.countValues":"Count of values","total.first":"First","total.last":"Last","total.custom":"Total","total.median":"Median","total.p25":"25th percentile","total.p75":"75th percentile","total.p90":"90th percentile","total.p95":"95th percentile","total.p99":"99th percentile","total.iqr":"Interquartile range","total.mad":"Median absolute deviation","total.variance":"Variance","total.varianceP":"Variance (population)","total.stddev":"Standard deviation","total.stddevP":"Standard deviation (population)","total.range":"Range","total.distinct":"Distinct","total.mode":"Mode","total.skewness":"Skewness","total.kurtosis":"Kurtosis","total.geomean":"Geometric mean","total.harmean":"Harmonic mean","total.sumSquares":"Sum of squares","total.weightedAvg":"Weighted average","total.argmin":"Lowest by","total.argmax":"Highest by","total.hhi":"Concentration (HHI)","total.entropy":"Entropy","total.evenness":"Evenness","total.top3Share":"Top 3 share","total.top10Share":"Top 10 share","total.gini":"Gini coefficient","total.trimmedMean":"Trimmed mean","total.winsorizedMean":"Winsorized mean","total.robustOutliers":"Outliers (robust)","total.jarqueBera":"Jarque–Bera","total.passRate":"Pass rate","total.failureCount":"Failures","stats.column":"Column","stats.choose":"Choose a column to profile","stats.noColumns":"No numeric columns to profile","stats.noValues":"Nothing numeric in this column","stats.count":"Count","stats.present":"Present","stats.missing":"Missing","stats.distinct":"Distinct","stats.min":"Minimum","stats.max":"Maximum","stats.mean":"Mean","stats.median":"Median","stats.q1":"Lower quartile","stats.q3":"Upper quartile","stats.iqr":"Interquartile range","stats.stddev":"Standard deviation","stats.outliers":"Outliers","stats.distribution":"Distribution","stats.bin":"{count} between {from} and {to}","stats.topValues":"Top values","stats.section.shape":"Shape","stats.section.robust":"Robust","stats.section.concentration":"Concentration","stats.section.capability":"Capability","stats.cp":"Cp","stats.cpk":"Cpk","stats.pp":"Pp","stats.ppk":"Ppk","stats.outOfSpec":"Out of specification","stats.filtered":"Over the {count} filtered rows","stats.unavailable":"Not computed by the source: {stats}.","stats.unavailable.notPlain":"`{column}` is not a plain column the engine can name","stats.unavailable.where":"a `where` predicate is in force ({list}), which only the browser can run","stats.unavailable.filter":"the grid's filter did not fully push to the engine","stats.unavailable.quick":"the quick search did not push to the engine","stats.unavailable.client":'the source did not compute "{fn}" in the engine ({reason}); set the pushdown source\'s `{setting}`',"stats.unavailable.outliers":"the count of values outside Tukey's fences is not an engine aggregate","stats.unavailable.histogram":"the shape of the column is not an engine aggregate","stats.unavailable.topValues":"the source did not answer a grouped count in the engine","regression.noModel":"No model configured. Set predictors and a response on the panel.","regression.cannotFit":"The model cannot be fitted over the current rows.","regression.observations":"Fitted over {count} rows","regression.r2":"R²","regression.adjR2":"Adjusted R²","regression.coefficients":"Coefficients","regression.term":"Term","regression.estimate":"Estimate ± SE","regression.stdError":"Std error","regression.t":"t","regression.p":"p","regression.vif":"Variance inflation (VIF)","regression.heteroscedasticity":"Heteroscedasticity (Breusch–Pagan)","regression.heteroscedastic":"Heteroscedastic: BP {statistic}, p {p}","regression.homoscedastic":"No heteroscedasticity detected: BP {statistic}, p {p}","menu.sortAscending":"Sort ascending","menu.sortDescending":"Sort descending","menu.clearSort":"Clear sort","menu.groupBy":"Group by this column","menu.ungroup":"Stop grouping by this column","menu.hideColumn":"Hide column","menu.pinStart":"Pin to start","menu.pinEnd":"Pin to end","menu.unpin":"Unpin","menu.autosize":"Fit to content","ai.valuesNotAmongOptions":'{values} {shown} not among the options for "{column}"',"menu.clearCells":{one:"Clear cell",other:"Clear {count} cells"},"menu.fillDown":"Fill down","menu.copy":"Copy","menu.copyWithHeaders":"Copy with headers","menu.paste":"Paste","menu.filterEllipsis":"Filter…","menu.columnStatistics":"Column statistics","menu.pinColumn":"Pin column","menu.sizeToFit":"Size to fit content","menu.sizeAllToFit":"Size all columns to fit","menu.width":"Width","menu.narrower":"Narrower","menu.wider":"Wider","menu.moveColumn":"Move column","menu.moveLeft":"Move left","menu.moveRight":"Move right","menu.moveToStart":"Move to start","menu.moveToEnd":"Move to end","menu.unpivot":"Remove from pivot","menu.pivotBy":"Pivot by this column","menu.stopTotalling":"Stop totalling","menu.totalColumn":"Total this column","menu.aggregate":"Aggregate","menu.aggregateNone":"None","menu.aggregateGroup":"Group subtotals","menu.aggregateGrand":"Grand total","menu.aggregateSame":"Same as total","menu.redactColumn":"Redact column","menu.stopRedacting":"Stop redacting","menu.stopRedactingAll":"Stop redacting everything","menu.sortGroupsAscending":"Sort groups ascending","menu.sortGroupsDescending":"Sort groups descending","menu.filterGroups":"Filter groups…","menu.expandAll":"Expand all","menu.collapseAll":"Collapse all","menu.clearGrouping":"Clear grouping","menu.colour":"Colour","menu.importCsv":"Import rows from CSV…","import.title":"Import rows","import.clipboard":"the clipboard","import.summary":{one:"{count} row from {name}",other:"{count} rows from {name}"},"import.opened":{one:"Import preview open, {count} row",other:"Import preview open, {count} rows"},"import.done":{one:"{count} row imported",other:"{count} rows imported"},"import.confirm":"Import","import.cancel":"Cancel","import.colSource":"Column","import.colField":"Maps to","import.colType":"Type","import.skip":"— skip —","import.mapLabel":'Map "{source}" to a field',"import.modeLabel":"On import","import.append":"Add to existing rows","import.replace":"Replace all rows","menu.deleteRow":{one:"Delete row",other:"Delete {count} rows"},"toolbar.undo":"Undo","toolbar.redo":"Redo","toolbar.undoLabelled":"Undo {label}","toolbar.redoLabelled":"Redo {label}","toolbar.exportCsv":"Export to CSV","toolbar.exportExcel":"Export to Excel","toolbar.clipboard":"Copy visible rows to the clipboard","toolbar.print":"Print","toolbar.pause":"Hold incoming updates","toolbar.resume":"Resume updates","toolbar.applyHeld":{one:"Apply {count} held update",other:"Apply {count} held updates"},"toolbar.restoreView":"Restore the default view","toolbar.maximiseGrid":"Maximise the grid to fill the window","toolbar.restoreSize":"Restore the grid to the page (Esc)","toolbar.annotate.pen":"Draw freehand","toolbar.annotate.arrow":"Draw an arrow","toolbar.annotate.rect":"Draw a rectangle","toolbar.annotate.highlight":"Highlight","toolbar.annotate.erase":"Erase","toolbar.annotate.clearAll":"Clear all annotations","toolbar.annotate.clearAllConfirm":"Clear","toolbar.annotate.clearAllKeep":"Keep","overlay.noRows":"No rows to show","overlay.noResults":"No rows match the current filters","overlay.loading":"Loading…","overlay.error":"Something went wrong","overlay.loadingRows":"Loading rows {from} to {to}","overlay.rowError":"Failed to load","comments.panel":"Cell comments","comments.close":"Close comments","comments.write":"Write a comment","comments.post":"Comment","comments.delete":"Delete","comments.valueMoved":"Written when the value was {was}: it is now {now}.","comments.resolve":"Resolve","comments.reopen":"Reopen","comments.loading":"Loading…","comments.empty":"No comments yet.","comments.unknownAuthor":"Unknown","comments.edited":"{time} (edited)","comments.cellTitle":"{column}: {row}","presence.hidden":{one:"{count} not in view",other:"{count} not in view"},"presence.someoneElse":"someone else","a11y.presence.refused":"This cell is being edited by {name}","presence.peer":"{name}: jump to their cursor","presence.peerIdle":"{name}, idle: jump to their cursor","presence.peerHidden":"{name}, not in the current view","facets.filter":"{column} distribution filter","header.totalOf":"{total} of {column}","diff.before":"Was: {value}","diff.empty":"(empty)","kanban.columnCards":{one:"{title}, {count} card",other:"{title}, {count} cards"},"kanban.laneCards":{one:"{lane}, {title}, {count} card",other:"{lane}, {title}, {count} cards"},"gantt.lag":"+{days}d","gantt.lead":"{days}d","gantt.a11y.moved":"{name} moved to {date}","gantt.a11y.day":"day {day}","gantt.a11y.resized":"{name} resized to {days} days","gantt.a11y.linkFrom":"Linking from {name}. Focus the successor and press L.","gantt.a11y.linked":"Linked {from} to {to}, finish to start.","gantt.a11y.linkCancelled":"Link cancelled.","gantt.a11y.deleted":"{name} deleted.","gantt.workload.title":"Resource workload","gantt.workload.resource":"Resource","gantt.workload.total":"Total","gantt.workload.unassigned":"Unassigned","gantt.workload.cell":"{hours} h from {date}","gantt.workload.over":"{hours} h from {date}, over a capacity of {capacity} h","gantt.workload.expand":"Show {name}’s tasks","gantt.workload.collapse":"Hide {name}’s tasks","gantt.a11y.hoursSet":"{name}: {hours} h from {date}","gantt.a11y.hoursCleared":"{name}: no hours from {date}","gantt.a11y.hoursRefused":"{date} is not a working day; {name} was not changed.","gantt.tip.range":"{from} to {to}","gantt.tip.duration":"{days}d","gantt.tip.slack":"slack {days}d","timeline.scrub":"Scrub through recent changes","timeline.goLive":"Go live","timeline.returnToPresent":"Return to the present","a11y.fillHandle":"Drag to fill","panel.icons":"Icons","value.tooLong":"Too long","shortcuts.title":"Keyboard shortcuts","shortcuts.close":"Close keyboard shortcuts","shortcuts.hint":"Press Escape to close.","shortcuts.or":"or","a11y.reorder.moved":"Moved to position {position} of {total}","a11y.reorder.sorted":"Rows cannot be reordered while the grid is sorted","a11y.reorder.filtered":"Rows cannot be reordered while a filter is applied","a11y.reorder.grouped":"Rows cannot be reordered while the grid is grouped","a11y.reorder.grab":"Reorder row","a11y.reorder.sortedManual":"Rows cannot be reordered while the grid is sorted. Press Alt+Shift+M, or the Manual order button in the heading, to order them by hand","a11y.reorder.groupDerived":"The row cannot join that group: the group is worked out from the value, so there is no single value to give it","a11y.reorder.groupReadOnly":"The row cannot join that group: its grouping value cannot be edited","a11y.reorder.invalid":"The row cannot join that group: the new value was not valid","a11y.reorder.vetoed":"The move was declined; the row stays where it was","a11y.reorder.vetoedBecause":"The move was declined ({reason}); the row stays where it was","a11y.reorder.refused":"The row cannot be moved there","a11y.reorder.regrouped":"Moved into {group}","a11y.rowOrder.entered":"Manual order: the rows keep their places and can be moved by hand","a11y.rowOrder.exited":"Manual order ended; the rows follow the sort","rowOrder.button":"Manual order","rowOrder.enter":"Order the rows by hand instead of by the sort","rowOrder.exit":"Return to the sorted order","a11y.transfer.moved":"Row moved to the other grid","a11y.transfer.copied":"Row copied to the other grid","a11y.transfer.refused":"That grid does not accept this row","a11y.transfer.declined":"The drop was declined; the row stays where it was","a11y.transfer.stale":"The drop target changed while it was being confirmed; the row stays where it was","shortcuts.group.grid":"In the data","shortcuts.group.header":"On a column heading","shortcuts.group.panel":"In the column list","shortcut.moveCell":"Move the focused cell","shortcut.rowEnds":"First / last cell of the row","shortcut.gridEnds":"First cell of the first row / last cell of the last row","shortcut.pageRows":"Move one viewport of rows","shortcut.nextCell":"Leave the grid for the next / previous focusable element (arrows move between cells)","shortcut.undo":"Undo the last edit, paste, fill or clear","shortcut.redo":"Redo the step that was undone","shortcut.startEdit":"Start editing the focused cell","shortcut.toggleRow":"Toggle selection of the focused row","shortcut.cancel":"Cancel the current edit or drag","shortcut.expandCollapse":"Expand / collapse a group or tree row","shortcut.focusHeader":"Move focus to the column header","shortcut.focusPanel":"Move focus to the tool panel","shortcut.contextMenu":"Open the context menu for the focused cell","shortcut.moveRow":"Move the focused row, when row reorder is enabled","shortcut.manualOrder":"Order the rows by hand, or return to the sort, when row reorder allows a manual order","shortcut.headingMove":"Move between headings","shortcut.headingEnds":"First / last heading","shortcut.headingSort":"Sort by the column, Shift to add to the sort","shortcut.headingResize":"Resize the column, Ctrl for a coarse step","shortcut.headingAutosize":"Size the column to its content","shortcut.headingReorder":"Move the column","shortcut.headingMenu":"Open the column menu","shortcut.headingExit":"Return focus to the data","shortcut.listGroup":"Group by the column, or stop grouping by it","shortcut.listValues":"Add the column to values, or take it out","shortcut.listPivot":"Pivot by the column, or stop pivoting by it","shortcut.listMove":"Move the column","shortcut.find":"Find in the grid","tags.label":"Show columns","tags.all":"All columns","tags.showing":"Showing {tag}","form.title":"Edit row","form.save":"Save","form.cancel":"Cancel","form.loading":"Loading…","form.loadFailed":"Could not load this record.","form.loadTimeout":"The record did not arrive in time.","form.retry":"Try again","form.choose":"Choose…","form.newTitle":"New row","form.createFailed":"Could not add this record.","presentation.cards":"Showing records as cards","presentation.table":"Showing records as a table","editor.format":"Format","editor.codeHint":"Tab indents · Esc cancels · Ctrl+Enter saves","editor.colours":"Colours","editor.customColour":"Custom colour","editor.hexValue":"Hex value","editor.hexPlaceholder":"#rrggbb","editor.clearColour":"Clear colour","editor.time":"Time","editor.noIcon":"No icon","editor.selectAll":"Select all","editor.passwordHint":"Enter the value twice to save it.","editor.clearRating":"Clear rating","editor.clear":"Clear","editor.value":"Value","editor.currency":"Currency","formatting.format":"Format","formatting.noRules":"No rules yet. The first one that matches a cell wins.","formatting.clearAll":"Clear all","formatting.addRule":"Add rule","formatting.condition":"Condition","formatting.value":"Value","formatting.secondValue":"Second value","formatting.moveEarlier":"Move earlier","formatting.moveLater":"Move later","formatting.ruleKind":"Rule type","formatting.aCondition":"A condition","formatting.aColourScale":"A colour scale","formatting.compare":"Compare a value","formatting.distribution":"By the distribution","formatting.colourScale":"Colour scale","formatting.scaleBounds":"Scale bounds","formatting.preview":"Preview","formatting.livePreview":"Live preview","history.title":"History","history.show":"Show history","history.empty":"Nothing to undo yet.","prompt.ask":"Ask","prompt.apply":"Apply","prompt.discard":"Discard","panel.searchColumns":"Search columns","panel.searchColumnsPlaceholder":"Search columns…","panel.searchColumnsToFilter":"Search columns to filter","panel.showAll":"Show all","panel.hideAll":"Hide all","panel.clearAll":"Clear all","panel.clear":"Clear","panel.filterAllColumns":"Filter all columns","panel.columnFiltered":"This column is filtered","panel.clearFilterOn":"Clear the filter on {column}","panel.clearFilter":"Clear this filter","panel.filterEmptyNoMatch":"No column matches “{query}”.","panel.filterEmptyNone":"No column on this grid can be filtered.","panel.filterSummaryActive":"{active} of {total} columns filtered","panel.filterSummaryNone":"No filters · {total} columns available","panel.filterBy":"Filter by {column}","panel.filteredBy":"Filtered by {column}","panel.columnDragHint":"Drag {column} into a zone above, or onto another column to reorder","panel.gridActions":"Grid actions","views.default":"Default","views.namePlaceholder":"Name this view…","views.nameLabel":"Name for the current layout","views.save":"Save view","licence.watermark":"Unlicensed: Lattice Grid trial","licence.watermark.free":$,"filter.op.contains":"Contains","filter.op.notContains":"Does not contain","filter.op.equals":"Equals","filter.op.notEqual":"Does not equal","filter.op.startsWith":"Starts with","filter.op.endsWith":"Ends with","filter.op.blank":"Is blank","filter.op.notBlank":"Is not blank","filter.op.lessThan":"Less than","filter.op.lessThanOrEqual":"Less than or equal","filter.op.greaterThan":"Greater than","filter.op.greaterThanOrEqual":"Greater than or equal","filter.op.inRange":"In range","filter.op.matches":"Matches","filter.op.before":"Before","filter.op.after":"After","filter.op.relative":"Relative to today","filter.rel.today":"Today","filter.rel.yesterday":"Yesterday","filter.rel.tomorrow":"Tomorrow","filter.rel.lastNDays":"Last N days","filter.rel.nextNDays":"Next N days","filter.rel.thisWeek":"This week","filter.rel.lastWeek":"Last week","filter.rel.thisMonth":"This month","filter.rel.lastMonth":"Last month","filter.rel.thisQuarter":"This quarter","filter.rel.quarterToDate":"Quarter to date","filter.rel.thisYear":"This year","filter.rel.yearToDate":"Year to date","filter.operator":"Operator","filter.join":"Join","filter.value":"Value","filter.from":"From","filter.to":"To","filter.addCondition":"Add condition","filter.noConditions":"No conditions","filter.removeCondition":"Remove condition","filter.search":"Search","filter.searchValues":"Search values","filter.noMatches":"No values match","filter.selectAll":"Select all","filter.clear":"Clear","filter.all":"All","filter.allExcept":"All but {count}","filter.loadingValues":"Loading values…","filter.topValues":"Top {shown} of {total} values","filter.valuesFailed":"Values could not be loaded: {error}","filter.valuesUnsupported":"This source cannot list the values of {column}; filter by condition instead.","filter.true":"True","filter.false":"False","filter.expression":"Filter expression","filter.column":"Column","filter.relativePeriod":"Relative period","filter.days":"Number of days","filter.tab.set":"Values","filter.tab.text":"Text","filter.tab.number":"Number","filter.tab.date":"Date","filter.tab.advanced":"Advanced","filterRow.label":"Filter row","filterRow.conditions":{one:"{count} condition",other:"{count} conditions"},"chart.empty":"Nothing to chart","chart.summary":"{type} chart of {measure} by {dimension}","chart.summaryShare":"{type} chart of {measure}","chart.summaryType":"{type} chart","chart.summaryGauge":"{type} chart of {measure}, {fn}: {value}","chart.waterfallTotal":"Total","chart.summaryEngine":"Figures computed by the data engine over every matching row","chart.summaryEngineViewport":"{count} points in this view, fetched from the data engine","chart.summaryEngineDensity":"{count} rows in this view, more than the {cap} drawn as points, so shown as {cells} density cells counted by the data engine","chart.summaryClientDensity":"{count} rows in this view, more than the {cap} drawn as points, so shown as {cells} density cells computed in the browser","chart.viewportOverCap":"{count} rows in this view, more than the {cap} this map draws; zoom in or narrow the filter","chart.dataTable":"Chart data","chart.viewportFilter.label":"Map view","chart.annotate.rail":"Drawing tools","chart.annotate.select":"Select and move a drawing","chart.annotate.trendLine":"Trend line","chart.annotate.horizontalLine":"Horizontal line","chart.annotate.verticalLine":"Vertical line","chart.annotate.channel":"Parallel channel","chart.annotate.fibonacci":"Fibonacci retracement","chart.annotate.arrow":"Arrow","chart.annotate.pen":"Freehand pen","chart.annotate.pen.described":"Freehand drawing from {from} to {to}","chart.annotate.measure-x":"Date range","chart.annotate.measure-y":"Price range","chart.annotate.measure-xy":"Date and price range","chart.annotate.measure.bars":{one:"{count} bar",other:"{count} bars"},"chart.annotate.measure.points":{one:"{count} point",other:"{count} points"},"chart.annotate.measure.volume":"Vol {value}","chart.annotate.measure.seconds":"{count}s","chart.annotate.measure.minutes":"{count}m","chart.annotate.measure.hours":"{count}h","chart.annotate.measure.days":"{count}d","chart.annotate.measure.weeks":"{count}w","chart.annotate.measure.months":"{count}mo","chart.annotate.measure.years":"{count}y","chart.annotate.measure":"Measure","chart.annotate.measure.dx":"Δx {value}","chart.annotate.measure.dy":"Δy {value}","chart.annotate.measure.pct":"{value}%","chart.annotate.measure.categories":{one:"{count} category",other:"{count} categories"},"chart.annotate.measure.slope.perDay":"Slope {value} per day","chart.annotate.measure.slope.perCategory":"Slope {value} per category","chart.annotate.measure.slope.perUnit":"Slope {value} per unit","chart.annotate.measure.dur.d":"{count} d","chart.annotate.measure.dur.h":"{count} h","chart.annotate.measure.dur.min":"{count} min","chart.annotate.measure.dur.s":"{count} s","chart.annotate.measure.dur.ms":"{count} ms","chart.annotate.measure.announce":"Measurement: {readout}","chart.annotate.measure.start":"Measure start: {x}, {y}","chart.annotate.text":"Text","chart.annotate.callout":"Callout","chart.annotate.note":"Note","chart.annotate.delete":"Delete the selected drawing","chart.annotate.editLabel":"Annotation text","chart.zoom.toolbar":"Zoom controls","chart.zoom.in":"Zoom in","chart.zoom.out":"Zoom out","chart.zoom.left":"Pan left","chart.zoom.right":"Pan right","chart.zoom.reset":"Reset the zoom","chart.legendMore":{one:"+{count} more",other:"+{count} more"},"chart.type.line":"Line","chart.type.area":"Area","chart.type.bar":"Bar","chart.type.pie":"Pie","chart.type.donut":"Donut","chart.type.sunburst":"Sunburst","chart.type.scatter":"Scatter","chart.type.step":"Step","chart.type.rangeArea":"Range","chart.type.horizontalBar":"Horizontal bar","chart.type.waterfall":"Waterfall","chart.type.floatingBar":"Floating bar","chart.type.horizontalFloatingBar":"Horizontal floating bar","chart.type.populationPyramid":"Population pyramid","chart.type.bullet":"Bullet","chart.type.bubble":"Bubble","chart.type.histogram":"Histogram","chart.type.boxplot":"Box plot","chart.type.forest":"Forest plot","chart.type.qq":"QQ plot","chart.type.ecdf":"ECDF","chart.type.lorenz":"Lorenz","chart.type.correlogram":"Correlogram","chart.type.control":"Control","chart.type.capability":"Capability","chart.type.movingRange":"Moving range","chart.type.treemap":"Treemap","chart.type.combo":"Combination","chart.type.pareto":"Pareto","chart.type.heatmap":"Heat map","chart.type.radar":"Radar","chart.type.gauge":"Gauge","chart.type.funnel":"Funnel","chart.type.candlestick":"Candlestick","chart.type.ohlc":"OHLC","chart.type.polarArea":"Polar area","chart.type.nightingale":"Nightingale rose","chart.type.rose":"Rose","chart.type.radialBar":"Radial bar","chart.type.polarScatter":"Polar scatter","chart.type.geomap":"Map","chart.type.sankey":"Sankey","chart.type.chord":"Chord","chart.type.pyramid":"Pyramid","chart.type.pictorial":"Pictorial","chart.type.serpentine":"Serpentine timeline","chart.type.spiral":"Spiral timeline","chart.edit.aggregated":"This value is a total of several rows, so it cannot be dragged.","chart.edit.refused":"That change was not applied.","chart.edit.refusedWhy":"That change was not applied: {reason}","chart.type.network":"Network","chart.type.stream":"Stream","chart.type.marimekko":"Marimekko","chart.type.violin":"Violin","chart.type.gantt":"Gantt","chart.type.forceTree":"Force-directed tree","chart.type.pack":"Packed circles","chart.type.tree":"Tree","chart.type.voronoiTreemap":"Voronoi treemap","chart.type.alluvial":"Alluvial","chart.type.arc":"Arc diagram","chart.type.barRace":"Bar chart race","chart.type.bubblemap":"Bubble map","chart.type.bump":"Bump chart","chart.type.calendar":"Calendar heat map","chart.type.choropleth":"Choropleth map","chart.type.decomposition":"Decomposition tree","chart.type.diverging":"Diverging bar","chart.type.dumbbell":"Dumbbell","chart.type.fan":"Fan chart","chart.type.hexbin":"Hexagonal bin","chart.type.hexmap":"Hex map","chart.type.icicle":"Icicle","chart.type.markermap":"Marker map","chart.type.motion":"Motion chart","chart.type.parallel":"Parallel coordinates","chart.type.ridgeline":"Ridgeline","chart.type.roc":"ROC curve","chart.type.slope":"Slope chart","chart.type.splom":"Scatter plot matrix","chart.type.venn":"Venn diagram","chart.type.waffle":"Waffle","chart.type.wordCloud":"Word cloud","chart.tasksDropped":{one:"{count} more task not shown",other:"{count} more tasks not shown"},"chart.geoUnmatched":{one:"{count} row could not be placed on the map",other:"{count} rows could not be placed on the map"},"chart.r2":"R² {value}","ai.insights":"Insights","ai.explainView":"Explain this view","ai.explain":"Explain","ai.ask":"Ask","ai.apply":"Apply","ai.discard":"Discard","ai.propose":"Propose","ai.approve":"Approve","ai.thinking":"Thinking…","ai.applying":"Applying…","ai.applied":"Applied: {what}","ai.couldNotApply":"Could not apply: {why}","ai.applyFailed":"it failed","ai.discarded":"Discarded.","ai.discardedNothingWritten":"Discarded. Nothing was written.","ai.nothingWritten":"Nothing was written.","ai.nothingWrittenVetoed":"Nothing was written — a before-handler vetoed it.","ai.scope":"Scope: {scope}","ai.unsafeQuery":"I could not turn that into a safe query: {why}","ai.nothingToDo":"nothing to do","ai.insightsFailed":"Could not generate insights right now. The grid is unaffected.","ai.modelUnreachable":"Could not reach the model right now. The grid is unaffected.","ai.flagged":{one:"{count} unverified figure was removed as ungrounded.",other:"{count} unverified figures were removed as ungrounded."},"ai.askPlaceholder":"Ask your data: “EMEA deals over 50k, biggest first”","ai.askLabel":"Ask your data","ai.actorPlaceholder":"Ask AI to change data: “set the Network Upgrade project to In Progress”","ai.actorLabel":"Ask AI to change data","editor.password.show":"Show value","editor.password.hide":"Hide value","editor.password.showField":"Show {column}","editor.password.hideField":"Hide {column}","facets.computing":"Computing…","facets.suppressed.cardinality":"Too many distinct values to chart","facets.suppressed.rows":"Too many rows to chart","facets.suppressed.streaming":"Paused while live data is streaming","facets.suppressed.noProvider":"No distribution available for this data source","facets.suppressed.type":"This column has no chartable distribution","facets.bucketOf":"{count} of {whole} rows","history.undo":"Undo","history.redo":"Redo","history.described":"{action} {label}","history.nothingToUndo":"Nothing to undo","history.nothingToRedo":"Nothing to redo","history.undoDisabled":"Undo (nothing to undo)","history.redoDisabled":"Redo (nothing to redo)","a11y.presence.joined":"{name} joined","a11y.presence.left":"{name} left","prompt.asking":"Asking…","prompt.moreNotes":{one:"and {count} more",other:"and {count} more"},"shortcuts.key.cmd":"Cmd","timeline.live":"Live","timeline.recording":"recording…","panel.zoneHint.group":"Drag a column here to group rows by its values","panel.zoneHint.values":"Drag a column here to total it","panel.zoneHint.pivot":"Drag a column here to pivot across its values","panel.zoneHint.any":"Drag a column here","panel.rowsOf":"{shown} of {total} rows","views.empty":"No saved views yet. Set the grid up as you want it, then save it below.","views.applied":"Applied","views.matchesGrid":"Matches the grid as it is","views.delete":"Delete","views.confirmDelete":"Delete {name}?","views.confirmDeleteLabel":"Confirm deleting {name}","gantt.row.expand":"Expand {name}","gantt.row.collapse":"Collapse {name}","gantt.resource.over":"{name} — over-allocated","kanban.board":"Board","kpi.status.good":"good","kpi.status.warn":"warn","kpi.status.critical":"critical","kpi.status.unknown":"No data","kpi.node.item":"{count} item","kpi.node.items":"{count} items","kpi.node.worst":"worst status {status}","kpi.node.unknown":"{count} unknown"}),I=Object.freeze(Object.keys(B))}),Fe("packages/core/src/i18n/format.js",function(e,K){"use strict";Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"formatMessage",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"lookup",{enumerable:!0,get:function(){return A}});const $=K("packages/core/src/internal/util.js").isFunction,B=/\{(\w+)\}/g,I=new Map,_=new Map;function X(g){const l=g||"";if(I.has(l))return I.get(l);let d=null;try{d=new Intl.PluralRules(g||void 0)}catch{d=null}return I.set(l,d),d}function W(g,l,d="conjunction"){const o=Array.isArray(g)?g.filter(r=>r!=null&&r!==""):[];if(o.length===0)return"";if(o.length===1)return String(o[0]);const n=`${l||""}|${d}`;let t=_.get(n);if(t===void 0){try{t=new Intl.ListFormat(l||void 0,{style:"long",type:d})}catch{t=null}_.set(n,t)}return t?t.format(o.map(String)):o.map(String).join(", ")}function H(g,l){return g==null?"":typeof g=="number"?Number.isFinite(g)?g.toLocaleString(l||void 0,{maximumFractionDigits:20}):"":String(g)}function V(g,l,d){if(typeof g=="string")return g;if(!g||typeof g!="object")return"";const o=l&&typeof l.count=="number"?l.count:null;if(o===null)return g.other??"";const n=X(d),t=n?n.select(o):o===1?"one":"other";return g[t]??g.other??""}function z(g,l={},d){const o=V(g,l,d);return o?o.replace(B,(n,t)=>Object.prototype.hasOwnProperty.call(l,t)?H(l[t],d):n):""}function w(g,l,d="en-GB"){return typeof g=="string"&&g?g:typeof l=="string"&&l?l:d}function A(g,l){const d=g?g[l]:void 0;return d==null||$(d)?l:d}}),Fe("packages/core/src/i18n/index.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"defaultMessages",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return o}});const Q=K("packages/core/src/i18n/catalogue.js"),$=Q.EN_GB,B=Q.MESSAGE_KEYS,I=K("packages/core/src/i18n/format.js"),_=I.formatMessage,X=I.formatList,W=I.lookup,H=I.resolveLocale,V=K("packages/core/src/internal/util.js"),z=V.isFunction,w=V.warnOnce;Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return Q.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return Q.MESSAGE_KEYS}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return I.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return I.resolveLocale}});const A="en-GB";class g{#e=A;#t=$;constructor(t={}){this.configure(t)}configure(t={}){this.#e=H(t.locale,t.declared,A);const r=t.messages;if(!r||typeof r!="object"){this.#t=$;return}const s=Object.keys(r).filter(h=>!(h in $));s.length&&w(`i18n:unknown:${s[0]}`,`message keys not in the catalogue and so ignored: ${s.slice(0,5).join(", ")}${s.length>5?`, and ${s.length-5} more`:""}`),this.#t={...$,...r}}get locale(){return this.#e}t(t,r){return _(W(this.#t,t),r||{},this.#e)}list(t,r){return X(t,this.#e,r)}number(t,r){const s=Number(t);return Number.isFinite(s)?s.toLocaleString(this.#e,r||{maximumFractionDigits:20}):""}}const l=new g;function d(n){return n instanceof g?n:new g(n||{})}function o(n){const t=n&&typeof n=="object"?n:{},r=B.filter(h=>{const u=t[h];return u==null||u===""||z(u)}),s=Object.keys(t).filter(h=>!(h in $));return{missing:r,unknown:s}}}),Fe("packages/core/src/columns/types/structured.js",function(e,K){"use strict";Object.defineProperty(e,"MASK_DEFAULTS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"canonicalJson",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"parseJsonText",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const Q=K("packages/core/src/internal/util.js"),$=Q.isNil,B=Q.isObject,_=K("packages/core/src/i18n/index.js").defaultMessages,X=Object.freeze({char:"•",length:8,fixedLength:!0,lastVisible:0,emptyDisplay:""});function W(n,t){const r=t||{},s=r.emptyDisplay??X.emptyDisplay;if($(n)||n==="")return s;const u=[...typeof r.char=="string"&&r.char!==""?r.char:X.char][0]||X.char,i=r.fixedLength??X.fixedLength,m=Number.isFinite(r.length)&&Number(r.length)>0?Math.floor(Number(r.length)):X.length,c=typeof n=="string"?n:typeof n=="number"||typeof n=="boolean"||typeof n=="bigint"?String(n):null;let f=0;if(c!==null){const a=Number.isFinite(r.lastVisible)?Math.floor(Number(r.lastVisible)):X.lastVisible,p=[...c];if(f=a>0&&a<p.length?a:0,f>0){const b=p.slice(p.length-f).join(""),O=Math.max(1,(i?m:p.length)-f);return u.repeat(O)+b}return u.repeat(i?m:Math.max(1,p.length))}return u.repeat(m)}const H=48;function V(n){try{const t=JSON.stringify(n);return t===void 0?null:t}catch{return null}}function z(n,t){if($(n))return"";const r=Number.isFinite(t&&t.inlineLimit)?Number(t.inlineLimit):H;if(typeof n=="string")return n.length>r?`${n.slice(0,r-1)}…`:n;if(typeof n!="object")return String(n);const s=V(n);if(s!==null&&s.length<=r)return s;if(Array.isArray(n)){const u=n.length;return`[${_.t("count.items",{count:u})}]`}const h=Object.keys(n).length;return`{${_.t("count.keys",{count:h})}}`}function w(n,t){if(n==null)return"null";const r=typeof n;if(r==="number"||r==="boolean"||r==="bigint")return String(n);if(r==="string")return JSON.stringify(n);if(r!=="object")return JSON.stringify(String(n));const s=t||new WeakSet;return s.has(n)?'"[circular]"':(s.add(n),n instanceof Date?JSON.stringify(n.toISOString()):Array.isArray(n)?`[${n.map(i=>w(i,s)).join(",")}]`:`{${Object.keys(n).sort().map(i=>`${JSON.stringify(i)}:${w(n[i],s)}`).join(",")}}`)}function A(n,t){if($(n))return $(t)?0:1;if($(t))return-1;const r=w(n),s=w(t);return r<s?-1:r>s?1:0}function g(n){if($(n))return null;const t=String(n);if(t.trim()==="")return null;try{return JSON.parse(t)}catch{return t}}function l(n){const t=n&&n.cell&&n.cell.props;return B(t)?t:{}}const d=Object.freeze({json:{base:"object",storage:"object",format:n=>z(n&&n.value,l(n&&n.column)),parse:n=>g(n&&n.text),compare:A,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:n=>{if($(n))return"";if(typeof n=="string")return n;try{const t=JSON.stringify(n,null,2);return t===void 0?String(n):t}catch{return String(n)}},fromClipboard:n=>g(n)},secret:{base:"text",storage:"object",format:n=>W(n&&n.value,l(n&&n.column)),parse:n=>{const t=n&&n.text;return $(t)||String(t)===""?null:String(t)},compare:(n,t)=>{const r=$(n)||n==="",s=$(t)||t==="";return r===s?0:r?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:n=>W(n),fromClipboard:n=>$(n)||String(n)===""?null:String(n)}}),o=d}),Fe("packages/core/src/columns/types/unit.js",function(e,K){"use strict";Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return N}});const Q=K("packages/core/src/internal/util.js"),$=Q.isNil,B=Q.warnOnce;function I(M,j,L,G){return Object.freeze({symbol:M,factor:j,aliases:Object.freeze(L||[]),binary:!!(G&&G.binary),prefix:G&&G.prefix||null,auto:!(G&&G.auto===!1)})}function _(M,j,L,G){return I(M,j,L,G)}const X=Object.freeze({data:Object.freeze([I("B",1,["byte","bytes"]),I("kB",1e3,["kilobyte","kilobytes"],{prefix:"k"}),I("KiB",1024,["kibibyte","kibibytes"],{binary:!0,prefix:"k"}),I("MB",1e6,["megabyte","megabytes"],{prefix:"m"}),I("MiB",1024**2,["mebibyte","mebibytes"],{binary:!0,prefix:"m"}),I("GB",1e9,["gigabyte","gigabytes"],{prefix:"g"}),I("GiB",1024**3,["gibibyte","gibibytes"],{binary:!0,prefix:"g"}),I("TB",1e12,["terabyte","terabytes"],{prefix:"t"}),I("TiB",1024**4,["tebibyte","tebibytes"],{binary:!0,prefix:"t"}),I("PB",1e15,["petabyte","petabytes"],{prefix:"p"})]),bitrate:Object.freeze([I("bps",1,["bit","bits","bit/s","b/s"]),I("kbps",1e3,["kbit","kbits","kbit/s","kb/s","kilobit","kilobits"],{prefix:"k"}),I("Mbps",1e6,["mbit","mbits","mbit/s","mb/s","megabit","megabits"],{prefix:"m"}),I("Gbps",1e9,["gbit","gbits","gbit/s","gb/s","gigabit","gigabits"],{prefix:"g"}),I("Tbps",1e12,["tbit","tbits","tbit/s","tb/s","terabit","terabits"],{prefix:"t"})]),length:Object.freeze([I("nm",1e-9,["nanometre","nanometres","nanometer","nanometers"]),I("µm",1e-6,["um","micrometre","micrometres","micrometer","micrometers","micron","microns"]),I("mm",.001,["millimetre","millimetres","millimeter","millimeters"]),I("cm",.01,["centimetre","centimetres","centimeter","centimeters"]),I("in",.0254,["inch","inches"],{auto:!1}),I("ft",.3048,["foot","feet"],{auto:!1}),I("yd",.9144,["yard","yards"],{auto:!1}),I("m",1,["metre","metres","meter","meters"]),I("km",1e3,["kilometre","kilometres","kilometer","kilometers"]),I("mi",1609.344,["mile","miles"],{auto:!1}),I("nmi",1852,["nauticalmile","nauticalmiles"],{auto:!1})]),mass:Object.freeze([I("mg",.001,["milligram","milligrams"]),I("g",1,["gram","grams"]),I("oz",28.349523125,["ounce","ounces"],{auto:!1}),I("lb",453.59237,["pound","pounds","lbs"],{auto:!1}),I("kg",1e3,["kilogram","kilograms"]),I("st",6350.29318,["stone"],{auto:!1}),I("t",1e6,["tonne","tonnes","ton"],{auto:!1}),I("ton (US)",907184.74,["ton","shortton"],{auto:!1}),I("ton (UK)",10160469088e-4,["ton","longton"],{auto:!1})]),duration:Object.freeze([I("ns",1e-9,["nsec","nsecs","nanosecond","nanoseconds"]),I("µs",1e-6,["us","usec","usecs","microsecond","microseconds"]),I("ms",.001,["msec","msecs","millisecond","milliseconds"]),I("s",1,["sec","secs","second","seconds"]),I("m",60,["min","mins","minute","minutes"]),I("h",3600,["hr","hrs","hour","hours"]),I("d",86400,["day","days"])]),speed:Object.freeze([I("mm/s",.001,["millimetre/s","millimeter/s"]),I("ft/s",.3048,["fps","foot/s","feet/s"],{auto:!1}),I("km/h",1/3.6,["kph","kmh","kilometre/h","kilometer/h"],{auto:!1}),I("mph",.44704,["mile/h","miles/h"],{auto:!1}),I("kn",1852/3600,["knot","knots"],{auto:!1}),I("m/s",1,["metre/s","meter/s","mps"]),I("km/s",1e3,["kilometre/s","kilometer/s"])]),acceleration:Object.freeze([I("mm/s²",.001,["mm/s2"]),I("ft/s²",.3048,["ft/s2"],{auto:!1}),I("m/s²",1,["m/s2","metre/s2","meter/s2"]),I("g",9.80665,["gee","gravity"],{auto:!1})]),area:Object.freeze([I("mm²",1e-6,["mm2"]),I("cm²",1e-4,["cm2"]),I("in²",64516e-8,["in2","sqin"],{auto:!1}),I("ft²",.09290304,["ft2","sqft"],{auto:!1}),I("yd²",.83612736,["yd2","sqyd"],{auto:!1}),I("m²",1,["m2","sqm"]),I("ha",1e4,["hectare","hectares"],{auto:!1}),I("ac",4046.8564224,["acre","acres"],{auto:!1}),I("km²",1e6,["km2","sqkm"])]),volume:Object.freeze([I("µL",1e-6,["ul","microlitre","microliter"]),I("mL",.001,["millilitre","milliliter"]),I("fl oz (US)",.0295735295625,["fl oz","usfloz"],{auto:!1}),I("fl oz (imp)",.0284130625,["fl oz","impfloz"],{auto:!1}),I("L",1,["litre","litres","liter","liters"]),I("gal (US)",3.785411784,["gal","usgal","usgallon"],{auto:!1}),I("gal (imp)",4.54609,["gal","impgal","impgallon"],{auto:!1}),I("m³",1e3,["m3","cubicmetre","cubicmeter","kl"],{auto:!1}),I("bbl",158.987294928,["barrel","barrels"],{auto:!1})]),energy:Object.freeze([I("eV",1602176634e-28,["electronvolt","electronvolts"],{auto:!1}),I("J",1,["joule","joules"]),I("cal",4.184,["calorie","calories"],{auto:!1}),I("kJ",1e3,["kilojoule","kilojoules"]),I("BTU",1055.05585262,["btu"],{auto:!1}),I("kcal",4184,["kilocalorie","kilocalories","Cal"],{auto:!1}),I("MJ",1e6,["megajoule","megajoules"]),I("kWh",36e5,["kilowatthour","kilowatthours"],{auto:!1}),I("GJ",1e9,["gigajoule","gigajoules"]),I("MWh",36e8,["megawatthour","megawatthours"],{auto:!1})]),power:Object.freeze([I("mW",.001,["milliwatt","milliwatts"]),I("W",1,["watt","watts"]),I("BTU/h",1055.05585262/3600,["btuh","btu/h"],{auto:!1}),I("kW",1e3,["kilowatt","kilowatts"]),I("hp",745.6998715822702,["horsepower"],{auto:!1}),I("MW",1e6,["megawatt","megawatts"]),I("GW",1e9,["gigawatt","gigawatts"])]),force:Object.freeze([I("mN",.001,["millinewton","millinewtons"]),I("N",1,["newton","newtons"]),I("lbf",4.4482216152605,["poundforce"],{auto:!1}),I("kgf",9.80665,["kilogramforce"],{auto:!1}),I("kN",1e3,["kilonewton","kilonewtons"]),I("MN",1e6,["meganewton","meganewtons"])]),pressure:Object.freeze([I("Pa",1,["pascal","pascals"]),I("mbar",100,["millibar"],{auto:!1}),I("inH₂O",249.0889,["inh2o"],{auto:!1}),I("mmHg",133.322387415,["torr"],{auto:!1}),I("kPa",1e3,["kilopascal","kilopascals"]),I("inHg",3386.388640341,["inhg"],{auto:!1}),I("psi",6894.757293168361,["lbf/in2"],{auto:!1}),I("bar",1e5,[],{auto:!1}),I("atm",101325,["atmosphere","atmospheres"],{auto:!1}),I("MPa",1e6,["megapascal","megapascals"]),I("GPa",1e9,["gigapascal","gigapascals"])]),torque:Object.freeze([I("N·m",1,["nm","n.m","newtonmetre","newtonmeter"]),I("lbf·ft",1.3558179483314003,["lbfft","lbf.ft","ftlb","ft-lb"],{auto:!1}),I("kN·m",1e3,["knm","kn.m"],{auto:!1}),I("MN·m",1e6,["mnm","mn.m"],{auto:!1})]),density:Object.freeze([I("kg/m³",1,["kg/m3"]),I("lb/ft³",16.01846337396014,["lb/ft3","pcf"],{auto:!1}),I("g/cm³",1e3,["g/cm3","g/ml","kg/l"],{auto:!1}),I("t/m³",1e3,["t/m3"],{auto:!1})]),flow:Object.freeze([I("L/min",1/6e4,["lpm","l/min"],{auto:!1}),I("m³/h",1/3600,["m3/h","cmh"],{auto:!1}),I("gpm (US)",.003785411784/60,["gpm","usgpm"],{auto:!1}),I("gpm (imp)",.00454609/60,["gpm","impgpm"],{auto:!1}),I("cfm",.0004719474432,["ft3/min"],{auto:!1}),I("L/s",.001,["lps","l/s"],{auto:!1}),I("m³/s",1,["m3/s","cms"])]),angle:Object.freeze([I("″",Math.PI/648e3,["arcsec","arcsecond","arcseconds"],{auto:!1}),I("′",Math.PI/10800,["arcmin","arcminute","arcminutes"],{auto:!1}),I("mrad",.001,["milliradian","milliradians"],{auto:!1}),I("mil",Math.PI/3200,["nato-mil"],{auto:!1}),I("°",Math.PI/180,["deg","degree","degrees"],{auto:!1}),I("gon",Math.PI/200,["grad","gradian","gradians"],{auto:!1}),I("rad",1,["radian","radians"]),I("turn",2*Math.PI,["rev","revolution","revolutions"],{auto:!1})]),angularVelocity:Object.freeze([I("°/s",Math.PI/180,["degps","deg/s","degrees/s"],{auto:!1}),I("rad/s",1,["radps","radians/s"]),I("rpm",2*Math.PI/60,["rev/min","r/min","revolutions/min"],{auto:!1}),I("rps",2*Math.PI,["rev/s","r/s","revolutions/s"],{auto:!1})]),fraction:Object.freeze([I("ppt",1e-12,["partspertrillion"],{auto:!1}),I("ppb",1e-9,["partsperbillion"]),I("ppm",1e-6,["partspermillion"]),I("bp",1e-4,["bps-finance","basispoint","basispoints","bips"],{auto:!1}),I("‰",.001,["permille","permil"],{auto:!1}),I("%",.01,["pct","percent"]),I("×",1,["x","ratio","times"])]),molarity:Object.freeze([I("pM",1e-12,["picomolar","picomolarity"]),I("nM",1e-9,["nanomolar","nanomolarity"]),I("µM",1e-6,["um-molar","micromolar","micromolarity"]),I("mM",.001,["millimolar","millimolarity"]),I("M",1,["molar","mol/l","mol/L","molarity"]),I("mol/m³",.001,["mol/m3"],{auto:!1})]),massFlow:Object.freeze([I("mg/s",1e-6,["milligrams/s"]),I("g/s",.001,["grams/s"]),I("kg/h",1/3600,["kilograms/h","kgph"],{auto:!1}),I("kg/s",1,["kilograms/s","kgps"]),I("t/h",1e3/3600,["tonnes/h","tph"],{auto:!1}),I("lb/h",.45359237/3600,["pounds/h","pph"],{auto:!1}),I("t/s",1e3,["tonnes/s"],{auto:!1})]),viscosity:Object.freeze([I("µPa·s",1e-6,["upas","micropascalsecond"]),I("cP",.001,["centipoise"],{auto:!1}),I("mPa·s",.001,["mpas","millipascalsecond"]),I("P",.1,["poise"],{auto:!1}),I("Pa·s",1,["pas","pascalsecond"])]),kinematicViscosity:Object.freeze([I("cSt",1e-6,["centistokes","centistoke"]),I("mm²/s",1e-6,["mm2/s"],{auto:!1}),I("St",1e-4,["stokes","stoke"],{auto:!1}),I("m²/s",1,["m2/s"])]),thermalConductivity:Object.freeze([I("mW/(m·K)",.001,["mw/mk"]),I("W/(m·K)",1,["w/mk","wmk"]),I("kW/(m·K)",1e3,["kw/mk"],{auto:!1}),I("BTU/(hr·ft·°F)",1.730734666,["btu/hrftf"],{auto:!1})]),specificHeat:Object.freeze([I("J/(kg·K)",1,["j/kgk","jkgk"]),I("kJ/(kg·K)",1e3,["kj/kgk"]),I("cal/(g·°C)",4184,["cal/gc"],{auto:!1})]),doseRate:Object.freeze([I("nSv/h",1e-9,["nsvh"]),I("µSv/h",1e-6,["usv/h","usvh"]),I("mSv/h",.001,["msvh"]),I("Sv/h",1,["svh"]),I("mSv/a",.001/8766,["msv/year","msvpa"],{auto:!1})])}),W=Symbol("ambiguous"),H=new Map,V=new Map;function z(M,j){const L=String(M||"").trim();if(!L)throw new Error("[lattice] a unit system needs a name");if(X[L]||V.has(L))throw new Error(`[lattice] unit system "${L}" already exists`);const G=[...j||[]];if(!G.length)throw new Error(`[lattice] unit system "${L}" has no units`);if(!G.some(Y=>Y.factor===1))throw new Error(`[lattice] unit system "${L}" has no base unit (none with factor 1)`);const q=new Set;for(const Y of G){if(q.has(Y.symbol))throw new Error(`[lattice] unit system "${L}" declares "${Y.symbol}" twice`);q.add(Y.symbol)}return V.set(L,Object.freeze(G)),H.delete(L),L}function w(){return[...Object.keys(X),...V.keys()]}function A(M){const j=g(M);return j?j.units:[]}function g(M){const j=String(M||""),L=H.get(j);if(L!==void 0)return L;const G=X[j]||V.get(j);if(!G)return H.set(j,null),null;const q=Object.freeze([...G].sort((ie,se)=>ie.factor-se.factor)),Y=new Map,J=new Map,ee=(ie,se)=>{const he=Y.get(ie);he===void 0?Y.set(ie,se):he!==se&&Y.set(ie,W)};for(const ie of q){ee(ie.symbol.toLowerCase(),ie);for(const se of ie.aliases)ee(se.toLowerCase(),ie);if(ie.prefix){const se=J.get(ie.prefix)||[];se.push(ie),J.set(ie.prefix,se)}}const ne={units:q,byToken:Y,byPrefix:J,decimal:q.filter(ie=>!ie.binary&&ie.auto),binary:q.some(ie=>ie.binary)?q.filter(ie=>(ie.binary||ie.factor===1)&&ie.auto):null};return H.set(j,ne),ne}function l(M,j){return j&&M.binary||M.decimal}function d(M,j){const L=g(M);if(!L||$(j))return null;const G=L.units.find(Y=>Y.symbol===String(j));if(G)return G;const q=L.byToken.get(String(j).trim().toLowerCase());return q&&q!==W?q:null}const o=new WeakMap;function n(M){const j=M||{};if(typeof j=="object"&&j!==null){const Y=o.get(j);if(Y!==void 0)return Y}const L=j.system||"data",G=g(L);let q=null;if(!G)B(`unit:system:${L}`,`unknown unit system "${L}"; known systems are ${w().join(", ")}`);else{let Y=j.unit?d(L,j.unit):null;Y||(j.unit&&B(`unit:unit:${L}:${j.unit}`,`unknown unit "${j.unit}" in system "${L}"; falling back to ${G.units[0].symbol}`),Y=G.units.find(J=>J.factor===1)||G.units[0]),q={index:G,base:Y,binary:j.binary===!0}}return typeof j=="object"&&j!==null&&o.set(j,q),q}const t=new WeakMap;function r(M,j){if(!M||!j||!Array.isArray(M.compound)||M.compound.length===0)return null;const L=t.get(M);if(L!==void 0)return L;const G=new Set,q=[];for(const J of M.compound){const ee=d(M.system||"data",J);if(!ee){B(`unit:compound:${M.system}:${J}`,`unknown compound unit "${J}" in system "${M.system||"data"}"; ignoring it`);continue}G.has(ee.symbol)||(G.add(ee.symbol),q.push(ee))}q.sort((J,ee)=>ee.factor-J.factor);const Y=q.length>=2?q:null;return t.set(M,Y),Y}function s(M,j,L){return j===L||j.factor===L.factor?M:M*j.factor/L.factor}const h=new Map;function u(M){const j=M||"",L=h.get(j);if(L)return L;const G={group:",",decimal:"."};try{for(const q of new Intl.NumberFormat(M||void 0).formatToParts(12345.6))q.type==="group"?G.group=q.value:q.type==="decimal"&&(G.decimal=q.value)}catch{}return h.set(j,G),G}const i=/[\s ]/g,m=/^[+-]?[\d '’ .,]*(?:[eE][+-]?\d+)?/,c=/^[^\d+\-(.,\s]+\s*/,f=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function a(M,j){const{group:L,decimal:G}=u(j);let q=String(M).replace(i,"");if(q==="")return null;const Y=G?q.indexOf(G):-1;if(L&&L!==G){if(Y>=0&&q.indexOf(L,Y+G.length)>=0)return null;q=q.split(L).join("")}if(G&&G!=="."&&(q=q.split(G).join(".")),!f.test(q))return null;const J=Number(q);return Number.isFinite(J)?J:null}function p(M,j,L){const G=String(M).trim().replace(/\.$/,"");if(G==="")return null;const q=j.units.find(se=>se.symbol===G);if(q)return q;const Y=G.toLowerCase(),J=j.byToken.get(Y);if(J===W)return null;if(J)return J;const ee=j.byPrefix.get(Y);if(!ee||!ee.length)return null;const ne=l(j,L),ie=ee.filter(se=>ne.includes(se));return ie.length===1?ie[0]:null}function b(M,j,L,G){let q=M,Y=0,J=!1,ee=!1;for(;q!=="";){const ne=m.exec(q)[0];if(ne==="")return null;const ie=a(ne,G&&G.locale);if(ie===null)return null;q=q.slice(ne.length).trim();const se=q.search(/[+-]?[\d]/),he=(se>=0?q.slice(0,se):q).trim();if(q=se>=0?q.slice(se).trim():"",he===""){if(J)return null;ee=!0,Y+=s(ie,L[0],j.base)}else{const ce=p(he,j.index,j.binary);if(!ce)return null;Y+=s(ie,ce,j.base)}if(J=!0,ee&&q!=="")return null}return J?Y:null}function O(M,j){if($(M))return null;if(typeof M=="number")return Number.isFinite(M)?M:null;const L=n(j);if(!L)return null;let G=String(M).trim();if(G==="")return null;let q=!1;G.startsWith("(")&&G.endsWith(")")&&(q=!0,G=G.slice(1,-1).trim());const Y=r(j,L);if(Y){G.startsWith("-")&&(q=!0,G=G.slice(1).trim());const te=b(G,L,Y,j);return te===null?null:q?-te:te}let J=null;const ee=c.exec(G);if(ee&&ee[0]){const te=p(ee[0].trim(),L.index,L.binary);te&&(J=te,G=G.slice(ee[0].length).trim())}const ne=m.exec(G)[0],ie=a(ne,j&&j.locale);if(ie===null)return null;const se=G.slice(ne.length).trim();if(J&&se!=="")return null;const he=J||(se===""?L.base:p(se,L.index,L.binary));if(!he)return null;const ce=s(ie,he,L.base);return q?-ce:ce}const k=new Map;function y(M,j,L,G){const q=`${M||""}|${j}|${L}|${G?1:0}`;let Y=k.get(q);return Y||(Y=new Intl.NumberFormat(M||void 0,{minimumFractionDigits:j,maximumFractionDigits:L,useGrouping:G}),k.set(q,Y)),Y}function v(M,j){if(!Number.isFinite(M)||M===0)return Math.max(0,j-1);const L=Math.floor(Math.log10(Math.abs(M)));return Math.min(20,Math.max(0,j-1-L))}function R(M,j){if(!Number.isFinite(M)||M===0)return M;const L=Math.ceil(Math.log10(Math.abs(M))),G=10**(j-L);return Math.round(M*G)/G}function S(M,j,L){if(!L||L===j.base.symbol)return j.base;if(L!=="auto")return x(j,L);if(M===0||!Number.isFinite(M))return j.base;const G=Math.abs(M)*j.base.factor,q=l(j.index,j.binary);let Y=q[0];for(const ne of q)G>=ne.factor&&(Y=ne);if(G>=Y.factor)return Y;let J=Y;for(const ne of j.index.units)ne.binary!==j.binary&&ne.factor!==1||ne.factor<=G&&ne.factor>(J===Y?0:J.factor)&&(J=ne);if(J!==Y)return J;let ee=Y;for(const ne of j.index.units)ne.binary!==j.binary&&ne.factor!==1||ne.factor<ee.factor&&(ee=ne);return ee.factor<j.base.factor?ee:j.base}function x(M,j){const L=M.index.units.find(q=>q.symbol===j);if(L)return L;const G=M.index.byToken.get(String(j).toLowerCase());return G&&G!==W?G:(B(`unit:display:${j}`,`unknown display unit "${j}"; rendering in ${M.base.symbol}`),M.base)}function C(M,j,L,G){const q=M<0;let Y=Math.abs(M)*j.base.factor;const J=typeof G.decimals=="number"?G.decimals:G.minDecimals??0,ee=typeof G.decimals=="number"?G.decimals:G.maxDecimals??Math.max(J,2),ne=G.space??" ",ie=[];for(let he=0;he<L.length;he++){const ce=L[he],te=he===L.length-1;let oe=te?Y/ce.factor:Math.floor(Y/ce.factor);if(Y-=oe*ce.factor,te){const de=10**ee;oe=Math.round(oe*de)/de+0}const fe=te?y(G.locale,J,ee,G.group!==!1):y(G.locale,0,0,G.group!==!1);ie.push(`${fe.format(oe)}${ne}${ce.symbol}`)}const se=ie.join(" ");return q?`-${se}`:se}function P(M,j){const L=j||{},G=L.nullDisplay??"";if($(M)||M==="")return G;const q=typeof M=="number"?M:Number(M);if(!Number.isFinite(q))return G;const Y=n(L);if(!Y)return String(q);const J=r(L,Y);if(J)return C(q,Y,J,L);const ee=typeof L.significantFigures=="number"&&L.significantFigures>0?L.significantFigures:0,ne=ee?R(q,ee):q,ie=S(ne,Y,L.display),se=s(ne,Y.base,ie);let he=typeof L.decimals=="number"?L.decimals:L.minDecimals??0,ce=typeof L.decimals=="number"?L.decimals:L.maxDecimals??Math.max(he,2);ee&&(he=v(se,ee),ce=he);const te=y(L.locale,he,ce,L.group!==!1).format(se),oe=L.space??" ";return L.placement==="prefix"?`${ie.symbol}${L.space??""}${te}`:`${te}${oe}${ie.symbol}`}function F(M,j){const L=$(M)||Number.isNaN(M)?null:Number(M),G=$(j)||Number.isNaN(j)?null:Number(j);return L===null||Number.isNaN(L)?G===null||Number.isNaN(G)?0:1:G===null||Number.isNaN(G)||L<G?-1:L>G?1:0}function E(M){const j=typeof M.decimals=="number"&&M.decimals>0?`.${"0".repeat(M.decimals)}`:"";return`${typeof M.decimals=="number"?`#,##0${j}`:"#,##0.##"}" ${M.symbol}"`}function D(M){const j={system:"data",...M||{}},L=n(j),G=L?L.base.symbol:String(j.unit||""),q=Object.freeze({...j,unit:G}),Y=Object.freeze({...q,display:G,decimals:void 0,minDecimals:0,maxDecimals:20,group:!1}),J=new Map([[q.locale||"",q]]),ee=ne=>{const ie=ne||"";let se=J.get(ie);return se||(se=Object.freeze({...q,locale:ne||void 0}),J.set(ie,se)),se};return{base:"number",extends:"number",storage:"float64",unitConfig:q,format:ne=>P(ne.value,ne.locale?ee(ne.locale):q),parse:ne=>O(ne.text,ne.locale?ee(ne.locale):q),compare:F,defaults:{filter:"number",editor:"unit",align:"end",total:j.total||"sum"},...j.totals?{totals:j.totals}:{},excel:j.excel||E({decimals:j.decimals,symbol:G}),toStorage:ne=>typeof ne=="number"?Number.isFinite(ne)?ne:null:typeof ne=="string"?O(ne,q):$(ne)?null:O(String(ne),q),toClipboard:ne=>P(ne,Y),fromClipboard:ne=>O(ne,q)}}const N=D}),Fe("packages/core/src/columns/types/engineering.js",function(e,K){"use strict";Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return _}});const $=K("packages/core/src/internal/util.js").isNil,I=K("packages/core/src/columns/types/unit.js").createUnitType;function _(H){const V=2*Math.PI/H;return z=>{let w=0,A=0,g=0;for(const d of z||[]){if($(d))continue;const o=Number(d);Number.isFinite(o)&&(w+=Math.cos(o*V),A+=Math.sin(o*V),g+=1)}return!g||Math.hypot(w,A)/g<1e-12?null:(Math.atan2(A,w)/V%H+H)%H}}function X(H){return{supported:["sum","avg","min","max","count","countValues"],implement:{avg:_(H)}}}const W=Object.freeze({metres:I({system:"length",unit:"m",display:"auto",maxDecimals:3}),millimetres:I({system:"length",unit:"mm",maxDecimals:2}),kilometres:I({system:"length",unit:"km",maxDecimals:3}),grams:I({system:"mass",unit:"g",display:"auto",maxDecimals:3}),kilograms:I({system:"mass",unit:"kg",maxDecimals:3}),tonnes:I({system:"mass",unit:"t",maxDecimals:3}),seconds:I({system:"duration",unit:"s",display:"auto",maxDecimals:3}),milliseconds:I({system:"duration",unit:"ms",maxDecimals:3}),hours:I({system:"duration",unit:"h",maxDecimals:2}),speed:I({system:"speed",unit:"m/s",display:"auto",maxDecimals:2}),kph:I({system:"speed",unit:"km/h",maxDecimals:1}),mph:I({system:"speed",unit:"mph",maxDecimals:1}),knots:I({system:"speed",unit:"kn",maxDecimals:1}),acceleration:I({system:"acceleration",unit:"m/s²",maxDecimals:3}),area:I({system:"area",unit:"m²",display:"auto",maxDecimals:2}),hectares:I({system:"area",unit:"ha",maxDecimals:4}),volume:I({system:"volume",unit:"L",display:"auto",maxDecimals:3}),cubicMetres:I({system:"volume",unit:"m³",maxDecimals:3}),energy:I({system:"energy",unit:"J",display:"auto",maxDecimals:3}),kilowattHours:I({system:"energy",unit:"kWh",maxDecimals:2}),power:I({system:"power",unit:"W",display:"auto",maxDecimals:2}),kilowatts:I({system:"power",unit:"kW",maxDecimals:2}),force:I({system:"force",unit:"N",display:"auto",maxDecimals:2}),pressure:I({system:"pressure",unit:"Pa",display:"auto",maxDecimals:2}),bar:I({system:"pressure",unit:"bar",maxDecimals:3}),psi:I({system:"pressure",unit:"psi",maxDecimals:1}),torque:I({system:"torque",unit:"N·m",maxDecimals:2}),density:I({system:"density",unit:"kg/m³",maxDecimals:2}),flow:I({system:"flow",unit:"m³/s",maxDecimals:4}),litresPerMinute:I({system:"flow",unit:"L/min",maxDecimals:1}),radians:I({system:"angle",unit:"rad",maxDecimals:4,totals:X(2*Math.PI)}),degrees:I({system:"angle",unit:"°",maxDecimals:2,totals:X(360)}),rpm:I({system:"angularVelocity",unit:"rpm",maxDecimals:0}),angularVelocity:I({system:"angularVelocity",unit:"rad/s",maxDecimals:3}),ppm:I({system:"fraction",unit:"ppm",maxDecimals:2}),ppb:I({system:"fraction",unit:"ppb",maxDecimals:2}),basisPoints:I({system:"fraction",unit:"bp",maxDecimals:1}),molarity:I({system:"molarity",unit:"M",display:"auto",maxDecimals:3}),massFlow:I({system:"massFlow",unit:"kg/s",maxDecimals:3}),tonnesPerHour:I({system:"massFlow",unit:"t/h",maxDecimals:2}),viscosity:I({system:"viscosity",unit:"Pa·s",display:"auto",maxDecimals:3}),kinematicViscosity:I({system:"kinematicViscosity",unit:"cSt",maxDecimals:2}),thermalConductivity:I({system:"thermalConductivity",unit:"W/(m·K)",maxDecimals:3}),specificHeat:I({system:"specificHeat",unit:"J/(kg·K)",maxDecimals:1}),doseRate:I({system:"doseRate",unit:"µSv/h",display:"auto",maxDecimals:2})})}),Fe("packages/core/src/columns/types/si.js",function(e,K){"use strict";Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const Q=K("packages/core/src/columns/types/unit.js"),$=Q.defineUnit,B=Q.registerUnitSystem,I=Q.createUnitType,_=Object.freeze([Object.freeze({symbol:"f",name:"femto",factor:1e-15}),Object.freeze({symbol:"p",name:"pico",factor:1e-12}),Object.freeze({symbol:"n",name:"nano",factor:1e-9}),Object.freeze({symbol:"µ",name:"micro",factor:1e-6}),Object.freeze({symbol:"m",name:"milli",factor:.001}),Object.freeze({symbol:"c",name:"centi",factor:.01}),Object.freeze({symbol:"",name:"",factor:1}),Object.freeze({symbol:"k",name:"kilo",factor:1e3}),Object.freeze({symbol:"M",name:"mega",factor:1e6}),Object.freeze({symbol:"G",name:"giga",factor:1e9}),Object.freeze({symbol:"T",name:"tera",factor:1e12}),Object.freeze({symbol:"P",name:"peta",factor:1e15})]),X=Object.freeze(["p","n","µ","m","","k","M","G"]);function W(A){const g=String(A.base),l=new Set([...A.prefixes||X,""]),d=[];for(const o of _){if(!l.has(o.symbol))continue;const n=`${o.symbol}${g}`,t=[];if(A.name){t.push(`${o.name}${A.name}`,`${o.name}${A.name}s`);const r=o.name.slice(-1);if(r&&A.name.startsWith(r)){const s=`${o.name.slice(0,-1)}${A.name}`;t.push(s,`${s}s`)}}o.symbol==="µ"&&t.push(`u${g}`),o.factor===1&&A.aliases&&t.push(...A.aliases),d.push($(n,o.factor,t))}for(const o of A.extra||[])d.push(o);return d}function H(A,g){const l=W(g);return B(A,l)}function V(A,g,l){return H(A,g),I({system:A,unit:g.base,display:"auto",maxDecimals:3,...l||{}})}const z=Object.freeze({voltage:V("voltage",{base:"V",name:"volt"}),current:V("current",{base:"A",name:"amp",aliases:["ampere","amperes"]}),resistance:V("resistance",{base:"Ω",name:"ohm",aliases:["ohm","ohms","R"],prefixes:["m","","k","M","G"]}),capacitance:V("capacitance",{base:"F",name:"farad",prefixes:["f","p","n","µ","m",""]}),inductance:V("inductance",{base:"H",name:"henry",prefixes:["p","n","µ","m",""]}),charge:V("charge",{base:"C",name:"coulomb",prefixes:["p","n","µ","m",""],extra:[$("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),$("Ah",3600,["amphour","amphours"],{auto:!1})]}),conductance:V("conductance",{base:"S",name:"siemens",prefixes:["n","µ","m","","k"]}),fluxDensity:V("fluxDensity",{base:"T",name:"tesla",prefixes:["n","µ","m",""],extra:[$("G",1e-4,["gauss"],{auto:!1})]}),luminousFlux:V("luminousFlux",{base:"lm",name:"lumen",prefixes:["m","","k"]}),illuminance:V("illuminance",{base:"lx",name:"lux",prefixes:["m","","k"]}),luminousIntensity:V("luminousIntensity",{base:"cd",name:"candela",prefixes:["m","","k"]}),substance:V("substance",{base:"mol",name:"mole",prefixes:["n","µ","m","","k"]}),absorbedDose:V("absorbedDose",{base:"Gy",name:"gray",prefixes:["µ","m",""]}),equivalentDose:V("equivalentDose",{base:"Sv",name:"sievert",prefixes:["n","µ","m",""]}),radioactivity:V("radioactivity",{base:"Bq",name:"becquerel",prefixes:["","k","M","G","T"],extra:[$("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:V("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),w=V}),Fe("packages/core/src/columns/types/temperature.js",function(e,K){"use strict";Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const $=K("packages/core/src/internal/util.js").isNil,B=Object.freeze({C:Object.freeze({symbol:"°C",aliases:["c","°c","celsius","centigrade"],toKelvin:d=>d+273.15,fromKelvin:d=>d-273.15}),F:Object.freeze({symbol:"°F",aliases:["f","°f","fahrenheit"],toKelvin:d=>(d+459.67)*(5/9),fromKelvin:d=>d*(9/5)-459.67}),K:Object.freeze({symbol:"K",aliases:["k","kelvin"],toKelvin:d=>d,fromKelvin:d=>d}),R:Object.freeze({symbol:"°R",aliases:["r","°r","rankine"],toKelvin:d=>d*(5/9),fromKelvin:d=>d*(9/5)})});function I(d){if($(d))return null;const o=String(d).trim();if(o==="")return null;for(const[t,r]of Object.entries(B))if(o===t||o===r.symbol)return{key:t,scale:r};const n=o.toLowerCase();for(const[t,r]of Object.entries(B))if(r.aliases.includes(n))return{key:t,scale:r};return null}function _(d,o,n){const t=I(o),r=I(n);return!t||!r||!Number.isFinite(Number(d))?null:t.key===r.key?Number(d):r.scale.fromKelvin(t.scale.toKelvin(Number(d)))}const X=new Map;function W(d,o,n){const t=`${d||""}|${o}|${n}`;let r=X.get(t);return r||(r=new Intl.NumberFormat(d||void 0,{minimumFractionDigits:o,maximumFractionDigits:n}),X.set(t,r)),r}function H(d,o){const n=o||{},t=n.nullDisplay??"";if($(d)||d==="")return t;const r=Number(d);if(!Number.isFinite(r))return t;const s=I(n.scale||"C");if(!s)return String(r);const h=I(n.display||n.scale||"C")||s,u=h.key===s.key?r:h.scale.fromKelvin(s.scale.toKelvin(r)),i=typeof n.decimals=="number"?n.decimals:null,m=i??n.minDecimals??0,c=i??n.maxDecimals??1;return`${W(n.locale,m,c).format(u)}${n.space??" "}${h.scale.symbol}`}const V=/^[+-]?[\d\s., ]*\d/;function z(d,o){const n=String(d).trim();if(n==="")return null;const t=new Intl.NumberFormat(o||void 0).formatToParts(1.1).find(u=>u.type==="decimal")?.value||".",r=t===","?".":",",s=n.split(r).join("").split(/[\s ]/).join("").replace(t,"."),h=Number(s);return Number.isFinite(h)?h:null}function w(d,o){if($(d))return null;const n=o||{},t=I(n.scale||"C");if(!t)return null;if(typeof d=="number")return Number.isFinite(d)?d:null;let r=String(d).trim();if(r==="")return null;let s=!1;r.startsWith("(")&&r.endsWith(")")&&(s=!0,r=r.slice(1,-1).trim());const h=V.exec(r);if(!h)return null;const u=z(h[0],n.locale);if(u===null)return null;const i=r.slice(h[0].length).trim();if(i==="")return s?-u:u;const m=I(i);if(!m)return null;const c=m.key===t.key?u:t.scale.fromKelvin(m.scale.toKelvin(u));return s?-c:c}function A(d){const o=Object.freeze({scale:"C",...d||{}}),t=(I(o.scale)||I("C")).scale.symbol,r=Object.freeze({...o,display:o.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),s=new Map([[o.locale||"",o]]),h=u=>{const i=u||"";let m=s.get(i);return m||(m=Object.freeze({...o,locale:u||void 0}),s.set(i,m)),m};return{base:"number",extends:"number",storage:"float64",temperatureConfig:o,format:u=>H(u.value,u.locale?h(u.locale):o),parse:u=>w(u.text,u.locale?h(u.locale):o),defaults:{filter:"number",editor:"temperature",align:"end",total:"avg"},totals:{supported:["avg","min","max","count","countValues"]},excel:o.excel||`#,##0${typeof o.decimals=="number"&&o.decimals>0?`.${"0".repeat(o.decimals)}`:".#"}" ${t}"`,toStorage:u=>typeof u=="number"?Number.isFinite(u)?u:null:typeof u=="string"?w(u,o):$(u)?null:w(String(u),o),toClipboard:u=>H(u,r),fromClipboard:u=>w(u,o)}}const g=Object.freeze({celsius:A({scale:"C"}),fahrenheit:A({scale:"F"}),kelvin:A({scale:"K"})}),l=A}),Fe("packages/core/src/columns/types/radix.js",function(e,K){"use strict";Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"digitsForWidth",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"radixRange",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"radixName",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"normaliseRadixOptions",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"compileRadixFormat",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"compileRadixParse",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"parseRadixResult",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return C}});const Q=K("packages/core/src/internal/util.js"),$=Q.isNil,B=Q.warnOnce,I=Object.freeze({2:2,8:8,16:16,bin:2,binary:2,base2:2,oct:8,octal:8,base8:8,hex:16,hexadecimal:16,base16:16}),_=Object.freeze({2:1,8:3,16:4}),X=Object.freeze({2:"0b",8:"0o",16:"0x"}),W=Object.freeze({2:4,8:3,16:2}),H=Object.freeze({2:/^[01]+$/,8:/^[0-7]+$/,16:/^[0-9a-f]+$/i}),V=Object.freeze({2:"binary",8:"octal",16:"hexadecimal"}),z=Object.freeze([[/^0x/i,16],[/^0b/i,2],[/^0o/i,8],[/^#/,16]]),w=/[\s\u00a0\u202f_,']/g,A=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,g=Object.freeze([8,16,32,53]),l=new WeakSet,d=new WeakMap,o=new Map,n=new WeakMap,t=new WeakMap,r=Object.freeze({hex:Object.freeze({radix:16}),hex8:Object.freeze({radix:16,bitWidth:8,pad:!0,signed:!1}),hex16:Object.freeze({radix:16,bitWidth:16,pad:!0,signed:!1}),hex32:Object.freeze({radix:16,bitWidth:32,pad:!0,signed:!1}),binary:Object.freeze({radix:2}),binary8:Object.freeze({radix:2,bitWidth:8,pad:!0,signed:!1,group:4}),octal:Object.freeze({radix:8})});function s(P){if(P==null)return 16;const F=typeof P=="string"?P.toLowerCase():P,E=I[F];return E||(B(`radix:base:${String(P)}`,`unsupported radix ${String(P)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function h(P,F){return Math.ceil(P/_[F])}function u(P,F){if(!P)return F?{min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}:{min:0,max:Number.MAX_SAFE_INTEGER};if(!F)return{min:0,max:2**P-1};const E=2**(P-1);return{min:-E,max:E-1}}function i(P){return V[P]||"hexadecimal"}function m(P){if(typeof P=="string"){const F=r[P];return F||B(`radix:preset:${P}`,`unknown radix preset "${P}"; known presets are ${Object.keys(r).join(", ")}`),{...F||{}}}if(P&&typeof P.preset=="string"){const F=r[P.preset];return F||B(`radix:preset:${P.preset}`,`unknown radix preset "${P.preset}"; known presets are ${Object.keys(r).join(", ")}`),{...F||{},...P}}return P||{}}function c(P){const F=m(P),E=s(F.radix),D=_[E];let N=null;if(F.bitWidth!==void 0&&F.bitWidth!==null&&F.bitWidth!==!1){const ne=Number(F.bitWidth);g.includes(ne)?N=ne:B(`radix:width:${String(F.bitWidth)}`,`unsupported bitWidth ${String(F.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let M=F.signed!==!1;!M&&N===null&&(B("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),N=32);const j=F.prefix===void 0||F.prefix===!0?X[E]:F.prefix===!1?"":String(F.prefix);let L=0;F.pad===!0?L=N?h(N,E):0:typeof F.pad=="number"&&F.pad>0&&(L=Math.floor(F.pad));let G=0;F.group===!0?G=W[E]:typeof F.group=="number"&&F.group>0&&(G=Math.floor(F.group));const q=u(N,M),Y=typeof F.min=="number"?Math.max(q.min,F.min):q.min,J=typeof F.max=="number"?Math.min(q.max,F.max):q.max,ee=Object.freeze({radix:E,bits:D,prefix:j,uppercase:F.uppercase!==!1,pad:L,group:G,groupSeparator:typeof F.groupSeparator=="string"?F.groupSeparator:" ",bitWidth:N,signed:M,min:Y,max:J<Y?Y:J,nullDisplay:typeof F.nullDisplay=="string"?F.nullDisplay:"",name:i(E)});return l.add(ee),ee}function f(P){if(P&&l.has(P))return P;if(typeof P=="string"){let F=o.get(P);return F||(F=c(P),o.set(P,F)),F}if(P&&typeof P=="object"){let F=d.get(P);return F||(F=c(P),d.set(P,F)),F}return f("hex")}function a(P){return P<0?-Math.round(-P):Math.round(P)}function p(P,F,E){if(F<=0||P.length<=F)return P;const D=P.length%F||F,N=[P.slice(0,D)];for(let M=D;M<P.length;M+=F)N.push(P.slice(M,M+F));return N.join(E)}function b(P){const F=f(P),{radix:E,prefix:D,uppercase:N,pad:M,group:j,groupSeparator:L,signed:G,bitWidth:q,nullDisplay:Y}=F,J=q?2**q:0,ee=ne=>{if($(ne)||ne==="")return Y;const ie=typeof ne=="number"?ne:Number(ne);if(!Number.isFinite(ie))return Y;const se=a(ie);let he="",ce=se;se<0&&(G?(he="-",ce=-se):ce=(se%J+J)%J);let te=ce.toString(E);return te=N?te.toUpperCase():te.toLowerCase(),M>0&&te.length<M&&(te=te.padStart(M,"0")),j>0&&(te=p(te,j,L)),he+D+te};return ee.options=F,ee}function O(P,F){const E=f(F);let D=n.get(E);return D||(D=b(E),n.set(E,D)),D(P)}function k(P){const F=f(P),{radix:E,groupSeparator:D,signed:N,min:M,max:j}=F,L=H[E],G=q=>{if($(q))return{ok:!0,value:null,reason:"blank"};let Y=String(q);if(D&&D!==""&&(Y=Y.split(D).join("")),Y=Y.replace(w,""),Y==="")return{ok:!0,value:null,reason:"blank"};let J=!1;if((Y[0]==="-"||Y[0]==="+")&&(J=Y[0]==="-",Y=Y.slice(1)),Y==="")return{ok:!1,value:null,reason:"digits"};let ee=null;for(const[ie,se]of z){const he=ie.exec(Y);if(!he)continue;const ce=Y.slice(he[0].length);if(ce==="")break;if(!H[se].test(ce))return{ok:!1,value:null,reason:"digits"};ee=parseInt(ce,se);break}if(ee===null)if(L.test(Y))ee=parseInt(Y,E);else if(A.test(Y))ee=Number(Y);else return{ok:!1,value:null,reason:"digits"};if(!Number.isFinite(ee))return{ok:!1,value:null,reason:"digits"};const ne=a(J?-ee:ee);return!N&&ne<0?{ok:!1,value:ne,reason:"negative"}:ne<M||ne>j?{ok:!1,value:ne,reason:"range"}:{ok:!0,value:ne,reason:"ok"}};return G.options=F,G}function y(P,F){const E=f(F);let D=t.get(E);return D||(D=k(E),t.set(E,D)),D(P)}function v(P,F){const E=y(P,F);return E.ok?E.value:null}function R(P,F){const E=$(P)||Number.isNaN(P)?null:Number(P),D=$(F)||Number.isNaN(F)?null:Number(F);return E===null?D===null?0:1:D===null||E<D?-1:E>D?1:0}function S(P){const F=P.min>=-2147483648&&P.max<=2147483647;return P.bitWidth&&F?"int32":"float64"}function x(P){const F=c(P),E=b(F),D=k(F);return{base:"number",extends:"number",storage:S(F),matches:null,format:N=>E(N.value),parse:N=>{const M=D(N.text);return M.ok?M.value:null},compare:R,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:N=>E(N),fromClipboard:N=>{const M=D(N);return M.ok?M.value:null},radix:F,formatValue:E,parseText:D}}const C=x}),Fe("packages/core/src/columns/types/aggregable.js",function(e,K){"use strict";Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"weightedMean",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"logarithmicSum",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"logarithmicMean",{enumerable:!0,get:function(){return _}});const $=K("packages/core/src/internal/util.js").isNil;function B(z){const w=[];for(const A of z||[]){if($(A))continue;const g=Number(A);Number.isFinite(g)&&w.push(g)}return w}function I(z){return w=>{const A=B(w);if(!A.length)return null;let g=0;for(const l of A)g+=10**(l/z);return z*Math.log10(g)}}function _(z){return w=>{const A=B(w);if(!A.length)return null;let g=0;for(const l of A)g+=10**(l/z);return z*Math.log10(g/A.length)}}function X(z,w){const A=w&&w.column,l=(A&&A.typeOptions||{}).weight,d=w&&w.valueAt;if(!l||typeof d!="function")return null;let o=0,n=0;for(let t=0;t<z.length;t++){if($(z[t]))continue;const r=Number(z[t]);if(!Number.isFinite(r))continue;const s=d(l,t);if($(s))continue;const h=Number(s);!Number.isFinite(h)||h<=0||(o+=r*h,n+=h)}return n===0?null:o/n}function W(z={}){const w=z.factor===20?20:10,A=typeof z.suffix=="string"?z.suffix:"",g=Number.isInteger(z.decimals)?z.decimals:1;return{base:"number",storage:"float64",name:z.name||"logarithmic",format:l=>{const d=l&&l.value;return $(d)||!Number.isFinite(Number(d))?"":`${Number(d).toFixed(g)}${A}`},parse:l=>{const d=String((l&&l.text)??"").replace(A,"").trim();if(!d)return null;const o=Number(d);return Number.isFinite(o)?o:null},defaults:{align:"end",filter:"number"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:{sum:I(w),avg:_(w)}}}}function H(z={}){const w=Number.isInteger(z.decimals)?z.decimals:1,A=z.percent===!0;return{base:"number",storage:"float64",name:z.name||"ratio",format:g=>{const l=g&&g.value;return $(l)||!Number.isFinite(Number(l))?"":A?`${Number(l).toFixed(w)}%`:Number(l).toFixed(w)},parse:g=>{const l=String((g&&g.text)??"").replace("%","").trim();if(!l)return null;const d=Number(l);return Number.isFinite(d)?d:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:X}}}}const V=Object.freeze({decibel:W({name:"decibel",factor:10,suffix:" dB"}),decibelAmplitude:W({name:"decibelAmplitude",factor:20,suffix:" dB"}),ratio:H({name:"ratio"}),percentRate:H({name:"percentRate",percent:!0})})}),Fe("packages/core/src/columns/types/currency.js",function(e,K){"use strict";Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"moneyToText",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const $=K("packages/core/src/internal/util.js").isNil,B="⚠ no rate";function I(u){if($(u))return null;const i=String(u).trim().toUpperCase();return i===""?null:i}function _(u){if($(u))return null;if(typeof u=="object"&&!Array.isArray(u)){const i=Number(u.amount),m=I(u.code);return!m||!Number.isFinite(i)?null:{amount:i,code:m}}if(Array.isArray(u)&&u.length===2){const i=Number(u[0]),m=I(u[1]);return!m||!Number.isFinite(i)?null:{amount:i,code:m}}return null}const X=Object.freeze({$:"USD","€":"EUR","£":"GBP","¥":"JPY","₹":"INR","₩":"KRW","₽":"RUB","₺":"TRY","₴":"UAH","₪":"ILS"}),W=Object.freeze({USD:"$",EUR:"€",GBP:"£",JPY:"¥",INR:"₹",KRW:"₩",RUB:"₽",TRY:"₺",UAH:"₴",ILS:"₪"}),H=/[+-]?[\d\s., ]*\d/;function V(u,i){const m=String(u).trim();if(m==="")return null;const c=new Intl.NumberFormat(i||void 0).formatToParts(1.1).find(b=>b.type==="decimal")?.value||".",f=c===","?".":",",a=m.split(f).join("").split(/[\s ]/).join("").replace(c,"."),p=Number(a);return Number.isFinite(p)?p:null}function z(u,i){const m=i||{},c=I(m.code);if($(u))return null;const f=_(u);if(f)return f;if(typeof u=="number")return Number.isFinite(u)&&c?{amount:u,code:c}:null;let a=String(u).trim();if(a==="")return null;let p=!1;a.startsWith("(")&&a.endsWith(")")&&(p=!0,a=a.slice(1,-1).trim());let b=null;for(const[S,x]of Object.entries(X)){if(a.startsWith(S)){b=x,a=a.slice(S.length).trim();break}if(a.endsWith(S)){b=x,a=a.slice(0,-S.length).trim();break}}const O=H.exec(a);if(!O)return null;const k=V(O[0],m.locale);if(k===null)return null;const y=(a.slice(0,O.index)+" "+a.slice(O.index+O[0].length)).trim();!b&&y!==""&&(b=I(y));const v=b||c;return v?{amount:p?-k:k,code:v}:null}function w(u,i){if(typeof u=="function")return(m,c)=>{if(m===c)return 1;const f=u(m,c);return typeof f=="number"&&Number.isFinite(f)&&f>0?f:null};if(u&&typeof u=="object"){const m=u;return(c,f)=>{if(c===f)return 1;const a=Number(m[c]),p=Number(m[f]);return!Number.isFinite(a)||!Number.isFinite(p)||a<=0||p<=0?null:p/a}}return(m,c)=>m===c?1:null}function A(u,i,m){if(!u)return null;if(u.code===i)return u.amount;const c=m(u.code,i);return c===null?null:u.amount*c}const g=new Map;function l(u,i,m){const c=`${u||""}|${i}|${m??""}`;let f=g.get(c);if(!f){const a={style:"currency",currency:i};typeof m=="number"&&(a.minimumFractionDigits=m,a.maximumFractionDigits=m);try{f={fmt:new Intl.NumberFormat(u||void 0,a),currency:!0}}catch{f={fmt:new Intl.NumberFormat(u||void 0,typeof m=="number"?{minimumFractionDigits:m,maximumFractionDigits:m}:{}),currency:!1}}g.set(c,f)}return f}function d(u,i){const m=i||{},c=m.nullDisplay??"",f=_(u);if(!f)return c;const a=I(m.display)||f.code;let p=f.amount,b=f.code;if(a!==f.code){const y=m.rateFn||w(m.rates,m.rateBase),v=A(f,a,y);if(v===null)return`${m.missingRate??B} ${f.code}→${a}`;p=v,b=a}const{fmt:O,currency:k}=l(m.locale,b,m.decimals);return k?O.format(p):`${O.format(p)} ${b}`}function o(u){const i=_(u);return i?`${i.amount} ${i.code}`:""}function n(u){const i=u||{},m=I(i.display),c=i.rateFn||w(i.rates,i.rateBase);return(f,a)=>{const p=_(f),b=_(a);if(!p&&!b)return 0;if(!p)return 1;if(!b)return-1;if(m){const O=A(p,m,c),k=A(b,m,c);if(O!==null&&k!==null)return O===k?0:O<k?-1:1}return p.code===b.code?p.amount===b.amount?0:p.amount<b.amount?-1:1:p.code<b.code?-1:1}}function t(u){const i=u||{},m=(f,a)=>{const p=[];for(const v of f||[]){const R=_(v);R&&p.push(R)}if(!p.length)return null;if(new Set(p.map(v=>v.code)).size===1){const v=p[0].code;return{amount:a(p.map(R=>R.amount)),code:v}}const O=I(i.display);if(!O)return`${i.missingRate??B}: mixed currencies, no display currency set`;const k=i.rateFn||w(i.rates,i.rateBase),y=[];for(const v of p){const R=A(v,O,k);if(R===null)return`${i.missingRate??B}: ${v.code}→${O}`;y.push(R)}return{amount:a(y),code:O}},c=f=>f.reduce((a,p)=>a+p,0);return{sum:f=>m(f,c),avg:f=>m(f,a=>c(a)/a.length),min:f=>m(f,a=>Math.min(...a)),max:f=>m(f,a=>Math.max(...a))}}function r(u){const i=Object.freeze({code:"USD",...u||{}}),m=w(i.rates,i.rateBase),c=Object.freeze({...i,rateFn:m}),f=t(c),a=n(c),p=new Map([[i.locale||"",c]]),b=y=>{const v=y||"";let R=p.get(v);return R||(R=Object.freeze({...c,locale:y||void 0}),p.set(v,R)),R},O=W[I(i.display||i.code)]||"",k=typeof i.decimals=="number"&&i.decimals>0?`.${"0".repeat(i.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:c,format:y=>d(y.value,y.locale?b(y.locale):c),parse:y=>z(y.text,y.locale?b(y.locale):c),compare:a,defaults:{filter:"number",editor:"currency",align:"end",total:"sum"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:f},excel:i.excel||(O?`"${O}"#,##0${k}`:`#,##0${k}`),toStorage:y=>{const v=_(y);return v||(typeof y=="string"||typeof y=="number"?z(y,c):null)},toClipboard:y=>o(y),fromClipboard:y=>z(y,c)}}const s=Object.freeze({currency:r({code:"USD"}),usd:r({code:"USD"}),eur:r({code:"EUR"}),gbp:r({code:"GBP"}),jpy:r({code:"JPY",decimals:0})}),h=r}),Fe("packages/core/src/columns/types/index.js",function(e,K){"use strict";Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return S}});const Q=K("packages/core/src/columns/types/temporal.js"),$=Q.TEMPORAL_TYPES,B=K("packages/core/src/columns/types/network.js"),I=B.NETWORK_TYPES,_=K("packages/core/src/columns/types/structured.js"),X=_.STRUCTURED_TYPES,W=K("packages/core/src/columns/types/unit.js"),H=W.createUnitType,V=W.UNIT_SYSTEMS,z=W.parseUnit,w=W.formatUnit,A=W.registerUnitSystem,g=W.unitSystemNames,l=W.unitsOf,d=W.defineUnit,o=K("packages/core/src/columns/types/engineering.js"),n=o.ENGINEERING_TYPES,t=K("packages/core/src/columns/types/si.js"),r=t.SI_TYPES,s=t.createSiType,h=t.createSiSystem,u=t.siUnits,i=t.SI_PREFIXES,m=K("packages/core/src/columns/types/temperature.js"),c=m.TEMPERATURE_TYPES,f=m.createTemperatureType,a=m.convertTemperature,p=m.formatTemperature,b=m.parseTemperature,O=m.TEMPERATURE_SCALES,k=K("packages/core/src/columns/types/radix.js"),y=k.createRadixType,v=k.RADIX_PRESETS,R=k.parseRadix,S=k.formatRadix,x=K("packages/core/src/columns/types/aggregable.js"),C=x.AGGREGABLE_TYPES,P=K("packages/core/src/columns/types/currency.js"),F=P.CURRENCY_TYPES,E=P.createCurrencyType,D=P.parseMoney,N=P.formatMoney,M=P.convertMoney,j=P.toMoney,L=P.rateFunction,G=P.moneyComparator,q=P.normaliseCode,Y=P.MISSING_RATE;Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return W.findUnit}}),Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return o.ENGINEERING_TYPES}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return o.circularMean}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return m.TEMPERATURE_TYPES}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return m.createTemperatureType}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return m.convertTemperature}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return m.formatTemperature}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return m.parseTemperature}}),Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return m.TEMPERATURE_SCALES}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return m.findScale}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return P.CURRENCY_TYPES}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return P.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return P.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return P.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return P.convertMoney}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return P.toMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return P.rateFunction}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return P.moneyComparator}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return P.normaliseCode}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return P.MISSING_RATE}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return Q.TEMPORAL_TYPES}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return B.NETWORK_TYPES}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return _.STRUCTURED_TYPES}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return x.AGGREGABLE_TYPES}}),Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return x.createLogarithmicType}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return x.createRatioType}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return Q.parseTime}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return Q.formatTime}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return Q.parseDateTime}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return Q.formatDateTime}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return Q.parseDuration}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return Q.formatDuration}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return B.parseIpv4}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return B.formatIpv4}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return B.parseCidr}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return B.formatCidr}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return B.parseIpv6}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return B.formatIpv6}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return B.networkAddress}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return B.broadcastAddress}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return B.hostCount}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return B.containsAddress}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return B.overlaps}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return _.maskValue}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return _.summariseJson}});const J=Object.freeze({...$,...I,...X,...C,hex:y(v.hex),hex8:y(v.hex8),hex16:y(v.hex16),hex32:y(v.hex32),binary:y(v.binary),binary8:y(v.binary8),octal:y(v.octal),bytes:H({system:"data",unit:"B",display:"auto"}),megabytes:H({system:"data",unit:"MB"}),gigabytes:H({system:"data",unit:"GB"}),bitrate:H({system:"bitrate",unit:"Mbps"}),gigabits:H({system:"bitrate",unit:"Gbps"}),...n,...r,...c,...F});{const ee=new Set;for(const ne of[$,I,X,C,n,r,c,F])for(const ie of Object.keys(ne)){if(ee.has(ie))throw new Error(`[lattice] data type "${ie}" is declared twice`);ee.add(ie)}}}),Fe("packages/core/src/compute/handle.js",function(e,K){"use strict";Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return t}});const Q=K("packages/core/src/internal/util.js"),$=Q.collator,B=Q.defaultCompare,I=Q.warnOnce;function _(r){const s=new Uint32Array(r);for(let h=0;h<r;h++)s[h]=h;return s}function X(r,s){if(s&&typeof s.count=="number")return s.count;if(!r)return 0;if(typeof r.count=="number")return r.count;if(typeof r.length=="number")return r.length;const h=r.values;return r.kind==="multi"&&r.offsets?Math.max(0,r.offsets.length-1):h?r.kind==="bitset"?typeof h.size=="number"?h.size:r.presence&&typeof r.presence.size=="number"?r.presence.size:(I(`count:${r.id}`,`column "${r.id}" is bitset-backed with no declared row count; assuming ${h.length*8}`),h.length*8):h.length:r.presence&&typeof r.presence.size=="number"?r.presence.size:0}const W=new WeakMap;function H(r){const s=r.constructor;if(!s)return"unknown";const h=W.get(s);if(h)return h;let u="unknown";try{let i=null;typeof s.from=="function"?i=s.from([!1,!0]):(i=new s(8),i.set(1));const m=i&&i.words;m&&m.length&&(m[0]===2?u="lsb":m[0]===64&&(u="msb"))}catch{u="unknown"}return W.set(s,u),u}function V(r){if(!r)return()=>0;const s=r instanceof Uint8Array?r:r.words;if(s instanceof Uint8Array){const h=r instanceof Uint8Array?"lsb":H(r);if(h==="lsb")return u=>s[u>>>3]>>>(u&7)&1;if(h==="msb")return u=>s[u>>>3]>>>7-(u&7)&1}return typeof r.get=="function"?h=>r.get(h)?1:0:()=>0}function z(r){return!r||!r.presence?null:V(r.presence)}function w(r){return r?typeof r.size=="number"?r.size:typeof r.values=="function"?r.values().length:0:0}function A(r,s){return r?typeof r.valueOf=="function"?r.valueOf(s):typeof r.values=="function"?r.values()[s]:null:null}function g(r,s){const h=r.offsets,u=r.values;if(!h||!u)return[];const i=h[s],m=h[s+1];if(!(m>i))return[];const c=r.dict,f=new Array(m-i);for(let a=i;a<m;a++)f[a-i]=c?A(c,u[a]):u[a];return f}function l(r){if(!r)return()=>{};const s=r.values,h=z(r),u=r.kind;if(u==="dictionary"){const i=r.dict;return h?m=>h(m)?A(i,s[m]):null:m=>A(i,s[m])}if(u==="bitset"){const i=V(s);return h?m=>h(m)?i(m)===1:null:m=>i(m)===1}if(u==="multi")return h?i=>h(i)?g(r,i):null:i=>g(r,i);if(!s&&typeof r.get=="function"){const i=r.get.bind(r);return m=>{const c=i(m);return c===void 0?null:c}}return h?i=>{if(!h(i))return null;const m=s[i];return m===void 0?null:m}:i=>{const m=s[i];return m===void 0?null:m}}function d(r,s){if(r<s)return-1;if(r>s)return 1;if(r===s){const i=Object.is(r,-0),m=Object.is(s,-0);return i===m?0:i?-1:1}const h=Number.isNaN(r),u=Number.isNaN(s);return h&&u?0:h?1:-1}function o(r){const s=$(r);return(h,u)=>{if(h===u)return 0;const i=typeof h,m=typeof u;if(i==="string"&&m==="string")return s.compare(h,u);if(i==="number"&&m==="number")return d(h,u);if(i==="boolean"&&m==="boolean")return h===u?0:h?1:-1;if(h instanceof Date||u instanceof Date){const c=h instanceof Date?h.getTime():Number(h),f=u instanceof Date?u.getTime():Number(u);return d(c,f)}return B(h,u)}}function n(r,s){if(r&&typeof r.ranks=="function")return r.ranks(s);const h=r&&typeof r.values=="function"?r.values():[],u=h.length,i=o(s),m=new Array(u);for(let f=0;f<u;f++)m[f]=f;m.sort((f,a)=>i(h[f],h[a])||f-a);const c=new Uint32Array(u);for(let f=0;f<u;f++)c[m[f]]=f;return c}function t(r){return r==null||typeof r=="number"&&Number.isNaN(r)}}),Fe("packages/core/src/compute/filter.js",function(e,K){"use strict";Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"wallMs",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"itemwisePredicate",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"declareOperators",{enumerable:!0,get:function(){return se}}),Object.defineProperty(e,"declaredOperator",{enumerable:!0,get:function(){return he}});const Q=K("packages/core/src/internal/util.js"),$=Q.isBlank,B=Q.toArray,I=Q.warnOnce,_=K("packages/core/src/format/date.js"),X=_.toDate,W=_.toIsoDate,H=K("packages/core/src/compute/handle.js"),V=H.bitReader,z=H.dictSize,w=H.dictValue,A=H.presenceReader,g=H.valueComparator,l=H.valueReader,d=/^\d{4}-\d{2}-\d{2}$/,o="\0null\0";function n(ce,te){const oe=ce&&ce.pool;if(oe){const fe=oe.mask||oe.acquireMask||oe.acquire||oe.take;if(typeof fe=="function"){const de=fe.call(oe,te);if(de&&de.length>=te)return de}}return new Uint8Array(te)}function t(ce,te){const oe=ce&&ce.pool;if(!oe||!te)return;const fe=oe.release||oe.releaseMask||oe.free||oe.recycle;typeof fe=="function"&&fe.call(oe,te)}function r(ce,te,oe){return ce.fill(oe,0,te),ce}function s(ce){return ce==null||typeof ce=="number"&&Number.isNaN(ce)}function h(ce,te){if(ce==null)return ce;if(te==="number")return typeof ce=="number"?ce:Number(ce);if(te==="date"||te==="dateString"){const oe=W(ce);return oe===null?u(ce):oe}return te==="boolean"?typeof ce=="boolean"?ce:ce==="true"||ce===1?!0:ce==="false"||ce===0?!1:!!ce:ce}function u(ce){return ce instanceof Date?ce.getTime():typeof ce=="number"?ce:Date.parse(String(ce))}function i(ce){return typeof ce=="number"?ce:ce instanceof Date?ce.getTime():ce==null||ce===""?NaN:Number(ce)}function m(ce,te){const oe=typeof ce=="string"?ce:String(ce);return te?oe:oe.toLowerCase()}function c(ce,te){return ce==null?o:typeof ce=="string"?te?ce:ce.toLowerCase():ce instanceof Date?ce.getTime():ce}function f(ce,te,oe){const fe=new Set;for(const de of B(ce)){const ve=h(de,oe);fe.add(c(ve,te)),typeof ve=="string"&&ve!==""&&Number.isFinite(Number(ve))?fe.add(Number(ve)):typeof ve=="number"&&Number.isFinite(ve)&&fe.add(c(String(ve),te))}return fe}function a(ce,te,oe){if(ce==null||te===null||te===void 0)return ce==null&&te==null;const fe=typeof ce,de=typeof te;return fe==="string"&&de==="string"?oe?ce===te:ce.toLowerCase()===te.toLowerCase():ce instanceof Date||te instanceof Date?u(ce)===u(te):fe==="number"&&de==="number"?ce===te||Number.isNaN(ce)&&Number.isNaN(te):fe==="number"&&de==="string"?ce===Number(te):fe==="string"&&de==="number"?Number(ce)===te:fe==="boolean"||de==="boolean"?ce===te:Array.isArray(ce)&&Array.isArray(te)?ce.length===te.length&&ce.every((ve,Me)=>a(ve,te[Me],oe)):ce===te}function p(ce,te){try{if(ce instanceof RegExp){const oe=ce.flags.replace(/[gy]/g,"");return new RegExp(ce.source,te||oe.includes("i")?oe:`${oe}i`)}return new RegExp(String(ce),te?"":"i")}catch(oe){return I(`regex:${String(ce)}`,`filter operator "matches" received an invalid pattern: ${String(ce)}`,oe),null}}function b(ce,te){if(ce&&ce.type==="datetime"&&O.has(ce.op))return S(ce,te);const oe=x(ce,te),fe=ce&&ce.type;return fe!=="date"&&fe!=="dateString"?oe:de=>oe(typeof de=="string"&&d.test(de)?de:W(de)??de)}const O=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),k=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3})\d*)?)?)?$/,y=new Map;function v(ce,te){let oe=y.get(te);if(oe===void 0){try{oe=new Intl.DateTimeFormat("en-CA",{timeZone:te,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{oe=null}y.set(te,oe)}if(!oe)return null;const fe={};for(const de of oe.formatToParts(ce))de.type!=="literal"&&(fe[de.type]=de.value);return fe}function R(ce,te){if(ce==null||ce==="")return null;if(typeof ce=="string"){const ve=k.exec(ce.trim());if(ve)return Date.UTC(+ve[1],+ve[2]-1,+ve[3],+(ve[4]||0),+(ve[5]||0),+(ve[6]||0),+(ve[7]||"0").padEnd(3,"0"))}const oe=X(ce);if(!oe)return null;const fe=oe.getUTCMilliseconds(),de=te?v(oe,te):null;return de?Date.UTC(+de.year,+de.month-1,+de.day,de.hour==="24"?0:+de.hour,+de.minute,+de.second,fe):Date.UTC(oe.getFullYear(),oe.getMonth(),oe.getDate(),oe.getHours(),oe.getMinutes(),oe.getSeconds(),fe)}function S(ce,te){const oe=typeof ce.timeZone=="string"&&ce.timeZone?ce.timeZone:void 0,fe=Me=>R(Me,oe),de=Array.isArray(ce.value)?ce.value.map(fe):fe(ce.value),ve=x({...ce,type:"number",value:de},te);return Me=>ve(R(Me))}function x(ce,te){const oe=ce&&ce.op,fe=!!(ce&&ce.caseSensitive),de=ce&&ce.type,ve=g(te),Me=Oe=>Ce=>!Oe(Ce);switch(oe){case"eq":{const Oe=h(ce.value,de);return Ce=>a(Ce,Oe,fe)}case"ne":{const Oe=h(ce.value,de);return Ce=>!a(Ce,Oe,fe)}case"lt":case"lte":case"gt":case"gte":{const Oe=h(ce.value,de);if(s(Oe))return()=>!1;const Ce=oe==="lt"?-1:oe==="lte"?0:oe==="gt"?1:2;return pe=>{if(s(pe))return!1;const we=ve(pe,Oe);return Ce===-1?we<0:Ce===0?we<=0:Ce===1?we>0:we>=0}}case"between":case"notBetween":{const Oe=B(ce.value),Ce=h(Oe[0],de),pe=h(Oe[1],de),we=ce.bounds||"[]",me=we.charAt(0)!=="(",Ne=we.charAt(1)!==")";if(s(Ce)||s(pe))return oe==="between"?()=>!1:()=>!0;const $e=He=>{if(s(He))return!1;const qe=ve(He,Ce),Ae=ve(He,pe);return(me?qe>=0:qe>0)&&(Ne?Ae<=0:Ae<0)};return oe==="between"?$e:Me($e)}case"in":case"notIn":{const Oe=f(ce.value,fe,de),Ce=pe=>Oe.has(c(pe,fe));return oe==="in"?Ce:Me(Ce)}case"contains":case"notContains":{const Oe=m(h(ce.value,de),fe),Ce=pe=>pe==null?!1:m(pe,fe).includes(Oe);return oe==="contains"?Ce:Me(Ce)}case"startsWith":{const Oe=m(h(ce.value,de),fe);return Ce=>Ce==null?!1:m(Ce,fe).startsWith(Oe)}case"endsWith":{const Oe=m(h(ce.value,de),fe);return Ce=>Ce==null?!1:m(Ce,fe).endsWith(Oe)}case"matches":{const Oe=p(ce.value,fe);return Oe?Ce=>Ce==null?!1:Oe.test(String(Ce)):()=>!1}case"blank":return Oe=>$(Oe)||Array.isArray(Oe)&&Oe.length===0;case"notBlank":return Oe=>!($(Oe)||Array.isArray(Oe)&&Oe.length===0);case"containsAny":case"containsNone":{const Oe=f(ce.value,fe,de),Ce=pe=>{const we=pe==null?[]:B(pe);for(let me=0;me<we.length;me++)if(Oe.has(c(we[me],fe)))return!0;return!1};return oe==="containsAny"?Ce:Me(Ce)}case"containsAll":{const Oe=B(ce.value).map(Ce=>c(h(Ce,de),fe));return Ce=>{const pe=Ce==null?[]:B(Ce);if(Oe.length===0)return!0;const we=new Set(pe.map(me=>c(me,fe)));for(let me=0;me<Oe.length;me++)if(!we.has(Oe[me]))return!1;return!0}}default:{const Oe=he(oe);return Oe?Oe.compile(ce.value):(I(`op:${String(oe)}`,`unknown filter operator "${String(oe)}"; the condition is refused rather than matching every row`),()=>!1)}}}function C(ce,te,oe){return b(te,oe)(ce)}const P=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),F=new Set(["containsAny","containsAll","containsNone"]);function E(ce,te,oe){const fe=ce&&ce.op,de=P[fe]||fe,ve=b({...ce,op:de,type:te.type},oe),Me=te.items,Oe=Ce=>{const pe=Me(Ce);if(!pe)return!1;for(let we=0;we<pe.length;we++)if(ve(pe[we]))return!0;return!1};return P[fe]?Ce=>!Oe(Ce):Oe}function D(ce,te,oe,fe){const de=A(ce);if(de){const Oe=te?1:0;for(let Ce=0;Ce<fe;Ce++)oe[Ce]=de(Ce)===Oe?1:0;return oe}const ve=ce.kind;if(ve==="float64"||ve==="int32"||ve==="bitset")return r(oe,fe,te?1:0);const Me=l(ce);for(let Oe=0;Oe<fe;Oe++){const Ce=Me(Oe),pe=$(Ce)||Array.isArray(Ce)&&Ce.length===0;oe[Oe]=pe===te?0:1}return oe}function N(ce,te,oe,fe){const de=ce.dict,ve=z(de),Me=new Uint8Array(ve);for(let we=0;we<ve;we++)Me[we]=te(w(de,we))?1:0;const Oe=ce.values,Ce=A(ce);if(!Ce){for(let we=0;we<fe;we++)oe[we]=Me[Oe[we]];return oe}const pe=te(null)?1:0;for(let we=0;we<fe;we++)oe[we]=Ce(we)===1?Me[Oe[we]]:pe;return oe}function M(ce,te,oe,fe){const de=V(ce.values),ve=te(!0)?1:0,Me=te(!1)?1:0,Oe=A(ce);if(!Oe){for(let pe=0;pe<fe;pe++)oe[pe]=de(pe)===1?ve:Me;return oe}const Ce=te(null)?1:0;for(let pe=0;pe<fe;pe++)oe[pe]=Oe(pe)===0?Ce:de(pe)===1?ve:Me;return oe}function j(ce,te,oe,fe,de){const ve=ce.values,Me=te.type,Oe=te.op;let Ce=!0;switch(Oe){case"eq":case"ne":{const we=i(h(te.value,Me)),me=typeof te.value=="number"&&Number.isNaN(te.value),Ne=Oe==="ne"?1:0;if(me)for(let $e=0;$e<de;$e++)fe[$e]=(Number.isNaN(ve[$e])?1:0)^Ne;else for(let $e=0;$e<de;$e++)fe[$e]=(ve[$e]===we?1:0)^Ne;break}case"lt":{const we=i(h(te.value,Me));for(let me=0;me<de;me++)fe[me]=ve[me]<we?1:0;break}case"lte":{const we=i(h(te.value,Me));for(let me=0;me<de;me++)fe[me]=ve[me]<=we?1:0;break}case"gt":{const we=i(h(te.value,Me));for(let me=0;me<de;me++)fe[me]=ve[me]>we?1:0;break}case"gte":{const we=i(h(te.value,Me));for(let me=0;me<de;me++)fe[me]=ve[me]>=we?1:0;break}case"between":case"notBetween":{const we=B(te.value),me=i(h(we[0],Me)),Ne=i(h(we[1],Me)),$e=te.bounds||"[]",He=$e.charAt(0)!=="(",qe=$e.charAt(1)!==")",Ae=Oe==="notBetween"?1:0;if(He&&qe)for(let Ge=0;Ge<de;Ge++)fe[Ge]=(ve[Ge]>=me&ve[Ge]<=Ne?1:0)^Ae;else if(He)for(let Ge=0;Ge<de;Ge++)fe[Ge]=(ve[Ge]>=me&ve[Ge]<Ne?1:0)^Ae;else if(qe)for(let Ge=0;Ge<de;Ge++)fe[Ge]=(ve[Ge]>me&ve[Ge]<=Ne?1:0)^Ae;else for(let Ge=0;Ge<de;Ge++)fe[Ge]=(ve[Ge]>me&ve[Ge]<Ne?1:0)^Ae;break}case"in":case"notIn":{const we=new Set;for(const Ne of B(te.value)){const $e=i(h(Ne,Me));Number.isNaN($e)||we.add($e)}const me=Oe==="notIn"?1:0;for(let Ne=0;Ne<de;Ne++)fe[Ne]=(we.has(ve[Ne])?1:0)^me;break}default:Ce=!1;break}if(!Ce)return!1;const pe=A(ce);if(pe){const we=oe(null)?1:0;for(let me=0;me<de;me++)pe(me)===0&&(fe[me]=we)}return!0}function L(ce,te,oe,fe){const de=l(ce);for(let ve=0;ve<fe;ve++)oe[ve]=te(de(ve))?1:0;return oe}function G(ce,te,oe){const fe=te.count|0,de=oe||n(te,fe);if(!ce)return r(de,fe,1);const ve=typeof te.handle=="function"?te.handle(ce.col):void 0,Me=typeof te.custom=="function"?te.custom:null;if(!ve){if(Me){for(let we=0;we<fe;we++)de[we]=Me(ce,we)?1:0;return de}return I(`filter:col:${String(ce.col)}`,`filter references unknown column "${String(ce.col)}"; the condition is refused rather than matching every row`),r(de,fe,0)}const Oe=ce.op;if(Oe==="blank"||Oe==="notBlank")return D(ve,Oe==="notBlank",de,fe);const Ce=typeof te.itemwise=="function"?te.itemwise(ce.col):null;if(Ce&&!he(Oe)&&!F.has(Oe))return L(ve,E(ce,Ce,te.locale),de,fe);const pe=b(ce,te.locale);switch(ve.kind){case"dictionary":return N(ve,pe,de,fe);case"bitset":return M(ve,pe,de,fe);case"float64":case"int32":return j(ve,ce,pe,de,fe)?de:L(ve,pe,de,fe);default:return L(ve,pe,de,fe)}}function q(ce,te,oe){if(!ce)return r(n(te,oe),oe,1);if(Array.isArray(ce.conditions)){const fe=ce.conditions.filter(Me=>Me!=null),de=ce.op==="or"?"or":ce.op==="not"?"not":"and";if(fe.length===0)return r(n(te,oe),oe,1);const ve=q(fe[0],te,oe);for(let Me=1;Me<fe.length;Me++){const Oe=q(fe[Me],te,oe);if(de==="or")for(let Ce=0;Ce<oe;Ce++)ve[Ce]|=Oe[Ce];else for(let Ce=0;Ce<oe;Ce++)ve[Ce]&=Oe[Ce];t(te,Oe)}if(de==="not")for(let Me=0;Me<oe;Me++)ve[Me]^=1;return ve}return G(ce,te,n(te,oe))}function Y(ce,te){return q(ce,te,te.count|0)}function J(ce,te){if(!ce||!te)return ce||null;const oe=ce;if(Array.isArray(oe.conditions)){if((oe.op==="or"?"or":oe.op==="not"?"not":"and")!=="and")return ee(oe,te)?null:ce;const de=[];for(const ve of oe.conditions){const Me=J(ve,te);Me&&de.push(Me)}return de.length?{...oe,op:"and",conditions:de}:null}return oe.col===te?null:ce}function ee(ce,te){if(!ce||typeof ce!="object")return!1;const oe=ce;if(oe.col===te)return!0;if(Array.isArray(oe.conditions)){for(const fe of oe.conditions)if(ee(fe,te))return!0}return!1}function ne(ce,te,oe){if(oe&&oe.length>=te){let Me=0;for(let Oe=0;Oe<te;Oe++)ce[Oe]&&(oe[Me++]=Oe);return oe.subarray(0,Me)}let fe=0;for(let Me=0;Me<te;Me++)fe+=ce[Me]?1:0;const de=new Uint32Array(fe);let ve=0;for(let Me=0;Me<te;Me++)ce[Me]&&(de[ve++]=Me);return de}const ie=new Map;function se(ce){if(!(!ce||typeof ce!="object"))for(const[te,oe]of Object.entries(ce))oe&&typeof oe.compile=="function"&&ie.set(te,oe)}function he(ce){return typeof ce=="string"?ie.get(ce):void 0}}),Fe("packages/core/src/columns/datatypes.js",function(e,K){"use strict";Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"parseNumberText",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"BUILTIN_TYPES",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"INFERENCE_ORDER",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"createTypeRegistry",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"comparatorFor",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"storageKind",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"typeLabel",{enumerable:!0,get:function(){return F}});const Q=K("packages/core/src/internal/util.js"),$=Q.collator,B=Q.defaultCompare,I=Q.isNil,_=Q.isObject,X=Q.isFunction,W=Q.fail,H=Q.titleCase,V=K("packages/core/src/format/date.js"),z=V.toDate,w=V.toIsoDate,A=V.compareIso,l=K("packages/core/src/format/boolean.js").toTriState,o=K("packages/core/src/columns/types/index.js").EXTENDED_TYPES,n=K("packages/core/src/formula/index.js"),t=n.evaluateFormula,r=n.looksLikeFormula,h=K("packages/core/src/compute/filter.js").declareOperators,u=/^\d{4}-\d{2}-\d{2}$/;function i(E){return E.getHours()===0&&E.getMinutes()===0&&E.getSeconds()===0&&E.getMilliseconds()===0}const m=new Map;function c(E){const D=E||"",N=m.get(D);if(N)return N;const M={group:",",decimal:"."};try{for(const j of new Intl.NumberFormat(E||void 0).formatToParts(12345.6))j.type==="group"?M.group=j.value:j.type==="decimal"&&(M.decimal=j.value)}catch{}return m.set(D,M),M}const f=/\d\s*[*/^]\s*[\d.(]/;function a(E,D){if(I(E))return null;let N=String(E).trim();if(N===""||N.startsWith("=")||f.test(N))return null;let M=1;N.startsWith("(")&&N.endsWith(")")&&(M=-1,N=N.slice(1,-1));const j=N.endsWith("%"),{group:L,decimal:G}=c(D);if(N=N.replace(/[\s\u00a0\u202f\u2009']/g,""),L&&L!=="."&&L!==","&&(N=N.split(L).join("")),N=N.replace(/[^0-9eE+\-.,]/g,""),G===","?N=N.split(".").join("").replace(",","."):N=N.split(",").join(""),N===""||N==="-"||N==="+")return null;const q=Number(N);return Number.isNaN(q)?null:M*(j?q/100:q)}function p(E,D){const N=I(E)||Number.isNaN(E)?null:Number(E),M=I(D)||Number.isNaN(D)?null:Number(D);return N===null?M===null?0:1:M===null||N<M?-1:N>M?1:0}function b(E,D){const N=l(E),M=l(D);return N===null?M===null?0:1:M===null?-1:N===M?0:N?1:-1}function O(E,D){const N=z(E),M=z(D);if(!N)return M?1:0;if(!M)return-1;const j=N.getTime(),L=M.getTime();return j<L?-1:j>L?1:0}const k=new Map;function y(E){const D=z(E.value);if(!D)return"";const N=E.locale||"";let M=k.get(N);return M||(M=new Intl.DateTimeFormat(E.locale||void 0,{dateStyle:"medium"}),k.set(N,M)),M.format(D)}const v={boolean:{base:"boolean",storage:"bitset",matches:E=>typeof E=="boolean",parse:E=>l(E.text),compare:b,format:E=>l(E.value)===null?"":l(E.value)?"Yes":"No",defaults:{filter:"set",editor:"checkbox",align:"center"},excel:"General",toClipboard:E=>l(E)===null?"":String(l(E)),fromClipboard:E=>l(E)},number:{base:"number",storage:"float64",matches:E=>typeof E=="number"&&!Number.isNaN(E),parse:E=>{if(r(E.text)){const D=t(E.text,E);if(!D.ok)return null;const N=Number(D.value);return Number.isFinite(N)?N:null}return a(E.text,E.locale)},compare:p,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:E=>I(E)?"":String(E),fromClipboard:(E,D)=>a(E,D&&D.locale)},date:{base:"dateString",storage:"dictionary",matches:E=>typeof E=="string"&&u.test(E)&&!Number.isNaN(Date.parse(E))||E instanceof Date&&!Number.isNaN(E.getTime())&&i(E),parse:E=>w(E.text),compare:A,format:y,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:E=>w(E),toClipboard:E=>I(E)?"":String(E),fromClipboard:E=>w(E)},dateString:{base:"dateString",storage:"dictionary",matches:E=>typeof E=="string"&&u.test(E)&&!Number.isNaN(Date.parse(E)),parse:E=>w(E.text),compare:A,format:y,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:E=>w(E),toClipboard:E=>I(E)?"":String(E),fromClipboard:E=>w(E)},text:{base:"text",storage:"dictionary",matches:E=>typeof E=="string",parse:E=>E.text===""?null:String(E.text),compare:(E,D)=>I(E)?I(D)?0:1:I(D)?-1:$().compare(String(E),String(D)),defaults:{filter:"text",editor:"text",align:"start"},excel:"@",toClipboard:E=>I(E)?"":String(E),fromClipboard:E=>E},image:{base:"text",storage:"dictionary",parse:E=>E.text===""||E.text==null?null:String(E.text).trim(),compare:(E,D)=>I(E)?I(D)?0:1:I(D)?-1:$().compare(String(E),String(D)),defaults:{filter:"text",editor:"text",align:"center",render:"image"},excel:"@",toClipboard:E=>I(E)?"":String(E),fromClipboard:E=>E},lookup:{base:"text",storage:"dictionary",parse:E=>{if(E.text===""||E.text==null)return null;const D=E.column&&E.column.lookup,N=D&&X(D.options)?D.options():null;if(!N)return E.text;const M=String(E.text),j=N.find(q=>String(q.id)===M);if(j)return j.id;const L=M.trim().toLowerCase(),G=N.find(q=>String(q.label).toLowerCase()===L);return G?G.id:E.text},compare:B,defaults:{filter:"set",editor:"select",align:"start"},excel:"@",multiStorage:"multi",toClipboard:E=>I(E)?"":String(E),fromClipboard:E=>E},object:{base:"object",storage:"object",matches:E=>E!==null&&typeof E=="object"&&!(E instanceof Date),parse:E=>{try{return E.text===""?null:JSON.parse(E.text)}catch{return E.text}},compare:(E,D)=>B(E,D),format:E=>{const D=E.value;if(I(D))return"";if(typeof D=="string")return D;try{return JSON.stringify(D)}catch{return String(D)}},defaults:{filter:"none",editor:"none",align:"start"},excel:"@",toClipboard:E=>I(E)?"":typeof E=="string"?E:JSON.stringify(E),fromClipboard:E=>E}},R=["boolean","number","date","dateString","datetime","text","object"];function S(E,D,N,M){const j=N.get(E);if(j)return j;M.includes(E)&&W(`circular data type extends chain: ${[...M,E].join(" → ")}`);const L=D[E];L||W(`unknown data type "${E}"`);let G=null;L.extends&&(G=S(L.extends,D,N,[...M,E]));const q={...G||{},...L,name:E,defaults:{...G&&G.defaults||{},...L.defaults||{}}};return q.base||(q.base=G&&G.base||"text"),q.storage||(q.storage=G&&G.storage||"object"),N.set(E,q),q}function x(E,D){const N={...v,...o};if(D&&typeof D.dataType=="function"&&typeof D.names=="function")for(const j of D.names("dataType")){const L=D.dataType(j);L&&(N[j]=L)}if(_(E))for(const[j,L]of Object.entries(E))N[j]=L;const M=new Map;for(const j of R)S(j,N,M,[]);S("lookup",N,M,[]);for(const j of Object.keys(N))S(j,N,M,[]);for(const j of M.values())h(j.operators);return M}function C(E,D){if(E.base==="text"&&(!E.compare||E.compare===v.text.compare)){const N=$(D);return(M,j)=>I(M)?I(j)?0:1:I(j)?-1:N.compare(String(M),String(j))}return E.compare||B}function P(E,D){return D?E.multiStorage||"multi":E.storage||"object"}function F(E){return H(String(E).replace(/([a-z])([A-Z])/g,"$1 $2"))}}),Fe("packages/core/src/columns/infer.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_SAMPLE",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"inferFromValues",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"inferColumnType",{enumerable:!0,get:function(){return X}});const Q=K("packages/core/src/internal/util.js"),$=Q.infoOnce,B=Q.isNil,I=100;function _(W,H,V={}){const z=V.sampleSize??I,w=[];for(let A=0;A<W.length&&w.length<z;A++){const g=W[A];B(g)||typeof g=="number"&&Number.isNaN(g)||w.push(g)}if(w.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[A,g]of H){if(typeof g.matches!="function")continue;let l=!0;for(let d=0;d<w.length;d++)if(!g.matches(w[d])){l=!1;break}if(l)return{type:A,unanimous:!0,sampled:w.length}}return V.quiet||$(`infer:${V.colId||"?"}`,`column "${V.colId||"?"}" has mixed or ambiguous values and was inferred as "text". Declare \`type\` on the column to get correct sorting, filtering and export.`),{type:"text",unanimous:!1,sampled:w.length}}function X(W,H,V,z,w={}){const A=w.sampleSize??I,g=[];for(let l=0;l<H.length&&g.length<A;l++){const d=V(H[l]);B(d)||typeof d=="number"&&Number.isNaN(d)||g.push(d)}return _(g,z,{...w,colId:W}).type}}),Fe("packages/core/src/columns/graph.js",function(e,K){"use strict";Object.defineProperty(e,"WHOLE_ROW",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"declarationOf",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"affectedBy",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return z}});const Q=K("packages/core/src/internal/util.js"),$=Q.DEV,B=Q.fail,I=Q.isFunction,_=Q.warnOnce,X="*";function W(w){const A=w.value||{};if(!I(A.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const l=A.pure!==!1;return A.deps===X?{computed:!0,wholeRow:!0,deps:[],pure:l}:Array.isArray(A.deps)?{computed:!0,wholeRow:!1,deps:A.deps.slice(),pure:l}:(_(`deps:missing:${w.id}`,`computed column "${w.id}" declares no \`value.deps\`; treating it as \`deps: '*'\` (a whole-row dependency). Declare the dependencies to get precise invalidation.`),{computed:!0,wholeRow:!0,deps:[],pure:l})}function H(w){const A=new Map;for(const m of w)A.set(m.id,m);const g=new Map,l=new Map,d=new Set,o=new Set,n=new Set,t=new Set;for(const m of w){const c=W(m);if(!c.computed){g.set(m.id,[]);continue}o.add(m.id),(c.pure?n:t).add(m.id),c.wholeRow&&d.add(m.id);const f=[],a=[];for(const p of c.deps)(A.has(p)?f:a).push(p);g.set(m.id,f),a.length&&l.set(m.id,a)}for(const m of n)for(const c of g.get(m))t.has(c)&&B(`pure computed column "${m}" depends on impure column "${c}". Mark it \`value.pure: false\` or make the dependency pure.`);const r=[],s=new Map,h=[],u=m=>{const c=s.get(m);if(c!=="done"){if(c==="open"){const f=h.indexOf(m);B(`circular column dependency: ${[...h.slice(f),m].join(" → ")}`)}s.set(m,"open"),h.push(m);for(const f of g.get(m)||[])A.has(f)&&u(f);h.pop(),s.set(m,"done"),r.push(m)}};for(const m of w)u(m.id);const i=new Map;for(const m of w)i.set(m.id,[]);for(const m of w)for(const c of g.get(m.id)||[]){const f=i.get(c);f&&!f.includes(m.id)&&f.push(m.id)}if(d.size)for(const m of w){if(o.has(m.id))continue;const c=i.get(m.id);for(const f of d)c.includes(f)||c.push(f)}return{order:r,dependents:i,pure:n,impure:t,computed:o,deps:g,wholeRow:d,external:l,index:A}}function V(w,A){const g=Array.isArray(A)?A:[A],l=new Set,d=[...g];for(;d.length;){const o=d.shift();for(const n of w.dependents.get(o)||[])l.has(n)||(l.add(n),d.push(n))}for(const o of g)l.delete(o);return w.order.filter(o=>l.has(o))}function z(w,A,g){if(!$)return w;const l=A instanceof Set?A:new Set(A);return new Proxy(w,{get(d,o){return typeof o=="string"&&!l.has(o)&&!Object.hasOwn(d,o)&&_(`undeclared:${g}:${o}`,`computed column "${g}" read undeclared dependency "${o}". Add it to \`value.deps\` or the value will go stale.`),d[o]}})}}),Fe("packages/core/src/model/rowkey.js",function(e,K){"use strict";Object.defineProperty(e,"KEY_DEPENDENT_FEATURES",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"compositeKey",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"warnMissingKeys",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"groupPathKey",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"splitPathKey",{enumerable:!0,get:function(){return d}});const Q=K("packages/core/src/internal/util.js"),$=Q.warnOnce,B=Q.pathGetter,I=Q.isFunction,_=Q.isBlank,X=["changes (rows.apply / rows.queue)","streaming dedupe","selection persistence","remote reload","cell comments"],W="";function H(o){if(o===null)return"\0n";if(o===void 0)return"\0u";const n=typeof o;if(n==="string")return o;if(n==="number"||n==="bigint"||n==="boolean")return String(o);if(o instanceof Date)return`\0d${o.getTime()}`;try{return`\0o${JSON.stringify(o)}`}catch{return"\0o?"}}function V(o){if(o.length===1)return H(o[0]);let n="";for(let t=0;t<o.length;t++)t&&(n+=W),n+=H(o[t]);return n}function z(o,n={}){const t=n.warn!==!1;if(I(o)){const r=o;return{stable:!0,fields:[],disabled:[],key(s,h){try{const u=r(s);return Array.isArray(u)?V(u):H(u)}catch(u){return $("rowKey.throw","rowKey function threw; falling back to index identity for the affected rows.",u),`#${h??-1}`}},keyEmpty(s){try{const h=r(s);return Array.isArray(h)?h.length===0||h.some(_):_(h)}catch{return!1}},missingFields(){return[]}}}if(Array.isArray(o)&&o.length>0){const r=o.filter(u=>typeof u=="string"),s=r.map(u=>B(u)),h=s.length;return{stable:!0,fields:r,disabled:[],key(u){const i=new Array(h);for(let m=0;m<h;m++)i[m]=s[m](u);return V(i)},keyEmpty(u){for(let i=0;i<h;i++)if(_(s[i](u)))return!0;return!1},missingFields(u){const i=[];for(let m=0;m<h;m++)_(s[m](u))&&i.push(r[m]);return i}}}if(typeof o=="string"&&o.length>0){const r=B(o);return{stable:!0,fields:[o],disabled:[],key(s){return H(r(s))},keyEmpty(s){return _(r(s))},missingFields(s){return _(r(s))?[o]:[]}}}return t&&$("rowKey.missing",`no rowKey configured, so rows are identified by object identity. This disables: ${X.join(", ")}. Set rowKey to a field name, an array of field names, or a function.`),{stable:!1,fields:[],disabled:X.slice(),key(r,s){if(r===null||typeof r!="object")return`#${s??0}:${String(r)}`;let h=w.get(r);return h===void 0&&(h=`#${A++}`,w.set(r,h)),h}}}const w=new WeakMap;let A=0;function g(o,n){if(!o||o.stable===!1||!I(o.keyEmpty)||!Array.isArray(n)||n.length===0)return;let t=0,r=null,s;for(let m=0;m<n.length;m++){const c=n[m];o.keyEmpty(c)&&(t++,r===null&&(r=I(o.missingFields)?o.missingFields(c):[],s=c))}if(t===0)return;const h=o.fields.length?o.fields.join(","):"(function)",u=r&&r.length?r.join(", "):o.fields.length?o.fields.join(", "):"the rowKey function",i=s!==null&&typeof s=="object"?Object.keys(s).join(", ")||"(no fields)":String(s);$(`rowKey.emptyValue:${h}`,`rowKey ${u} is missing on ${t} of ${n.length} rows; the first such row has: ${i}. Rows without a key value collapse onto one key, so selection, edits and rows.apply updates land on whichever row now shares it. Set rowKey to a field present on every row, or fix the source data.`)}function l(o){return V(o)}function d(o){return o.split(W)}}),Fe("packages/core/src/columns/lookup.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_SEPARATOR",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"normaliseOption",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"flattenOptions",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return o}});const Q=K("packages/core/src/internal/util.js"),$=Q.collator,B=Q.defaultCompare,I=Q.isFunction,_=Q.isNil,X=Q.warnOnce,H=K("packages/core/src/model/rowkey.js").compositeKey,V=", ",z="";function w(n,t,r,s){if(n===null||typeof n!="object")return{id:n,label:n==null?"":String(n)};const h=n[t],u=n[r],i={id:h,label:u==null?String(h??""):String(u)};n.disabled&&(i.disabled=!0),n.variant&&(i.variant=n.variant),n.icon&&(i.icon=n.icon);const m=s?n[s]:n.group;return m!==void 0&&(i.group=m),i}function A(n,t,r=0,s=[],h=[]){for(const u of n||[]){const i=u&&typeof u=="object"?u[t]:null;if(h.push({raw:u,depth:r,path:s}),Array.isArray(i)&&i.length){const m=String(u&&typeof u=="object"?u.label??u.name??u.id??"":u);A(i,t,r+1,[...s,m],h)}}return h}function g(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&I(n.router&&n.router.subscribe)}class l{#e;#t;#n;#r;#o=[];#i=new Map;#s=new Map;#l=0;#a="idle";#u=null;#c;#d=null;#h=new Map;constructor(t,r={}){this.#e=t||{},this.#t=r.colId||"?",this.#n=r.locale,this.#r=r.onChange||null,this.#c=$(this.#n),Array.isArray(this.#e.options)?this.#f(this.#e.options):this.#e.options===void 0&&(this.#a="ready")}get colId(){return this.#t}get version(){return this.#l}get state(){return this.#a}get ready(){return this.#a==="ready"}get multiple(){return this.#e.multiple===!0}get separator(){return this.#e.separator??V}get allowCustom(){return this.#e.allowCustom===!0}get sortBy(){return this.#e.sortBy||"label"}get spec(){return this.#e}options(){return this.#o}setLocale(t){this.#n=t,this.#c=$(t)}#f(t){const r=this.#e,s=r.valueKey||"id",h=r.labelKey||"label",u=r.childrenKey||"children";this.#o=A(t,u).map(i=>{const m=w(i.raw,s,h,r.groupKey);return i.depth&&(m.depth=i.depth,m.path=i.path),m}),this.#i=new Map,this.#s=new Map,this.#o.forEach((i,m)=>{this.#i.set(i.id,i),this.#s.set(i.id,m)}),this.#a="ready",this.#l+=1}load(){if(this.#u)return this.#u;const t=this.#e.options;if(Array.isArray(t)||t===void 0)return this.#u=Promise.resolve(this.#o),this.#u;if(g(t))return this.#u=this.#p(t),this.#u;if(!I(t))return X(`lookup:options:${this.#t}`,`column "${this.#t}" has an invalid \`lookup.options\`; expected an array, a function, or a router route`),this.#a="ready",this.#u=Promise.resolve([]),this.#u;this.#a="loading";let r;try{r=t()}catch(s){return this.#a="error",X(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,s),this.#u=Promise.resolve([]),this.#u}return!r||!I(r.then)?(this.#f(r),this.#u=Promise.resolve(this.#o),this.#r&&this.#r(this),this.#u):(this.#u=r.then(s=>(this.#f(s),this.#r&&this.#r(this),this.#o),s=>(this.#a="error",X(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,s),[])),this.#u)}refresh(){return this.#u=null,Array.isArray(this.#e.options)?(this.#f(this.#e.options),this.#r&&this.#r(this),Promise.resolve(this.#o)):this.load()}#p(t){if(this.#d)return Promise.resolve(this.#o);const r=this.#e,s=r.valueKey||"id",h=r.labelKey||"label",u=r.groupKey,i=I(t.map)?t.map:null,m=f=>w(i?i(f):f,s,h,u).id,c=f=>this.#m(f,i,s,h,u);return t.router.subscribe(t.predicate,c,{rowKey:m}),this.#d=()=>{I(t.router.detach)&&t.router.detach(c)},this.#a="ready",Promise.resolve(this.#o)}#m(t,r,s,h,u){const i=t&&t.add||[],m=t&&t.update||[],c=t&&t.remove||[];if(!(!i.length&&!m.length&&!c.length)){for(const f of i)this.#g(f,r,s,h,u);for(const f of m)this.#g(f,r,s,h,u);for(const f of c){if(!this.#h.has(f))continue;const a=this.#h.get(f);this.#h.delete(f),this.#i.delete(a);const p=this.#o.findIndex(b=>b.id===a);p>=0&&this.#o.splice(p,1)}this.#s=new Map(this.#o.map((f,a)=>[f.id,a])),this.#a="ready",this.#l+=1,this.#r&&this.#r(this)}}#g(t,r,s,h,u){const i=w(r?r(t):t,s,h,u);this.#h.set(H([i.id]),i.id);const m=this.#o.findIndex(c=>c.id===i.id);m>=0?this.#o[m]=i:this.#o.push(i),this.#i.set(i.id,i)}destroy(){this.#d&&(this.#d(),this.#d=null)}search(t,r){const s=this.#e;if(!I(s.search)){const i=String(t||"").toLowerCase();return Promise.resolve(i===""?this.#o:this.#o.filter(m=>m.label.toLowerCase().includes(i)))}const h=s.valueKey||"id",u=s.labelKey||"label";return Promise.resolve(s.search(t,r)).then(i=>(i||[]).map(m=>w(m,h,u,s.groupKey)))}option(t){return this.#i.get(t)}has(t){return this.#i.has(t)}label(t){if(_(t)||t==="")return"";const r=this.#i.get(t);if(r)return r.label;if(this.#a==="loading"||this.#a==="idle")return"";this.allowCustom||X(`lookup:unknown:${this.#t}`,`column "${this.#t}" holds value ${JSON.stringify(t)} which is not in its lookup options. Showing the raw value; set \`lookup.unknownLabel\` or \`lookup.allowCustom\` to change that.`);const s=this.#e.unknownLabel;return I(s)?String(s(t)??""):typeof s=="string"?s:String(t)}text(t){if(this.multiple){const r=d(t);return r.length===0?"":r.map(s=>this.label(s)).join(this.separator)}return this.label(t)}dictionary(){return this.#o.map(t=>t.id)}sorted(){const t=this.sortBy;if(t==="optionOrder"||t==="count")return this.#o.slice();if(t==="value")return this.#o.slice().sort((s,h)=>B(s.id,h.id));const r=this.#c;return this.#o.slice().sort((s,h)=>r.compare(s.label,h.label))}comparator(){const t=this.sortBy,r=this.multiple,s=this.#c,h=this.#s;if(r&&t==="count")return(i,m)=>d(i).length-d(m).length;const u=r?i=>d(i)[0]:i=>i;return t==="value"?(i,m)=>B(u(i),u(m)):t==="optionOrder"?(i,m)=>{const c=h.has(u(i))?h.get(u(i)):Number.MAX_SAFE_INTEGER,f=h.has(u(m))?h.get(u(m)):Number.MAX_SAFE_INTEGER;return c-f}:(i,m)=>{const c=u(i),f=u(m);return _(c)?_(f)?0:1:_(f)?-1:s.compare(this.label(c),this.label(f))}}groupKey(t){return this.multiple?d(t).map(s=>String(s)).sort().join(z):_(t)?"":String(t)}countValues(t){return this.multiple?d(t).length:_(t)?0:1}contains(t,r,s){const h=this.multiple?d(t):_(t)?[]:[t],u=Array.isArray(r)?r:[r];switch(s){case"containsAll":return u.every(i=>h.includes(i));case"containsNone":return!u.some(i=>h.includes(i));default:return u.some(i=>h.includes(i))}}exportText(t,r="label"){return r==="value"?this.multiple?d(t).join(this.separator):_(t)?"":String(t):this.text(t)}exportColumns(){const t=this.multiple;return this.#o.map(r=>({id:r.id,label:r.label,has:s=>t?d(s).includes(r.id):s===r.id}))}}function d(n){return Array.isArray(n)?n:_(n)||n===""?[]:[n]}function o(n,t={}){const r=n.lookup;if(!r)return null;const s=new l(r,{colId:n.id,locale:t.locale,onChange:t.onChange});return!Array.isArray(r.options)&&r.options!==void 0&&s.load(),s}}),Fe("packages/core/src/columns/value.js",function(e,K){"use strict";Object.defineProperty(e,"compileDisplay",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"warnImpureUse",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return g}});const Q=K("packages/core/src/internal/util.js"),$=Q.getPath,B=Q.isFunction,I=Q.isNil,_=Q.Lru,X=Q.warnOnce,H=K("packages/core/src/columns/graph.js").depsProxy,V="\0";function z(n,t={}){const r=t.locale,s=t.grid??null,h=t.context,u=n.value&&n.value.format,i=n.formatter||null,m=n.dataType&&n.dataType.format,c=n.lookup||null,f=(a,p,b)=>({value:a,data:b,row:p,column:n,colId:n.id,grid:s,context:h,locale:r});if(B(u))return(a,p,b)=>{const O=u(f(a,p,b));return O==null?"":String(O)};if(i){if(c){const a=i.kind==="text";return(p,b,O)=>i(a?c.text(p):p,f(p,b,O))}return(a,p,b)=>i(a,f(a,p,b))}return B(m)?(a,p,b)=>{const O=m(f(a,p,b));return O==null?"":String(O)}:c?a=>c.text(a):a=>I(a)?"":typeof a=="string"?a:String(a)}function w(n,t){!n||!n.value||n.value.pure!==!1||X(`impure:${t}:${n.id}`,`column "${n.id}" is an impure computed column (\`value.pure: false\`) and is being used to ${t}. The result is not stable across passes.`)}class A{#e;#t;#n;#r;#o;#i;#s=new _(4096);constructor(t){this.#e=t.columns instanceof Map?t.columns:new Map((t.columns||[]).map(r=>[r.id,r])),this.#t=t.graph,this.#n=t.grid??null,this.#r=t.context,this.#i=t.stored||null,this.#o=t.rowKey||g}get graph(){return this.#t}setGraph(t){this.#t=t,this.#s.clear()}beginPass(){this.#s.clear()}endPass(){this.#s.clear()}invalidate(t){if(this.#s.size===0)return;const r=t&&t.rows?new Set([...t.rows].map(String)):null,s=t&&t.columns?[...t.columns]:null;if(!r&&!s){this.#s.clear();return}const h=s?this.#l(s):null;for(const u of[...this.#s.keys()]){const i=String(u).split(V);i.length===3&&(r&&!r.has(i[0])||h&&!h.has(i[2])||this.#s.delete(u))}}#l(t){const r=new Set,s=this.#t,h=[...t];for(;h.length;){const u=h.pop();if(!r.has(u)){r.add(u);for(const i of s?s.dependents.get(u)||[]:[])h.push(i)}}return r}value(t,r,s){const h=typeof t=="string"?this.#e.get(t):t;if(!h)return;if(!h.computed)return this.#u(h,r,s);if(h.value.pure!==!1&&this.#i&&s&&s.physical!=null&&this.#i.has(h.id))return this.#i.get(h.id,s.physical);if(h.volatile)return this.compute(h,r,s);if(h.value.pure===!1)return this.compute(h,r,s);const u=`${this.#a(r,s)}${V}${h.id}`;if(this.#s.has(u))return this.#s.get(u);const i=this.compute(h,r,s);return this.#s.set(u,i),i}#a(t,r){return`${this.#o(t,r)}${V}${l(t)}`}#u(t,r,s){if(this.#i&&s&&s.physical!=null&&this.#i.has(t.id))return this.#i.get(t.id,s.physical);if(t.field)return t.read?t.read(r):$(r,t.field)}compute(t,r,s){const h=this.#t,u=h&&h.wholeRow.has(t.id);let i;if(u)i=r??{};else{i={};const c=h&&h.deps.get(t.id)||[];for(const a of c)i[a]=this.value(a,r,s);const f=h&&h.external.get(t.id)||[];for(const a of f)i[a]=$(r,a);i=H(i,[...c,...f],t.id)}const m={data:r,row:s,column:t,grid:this.#n,context:this.#r};return t.value.compute(i,m)}values(t,r){const s={},h=this.#t?this.#t.order:[...this.#e.keys()];for(const u of h)s[u]=this.value(u,t,r);return s}text(t,r,s){const h=typeof t=="string"?this.#e.get(t):t;return h?h.formatValue(this.value(h,r,s),s,r):""}key(t,r,s){const h=typeof t=="string"?this.#e.get(t):t;if(!h)return"";const u=this.value(h,r,s);return B(h.value.key)?String(h.value.key(this.#c(h,u,r,s))):h.lookup?h.lookup.groupKey(u):I(u)?"":String(u)}quickFilterText(t,r,s){const h=typeof t=="string"?this.#e.get(t):t;if(!h)return"";if(B(h.value.quickFilterText)){const u=this.value(h,r,s);return String(h.value.quickFilterText(this.#c(h,u,r,s))??"")}return this.text(h,r,s)}#c(t,r,s,h){return{value:r,data:s,row:h,column:t,colId:t.id,grid:this.#n,context:this.#r}}parse(t,r,s,h){const u=typeof t=="string"?this.#e.get(t):t;if(!u)return r;const i={text:r,value:this.value(u,s,h),data:s,row:h,column:u,grid:this.#n,context:this.#r,locale:this.#n&&B(this.#n.get)?this.#n.get("locale"):void 0,formulaFunctions:this.#n&&B(this.#n.get)?this.#n.get("formulaFunctions"):void 0};return B(u.value.parse)?u.value.parse(i):u.dataType&&B(u.dataType.parse)?u.dataType.parse(i):r}validate(t,r,s,h,u){const i=typeof t=="string"?this.#e.get(t):t;if(!i||!B(i.edit.validate))return!0;const m=i.edit.validate({value:r,oldValue:s,data:h,row:u,column:i,grid:this.#n,context:this.#r});return m===!0||m===void 0?!0:String(m)}apply(t,r,s,h){const u=typeof t=="string"?this.#e.get(t):t;if(!u)return!1;const i=this.value(u,s,h);if(B(u.value.apply)){const m=u.value.apply({value:r,oldValue:i,data:s,row:h,column:u,grid:this.#n,context:this.#r});return this.#d(u,s,h),m!==!1}return u.field?i===r?!1:(u.write(s,r),this.#d(u,s,h),!0):(X(`apply:${u.id}`,`column "${u.id}" has no \`field\` and no \`value.apply\`, so an edit cannot be written back.`),!1)}commit(t,r,s,h){const u=typeof t=="string"?this.#e.get(t):t;if(!u)return{ok:!1,value:void 0,oldValue:void 0,changed:!1,error:"unknown column"};const i=this.value(u,s,h),m=this.parse(u,r,s,h),c=this.validate(u,m,i,s,h);if(c!==!0)return{ok:!1,value:m,oldValue:i,changed:!1,error:c};const f=this.apply(u,m,s,h);return{ok:!0,value:m,oldValue:i,changed:f}}#d(t,r,s){if(this.#s.size===0)return;const h=this.#a(r,s);this.#s.delete(`${h}${V}${t.id}`);for(const u of this.#t?this.#t.dependents.get(t.id)||[]:[])this.#s.delete(`${h}${V}${u}`)}}function g(n,t){return t&&t.key!=null?String(t.key):l(n)}function l(n){if(n&&typeof n=="object"){let t=d.get(n);return t===void 0&&(t=`#${o++}`,d.set(n,t)),t}return String(n)}const d=new WeakMap;let o=0}),Fe("packages/core/src/model/shadow.js",function(e,K){"use strict";Object.defineProperty(e,"MAX_TRACKED",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"DEFAULT_DEPTH",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"HISTORY_TICK_MAX_MS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"HISTORY_TICK_MIN_MS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"historyTickFor",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"SHADOW_KINDS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"ROLLING_KINDS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"FIT_SHADOW_KINDS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"DEFAULT_ANOMALY_THRESHOLD",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"SPEC_STATUS",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"POSITIONAL_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"SHADOW_LABELS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"specStatusOf",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ShadowTracker",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shadowsIn",{enumerable:!0,get:function(){return i}});const $=K("packages/core/src/internal/util.js").warnOnce,B=2e5,I=20,_=1e3,X=50;function W(m){return Math.min(_,Math.max(X,Math.floor(m)))}const H=Object.freeze(["updates","updatedAt","sinceUpdate","delta","deltaPercent","rate","history","firstValue","streak","rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag","specStatus","rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta","fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),V=Object.freeze(["rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta"]),z=Object.freeze(["fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),w=.6745,A=3.5,g=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),l=Object.freeze(["rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag"]),d=Object.freeze({updates:"Updates",updatedAt:"Updated at",sinceUpdate:"Since update",delta:"Change",deltaPercent:"Change %",rate:"Rate of change",history:"History",firstValue:"Baseline",streak:"Streak",rank:"Rank",rankAsc:"Rank, ascending",rankChange:"Rank change",percentile:"Percentile",quartile:"Quartile",zScore:"Z-score",shareOfTotal:"Share of total",anomalyScore:"Anomaly score",anomalyFlag:"Anomaly",specStatus:"Spec status",rollingSum:"Rolling sum",rollingAvg:"Rolling average",rollingMin:"Rolling minimum",rollingMax:"Rolling maximum",windowCoverage:"Window coverage",cumulativeToDate:"Cumulative to date",periodOverPeriod:"Period over period",rollingQuantile:"Rolling quantile",windowApproximate:"Window approximate",tsTrend:"Trend",tsSeasonal:"Seasonal",tsResidual:"Seasonal residual",tsCoverage:"Decomposition coverage",tsSmoothed:"Smoothed",tsSmoothingAlpha:"Smoothing α",tsSmoothingBeta:"Smoothing β",fitPredicted:"Predicted",fitResidual:"Residual",fitInfluence:"Influence",fitStdResidual:"Std. residual",fitLeverage:"Leverage",fitCooksD:"Cook's D"});function o(m,c){if(!c)return null;const f=Number.isFinite(Number(c.lower))?Number(c.lower):null,a=Number.isFinite(Number(c.upper))?Number(c.upper):null;if(f===null&&a===null||!Number.isFinite(m))return null;if(f!==null&&m<f||a!==null&&m>a)return g.FAIL;const p=Number.isFinite(Number(c.warnLower))?Number(c.warnLower):null,b=Number.isFinite(Number(c.warnUpper))?Number(c.warnUpper):null;return p!==null&&m<p||b!==null&&m>b?g.WARN:g.PASS}function n(m,c,f){if(!c||typeof c!="object")return null;if(c.kind!=="time")return c.kind!==void 0&&$(`shadow.history.window.kind:${m}`,`a 'history' shadow's 'window' only accepts {kind: 'time', span}; '${c.kind}' is not honoured (a plain count is already what 'depth' means, and a session has no span to divide into buckets), so it reported the original, unwindowed history.`),null;const a=c.minutes!=null?Number(c.minutes)*6e4:Number(c.span);if(!(a>0))return $(`shadow.history.window.span:${m}`,"a 'history' shadow's time window needs a positive 'span' (ms) or 'minutes'; it had none, so it reported the original, unwindowed history."),null;const p=Math.max(2,Math.floor(f)||I);return{span:a,bucketMs:Math.max(1,Math.floor(a/p))}}class t{#e;#t=new Map;#n=new Map;#r=new Map;#o=new Map;#i=new Map;#s=new Map;#l=0;#a;#u;#c;#d;#h=new Map;#f=null;#p=null;#m=null;constructor(c){this.#e=c.colId,this.#a=Math.max(2,c.depth||I),this.#u=Math.max(1,c.max||B),this.#c=c.now||(()=>Date.now()),this.#d=n(this.#e,c.historyWindow,this.#a),this.#d&&(this.#f=Math.floor(this.#c()/this.#d.bucketMs))}get colId(){return this.#e}get forgotten(){return this.#l}get size(){return this.#n.size}get historyWindow(){return this.#d}observe(c,f){const a=u(f);if(a===null)return;if(!this.#n.has(c)){this.#p=null,this.#m=null,this.#g(),this.#t.set(c,a),this.#n.set(c,a),this.#r.set(c,0),this.#o.set(c,this.#c()),this.#i.set(c,[a]),this.#d&&this.#h.set(c,[a]),this.#s.set(c,0);return}const p=this.#n.get(c);if(p===a)return;this.#p=null,this.#m=null,this.#n.set(c,a),this.#r.set(c,(this.#r.get(c)||0)+1),this.#o.set(c,this.#c());const b=this.#i.get(c)||[];b.push(a),b.length>this.#a&&b.splice(0,b.length-this.#a),this.#i.set(c,b);const O=Math.sign(a-p),k=this.#s.get(c)||0;this.#s.set(c,Math.sign(k)===O?k+O:O)}#g(){if(this.#n.size<this.#u)return;const c=this.#n.keys().next().value;c!==void 0&&(this.#t.delete(c),this.#n.delete(c),this.#r.delete(c),this.#o.delete(c),this.#i.delete(c),this.#h.delete(c),this.#s.delete(c),this.#l++)}rebase(){for(const[c,f]of this.#n)this.#t.set(c,f);this.#p=null,this.#m=null}reset(){this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#o.clear(),this.#i.clear(),this.#h.clear(),this.#s.clear(),this.#l=0,this.#p=null,this.#m=null,this.#d&&(this.#f=Math.floor(this.#c()/this.#d.bucketMs))}retain(c){const f=c instanceof Set?c:new Set(c);let a=0;for(const p of[...this.#n.keys()])f.has(p)||(this.#t.delete(p),this.#n.delete(p),this.#r.delete(p),this.#o.delete(p),this.#i.delete(p),this.#h.delete(p),this.#s.delete(p),a++);return a&&(this.#p=null,this.#m=null),a}advanceHistoryWindow(c=this.#c()){const f=this.#d;if(!f)return 0;const a=Math.floor(c/f.bucketMs),p=a-this.#f;if(!(p>0))return 0;const b=Math.min(p,this.#a);for(const[O,k]of this.#h){const y=this.#n.get(O);for(let v=0;v<b;v++)k.push(y);k.length>this.#a&&k.splice(0,k.length-this.#a)}return this.#f=a,p}read(c,f,a,p){switch(c){case"updates":return this.#r.has(f)?this.#r.get(f):0;case"updatedAt":{const b=this.#o.get(f);return b===void 0?null:new Date(b)}case"sinceUpdate":{const b=this.#o.get(f);return b===void 0?null:this.#c()-b}case"firstValue":return this.#t.has(f)?this.#t.get(f):null;case"delta":return this.#n.has(f)?this.#n.get(f)-this.#t.get(f):null;case"deltaPercent":{if(!this.#n.has(f))return null;const b=this.#t.get(f);return b?(this.#n.get(f)-b)/Math.abs(b)*100:null}case"rate":{const b=this.#i.get(f),O=this.#o.get(f);if(!b||b.length<2||O===void 0)return null;const k=this.#c()-O,y=b[b.length-1]-b[b.length-2];return k>0?y/k*1e3:y}case"history":return this.#d?this.#h.has(f)?[...this.#h.get(f)]:null:this.#i.has(f)?[...this.#i.get(f)]:null;case"streak":return this.#s.has(f)?this.#s.get(f):0;case"specStatus":return this.#n.has(f)?o(this.#n.get(f),p):null;default:return l.includes(c)?this.#S(c,f,a,p):null}}#b(c){if(c){if(this.#m&&this.#m.only===c)return this.#m.view;const f=this.#w(c);return this.#m={only:c,view:f},f}return this.#p?this.#p:(this.#p=this.#w(null),this.#p)}#w(c){const f=[];for(const[x,C]of this.#n)c&&!c.has(x)||f.push(C);const a=f.sort((x,C)=>x-C);let p=0,b=0,O=0,k=0;for(const x of a){k+=x,p++;const C=x-b;b+=C/p,O+=C*(x-b)}const y=[];for(const[x,C]of this.#t)c&&!c.has(x)||y.push(C);const v=p?r(a):0,R=a.map(x=>Math.abs(x-v)).sort((x,C)=>x-C),S=p?r(R):0;return{sorted:a,baseline:y.sort((x,C)=>x-C),sum:k,mean:p?b:0,sd:p>1?Math.sqrt(O/(p-1)):0,median:v,mad:S}}#S(c,f,a,p){if(!this.#n.has(f)||a&&!a.has(f))return null;const b=this.#n.get(f),O=this.#b(a),k=O.sorted.length;if(!k)return null;switch(c){case"rank":return k-h(O.sorted,b)+1;case"rankAsc":return s(O.sorted,b)+1;case"rankChange":{if(!this.#t.has(f)||!O.baseline.length)return null;const y=O.baseline.length-h(O.baseline,this.#t.get(f))+1,v=k-h(O.sorted,b)+1;return y-v}case"percentile":return h(O.sorted,b)/k*100;case"quartile":{const y=h(O.sorted,b)/k;return Math.min(4,Math.max(1,Math.ceil(y*4)))}case"zScore":return O.sd?(b-O.mean)/O.sd:null;case"anomalyScore":return O.mad?w*(b-O.median)/O.mad:null;case"anomalyFlag":{if(!O.mad)return null;const y=p&&Number.isFinite(Number(p.threshold))?Number(p.threshold):A;return Math.abs(w*(b-O.median)/O.mad)>y}case"shareOfTotal":return O.sum?b/O.sum*100:null;default:return null}}}function r(m){const c=m.length;if(!c)return 0;const f=(c-1)*.5,a=Math.floor(f),p=Math.ceil(f);return a===p?m[a]:m[a]+(f-a)*(m[p]-m[a])}function s(m,c){let f=0,a=m.length;for(;f<a;){const p=f+a>>1;m[p]<c?f=p+1:a=p}return f}function h(m,c){let f=0,a=m.length;for(;f<a;){const p=f+a>>1;m[p]<=c?f=p+1:a=p}return f}function u(m){if(m==null||m==="")return null;if(m instanceof Date){const f=m.getTime();return Number.isFinite(f)?f:null}const c=typeof m=="number"?m:Number(m);return Number.isFinite(c)?c:null}function i(m){const c=[];for(const f of m||[]){const a=f.shadow;if(!a)continue;const p=typeof a=="string"?{kind:a}:a,b=p.kind;H.includes(b)&&(V.includes(b)||z.includes(b)||c.push({colId:f.id||f.field,of:p.of||f.field||f.id,kind:b,depth:p.depth,historyWindow:b==="history"?p.window:void 0}))}return c}}),Fe("packages/core/src/columns/model.js",function(e,K){"use strict";Object.defineProperty(e,"BUILTIN_DEFAULTS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"normaliseAlign",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"normaliseVAlign",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"expandColumn",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"flattenTree",{enumerable:!0,get:function(){return se}});const Q=K("packages/core/src/internal/util.js"),$=Q.expand,B=Q.fail,I=Q.getPath,_=Q.humanise,X=Q.isFunction,W=Q.isObject,H=Q.merge,V=Q.pathGetter,z=Q.pathSetter,w=Q.toArray,A=Q.uid,g=Q.warnOnce,d=K("packages/core/src/format/index.js").compileFormat,o=K("packages/core/src/columns/datatypes.js"),n=o.comparatorFor,t=o.createTypeRegistry,r=o.storageKind,s=K("packages/core/src/columns/infer.js"),h=s.inferColumnType,u=s.DEFAULT_SAMPLE,i=K("packages/core/src/columns/graph.js"),m=i.buildGraph,c=i.affectedBy,a=K("packages/core/src/columns/lookup.js").createLookup,p=K("packages/core/src/columns/value.js"),b=p.compileDisplay,O=p.ValuePipeline,k=p.warnImpureUse,v=K("packages/core/src/model/shadow.js").FIT_SHADOW_KINDS,R=Object.freeze({geometry:"geometry",list:"list"}),S={value:{pure:!0},cell:{},edit:{enabled:!1},sort:{enabled:!0,direction:null,order:0,nullsFirst:!1},filter:{enabled:!0,type:"text"},group:{enabled:!1,index:-1,explode:!1},pivot:{enabled:!1,index:-1},total:null,layout:{width:150,min:40,max:null,flex:0,pin:null,hidden:!1,resizable:!0,movable:!0,lockVisible:!1,lockPosition:!1},header:{},facet:{},export:{lookup:"label",csv:!0,excel:!0},allowGroup:!0,allowPivot:!0,allowTotal:!0,nullable:!0,quickFilter:!0},x={centre:"center"},C=new Set(["start","center","end","left","right"]);function P(ce){if(typeof ce!="string")return;const te=ce.toLowerCase();return x[te]?x[te]:C.has(te)?te:void 0}function F(ce){if(typeof ce!="string")return;const te=ce.toLowerCase();return te==="center"||te==="centre"?"middle":te==="top"||te==="middle"||te==="bottom"?te:void 0}const E=["cell","layout","header"];function D(ce){if(!W(ce))return{};const te={...ce},oe=(fe,de)=>{if(ce[fe]===void 0)return;const ve=$(ce[fe],de);ve&&E.includes(fe)&&!W(ce[fe])&&delete ve.enabled,te[fe]=ve};return oe("sort","direction"),oe("filter","type"),oe("cell","render"),oe("edit","editor"),oe("layout","width"),oe("group","index"),oe("pivot","index"),oe("header","render"),oe("facet","strategy"),te}function N(ce,te){const oe={...ce||{}},fe=W(te)&&W(te.layout)&&te.layout.width!==void 0;return oe.fit==="content"&&!fe&&delete oe.width,oe}const M=new Set(["allowGroup","allowPivot","allowTotal","cell","colSpan","contextMenu","diff","edit","export","facet","field","filter","filterRow","format","grandTotal","group","groupTotal","header","headerControls","id","layout","lookup","nullable","pivot","preset","quickFilter","rowSpan","running","shadow","showWhen","sort","spec","tags","title","total","type","typeOptions","validation","value","verticalAlign"]),j=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function L(ce,te,oe,fe){const de=oe==="columnGroup"?"column group":"column";for(const ve of Object.keys(ce))if(!te.has(ve)){if(ve==="timeZone"&&oe==="column"){g("column.timeZone",`\`timeZone\` is not a column option, so it had no effect on column "${fe}". A date column stores, displays, sorts and filters in the grid-level \`timeZone\` (else the viewer's); set \`timeZone\` on the grid, not the column.`);continue}g(`${oe}.unknown:${ve}`,`'${ve}' is not a configuration key this grid recognises, so it had no effect on ${de} "${fe}". Check the spelling against the reference.`)}}function G(ce){W(ce.cell)&&ce.cell.autoHeight!==void 0&&g("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 q(ce,te){const oe=te&&X(ce.defaultsFor)?ce.defaultsFor(te):null,fe={...ce.defaults||{},...W(oe)?oe:{}},de={};return fe.align&&(de.align=fe.align,de.cell={align:fe.align},de.header={align:fe.align}),fe.filter&&(de.filter=fe.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:fe.filter}),fe.editor&&(de.edit=fe.editor==="none"?{editor:null}:{editor:fe.editor}),fe.total&&(de.total=fe.total),fe.render&&(de.cell={...de.cell||{},render:fe.render}),ce.export&&(de.export={...ce.export}),de}function Y(ce){if(typeof ce=="string")return ce.trim()?[ce.trim()]:[];if(!Array.isArray(ce))return[];const te=[];for(const oe of ce){if(typeof oe!="string")continue;const fe=oe.trim();fe&&!te.includes(fe)&&te.push(fe)}return te}class J{#e=new Map;#t=[];#n=[];#r=new WeakMap;#o;#i;#s;#l;#a;#u;#c(te,oe,fe){const de=this.#d(te,oe,fe);if(typeof de!="string"||!this.#h)return de??null;const ve=oe&&oe.totals&&oe.totals.implement;if(ve&&X(ve[de])){const Oe=ve[de];return Oe.totalName=de,Oe}const Me=this.#h.totalFn?.(de);return X(Me)?Me:de}#d(te,oe,fe){if(typeof te!="string")return te;const de=oe&&oe.totals&&oe.totals.supported;if(!Array.isArray(de)||de.includes(te))return te;const ve=de.length?de.join(", "):"none";return B(`column "${fe}" is typed ${oe.name||"a type"}, for which the total "${te}" is not meaningful. Supported: ${ve}. Aggregating it anyway would produce a confident wrong number.`),te}#h;#f;#p;#m;#g;#b;#w=!1;#S;#y;constructor(te={}){this.#i=D(te.columnDefaults||{}),this.#s=te.columnPresets||{},this.#a=te.locale,this.#l=te.timeZone,this.#u=F(te.verticalAlign),this.#h=te.registry||null,this.#f=te.grid||null,this.#p=te.context,this.#S=te.sampleSize??u,this.#y=te.onChange||null,this.#b=X(te.rowKey)?te.rowKey:void 0,this.#o=t(te.dataTypes,this.#h);const{leaves:oe,groups:fe}=se(te.columns||[]);this.#n=fe;for(const de of oe){de.facet!==void 0&&this.#r.set(de.def,de.facet);const ve=this.#O(de.def,null);if(ve.groupPath=de.path,this.#e.has(ve.id)){g(`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}de.column=ve,this.#e.set(ve.id,ve),this.#t.push(ve.id)}this.#T(te.stored||null)}#O(te,oe){L(te,M,"column",te.id||te.field||"(unnamed)"),G(te);const fe=D(te),de=w(te.preset),ve=de.map(Ae=>{const Ge=this.#s[Ae];return Ge?D(Ge):(g(`preset:${Ae}`,`unknown column preset "${Ae}"; ignoring`),{})}),Me=this.#A(fe,ve,oe),Oe=this.#o.get(Me)||this.#o.get("text");if(!this.#o.has(Me)&&te.type){const Ae=R[Me];g(`type:${Me}`,`unknown data type "${Me}"; falling back to "text"`+(Ae?`. It is registered by importing '@toclocoinc/lattice-grid/modules/${Ae}'.`:""))}const Ce=X(Oe.items)?this.#j(fe,ve,te.id||te.field||"(unnamed)"):null;let pe=S;pe=H(pe,this.#i),te.type!==!1&&(pe=H(pe,q(Oe,Ce)));for(const Ae of ve)pe=H(pe,Ae);this.#r.has(te)&&(pe=H(pe,D({facet:this.#r.get(te)}))),pe=H(pe,fe);const we=pe.edit;we&&we.editor&&we.enabled!==!0&&!X(we.enabled)&&(te.edit||{}).editor&&g(`column.editor-not-enabled:${te.id||te.field}`,`column '${te.id||te.field}' names the editor '${we.editor}' but does not enable editing, so it stays read-only. Add \`enabled: true\`, or use \`edit: true\` and set \`editor\` alongside it.`);const me=te.id||te.field||A("col");if(te.shadow&&!X(pe.value&&pe.value.compute)){const Ae=typeof te.shadow=="string"?{kind:te.shadow}:te.shadow,Ge=Ae.of||te.field||me,Ze=v.includes(Ae.kind),nt=Ze?Ae.model||Ae:null,lt=Ze&&nt?[...Array.isArray(nt.predictors)?nt.predictors:[],nt.response].filter(Boolean):null;pe.value={...pe.value||{},deps:lt&<.length?lt:Ae.orderBy&&Ae.orderBy!==Ge?[Ge,Ae.orderBy]:[Ge],pure:!1,compute:(ft,gt)=>{const At=gt.grid&>.grid.statistics;if(!At)return null;const Pt=gt.row&>.row.key||At.keyOf(gt.data);if(!Pt)return null;if(Ze){if(!X(At.fitShadow))return null;const Ct=Ae.model?{...Ae.model,threshold:Ae.threshold}:Ae;return At.fitShadow(Ae.kind,Pt,Ct)}return At.shadow(Ge,Ae.kind,Pt,Ae.scope,Ae)}}}if(te.running&&!X(pe.value&&pe.value.compute)){const Ae=typeof te.running=="string"?{kind:te.running}:te.running,Ge=Ae.of||te.field||me;pe.value={...pe.value||{},deps:[Ge],pure:!1,compute:(Ze,nt)=>{const lt=nt.grid&&nt.grid.statistics;if(!lt||!X(lt.running))return null;const ft=nt.row&&nt.row.key||lt.keyOf(nt.data);return ft?lt.running(Ge,Ae.kind||"total",ft):null}},te.sort===void 0&&(pe.sort={...pe.sort||{},enabled:!1})}const Ne=te.field??(X(pe.value&&pe.value.compute)?null:te.id??null),$e=X(pe.value&&pe.value.compute),He={id:me,field:Ne,shadow:te.shadow||null,running:te.running||null,spec:te.spec||null,validation:te.validation||null,volatile:!!(te.shadow||te.running),title:pe.title??_(Ne||me),type:Oe.name,dataType:Oe,itemType:Ce,nullable:pe.nullable!==!1,align:P(fe.cell&&fe.cell.align||fe.align||pe.cell&&pe.cell.align||pe.align||Oe.defaults&&Oe.defaults.align)||"start",verticalAlign:F(fe.cell&&fe.cell.verticalAlign||fe.verticalAlign||pe.cell&&pe.cell.verticalAlign||pe.verticalAlign)||this.#u,rowSpan:X(pe.rowSpan)?pe.rowSpan:null,colSpan:X(pe.colSpan)?pe.colSpan:null,value:{pure:!0,...pe.value||{}},cell:{...pe.cell||{}},edit:{...pe.edit||{}},sort:{...pe.sort||{}},filter:{...pe.filter||{}},group:{enabled:!1,index:-1,explode:!1,...pe.group||{}},pivot:{enabled:!1,index:-1,...pe.pivot||{}},total:this.#c(pe.total,Oe,te.id||te.field||"(unnamed)"),groupTotal:pe.groupTotal===void 0?null:this.#c(pe.groupTotal,Oe,te.id||te.field||"(unnamed)"),grandTotal:pe.grandTotal===void 0?null:this.#c(pe.grandTotal,Oe,te.id||te.field||"(unnamed)"),tags:Y(pe.tags),typeOptions:pe.typeOptions??null,...W(pe[Me])?{[Me]:pe[Me]}:{},layout:N(pe.layout,fe),header:{...pe.header||{}},contextMenu:pe.contextMenu===void 0?null:pe.contextMenu,facet:{...pe.facet||{}},export:{...pe.export||{}},allowGroup:pe.allowGroup!==!1,allowPivot:pe.allowPivot!==!1,allowTotal:pe.allowTotal!==!1,quickFilter:pe.quickFilter!==!1,def:te,format:pe.format,presets:de,inferred:oe!=null&&!te.type,computed:$e,diff:te.diff===void 0?void 0:!!te.diff,read:Ne?V(Ne):null,write:Ne?z(Ne):null};He.cell.align=P(fe.cell&&fe.cell.align)||He.align,He.header.align=P(fe.header&&fe.header.align)||He.align;const qe=pe.lookup||null;return He.lookup=qe?a({id:me,lookup:qe},{locale:this.#a,onChange:()=>{this.#y&&this.#y("lookup",{colId:me})}}):null,He.group.explode&&He.lookup&&He.lookup.multiple&&g(`explode:${me}`,`column "${me}" has \`group.explode\`, so rows appear under each of their values and totals double-count. Group footers should be annotated accordingly.`),this.#k(He),He}#k(te){te.formatter=d(te.format,te.dataType,this.#a,this.#l,te.id),te.formatValue=b(te,{locale:this.#a,grid:this.#f,context:this.#p}),te.itemCompare=te.itemType?n(te.itemType,this.#a):null,te.compare=X(te.value.compare)?te.value.compare:te.lookup?te.lookup.comparator():X(te.dataType.compareFor)?te.dataType.compareFor(te):n(te.dataType,this.#a),te.excel=te.formatter&&te.formatter.ooxml||te.dataType&&te.dataType.excel||"General",te.storeKind=r(te.dataType,!!(te.lookup&&te.lookup.multiple))}#j(te,oe,fe){let de=W(te.typeOptions)?te.typeOptions:null;for(let Ce=oe.length-1;!de&&Ce>=0;Ce--)W(oe[Ce].typeOptions)&&(de=oe[Ce].typeOptions);!de&&W(this.#i.typeOptions)&&(de=this.#i.typeOptions);const ve=de&&de.of!==void 0?de.of:"text",Me=typeof ve=="string"?this.#o.get(ve):void 0;return Me&&!X(Me.items)&&Me.storage!=="object"?Me:(g(`type:of:${String(ve)}`,`column "${fe}" names "${String(ve)}" as its item type (typeOptions.of), which is not ${Me?"a scalar data type":"a known data type"}; its items are read as text.`),this.#o.get("text"))}#A(te,oe,fe){if(te.type===!1)return"text";if(te.type)return te.type;for(let de=oe.length-1;de>=0;de--)if(oe[de].type)return oe[de].type;if(this.#i.type)return this.#i.type;if(te.shadow){const de=typeof te.shadow=="string"?te.shadow:te.shadow.kind;if(de==="fitInfluence")return"boolean";if(de==="fitPredicted"||de==="fitResidual"||de==="fitStdResidual"||de==="fitLeverage"||de==="fitCooksD"||de==="tsTrend"||de==="tsSeasonal"||de==="tsResidual"||de==="tsCoverage"||de==="tsSmoothed"||de==="tsSmoothingAlpha"||de==="tsSmoothingBeta")return"number"}return fe||(te.lookup?"lookup":"text")}#T(te){const oe=this.all();this.#m=m(oe),this.#g?this.#g.setGraph(this.#m):this.#g=new O({columns:this.#e,graph:this.#m,grid:this.#f,context:this.#p,stored:te||null,rowKey:this.#b});const fe=this.#g;for(const de of oe)de.getValue=(ve,Me)=>fe.value(de,ve,Me)}all(){return this.#t.map(te=>this.#e.get(te))}visible(){return this.all().filter(te=>!te.layout.hidden)}get(te){return this.#e.get(te)}groups(){const te=oe=>{const fe=[];for(const de of oe)Array.isArray(de.columns)?fe.push({...de,columns:te(de.columns)}):de.column&&fe.push(de.column);return fe};return te(this.#n)}graph(){return this.#m}pipeline(){return this.#g}types(){return this.#o}affectedBy(te){return c(this.#m,te)}value(te,oe,fe){return this.#g.value(te,oe,fe)}text(te,oe,fe){return this.#g.text(te,oe,fe)}checkImpure(te,oe){k(this.#e.get(te),oe)}setLocale(te){this.#a=te;for(const oe of this.all())oe.lookup&&oe.lookup.setLocale(te),this.#k(oe);this.#y&&this.#y("locale",{locale:te})}infer(te){const oe={};if(this.#w||!Array.isArray(te)||te.length===0)return oe;this.#w=!0;let fe=!1;for(const de of this.all()){const ve=de.def;if(ve.type!==void 0||!de.field||de.computed||de.lookup||this.#M(de))continue;const Me=de.read||(pe=>I(pe,de.field)),Oe=h(de.id,te,Me,this.#o,{sampleSize:this.#S});if(Oe===de.type)continue;oe[de.id]=Oe;const Ce=this.#O(ve,Oe);Ce.groupPath=de.groupPath,Ce.layout={...Ce.layout,...ee(de.layout)},this.#e.set(de.id,Ce),he(this.#n,de.id,Ce),fe=!0}return fe&&this.#T(null),oe}redecorate(te,oe,fe={}){const de=this.#e.get(te);if(!de){g(`redecorate:${te}`,`columns.decorate('${te}', …): no column with id '${te}'.`);return}const ve=de.def||{},Me={...W(ve.cell)?ve.cell:{}};Me.decoration=oe??void 0,fe&&"variant"in fe&&(Me.variant=fe.variant);const Oe={...ve,cell:Me};this.#r.has(ve)&&this.#r.set(Oe,this.#r.get(ve));const Ce=this.#O(Oe,de.type);return Ce.groupPath=de.groupPath,Ce.layout={...Ce.layout,...ee(de.layout)},de.lookup&&de.lookup!==Ce.lookup&&X(de.lookup.destroy)&&de.lookup.destroy(),this.#e.set(te,Ce),he(this.#n,te,Ce),this.#T(null),this.#y&&this.#y("decorate",{colId:te}),Ce}destroy(){for(const te of this.#e.values())te.lookup&&X(te.lookup.destroy)&&te.lookup.destroy()}#M(te){for(const oe of te.presets){const fe=this.#s[oe];if(fe&&fe.type)return!0}return!!this.#i.type}#C(te){return!te.computed&&X(te.dataType&&te.dataType.toStorage)}storeReader(te){if(te.computed)return oe=>this.#g.value(te,oe,null);if(this.#C(te)){const oe=te.dataType.toStorage,fe={timeZone:this.#l,colId:te.id,itemType:te.itemType||null};return de=>oe(te.read(de),fe)}return te.read}storeValue(te,oe){if(!(!te||te.computed)&&X(te.read))return this.storeReader(te)(oe)}storeSchema(){const te=[];for(const oe of this.all()){if(oe.computed&&oe.value.pure===!1||!oe.computed&&!oe.field)continue;const fe=this.storeReader(oe);let de=null;!oe.computed&&!this.#C(oe)&&typeof oe.field=="string"&&!oe.lookup&&(de=oe.field);const ve={id:oe.id,kind:oe.storeKind,nullable:oe.nullable,read:fe};de!==null&&(ve.field=de),oe.lookup&&(ve.dictionary=oe.lookup.dictionary()),te.push(ve)}return te}state(){return this.all().map(te=>({id:te.id,width:te.layout.width,flex:te.layout.flex||void 0,hidden:!!te.layout.hidden,pin:te.layout.pin??null,sort:te.sort.direction??null,sortIndex:te.sort.direction?te.sort.order??0:null,groupIndex:te.group.enabled?te.group.index??0:null,pivotIndex:te.pivot.enabled?te.pivot.index??0:null,total:typeof te.total=="string"?te.total:null,groupTotal:typeof te.groupTotal=="string"?te.groupTotal:void 0,grandTotal:typeof te.grandTotal=="string"?te.grandTotal:void 0,decoration:te.cell&&te.cell.decoration!=null?ne(te.cell.decoration):void 0,variant:te.cell&&te.cell.variant!=null?ne(te.cell.variant):void 0}))}applyState(te,oe={}){const fe={applied:[],skipped:[]},de=Array.isArray(te)?te:te&&te.columns||[],ve=!Array.isArray(te)&&te&&te.columnOrder||null;for(const Oe of de){if(!Oe||!Oe.id){fe.skipped.push({key:"?",reason:"no id"});continue}let Ce=this.#e.get(Oe.id);if(!Ce){fe.skipped.push({key:Oe.id,reason:"unknown column"});continue}if(Object.hasOwn(Oe,"decoration")||Object.hasOwn(Oe,"variant")){const pe=Ce.cell?Ce.cell.decoration:void 0,we=Oe.decoration??null,me=Object.hasOwn(Oe,"variant"),Ne=me&&!ie(Ce.cell?Ce.cell.variant:void 0,Oe.variant);(!ie(pe,we)||Ne)&&(this.redecorate(Oe.id,we,me?{variant:Oe.variant??void 0}:{}),Ce=this.#e.get(Oe.id)||Ce)}Oe.width!=null&&(Ce.layout.width=Oe.width),Oe.flex!=null&&(Ce.layout.flex=Oe.flex),Oe.hidden!=null&&(Ce.layout.hidden=!!Oe.hidden),Oe.pin!==void 0&&(Ce.layout.pin=Oe.pin),Oe.sort!==void 0&&(Ce.sort.direction=Oe.sort),Oe.sortIndex!=null&&(Ce.sort.order=Oe.sortIndex),Oe.groupIndex!=null&&(Ce.group.enabled=!0,Ce.group.index=Oe.groupIndex),Oe.pivotIndex!=null&&(Ce.pivot.enabled=!0,Ce.pivot.index=Oe.pivotIndex),Oe.total!==void 0&&(Ce.total=Oe.total),Oe.groupTotal!==void 0&&(Ce.groupTotal=Oe.groupTotal),Oe.grandTotal!==void 0&&(Ce.grandTotal=Oe.grandTotal),fe.applied.push(Oe.id)}const Me=ve||(oe&&oe.keepOrder?[]:de.map(Oe=>Oe&&Oe.id).filter(Boolean));if(Me.length){const Oe=Me.filter(pe=>this.#e.has(pe)),Ce=this.#t.filter(pe=>!Oe.includes(pe));this.#t=[...Oe,...Ce]}return this.#y&&this.#y("state",fe),fe}move(te,oe){this.#E(te,oe)&&(this.#x(),this.#y&&this.#y("move",{id:te,to:oe}))}reorder(te){const oe={applied:[],skipped:[]},fe=[];let de=0;for(const ve of Array.isArray(te)?te:[]){const Me=de++;this.#E(ve,Me)&&(oe.applied.push(ve),fe.push({id:ve,to:Me}))}if(!fe.length)return oe;if(this.#x(),this.#y)for(const ve of fe)this.#y("move",ve);return oe}#E(te,oe){const fe=this.#t.indexOf(te);if(fe===-1||Math.max(0,Math.min(Number(oe)||0,this.#t.length-1))===fe)return!1;const ve=this.#e.get(te);if(ve.layout.movable===!1||ve.layout.lockPosition)return g(`move:${te}`,`column "${te}" is not movable; the move was ignored`),!1;const Me=this.#L(te,oe);return Me?(g(`move.married:${Me}`,`band "${Me}" declares marryChildren, so its columns stay together; the move was ignored`),!1):(this.#t.splice(fe,1),this.#t.splice(Math.max(0,Math.min(oe,this.#t.length)),0,te),!0)}#L(te,oe){if(!this.#n||!this.#n.length)return null;const fe=this.#t.filter(Oe=>Oe!==te),de=Math.max(0,Math.min(oe,fe.length)),ve=(Oe,Ce)=>{if(Array.isArray(Oe.columns)){for(const we of Oe.columns)ve(we,Ce);return Ce}const pe=Oe.column?Oe.column.id:Oe.id;return pe&&Ce.push(pe),Ce},Me=Oe=>{for(const Ce of Oe){if(!Array.isArray(Ce.columns))continue;if(Ce.marryChildren===!0){const we=ve(Ce,[]),me=we.includes(te),Ne=we.map($e=>fe.indexOf($e)).filter($e=>$e>=0);if(Ne.length){const $e=Math.min(...Ne),He=Math.max(...Ne);if(me?de<$e||de>He+1:de>$e&&de<=He)return Ce.id}}const pe=Me(Ce.columns);if(pe)return pe}return null};return Me(this.#n)}#x(){const te=new Map(this.#t.map((de,ve)=>[de,ve])),oe=de=>{if(!Array.isArray(de.columns)){const Me=de.column?de.column.id:de.id;return te.has(Me)?te.get(Me):1/0}let ve=1/0;for(const Me of de.columns)ve=Math.min(ve,oe(Me));return ve},fe=de=>{de.sort((ve,Me)=>oe(ve)-oe(Me));for(const ve of de)Array.isArray(ve.columns)&&fe(ve.columns)};fe(this.#n)}#B(te){const oe=fe=>{for(let de=0;de<fe.length;de++){const ve=fe[de];if(Array.isArray(ve.columns)){const Me=oe(ve.columns);if(Me)return Me}else if(ve.column&&ve.column.id===te)return fe.splice(de,1)[0]}return null};return oe(this.#n)}#H(te){const oe=[];for(let fe=te.length-1;fe>=0;fe--){const de=te[fe];Array.isArray(de.columns)&&(oe.push(...this.#H(de.columns)),de.columns.length===0&&(oe.push(de.id),te.splice(fe,1)))}return oe}#U(){const te=(oe,fe,de)=>{for(const ve of oe)Array.isArray(ve.columns)?te(ve.columns,[...fe,ve.id]):ve.column&&(ve.column.groupPath=fe)};te(this.#n,[])}#N(te){const oe=new Set(te),fe=this.#t.filter(Oe=>oe.has(Oe));if(!fe.length)return;const de=Math.min(...fe.map(Oe=>this.#t.indexOf(Oe))),ve=this.#t.slice(0,de).filter(Oe=>!oe.has(Oe)),Me=this.#t.slice(de).filter(Oe=>!oe.has(Oe));this.#t=[...ve,...fe,...Me]}#$(te){const oe=[],fe=de=>{if(Array.isArray(de.columns))for(const ve of de.columns)fe(ve);else de.column&&oe.push(de.column.id)};return fe(te),oe}#z(te){const oe=fe=>{for(const de of fe){if(!Array.isArray(de.columns))continue;if(de.id===te)return{node:de,parent:fe};const ve=oe(de.columns);if(ve)return ve}return null};return oe(this.#n)}groupColumns(te,oe={}){const fe=w(te).filter(Ce=>this.#e.has(Ce));if(!fe.length)return g("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const Ce of fe)if(this.#e.get(Ce).layout.lockPosition)return g(`columns.group.locked:${Ce}`,`column "${Ce}" is position-locked and cannot be grouped.`),null;const de=oe.groupId?this.#z(oe.groupId):null;if(oe.groupId&&!de)return g(`columns.group.unknown:${oe.groupId}`,`no band "${oe.groupId}" to add to; nothing was grouped.`),null;let ve=null;if(!de&&oe.id!=null&&(ve=String(oe.id),this.#z(ve)||this.#e.has(ve)))return g(`columns.group.idtaken:${ve}`,`band id "${ve}" is already in use; nothing was grouped.`),null;const Me=fe.map(Ce=>this.#B(Ce)).filter(Boolean);if(!Me.length)return null;let Oe;if(de)de.node.columns.push(...Me),Oe=de.node.id;else{const Ce={id:ve||A("grp"),title:oe.title||"",collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Me},pe=Number.isInteger(oe.at)?Math.max(0,Math.min(oe.at,this.#n.length)):this.#n.length;this.#n.splice(pe,0,Ce),Oe=Ce.id}return this.#H(this.#n),this.#N(fe),this.#U(),this.#x(),this.#y&&this.#y("columngroup",{action:"formed",groupId:Oe,ids:fe}),Oe}ungroupColumn(te){const oe=this.#e.get(te);if(!oe){g(`columns.ungroup.unknown:${te}`,`no column "${te}" to ungroup.`);return}const fe=oe.groupPath||[];if(!fe.length)return;const de=fe[fe.length-1],ve=this.#z(de);if(!ve)return;const Me=this.#B(te);if(!Me)return;const Oe=ve.parent.indexOf(ve.node);ve.parent.splice(Oe+1,0,Me);const Ce=this.#H(this.#n),pe=this.#$(ve.node);if(pe.length){this.#N(pe);const we=Math.max(...pe.map(Ne=>this.#t.indexOf(Ne))),me=this.#t.filter(Ne=>Ne!==te);me.splice(we+1,0,te),this.#t=me}this.#U(),this.#x(),this.#y&&this.#y("columngroup",{action:"removed",id:te,dissolved:Ce})}renameGroup(te,oe){const fe=this.#z(te);if(!fe){g(`columns.group.rename:${te}`,`no band "${te}" to rename.`);return}fe.node.title=String(oe??""),this.#y&&this.#y("columngroup",{action:"renamed",groupId:te,title:fe.node.title})}dissolveGroup(te){const oe=this.#z(te);if(!oe){g(`columns.group.dissolve:${te}`,`no band "${te}" to dissolve.`);return}const fe=oe.parent.indexOf(oe.node);oe.parent.splice(fe,1,...oe.node.columns),this.#U(),this.#x(),this.#y&&this.#y("columngroup",{action:"dissolved",groupId:te})}moveGroup(te,oe){const fe=this.#z(te);if(!fe){g(`columns.group.move:${te}`,`no band "${te}" to move.`);return}const de=fe.parent,ve=de.indexOf(fe.node);ve!==-1&&(de.splice(ve,1),de.splice(Math.max(0,Math.min(oe,de.length)),0,fe.node),this.#_(),this.#U(),this.#y&&this.#y("columngroup",{action:"moved",groupId:te,to:oe}))}#_(){const te=[],oe=de=>{for(const ve of de)Array.isArray(ve.columns)?oe(ve.columns):ve.column&&te.push(ve.column.id)};oe(this.#n);const fe=new Set(te);this.#t=[...te,...this.#t.filter(de=>!fe.has(de))]}groupTree(){const te=fe=>fe.map(de=>Array.isArray(de.columns)?{id:de.id,title:de.title||"",collapsible:!!de.collapsible,openByDefault:de.openByDefault!==!1,columns:te(de.columns)}:de.column?de.column.id:null).filter(de=>de!==null),oe=te(this.#n);return oe.some(fe=>fe&&typeof fe=="object")?oe:[]}applyGroupTree(te){if(!Array.isArray(te))return;const oe=new Set,fe=ve=>{const Me=[];for(const Oe of ve)if(Oe&&typeof Oe=="object"&&Array.isArray(Oe.columns)){const Ce=fe(Oe.columns);if(!Ce.length)continue;Me.push({id:Oe.id||A("grp"),title:Oe.title||"",collapsible:Oe.collapsible===!0,openByDefault:Oe.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Ce})}else if(typeof Oe=="string"){const Ce=this.#e.get(Oe);Ce&&!oe.has(Oe)&&(oe.add(Oe),Me.push({column:Ce,path:[]}))}return Me},de=fe(te);for(const ve of this.#t){if(oe.has(ve))continue;const Me=this.#e.get(ve);Me&&de.push({column:Me,path:[]})}this.#n=de,this.#U(),this.#x(),this.#y&&this.#y("columngroup",{action:"applied"})}show(te){this.#Y(te,!1)}hide(te){this.#Y(te,!0)}#Y(te,oe){const fe=[];for(const de of w(te)){const ve=this.#e.get(de);if(ve){if(oe&&ve.layout.lockVisible){g(`lockVisible:${de}`,`column "${de}" is \`layout.lockVisible\` and cannot be hidden`);continue}ve.layout.hidden!==oe&&(ve.layout.hidden=oe,fe.push(de))}}fe.length&&this.#y&&this.#y("visible",{ids:fe,hidden:oe})}pin(te,oe){const fe=this.#e.get(te);fe&&(fe.layout.pin=oe??null,this.#y&&this.#y("pin",{id:te,side:fe.layout.pin}))}resize(te,oe){const fe=this.#e.get(te);if(!fe)return;if(fe.layout.resizable===!1){g(`resize:${te}`,`column "${te}" is not resizable; the resize was ignored`);return}const de=fe.layout.min??0,ve=fe.layout.max;let Me=Math.max(de,oe);ve!=null&&(Me=Math.min(ve,Me)),fe.layout.width=Me,fe.layout.flex=0,this.#y&&this.#y("resize",{id:te,width:Me})}}function ee(ce){const te={};return ce.width!=null&&(te.width=ce.width),ce.hidden!=null&&(te.hidden=ce.hidden),ce.pin!==void 0&&(te.pin=ce.pin),te}function ne(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 ie(ce,te){const oe=ce??null,fe=te??null;if(oe===fe)return!0;if(oe===null||fe===null)return!1;if(typeof oe!="object"||typeof fe!="object")return oe===fe;try{return JSON.stringify(oe)===JSON.stringify(fe)}catch{return!1}}function se(ce){const te=[],oe=(de,ve,Me)=>{const Oe=[];for(const Ce of de){if(!W(Ce)){B("a column definition must be an object");continue}if(Array.isArray(Ce.columns)){L(Ce,j,"columnGroup",Ce.title||Ce.id||"(unnamed)");const pe={id:Ce.id||A("grp"),title:Ce.title||"",collapsible:Ce.collapsible===!0,openByDefault:Ce.openByDefault!==!1,showWhen:Ce.showWhen||"always",marryChildren:Ce.marryChildren===!0,header:Ce.header||{},def:Ce,columns:[]};pe.columns=oe(Ce.columns,[...ve,pe.id],Ce.facet!==void 0?Ce.facet:Me),Oe.push(pe)}else{const pe={def:Ce,path:ve,facet:Me};te.push(pe),Oe.push(pe)}}return Oe},fe=oe(ce,[],void 0);return{leaves:te,groups:fe}}function he(ce,te,oe){for(const fe of ce){if(fe.columns){if(he(fe.columns,te,oe))return!0;continue}if(fe.column&&fe.column.id===te)return fe.column=oe,!0}return!1}}),Fe("packages/core/src/columns/autogroup.js",function(e,K){"use strict";Object.defineProperty(e,"AUTO_GROUP_ID",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createAutoGroupColumn",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"warnOnAbsurdGrouping",{enumerable:!0,get:function(){return W}});const $=K("packages/core/src/internal/util.js").warnOnce,B="__lattice_group",I=240,_=.5;function X(H){const{columns:V,groupBy:z}=H,w=z.map(l=>V.get(l)).filter(Boolean),A=w.length?w.map(l=>l.title||l.id).join(" > "):"Group",g=H.config&&H.config.autoGroupColumnWidth||I;return{id:B,field:null,title:A,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group"},edit:{enabled:!1},sort:{enabled:!0,direction:null},filter:{enabled:!0},groupedIds:z.slice(),group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:g,min:120,pin:H.config&&H.config.autoGroupColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(l,d){return d&&d.group?d.groupValue:null},formatValue(l,d){if(!d||!d.group)return"";if(d.grandTotal)return H.config&&H.config.grandTotalLabel||"Total";const o=w[Math.min(d.level||0,w.length-1)];return o&&typeof o.formatValue=="function"?o.formatValue(l,d):l==null?"":String(l)}}}function W(H,V,z){!H.length||z<100||V<z*_||$(`grouping.cardinality:${H.join(",")}`,`grouping by ${H.join(", ")} produced ${V} groups for ${z} rows: nearly one group per row. Grouping a continuous value such as a percentage or a timestamp rarely reads usefully; consider a computed banding column.`)}}),Fe("packages/core/src/columns/selectcolumn.js",function(e,K){"use strict";Object.defineProperty(e,"SELECT_COLUMN_ID",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"createSelectionColumn",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return I}});const Q="__lattice_select",$=44;function B(_){const X=_.selection||{},W=_.config&&_.config.selectionColumnWidth||$;return{id:Q,field:null,title:"",type:"boolean",dataType:{base:"boolean"},nullable:!1,align:"center",generated:!0,control:!0,value:{pure:!0},cell:{render:"checkbox",props:{mode:"selection"},align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:W,min:W,max:W,pin:_.config&&_.config.selectionColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,headerCheckbox:X.headerCheckbox===!0,def:{},getValue(H,V){return V?V.selected:!1},formatValue(){return""}}}const I=B}),Fe("packages/core/src/columns/rownumbercolumn.js",function(e,K){"use strict";Object.defineProperty(e,"ROW_NUMBER_COLUMN_ID",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createRowNumberColumn",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return V}});const $=K("packages/core/src/internal/util.js").isFunction,B="__lattice_rownumber",I=40,_=9,X=22;function W(z){const w=String(Math.max(1,Math.trunc(Math.abs(z))||1)).length;return Math.max(I,w*_+X)}function H(z){const w=z.rowNumbers,A=w&&typeof w=="object"?w:{},g=Number.isFinite(A.start)?A.start:1,l=Number.isFinite(A.width)?A.width:W((z.maxNumber||0)+g),d=$(z.rank)?z.rank:()=>null;return{id:B,field:null,title:typeof A.title=="string"?A.title:"",type:"number",dataType:{base:"number"},nullable:!0,align:"end",generated:!0,control:!0,value:{pure:!0},cell:{align:"end"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:l,min:l,max:l,pin:"start",hidden:!1,resizable:A.width==null,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(o,n){const t=d(n);return t==null?null:t-1+g},formatValue(o){return o==null?"":String(o)}}}const V=H}),Fe("packages/core/src/model/detail.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_DETAIL_HEIGHT",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"DEFAULT_CACHE_LIMIT",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"resolveDetail",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DetailModel",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return H}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,I=240,_=10;function X(V){if(!V)return null;const z=V===!0?{}:V;return z.enabled===!1?null:!$(z.rows)&&!z.render?(B("detail.rows","detail is enabled but neither `rows` nor `render` was supplied; expanding a master would show an empty region, so it stays off."),null):{render:z.render||null,config:z.config||null,rows:$(z.rows)?z.rows:null,height:z.height??I,cacheLimit:Number.isFinite(z.cacheLimit)?Math.max(0,z.cacheLimit):_,isMaster:$(z.isMaster)?z.isMaster:null,target:z.target||null,onCreate:$(z.onCreate)?z.onCreate:null,path:typeof z.path=="string"?z.path:null}}class W{#e;#t=new Set;#n;#r=0;constructor(z){this.#e=z.config,this.#n=$(z.onChange)?z.onChange:()=>{}}get config(){return this.#e}get inline(){return!this.#e.target}isMaster(z){if(!z||z.group||z.detail)return!1;const w=this.#e.isMaster;return w?!!w(z.data,z):!0}isOpen(z){return this.#t.has(z)}keys(){return[...this.#t]}activeKey(){for(const z of this.#t)return z;return null}heightOf(z){const w=this.#e.height;return $(w)?Number(w(z))||I:w==="auto"?I:Number(w)||I}open(z){return this.#t.has(z)?!1:(this.inline||this.#t.clear(),this.#t.add(z),this.#o(),!0)}close(z){return this.#t.delete(z)?(this.#o(),!0):!1}toggle(z){return this.#t.has(z)?(this.close(z),!1):(this.open(z),!0)}closeAll(){this.#t.size&&(this.#t.clear(),this.#o())}prune(z){if(!this.#t.size||!$(z))return;let w=!1;for(const A of[...this.#t])z(A)||(this.#t.delete(A),w=!0);w&&this.#o()}signature(){return`${this.#r}`}set(z){this.#t.clear();const w=Array.isArray(z)?z:[];for(const A of this.inline?w:w.slice(0,1))this.#t.add(A);this.#o()}#o(){this.#r++,this.#n()}}const H=W}),Fe("packages/core/src/compute/special.js",function(e,K){"use strict";Object.defineProperty(e,"logGamma",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"incompleteBeta",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"normalQuantile",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"normalCdf",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"studentT",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"studentTQuantile",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"regularizedGammaP",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"chiSquareUpperTail",{enumerable:!0,get:function(){return o}});const Q=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),$=3e-12,B=1e-300;function I(n){if(n<.5)return Math.log(Math.PI/Math.sin(Math.PI*n))-I(1-n);const t=n-1;let r=.9999999999998099;const s=t+7.5;for(let h=0;h<Q.length;h++)r+=Q[h]/(t+h+1);return .5*Math.log(2*Math.PI)+(t+.5)*Math.log(s)-s+Math.log(r)}function _(n,t,r){const s=n+t,h=n+1,u=n-1;let i=1,m=1-s*r/h;Math.abs(m)<B&&(m=B),m=1/m;let c=m;for(let f=1;f<=300;f++){const a=2*f;let p=f*(t-f)*r/((u+a)*(n+a));m=1+p*m,Math.abs(m)<B&&(m=B),i=1+p/i,Math.abs(i)<B&&(i=B),m=1/m,c*=m*i,p=-(n+f)*(s+f)*r/((n+a)*(h+a)),m=1+p*m,Math.abs(m)<B&&(m=B),i=1+p/i,Math.abs(i)<B&&(i=B),m=1/m;const b=m*i;if(c*=b,Math.abs(b-1)<$)break}return c}function X(n,t,r){if(!(n>0)||!(t>0)||!Number.isFinite(r))return Number.NaN;if(r<=0)return 0;if(r>=1)return 1;const s=Math.exp(I(n+t)-I(n)-I(t)+n*Math.log(r)+t*Math.log(1-r));return r<(n+1)/(n+t+2)?s*_(n,t,r)/n:1-s*_(t,n,1-r)/t}function W(n){if(!(n>0)||!(n<1))return n===0?-1/0:n===1?1/0:Number.NaN;const t=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],r=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],s=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],h=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],u=.02425;let i,m,c;n<u?(i=Math.sqrt(-2*Math.log(n)),c=(((((s[0]*i+s[1])*i+s[2])*i+s[3])*i+s[4])*i+s[5])/((((h[0]*i+h[1])*i+h[2])*i+h[3])*i+1)):n<=1-u?(i=n-.5,m=i*i,c=(((((t[0]*m+t[1])*m+t[2])*m+t[3])*m+t[4])*m+t[5])*i/(((((r[0]*m+r[1])*m+r[2])*m+r[3])*m+r[4])*m+1)):(i=Math.sqrt(-2*Math.log(1-n)),c=-(((((s[0]*i+s[1])*i+s[2])*i+s[3])*i+s[4])*i+s[5])/((((h[0]*i+h[1])*i+h[2])*i+h[3])*i+1));const a=(.5*H(-c/Math.SQRT2)-n)*Math.sqrt(2*Math.PI)*Math.exp(c*c/2);return c-a/(1+c*a/2)}function H(n){const t=Math.abs(n),r=2/(2+t),s=4*r-2,h=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let u=0,i=0,m;for(let f=h.length-1;f>0;f--)m=i,i=s*i-u+h[f],u=m;const c=r*Math.exp(-t*t+.5*(h[0]+s*i)-u);return n>=0?c:2-c}function V(n){return .5*H(-n/Math.SQRT2)}function z(n,t){if(!(t>0)||!Number.isFinite(n))return Number.NaN;const r=.5*X(t/2,.5,t/(t+n*n));return n>0?1-r:r}function w(n,t){if(!(n>0)||!(n<1)||!(t>0))return Number.NaN;if(t>1e7)return W(n);let r=-1e4,s=1e4,h=W(n);const u=I(t/2)+I(.5)-I((t+1)/2);for(let i=0;i<60;i++){const m=z(h,t);m<n?r=h:s=h;const c=Math.exp(-((t+1)/2)*Math.log(1+h*h/t)-u)/Math.sqrt(t),f=c>0?(m-n)/c:0;if(Math.abs(f)<1e-12)break;const a=h-f;if(h=a>r&&a<s&&Number.isFinite(a)?a:(r+s)/2,s-r<1e-12)break}return h}function A(n,t){let r=n,s=1/n,h=s;for(let u=0;u<300&&(r+=1,h*=t/r,s+=h,!(Math.abs(h)<Math.abs(s)*$));u++);return s*Math.exp(-t+n*Math.log(t)-I(n))}function g(n,t){let r=t+1-n,s=1/B,h=1/r,u=h;for(let i=1;i<=300;i++){const m=-i*(i-n);r+=2,h=m*h+r,Math.abs(h)<B&&(h=B),s=r+m/s,Math.abs(s)<B&&(s=B),h=1/h;const c=h*s;if(u*=c,Math.abs(c-1)<$)break}return Math.exp(-t+n*Math.log(t)-I(n))*u}function l(n,t){return!(n>0)||!(t>=0)||!Number.isFinite(t)?Number.NaN:t===0?0:t<n+1?A(n,t):1-g(n,t)}function d(n,t){return t>0?l(t/2,n/2):Number.NaN}function o(n,t){const r=d(n,t);return Number.isNaN(r)?Number.NaN:Math.min(1,Math.max(0,1-r))}}),Fe("packages/core/src/compute/linalg.js",function(e,K){"use strict";Object.defineProperty(e,"cholesky",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"choleskySolve",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"choleskyInverse",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"normalEquations",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"matVec",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"quadForm",{enumerable:!0,get:function(){return X}});function Q(W){const H=W.length,V=Array.from({length:H},()=>new Array(H).fill(0));for(let z=0;z<H;z++)for(let w=0;w<=z;w++){let A=W[z][w];for(let g=0;g<w;g++)A-=V[z][g]*V[w][g];if(z===w){if(!(A>0))return null;V[z][w]=Math.sqrt(A)}else V[z][w]=A/V[w][w]}return V}function $(W,H){const V=W.length,z=new Array(V).fill(0);for(let A=0;A<V;A++){let g=H[A];for(let l=0;l<A;l++)g-=W[A][l]*z[l];z[A]=g/W[A][A]}const w=new Array(V).fill(0);for(let A=V-1;A>=0;A--){let g=z[A];for(let l=A+1;l<V;l++)g-=W[l][A]*w[l];w[A]=g/W[A][A]}return w}function B(W){const H=W.length,V=Array.from({length:H},()=>new Array(H).fill(0));for(let z=0;z<H;z++){const w=new Array(H).fill(0);w[z]=1;const A=$(W,w);for(let g=0;g<H;g++)V[g][z]=A[g]}return V}function I(W,H,V){const z=W.length,w=z?W[0].length:0,A=Array.from({length:w},()=>new Array(w).fill(0)),g=new Array(w).fill(0);for(let l=0;l<z;l++){const d=V?V[l]:1,o=W[l];for(let n=0;n<w;n++){const t=d*o[n];g[n]+=t*H[l];for(let r=n;r<w;r++)A[n][r]+=t*o[r]}}for(let l=0;l<w;l++)for(let d=0;d<l;d++)A[l][d]=A[d][l];return{xtwx:A,xtwy:g}}function _(W,H){return W.map(V=>V.reduce((z,w,A)=>z+w*H[A],0))}function X(W,H){let V=0;for(let z=0;z<W.length;z++){let w=0;for(let A=0;A<W.length;A++)w+=H[z][A]*W[A];V+=W[z]*w}return V}}),Fe("packages/core/src/compute/sketch.js",function(e,K){"use strict";Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return A}});class Q{#e=0;#t=0;#n=0;static get errorBound(){return Object.freeze({kind:"exact",metric:"none",value:0,statement:"mean and variance match a full recompute to float rounding"})}get count(){return this.#e}add(l){if(!Number.isFinite(l))return;this.#e++;const d=l-this.#t;this.#t+=d/this.#e,this.#n+=d*(l-this.#t)}merge(l){if(l.#e===0)return;if(this.#e===0){this.#e=l.#e,this.#t=l.#t,this.#n=l.#n;return}const d=this.#e+l.#e,o=l.#t-this.#t;this.#t+=o*(l.#e/d),this.#n+=l.#n+o*o*(this.#e*l.#e/d),this.#e=d}mean(){return this.#e?this.#t:null}variance(){return this.#e>1?this.#n/(this.#e-1):null}varianceP(){return this.#e?this.#n/this.#e:null}stddev(){const l=this.variance();return l===null?null:Math.sqrt(l)}stddevP(){const l=this.varianceP();return l===null?null:Math.sqrt(l)}}class ${#e=[];#t=0;#n;#r;constructor(l,d=Math.random){if(!(l>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(l),this.#r=d}static get errorBound(){return Object.freeze({kind:"probabilistic",metric:"none",value:0,statement:"uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators"})}get seen(){return this.#t}get size(){return this.#e.length}add(l){if(!Number.isFinite(l))return;if(this.#t++,this.#e.length<this.#n){this.#e.push(l);return}const d=Math.floor(this.#r()*this.#t);d<this.#n&&(this.#e[d]=l)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let l=0;for(const d of this.#e)l+=d;return l/this.#e.length}quantile(l){const d=this.#e.length;if(!d)return null;const o=this.#e.slice().sort((s,h)=>s-h);if(d===1)return o[0];const n=(d-1)*Math.min(1,Math.max(0,l)),t=Math.floor(n),r=Math.ceil(n);return t===r?o[t]:o[t]+(n-t)*(o[r]-o[t])}}function B(g){return g^=g>>>16,g=Math.imul(g,2246822507),g^=g>>>13,g=Math.imul(g,3266489909),g^=g>>>15,g>>>0}function I(g){if(typeof g=="number"){const o=new DataView(new ArrayBuffer(8));return o.setFloat64(0,g===0?0:g),B(o.getUint32(0)^o.getUint32(4))}const l=typeof g=="string"?g:String(g);let d=2166136261;for(let o=0;o<l.length;o++)d^=l.charCodeAt(o),d=Math.imul(d,16777619);return B(d)}class _{#e;#t;#n;constructor(l=14){const d=Math.floor(l);if(d<4||d>16)throw new RangeError("HLL precision must be 4..16");this.#e=d,this.#t=1<<d,this.#n=new Uint8Array(this.#t)}static errorBoundFor(l=14){const d=1<<Math.floor(l),o=1.04/Math.sqrt(d);return Object.freeze({kind:"probabilistic",metric:"relative",value:o,statement:`distinct count within ~${(o*100).toFixed(2)}% relative standard error (m=${d} buckets)`})}errorBound(){return _.errorBoundFor(this.#e)}add(l){const d=I(l),o=d&this.#t-1,n=d>>>this.#e|1<<32-this.#e;let t=1,r=n;for(;(r&1)===0;)t++,r>>>=1;t>this.#n[o]&&(this.#n[o]=t)}count(){const l=this.#t,d=32-this.#e,o=new Float64Array(d+2);for(let r=0;r<l;r++)o[this.#n[r]]++;let n=l*H(1-o[d+1]/l);for(let r=d;r>=1;r--)n=.5*(n+o[r]);n+=l*W(o[0]/l);const t=X*l*l/n;return Math.round(t)}}const X=.5/Math.log(2);function W(g){if(g===1)return 1/0;let l=1,d=g,o;do g*=g,o=d,d+=g*l,l+=l;while(d!==o);return d}function H(g){if(g===0||g===1)return 0;let l=1,d=1-g,o;do g=Math.sqrt(g),o=d,l*=.5,d-=(1-g)**2*l;while(d!==o);return d/3}class V{#e=new Map;#t;#n=0;constructor(l){if(!(l>0))throw new RangeError("Space-Saving capacity must be positive");this.#t=Math.floor(l)}errorBoundFor(l){const d=l/this.#t;return Object.freeze({kind:"deterministic",metric:"absolute",value:d,statement:`each count overestimates the truth by at most N/m = ${d.toFixed(2)} (N=${l}, m=${this.#t})`})}get seen(){return this.#n}add(l){this.#n++;const d=this.#e.get(l);if(d){d.count++;return}if(this.#e.size<this.#t){this.#e.set(l,{count:1,error:0});return}let o,n=1/0;for(const[t,r]of this.#e)r.count<n&&(n=r.count,o=t);this.#e.delete(o),this.#e.set(l,{count:n+1,error:n})}top(l=this.#t){return[...this.#e.entries()].map(([o,n])=>({item:o,count:n.count,error:n.error})).sort((o,n)=>n.count-o.count).slice(0,Math.max(0,Math.floor(l)))}}class z{#e;#t=[[]];#n=0;#r;#o;constructor(l=200,d=Math.random){this.#e=Math.max(8,Math.floor(l)),this.#r=d,this.#o=2/3}static errorBoundFor(l=200){const d=1/Math.max(8,Math.floor(l));return Object.freeze({kind:"probabilistic",metric:"rank",value:d,statement:`queried quantile's true rank within ~${(d*100).toFixed(2)}% of N of the requested rank (k=${l})`})}errorBound(){return z.errorBoundFor(this.#e)}get count(){return this.#n}#i(l){const o=this.#t.length-1-l,n=Math.ceil(this.#e*this.#o**o);return Math.max(2,n)}add(l){Number.isFinite(l)&&(this.#n++,this.#t[0].push(l),this.#t[0].length>=this.#i(0)&&this.#s(0))}#s(l){const d=this.#t[l];d.sort((t,r)=>t-r),l+1>=this.#t.length&&this.#t.push([]);const o=this.#t[l+1],n=this.#r()<.5?0:1;for(let t=n;t<d.length;t+=2)o.push(d[t]);this.#t[l]=[];for(let t=0;t<this.#t.length;t++)if(this.#t[t].length>=this.#i(t)){this.#s(t);return}}#l(){const l=[];for(let d=0;d<this.#t.length;d++){const o=1<<d;for(const n of this.#t[d])l.push({v:n,w:o})}return l}quantile(l){const d=this.#l();if(!d.length)return null;d.sort((r,s)=>r.v-s.v);let o=0;for(const r of d)o+=r.w;const n=Math.min(1,Math.max(0,l))*o;let t=0;for(const r of d)if(t+=r.w,t>=n)return r.v;return d[d.length-1].v}rank(l){let d=0;for(let o=0;o<this.#t.length;o++){const n=1<<o;for(const t of this.#t[o])t<=l&&(d+=n)}return d}}const w=Object.freeze({distinct:_.errorBoundFor(14),median:z.errorBoundFor(200),p25:z.errorBoundFor(200),p75:z.errorBoundFor(200),p90:z.errorBoundFor(200),p95:z.errorBoundFor(200),p99:z.errorBoundFor(200),iqr:z.errorBoundFor(200),topK:Object.freeze({kind:"deterministic",metric:"absolute",value:0,statement:"each count overestimates the truth by at most N/m; top-K exact when the K-th item exceeds N/m"})}),A={Welford:Q,Reservoir:$,HyperLogLog:_,SpaceSaving:V,KLL:z,hash32:I,SKETCH_BOUNDS:w}}),Fe("packages/core/src/compute/statistics.js",function(e,K){"use strict";Object.defineProperty(e,"KENDALL_LIMIT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"numbers",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"frequencies",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"entropy",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"evenness",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"topShare",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"gini",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"moments",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"quantileSorted",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"quantile",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"STAT_FNS",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"STAT_LABELS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"extremeRow",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"correlation",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"trimmedMean",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"winsorizedMean",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"modifiedZOutliers",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"jarqueBera",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"covariance",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"regression",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"fitLinearModel",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(e,"kendall",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(e,"seriesStats",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"D2_N2",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"D4_N2",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(e,"movingRanges",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"withinSigma",{enumerable:!0,get:function(){return He}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(e,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(e,"controlViolations",{enumerable:!0,get:function(){return lt}}),Object.defineProperty(e,"countOutside",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(e,"histogram",{enumerable:!0,get:function(){return gt}}),Object.defineProperty(e,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return At}}),Object.defineProperty(e,"meanInterval",{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(e,"proportionInterval",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(e,"slopeInterval",{enumerable:!0,get:function(){return Dt}}),Object.defineProperty(e,"capabilityInterval",{enumerable:!0,get:function(){return Bt}}),Object.defineProperty(e,"standardizedMeanDifference",{enumerable:!0,get:function(){return dt}}),Object.defineProperty(e,"normalTotalVariation",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(e,"frequencyMap",{enumerable:!0,get:function(){return le}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(e,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(e,"compareColumn",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"isNumericColumn",{enumerable:!0,get:function(){return De}}),Object.defineProperty(e,"populationRead",{enumerable:!0,get:function(){return Qe}});const Q=K("packages/core/src/compute/handle.js"),$=Q.presenceReader,B=Q.valueReader,I=K("packages/core/src/compute/special.js"),_=I.studentTQuantile,X=I.studentT,W=I.normalQuantile,H=I.normalCdf,V=I.chiSquareUpperTail,z=K("packages/core/src/compute/linalg.js"),w=z.cholesky,A=z.choleskySolve,g=z.choleskyInverse,l=z.normalEquations,d=z.quadForm,n=K("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,t=5e3,r=Object.freeze({variance:"rescan",varianceP:"rescan",stddev:"rescan",stddevP:"rescan",sumSquares:"rescan",weightedAvg:"rescan",median:"rescan",p25:"rescan",p75:"rescan",p90:"rescan",p95:"rescan",p99:"rescan",iqr:"rescan",mode:"rescan",distinct:"rescan",range:"rescan",skewness:"rescan",kurtosis:"rescan",geomean:"rescan",harmean:"rescan",mad:"rescan",argmin:"rescan",argmax:"rescan",hhi:"rescan",entropy:"rescan",evenness:"rescan",top3Share:"rescan",top10Share:"rescan",gini:"rescan",trimmedMean:"rescan",winsorizedMean:"rescan",robustOutliers:"rescan",jarqueBera:"rescan",passRate:"rescan",failureCount:"rescan"}),s=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:n.distinct}),median:Object.freeze({sketch:"KLL",bound:n.median}),p25:Object.freeze({sketch:"KLL",bound:n.p25}),p75:Object.freeze({sketch:"KLL",bound:n.p75}),p90:Object.freeze({sketch:"KLL",bound:n.p90}),p95:Object.freeze({sketch:"KLL",bound:n.p95}),p99:Object.freeze({sketch:"KLL",bound:n.p99}),iqr:Object.freeze({sketch:"KLL",bound:n.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:n.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:n.topK})});function h(ye){const ge=ye==="sum"||ye==="avg"||ye==="countValues"||ye==="min"||ye==="max"?"maintained":Object.prototype.hasOwnProperty.call(r,ye)?r[ye]:null,Se=Object.prototype.hasOwnProperty.call(s,ye)?s[ye]:null;return{stat:ye,exact:ge,approximate:Se}}function u(ye,ge){const Se=ge.length,Pe=new Float64Array(Se);let Re=0;if(ye&&(ye.kind==="float64"||ye.kind==="int32")){const be=ye.values,Ee=$(ye);for(let ze=0;ze<Se;ze++){const Ve=ge[ze];if(Ee&&Ee(Ve)!==1)continue;const Je=be[Ve];Number.isNaN(Je)||(Pe[Re++]=Je)}return Pe.subarray(0,Re)}const _e=B(ye);for(let be=0;be<Se;be++){const Ee=_e(ge[be]);if(Ee==null||Ee==="")continue;const ze=typeof Ee=="number"?Ee:Number(Ee);Number.isFinite(ze)&&(Pe[Re++]=ze)}return Pe.subarray(0,Re)}function i(ye,ge){const Se=new Map,Pe=B(ye);let Re=0;for(let _e=0;_e<ge.length;_e++){const be=Pe(ge[_e]);if(be==null||be===""||typeof be=="number"&&Number.isNaN(be))continue;const Ee=typeof be=="object"?String(be):be;Se.set(Ee,(Se.get(Ee)||0)+1),Re++}const Be=[...Se.values()].sort((_e,be)=>be-_e);return{counts:Be,total:Re,distinct:Be.length}}function m(ye){return ye.total>0?ye.counts.map(ge=>ge/ye.total):[]}function c(ye,ge){const Se=i(ye,ge);if(!Se.total)return null;let Pe=0;for(const Re of m(Se))Pe+=Re*Re;return Pe}function f(ye,ge){const Se=i(ye,ge);if(!Se.total)return null;let Pe=0;for(const Re of m(Se))Re>0&&(Pe-=Re*Math.log2(Re));return Pe}function a(ye,ge){const Se=i(ye,ge);if(!Se.total||Se.distinct<2)return Se.total?1:null;let Pe=0;for(const Re of m(Se))Re>0&&(Pe-=Re*Math.log2(Re));return Pe/Math.log2(Se.distinct)}function p(ye,ge,Se=3){const Pe=i(ye,ge);if(!Pe.total)return null;const Re=Math.max(1,Math.floor(Se));let Be=0;for(let _e=0;_e<Math.min(Re,Pe.counts.length);_e++)Be+=Pe.counts[_e];return Be/Pe.total}function b(ye,ge){const Se=u(ye,ge),Pe=Se.length;if(!Pe)return null;const Re=Se.slice().sort();if(Re[0]<0)return null;let Be=0,_e=0;for(let be=0;be<Pe;be++)Be+=Re[be],_e+=(be+1)*Re[be];return Be===0?0:2*_e/(Pe*Be)-(Pe+1)/Pe}function O(ye){let ge=0,Se=0,Pe=0;for(let Re=0;Re<ye.length;Re++){const Be=ye[Re];ge++;const _e=Be-Se;Se+=_e/ge,Pe+=_e*(Be-Se)}return{n:ge,mean:Se,m2:Pe}}function k(ye,ge){const Se=ye.length;if(!Se)return NaN;if(Se===1)return ye[0];const Pe=(Se-1)*Math.min(1,Math.max(0,ge)),Re=Math.floor(Pe),Be=Math.ceil(Pe);return Re===Be?ye[Re]:ye[Re]+(Pe-Re)*(ye[Be]-ye[Re])}function y(ye,ge){if(!ye.length)return NaN;const Se=ye.slice().sort();return k(Se,ge)}function v(ye,ge){const Se=B(ye);let Pe=0,Re=0,Be=0;for(let _e=0;_e<ge.length;_e++){const be=Se(ge[_e]);if(be==null||be==="")continue;const Ee=String(be).toUpperCase();Ee==="PASS"?Pe++:Ee==="FAIL"?Re++:Ee==="WARN"&&Be++}return{pass:Pe+Be,fail:Re,warn:Be,judged:Pe+Be+Re}}const R=Object.freeze({hhi:(ye,ge)=>c(ye,ge),entropy:(ye,ge)=>f(ye,ge),evenness:(ye,ge)=>a(ye,ge),top3Share:(ye,ge)=>p(ye,ge,3),top10Share:(ye,ge)=>p(ye,ge,10),gini:(ye,ge)=>b(ye,ge),trimmedMean:(ye,ge)=>F(u(ye,ge),.1),winsorizedMean:(ye,ge)=>E(u(ye,ge),.1),robustOutliers:(ye,ge)=>D(u(ye,ge),3.5),jarqueBera:(ye,ge)=>N(u(ye,ge)),variance:(ye,ge)=>{const{n:Se,m2:Pe}=O(u(ye,ge));return Se>1?Pe/(Se-1):null},varianceP:(ye,ge)=>{const{n:Se,m2:Pe}=O(u(ye,ge));return Se>0?Pe/Se:null},stddev:(ye,ge)=>{const{n:Se,m2:Pe}=O(u(ye,ge));return Se>1?Math.sqrt(Pe/(Se-1)):null},stddevP:(ye,ge)=>{const{n:Se,m2:Pe}=O(u(ye,ge));return Se>0?Math.sqrt(Pe/Se):null},median:(ye,ge)=>{const Se=u(ye,ge);return Se.length?y(Se,.5):null},p25:(ye,ge)=>{const Se=u(ye,ge);return Se.length?y(Se,.25):null},p75:(ye,ge)=>{const Se=u(ye,ge);return Se.length?y(Se,.75):null},p90:(ye,ge)=>{const Se=u(ye,ge);return Se.length?y(Se,.9):null},p95:(ye,ge)=>{const Se=u(ye,ge);return Se.length?y(Se,.95):null},p99:(ye,ge)=>{const Se=u(ye,ge);return Se.length?y(Se,.99):null},iqr:(ye,ge)=>{const Se=u(ye,ge);if(!Se.length)return null;const Pe=Se.slice().sort();return k(Pe,.75)-k(Pe,.25)},mad:(ye,ge)=>{const Se=u(ye,ge);if(!Se.length)return null;const Pe=y(Se,.5),Re=new Float64Array(Se.length);for(let Be=0;Be<Se.length;Be++)Re[Be]=Math.abs(Se[Be]-Pe);return y(Re,.5)},range:(ye,ge)=>{const Se=u(ye,ge);if(!Se.length)return null;let Pe=1/0,Re=-1/0;for(let Be=0;Be<Se.length;Be++)Se[Be]<Pe&&(Pe=Se[Be]),Se[Be]>Re&&(Re=Se[Be]);return Re-Pe},distinct:(ye,ge)=>{const Se=B(ye),Pe=new Set;for(let Re=0;Re<ge.length;Re++){const Be=Se(ge[Re]);Be==null||Be===""||Pe.add(Be instanceof Date?Be.getTime():Be)}return Pe.size},mode:(ye,ge)=>{const Se=B(ye),Pe=new Map;for(let _e=0;_e<ge.length;_e++){const be=Se(ge[_e]);if(be==null||be==="")continue;const Ee=be instanceof Date?be.getTime():be;Pe.set(Ee,(Pe.get(Ee)||0)+1)}let Re=null,Be=1;for(const[_e,be]of Pe)be>Be&&(Be=be,Re=_e);return Re},skewness:(ye,ge)=>{const Se=u(ye,ge),{n:Pe,mean:Re,m2:Be}=O(Se);if(Pe<3||Be<=0)return null;const _e=Math.sqrt(Be/(Pe-1));let be=0;for(let Ee=0;Ee<Se.length;Ee++)be+=((Se[Ee]-Re)/_e)**3;return Pe/((Pe-1)*(Pe-2))*be},kurtosis:(ye,ge)=>{const Se=u(ye,ge),{n:Pe,mean:Re,m2:Be}=O(Se);if(Pe<4||Be<=0)return null;const _e=Math.sqrt(Be/(Pe-1));let be=0;for(let Ve=0;Ve<Se.length;Ve++)be+=((Se[Ve]-Re)/_e)**4;const Ee=Pe*(Pe+1)/((Pe-1)*(Pe-2)*(Pe-3)),ze=3*(Pe-1)**2/((Pe-2)*(Pe-3));return Ee*be-ze},geomean:(ye,ge)=>{const Se=u(ye,ge);if(!Se.length)return null;let Pe=0;for(let Re=0;Re<Se.length;Re++){if(Se[Re]<=0)return null;Pe+=Math.log(Se[Re])}return Math.exp(Pe/Se.length)},harmean:(ye,ge)=>{const Se=u(ye,ge);if(!Se.length)return null;let Pe=0;for(let Re=0;Re<Se.length;Re++){if(Se[Re]===0)return null;Pe+=1/Se[Re]}return Se.length/Pe},sumSquares:(ye,ge)=>{const Se=u(ye,ge);let Pe=0;for(let Re=0;Re<Se.length;Re++)Pe+=Se[Re]*Se[Re];return Pe},passRate:(ye,ge)=>{const{pass:Se,judged:Pe}=v(ye,ge);return Pe?Se/Pe:null},failureCount:(ye,ge)=>v(ye,ge).fail}),S=Object.freeze({hhi:"Concentration (HHI)",entropy:"Entropy",evenness:"Evenness",top3Share:"Top 3 share",top10Share:"Top 10 share",gini:"Gini coefficient",trimmedMean:"Trimmed mean",winsorizedMean:"Winsorized mean",robustOutliers:"Outliers (robust)",jarqueBera:"Jarque–Bera",median:"Median",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function x(ye,ge,Se){const Pe=B(ye),Re=B(ge);let Be=0,_e=0;for(let be=0;be<Se.length;be++){const Ee=Se[be],ze=Number(Pe(Ee)),Ve=Number(Re(Ee));!Number.isFinite(ze)||!Number.isFinite(Ve)||(Be+=ze*Ve,_e+=Ve)}return _e===0?null:Be/_e}function C(ye,ge,Se){const Pe=B(ye);let Re=null,Be=Se?-1/0:1/0;for(let _e=0;_e<ge.length;_e++){const be=ge[_e],Ee=Number(Pe(be));Number.isFinite(Ee)&&(Se?Ee>Be:Ee<Be)&&(Be=Ee,Re=be)}return Re}function P(ye,ge,Se){const Pe=B(ye),Re=B(ge);let Be=0,_e=0,be=0,Ee=0,ze=0,Ve=0;for(let st=0;st<Se.length;st++){const wt=Se[st],kt=Number(Pe(wt)),mt=Number(Re(wt));!Number.isFinite(kt)||!Number.isFinite(mt)||(Be++,_e+=kt,be+=mt,Ee+=kt*kt,ze+=mt*mt,Ve+=kt*mt)}if(Be<2)return null;const Je=Be*Ve-_e*be,ot=Math.sqrt((Be*Ee-_e*_e)*(Be*ze-be*be));if(ot===0)return null;const at=Je/ot;return Math.max(-1,Math.min(1,at))}function F(ye,ge=.1){const Se=ye.length;if(!Se)return null;const Pe=Array.from(ye).sort((be,Ee)=>be-Ee),Re=Math.floor(Se*Math.min(.49,Math.max(0,ge))),Be=Pe.slice(Re,Se-Re);if(!Be.length)return k(Pe,.5);let _e=0;for(const be of Be)_e+=be;return _e/Be.length}function E(ye,ge=.1){const Se=ye.length;if(!Se)return null;const Pe=Array.from(ye).sort((Ee,ze)=>Ee-ze),Re=Math.floor(Se*Math.min(.49,Math.max(0,ge))),Be=Pe[Re],_e=Pe[Se-1-Re];let be=0;for(const Ee of Pe)be+=Math.min(_e,Math.max(Be,Ee));return be/Se}function D(ye,ge=3.5){if(!ye.length)return null;const Pe=Array.from(ye).sort((Ee,ze)=>Ee-ze),Re=k(Pe,.5),Be=Pe.map(Ee=>Math.abs(Ee-Re)).sort((Ee,ze)=>Ee-ze),_e=k(Be,.5);if(_e===0)return null;let be=0;for(const Ee of Pe)Math.abs(.6745*(Ee-Re)/_e)>ge&&be++;return be}function N(ye){const ge=ye.length;if(ge<8)return null;let Se=0;for(const Ee of ye)Se+=Ee;Se/=ge;let Pe=0,Re=0,Be=0;for(const Ee of ye){const ze=Ee-Se;Pe+=ze*ze,Re+=ze*ze*ze,Be+=ze*ze*ze*ze}if(Pe/=ge,Re/=ge,Be/=ge,Pe===0)return null;const _e=Re/Pe**1.5,be=Be/(Pe*Pe)-3;return ge/6*(_e*_e+be*be/4)}function M(ye,ge,Se){const Pe=[];let Re=0;for(let Ee=0;Ee<ye.length;Ee++){const ze=Number(ye[Ee]),Ve=Number(ge[Ee]);!Number.isFinite(ze)||!Number.isFinite(Ve)||Ve<=0||(Pe.push([ze,Ve]),Re+=Ve)}if(!Pe.length||Re<=0)return null;if(Pe.sort((Ee,ze)=>Ee[0]-ze[0]),Pe.length===1)return Pe[0][0];const Be=[];let _e=0;for(const[,Ee]of Pe)Be.push((_e+Ee/2)/Re),_e+=Ee;const be=Math.max(0,Math.min(1,Se));if(be<=Be[0])return Pe[0][0];if(be>=Be[Be.length-1])return Pe[Pe.length-1][0];for(let Ee=1;Ee<Be.length;Ee++){if(be>Be[Ee])continue;const ze=Be[Ee]-Be[Ee-1],Ve=ze>0?(be-Be[Ee-1])/ze:0;return Pe[Ee-1][0]+(Pe[Ee][0]-Pe[Ee-1][0])*Ve}return Pe[Pe.length-1][0]}function j(ye,ge,Se){const Pe=B(ye),Re=B(ge),Be=new Float64Array(Se.length),_e=new Float64Array(Se.length);let be=0;for(let Ee=0;Ee<Se.length;Ee++){const ze=Se[Ee],Ve=Number(Pe(ze)),Je=Number(Re(ze));!Number.isFinite(Ve)||!Number.isFinite(Je)||(Be[be]=Ve,_e[be]=Je,be++)}return{xs:Be.subarray(0,be),ys:_e.subarray(0,be),n:be}}function L(ye,ge,Se,Pe=!1){const{xs:Re,ys:Be,n:_e}=j(ye,ge,Se);if(_e<2)return null;let be=0,Ee=0;for(let Ve=0;Ve<_e;Ve++)be+=Re[Ve],Ee+=Be[Ve];be/=_e,Ee/=_e;let ze=0;for(let Ve=0;Ve<_e;Ve++)ze+=(Re[Ve]-be)*(Be[Ve]-Ee);return ze/(Pe?_e:_e-1)}function G(ye,ge,Se){const{xs:Pe,ys:Re,n:Be}=j(ye,ge,Se);if(Be<2)return null;let _e=0,be=0;for(let kt=0;kt<Be;kt++)_e+=Pe[kt],be+=Re[kt];_e/=Be,be/=Be;let Ee=0,ze=0,Ve=0;for(let kt=0;kt<Be;kt++){const mt=Pe[kt]-_e,Et=Re[kt]-be;Ee+=mt*mt,ze+=mt*Et,Ve+=Et*Et}if(Ee===0)return null;const Je=ze/Ee,ot=be-Je*_e,at=Ve===0?1:Math.max(0,Math.min(1,ze*ze/(Ee*Ve))),st=Math.max(0,Ve-Je*ze),wt=Be>2?Math.sqrt(st/(Be-2)/Ee):0;return{slope:Je,intercept:ot,r2:at,stdError:wt,n:Be}}const q=new Set(["ols","wls","robust"]),Y=new Set(["quantile"]),J=new Set(["ridge","lasso","elasticnet","mixed","gls"]),ee=1.345;function ne(ye,ge,Se){const{xtwx:Pe,xtwy:Re}=l(ye,ge,Se),Be=w(Pe);if(!Be)return null;const _e=A(Be,Re),be=g(Be),Ee=ie(ye,_e),ze=ge.map((Ve,Je)=>Ve-Ee[Je]);return{beta:_e,cov:be,fitted:Ee,residuals:ze}}function ie(ye,ge){return ye.map(Se=>Se.reduce((Pe,Re,Be)=>Pe+Re*ge[Be],0))}function se(ye,ge){const Se=ye.length,Pe=ye.map(ze=>ze[ge]),Re=ye.map(ze=>[1,...ze.filter((Ve,Je)=>Je!==ge)]),Be=ne(Re,Pe,null);if(!Be)return 1;const _e=Pe.reduce((ze,Ve)=>ze+Ve,0)/Se;let be=0,Ee=0;for(let ze=0;ze<Se;ze++)be+=Be.residuals[ze]**2,Ee+=(Pe[ze]-_e)**2;return Ee===0?1:Math.max(0,Math.min(1,1-be/Ee))}function he(ye){const ge=[...ye].sort((Re,Be)=>Re-Be),Se=ce(ge),Pe=ye.map(Re=>Math.abs(Re-Se)).sort((Re,Be)=>Re-Be);return ce(Pe)/.6745}function ce(ye){const ge=ye.length;if(!ge)return 0;const Se=Math.floor(ge/2);return ge%2?ye[Se]:(ye[Se-1]+ye[Se])/2}function te(ye,ge,Se={}){const Pe=Se.method||"ols";if(J.has(Pe))throw new Error(`[lattice] regression method "${Pe}" is out of scope; use ols, wls or robust.`);if(Y.has(Pe))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!q.has(Pe))throw new Error(`[lattice] unknown regression method "${Pe}"; use ols, wls or robust.`);const Re=Array.isArray(ge)?ge.length:0,Be=Re&&Array.isArray(ye[0])?ye[0].length:0,_e=Be+1;if(!(Re>_e))return null;for(let Tt=0;Tt<Re;Tt++){if(!Number.isFinite(ge[Tt])||!Array.isArray(ye[Tt])||ye[Tt].length!==Be)return null;for(let $t=0;$t<Be;$t++)if(!Number.isFinite(ye[Tt][$t]))return null}let be=null;if(Pe==="wls"){if(be=Se.weights,!Array.isArray(be)||be.length!==Re)return null;for(let Tt=0;Tt<Re;Tt++)if(!(be[Tt]>0)||!Number.isFinite(be[Tt]))return null}const Ee=ye.map(Tt=>[1,...Tt]);let ze,Ve=null;if(Pe==="robust"){if(ze=ne(Ee,ge,null),!ze)return null;for(let Tt=0;Tt<50;Tt++){const $t=he(ze.residuals);if(!($t>0))break;const Ut=ze.residuals.map(Yt=>{const Jt=Math.abs(Yt/$t);return Jt<=ee?1:ee/Jt}),Wt=ne(Ee,ge,Ut);if(!Wt)return null;const Qt=Wt.beta.reduce((Yt,Jt,rn)=>Math.max(Yt,Math.abs(Jt-ze.beta[rn])),0);if(ze=Wt,Ve=Ut,Qt<1e-10)break}}else if(ze=ne(Ee,ge,be),!ze)return null;const Je=Pe==="robust"?Ve:be,{beta:ot,cov:at,fitted:st,residuals:wt}=ze;let kt=0,mt=0,Et=0;for(let Tt=0;Tt<Re;Tt++){const $t=Je?Je[Tt]:1;kt+=$t*wt[Tt]**2,mt+=$t,Et+=$t*ge[Tt]}const Ke=Et/mt;let ht=0;for(let Tt=0;Tt<Re;Tt++){const $t=Je?Je[Tt]:1;ht+=$t*(ge[Tt]-Ke)**2}const it=Re-_e,ct=kt/it,St=ht===0?1:Math.max(0,Math.min(1,1-kt/ht)),Rt=1-(1-St)*(Re-1)/it,yt=Array.isArray(Se.names)&&Se.names.length===Be?Se.names:ye[0].map((Tt,$t)=>`x${$t+1}`),Nt=Pt(Se.confidence),zt=it>0?_(1-(1-Nt)/2,it):1/0,tn=ot.map((Tt,$t)=>{const Ut=Math.sqrt(Math.max(0,ct*at[$t][$t])),Wt=Ut>0?Tt/Ut:Tt===0?0:1/0,Qt=Number.isFinite(Wt)?2*(1-X(Math.abs(Wt),it)):0,Yt=Number.isFinite(zt)?zt*Ut:null;return{name:$t===0?"(intercept)":yt[$t-1],estimate:Tt,stdError:Ut,t:Wt,p:Math.max(0,Math.min(1,Qt)),lower:Yt===null?null:Tt-Yt,upper:Yt===null?null:Tt+Yt}}),mn=new Array(Re),an=new Array(Re);for(let Tt=0;Tt<Re;Tt++){const $t=Je?Je[Tt]:1,Ut=Math.max(0,Math.min(1,$t*d(Ee[Tt],at)));mn[Tt]=Ut;const Wt=(1-Ut)**2;an[Tt]=Wt>0&&ct>0?wt[Tt]**2/(_e*ct)*(Ut/Wt):null}const dn=ye[0].map((Tt,$t)=>{if(Be<2)return 1;const Ut=se(ye,$t);return Ut>=1?1/0:1/(1-Ut)});let qt=null;{const Tt=wt.map(Ut=>Ut*Ut),$t=ne(Ee,Tt,null);if($t){const Ut=Tt.reduce((en,cn)=>en+cn,0)/Re;let Wt=0,Qt=0;for(let en=0;en<Re;en++)Wt+=$t.residuals[en]**2,Qt+=(Tt[en]-Ut)**2;const Yt=Qt===0?0:Math.max(0,Math.min(1,1-Wt/Qt)),Jt=Re*Yt,rn=V(Jt,Be);qt={statistic:Jt,df:Be,p:rn,heteroscedastic:rn<.05}}}let _t=null;if(Be===1){const Tt=ye.map(($t,Ut)=>Ut).sort(($t,Ut)=>ye[$t][0]-ye[Ut][0]);_t={confidence:Nt,points:Tt.map($t=>{const Ut=Ee[$t],Wt=Math.sqrt(Math.max(0,ct*d(Ut,at)));return{x:ye[$t][0],yhat:st[$t],lower:st[$t]-zt*Wt,upper:st[$t]+zt*Wt}})}}return{method:Pe,coefficients:tn,r2:St,adjR2:Rt,n:Re,df:it,sigma2:ct,fitted:st,residuals:wt,leverage:mn,cooksD:an,vif:dn,heteroscedasticity:qt,band:_t,weights:Je?[...Je]:null}}function oe(ye){const ge=ye.length,Se=Array.from({length:ge},(Be,_e)=>_e).sort((Be,_e)=>ye[Be]-ye[_e]),Pe=new Float64Array(ge);let Re=0;for(;Re<ge;){let Be=Re;for(;Be+1<ge&&ye[Se[Be+1]]===ye[Se[Re]];)Be++;const _e=(Re+Be)/2+1;for(let be=Re;be<=Be;be++)Pe[Se[be]]=_e;Re=Be+1}return Pe}const fe=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function de(ye){const ge=[.01,.05,.1],Se=[fe["1%"],fe["5%"],fe["10%"]];if(ye<=Se[0]){const Be=(Math.log(ge[1])-Math.log(ge[0]))/(Se[1]-Se[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(ge[0])+Be*(ye-Se[0]))))}if(ye>=Se[2]){const Be=(Math.log(ge[2])-Math.log(ge[1]))/(Se[2]-Se[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(ge[2])+Be*(ye-Se[2]))))}const Pe=ye<Se[1]?0:1,Re=(ye-Se[Pe])/(Se[Pe+1]-Se[Pe]);return Math.exp(Math.log(ge[Pe])+Re*(Math.log(ge[Pe+1])-Math.log(ge[Pe])))}function ve(ye,ge,Se,Pe){const Re=Se-Pe,Be=Pe+3,_e=new Array(Re),be=new Array(Re);let Ee=!0,ze=Pe;for(let st=0;st<Re;st++){const wt=Pe+st,kt=new Float64Array(Be);kt[0]=1,kt[1]=st+1,kt[2]=ye[wt];for(let mt=1;mt<=Pe;mt++)kt[2+mt]=ge[wt-mt];for(let mt=1;mt<Be;mt++)Number.isFinite(kt[mt])||(ze=Math.min(ze,mt-3));_e[st]=kt,be[st]=ge[wt],Number.isFinite(be[st])||(Ee=!1)}if(!Ee)return 0;const{xtwx:Ve,xtwy:Je}=l(_e,be,null);let ot=0,at=1/0;for(let st=0;st<=ze;st++){const wt=st+3;if(!(Re>wt))continue;const kt=new Array(wt);for(let St=0;St<wt;St++)kt[St]=Ve[St].slice(0,wt);const mt=w(kt);if(!mt)continue;const Et=A(mt,Je.slice(0,wt));let Ke=0;for(let St=0;St<Re;St++){const Rt=_e[St];let yt=0;for(let Nt=0;Nt<wt;Nt++)yt+=Rt[Nt]*Et[Nt];Ke+=(be[St]-yt)**2}const it=Ke/(Re-wt)*(Re-wt);if(!(it>0))continue;const ct=Re*Math.log(it/Re)+2*wt;ct<at&&(at=ct,ot=st)}return ot}function Me(ye,ge={}){const Se=[];for(let at=0;at<ye.length;at++){const st=Number(ye[at]);Number.isFinite(st)&&Se.push(st)}const Pe=Se.length,Re=Pe-1;if(Pe<8||Re<6)return null;const Be=new Array(Re);for(let at=0;at<Re;at++)Be[at]=Se[at+1]-Se[at];let _e=Number.isFinite(ge.maxlag)?Math.floor(ge.maxlag):Math.ceil(12*(Pe/100)**.25);_e=Math.max(0,Math.min(_e,Math.floor((Re-5)/2)));const be=(at,st)=>{const wt=[],kt=[];for(let mt=st;mt<Re;mt++){const Et=[mt-st+1,Se[mt]];for(let Ke=1;Ke<=at;Ke++)Et.push(Be[mt-Ke]);wt.push(Et),kt.push(Be[mt])}return te(wt,kt,{method:"ols"})},Ee=ve(Se,Be,Re,_e),ze=be(Ee,Ee);if(!ze||!ze.coefficients[2])return null;const Ve=ze.coefficients[2].t,Je=de(Ve),ot=Ve<fe["5%"];return{statistic:Ve,usedLag:Ee,nobs:Re-Ee,criticalValues:{...fe},pValue:Je,pApproximate:!0,stationary:ot,verdict:ot?"stationary":"non-stationary",regression:"ct"}}function Oe(ye,ge={}){const Se=[];for(let ot=0;ot<ye.length;ot++){const at=Number(ye[ot]);Number.isFinite(at)&&Se.push(at)}const Pe=Se.length;if(Pe<3)return null;let Re=Number.isFinite(ge.maxlag)?Math.floor(ge.maxlag):Math.min(10,Pe-1);Re=Math.max(1,Math.min(Re,Pe-1));let Be=0;for(const ot of Se)Be+=ot;Be/=Pe;const _e=Se.map(ot=>ot-Be);let be=0;for(const ot of _e)be+=ot*ot;be/=Pe;const Ee=new Array(Re+1).fill(0);Ee[0]=1;for(let ot=1;ot<=Re;ot++){let at=0;for(let st=ot;st<Pe;st++)at+=_e[st]*_e[st-ot];Ee[ot]=be>0?at/Pe/be:0}const ze=new Array(Re+1).fill(0);ze[0]=1;let Ve=[];for(let ot=1;ot<=Re;ot++){let at=Ee[ot];for(let mt=1;mt<ot;mt++)at-=Ve[mt-1]*Ee[ot-mt];let st=1;for(let mt=1;mt<ot;mt++)st-=Ve[mt-1]*Ee[mt];const wt=st!==0?at/st:0,kt=new Array(ot);for(let mt=1;mt<ot;mt++)kt[mt-1]=Ve[mt-1]-wt*Ve[ot-1-mt];kt[ot-1]=wt,ze[ot]=wt,Ve=kt}const Je=1.96/Math.sqrt(Pe);return{acf:Ee,pacf:ze,bounds:{upper:Je,lower:-Je},n:Pe,nlags:Re,approximate:!0}}function Ce(ye,ge,Se){const{xs:Pe,ys:Re,n:Be}=j(ye,ge,Se);if(Be<2)return null;const _e=oe(Pe),be=oe(Re);let Ee=0,ze=0;for(let at=0;at<Be;at++)Ee+=_e[at],ze+=be[at];Ee/=Be,ze/=Be;let Ve=0,Je=0,ot=0;for(let at=0;at<Be;at++){const st=_e[at]-Ee,wt=be[at]-ze;Ve+=st*wt,Je+=st*st,ot+=wt*wt}return Je===0||ot===0?null:Math.max(-1,Math.min(1,Ve/Math.sqrt(Je*ot)))}function pe(ye,ge,Se){const{xs:Pe,ys:Re,n:Be}=j(ye,ge,Se);if(Be<2||Be>t)return null;let _e=0,be=0,Ee=0,ze=0;for(let ot=0;ot<Be;ot++)for(let at=ot+1;at<Be;at++){const st=Math.sign(Pe[ot]-Pe[at]),wt=Math.sign(Re[ot]-Re[at]),kt=st*wt;kt>0?_e++:kt<0?be++:st===0&&wt===0||(st===0?Ee++:ze++)}const Ve=_e+be+ze,Je=_e+be+Ee;return Ve===0||Je===0?null:(_e-be)/Math.sqrt(Ve*Je)}function we(ye,ge={}){const Se=ye.length;if(Se<2)return null;const Pe=ye[0],Re=ye[Se-1],Be=[];for(let mt=1;mt<Se;mt++){const Et=ye[mt-1];Et!==0&&Be.push((ye[mt]-Et)/Math.abs(Et))}let _e=null;if(Be.length>1){let mt=0;for(const Ke of Be)mt+=Ke;mt/=Be.length;let Et=0;for(const Ke of Be)Et+=(Ke-mt)**2;_e=Math.sqrt(Et/(Be.length-1))}const be=Number(ge.periodsPerYear)>0?Number(ge.periodsPerYear):null;let Ee=ye[0],ze=0,Ve=0,Je=0,ot=0;for(let mt=1;mt<Se;mt++){if(ye[mt]>Ee){Ee=ye[mt],ze=mt;continue}if(Ee<=0)continue;const Et=(Ee-ye[mt])/Ee;Et>Ve&&(Ve=Et,Je=ze,ot=mt)}let at=null;if(Se>2){let mt=0;for(let ht=0;ht<Se;ht++)mt+=ye[ht];mt/=Se;let Et=0,Ke=0;for(let ht=0;ht<Se;ht++){const it=ye[ht]-mt;Ke+=it*it,ht>0&&(Et+=it*(ye[ht-1]-mt))}at=Ke>0?Et/Ke:null}let st=0,wt=0;for(const mt of Be)mt>0?st++:mt<0&&wt++;let kt=null;if(Pe>0&&Re>0){const mt=(Re/Pe)**(1/(Se-1))-1;kt=be?(1+mt)**be-1:mt}return{n:Se,first:Pe,last:Re,change:Re-Pe,changePercent:Pe===0?null:(Re-Pe)/Math.abs(Pe)*100,volatility:_e,annualisedVolatility:_e!==null&&be?_e*Math.sqrt(be):null,growth:kt,maxDrawdown:Ve,maxDrawdownFrom:Je,maxDrawdownTo:ot,autocorrelation:at,upDays:st,downDays:wt}}const me=1.128,Ne=3.267;function $e(ye){const ge=ye.length;if(ge<2)return null;const Se=[];for(let Re=1;Re<ge;Re++)Se.push(Math.abs(ye[Re]-ye[Re-1]));const Pe=Se.reduce((Re,Be)=>Re+Be,0)/Se.length;return{ranges:Se,centre:Pe,upper:Ne*Pe,lower:0}}function He(ye){const ge=ye.length;if(ge<2)return null;let Se=0;for(let Re=1;Re<ge;Re++)Se+=Math.abs(ye[Re]-ye[Re-1]);const Pe=Se/(ge-1);return{sigma:Pe/me,meanRange:Pe}}function qe(ye,ge){const Se=ye.length;if(Se<2||!ge)return null;const Pe=Number.isFinite(Number(ge.lower))?Number(ge.lower):null,Re=Number.isFinite(Number(ge.upper))?Number(ge.upper):null;if(Pe===null&&Re===null)return null;let Be=0;for(let st=0;st<Se;st++)Be+=ye[st];Be/=Se;let _e=0;for(let st=0;st<Se;st++)_e+=(ye[st]-Be)**2;const be=Math.sqrt(_e/(Se-1)),Ee=He(ye),ze=Ee?Ee.sigma:null,Ve=st=>{if(!st||st<=0)return{index:null,k:null};const kt=Pe!==null&&Re!==null?(Re-Pe)/(6*st):null,mt=Re!==null?(Re-Be)/(3*st):1/0,Et=Pe!==null?(Be-Pe)/(3*st):1/0;return{index:kt,k:Math.min(mt,Et)}},Je=Ve(ze),ot=Ve(be);let at=0;for(let st=0;st<Se;st++){if(Pe!==null&&ye[st]<Pe){at++;continue}Re!==null&&ye[st]>Re&&at++}return{n:Se,mean:Be,lower:Pe,upper:Re,target:Number.isFinite(Number(ge.target))?Number(ge.target):null,sigmaWithin:ze,sigmaOverall:be,cp:Je.index,cpk:Je.k,pp:ot.index,ppk:ot.k,outOfSpec:at,defectRate:Se?at/Se:null}}function Ae(ye){const ge=ye.length;if(ge<2)return null;const Se=He(ye);if(!Se||!(Se.sigma>0))return null;let Pe=0;for(let Re=0;Re<ge;Re++)Pe+=ye[Re];return Pe/=ge,{centre:Pe,sigma:Se.sigma,upper:Pe+3*Se.sigma,lower:Pe-3*Se.sigma}}function Ge(ye,ge){if(!ge||!(ge.sigma>0))return[];const Se=ye.length,{centre:Pe,sigma:Re}=ge,Be=be=>(ye[be]-Pe)/Re,_e=[];for(let be=0;be<Se;be++){if(Math.abs(Be(be))>3&&_e.push({index:be,rule:1,description:"beyond three sigma"}),be>=2)for(const Ee of[1,-1]){let ze=0;for(let Ve=be-2;Ve<=be;Ve++)Be(Ve)*Ee>2&&ze++;if(ze>=2){_e.push({index:be,rule:2,description:"two of three past two sigma"});break}}if(be>=4)for(const Ee of[1,-1]){let ze=0;for(let Ve=be-4;Ve<=be;Ve++)Be(Ve)*Ee>1&&ze++;if(ze>=4){_e.push({index:be,rule:3,description:"four of five past one sigma"});break}}if(be>=7)for(const Ee of[1,-1]){let ze=!0;for(let Ve=be-7;Ve<=be;Ve++)if(Be(Ve)*Ee<=0){ze=!1;break}if(ze){_e.push({index:be,rule:4,description:"eight in a row on one side"});break}}}return _e}function Ze(ye,ge){if(!ge||!(ge.sigma>0))return[];const Se=ye.length,{centre:Pe,sigma:Re}=ge,Be=Ee=>(ye[Ee]-Pe)/Re,_e=(Ee,ze,Ve,Je)=>{for(const ot of[1,-1]){let at=0;for(let st=Ee;st<=ze;st++)Be(st)*ot>Ve&&at++;if(at>=Je)return!0}return!1},be=[];for(let Ee=0;Ee<Se;Ee++){if(Math.abs(Be(Ee))>3&&be.push({index:Ee,rule:1,description:"beyond three sigma"}),Ee>=8)for(const ze of[1,-1]){let Ve=!0;for(let Je=Ee-8;Je<=Ee;Je++)if(Be(Je)*ze<=0){Ve=!1;break}if(Ve){be.push({index:Ee,rule:2,description:"nine in a row on one side"});break}}if(Ee>=5)for(const ze of[1,-1]){let Ve=!0;for(let Je=Ee-4;Je<=Ee;Je++)if((ye[Je]-ye[Je-1])*ze<=0){Ve=!1;break}if(Ve){be.push({index:Ee,rule:3,description:ze>0?"six rising":"six falling"});break}}if(Ee>=13){let ze=!0;for(let Ve=Ee-12;Ve<=Ee;Ve++){const Je=ye[Ve]-ye[Ve-1],ot=ye[Ve+1<=Ee?Ve+1:Ve]-ye[Ve];if(Ve+1>Ee)break;if(Je===0||ot===0||Je>0==ot>0){ze=!1;break}}ze&&be.push({index:Ee,rule:4,description:"fourteen alternating"})}if(Ee>=2&&_e(Ee-2,Ee,2,2)&&be.push({index:Ee,rule:5,description:"two of three past two sigma"}),Ee>=4&&_e(Ee-4,Ee,1,4)&&be.push({index:Ee,rule:6,description:"four of five past one sigma"}),Ee>=14){let ze=!0;for(let Ve=Ee-14;Ve<=Ee;Ve++)if(Math.abs(Be(Ve))>=1){ze=!1;break}ze&&be.push({index:Ee,rule:7,description:"fifteen within one sigma"})}if(Ee>=7){let ze=!0;for(let Ve=Ee-7;Ve<=Ee;Ve++)if(Math.abs(Be(Ve))<=1){ze=!1;break}ze&&be.push({index:Ee,rule:8,description:"eight beyond one sigma"})}}return be}const nt=Object.freeze(["westernElectric","nelson"]);function lt(ye,ge,Se="westernElectric"){return String(Se)==="nelson"?Ze(ye,ge):Ge(ye,ge)}function ft(ye,ge,Se){let Pe=0;for(let Re=0;Re<ye.length;Re++)(ye[Re]<ge||ye[Re]>Se)&&Pe++;return Pe}function gt(ye,ge,Se,Pe=20){const Re=ye.length;if(!Re)return[];const Be=ye[0],_e=ye[Re-1];if(_e===Be)return[{from:Be,to:_e,count:Re}];const be=Se-ge,Ee=1.5*be;let ze=be>0?Math.max(Be,ge-Ee):Be,Ve=be>0?Math.min(_e,Se+Ee):_e;Ve>ze||(ze=Be,Ve=_e);const Je=be>0?2*be/Math.cbrt(Re):(Ve-ze)/(Math.ceil(Math.log2(Re))+1),ot=Je>0?Math.min(Pe,Math.max(1,Math.ceil((Ve-ze)/Je))):1,at=(Ve-ze)/ot,st=[];for(let wt=0;wt<ot;wt++)st.push({from:ze+wt*at,to:ze+(wt+1)*at,count:0});for(let wt=0;wt<Re;wt++){const kt=Math.min(ot-1,Math.max(0,Math.floor((ye[wt]-ze)/at)));st[kt].count++}return st[0].from=Be,st[ot-1].to=_e,st}const At=.95;function Pt(ye){const ge=Number(ye);return Number.isFinite(ge)&&ge>0&&ge<1?ge:At}function Ct(ye,ge=At){const Se=ye.length;if(Se<2)return null;let Pe=0;for(let Ve=0;Ve<Se;Ve++)Pe+=ye[Ve];const Re=Pe/Se;let Be=0;for(let Ve=0;Ve<Se;Ve++){const Je=ye[Ve]-Re;Be+=Je*Je}const _e=Math.sqrt(Be/(Se-1)),be=Pt(ge),ze=_(1-(1-be)/2,Se-1)*_e/Math.sqrt(Se);return{mean:Re,lower:Re-ze,upper:Re+ze,margin:ze,n:Se,confidence:be}}function Mt(ye,ge,Se=At){const Pe=Number(ye),Re=Number(ge);if(!(Re>0)||!(Pe>=0)||Pe>Re)return null;const Be=Pt(Se),_e=W(1-(1-Be)/2),be=Pe/Re,Ee=_e*_e,ze=1+Ee/Re,Ve=(be+Ee/(2*Re))/ze,Je=_e/ze*Math.sqrt(be*(1-be)/Re+Ee/(4*Re*Re));return{proportion:be,lower:Math.max(0,Ve-Je),upper:Math.min(1,Ve+Je),n:Re,confidence:Be}}function Dt(ye,ge=At){if(!ye||!(ye.n>2)||!Number.isFinite(ye.stdError))return null;const Se=Pt(ge),Re=_(1-(1-Se)/2,ye.n-2)*ye.stdError;return{slope:ye.slope,lower:ye.slope-Re,upper:ye.slope+Re,margin:Re,confidence:Se}}function Bt(ye,ge,Se=At){const Pe=Number(ye),Re=Number(ge);if(!Number.isFinite(Pe)||!(Re>1))return null;const Be=Pt(Se),be=W(1-(1-Be)/2)*Math.sqrt(1/(9*Re)+Pe*Pe/(2*(Re-1)));return{index:Pe,lower:Pe-be,upper:Pe+be,margin:be,n:Re,confidence:Be}}function dt(ye,ge){return!ye||!(ye.sd>0)||!Number.isFinite(ge)||!Number.isFinite(ye.mean)?null:(ge-ye.mean)/ye.sd}function rt(ye){return Number.isFinite(ye)?Math.min(1,Math.max(0,2*H(Math.abs(ye)/2)-1)):0}function le(ye,ge){const Se=new Map,Pe=B(ye);let Re=0;for(let Be=0;Be<ge.length;Be++){const _e=Pe(ge[Be]);if(_e==null||_e===""||typeof _e=="number"&&Number.isNaN(_e))continue;const be=_e instanceof Date?_e.getTime():typeof _e=="object"?String(_e):_e;Se.set(be,(Se.get(be)||0)+1),Re++}return{map:Se,total:Re}}function ke(ye,ge,Se,Pe){if(!(ge>0)||!(Pe>0))return null;let Re=0;const Be=new Set(ye.keys());for(const _e of Se.keys())Be.add(_e);for(const _e of Be){const be=(ye.get(_e)||0)/ge,Ee=(Se.get(_e)||0)/Pe;Re+=Math.abs(be-Ee)}return Re/2}const Le=10;function Ie(ye,ge,Se){if(Se&&Se.numeric){const be=u(ye,ge),{n:Ee,mean:ze}=O(be),Ve=Ee>0?dt({mean:Se.mean,sd:Se.sd},ze):null;return{measure:"standardizedMeanDifference",magnitude:Ve,distance:Ve===null?0:rt(Ve),direction:Ve===null?0:Math.sign(Ve),subsetN:Ee,populationN:Se.n||0,reliable:Ee>=Le}}const{map:Re,total:Be}=le(ye,ge),_e=ke(Re,Be,Se.map,Se.total);return{measure:"categoricalTotalVariation",magnitude:_e,distance:_e===null?0:_e,direction:0,subsetN:Be,populationN:Se.total||0,reliable:Be>=Le}}function De(ye,ge){if(ye&&(ye.kind==="float64"||ye.kind==="int32"))return!0;const Se=B(ye);let Pe=0,Re=0;for(let Be=0;Be<ge.length&&Pe<200;Be++){const _e=Se(ge[Be]);if(_e==null||_e==="")continue;if(_e instanceof Date)return!1;Pe++;const be=typeof _e=="number"?_e:Number(_e);Number.isFinite(be)&&Re++}return Pe===0?!1:Re/Pe>=.9}function Qe(ye,ge){if(De(ye,ge)){const Re=u(ye,ge),{n:Be,mean:_e,m2:be}=O(Re);return{numeric:!0,mean:_e,sd:Be>0?Math.sqrt(be/Be):0,n:Be}}const{map:Se,total:Pe}=le(ye,ge);return{numeric:!1,map:Se,total:Pe}}}),Fe("packages/core/src/compute/total.js",function(e,K){"use strict";Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"aggregatesFor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"aggregateAllowed",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return b}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,I=K("packages/core/src/compute/handle.js"),_=I.presenceReader,X=I.valueComparator,W=I.valueReader,H=K("packages/core/src/compute/statistics.js"),V=H.STAT_FNS,z=H.STAT_LABELS;function w(O){return!!O&&(O.kind==="float64"||O.kind==="int32")}function A(O,k){const y=k.length;let v=0;if(w(O)){const S=O.values,x=_(O);if(!x){for(let C=0;C<y;C++){const P=S[k[C]];Number.isNaN(P)||(v+=P)}return v}for(let C=0;C<y;C++){const P=k[C];if(x(P)===1){const F=S[P];Number.isNaN(F)||(v+=F)}}return v}const R=W(O);for(let S=0;S<y;S++){const x=h(R(k[S]));x!==null&&(v+=x)}return v}A.kernel=!0;function g(O,k){const y=k.length;let v=0;if(w(O)){const S=O.values,x=_(O);if(!x){for(let C=0;C<y;C++)Number.isNaN(S[k[C]])||v++;return v}for(let C=0;C<y;C++){const P=k[C];x(P)===1&&!Number.isNaN(S[P])&&v++}return v}const R=W(O);for(let S=0;S<y;S++){const x=R(k[S]);x!=null&&!(typeof x=="number"&&Number.isNaN(x))&&v++}return v}g.kernel=!0;function l(O,k){return k.length}l.kernel=!0;function d(O,k){const y=g(O,k);return y===0?null:A(O,k)/y}d.kernel=!0;function o(O,k,y,v){const R=k.length;if(w(O)){const P=O.values,F=_(O);let E=null;if(!F){for(let D=0;D<R;D++){const N=P[k[D]];Number.isNaN(N)||(E===null||(y<0?N<E:N>E))&&(E=N)}return E}for(let D=0;D<R;D++){const N=k[D];if(F(N)===0)continue;const M=P[N];Number.isNaN(M)||(E===null||(y<0?M<E:M>E))&&(E=M)}return E}const S=W(O),x=X(v);let C=null;for(let P=0;P<R;P++){const F=S(k[P]);F==null||typeof F=="number"&&Number.isNaN(F)||(C===null||(y<0?x(F,C)<0:x(F,C)>0))&&(C=F)}return C}function n(O,k,y){return o(O,k,-1,y&&y.locale)}n.kernel=!0;function t(O,k,y){return o(O,k,1,y&&y.locale)}t.kernel=!0;function r(O,k){return k.length===0?null:W(O)(k[0])}r.kernel=!0;function s(O,k){return k.length===0?null:W(O)(k[k.length-1])}s.kernel=!0;function h(O){if(typeof O=="number")return Number.isNaN(O)?null:O;if(O==null||O===""||typeof O=="boolean")return null;if(O instanceof Date)return O.getTime();const k=Number(O);return Number.isNaN(k)?null:k}const u={sum:A,min:n,max:t,avg:d,count:l,first:r,last:s,countValues:g,...V},i=Object.freeze({...z,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function m(O){return O?typeof O=="string"?i[O]||O:"Total":""}const c=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function f(O){const k=O&&O.dataType&&O.dataType.totals&&O.dataType.totals.supported;if(Array.isArray(k))return k.slice();const y=c.filter(v=>v in u);for(const v of Object.keys(u))y.includes(v)||y.push(v);return y}function a(O,k){return typeof k!="string"?!0:f(O).includes(k)}function p(O,k){const y=W(O),v=[];for(let R=0;R<k.length;R++){const S=y(k[R]);S!=null&&v.push(S)}return v}function b(O,k,y,v){const R=k||[];if(typeof y=="string"){const S=u[y];return S?S(O,R,v):(B(`total:${y}`,`unknown total function "${y}"; register it in config.totalFns`),null)}return $(y)?y.kernel===!0?y(O,R,v):y(p(O,R),v||{}):null}}),Fe("packages/core/src/compute/windowed.js",function(e,K){"use strict";Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const $=K("packages/core/src/compute/sketch.js").Welford;class B{#e;#t;#n=[];#r;#o;constructor(H,V=0,z=Date.now){if(H!=="count"&&H!=="time"&&H!=="session")throw new RangeError(`unknown window kind: ${H}`);if((H==="count"||H==="time")&&!(V>0))throw new RangeError(`a ${H} window needs a positive span`);this.#e=H,this.#t=Math.floor(V),this.#r=z,this.#o=z()}get size(){return this.#n.length}push(H,V=this.#r()){Number.isFinite(H)&&(this.#n.push({t:V,v:H}),this.#i(V))}#i(H){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const V=H-this.#t;for(;this.#n.length&&this.#n[0].t<V;)this.#n.shift()}}spec(){const H=this.#e==="session"?this.#r()-this.#o:this.#t;return{kind:this.#e,span:H,size:this.#n.length}}values(){return this.#n.map(H=>H.v)}aggregate(){const H=this.spec();if(!this.#n.length)return{over:H,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const V=new $;let z=0,w=1/0,A=-1/0;for(const{v:g}of this.#n)z+=g,g<w&&(w=g),g>A&&(A=g),V.add(g);return{over:H,count:this.#n.length,sum:z,mean:V.mean(),min:w,max:A,variance:V.variance(),stddev:V.stddev()}}reduce(H){const V=this.aggregate(),z={sum:V.sum,avg:V.mean,mean:V.mean,min:V.min,max:V.max,count:V.count,variance:V.variance,stddev:V.stddev};if(!(H in z))throw new RangeError(`unknown windowed aggregate: ${H}`);return{value:z[H],over:V.over}}}const I=Object.freeze(["count","time","session"]);function _(W,H=Date.now){const V=W.kind==="time"&&W.minutes!=null?W.minutes*6e4:W.span??0;return new B(W.kind,V,H)}const X={Window:B,WINDOW_KINDS:I,openWindow:_}}),Fe("packages/core/src/compute/rolling.js",function(e,K){"use strict";Object.defineProperty(e,"ROLLING_WINDOW_FIELDS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"rollingWindow",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"cumulativeToDate",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"periodOverPeriod",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"QUANTILE_SPAN_CAP",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"rollingQuantile",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"seasonalDecompose",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"exponentialSmoothing",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const $=K("packages/core/src/compute/windowed.js").openWindow,I=K("packages/core/src/compute/sketch.js").KLL,_=Object.freeze({rollingSum:"sum",rollingAvg:"avg",rollingMin:"min",rollingMax:"max"});function X(i,m,c,f){if(i.kind==="count"){const a=Math.max(1,Math.floor(i.span||0));return{coverage:Math.min(1,m/a),partial:m<a}}if(i.kind==="time"){const a=i.minutes!=null?i.minutes*6e4:i.span||0;if(!(a>0))return{coverage:1,partial:!1};const p=c-f;return{coverage:Math.min(1,p/a),partial:p<a}}return{coverage:null,partial:!1}}function W(i,m){const c=$(m),f=new Map,a=i.length?i[0].at:0;for(let p=0;p<i.length;p++){const{key:b,at:O,value:k}=i[p];Number.isFinite(k)&&c.push(k,O);const y=c.aggregate(),v=X(m,y.count,O,a);b!=null&&f.set(String(b),{sum:y.sum,avg:y.mean,min:y.min,max:y.max,count:y.count,coverage:v.coverage,partial:v.partial})}return f}function H(i){const m=new Map;let c=0;for(const{key:f,value:a}of i)Number.isFinite(a)&&(c+=a),f!=null&&m.set(String(f),c);return m}function V(i,m=1){const c=new Map,f=Math.max(1,Math.floor(m));for(let a=0;a<i.length;a++){const{key:p,value:b}=i[a];if(p==null)continue;const O=a>=f?i[a-f].value:null,k=Number.isFinite(b)?b:null,y=Number.isFinite(O)?O:null;c.set(String(p),k!==null&&y!==null?k-y:null)}return c}const z=4096;function w(i){let m=i>>>0;return()=>{m+=1831565813;let c=m;return c=Math.imul(c^c>>>15,c|1),c^=c+Math.imul(c^c>>>7,c|61),((c^c>>>14)>>>0)/4294967296}}function A(i,m){const c=i.length;if(c===1)return i[0];const f=(c-1)*m,a=Math.floor(f),p=Math.ceil(f);return a===p?i[a]:i[a]+(f-a)*(i[p]-i[a])}function g(i,m,c={}){const f=Math.min(1,Math.max(0,c.q==null?.5:c.q)),a=Math.max(1,Math.floor(c.cap==null?z:c.cap)),p=w(c.seed==null?2654435769:c.seed),b=new Map,O=i.length?i[0].at:0;if(m.kind==="session"){const y=new I(200,p);let v=0;for(const{key:R,value:S}of i)Number.isFinite(S)&&(y.add(S),v++),R!=null&&b.set(String(R),{value:v?y.quantile(f):null,approx:v>0,count:v,coverage:null,partial:!1});return b}const k=$(m);for(const{key:y,at:v,value:R}of i){Number.isFinite(R)&&k.push(R,v);const S=k.values(),x=S.length;let C=null,P=!1;if(x)if(x<=a)C=A([...S].sort((E,D)=>E-D),f);else{const E=new I(200,p);for(const D of S)E.add(D);C=E.quantile(f),P=!0}const F=X(m,x,v,O);y!=null&&b.set(String(y),{value:C,approx:P,count:x,coverage:F.coverage,partial:F.partial})}return b}function l(i,m){const c=i.length,f=new Array(c).fill(null),a=Math.floor(m/2),p=m%2===0;for(let b=0;b<c;b++){if(b-a<0||b+a>=c)continue;let O=0,k=!0;if(p)for(let y=-a;y<=a;y++){const v=i[b+y];if(!Number.isFinite(v)){k=!1;break}O+=y===-a||y===a?v*.5:v}else for(let y=-a;y<=a;y++){const v=i[b+y];if(!Number.isFinite(v)){k=!1;break}O+=v}k&&(f[b]=O/m)}return f}function d(i,m){const c=new Map,f=Math.floor(Number(m&&m.period));if(!(f>=2))return c;const a=m&&m.model==="multiplicative",p=i.length,b=i.map(P=>Number.isFinite(P.value)?P.value:null),O=l(b,f),k=new Array(p).fill(null);for(let P=0;P<p;P++){const F=O[P],E=b[P];F===null||E===null||(a?F!==0&&(k[P]=E/F):k[P]=E-F)}const y=new Array(f).fill(0),v=new Array(f).fill(0);for(let P=0;P<p;P++){if(k[P]===null)continue;const F=P%f;y[F]+=k[P],v[F]+=1}const R=a?1:0,S=y.map((P,F)=>v[F]?P/v[F]:R),x=S.reduce((P,F)=>P+F,0)/f,C=a?S.map(P=>x!==0?P/x:1):S.map(P=>P-x);for(let P=0;P<p;P++){const{key:F}=i[P];if(F==null)continue;const E=O[P],D=C[P%f],N=b[P];let M=null;E!==null&&N!==null&&(M=a?E*D!==0?N/(E*D):null:N-E-D),c.set(String(F),{trend:E,seasonal:N===null?null:D,residual:M,coverage:E===null?0:1,partial:E===null})}return c}function o(i,m,c,f=80){const a=(Math.sqrt(5)-1)/2;let p=m,b=c,O=b-a*(b-p),k=p+a*(b-p),y=i(O),v=i(k);for(let R=0;R<f;R++)y<v?(b=k,k=O,v=y,O=b-a*(b-p),y=i(O)):(p=O,O=k,y=v,k=p+a*(b-p),v=i(k));return(p+b)/2}const n=1e-4,t=1-1e-4;function r(i,m){const c=i.length,f=new Array(c).fill(null),a=new Array(c).fill(null);let p=null,b=0;for(let O=0;O<c;O++){const k=i[O];if(!Number.isFinite(k)){p!==null&&(a[O]=p,f[O]=p);continue}if(p===null){p=k,a[O]=k,f[O]=k;continue}a[O]=p,b+=(k-p)**2,p=m*k+(1-m)*p,f[O]=p}return{smoothed:f,fitted:a,sse:b}}function s(i,m,c){const f=i.length,a=new Array(f).fill(null),p=new Array(f).fill(null);let b=null,O=null,k=0;for(let y=0;y<f;y++){const v=i[y];if(!Number.isFinite(v)){b!==null&&(b+=O,a[y]=b);continue}if(b===null){b=v,a[y]=v;continue}if(O===null){O=v-b;const x=b+O;p[y]=x,k+=(v-x)**2;const C=b;b=m*v+(1-m)*(C+O),O=c*(b-C)+(1-c)*O,a[y]=b;continue}const R=b+O;p[y]=R,k+=(v-R)**2;const S=b;b=m*v+(1-m)*(S+O),O=c*(b-S)+(1-c)*O,a[y]=b}return{smoothed:a,fitted:p,sse:k}}function h(i,m={}){const c=new Map,f=m.method==="holt",a=i.map(R=>Number.isFinite(R.value)?R.value:null),p=a.filter(R=>R!==null).length,b=R=>Math.min(t,Math.max(n,R)),O=()=>{for(const{key:R}of i)R!=null&&c.set(String(R),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return c};if(p<(f?2:1))return O();let k=Number.isFinite(m.alpha)?b(m.alpha):null,y=f&&Number.isFinite(m.beta)?b(m.beta):null;if(f){if(k===null||y===null){let R=k===null?.5:k,S=y===null?.5:y;for(let x=0;x<6;x++)k===null&&(R=o(C=>s(a,C,S).sse,n,t)),y===null&&(S=o(C=>s(a,R,C).sse,n,t));k=k===null?R:k,y=y===null?S:y}}else k===null&&(k=o(R=>r(a,R).sse,n,t));const v=f?s(a,k,y):r(a,k);for(let R=0;R<i.length;R++){const{key:S}=i[R];S!=null&&c.set(String(S),{smoothed:v.smoothed[R],fitted:v.fitted[R],alpha:k,beta:f?y:null,sse:v.sse})}return c}const u={ROLLING_WINDOW_FIELDS:_,QUANTILE_SPAN_CAP:z,rollingWindow:W,rollingQuantile:g,cumulativeToDate:H,periodOverPeriod:V,seasonalDecompose:d,exponentialSmoothing:h}}),Fe("packages/core/src/compute/compare.js",function(e,K){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"pooledStandardMeanDifference",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"numericSummary",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"bothNumeric",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"compareColumnAcross",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"compareDatasets",{enumerable:!0,get:function(){return l}});const Q=K("packages/core/src/compute/statistics.js"),$=Q.numbers,B=Q.moments,I=Q.frequencyMap,_=Q.categoricalDistance,X=Q.normalTotalVariation,W=Q.isNumericColumn,H=Q.SUBSET_RELIABILITY_FLOOR,V=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function z(d,o){if(!d||!o||!(d.n>0)||!(o.n>0)||!Number.isFinite(d.mean)||!Number.isFinite(o.mean))return null;const n=(d.n*d.sd*d.sd+o.n*o.sd*o.sd)/(d.n+o.n);return n>0?(d.mean-o.mean)/Math.sqrt(n):null}function w(d,o){const n=$(d,o),{n:t,mean:r,m2:s}=B(n),h=t>0?Math.sqrt(s/t):0;return{mean:r,sd:h,n:t}}function A(d,o,n,t){return W(d,o)&&W(n,t)}function g(d,o,n,t){if(A(d,o,n,t)){const u=w(d,o),i=w(n,t),m=z(u,i);return{measure:V.numeric,magnitude:m,distance:m===null?0:X(m),direction:m===null?0:Math.sign(m),nA:u.n,nB:i.n,reliable:u.n>=H&&i.n>=H}}const r=I(d,o),s=I(n,t),h=_(r.map,r.total,s.map,s.total);return{measure:V.categorical,magnitude:h,distance:h===null?0:h,direction:0,nA:r.total,nB:s.total,reliable:r.total>=H&&s.total>=H}}function l(d,o,n={}){const t=new Set(d.columns),r=new Set(o.columns),s=d.columns.filter(c=>r.has(c)),h=Array.isArray(n.columns)&&n.columns.length?s.filter(c=>n.columns.includes(c)):s,u=d.indices(),i=o.indices(),m=[];for(const c of h){const f=d.handle(c),a=o.handle(c);if(!f||!a)continue;const p=g(f,u,a,i);m.push({column:c,name:d.name&&d.name(c)||o.name&&o.name(c)||c,measure:p.measure,magnitude:p.magnitude,distance:p.distance,direction:p.direction,nA:p.nA,nB:p.nB,reliable:p.reliable})}return m.sort((c,f)=>f.distance-c.distance||Math.abs(f.magnitude||0)-Math.abs(c.magnitude||0)),{ranked:m,nA:u.length,nB:i.length,unmatched:{onlyA:d.columns.filter(c=>!r.has(c)),onlyB:o.columns.filter(c=>!t.has(c))},measures:V}}}),Fe("packages/core/src/compute/anomaly.js",function(e,K){"use strict";Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"robustSpread",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return u}});const $=K("packages/core/src/compute/statistics.js").quantileSorted,I=K("packages/core/src/compute/special.js").logGamma,_=.6745,X=3.5,W=1.5,H=.975,V=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function z(i){if(!i.length)return null;const c=Array.from(i,Number).sort((b,O)=>b-O),f=$(c,.5),a=c.map(b=>Math.abs(b-f)).sort((b,O)=>b-O),p=$(a,.5);return{median:f,mad:p}}function w(i,m={}){const c=Number.isFinite(m.threshold)?m.threshold:X,f=i.length,a=new Array(f).fill(null),p=new Array(f).fill(!1),b=[];for(let y=0;y<f;y++){const v=Number(i[y]);Number.isFinite(v)&&b.push(v)}if(!b.length)return{median:null,mad:null,threshold:c,scores:a,flags:p,flagged:0};const O=z(b);if(O.mad===0)return{median:O.median,mad:0,threshold:c,scores:a,flags:p,flagged:0};let k=0;for(let y=0;y<f;y++){const v=Number(i[y]);if(!Number.isFinite(v))continue;const R=_*(v-O.median)/O.mad;a[y]=R,Math.abs(R)>c&&(p[y]=!0,k++)}return{median:O.median,mad:O.mad,threshold:c,scores:a,flags:p,flagged:k}}function A(i,m={}){const c=Number.isFinite(m.k)?m.k:W,f=[];for(let k=0;k<i.length;k++){const y=Number(i[k]);Number.isFinite(y)&&f.push(y)}if(!f.length)return null;const a=f.sort((k,y)=>k-y),p=$(a,.25),b=$(a,.75),O=b-p;return{q1:p,q3:b,iqr:O,lower:p-c*O,upper:b+c*O,k:c}}function g(i,m){if(m<=0)return 0;const c=I(i);if(m<i+1){let y=i,v=1/i,R=v;for(let S=0;S<1e3&&(y+=1,R*=m/y,v+=R,!(Math.abs(R)<Math.abs(v)*1e-15));S++);return v*Math.exp(-m+i*Math.log(m)-c)}const f=1e-300;let a=m+1-i,p=1/f,b=1/a,O=b;for(let y=1;y<1e3;y++){const v=-y*(y-i);a+=2,b=v*b+a,Math.abs(b)<f&&(b=f),p=a+v/p,Math.abs(p)<f&&(p=f),b=1/b;const R=b*p;if(O*=R,Math.abs(R-1)<1e-15)break}return 1-Math.exp(-m+i*Math.log(m)-c)*O}function l(i,m){return i<=0?0:g(m/2,i/2)}function d(i,m=H){if(!(m>0)||!(m<1))return NaN;let c=0,f=Math.max(1,i);for(;l(f,i)<m;)f*=2;for(let a=0;a<200;a++){const p=(c+f)/2;if(l(p,i)<m?c=p:f=p,f-c<1e-10)break}return(c+f)/2}function o(i){const m=i.length,c=i.map((f,a)=>{const p=f.slice();for(let b=0;b<m;b++)p.push(a===b?1:0);return p});for(let f=0;f<m;f++){let a=f;for(let b=f+1;b<m;b++)Math.abs(c[b][f])>Math.abs(c[a][f])&&(a=b);if(Math.abs(c[a][f])<1e-12)return null;if(a!==f){const b=c[a];c[a]=c[f],c[f]=b}const p=c[f][f];for(let b=0;b<2*m;b++)c[f][b]/=p;for(let b=0;b<m;b++){if(b===f)continue;const O=c[b][f];if(O!==0)for(let k=0;k<2*m;k++)c[b][k]-=O*c[f][k]}}return c.map(f=>f.slice(m))}function n(i,m){const c=i.length,f=new Array(m).fill(0);for(const b of i)for(let O=0;O<m;O++)f[O]+=b[O];for(let b=0;b<m;b++)f[b]/=c;const a=Array.from({length:m},()=>new Array(m).fill(0));for(const b of i)for(let O=0;O<m;O++){const k=b[O]-f[O];for(let y=O;y<m;y++)a[O][y]+=k*(b[y]-f[y])}const p=c>1?c-1:1;for(let b=0;b<m;b++)for(let O=b;O<m;O++)a[b][O]/=p,a[O][b]=a[b][O];return{mean:f,cov:a}}function t(i,m={}){const c=Number.isFinite(m.p)?m.p:H,f=Number.isFinite(m.ridge)?m.ridge:1e-6,a=i.length;if(!a)return null;const p=i[0].length;if(!p)return null;const b=new Array(a).fill(null),O=new Array(a).fill(null),k=new Array(a).fill(!1),y=[],v=[];for(let D=0;D<a;D++){const N=i[D];let M=N.length===p;const j=new Array(p);for(let L=0;M&&L<p;L++){const G=Number(N[L]);Number.isFinite(G)?j[L]=G:M=!1}M&&(y.push(D),v.push(j))}const R=p,S=d(R,c);if(v.length<=p)return{center:[],df:R,cutoff:S,singular:!0,used:v.length,distances:b,squared:O,flags:k,flagged:0};const{mean:x,cov:C}=n(v,p);let P=o(C),F=!1;if(!P){F=!0;let D=0;for(let j=0;j<p;j++)D+=C[j][j];const N=D/p*f||f,M=C.map((j,L)=>j.map((G,q)=>L===q?G+N:G));if(P=o(M),!P)return{center:x,df:R,cutoff:S,singular:!0,used:v.length,distances:b,squared:O,flags:k,flagged:0}}let E=0;for(let D=0;D<v.length;D++){const N=v[D],M=new Array(p);for(let G=0;G<p;G++)M[G]=N[G]-x[G];let j=0;for(let G=0;G<p;G++){let q=0;for(let Y=0;Y<p;Y++)q+=P[G][Y]*M[Y];j+=M[G]*q}j<0&&(j=0);const L=y[D];O[L]=j,b[L]=Math.sqrt(j),j>S&&(k[L]=!0,E++)}return{center:x,df:R,cutoff:S,singular:F,used:v.length,distances:b,squared:O,flags:k,flagged:E}}const r=20,s=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function h(i,m={}){const c=m.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",f=Number.isFinite(m.windowLen)&&m.windowLen>=1?Math.floor(m.windowLen):r,a=Number.isFinite(m.threshold)?m.threshold:X,p=Number.isFinite(m.k)?m.k:W,b=Number.isFinite(m.minPeriods)&&m.minPeriods>=1?Math.floor(m.minPeriods):f,O=i.length,k=new Array(O).fill(null),y=new Array(O).fill(!1);let v=0;for(let R=0;R<O;R++){const S=Number(i[R]);if(!Number.isFinite(S))continue;const x=Math.max(0,R-f+1),C=[];for(let P=x;P<=R;P++){const F=Number(i[P]);Number.isFinite(F)&&C.push(F)}if(!(C.length<b))if(c==="rollingIqr"){const P=A(C,{k:p});if(!P)continue;(S<P.lower||S>P.upper)&&(y[R]=!0,v++)}else{const P=z(C);if(!P||P.mad===0)continue;const F=_*(S-P.median)/P.mad;k[R]=F,Math.abs(F)>a&&(y[R]=!0,v++)}}return{method:c,windowLen:f,minPeriods:b,threshold:a,k:p,scores:k,flags:y,flagged:v}}function u(i={}){const m=i||{},c=m.field;if(typeof c!="string"||!c)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const f=m.method||"modifiedZScore";if(!(V.includes(f)||s.includes(f))||f==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${f}'`);const p=typeof m.orderBy=="string"?m.orderBy:null,b=m.latest===!0,O=s.includes(f),k=y=>Number(y==null?NaN:y[c]);return y=>{const v=Array.isArray(y)?y.slice():[...y];p&&v.sort((P,F)=>{const E=P?.[p],D=F?.[p];return E===D?0:E==null?-1:D==null?1:E<D?-1:1});const R=v.map(k);let S,x;if(O)({flags:S,scores:x}=h(R,{method:f,windowLen:m.windowLen,threshold:m.threshold,k:m.k,minPeriods:m.minPeriods}));else if(f==="iqr"){const P=A(R,{k:m.k});S=R.map(F=>P?Number.isFinite(F)&&(F<P.lower||F>P.upper):!1),x=R.map(()=>null)}else({flags:S,scores:x}=w(R,{threshold:m.threshold}));if(b){const P=S.length-1;return P<0||!S[P]?!1:{method:f,field:c,flagged:[{row:v[P],score:x[P]}]}}const C=[];for(let P=0;P<S.length;P++)S[P]&&C.push({row:v[P],score:x[P]});return C.length?{method:f,field:c,flagged:C}:!1}}}),Fe("packages/core/src/compute/forecast.js",function(e,K){"use strict";Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const Q=K("packages/core/src/compute/special.js"),$=Q.normalQuantile,B=Q.studentTQuantile,_=K("packages/core/src/internal/util.js").warnOnce,X=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),W=1e-4,H=1-1e-4;function V(m){const c=[];for(let f=0;f<m.length;f++){const a=m[f];if(a!==null&&typeof a=="object"){const p=Number.isFinite(a.at)?a.at:f,b=Number.isFinite(a.value)?a.value:null;c.push({at:p,value:b})}else c.push({at:f,value:Number.isFinite(a)?Number(a):null})}return c}function z(m){const c=m.filter(O=>O.value!==null),f=c[0],a=c[c.length-1],p=a.at-f.at,b=c.length>1&&p>0?p/(c.length-1):1;return{lastAt:a.at,step:b}}function w(m){return Math.min(H,Math.max(W,m))}function A(m,c=W,f=H,a=80){const p=(Math.sqrt(5)-1)/2;let b=c,O=f,k=O-p*(O-b),y=b+p*(O-b),v=m(k),R=m(y);for(let S=0;S<a;S++)v<R?(O=y,y=k,R=v,k=O-p*(O-b),v=m(k)):(b=k,k=y,v=R,y=b+p*(O-b),R=m(y));return(b+O)/2}function g(m,c){let f=null,a=0,p=0;for(let b=0;b<m.length;b++){const O=m[b];if(O!==null){if(f===null){f=O;continue}a+=(O-f)**2,p+=1,f=c*O+(1-c)*f}}return{level:f,sse:a,m:p}}function l(m,c,f){let a=null,p=null,b=0,O=0;for(let k=0;k<m.length;k++){const y=m[k];if(y===null){a!==null&&p!==null&&(a+=p);continue}if(a===null){a=y;continue}p===null&&(p=y-a);const v=a+p;b+=(y-v)**2,O+=1;const R=a;a=c*y+(1-c)*(R+p),p=f*(a-R)+(1-f)*p}return{level:a,trend:p,sse:b,m:O}}function d(m,c,f,a,p){const b=m.length;if(b<2*c)return null;const O=F=>{let E=0,D=0;for(let N=F;N<F+c&&N<b;N++)m[N]!==null&&(E+=m[N],D+=1);return D?E/D:null},k=O(0),y=O(c);if(k===null||y===null)return null;let v=k,R=(y-k)/c;const S=new Array(c).fill(0);for(let F=0;F<c;F++)S[F]=m[F]===null?0:m[F]-v;const x=S.reduce((F,E)=>F+E,0)/c;for(let F=0;F<c;F++)S[F]-=x;let C=0,P=0;for(let F=c;F<b;F++){const E=F%c,D=S[E],N=m[F];if(N===null){v+=R;continue}const M=v+R+D;C+=(N-M)**2,P+=1;const j=v;v=f*(N-D)+(1-f)*(v+R),R=a*(v-j)+(1-a)*R,S[E]=p*(N-v)+(1-p)*D}return{level:v,trend:R,season:S,phase:(b-1)%c,sse:C,count:P}}function o(m,c,f){let a=1;for(const b of c)a+=b*b;const p=Math.sqrt(m*a);return{se:p,margin:f*p}}function n(m,c={}){if(!m||typeof m.length!="number"||m.length===0)return null;const f=X.includes(c.method)?c.method:"linear",a=Math.max(1,Math.floor(Number(c.horizon)||1)),p=Number.isFinite(c.confidence)&&c.confidence>0&&c.confidence<1?c.confidence:.95,b=1-(1-p)/2,O=V(m),k=O.map(C=>C.value),y=k.filter(C=>C!==null),v=y.length,{lastAt:R,step:S}=v?z(O):{lastAt:0,step:1},x=C=>R+C*S;return f==="linear"?t(O,v,a,p,b,x):f==="movingAverage"?r(y,v,a,p,b,c,x):f==="ses"?s(k,v,a,p,b,c,x):f==="holt"?h(k,v,a,p,b,c,x):u(k,v,a,p,b,c,x)}function t(m,c,f,a,p,b){if(c<2)return null;let O=0,k=0;for(const N of m)N.value!==null&&(O+=N.at,k+=N.value);O/=c,k/=c;let y=0,v=0,R=0;for(const N of m){if(N.value===null)continue;const M=N.at-O,j=N.value-k;y+=M*M,v+=M*j,R+=j*j}if(y===0)return null;const S=v/y,x=k-S*O,C=R===0?1:Math.max(0,Math.min(1,v*v/(y*R))),P=Math.max(0,R-S*v),F=c>2?Math.sqrt(P/(c-2)):null,E=c>2?B(p,c-2):null,D=[];for(let N=1;N<=f;N++){const M=b(N),j=x+S*M;let L=null,G=null,q=null,Y=null,J=null;if(F!==null){const ee=1/c+(M-O)**2/y,ne=F*Math.sqrt(1+ee),ie=F*Math.sqrt(ee);J=ne,L=j-E*ne,G=j+E*ne,q=j-E*ie,Y=j+E*ie}D.push({step:N,at:M,mean:j,lower:L,upper:G,lowerMean:q,upperMean:Y,se:J})}return{method:"linear",horizon:f,confidence:a,n:c,sigma:F,r2:C,params:{slope:S,intercept:x},points:D}}function r(m,c,f,a,p,b,O){if(c<1)return null;const k=Math.max(1,Math.min(c,Math.floor(Number(b.windowLen)||c))),y=m.slice(c-k);let v=0;for(const F of y)v+=F;const R=v/k;let S=null,x=null;if(k>1){let F=0;for(const D of y)F+=(D-R)**2;S=Math.sqrt(F/(k-1))*Math.sqrt(1+1/k),x=B(p,k-1)}const C=S===null?null:x*S,P=[];for(let F=1;F<=f;F++)P.push({step:F,at:O(F),mean:R,lower:C===null?null:R-C,upper:C===null?null:R+C,se:S});return{method:"movingAverage",horizon:f,confidence:a,n:c,sigma:S===null?null:S,params:{windowLen:k},points:P}}function s(m,c,f,a,p,b,O){if(c<1)return null;let k=Number.isFinite(b.alpha)?w(b.alpha):null;k===null&&(k=A(x=>g(m,x).sse));const y=g(m,k),v=$(p),R=y.m>0?y.sse/y.m:null,S=[];for(let x=1;x<=f;x++){const C=y.level;let P=null,F=null,E=null;if(R!==null){const D=[];for(let M=1;M<x;M++)D.push(k);const N=o(R,D,v);E=N.se,P=C-N.margin,F=C+N.margin}S.push({step:x,at:O(x),mean:C,lower:P,upper:F,se:E})}return{method:"ses",horizon:f,confidence:a,n:c,sigma:R===null?null:Math.sqrt(R),params:{alpha:k},points:S}}function h(m,c,f,a,p,b,O){if(c<2)return null;let k=Number.isFinite(b.alpha)?w(b.alpha):null,y=Number.isFinite(b.beta)?w(b.beta):null;if(k===null||y===null){let P=k===null?.5:k,F=y===null?.5:y;for(let E=0;E<6;E++)k===null&&(P=A(D=>l(m,D,F).sse)),y===null&&(F=A(D=>l(m,P,D).sse));k=k===null?P:k,y=y===null?F:y}const v=l(m,k,y),R=$(p),S=v.m>0?v.sse/v.m:null,x=k*y,C=[];for(let P=1;P<=f;P++){const F=v.level+P*v.trend;let E=null,D=null,N=null;if(S!==null){const M=[];for(let L=1;L<P;L++)M.push(k+L*x);const j=o(S,M,R);N=j.se,E=F-j.margin,D=F+j.margin}C.push({step:P,at:O(P),mean:F,lower:E,upper:D,se:N})}return{method:"holt",horizon:f,confidence:a,n:c,sigma:S===null?null:Math.sqrt(S),params:{alpha:k,beta:y},points:C}}function u(m,c,f,a,p,b,O){const k=Math.floor(Number(b.period));if(!(k>=2))return _("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(c<2*k)return null;let y=Number.isFinite(b.alpha)?w(b.alpha):null,v=Number.isFinite(b.beta)?w(b.beta):null,R=Number.isFinite(b.gamma)?w(b.gamma):null;const S=(N,M,j)=>{const L=d(m,k,N,M,j);return L?L.sse:1/0};if(y===null||v===null||R===null){let N=y===null?.5:y,M=v===null?.5:v,j=R===null?.5:R;for(let L=0;L<8;L++)y===null&&(N=A(G=>S(G,M,j))),v===null&&(M=A(G=>S(N,G,j))),R===null&&(j=A(G=>S(N,M,G)));y=y===null?N:y,v=v===null?M:v,R=R===null?j:R}const x=d(m,k,y,v,R);if(!x)return null;const C=$(p),P=x.count>0?x.sse/x.count:null,F=y*v,E=R*(1-y),D=[];for(let N=1;N<=f;N++){const M=x.season[(x.phase+N)%k],j=x.level+N*x.trend+M;let L=null,G=null,q=null;if(P!==null){const Y=[];for(let ee=1;ee<N;ee++)Y.push(y+ee*F+(ee%k===0?E:0));const J=o(P,Y,C);q=J.se,L=j-J.margin,G=j+J.margin}D.push({step:N,at:O(N),mean:j,lower:L,upper:G,se:q})}return{method:"holtWinters",horizon:f,confidence:a,n:c,sigma:P===null?null:Math.sqrt(P),params:{alpha:y,beta:v,gamma:R,period:k},points:D}}const i={FORECAST_METHODS:X,forecast:n}}),Fe("packages/core/src/compute/hypothesis.js",function(e,K){"use strict";Object.defineProperty(e,"GROUP_TESTS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"NORMALITY_ALPHA",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"HL_PAIR_LIMIT",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"welchTTest",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"mannWhitneyUTest",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"chiSquareTest",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"compareGroups",{enumerable:!0,get:function(){return C}});const $=K("packages/core/src/internal/util.js").warnOnce,I=K("packages/core/src/compute/handle.js").valueReader,_=K("packages/core/src/compute/statistics.js"),X=_.numbers,W=_.moments,H=_.frequencyMap,V=_.categoricalDistance,z=_.isNumericColumn,w=_.jarqueBera,A=_.proportionInterval,g=_.SUBSET_RELIABILITY_FLOOR,d=K("packages/core/src/compute/compare.js").pooledStandardMeanDifference,o=K("packages/core/src/compute/special.js"),n=o.studentT,t=o.studentTQuantile,r=o.normalCdf,s=o.normalQuantile,h=o.chiSquareUpperTail,u=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),i=.05,m=2e6;function c(P){const F=Number(P);return Number.isFinite(F)&&F>0&&F<1?F:.95}function f(P){const{n:F,mean:E,m2:D}=W(P);return{mean:E,sd:F>0?Math.sqrt(D/F):0,n:F}}function a(P,F){const E=P.length;if(E<2)return 0;let D=0;for(let N=0;N<E;N++){const M=P[N]-F;D+=M*M}return D/(E-1)}function p(P,F){return{name:"pooledStandardMeanDifference",value:d(f(P),f(F))}}function b(P,F,E){const D=P.length,N=F.length;if(D<2||N<2)return null;const M=c(E),{mean:j}=W(P),{mean:L}=W(F),G=a(P,j),q=a(F,L),Y=G/D+q/N;if(!(Y>0))return null;const J=Math.sqrt(Y),ee=(j-L)/J,ne=G/D*(G/D)/(D-1),ie=q/N*(q/N)/(N-1),se=Y*Y/(ne+ie),he=Math.min(1,Math.max(0,2*(1-n(Math.abs(ee),se)))),ce=j-L,te=t(1-(1-M)/2,se)*J;return{test:u.WELCH,statistic:ee,statisticName:"t",df:se,pValue:he,interval:{estimate:ce,lower:ce-te,upper:ce+te,confidence:M,method:"welch-t (difference of means)"},effectSize:p(P,F),nA:D,nB:N,reliable:D>=g&&N>=g,method:"Welch's t-test (unequal variances; Welch–Satterthwaite df)"}}function O(P){const F=P.length;if(F===0)return Number.NaN;const E=F>>1;return F%2?P[E]:(P[E-1]+P[E])/2}function k(P,F,E){const D=P.length,N=F.length,M=D*N;if(M===0||M>m)return null;const j=new Float64Array(M);let L=0;for(let ne=0;ne<D;ne++)for(let ie=0;ie<N;ie++)j[L++]=P[ne]-F[ie];j.sort();const G=O(j),q=Math.sqrt(D*N*(D+N+1)/12),Y=s(1-(1-E)/2);let J=Math.round(M/2-Y*q);J>=0||(J=0);const ee=Math.floor((M-1)/2);return J>ee&&(J=ee),{estimate:G,lower:j[J],upper:j[M-1-J],confidence:E,method:"hodges-lehmann (normal approximation)"}}function y(P,F,E){const D=P.length,N=F.length;if(D<1||N<1)return null;const M=c(E),j=D+N,L=new Array(j);for(let he=0;he<D;he++)L[he]={v:P[he],g:0};for(let he=0;he<N;he++)L[D+he]={v:F[he],g:1};L.sort((he,ce)=>he.v-ce.v);let G=0,q=0,Y=0;for(;Y<j;){let he=Y;for(;he<j&&L[he].v===L[Y].v;)he++;const ce=he-Y,te=(Y+1+he)/2;for(let oe=Y;oe<he;oe++)L[oe].g===0&&(G+=te);q+=ce*ce*ce-ce,Y=he}const J=G-D*(D+1)/2,ee=D*N/2,ne=D*N/12*(j+1-q/(j*(j-1)));let ie=1;if(ne>0){const he=Math.max(0,Math.abs(J-ee)-.5);ie=Math.min(1,2*r(-he/Math.sqrt(ne)))}const se=k(P,F,M);return{test:u.MANN_WHITNEY,statistic:J,statisticName:"U",df:null,pValue:ie,interval:se,effectSize:p(P,F),nA:D,nB:N,reliable:D>=g&&N>=g,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function v(P,F,E,D,N){const M=A(P,F,N),j=A(E,D,N);if(!M||!j)return null;const L=M.proportion-j.proportion,G=L-Math.sqrt((M.proportion-M.lower)**2+(j.upper-j.proportion)**2),q=L+Math.sqrt((M.upper-M.proportion)**2+(j.proportion-j.lower)**2);return{lower:G,upper:q}}function R(P,F,E,D,N,M={}){if(!(F>0)||!(D>0))return null;const j=new Set([...P.keys(),...E.keys()]),L=j.size;if(L<2)return null;const G=F+D;let q=0;for(const ie of j){const se=P.get(ie)||0,he=E.get(ie)||0,ce=se+he,te=F*ce/G,oe=D*ce/G;te>0&&(q+=(se-te)*(se-te)/te),oe>0&&(q+=(he-oe)*(he-oe)/oe)}const Y=L-1,J=h(q,Y);let ee=null;M.category!==void 0&&j.has(M.category)?ee=M.category:L===2&&([ee]=[...j]);let ne=null;if(ee!==null){const ie=v(P.get(ee)||0,F,E.get(ee)||0,D,c(N));ie&&(ne={estimate:(P.get(ee)||0)/F-(E.get(ee)||0)/D,lower:ie.lower,upper:ie.upper,confidence:c(N),method:"newcombe (difference in this category's share)",category:ee})}return{test:u.CHI_SQUARE,statistic:q,statisticName:"chiSquare",df:Y,pValue:J,interval:ne,effectSize:{name:"categoricalTotalVariation",value:V(P,F,E,D)},nA:F,nB:D,reliable:F>=g&&D>=g,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function S(P){return P==null||P===""||typeof P=="number"&&Number.isNaN(P)?null:P instanceof Date?P.getTime():typeof P=="object"?String(P):P}function x(P,F,E){if(E===u.WELCH||E===u.MANN_WHITNEY)return{test:E,chosenBy:"override",reason:`caller override: ${E}`};const D=w(P),N=w(F),M=D===null?null:Math.exp(-D/2),j=N===null?null:Math.exp(-N/2);return M!==null&&M<i||j!==null&&j<i?{test:u.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${i})`}:{test:u.WELCH,chosenBy:"auto",reason:M!==null||j!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function C(P,F,E,D={}){if(!P||!F)return null;const N=c(D.confidence),M=I(F);let j;if(Array.isArray(D.groups)&&D.groups.length===2)j=[S(D.groups[0]),S(D.groups[1])];else{const{map:he}=H(F,E),ce=[...he.entries()].sort((te,oe)=>oe[1]-te[1]).slice(0,2).map(te=>te[0]);if(ce.length<2)return $("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;j=ce}const[L,G]=j;if(L===null||G===null||L===G)return $("compareGroups:distinct","[lattice] compareGroups: the two groups must be two distinct, present values."),null;const q=[],Y=[];for(let he=0;he<E.length;he++){const ce=S(M(E[he]));ce===L?q.push(E[he]):ce===G&&Y.push(E[he])}if(q.length===0||Y.length===0)return $("compareGroups:empty","[lattice] compareGroups: one of the two groups has no rows in the current set."),null;const J=D.test&&D.test!=="auto"?String(D.test):null,ee=z(P,q.concat(Y));let ne,ie,se;if(J===u.CHI_SQUARE||!J&&!ee){ie=J?"override":"auto",se=J?"caller override: chiSquare":"column family: categorical";const he=H(P,q),ce=H(P,Y);ne=R(he.map,he.total,ce.map,ce.total,N,{category:D.category})}else{if((J===u.WELCH||J===u.MANN_WHITNEY)&&!ee)return $("compareGroups:numeric-override",`[lattice] compareGroups: ${J} needs a numeric column, but the column is not numeric.`),null;const he=X(P,q),ce=X(P,Y),te=x(he,ce,J);ie=te.chosenBy,se=te.reason,ne=te.test===u.MANN_WHITNEY?y(he,ce,N):b(he,ce,N)}return ne?{...ne,chosenBy:ie,reason:se,groups:[L,G]}:($("compareGroups:degenerate","[lattice] compareGroups: the chosen test had too little to work with (too few values, or no variation)."),null)}}),Fe("packages/core/src/columns/detailcolumn.js",function(e,K){"use strict";Object.defineProperty(e,"DETAIL_COLUMN_ID",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"createDetailColumn",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return I}});const Q="__lattice_detail",$=36;function B(_){const X=_.config&&_.config.detailColumnWidth||$;return{id:Q,field:null,title:"",type:"text",dataType:{base:"text"},nullable:!0,align:"center",generated:!0,control:!0,detailExpander:!0,value:{pure:!0},cell:{render:"detailExpander",align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:X,min:X,max:X,pin:_.config&&_.config.detailColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(W,H){return!!(H&&H.expanded)},formatValue(){return""}}}const I=B}),Fe("packages/core/src/columns/treecolumn.js",function(e,K){"use strict";Object.defineProperty(e,"TREE_COLUMN_ID",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createTreeColumn",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const $=K("packages/core/src/internal/util.js").isFunction,B="__lattice_tree",I=260;function _(W){const H=W.tree||{},V=W.config&&W.config.treeColumnWidth||I,z=()=>(W.columns&&$(W.columns.visible)?W.columns.visible():[]).find(l=>!l.generated)||null,w=(g,l)=>{if(l&&l.group)return l.groupValue;if($(H.label))return H.label(g,l);if(typeof H.label=="string")return g==null?null:g[H.label];const d=z();return d&&$(d.getValue)?d.getValue(g,l):null},A=()=>{if(H.title)return H.title;const g=typeof H.label=="string"?W.columns&&$(W.columns.get)?W.columns.get(H.label):null:z();return g&&(g.title||g.id)||"Hierarchy"};return{id:B,get title(){return A()},field:null,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group"},edit:{enabled:!1},sort:{enabled:!0,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:V,min:140,pin:W.config&&W.config.treeColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(g,l){return w(g,l)},formatValue(g,l){if(l&&l.grandTotal)return W.config&&W.config.grandTotalLabel||"Total";if(g==null)return"";if(!H.label){const d=z();if(d&&$(d.formatValue))return d.formatValue(g,l)}return String(g)}}}const X=_}),Fe("packages/core/src/columns/pivotcolumns.js",function(e,K){"use strict";Object.defineProperty(e,"PIVOT_PREFIX",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createPivotColumns",{enumerable:!0,get:function(){return _}});const $=K("packages/core/src/internal/util.js").warnOnce,B="__lattice_pivot",I=500;function _(V){const{pivot:z,valueColumns:w,config:A}=V,g=z&&z.paths||[],l=V.separator||A&&A.pivot&&A.pivot.separator||" | ",d=A&&A.pivot&&A.pivot.maxColumns||I;if(!g.length||!w.length)return{tree:[],leaves:[],error:null};const o=X(A),n=g.length*w.length+(o?w.length:0);if(n>d){const s=`pivot would generate ${n} columns, above the limit of ${d}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return $(`pivot.maxColumns:${n}`,s),{tree:[],leaves:[],error:s}}const t=[],r=[];for(const s of g){const h=[];for(const u of w){const i=H(s,u,l);h.push(i),r.push(i)}h.length===1?(h[0].title=String(s),t.push(h[0])):t.push({id:`${B}:group:${s}`,title:String(s),columns:h,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(o){const s=w.map(u=>W(u,A));r.push(...s);const h=A&&A.pivot&&A.pivot.totalsLabel||"Total";if(s.length===1)s[0].title=h,o==="before"?t.unshift(s[0]):t.push(s[0]);else{const u={id:`${B}:group:__totals`,title:h,columns:s,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};o==="before"?t.unshift(u):t.push(u)}}return{tree:t,leaves:r,error:null}}function X(V){const z=V&&V.pivot&&V.pivot.groupTotals;return z==="before"||z==="after"?z:null}function W(V,z){return{id:`${B}:__total${z&&z.pivot&&z.pivot.separator||" | "}${V.id}`,field:null,title:V.title||V.id,type:V.type,dataType:V.dataType,nullable:!0,align:V.align,generated:!0,pivot:{enabled:!1,index:0,sourceId:V.id,total:!0},value:{pure:!0},cell:{align:V.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:V.total,lookup:null,layout:{width:V.layout&&V.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(w,A){const g=A&&A.totals;return g&&Object.hasOwn(g,V.id)?g[V.id]:null},formatValue(w,A){return w==null?"":V.formatValue?V.formatValue(w,A):String(w)}}}function H(V,z,w){return{id:`${B}:${V}${w}${z.id}`,field:null,title:z.title||z.id,type:z.type,dataType:z.dataType,nullable:!0,align:z.align,generated:!0,pivot:{enabled:!1,index:0,path:V,sourceId:z.id},value:{pure:!0},cell:{align:z.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:z.total,lookup:null,layout:{width:z.layout&&z.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(){return null},formatValue(A,g){return A==null?"":z.formatValue?z.formatValue(A,g):String(A)}}}}),Fe("packages/core/src/compute/group.js",function(e,K){"use strict";Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return A}});const Q=K("packages/core/src/compute/handle.js"),$=Q.dictSize,B=Q.identity,I=Q.presenceReader,_=Q.rowCount,X=Q.valueReader,W="",H="\0",V=1<<20;function z(g,l,d,o){const n=g.length,t=g.map(m=>X(m)),r=Array.isArray(o)&&o.some(Boolean),s=r?t.map((m,c)=>o[c]?f=>o[c](m(f)):m):t;if(!r&&n>0&&g.every(m=>m&&m.kind==="dictionary"&&m.dict)){const m=g.map(f=>$(f.dict)+1);let c=1;for(let f=0;f<n;f++)c*=m[f];if(c<=Number.MAX_SAFE_INTEGER){const f=g.map(O=>O.values),a=g.map(O=>I(O)),p=O=>{let k=0;for(let y=0;y<n;y++){const v=a[y],R=v&&v(O)===0?m[y]-1:f[y][O];k=k*m[y]+R}return k},b=new Float64Array(d);for(let O=0;O<d;O++)b[O]=p(l[O]);return{packed:b,strings:null,product:c,readers:s,keyOf:p}}}const u=m=>{let c="";for(let f=0;f<n;f++){const a=s[f](m);c+=(f===0?"":W)+(a==null?H:String(a))}return c},i=new Array(d);for(let m=0;m<d;m++)i[m]=u(l[m]);return{packed:null,strings:i,product:1/0,readers:s,keyOf:u}}function w(g,l,d,o){const n=new Uint32Array(o+1);for(let h=0;h<d;h++)n[l[h]+1]++;for(let h=0;h<o;h++)n[h+1]+=n[h];const t=new Uint32Array(d),r=n.slice(0,o);for(let h=0;h<d;h++)t[r[l[h]]++]=g[h];const s=new Array(o);for(let h=0;h<o;h++)s[h]=t.subarray(n[h],n[h+1]);return s}function A(g,l,d={}){const o=g||[],n=l||B(_(o[0],d)),t=n.length;if(o.length===0||t===0)return{keys:[],buckets:[]};const{packed:r,strings:s,product:h,readers:u}=z(o,n,t,d.project),i=new Uint32Array(t);let m=0,c=null;if(r&&h<=Math.max(1024,Math.min(V,t*4))){const b=h,O=new Int32Array(b).fill(-1);for(let k=0;k<t;k++)O[r[k]]=0;for(let k=0;k<b;k++)O[k]===0&&(O[k]=m++);for(let k=0;k<t;k++)i[k]=O[r[k]];c=new Float64Array(m);for(let k=0;k<b;k++)O[k]>=0&&(c[O[k]]=k)}else if(r){const b=new Map;for(let O=0;O<t;O++){const k=r[O];let y=b.get(k);y===void 0&&(y=m++,b.set(k,y)),i[O]=y}c=new Float64Array(m);for(const[O,k]of b)c[k]=O}else{const b=new Map;for(let O=0;O<t;O++){const k=s[O];let y=b.get(k);y===void 0&&(y=m++,b.set(k,y)),i[O]=y}}const f=w(n,i,t,m),a=new Array(m);for(let b=0;b<m;b++){const O=f[b][0],k=new Array(u.length);for(let y=0;y<u.length;y++)k[y]=u[y](O);a[b]=k}const p={keys:a,buckets:f};return c&&(p.packed=c),p}}),Fe("packages/core/src/compute/pivot.js",function(e,K){"use strict";Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return t}});const $=K("packages/core/src/internal/util.js").warnOnce,I=K("packages/core/src/compute/handle.js").valueComparator,X=K("packages/core/src/compute/group.js").packKeys,H=K("packages/core/src/compute/total.js").total,V="|",z="/",w=2e3;function A(h,u,i){return`${h}${V}${u}${V}${i}`}function g(h,u){let i="";for(let m=0;m<h.length;m++){const c=h[m];i+=(m===0?"":u)+(c==null?"":String(c))}return i}function l(h,u,i={}){const m=i.separator||z,c=u.length,{keyOf:f,readers:a}=X(h,u,0),p=new Map,b=[],O=[];for(let C=0;C<c;C++){const P=u[C],F=f(P);if(p.has(F))continue;p.set(F,b.length),O.push(F);const E=new Array(a.length);for(let D=0;D<a.length;D++)E[D]=a[D](P);b.push(E)}const k=I(i.locale),y=b.map((C,P)=>P);y.sort((C,P)=>{const F=b[C],E=b[P];for(let D=0;D<F.length;D++){const N=d(F[D],E[D],k);if(N!==0)return N}return C-P});const v=new Array(y.length),R=new Array(y.length),S=new Map;for(let C=0;C<y.length;C++){const P=y[C];v[C]=b[P],R[C]=g(b[P],m),S.set(O[P],C)}return{keys:v,paths:R,idOf:C=>{const P=S.get(f(C));return P===void 0?-1:P}}}function d(h,u,i){const m=h==null,c=u==null;return m||c?m&&c?0:m?1:-1:i(h,u)}function o(h){const u=h.values||h.totals||[];if(u.length&&typeof u[0]=="object"&&u[0]!==null)return u.filter(f=>f&&f.handle);const i=typeof h.handle=="function"?h.handle:null;if(!i)return u.length&&$("pivot:handles","pivot was given total column ids but no handle(colId) resolver, so no cell values were reduced. Pass values: [{ colId, handle, fn }] or opts.handle."),[];const m=typeof h.totalOf=="function"?h.totalOf:null,c=[];for(const f of u){const a=i(f);a&&c.push({colId:f,handle:a,fn:m?m(f):"sum"})}return c}function n(h,u,i){if(Array.isArray(h)){const m=i||{};return{...m,pivotHandles:h,order:u||null,groups:m.groups||null}}return h||{}}function t(h,u,i){const m=n(h,u,i),c=m.separator||z,f=o(m),a=m.maxColumns===void 0?w:m.maxColumns,p=m.groups&&m.groups.buckets?m.groups:null,b=p?p.buckets:[m.order||new Uint32Array(0)],O=m.groupPaths||(p?p.keys.map(F=>g(F,c)):[""]),k=s(b),{keys:y,paths:v,idOf:R}=l(m.pivotHandles||[],k,m),S=v.length*Math.max(1,f.length),x=r(v,f,c);if(a&&S>a){const F=new Map;return{keys:y,paths:v,fields:x,groupPaths:O,columns:S,values:F,cells:F,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${S} columns, above pivot.maxColumns of ${a}. Narrow the pivot columns or raise the limit.`,columns:S,maxColumns:a}}}const C=new Map,P=v.length;for(let F=0;F<b.length;F++){const E=b[F],D=O[F]===void 0?"":O[F],N=E.length;if(N===0)continue;const M=new Int32Array(N),j=new Uint32Array(P+1);for(let q=0;q<N;q++){const Y=R(E[q]);M[q]=Y,Y>=0&&j[Y+1]++}for(let q=0;q<P;q++)j[q+1]+=j[q];const L=new Uint32Array(N),G=j.slice(0,P);for(let q=0;q<N;q++){const Y=M[q];Y>=0&&(L[G[Y]++]=E[q])}for(let q=0;q<P;q++){const Y=j[q],J=j[q+1];if(J===Y)continue;const ee=L.subarray(Y,J);for(let ne=0;ne<f.length;ne++){const ie=f[ne],se=H(ie.handle,ee,ie.fn,m.totalContext||{locale:m.locale});C.set(A(D,v[q],ie.colId),se)}}}return{keys:y,paths:v,fields:x,groupPaths:O,columns:S,values:C,cells:C,error:null}}function r(h,u,i){if(u.length===0)return h.slice();const m=[];for(const c of h)for(const f of u)m.push(`${c}${i}${f.colId}`);return m}function s(h){if(h.length===1)return h[0]||new Uint32Array(0);let u=0;for(const c of h)u+=c?c.length:0;const i=new Uint32Array(u);let m=0;for(const c of h)!c||c.length===0||(i.set(c,m),m+=c.length);return i}}),Fe("packages/core/src/store/bitset.js",function(e,K){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return $}});const Q=8;class ${static#e=new Uint8Array(256);static{for(let I=1;I<256;I++)$.#e[I]=$.#e[I>>1]+(I&1)}#t;#n;constructor(I=0){const _=Math.max(0,I|0);this.#n=_,this.#t=new Uint8Array(Math.ceil(_/Q))}get size(){return this.#n}get words(){return this.#t}get bytes(){return this.#t?this.#t.byteLength:0}get(I){return I<0||I>=this.#n?0:this.#t[I>>3]>>(I&7)&1}set(I){return I>=0&&I<this.#n&&(this.#t[I>>3]|=1<<(I&7)),this}clear(I){return I>=0&&I<this.#n&&(this.#t[I>>3]&=~(1<<(I&7))),this}assign(I,_){return _?this.set(I):this.clear(I)}fill(I=!1){return this.#t.fill(I?255:0),I&&this.#r(),this}grow(I){const _=Math.max(0,I|0);if(_<=this.#n)return this;const X=Math.ceil(_/Q);if(X>this.#t.length){const W=new Uint8Array(X);W.set(this.#t),this.#t=W}return this.#n=_,this}count(){const I=this.#t,_=$.#e;let X=0;for(let W=0;W<I.length;W++)X+=_[I[W]];return X}and(I){const _=I instanceof $?I.words:I,X=this.#t,W=Math.min(X.length,_.length);for(let H=0;H<W;H++)X[H]&=_[H];for(let H=W;H<X.length;H++)X[H]=0;return this}or(I){const _=I instanceof $?I.words:I,X=this.#t,W=Math.min(X.length,_.length);for(let H=0;H<W;H++)X[H]|=_[H];return this}not(){const I=this.#t;for(let _=0;_<I.length;_++)I[_]=~I[_]&255;return this.#r(),this}clone(){const I=new $(this.#n);return I.words.set(this.#t.subarray(0,I.words.length)),I}release(){this.#t=new Uint8Array(0),this.#n=0}#r(){const I=this.#n&7;if(I===0)return;const _=this.#n>>3;_<this.#t.length&&(this.#t[_]&=(1<<I)-1)}static from(I){const _=Array.isArray(I)?I:Array.from(I),X=new $(_.length);for(let W=0;W<_.length;W++)_[W]&&X.set(W);return X}}}),Fe("packages/core/src/store/dictionary.js",function(e,K){"use strict";Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return I}});const Q=K("packages/core/src/internal/util.js"),$=Q.collator,B=Q.defaultCompare;class I{#e;#t=new Map;#n=0;#r=null;#o=-1;#i="\0";constructor(X=[]){this.#e=[];for(let W=0;W<X.length;W++){const H=X[W];this.#t.has(H)||(this.#t.set(H,this.#e.length),this.#e.push(H))}}get size(){return this.#e.length}get version(){return this.#n}get bytes(){let X=this.#e.length*8;for(let W=0;W<this.#e.length;W++){const H=this.#e[W];typeof H=="string"&&(X+=H.length*2),X+=16}return X}codeOf(X){const W=this.#t.get(X);if(W!==void 0)return W;const H=this.#e.length;return this.#e.push(X),this.#t.set(X,H),this.#n++,H}lookup(X){const W=this.#t.get(X);return W===void 0?-1:W}has(X){return this.#t.has(X)}valueOf(X){return this.#e[X]}values(){return this.#e}ranks(X){const W=X||"";if(this.#r&&this.#o===this.#n&&this.#i===W)return this.#r;const H=this.#e.length,V=new Array(H);for(let g=0;g<H;g++)V[g]=g;const z=$(X).compare,w=this.#e;V.sort((g,l)=>this.#s(w[g],w[l],z));const A=new Uint32Array(H);for(let g=0;g<H;g++)A[V[g]]=g;return this.#r=A,this.#o=this.#n,this.#i=W,A}#s(X,W,H){return typeof X=="string"&&typeof W=="string"?H(X,W):B(X,W)}}}),Fe("packages/core/src/store/multivalue.js",function(e,K){"use strict";Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return Q}});class Q{#e;#t;#n=0;#r=0;constructor(B={}){const I=Math.max(1,B.rows??16),_=Math.max(1,B.values??I);this.#e=new Int32Array(_),this.#t=new Uint32Array(I+1)}get values(){return this.#e}get offsets(){return this.#t}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#e.byteLength+this.#t.byteLength}count(B){return B<0||B>=this.#n?0:this.#t[B+1]-this.#t[B]}at(B){return B<0||B>=this.#n?this.#e.subarray(0,0):this.#e.subarray(this.#t[B],this.#t[B+1])}has(B,I){if(B<0||B>=this.#n)return!1;const _=this.#e,X=this.#t[B+1];for(let W=this.#t[B];W<X;W++)if(_[W]===I)return!0;return!1}hasAny(B,I){for(let _=0;_<I.length;_++)if(this.has(B,I[_]))return!0;return!1}hasAll(B,I){for(let _=0;_<I.length;_++)if(!this.has(B,I[_]))return!1;return!0}hasNone(B,I){return!this.hasAny(B,I)}push(B){const I=this.#n,_=B.length;this.#o(I+1),this.#i(this.#r+_);const X=this.#r;for(let W=0;W<_;W++)this.#e[X+W]=B[W]|0;return this.#r+=_,this.#n=I+1,this.#t[I]=X,this.#t[I+1]=this.#r,I}write(B,I){if(B===this.#n){this.push(I);return}if(B<0||B>this.#n)return;const _=this.#t[B],X=this.#t[B+1],W=I.length;if(X-_===W){for(let H=0;H<W;H++)this.#e[_+H]=I[H]|0;return}this.#s(B,I)}compact(B,I,_){const X=this.#e,W=this.#t,H=this.#n,V=new Int32Array(Math.max(1,this.#r)),z=new Uint32Array(I+1);let w=0;for(let A=0;A<H;A++){if(B[A]===_)continue;const g=W[A],l=W[A+1];z[B[A]]=w;for(let d=g;d<l;d++)V[w++]=X[d];z[B[A]+1]=w}this.#e=V,this.#t=z,this.#n=I,this.#r=w}release(){this.#e=new Int32Array(0),this.#t=new Uint32Array(1),this.#n=0,this.#r=0}#o(B){if(B+1<=this.#t.length)return;let I=this.#t.length-1;for(;I<B;)I=I*2||16;const _=new Uint32Array(I+1);_.set(this.#t),this.#t=_}#i(B){if(B<=this.#e.length)return;let I=this.#e.length;for(;I<B;)I=I*2||16;const _=new Int32Array(I);_.set(this.#e),this.#e=_}#s(B,I){const _=this.#e,X=this.#t,W=this.#n,H=I.length-(X[B+1]-X[B]),V=new Int32Array(Math.max(1,this.#r+H)),z=new Uint32Array(X.length);let w=0;for(let A=0;A<W;A++){if(z[A]=w,A===B)for(let g=0;g<I.length;g++)V[w++]=I[g]|0;else for(let g=X[A];g<X[A+1];g++)V[w++]=_[g];z[A+1]=w}this.#e=V,this.#t=z,this.#r=w}}}),Fe("packages/core/src/compute/sort.js",function(e,K){"use strict";Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return P}});const Q=K("packages/core/src/compute/handle.js"),$=Q.bitReader,B=Q.dictRanks,I=Q.dictSize,_=Q.identity,X=Q.isMissing,W=Q.presenceReader,H=Q.rowCount,V=Q.valueComparator,z=Q.valueReader,w=new Uint32Array(0),A=new ArrayBuffer(8),g=new Float64Array(A),l=new Uint32Array(A),d=(g[0]=-1,(l[1]&2147483648)!==0?1:0),o=d===1?0:1;function n(E,D){g[0]=E;let N=l[d],M=l[o];(N&2147483648)!==0?(N=~N>>>0,M=~M>>>0):N=(N^2147483648)>>>0,D[0]=M,D[1]=N}function t(E,D,N,M){if(M<2)return E;const j=new Uint32Array(256*8);for(let ie=0;ie<M;ie++){const se=D[ie],he=N[ie];j[se&255]++,j[256+(se>>>8&255)]++,j[512+(se>>>16&255)]++,j[768+(se>>>24&255)]++,j[1024+(he&255)]++,j[1280+(he>>>8&255)]++,j[1536+(he>>>16&255)]++,j[1792+(he>>>24&255)]++}let L=E,G=D,q=N,Y=new Uint32Array(M),J=new Uint32Array(M),ee=new Uint32Array(M);const ne=new Uint32Array(256);for(let ie=0;ie<8;ie++){const se=ie<<8,he=(ie&3)<<3,ce=ie>=4;let te=!1;for(let de=0;de<256;de++)if(j[se+de]===M){te=!0;break}if(te)continue;let oe=0;for(let de=0;de<256;de++)ne[de]=oe,oe+=j[se+de];for(let de=0;de<M;de++){const ve=G[de],Me=q[de],Oe=(ce?Me:ve)>>>he&255,Ce=ne[Oe]++;Y[Ce]=L[de],J[Ce]=ve,ee[Ce]=Me}let fe=L;L=Y,Y=fe,fe=G,G=J,J=fe,fe=q,q=ee,ee=fe}return L}function r(E,D,N){if(N<2)return E;const M=new Uint32Array(256*4);for(let J=0;J<N;J++){const ee=D[J];M[ee&255]++,M[256+(ee>>>8&255)]++,M[512+(ee>>>16&255)]++,M[768+(ee>>>24&255)]++}let j=E,L=D,G=new Uint32Array(N),q=new Uint32Array(N);const Y=new Uint32Array(256);for(let J=0;J<4;J++){const ee=J<<8,ne=J<<3;let ie=!1;for(let ce=0;ce<256;ce++)if(M[ee+ce]===N){ie=!0;break}if(ie)continue;let se=0;for(let ce=0;ce<256;ce++)Y[ce]=se,se+=M[ee+ce];for(let ce=0;ce<N;ce++){const te=L[ce],oe=Y[te>>>ne&255]++;G[oe]=j[ce],q[oe]=te}let he=j;j=G,G=he,he=L,L=q,q=he}return j}function s(E,D,N,M){const j=new Uint32Array(M+1);for(let q=0;q<N;q++)j[D[q]]++;let L=0;for(let q=0;q<=M;q++){const Y=j[q];j[q]=L,L+=Y}const G=new Uint32Array(N);for(let q=0;q<N;q++)G[j[D[q]]++]=E[q];return G}function h(E,D,N,M){return N<2?E:M<=65536||M<=N*2?s(E,D,N,M):r(E,D,N)}function u(E,D){return E.length===D&&E.byteOffset===0?E:Uint32Array.prototype.slice.call(E,0,D)}function i(E,D,N=!1){const M=D||_(E.length),j=M.length;if(j<2)return Uint32Array.from(M);const L=new Uint32Array(j),G=new Uint32Array(j),q=new Uint32Array(j),Y=new Uint32Array(j),J=new Uint32Array(2);let ee=0,ne=0;for(let he=0;he<j;he++){const ce=M[he],te=E[ce];if(Number.isNaN(te)){Y[ne++]=ce;continue}n(te,J),N?(G[ee]=~J[0]>>>0,q[ee]=~J[1]>>>0):(G[ee]=J[0],q[ee]=J[1]),L[ee++]=ce}const ie=t(L.subarray(0,ee),G.subarray(0,ee),q.subarray(0,ee),ee);if(ne===0)return u(ie,ee);const se=new Uint32Array(j);return se.set(ie.subarray(0,ee),0),se.set(Y.subarray(0,ne),ee),se}function m(E,D,N=!1){const M=D||_(E.length),j=M.length;if(j<2)return Uint32Array.from(M);const L=Uint32Array.from(M),G=new Uint32Array(j);for(let q=0;q<j;q++){const Y=(E[L[q]]^2147483648)>>>0;G[q]=N?~Y>>>0:Y}return u(r(L,G,j),j)}function c(E,D,N={}){const M=D||_(H(E,N)),j=M.length;if(j<2)return Uint32Array.from(M);const L=B(E.dict,N.locale),G=E.values,q=W(E),Y=Math.max(I(E.dict),L.length),J=Y,ee=Uint32Array.from(M),ne=new Uint32Array(j),ie=!!N.descending;for(let se=0;se<j;se++){const he=ee[se];let ce=q&&q(he)===0?J:L[G[he]];ce===void 0&&(ce=J),ne[se]=ie?J-ce:ce}return u(h(ee,ne,j,Y+1),j)}function f(E,D,N){const M=D.length;let j=Uint32Array.from(D);if(M<2)return j;let L=new Uint32Array(M);for(let G=1;G<M;G<<=1){for(let Y=0;Y<M;Y+=G<<1){const J=Math.min(Y+G,M),ee=Math.min(Y+(G<<1),M);let ne=Y,ie=J,se=Y;for(;ne<J&&ie<ee;)L[se++]=N(E[j[ne]],E[j[ie]])<=0?j[ne++]:j[ie++];for(;ne<J;)L[se++]=j[ne++];for(;ie<ee;)L[se++]=j[ie++]}const q=j;j=L,L=q}return j}function a(E,D,N){const M=$(E.values),j=D.length,L=new Uint32Array(j),G=N?1:0;let q=0;for(let Y=0;Y<j;Y++)M(D[Y])===G&&(L[q++]=D[Y]);for(let Y=0;Y<j;Y++)M(D[Y])!==G&&(L[q++]=D[Y]);return L}function p(E,D){const N=E.values,M=E.kind;if((M==="object"||M===void 0)&&(Array.isArray(N)||ArrayBuffer.isView(N))&&!E.presence)return N;const L=z(E),G=new Array(H(E)||0);for(let q=0;q<D.length;q++){const Y=D[q];G[Y]=L(Y)}return G}function b(E,D){for(let N=0;N<D.length;N++)if(typeof E[D[N]]!="string")return!1;return!0}function O(E,D,N,M,j){const L=E.length,G=Uint32Array.from(E);if(L<2||M<1)return G;const q=new Uint32Array(L),Y=M-1;for(let J=0;J<L;J++){const ee=N[D[J]];q[J]=j?Y-ee:ee}return u(h(G,q,L,M),L)}function k(E,D,N){const M=V(N),j=new Array(D);for(let G=0;G<D;G++)j[G]=G;j.sort((G,q)=>M(E[G],E[q])||G-q);const L=new Uint32Array(D);for(let G=0;G<D;G++)L[j[G]]=G;return L}function y(E,D,N){const M=D.length,j=new Map,L=[],G=new Uint32Array(M);for(let J=0;J<M;J++){const ee=E[D[J]];let ne=j.get(ee);ne===void 0&&(ne=L.length,j.set(ee,ne),L.push(ee)),G[J]=ne}const q=L.length,Y=k(L,q,N.locale);return O(D,G,Y,q,!!N.descending)}function v(E,D,N){const M=p(E,D);if(D.length>=2&&b(M,D)){const G=E.stringRank;return G&&G.version===E.version&&G.usable(D,M,N.locale)?G.sort(D,N):y(M,D,N)}const j=V(N.locale),L=N.descending?(G,q)=>j(q,G):j;return f(M,D,L)}function R(E,D,N){const M=p(E,D),j=N.compare,G=!!N.descending?(q,Y)=>-j(q,Y,void 0,void 0,!0):(q,Y)=>j(q,Y,void 0,void 0,!1);return f(M,D,G)}function S(E,D){const N=D.length,M=W(E),j=E.values,L=E.kind==="float64"&&!!j,G=E.kind==="object"||E.kind==="multi"||E.kind===void 0;if(!M&&!L&&!G)return{present:D,absent:w};const q=new Uint32Array(N),Y=new Uint32Array(N);let J=0,ee=0;if(M&&L)for(let ne=0;ne<N;ne++){const ie=D[ne];M(ie)===1&&!Number.isNaN(j[ie])?q[J++]=ie:Y[ee++]=ie}else if(L&&!M)for(let ne=0;ne<N;ne++){const ie=D[ne];Number.isNaN(j[ie])?Y[ee++]=ie:q[J++]=ie}else if(M&&!G)for(let ne=0;ne<N;ne++){const ie=D[ne];M(ie)===1?q[J++]=ie:Y[ee++]=ie}else{const ne=z(E);for(let ie=0;ie<N;ie++){const se=D[ie];X(ne(se))?Y[ee++]=se:q[J++]=se}}return ee===0?{present:D,absent:w}:{present:q.subarray(0,J),absent:Y.subarray(0,ee)}}function x(E,D,N){if(D.length===0)return E;const M=new Uint32Array(E.length+D.length);return N?(M.set(D,0),M.set(E,D.length)):(M.set(E,0),M.set(D,E.length)),M}function C(E,D,N={}){const M=D||_(H(E,N));if(!E||M.length<2)return Uint32Array.from(M);const{present:j,absent:L}=S(E,M);if(j.length===0)return Uint32Array.from(M);const G=!!N.descending;let q;if(typeof N.compare=="function")q=R(E,j,N);else switch(E.kind){case"float64":q=i(E.values,j,G);break;case"int32":q=m(E.values,j,G);break;case"dictionary":q=c(E,j,N);break;case"bitset":q=a(E,j,G);break;default:q=v(E,j,N);break}return x(q,L,!!N.nullsFirst)}function P(E,D,N,M={}){const j=D||[],L=j.length&&(j[0].handle||F(E,j[0].col))||E&&E[0];let G=N||_(H(L,M));for(let q=j.length-1;q>=0;q--){const Y=j[q],J=Y.handle||F(E,Y.col)||E&&E[q];J&&(G=C(J,G,{descending:Y.descending!==void 0?!!Y.descending:Y.dir==="desc",nullsFirst:!!Y.nullsFirst,locale:Y.locale!==void 0?Y.locale:M.locale,compare:Y.compare}))}return G instanceof Uint32Array?G:Uint32Array.from(G)}function F(E,D){if(!(!E||D===void 0)){for(let N=0;N<E.length;N++)if(E[N]&&E[N].id===D)return E[N]}}}),Fe("packages/core/src/store/stringrank.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"StringRankIndex",{enumerable:!0,get:function(){return _}});const Q=K("packages/core/src/compute/sort.js"),$=Q.collateStringRanks,B=Q.rankSortStrings,I=1e5;class _{#e=[];#t=new Map;#n;#r=0;#o=0;#i=-1;#s;#l=!1;#a=null;#u=-1;#c="\0";constructor(W=I){this.#s=W>0?W:I,this.#n=new Uint32Array(0)}get version(){return this.#i}set version(W){this.#i=W}get generation(){return this.#o}get size(){return this.#e.length}get capped(){return this.#l}get length(){return this.#r}get bytes(){let W=this.#n.byteLength;const H=this.#e;for(let V=0;V<H.length;V++)W+=H[V].length*2+24;return W}#d(W,H){const V=this.#t.get(W);if(V!==void 0)return V;if(this.#l)return-1;if(H&&this.#e.length>=this.#s)return this.#l=!0,-1;const z=this.#e.length;return this.#e.push(W),this.#t.set(W,z),this.#o++,z}build(W,H){const V=H|0;this.#e=[],this.#t=new Map,this.#o=0,this.#l=!1,this.#a=null,this.#u=-1,this.#n=new Uint32Array(V);for(let z=0;z<V;z++){const w=W[z],A=typeof w=="string"?this.#d(w,!1):-1;this.#n[z]=A<0?0:A}this.#r=V}append(W,H,V){const z=(H|0)+(V|0);if(z>this.#n.length){const w=new Uint32Array(z);w.set(this.#n.subarray(0,this.#r)),this.#n=w}for(let w=H|0;w<z;w++){const A=W[w],g=typeof A=="string"?this.#d(A,!0):-1;this.#n[w]=g<0?0:g}this.#r=Math.max(this.#r,z)}ranks(W){const H=W||"";if(this.#a&&this.#u===this.#o&&this.#c===H)return this.#a;const V=$(this.#e,this.#e.length,W);return this.#a=V,this.#u=this.#o,this.#c=H,V}usable(W,H,V){if(this.#l||this.#e.length===0)return!1;const z=this.#n,w=this.#e,A=this.#r;for(let g=0;g<W.length;g++){const l=W[g];if(l>=A||w[z[l]]!==H[l])return!1}return!0}sort(W,H){const V=this.ranks(H.locale),z=this.#e.length,w=W.length,A=new Uint32Array(w),g=this.#n;for(let l=0;l<w;l++)A[l]=g[W[l]];return B(W,A,V,z,!!H.descending)}}}),Fe("packages/core/src/store/columnstore.js",function(e,K){"use strict";Object.defineProperty(e,"REMOVED",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toFloat",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ColumnHandle",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return c}});const Q=K("packages/core/src/internal/util.js"),$=Q.warnOnce,B=Q.isFunction,I=Q.pathGetter,X=K("packages/core/src/store/bitset.js").Bitset,H=K("packages/core/src/store/dictionary.js").Dictionary,z=K("packages/core/src/store/multivalue.js").MultiValue,A=K("packages/core/src/store/stringrank.js").StringRankIndex,g=4294967295,l=1024,d=5e3,o=.2,n=new Set(["float64","int32","bitset","dictionary","object","multi"]);function t(f){return f==null}function r(f){if(typeof f=="number")return f;if(f instanceof Date)return f.getTime();if(typeof f=="boolean")return f?1:0;const a=Number(f);return Number.isNaN(a)&&typeof f=="string"?Date.parse(f):a}function s(f){const a=r(f);return Number.isFinite(a)?a|0:0}function h(f){return t(f)?[]:Array.isArray(f)?f:[f]}function u(f,a){switch(f.kind){case"float64":case"int32":return f.buf[a];case"bitset":return f.bits.get(a)===1;case"dictionary":return f.dict.valueOf(f.buf[a]);case"multi":{const p=f.mv.at(a),b=new Array(p.length);for(let O=0;O<p.length;O++)b[O]=f.dict.valueOf(p[O]);return b}default:return f.buf[a]}}function i(f,a){switch(f.kind){case"float64":case"int32":return f.values[a];case"bitset":return(f.values[a>>3]&1<<(a&7))!==0;case"dictionary":return(f.table||[])[f.values[a]];case"multi":{const p=f.offsets[a],b=f.offsets[a+1],O=f.table||[],k=new Array(b-p);for(let y=p;y<b;y++)k[y-p]=O[f.values[y]];return k}default:return f.values[a]}}class m{#e;#t;#n;#r;#o;#i;#s;#l=!1;#a=null;#u=null;#c=null;#d=null;#h=null;#f;#p;#m=-1;#g=null;#b=0;#w=0;#S=null;#y=null;#O=!1;constructor(a,p){this.#e=a.id;const b=n.has(a.kind)?a.kind:"object";a.kind&&!n.has(a.kind)&&$(`store.kind.${a.id}`,`column "${a.id}" declares unknown storage kind "${a.kind}"; falling back to object`),this.#n=b,this.#t=b,this.#r=a.nullable!==!1,this.#s=a.dictionary??null,this.#i=p,this.#o=B(a.read)?a.read:I(a.field||a.id),this.#f=a.stringRankIndex!=="off",this.#p=typeof a.stringRankMaxDistinct=="number"?a.stringRankMaxDistinct:0,this.#S=new Map}get id(){return this.#e}get kind(){return this.#l?this.#t:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#O?null:this.#l?this.#t==="bitset"?this.#u.words:this.#t==="multi"?this.#c.values:this.#a:this.#C().values}get presence(){return this.#O||!this.#r?null:this.#l?this.#g:this.#C().presence}get dict(){return this.#O||!this.#l?null:this.#t==="dictionary"||this.#t==="multi"?this.#d:null}get stringRank(){if(this.#O||!this.#f||this.kind!=="object")return null;const a=this.values,p=this.#i.physical();if(!a||p===0)return null;if(this.#h===null){if(typeof a[0]!="string")return null;const b=new A(this.#k());return b.build(a,p),b.version=this.#w,this.#h=b,this.#m=this.#w,b.capped?null:b}return this.#h.length<p&&this.#h.append(a,this.#h.length,p-this.#h.length),this.#h.version=this.#w,this.#m=this.#w,this.#h.capped?null:this.#h}#k(){return this.#p}#j(){this.#h=null,this.#m=-1}get offsets(){return this.#O||!this.#l||this.#t!=="multi"?null:this.#c.offsets}get version(){return this.#w}get bytes(){let a=0;return this.#a&&(a+=this.#a.byteLength??this.#a.length*8),this.#u&&(a+=this.#u.bytes),this.#c&&(a+=this.#c.bytes),this.#g&&(a+=this.#g.bytes),this.#d&&(a+=this.#d.bytes),this.#S&&(a+=this.#S.size*24),a}get(a){if(!this.#O&&!(a<0||a>=this.#i.physical())){if(!this.#l)return this.#M(a);if(this.#r&&this.#g.get(a)===0)return null;switch(this.#t){case"float64":case"int32":return this.#a[a];case"bitset":return this.#u.get(a)===1;case"dictionary":return this.#d.valueOf(this.#a[a]);case"multi":{const p=this.#c.at(a),b=new Array(p.length);for(let O=0;O<p.length;O++)b[O]=this.#d.valueOf(p[O]);return b}default:return this.#a[a]}}}set(a,p){this.#O||(this.#l?this.#T(a,p):this.#S.set(a,p===void 0?null:p),this.#h&&this.#j(),this.#w++)}read(a){return this.#o(a)}appendColumn(a,p,b){if(this.#O||b<=0)return;if(!this.#l){this.#w++;return}const O=this.#o,k=this.#r,y=this.#g;let v=!1;switch(this.#t){case"float64":{const R=this.#a;for(let S=0;S<b;S++){const x=O(a[S]);if(typeof x=="number"){k&&y.set(p+S),R[p+S]=x;continue}const C=x==null;k?y.assign(p+S,!C):C&&(v=!0),R[p+S]=C?NaN:r(x)}break}case"int32":{const R=this.#a;for(let S=0;S<b;S++){const x=O(a[S]),C=x==null;k?y.assign(p+S,!C):C&&(v=!0),R[p+S]=C?0:s(x)}break}case"bitset":{const R=this.#u;for(let S=0;S<b;S++){const x=O(a[S]),C=x==null;k?y.assign(p+S,!C):C&&(v=!0),R.assign(p+S,!C&&!!x)}break}case"dictionary":{const R=this.#a,S=this.#d;for(let x=0;x<b;x++){const C=O(a[x]),P=C==null;k?y.assign(p+x,!P):P&&(v=!0),R[p+x]=P?0:S.codeOf(C)}break}case"multi":{const R=this.#c,S=this.#d;for(let x=0;x<b;x++){const C=O(a[x]),P=C==null;k?y.assign(p+x,!P):P&&(v=!0);const F=h(C),E=new Array(F.length);for(let D=0;D<F.length;D++)E[D]=S.codeOf(F[D]);R.write(p+x,E)}break}default:{const R=this.#a;for(let S=0;S<b;S++){const x=O(a[S]),C=x==null;k?y.assign(p+S,!C):C&&(v=!0),R[p+S]=C?null:x}break}}v&&$(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#h&&this.#t==="object"&&(this.#h.append(this.#a,p,b),this.#h.version=this.#w+1,this.#m=this.#w+1),this.#w++}appendPacked(a,p,b){if(this.#O||b<=0||!a)return;if(!this.#l){this.#w++;return}const O=this.#g,k=a.presence;if(O)if(k)for(let v=0;v<b;v++)O.assign(p+v,(k[v>>3]&1<<(v&7))!==0);else for(let v=0;v<b;v++)O.set(p+v);const y=a.kind===this.#t;if(y&&(this.#t==="float64"||this.#t==="int32")){this.#a.set(a.values,p),this.#w++;return}if(y&&this.#t==="bitset"){const v=a.values;for(let R=0;R<b;R++)this.#u.assign(p+R,(v[R>>3]&1<<(R&7))!==0);this.#w++;return}if(y&&this.#t==="dictionary"){const v=a.table||[],R=new Uint32Array(v.length);for(let P=0;P<v.length;P++)R[P]=this.#d.codeOf(v[P]);const S=a.values,x=this.#a,C=O;for(let P=0;P<b;P++){if(C&&(k&&(k[P>>3]&1<<(P&7))===0)){x[p+P]=0;continue}x[p+P]=R[S[P]]??0}this.#w++;return}if(y&&this.#t==="multi"){const v=a.table||[],R=new Uint32Array(v.length);for(let C=0;C<v.length;C++)R[C]=this.#d.codeOf(v[C]);const S=a.values,x=a.offsets;for(let C=0;C<b;C++){const P=x[C],F=x[C+1],E=new Array(F-P);for(let D=P;D<F;D++)E[D-P]=R[S[D]]??0;this.#c.write(p+C,E)}this.#w++;return}for(let v=0;v<b;v++){const R=k?(k[v>>3]&1<<(v&7))===0:a.kind==="object"?a.values[v]===null:!1;this.#T(p+v,R?null:i(a,v))}this.#w++}touch(){this.#w++}columnarise(a,p){if(this.#l||this.#O)return;const b=new Array(p);for(let O=0;O<p;O++)b[O]=this.#M(O);this.#t=this.#n,this.#l=!0,this.#A(a);for(let O=0;O<p;O++)this.#T(O,b[O]);this.#S.clear(),this.#y=null,this.#j(),this.#w++}grow(a){if(!(!this.#l||this.#O||a<=this.#b)){switch(this.#t){case"float64":case"int32":case"dictionary":{const p=new this.#a.constructor(a);p.set(this.#a),this.#a=p;break}case"bitset":this.#u.grow(a);break;case"multi":break;default:this.#a.length=a;break}this.#g&&this.#g.grow(a),this.#b=a,this.#w++}}convert(a){if(this.#O||!n.has(a)||(this.#n=a,!this.#l||a===this.#t))return!1;const p={kind:this.#t,buf:this.#a,bits:this.#u,mv:this.#c,dict:this.#d},b=this.#i.physical(),O=this.#g;this.#t=a,this.#A(this.#b);for(let k=0;k<b;k++){const y=O!==null&&O.get(k)===0;y&&a!=="multi"||this.#T(k,y?null:u(p,k))}return this.#j(),this.#w++,!0}compact(a,p,b){if(!this.#O){if(this.#j(),!this.#l){const O=this.#S;if(O.size){const k=new Map;for(const[y,v]of O)a[y]!==g&&k.set(a[y],v);this.#S=k}this.#y=null,this.#w++;return}switch(this.#t){case"float64":case"int32":case"dictionary":case"object":{const O=this.#a;for(let k=0;k<p;k++)a[k]!==g&&(O[a[k]]=O[k]);if(this.#t==="object")for(let k=b;k<p;k++)O[k]=void 0;break}case"bitset":{const O=this.#u;for(let k=0;k<p;k++)a[k]!==g&&O.assign(a[k],O.get(k)===1);for(let k=b;k<p;k++)O.clear(k);break}case"multi":this.#c.compact(a,b,g);break;default:break}if(this.#g){const O=this.#g;for(let k=0;k<p;k++)a[k]!==g&&O.assign(a[k],O.get(k)===1);for(let k=b;k<p;k++)O.clear(k)}this.#w++}}release(){this.#O||(this.#O=!0,this.#a=null,this.#u&&this.#u.release(),this.#u=null,this.#c&&this.#c.release(),this.#c=null,this.#g&&this.#g.release(),this.#g=null,this.#d=null,this.#h=null,this.#S=new Map,this.#y=null,this.#b=0,this.#w++)}#A(a){const p=Math.max(1,a);switch(this.#a=null,this.#u=null,this.#c=null,this.#t){case"float64":this.#a=new Float64Array(p);break;case"int32":this.#a=new Int32Array(p);break;case"bitset":this.#u=new X(p);break;case"dictionary":this.#a=new Uint32Array(p),this.#d=this.#d??new H(this.#s??[]);break;case"multi":this.#c=new z({rows:p,values:p}),this.#d=this.#d??new H(this.#s??[]);break;default:this.#a=new Array(p);break}this.#t!=="dictionary"&&this.#t!=="multi"&&(this.#d=null),this.#r&&(this.#g?this.#g.grow(p):this.#g=new X(p)),this.#b=p}#T(a,p){const b=t(p);switch(this.#r?this.#g.assign(a,!b):b&&$(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#t){case"float64":this.#a[a]=b?NaN:r(p);break;case"int32":this.#a[a]=b?0:s(p);break;case"bitset":this.#u.assign(a,!b&&!!p);break;case"dictionary":this.#a[a]=b?0:this.#d.codeOf(p);break;case"multi":{const O=h(p),k=new Array(O.length);for(let y=0;y<O.length;y++)k[y]=this.#d.codeOf(O[y]);this.#c.write(a,k);break}default:this.#a[a]=b?null:p;break}}#M(a){if(this.#S.has(a))return this.#S.get(a);const p=this.#o(this.#i.rowAt(a));return p===void 0?null:p}#C(){if(this.#y&&this.#y.version===this.#w)return this.#y;const a=this.#i.physical(),p=new Array(a),b=this.#r?new X(a):null;for(let O=0;O<a;O++){const k=this.#M(O);p[O]=k,b&&!t(k)&&b.set(O)}return this.#y={version:this.#w,values:p,presence:b},this.#y}}class c{#e;#t=new Map;#n=[];#r=[];#o=0;#i=0;#s=0;#l=0;#a=new X(0);#u=!1;#c=!0;#d;#h;#f;#p=!1;constructor(a,p={}){this.#e=Array.isArray(a)?a:[],this.#h=Math.max(1,p.initialCapacity??l),this.#c=p.retainSource!==!1,this.#d=this.#c?p.columnarBelow??d:0,this.#f=p.compactRatio??o;const b={rowAt:O=>this.#r[O],physical:()=>this.#o};for(const O of this.#e){if(!O||!O.id)continue;if(this.#t.has(O.id)){$(`store.dup.${O.id}`,`duplicate column id "${O.id}" in the store schema; ignoring the second`);continue}const k=new m(O,b);this.#t.set(O.id,k),this.#n.push(k)}this.#d<=0&&this.#b()}get count(){return this.#s}get physical(){return this.#o}get capacity(){return this.#u?this.#i:this.#r.length}get tombstones(){return this.#l}get columnar(){return this.#u}get destroyed(){return this.#p}get bytes(){let a=this.#a.bytes+this.#r.length*8;for(const p of this.#n)a+=p.bytes;return a}append(a){const p=this.#o;if(this.#p||!a)return{from:p,to:p};const b=a.length|0;if(b===0)return{from:p,to:p};if(this.#c)for(let k=0;k<b;k++)this.#r[p+k]=a[k];if(this.#o=p+b,this.#s+=b,this.#a.grow(this.#o),!this.#u){if(this.#o>=this.#d)this.#b();else for(const k of this.#n)k.touch();return{from:p,to:this.#o}}this.#m(this.#o);const O=this.#n;for(let k=0;k<O.length;k++)O[k].appendColumn(a,p,b);return{from:p,to:this.#o}}appendPacked(a,p){const b=this.#o;if(this.#p||!a)return{from:b,to:b};const O=a.count|0;if(O===0)return{from:b,to:b};if(this.#c&&p)for(let y=0;y<O;y++)this.#r[b+y]=p[y];this.#o=b+O,this.#s+=O,this.#a.grow(this.#o),this.#u||this.#b(),this.#m(this.#o);const k=new Map;for(const y of a.columns)k.set(y.id,y);for(const y of this.#n){const v=k.get(y.id);v?y.appendPacked(v,b,O):y.grow(this.#i)}return{from:b,to:this.#o}}source(a){if(this.#c)return this.#r[a];if(!(a<0||a>=this.#o))return this.#g(a)}setSource(a,p){this.#p||a<0||a>=this.#o||this.#c&&(this.#r[a]=p)}get(a,p){const b=this.#t.get(a);return b?b.get(p):void 0}set(a,p,b){if(this.#p||p<0||p>=this.#o)return;const O=this.#t.get(a);if(!O){$(`store.set.${a}`,`set() on unknown column "${a}"`);return}O.set(p,b)}remove(a){return this.#p||a<0||a>=this.#o||this.#a.get(a)===1?!1:(this.#a.set(a),this.#l++,this.#s--,!0)}live(a){return a<0||a>=this.#o?!1:this.#a.get(a)===0}compact(a={}){if(this.#p||this.#l===0||!a.force&&this.#l/this.#o<this.#f)return null;const p=this.#o,b=new Uint32Array(p);let O=0;for(let k=0;k<p;k++)b[k]=this.#a.get(k)===1?g:O++;for(const k of this.#n)k.compact(b,p,O);if(this.#c){const k=this.#r;for(let y=0;y<p;y++)b[y]!==g&&(k[b[y]]=k[y]);k.length=O}return this.#o=O,this.#s=O,this.#l=0,this.#a=new X(Math.max(this.#i,O)),b}column(a){return this.#t.get(a)}columns(){return this.#n.slice()}liveIndices(){const a=new Uint32Array(this.#s);if(this.#l===0){for(let b=0;b<this.#o;b++)a[b]=b;return a}let p=0;for(let b=0;b<this.#o;b++)this.#a.get(b)===0&&(a[p++]=b);return a}convert(a,p){const b=this.#t.get(a);return b?b.convert(p):!1}destroy(){if(!this.#p){this.#p=!0;for(const a of this.#n)a.release();this.#t.clear(),this.#n.length=0,this.#r.length=0,this.#a.release(),this.#o=0,this.#s=0,this.#l=0,this.#i=0}}#m(a){if(a<=this.#i)return;let p=this.#i||this.#h;for(;p<a;)p*=2;for(const b of this.#n)b.grow(p);this.#a.grow(p),this.#i=p}#g(a){const p={};for(const b of this.#n)p[b.id]=b.get(a);return p}#b(){if(this.#u)return;let a=this.#h;for(;a<this.#o;)a*=2;this.#u=!0,this.#i=a,this.#a.grow(a);for(const p of this.#n)p.columnarise(a,this.#o)}}}),Fe("packages/core/src/store/pool.js",function(e,K){"use strict";Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"sharedPool",{enumerable:!0,get:function(){return _}});const Q=64,$=8;function B(W){let H=Q;for(;H<W;)H*=2;return H}class I{#e=new Map;#t=new WeakSet;#n;#r=0;#o={acquired:0,reused:0,released:0};constructor(H={}){this.#n=H.limit??$}get bytes(){return this.#r}mask(H){const V=new Uint8Array(this.#i(H),0,H);return V.fill(0),V}indices(H){return new Uint32Array(this.#i(H*4),0,H)}release(H){if(!H||!H.buffer)return!1;const V=H.buffer;if(!this.#t.has(V))return!1;this.#t.delete(V),this.#o.released++;const z=V.byteLength;let w=this.#e.get(z);return w||this.#e.set(z,w=[]),w.length>=this.#n||(w.push(V),this.#r+=z),!0}releaseAll(H){for(const V of H)this.release(V)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#o,retained:this.#r}}#i(H){const V=B(H),z=this.#e.get(V);this.#o.acquired++;let w;return z&&z.length?(w=z.pop(),this.#r-=V,this.#o.reused++):w=new ArrayBuffer(V),this.#t.add(w),w}}function _(){return X??=new I,X}let X=null}),Fe("packages/core/src/compute/sortspec.js",function(e,K){"use strict";Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return _}});function Q(X){return{locale:X===void 0?void 0:String(X),numeric:!0,sensitivity:"variant"}}function $(X){return!!X&&typeof X.compare!="function"}function B(X){if(!X)return!0;for(let W=0;W<X.length;W++)if(!$(X[W]))return!1;return!0}function I(X,W){const H=X.col!==void 0?X.col:X.handle&&X.handle.id,V=X.locale!==void 0?X.locale:W;return{col:H,descending:X.descending!==void 0?!!X.descending:X.dir==="desc",nullsFirst:!!X.nullsFirst,collation:Q(V)}}function _(X,W){const H=X||[],V=new Array(H.length);for(let z=0;z<H.length;z++)V[z]=I(H[z],W);return V}}),Fe("packages/core/src/compute/facet.js",function(e,K){"use strict";Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"orderedReader",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"toNumeric",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return O}});const Q=K("packages/core/src/compute/handle.js"),$=Q.presenceReader,B=Q.valueReader,I=Q.dictSize,_=Q.dictValue,X=Object.freeze(["equal","quantile","log"]),W=Object.freeze(["hour","day","week","month","quarter","year"]),H=20,V=50,z=1e4;function w(k,y){if(!k)return"none";const v=y;if(v&&(v.multi===!0||typeof v.items=="function"))return"category";const R=y&&y.base;if(R==="date"||R==="datetime"||R==="time"||R==="dateString")return"date";switch(k.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return R==="number"?"numeric":R==="boolean"?"boolean":R==="text"?"category":"none"}}function A(k){const y=k.values,v=k.kind;if((v==="float64"||v==="int32")&&y)return S=>y[S];const R=B(k);return S=>g(R(S))}function g(k){if(typeof k=="number")return k;if(k instanceof Date)return k.getTime();if(k==null||k==="")return NaN;if(typeof k=="boolean")return k?1:0;if(typeof k=="string"){const y=Number(k);if(Number.isFinite(y))return y;const v=Date.parse(k);return Number.isFinite(v)?v:NaN}return NaN}function l(k,y,v,R=V){if(!k)return{cardinality:0,exact:!0};if(k.dict)return{cardinality:I(k.dict),exact:!0};if(k.kind==="bitset")return{cardinality:2,exact:!0};const S=B(k),x=y?y.length:v,C=new Set;for(let P=0;P<x;P++){const F=S(y?y[P]:P);if(F!=null&&(C.add(F),C.size>R))return{cardinality:C.size,exact:!1}}return{cardinality:C.size,exact:!0}}const d=36e5,o=864e5;function n(k,y=H){const v=Number.isFinite(k)&&k>0?k:0,R=Math.max(1,y)*2;return v/d<=R?"hour":v/o<=R?"day":v/(7*o)<=R?"week":v/(30*o)<=R?"month":v/(91*o)<=R?"quarter":"year"}function t(k,y){if(!Number.isFinite(k))return NaN;const v=new Date(k);switch(y){case"hour":return v.setMinutes(0,0,0),v.getTime();case"day":return v.setHours(0,0,0,0),v.getTime();case"week":{v.setHours(0,0,0,0);const R=(v.getDay()+6)%7;return v.setDate(v.getDate()-R),v.getTime()}case"month":return v.setDate(1),v.setHours(0,0,0,0),v.getTime();case"quarter":return v.setMonth(Math.floor(v.getMonth()/3)*3,1),v.setHours(0,0,0,0),v.getTime();default:return v.setMonth(0,1),v.setHours(0,0,0,0),v.getTime()}}function r(k,y){const v=new Date(k);switch(y){case"hour":v.setHours(v.getHours()+1);break;case"day":v.setDate(v.getDate()+1);break;case"week":v.setDate(v.getDate()+7);break;case"month":v.setMonth(v.getMonth()+1);break;case"quarter":v.setMonth(v.getMonth()+3);break;default:v.setFullYear(v.getFullYear()+1);break}return v.getTime()}function s(k,y,v){const R=A(k),S=$(k),x=y?y.length:v;let C=1/0,P=-1/0,F=0,E=0;for(let D=0;D<x;D++){const N=y?y[D]:D;if(S&&!S(N)){F++;continue}const M=R(N);if(!Number.isFinite(M)){F++;continue}M<C&&(C=M),M>P&&(P=M),E++}return{min:C,max:P,nulls:F,finite:E}}function h(k,y,v,R){const S=A(k),x=$(k),C=y?y.length:v,P=C>R?C/R:1,F=[];for(let D=0;D<C;D+=P){const N=y?y[Math.floor(D)]:Math.floor(D);if(x&&!x(N))continue;const M=S(N);Number.isFinite(M)&&F.push(M)}const E=Float64Array.from(F);return E.sort(),E}function u(k,y,v,R={}){const S=R.kind||w(k,R.type);return S==="none"||!k?{kind:"none",buckets:[],suppressed:"type"}:S==="boolean"?i(k,y,v):S==="category"?m(k,y,v,R):c(k,y,v,S,R)}function i(k,y,v){const R=$(k);let S=0;if(R){const C=y?y.length:v;for(let P=0;P<C;P++)R(y?y[P]:P)||S++}const x=[{value:!1,label:"false"},{value:!0,label:"true"}];return S>0&&x.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:x}}function m(k,y,v,R){const S=R.cardinalityLimit??V,{cardinality:x}=l(k,y,v,S);if(x>S&&(R.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:x};const C=B(k),P=y?y.length:v,F=new Map;let E=0;for(let L=0;L<P;L++){const G=C(y?y[L]:L);if(G==null||G===""){E++;continue}if(Array.isArray(G)){if(!G.length){E++;continue}for(const q of G)F.set(q,(F.get(q)||0)+1);continue}F.set(G,(F.get(G)||0)+1)}let D=[...F.entries()];R.order==="alpha"?D.sort((L,G)=>String(L[0]).localeCompare(String(G[0]))):D.sort((L,G)=>G[1]-L[1]);let N=0,M=0;if(D.length>S){M=D.length-S;for(let L=S;L<D.length;L++)N+=D[L][1];D=D.slice(0,S)}const j=D.map(([L])=>({value:L,label:String(L)}));return N>0&&j.push({remainder:!0,label:`Other (${M} values)`}),E>0&&j.push({null:!0,label:"Empty"}),{kind:"category",buckets:j,cardinality:x}}function c(k,y,v,R,S){const{min:x,max:C,nulls:P,finite:F}=s(k,y,v);if(!F)return{kind:R,buckets:P?[{null:!0,label:"Empty"}]:[],empty:!0};const E=Math.max(1,Math.floor(S.buckets||H));let D=[];if(R==="date"){const M=W.includes(S.granularity)?S.granularity:n(C-x,E);let j=t(x,M);for(;j<=C&&D.length<4096;){const L=r(j,M);if(!(L>j))break;D.push({from:j,to:L}),j=L}return{kind:R,buckets:f(D,P),granularity:M}}const N=X.includes(S.strategy)?S.strategy:"equal";if(N==="quantile"){const M=h(k,y,v,z);if(M.length){const j=[M[0]];for(let L=1;L<E;L++){const G=M[Math.min(M.length-1,Math.floor(L/E*M.length))];G>j[j.length-1]&&j.push(G)}j.push(C);for(let L=0;L<j.length-1;L++)D.push({from:j[L],to:j[L+1]})}}else if(N==="log"&&x>0){const M=Math.log10(x),L=(Math.log10(C)-M)/E||1;for(let G=0;G<E;G++)D.push({from:10**(M+G*L),to:10**(M+(G+1)*L)})}if(!D.length){const M=(C-x)/E||1;for(let j=0;j<E;j++)D.push({from:x+j*M,to:x+(j+1)*M})}return D[D.length-1].to=C,{kind:R,buckets:f(D,P),strategy:N,min:x,max:C}}function f(k,y){return y>0?[...k,{null:!0,label:"Empty"}]:k}function a(k,y,v,R,S){const x=R&&R.buckets||[],C=S&&S.length>=x.length?S.subarray(0,x.length):new Uint32Array(x.length);if(C.fill(0),!k||!x.length)return C;const P=x.length-1,F=!!x[P]&&x[P].null===!0,E=y?y.length:v;if(R.kind==="boolean"){const L=B(k);for(let G=0;G<E;G++){const q=L(y?y[G]:G);if(q==null){F&&C[P]++;continue}C[q?1:0]++}return C}if(R.kind==="category"){const L=new Map;for(let Y=0;Y<x.length;Y++)!x[Y].null&&!x[Y].remainder&&L.set(x[Y].value,Y);const G=x.findIndex(Y=>Y.remainder),q=B(k);for(let Y=0;Y<E;Y++){const J=q(y?y[Y]:Y);if(J==null||J===""){F&&C[P]++;continue}if(Array.isArray(J)){if(!J.length){F&&C[P]++;continue}for(const ne of J){const ie=L.get(ne);ie!==void 0?C[ie]++:G>=0&&C[G]++}continue}const ee=L.get(J);ee!==void 0?C[ee]++:G>=0&&C[G]++}return C}const D=F?x.length-1:x.length,N=new Float64Array(D+1);for(let L=0;L<D;L++)N[L]=x[L].from;N[D]=D?x[D-1].to:0;const M=A(k),j=$(k);for(let L=0;L<E;L++){const G=y?y[L]:L;if(j&&!j(G)){F&&C[P]++;continue}const q=M(G);if(!Number.isFinite(q)){F&&C[P]++;continue}const Y=p(N,D,q);Y>=0&&C[Y]++}return C}function p(k,y,v){if(!y||v<k[0])return-1;if(v>=k[y])return v===k[y]?y-1:-1;let R=0,S=y-1;for(;R<S;){const x=R+S+1>>>1;v>=k[x]?R=x:S=x-1}return R}function b(k,y,v,R={}){const S=R.bounds||u(k,R.boundsIndices??y,v,R);return{bounds:S,counts:a(k,y,v,S)}}const O=b}),Fe("packages/core/src/compute/pivotmatrix.js",function(e,K){"use strict";Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return t}});const $=K("packages/core/src/compute/handle.js").valueComparator,I=K("packages/core/src/compute/total.js").total,X=K("packages/core/src/compute/group.js").packKeys,W=K("packages/core/src/compute/pivot.js"),H=W.joinPath,V=W.DEFAULT_PATH_SEPARATOR,z=W.DEFAULT_MAX_COLUMNS,w="";function A(r,s,h={}){const u=h.separator||V,i=r||[],m=s instanceof Uint32Array?s:Uint32Array.from(s||[]),c=m.length;if(i.length===0)return{tuples:[[]],paths:[w],buckets:[m]};const{keyOf:f,readers:a}=X(i,m,0),p=new Map,b=[],O=[],k=[];for(let C=0;C<c;C++){const P=m[C],F=f(P);let E=p.get(F);if(E===void 0){E=b.length,p.set(F,E),O.push(F);const D=new Array(a.length);for(let N=0;N<a.length;N++)D[N]=a[N](P);b.push(D),k.push([])}k[E].push(P)}const y=$(h.locale),v=b.map((C,P)=>P);v.sort((C,P)=>{const F=b[C],E=b[P];for(let D=0;D<F.length;D++){const N=g(F[D],E[D],y);if(N!==0)return N}return C-P});const R=new Array(v.length),S=new Array(v.length),x=new Array(v.length);for(let C=0;C<v.length;C++){const P=v[C];R[C]=b[P],S[C]=H(b[P],u),x[C]=Uint32Array.from(k[P])}return{tuples:R,paths:S,buckets:x}}function g(r,s,h){const u=r==null,i=s==null;return u||i?u&&i?0:u?1:-1:h(r,s)}function l(r,s,h){const u=[];for(let i=0;i<r.length;i++)h.has(r[i])&&u.push(r[i]);return Uint32Array.from(u)}function d(r,s,h,u){return{value:s.length?I(r,s,h,u):null,leaves:s,count:s.length}}function o(r){const s=r&&r.opts||{},h=s.separator||V,u=s.totalContext||{locale:s.locale},i=(r.measures||[]).filter(S=>S&&S.handle),m=r.leaves instanceof Uint32Array?r.leaves:Uint32Array.from(r.leaves||[]),c=A(r.rowHandles||[],m,{...s,separator:h}),f=A(r.columnHandles||[],m,{...s,separator:h}),a=s.maxColumns===void 0?z:s.maxColumns,p=f.paths.length*Math.max(1,i.length),b=new Map;if(a&&p>a)return{rowAxis:c,columnAxis:f,measures:i.map(S=>({colId:S.colId,fn:S.fn})),body:b,rowMargin:b,columnMargin:b,grand:b,columns:p,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${p} columns, above pivot.maxColumns of ${a}. Narrow the pivot columns or raise the limit.`,columns:p,maxColumns:a}};const O=new Map,k=new Map,y=new Map,v=new Map,R=f.buckets.map(S=>new Set(S));for(let S=0;S<f.paths.length;S++){const x=f.buckets[S],C=f.paths[S];for(const P of i)y.set(t(C,P.colId),d(P.handle,x,P.fn,u))}for(let S=0;S<c.paths.length;S++){const x=c.buckets[S],C=c.paths[S];for(const P of i)k.set(t(C,P.colId),d(P.handle,x,P.fn,u));for(let P=0;P<f.paths.length;P++){const F=l(x,f.buckets[P],R[P]);if(F.length===0)continue;const E=f.paths[P];for(const D of i)O.set(n(C,E,D.colId),d(D.handle,F,D.fn,u))}}for(const S of i)v.set(S.colId,d(S.handle,m,S.fn,u));return{rowAxis:c,columnAxis:f,measures:i.map(S=>({colId:S.colId,fn:S.fn})),body:O,rowMargin:k,columnMargin:y,grand:v,columns:p,error:null}}function n(r,s,h){return`${r}\0${s}\0${h}`}function t(r,s){return`${r}\0${s}`}}),Fe("packages/core/src/compute/reference.js",function(e,K){"use strict";Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return o}});const $=K("packages/core/src/internal/util.js").getPath,B=K("packages/core/src/compute/handle.js"),I=B.isMissing,_=B.valueComparator,W=K("packages/core/src/compute/filter.js").testValue,H="",V="\0";function z(r,s){const h=s.includes(".")?$(r,s):r?.[s];return h===void 0?null:h}function w(r,s,h={}){const u=s||[];let i=r.map((m,c)=>c);if(u.length===0)return i;for(let m=u.length-1;m>=0;m--)i=A(r,i,u[m],h);return i}function A(r,s,h,u){const i=h.locale!==void 0?h.locale:u.locale,m=_(i),c=h.descending!==void 0?!!h.descending:h.dir==="desc",f=[],a=[];for(const O of s){const k=z(r[O],h.col);I(k)?a.push(O):f.push(O)}const p=new Map;for(let O=0;O<f.length;O++)p.set(f[O],O);const b=(O,k)=>{const y=z(r[O],h.col),v=z(r[k],h.col);let R;return typeof h.compare=="function"?(R=h.compare(y,v,r[O],r[k],c),c&&(R=-R)):R=c?m(v,y):m(y,v),R!==0?R:p.get(O)-p.get(k)};return f.sort(b),h.nullsFirst?a.concat(f):f.concat(a)}function g(r,s,h={}){const u=[];for(let i=0;i<r.length;i++)l(r[i],s,h,i)&&u.push(i);return u}function l(r,s,h,u){if(!s)return!0;if(Array.isArray(s.conditions)){const i=s.conditions.filter(c=>c!=null);if(i.length===0)return!0;if(s.op==="or")return i.some(c=>l(r,c,h,u));const m=i.every(c=>l(r,c,h,u));return s.op==="not"?!m:m}return s.col===void 0&&typeof h.custom=="function"?!!h.custom(s,r,u):W(z(r,s.col),s,h.locale)}function d(r,s,h,u){const i=h||r.map((a,p)=>p),m=new Map,c=[],f=[];for(const a of i){const p=s.map((k,y)=>{const v=z(r[a],k);return u&&u[y]?u[y](v):v}),b=p.map(k=>k==null?V:String(k)).join(H);let O=m.get(b);O===void 0&&(O=c.length,m.set(b,O),c.push(p),f.push([])),f[O].push(a)}return{keys:c,buckets:f}}function o(r,s,h={}){const u=_(h.locale),i=r.filter(c=>!I(c)),m=i.map(n).filter(c=>c!==null);switch(s){case"count":return r.length;case"countValues":return i.length;case"sum":return m.reduce((c,f)=>c+f,0);case"avg":return i.length===0?null:m.reduce((c,f)=>c+f,0)/i.length;case"min":return i.length===0?null:i.reduce((c,f)=>u(f,c)<0?f:c);case"max":return i.length===0?null:i.reduce((c,f)=>u(f,c)>0?f:c);case"first":return r.length===0?null:t(r[0]);case"last":return r.length===0?null:t(r[r.length-1]);default:return null}}function n(r){if(typeof r=="number")return Number.isNaN(r)?null:r;if(r==null||r===""||typeof r=="boolean")return null;if(r instanceof Date)return r.getTime();const s=Number(r);return Number.isNaN(s)?null:s}function t(r){return r===void 0?null:r}}),Fe("packages/core/src/compute/index.js",function(e,K){"use strict";const Q=K("packages/core/src/compute/sort.js");Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return Q.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return Q.sortMulti}}),Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return Q.radixSortFloat64}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return Q.radixSortInt32}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return Q.rankSortDictionary}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return Q.mergeSortComparator}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return Q.collateStringRanks}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return Q.rankSortStrings}});const $=K("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return $.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return $.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return $.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return $.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return $.describeSort}});const B=K("packages/core/src/compute/filter.js");Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return B.evaluateFilters}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return B.evaluateCondition}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return B.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return B.testValue}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return B.compilePredicate}}),Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return B.releaseMask}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return B.pruneColumn}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return B.mentionsColumn}});const I=K("packages/core/src/compute/group.js");Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return I.groupByColumns}}),Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return I.packKeys}});const _=K("packages/core/src/compute/facet.js");Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return _.facet}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return _.computeBounds}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return _.countInto}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return _.bucketOf}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return _.facetKind}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return _.cardinalityOf}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return _.pickGranularity}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return _.floorTo}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return _.advance}}),Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return _.STRATEGIES}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return _.GRANULARITIES}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return _.DEFAULT_BUCKETS}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return _.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return _.QUANTILE_SAMPLE}});const X=K("packages/core/src/compute/total.js");Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return X.TOTAL_FNS}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return X.TOTAL_LABELS}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return X.totalLabel}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return X.total}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return X.collectValues}});const W=K("packages/core/src/compute/pivot.js");Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return W.pivot}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return W.resolvePivotKeys}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return W.pivotKey}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return W.joinPath}}),Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return W.KEY_DELIMITER}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return W.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return W.DEFAULT_MAX_COLUMNS}});const H=K("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return H.pivotMatrix}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return H.resolveAxis}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return H.cellKey}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return H.marginKey}}),Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return H.GRAND_PATH}});const V=K("packages/core/src/compute/reference.js");Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return V.referenceSort}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return V.referenceFilter}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return V.referenceGroup}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return V.referenceTotal}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return V.referencePasses}}),Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return V.referenceValue}});const z=K("packages/core/src/compute/handle.js");Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return z.identity}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return z.rowCount}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return z.presenceReader}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return z.bitReader}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return z.valueReader}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return z.valueComparator}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return z.numericTotalOrder}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return z.dictRanks}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return z.dictSize}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return z.dictValue}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return z.multiValue}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return z.isMissing}});const w=K("packages/core/src/compute/sketch.js");Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return w.Welford}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return w.Reservoir}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return w.HyperLogLog}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return w.SpaceSaving}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return w.KLL}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return w.hash32}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return w.SKETCH_BOUNDS}});const A=K("packages/core/src/compute/windowed.js");Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return A.Window}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return A.WINDOW_KINDS}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return A.openWindow}});const g=K("packages/core/src/compute/statistics.js");Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return g.MAINTENANCE}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return g.APPROXIMATE}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return g.maintenanceOf}});const l=K("packages/core/src/compute/anomaly.js");Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return l.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return l.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return l.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return l.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return l.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return l.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return l.anomalyCondition}});const d=K("packages/core/src/compute/forecast.js");Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return d.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return d.forecast}})}),Fe("packages/core/src/source/rows.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_ROW_HEIGHT",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"KEY_SEP",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"createRowFactory",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"RowFactory",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"pinnedRow",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"lazyRowView",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"groupPathElement",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"groupKey",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"groupPrefixKeys",{enumerable:!0,get:function(){return l}});const Q=K("packages/core/src/internal/util.js"),$=Q.warnOnce,B=Q.isFunction,I=32,_="\0";function X(d){return new W(d)}class W{#e;#t;constructor(o){this.#e=B(o&&o.rowKey)?o.rowKey:null;const n=o&&o.config?o.config.rowHeight:void 0;this.#t=typeof n=="number"||B(n)?n:I}get keyed(){return this.#e!==null}keyOf(o,n){if(this.#e){const t=this.#e(o);if(t!=null)return String(t)}else $("source.rowKey.missing","no config.rowKey; falling back to index identity.","Row changes, streaming dedupe, selection persistence and remote reload are disabled.");return`#${n}`}heightOf(o){return B(this.#t)?Number(this.#t(o))||I:this.#t}leaf(o,n,t=0,r=null){const s={key:this.keyOf(o,n),data:o,level:t,parent:r,group:!1,expanded:!1,leafCount:1,height:0,index:null,selected:!1,physical:n};return s.height=this.heightOf(s),s}group(o){const n={key:g(o.keyPath||o.path),data:null,level:o.level,parent:o.parent||null,children:[],group:!0,expanded:o.expanded!==!1,leafCount:o.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:o.column,groupValue:o.value,groupPath:o.path,hasChildren:o.hasChildren!==!1};return o.totals&&(n.totals=o.totals),n.height=this.heightOf(n),n}footer(o){const n={key:`${o.key}${_}footer`,data:null,level:o.level,parent:o,group:!0,footer:!0,expanded:!1,leafCount:o.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:o.groupColumn,groupValue:o.groupValue,groupPath:o.groupPath,hasChildren:!1,totals:o.totals};return n.height=this.heightOf(n),n}detail(o,n){return{key:`${o.key}${_}detail`,data:o.data,level:o.level+1,parent:o,group:!1,detail:!0,expanded:!1,leafCount:0,height:n,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:o.key}}grandTotal(o,n){const t={key:`${_}grandTotal`,data:null,level:0,parent:null,group:!0,grandTotal:!0,expanded:!1,leafCount:n,height:0,index:null,selected:!1,physical:null,groupPath:[],hasChildren:!1,totals:o};return t.height=this.heightOf(t),t}skeleton(o,n=0,t=!1){const r={key:`${_}pending${_}${o}`,data:null,level:n,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:o,selected:!1,physical:null,pending:!0};return t&&(r.loadError=!0),r.height=this.heightOf(r),r}}function H(d,o,n,t){return{key:`${_}pinned${_}${n}${_}${o}`,data:d,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:t,index:null,selected:!1,physical:null,hasChildren:!1,pinned:n}}function V(d,o){return new Proxy([],{get(n,t,r){if(t==="length")return d();if(typeof t=="string"){const s=Number(t);if(Number.isInteger(s)&&s>=0)return o(s)}return Reflect.get(n,t,r)},has(n,t){if(typeof t=="string"){const r=Number(t);if(Number.isInteger(r)&&r>=0)return r<d()}return Reflect.has(n,t)}})}function z(d){return d==null?"":String(d)}const w="";function A(d){if(d==null)return w;const o=String(d);return o.startsWith(w)?w+o:o}function g(d){const o=d||[];let n="g";for(let t=0;t<o.length;t++)n+=_+A(o[t]);return n}function l(d){const o=new Array(d.length),n=[];for(let t=0;t<d.length;t++)n.push(d[t]),o[t]=g(n);return o}}),Fe("packages/core/src/source/handles.js",function(e,K){"use strict";Object.defineProperty(e,"HandleProvider",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"createHandleProvider",{enumerable:!0,get:function(){return _}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce;class I{#e;#t;#n;#r=new Map;#o=0;constructor(W,H,V){this.#e=W,this.#t=H,this.#n=$(V)?V:()=>!1}get store(){const W=this.#e.store;return W&&$(W.column)?W:null}invalidate(){this.#o++}handle(W){const H=this.store;if(H){const A=H.column(W);if(A)return A}const V=this.#r.get(W);if(V&&V.builtAt===this.#o)return V.handle;const z=this.#i(W);if(!z)return;if(H&&this.#n()){B(`source.dropped.${W}`,`column "${W}" cannot be served under ingest.dropSourceRows: it is an impure computed column (a shadow or a positional/rank column) that is never stored, so it can only be read from the caller's row objects — which dropSourceRows has released. Do not sort, filter, group or total on such a column with dropSourceRows enabled.`);return}const w=this.#s(z);return this.#r.set(W,{handle:w,builtAt:this.#o}),w}#i(W){const H=this.#e.columns;return H&&$(H.get)?H.get(W):void 0}#s(W){const H=this.#t()||[],V=H.length,z=new Array(V),w=$(W.getValue)?g=>W.getValue(g):g=>g?.[W.field||W.id];for(let g=0;g<V;g++)z[g]=H[g]===void 0?void 0:w(H[g]);const A=this.#o;return{id:W.id,kind:"object",nullable:!1,values:z,presence:null,dict:null,offsets:null,get(g){return z[g]},version:A}}}function _(X,W,H){return new I(X,W,H)}}),Fe("packages/core/src/compute/incremental.js",function(e,K){"use strict";Object.defineProperty(e,"INCREMENTAL_FNS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"INCREMENTAL_KINDS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"MAGNITUDE_LIMIT",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"isIncremental",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"RunningTotal",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return V}});const $=K("packages/core/src/store/columnstore.js").toFloat,B=Object.freeze(["sum","avg","countValues","min","max"]),I=Object.freeze(["float64"]),_=1e15;function X(z,w){return typeof z!="string"||!B.includes(z)?!1:!!w&&I.includes(w.kind)}function W(z){if(z==null)return null;const w=$(z);return Number.isNaN(w)?null:w}class H{#e;#t=0;#n=0;#r=0;#o=1/0;#i=-1/0;#s=!1;#l=!1;constructor(w){this.#e=w}get valid(){return this.#s&&!this.#l}get fn(){return this.#e}seed(w){this.#a();for(let A=0;A<w.length;A++){const g=W(w[A]);g!==null&&this.#u(g)}this.#s=!0}seedColumn(w,A,g){this.#a();for(let l=0;l<g.length;l++){const d=g[l];if(A&&A(d)===0)continue;const o=w[d];Number.isNaN(o)||this.#u(o)}this.#s=!0}#a(){this.#t=0,this.#n=0,this.#r=0,this.#o=1/0,this.#i=-1/0,this.#l=!1}#u(w){if(!Number.isFinite(w)){this.#l=!0;return}const A=this.#t+w;this.#n+=Math.abs(this.#t)>=Math.abs(w)?this.#t-A+w:w-A+this.#t,this.#t=A,this.#r++,w<this.#o&&(this.#o=w),w>this.#i&&(this.#i=w)}#c(w){const A=this.#t-w;this.#n+=Math.abs(this.#t)>=Math.abs(w)?this.#t-A-w:-w-A+this.#t,this.#t=A,this.#r--}update(w,A){if(!this.#s)return!1;const g=W(w),l=W(A);return g===null&&l===null?!0:g!==null&&!Number.isFinite(g)||l!==null&&!Number.isFinite(l)?!1:this.#e==="min"||this.#e==="max"?g===null||l===null?!1:this.#e==="min"?l<this.#o?(this.#o=l,!0):g>this.#o:l>this.#i?(this.#i=l,!0):g<this.#i:Math.abs(this.#t)>_?!1:(g!==null&&this.#c(g),l!==null&&this.#u(l),!0)}value(){switch(this.#e){case"countValues":return this.#r;case"avg":return this.#r?(this.#t+this.#n)/this.#r:null;case"min":return this.#r?this.#o:null;case"max":return this.#r?this.#i:null;default:return this.#t+this.#n}}invalidate(){this.#s=!1}}const V=H}),Fe("packages/core/src/source/filterwire.js",function(e,K){"use strict";Object.defineProperty(e,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"warnWherePageRelative",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"warnWhereNotApplied",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"warnWhereOverThreshold",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"parseRelativeToken",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"resolveRelativeRange",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"relativeTokenOf",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"relativeTokenHelp",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isResolvableRelative",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"resolveRelativeCondition",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"isGroup",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"forEachCondition",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"mapConditions",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"normaliseFilterSet",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"buildFilterSet",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"wireFilters",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"querySignature",{enumerable:!0,get:function(){return y}});const $=K("packages/core/src/internal/util.js").warnOnce,B="source.remote.hostFilter",I="source.where.pageRelative";function _(S,x){!Array.isArray(S)||!S.length||$(I,`filters.where (${S.join(", ")}) runs over the rows the ${x} source fetched,`,"not the whole dataset: match counts and totals are page-relative.","Give the predicate a { condition } twin so the engine can narrow the fetch itself.")}function X(S){const x=(S||{}).config;!x||!x.hostFilter||$(B,"config.hostFilter is not sent to a server-delegated source (paged/remote) and is not applied:","filtering only the fetched window would give wrong counts and totals.","Express the filter as a FilterSet condition, or send it through config.context.")}const W="source.where.notApplied";function H(S,x){$(`${W}:${S}`,`filters.where("${S}") is registered but the ${x} source holds only its fetched window`,"and cannot run the predicate over it: the predicate is not applied there, and rows it would","exclude stay on screen.","Give it a { condition } twin so the engine can narrow the fetch itself — that is the","supported route for a paged or remote source.")}const V="source.where.overThreshold";function z(S,x,C,P){!Array.isArray(S)||!S.length||$(`${V}:${x}`,`filters.where (${S.join(", ")}) is not applied to the ${x} pushdown source:`,C===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${C.toLocaleString()} rows, at or past the whereRowLimit of ${P.toLocaleString()}.`,"Running the predicate needs every matching row fetched and held here, which is the whole","download a pushdown source exists to avoid, so it is refused and the rows the predicate","would exclude stay on screen.","Give the predicate a { condition } twin so the engine narrows the fetch itself — that is the","route that works at any size — or raise `whereRowLimit` on the source config if you want the","download.")}const w=new Map;function A(S){let x=w.get(S);return x||(x=new Intl.DateTimeFormat("en-US",{timeZone:S,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),w.set(S,x)),x}function g(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function l(S,x){const C=A(x).formatToParts(new Date(S)),P={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const F of C)F.type==="year"?P.y=+F.value:F.type==="month"?P.m=+F.value:F.type==="day"?P.d=+F.value:F.type==="hour"?P.h=+F.value%24:F.type==="minute"?P.mi=+F.value:F.type==="second"&&(P.s=+F.value);return P}function d(S,x){const C=l(S,x);return Date.UTC(C.y,C.m-1,C.d,C.h,C.mi,C.s)-Math.floor(S/1e3)*1e3}function o(S,x,C,P){const F=Date.UTC(S,x-1,C),E=F-d(F,P);return F-d(E,P)}function n(S,x,C){const P=new Date(Date.UTC(S.y,S.m-1,S.d+x));return o(P.getUTCFullYear(),P.getUTCMonth()+1,P.getUTCDate(),C)}const t=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function r(S,x){if(typeof S!="string")return null;const C=S.trim().toLowerCase().replace(/[\s_-]+/g,""),P=/^last(\d*|n)days?$/.exec(C);if(P){const F=P[1]==="n"?"":P[1],E=Number(F||x);return!Number.isFinite(E)||E<=0?null:{kind:"lastNDays",n:Math.floor(E)}}switch(C){case"today":return{kind:"today",n:0};case"yesterday":return{kind:"yesterday",n:0};case"thisweek":return{kind:"thisWeek",n:0};case"thismonth":return{kind:"thisMonth",n:0};case"thisquarter":return{kind:"thisQuarter",n:0};case"thisyear":return{kind:"thisYear",n:0};case"quartertodate":case"qtd":return{kind:"quarterToDate",n:0};case"yeartodate":case"ytd":return{kind:"yearToDate",n:0};default:return null}}function s(S,x={}){const C=r(S,x.n);if(!C)return null;const P=x.tz||g(),F=x.now instanceof Date?x.now.getTime():typeof x.now=="number"?x.now:Date.now(),E=l(F,P),D=o(E.y,E.m,E.d,P),N=n(E,1,P);let M=D,j=N;switch(C.kind){case"today":break;case"yesterday":M=n(E,-1,P),j=D;break;case"lastNDays":j=x.includeToday?N:D,M=n(E,x.includeToday?-(C.n-1):-C.n,P);break;case"thisWeek":{const L=Number.isFinite(x.weekStartsOn)?Number(x.weekStartsOn):1,q=(new Date(Date.UTC(E.y,E.m-1,E.d)).getUTCDay()-L+7)%7;M=n(E,-q,P),j=n(E,-q+7,P);break}case"thisMonth":M=o(E.y,E.m,1,P),j=o(E.m===12?E.y+1:E.y,E.m===12?1:E.m+1,1,P);break;case"thisQuarter":case"quarterToDate":{const L=Math.floor((E.m-1)/3)*3+1;M=o(E.y,L,1,P),j=C.kind==="quarterToDate"?N:L===10?o(E.y+1,1,1,P):o(E.y,L+3,1,P);break}case"thisYear":case"yearToDate":M=o(E.y,1,1,P),j=C.kind==="yearToDate"?N:o(E.y+1,1,1,P);break;default:return null}return{from:new Date(M).toISOString(),to:new Date(j).toISOString(),bounds:"[)",tz:P,relative:C.kind==="lastNDays"?`last${C.n}Days`:C.kind,n:C.n}}function h(S){if(!S||typeof S!="object")return null;const x=S.value;if(x&&typeof x=="object"&&!Array.isArray(x)&&"relative"in x)return{token:String(x.relative),n:typeof x.n=="number"?x.n:void 0};if(S.op==="relative"&&typeof S.value=="string")return{token:S.value,n:void 0};const C=S.meta;return C&&typeof C.relative=="string"&&S.value===void 0?{token:C.relative,n:typeof C.n=="number"?C.n:void 0}:null}function u(){return`Known tokens: ${t.filter(x=>x!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function i(S){const x=h(S);return x?r(x.token,x.n)!==null:!1}function m(S,x={}){const C=h(S);if(!C)return S;const P=s(C.token,{...x,n:C.n});return P?{...S,type:S.type||"date",op:"between",value:[P.from,P.to],bounds:S.bounds||P.bounds,meta:{...S.meta||{},relative:P.relative,tz:P.tz}}:($(`source.relative.${C.token}`,`unknown relative date token "${C.token}"; sending the condition unresolved.`,u()),S)}function c(S){return!!S&&typeof S=="object"&&Array.isArray(S.conditions)}function f(S,x){if(S){if(c(S)){for(const C of S.conditions)f(C,x);return}x(S)}}function a(S,x){if(!S)return null;if(!c(S))return x(S);const C=S;let P=!1;const F=[];for(const E of C.conditions){const D=a(E,x);D!==E&&(P=!0),D&&F.push(D)}return!P&&F.length===C.conditions.length?S:F.length?{...C,conditions:F}:null}function p(S){if(!S)return null;if(!c(S))return S;const x=S,C=[];for(const P of x.conditions){const F=p(P);F&&C.push(F)}return C.length?{op:x.op,conditions:C}:null}function b(S){const x=p(S);return x?c(x)&&x.op==="and"?x:{op:"and",conditions:[x]}:null}function O(S){const x=(S||[]).filter(Boolean);return x.length?{op:"and",conditions:x}:null}function k(S,x={}){const C=a(S,P=>m(P,x));return b(C)}function y(S){const x=v(S.filters??null);return JSON.stringify([x,S.sort??null,S.quick??"",S.groupBy??null,S.pivotBy??null,R(S.context)])}function v(S){if(!S)return null;if(c(S)){const P=S;return{op:P.op,conditions:P.conditions.map(v)}}const x=S,C=x.meta&&typeof x.meta.relative=="string"?x.meta.relative:h(x)?.token;return{col:x.col,op:x.op,bounds:x.bounds??null,caseSensitive:x.caseSensitive??!1,value:C?`rel:${C}`:x.value??null}}function R(S){if(S==null)return null;try{return JSON.parse(JSON.stringify(S))}catch{return $("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),Fe("packages/core/src/source/tree.js",function(e,K){"use strict";Object.defineProperty(e,"SYNTHETIC",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"buildFromPath",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"buildFromParentKey",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"assignLevels",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"resolveTree",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"buildTree",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return g}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,I="",_="\0tree:";function X(l,d){return{physical:l,key:d,level:0,children:[],value:void 0}}function W(l,d){const o=[],n=new Map;for(let t=0;t<l.length;t++){const r=l[t],s=d.pathOf(r),h=Array.isArray(s)?s.map(i=>String(i)):[];if(!h.length){const i=X(r,d.keyOf(r));o.push(i);continue}let u=null;for(let i=0;i<h.length;i++){const m=h.slice(0,i+1).join(I),c=i===h.length-1;let f=n.get(m);f&&c&&f.physical===-1&&(f.physical=r,f.key=d.keyOf(r)),f||(f=X(c?r:-1,c?d.keyOf(r):_+m),f.level=i,f.value=h[i],n.set(m,f),u?u.children.push(f):o.push(f)),u=f}}return{roots:o,nodes:n}}function H(l,d){const o=new Map,n=[];for(let h=0;h<l.length;h++){const u=l[h],i=d.keyOf(u),m=X(u,i);o.set(i,m);const c=d.parentOf(u);c!=null&&c!==""&&n.push({node:m,parent:String(c)})}let t=null;const r=new Map;for(const{node:h,parent:u}of n){const i=o.get(u);if(i){r.set(h.key,i);continue}d.orphans&&d.orphans!=="root"&&(t||(t=X(-1,`${_}orphans`),t.value=d.orphans),r.set(h.key,t))}const s=[];for(const h of o.values()){const u=r.get(h.key);u?u.children.push(h):s.push(h)}return t&&t.children.length&&s.push(t),{roots:V(s,o,d.orphans,t),nodes:o}}function V(l,d,o,n){const t=new Set,r=[...l];for(;r.length;){const m=r.pop();if(!t.has(m.key)){t.add(m.key);for(const c of m.children)r.push(c)}}const s=[];for(const m of d.values())t.has(m.key)||s.push(m);if(!s.length)return l;const h=!!o&&o!=="root";B("tree.cycle",`tree.parentKey produced ${s.length} row(s) inside a parent cycle; `+(h?`they are shown under "${o}".`:"they are shown at the root."));for(const m of s)m.children=m.children.filter(c=>t.has(c.key));if(!h)return[...l,...s];let u=n;const i=[...l];return u||(u=X(-1,`${_}orphans`),u.value=o,i.push(u)),u.children.push(...s),i}function z(l){let d=0;const o=(n,t)=>{for(const r of n)r.level=t,t>d&&(d=t),r.children.length&&o(r.children,t+1)};return o(l,0),d}function w(l,d){if(!l||typeof l!="object")return null;const o=l.path,n=l.parentKey,t=$(l.hasChildren)?r=>!!l.hasChildren(d.dataAt(r)):null;if($(o))return{mode:"path",pathOf:r=>o(d.dataAt(r)),keyOf:d.keyOf,declaresChildren:t};if(n!=null){const r=$(n)?n:s=>s?.[n];return{mode:"parentKey",parentOf:s=>r(d.dataAt(s)),keyOf:d.keyOf,orphans:l.orphans||"root",declaresChildren:t}}return B("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function A(l,d){const o=d.mode==="path"?W(l,d):H(l,d),n=z(o.roots);return{...o,depth:n}}function g(l,d){const o=new Map,n=t=>{for(let r=0;r<t.length;r++){const s=t[r];if(s.physical>=0){const h=d?d(s.physical):!1,u=h&&s.children.length===0;o.set(s.physical,{level:s.level,posinset:r+1,setsize:t.length,hasChildren:s.children.length>0||h,lazy:u})}s.children.length&&n(s.children)}};return n(l),o}}),Fe("packages/core/src/source/memory.js",function(e,K){"use strict";Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"quickMatcher",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"MemorySource",{enumerable:!0,get:function(){return N}});const Q=K("packages/core/src/internal/util.js"),$=Q.Lru,B=Q.warnOnce,I=Q.fail,_=Q.isFunction,X=Q.defaultCompare,W=Q.mergeRow,H=K("packages/core/src/source/rows.js"),V=H.createRowFactory,z=H.groupKey,w=H.groupPathElement,A=H.groupPrefixKeys,g=H.lazyRowView,d=K("packages/core/src/source/handles.js").createHandleProvider,o=K("packages/core/src/compute/incremental.js"),n=o.RunningTotal,t=o.isIncremental,s=K("packages/core/src/compute/handle.js").presenceReader,h=K("packages/core/src/source/filterwire.js"),u=h.querySignature,i=h.mapConditions,m=h.resolveRelativeCondition,c=K("packages/core/src/source/tree.js"),f=c.buildTree,a=c.resolveTree,p=c.indexTree,b=Object.freeze(["filter","sort","group","total","pivot","flatten"]),O=Object.freeze(["pipeline:sort","pipeline:sort:error"]);function k(M){const j=M&&typeof M=="object"?M.reason:null;return typeof j=="string"&&O.includes(j)}const y=Object.freeze([]);function v(M,j){if(!M)return null;const L=j==="grand"?M.grandTotal:M.groupTotal;return L??M.total}function R(M){return!!M&&!M.running}function S(M){if(M)return M.value&&_(M.value.compare)?M.value.compare:_(M.compare)?M.compare:void 0}function x(M){const j=M&&M.dataType;return!j||!_(j.items)?null:{items:j.items,type:M.itemType&&M.itemType.name||"text"}}function C(M){return!!M&&(typeof M=="object"||typeof M=="function")&&_(M.then)}const P=new Uint32Array(0),F=4096;function E(M,j){return new N(M,j)}function D(M,j){if(j==="regex")try{const L=new RegExp(M,"iu");return G=>L.test(G)}catch{return L=>L.includes(M)}if(j==="fuzzy"){const L=[...M].filter(G=>G!==" ");return L.length?G=>{let q=0;for(let Y=0;Y<G.length&&q<L.length;Y++)G[Y]===L[q]&&q++;return q===L.length}:()=>!0}if(j==="words"){const L=M.split(/\s+/).filter(Boolean);return L.length?G=>L.every(q=>G.includes(q)):()=>!0}return L=>L.includes(M)}class N{mode="memory";#e;#t;#n;#r=!1;#o=null;#i;#s;#l=new Map;#a=!1;#u=0;#c=0;#d=new Map;#h=new Map;#f;#p=null;#m=N.#g();static#g(){return{slots:[],groupHeadings:y,unnumbered:y,pivot:null,inlineLeaves:null,matchCount:0,grand:null,grandLeaves:0,groupLeaves:null}}#b=new Map;#w=null;#S=new Map;#y=-1;#O=[];#k=new Map;#j=-1;#A=[];#T=null;#M=null;#C=null;#E=null;#L=null;#x=null;#B=null;#H=null;#U=Symbol("unset");#N=new Map;#$=null;get#z(){return this.#m.slots}set#z(j){this.#m.slots=j}get#_(){return this.#m.inlineLeaves}set#_(j){this.#m.inlineLeaves=j}get#Y(){return this.#m.groupHeadings}set#Y(j){this.#m.groupHeadings=j}get#le(){return this.#m.unnumbered}set#le(j){this.#m.unnumbered=j}get#re(){return this.#m.pivot}set#re(j){this.#m.pivot=j}constructor(j,L){this.#t=j||{mode:"memory"},this.#e=L||{};const G=this.#e.config||{};this.#n=this.#t.rows||G.rows||[],this.#i=V(this.#e),this.#s=d(this.#e,()=>this.#n,()=>this.#r),this.#f=new $(Number(G.rowCacheSize)||F);for(const q of b)this.#l.set(q,{key:null,result:null,id:0,computed:!1})}count(){this.#q();const j=this.#se();return j?j.length:this.#z.length}#se(){const j=Number(this.#K("pageSize",0))||0;if(j<=0)return null;const L=this.#z.length,G=Math.max(1,Math.ceil(L/j)),Y=Math.min(Math.max(0,Number(this.#K("page",0))||0),G-1)*j;return{offset:Y,length:Math.max(0,Math.min(j,L-Y))}}pageInfo(){this.#q();const j=Number(this.#K("pageSize",0))||0,L=this.#z.length;if(j<=0)return{page:0,pageSize:0,total:L,pageCount:1};const G=Math.max(1,Math.ceil(L/j));return{page:Math.min(Math.max(0,Number(this.#K("page",0))||0),G-1),pageSize:j,total:L,pageCount:G}}totalCount(){return this.#Ie().length}matchCount(){return this.#q(),this.#m.matchCount}at(j){this.#q();const L=this.#se();if(L)return j<0||j>=L.length?void 0:this.#qe(L.offset+j,j);if(!(j<0||j>=this.#z.length))return this.#qe(j,j)}byKey(j){this.#q(),this.#p||this.#Q();const L=this.#p.get(j);if(L!==void 0)return this.#Te(L);for(let G=0;G<this.#z.length;G++){const q=this.#z[G];if(typeof q!="number"&&q&&q.key===j)return this.#qe(G)}}loaded(j){return j>=0&&j<this.count()}hint(j,L){}display(){return this.#q(),this.#$||(this.#$=this.#Lt()),this.#$}invalidateQuickText(){this.#N.clear(),this.invalidate("filter")}invalidate(j){const L=b.indexOf(j);L<0&&I(`unknown pipeline stage "${j}"; expected one of ${b.join(", ")}`);for(let G=L;G<b.length;G++){const q=this.#l.get(b[G]);q.key=null,q.computed=!1}this.#$=null}apply(j){const L=[],G={added:[],updated:[],removed:[],rejected:L};if(!j)return G;let q=!1;const Y=new Set;if(j.remove&&j.remove.length)for(const J of j.remove){const ee=this.#X(J);if(ee===void 0){L.push({operation:"remove",id:this.#pe(J),reason:"unknown-id"});continue}G.removed.push(this.#i.keyOf(this.#r?this.#Ne(ee):this.#n[ee],ee)),this.#r||(this.#n[ee]=void 0),this.#f.delete(ee),this.#N.delete(ee),q=!0}if(j.update&&j.update.length){const J=this.#S.size||this.#ot()?this.#ut():null,ee=this.#k.size?this.#ft():null,ne=ee&&ee.length?this.#ut():null;for(const ie of j.update){const se=this.#X(ie);if(se===void 0){L.push({operation:"update",id:this.#te(ie),reason:"unknown-id"});continue}const he=this.#r?this.#o&&this.#o.has(se)?this.#o.get(se):this.#Ne(se):this.#n[se],ce=W(he,ie);for(const te of this.#Z(he,ce))Y.add(te);if(this.#r||(this.#n[se]=ce),J&&this.#Ct(J,se,he,ce),ne&&this.#et(ee,ne,se,he,ce),this.#p){const te=this.#i.keyOf(he,se),oe=this.#i.keyOf(ce,se);te!==oe&&(this.#p.delete(te),this.#p.set(oe,se))}this.#f.delete(se),this.#N.delete(se),G.updated.push(this.#Te(se))}}if(j.add&&j.add.length&&this.#r){typeof j.at=="number"&&j.at<this.#at()&&(this.#f.clear(),this.#N.clear()),this.#p=null;for(const J of j.add){const ee=this.#G(this.#te(J));ee!==void 0&&G.added.push(this.#Te(ee))}q=!0}else if(j.add&&j.add.length){const J=typeof j.at=="number"?j.at:this.#n.length,ee=this.#n.length;let ne=j.add===this.#n?j.add.slice():j.add;if(this.#i.keyed){const ie=[];for(const se of ne){const he=this.#te(se);if(this.#X(he)!==void 0){L.push({operation:"add",id:he,reason:"duplicate-id"});continue}ie.push(se)}ie.length!==ne.length&&(ne=ie)}if(!ne.length)return G;if(J>=ee)for(let ie=0;ie<ne.length;ie++)this.#n.push(ne[ie]);else this.#n.splice(J,0,...ne),this.#f.clear(),this.#N.clear();for(let ie=0;ie<ne.length;ie++)G.added.push(this.#Te(J>=ee?ee+ie:J+ie));q=!0}return this.#u++,q&&(this.#p=null,this.#xe()),this.#s.invalidate(),this.#$=null,q||this.#ae(Y)?(this.#c++,this.invalidate("filter")):this.invalidate("total"),this.#He("rows:changed",{companion:!0,added:G.added.length,updated:G.updated.length,removed:G.removed.length}),this.#o=null,G}groupHeadingsAt(j){this.#q();const L=this.#Y;if(!L.length||!Number.isInteger(j)||j<0)return y;let G=0,q=L.length-1,Y=-1;for(;G<=q;){const ee=G+q>>1;L[ee].at<=j?(Y=ee,G=ee+1):q=ee-1}if(Y<0)return y;const J=[];for(let ee=L[Y].row;ee;ee=ee.parent)J.push(ee);return J.reverse(),J}unnumberedRowCount(j){this.#q();const L=this.#le;if(!L.length||!Number.isInteger(j)||j<0)return 0;let G=0,q=L.length-1,Y=-1;for(;G<=q;){const J=G+q>>1;L[J].at<=j?(Y=J,G=J+1):q=J-1}return Y+1}moveRow(j,L){if(this.#r)return B("source.moveRow.dropped","rows.move() is not supported under ingest.dropSourceRows: the source objects have been released and the store cannot reorder its columns in place. Enable retainSource (leave dropSourceRows off) to reorder rows."),!1;const G=this.#n;if(!Number.isInteger(j)||!Number.isInteger(L)||j<0||j>=G.length)return!1;const q=Math.max(0,Math.min(G.length-1,L));if(q===j)return!1;const[Y]=G.splice(j,1);return G.splice(q,0,Y),this.#u++,this.#c++,this.#p=null,this.#f.clear(),this.#N.clear(),this.#xe(),this.#s.invalidate(),this.#$=null,this.invalidate("filter"),this.#He("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(j){this.#ge(),this.#u++,this.#c++,this.#p=null,this.#N.clear(),this.#f.clear(),this.#xe(),this.#s.invalidate(),this.invalidate("filter"),this.#He("model:changed",{reason:"reload"})}destroy(){this.#ge(),this.#f.clear(),this.#N.clear(),this.#p=null,this.#z=[],this.#_=null,this.#$=null,this.#xe();for(const j of b)this.#l.set(j,{key:null,result:null,id:0,computed:!1})}#ge(){for(const{controller:j}of this.#b.values())try{j.abort()}catch{}this.#b.clear()}setRows(j){this.#n=j||[],this.#r=!1,this.#u++,this.#c++,this.#p=null,this.#N.clear(),this.#f.clear(),this.#xe(),this.#s.invalidate(),this.invalidate("filter")}notePriorRows(j){this.#o=j||null}releaseSource(){this.#r=!0,this.#n=[],this.#p=null,this.#f.clear(),this.#N.clear(),this.#s.invalidate()}data(){if(!this.#r)return this.#n;const j=this.#e.store;if(!j||!_(j.source))return this.#n;const L=j.physical||0,G=new Array(L);for(let q=0;q<L;q++)G[q]=j.live&&!j.live(q)?void 0:j.source(q);return G}#Me(){const j=this.#K("detail",null);return!j||!_(j.isOpen)||j.inline===!1?null:j}#we(){const j=(this.#e.config||{}).tree;return this.#U!==j&&(this.#U=j,this.#H=a(j,{dataAt:L=>this.#Ne(L),keyOf:L=>this.#i.keyOf(this.#Ne(L),L)})),this.#H}#oe(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#oe())return null;this.#q();const j=this.#m.grand;return j?this.#i.grandTotal(j,this.#tt(this.#m.grandLeaves)):null}pivot(){return this.#q(),this.#re}pivotMatrix(){this.#q();const j=this.#m.groupLeaves,L=(this.#e.compute||{}).pivotMatrix;if(!_(L))return null;const G=this.#K("groupBy",[]),q=this.#K("pivotBy",[]);if(!G.length&&!q.length)return B("pivotView.no-dimension","pivotView is on but the grid has no pivot dimension, so there is no matrix to draw. Put a column on the pivot (its `pivot` setting, or `pivotBy` in the query) for the columns across the top, and group by a column for the rows down the side."),null;const Y=this.#ut().map(ee=>({colId:ee.id,handle:this.#s.handle(ee.id),fn:v(ee,"group")})).filter(ee=>ee.handle&&ee.fn),J=this.#e.config||{};return L({rowHandles:G.map(ee=>this.#s.handle(ee)).filter(Boolean),columnHandles:q.map(ee=>this.#s.handle(ee)).filter(Boolean),measures:Y,leaves:j||new Uint32Array(0),opts:{locale:J.locale,separator:(J.pivot||{}).separator,maxColumns:(J.pivot||{}).maxColumns}})}keysForLeaves(j){const L=[];if(!j)return L;for(let G=0;G<j.length;G++){const q=this.#Te(j[G]);q&&q.key!=null&&L.push(String(q.key))}return L}leavesOf(j){this.#q();const L=this.#l.get("group"),G=L&&L.result;if(!G||!G.nodes)return[];const q=G.nodes.get(j);if(!q)return[];const Y=[],J=ee=>{const ne=ee.row&&ee.row.children;if(ne&&ne.length){for(const ie of ne){const se=G.nodes.get(ie.key);se&&J(se)}return}if(ee.leaves)for(let ie=0;ie<ee.leaves.length;ie++)Y.push(this.#Te(ee.leaves[ie]))};return J(q),Y}#pe(j){return typeof j=="string"?j:this.#te(j)}#te(j){try{return this.#i.keyOf(j,-1)}catch{return"(unkeyed)"}}#X(j){if(typeof j=="string")return this.#G(j);if(this.#i.keyed){const G=this.#i.keyOf(j,-1),q=this.#G(G);if(q!==void 0)return q}if(this.#r)return;const L=this.#n.indexOf(j);return L>=0?L:void 0}#G(j){return this.#p||this.#Q(),this.#p.get(j)}#Q(){this.#p=new Map;const j=this.#at(),L=this.#e.store,G=L&&_(L.live)?q=>L.live(q):null;for(let q=0;q<j;q++){if(G&&!G(q))continue;const Y=this.#Ne(q);Y!==void 0&&this.#p.set(this.#i.keyOf(Y,q),q)}}#Z(j,L){const G=[];for(const q of this.#ie())this.#ze(q)&&this.#ve(q,j,L,new Set)&&G.push(q);return G}#ve(j,L,G,q){if(q.has(j))return!1;q.add(j);const Y=this.#ze(j);if(!Y)return!1;const J=Y.value&&Y.value.deps;return Array.isArray(J)&&J.length?J.some(ee=>this.#ve(String(ee),L,G,q)):_(Y.getValue)?!Object.is(Y.getValue(L),Y.getValue(G)):!1}#ie(){const j=new Set;for(const G of this.#K("sort",[]))j.add(G.col);for(const G of this.#K("groupBy",[]))j.add(G);const L=G=>{if(G){if(Array.isArray(G.conditions)){G.conditions.forEach(L);return}G.col&&j.add(G.col)}};return L(this.#K("filters",null)),[...j]}#ae(j){if(!j.size)return!1;if(this.#K("quick",""))return!0;for(const L of this.#ie())if(j.has(L))return!0;return!1}#q(){if(!this.#a){this.#a=!0;try{this.#me()}finally{this.#a=!1}}}pipelineRunning(){return this.#a}#me(){const j=this.#I("filter",()=>this.#ce(),()=>this.#ye()),L=this.#je(j),G=this.#I("group",()=>this.#Be(),()=>this.#We(L)),q=this.#I("total",()=>this.#Ge(),()=>this.#Fe(G));this.#I("pivot",()=>this.#Ke(),()=>this.#Ve(G)),this.#I("flatten",()=>this.#Pe(),()=>this.#st(G)),this.#ue(G,q)}#je(j){const L=this.#l.get("sort"),G=this.#he();if(L.computed&&L.key===G&&!this.#b.has("sort"))return L.result;const q=this.#b.get("sort");return q&&q.key===G?L.result:L.result&&this.#ke(j)?(this.#de(j,G),L.result):this.#I("sort",()=>G,()=>this.#Ce(j))}#fe(){if(this.#w===null){const j=this.#e.pipelineWorker,L=_(j)?j():null;this.#w=L||!1}return this.#w||null}#ne(){const j=this.#K("sort",[]);if(!Array.isArray(j)||!j.length)return null;const L=(this.#e.config||{}).locale,G=[],q=[];for(const Y of j){const J=this.#ze(Y.col);if(J&&J.running)continue;if(J&&J.value&&_(J.value.compare))return null;const ee=this.#s.handle(Y.col);if(!ee)return null;G.push({col:Y.col,descending:Y.dir==="desc",nullsFirst:!!Y.nullsFirst,locale:L}),q.push(ee)}return G.length?{entries:G,handles:q,locale:L}:null}#ke(j){if(this.#v())return!1;const L=this.#fe();if(!L)return!1;const G=Number(L.threshold);return Number.isFinite(G)&&j.length<G?!1:!!this.#ne()}#de(j,L){const G=this.#fe(),q=G&&this.#ne();if(!q){this.#I("sort",()=>L,()=>this.#Ce(j));return}const Y=new AbortController;this.#b.set("sort",{key:L,controller:Y});const J=q.entries.length===1?G.sortColumn(q.handles[0],j,{descending:q.entries[0].descending,nullsFirst:q.entries[0].nullsFirst,locale:q.locale,signal:Y.signal,key:"sort"}):G.sortMulti(q.handles,q.entries.map((ee,ne)=>({...ee,handle:q.handles[ne]})),j,{signal:Y.signal,key:"sort"});if(!C(J)){this.#b.delete("sort"),this.#I("sort",()=>L,()=>J);return}J.then(ee=>this.#V(L,ee),ee=>this.#R("sort",L,ee))}#V(j,L){const G=this.#b.get("sort");if(!(!G||G.key!==j)){if(this.#he()!==j){this.#b.delete("sort");return}this.#b.delete("sort"),this.#I("sort",()=>j,()=>L),this.#$=null,this.#q(),this.#He("model:changed",{reason:O[0]})}}#R(j,L,G){const q=this.#b.get(j);if(!(!q||q.key!==L)&&(this.#b.delete(j),!(G&&G.name==="AbortError")&&j==="sort"&&this.#he()===L)){const Y=this.#I("filter",()=>this.#ce(),()=>this.#ye());this.#I("sort",()=>L,()=>this.#Ce(Y)),this.#$=null,this.#q(),B("source.pipeline.sort","off-thread sort failed; recomputed on the main thread.",G),this.#He("model:changed",{reason:O[1]})}}#ue(j,L){const G=j&&j.leaves?j.leaves.length:this.#m.slots.length;this.#m.matchCount=G,this.#m.grand=L&&L.grand||null,this.#m.grandLeaves=j&&j.leaves?j.leaves.length:0,this.#m.groupLeaves=j&&j.leaves?j.leaves:null}#I(j,L,G){const q=this.#l.get(j),Y=L();return q.computed&&q.key===Y||(q.result=G(),q.key=Y,q.computed=!0,q.id++,j==="flatten"&&(this.#$=null)),q.result}#D(j){return this.#l.get(j).id}#ce(){const j=(this.#e.config||{}).hostFilter,L=j&&_(j.active)&&j.active()?1:0,G=this.#K("where",null),q=G?G.version:0,Y=this.#bt("filter.sig",`${this.#ct()}`,()=>u({filters:this.#K("filters",null),quick:this.#K("quick",""),quickMode:this.#K("quickMode","contains")}));return`${this.#c}|${Y}|${L}|${q}`}#he(){const j=this.#v();return`${this.#D("filter")}|${JSON.stringify(this.#K("sort",[]))}`+(j?`|manual:${j.version}`:"")}#v(){const j=this.#K("rowOrder",null);return j&&Array.isArray(j.keys)?j:null}#Se(j,L){this.#p||this.#Q();const G=this.#p,q=this.#at(),Y=L.keys.length,J=new Float64Array(q);for(let ee=0;ee<q;ee++)J[ee]=Y+ee;for(let ee=0;ee<Y;ee++){const ne=G.get(L.keys[ee]);ne!==void 0&&(J[ne]=ee)}return Uint32Array.from(j).sort((ee,ne)=>J[ee]-J[ne])}orderedKeys(){this.#p||this.#Q();const j=this.#p,L=new Map;for(const[ee,ne]of j)L.set(ne,ee);const G=Uint32Array.from([...L.keys()]).sort(),q=this.#v(),Y=q?this.#Se(G,q):this.#Ce(G),J=new Array(Y.length);for(let ee=0;ee<Y.length;ee++)J[ee]=L.get(Y[ee]);return J}#Be(){const j=this.#K("pivotBy",[]).length>0?"p":"u";return`${this.#D("sort")}|${JSON.stringify(this.#K("groupBy",[]))}|${j}`}#Ge(){const j=this.#Ue()?"f":"a",L=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#D("group")}|${JSON.stringify(this.#K("totals",[]))}|${j}${L}|${this.#u}`}#Ke(){return`${this.#D("group")}|${JSON.stringify(this.#K("pivotBy",[]))}`}#Pe(){const L=this.#Qe()||!this.#oe()?this.#D("total"):"x",G=`${this.#ct()}`,q=this.#bt("flatten.keys",G,()=>{const J=this.#K("expanded",null);return J?[...J].sort().join(""):"*"}),Y=this.#bt("flatten.detail",G,()=>{const J=this.#K("detail",null);return J&&_(J.signature)?J.signature():""});return`${L}|${this.#D("pivot")}|${q}|${Y}`}#Qe(){const j=this.#K("groupBy",[]);return Array.isArray(j)&&j.length>0}stageState(){const j=[];for(const[L,G]of this.#l){const q=G.result;j.push({stage:L,materialised:!!G.computed,bytes:q&&typeof q.byteLength=="number"?q.byteLength:null,rows:q&&typeof q.length=="number"?q.length:null,rebuilds:G.id})}return j}facetIndices(j){return this.#ye(j||null)}facetRows(j){const L=this.facetIndices(j),G=[];for(let q=0;q<L.length;q++){const Y=this.#Te(L[q]);Y&&G.push(Y)}return G}invalidateRows(){this.#f.clear(),this.#N.clear(),this.#$=null}invalidateHandles(){this.#s.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#Ie()}filteredIndices(){const j=this.#l.get("filter");if(j&&j.computed&&j.key===this.#ce())return j.result||this.#Ie();this.#q();const L=this.#l.get("filter");return(L&&L.computed?L.result:null)||this.#Ie()}unfilteredRows(){const j=this.#Ie(),L=[];for(let G=0;G<j.length;G++){const q=this.#Te(j[G]);q&&L.push(q)}return L}#ye(j=null){const L=this.#Ie(),G=this.#K("filters",null),q=j?this.#De("pruneColumn")(G,j):G,Y=this.#Ft(q),J=String(this.#K("quick","")||"").trim().toLowerCase(),ee=J?D(J,String(this.#K("quickMode","contains")||"contains")):null,ne=(this.#e.config||{}).hostFilter,ie=!!(ne&&_(ne.active)&&ne.active()),se=this.#K("where",null),he=!!(se&&se.active);if(!Y&&!J&&!ie&&!he)return L;let ce=null;Y&&(ce=this.#De("evaluateFilters")(Y,{handle:de=>this.#s.handle(de),count:this.#at(),pool:this.#e.pool,locale:(this.#e.config||{}).locale,itemwise:de=>x(this.#ze(de))}));const te=new Uint32Array(L.length);let oe=0;for(let fe=0;fe<L.length;fe++){const de=L[fe];if(!(ce&&!ce[de])&&!(ee&&!this.#nt(de,ee))){if(ie||he){const ve=this.#Te(de);if(ie&&!ne.passes(ve)||he&&!se.passes(ve.data,ve.key))continue}te[oe++]=de}}if(ce){const fe=(this.#e.compute||{}).releaseMask;_(fe)&&fe({pool:this.#e.pool},ce)}return te.subarray(0,oe)}handleFor(j){return this.#s.handle(j)}#Ce(j){const L=this.#v();if(L)return this.#Se(j,L);const G=this.#K("sort",[]).filter(J=>{const ee=this.#ze(J.col);return!ee||!ee.running?!0:(B(`source.sort.running.${J.col}`,`sort ignores "${J.col}": a running total is a function of the sort order, so it cannot also decide it. Sort by the column it runs over instead.`),!1)});if(!G.length)return j;const q=(this.#e.config||{}).locale;if(G.length===1){const J=G[0],ee=this.#s.handle(J.col);if(!ee)return B(`source.sort.${J.col}`,`sort ignores unknown column "${J.col}".`),j;const ne=this.#ze(J.col);return this.#De("sortColumn")(ee,j,{descending:J.dir==="desc",nullsFirst:J.nullsFirst,locale:q,compare:S(ne)})}const Y=[];for(const J of G){const ee=this.#s.handle(J.col);if(!ee){B(`source.sort.${J.col}`,`sort ignores unknown column "${J.col}".`);continue}Y.push({handle:ee,descending:J.dir==="desc",nullsFirst:J.nullsFirst,locale:q,compare:S(this.#ze(J.col))})}return Y.length?this.#De("sortMulti")(Y.map(J=>J.handle),Y,j):j}#We(j){const L=this.#K("groupBy",[]),G=this.#we();if(G&&!L.length){const fe=f(j,G);return this.#x=p(fe.roots,G.declaresChildren),{roots:null,leaves:j,nodes:new Map,tree:fe}}if(this.#x=null,G&&L.length&&B("tree.grouped","grouping is active on a grid configured with `tree`; the grouping wins and the hierarchy is not shown."),!L.length)return{roots:null,leaves:j,nodes:new Map};const q=(this.#e.config||{}).timeZone,Y=[],J=[];let ee=!1;for(const fe of L){const de=this.#s.handle(fe);if(!de){B(`source.group.${fe}`,`grouping ignores unknown column "${fe}".`);continue}Y.push(de);const ve=this.#ze(fe),Me=ve&&ve.dataType;if(Me&&_(Me.groupProjector)){const Oe=ve.typeOptions&&ve.typeOptions.timeZone||q||void 0,Ce=Me.groupProjector(ve,Oe);J.push(Ce||null),Ce&&(ee=!0)}else J.push(null)}if(!Y.length)return{roots:null,leaves:j,nodes:new Map};const{keys:ne,buckets:ie}=this.#De("groupByColumns")(Y,j,{locale:(this.#e.config||{}).locale,project:ee?J:void 0}),se=this.#K("pivotBy",[]).length>0,he=[],ce=new Map;for(let fe=0;fe<ie.length;fe++){const de=ne[fe];let ve=null;const Me=[];for(let Oe=0;Oe<de.length;Oe++){Me.push(w(de[Oe]));const Ce=z(Me),pe=Oe===de.length-1;let we=ce.get(Ce);if(!we){const me=this.#i.group({path:[...Me],column:L[Oe],value:de[Oe],level:Oe,parent:ve,expanded:se&&pe?!1:this.#gt(Ce,{key:Ce,column:L[Oe],value:de[Oe],level:Oe,path:[...Me]}),hasChildren:!(se&&pe)});we={row:me,leaves:null},ce.set(Ce,we),ve?ve.children.push(me):he.push(me)}we.row.leafCount+=ie[fe].length,Oe===de.length-1&&(we.leaves=ie[fe]),ve=we.row}}const te=this.#K("sort",[])||[],oe=(fe,de)=>{if(!fe||fe.length<2){if(fe)for(const Ce of fe)oe(Ce.children,de+1);return}const ve=L[de],Me=te.find(Ce=>Ce.col===ve),Oe=Me&&Me.dir==="desc"?-1:1;fe.sort((Ce,pe)=>Oe*X(Ce.groupValue,pe.groupValue));for(const Ce of fe)oe(Ce.children,de+1)};return oe(he,0),{roots:he,leaves:j,nodes:ce,keys:ne,buckets:ie}}#_e(j,L){const G=new Map,q=new Map,Y=J=>{const ee=J.physical>=0?[J.physical]:[];for(const ne of J.children)ee.push(...Y(ne));if(J.children.length){const ne=this.#Ze(L,Uint32Array.from(ee),null);J.physical>=0?G.set(J.physical,ne):q.set(J.key,ne)}return ee};for(const J of j.roots)Y(J);return{byPhysical:G,byKey:q}}#Fe(j){const L=this.#ut();if(!L.length)return this.#M=null,this.#C=null,{grand:null};const G={id:this.#D("group"),columns:L.map(te=>te.id).join("")},q=this.#M&&this.#M.id===G.id&&this.#M.columns===G.columns,Y=this.#ot()&&q?this.#T:null,J=Y?L.filter(te=>Y.has(te.id)):L,ee=q?this.#C:null,ne=this.#Ue()?null:this.#P(),ie=this.#be(L),se=te=>{const oe=j.nodes.get(te.key);let fe=oe&&oe.leaves?oe.leaves:null;if(te.children&&te.children.length){const Me=te.children.map(se);let Oe=0;for(const we of Me)Oe+=we.length;const Ce=new Uint32Array(Oe);let pe=0;for(const we of Me)Ce.set(we,pe),pe+=we.length;fe=Ce}fe=fe||new Uint32Array(0);const de=ne?ne.get(te.key)||P:fe,ve=this.#ht(te,Y?J:L,de,ie);return te.totals=Y?{...te.totals,...ve}:ve,fe};if(j.roots&&J.length)for(const te of j.roots)se(te);if(this.#B=j.tree?this.#_e(j.tree,L):null,this.#M=G,this.#T=this.#ot()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#O.length=0,this.#C=null,{grand:null};const ce=ne?this.#mt():j.leaves;return this.#C=this.#Je(L,ce,Y,ee),{grand:this.#C}}#Je(j,L,G,q){const Y={},J=this.#D("group");J!==this.#y&&(this.#$e(),this.#y=J);const ee=this.#O;this.#O=[];for(const ne of j){if(!R(ne))continue;const ie=this.#s.handle(ne.id);if(!ie)continue;const se=v(ne,"grand");if(!t(se,ie)){if(G&&!G.has(ne.id)&&q&&ne.id in q){Y[ne.id]=q[ne.id];continue}Y[ne.id]=this.#Ze([ne],L,null,"grand")[ne.id];continue}let he=this.#S.get(ne.id);if((!he||he.fn!==se)&&(he=new n(se),this.#S.set(ne.id,he)),he.valid){let ce=!0;for(const te of ee)if(te.colId===ne.id&&!he.update(te.before,te.after)){ce=!1;break}if(ce){Y[ne.id]=he.value();continue}he.invalidate()}he.seedColumn(ie.values,s(ie),L),Y[ne.id]=he.valid?he.value():this.#Ze([ne],L,null,"grand")[ne.id]}return Y}#be(j){const L=this.#D("group");L!==this.#j&&(this.#k.clear(),this.#j=L);const G=new Map;for(const Y of j){if(!R(Y))continue;const J=this.#s.handle(Y.id),ee=v(Y,"group");t(ee,J)&&G.set(Y.id,{fn:ee})}if(!G.size)return this.#A.length=0,G;const q=this.#A;this.#A=[];for(const Y of q){const{beforeKeys:J,afterKeys:ee,colDeltas:ne}=Y,ie=J.length?new Set(J):null,se=ee.length?new Set(ee):null;for(const{colId:he,before:ce,after:te}of ne)if(G.has(he)){for(const oe of J)se&&se.has(oe)||this.#W(oe,he,ce,null);for(const oe of ee)ie&&ie.has(oe)||this.#W(oe,he,null,te);for(const oe of J)se&&!se.has(oe)||this.#W(oe,he,ce,te)}}return G}#W(j,L,G,q){const Y=this.#k.get(j),J=Y&&Y.get(L);!J||!J.valid||J.update(G,q)||J.invalidate()}#ht(j,L,G,q){if(!q||!q.size)return this.#Ze(L,G,j);const Y={};let J=null,ee=this.#k.get(j.key);for(const ne of L){const ie=q.get(ne.id);if(!ie){(J||(J=[])).push(ne);continue}const se=this.#s.handle(ne.id);if(!se)continue;ee||(ee=new Map,this.#k.set(j.key,ee));let he=ee.get(ne.id);if((!he||he.fn!==ie.fn)&&(he=new n(ie.fn),ee.set(ne.id,he)),he.valid||he.seedColumn(se.values,s(se),G),he.valid){Y[ne.id]=he.value();continue}(J||(J=[])).push(ne)}return J&&Object.assign(Y,this.#Ze(J,G,j)),Y}#Ct(j,L,G,q){const Y=!this.#Ue()||this.#it(L);for(const J of j){const ee=J.getValue;if(!_(ee))continue;const ne=ee(G),ie=ee(q);Object.is(ne,ie)||(this.#T&&this.#T.add(J.id),Y&&this.#S.has(J.id)&&this.#O.push({colId:J.id,before:ne,after:ie}))}}#ft(){const j=this.#K("groupBy",[]),L=[];for(const G of j){const q=this.#ze(G);q&&L.push(q)}return L}#pt(j,L){const G=new Array(j.length);for(let q=0;q<j.length;q++){const Y=j[q].getValue;G[q]=w(_(Y)?Y(L):void 0)}return G}#et(j,L,G,q,Y){if(this.#Ue()&&!this.#it(G))return;const J=A(this.#pt(j,q)),ee=A(this.#pt(j,Y)),ne=J.length!==ee.length||J.some((se,he)=>se!==ee[he]),ie=[];for(const se of L){const he=se.getValue;if(!_(he))continue;const ce=he(q),te=he(Y);!ne&&Object.is(ce,te)||ie.push({colId:se.id,before:ce,after:te})}!ie.length&&!ne||this.#A.push({beforeKeys:J,afterKeys:ee,colDeltas:ie})}#it(j){const L=this.#l.get("filter"),G=L&&L.computed?L.result:null;if(!G)return!0;let q=0,Y=G.length-1;for(;q<=Y;){const J=q+Y>>1,ee=G[J];if(ee===j)return!0;ee<j?q=J+1:Y=J-1}return!1}#Ue(){return(this.#e.config||{}).totalFilteredOnly!==!1}#tt(j){return this.#Ue()?j:this.#mt().length}#mt(){return(!this.#E||this.#E.version!==this.#c)&&(this.#E={version:this.#c,indices:this.#Ie()}),this.#E.indices}#P(){const j=this.#K("groupBy",[]),L=`${this.#c}|${JSON.stringify(j)}`;if(this.#L&&this.#L.key===L)return this.#L.map;const G=new Map,q=[];for(const Y of j){const J=this.#s.handle(Y);J&&q.push(J)}if(q.length){const Y=this.#mt(),{keys:J,buckets:ee}=this.#De("groupByColumns")(q,Y,{locale:(this.#e.config||{}).locale}),ne=new Map;for(let ie=0;ie<ee.length;ie++){const se=J[ie],he=[];for(let ce=0;ce<se.length;ce++){he.push(w(se[ce]));const te=z(he);let oe=ne.get(te);oe||(oe=[],ne.set(te,oe));for(let fe=0;fe<ee[ie].length;fe++)oe.push(ee[ie][fe])}}for(const[ie,se]of ne)G.set(ie,Uint32Array.from(se))}return this.#L={key:L,map:G},G}#ot(){return!!(this.#e.config||{}).totalOnlyChangedColumns}#xe(){this.#$e(),this.#Ee(),this.#T=null,this.#M=null,this.#C=null}#$e(){this.#S.clear(),this.#O.length=0,this.#y=-1}#Ee(){this.#k.clear(),this.#A.length=0,this.#j=-1}#Ve(j){const L=this.#K("pivotBy",[]);if(!L.length)return this.#re=null,null;const G=(this.#e.compute||{}).pivot;if(!_(G))return B("source.pivot.kernel","pivot requested but ctx.compute.pivot is not available; showing unpivoted rows."),this.#re=null,null;const q=L.map(J=>this.#s.handle(J)).filter(Boolean),Y=this.#ut();return this.#re=G(q,j.leaves,{groups:j.keys&&j.buckets?{keys:j.keys,buckets:j.buckets}:null,totals:Y.map(J=>J.id),handle:J=>this.#s.handle(J),totalOf:J=>v(Y.find(ee=>ee.id===J),"group"),separator:((this.#e.config||{}).pivot||{}).separator,maxColumns:((this.#e.config||{}).pivot||{}).maxColumns})||null,this.#re}#st(j){const L=this.#l.get("total").result,G=!!(this.#e.config||{}).groupFooter,q=this.#Me();if(j.tree)return this.#lt(j,L,q);if(!j.roots&&!q){if(L&&L.grand&&!this.#oe()){const se=this.#i.grandTotal(L.grand,this.#tt(j.leaves.length));if(this.#_===j.leaves&&Array.isArray(this.#z))this.#z[this.#z.length-1]=se;else{const he=Array.from(j.leaves);he.push(se),this.#z=he,this.#_=j.leaves}this.#le=[{at:this.#z.length-1}]}else this.#_=null,this.#z=j.leaves,this.#le=y;return this.#Y=y,this.#z}const Y=[],J=[],ee=[],ne=se=>{if(Y.push(se),!q)return;const he=this.#Te(se);!he||!q.isOpen(he.key)||(he.master=!0,he.expanded=!0,ee.push({at:Y.length}),Y.push(this.#i.detail(he,q.heightOf(he))))};if(!j.roots){for(let se=0;se<j.leaves.length;se++)ne(j.leaves[se]);return L&&L.grand&&!this.#oe()&&(ee.push({at:Y.length}),Y.push(this.#i.grandTotal(L.grand,this.#tt(j.leaves.length)))),this.#_=null,this.#Y=y,this.#le=ee.length?ee:y,this.#z=Y,Y}const ie=(se,he,ce)=>{if(se.expanded=se.hasChildren===!1?!1:this.#gt(se.key,{key:se.key,column:se.groupColumn,value:se.groupValue,level:se.level,path:se.groupPath}),se.posinset=he+1,se.setsize=ce,J.push({at:Y.length,row:se}),ee.push({at:Y.length}),Y.push(se),!!se.expanded){if(se.children&&se.children.length)for(let te=0;te<se.children.length;te++)ie(se.children[te],te,se.children.length);else{const te=j.nodes.get(se.key),oe=te&&te.leaves?te.leaves:null;if(oe)for(let fe=0;fe<oe.length;fe++)ne(oe[fe])}G&&se.totals&&(ee.push({at:Y.length}),Y.push(this.#i.footer(se)))}};for(let se=0;se<j.roots.length;se++)ie(j.roots[se],se,j.roots.length);return L&&L.grand&&!this.#oe()&&(ee.push({at:Y.length}),Y.push(this.#i.grandTotal(L.grand,this.#tt(j.leaves.length)))),this.#Y=J,this.#le=ee,this.#z=Y,Y}#Ie(){const j=this.#e.store;if(j&&_(j.liveIndices))return j.liveIndices();const L=new Uint32Array(this.#n.length);let G=0;for(let q=0;q<this.#n.length;q++)this.#n[q]!==void 0&&(L[G++]=q);return L.subarray(0,G)}#at(){const j=this.#e.store;return j&&typeof j.physical=="number"?j.physical:this.#n.length}#Ne(j){const L=this.#e.store;return L&&_(L.source)?L.source(j):this.#n[j]}#qe(j,L=j){const G=this.#z[j];if(typeof G!="number")return G.index=L,G;const q=this.#Te(G);return q.index=L,q}#Te(j){let L=this.#f.get(j);L||(L=this.#i.leaf(this.#Ne(j),j),this.#f.set(j,L));const G=this.#x?this.#x.get(j):null;if(G){L.level=G.level,L.posinset=G.posinset,L.setsize=G.setsize,L.hasChildren=G.hasChildren,L.expanded=G.hasChildren&&!G.lazy&&this.#gt(L.key);const q=this.#B?this.#B.byPhysical.get(j):void 0;q?L.totals=q:L.totals&&(L.totals=null)}else L.hasChildren&&(L.level=0,L.hasChildren=!1,L.expanded=!1,L.posinset=void 0,L.setsize=void 0);return L}#lt(j,L,G){const q=[],Y=[],J=ne=>{if(ne.leafCount!==void 0)return ne.leafCount;let ie=ne.physical>=0?1:0;for(const se of ne.children)ie+=J(se);return ne.leafCount=ie,ie},ee=ne=>{const ie=this.#gt(ne.key);if(ne.physical>=0){if(q.push(ne.physical),G&&G.isOpen(this.#Te(ne.physical).key)){const se=this.#Te(ne.physical);Y.push({at:q.length}),q.push(this.#i.detail(se,G.heightOf(se)))}}else q.push(this.#i.group({path:[ne.key],column:null,value:ne.value,level:ne.level,parent:null,expanded:ie,hasChildren:ne.children.length>0,leafCount:J(ne),totals:this.#B?this.#B.byKey.get(ne.key):void 0}));if(ie)for(const se of ne.children)ee(se)};for(const ne of j.tree.roots)ee(ne);return L&&L.grand&&!this.#oe()&&(Y.push({at:q.length}),q.push(this.#i.grandTotal(L.grand,this.#tt(j.leaves.length)))),this.#_=null,this.#Y=y,this.#le=Y.length?Y:y,this.#z=q,q}#Lt(){return g(()=>this.count(),j=>this.at(j))}#nt(j,L){let G=this.#N.get(j);if(G===void 0){const q=this.#Ne(j),Y=this.#rt(),J=[],ee=this.#e.columnHidden;for(const ne of Y){if(ne.quickFilter===!1||_(ee)&&ee(ne.id))continue;const ie=ne.value&&_(ne.value.quickFilterText)?ne.value.quickFilterText({value:void 0,data:q,row:null,column:ne,colId:ne.id,grid:null,context:this.#K("context",null)}):null,se=ie??(_(ne.formatValue)?ne.formatValue(_(ne.getValue)?ne.getValue(q):void 0):"");se!=null&&se!==""&&J.push(String(se))}G=J.join(" ").toLowerCase(),this.#N.set(j,G)}return L(G)}#ut(){const j=this.#K("totals",[]),L=j&&j.length?new Set(j):null;return this.#rt().filter(G=>L?L.has(G.id):!!(G.total||G.groupTotal||G.grandTotal))}#Ze(j,L,G,q="group"){const Y={},J=(this.#e.compute||{}).total;for(const ee of j){if(!R(ee))continue;const ne=this.#s.handle(ee.id);if(!ne)continue;const ie=v(ee,q);if(ie)if(_(ie)){const se=new Array(L.length);for(let he=0;he<L.length;he++)se[he]=ne.get(L[he]);Y[ee.id]=ie(se,{row:G,column:ee,grid:this.#e.grid||null,context:this.#K("context",null),valueAt:(he,ce)=>{const te=this.#s.handle(he);return te&&ce>=0&&ce<L.length?te.get(L[ce]):null}})}else _(J)&&(Y[ee.id]=J(ne,L,ie))}return Y}#Ft(j){if(!j)return j;const L=this.#e.config||{},G={tz:L.timeZone,weekStartsOn:L.weekStartsOn};return i(j,q=>{const Y=m(q,G),J=this.#ze(Y&&Y.col),ee=J&&J.type==="datetime";if(Y&&Y.type)return Y.type==="datetime"&&!Y.timeZone&&J?{...Y,timeZone:L.timeZone||void 0}:Y;if(ee)return{...Y,type:"datetime",timeZone:L.timeZone||void 0};const ne=J&&(J.dataType?.base||J.type);return ne?{...Y,type:ne}:Y})}#gt(j,L){const G=this.#K("expanded",null);return G?_(G.has)?G.has(j,L):Array.prototype.includes.call(G,j):!0}#K(j,L){if(j==="context"||!_(this.#e.stateVersion))return this.#Et(j,L);const G=this.#yt(j),q=this.#d.get(j);if(q&&q.version===G)return q.value;const Y=this.#Et(j,L);return this.#d.set(j,{version:G,value:Y}),Y}#Et(j,L){const G=this.#e.state;if(G&&_(G[j])){const q=G[j]();return q??L}return L}#ct(){const j=this.#e.stateVersion;return _(j)?j():0}#St(){const j=this.#e.columnsVersion,L=this.#e.permissionsVersion;return`${_(j)?j():0}|${_(L)?L():0}`}#yt(j){return j==="totals"?this.#St():`${this.#ct()}`}#bt(j,L,G){if(!_(this.#e.stateVersion))return G();const q=this.#h.get(j);if(q&&q.version===L)return q.key;const Y=G();return this.#h.set(j,{version:L,key:Y}),Y}#De(j){const L=(this.#e.compute||{})[j];return _(L)||I(`ctx.compute.${j} is required by the memory source pipeline`),L}#rt(){const j=this.#e.columns;return j&&_(j.all)?j.all():[]}#ze(j){const L=this.#e.columns;return L&&_(L.get)?L.get(j):void 0}#He(j,L){const G=this.#e.emit;_(G)&&G(j,L)}}}),Fe("packages/core/src/source/abort.js",function(e,K){"use strict";Object.defineProperty(e,"SupersededError",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"RequestToken",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"AbortScope",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createAbortScope",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"isAbortError",{enumerable:!0,get:function(){return _}});class Q extends Error{constructor(W,H="superseded"){super(`[lattice] request ${W?`"${W}" `:""}${H}`),this.name="SupersededError",this.superseded=!0,this.key=W}}class ${#e;constructor(W,H,V,z){this.#e=W,this.key=H,this.controller=V,this.signal=V.signal,this.seq=z}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(W){this.signal.aborted||this.controller.abort(new Q(this.key,W)),this.#e.settle(this)}}class B{#e=new Map;#t=0;begin(W="",H="superseded"){const V=this.#e.get(W);V&&!V.signal.aborted&&V.controller.abort(new Q(W,H));const z=new $(this,W,new AbortController,++this.#t);return this.#e.set(W,z),z}tokenFor(W){return this.#e.get(W)}pending(W=""){const H=this.#e.get(W);return!!H&&!H.signal.aborted}get size(){return this.#e.size}settle(W){this.#e.get(W.key)===W&&this.#e.delete(W.key)}abort(W="",H="superseded"){const V=this.#e.get(W);V&&V.abort(H)}abortAll(W="superseded"){for(const H of[...this.#e.values()])H.abort(W);this.#e.clear()}}function I(){return new B}function _(X){if(!X||typeof X!="object")return!1;const W=X;return W.superseded===!0||W.name==="AbortError"||W.name==="SupersededError"}}),Fe("packages/core/src/source/blockcache.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_PAGE_SIZE",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"DEFAULT_MAX_CACHED_PAGES",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return I}});const Q=100,$=32;class B{constructor(X){this.id=X,this.rows=null,this.state="pending",this.token=null,this.error=null}}class I{#e=new Map;#t;#n;#r=0;#o=-1;constructor(X={}){this.#t=Math.max(1,Math.floor(Number(X.pageSize)||Q)),this.#n=Math.max(1,Math.floor(Number(X.maxCachedPages)||$))}get pageSize(){return this.#t}get maxBlocks(){return this.#n}get size(){return this.#e.size}blockOf(X){return Math.floor(X/this.#t)}rangeOf(X){return{start:X*this.#t,end:(X+1)*this.#t}}has(X){return this.#e.has(X)}pending(X){const W=this.#e.get(X);return!!W&&W.state==="pending"}loaded(X){const W=this.#e.get(X);return!!W&&W.state==="loaded"}begin(X,W){let H=this.#e.get(X);return H||(H=new B(X)),H.state="pending",H.token=W,H.error=null,this.#i(X,H),H}fill(X,W){const H=this.#e.get(X)||new B(X);H.rows=W,H.state="loaded",H.token=null,this.#i(X,H)}failed(X,W){const H=this.#e.get(X)||new B(X);H.state="error",H.error=W,H.token=null,this.#i(X,H)}delete(X){return this.#e.delete(X)}rowAt(X){const W=this.blockOf(X),H=this.#e.get(W);if(!(!H||H.state!=="loaded"||!H.rows))return this.#i(W,H),H.rows[X-W*this.#t]}rowLoaded(X){const W=this.blockOf(X),H=this.#e.get(W);return!!H&&H.state==="loaded"&&!!H.rows&&X-W*this.#t<H.rows.length}erroredAt(X){const W=this.#e.get(this.blockOf(X));return!!W&&W.state==="error"}loadedExtent(){let X=0;for(const W of this.#e.values()){if(W.state!=="loaded"||!W.rows)continue;const H=W.id*this.#t+W.rows.length;H>X&&(X=H)}return X}fillOf(X){const W=this.#e.get(X);return W&&W.state==="loaded"&&W.rows?W.rows.length:null}protect(X,W){this.#r=this.blockOf(Math.max(0,X)),this.#o=this.blockOf(Math.max(0,W))}evict(){const X=[];if(this.#e.size<=this.#n)return X;for(const[W,H]of this.#e){if(this.#e.size-X.length<=this.#n)break;W>=this.#r&&W<=this.#o||H.state!=="pending"&&X.push(W)}for(const W of X)this.#e.delete(W);return X}ids(){return[...this.#e.keys()]}clear(){this.#e.clear()}#i(X,W){this.#e.delete(X),this.#e.set(X,W)}}}),Fe("packages/core/src/source/pagewindow.js",function(e,K){"use strict";Object.defineProperty(e,"pageWindow",{enumerable:!0,get:function(){return Q}});function Q($,B,I,_){const X=Math.floor(Number($)||0);if(X<=0)return null;const W=Math.max(0,Math.floor(Number(B)||0)),H=Math.max(0,Math.floor(Number(I)||0));if(_){const V=Math.max(1,Math.ceil(H/X)),z=Math.min(W,V-1),w=z*X;return{page:z,pageSize:X,offset:w,length:Math.max(0,Math.min(X,H-w)),pageCount:V,total:H}}return{page:W,pageSize:X,offset:W*X,length:X,pageCount:Math.max(W+2,Math.ceil(H/X)),total:null}}}),Fe("packages/core/src/source/paged.js",function(e,K){"use strict";Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PagedSource",{enumerable:!0,get:function(){return i}});const Q=K("packages/core/src/internal/util.js"),$=Q.Lru,B=Q.isFunction,I=Q.warnOnce,_=Q.settleDebounce,X=K("packages/core/src/source/abort.js"),W=X.createAbortScope,H=X.isAbortError,V=K("packages/core/src/source/blockcache.js"),z=V.BlockCache,w=V.DEFAULT_PAGE_SIZE,A=V.DEFAULT_MAX_CACHED_PAGES,l=K("packages/core/src/source/rows.js").createRowFactory,d=K("packages/core/src/source/filterwire.js"),o=d.wireFilters,n=d.querySignature,t=d.warnHostFilterNotApplied,s=K("packages/core/src/source/pagewindow.js").pageWindow,h=120;function u(m,c){return new i(m,c)}class i{mode="paged";#e;#t;#n;#r=W();#o;#i;#s=new Map;#l=null;#a=null;#u=!1;#c=0;#d="";#h={start:0,end:0};#f;#p=!1;#m=0;#g="";constructor(c,f){this.#e=c||{mode:"paged"},this.#t=f||{},this.#n=new z({pageSize:this.#e.pageSize||w,maxCachedPages:this.#e.maxCachedPages||A}),this.#o=l(this.#t),this.#i=new $(this.#n.pageSize*4),this.#f=_((a,p)=>this.#y(a,p),h),this.#d=this.#T(),B(this.#e.fetch)||I("source.paged.fetch",'source.mode "paged" requires a fetch function; the grid will stay empty.'),t(this.#t)}count(){const c=this.#w();return c?c.length:this.#b()}#b(){if(this.#j(),this.#l!==null)return this.#l;const c=Math.max(this.#c,this.#n.loadedExtent());return this.#u?c:c+this.#n.pageSize}matchCount(){return this.#b()}totalCount(){return this.#b()}pageInfo(){const c=this.#w();if(!c){const f=this.#b();return{page:0,pageSize:0,total:this.exact()?f:null,pageCount:1,counting:!1}}return{page:c.page,pageSize:c.pageSize,total:c.total,pageCount:c.pageCount,counting:c.total===null&&this.#r.size>0&&this.#c===0&&this.#n.loadedExtent()===0}}#w(){const c=this.#b(),f=s(this.#C("pageSize",0),this.#C("page",0),c,this.exact());if(!f)return this.#g="",null;const a=`${this.#m}:${f.offset}:${f.length}`;if(a!==this.#g&&!this.#p&&(this.#g=a,f.length>0)){const p=f.offset+f.length-1;this.#h={start:f.offset,end:p},this.#y(f.offset,p)}return f}at(c){const f=this.#w();if(f){if(c<0||c>=f.length)return;const a=this.#S(f.offset+c);return a&&(a.index=c),a}return this.#S(c)}#S(c){if(c<0||c>=this.#b())return;const f=this.#i.get(c);if(f&&(f.data!==null||!this.#n.rowLoaded(c)))return f;const a=this.#n.rowAt(c);if(a===void 0){const b=this.#o.skeleton(c,0,this.#n.erroredAt(c));return this.#i.set(c,b),b}const p=this.#o.leaf(a,c);return p.index=c,this.#i.set(c,p),this.#s.set(p.key,c),p}byKey(c){const f=this.#s.get(c);return f===void 0?void 0:this.#S(f)}loaded(c){const f=this.#w();return f?c>=0&&c<f.length&&this.#n.rowLoaded(f.offset+c):this.#n.rowLoaded(c)}loadedCount(){this.#j();let c=0;for(const f of this.#n.ids()){if(!this.#n.loaded(f))continue;const a=this.#n.fillOf(f);typeof a=="number"&&(c+=a)}return c}residentRows(){this.#j();const c=this.#w(),f=c?c.offset:0,a=c?c.offset+c.length:1/0,p=[],b=this.#n.ids().sort((O,k)=>O-k);for(const O of b){if(!this.#n.loaded(O))continue;const{start:k}=this.#n.rangeOf(O),y=this.#n.fillOf(O)||0;for(let v=k;v<k+y;v++){if(v<f||v>=a)continue;const R=this.#i.peek(v);if(R&&R.data!==null&&R.data!==void 0){p.push(R);continue}const S=this.#n.rowAt(v);if(S===void 0)continue;const x=this.#o.leaf(S,v);x.index=v,this.#i.set(v,x),this.#s.set(x.key,v),p.push(x)}}return p}hint(c,f){if(this.#p)return;const a=this.#j();let p=Math.max(0,Math.floor(c)),b=Math.max(p,Math.floor(f));const O=this.#w();if(O){if(O.length===0)return;p=O.offset,b=O.offset+O.length-1}this.#h={start:p,end:b},this.#n.protect(p,b);for(const k of this.#n.evict())this.#k(k);this.#f(p,b),a&&this.#f.flush()}#y(c,f){if(this.#p)return;this.#n.protect(c,f);const a=this.#n.blockOf(c),p=this.#n.blockOf(f);for(let b=a;b<=p&&!(this.#l!==null&&b*this.#n.pageSize>=this.#l);b++)this.#n.has(b)||this.#O(b)}apply(c){const f={added:[],updated:[],removed:[]};if(!c)return f;if(c.update)for(const a of c.update){const p=this.#o.keyOf(a,-1),b=this.#s.get(p);if(b===void 0)continue;const O=this.#o.leaf(a,b);O.index=b,this.#i.set(b,O),f.updated.push(O)}return(c.add&&c.add.length||c.remove&&c.remove.length)&&this.reload(),f}reload(c){this.#A("reload"),this.#f.cancel(),this.hint(this.#h.start,this.#h.end)}destroy(){this.#p=!0,this.#f.cancel(),this.#r.abortAll("destroyed"),this.#n.clear(),this.#i.clear(),this.#s.clear()}exact(){return this.#l!==null||this.#u}pending(){return this.#r.size}async#O(c){if(!B(this.#e.fetch))return;const f=this.#r.begin(`block:${c}`);this.#n.begin(c,f);const{start:a,end:p}=this.#n.rangeOf(c),b=this.#d;try{const O=await this.#e.fetch({range:{start:a,end:p},sort:this.#C("sort",[]),filters:o(this.#C("filters",null),this.#M()),quick:this.#C("quick","")||void 0,context:this.#C("context",null),signal:f.signal});if(!f.current||b!==this.#d||this.#p)return;f.settle();const k=O&&O.rows||[];this.#n.fill(c,k);for(let v=0;v<k.length;v++)this.#i.delete(a+v);const y=O&&typeof O.total=="number"?O.total:O&&typeof O.count=="number"?O.count:null;y!==null?(this.#l=y,this.#u=!0):k.length<this.#n.pageSize?(this.#u=!0,this.#l=a+k.length):this.#c=Math.max(this.#c,a+k.length),this.#E("model:changed",{reason:"page",block:c,from:a,to:a+k.length}),this.#E("rows:changed",{companion:!0,reason:"page",block:c,from:a,to:a+k.length}),this.#l!==null&&this.#l!==this.#a&&(this.#a=this.#l,this.#E("source:total",{total:this.#l,groupPath:[]}))}catch(O){if(f.settle(),H(O))return;this.#n.failed(c,O);for(let k=a;k<p;k++)this.#i.delete(k);this.#E("model:changed",{reason:"page-error",block:c,range:{start:a,end:p}}),this.#E("source:error",{error:O,block:c,range:{start:a,end:p}})}}#k(c){const{start:f,end:a}=this.#n.rangeOf(c);for(let p=f;p<a;p++){const b=this.#i.peek(p);b&&this.#s.delete(b.key),this.#i.delete(p)}}#j(){const c=this.#T();return c===this.#d?!1:(this.#d=c,this.#A("query"),!0)}#A(c){this.#r.abortAll(c),this.#n.clear(),this.#i.clear(),this.#s.clear(),this.#l=null,this.#a=null,this.#u=!1,this.#c=0,this.#m++,this.#E("model:changed",{reason:c})}#T(){return n({filters:this.#C("filters",null),sort:this.#C("sort",[]),quick:this.#C("quick",""),context:this.#C("context",null)})}#M(){const c=this.#t.config||{};return{tz:c.timeZone,weekStartsOn:c.weekStartsOn}}#C(c,f){const a=this.#t.state;if(a&&B(a[c])){const p=a[c]();return p??f}return f}#E(c,f){const a=this.#t.emit;B(a)&&a(c,f)}}}),Fe("packages/core/src/source/aggregates.js",function(e,K){"use strict";Object.defineProperty(e,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"pushableAggregates",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"fillAggregateSql",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"resolveAggregatesConfig",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"routeAggregate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"resolveAggregatePlan",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"groupKeysPushable",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"pushdownDocRows",{enumerable:!0,get:function(){return V}});const Q=Object.freeze({sum:{pushable:!0,class:"identical",sql:"sum(%c)"},avg:{pushable:!0,class:"identical",sql:"avg(%c)"},min:{pushable:!0,class:"identical",sql:"min(%c)"},max:{pushable:!0,class:"identical",sql:"max(%c)"},count:{pushable:!0,class:"identical",sql:"count(*)"},countValues:{pushable:!0,class:"identical",sql:"count(%c)",blankAware:!0},range:{pushable:!0,class:"identical",sql:"(max(%c) - min(%c))"},variance:{pushable:!0,class:"identical",sql:"var_samp(%c)"},varianceP:{pushable:!0,class:"identical",sql:"var_pop(%c)"},stddev:{pushable:!0,class:"identical",sql:"stddev_samp(%c)"},stddevP:{pushable:!0,class:"identical",sql:"stddev_pop(%c)"},sumSquares:{pushable:!0,class:"identical",sql:"sum(%c * %c)"},median:{pushable:!0,class:"identical",sql:"median(%c)"},p25:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.25)"},p75:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.75)"},p90:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.9)"},p95:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.95)"},p99:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.99)"},iqr:{pushable:!0,class:"identical",sql:"(quantile_cont(%c, 0.75) - quantile_cont(%c, 0.25))"},mad:{pushable:!0,class:"identical",sql:"mad(%c)"},distinct:{pushable:!0,class:"identical",sql:"count(DISTINCT %c)",blankAware:!0},skewness:{pushable:!0,class:"identical",sql:"skewness(%c)"},kurtosis:{pushable:!0,class:"identical",sql:"kurtosis(%c)"},geomean:{pushable:!0,class:"identical",sql:"exp(avg(ln(%c)))"},harmean:{pushable:!0,class:"identical",sql:"(count(%c) / sum(1.0 / %c))"},entropy:{pushable:!0,class:"identical",sql:"entropy(%c)",blankAware:!0},correlation:{pushable:!0,class:"identical",sql:"corr(%w, %c)",twoColumn:!0},hhi:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_transform(map_values(histogram(%c)), lambda v: (v::DOUBLE/count(%c))*(v::DOUBLE/count(%c)))) END"},evenness:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL WHEN count(DISTINCT %c)<2 THEN 1.0 ELSE entropy(%c)/log2(count(DISTINCT %c)) END"},top3Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,3))::DOUBLE/count(%c) END"},top10Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,10))::DOUBLE/count(%c) END"},gini:{pushable:!0,class:"identical",sql:"CASE WHEN list_min(list(%c) FILTER (WHERE isfinite(%c)))<0 THEN NULL WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL WHEN list_sum(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN 0 ELSE 2.0*list_sum(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v, i: i*v))/(len(list(%c) FILTER (WHERE isfinite(%c)))*list_sum(list(%c) FILTER (WHERE isfinite(%c))))-(len(list(%c) FILTER (WHERE isfinite(%c)))+1.0)/len(list(%c) FILTER (WHERE isfinite(%c))) END"},trimmedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_slice(list_sort(list(%c) FILTER (WHERE isfinite(%c))), floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1, len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT)) END"},winsorizedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v: least(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT], greatest(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1], v)))) END"},robustOutliers:{pushable:!0,class:"identical",sql:"(SELECT CASE WHEN len(d.a)=0 THEN NULL WHEN d.mad=0 THEN NULL ELSE len(list_filter(d.a, lambda v: abs(0.6745*(v-d.med)/d.mad)>3.5)) END FROM (SELECT xs AS a, list_median(xs) AS med, list_median(list_transform(xs, lambda w: abs(w-list_median(xs)))) AS mad FROM (SELECT list(%c) FILTER (WHERE isfinite(%c)) AS xs)) d)"},jarqueBera:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))<8 THEN NULL WHEN list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2)))=0 THEN NULL ELSE (len(list(%c) FILTER (WHERE isfinite(%c)))/6.0)*(power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),3)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),1.5),2)+power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),4)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),2)-3,2)/4.0) END"},weightedAvg:{pushable:!0,class:"identical",twoColumn:!0,sql:"sum(%c*%w) FILTER (WHERE isfinite(%c) AND isfinite(%w))/nullif(sum(%w) FILTER (WHERE isfinite(%c) AND isfinite(%w)),0)"},mode:{pushable:!0,class:"may-differ",sql:"mode(%c)",note:"DuckDB returns a modal value even for an all-distinct column; the grid returns null. Tie-breaking can also differ, and on a text column an empty string counts as a value. Under pushdown you will see a value."},weightedQuantile:{pushable:!1,class:"fallback",note:"No SQL equivalent for the grid's weighted-quantile midpoint convention; always computed client-side (needs a full-dataset pull for a correct figure over a remote source)."}});function $(){const z=new Set;for(const[w,A]of Object.entries(Q))A.pushable&&z.add(w);return z}function B(z,w,A){let g=z.split("%c").join(w);return A!==void 0&&(g=g.split("%w").join(A)),g}function I(z){const w=z||{},A=w.default==="engine"||w.default==="engine-if-identical"?w.default:"client",g={};if(w.overrides&&typeof w.overrides=="object")for(const[l,d]of Object.entries(w.overrides))(d==="engine"||d==="client")&&(g[l]=d);return{default:A,overrides:g}}function _(z,w){const A=Q[z];if(!A||!A.pushable)return"client";const g=w.overrides[z];return g==="engine"||g==="client"?g:w.default==="client"?"client":w.default==="engine-if-identical"?A.class==="identical"?"engine":"client":"engine"}function X(z,w){const A=I(w),g=[],l=[];for(const d of z||[]){const o=Q[d.fn],n=_(d.fn,A),t={id:d.id,col:d.col,fn:d.fn,class:o?o.class:"fallback"};d.weight!==void 0&&(t.weight=d.weight),d.params!==void 0&&(t.params=d.params),n==="engine"?g.push(t):(t.reason=o&&!o.pushable?o.note||"the engine cannot express this stat":"client by config",l.push(t))}return{engine:g,client:l,config:A}}const W=/^[A-Za-z_][A-Za-z0-9_$]*$/;function H(z,w=[]){return(z||[]).every(g=>{if(typeof g=="string")return W.test(g);if(!g||typeof g!="object")return!1;const l=g;return Array.isArray(w)&&w.includes(l.bucket)&&typeof l.col=="string"&&W.test(l.col)&&typeof l.size=="number"&&Number.isFinite(l.size)&&l.size>0})}function V(){return Object.entries(Q).map(([z,w])=>({stat:z,class:w.class,sql:w.sql?B(w.sql,"col",w.twoColumn?"weight":void 0):"",note:w.note||(w.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),Fe("packages/core/src/source/pushdown.js",function(e,K){"use strict";Object.defineProperty(e,"FOREGROUND_WAIT_MS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"LEAF_COUNT_ID",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"PIVOT_UNSUPPORTED",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"GROUP_UNSUPPORTED",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"UNGROUPED_LEVEL",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return j}});const Q=K("packages/core/src/internal/util.js"),$=Q.defaultCompare,B=Q.isFunction,I=Q.toArray,_=Q.warnOnce,X=K("packages/core/src/source/filterwire.js"),W=X.isGroup,H=X.warnWherePageRelative,V=X.warnWhereOverThreshold,z=K("packages/core/src/source/aggregates.js"),w=z.resolveAggregatePlan,A=z.groupKeysPushable,g=z.STAT_PUSHDOWN,d=K("packages/core/src/source/abort.js").SupersededError,o=1e3;function n(L){const G=L&&L.signal;if(!G||!G.aborted)return;const q=G.reason;throw q instanceof Error?q:new d("","superseded before it was sent")}const t=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,pivot:!1,mutate:!1});function r(L){if(!L||typeof L!="object")return!1;const G=L.returning==="row"||L.returning==="key"?L.returning:"none";return{append:L.append===!0,update:L.update===!0,delete:L.delete===!0,returning:G}}function s(L,G){if(!L||typeof G!="string")return;if(!G.includes("."))return L[G];let q=L;for(const Y of G.split(".")){if(q===null||typeof q!="object")return;q=q[Y]}return q}function h(L){if(L===!0)return!0;if(!L||typeof L!="object")return!1;const G=L;return G.enabled===!1?!1:G.enabled===!0||B(G.commit)}function u(L){const G={...t,...L||{}};return G.operators=new Set(G.operators||[]),G.mutate=r(G.mutate),G}function i(L,G){return!L||!L.op||!G.operators.size?!1:G.operators.has(L.op)}function m(L,G){if(!L)return{pushed:null,residual:null};if(!G.filter)return{pushed:null,residual:L};if(G.filter==="term"){if(W(L)){const ee=L.conditions||[];if(String(L.op)!=="and")return{pushed:null,residual:L};const ne=ee.findIndex(se=>!W(se)&&i(se,G));if(ne<0)return{pushed:null,residual:L};const ie=ee.filter((se,he)=>he!==ne);return{pushed:ee[ne],residual:ie.length?{op:"and",conditions:ie}:null}}return i(L,G)?{pushed:L,residual:null}:{pushed:null,residual:L}}if(!W(L))return i(L,G)?{pushed:L,residual:null}:{pushed:null,residual:L};if(String(L.op)!=="and")return(L.conditions||[]).every(ne=>W(ne)?m(ne,G).residual===null:i(ne,G))?{pushed:L,residual:null}:{pushed:null,residual:L};const q=[],Y=[];for(const ee of L.conditions||[]){if(W(ee)){if(G.filter==="flat"){Y.push(ee);continue}const ne=m(ee,G);ne.pushed&&q.push(ne.pushed),ne.residual&&Y.push(ne.residual);continue}(i(ee,G)?q:Y).push(ee)}const J=ee=>ee.length===0?null:ee.length===1?ee[0]:{op:"and",conditions:ee};return{pushed:J(q),residual:J(Y)}}const c="__lattice_leaves";function f(L){return L.aggregates?L.aggregates instanceof Set?L.aggregates:new Set(I(L.aggregates)):new Set}function a(L){const G=f(L);return G.size?G.has("count")?L.filter!=="tree"||!L.operators||!L.operators.has("eq")?"the adapter does not declare the `group` capability, and cannot narrow a group's rows by its key (that needs a `tree` filter with the `eq` operator)":"":"the adapter does not declare the `group` capability, and its declared aggregates have no `count` to give each group its row count":"the adapter does not declare the `group` capability"}function p(L,G,q,Y,J,ee,ne){const ie=Array.isArray(L.groupBy)?L.groupBy:[],se=Array.isArray(L.groupPath)?L.groupPath:[],he=Array.isArray(L.groupValues)?L.groupValues:null;if(!G.group){const ce=a(G);if(ce)return ce}return A(ie)?q.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":Y?J?ee?"a host `where` predicate can only run in the browser, over rows the engine grouped":ne?"fullDataset holds the whole matching set, so the grid groups it itself":!he||he.length!==se.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would group unsearched rows":"the sort did not push, so the engine would order the groups differently":"a grouping key is not a plain column the engine can name in a GROUP BY"}const b="pushdown:pivot-unsupported",O="pushdown:group-unsupported",k=Symbol("lattice.remote.ungroupedLevel");function y(L,G,q,Y,J,ee){const ne=Array.isArray(L.pivotBy)?L.pivotBy:[],ie=Array.isArray(L.groupBy)?L.groupBy:[],se=Array.isArray(L.groupPath)?L.groupPath:[],he=Array.isArray(L.groupValues)?L.groupValues:null;return G.pivot?A(ne)?ie.length&&!A(ie)?"a grouping key is not a plain column the engine can name in a GROUP BY":q.residual?"the filter did not fully push, so the engine would pivot a superset of the matching rows":Y?J?ee?"a host `where` predicate can only run in the browser, over rows the engine pivoted":!he||he.length!==se.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would pivot unsearched rows":"the sort did not push, so the engine would order the rows differently":"a pivot column is not a plain column the engine can name in a GROUP BY":"the adapter does not declare the `pivot` capability"}function v(L,G,q=!1){const Y=m(L.filters||null,G),J=[];Y.residual&&J.push("filter");const ee=L.sort||[],ne=ee.length===0||G.sort==="multi"&&ee.length>=1||G.sort==="single"&&ee.length===1;!ne&&ee.length&&J.push("sort");const ie=L.quick?String(L.quick):"",se=!ie||!!G.quick;se||J.push("quick");const he=L.where&&L.where.active?L.where:null;he&&J.push("where");const ce={filters:Y.residual,sort:ne?null:ee,quick:se?"":ie,where:he},te=!!q,oe=Array.isArray(L.groupBy)&&L.groupBy.length>0,fe=oe?p(L,G,Y,ne,se,he,te):"",de=L.pivotMode!==!1&&Array.isArray(L.pivotBy)&&L.pivotBy.length>0,ve=de?y(L,G,Y,ne,se,he):"",Me=de&&ve==="";de&&!Me&&J.push("pivot");const Oe=de?Me&&oe:oe&&fe==="";oe&&!de&&!Oe&&J.push("group");const Ce=(Oe||Me)&&Array.isArray(L.groupValues)?L.groupValues.length:0,pe=Oe||de?!1:te||!!(ce.filters||ce.sort||ce.quick||ce.where)||!G.range;return{pushed:{...L,filters:Y.pushed,sort:ne?ee:[],quick:se?ie:"",range:pe?null:L.range},residual:ce,needsAll:pe,unpushed:J,full:te,grouped:Oe,groupLevel:Ce,groupReason:de?"":fe,pivoted:Me,pivotReason:ve}}function R(L){const G=Array.isArray(L.totals)?L.totals:[],q=L.totalFns&&typeof L.totalFns=="object"?L.totalFns:{},Y=[],J=[];for(const ee of G){const ne=String(ee),ie=typeof q[ne]=="string"?q[ne]:null,se=ie?g[ie]:null;ie?!se||!se.pushable||!se.sql?J.push({id:ne,fn:ie,class:se?se.class:"fallback",reason:se&&se.note?se.note:`the pushdown map cannot express "${ie}"`}):se.twoColumn?J.push({id:ne,fn:ie,class:se.class,reason:`"${ie}" reduces two columns, and a grouped request carries no weight column`}):Y.push({id:ne,col:ne,fn:ie,class:se.class}):J.push({id:ne,fn:null,class:"fallback",reason:"the column totals with a host function, so there is no named statistic to push"})}return{engine:Y,client:J}}const S=Object.freeze({items:L=>L==null?[]:Array.isArray(L)?L:[L]});function x(L,G,q){if(!G)return L;let Y=L;if(G.filters&&B(q.evaluateFilters)){const J=Y,ee={count:Y.length,handle:se=>({id:se,get:he=>s(J[he],se)}),itemwise:se=>J.some(he=>Array.isArray(s(he,se)))?S:null},ne=q.evaluateFilters(G.filters,ee),ie=[];for(let se=0;se<Y.length;se++)ne[se]&&ie.push(Y[se]);Y=ie}if(G.where&&G.where.active&&(G.whole||H(G.where.names,"pushdown"),Y=Y.filter(J=>G.where.passes(J))),G.quick){const J=G.quick.toLowerCase();Y=Y.filter(ee=>{if(!ee||typeof ee!="object")return!1;for(const ne of Object.values(ee))if(ne!=null&&String(ne).toLowerCase().includes(J))return!0;return!1})}if(G.sort&&G.sort.length&&B(q.sortMulti)){const J=[...new Set(G.sort.map(se=>se.col))],ee=Y,ne=J.map(se=>({id:se,get:he=>s(ee[he],se)})),ie=q.sortMulti(ne,G.sort.map(se=>({col:se.col,dir:se.dir})),Uint32Array.from({length:Y.length},(se,he)=>he),{});Y=Array.from(ie,se=>ee[se])}return Y}function C(L){return JSON.stringify({filters:L.filters||null,sort:L.sort||[],quick:L.quick||"",groupBy:L.groupBy||[],groupPath:L.groupPath||[],context:L.context??null})}function P(L){if(!L||typeof L!="object")return 16;let G="";try{G=JSON.stringify(L)}catch{return 200}return G.length*2+64}function F(L){const G=L||{};return{enabled:!!G.enabled,maxRows:Number.isFinite(G.maxRows)?G.maxRows:1e6,maxBytesEstimate:Number.isFinite(G.maxBytesEstimate)?G.maxBytesEstimate:512*1024*1024}}const E=5e4;function D(L){return Number.isFinite(L)&&L>=0?L:E}function N(L){return!!L&&B(L.then)}async function M(L){if(!L||L.total!==void 0||!N(L.pendingTotal))return L;const G=await L.pendingTotal,{pendingTotal:q,...Y}=L;return typeof G=="number"?{...Y,total:G}:Y}function j(L={}){const G=L.adapter;if(!G||!B(G.execute))return _("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{...L,mode:"remote",fetch:async()=>({rows:[],total:0})};const q=u(G.capabilities),Y=G.capabilities&&Object.getOwnPropertyDescriptor(G.capabilities,"operators");Y&&B(Y.get)&&Object.defineProperty(q,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(G.capabilities.operators||[]),set:()=>{}});const J=G.name||"adapter";let ee=null;const ne=()=>B(G.ready)?(ee||(ee=Promise.resolve(G.ready()).then(()=>{Object.assign(q,u(G.capabilities))},Ie=>{throw ee=null,Ie})),ee):null,ie=F(L.fullDataset),se=!!L.allowPartialResults,he=D(L.whereRowLimit);let ce=null;const te=L.aggregates;let oe=null,fe=null,de=null,ve=null,Me=null,Oe,Ce=null,pe=0,we=null;const me=()=>!ie.enabled||!oe?null:(we!==oe.key&&(pe++,we=oe.key),{rows:oe.rows,version:pe}),Ne=async Ie=>{const De=Ie.where&&Ie.where.active?Ie.where:null;if(!De)return{request:Ie,probe:null};const{where:Qe,...ye}=Ie,ge=v(ye,q,ie.enabled);if(ge.needsAll)return{request:Ie,probe:null};const Se=C(ge.pushed);let Pe=null;return(!ce||ce.key!==Se)&&(q.total?(n(Ie),Pe=await M(await G.execute(ge.pushed,Ie)),ce={key:Se,size:Pe&&typeof Pe.total=="number"?Pe.total:null}):ce={key:Se,size:null}),ce.size!==null&&ce.size<he?{request:Ie,probe:null}:(V(De.names,J,ce.size,he),{request:ye,probe:Pe})},$e=async(Ie,De)=>{Ce=null;const Qe=R(Ie.pushed);de={engine:Qe.engine,client:Qe.client,groupBy:Ie.pushed.groupBy},Qe.client.length&&_(`source.pushdown.group.totals.${J}.${Qe.client.map(Se=>Se.id).join(".")}`,`the ${J} adapter cannot compute the group subtotal for ${Qe.client.map(Se=>`"${Se.id}" (${Se.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 ye=await G.executeGroupLevel(Ie.pushed,Qe.engine,De)||{};let ge=ye.rows||[];return!q.range&&De.range&&(ge=ge.slice(De.range.start,De.range.end)),Ge(ye),ye.total===void 0?{rows:ge}:{rows:ge,total:ye.total}},He=new Map,qe=64,Ae=async(Ie,De)=>{Ce=null;const Qe=Ie.pushed,ye=Qe.groupBy,ge=Array.isArray(Qe.groupValues)?Qe.groupValues:[],Se=ge.length,Pe=[...Qe.filters?[Qe.filters]:[],...ye.slice(0,Se).map((it,ct)=>({col:it,op:"eq",value:ge[ct]===void 0?null:ge[ct],caseSensitive:!0}))],Re=Pe.length===0?null:Pe.length===1?Pe[0]:{op:"and",conditions:Pe},Be=De.range?De.range.start:0;if(Se>=ye.length){const it={...Qe,filters:Re,groupBy:[],groupPath:[],groupValues:[],totals:[],totalFns:{}},ct=await M(await G.execute(it,De))||{};let St=ct.rows||[];return!q.range&&De.range&&(St=St.slice(De.range.start,De.range.end)),typeof ct.total=="number"?{rows:St,total:ct.total}:{rows:St}}const _e=ye[Se],be=R(Qe),Ee=f(q),ze=be.engine.filter(it=>Ee.has(it.fn)),Ve=[...be.engine.filter(it=>!Ee.has(it.fn)).map(it=>({id:it.id,fn:it.fn,class:it.class,reason:`the ${J} adapter does not compute "${it.fn}"`})),...be.client];de={engine:ze,client:Ve,groupBy:ye},Ve.length&&_(`source.pushdown.group.totals.${J}.${Ve.map(it=>it.id).join(".")}`,`the ${J} adapter cannot compute the group subtotal for ${Ve.map(it=>`"${it.id}" (${it.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 Je=[...ze.map(it=>({id:it.id,col:it.col,fn:it.fn})),{id:c,col:_e,fn:"count"}],ot={...Qe,filters:Re,range:null},at=JSON.stringify([C(ot),ge,_e,Je]);let st=Be>0?He.get(at):void 0;if(!st){for(st=Promise.resolve(G.executeGroupedAggregates(ot,[_e],Je)),He.delete(at),He.set(at,st);He.size>qe;)He.delete(He.keys().next().value);st.catch(()=>{He.get(at)===st&&He.delete(at)})}const wt=await st||[];n(De);const kt=it=>{const ct={};for(const St of ze)ct[St.id]=it?it[St.id]:void 0;return ct},mt=(Qe.sort||[]).find(it=>it&&it.col===_e),Et=mt&&mt.dir==="desc"?-1:1,Ke=wt.filter(it=>it&&it.level===1).map(it=>({[_e]:it.keys[0]===void 0?null:it.keys[0],leafCount:Number(it.values&&it.values[c])||0,totals:kt(it.values)})).sort((it,ct)=>Et*$(it[_e],ct[_e]));if(Se===0){const it=wt.find(St=>St&&St.level===0),ct=it?Number(it.values&&it.values[c]):NaN;Ge({matchCount:Number.isFinite(ct)?ct:Ke.reduce((St,Rt)=>St+Rt.leafCount,0),...it?{grand:kt(it.values)}:{}})}const ht=De.range?De.range.end:Ke.length;return{rows:Ke.slice(Be,ht),total:Ke.length}},Ge=Ie=>{typeof Ie.matchCount=="number"&&(ve=Ie.matchCount,Me=Ie.grand?{totals:Ie.grand,leafCount:Ie.matchCount}:null,Oe===void 0&&B(G.unfilteredCount)&&(Oe=null,Promise.resolve(G.unfilteredCount()).then(De=>{Oe=typeof De=="number"?De:null}).catch(De=>{_(`source.pushdown.group.unfiltered.${J}`,`the ${J} adapter could not count the unfiltered set (${De&&De.message?De.message:De}), so "N of M" falls back to the display count for its denominator.`)})))},Ze=async(Ie,De)=>{Ce=null;const Qe=R(Ie.pushed);de={engine:Qe.engine,client:Qe.client,groupBy:Ie.pushed.groupBy,pivotBy:Ie.pushed.pivotBy},Qe.client.length&&_(`source.pushdown.pivot.totals.${J}.${Qe.client.map(Re=>Re.id).join(".")}`,`the ${J} adapter cannot compute the pivot cells for ${Qe.client.map(Re=>`"${Re.id}" (${Re.reason})`).join(", ")}, so those cells are empty. A figure computed over anything other than the cell would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const ye=await G.executePivotLevel(Ie.pushed,Qe.engine,De)||{};let ge=ye.rows||[];!q.range&&De.range&&(ge=ge.slice(De.range.start,De.range.end)),Ge(ye);const Se=ye.pivot&&typeof ye.pivot=="object"?ye.pivot:{},Pe={cells:Array.isArray(Se.cells)?Se.cells:[],...Array.isArray(Se.axis)?{axis:Se.axis}:{}};return ye.total===void 0?{rows:ge,pivot:Pe}:{rows:ge,total:ye.total,pivot:Pe}},nt=Ie=>{_(`source.pushdown.pivot.${J}.${Ie}`,`pushdown:pivot-unsupported: the ${J} adapter cannot pivot this query because ${Ie}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);const De=new Error(`[lattice] ${b}: the ${J} adapter cannot pivot this query because ${Ie}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);throw De.code=b,De.reason=Ie,De},lt=(Ie,De)=>{const Qe={key:De,state:"pending",value:null};return Ce=Qe,Ie.then(ye=>(Ce===Qe&&(Ce={key:De,state:"settled",value:typeof ye=="number"?ye:null}),ye),ye=>{throw Ce===Qe&&(Ce={key:De,state:"failed",value:null}),ye})};let ft=0,gt=[];const At=()=>ft===0?null:new Promise(Ie=>{const De=setTimeout(Ie,o);gt.push(()=>{clearTimeout(De),Ie()})}),Pt=async Ie=>{const De=ne();De&&await De;const ye=Ie&&Ie.pivotMode!==!1&&Array.isArray(Ie.pivotBy)&&Ie.pivotBy.length>0?{request:Ie,probe:null}:await Ne(Ie);n(Ie);let ge=v(ye.request,q,ie.enabled);if(q.group&&ge.grouped&&!ge.pivoted&&!B(G.executeGroupLevel)&&(_(`source.pushdown.group.method.${J}`,`the ${J} adapter declares the \`group\` capability but has no \`executeGroupLevel(query, aggregates, request)\`, so grouping is not pushed and the grid stays ungrouped unless it holds the whole matching set. Implement the method or drop the capability.`),ge=v(ye.request,{...q,group:!1,aggregates:null},ie.enabled)),ge.pivoted&&!B(G.executePivotLevel)&&(ge=v(ye.request,{...q,pivot:!1},ie.enabled),ge.pivotReason="the adapter declares the `pivot` capability but has no `executePivotLevel(query, aggregates, request)`"),ge.grouped&&!ge.pivoted&&!q.group&&!B(G.executeGroupedAggregates)&&(_(`source.pushdown.group.aggregates.method.${J}`,`the ${J} adapter declares \`aggregates\` but has no \`executeGroupedAggregates(query, groupBy, aggregates)\`, so the grouped view cannot be built from grouped aggregates and the grid stays ungrouped unless it holds the whole matching set. Implement the method, or declare \`group\` and implement \`executeGroupLevel\`.`),ge=v(ye.request,{...q,aggregates:null},ie.enabled)),fe=ge,ge.pivoted)return Ze(ge,Ie);if(ge.pivotReason&&nt(ge.pivotReason),ge.grouped)return q.group?$e(ge,Ie):Ae(ge,Ie);const Pe=!!ge.groupReason&&!ge.full;Pe?_(`source.pushdown.group-unsupported.${J}.${ge.groupReason}`,`pushdown:group-unsupported: the ${J} adapter was not asked to group this query because ${ge.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.`):ge.groupReason&&_(`source.pushdown.group.${J}.${ge.groupReason}`,`the ${J} adapter was not asked to group this query because ${ge.groupReason}. The engine returns rows and the grouping is the grid's to do, which needs every matching row in the browser — correct where the grid holds them, and wrong-looking where it holds a window. \`lastPlan().unpushed\` names it.`);const Re=Je=>Pe?{...Je,[k]:!0}:Je;if(!ge.needsAll){const Je=ye.probe||await G.execute(ge.pushed,Ie),ot=Je.rows||[];return N(Je.pendingTotal)&&Je.total===void 0?Re({rows:ot,pendingTotal:lt(Je.pendingTotal,C(ge.pushed))}):(Ce=null,!q.total&&Je.total===void 0?Re({rows:ot}):Re({rows:ot,total:Je.total??ot.length}))}ge.unpushed.length&&_(`source.pushdown.residual.${J}.${ge.unpushed.join(".")}`,`the ${J} adapter cannot push ${ge.unpushed.join(" or ")}, so every matching row is fetched and the rest is applied in the browser. Correct, and slower than it needs to be: widening the adapter is the fix.`);const Be=C(ge.pushed);if(!oe||oe.key!==Be){const Je=await M(await G.execute(ge.pushed,Ie));Ce=null;const ot=Je.rows||[];if(ge.full){const at=typeof Je.total=="number"?Math.max(Je.total,ot.length):ot.length;if(at>ie.maxRows)throw new Error(`[lattice] fullDataset refused: the ${J} adapter's matching set is ${at.toLocaleString()} rows, past the configured maxRows of ${ie.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 st=ot.length*P(ot[0]);if(st>ie.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${J} adapter's matching set is an estimated ${Math.round(st/(1024*1024)).toLocaleString()} MB across ${ot.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(ie.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 Je.total=="number"&&ot.length<Je.total){const at=!!(ge.residual.filters||ge.residual.quick||ge.residual.sort&&ge.residual.sort.length);if(at&&!se)throw new Error(`[lattice] the ${J} adapter returned ${ot.length} of ${Je.total} matching rows when asked for the whole result, and the query has residual ${ge.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.`);at?_(`source.pushdown.partial.residual.${J}`,`the ${J} adapter returned ${ot.length} of ${Je.total} matching rows when asked for the whole result, and residual work will run over that fraction. allowPartialResults is set, so the result is used as-is — it may be wrong. The adapter must follow the engine's own paging to be correct.`):_(`source.pushdown.partial.${J}`,`the ${J} adapter returned ${ot.length} of ${Je.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}oe={key:Be,rows:ot,total:typeof Je.total=="number"?Je.total:null}}let _e=ge;if(ge.residual.where){const Je=oe.total??oe.rows.length;if(Je>=he){V(ge.residual.where.names,J,Je,he);const{where:ot,...at}=ye.request;_e=v(at,q,ie.enabled),fe=_e}}const be=oe.total!==null&&oe.rows.length>=oe.total,Ee=x(oe.rows,{..._e.residual,whole:be},L.compute||{}),ze=Ie.range?Ie.range.start:0,Ve=Ie.range?Ie.range.end:Ee.length;return Re({rows:Ee.slice(ze,Ve),total:Ee.length})},Ct=async(Ie,De)=>{const Qe=At();Qe&&await Qe;const ye=ne();ye&&await ye;const ge=v(Ie,q,ie.enabled);fe=ge;const Se=w(De,te),Pe=Array.isArray(Ie.groupBy)?Ie.groupBy:[],Re=Pe.length>0,Be=!ge.residual.filters&&!ge.residual.quick,_e=!Re||A(Pe,q.buckets);let be=Se.engine,Ee=Se.client;if(q.aggregates&&be.length){const ot=q.aggregates instanceof Set?q.aggregates:new Set(I(q.aggregates)),at=be.filter(st=>!ot.has(st.fn));at.length&&(be=be.filter(st=>ot.has(st.fn)),Ee=[...at.map(st=>({...st,reason:`the ${J} adapter does not compute "${st.fn}"`})),...Ee])}const ze=ot=>{Ee=[...be.map(at=>({...at,reason:ot})),...Ee],be=[]};be.length&&!Be?ze(ge.residual.quick&&!ge.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)"):be.length&&!_e&&ze("a grouping key the engine cannot form forces all-client (no mixed provenance)");let Ve={},Je;return be.length&&(B(Re?G.executeGroupedAggregates:G.executeAggregates)?Re?Je=await G.executeGroupedAggregates(ge.pushed,Pe,be)||[]:Ve=await G.executeAggregates(ge.pushed,be)||{}:(_(`source.pushdown.aggregates.${J}${Re?".grouped":""}`,`the ${J} adapter cannot compute ${Re?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),ze(`adapter cannot compute ${Re?"grouped ":""}aggregates`))),de={engine:be,client:Ee,...Re?{groupBy:Pe}:{}},{values:Ve,engine:be,client:Ee,...Je!==void 0?{groups:Je}:{}}},Mt=async Ie=>{ft++;try{return await Pt(Ie)}finally{if(ft--,ft===0&>.length){const De=gt;gt=[];for(const Qe of De)Qe()}}},Dt=h(L.edit),Bt=L.edit&&typeof L.edit=="object"&&B(L.edit.commit);let dt=L.edit;if(Dt&&!Bt)if(q.mutate&&q.mutate.update){const Ie=De=>{if(!q.mutate||!q.mutate.update)throw new Error(`[lattice] the ${J} adapter cannot update rows (mutate.update is not declared), so this edit cannot be persisted. The cell is reverted rather than left looking saved.`);const Qe={kind:"update",key:String(De.key),patch:{[De.colId]:De.value}};return G.mutate(Qe,De.request||{})};dt={...L.edit===!0?{}:L.edit,commit:Ie}}else _(`source.pushdown.readonly.${J}`,`edit is enabled but the ${J} adapter declares mutate: ${q.mutate?"without update":"false"} (read-only by declaration), so no commit is synthesised and the grid stays read-only. Declare \`mutate: { update: true }\` on the adapter to allow cell edits.`);const rt=Dt&&q.mutate&&(q.mutate.append||q.mutate.delete)?{append:q.mutate.append===!0,remove:q.mutate.delete===!0,returning:q.mutate.returning,mutate:(Ie,De)=>G.mutate(Ie,De||{})}:null,le=async Ie=>{const De=ne();De&&await De;const{range:Qe,signal:ye,export:ge,...Se}=Ie||{},Pe={...Se,groupBy:[],groupPath:[],groupValues:[],pivotBy:[],pivotMode:!1,totals:[]};return{plan:v(Pe,q,ie.enabled),signal:ye}};async function*ke(Ie,De={}){const{plan:Qe,signal:ye}=await le(Ie),ge=Math.max(1,Math.floor(Number(De.pageSize))||5e3),Se={signal:ye,stream:!0};if(!Qe.needsAll)for(let Be=0;;Be+=ge){n(Se);const _e=await G.execute({...Qe.pushed,range:{start:Be,end:Be+ge}},Se);_e&&N(_e.pendingTotal)&&_e.pendingTotal.then(null,()=>{});const be=_e&&_e.rows||[];if(be.length&&(yield be),be.length<ge)return}n(Se);const Pe=await M(await G.execute({...Qe.pushed,range:void 0},Se)),Re=x(Pe&&Pe.rows||[],{...Qe.residual,whole:!0},L.compute||{});for(let Be=0;Be<Re.length;Be+=ge)yield Re.slice(Be,Be+ge)}return{...L,edit:dt,rowMutate:rt,mode:"remote",fetch:Mt,foregroundIdle:At,aggregate:Ct,countMatching:async Ie=>{const{plan:De,signal:Qe}=await le(Ie);if(!De.needsAll&&q.total){n({signal:Qe});const ge=await M(await G.execute({...De.pushed,range:{start:0,end:0}},{signal:Qe}));if(ge&&typeof ge.total=="number")return ge.total}let ye=0;for await(const ge of ke(Ie))ye+=ge.length;return ye},streamMatching:ke,lastPlan:()=>fe?{...fe,...de?{aggregates:de}:{},...Ce?{total:{deferred:!0,state:Ce.state,value:Ce.value}}:{}}:null,fullFrame:me,counts:()=>({match:ve,total:Oe??null,pending:!!Ce&&Ce.state==="pending"}),grandTotals:()=>Me}}}),Fe("packages/core/src/source/remote.js",function(e,K){"use strict";Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return P}});const Q=K("packages/core/src/internal/util.js"),$=Q.Lru,B=Q.isFunction,I=Q.warnOnce,_=Q.settleDebounce,X=K("packages/core/src/source/abort.js"),W=X.createAbortScope,H=X.isAbortError,V=K("packages/core/src/source/blockcache.js"),z=V.BlockCache,w=V.DEFAULT_PAGE_SIZE,A=V.DEFAULT_MAX_CACHED_PAGES,g=K("packages/core/src/source/rows.js"),l=g.createRowFactory,d=g.groupKey,o=K("packages/core/src/source/filterwire.js"),n=o.wireFilters,t=o.querySignature,r=o.warnHostFilterNotApplied,h=K("packages/core/src/source/pagewindow.js").pageWindow,i=K("packages/core/src/source/memory.js").MemorySource,c=K("packages/core/src/compute/handle.js").valueComparator,f=K("packages/core/src/compute/pivot.js"),a=f.pivotKey,p=f.joinPath,b=f.DEFAULT_PATH_SEPARATOR,k=K("packages/core/src/source/pushdown.js").UNGROUPED_LEVEL,y=1,v=120,R=1e3;function S(F,E,D){for(let N=0;N<Math.max(F.length,E.length);N++){const M=F[N],j=E[N],L=M==null,G=j==null;if(L||G){if(L&&G)continue;return L?1:-1}const q=D(M,j);if(q!==0)return q}return 0}function x(F,E){return new P(F,E)}class C{constructor(E,D,N,M){this.path=E,this.keyPath=M||E,this.values=[],this.level=D,this.key=d(this.keyPath),this.cache=new z(N),this.count=null,this.complete=!1,this.announced=null,this.counting=!1,this.failed=!1,this.children=new Map,this.row=null,this.flat=!1}}class P{mode="remote";#e;#t;#n;#r;#o=new Map;#i=new Set;#s=W();#l;#a;#u=new Map;#c=[];#d=null;#h="";#f;#p=!1;#m=!1;#g=[];#b=0;#w="";#S=null;#y=-1;constructor(E,D){this.#e=E||{mode:"remote"},this.#t=D||{},B(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#x(),this.unfilteredIndices=()=>this.#B(),this.handleFor=G=>this.#H(G),this.display=()=>this.#U(),this.grandTotalRow=()=>this.#$(),this.unfilteredRows=()=>this.#Y(),this.facetIndices=G=>this.#N(G));const N=this.#e.counts;B(N)&&(this.matchCount=()=>this.#z("match"),this.totalCount=()=>this.#z("total"));const M=this.#e.grandTotals;B(M)&&(this.grandTotalRow=()=>this.#_());const j=this.#e.foregroundIdle;B(j)&&(this.foregroundIdle=()=>this.#oe(j));const L=this.#e;B(L.countMatching)&&B(L.streamMatching)&&(this.selectionQuery=()=>this.#le(),this.countMatching=G=>L.countMatching(G),this.streamMatching=(G,q)=>L.streamMatching(G,q),this.loadedRows=()=>this.#re(),this.resident=()=>this.#E()!==null),this.#n={pageSize:this.#e.pageSize||w,maxCachedPages:this.#e.maxCachedPages||A},this.#l=l(this.#t),this.#a=new $(this.#n.pageSize*4),this.#f=_((G,q)=>this.#M(G,q),v),this.#r=new C([],0,this.#n),this.#o.set(this.#r.key,this.#r),this.#h=this.#fe(),B(this.#e.fetch)||I("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#R()}count(){const E=this.#j();return E?E.length:this.#O()}#O(){const E=this.#E();return E?E.count():(this.#me(),this.#Q(this.#r))}#k(){if(this.#E())return!0;const E=D=>{if(D.count===null&&!D.complete)return!1;for(const N of D.children.values())if(this.#ne(N.key)&&!E(N))return!1;return!0};return E(this.#r)}pageInfo(){const E=this.#j(),D=this.totalPending();if(!E){const N=this.#O();return{page:0,pageSize:0,total:this.#k()?N:null,pageCount:1,counting:D}}return{page:E.page,pageSize:E.pageSize,total:E.total,pageCount:E.pageCount,counting:D||E.total===null&&this.#s.size>0&&this.#r.cache.loadedExtent()===0}}#j(){const E=this.#O(),D=h(this.#I("pageSize",0),this.#I("page",0),E,this.#k());if(!D)return this.#w="",null;const N=`${this.#b}:${D.offset}:${D.length}`;return N!==this.#w&&!this.#p&&(this.#w=N,D.length>0&&!this.#E()&&this.#M(D.offset,D.offset+D.length-1)),D}at(E){const D=this.#j();if(D){if(E<0||E>=D.length)return;const N=this.#A(D.offset+E);return N&&(N.index=E),N}return this.#A(E)}#A(E){const D=this.#E();if(D)return D.at(E);if(this.#me(),E<0||E>=this.#O())return;const N=this.#ve(this.#r,E);if(!N)return;const M=this.#ie(N.node,N.local);return M&&(M.index=E),M||this.#l.skeleton(E,N.node.level,N.node.cache.erroredAt(N.local))}byKey(E){const D=this.#E();if(D)return D.byKey(E);const N=this.#u.get(E);if(!N)return;const M=N.lastIndexOf(":"),j=this.#o.get(N.slice(0,M));return j&&this.#ie(j,Number(N.slice(M+1)))||void 0}loaded(E){const D=this.#j();if(D){if(E<0||E>=D.length)return!1;E+=D.offset}const N=this.#E();if(N)return N.loaded(E);if(E<0||E>=this.#O())return!1;const M=this.#ve(this.#r,E);return!!M&&M.node.cache.rowLoaded(M.local)}hint(E,D){if(this.#p)return;const N=this.#me();let M=Math.max(0,Math.floor(E)),j=Math.max(M,Math.floor(D));const L=this.#j();if(L){if(L.length===0)return;M=L.offset,j=L.offset+L.length-1}for(const[G,q]of this.#T(M,j)){G.cache.protect(q.min,q.max);for(const Y of G.cache.evict())this.#q(G,Y)}this.#f(M,j),N&&this.#f.flush()}#T(E,D){const N=this.#O(),M=new Map;for(let j=E;j<=D&&j<N;j++){const L=this.#ve(this.#r,j);if(!L)continue;const G=M.get(L.node);G?(G.min=Math.min(G.min,L.local),G.max=Math.max(G.max,L.local)):M.set(L.node,{min:L.local,max:L.local})}return M.size||M.set(this.#r,{min:E,max:E}),M}#M(E,D){if(!this.#p)for(const[N,M]of this.#T(E,D)){N.cache.protect(M.min,M.max);const j=N.cache.blockOf(M.min),L=N.cache.blockOf(M.max);for(let G=j;G<=L&&!(N.count!==null&&G*N.cache.pageSize>=N.count);G++)N.cache.has(G)||this.#ge(N,G)}}apply(E){const D={added:[],updated:[],removed:[]};if(!E)return D;if(E.update)for(const N of E.update){const M=this.#u.get(this.#l.keyOf(N,-1));if(!M)continue;this.#a.delete(M);const j=M.lastIndexOf(":"),L=this.#o.get(M.slice(0,j));if(!L)continue;const G=Number(M.slice(j+1)),q=L.cache.blockOf(G);if(!L.cache.loaded(q))continue;const{start:Y}=L.cache.rangeOf(q),J=[];for(let ne=Y;ne<Y+L.cache.pageSize;ne++){const ie=L.cache.rowAt(ne);if(ie===void 0)break;J.push(ne===G?N:ie)}L.cache.fill(q,J);const ee=this.#ie(L,G);ee&&D.updated.push(ee)}return(E.add&&E.add.length||E.remove&&E.remove.length)&&this.reload({keepExpanded:!0}),D}reload(E){this.#s.abortAll("reload"),this.#f.cancel(),E&&E.keepExpanded===!1&&this.#i.clear(),this.#je(),this.#D("model:changed",{reason:"reload"})}destroy(){this.#p=!0,this.#f.cancel(),this.#s.abortAll("destroyed"),this.#je(),this.#o.clear(),this.#i.clear(),this.#S&&B(this.#S.destroy)&&this.#S.destroy(),this.#S=null}expand(E){this.#i.has(E)||(this.#i.add(E),this.#D("group:toggled",{key:E,expanded:!0}),this.#D("model:changed",{reason:"expand",key:E}))}collapse(E){this.#i.delete(E)&&(this.#D("group:toggled",{key:E,expanded:!1}),this.#D("model:changed",{reason:"collapse",key:E}))}expandedKeys(){return[...this.#i]}pivotFields(){return this.#c}pivot(){this.#me();const E=this.#d;if(!E||!E.keys.size||!this.#I("pivotBy",[]).length)return null;if(!E.result){const D=c((this.#t.config||{}).locale),N=[...E.keys.entries()].sort((j,L)=>S(j[1],L[1],D)),M=N.map(([j])=>j);E.result={keys:N.map(([,j])=>j),paths:M,fields:this.#X(M),groupPaths:[],columns:M.length*Math.max(1,this.#ke().length),values:E.cells,cells:E.cells,error:null}}return E.result}invalidateHandles(){this.#S&&(B(this.#S.invalidateHandles)&&this.#S.invalidateHandles(),B(this.#S.invalidate)&&this.#S.invalidate("filter"))}#C(){const E=this.#e.fullFrame;return B(E)?E():null}#E(){const E=this.#C();return E?(this.#S||(this.#S=new i({mode:"memory"},this.#L())),E.version!==this.#y&&(this.#S.setRows(E.rows),this.#y=E.version),this.#S):null}#L(){const E=this.#t,D=E.state||{};return{...E,state:{...D,page:()=>0,pageSize:()=>0}}}#x(){const E=this.#E();return E?E.filteredIndices():new Uint32Array(0)}#B(){const E=this.#E();return E?E.unfilteredIndices():new Uint32Array(0)}#H(E){const D=this.#E();return D?D.handleFor(E):void 0}#U(){const E=this.#E();return E?E.display():[]}#N(E){const D=this.#E();return D&&B(D.facetIndices)?D.facetIndices(E):new Uint32Array(0)}#$(){const E=this.#E();return E&&B(E.grandTotalRow)?E.grandTotalRow():null}#z(E){const D=this.#E();if(D){const L=E==="match"?D.matchCount:D.totalCount;if(B(L))return L.call(D)}const N=this.#e.counts,M=B(N)?N():null,j=M?M[E]:null;return typeof j=="number"?j:this.#O()}#_(){const E=this.#E();if(E&&B(E.grandTotalRow))return E.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const N=this.#e.grandTotals,M=B(N)?N():null;return!M||!M.totals?null:this.#l.grandTotal(M.totals,M.leafCount||0)}#Y(){const E=this.#E();if(E&&B(E.unfilteredRows))return E.unfilteredRows();const D=[],N=this.count();for(let M=0;M<N;M++){const j=this.at(M);j&&D.push(j)}return D}#le(){const E=this.#I("quick",""),D={protocol:y,groupPath:[],groupValues:[],groupBy:[],totals:[],totalFns:{},pivotBy:[],pivotMode:!1,filters:n(this.#I("filters",null),this.#ue()),sort:this.#I("sort",[]),context:this.#I("context",null)};E&&(D.quick=E);const N=this.#I("where",null);return N&&N.active&&(D.where=N),D}#re(){const E=this.#I("groupBy",[]).length,D=[];for(const N of this.#o.values())if(!(N.level!==E&&!N.flat))for(const M of N.cache.ids()){if(!N.cache.loaded(M))continue;const{start:j,end:L}=N.cache.rangeOf(M);for(let G=j;G<L&&N.cache.rowLoaded(G);G++){const q=this.#ie(N,G);q&&!q.group&&D.push(q)}}return D}loadedCount(){const E=this.#E();if(E){const M=E.matchCount();return typeof M=="number"?M:E.count()}this.#me();const D=this.#I("groupBy",[]).length;let N=0;for(const M of this.#o.values())if(!(M.level!==D&&!M.flat))for(const j of M.cache.ids()){if(!M.cache.loaded(j))continue;const L=M.cache.fillOf(j);typeof L=="number"&&(N+=L)}return N}residentRows(){const E=this.#E();return E?E.display():this.#I("groupBy",[]).length>0?null:(this.#me(),this.#re())}#se(E,D,N){const{start:M,end:j}=E.cache.rangeOf(D),L=this.#I("groupBy",[]),G=this.#I("pivotBy",[]),q=this.#I("quick",""),Y=this.#ke(),J={protocol:y,range:{start:M,end:j},groupPath:E.path,groupValues:E.values,groupBy:L,totals:Y,totalFns:this.#de(Y),pivotBy:G,pivotMode:G.length>0,filters:n(this.#I("filters",null),this.#ue()),sort:this.#I("sort",[]),context:this.#I("context",null),signal:N};q&&(J.quick=q);const ee=this.#I("where",null);return ee&&ee.active&&(J.where=ee),J}async#ge(E,D){if(!B(this.#e.fetch))return;if(!this.#m){this.#m=!0;const L=this.#g;this.#g=[],queueMicrotask(()=>{for(const G of L)G()})}const N=this.#s.begin(`${E.key}:${D}`);E.cache.begin(D,N);const M=this.#h,{start:j}=E.cache.rangeOf(D);try{const L=await this.#e.fetch(this.#se(E,D,N.signal));if(!N.current||M!==this.#h||this.#p)return;N.settle();const G=L&&L.rows||[];if(!!(L&&L[k])&&!E.flat){E.flat=!0,E.children.clear();for(const[ee,ne]of[...this.#u])ne.startsWith(`${E.key}:`)&&(this.#a.delete(ne),this.#u.delete(ee))}E.cache.fill(D,G),E.failed=!1;for(let ee=0;ee<G.length;ee++)this.#a.delete(`${E.key}:${j+ee}`);const Y=L&&typeof L.count=="number"?L.count:L&&typeof L.total=="number"?L.total:null,J=L&&B(L.pendingTotal?.then)?L.pendingTotal:null;Y!==null?(E.count=Y,E.complete=!0):G.length<E.cache.pageSize?(E.count=j+G.length,E.complete=!0):J&&(E.counting=!0,E.announced=null),L&&Array.isArray(L.pivotFields)&&this.#pe(L.pivotFields),L&&L.pivot&&typeof L.pivot=="object"&&this.#G(L.pivot),this.#D("model:changed",{reason:"page",groupPath:E.path,block:D}),this.#D("rows:changed",{companion:!0,reason:"page",groupPath:E.path,block:D}),this.#we(E),J&&this.#Me(E,J,M)}catch(L){if(N.settle(),H(L))return;E.cache.failed(D,L),E.failed=!0;const{end:G}=E.cache.rangeOf(D);for(let q=j;q<G;q++)this.#a.delete(`${E.key}:${q}`);this.#D("model:changed",{reason:"page-error",groupPath:E.path,block:D}),this.#D("source:error",{error:L,groupPath:E.path,block:D})}}async#Me(E,D,N){let M;try{M=await D}catch(j){if(N!==this.#h||this.#p)return;E.counting=!1,H(j)||(E.failed=!0),H(j)||this.#D("source:error",{error:j,groupPath:E.path});return}N!==this.#h||this.#p||(E.counting=!1,typeof M=="number"&&(E.count=M,E.complete=!0,this.#we(E),this.#D("model:changed",{reason:"total",count:M,groupPath:E.path})))}#we(E){typeof E.count!="number"||!E.complete||E.announced!==E.count&&(E.announced=E.count,this.#D("source:total",{total:E.count,groupPath:E.path}))}#oe(E){if(this.#p)return null;const D=this.#m?null:new Promise(G=>{this.#g.push(G),setTimeout(G,R)}),N=E();if(!D&&!N)return null;const M=(async()=>{D&&await D;for(let G=E();G;G=E())await G})();let j;const L=new Promise(G=>{j=setTimeout(G,R)});return Promise.race([M,L]).then(()=>clearTimeout(j))}totalPending(){if(this.#r.failed)return!1;if(this.#r.counting===!0)return!0;if(this.#E())return!1;this.#me();const E=this.#r;return E.count===null&&!E.complete&&E.cache.loadedExtent()===0}totalFailed(){return this.#r.failed===!0}#pe(E){E.length===this.#c.length&&E.every((D,N)=>D===this.#c[N])||(this.#c=E,this.#D("column:pivoted",{pivotFields:E,remote:!0}))}#te(){const E=this.#t.config||{};return E.pivot&&E.pivot.separator||b}#X(E){const D=this.#te(),N=this.#ke();if(!N.length)return E.slice();const M=[];for(const j of E)for(const L of N)M.push(`${j}${D}${L}`);return M}#G(E){const D=this.#te();this.#d||(this.#d={keys:new Map,cells:new Map,result:null});const N=this.#d;let M=!1;const j=G=>{const q=Array.isArray(G)?G:[G],Y=p(q,D);return N.keys.has(Y)||(N.keys.set(Y,q),M=!0),Y},L=this.#I("groupBy",[]).length>0;for(const G of Array.isArray(E.axis)?E.axis:[])j(G);for(const G of Array.isArray(E.cells)?E.cells:[]){if(!G||typeof G!="object")continue;const q=j(G.pivot);if(L&&!(Array.isArray(G.group)&&G.group.length))continue;const Y=p(Array.isArray(G.group)?G.group:[],D);for(const[J,ee]of Object.entries(G.values||{}))N.cells.set(a(Y,q,J),ee)}N.result=null,M&&this.#pe((this.pivot()||{fields:[]}).fields)}#Q(E){let D=this.#Z(E);for(const N of E.children.values())this.#ne(N.key)&&(D+=this.#Q(N));return D}#Z(E){if(E.count!==null)return E.count;const D=E.cache.loadedExtent();return E.complete?D:E.row&&E.row.leafCount>0?E.level>=this.#I("groupBy",[]).length?Math.max(D,E.row.leafCount):D===0?1:Math.min(D+E.cache.pageSize,Math.max(D,E.row.leafCount)):D+E.cache.pageSize}#ve(E,D){let N=D,M=0;const j=[...E.children.entries()].filter(([,G])=>this.#ne(G.key)).sort((G,q)=>G[0]-q[0]);for(const[G,q]of j){const Y=G-M+1;if(N<Y)return{node:E,local:M+N};N-=Y,M=G+1;const J=this.#Q(q);if(N<J)return this.#ve(q,N);N-=J}const L=this.#Z(E);return M+N<L?{node:E,local:M+N}:null}#ie(E,D){const N=`${E.key}:${D}`,M=this.#a.get(N);if(M)return M;const j=E.cache.rowAt(D);if(j===void 0)return null;const L=this.#I("groupBy",[]);let G;if(E.level<L.length&&!E.flat){const q=L[E.level],Y=this.#d!==null&&E.level===L.length-1&&this.#I("pivotBy",[]).length>0,J=this.#V(j,q),ee=J==null,ne=[...E.path,ee?"":String(J)],ie=[...E.keyPath,ee?null:String(J)];if(G=this.#l.group({path:ne,keyPath:ie,column:q,value:J,level:E.level,parent:E.row,leafCount:Number(j.leafCount)||0,expanded:Y?!1:this.#ne(d(ie)),...Y?{hasChildren:!1}:{}}),G.totals=this.#ae(j),G.data=j,!Y){let se=this.#o.get(G.key);se?se.row=G:(se=new C(ne,E.level+1,this.#n,ie),se.row=G,this.#o.set(se.key,se)),se.values=[...E.values,J],E.children.set(D,se)}}else G=this.#l.leaf(j,D,E.level,E.row);return this.#a.set(N,G),this.#u.set(G.key,N),G}#ae(E){const D=E||{};if(D.totals&&typeof D.totals=="object")return D.totals;const N={};for(const M of this.#ke())Object.hasOwn(D,M)&&(N[M]=D[M]);return N}#q(E,D){const{start:N,end:M}=E.cache.rangeOf(D);for(let j=N;j<M;j++){const L=`${E.key}:${j}`,G=this.#a.peek(L);G&&this.#u.delete(G.key),this.#a.delete(L)}}#me(){const E=this.#fe();return E===this.#h?!1:(this.#h=E,this.#s.abortAll("query"),this.#je(),this.#D("model:changed",{reason:"query"}),!0)}#je(){for(const E of this.#o.values())E.cache.clear(),E.count=null,E.complete=!1,E.announced=null,E.counting=!1,E.failed=!1,E.children.clear(),E.flat=!1;this.#a.clear(),this.#u.clear(),this.#b++,this.#d=null}#fe(){const E=this.#I("where",null);return`${t({filters:this.#I("filters",null),sort:this.#I("sort",[]),quick:this.#I("quick",""),groupBy:this.#I("groupBy",[]),pivotBy:this.#I("pivotBy",[]),context:this.#I("context",null)})}|${E?E.version:0}`}#ne(E){const D=this.#I("expanded",null);return D?B(D.has)?D.has(E):Array.prototype.includes.call(D,E):this.#i.has(E)}#ke(){const E=this.#I("totals",[]);if(E&&E.length)return[...E];const D=this.#t.columns;return!D||!B(D.all)?[]:D.all().filter(N=>!!N.total).map(N=>N.id)}#de(E){const D=this.#t.columns,N={};if(!D||!B(D.get))return N;for(const M of E){const j=D.get(M);if(!j)continue;const L=j.groupTotal!=null?j.groupTotal:j.total;typeof L=="string"&&(N[M]=L)}return N}#V(E,D){const N=this.#t.columns,M=N&&B(N.get)?N.get(D):void 0;return M&&B(M.getValue)?M.getValue(E):E?.[D]}#R(){r(this.#t)}#ue(){const E=this.#t.config||{};return{tz:E.timeZone,weekStartsOn:E.weekStartsOn}}#I(E,D){const N=this.#t.state;if(N&&B(N[E])){const M=N[E]();return M??D}return D}#D(E,D){const N=this.#t.emit;B(N)&&N(E,D)}}}),Fe("packages/core/src/source/gapbuffer.js",function(e,K){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return $}});const Q=64;class ${#e;#t=0;#n=0;constructor(I=Q){this.#e=new Uint32Array(Math.max(1,I)),this.#n=this.#e.length}static from(I,_=Q){const X=new $(I.length+Math.max(1,_));return X.#e.set(I,0),X.#t=I.length,X.#n=X.#e.length,X}get length(){return this.#t+(this.#e.length-this.#n)}get capacity(){return this.#e.length}at(I){return I<0||I>=this.length?0:I<this.#t?this.#e[I]:this.#e[I+(this.#n-this.#t)]}insert(I,_){const X=I<0?0:I>this.length?this.length:I;this.#r(X),this.#t===this.#n&&this.#o(),this.#e[this.#t++]=_}push(I){this.insert(this.length,I)}removeAt(I){return!Number.isInteger(I)||I<0||I>=this.length?!1:(this.#r(I),this.#n++,!0)}toArray(){const I=new Uint32Array(this.length);return I.set(this.#e.subarray(0,this.#t),0),I.set(this.#e.subarray(this.#n),this.#t),I}clear(){this.#t=0,this.#n=this.#e.length}#r(I){if(I!==this.#t)if(I<this.#t){const _=this.#t-I;this.#e.copyWithin(this.#n-_,I,this.#t),this.#t=I,this.#n-=_}else{const _=I-this.#t;this.#e.copyWithin(this.#t,this.#n,this.#n+_),this.#t=I,this.#n+=_}}#o(){const I=this.#e.length-this.#n,_=new Uint32Array(Math.max(this.#e.length*2,this.#e.length+Q));_.set(this.#e.subarray(0,this.#t),0),_.set(this.#e.subarray(this.#n),_.length-I),this.#e=_,this.#n=_.length-I}}}),Fe("packages/core/src/store/ingest.js",function(e,K){"use strict";Object.defineProperty(e,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"inferKind",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"decideText",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"createReaders",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"Ingest",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return n}});const Q=K("packages/core/src/internal/util.js"),$=Q.now,B=Q.nextFrame,I=Q.infoOnce,_=Q.warnOnce,X=Q.isFunction,W=Q.pathGetter,V=K("packages/core/src/store/columnstore.js").ColumnStore,z=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function w(t,r={}){if(r.multi)return"multi";if(t.length===0)return"object";let s=0,h=0,u=0,i=0,m=0;for(let f=0;f<t.length;f++){const a=t[f];typeof a=="number"?s++:typeof a=="boolean"?h++:typeof a=="string"?u++:a instanceof Date?i++:Array.isArray(a)&&m++}const c=t.length;return s===c?"float64":h===c?"bitset":i===c?"float64":u===c?"text":m===c?"multi":"object"}function A(t,r,s){return r<=0||t<s*r?"dictionary":"object"}function g(t,r,s){const h=new Map,u=new Map;for(const y of t){if(y.computed)continue;const v=X(y.read)?y.read:W(y.field||y.id);u.set(y.id,v),h.set(y.id,v)}const i=r?.order??[],m=r?.fns??{},c=r?.deps??{},f=r?.wrapDeps??null,a=i.filter(y=>X(m[y])),p=a.some(y=>c[y]==="*");let b=new WeakMap;const O=y=>{const v={};if(p)for(const[R,S]of u)v[R]=S(y);for(const R of a){const S=c[R];let x;if(S==="*")x=v;else{x={};const C=S||[];for(let P=0;P<C.length;P++){const F=C[P];x[F]=F in v?v[F]:u.get(F)?.(y)}}v[R]=m[R](f?f(x,R):x,{data:y,row:null,column:null,grid:null,context:s})}return v},k=y=>{if(y===null||typeof y!="object"&&typeof y!="function")return O(y);let v=b.get(y);return v===void 0&&(v=O(y),b.set(y,v)),v};for(const y of a)h.set(y,v=>k(v)[y]);return{readers:h,reset(){b=new WeakMap}}}class l{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(r,s){this.spec=r,this.read=s,this.kind="object",this.inferred=!1,this.nullable=r.nullable!==!1}}class d{#e;#t=[];#n=null;#r;#o=0;#i;#s=!1;#l=!1;#a=0;#u;constructor(r,s={},h={}){this.#e=Array.isArray(r)?r:Array.from(r||[]),this.#i={...z,...h};const u=s.columns??[];this.#r=g(u,s.computed??null,s.context),this.#u=this.#e.length>=this.#i.columnarBelow,this.#c(u,s.computed??null),this.#n=new V(this.#t.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,read:i.read,dictionary:i.spec.dictionary})),{initialCapacity:this.#i.initialCapacity,columnarBelow:this.#i.columnarBelow})}get store(){return this.#n}get done(){return this.#s||this.#l}get progress(){return this.#o}slice(){if(this.done)return!1;if(this.#i.signal?.aborted)return this.#l=!0,!1;const r=$(),{chunkMs:s,chunkRows:h}=this.#i,u=this.#e.length;do{const i=Math.min(this.#o+h,u);this.#n.append(this.#e.slice(this.#o,i)),this.#d(this.#o,i),this.#o=i,this.#r.reset(),this.#f(!1)}while(this.#o<u&&$()-r<s);return this.#a+=$()-r,this.#i.onProgress?.({loaded:this.#o,total:u}),this.#o>=u?(this.#f(!0),this.#s=!0,!1):!0}cancel(){this.#l=!0}result(){return{store:this.#n,schema:this.#t.map(r=>({id:r.spec.id,kind:r.kind,nullable:r.nullable,read:r.read,dictionary:r.spec.dictionary})),decisions:this.#t.map(r=>({id:r.spec.id,kind:r.kind,nullable:r.nullable,inferred:r.inferred,distinct:r.candidate||r.change?this.#h(r):null,change:r.change,reason:r.reason})),count:this.#n.count,elapsed:this.#a,cancelled:this.#l}}#c(r,s){const h=this.#e,u=Math.min(this.#i.sampleSize,h.length),i=this.#i.dictionaryRatio,m=s?.pure instanceof Set?s.pure:new Set(s?.pure??s?.order??[]);for(const c of r){if(!c||!c.id)continue;if(c.computed&&(c.pure===!1||s&&!m.has(c.id))){_(`ingest.impure.${c.id}`,`column "${c.id}" is an impure computed column and is not materialised into the store`);continue}const f=this.#r.readers.get(c.id)??(X(c.read)?c.read:W(c.field||c.id)),a=new l(c,f);if(c.kind)a.kind=c.kind,a.reason="declared by the caller";else if(c.dictionary)a.kind=c.multi?"multi":"dictionary",a.reason="value table supplied (lookup column)";else{const p=[];for(let O=0;O<u&&p.length<this.#i.sampleSize;O++){const k=f(h[O]);k!=null&&p.push(k)}a.inferred=!0;const b=w(p,{multi:c.multi});if(b==="text"){const O=new Set(p).size;a.kind=A(O,p.length,i),a.candidate=this.#u,a.reason=`sampled ${O} distinct in ${p.length}`}else a.kind=b,a.reason=`inferred from ${p.length} sampled values`,b==="object"&&p.length&&I(`ingest.mixed.${c.id}`,`column "${c.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);a.kind==="object"&&a.candidate&&(a.distinct=new Set(p))}this.#t.push(a)}}#d(r,s){const h=this.#e;for(const u of this.#t){if(!u.candidate||!u.distinct)continue;const i=u.distinct;for(let m=r;m<s;m++){const c=u.read(h[m]);c!=null&&i.add(c)}}}#h(r){if(r.distinct)return r.distinct.size;const s=this.#n.column(r.spec.id);return s?.dict?s.dict.size:0}#f(r){const s=this.#i.dictionaryRatio,h=this.#e.length;for(const u of this.#t){if(!u.candidate)continue;const i=this.#h(u);if(u.kind==="dictionary"&&i>=s*h){const m=this.#n.column(u.spec.id);u.distinct=new Set(m?.dict?m.dict.values():[]),this.#n.convert(u.spec.id,"object"),u.kind="object",u.change="demoted",u.reason=`${i} distinct values is at or above ${s*100}% of ${h} rows`;continue}if(u.kind==="object"&&i>=s*h){u.candidate=!1,u.distinct=null,u.reason=`${i} distinct values is at or above ${s*100}% of ${h} rows`;continue}r&&u.kind==="object"&&i<s*h&&(this.#n.convert(u.spec.id,"dictionary"),u.kind="dictionary",u.change=u.change==="demoted"?null:"promoted",u.reason=`${i} distinct values is below ${s*100}% of ${h} rows`,u.distinct=null),r&&(u.candidate=!1)}}}async function o(t,r={},s={}){const h=new d(t,r,s),u=s.scheduler?.frame??B;for(;h.slice();)await new Promise(i=>{u(i)});return h.result()}function n(t,r={},s={}){const h=new d(t,r,{...s,chunkMs:1/0});for(;h.slice(););return h.result()}}),Fe("packages/core/src/store/columnpack.js",function(e,K){"use strict";Object.defineProperty(e,"isPortableSchema",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"packChunk",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"packedTransfers",{enumerable:!0,get:function(){return d}});const $=K("packages/core/src/internal/util.js").pathGetter,B=K("packages/core/src/store/ingest.js"),I=B.inferKind,_=B.decideText,X=B.INGEST_DEFAULTS,H=K("packages/core/src/store/columnstore.js").toFloat,V=new Set(["float64","int32","bitset","dictionary","object","multi"]);function z(o){if(!Array.isArray(o)||o.length===0)return!1;for(const n of o)if(!n||typeof n.id!="string"||typeof n.field!="string"||n.field===""||n.kind&&!V.has(n.kind))return!1;return!0}function w(o){const n=H(o);return Number.isFinite(n)?n|0:0}function A(o){return o==null?[]:Array.isArray(o)?o:[o]}function g(o,n,t,r){if(o.kind)return o.kind;const s=[];for(let i=0;i<n.length&&s.length<X.sampleSize;i++){const m=n[i];m!=null&&s.push(m)}const h=I(s,{multi:o.multi});if(h!=="text")return h;const u=new Set(s).size;return _(u,s.length,r)}function l(o,n,t={}){const r=n.length|0,s=t.dictionaryRatio??X.dictionaryRatio,h=[];for(const u of o){const i=$(u.field||u.id),m=u.nullable!==!1,c=new Array(r);for(let O=0;O<r;O++){const k=i(n[O]);c[O]=k===void 0?null:k}const f=g(u,c,r,s),a=m?new Uint8Array(r+7>>3):null,p=O=>{a&&(a[O>>3]|=1<<(O&7))};let b;switch(f){case"float64":{const O=new Float64Array(r);for(let k=0;k<r;k++){const y=c[k],v=y===null;v||p(k),O[k]=v?NaN:H(y)}b={id:u.id,kind:f,nullable:m,values:O,presence:a,offsets:null,table:null};break}case"int32":{const O=new Int32Array(r);for(let k=0;k<r;k++){const y=c[k],v=y===null;v||p(k),O[k]=v?0:w(y)}b={id:u.id,kind:f,nullable:m,values:O,presence:a,offsets:null,table:null};break}case"bitset":{const O=new Uint8Array(r+7>>3);for(let k=0;k<r;k++){const y=c[k],v=y===null;v||p(k),!v&&y&&(O[k>>3]|=1<<(k&7))}b={id:u.id,kind:f,nullable:m,values:O,presence:a,offsets:null,table:null};break}case"dictionary":{const O=new Uint32Array(r),k=[],y=new Map;for(let v=0;v<r;v++){const R=c[v];if(R===null){O[v]=0;continue}p(v);let S=y.get(R);S===void 0&&(S=k.length,k.push(R),y.set(R,S)),O[v]=S}b={id:u.id,kind:f,nullable:m,values:O,presence:a,offsets:null,table:k};break}case"multi":{const O=[],k=new Map,y=new Uint32Array(r+1),v=[];for(let R=0;R<r;R++){const S=c[R];y[R]=v.length,S===null||p(R);const C=A(S);for(let P=0;P<C.length;P++){const F=C[P];let E=k.get(F);E===void 0&&(E=O.length,O.push(F),k.set(F,E)),v.push(E)}}y[r]=v.length,b={id:u.id,kind:f,nullable:m,values:Int32Array.from(v),presence:a,offsets:y,table:O};break}default:{const O=new Array(r);for(let k=0;k<r;k++){const y=c[k];y!==null&&p(k),O[k]=y}b={id:u.id,kind:"object",nullable:m,values:O,presence:a,offsets:null,table:null};break}}h.push(b)}return{count:r,columns:h}}function d(o){const n=[];if(!o||!Array.isArray(o.columns))return n;const t=r=>{ArrayBuffer.isView(r)&&r.buffer&&!n.includes(r.buffer)&&n.push(r.buffer)};for(const r of o.columns)t(r.values),t(r.presence),t(r.offsets);return n}}),Fe("packages/core/src/source/stream.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_PROMOTE_BELOW",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"StreamSource",{enumerable:!0,get:function(){return S}});const Q=K("packages/core/src/internal/util.js"),$=Q.Lru,B=Q.isFunction,I=Q.now,_=Q.nextFrame,X=Q.cancelFrame,W=Q.whenIdle,H=Q.defaultCompare,V=Q.warnOnce,z=Q.infoOnce,w=Q.getPath,A=K("packages/core/src/source/abort.js"),g=A.createAbortScope,l=A.isAbortError,d=K("packages/core/src/source/rows.js"),o=d.createRowFactory,n=d.lazyRowView,r=K("packages/core/src/source/gapbuffer.js").GapBuffer,h=K("packages/core/src/source/memory.js").createMemorySource,i=K("packages/core/src/source/filterwire.js").querySignature,c=K("packages/core/src/store/columnpack.js").isPortableSchema,f=25e4,a=Symbol("lattice.stream.storeBacked"),p=8,b=.1,O=1e3,k=50;function y(x){return Math.min(O,Math.max(k,Math.floor(x/4)))}function v(x){if(x instanceof Date)return x.getTime();if(typeof x=="number")return Number.isFinite(x)?x:NaN;if(typeof x=="string"){const C=x.trim();if(!C)return NaN;const P=Date.parse(C);return Number.isNaN(P)?Number(C):P}return NaN}function R(x,C){return new S(x,C)}class S{mode="stream";writesStore=!0;#e;#t;#n=[];#r=null;#o=[];#i=null;#s;#l;#a=new Map;#u=g();#c={loaded:0,estimated:void 0};#d=null;#h=0;#f=0;#p=0;#m=0;#g=null;#b=null;#w=null;#S=!1;#y=!1;#O=!1;#k=!1;#j="";#A=0;#T=0;#M=0;#C=null;#E=1/0;#L=!1;#x=null;#B=null;#H=null;#U=null;#N=!1;#$=0;#z=0;#_=!1;constructor(C,P){this.#e=C||{mode:"stream"},this.#t=P||{},this.#s=o(this.#t),this.#l=new $(4096),this.#j=this.#Je();const F=(this.#t.config||{}).ingest;this.#N=!!F&&F.retainSource===!1,B(this.#e.open)||V("source.stream.open",'source.mode "stream" requires an open function; the grid will stay empty.'),this.#e.autoStart!==!1&&queueMicrotask(()=>this.start());const E=Number(this.#e.poll);Number.isFinite(E)&&E>0&&(this.#U=setInterval(()=>{this.#k||this.reload()},E),this.#U&&B(this.#U.unref)&&this.#U.unref()),this.#le()}#Y(){const C=Number(this.#e.maxAge);return Number.isFinite(C)&&C>0?C:0}#le(){const C=this.#Y();if(!C)return;const P=this.#e.ageBy;B(P)?this.#B=P:typeof P=="string"&&P?this.#B=F=>w(F,P):this.#B=null,this.#C=[],this.#x=setInterval(()=>{this.#k||this.#re()&&(this.#je(),this.#v())},y(C)),this.#x&&B(this.#x.unref)&&this.#x.unref()}#re(){const C=this.#Y();return!C||!this.#C?!1:this.#L?!0:this.#E<Date.now()-C*(1+b)}#se(C,P){if(!this.#C)return;const F=this.#B?v(this.#B(P)):Date.now();this.#C[C]=F,Number.isNaN(F)||(F<this.#E&&(this.#E=F),F<Date.now()-this.#Y()&&(this.#L=!0))}#ge(){return this.#be("groupBy",[]).length>0?!0:!!this.#be("pivotMode",!1)&&this.#be("pivotBy",[]).length>0}#Me(){if(this.#g||this.#k)return;const C=this.#ge();if(C&&!this.#b){this.#b=h({mode:"memory",rows:this.#n},this.#we()),this.#S=!1;return}!C&&this.#b&&(this.#b.destroy(),this.#b=null)}#we(){if(this.#w)return this.#w;const C=this,P={liveIndices:()=>C.#oe(),live:F=>C.#n[F]!==void 0,source:F=>C.#Pe(F),get physical(){return C.#n.length}};return this.#N&&(P.column=F=>{const E=C.#t.store;return E&&B(E.column)?E.column(F):void 0}),this.#w=Object.create(this.#t,{store:{value:P,enumerable:!0,configurable:!0}}),this.#w}#oe(){const C=new Uint32Array(this.#n.length);let P=0;for(let F=0;F<this.#n.length;F++)this.#n[F]!==void 0&&(C[P++]=F);return C.subarray(0,P)}#pe(){return this.#g?this.#g:this.#b?(this.#S&&(this.#S=!1,this.#b.setRows(this.#n)),this.#b):null}invalidate(C="filter"){if(this.#g){this.#g.invalidate(C);return}this.#Me(),this.#b&&this.#b.invalidate(C),(C==="filter"||C==="sort")&&this.#de()}count(){const C=this.#pe();return C?C.count():this.#r?this.#r.length:this.#A}matchCount(){const C=this.#pe();return C&&B(C.matchCount)?C.matchCount():this.#r?this.#r.length:this.#A}totalCount(){const C=this.#pe();return C&&B(C.totalCount)?C.totalCount():this.#A}unfilteredRows(){const C=this.#pe();if(C&&B(C.unfilteredRows))return C.unfilteredRows();const P=[];for(let F=0;F<this.#n.length;F++){if(!this.#n[F])continue;const E=this.#ye(F);E&&P.push(E)}return P}at(C){const P=this.#pe();if(P)return P.at(C);if(C<0||C>=this.count())return;const F=this.#r?this.#r.at(C):C,E=this.#ye(F);return E.index=C,E}byKey(C){const P=this.#pe();if(P)return P.byKey(C);const F=this.#a.get(C);return F===void 0?void 0:this.#ye(F)}leavesOf(C){const P=this.#pe();return P&&B(P.leavesOf)?P.leavesOf(C):[]}loaded(C){return C>=0&&C<this.count()}hint(C,P){if(this.#g){this.#g.hint(C,P);return}this.#te(),this.#p=Math.max(0,Math.floor(C))}#te(){this.#k||this.#Je()===this.#j||this.reload()}display(){const C=this.#pe();return C?C.display():n(()=>this.count(),P=>this.at(P))}apply(C){if(this.#g)return this.#g.apply(C);const P={added:[],updated:[],removed:[]};if(!C)return P;if(C.update){let F=!1;for(const E of C.update){const D=this.#a.get(this.#s.keyOf(E,-1));if(D===void 0)continue;const N=this.#ue(D);this.#N?this.#Qe(D,E):this.#n[D]=E,this.#l.delete(D),this.#I(D,N),this.#C&&(this.#se(D,E),F=!0),this.#S=!0,P.updated.push(this.#ye(D))}F&&this.#je()}if(C.add&&C.add.length){const F=this.#q(C.add);for(const E of F)P.added.push(this.#ye(E))}return C.remove&&C.remove.length&&V("source.stream.remove","removing rows from a live stream is not supported; reload instead."),this.#v(),P}reload(C){this.#u.abortAll("reload"),this.#Fe(),this.#b&&(this.#b.destroy(),this.#b=null),this.#S=!1,this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear(),this.#g=null,this.#A=0,this.#T=0,this.#M=0,this.#C&&(this.#C=[]),this.#E=1/0,this.#L=!1,this.#y=!1,this.#O=!1,this.#c={loaded:0,estimated:void 0},this.#j=this.#Je(),this.#W("model:changed",{reason:"reload"}),this.start()}destroy(){this.#k=!0,this.#U!==null&&(clearInterval(this.#U),this.#U=null),this.#x!==null&&(clearInterval(this.#x),this.#x=null),this.#C=null,this.#u.abortAll("destroyed"),this.#Fe(),this.#d!==null&&(this.#Ke(this.#d),this.#d=null),this.#b&&(this.#b.destroy(),this.#b=null),this.#g&&this.#g.destroy(),this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear()}async start(){if(this.#O||this.#k||!B(this.#e.open))return;this.#O=!0;const C=this.#u.begin("stream");this.#de(),this.#Me();let P;try{P=this.#e.open({sort:this.#be("sort",[]),filters:this.#be("filters",null),quick:this.#be("quick","")||void 0,context:this.#be("context",null),signal:C.signal})}catch(E){this.#W("source:error",{error:E});return}const F=B(P[Symbol.asyncIterator])?P[Symbol.asyncIterator]():P[Symbol.iterator]();this.#H=F;try{for(;;){const E=await F.next();if(!C.current||this.#k)return;if(E.done){this.#he();return}if(await this.#X(E.value,C),!C.current||this.#k)return;if(E.value&&E.value.done){this.#he();return}if(await this.#Se(),!C.current||this.#k)return}}catch(E){if(l(E))return;this.#W("source:error",{error:E})}finally{C.settle()}}progress(){return{loaded:this.#c.loaded,estimated:this.#c.estimated,done:this.#y,live:this.#A,evicted:this.#T}}promoted(){return this.#g!==null}memorySource(){return this.#g}invalidateHandles(){const C=this.#pe();C&&(B(C.invalidateHandles)&&C.invalidateHandles(),B(C.invalidate)&&C.invalidate("sort"))}renderCount(){return this.#h}ingestStats(){return{worker:this.#$,inline:this.#z,storeBacked:this.#N}}#X(C,P){if(!C)return;const F=C.rows;if(F&&F.length&&this.#Q(F))return this.#ve(C,P);const E=I();F&&F.length&&(this.#q(F),this.#z++),this.#G(C),this.#f+=I()-E,this.#v()}#G(C){this.#c.loaded=C.progress&&typeof C.progress.loaded=="number"?C.progress.loaded:this.#n.length,C.progress&&typeof C.progress.estimated=="number"&&(this.#c.estimated=C.progress.estimated)}#Q(C){if(this.#_||this.#g)return!1;const P=this.#ie();if(!P)return!1;const F=this.#t.store;if(!F||!B(F.appendPacked))return!1;const E=this.#ae();return!E||!c(E)?(this.#_=!0,z("source.stream.ingest-worker","stream ingest.useWorker is on but a column reads through a closure (a computed or date column); columnizing on the main thread instead."),!1):C.length<P.threshold?!1:!this.#Z(C)}#Z(C){if(!this.#s.keyed)return!1;const P=new Set;for(let F=0;F<C.length;F++){const E=this.#s.keyOf(C[F],this.#n.length+F);if(E!=null){if(P.has(E)||this.#a.has(E))return!0;P.add(E)}}return!1}async#ve(C,P){const F=C.rows,E=this.#ie(),D=this.#ae();let N;try{N=await E.columnize(D,F,{key:"ingest:stream",signal:P&&P.signal})}catch(q){if(l(q)||(V("source.stream.columnize","worker columnization failed; columnizing on the main thread",q),this.#_=!0,P&&(!P.current||this.#k)))return;this.#q(F),this.#z++,this.#G(C),this.#v();return}if(P&&(!P.current||this.#k))return;const M=this.#t.store,j=this.#N?void 0:F,{from:L}=M.appendPacked(N,j),G=N.count|0;for(let q=0;q<G;q++){const Y=L+q,J=F[q],ee=this.#s.keyed?this.#s.keyOf(J,Y):null;if(this.#n[Y]=this.#N?a:J,this.#A++,this.#se(Y,J),ee!==null&&this.#a.set(ee,Y),!this.#r||!this.#V(Y))continue;const ne=this.#D(Y);this.#r.insert(ne,Y),ne<=this.#p&&this.#m++}this.#S=!0,this.#je(),this.#$++,this.#G(C),this.#v()}#ie(){const C=this.#t.ingestWorker;return B(C)?C():null}#ae(){const C=this.#t.storeSchema;return B(C)?C():null}#q(C){const P=[],F=this.#t.store,E=new Array(C.length),D=[],N=new Set;for(let j=0;j<C.length;j++){const L=this.#s.keyed?this.#s.keyOf(C[j],this.#n.length+D.length):null;E[j]=L,!(L!==null&&(this.#a.has(L)||N.has(L)))&&(L!==null&&N.add(L),D.push(C[j]))}let M=D.length&&F&&B(F.append)?F.append(D).from:this.#n.length;for(let j=0;j<C.length;j++){const L=C[j],G=E[j];if(G!==null&&this.#a.has(G)){const J=this.#a.get(G),ee=this.#ue(J);this.#N||(this.#n[J]=L,F&&B(F.setSource)&&F.setSource(J,L)),this.#Qe(J,L),this.#l.delete(J),this.#se(J,L),this.#I(J,ee);continue}const q=M++;if(this.#n[q]=this.#N?a:L,this.#A++,this.#se(q,L),G!==null&&this.#a.set(G,q),P.push(q),!this.#r||!this.#V(q))continue;const Y=this.#D(q);this.#r.insert(Y,q),Y<=this.#p&&this.#m++}return this.#S=!0,this.#je(),P}#me(C){const P=this.#n[C];let F=!1;if(this.#r){const M=this.#ke(C);M>=0&&M<=this.#p&&(F=!0)}else C<=this.#p&&(F=!0);const E=P===a?this.#Pe(C):P,D=this.#s.keyed?this.#s.keyOf(E,C):null;D!==null&&this.#a.get(D)===C&&this.#a.delete(D),this.#n[C]=void 0,this.#C&&(this.#C[C]=NaN),this.#l.delete(C);const N=this.#t.store;return N&&B(N.remove)&&N.remove(C),this.#A--,F}#je(){let C=0,P=0;const F=this.#ne();C+=F.dropped,P+=F.aboveAnchor;const E=this.#fe();C+=E.dropped,P+=E.aboveAnchor,C&&(this.#S=!0,this.#T+=C,this.#de(),this.#m-=P,this.#W("stream:evicted",{evicted:C,total:this.#T,live:this.#A}))}#fe(){const C=this.#e.maxRows;if(!Number.isFinite(C)||C<=0||this.#A<=C)return{dropped:0,aboveAnchor:0};const P=Math.max(1,Math.floor(C*(1-b)));let F=0,E=0;for(;this.#A>P&&this.#M<this.#n.length;){const D=this.#M++;this.#n[D]!==void 0&&(this.#me(D)&&E++,F++)}return{dropped:F,aboveAnchor:E}}#ne(){const C=this.#Y();if(!C||!this.#C||!this.#re())return{dropped:0,aboveAnchor:0};const P=Date.now()-C;let F=0,E=0,D=1/0;for(let N=this.#M;N<this.#n.length;N++){if(this.#n[N]===void 0)continue;const M=this.#C[N];if(!(Number.isNaN(M)||M===void 0)){if(M>=P){M<D&&(D=M);continue}this.#me(N)&&E++,F++}}for(this.#E=D,this.#L=!1;this.#M<this.#n.length&&this.#n[this.#M]===void 0;)this.#M++;return{dropped:F,aboveAnchor:E}}#ke(C){if(!this.#r)return C;for(let P=0;P<this.#r.length;P++)if(this.#r.at(P)===C)return P;return-1}#de(){this.#o=this.#be("sort",[]),this.#i=this.#be("filters",null);const C=Number.isFinite(this.#e.maxRows)&&this.#e.maxRows>0||this.#Y()>0,P=this.#be("where",null),F=(this.#t.config||{}).hostFilter,E=!!(P&&P.active)||!!(F&&B(F.active)&&F.active());if(!(C||this.#o.length>0||!!this.#i||!!this.#be("quick","")||E)){this.#r=null;return}this.#r=new r(Math.max(64,this.#n.length+64));for(let N=0;N<this.#n.length;N++)this.#n[N]!==void 0&&this.#V(N)&&this.#r.insert(this.#D(N),N)}#V(C){const P=this.#Pe(C);if(this.#i&&!this.#R(this.#i,P))return!1;const F=String(this.#be("quick","")||"").toLowerCase();if(F&&!this.#We(P).includes(F))return!1;const E=(this.#t.config||{}).hostFilter;if(E&&B(E.active)&&E.active()&&!E.passes(this.#ye(C)))return!1;const D=this.#be("where",null);if(D&&D.active){const N=this.#ye(C);if(!D.passes(N.data,N.key))return!1}return!0}#R(C,P){if(!C)return!0;const F=C;if(Array.isArray(F.conditions))return F.op==="or"?F.conditions.some(N=>this.#R(N,P)):F.op==="not"?!F.conditions.some(N=>this.#R(N,P)):F.conditions.every(N=>this.#R(N,P));const E=C,D=(this.#t.compute||{}).testValue;return B(D)?!!D(this.#Ce(P,E.col),E,(this.#t.config||{}).locale):(V("source.stream.testValue","ctx.compute.testValue is unavailable; streamed rows are not filtered client-side."),!0)}#ue(C){if(!this.#r)return-1;if(!this.#o.length)return this.#ke(C);let P=0,F=this.#r.length;for(;P<F;){const E=P+F>>>1;this.#ce(this.#r.at(E),C)<0?P=E+1:F=E}for(let E=P;E<this.#r.length;E++){const D=this.#r.at(E);if(D===C)return E;if(this.#ce(D,C)>0)break}return this.#ke(C)}#I(C,P){if(!this.#r||!this.#o.length)return;const F=this.#V(C);if(P>=0&&this.#r.at(P)===C)this.#r.removeAt(P),P<=this.#p&&this.#m--;else if(P>=0)return;if(!F)return;const E=this.#D(C);this.#r.insert(E,C),E<=this.#p&&this.#m++}#D(C){if(!this.#r||!this.#o.length)return this.#r?this.#r.length:0;let P=0,F=this.#r.length;for(;P<F;){const E=P+F>>>1;this.#ce(C,this.#r.at(E))<0?F=E:P=E+1}return P}#ce(C,P){const F=this.#Pe(C),E=this.#Pe(P);for(const D of this.#o){const N=this.#_e(D.col),M=this.#Ce(F,D.col),j=this.#Ce(E,D.col),G=(N&&N.value&&B(N.value.compare)?N.value.compare:H)(M,j);if(G!==0)return D.dir==="desc"?-G:G}return 0}#he(){this.#y=!0,this.#c.loaded=this.#c.loaded||this.#n.length;const C=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:f;!this.#N&&this.#n.length<C&&(this.#g=h({mode:"memory",rows:this.#n},this.#t),this.#x!==null&&(clearInterval(this.#x),this.#x=null),this.#b&&(this.#b.destroy(),this.#b=null)),this.#v(),this.#W("stream:end",{loaded:this.#n.length,promoted:this.#g!==null,threshold:C})}#v(){this.#d!==null||this.#k||(this.#d=this.#Ge(()=>{this.#d=null,this.#h++;const C=this.#m;this.#m=0,this.#f=0,this.#W("stream:chunk",{loaded:this.#c.loaded,estimated:this.#c.estimated,count:this.count(),renders:this.#h}),this.#W("model:changed",{reason:"stream",shiftAboveViewport:C,anchor:this.#p}),this.#W("rows:changed",{companion:!0,reason:"stream"})}))}#Se(){return this.#h===0||this.#f<this.#Be()?Promise.resolve():(this.#f=0,new Promise(C=>{const P=(this.#t.scheduler||{}).idle;B(P)?P(()=>C()):W(()=>C())}))}#Be(){return typeof this.#e.coalesceMs=="number"&&this.#e.coalesceMs>0?this.#e.coalesceMs:p}#Ge(C){const P=this.#t.scheduler||{};return B(P.frame)?P.frame(C):_(C)}#Ke(C){const P=this.#t.scheduler||{};B(P.cancel)?P.cancel(C):X(C)}#Pe(C){const P=this.#n[C];if(P!==void 0&&P!==a)return P;if(P===void 0)return;const F=this.#t.store;return F&&B(F.source)?F.source(C):void 0}#Qe(C,P){const F=this.#t.store;if(!F||!B(F.set))return;const E=this.#ae();if(Array.isArray(E))for(const D of E){if(!D||!D.id)continue;const N=B(D.read)?D.read:M=>w(M,D.field||D.id);F.set(D.id,C,N(P))}}#ye(C){let P=this.#l.get(C);return P||(P=this.#s.leaf(this.#Pe(C),C),this.#l.set(C,P)),P}#Ce(C,P){const F=this.#_e(P);return F&&B(F.getValue)?F.getValue(C):C?.[P]}#We(C){const P=this.#t.columns,F=P&&B(P.all)?P.all():[],E=[];for(const D of F){const N=B(D.getValue)?D.getValue(C):void 0;N!=null&&N!==""&&E.push(String(N))}return E.join(" ").toLowerCase()}#_e(C){const P=this.#t.columns;return P&&B(P.get)?P.get(C):void 0}#Fe(){const C=this.#H;if(this.#H=null,C&&B(C.return))try{C.return()}catch{}}#Je(){return i({context:this.#be("context",null)})}#be(C,P){const F=this.#t.state;if(F&&B(F[C])){const E=F[C]();return E??P}return P}#W(C,P){const F=this.#t.emit;B(F)&&F(C,P)}}}),Fe("packages/core/src/source/url.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_URL_BATCH",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return w}});const Q=K("packages/core/src/internal/util.js"),$=Q.warnOnce,B=Q.isObject,I=Q.isFunction,_=Q.getPath,W=K("packages/core/src/source/abort.js").isAbortError,H=500,V=new Set(["application/x-ndjson","application/ndjson","application/jsonlines","application/jsonl","application/x-jsonlines","text/x-ndjson"]),z=Symbol("lattice.url.skip");function w(c,f={}){const a=B(f)?f:{},p=I(a.fetch)?a.fetch:typeof globalThis<"u"&&I(globalThis.fetch)?globalThis.fetch:null,b=a.format==="json"||a.format==="ndjson"?a.format:void 0,O=typeof a.rowsPath=="string"&&a.rowsPath?a.rowsPath:void 0,k=I(a.map)?a.map:void 0,y=B(a.headers)?a.headers:void 0,v=Number.isFinite(a.batchSize)&&a.batchSize>0?Math.floor(a.batchSize):H,R=a.lenient===!0,S=Number.isFinite(a.poll)&&a.poll>0?Math.floor(a.poll):void 0,x=typeof c=="string"&&c.length>0;x||$("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*C(F={}){if(!x)return;if(!p)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const E=F&&F.signal;let D;try{D=await p(c,y?{signal:E,headers:y}:{signal:E})}catch(j){throw W(j)?j:new Error(`[lattice] createUrlSource: request to ${c} failed — ${j&&j.message||j}`)}if(!D||!D.ok){const j=D?D.status:"no response";throw new Error(`[lattice] createUrlSource: ${j} for ${c}`)}const N=A(c,b,D),M=D.body&&I(D.body.getReader)?D.body.getReader():null;try{if(!M){const G=await D.text();(N||d(G,c))==="ndjson"?yield*h(null,null,G,0,D,c,v,R):yield*s(G,c,O,k);return}const j=new TextDecoder("utf-8");if(N==="json"){yield*s(await r(M,j,""),c,O,k);return}if(N==="ndjson"){yield*h(M,j,"",0,D,c,v,R);return}const L=await o(M,j,c);L.format==="json"?yield*s(await r(M,j,L.seed),c,O,k):yield*h(M,j,L.seed,L.bytes,D,c,v,R)}finally{if(M&&I(M.cancel))try{await M.cancel()}catch{}}}const P={mode:"stream",open:C,autoStart:a.autoStart!==!1};return S!==void 0&&(P.poll=S),Number.isFinite(a.maxRows)&&(P.maxRows=a.maxRows),Number.isFinite(a.maxAge)&&(P.maxAge=a.maxAge),(typeof a.ageBy=="string"||I(a.ageBy))&&(P.ageBy=a.ageBy),Number.isFinite(a.coalesceMs)&&(P.coalesceMs=a.coalesceMs),Number.isFinite(a.promoteToMemoryBelow)&&(P.promoteToMemoryBelow=a.promoteToMemoryBelow),P}function A(c,f,a){if(f)return f;const p=g(c);if(p)return p;const b=a&&a.headers&&I(a.headers.get)?a.headers.get("content-type"):null;return l(b)}function g(c){const f=String(c).split(/[?#]/)[0].toLowerCase();if(f.endsWith(".ndjson")||f.endsWith(".jsonl"))return"ndjson";if(f.endsWith(".json"))return"json"}function l(c){if(!c)return;const f=c.split(";")[0].trim().toLowerCase();if(V.has(f))return"ndjson";if(f==="application/json"||f==="text/json"||f.endsWith("+json"))return"json"}function d(c,f){const a=c.replace(/^\s+/,""),p=n(a);if(p==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${f} — pass opts.format: 'json' | 'ndjson'.`);return p}async function o(c,f,a){let p="",b=0;for(;;){const{value:k,done:y}=await c.read();if(k&&(b+=k.byteLength,p+=f.decode(k,{stream:!0})),y){p+=f.decode();break}const v=p.replace(/^\s+/,"");if(v){if(v[0]==="[")return{format:"json",seed:p,bytes:b};if(v[0]!=="{"||p.indexOf(`
|
|
8
8
|
`)!==-1)break}}const O=n(p.replace(/^\s+/,""));if(O==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${a} — pass opts.format: 'json' | 'ndjson'.`);return{format:O,seed:p,bytes:b}}function n(c){if(!c||c[0]==="[")return"json";if(c[0]!=="{")return"error";const f=c.indexOf(`
|
|
9
9
|
`);if(f===-1)return"json";let a=c.slice(0,f);return a.endsWith("\r")&&(a=a.slice(0,-1)),t(a)?"ndjson":"json"}function t(c){try{return JSON.parse(c),!0}catch{return!1}}async function r(c,f,a){let p=a;for(;;){const{value:b,done:O}=await c.read();if(b&&(p+=f.decode(b,{stream:!0})),O)break}return p+=f.decode(),p}function*s(c,f,a,p){let b;try{b=JSON.parse(c)}catch(k){throw new Error(`[lattice] createUrlSource: ${f} is not valid JSON — ${k.message}`)}let O=a!==void 0?_(b,a):b;if(p&&(O=p(O)),!Array.isArray(O)){const k=a!==void 0||p?"":"; pass opts.rowsPath or opts.map to select the array";throw new Error(`[lattice] createUrlSource: ${f} did not resolve to an array${k}.`)}yield{rows:O,progress:{loaded:O.length,estimated:O.length}}}async function*h(c,f,a,p,b,O,k,y){const v=m(b);let R=a||"",S=p||0,x=0,C=0,P=[];function*F(){let D;for(;(D=R.indexOf(`
|
|
@@ -54,6 +54,6 @@ ${ee}[data-heat-side="low"]{background-color:color-mix(in srgb, var(--lattice-va
|
|
|
54
54
|
`,b),R=a.slice(y,v),S=R.split(`
|
|
55
55
|
`);let x=0;const C=S.map(P=>{if(!c)return x+=O.length,O+P;if(P.startsWith(O))return x-=O.length,P.slice(O.length);const F=P.replace(/^[ \t]/,"");return x-=P.length-F.length,F}).join(`
|
|
56
56
|
`);return C===R?!1:(f.value=a.slice(0,y)+C+a.slice(v),this.#r(Math.max(y,p+(c?-O.length:O.length)),Math.max(y,b+x)),this.revalidate(),!0)}#r(c,f){const a=this.input;a&&(a.selectionStart=c,a.selectionEnd=f===void 0?c:f,W(a.setSelectionRange)&&a.setSelectionRange(a.selectionStart,a.selectionEnd))}format(c){const f=this.input;if(!f||this.language!=="json")return!1;const a=o(f.value);if(!a.ok)return this.revalidate(),!1;if(a.value===null&&f.value.trim()==="")return!1;try{const p=JSON.stringify(a.value,null,c===void 0?this.indent:c);return p===void 0?!1:(f.value=p,this.#r(p.length),this.revalidate(),!0)}catch{return!1}}revalidate(){const c=this.input?this.input.value:"",f=s(c,this.language);this.lastResult=f;const a=this.errorNode;return a&&(a.textContent=f.ok?"":h(f),a.classList.toggle(w.errorOn,!f.ok)),this.input&&(f.ok?this.input.removeAttribute("aria-invalid"):this.input.setAttribute("aria-invalid","true"),f.ok||!a?this.input.removeAttribute("aria-errormessage"):(a.id||(a.id=H("lat-err")),this.input.setAttribute("aria-errormessage",a.id))),f}text(){return this.input?this.input.value:""}readValue(){const c=this.text();if(c.trim()==="")return null;if(this.language!=="json"||(this.props.parseOnCommit??!0)!==!0)return c;const a=o(c);return a.ok?a.value:c}checkValue(c){if(this.props.allowInvalid===!0)return!0;const f=this.revalidate();return f.ok?!0:h(f)}toClipboard(){return this.text()}fromClipboard(c){const f=c==null?"":String(c);return this.input&&(this.input.value=f),this.revalidate(),f.trim()===""?{ok:!0,value:null}:this.language!=="json"?{ok:!0,value:f}:{ok:!0,value:z(f)}}destroy(){for(const c of this.#e)c();this.#e.length=0,this.input=null,this.errorNode=null,this.formatButton=null,super.destroy()}}const i=u}),Fe("packages/dom/src/editors/unit.js",function(e,K){"use strict";Object.defineProperty(e,"presentUnit",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const Q=K("packages/dom/src/editors/common.js"),$=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,W=K("packages/core/src/internal/util.js").isFunction,H=K("packages/core/src/columns/types/unit.js"),V=H.parseUnit,z=H.formatUnit,w=H.findUnit;function A(d,o){return z(d,o)}class g extends ${input=null;hint=null;opts=null;#e=[];buildOptions(){const o=this.props,n=this.params.column&&this.params.column.dataType||null,t=n&&n.unitConfig||{};return{system:o.system||t.system||"data",unit:o.unit??t.unit,binary:o.binary===!0||o.binary===void 0&&t.binary===!0,display:o.display??t.display,locale:this.params.locale,group:!1,minDecimals:0,maxDecimals:20}}build(){const o=this.props;this.opts=this.buildOptions();const n=this.symbol(),t=`${this.id}-unit`,r=I(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:o.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":n?t:null}});r.value=A(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(r.value=this.params.key),this.input=r;const s=typeof o.step=="number"?o.step:0;return s>0&&this.#e.push(_(r,"keydown",h=>{h.key==="ArrowUp"?(W(h.preventDefault)&&h.preventDefault(),this.nudge(s)):h.key==="ArrowDown"&&(W(h.preventDefault)&&h.preventDefault(),this.nudge(-s))})),this.hint=I(this.doc,"span",{class:`${B.editor}__suffix`,text:n,attrs:{id:t,"aria-hidden":"true"}}),I(this.doc,"div",{class:`${B.editor}__unit`,children:[r,this.hint]})}symbol(){const o=w(this.opts.system,this.opts.unit);return o?o.symbol:String(this.opts.unit||"")}focusTarget(){return this.input}attached(){super.attached();const o=this.input;o&&!this.params.key&&this.props.selectOnFocus!==!1&&W(o.select)&&o.select()}nudge(o){const n=V(this.input?this.input.value:"",this.opts);let t=(n??0)+o;const{min:r,max:s}=this.props;typeof r=="number"&&t<r&&(t=r),typeof s=="number"&&t>s&&(t=s),this.input&&(this.input.value=A(t,this.opts))}readValue(){const o=this.input?this.input.value:"";if(String(o).trim()==="")return null;const n=V(o,this.opts);if(n===null)return NaN;if(this.mode()!=="clamp")return n;const{min:t,max:r}=this.props;let s=n;return typeof t=="number"&&s<t&&(s=t),typeof r=="number"&&s>r&&(s=r),s}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}checkValue(o){if(o===null)return!0;if(typeof o!="number"||Number.isNaN(o)){const n=this.symbol();return n?`Enter a value such as 10 ${n}`:"Enter a value"}if(this.mode()==="reject"){const{min:n,max:t}=this.props;if(typeof n=="number"&&o<n)return`Must be ${this.describe(n)} or more`;if(typeof t=="number"&&o>t)return`Must be ${this.describe(t)} or less`}return!0}describe(o){return z(o,{...this.opts,display:this.opts.unit,group:!0,maxDecimals:4})}toClipboard(){return z(this.readValue(),{...this.opts,display:this.opts.unit})}fromClipboard(o){const n=o==null?"":String(o);if(n.trim()==="")return{ok:!0,value:null};const t=V(n,this.opts),r=t===null?NaN:t,s=this.checkValue(r);return s!==!0?{ok:!1,message:s}:{ok:!0,value:r}}destroy(){for(const o of this.#e)o();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const l=g}),Fe("packages/dom/src/editors/radix.js",function(e,K){"use strict";Object.defineProperty(e,"RADIX_CLS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"mergeRadixOptions",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});const Q=K("packages/dom/src/editors/common.js"),$=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,X=K("packages/core/src/internal/util.js"),W=X.isFunction,H=X.uid,V=K("packages/core/src/columns/types/radix.js"),z=V.compileRadixFormat,w=V.compileRadixParse,A=V.normaliseRadixOptions,g=V.radixRange,l=Object.freeze({root:"lat-editor__radix",hint:"lat-editor__hint",hintInvalid:"lat-editor__hint--invalid"}),d=Object.freeze(["preset","radix","prefix","uppercase","pad","group","groupSeparator","bitWidth","signed","nullDisplay"]),o=new Map;function n(h){const u=h||"";let i=o.get(u);if(i)return i;try{i=new Intl.NumberFormat(h||void 0,{maximumFractionDigits:0})}catch{i={format:m=>String(m)}}return o.set(u,i),i}function t(h,u){const i=u||{},m={};if(h){for(const f of d)h[f]!==void 0&&(m[f]=h[f]);const c=g(h.bitWidth??null,h.signed!==!1);typeof h.min=="number"&&h.min>c.min&&(m.min=h.min),typeof h.max=="number"&&h.max<c.max&&(m.max=h.max)}for(const c of d)i[c]!==void 0&&(m[c]=i[c]);return typeof i.min=="number"&&(m.min=i.min),typeof i.max=="number"&&(m.max=i.max),A(m)}class r extends ${input=null;hint=null;options=null;format=null;parse=null;#e=[];build(){const u=this.params.column&&this.params.column.dataType;this.options=t(u&&u.radix||null,this.props),this.format=z(this.options),this.parse=w(this.options);const i=I(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:this.options.radix===2?"numeric":"text",autocomplete:"off",autocapitalize:"off",spellcheck:"false",placeholder:this.props.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-valuemin":this.options.min,"aria-valuemax":this.options.max}});i.value=this.format(this.params.value),this.params.key&&this.#t(this.params.key)&&(i.value=this.params.key),this.input=i;const m=I(this.doc,"span",{class:l.hint,attrs:{"aria-live":"polite"}});this.hint=m,this.#e.push(_(i,"input",()=>this.refresh())),this.#e.push(_(i,"keydown",f=>this.#n(f)));const c=I(this.doc,"div",{class:l.root,children:[i,m]});return this.refresh(),c}focusTarget(){return this.input}attached(){super.attached();const u=this.input;u&&!this.params.key&&this.props.selectOnFocus!==!1&&W(u.select)&&u.select()}#t(u){return u.length===1&&/[0-9a-fA-FxXbBoO#+\-.]/.test(u)}#n(u){const i=typeof this.props.step=="number"&&this.props.step!==0?this.props.step:1;u.key==="ArrowUp"?(W(u.preventDefault)&&u.preventDefault(),this.nudge(i)):u.key==="ArrowDown"&&(W(u.preventDefault)&&u.preventDefault(),this.nudge(-i))}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}clamp(u){const{min:i,max:m}=this.options;return u<i?i:u>m?m:u}evaluate(){const u=this.input?String(this.input.value):"";if(u.trim()==="")return{value:null,message:null};const i=this.parse(u);return i.ok?{value:this.mode()==="clamp"?this.clamp(i.value):i.value,message:null}:this.mode()==="clamp"&&typeof i.value=="number"&&(i.reason==="range"||i.reason==="negative")?{value:this.clamp(i.value),message:null}:{value:NaN,message:this.messageFor(i.reason)}}messageFor(u){const i=this.options;return u==="negative"?`This column holds an unsigned ${i.bitWidth}-bit pattern; enter ${this.format(0)} or more`:u==="range"?`Must be between ${this.format(i.min)} and ${this.format(i.max)}`:`Enter a ${i.name} value, e.g. ${this.format(i.radix===2?5:26)}`}refresh(){const{value:u,message:i}=this.evaluate();if(this.input&&this.input.classList&&(i?this.input.classList.add(B.invalid):this.input.classList.remove(B.invalid),this.input.setAttribute("aria-invalid",i?"true":"false"),i&&this.hint?(this.hint.id||(this.hint.id=H("lat-err")),this.input.setAttribute("aria-errormessage",this.hint.id)):this.input.removeAttribute("aria-errormessage")),!!this.hint){if(i){this.hint.textContent=i,this.hint.classList&&this.hint.classList.add(l.hintInvalid);return}this.hint.classList&&this.hint.classList.remove(l.hintInvalid),this.hint.textContent=u===null?"":`= ${n(this.params.locale).format(u)}`}}nudge(u){if(!this.input)return;const i=this.parse(this.input.value);let m;typeof i.value=="number"?m=i.value:typeof this.params.value=="number"?m=this.params.value:m=0,this.input.value=this.format(this.clamp(m+u)),this.refresh()}readValue(){return this.evaluate().value}checkValue(u){return u===null?!0:typeof u!="number"||Number.isNaN(u)?this.evaluate().message||this.messageFor("digits"):!this.options.signed&&u<0?this.messageFor("negative"):this.mode()==="reject"&&(u<this.options.min||u>this.options.max)?this.messageFor("range"):!0}toClipboard(){const u=this.readValue();return u===null||Number.isNaN(u)?this.input?String(this.input.value):"":this.format(u)}fromClipboard(u){const i=u==null?"":String(u);if(i.trim()==="")return{ok:!0,value:null};const m=this.parse(i);let c;if(m.ok)c=m.value;else if(this.mode()==="clamp"&&typeof m.value=="number"&&(m.reason==="range"||m.reason==="negative"))c=this.clamp(m.value);else return{ok:!1,message:this.messageFor(m.reason)};const f=this.checkValue(c);return f!==!0?{ok:!1,message:f}:{ok:!0,value:c}}destroy(){for(const u of this.#e)u();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const s=r}),Fe("packages/dom/src/editors/segmented.js",function(e,K){"use strict";Object.defineProperty(e,"SEGMENTED_MAX",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const Q=K("packages/dom/src/editors/common.js"),$=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,X=Q.keyOf,W=Q.normaliseLookup,H=Q.documentFor,V=Q.lookupFor,w=K("packages/dom/src/editors/select.js").SelectEditor,g=K("packages/core/src/internal/util.js").isFunction,d=K("packages/dom/src/cell/icons.js").createIcon,o=6;class n extends ${static popup=!1;options=[];selected=null;segments=[];focused=0;#e=null;#t=[];init(h){const u=h||{},i=t(u),m=V(u,i,{colId:u.column&&(u.column.id||u.column.field)}),c=Number(i.max??o),f=m.options().length;if(Number.isFinite(c)&&f>c){const a=new w;a.init(u),this.#e=a,this.params=u,this.doc=H(u),this.props=i,this.lookup=m,this.popup=a.popup;return}super.init(u),(!this.lookup||!this.lookup.options().length)&&(this.lookup=m)}usesFallback(){return this.#e!==null}build(){const h=this.doc;this.options=this.lookup?this.lookup.options():[],this.selected=this.params.value??null;const u=I(h,"div",{class:`${B.editor}__segmented`,attrs:{role:"radiogroup","aria-label":this.params.column&&this.params.column.title||null,"data-size":this.props.size?String(this.props.size):null}});for(let i=0;i<this.options.length;i++)u.appendChild(this.buildSegment(this.options[i],i));return this.props.allowClear===!0&&u.appendChild(this.buildClear()),this.#t.push(_(u,"keydown",i=>this.onKeyDown(i))),this.focused=Math.max(0,this.indexOf(this.selected)),this.paint(),u}buildSegment(h,u){const i=this.doc,m=I(i,"button",{class:`${B.editor}__segment`,attrs:{type:"button",role:"radio",tabindex:"-1","aria-checked":"false","data-index":u,"data-variant":h.variant??null,"aria-disabled":h.disabled===!0?"true":null}});return h.icon&&m.appendChild(d(i,h.icon,{className:B.icon})),m.appendChild(I(i,"span",{class:`${B.editor}__segment-label`,text:h.label})),this.#t.push(_(m,"mousedown",c=>{c&&g(c.preventDefault)&&c.preventDefault(),h.disabled!==!0&&(this.focused=u,this.select(u,{commit:!0}))})),this.segments.push(m),m}buildClear(){const h=I(this.doc,"button",{class:`${B.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clear")}});return this.#t.push(_(h,"mousedown",u=>{u&&g(u.preventDefault)&&u.preventDefault(),this.clearSelection()})),h}indexOf(h){if(h==null)return-1;const u=X(h);for(let i=0;i<this.options.length;i++)if(X(this.options[i].id)===u)return i;return-1}paint(){for(let h=0;h<this.segments.length;h++){const u=h===this.indexOf(this.selected),i=this.segments[h];i.setAttribute("aria-checked",u?"true":"false"),i.setAttribute("tabindex",h===this.focused?"0":"-1"),i.classList.toggle(`${B.editor}__segment--active`,u),i.classList.toggle(`${B.editor}__segment--disabled`,this.options[h].disabled===!0)}}select(h,u){const i=this.options[h];!i||i.disabled===!0||(this.selected=i.id,this.paint(),u&&u.commit&&this.commit())}clearSelection(){this.selected=null,this.paint()}moveFocus(h){const u=this.segments.length;if(!u)return;let i=this.focused;for(let m=0;m<u;m++)if(i=(i+h+u)%u,this.options[i].disabled!==!0){this.focusAt(i);return}}focusAt(h){if(h<0||h>=this.segments.length)return;this.focused=h,this.paint();const u=this.segments[h];u&&g(u.focus)&&u.focus()}edgeIndex(h){const u=this.options.length;for(let i=0;i<u;i++){const m=h===1?i:u-1-i;if(this.options[m].disabled!==!0)return m}return-1}onKeyDown(h){const u=()=>{g(h.preventDefault)&&h.preventDefault()};switch(h.key){case"ArrowRight":case"ArrowDown":u(),this.moveFocus(1);break;case"ArrowLeft":case"ArrowUp":u(),this.moveFocus(-1);break;case"Home":u(),this.focusAt(this.edgeIndex(1));break;case"End":u(),this.focusAt(this.edgeIndex(-1));break;case"Enter":u(),this.select(this.focused,{commit:!0});break;case" ":case"Spacebar":u(),this.select(this.focused);break;case"Escape":u(),this.cancel();break;case"Tab":this.select(this.focused),this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(u(),this.clearSelection());break;default:break}}readValue(){return this.selected??null}checkValue(h){return h==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.lookup||!this.lookup.options().length||this.lookup.option(h)||this.lookup.allowCustom||this.props.allowCustom===!0?!0:`"${String(h)}" is not a valid option`}element(){return this.#e?this.#e.element():super.element()}value(){return this.#e?this.#e.value():super.value()}focusTarget(){if(!this.segments.length)return super.focusTarget();const h=this.indexOf(this.selected);return this.segments[h>=0?h:Math.max(0,this.edgeIndex(1))]||null}attached(){if(this.#e){this.#e.attached();return}if(super.attached(),!this.lookup)return;const h=this.lookup.ready();!h||!g(h.then)||h.then(()=>{if(!super.element()||this.options.length)return;const u=super.element();this.options=this.lookup.options();for(let i=0;i<this.options.length;i++)u.appendChild(this.buildSegment(this.options[i],i));this.focused=Math.max(0,this.indexOf(this.selected)),this.paint()})}cancelBeforeStart(){return this.#e?this.#e.cancelBeforeStart():super.cancelBeforeStart()}cancelOnClose(){return this.#e?this.#e.cancelOnClose():super.cancelOnClose()}commit(){return this.#e?this.#e.commit():super.commit()}cancel(){this.#e?this.#e.cancel():super.cancel()}validate(h){return this.#e?this.#e.validate(h):super.validate(h)}message(){return this.#e?this.#e.message():super.message()}toClipboard(){return this.#e?this.#e.toClipboard():super.toClipboard()}fromClipboard(h){return this.#e?this.#e.fromClipboard(h):super.fromClipboard(h)}destroy(){for(const h of this.#t)h();this.#t.length=0,this.segments.length=0,this.options=[],this.#e&&(this.#e.destroy(),this.#e=null),super.destroy()}}function t(s){return{...s.column&&s.column.edit&&s.column.edit.props||{},...s.props||{}}}const r=n}),Fe("packages/dom/src/editors/rating.js",function(e,K){"use strict";Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"normaliseRating",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const Q=K("packages/dom/src/editors/common.js"),$=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,W=K("packages/dom/src/cell/icons.js").createIcon,H=K("packages/dom/src/cell/renderers/rating.js"),V=H.ratingFills,z=H.fillState,w=H.ratingText,A=H.clampRating,g=H.DEFAULT_RATING_ICON,l=H.DEFAULT_RATING_MAX,o=K("packages/core/src/internal/util.js").isFunction;class n extends ${static popup=!1;rating=null;preview=null;items=[];fills=[];slider=null;readout=null;#e=[];max(){const h=Math.floor(Number(this.props.max??l));return Number.isFinite(h)&&h>0?h:l}step(){return this.props.allowHalf===!0?.5:1}build(){const h=this.doc,u=this.max();this.rating=t(this.params.value,u,this.props.allowHalf===!0);const i=I(h,"div",{class:`${B.editor}__rating`}),m=I(h,"div",{class:`${B.editor}__rating-slider`,attrs:{role:"slider",tabindex:"0","aria-valuemin":"0","aria-valuemax":String(u),"aria-label":this.params.column&&this.params.column.title||"Rating"}});for(let f=0;f<u;f++)m.appendChild(this.buildItem(f));i.appendChild(m),this.slider=m;const c=I(h,"span",{class:`${B.editor}__rating-value`});return i.appendChild(c),this.readout=c,this.props.allowClear===!0&&i.appendChild(this.buildClear()),this.#e.push(_(m,"keydown",f=>this.onKeyDown(f))),this.props.hoverPreview!==!1&&this.#e.push(_(m,"mouseleave",()=>{this.preview=null,this.paint()})),this.params.key&&/^[0-9]$/.test(this.params.key)&&(this.rating=Math.min(Number(this.params.key),u)),this.paint(),i}buildItem(h){const u=this.doc,i=String(this.props.icon??g),m=I(u,"span",{class:`${B.editor}__rating-fill`,attrs:{"aria-hidden":"true"},children:[W(u,i,{className:B.icon})]}),c=I(u,"span",{class:`${B.editor}__rating-item`,attrs:{"data-index":h,"data-icon":i,"aria-hidden":"true"},children:[W(u,i,{className:B.icon}),m]});return this.fills.push(m),this.#e.push(_(c,"mousedown",f=>{f&&o(f.preventDefault)&&f.preventDefault(),this.setRating(this.ratingAt(h,f),{commit:!0})})),this.props.hoverPreview!==!1&&this.#e.push(_(c,"mousemove",f=>{const a=this.ratingAt(h,f);a!==this.preview&&(this.preview=a,this.paint())})),this.items.push(c),c}buildClear(){const h=I(this.doc,"button",{class:`${B.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearRating")}});return this.#e.push(_(h,"mousedown",u=>{u&&o(u.preventDefault)&&u.preventDefault(),this.setRating(null)})),h}ratingAt(h,u){if(this.props.allowHalf!==!0)return h+1;const i=this.items[h],m=i&&Number(i.offsetWidth),c=u&&Number(u.offsetX);return!Number.isFinite(m)||m<=0||!Number.isFinite(c)?h+1:c*2<m?h+.5:h+1}focusTarget(){return this.slider}setRating(h,u){this.rating=h===null?null:A(h,this.max(),this.props.allowHalf===!0,!1),this.preview=null,this.paint(),u&&u.commit&&this.commit()}nudge(h){const u=this.rating===null?0:this.rating;this.setRating(u+h)}paint(){const h=this.max(),u=this.props.allowHalf===!0,i=this.preview===null?this.rating:this.preview,m=V(i===null?0:i,h,{allowHalf:u});for(let a=0;a<this.items.length;a++){const p=z(m[a]);this.items[a].setAttribute("data-fill",p),this.items[a].classList.toggle(`${B.editor}__rating-item--filled`,p!=="empty"),this.fills[a]&&this.fills[a].style.setProperty("--lat-rating-fill",`${(m[a]*100).toFixed(2)}%`)}const c=i===null?String(this.props.emptyLabel??this.t("cell.rating.empty")):this.t("cell.rating.of",{rating:w(i),max:h}),f=this.slider;f&&(f.setAttribute("aria-valuenow",i===null?"0":String(i)),f.setAttribute("aria-valuetext",c),f.setAttribute("data-preview",this.preview===null?"false":"true")),this.readout&&(this.readout.textContent=c)}onKeyDown(h){const u=()=>{o(h.preventDefault)&&h.preventDefault()},i=this.step();if(/^[0-9]$/.test(h.key)){u(),this.setRating(Math.min(Number(h.key),this.max()));return}switch(h.key){case"ArrowRight":case"ArrowUp":u(),this.nudge(i);break;case"ArrowLeft":case"ArrowDown":u(),this.nudge(-i);break;case"Home":u(),this.setRating(0);break;case"End":u(),this.setRating(this.max());break;case"Enter":u(),this.commit();break;case"Escape":u(),this.cancel();break;case"Tab":this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(u(),this.setRating(null));break;default:break}}readValue(){return this.rating}checkValue(h){if(h==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a rating";if(typeof h!="number"||!Number.isFinite(h))return"Enter a rating";const u=this.max();return h<0?"Must be 0 or more":h>u?`Must be ${u} or less`:this.props.allowHalf!==!0&&!Number.isInteger(h)?"Choose a whole rating":!0}toClipboard(){return this.rating===null?"":w(this.rating)}fromClipboard(h){const u=String(h??"").trim();if(u==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a rating"};const i=Number(u);if(!Number.isFinite(i))return{ok:!1,message:`"${u}" is not a rating`};const m=this.checkValue(i);return m!==!0?{ok:!1,message:m}:{ok:!0,value:i}}destroy(){for(const h of this.#e)h();this.#e.length=0,this.items.length=0,this.slider=null,this.readout=null,super.destroy()}}function t(s,h,u){if(s==null||s==="")return null;const i=Number(s);return Number.isFinite(i)?A(i,h,u,!1):null}const r=n}),Fe("packages/dom/src/editors/slider.js",function(e,K){"use strict";Object.defineProperty(e,"SLIDER_MIN",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"SLIDER_MAX",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"proportion",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"decimalsOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"normaliseMarks",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const Q=K("packages/dom/src/editors/common.js"),$=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,X=K("packages/dom/src/editors/number.js"),W=X.parseNumberText,H=X.presentNumber,z=K("packages/core/src/internal/util.js").isFunction,w=0,A=100;class g extends ${static popup=!1;amount=null;range=null;field=null;readout=null;root=null;marks=[];#e=[];min(){const r=Number(this.props.min??w);return Number.isFinite(r)?r:w}max(){const r=Number(this.props.max??A);return Number.isFinite(r)?r:A}step(){const r=Number(this.props.step??1);return Number.isFinite(r)&&r>0?r:1}build(){const r=this.doc,s=this.min(),h=this.max(),u=this.step(),i=o(this.props.marks);this.marks=i,this.amount=this.params.value==null||this.params.value===""?null:this.snap(Number(this.params.value));const m=I(r,"div",{class:`${B.editor}__slider`});this.root=m;const c=I(r,"input",{class:`${B.editor}__slider-input`,attrs:{type:"range",min:String(s),max:String(h),step:String(u),"aria-label":this.params.column&&this.params.column.title||null,"aria-valuetext":null,list:i.length?`${this.id}-marks`:null}});if(this.range=c,m.appendChild(c),i.length){const a=I(r,"datalist",{attrs:{id:`${this.id}-marks`}}),p=I(r,"div",{class:`${B.editor}__slider-marks`});for(const b of i){a.appendChild(I(r,"option",{attrs:{value:String(b.value),label:b.label}}));const O=I(r,"span",{class:`${B.editor}__slider-mark`,text:b.label,attrs:{"data-value":String(b.value)}});O.style&&z(O.style.setProperty)&&O.style.setProperty("--lat-slider-mark",`${(l(b.value,s,h)*100).toFixed(2)}%`),p.appendChild(O)}m.appendChild(a),m.appendChild(p)}const f=I(r,"input",{class:`${B.editor}__slider-number`,attrs:{type:"text",inputmode:"decimal","aria-label":this.t("editor.value")}});if(this.field=f,m.appendChild(f),this.props.showValue!==!1){const a=I(r,"span",{class:`${B.editor}__slider-value`});m.appendChild(a),this.readout=a}return this.#e.push(_(c,"input",()=>this.setAmount(Number(c.value),"range"))),this.#e.push(_(c,"change",()=>this.setAmount(Number(c.value),"range"))),this.#e.push(_(c,"keydown",a=>this.onKeyDown(a))),this.#e.push(_(f,"input",()=>this.onFieldInput())),this.#e.push(_(f,"change",()=>this.paint())),this.#e.push(_(f,"keydown",a=>this.onKeyDown(a))),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(f.value=this.params.key,this.onFieldInput()),this.paint(),m}focusTarget(){return this.field}attached(){super.attached();const r=this.field;r&&!this.params.key&&this.props.selectOnFocus!==!1&&z(r.select)&&r.select()}snap(r){if(!Number.isFinite(r))return this.min();const s=this.min(),h=this.max(),u=this.step(),i=Math.min(Math.max(r,s),h),m=s+Math.round((i-s)/u)*u,c=d(u),f=c>0?Number(m.toFixed(c)):Math.round(m);return Math.min(Math.max(f,s),h)}setAmount(r,s){this.amount=r===null?null:this.snap(r),this.paint(s)}onFieldInput(){const r=this.field?String(this.field.value):"";if(r.trim()===""){this.amount=null,this.paint("field");return}const s=W(r,this.params.locale);if(s===null||Number.isNaN(s)){this.paint("field");return}this.setAmount(s,"field")}paint(r){const s=this.min(),h=this.max(),u=this.amount,i=u===null?s:u;this.range&&r!=="range"&&(this.range.value=String(i)),this.field&&r!=="field"&&(this.field.value=u===null?"":H(u,this.props));const m=this.root;m&&m.style&&z(m.style.setProperty)&&m.style.setProperty("--lat-slider-pos",`${(l(i,s,h)*100).toFixed(2)}%`),m&&m.setAttribute&&m.setAttribute("data-empty",u===null?"true":"false");const c=this.labelFor(u);this.range&&this.range.setAttribute&&this.range.setAttribute("aria-valuetext",c),this.readout&&(this.readout.textContent=c)}labelFor(r){if(r===null)return String(this.props.emptyLabel??"");const s=this.marks.find(u=>u.value===r),h=H(r,this.props);return s&&s.label!==h?`${h} (${s.label})`:h}onKeyDown(r){if(r.key==="Escape"){z(r.preventDefault)&&r.preventDefault(),this.cancel();return}if(r.key==="Enter"){z(r.preventDefault)&&r.preventDefault(),this.commit();return}r.key==="Tab"&&this.commit()}readValue(){const r=this.field?String(this.field.value):"";if(r.trim()==="")return null;const s=W(r,this.params.locale);return s===null||Number.isNaN(s)?NaN:this.snap(s)}checkValue(r){return r==null?this.props.allowClear===!0||this.params.value==null?!0:"Enter a value":typeof r!="number"||Number.isNaN(r)?"Enter a number":r<this.min()?`Must be ${this.min()} or more`:r>this.max()?`Must be ${this.max()} or less`:!0}fromClipboard(r){const s=String(r??"").trim();if(s==="")return this.checkValue(null)===!0?{ok:!0,value:null}:{ok:!1,message:"Enter a value"};const h=W(s,this.params.locale);if(h===null||Number.isNaN(h))return{ok:!1,message:"Enter a number"};const u=this.snap(h),i=this.checkValue(u);return i!==!0?{ok:!1,message:i}:{ok:!0,value:u}}destroy(){for(const r of this.#e)r();this.#e.length=0,this.range=null,this.field=null,this.readout=null,this.root=null,this.marks=[],super.destroy()}}function l(t,r,s){const h=s-r;return!Number.isFinite(h)||h===0?0:Math.min(1,Math.max(0,(Number(t)-r)/h))}function d(t){if(!Number.isFinite(t))return 0;const r=String(t),s=r.indexOf("e");if(s>=0){const u=r.slice(0,s),i=u.indexOf("."),m=i<0?0:u.length-i-1;return Math.min(15,Math.max(0,m-Number(r.slice(s+1))))}const h=r.indexOf(".");return h<0?0:Math.min(15,r.length-h-1)}function o(t){if(!t)return[];const r=[];if(Array.isArray(t)){for(const s of t){if(s&&typeof s=="object"){const u=Number(s.value);Number.isFinite(u)&&r.push({value:u,label:String(s.label??u)});continue}const h=Number(s);Number.isFinite(h)&&r.push({value:h,label:String(h)})}return r}if(typeof t=="object")for(const[s,h]of Object.entries(t)){const u=Number(s);Number.isFinite(u)&&r.push({value:u,label:String(h)})}return r}const n=g}),Fe("packages/dom/src/editors/colour.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_SWATCHES",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"TOKEN_FALLBACK",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"normaliseSwatch",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolveSwatchColour",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"toSwatches",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const Q=K("packages/dom/src/editors/common.js"),$=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,X=K("packages/dom/src/cell/renderers/colour.js"),W=X.normaliseColour,H=X.parseColour,z=K("packages/core/src/internal/util.js").isFunction,w=Object.freeze(["neutral","info","success","warning","danger","accent"]),A=Object.freeze({neutral:"#5b6670",info:"#1a6bc7",success:"#1b7f3b",warning:"#a96a0b",danger:"#c22b2b",accent:"#5a46d6"});function g(r){if(r==null)return null;if(typeof r=="object"){const u=r,i=g(u.token??u.value??u.colour??u.color);return i?{...i,label:u.label==null?i.label:String(u.label)}:null}const s=String(r).trim();if(s==="")return null;const h=W(s);return h?{token:null,hex:h,label:h}:Object.hasOwn(A,s)?{token:s,hex:A[s],label:s}:null}function l(r,s){const h=r&&r.ownerDocument,u=h&&h.defaultView;if(!u||!z(u.getComputedStyle))return null;try{const i=u.getComputedStyle(r);return!i||!z(i.getPropertyValue)?null:W(String(i.getPropertyValue(`--lattice-variant-${s}-solid`)).trim())}catch{return null}}class d extends ${static popup=!0;swatches=[];buttons=[];native=null;hex=null;preview=null;#e=[];alpha(){return this.props.alpha===!0}build(){const s=this.doc;this.swatches=o(this.props.swatches);const h=I(s,"div",{class:`${B.editor}__colour`,attrs:{"aria-label":this.params.column&&this.params.column.title||null}});if(this.preview=I(s,"span",{class:`${B.editor}__colour-preview`,attrs:{"aria-hidden":"true"}}),h.appendChild(this.preview),this.swatches.length){const i=I(s,"div",{class:`${B.editor}__colour-swatches`,attrs:{role:"radiogroup","aria-label":this.t("editor.colours")}});for(let m=0;m<this.swatches.length;m++)i.appendChild(this.buildSwatch(this.swatches[m],m));h.appendChild(i)}this.native=I(s,"input",{class:`${B.editor}__colour-native`,attrs:{type:"color","aria-label":this.t("editor.customColour")}}),h.appendChild(this.native),this.hex=I(s,"input",{class:`${B.editor}__colour-hex`,attrs:{type:"text",spellcheck:"false",autocomplete:"off",placeholder:this.t("editor.hexPlaceholder"),"aria-label":this.t("editor.hexValue")}}),h.appendChild(this.hex),this.props.allowClear===!0&&h.appendChild(this.buildClear()),this.#e.push(_(this.native,"input",()=>this.setColour(this.native?this.native.value:null))),this.#e.push(_(this.native,"change",()=>this.setColour(this.native?this.native.value:null))),this.#e.push(_(this.hex,"input",()=>this.paint())),this.#e.push(_(this.hex,"change",()=>this.paint())),this.#e.push(_(this.hex,"keydown",i=>this.onKeyDown(i))),this.#e.push(_(h,"keydown",i=>this.onKeyDown(i)));const u=W(this.params.value,{alpha:this.alpha()});return this.hex.value=u===null?this.params.value==null?"":String(this.params.value):u,this.params.key&&/^[#0-9a-fA-F]$/.test(this.params.key)&&(this.hex.value=this.params.key),this.paint(),h}buildSwatch(s,h){const u=I(this.doc,"button",{class:`${B.editor}__colour-swatch`,attrs:{type:"button",role:"radio","aria-checked":"false","aria-label":s.label,"data-index":h,"data-variant":s.token}});return s.token||n(u,s.hex),this.#e.push(_(u,"mousedown",i=>{i&&z(i.preventDefault)&&i.preventDefault(),this.setColour(this.swatches[h].hex)})),this.buttons.push(u),u}buildClear(){const s=I(this.doc,"button",{class:`${B.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearColour")}});return this.#e.push(_(s,"mousedown",h=>{h&&z(h.preventDefault)&&h.preventDefault(),this.setColour(null)})),s}focusTarget(){return this.hex}attached(){super.attached();for(let s=0;s<this.swatches.length;s++){const h=this.swatches[s];if(!h.token)continue;const u=l(this.buttons[s]||this.element(),h.token);u&&(h.hex=u)}this.paint()}setColour(s){const h=s===null?null:W(s,{alpha:this.alpha()});this.hex&&(this.hex.value=h===null?"":h),this.paint()}current(){const s=this.hex?String(this.hex.value).trim():"";return s===""?null:W(s,{alpha:this.alpha()})}paint(){const s=this.current(),h=s===null?null:s.slice(0,7);n(this.preview,h),this.preview&&this.preview.setAttribute&&this.preview.setAttribute("data-empty",s===null?"true":"false"),this.native&&(this.native.value=h===null?"#000000":h);for(let u=0;u<this.buttons.length;u++){const i=s!==null&&this.swatches[u].hex.toLowerCase()===s.toLowerCase();this.buttons[u].setAttribute("aria-checked",i?"true":"false"),this.buttons[u].classList.toggle(`${B.editor}__colour-swatch--selected`,i),this.swatches[u].token||n(this.buttons[u],this.swatches[u].hex)}}onKeyDown(s){if(s.key==="Escape"){z(s.preventDefault)&&s.preventDefault(),this.cancel();return}if(s.key==="Enter"){z(s.preventDefault)&&s.preventDefault(),this.commit();return}s.key==="Tab"&&this.commit()}readValue(){const s=this.hex?String(this.hex.value).trim():"";if(s==="")return null;const h=W(s,{alpha:this.alpha()});return h===null?s:h}checkValue(s){if(s==null||s==="")return this.props.allowClear===!0||this.params.value==null?!0:"Choose a colour";const h=H(s);return h?!this.alpha()&&h.a<1?"This column does not accept transparency":!0:`"${String(s)}" is not a colour`}toClipboard(){const s=this.current();return s===null?"":s}fromClipboard(s){const h=String(s??"").trim();if(h==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a colour"};const u=W(h,{alpha:this.alpha()});if(u===null)return{ok:!1,message:`"${h}" is not a colour`};const i=this.checkValue(u);return i!==!0?{ok:!1,message:i}:{ok:!0,value:u}}destroy(){for(const s of this.#e)s();this.#e.length=0,this.buttons.length=0,this.swatches=[],this.native=null,this.hex=null,this.preview=null,super.destroy()}}function o(r){const s=Array.isArray(r)&&r.length?r:r===!1?[]:w,h=[];for(const u of s){const i=g(u);i&&h.push(i)}return h}function n(r,s){const h=r&&r.style;if(h){if(s===null){z(h.removeProperty)&&h.removeProperty("--lat-swatch");return}z(h.setProperty)&&h.setProperty("--lat-swatch",s)}}const t=d}),Fe("packages/dom/src/editors/treeselect.js",function(e,K){"use strict";Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const $=K("packages/dom/src/editors/select.js").SelectEditorBase,I=K("packages/dom/src/cell/icons.js").createIcon,_=K("packages/dom/src/editors/common.js"),X=_.CLS,W=_.el,H=_.on,V=_.clear,z=_.keyOf,w=_.rawOptions,A=_.lookupKey,g=K("packages/core/src/internal/util.js"),l=g.isFunction,d=g.isObject,o="\0";class n extends ${static popup=!0;roots=[];nodes=new Map;expanded=new Set;matched=new Set;selected=null;leavesOnly=!0;build(){this.leavesOnly=this.props.selectLeavesOnly!==!1;const s=super.build();return s.classList.add("lat-treeselect"),this.list&&this.list.element().setAttribute("role","tree"),s}initSelection(){this.rebuild(),this.selected=this.params.value??null;const s=this.nodeById(this.selected);if(s)for(let h=s.parent;h;h=h.parent)this.expanded.add(h.key)}rebuild(){const s=w(this.params,this.props),h=this.props.keys||{},u=h.value||A(this.params,"valueKey")||"id",i=h.label||A(this.params,"labelKey")||"label";this.roots=[],this.nodes=new Map;for(const m of s){if(!d(m)){this.addNode(null,String(m??""),m,null);continue}Array.isArray(m.path)&&m.path.length?this.addByPath(m,u,i):this.addByChildren(m,null,u,i)}if(this.props.defaultExpanded===!0)for(const m of this.nodes.keys())this.expanded.add(m)}addNode(s,h,u,i){const m=s?`${s.key}${o}${h}`:h;let c=this.nodes.get(m);return c?c.id===void 0&&u!==void 0&&(c.id=u):(c={id:u,label:h,key:m,parent:s,children:[],depth:s?s.depth+1:0,disabled:!1},this.nodes.set(m,c),(s?s.children:this.roots).push(c)),i&&(i.disabled===!0&&(c.disabled=!0),i.icon!==void 0&&(c.icon=i.icon),i.variant!==void 0&&(c.variant=i.variant)),c}addByPath(s,h,u){const i=s.path;let m=null;for(let c=0;c<i.length;c++){const f=c===i.length-1,a=String(i[c]),p=f&&s[u]!=null?String(s[u]):a,b=this.addNode(m,a,f?s[h]:void 0,f?s:null);f&&(b.label=p),m=b}}addByChildren(s,h,u,i){const m=s[u],c=s[i]!=null?String(s[i]):String(m??""),f=this.addNode(h,c,m,s),a=Array.isArray(s.children)?s.children:[];for(const p of a)d(p)?this.addByChildren(p,f,u,i):this.addNode(f,String(p??""),p,null)}nodeById(s){if(s==null)return;const h=z(s);for(const u of this.nodes.values())if(u.id!==void 0&&z(u.id)===h)return u}filterOptions(s){const h=String(s||"").trim().toLowerCase(),u=h!=="";this.matched=u?this.computeMatches(h):new Set;const i=[],m=c=>{for(const f of c)u&&!this.matched.has(f.key)||(i.push(f),f.children.length&&(u||this.expanded.has(f.key))&&m(f.children))};return m(this.roots),i}computeMatches(s){const h=new Set,u=i=>{let m=i.label.toLowerCase().includes(s);for(const c of i.children)u(c)&&(m=!0);return m&&h.add(i.key),m};for(const i of this.roots)u(i);return h}repaint(s){if(this.refreshOptions(),!s||!this.list)return;const h=this.visible.findIndex(u=>u.key===s);h>=0&&this.list.setActive(h)}isBranch(s){return!!s&&s.children.length>0}isSelectable(s){return!s||s.disabled||s.id===void 0||s.id===null?!1:!(this.leavesOnly&&this.isBranch(s))}setExpanded(s,h){this.isBranch(s)&&(h?this.expanded.add(s.key):this.expanded.delete(s.key),this.repaint(s.key))}choose(s){if(s){if(!this.isSelectable(s)){this.isBranch(s)&&this.setExpanded(s,!this.expanded.has(s.key));return}this.selected=s.id,this.input&&(this.input.value=""),this.query="",this.repaint(s.key),this.paintDisplay(),this.commit()}}isSelected(s){return this.selected!=null&&s&&s.id!==void 0&&z(s.id)===z(this.selected)}clearSelection(){this.selected=null,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay()}readValue(){return this.selected??null}checkValue(s){if(s==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a value";if(!this.nodes.size)return!0;const h=this.nodeById(s);return h&&this.isSelectable(h)?!0:h?`"${h.label}" is a group, not a value`:this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(s)}" is not a valid option`}renderOption(s,h,u){V(h),h.setAttribute("role","treeitem"),h.setAttribute("aria-level",String(s.depth+1)),h.setAttribute("data-depth",String(s.depth));const i=W(this.doc,"span",{class:"lat-tree__indent"});for(let b=0;b<s.depth;b++)i.appendChild(W(this.doc,"span",{class:"lat-tree__guide"}));h.appendChild(i);const m=this.isBranch(s),c=m&&(this.expanded.has(s.key)||this.query.trim()!==""),f=m?c?"chevronDown":"chevronRight":"blank",a=W(this.doc,"span",{class:m?"lat-tree__twisty":"lat-tree__twisty lat-tree__twisty--leaf",children:[I(this.doc,f,{className:X.icon})],attrs:{"data-icon":m?f:null,"aria-hidden":"true"}});m&&H(a,"mousedown",b=>{l(b.preventDefault)&&b.preventDefault(),l(b.stopPropagation)&&b.stopPropagation(),this.setExpanded(s,!this.expanded.has(s.key))}),h.appendChild(a),s.icon&&h.appendChild(I(this.doc,s.icon,{className:X.icon})),h.appendChild(W(this.doc,"span",{class:`${X.option}__label`,text:s.label})),s.variant?h.setAttribute("data-variant",s.variant):h.removeAttribute("data-variant"),m?h.setAttribute("aria-expanded",c?"true":"false"):h.removeAttribute("aria-expanded");const p=this.isSelected(s);h.classList.toggle(X.optionSelected,p),h.classList.toggle(X.optionDisabled,!this.isSelectable(s)),h.classList.toggle("lat-tree__row--branch",m),h.setAttribute("aria-selected",p?"true":"false"),this.isSelectable(s)?h.removeAttribute("aria-disabled"):h.setAttribute("aria-disabled","true")}paintDisplay(){const s=this.display;if(!s)return;if(V(s),this.selected==null){s.removeAttribute("data-variant");return}const h=this.nodeById(this.selected);if(!h){s.appendChild(W(this.doc,"span",{text:String(this.selected)}));return}h.icon&&s.appendChild(I(this.doc,h.icon,{className:X.icon})),s.appendChild(W(this.doc,"span",{class:"lat-tree__path",text:this.pathLabel(h)})),h.variant?s.setAttribute("data-variant",h.variant):s.removeAttribute("data-variant")}pathLabel(s){const h=[];for(let u=s;u;u=u.parent)h.unshift(u.label);return h.join(String(this.props.pathSeparator??" / "))}onKeyDown(s){const h=this.list,u=h&&h.active>=0?this.visible[h.active]:null;switch(s.key){case"ArrowRight":{if(l(s.preventDefault)&&s.preventDefault(),!u)return;this.isBranch(u)&&!this.expanded.has(u.key)?this.setExpanded(u,!0):this.isBranch(u)&&h&&h.setActive(Math.min(this.visible.length-1,h.active+1));return}case"ArrowLeft":{if(l(s.preventDefault)&&s.preventDefault(),!u)return;this.isBranch(u)&&this.expanded.has(u.key)?this.setExpanded(u,!1):u.parent&&this.focusNode(u.parent.key);return}case"Home":l(s.preventDefault)&&s.preventDefault(),h&&this.visible.length&&h.setActive(0);return;case"End":l(s.preventDefault)&&s.preventDefault(),h&&this.visible.length&&h.setActive(this.visible.length-1);return;default:super.onKeyDown(s)}}focusNode(s){if(!this.list)return;const h=this.visible.findIndex(u=>u.key===s);h>=0&&this.list.setActive(h)}acceptHighlight(s){const h=this.list,u=h&&h.active>=0?this.visible[h.active]:null;if(!u){s&&s.commit&&this.commit();return}if(this.isSelectable(u)){this.choose(u);return}this.isBranch(u)?this.setExpanded(u,!this.expanded.has(u.key)):s&&s.commit&&this.commit()}moveHighlight(s){const h=this.list;if(!h)return;let u=h.active;for(let i=0;i<this.visible.length;i++){if(u+=s,u<0||u>=this.visible.length)return;if(!this.visible[u].disabled){h.setActive(u);return}}}}const t=n}),Fe("packages/dom/src/editors/objectpicker.js",function(e,K){"use strict";Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"readField",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"initialsOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return m}});const $=K("packages/dom/src/editors/select.js").SelectEditorBase,B=K("packages/dom/src/editors/common.js"),I=B.CLS,_=B.el,X=B.on,W=B.clear,H=B.keyOf,V=B.debounce,z=B.rawOptions,w=B.optionSource,A=B.lookupSearch,g=B.lookupKey,l=K("packages/core/src/internal/util.js"),d=l.isFunction,o=l.isObject,n=l.getPath,r=K("packages/dom/src/cell/icons.js").createIcon;class s extends ${static popup=!0;all=[];selected=null;#e=null;#t=!1;#n=null;build(){const f=super.build();if(f.classList.add("lat-objectpicker"),d(this.props.search)&&!(this.lookup&&this.lookup.search)){const a=Number(this.props.searchDebounce)||200;this.#n=V(p=>this.runRemoteSearch(String(p)),a)}return f}onQuery(f){super.onQuery(f),this.#n&&this.#n(f)}initSelection(){const f=z(this.params,this.props).map(a=>this.toOption(a));(f.length||!this.all.length)&&(this.all=f),this.selected=this.params.value??null}toOption(f){if(!o(f)){const y=f==null?"":String(f);return{id:f,label:y,secondary:"",avatar:"",initials:u(y),disabled:!1,raw:{}}}const a=this.props.valueKey||g(this.params,"valueKey")||"id",p=this.props.labelKey||g(this.params,"labelKey")||"label",b=h(f,this.props.template??p,""),O=h(f,this.props.secondary,""),k=h(f,this.props.avatar,"");return{id:f[a],label:b||String(f[a]??""),secondary:O,avatar:k,initials:u(b||String(f[a]??"")),disabled:f.disabled===!0,icon:f.icon,variant:f.variant,raw:f}}attached(){if(super.attached(),this.#t||this.all.length)return;const f=w(this.params,this.props);d(f)&&(this.#t=!0,Promise.resolve(f()).then(a=>{!this.element()||!Array.isArray(a)||(this.all=a.map(p=>this.toOption(p)),this.refreshOptions(),this.paintDisplay())}))}filterOptions(f){const a=String(f||"").trim().toLowerCase();if(a==="")return this.all;const p=i(this.props.searchFields);return this.all.filter(b=>{if(!p)return b.label.toLowerCase().includes(a)||b.secondary.toLowerCase().includes(a);for(const O of p){const k=d(O)?O(b.raw):n(b.raw,O);if(k!=null&&String(k).toLowerCase().includes(a))return!0}return!1})}async runRemoteSearch(f){const a=A(this.params,this.props);if(!a)return;this.#e&&this.#e.abort();const p=new AbortController;this.#e=p;try{const b=await a(f,p.signal);if(p.signal.aborted||this.#e!==p)return;this.refreshOptions(Array.isArray(b)?b.map(O=>this.toOption(O)):[])}catch(b){if(!p.signal.aborted)throw b}finally{this.#e===p&&(this.#e=null)}}choose(f){!f||f.disabled||(this.selected=f.id,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay(),this.commit())}isSelected(f){return this.selected!=null&&f!=null&&H(f.id)===H(this.selected)}clearSelection(){this.selected=null,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay()}readValue(){return this.selected??null}optionById(f){if(f==null)return;const a=H(f);return this.all.find(p=>H(p.id)===a)}checkValue(f){return f==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.all.length||this.optionById(f)||this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(f)}" is not a valid option`}renderOption(f,a,p){W(a),a.appendChild(this.buildAvatar(f));const b=_(this.doc,"span",{class:"lat-object__text"});b.appendChild(_(this.doc,"span",{class:"lat-object__primary",text:f.label})),f.secondary&&b.appendChild(_(this.doc,"span",{class:"lat-object__secondary",text:f.secondary})),a.appendChild(b),f.icon&&a.appendChild(r(this.doc,f.icon,{className:I.icon})),f.variant?a.setAttribute("data-variant",f.variant):a.removeAttribute("data-variant");const O=this.isSelected(f);a.classList.add("lat-object__row"),a.classList.toggle(I.optionSelected,O),a.classList.toggle(I.optionDisabled,f.disabled===!0),a.setAttribute("aria-selected",O?"true":"false"),f.disabled?a.setAttribute("aria-disabled","true"):a.removeAttribute("aria-disabled")}buildAvatar(f){const a=_(this.doc,"span",{class:"lat-avatar",attrs:{"aria-hidden":"true"}});if(!f.avatar)return a.appendChild(_(this.doc,"span",{class:"lat-avatar__initials",text:f.initials})),a.setAttribute("data-fallback","initials"),a;const p=_(this.doc,"img",{class:"lat-avatar__image",attrs:{src:f.avatar,alt:"",loading:"lazy",decoding:"async"}});return X(p,"error",()=>{p.parentNode===a&&(a.removeChild(p),a.appendChild(_(this.doc,"span",{class:"lat-avatar__initials",text:f.initials})),a.setAttribute("data-fallback","initials"))}),a.appendChild(p),a}paintDisplay(){const f=this.display;if(!f)return;if(W(f),this.selected==null){f.removeAttribute("data-variant");return}const a=this.optionById(this.selected);if(!a){f.appendChild(_(this.doc,"span",{text:this.lookup?this.lookup.label(this.selected):String(this.selected)}));return}f.appendChild(this.buildAvatar(a)),f.appendChild(_(this.doc,"span",{class:"lat-object__primary",text:a.label})),a.variant?f.setAttribute("data-variant",a.variant):f.removeAttribute("data-variant")}destroy(){this.#e&&(this.#e.abort(),this.#e=null),this.#n&&(this.#n.cancel(),this.#n=null),this.all=[],super.destroy()}}function h(c,f,a){if(f==null)return a;const p=d(f)?f(c):n(c,String(f));return p==null?a:String(p)}function u(c){const f=String(c||"").trim().split(/\s+/).filter(b=>b!=="");if(!f.length)return"";const a=[...f[0]][0]||"";if(f.length===1)return a.toUpperCase();const p=[...f[f.length-1]][0]||"";return(a+p).toUpperCase()}function i(c){if(c==null)return null;const a=(Array.isArray(c)?c:[c]).filter(p=>typeof p=="string"||d(p));return a.length?a:null}const m=s}),Fe("packages/dom/src/editors/iconpicker.js",function(e,K){"use strict";Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolveNames",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const Q=K("packages/dom/src/editors/common.js"),$=Q.BaseEditor,B=Q.CLS,I=Q.VirtualList,_=Q.el,X=Q.on,W=Q.clear,H=K("packages/dom/src/cell/icons.js"),V=H.createIcon,z=H.iconNames,A=K("packages/core/src/internal/util.js").isFunction;class g extends ${static popup=!0;input=null;display=null;list=null;names=[];matches=[];rows=[];columns=8;cursor=-1;selected=null;query="";off=[];build(){const n=this.props;this.columns=Math.max(1,Math.floor(Number(n.columns)||8)),this.names=l(n.icons),this.selected=this.params.value==null?null:String(this.params.value);const t=_(this.doc,"div",{class:["lat-iconpicker",`${B.editor}__select`],attrs:{role:"combobox","aria-expanded":"true"}});return this.display=_(this.doc,"div",{class:`${B.editor}__display`}),this.input=_(this.doc,"input",{class:B.input,attrs:{type:"text",autocomplete:"off",placeholder:n.placeholder??"Search icons","aria-label":this.params.column&&this.params.column.title||"Search icons","aria-autocomplete":"list"}}),this.input.value="",this.list=new I({document:this.doc,itemHeight:Number(n.rowHeight)||34,height:Number(n.listHeight)||204,renderItem:(r,s,h)=>this.renderRow(r,s,h)}),this.list.element().setAttribute("role","grid"),this.list.element().setAttribute("aria-label",this.t("panel.icons")),t.appendChild(this.display),t.appendChild(this.input),n.allowClear===!0&&t.appendChild(this.buildClearButton()),t.appendChild(this.list.element()),this.off.push(X(this.input,"input",()=>this.onQuery(this.input?this.input.value:""))),this.off.push(X(this.input,"keydown",r=>this.onKeyDown(r))),this.refreshIcons(),this.paintDisplay(),this.params.key&&this.params.key.length===1&&(this.input.value=this.params.key,this.onQuery(this.params.key)),t}buildClearButton(){const n=_(this.doc,"button",{class:"lat-iconpicker__clear",text:this.t("editor.noIcon"),attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.noIcon")}});return this.off.push(X(n,"mousedown",t=>{A(t.preventDefault)&&t.preventDefault(),this.selected=null,this.paintDisplay(),this.commit()})),n}focusTarget(){return this.input}onQuery(n){this.query=n,this.refreshIcons()}refreshIcons(){const n=this.query.trim().toLowerCase();this.matches=n===""?this.names.slice():this.names.filter(r=>r.toLowerCase().includes(n)),this.rows=[];for(let r=0;r<this.matches.length;r+=this.columns)this.rows.push(this.matches.slice(r,r+this.columns));const t=this.selected?this.matches.indexOf(this.selected):-1;this.cursor=t>=0?t:this.matches.length?0:-1,this.list&&this.list.setItems(this.rows,this.rowOf(this.cursor))}rowOf(n){return n<0?-1:Math.floor(n/this.columns)}moveCursor(n){if(!this.matches.length)return-1;const t=Math.max(0,Math.min(this.matches.length-1,this.cursor+n));return this.setCursor(t)}setCursor(n){return this.cursor=n,this.list&&this.list.setActive(this.rowOf(n)),this.cursor}cursorName(){return this.cursor>=0&&this.cursor<this.matches.length?this.matches[this.cursor]:null}renderRow(n,t,r){t.setAttribute("role","row"),t.classList.add("lat-iconpicker__row");let s=t.__latIconCells;if(!s){s=[],W(t);for(let h=0;h<this.columns;h++){const u=_(this.doc,"span",{class:"lat-iconpicker__cell",attrs:{role:"gridcell",tabindex:"-1"}});X(u,"mousedown",i=>{A(i.preventDefault)&&i.preventDefault();const m=u.getAttribute("data-icon");m&&this.choose(m)}),t.appendChild(u),s.push(u)}t.__latIconCells=s}for(let h=0;h<s.length;h++){const u=s[h],i=n[h];if(i===void 0){u.setAttribute("aria-hidden","true"),u.removeAttribute("data-icon"),u.removeAttribute("title"),u.removeAttribute("aria-label"),u.classList.add("lat-iconpicker__cell--empty"),u.classList.remove("lat-iconpicker__cell--active"),u.classList.remove("lat-iconpicker__cell--selected"),u.__latIconName!==void 0&&(W(u),u.__latIconName=void 0);continue}const m=r*this.columns+h;u.removeAttribute("aria-hidden"),u.classList.remove("lat-iconpicker__cell--empty"),u.setAttribute("data-icon",i),u.setAttribute("title",i),u.setAttribute("aria-label",i),u.__latIconName!==i&&(W(u),u.appendChild(V(this.doc,i,{className:B.icon})),u.__latIconName=i);const c=this.selected===i;u.classList.toggle("lat-iconpicker__cell--active",m===this.cursor),u.classList.toggle("lat-iconpicker__cell--selected",c),u.setAttribute("aria-selected",c?"true":"false")}}paintDisplay(){const n=this.display;if(n){if(W(n),this.selected==null){n.appendChild(_(this.doc,"span",{class:"lat-iconpicker__none",text:this.t("editor.noIcon")}));return}n.appendChild(V(this.doc,this.selected,{className:B.icon})),n.appendChild(_(this.doc,"span",{text:this.selected}))}}choose(n){this.selected=n;const t=this.matches.indexOf(n);t>=0&&(this.cursor=t),this.list&&this.list.paint(),this.paintDisplay(),this.commit()}readValue(){return this.selected??null}checkValue(n){return n==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose an icon":this.names.includes(String(n))?!0:`"${String(n)}" is not a known icon name`}onKeyDown(n){const t=()=>{A(n.preventDefault)&&n.preventDefault()};switch(n.key){case"ArrowRight":t(),this.moveCursor(1);return;case"ArrowLeft":t(),this.moveCursor(-1);return;case"ArrowDown":t(),this.moveCursor(this.columns);return;case"ArrowUp":t(),this.moveCursor(-this.columns);return;case"PageDown":t(),this.moveCursor(this.columns*5);return;case"PageUp":t(),this.moveCursor(-this.columns*5);return;case"Home":t(),this.setCursor(this.matches.length?0:-1);return;case"End":t(),this.setCursor(this.matches.length-1);return;case"Enter":{t();const r=this.cursorName();r&&this.choose(r);return}case"Escape":t(),this.cancel();return;case"Tab":{const r=this.cursorName();r&&(this.selected=r),this.commit();return}default:break}}destroy(){for(const n of this.off)n();this.off.length=0,this.list&&(this.list.destroy(),this.list=null),this.input=null,this.display=null,this.rows=[],super.destroy()}}function l(o){const n=z();if(Array.isArray(o)&&o.length){const t=new Set(n);return o.map(r=>String(r)).filter(r=>t.has(r))}return n.filter(t=>t!=="blank")}const d=g}),Fe("packages/dom/src/editors/temperature.js",function(e,K){"use strict";Object.defineProperty(e,"presentTemperature",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const Q=K("packages/dom/src/editors/common.js"),$=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,W=K("packages/core/src/internal/util.js").isFunction,H=K("packages/core/src/columns/types/temperature.js"),V=H.formatTemperature,z=H.parseTemperature,w=H.findScale;function A(d,o){return V(d,{...o,decimals:void 0,minDecimals:0,maxDecimals:20})}class g extends ${input=null;hint=null;opts=null;#e=[];buildOptions(){const o=this.params.column&&this.params.column.dataType||null,n=o&&o.temperatureConfig||{};return{scale:this.props.scale||n.scale||"C",locale:this.params.locale}}build(){const o=this.props;this.opts=this.buildOptions();const n=w(this.opts.scale),t=n?n.scale.symbol:"",r=`${this.id}-scale`,s=I(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:o.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":t?r:null}});s.value=A(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(s.value=this.params.key),this.input=s;const h=typeof o.step=="number"?o.step:0;return h>0&&this.#e.push(_(s,"keydown",u=>{u.key==="ArrowUp"?(W(u.preventDefault)&&u.preventDefault(),this.nudge(h)):u.key==="ArrowDown"&&(W(u.preventDefault)&&u.preventDefault(),this.nudge(-h))})),this.hint=I(this.doc,"span",{class:`${B.editor}__suffix`,text:t,attrs:{id:r,"aria-hidden":"true"}}),I(this.doc,"div",{class:`${B.editor}__unit`,children:[s,this.hint]})}focusTarget(){return this.input}attached(){super.attached();const o=this.input;o&&!this.params.key&&this.props.selectOnFocus!==!1&&W(o.select)&&o.select()}nudge(o){const n=z(this.input?this.input.value:"",this.opts);let t=(n??0)+o;const{min:r,max:s}=this.props;typeof r=="number"&&t<r&&(t=r),typeof s=="number"&&t>s&&(t=s),this.input&&(this.input.value=A(t,this.opts))}readValue(){const o=this.input?String(this.input.value).trim():"";if(o==="")return null;const n=z(o,this.opts);return n===null?Number.NaN:n}checkValue(o){if(o===null)return!0;if(typeof o!="number"||Number.isNaN(o))return"Enter a temperature";const{min:n,max:t}=this.props;return typeof n=="number"&&o<n?`Must be ${n} or more`:typeof t=="number"&&o>t?`Must be ${t} or less`:!0}destroy(){for(const o of this.#e)o();this.#e=[],this.input=null,this.hint=null,super.destroy()}}const l=g}),Fe("packages/dom/src/editors/currency.js",function(e,K){"use strict";Object.defineProperty(e,"presentAmount",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"CurrencyEditor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const Q=K("packages/dom/src/editors/common.js"),$=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,W=K("packages/core/src/internal/util.js").isFunction,H=K("packages/core/src/columns/types/currency.js"),V=H.parseMoney,z=H.toMoney,w=H.normaliseCode,A=["USD","EUR","GBP","JPY","CHF","CAD","AUD","CNY"];function g(o){const n=z(o);return n?String(n.amount):""}class l extends ${input=null;picker=null;opts=null;#e=[];buildOptions(){const n=this.params.column&&this.params.column.dataType||null,t=n&&n.currencyConfig||{},r=z(this.params.value),s=w(this.props.code)||r&&r.code||w(t.code)||"USD";let h=this.props.codes||t.codes||A;return h=h.map(u=>w(u)).filter(Boolean),h.includes(s)||(h=[s,...h]),{code:s,codes:h,locale:this.params.locale}}build(){const n=this.props;this.opts=this.buildOptions();const t=I(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:n.placeholder??null,"aria-label":this.params.column&&this.params.column.title||"Amount"}});t.value=g(this.params.value),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(t.value=this.params.key),this.input=t;const r=I(this.doc,"select",{class:`${B.editor}__suffix`,attrs:{"aria-label":this.t("editor.currency")}});for(const s of this.opts.codes){const h=I(this.doc,"option",{text:s,attrs:{value:s}});s===this.opts.code&&(h.selected=!0),r.appendChild(h)}return this.picker=r,I(this.doc,"div",{class:`${B.editor}__unit`,children:[t,r]})}focusTarget(){return this.input}attached(){super.attached();const n=this.input;n&&!this.params.key&&this.props.selectOnFocus!==!1&&W(n.select)&&n.select()}readValue(){const n=this.input?String(this.input.value).trim():"";if(n==="")return null;const t=this.picker?this.picker.value:this.opts.code,r=V(n,{...this.opts,code:t});return r===null?Number.NaN:r}checkValue(n){if(n===null)return!0;if(!n||typeof n!="object"||!Number.isFinite(n.amount))return"Enter an amount";const t=n.amount,{min:r,max:s}=this.props;return typeof r=="number"&&t<r?`Must be ${r} or more`:typeof s=="number"&&t>s?`Must be ${s} or less`:!0}destroy(){for(const n of this.#e)n();this.#e=[],this.input=null,this.picker=null,super.destroy()}}const d=l}),Fe("packages/dom/src/editors/index.js",function(e,K){"use strict";Object.defineProperty(e,"TextEditor",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"TextareaEditor",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"NumberEditor",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DateEditor",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"CheckboxEditor",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"SelectEditor",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"MultiSelectEditor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"TimeEditor",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DateTimeEditor",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DurationEditor",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"IpAddressEditor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PasswordEditor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"CodeEditor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"CurrencyEditor",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return he}}),Object.defineProperty(e,"editorByType",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return fe}});const $=K("packages/dom/src/editors/text.js").TextEditor,I=K("packages/dom/src/editors/textarea.js").TextareaEditor,X=K("packages/dom/src/editors/number.js").NumberEditor,H=K("packages/dom/src/editors/date.js").DateEditor,z=K("packages/dom/src/editors/checkbox.js").CheckboxEditor,A=K("packages/dom/src/editors/select.js").SelectEditor,l=K("packages/dom/src/editors/multiselect.js").MultiSelectEditor,o=K("packages/dom/src/editors/time.js").TimeEditor,t=K("packages/dom/src/editors/datetime.js").DateTimeEditor,s=K("packages/dom/src/editors/duration.js").DurationEditor,u=K("packages/dom/src/editors/ipaddress.js").IpAddressEditor,m=K("packages/dom/src/editors/password.js").PasswordEditor,f=K("packages/dom/src/editors/code.js").CodeEditor,p=K("packages/dom/src/editors/unit.js").UnitEditor,O=K("packages/dom/src/editors/radix.js").RadixEditor,y=K("packages/dom/src/editors/segmented.js").SegmentedEditor,R=K("packages/dom/src/editors/rating.js").RatingEditor,x=K("packages/dom/src/editors/slider.js").SliderEditor,P=K("packages/dom/src/editors/colour.js").ColourEditor,E=K("packages/dom/src/editors/treeselect.js").TreeSelectEditor,N=K("packages/dom/src/editors/objectpicker.js").ObjectPickerEditor,j=K("packages/dom/src/editors/iconpicker.js").IconPickerEditor,G=K("packages/dom/src/editors/temperature.js").TemperatureEditor,Y=K("packages/dom/src/editors/currency.js").CurrencyEditor,J=K("packages/core/src/internal/util.js"),ee=J.isCtor,ne=J.isFunction,ie=J.warnOnce,se=K("packages/dom/src/editors/common.js");for(const de of Object.keys(se))de!=="default"&&Object.defineProperty(e,de,{enumerable:!0,get:function(){return se[de]}});const he=Object.freeze({text:$,textarea:I,number:X,date:H,checkbox:z,select:A,multiSelect:l,temperature:G,currency:Y,time:o,datetime:t,duration:s,ipaddress:u,password:m,code:f,unit:p,radix:O,slider:x,rating:R,segmented:y,treeSelect:E,objectPicker:N,iconPicker:j,colour:P}),ce=Object.freeze({text:"text",number:"number",boolean:"checkbox",date:"date",dateString:"date",lookup:"select",object:""});function te(de,ve){const Me=de&&de.edit&&de.edit.editor,Oe=ve&&ve.editors||{},Ce=!!(de&&de.lookup&&de.lookup.multiple);if(ee(Me)||ne(Me))return Me;if(typeof Me=="string"){if(Ce&&Me==="select")return l;const me=Oe[Me]||he[Me];if(me)return me;ie(`editor:missing:${Me}`,`unknown editor "${Me}"; falling back to the data type default`)}const pe=de&&de.type||"text";if(pe==="lookup"||de&&de.lookup)return Ce?l:A;const we=ce[pe];return we&&(Oe[we]||he[we])||null}function oe(de,ve){const Me=te(de.column||{},ve);if(!Me)return null;const Oe=new Me;return Oe.init(de),ne(Oe.cancelBeforeStart)&&Oe.cancelBeforeStart()===!0?(ne(Oe.destroy)&&Oe.destroy(),null):Oe}const fe=he}),Fe("packages/dom/src/ui/statusbar.js",function(e,K){"use strict";Object.defineProperty(e,"aggregate",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"StatusPanel",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"RowCountPanel",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"SelectedCountPanel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"AggregationPanel",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ProgressPanel",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return m}});const Q=K("packages/dom/src/editors/common.js"),$=Q.CLS,B=Q.documentFor,I=Q.el,_=Q.clear,W=K("packages/core/src/i18n/index.js").defaultMessages,V=K("packages/core/src/internal/util.js").isFunction;function z(c){let f=0,a=0,p=0,b=null,O=null;for(const k of c||[]){if(k==null||k==="")continue;f++;const y=typeof k=="number"?k:Number(k);Number.isFinite(y)&&(a++,p+=y,(b===null||y<b)&&(b=y),(O===null||y>O)&&(O=y))}return{count:f,numericCount:a,sum:a?p:null,min:b,max:O,avg:a?p/a:null}}class w{root=null;valueNode=null;init(f){this.ctx=f,this.doc=f.document,this.root=I(this.doc,"div",{class:`${$.statusBar}__panel`,attrs:{"data-align":f.align||"end"}}),f.label&&this.root.appendChild(I(this.doc,"span",{class:`${$.statusBar}__label`,text:f.label})),this.valueNode=I(this.doc,"span",{class:`${$.statusBar}__value`,text:""}),this.root.appendChild(this.valueNode)}t(f,a){const p=this.ctx&&this.ctx.messages;return(p&&V(p.t)?p:W).t(f,a)}element(){return this.root}refresh(){const f=this.read();this.valueNode&&this.valueNode.textContent!==f&&(this.valueNode.textContent=f)}read(){return""}destroy(){this.root=null,this.valueNode=null}}class A extends w{read(){const f=this.ctx.host||{},a=V(f.totalRowCount)?f.totalRowCount():0,p=V(f.loadError)?f.loadError():null;if(p)return p;if(a==null)return this.t("status.counting");const b=V(f.rowCount)?f.rowCount():a;if(b==null)return p||this.t("status.counting");const O=this.ctx.noun,k=y=>O===void 0?this.t("count.rows",{count:y}):`${h(y,this.ctx.locale)}${O?` ${O}`:""}`;return b===a?this.t("status.total",{rows:k(a)}):this.t("status.shownOfTotal",{shown:h(b,this.ctx.locale),total:k(a)})}}class g extends w{read(){const f=this.ctx.host||{},a=V(f.selectedAcrossSource)?f.selectedAcrossSource():null;if(a)return typeof a.count=="number"?this.t("status.selectedAcrossSource",{count:a.count}):this.t("status.selectedAcrossSourceCounting");const p=V(f.selectedCount)?f.selectedCount():0;return p?this.t("status.selected",{count:p}):""}}class l extends w{read(){const f=this.ctx.host||{},a=V(f.rangeValues)?f.rangeValues():[],p=z(a);if(!p.count)return"";const b=this.ctx.stats||["count","sum","min","max","avg"],O=[];for(const k of b){if(k==="count"){O.push(this.t("status.count",{count:p.count}));continue}const y=p[k];y!==null&&O.push(`${this.t(`status.stat.${k}`)} ${i(y,this.ctx.locale)}`)}return O.join(" ")}}class d extends w{read(){const f=this.ctx.host||{},a=V(f.progress)?f.progress():null;if(!a)return"";const{loaded:p,estimated:b,done:O}=a;if(O)return"";if(!b)return this.t("status.loading",{count:p||0});const k=Math.min(100,Math.round((p||0)/b*100));return this.t("status.loadingOf",{loaded:p||0,total:b,percent:k})}}class o extends w{read(){const f=this.ctx.host||{},a=V(f.updateStats)?f.updateStats():null;return a?a.paused?a.pending?this.t("status.pausedWaiting",{waiting:this.t("count.waiting",{count:a.pending})}):this.t("status.paused"):a.coalescedTotal?this.t("status.coalesced",{count:a.coalescedTotal}):"":""}}class n extends w{read(){const f=this.ctx.host||{},a=V(f.hiddenUnresolved)?f.hiddenUnresolved():0;return a?this.t("status.hiddenComments",{comments:this.t("count.unresolvedComments",{count:a})}):""}}const t=Object.freeze({rowCount:A,selectedCount:g,aggregation:l,progress:d,updates:o,comments:n});class r{panels=[];root=null;init(f){const a=f||{};this.doc=B(a),this.host=a.host||{},this.messages=a.messages||null,this.root=I(this.doc,"div",{class:$.statusBar,attrs:{role:"status","aria-live":"polite"}});const p=a.registry||{},b=Array.isArray(a.panels)&&a.panels.length?a.panels:["rowCount","selectedCount","aggregation","comments","updates","progress"];for(const O of b){const k=typeof O=="string"?O:O.name,y=typeof O=="function"?O:p[k]||t[k];if(!y)continue;const v=new y;v.init({document:this.doc,host:this.host,locale:a.locale,messages:this.messages,...typeof O=="object"?O.props||{}:{}}),this.panels.push({name:String(k||"panel"),panel:v}),this.root.appendChild(v.element())}this.refresh()}element(){return this.root}addPanel(f,a,p){const b=new a;return b.init({document:this.doc,host:this.host,messages:this.messages,...p||{}}),this.panels.push({name:f,panel:b}),this.root&&this.root.appendChild(b.element()),b.refresh(),b}removePanel(f){const a=this.panels.findIndex(O=>O.name===f);if(a<0)return!1;const[p]=this.panels.splice(a,1),b=p.panel.element();return b&&b.parentNode&&b.parentNode.removeChild(b),V(p.panel.destroy)&&p.panel.destroy(),!0}refresh(){for(const f of this.panels)f.panel.refresh()}destroy(){for(const f of this.panels)V(f.panel.destroy)&&f.panel.destroy();this.panels=[],this.root&&_(this.root),this.root=null}}const s=new Map;function h(c,f){const a=f||"";let p=s.get(a);return p||(p=new Intl.NumberFormat(f||void 0,{maximumFractionDigits:0}),s.set(a,p)),p.format(Number(c)||0)}const u=new Map;function i(c,f){const a=f||"";let p=u.get(a);return p||(p=new Intl.NumberFormat(f||void 0,{maximumFractionDigits:3}),u.set(a,p)),p.format(Number(c)||0)}const m=r}),Fe("packages/dom/src/ui/contextmenu.js",function(e,K){"use strict";Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const Q=K("packages/dom/src/editors/common.js"),$=Q.CLS,B=Q.documentFor,I=Q.el,_=Q.on,X=Q.clear,H=K("packages/core/src/internal/util.js").isFunction,z=K("packages/dom/src/renderer/direction.js").isRtlElement,A=K("packages/dom/src/cell/icons.js").renderIconInto;function g(t,r){const s=[];for(const h of t||[]){const u=H(h)?h(r):h;if(u==null||u===!1)continue;if(u==="separator"){s.push({separator:!0});continue}if(typeof u=="string"){s.push({name:u});continue}const i=u,m=i.subMenu||i.children;m?s.push({...i,subMenu:g(m,r)}):s.push(i)}return s.filter((h,u,i)=>h.separator?u===0||u===i.length-1?!1:!i[u-1].separator:!0)}class l{root=null;itemNodes=[];items=[];focused=-1;child=null;off=[];open=!1;anchor=null;constructor(r){const s=r||{};this.doc=B(s),this.host=s.host||this.doc.body,this.ctx=s.ctx||{},this.onClose=s.onClose||null,this.parent=s.parent||null}place(r){const s=this.host,h=H(s.getBoundingClientRect)?s.getBoundingClientRect():{left:0,top:0},u=H(this.root.getBoundingClientRect)?this.root.getBoundingClientRect():{width:0,height:0},i=this.doc.defaultView||{innerWidth:0,innerHeight:0},m=i.innerWidth||0,c=i.innerHeight||0;let f=r.x||0,a=r.y||0;const p=z(s);if(r.anchor&&H(r.anchor.getBoundingClientRect)){const k=r.anchor.getBoundingClientRect();r.placement==="below"?(f=p?k.right-u.width:k.left,a=k.bottom):(f=p?k.left-u.width:k.right,a=k.top)}else p&&(f-=u.width);const b={left:Math.max(0,h.left||0),top:Math.max(0,h.top||0),right:Math.min(m||1/0,(h.left||0)+(h.width||1/0)),bottom:Math.min(c||1/0,(h.top||0)+(h.height||1/0))};f+u.width>b.right&&(f-=u.width),f<b.left&&(f=b.left),a+u.height>b.bottom&&(a-=u.height),a<b.top&&(a=b.top);const O=b.bottom-a;u.height>O&&(this.root.style.maxHeight=`${Math.max(0,Math.floor(O))}px`,this.root.style.overflowY="auto"),this.root.style.left=`${Math.round(f-h.left+(s.scrollLeft||0))}px`,this.root.style.top=`${Math.round(a-h.top+(s.scrollTop||0))}px`}show(r){return this.hide(),r.ctx&&(this.ctx={...this.ctx||{},...r.ctx}),this.items=g(r.items,this.ctx),this.returnFocus=r.returnFocus||null,this.anchor=r.anchor&&H(r.anchor.setAttribute)&&r.anchor.getAttribute&&r.anchor.getAttribute("aria-haspopup")?r.anchor:null,this.anchor&&this.anchor.setAttribute("aria-expanded","true"),this.root=I(this.doc,"div",{class:$.menu,attrs:{role:"menu",tabindex:"-1"},style:{position:"absolute"}}),this.itemNodes=[],this.items.forEach((s,h)=>{if(s.separator){this.root.appendChild(I(this.doc,"div",{class:$.menuSeparator,attrs:{role:"separator"}}));return}const u=I(this.doc,"div",{class:[$.menuItem,s.cssClass||""],attrs:{role:s.checked===void 0?"menuitem":"menuitemcheckbox",tabindex:"-1","aria-disabled":s.disabled?"true":null,"aria-checked":s.checked===void 0?null:String(s.checked===!0),"aria-haspopup":s.subMenu?"true":null,"aria-expanded":s.subMenu?"false":null,"data-index":h}});if(s.icon!=null&&s.icon!==""){const m=I(this.doc,"span",{class:$.icon});A(m,s.icon,`menu:${s.name||h}`),u.appendChild(m)}u.appendChild(I(this.doc,"span",{class:`${$.menuItem}__label`,text:s.name||""})),s.shortcut&&u.appendChild(I(this.doc,"span",{class:`${$.menuItem}__shortcut`,text:s.shortcut})),s.subMenu&&u.appendChild(I(this.doc,"span",{class:`${$.menuItem}__arrow`,text:"›"}));const i=this.itemNodes.length;this.off.push(_(u,"click",()=>this.invoke(i))),this.off.push(_(u,"mouseenter",()=>{this.focus(i),s.subMenu?this.openSubMenu(i):this.closeChild()})),this.itemNodes.push(u),this.root.appendChild(u)}),this.host.appendChild(this.root),this.place(r),this.open=!0,this.off.push(_(this.root,"keydown",s=>this.onKeyDown(s))),H(this.doc.addEventListener)&&this.off.push(_(this.doc,"mousedown",this.outside=s=>{this.root&&!o(this.root,s.target)&&!(this.child&&this.child.root&&o(this.child.root,s.target))&&this.hide()},!0)),H(this.root.focus)&&this.root.focus({preventScroll:!0}),this.focus(this.firstEnabled()),this.root}firstEnabled(){for(let r=0;r<this.itemNodes.length;r++)if(!this.itemAt(r).disabled)return r;return-1}itemAt(r){const s=this.itemNodes[r];return s?this.items[Number(s.getAttribute("data-index"))]||{}:{}}focus(r){if(r<0||r>=this.itemNodes.length)return;const s=this.itemNodes[this.focused];s&&s.classList.remove(`${$.menuItem}--focused`),this.focused=r;const h=this.itemNodes[r];h.classList.add(`${$.menuItem}--focused`),H(h.focus)&&h.focus(),H(h.scrollIntoView)&&h.scrollIntoView({block:"nearest",inline:"nearest"})}move(r){const s=this.itemNodes.length;if(!s)return;let h=this.focused;for(let u=0;u<s;u++)if(h=(h+r+s)%s,!this.itemAt(h).disabled){this.focus(h);return}}invoke(r){const s=this.itemAt(r);if(!(!s||s.disabled)){if(s.subMenu){this.openSubMenu(r);return}H(s.action)&&s.action({...this.ctx,item:s}),this.hideRoot()}}openSubMenu(r){const s=this.itemAt(r);s.subMenu&&(this.closeChild(),this.child=new l({document:this.doc,host:this.host,ctx:this.ctx,parent:this}),this.child.show({items:s.subMenu,anchor:this.itemNodes[r]}))}closeChild(){this.child&&(this.child.hide(),this.child=null)}onKeyDown(r){switch(r.key){case"ArrowDown":d(r),this.move(1);break;case"ArrowUp":d(r),this.move(-1);break;case"Home":d(r),this.focus(this.firstEnabled());break;case"End":d(r),this.focus(this.itemNodes.length-1);break;case"ArrowRight":d(r),this.openSubMenu(this.focused);break;case"ArrowLeft":d(r),this.parent&&(this.hide(),H(this.parent.root?.focus)&&this.parent.root.focus());break;case"Enter":case" ":d(r),this.invoke(this.focused);break;case"Escape":d(r),this.hideRoot();break;default:r.key&&r.key.length===1&&this.jumpTo(r.key);break}}jumpTo(r){const s=r.toLowerCase(),h=this.itemNodes.length;for(let u=1;u<=h;u++){const i=(this.focused+u+h)%h,m=this.itemAt(i);if(!m.disabled&&(m.name||"").toLowerCase().startsWith(s)){this.focus(i);return}}}hideRoot(){let r=this;for(;r.parent;)r=r.parent;r.hide()}hide(){this.closeChild();for(const r of this.off)r();this.off.length=0,this.root&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.root=null,this.itemNodes=[],this.focused=-1,this.anchor&&H(this.anchor.setAttribute)&&this.anchor.setAttribute("aria-expanded","false"),this.anchor=null,this.open&&this.returnFocus&&H(this.returnFocus.focus)&&this.returnFocus.focus(),this.open=!1,H(this.onClose)&&this.onClose()}destroy(){this.hide(),this.items=[]}}function d(t){H(t.preventDefault)&&t.preventDefault(),H(t.stopPropagation)&&t.stopPropagation()}function o(t,r){let s=r;for(;s;){if(s===t)return!0;s=s.parentNode}return!1}const n=l}),Fe("packages/dom/src/viewpicker.js",function(e,K){"use strict";Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const Q=K("packages/dom/src/editors/common.js"),$=Q.documentFor,B=Q.el,I=Q.on,_=Q.clear,W=K("packages/core/src/i18n/index.js").defaultMessages,V=K("packages/core/src/internal/util.js").isFunction,w=K("packages/dom/src/cell/icons.js").createIcon,A=Object.freeze({root:"lat-views",head:"lat-views__head",title:"lat-views__title",count:"lat-views__count",list:"lat-views__list",empty:"lat-views__empty",item:"lat-views__item",itemActive:"lat-views__item--active",itemEditing:"lat-views__item--editing",apply:"lat-views__apply",name:"lat-views__name",description:"lat-views__description",badges:"lat-views__badges",badge:"lat-views__badge",badgeDefault:"lat-views__badge--default",badgeShared:"lat-views__badge--shared",badgePrivate:"lat-views__badge--private",diff:"lat-views__diff",diffClean:"lat-views__diff--clean",actions:"lat-views__actions",action:"lat-views__action",actionIcon:"lat-views__action-icon",actionDanger:"lat-views__action--danger",confirm:"lat-views__confirm",foot:"lat-views__foot",input:"lat-views__input",save:"lat-views__save"});class g{root=null;off=[];host={};props={};editing=null;confirming=null;draft="";t(n,t){return(this.messages&&typeof this.messages.t=="function"?this.messages:W).t(n,t)}init(n){this.messages=n&&n.messages||n&&n.grid&&n.grid.messages||W;const t=n||{};this.doc=$(t),this.host=t.host||{},this.props=t.props||{},this.root=B(this.doc,"div",{class:A.root,attrs:{role:"group","aria-label":String(this.props.title||"Saved views")}}),this.refresh()}element(){return this.root}refresh(){const n=this.root;if(!n)return;for(const u of this.off)u();this.off.length=0,_(n),this.diffs=new Map;const t=this.views(),r=t.filter(u=>u.builtin),s=t.filter(u=>!u.builtin);r.length&&(n.appendChild(this.buildHead(String(this.props.builtinTitle||"Defined views"),r.length)),n.appendChild(this.buildList(r))),n.appendChild(this.buildHead(String(this.props.title||"Saved views"),s.length)),s.length?n.appendChild(this.buildList(s)):n.appendChild(B(this.doc,"p",{class:A.empty,text:String(this.props.emptyText||this.t("views.empty"))}));const h=this.buildFoot();h&&n.appendChild(h)}buildList(n){const t=B(this.doc,"div",{class:A.list,attrs:{role:"list"}});for(const r of n)t.appendChild(this.buildItem(r));return t}views(){const n=V(this.host.views)?this.host.views()||[]:[];return this.props.sort!=="name"?n:n.slice().sort((t,r)=>String(t.name||"").localeCompare(String(r.name||"")))}activeId(){return V(this.host.activeId)?this.host.activeId():null}buildHead(n,t){return B(this.doc,"div",{class:A.head,children:[B(this.doc,"span",{class:A.title,text:String(n)}),B(this.doc,"span",{class:A.count,text:String(t)})]})}buildItem(n){const t=String(n.id),r=this.activeId()===t,s=V(this.host.canEdit)?this.host.canEdit(n)!==!1:!0,h=B(this.doc,"div",{class:[A.item,r?A.itemActive:"",this.editing===t?A.itemEditing:""],attrs:{role:"listitem","data-view":t,"data-shared":n.shared?"true":"false"}});if(this.editing===t)return h.appendChild(this.buildRenameRow(n)),h;const u=B(this.doc,"button",{class:A.apply,attrs:{type:"button","aria-current":r?"true":null,title:[r?`${n.name} is applied`:`Apply ${n.name}`,n.shared?"Shared with everyone":"Private to you"].join(": ")},children:[B(this.doc,"span",{class:A.name,text:String(n.name||"")}),n.isDefault?this.buildBadges(n):null].filter(Boolean)});V(this.host.apply)?this.off.push(I(u,"click",()=>this.applyView(t))):u.setAttribute("disabled",""),n.description&&u.appendChild(B(this.doc,"span",{class:A.description,text:String(n.description)}));const i=this.buildDiff(t,r);return i&&u.appendChild(i),h.appendChild(u),n.builtin||h.appendChild(this.confirming===t?this.buildConfirm(n):this.buildActions(n,s)),h}buildBadges(n){const t=B(this.doc,"span",{class:A.badges});return n.isDefault&&t.appendChild(B(this.doc,"span",{class:[A.badge,A.badgeDefault],text:this.t("views.default"),attrs:{title:"Applied when the grid loads"}})),t}buildDiff(n,t){if(this.props.showDiff!==!0||!V(this.host.diff))return null;const r=this.diffOf(n);if(!r)return null;if(!r.changed)return B(this.doc,"span",{class:[A.diff,A.diffClean],text:this.t(t?"views.applied":"views.matchesGrid")});const s=l(r);return s.length?B(this.doc,"span",{class:A.diff,text:s.join(" · ")}):null}diffOf(n){if(!V(this.host.diff))return null;if(this.diffs.has(n))return this.diffs.get(n);let t=null;try{t=this.host.diff(n)}catch{t=null}return this.diffs.set(n,t),t}buildActions(n,t){const r=String(n.id),s=B(this.doc,"span",{class:A.actions});if(t&&V(this.host.rename)&&s.appendChild(this.buildAction("Rename",`Rename ${n.name}`,()=>{this.editing=r,this.confirming=null,this.refresh(),this.focusInput()},"pencil")),n.isDefault&&V(this.host.clearDefault)?s.appendChild(this.buildAction("Unset default",`Stop applying ${n.name} at load`,()=>{this.host.clearDefault(r),this.refresh()},"pin")):!n.isDefault&&V(this.host.setDefault)&&s.appendChild(this.buildAction("Make default",`Apply ${n.name} when the grid loads`,()=>{this.host.setDefault(r),this.refresh()},"pin")),V(this.host.export)&&s.appendChild(this.buildAction("Share",`Export ${n.name}`,()=>this.host.export(r),"share")),t&&V(this.host.remove)){const h=this.buildAction("Delete",`Delete ${n.name}`,()=>{this.confirming=r,this.refresh()},"trash");h.classList.add(A.actionDanger),s.appendChild(h)}return s}buildConfirm(n){const t=String(n.id),r=B(this.doc,"span",{class:A.confirm});r.appendChild(B(this.doc,"span",{text:this.t("views.confirmDelete",{name:n.name})}));const s=this.buildAction(this.t("views.delete"),this.t("views.confirmDeleteLabel",{name:n.name}),()=>{this.confirming=null,this.host.remove(t),this.refresh()});return s.classList.add(A.actionDanger),r.appendChild(s),r.appendChild(this.buildAction("Cancel","Keep this view",()=>{this.confirming=null,this.refresh()})),r}buildRenameRow(n){const t=String(n.id),r=B(this.doc,"span",{class:A.confirm}),s=B(this.doc,"input",{class:A.input,attrs:{type:"text","aria-label":`New name for ${n.name}`}});s.value=String(n.name||""),this.input=s;const h=()=>{const i=String(s.value||"").trim();this.editing=null,i&&i!==n.name&&this.host.rename(t,i),this.refresh()},u=()=>{this.editing=null,this.refresh()};return this.off.push(I(s,"keydown",i=>{i.key==="Enter"?h():i.key==="Escape"&&u()})),r.appendChild(s),r.appendChild(this.buildAction("Save","Save the new name",h)),r.appendChild(this.buildAction("Cancel","Leave the name alone",u)),r}buildFoot(){if(this.props.allowSave===!1||!V(this.host.saveAs))return null;const n=B(this.doc,"div",{class:A.foot}),t=B(this.doc,"input",{class:A.input,attrs:{type:"text",placeholder:this.t("views.namePlaceholder"),"aria-label":this.t("views.nameLabel")}});t.value=this.draft,this.editing===null&&(this.input=t);const r=()=>{const h=String(t.value||"").trim();if(!h){V(t.focus)&&t.focus();return}this.draft="",this.host.saveAs(h),this.refresh()};this.off.push(I(t,"input",()=>{this.draft=String(t.value||"")})),this.off.push(I(t,"keydown",h=>{h.key==="Enter"&&r()}));const s=B(this.doc,"button",{class:A.save,text:this.t("views.save"),attrs:{type:"button"}});return this.off.push(I(s,"click",r)),n.appendChild(t),n.appendChild(s),n}buildAction(n,t,r,s){const h=B(this.doc,"button",{class:A.action,text:s?null:n,attrs:{type:"button",title:t,"aria-label":t,"data-action":n}});return s&&h.appendChild(w(this.doc,s,{className:A.actionIcon})),this.off.push(I(h,"click",r)),h}applyView(n){this.confirming=null,this.host.apply(n),this.refresh()}focusInput(){const n=this.input;n&&V(n.focus)&&n.focus(),n&&V(n.select)&&n.select()}destroy(){for(const n of this.off)n();this.off.length=0,this.root=null,this.input=null,this.diffs=new Map}}function l(o,n=3){if(!o||!o.changed)return[];const t=o.counts||{},r=[],s=(h,u,i)=>{h&&r.push((h===1?u:i).replace("%",String(h)))};if(s(t.columnsHidden,"hides % column","hides % columns"),s(t.columnsShown,"shows % column","shows % columns"),s(t.columnsMoved,"moves % column","moves % columns"),s(t.columnsPinned,"repins % column","repins % columns"),s(t.columnsResized,"resizes % column","resizes % columns"),o.filters&&o.filters.changed){const h=t.filterColumns||0;r.push(h?`changes ${h} filter${h===1?"":"s"}`:"changes the filter")}return o.quick&&o.quick.changed&&r.push("changes the search"),o.sort&&o.sort.changed&&r.push("changes the sort"),o.group&&o.group.changed&&r.push("changes the grouping"),o.pivot&&o.pivot.changed&&r.push("changes the pivot"),s(t.columnsTotalled,"changes % total","changes % totals"),o.pagination&&o.pagination.changed&&r.push("changes the page size"),r.length<=n?r:[...r.slice(0,n),`and ${r.length-n} more`]}const d=g}),Fe("packages/dom/src/ui/panelbase.js",function(e,K){"use strict";Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return X}});const Q=K("packages/dom/src/editors/common.js"),$=Q.CLS,B=Q.el,_=K("packages/core/src/i18n/index.js").defaultMessages;class X{root=null;off=[];init(H){this.ctx=H,this.doc=H.document,this.host=H.host||{},this.props=H.props||{},this.root=B(this.doc,"div",{class:`${$.panel}__body`}),this.refresh()}t(H,V){const z=this.host||{};if(typeof z.t=="function")return z.t(H,V);const w=this.ctx||{};if(w.messages&&typeof w.messages.t=="function")return w.messages.t(H,V);const A=w.grid;return(A&&A.messages?A.messages:_).t(H,V)}element(){return this.root}refresh(){}destroy(){for(const H of this.off)H();this.off.length=0,this.root=null}}}),Fe("packages/dom/src/formattingpanel.js",function(e,K){"use strict";Object.defineProperty(e,"describeRule",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"FormattingPanel",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"createFormattingPanel",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return p}});const Q=K("packages/dom/src/editors/common.js"),$=Q.CLS,B=Q.documentFor,I=Q.el,_=Q.on,X=Q.clear,H=K("packages/core/src/internal/util.js").isFunction,z=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,w=K("packages/core/src/formatting/rules.js"),A=w.compileRules,g=w.summariseColumn,l=w.needsDistribution,d=w.DISTRIBUTION_LABELS,o="*",n=8,t=Object.freeze([{op:"gt",label:"greater than",values:1},{op:"gte",label:"at least",values:1},{op:"lt",label:"less than",values:1},{op:"lte",label:"at most",values:1},{op:"eq",label:"equal to",values:1},{op:"ne",label:"not equal to",values:1},{op:"between",label:"between",values:2},{op:"outside",label:"outside",values:2},{op:"contains",label:"contains",values:1},{op:"notContains",label:"does not contain",values:1},{op:"startsWith",label:"starts with",values:1},{op:"endsWith",label:"ends with",values:1},{op:"blank",label:"is blank",values:0},{op:"notBlank",label:"is not blank",values:0}]),r=Object.freeze([{op:"topPercent",label:d.topPercent,values:1},{op:"bottomPercent",label:d.bottomPercent,values:1},{op:"topN",label:d.topN,values:1},{op:"bottomN",label:d.bottomN,values:1},{op:"aboveMean",label:d.aboveMean,values:0},{op:"belowMean",label:d.belowMean,values:0},{op:"aboveMedian",label:d.aboveMedian,values:0},{op:"belowMedian",label:d.belowMedian,values:0},{op:"zAbove",label:d.zAbove,values:1},{op:"zBelow",label:d.zBelow,values:1},{op:"outlier",label:d.outlier,values:0}]),s=Object.freeze([...t,...r]),h=Object.freeze([{name:"Red",background:"#fbeceb",color:"#b03030"},{name:"Amber",background:"#fdf3e0",color:"#9a6400"},{name:"Green",background:"#e8f5ee",color:"#1a7f4b"},{name:"Blue",background:"#e7f0fb",color:"#1a6bc7"},{name:"Grey",background:"#f1f3f5",color:"#5b6570"}]),u=Object.freeze([{name:"White → Blue",colours:["#f8f9fa","#1a6bc7"]},{name:"White → Green",colours:["#f8f9fa","#1a7f4b"]},{name:"Red → Green",colours:["#d64545","#f6e58d","#1a7f4b"]},{name:"Blue → White → Red",colours:["#1a6bc7","#f8f9fa","#d64545"]}]),i=Object.freeze([{from:"minmax",label:"across the full range"},{from:"quantile",label:"across the middle 90%"},{from:"stddev",label:"within 2 deviations of the mean"}]);function m(b){const O=s.find(k=>k.op===b);return O?O.values:1}function c(b){if(!b)return"";if(b.scale){const{min:v,max:R,from:S}=b.scale;if(Number.isFinite(v)&&Number.isFinite(R))return`Colour scale, ${v} to ${R}`;const x=i.find(C=>C.from===S);return x?`Colour scale ${x.label}`:"Colour scale"}const O=b.when||{},k=s.find(v=>v.op===O.op),y=k?k.label:O.op;return!k||k.values===0?`Value ${y}`:k.values===2?`Value ${y} ${O.value} and ${O.value2}`:`Value ${y} ${O.value}`}class f extends z{scope=o;mode="condition";refresh(){const O=this.root;if(O){for(const k of this.off)k();this.off.length=0,X(O),O.appendChild(this.#o()),O.appendChild(this.#i()),O.appendChild(this.#l())}}#e(){const O=H(this.host.formattableColumns)?this.host.formattableColumns():[];return[{id:o,title:"All columns"},...O]}#t(){return H(this.host.formattingRules)?this.host.formattingRules(this.scope):[]}#n(O){if(!H(this.host.columnSamples))return[];const k=this.host.columnSamples(O);return Array.isArray(k)?k:[...k||[]]}#r(O,k,y){const v=l(O)?g(k):null;return A(O,v)({value:y})}#o(){const O=I(this.doc,"div",{class:`${$.panel}__row`});O.appendChild(I(this.doc,"label",{class:`${$.panel}__label`,text:this.t("formatting.format"),attrs:{for:"lat-fmt-scope"}}));const k=I(this.doc,"select",{class:`${$.panel}__select`,attrs:{id:"lat-fmt-scope"}});for(const y of this.#e()){const v=I(this.doc,"option",{text:y.title,attrs:{value:y.id}});y.id===this.scope&&v.setAttribute("selected","selected"),k.appendChild(v)}return k.value=this.scope,this.off.push(_(k,"change",()=>{this.scope=k.value||o,this.refresh()})),O.appendChild(k),O}#i(){const O=I(this.doc,"ul",{class:`${$.panel}__list`}),k=this.#t();if(!k.length)return O.appendChild(I(this.doc,"li",{class:`${$.panel}__empty`,text:this.t("formatting.noRules")})),O;k.forEach((R,S)=>{const x=I(this.doc,"li",{class:`${$.panel}__item`,attrs:{"data-rule":R.id}}),C=I(this.doc,"input",{attrs:{type:"checkbox","aria-label":`Enable ${c(R)}`}});C.checked=R.enabled!==!1,this.off.push(_(C,"change",()=>{this.#c("updateRule",this.scope,R.id,{enabled:C.checked})})),x.appendChild(C);const P=I(this.doc,"span",{class:`${$.panel}__swatch`}),F=R.style||{};if(F.background&&P.style&&P.style.setProperty)P.style.setProperty("background",String(F.background));else if(R.scale&&R.scale.colours&&P.style&&P.style.setProperty){const M=R.scale.colours;P.style.setProperty("background",`linear-gradient(90deg, ${M[0]}, ${M[M.length-1]})`)}x.appendChild(P),x.appendChild(I(this.doc,"span",{class:`${$.panel}__text`,text:c(R)}));const E=I(this.doc,"button",{class:`${$.panel}__icon`,text:"↑",attrs:{type:"button","aria-label":this.t("formatting.moveEarlier"),...S===0?{disabled:"disabled"}:{}}});this.off.push(_(E,"click",()=>this.#c("moveRule",this.scope,R.id,S-1))),x.appendChild(E);const D=I(this.doc,"button",{class:`${$.panel}__icon`,text:"↓",attrs:{type:"button","aria-label":this.t("formatting.moveLater"),...S===k.length-1?{disabled:"disabled"}:{}}});this.off.push(_(D,"click",()=>this.#c("moveRule",this.scope,R.id,S+1))),x.appendChild(D);const N=I(this.doc,"button",{class:`${$.panel}__icon`,text:"×",attrs:{type:"button","aria-label":`Remove ${c(R)}`}});this.off.push(_(N,"click",()=>this.#c("removeRule",this.scope,R.id))),x.appendChild(N),O.appendChild(x)});const y=this.#s(k);y&&O.appendChild(y);const v=I(this.doc,"button",{class:`${$.panel}__link`,text:this.t("formatting.clearAll"),attrs:{type:"button"}});return this.off.push(_(v,"click",()=>this.#c("clearRules",this.scope))),O.appendChild(v),O}#s(O){const k=this.#n(this.scope);if(!k.length)return null;const y=O.filter(R=>R.enabled!==!1);if(!y.length)return null;const v=I(this.doc,"div",{class:`${$.panel}__preview`,attrs:{"aria-label":this.t("formatting.preview")}});for(const R of k.slice(0,n)){const S=this.#r(y,k,R),x=I(this.doc,"span",{class:`${$.panel}__previewcell`,text:String(R)});S&&x.style&&x.style.setProperty&&(S.background&&x.style.setProperty("background",String(S.background)),S.color&&x.style.setProperty("color",String(S.color))),v.appendChild(x)}return v}#l(){const O=I(this.doc,"div",{class:`${$.panel}__form`}),k=I(this.doc,"select",{class:`${$.panel}__select`,attrs:{"aria-label":this.t("formatting.ruleKind")}});return k.appendChild(I(this.doc,"option",{text:this.t("formatting.aCondition"),attrs:{value:"condition"}})),k.appendChild(I(this.doc,"option",{text:this.t("formatting.aColourScale"),attrs:{value:"scale"}})),k.value=this.mode,this.off.push(_(k,"change",()=>{this.mode=k.value==="scale"?"scale":"condition",this.refresh()})),O.appendChild(k),this.mode==="scale"?O.appendChild(this.#u()):O.appendChild(this.#a()),O}#a(){const O=I(this.doc,"div",{class:`${$.panel}__form`}),k=I(this.doc,"select",{class:`${$.panel}__select`,attrs:{"aria-label":this.t("formatting.condition")}}),y=I(this.doc,"optgroup",{attrs:{label:this.t("formatting.compare")}});for(const N of t)y.appendChild(I(this.doc,"option",{text:N.label,attrs:{value:N.op}}));k.appendChild(y);const v=I(this.doc,"optgroup",{attrs:{label:this.t("formatting.distribution")}});for(const N of r)v.appendChild(I(this.doc,"option",{text:N.label,attrs:{value:N.op}}));k.appendChild(v),k.value="gt",O.appendChild(k);const R=I(this.doc,"input",{class:`${$.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.value")}}),S=I(this.doc,"input",{class:`${$.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.secondValue")}});O.appendChild(R),O.appendChild(S);const x=()=>{const N=m(k.value);R.style.setProperty("display",N>=1?"":"none"),S.style.setProperty("display",N>=2?"":"none"),E()};this.off.push(_(k,"change",x));const C=I(this.doc,"select",{class:`${$.panel}__select`,attrs:{"aria-label":this.t("menu.colour")}});for(const N of h)C.appendChild(I(this.doc,"option",{text:N.name,attrs:{value:N.name}}));C.value=h[0].name,O.appendChild(C);const P=I(this.doc,"div",{class:`${$.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});O.appendChild(P);const F=()=>{const N=h.find(L=>L.name===C.value)||h[0],M=m(k.value),j={op:k.value};return M>=1&&(j.value=R.value),M>=2&&(j.value2=S.value),{when:j,style:{background:N.background,color:N.color}}},E=()=>{X(P);const N=this.#n(this.scope);if(N.length)for(const M of N.slice(0,n)){const j=this.#r([F()],N,M),L=I(this.doc,"span",{class:`${$.panel}__previewcell`,text:String(M)});j&&L.style&&L.style.setProperty&&(j.background&&L.style.setProperty("background",String(j.background)),j.color&&L.style.setProperty("color",String(j.color))),P.appendChild(L)}};this.off.push(_(R,"input",E)),this.off.push(_(S,"input",E)),this.off.push(_(C,"change",E)),x();const D=I(this.doc,"button",{class:`${$.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(_(D,"click",()=>{this.#c("addRule",this.scope,F()),R.value="",S.value=""})),O.appendChild(D),O}#u(){const O=I(this.doc,"div",{class:`${$.panel}__form`}),k=I(this.doc,"select",{class:`${$.panel}__select`,attrs:{"aria-label":this.t("formatting.colourScale")}});for(const C of u)k.appendChild(I(this.doc,"option",{text:C.name,attrs:{value:C.name}}));k.value=u[0].name,O.appendChild(k);const y=I(this.doc,"select",{class:`${$.panel}__select`,attrs:{"aria-label":this.t("formatting.scaleBounds")}});for(const C of i)y.appendChild(I(this.doc,"option",{text:C.label,attrs:{value:C.from}}));y.value=i[0].from,O.appendChild(y);const v=I(this.doc,"div",{class:`${$.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});O.appendChild(v);const R=()=>{const C=u.find(P=>P.name===k.value)||u[0];return{scale:{from:y.value,colours:[...C.colours]}}},S=()=>{X(v);const C=this.#n(this.scope);if(C.length)for(const P of C.slice(0,n)){const F=this.#r([R()],C,P),E=I(this.doc,"span",{class:`${$.panel}__previewcell`,text:String(P)});F&&F.background&&E.style&&E.style.setProperty&&E.style.setProperty("background",String(F.background)),v.appendChild(E)}};this.off.push(_(k,"change",S)),this.off.push(_(y,"change",S)),S();const x=I(this.doc,"button",{class:`${$.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(_(x,"click",()=>{this.#c("addRule",this.scope,R())})),O.appendChild(x),O}#c(O,...k){H(this.host[O])&&this.host[O](...k),this.refresh()}}function a(b={}){const O=new f;return O.init({document:B(b),host:b.host||{}}),O}const p=f}),Fe("packages/dom/src/statisticspanel.js",function(e,K){"use strict";Object.defineProperty(e,"StatisticsPanel",{enumerable:!0,get:function(){return l}});const Q=K("packages/dom/src/editors/common.js"),$=Q.CLS,B=Q.el,I=Q.on,_=Q.clear,W=K("packages/core/src/internal/util.js").isFunction,V=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,z=Object.freeze([{key:"present",label:"stats.present",kind:"count"},{key:"missing",label:"stats.missing",kind:"count"},{key:"distinct",label:"stats.distinct",kind:"count"},{key:"min",label:"stats.min",kind:"value"},{key:"max",label:"stats.max",kind:"value"},{key:"mean",label:"stats.mean",kind:"value"},{key:"median",label:"stats.median",kind:"value"},{key:"q1",label:"stats.q1",kind:"value"},{key:"q3",label:"stats.q3",kind:"value"},{key:"iqr",label:"stats.iqr",kind:"value"},{key:"stddev",label:"stats.stddev",kind:"value"},{key:"outliers",label:"stats.outliers",kind:"count"}]),w=Object.freeze([{key:"present",label:"stats.present",kind:"count"},{key:"missing",label:"stats.missing",kind:"count"},{key:"distinct",label:"stats.distinct",kind:"count"}]),A=Object.freeze([{label:"stats.section.shape",kernels:["skewness","kurtosis","jarqueBera"]},{label:"stats.section.robust",kernels:["trimmedMean","winsorizedMean","mad","robustOutliers"]},{label:"stats.section.concentration",kernels:["gini","hhi","entropy","evenness","top3Share"]}]);function g(d){if(d==null||!Number.isFinite(d))return"—";if(Number.isInteger(d))return String(d);const o=Math.abs(d);return o!==0&&(o<.001||o>=1e7)?d.toExponential(2):String(Number(d.toPrecision(4)))}class l extends V{column=null;#e=0;#t(){return W(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const o=this.root;if(!o)return;for(const r of this.off)r();this.off.length=0,_(o);const n=this.#t();if(!n.length){o.appendChild(B(this.doc,"p",{class:`${$.panel}__empty`,text:this.t("stats.noColumns")}));return}n.some(r=>r.id===this.column)||(this.column=n[0].id),o.appendChild(this.#o(n));const t=W(this.host.columnProfile)?this.host.columnProfile(this.column):null;if(!t&&W(this.host.columnProfileAsync)){const r=B(this.doc,"p",{class:`${$.panel}__empty`,text:this.t("facets.computing")});o.appendChild(r);const s=++this.#e,h=this.column;Promise.resolve(this.host.columnProfileAsync(h)).then(u=>{if(s!==this.#e||this.root!==o||this.column!==h)return;const i=B(this.doc,"div",{});this.#n(i,u);for(const m of[...i.children])o.insertBefore(m,r);o.removeChild(r)},()=>{s!==this.#e||this.root!==o||(r.textContent=this.t("stats.noValues"))});return}this.#e++,this.#n(o,t)}#n(o,n){if(!n||!n.present){o.appendChild(B(this.doc,"p",{class:`${$.panel}__empty`,text:this.t("stats.noValues")}));const r=this.#r(n);r&&o.appendChild(r);return}if(o.appendChild(B(this.doc,"p",{class:`${$.panel}__count`,text:this.t("stats.filtered",{count:n.rows})})),Array.isArray(n.topValues)){o.appendChild(this.#l(n,w)),o.appendChild(this.#a(n.topValues));const r=this.#r(n);r&&o.appendChild(r);return}if(o.appendChild(this.#l(n)),n.computed!=="source"){for(const s of A){const h=this.#i(s);h&&o.appendChild(h)}const r=this.#s();r&&o.appendChild(r)}n.histogram&&n.histogram.length>1&&o.appendChild(this.#u(n.histogram));const t=this.#r(n);t&&o.appendChild(t)}#r(o){const n=o&&Array.isArray(o.unavailable)?o.unavailable:[];if(!n.length)return null;const t=this.doc.createElement("div");t.setAttribute("data-unavailable",""),t.appendChild(B(this.doc,"p",{class:`${$.panel}__count`,text:this.t("stats.unavailable",{stats:n.map(s=>s.stat).join(", ")})}));const r=B(this.doc,"dl",{class:`${$.panel}__stats`});for(const s of n)r.appendChild(B(this.doc,"dt",{class:`${$.panel}__stat-name`,text:s.stat})),r.appendChild(B(this.doc,"dd",{class:`${$.panel}__stat-value`,text:s.reasonKey?this.t(s.reasonKey,s.reasonParams):s.reason}));return t.appendChild(r),t}#o(o){const n=B(this.doc,"select",{class:`${$.panel}__select`,attrs:{"aria-label":this.t("stats.choose")}});for(const t of o){const r=B(this.doc,"option",{text:t.title,attrs:{value:t.id,selected:t.id===this.column?!0:null}});n.appendChild(r)}return n.value=this.column,this.off.push(I(n,"change",()=>{this.column=n.value,this.refresh()})),B(this.doc,"label",{class:`${$.panel}__field`,children:[B(this.doc,"span",{class:`${$.panel}__label`,text:this.t("stats.column")}),n]})}#i(o){const n=this.host.reduceColumn;if(!W(n)||!this.column)return null;const t=[];for(const h of o.kernels){const u=n(this.column,h);u==null||Number.isNaN(u)||t.push([h,u])}if(!t.length)return null;const r=this.doc.createElement("div");r.appendChild(B(this.doc,"h4",{class:`${$.panel}__subtitle`,text:this.t(o.label)}));const s=B(this.doc,"dl",{class:`${$.panel}__stats`});for(const[h,u]of t)s.appendChild(B(this.doc,"dt",{class:`${$.panel}__stat-name`,text:this.t(`total.${h}`)})),s.appendChild(B(this.doc,"dd",{class:`${$.panel}__stat-value`,text:typeof u=="number"?g(u):String(u)}));return r.appendChild(s),r}#s(){const o=this.host.columnCapability;if(!W(o)||!this.column)return null;const n=o(this.column);if(!n)return null;const t=this.doc.createElement("div");t.appendChild(B(this.doc,"h4",{class:`${$.panel}__subtitle`,text:this.t("stats.section.capability")}));const r=B(this.doc,"dl",{class:`${$.panel}__stats`}),s=[["stats.cp",n.cp,null],["stats.cpk",n.cpk,n.interval],["stats.pp",n.pp,null],["stats.ppk",n.ppk,n.intervalPp],["stats.outOfSpec",n.outOfSpec,null]];for(const[h,u,i]of s){if(u==null)continue;r.appendChild(B(this.doc,"dt",{class:`${$.panel}__stat-name`,text:this.t(h)}));const m=[B(this.doc,"span",{text:g(u)})];i&&Number.isFinite(i.lower)&&m.push(B(this.doc,"span",{class:`${$.panel}__stat-interval`,text:`${g(i.lower)} – ${g(i.upper)}`,attrs:{title:`${Math.round(i.confidence*100)}%`}})),r.appendChild(B(this.doc,"dd",{class:`${$.panel}__stat-value`,children:m}))}return t.appendChild(r),t}#l(o,n=z){const t=B(this.doc,"dl",{class:`${$.panel}__stats`});for(const r of n){const s=o[r.key];t.appendChild(B(this.doc,"dt",{class:`${$.panel}__stat-name`,text:this.t(r.label)})),t.appendChild(B(this.doc,"dd",{class:`${$.panel}__stat-value`,text:r.kind==="count"?String(s??0):g(s)}))}return t}#a(o){const n=this.doc.createElement("div");n.appendChild(B(this.doc,"h4",{class:`${$.panel}__subtitle`,text:this.t("stats.topValues")}));const t=B(this.doc,"dl",{class:`${$.panel}__stats`});for(const r of o)t.appendChild(B(this.doc,"dt",{class:`${$.panel}__stat-name`,text:String(r.value)})),t.appendChild(B(this.doc,"dd",{class:`${$.panel}__stat-value`,children:[B(this.doc,"span",{text:String(r.count)}),B(this.doc,"span",{class:`${$.panel}__stat-interval`,text:`${Math.round(r.share*100)}%`})]}));return n.appendChild(t),n}#u(o){const n=o.reduce((r,s)=>Math.max(r,s.count),0)||1,t=B(this.doc,"div",{class:`${$.panel}__histogram`});t.appendChild(B(this.doc,"h4",{class:`${$.panel}__subtitle`,text:this.t("stats.distribution")}));for(const r of o){const s=B(this.doc,"div",{class:`${$.panel}__bar`,style:{width:`${r.count?Math.max(2,r.count/n*100):0}%`}});t.appendChild(B(this.doc,"div",{class:`${$.panel}__bin`,attrs:{title:this.t("stats.bin",{count:r.count,from:g(r.from),to:g(r.to)})},children:[s]}))}return t}}}),Fe("packages/dom/src/regressionpanel.js",function(e,K){"use strict";Object.defineProperty(e,"RegressionPanel",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const Q=K("packages/dom/src/editors/common.js"),$=Q.CLS,B=Q.el,I=Q.clear,X=K("packages/core/src/internal/util.js").isFunction,H=K("packages/dom/src/ui/panelbase.js").ToolPanelBase;function V(A,g=4){const l=Number(A);return Number.isFinite(l)?l.toFixed(g):l===1/0?"∞":"—"}class z extends H{#e(){const g=this.props||{};if(Array.isArray(g.predictors)&&g.predictors.length&&g.response)return g;const l=this.ctx&&this.ctx.grid,d=l&&X(l.get)?l.get("regression"):null;return d&&Array.isArray(d.predictors)&&d.response?d:null}refresh(){const g=this.root;if(!g)return;I(g);const l=this.#e();if(!l){g.appendChild(B(this.doc,"p",{class:`${$.panel}__empty`,text:this.t("regression.noModel")}));return}const d=X(this.host.regressionModel)?this.host.regressionModel(l):null;if(!d){g.appendChild(B(this.doc,"p",{class:`${$.panel}__empty`,text:this.t("regression.cannotFit")}));return}g.appendChild(B(this.doc,"p",{class:`${$.panel}__count`,text:this.t("regression.observations",{count:d.n})})),g.appendChild(this.#t(d)),g.appendChild(this.#n(d));const o=this.#r(d,l);o&&g.appendChild(o),g.appendChild(this.#o(d))}#t(g){const l=B(this.doc,"dl",{class:`${$.panel}__stats`}),d=(o,n)=>{l.appendChild(B(this.doc,"dt",{class:`${$.panel}__stat-label`,text:o})),l.appendChild(B(this.doc,"dd",{class:`${$.panel}__stat-value`,text:n}))};return d(this.t("regression.r2"),V(g.r2,4)),d(this.t("regression.adjR2"),V(g.adjR2,4)),l}#n(g){const l=B(this.doc,"div",{class:`${$.panel}__section`});l.appendChild(B(this.doc,"h4",{class:`${$.panel}__heading`,text:this.t("regression.coefficients")}));const d=B(this.doc,"table",{class:`${$.panel}__coef-table`}),o=B(this.doc,"tr");for(const n of["regression.term","regression.estimate","regression.stdError","regression.t","regression.p"])o.appendChild(B(this.doc,"th",{text:this.t(n)}));d.appendChild(o);for(const n of g.coefficients){const t=B(this.doc,"tr");t.appendChild(B(this.doc,"td",{text:n.name})),t.appendChild(B(this.doc,"td",{text:`${V(n.estimate)} ± ${V(n.stdError)}`})),t.appendChild(B(this.doc,"td",{text:V(n.stdError)})),t.appendChild(B(this.doc,"td",{text:V(n.t,3)})),t.appendChild(B(this.doc,"td",{text:V(n.p,4)})),d.appendChild(t)}return l.appendChild(d),l}#r(g,l){if(!Array.isArray(g.vif)||g.vif.length<2)return null;const d=B(this.doc,"div",{class:`${$.panel}__section`});d.appendChild(B(this.doc,"h4",{class:`${$.panel}__heading`,text:this.t("regression.vif")}));const o=B(this.doc,"dl",{class:`${$.panel}__stats`});return g.vif.forEach((n,t)=>{o.appendChild(B(this.doc,"dt",{class:`${$.panel}__stat-label`,text:l.predictors[t]})),o.appendChild(B(this.doc,"dd",{class:`${$.panel}__stat-value`,text:V(n,3)}))}),d.appendChild(o),d}#o(g){const l=g.heteroscedasticity,d=B(this.doc,"div",{class:`${$.panel}__section`});return d.appendChild(B(this.doc,"h4",{class:`${$.panel}__heading`,text:this.t("regression.heteroscedasticity")})),l?(d.appendChild(B(this.doc,"p",{class:`${$.panel}__flag`,attrs:{"data-heteroscedastic":l.heteroscedastic?"true":"false"},text:this.t(l.heteroscedastic?"regression.heteroscedastic":"regression.homoscedastic",{statistic:V(l.statistic,3),p:V(l.p,4)})})),d):(d.appendChild(B(this.doc,"p",{class:`${$.panel}__empty`,text:this.t("regression.cannotFit")})),d)}}const w=z}),Fe("packages/dom/src/comparepanel.js",function(e,K){"use strict";Object.defineProperty(e,"ComparePanel",{enumerable:!0,get:function(){return A}});const Q=K("packages/dom/src/editors/common.js"),$=Q.CLS,B=Q.el,I=Q.on,_=Q.clear,W=K("packages/core/src/internal/util.js").isFunction,V=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,z=Object.freeze([{key:"pearson",label:"compare.pearson"},{key:"spearman",label:"compare.spearman"},{key:"kendall",label:"compare.kendall"},{key:"slope",label:"compare.slope"},{key:"intercept",label:"compare.intercept"},{key:"r2",label:"compare.r2"},{key:"stdError",label:"compare.stdError"},{key:"covariance",label:"compare.covariance"},{key:"weighted",label:"compare.weighted"}]);function w(g){if(g==null||!Number.isFinite(g))return"—";if(Number.isInteger(g))return String(g);const l=Math.abs(g);return l!==0&&(l<.001||l>=1e7)?g.toExponential(2):String(Number(g.toPrecision(4)))}class A extends V{first=null;second=null;#e(){return W(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const l=this.root;if(!l)return;for(const t of this.off)t();this.off.length=0,_(l);const d=this.#e();if(d.length<2){l.appendChild(B(this.doc,"p",{class:`${$.panel}__empty`,text:this.t("compare.needTwo")}));return}d.some(t=>t.id===this.first)||(this.first=d[0].id),(!d.some(t=>t.id===this.second)||this.second===this.first)&&(this.second=(d.find(t=>t.id!==this.first)||d[0]).id),l.appendChild(this.#t("compare.first",d,this.first,t=>{this.first=t,this.second===t&&(this.second=(d.find(r=>r.id!==t)||d[0]).id),this.refresh()})),l.appendChild(this.#t("compare.second",d,this.second,t=>{this.second=t,this.first===t&&(this.first=(d.find(r=>r.id!==t)||d[0]).id),this.refresh()}));const o=W(this.host.compareColumns)?this.host.compareColumns(this.first,this.second):null;if(!o||!o.n){l.appendChild(B(this.doc,"p",{class:`${$.panel}__empty`,text:this.t("compare.noPairs")}));return}l.appendChild(B(this.doc,"p",{class:`${$.panel}__count`,text:this.t("compare.pairs",{count:o.n})}));const n=B(this.doc,"dl",{class:`${$.panel}__stats`});for(const t of z){const r=o[t.key];r!=null&&(n.appendChild(B(this.doc,"dt",{class:`${$.panel}__stat-name`,text:this.t(t.label)})),n.appendChild(B(this.doc,"dd",{class:`${$.panel}__stat-value`,text:w(r)})))}l.appendChild(n)}#t(l,d,o,n){const t=B(this.doc,"select",{class:`${$.panel}__select`,attrs:{"aria-label":this.t(l)}});for(const r of d)t.appendChild(B(this.doc,"option",{text:r.title,attrs:{value:r.id,selected:r.id===o?!0:null}}));return t.value=o,this.off.push(I(t,"change",()=>n(t.value))),B(this.doc,"label",{class:`${$.panel}__field`,children:[B(this.doc,"span",{class:`${$.panel}__label`,text:this.t(l)}),t]})}}}),Fe("packages/dom/src/insightspanel.js",function(e,K){"use strict";Object.defineProperty(e,"InsightsPanel",{enumerable:!0,get:function(){return A}});const Q=K("packages/dom/src/editors/common.js"),$=Q.CLS,B=Q.el,I=Q.on,_=Q.clear,W=K("packages/core/src/internal/util.js").isFunction,V=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,z=Object.freeze([{key:"stats.cp",field:"cp",interval:null},{key:"stats.cpk",field:"cpk",interval:"interval"},{key:"stats.pp",field:"pp",interval:null},{key:"stats.ppk",field:"ppk",interval:"intervalPp"},{key:"stats.outOfSpec",field:"outOfSpec",interval:null}]);function w(g){if(g==null||!Number.isFinite(g))return"—";if(Number.isInteger(g))return String(g);const l=Math.abs(g);return l!==0&&(l<.001||l>=1e7)?g.toExponential(2):String(Number(g.toPrecision(4)))}class A extends V{column=null;by=null;#e(){return W(this.host.insightsColumns)?this.host.insightsColumns():[]}refresh(){const l=this.root;if(!l)return;for(const s of this.off)s();this.off.length=0,_(l);const d=this.#e();if(!d.length){l.appendChild(B(this.doc,"p",{class:`${$.panel}__empty`,text:this.t("insights.empty")}));return}const o=this.#t();o&&l.appendChild(o);const n=this.#n();n&&l.appendChild(n),l.appendChild(this.#o(d));const t=this.#s();t&&l.appendChild(t);const r=this.#u();r&&l.appendChild(r)}#t(){if(!W(this.host.subsetVsPopulation))return null;const l=this.host.subsetVsPopulation();if(!l)return null;const d=this.#c("insights.subset");return l.filtered?(d.appendChild(B(this.doc,"p",{class:`${$.panel}__count`,text:this.t("stats.filtered",{count:l.subsetN})})),d.appendChild(this.#r(l.ranked)),d):(d.appendChild(B(this.doc,"p",{class:`${$.panel}__empty`,text:this.t("insights.noFilter")})),d)}#n(){const l=this.props&&this.props.other;if(!l||!W(this.host.datasetVsDataset))return null;let d;try{d=this.host.datasetVsDataset(l)}catch{return null}if(!d||!d.ranked)return null;const o=this.#c("insights.dataset");return o.appendChild(this.#r(d.ranked)),o}#r(l){const d=B(this.doc,"dl",{class:`${$.panel}__stats`});for(const o of l||[]){const n=B(this.doc,"dt",{class:`${$.panel}__stat-name`});n.appendChild(B(this.doc,"span",{text:String(o.name??o.column)})),n.appendChild(B(this.doc,"span",{class:`${$.panel}__stat-interval`,text:String(o.measure||"")}));const t=B(this.doc,"dd",{class:`${$.panel}__stat-value`});t.appendChild(B(this.doc,"span",{text:w(o.magnitude)})),o.reliable===!1&&t.appendChild(B(this.doc,"span",{class:`${$.panel}__stat-interval`,text:this.t("insights.smallSample")})),d.appendChild(n),d.appendChild(t)}return d}#o(l){const d=this.#c("insights.groups");l.some(n=>n.id===this.column)||(this.column=l[0].id),(!l.some(n=>n.id===this.by)||this.by===this.column)&&(this.by=(l.find(n=>n.id!==this.column)||l[0]).id),d.appendChild(this.#d("stats.column",l,this.column,n=>{this.column=n,this.by===n&&(this.by=(l.find(t=>t.id!==n)||l[0]).id),this.refresh()})),d.appendChild(this.#d("insights.by",l,this.by,n=>{this.by=n,this.column===n&&(this.column=(l.find(t=>t.id!==n)||l[0]).id),this.refresh()}));const o=W(this.host.compareGroups)?this.host.compareGroups(this.column,{by:this.by}):null;return o?(d.appendChild(this.#i(o)),d):(d.appendChild(B(this.doc,"p",{class:`${$.panel}__empty`,text:this.t("insights.needGroups")})),d)}#i(l){const d=B(this.doc,"dl",{class:`${$.panel}__stats`});Array.isArray(l.groups)&&l.groups.length===2&&this.#a(d,"insights.groups",`${l.groups[0]} · ${l.groups[1]}`),this.#a(d,"insights.test",String(l.method||l.test||""));const o=l.effectSize||{};this.#a(d,"insights.effect",`${o.name||""} ${w(o.value)}`.trim());const n=l.interval;let t="—";if(n&&Number.isFinite(n.lower)&&Number.isFinite(n.upper)){const s=Number.isFinite(n.confidence)?` (${Math.round(n.confidence*100)}%)`:"";t=`${w(n.lower)} – ${w(n.upper)}${s}`}const r=this.#a(d,"insights.interval",t);return n&&n.method&&r.appendChild(B(this.doc,"span",{class:`${$.panel}__stat-interval`,text:String(n.method)})),Number.isFinite(l.pValue)&&this.#a(d,"insights.pValue",w(l.pValue)),d}#s(){if(!W(this.host.anomalies))return null;let l;try{l=this.host.anomalies()}catch{return null}if(!l)return null;const d=this.#c("insights.anomalies");d.appendChild(B(this.doc,"p",{class:`${$.panel}__count`,text:this.t("insights.anomalyCount",{count:l.flagged||0,n:l.n||0})}));const o=B(this.doc,"dl",{class:`${$.panel}__stats`});this.#a(o,"insights.anomalyMethod",String(l.method||""));const n=this.#l(l);n!==null&&this.#a(o,"insights.anomalyThreshold",w(n)),d.appendChild(o);const t=(l.rows||[]).map(r=>({name:r.rowKey!=null?String(r.rowKey):`#${r.index}`,measure:(r.why||[]).map(s=>s.name||s.column).join(", "),magnitude:r.score}));return d.appendChild(this.#r(t)),d}#l(l){if(l.method==="mahalanobis")return Number.isFinite(l.cutoff)?l.cutoff:null;if(l.method==="iqr")return Number.isFinite(l.k)?l.k:null;const d=Array.isArray(l.columns)?l.columns[0]:null;return d&&Number.isFinite(d.threshold)?d.threshold:null}#a(l,d,o){l.appendChild(B(this.doc,"dt",{class:`${$.panel}__stat-name`,text:this.t(d)}));const n=B(this.doc,"dd",{class:`${$.panel}__stat-value`});return n.appendChild(B(this.doc,"span",{text:o})),l.appendChild(n),n}#u(){if(!W(this.host.columnCapability)||!this.column)return null;const l=this.host.columnCapability(this.column);if(!l)return null;const d=this.#c("stats.section.capability"),o=B(this.doc,"dl",{class:`${$.panel}__stats`});for(const n of z){const t=l[n.field];if(t==null)continue;o.appendChild(B(this.doc,"dt",{class:`${$.panel}__stat-name`,text:this.t(n.key)}));const r=[B(this.doc,"span",{text:w(t)})],s=n.interval?l[n.interval]:null;s&&Number.isFinite(s.lower)&&r.push(B(this.doc,"span",{class:`${$.panel}__stat-interval`,text:`${w(s.lower)} – ${w(s.upper)}`,attrs:{title:`${Math.round(s.confidence*100)}%`}})),o.appendChild(B(this.doc,"dd",{class:`${$.panel}__stat-value`,children:r}))}return d.appendChild(o),d}#c(l){const d=this.doc.createElement("div");return d.appendChild(B(this.doc,"h4",{class:`${$.panel}__subtitle`,text:this.t(l)})),d}#d(l,d,o,n){const t=B(this.doc,"select",{class:`${$.panel}__select`,attrs:{"aria-label":this.t(l)}});for(const r of d)t.appendChild(B(this.doc,"option",{text:r.title,attrs:{value:r.id,selected:r.id===o?!0:null}}));return t.value=o,this.off.push(I(t,"change",()=>n(t.value))),B(this.doc,"label",{class:`${$.panel}__field`,children:[B(this.doc,"span",{class:`${$.panel}__label`,text:this.t(l)}),t]})}}}),Fe("packages/dom/src/ui/toolpanel.js",function(e,K){"use strict";Object.defineProperty(e,"ColumnsPanel",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"FiltersPanel",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"QuickFilterPanel",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"toolPanelTitles",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"toolPanelIcons",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return E}});const Q=K("packages/dom/src/editors/common.js"),$=Q.CLS,B=Q.cssEscape,I=Q.documentFor,_=Q.el,X=Q.on,W=Q.clear,V=K("packages/core/src/i18n/index.js").defaultMessages,z=K("packages/core/src/internal/util.js"),w=z.isFunction,A=z.nextFrame,g=K("packages/dom/src/cell/icons.js"),l=g.createIcon,d=g.updateIcon,o=g.icon,t=K("packages/dom/src/viewpicker.js").ViewPicker,s=K("packages/dom/src/formattingpanel.js").FormattingPanel,u=K("packages/dom/src/statisticspanel.js").StatisticsPanel,m=K("packages/dom/src/regressionpanel.js").RegressionPanel,f=K("packages/dom/src/comparepanel.js").ComparePanel,p=K("packages/dom/src/insightspanel.js").InsightsPanel,O=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,y=K("packages/core/src/compute/total.js").TOTAL_LABELS;class v extends O{dragging=null;collapsed=new Set;refresh(){const M=this.root;if(!M)return;for(const Y of this.off)Y();this.off.length=0,W(M);const j=_(this.doc,"input",{class:`${$.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.searchColumns"),"aria-label":this.t("panel.searchColumns")}});this.query&&(j.value=this.query),this.off.push(X(j,"input",()=>{this.query=j.value,this.paintList()})),M.appendChild(j),M.appendChild(this.buildZone("group","Row groups")),M.appendChild(this.buildZone("values","Grouped row calculation")),M.appendChild(this.buildZone("pivot","Pivot"));const L=_(this.doc,"div",{class:`${$.panel}__heading`});L.appendChild(_(this.doc,"span",{text:this.t("panel.columns")}));const G=_(this.doc,"button",{class:`${$.panel}__link`,text:this.t("panel.showAll"),attrs:{type:"button"}}),q=_(this.doc,"button",{class:`${$.panel}__link`,text:this.t("panel.hideAll"),attrs:{type:"button"}});this.off.push(X(G,"click",()=>{const Y=this.columns().filter(J=>!(J.layout&&J.layout.lockVisible)).map(J=>J.id);w(this.host.showColumns)&&this.host.showColumns(Y),this.refresh()})),this.off.push(X(q,"click",()=>{const Y=this.columns().filter(J=>!(J.layout&&J.layout.lockVisible)).map(J=>J.id);w(this.host.hideColumns)&&this.host.hideColumns(Y),this.refresh()})),L.appendChild(G),L.appendChild(q),M.appendChild(L),this.list=_(this.doc,"div",{class:`${$.panel}__columns`,attrs:{role:"group","aria-label":this.t("panel.columns")}}),M.appendChild(this.list),this.paintList()}columns(){const M=this.host;return w(M.columns)?M.columns()||[]:M.columns&&w(M.columns.all)?M.columns.all():[]}paintList(){const M=this.list;if(!M)return;W(M);const j=String(this.query||"").trim().toLowerCase();this.paintNodes(M,this.bandTree(),j)}paintNodes(M,j,L,G=!1){let q=0;for(const Y of j){if(Y.column){const he=String(Y.column.title||Y.column.id||"");if(L&&!G&&!he.toLowerCase().includes(L))continue;M.appendChild(this.buildColumnRow(Y.column)),q++;continue}const J=!!L&&this.bandTitle(Y.band).toLowerCase().includes(L),ee=_(this.doc,"div",{class:`${$.panel}__bandBody`}),ne=this.paintNodes(ee,Y.children,L,G||J);if(L&&!ne&&!J)continue;const ie=_(this.doc,"div",{class:`${$.panel}__band`,attrs:{role:"group","aria-label":this.bandTitle(Y.band),"data-band":Y.band.id}}),se=!this.collapsed.has(Y.band.id);ie.appendChild(this.buildBandRow(Y,se)),(se||L)&&ie.appendChild(ee),M.appendChild(ie),q++}return q}bandTree(){const M=this.columns(),j=new Map,L=this.host;if(w(L.columnGroups)){const Y=J=>{for(const ee of J||[])Array.isArray(ee.columns)&&(j.set(ee.id,ee.title),Y(ee.columns))};Y(L.columnGroups())}const G=[],q=new Map;for(const Y of M){let J=G,ee="";for(const ne of Y.groupPath||[]){ee+=`/${ne}`;let ie=q.get(ee);ie||(ie={band:{id:ne,title:j.has(ne)?j.get(ne):""},children:[],ids:[]},q.set(ee,ie),J.push(ie)),ie.ids.push(Y.id),J=ie.children}J.push({column:Y})}return G}bandTitle(M){return String(M.title||"")||this.t("columngroup.untitled")}buildColumnRow(M){const j=String(M.title||M.id||""),L=_(this.doc,"div",{class:`${$.panel}__column`,attrs:{"data-col":M.id,draggable:"true",title:this.t("panel.columnDragHint",{column:j})}});L.appendChild(_(this.doc,"span",{class:`${$.panel}__grip`,attrs:{"aria-hidden":"true"}}));const G=_(this.doc,"input",{attrs:{type:"checkbox","aria-label":j}});return G.checked=!(M.layout&&M.layout.hidden),M.layout&&M.layout.lockVisible&&G.setAttribute("disabled",""),this.off.push(X(G,"change",()=>this.setVisible(M.id,G.checked))),L.appendChild(G),L.appendChild(_(this.doc,"span",{text:j})),L.setAttribute("tabindex","0"),L.setAttribute("role","listitem"),this.off.push(X(L,"keydown",q=>this.onRowKey(q,M))),this.off.push(X(L,"dragstart",()=>{this.dragging=M.id})),this.off.push(X(L,"dragend",()=>{this.dragging=null,this.clearDropMark()})),this.off.push(X(L,"dragover",q=>{if(!this.dragging||this.dragging===M.id)return;if(w(q.preventDefault)&&q.preventDefault(),this.bandDrop(this.dragging,M)){L.setAttribute("data-drop","into");return}const J=D(q,L);L.setAttribute("data-drop",J?"before":"after")})),this.off.push(X(L,"dragleave",()=>L.removeAttribute("data-drop"))),this.off.push(X(L,"drop",q=>{w(q.preventDefault)&&q.preventDefault();const Y=this.dragging;if(this.dragging=null,this.clearDropMark(),!Y||Y===M.id)return;const J=this.bandDrop(Y,M);if(J==="leave"){this.leaveBand(Y);return}if(J){this.joinBand(Y,J);return}this.moveColumn(Y,M.id,D(q,L))})),L}bandOf(M){const j=typeof M=="string"?this.columns().find(G=>G.id===M):M,L=j&&j.groupPath||[];return L.length?L[L.length-1]:null}bandDrop(M,j){const L=this.host;if(!w(L.groupColumns))return null;const G=this.bandOf(M),q=this.bandOf(j);return q&&q!==G?q:G&&!q?"leave":null}joinBand(M,j){const L=this.columns().find(q=>q.id===M),G=this.titleOf(M);if(L&&L.layout&&L.layout.lockPosition){this.announce(this.t("a11y.column.cannotGroup",{column:G}),{repeat:!0});return}this.host.groupColumns([M],{groupId:j}),this.announce(this.t("a11y.column.addedToGroup",{column:G,group:this.bandName(j)}),{repeat:!0}),this.refresh()}leaveBand(M){w(this.host.ungroupColumn)&&(this.host.ungroupColumn(M),this.announce(this.t("a11y.column.removedFromGroup",{column:this.titleOf(M)}),{repeat:!0}),this.refresh())}bandName(M){const j=G=>{for(const q of G){if(!q.band)continue;if(q.band.id===M)return q.band;const Y=j(q.children);if(Y)return Y}return null},L=j(this.bandTree());return L?this.bandTitle(L):M}buildBandRow(M,j){const{band:L,ids:G}=M,q=this.bandTitle(L),Y=_(this.doc,"div",{class:`${$.panel}__bandRow`,attrs:{"data-band-row":L.id,tabindex:"0",role:"listitem","aria-label":q}}),J=_(this.doc,"button",{class:`${$.panel}__bandToggle`,attrs:{type:"button","aria-expanded":j?"true":"false","aria-label":this.t(j?"panel.bandCollapse":"panel.bandExpand",{band:q})},text:j?"▾":"▸"});this.off.push(X(J,"click",()=>this.toggleBand(L.id))),Y.appendChild(J);const ee=new Map(this.columns().map(ce=>[ce.id,ce])),ne=G.filter(ce=>!(ee.get(ce).layout&&ee.get(ce).layout.hidden)).length,ie=_(this.doc,"input",{attrs:{type:"checkbox","aria-label":this.t("panel.bandVisible",{band:q})}});ie.checked=ne===G.length,ie.indeterminate=ne>0&&ne<G.length,ne>0&&ne<G.length&&ie.setAttribute("aria-checked","mixed");const se=G.filter(ce=>!(ee.get(ce).layout&&ee.get(ce).layout.lockVisible));se.length||ie.setAttribute("disabled",""),this.off.push(X(ie,"change",()=>{const ce=this.host;ie.checked?w(ce.showColumns)&&ce.showColumns(se):w(ce.hideColumns)&&ce.hideColumns(se),this.refresh()})),Y.appendChild(ie);const he=_(this.doc,"span",{class:`${$.panel}__bandTitle`,text:q});if(Y.appendChild(he),w(this.host.renameGroup)){const ce=_(this.doc,"button",{class:`${$.panel}__link`,text:this.t("columngroup.rename"),attrs:{type:"button","aria-label":this.t("panel.bandRenameFor",{band:q})}});this.off.push(X(ce,"click",()=>this.startBandRename(Y,he,L))),Y.appendChild(ce)}if(w(this.host.dissolveGroup)){const ce=_(this.doc,"button",{class:`${$.panel}__link`,text:this.t("columngroup.dissolve"),attrs:{type:"button","aria-label":this.t("panel.bandDissolveFor",{band:q})}});this.off.push(X(ce,"click",()=>this.dissolveBand(L.id))),Y.appendChild(ce)}return this.off.push(X(Y,"keydown",ce=>this.onBandKey(ce,L,Y))),this.off.push(X(Y,"dragover",ce=>{!this.dragging||!w(this.host.groupColumns)||this.bandOf(this.dragging)===L.id||(w(ce.preventDefault)&&ce.preventDefault(),Y.setAttribute("data-drop","into"))})),this.off.push(X(Y,"dragleave",()=>Y.removeAttribute("data-drop"))),this.off.push(X(Y,"drop",ce=>{w(ce.preventDefault)&&ce.preventDefault();const te=this.dragging;this.dragging=null,this.clearDropMark(),!(!te||!w(this.host.groupColumns)||this.bandOf(te)===L.id)&&this.joinBand(te,L.id)})),Y}toggleBand(M){this.collapsed.has(M)?this.collapsed.delete(M):this.collapsed.add(M),this.paintList(),this.focusBand(M)}focusBand(M){const j=this.list&&this.list.querySelector?this.list.querySelector(`[data-band-row="${B(M)}"]`):null;j&&w(j.focus)&&j.focus()}dissolveBand(M){if(!w(this.host.dissolveGroup))return;const j=this.bandName(M);this.collapsed.delete(M),this.host.dissolveGroup(M),this.announce(this.t("a11y.group.dissolved",{group:j}),{repeat:!0}),this.refresh()}startBandRename(M,j,L){const G=_(this.doc,"input",{class:`${$.panel}__bandRename`,attrs:{type:"text","aria-label":this.t("columngroup.rename")}});G.value=L.title||"";let q=!1;const Y=J=>{q||(q=!0,J?(this.host.renameGroup(L.id,G.value),this.announce(this.t("a11y.group.renamed",{group:G.value}),{repeat:!0}),this.refresh()):this.paintList(),this.focusBand(L.id))};this.off.push(X(G,"keydown",J=>{J.key==="Enter"?(w(J.preventDefault)&&J.preventDefault(),Y(!0)):J.key==="Escape"&&(w(J.preventDefault)&&J.preventDefault(),Y(!1))})),this.off.push(X(G,"blur",()=>Y(!0))),j.parentNode&&j.parentNode.replaceChild(G,j),w(G.focus)&&G.focus(),w(G.select)&&G.select()}onBandKey(M,j,L){if(M.target&&M.target!==L)return;const G=M.key;G==="Enter"?(w(M.preventDefault)&&M.preventDefault(),this.toggleBand(j.id)):G==="Delete"?(w(M.preventDefault)&&M.preventDefault(),this.dissolveBand(j.id)):(G==="ArrowUp"||G==="ArrowDown")&&(w(M.preventDefault)&&M.preventDefault(),this.walk(L,G==="ArrowUp"))}walk(M,j){const L=this.list&&this.list.querySelectorAll?[...this.list.querySelectorAll("[data-col], [data-band-row]")]:[],G=L.indexOf(M),q=L[G+(j?-1:1)];q&&w(q.focus)&&q.focus()}onRowKey(M,j){const L=M&&M.key,G=v.zoneKeys[String(L).toLowerCase()];if(G&&!M.ctrlKey&&!M.metaKey&&!M.altKey){w(M.preventDefault)&&M.preventDefault(),this.toggleZone(G,j);return}if(L!=="ArrowUp"&&L!=="ArrowDown")return;const q=L==="ArrowUp",Y=this.columns().map(he=>he.id),J=Y.indexOf(j.id);if(J<0)return;if(w(M.preventDefault)&&M.preventDefault(),!M.shiftKey){const he=this.list&&this.list.querySelectorAll?[...this.list.querySelectorAll("[data-col], [data-band-row]")]:[],ce=he.findIndex(oe=>oe.getAttribute("data-col")===j.id),te=he[ce+(q?-1:1)];te&&w(te.focus)&&te.focus();return}const ee=j.layout&&(j.layout.movable===!1||j.layout.lockPosition),ne=String(j.title||j.id||"");if(ee){this.announce(this.t("a11y.panel.cannotMove",{column:ne}),{repeat:!0});return}const ie=Y[J+(q?-1:1)];if(!ie){this.announce(this.t(q?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:ne}),{repeat:!0});return}this.moveColumn(j.id,ie,q),this.announce(this.t("a11y.panel.moved",{column:ne,at:q?J:J+2,of:Y.length}),{repeat:!0});const se=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${B(j.id)}"]`):null;se&&w(se.focus)&&se.focus()}toggleZone(M,j){const L=this.titleOf(j.id),G=this.t(v.zoneLabel[M]||"panel.zone.group");if(this.zoneColumns(M).includes(j.id)){this.dropFromZone(M,j.id),this.announce(this.t("a11y.panel.removedFrom",{column:L,list:G}),{repeat:!0}),this.restoreFocus(j.id);return}if(this.addToZone(M,j.id)){this.announce(this.t("a11y.panel.addedTo",{column:L,list:G}),{repeat:!0}),this.restoreFocus(j.id);return}this.announce(this.t("a11y.panel.cannotAddTo",{column:L,list:G}),{repeat:!0})}restoreFocus(M){const j=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${B(M)}"]`):null;j&&w(j.focus)&&j.focus()}announce(M,j){const L=this.host||{};w(L.announce)&&L.announce(M,j)}clearDropMark(){if(!(!this.list||!this.list.querySelectorAll))for(const M of this.list.querySelectorAll("[data-drop]"))M.removeAttribute("data-drop")}moveColumn(M,j,L){const G=this.host||{};w(G.moveColumn)&&(G.moveColumn(M,j,L),this.refresh())}buildZone(M,j){const L=_(this.doc,"div",{class:`${$.panel}__zone`,attrs:{"data-zone":M,role:"group","aria-label":j}});L.appendChild(_(this.doc,"div",{class:`${$.panel}__zoneTitle`,text:j}));const G=this.zoneColumns(M);let q=v.zoneAbout[M]||"";M==="values"&&G.length&&!this.zoneColumns("group").length&&(q+=" Add a row group to see them."),q&&L.appendChild(_(this.doc,"div",{class:`${$.panel}__zoneAbout`,text:q}));const Y=_(this.doc,"div",{class:`${$.panel}__zoneBody`});G.length||Y.appendChild(_(this.doc,"span",{class:`${$.panel}__zoneHint`,text:this.t(v.zoneHint[M]||"panel.zoneHint.any")})),M==="values"&&Y.classList.add(`${$.panel}__zoneBody--rows`);for(const J of G){const ee=_(this.doc,"span",{class:[$.chip,M==="values"?`${$.chip}--row`:""]});if(ee.appendChild(_(this.doc,"span",{class:`${$.chip}__label`,text:this.titleOf(J)})),M==="values"&&w(this.host.setValueAggregation)){const ie=w(this.host.valueAggregation)?this.host.valueAggregation(J):"sum",se=_(this.doc,"select",{class:`${$.chip}__fn`,attrs:{"aria-label":`Calculation for ${this.titleOf(J)}`}});for(const he of v.aggregations)se.appendChild(_(this.doc,"option",{text:this.t(`total.${he.name}`),attrs:{value:he.name,selected:he.name===ie?"":null}}));se.value=ie,this.off.push(X(se,"change",()=>{this.host.setValueAggregation(J,se.value),this.refresh()})),ee.appendChild(se)}const ne=_(this.doc,"button",{class:$.chipRemove,text:"×",attrs:{type:"button","aria-label":`Remove ${this.titleOf(J)}`}});this.off.push(X(ne,"click",()=>this.dropFromZone(M,J))),ee.appendChild(ne),Y.appendChild(ee)}return this.off.push(X(L,"dragover",J=>{w(J.preventDefault)&&J.preventDefault(),L.setAttribute("data-over","true")})),this.off.push(X(L,"dragleave",()=>L.removeAttribute("data-over"))),this.off.push(X(L,"drop",J=>{w(J.preventDefault)&&J.preventDefault(),L.removeAttribute("data-over"),this.dragging&&this.addToZone(M,this.dragging)})),L.appendChild(Y),L}static aggregations=Object.freeze(Object.keys(y).map(M=>({name:M})));static zoneAbout=Object.freeze({group:"Rows are grouped by these columns, in order.",values:"Each column here is calculated for every group. Pick the calculation on its chip.",pivot:"Generates a column for each distinct value."});static zoneHint=Object.freeze({group:"panel.zoneHint.group",values:"panel.zoneHint.values",pivot:"panel.zoneHint.pivot"});static zoneKeys=Object.freeze({g:"group",v:"values",p:"pivot"});static zoneLabel=Object.freeze({group:"panel.zone.group",values:"panel.zone.values",pivot:"panel.zone.pivot"});static zoneApi=Object.freeze({group:{read:"groupBy",write:"setGroupBy",permission:"allowGroup"},values:{read:"valueColumns",write:"setValueColumns",permission:"allowTotal"},pivot:{read:"pivotBy",write:"setPivotBy",permission:"allowPivot"}});zoneColumns(M){const j=v.zoneApi[M],L=this.host;return j&&w(L[j.read])?L[j.read]()||[]:[]}titleOf(M){const j=this.columns().find(L=>L.id===M);return String(j&&(j.title||j.id)||M)}addToZone(M,j){const L=v.zoneApi[M],G=this.columns().find(Y=>Y.id===j);if(!L||!G||G[L.permission]===!1||!w(this.host[L.write]))return!1;const q=this.zoneColumns(M);return q.includes(j)?!1:(this.host[L.write]([...q,j]),this.refresh(),!0)}dropFromZone(M,j){const L=v.zoneApi[M];return!L||!w(this.host[L.write])?!1:(this.host[L.write](this.zoneColumns(M).filter(G=>G!==j)),this.refresh(),!0)}setVisible(M,j){const L=this.host;j&&w(L.showColumns)?L.showColumns([M]):!j&&w(L.hideColumns)&&L.hideColumns([M])}}class R extends O{open=new Set;query="";#e=!1;#t=!1;refresh(){if(this.#e){this.#t=!0;return}this.#e=!0;try{do this.#t=!1,this.#n();while(this.#t)}finally{this.#e=!1}}#n(){const M=this.root;if(!M)return;for(const ee of this.off)ee();this.off.length=0,W(M);const j=this.host,L=(w(j.columns)?j.columns():[]).filter(ee=>!(ee.filter&&ee.filter.enabled===!1));if(!w(j.filterFor))return;const G=L.filter(ee=>this.isFiltered(ee.id));M.appendChild(this.buildSearch()),M.appendChild(this.buildSummary(G.length,L.length));const q=this.query.trim().toLowerCase(),Y=q?L.filter(ee=>String(ee.title||ee.id).toLowerCase().includes(q)):L;if(!Y.length){M.appendChild(_(this.doc,"p",{class:`${$.panel}__empty`,text:q?this.t("panel.filterEmptyNoMatch",{query:this.query.trim()}):this.t("panel.filterEmptyNone")}));return}const J=_(this.doc,"div",{class:`${$.panel}__filters`});for(const ee of Y)J.appendChild(this.buildSection(ee));M.appendChild(J)}isFiltered(M){const j=this.host;return w(j.isFiltered)?j.isFiltered(M)===!0:!1}buildSearch(){const M=_(this.doc,"input",{class:`${$.panel}__search`,attrs:{type:"text",placeholder:this.t("panel.searchColumnsPlaceholder"),"aria-label":this.t("panel.searchColumnsToFilter")}});return M.value=this.query,this.off.push(X(M,"input",()=>{this.query=M.value||"",this.refresh();const j=this.root&&this.root.querySelector?this.root.querySelector(`.${$.panel}__search`):null;j&&w(j.focus)&&j.focus()})),M}buildSummary(M,j){const L=_(this.doc,"div",{class:`${$.panel}__filterSummary`});if(L.appendChild(_(this.doc,"span",{class:`${$.panel}__filterCount`,text:M?this.t("panel.filterSummaryActive",{active:M,total:j}):this.t("panel.filterSummaryNone",{total:j}),attrs:{"data-active":M?"true":"false"}})),!M)return L;const G=_(this.doc,"button",{class:`${$.panel}__clearAll`,text:this.t("panel.clearAll"),attrs:{type:"button"}});return this.off.push(X(G,"click",()=>{w(this.host.clearAllFilters)&&this.host.clearAllFilters(),this.refresh()})),L.appendChild(G),L}buildSection(M){const j=M.id,L=String(M.title||j),G=this.isFiltered(j),q=this.open.has(j),Y=_(this.doc,"section",{class:`${$.panel}__filter`,attrs:{"data-col":j,"data-filtered":G?"true":null}}),J=_(this.doc,"button",{class:`${$.panel}__filterTitle`,attrs:{type:"button","aria-expanded":q?"true":"false",title:this.t(G?"panel.filteredBy":"panel.filterBy",{column:L})},children:[l(this.doc,q?"chevronDown":"chevronRight",{className:`${$.panel}__twisty`}),_(this.doc,"span",{class:`${$.panel}__filterName`,text:L})]});G&&J.appendChild(_(this.doc,"span",{class:`${$.panel}__filterDot`,attrs:{"aria-label":this.t("panel.columnFiltered"),title:this.t("panel.columnFiltered")}}));const ee=_(this.doc,"div",{class:`${$.panel}__filterBody`,style:{display:q?"":"none"}}),ne=()=>{if(ee.firstChild)return;const ie=this.host.filterFor(j);ie&&w(ie.element)&&ee.appendChild(ie.element())};if(this.off.push(X(J,"click",()=>{const ie=this.open.has(j);ie?this.open.delete(j):this.open.add(j),J.setAttribute("aria-expanded",ie?"false":"true"),ee.style.display=ie?"none":"";const se=J.firstElementChild;se&&d(se,ie?"chevronRight":"chevronDown"),ie||ne()})),Y.appendChild(J),G){const ie=_(this.doc,"button",{class:`${$.panel}__filterClear`,attrs:{type:"button","aria-label":this.t("panel.clearFilterOn",{column:L}),title:this.t("panel.clearFilter")},children:[l(this.doc,"close",{className:$.icon})]});this.off.push(X(ie,"click",se=>{w(se.stopPropagation)&&se.stopPropagation(),w(this.host.clearFilter)&&this.host.clearFilter(j),this.refresh()})),Y.appendChild(ie)}return Y.appendChild(ee),q&&ne(),Y}}class S extends O{refresh(){const M=this.root;if(!M)return;if(this.box){const q=w(this.host.quickFilter)?this.host.quickFilter():"";this.doc&&this.doc.activeElement!==this.box&&this.box.value!==q&&(this.box.value=q),this.paintCount();return}for(const q of this.off)q();this.off.length=0,W(M);const j=w(this.host.quickFilter)?this.host.quickFilter():"",L=_(this.doc,"input",{class:`${$.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.filterAllColumns"),"aria-label":this.t("panel.quickFilter")}});L.value=j||"",this.off.push(X(L,"input",()=>{w(this.host.setQuickFilter)&&this.host.setQuickFilter(L.value),this.paintCount()})),M.appendChild(L),this.box=L;const G=_(this.doc,"button",{class:`${$.panel}__link`,text:this.t("panel.clear"),attrs:{type:"button"}});this.off.push(X(G,"click",()=>{L.value="",w(this.host.setQuickFilter)&&this.host.setQuickFilter(""),this.paintCount(),w(L.focus)&&L.focus()})),M.appendChild(G),this.count=_(this.doc,"p",{class:`${$.panel}__count`}),M.appendChild(this.count),this.paintCount()}destroy(){this.box=null,this.count=null,super.destroy()}focus(){A(()=>{this.box&&w(this.box.focus)&&this.box.focus()})}paintCount(){if(!this.count)return;const M=w(this.host.rowCount)?this.host.rowCount():null,j=w(this.host.totalRowCount)?this.host.totalRowCount():null;if(M===null||j===null||M===void 0){this.count.textContent="";return}this.count.textContent=M===j?this.t("count.rows",{count:j}):this.t("panel.rowsOf",{shown:M,total:j})}}const x=Object.freeze({columns:v,filters:R,views:t,quick:S,formatting:s,statistics:u,regression:m,compare:f,insights:p}),C=Object.freeze({columns:"panel.columns",filters:"panel.filters",views:"panel.views",quick:"panel.quickFilter",formatting:"panel.formatting",statistics:"panel.statistics",regression:"panel.regression",compare:"panel.compare",insights:"panel.insights"}),P=Object.freeze({columns:"columns",filters:"filter",views:"views",quick:"search",formatting:"palette",statistics:"chart",regression:"chart",compare:"link",insights:"chart"});class F{panels=[];actions=[];root=null;openPanel=null;off=[];t(M,j){return(this.messages&&typeof this.messages.t=="function"?this.messages:V).t(M,j)}init(M){const j=M||{};this.doc=I(j),this.host=j.host||{},this.messages=j.messages||j.grid&&j.grid.messages||V,this.icons=j.icons===void 0?j.side==="left":!!j.icons,this.side=j.side==="left"?"left":"right",this.root=_(this.doc,"div",{class:[$.panel,`${$.panel}--${this.side}`,this.icons?`${$.panel}--icons`:null]}),this.tabs=_(this.doc,"div",{class:`${$.panel}__tabs`,attrs:{role:"tablist"}}),this.body=_(this.doc,"div",{class:`${$.panel}__content`}),this.side==="left"?(this.root.appendChild(this.tabs),this.root.appendChild(this.body)):(this.root.appendChild(this.body),this.root.appendChild(this.tabs)),this.actionGroup=_(this.doc,"div",{class:`${$.panel}__actions`,attrs:{role:"group","aria-label":this.t("panel.gridActions")}}),this.tabs.appendChild(this.actionGroup);for(const q of Array.isArray(j.actions)?j.actions:[])this.registerAction(q);const L=j.registry||{},G=Array.isArray(j.panels)&&j.panels.length?j.panels:["columns","filters"];for(const q of G){const Y=typeof q=="string"?q:q.name,J=typeof q=="function"?q:L[Y]||x[Y];J&&this.registerPanel(String(Y),J,typeof q=="object"?q:{})}j.openPanel&&this.show(j.openPanel)}registerPanel(M,j,L){const G=new j;G.init({document:this.doc,host:this.host,props:L&&L.props||{}});const q=L&&L.title||M,Y=L&&L.icon||M,J=_(this.doc,"button",{class:`${$.panel}__tab`,text:this.icons?null:q,attrs:{type:"button",role:"tab","aria-selected":"false","data-panel":M,title:this.icons?q:null,"aria-label":this.icons?q:null}});return this.icons&&J.appendChild(l(this.doc,Y,{className:`${$.panel}__icon`})),this.off.push(X(J,"click",()=>this.toggle(M))),this.tabs.appendChild(J),this.panels.push({name:M,title:q,panel:G}),G}registerAction(M){if(!M||!M.name)return null;if(M.separator)return this.actionGroup.appendChild(_(this.doc,"div",{class:`${$.panel}__divider`,attrs:{"aria-hidden":"true"}})),null;const j=_(this.doc,"button",{class:`${$.panel}__action`,text:this.icons?null:w(M.title)?String(M.title()):M.title,attrs:{type:"button","data-action":M.name,title:w(M.title)?null:M.title,"aria-label":w(M.title)?null:M.title}});if(this.icons){const q=(w(M.icon)?M.icon():M.icon)||(o(M.name)?M.name:"blank");j.appendChild(l(this.doc,q,{className:`${$.panel}__icon`})),j.setAttribute("data-icon",q)}const L=X(j,"click",()=>{w(M.enabled)&&!M.enabled()||(w(M.run)&&M.run(),this.paintActions())});return this.off.push(L),this.actionGroup.appendChild(j),this.actions.push({...M,button:j,offClick:L}),this.paintActions(),j}removeAction(M){const j=this.actions.findIndex(G=>G.name===M);if(j<0)return!1;const L=this.actions[j];return w(L.offClick)&&L.offClick(),L.button&&L.button.parentNode&&L.button.parentNode.removeChild(L.button),this.actions.splice(j,1),!0}paintActions(){for(const M of this.actions){if(!M.button)continue;const j=w(M.enabled)?!!M.enabled():!0;if(M.button.disabled=!j,M.button.setAttribute("aria-disabled",j?"false":"true"),w(M.active)&&M.button.setAttribute("aria-pressed",M.active()?"true":"false"),w(M.title)){const L=String(M.title());M.button.setAttribute("title",L),M.button.setAttribute("aria-label",L),!this.icons&&M.button.textContent!==L&&(M.button.textContent=L)}if(this.icons&&w(M.icon)){const L=String(M.icon());M.button.getAttribute("data-icon")!==L&&(W(M.button),M.button.appendChild(l(this.doc,L,{className:`${$.panel}__icon`})),M.button.setAttribute("data-icon",L))}}}show(M){const j=this.panels.find(L=>L.name===M);return j?(W(this.body),w(j.panel.refresh)&&j.panel.refresh(),this.body.appendChild(j.panel.element()),this.openPanel=M,this.paintTabs(),w(j.panel.focus)&&j.panel.focus(),!0):!1}hide(){W(this.body),this.openPanel=null,this.paintTabs()}toggle(M){this.openPanel===M?this.hide():this.show(M)}paintTabs(){if(!(!this.tabs||!this.tabs.childNodes))for(let M=0;M<this.tabs.childNodes.length;M++){const j=this.tabs.childNodes[M];j&&j.setAttribute&&j.setAttribute("aria-selected",j.getAttribute("data-panel")===this.openPanel?"true":"false")}}element(){return this.root}refresh(){const M=this.panels.find(j=>j.name===this.openPanel);M&&w(M.panel.refresh)&&!this.#e(M.panel)&&M.panel.refresh(),this.paintActions()}#e(M){const j=this.doc&&this.doc.activeElement;if(!j||j===this.doc.body)return!1;const L=w(M.element)?M.element():null;return!!(L&&w(L.contains)&&L.contains(j))}destroy(){for(const M of this.off)M();this.off.length=0;for(const M of this.panels)w(M.panel.destroy)&&M.panel.destroy();this.panels=[],this.root=null}}const E=F;function D(N,M){if(!M.getBoundingClientRect||typeof N.clientY!="number")return!0;const j=M.getBoundingClientRect();return N.clientY<j.top+j.height/2}}),Fe("packages/dom/src/ui/groupbyzone.js",function(e,K){"use strict";Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return A}});const $=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,B=K("packages/dom/src/editors/common.js"),I=B.CLS,_=B.el,X=B.on,W=B.clear,H=B.cssEscape,z=K("packages/core/src/internal/util.js").isFunction,w="text/x-lattice-col";class A extends ${dragging=null;#e=[];init(l){this.ctx=l,this.doc=l.document,this.host=l.host||{},this.props=l.props||{},this.root=_(this.doc,"div",{class:I.groupZone,attrs:{role:"group","aria-label":this.t("groupZone.label")}}),this.refresh()}columns(){const l=this.host;return z(l.columns)?l.columns()||[]:l.columns&&z(l.columns.all)?l.columns.all():[]}groups(){return z(this.host.groupBy)?this.host.groupBy()||[]:[]}setGroups(l){z(this.host.setGroupBy)&&this.host.setGroupBy(l)}titleOf(l){const d=this.columns().find(o=>o.id===l);return String(d&&(d.title||d.id)||l)}canGroup(l){const d=this.columns().find(o=>o.id===l);return!!d&&d.allowGroup!==!1&&!d.generated}announce(l,d){z(this.host.announce)&&this.host.announce(l,d)}refresh(){const l=this.root;if(!l)return;for(const n of this.off)n();this.off.length=0,W(l),l.appendChild(_(this.doc,"span",{class:I.groupZoneTitle,text:this.t("groupZone.title"),attrs:{"aria-hidden":"true"}}));const d=this.groups(),o=_(this.doc,"div",{class:I.groupZoneChips,attrs:{role:"listbox","aria-orientation":"horizontal","aria-label":this.t("groupZone.label")}});d.length||o.appendChild(_(this.doc,"span",{class:I.groupZoneHint,text:this.t("groupZone.hint")})),d.forEach((n,t)=>o.appendChild(this.#t(n,t,d.length))),l.appendChild(o),this.chips=o,l.appendChild(this.#i(d)),this.off.push(X(l,"dragover",n=>{this.dragging==null&&!this.#l(n)||(z(n.preventDefault)&&n.preventDefault(),l.setAttribute("data-over","true"))})),this.off.push(X(l,"dragleave",()=>l.removeAttribute("data-over"))),this.off.push(X(l,"drop",n=>{z(n.preventDefault)&&n.preventDefault(),l.removeAttribute("data-over");const t=this.#l(n)||this.dragging;t!=null&&this.#o(t,this.groups().length)})),this.#s()}#t(l,d,o){const n=this.titleOf(l),t=_(this.doc,"div",{class:[I.chip,I.groupZoneChip],attrs:{role:"option","aria-selected":"true",tabindex:"0",draggable:"true","data-col":l,"aria-label":this.t("groupZone.chip",{column:n,at:d+1,of:o})}});t.appendChild(_(this.doc,"span",{class:I.groupZoneChipText,text:n}));const r=_(this.doc,"button",{class:I.chipRemove,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("groupZone.remove",{column:n})}});return this.off.push(X(r,"click",()=>this.#r(l))),t.appendChild(r),this.off.push(X(t,"dragstart",s=>{this.dragging=l,s.dataTransfer&&z(s.dataTransfer.setData)&&s.dataTransfer.setData(w,l)})),this.off.push(X(t,"dragend",()=>{this.dragging=null})),this.off.push(X(t,"dragover",s=>{const h=this.#l(s)||this.dragging;h==null||h===l||z(s.preventDefault)&&s.preventDefault()})),this.off.push(X(t,"drop",s=>{const h=this.#l(s)||this.dragging;h!=null&&(z(s.preventDefault)&&s.preventDefault(),z(s.stopPropagation)&&s.stopPropagation(),this.#o(h,d))})),this.off.push(X(t,"keydown",s=>this.#n(s,l,d))),t}#n(l,d,o){const n=l&&l.key,t=this.groups();if(n==="Delete"||n==="Backspace"){z(l.preventDefault)&&l.preventDefault(),this.#r(d,t,o);return}const r=n==="ArrowLeft"||n==="ArrowUp",s=n==="ArrowRight"||n==="ArrowDown",h=n==="Home",u=n==="End";if(!r&&!s&&!h&&!u)return;if(z(l.preventDefault)&&l.preventDefault(),l.shiftKey&&(r||s)){const c=o+(r?-1:1);if(c<0||c>=t.length){this.announce(this.t(r?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:this.titleOf(d)}),{repeat:!0});return}const f=t.slice();f.splice(o,1),f.splice(c,0,d),this.setGroups(f),this.announce(this.t("a11y.panel.moved",{column:this.titleOf(d),at:c+1,of:f.length}),{repeat:!0}),this.#a(d);return}let i=o+(r?-1:s?1:0);h&&(i=0),u&&(i=t.length-1);const m=t[i];m&&this.#a(m)}#r(l,d=this.groups(),o=d.indexOf(l)){const n=this.titleOf(l);this.setGroups(d.filter(r=>r!==l)),this.announce(this.t("a11y.panel.removedFrom",{column:n,list:this.t("panel.zone.group")}),{repeat:!0});const t=this.groups();t.length?this.#a(t[Math.min(o,t.length-1)]):this.#u()}#o(l,d){if(!this.canGroup(l)){this.announce(this.t("a11y.panel.cannotAddTo",{column:this.titleOf(l),list:this.t("panel.zone.group")}),{repeat:!0});return}const o=this.groups(),n=o.indexOf(l),t=o.slice();n>=0&&(t.splice(n,1),n<d&&(d-=1)),t.splice(Math.max(0,Math.min(d,t.length)),0,l),this.setGroups(t);const r=t.indexOf(l);this.announce(this.t(n>=0?"a11y.panel.moved":"a11y.panel.addedTo",n>=0?{column:this.titleOf(l),at:r+1,of:t.length}:{column:this.titleOf(l),list:this.t("panel.zone.group")}),{repeat:!0}),this.#a(l)}#i(l){const d=new Set(l),o=_(this.doc,"label",{class:I.groupZoneAdd}),n=_(this.doc,"select",{class:I.groupZoneAddSelect,attrs:{"aria-label":this.t("groupZone.add")}});n.appendChild(_(this.doc,"option",{text:this.t("groupZone.add"),attrs:{value:""}}));for(const t of this.columns())d.has(t.id)||!this.canGroup(t.id)||n.appendChild(_(this.doc,"option",{text:this.titleOf(t.id),attrs:{value:t.id}}));return this.off.push(X(n,"change",()=>{const t=n.value;t&&this.#o(t,this.groups().length)})),this.adderSelect=n,o.appendChild(n),o}#s(){for(const d of this.#e)d();this.#e.length=0;const l=this.props&&this.props.header;if(!(!l||!z(l.querySelectorAll)))for(const d of l.querySelectorAll("[data-col]")){const o=z(d.getAttribute)?d.getAttribute("data-col"):null;!o||!this.canGroup(o)||(z(d.setAttribute)&&d.setAttribute("draggable","true"),this.#e.push(X(d,"dragstart",n=>{this.dragging=o,n.dataTransfer&&z(n.dataTransfer.setData)&&n.dataTransfer.setData(w,o)})),this.#e.push(X(d,"dragend",()=>{this.dragging=null})))}}#l(l){const d=l&&l.dataTransfer;if(d&&z(d.getData)){const o=d.getData(w);if(o)return o}return null}#a(l){const d=this.chips&&z(this.chips.querySelector)?this.chips.querySelector(`[data-col="${H(l)}"]`):null;d&&z(d.focus)&&d.focus()}#u(){this.adderSelect&&z(this.adderSelect.focus)&&this.adderSelect.focus()}destroy(){for(const l of this.#e)l();this.#e.length=0,super.destroy()}}}),Fe("packages/dom/src/ui/tooltip.js",function(e,K){"use strict";Object.defineProperty(e,"TextTooltip",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const Q=K("packages/dom/src/editors/common.js"),$=Q.CLS,B=Q.documentFor,I=Q.el,_=Q.on,X=Q.clear,H=K("packages/core/src/internal/util.js").isFunction;class V{root=null;init(g){this.doc=g.document,this.root=I(this.doc,"div",{class:`${$.tooltip}__text`}),this.update(g.content)}update(g){if(!this.root)return;const l=g==null?"":String(g);this.root.textContent!==l&&(this.root.textContent=l)}element(){return this.root}destroy(){this.root=null}}class z{root=null;component=null;timer=null;target=null;off=[];constructor(g){const l=g||{};this.doc=B(l),this.host=l.host||this.doc.body,this.delay=l.delay??400,this.hideDelay=l.hideDelay??0,this.components={text:V,...l.components||{}}}show(g){this.cancelTimer();const l=g.delay??this.delay;if(!l){this.showNow(g);return}this.timer=setTimeout(()=>{this.timer=null,this.showNow(g)},l)}showNow(g){const l=g.component||"text",d=typeof l=="function"?l:this.components[l]||V;return this.root||(this.root=I(this.doc,"div",{class:$.tooltip,attrs:{role:"tooltip"},style:{position:"absolute"}}),this.host.appendChild(this.root)),!this.component||this.componentCtor!==d?(this.component&&H(this.component.destroy)&&this.component.destroy(),X(this.root),this.component=new d,this.componentCtor=d,this.component.init({document:this.doc,content:g.content,...g.props||{}}),this.root.appendChild(this.component.element())):H(this.component.update)&&this.component.update(g.content),this.target=g.target||null,this.position(),this.root.setAttribute("data-open","true"),this.root}position(){if(!this.root||!this.target||!H(this.target.getBoundingClientRect))return;const g=this.target.getBoundingClientRect(),l=this.doc.defaultView||{};this.root.style.left=`${g.left+(l.scrollX||0)}px`,this.root.style.top=`${g.bottom+(l.scrollY||0)}px`}hide(){this.cancelTimer(),this.root&&(this.root.setAttribute("data-open","false"),this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.target=null)}cancelTimer(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)}attach(g,l,d){const o=()=>this.show({target:g,content:l(),...d||{}}),n=()=>this.hide(),t=[_(g,"mouseenter",o),_(g,"mouseleave",n),_(g,"focus",o),_(g,"blur",n)],r=()=>{for(const s of t)s()};return this.off.push(r),r}destroy(){this.hide();for(const g of this.off)g();this.off.length=0,this.component&&H(this.component.destroy)&&this.component.destroy(),this.component=null,this.root=null}}const w=z}),Fe("packages/dom/src/ui/pagination.js",function(e,K){"use strict";Object.defineProperty(e,"pageModel",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const Q=K("packages/dom/src/editors/common.js"),$=Q.CLS,B=Q.documentFor,I=Q.el,_=Q.on,X=Q.clear,H=K("packages/core/src/i18n/index.js").defaultMessages,z=K("packages/core/src/internal/util.js").isFunction;function w(l){const d=Math.max(1,Number(l.pageSize)||100),o=l.total==null?null:Math.max(0,Number(l.total)),n=o==null?null:Math.max(1,Math.ceil(o/d)),t=Math.max(0,n==null?Number(l.page)||0:Math.min(Number(l.page)||0,n-1)),r=o===0?0:t*d+1,s=o==null?(t+1)*d:Math.min(o,(t+1)*d);return{page:t,pageSize:d,pageCount:n,from:r,to:s,first:t===0,last:n==null?l.hasMore!==!0:t>=n-1,total:o}}class A{root=null;page=0;pageSize=100;total=null;counting=!1;hasMore=!1;off=[];init(d){const o=d||{};this.doc=B(o),this.host=o.host||{},this.pageSize=Number(o.pageSize)||100;const n=Array.isArray(o.pageSizes)&&o.pageSizes.length?[...o.pageSizes]:[25,50,100,250,1e3];this.pageSize>0&&!n.includes(this.pageSize)&&n.push(this.pageSize),this.pageSizes=n.sort((t,r)=>t-r),this.page=Number(o.page)||0,this.total=o.total===void 0?null:o.total,this.locale=o.locale,this.messages=o.messages||null,this.onChange=o.onChange||null,this.root=I(this.doc,"nav",{class:$.pagination,attrs:{"aria-label":this.t("pagination.label")}}),this.paint()}t(d,o){const n=this.messages;return(n&&typeof n.t=="function"?n:H).t(d,o)}element(){return this.root}model(){return w({total:this.total,pageSize:this.pageSize,page:this.page,hasMore:this.hasMore})}setState(d){d.total!==void 0&&(this.total=d.total),d.counting!==void 0&&(this.counting=d.counting===!0),d.hasMore!==void 0&&(this.hasMore=d.hasMore===!0),d.page!==void 0&&(this.page=Number(d.page)||0),this.paint()}goTo(d){const o=this.page;this.page=d;const n=this.model();return this.page=n.page,this.paint(),this.page!==o&&z(this.onChange)&&this.onChange({page:this.page,pageSize:this.pageSize}),this.page}next(){return this.model().last?this.page:this.goTo(this.page+1)}previous(){return this.page===0?0:this.goTo(this.page-1)}last(){const d=this.model();return d.pageCount==null?this.page:this.goTo(d.pageCount-1)}setPageSize(d){const o=this.page*this.pageSize;this.pageSize=Math.max(1,Number(d)||1),this.page=Math.floor(o/this.pageSize),this.paint(),z(this.onChange)&&this.onChange({page:this.page,pageSize:this.pageSize})}paint(){const d=this.root;if(!d)return;for(const i of this.off)i();this.off.length=0,X(d);const o=this.model(),n=I(this.doc,"select",{class:`${$.pagination}__size`,attrs:{"aria-label":this.t("pagination.pageSize")}});for(const i of this.pageSizes)n.appendChild(I(this.doc,"option",{text:String(i),attrs:{value:i}}));n.value=String(this.pageSize),this.off.push(_(n,"change",()=>this.setPageSize(Number(n.value)))),d.appendChild(n);const t=o.total==null?this.t(this.counting?"pagination.counting":"pagination.range",{from:o.from,to:o.to}):this.t("pagination.summary",{from:o.from,to:o.to,total:o.total});d.appendChild(I(this.doc,"span",{class:`${$.pagination}__summary`,text:t}));const r=(i,m,c,f)=>{const a=I(this.doc,"button",{class:`${$.pagination}__button`,text:i,attrs:{type:"button","aria-label":f,disabled:c?"":null}});return c||this.off.push(_(a,"click",m)),a};d.appendChild(r("«",()=>this.goTo(0),o.first,this.t("pagination.first"))),d.appendChild(r("‹",()=>this.previous(),o.first,this.t("pagination.previous")));const s=I(this.doc,"span",{class:`${$.pagination}__page`});s.appendChild(I(this.doc,"span",{text:`${this.t("pagination.page")} `}));const h=I(this.doc,"input",{class:`${$.pagination}__field`,attrs:{type:"text",inputmode:"numeric","aria-label":o.pageCount==null?this.t("pagination.jump"):this.t("pagination.jumpBounded",{pages:o.pageCount}),size:String(Math.max(2,String(o.pageCount??o.page+1).length))}});h.value=String(o.page+1);const u=()=>{const i=parseInt(String(h.value).trim(),10);if(!Number.isFinite(i)){h.value=String(this.model().page+1);return}this.goTo(i-1)};this.off.push(_(h,"keydown",i=>{i.key==="Enter"?(u(),i.preventDefault?.()):i.key==="Escape"?(h.value=String(this.model().page+1),h.blur?.()):i.stopPropagation?.()})),this.off.push(_(h,"blur",()=>u())),this.off.push(_(h,"focus",()=>h.select?.())),s.appendChild(h),o.pageCount!=null&&s.appendChild(I(this.doc,"span",{text:` ${this.t("pagination.ofPages",{pages:o.pageCount})}`})),d.appendChild(s),d.appendChild(r("›",()=>this.next(),o.last,this.t("pagination.next"))),d.appendChild(r("»",()=>this.last(),o.last||o.pageCount==null,this.t("pagination.last")))}destroy(){for(const d of this.off)d();this.off.length=0,this.root=null}}const g=A}),Fe("packages/dom/src/ui/overlay.js",function(e,K){"use strict";Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const Q=K("packages/dom/src/editors/common.js"),$=Q.CLS,B=Q.documentFor,I=Q.el,_=Q.clear,W=K("packages/core/src/internal/util.js").isFunction,V=K("packages/core/src/i18n/index.js").defaultMessages;function z(o,n){const t=o&&o.grid&&o.grid.messages;return(t&&W(t.t)?t:V).t(n)}class w{root=null;init(n){this.doc=n.document,this.root=I(this.doc,"div",{class:`${$.overlay}__loading`,attrs:{role:"status","aria-live":"polite"},children:[I(this.doc,"span",{class:`${$.overlay}__spinner`,attrs:{"aria-hidden":"true"}}),I(this.doc,"span",{class:`${$.overlay}__message`,text:n.message||z(n,"overlay.loading")})]})}element(){return this.root}destroy(){this.root=null}}class A{root=null;init(n){this.doc=n.document,this.root=I(this.doc,"div",{class:`${$.overlay}__empty`,attrs:{role:"status"},children:[I(this.doc,"span",{class:`${$.overlay}__message`,text:n.message||z(n,"overlay.noRows")})]})}element(){return this.root}destroy(){this.root=null}}const g=Object.freeze({loading:w,empty:A});class l{root=null;slot=null;component=null;current=null;init(n){const t=n||{};this.doc=B(t),this.components={...g,...t.components||{}},this.root=I(this.doc,"div",{class:$.overlay,attrs:{"data-open":"false"}}),this.slot=I(this.doc,"div",{class:`${$.overlay}__slot`}),this.root.appendChild(this.slot),t.host&&t.host.appendChild(this.root)}element(){return this.root}show(n,t){const r=typeof n=="function"?n:this.components[n];return r?(this.hide(),this.component=new r,this.component.init({document:this.doc,message:t&&t.message,...t&&t.props||{}}),this.slot.appendChild(this.component.element()),this.current=typeof n=="string"?n:"custom",this.root.setAttribute("data-open","true"),this.root.setAttribute("data-overlay",this.current),this.component.element()):null}hide(){this.component&&W(this.component.destroy)&&this.component.destroy(),this.component=null,this.current=null,this.slot&&_(this.slot),this.root&&(this.root.setAttribute("data-open","false"),this.root.removeAttribute("data-overlay"))}showing(){return this.current}register(n,t){this.components[n]=t}destroy(){this.hide(),this.root&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.root=null,this.slot=null}}const d=l}),Fe("packages/dom/src/ui/index.js",function(e,K){"use strict";const Q=K("packages/dom/src/ui/statusbar.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return Q.StatusBar}}),Object.defineProperty(e,"StatusPanel",{enumerable:!0,get:function(){return Q.StatusPanel}}),Object.defineProperty(e,"RowCountPanel",{enumerable:!0,get:function(){return Q.RowCountPanel}}),Object.defineProperty(e,"SelectedCountPanel",{enumerable:!0,get:function(){return Q.SelectedCountPanel}}),Object.defineProperty(e,"AggregationPanel",{enumerable:!0,get:function(){return Q.AggregationPanel}}),Object.defineProperty(e,"ProgressPanel",{enumerable:!0,get:function(){return Q.ProgressPanel}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return Q.UpdatesPanel}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return Q.CommentsPanel}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return Q.statusPanels}}),Object.defineProperty(e,"aggregate",{enumerable:!0,get:function(){return Q.aggregate}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return Q.formatCount}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return Q.formatNumber}});const $=K("packages/dom/src/ui/contextmenu.js");Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return $.ContextMenu}}),Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return $.resolveMenuItems}});const B=K("packages/dom/src/ui/toolpanel.js");Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return B.ToolPanel}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return B.ToolPanelBase}}),Object.defineProperty(e,"ColumnsPanel",{enumerable:!0,get:function(){return B.ColumnsPanel}}),Object.defineProperty(e,"FiltersPanel",{enumerable:!0,get:function(){return B.FiltersPanel}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return B.toolPanels}});const I=K("packages/dom/src/ui/groupbyzone.js");Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return I.GroupByZone}});const _=K("packages/dom/src/ui/tooltip.js");Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return _.TooltipManager}}),Object.defineProperty(e,"TextTooltip",{enumerable:!0,get:function(){return _.TextTooltip}});const X=K("packages/dom/src/ui/pagination.js");Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return X.Pagination}}),Object.defineProperty(e,"pageModel",{enumerable:!0,get:function(){return X.pageModel}});const W=K("packages/dom/src/ui/overlay.js");Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return W.OverlayLayer}}),Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return W.LoadingOverlay}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return W.EmptyOverlay}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return W.overlays}})}),Fe("packages/dom/src/ui/celltooltip.js",function(e,K){"use strict";Object.defineProperty(e,"CellTooltips",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return f}});const Q=K("packages/dom/src/editors/common.js"),$=Q.documentFor,B=Q.el,I=Q.on,_=Q.clear,X=K("packages/core/src/internal/util.js"),W=X.isFunction,H=X.warnOnce,z=K("packages/dom/src/cell/sanitise.js").sanitiseHtml,A=K("packages/dom/src/detailhost.js").insideDetail,l=K("packages/dom/src/renderer/renderer.js").displayIndexOf,d=K("packages/dom/src/renderer/viewport.js"),o=d.CLASS,n=d.NAMESPACE,r=K("packages/dom/src/themeof.js").carryTheme,s={tooltip:"lat-cell-tooltip",body:"lat-cell-tooltip__body",title:"lat-cell-tooltip__title",rows:"lat-cell-tooltip__rows",row:"lat-cell-tooltip__row",label:"lat-cell-tooltip__label",value:"lat-cell-tooltip__value",note:"lat-cell-tooltip__note"},h=400,u=140,i=6;let m=0;class c{#e;#t;#n;#r;#o=null;#i=null;#s;#l=!1;#a=null;#u=null;#c=null;#d=null;#h=null;#f=[];#p=!1;constructor(p){const b=p||{};this.#e=b.grid,this.#t=b.host,this.#n=b.viewport,this.#r=$(b),m+=1,this.#s=`lat-cell-tooltip-${m}`}mount(){const p=this.#n&&this.#n.root;if(!p||!W(p.addEventListener))return;const b=this.#e.on("cell:mouseover",y=>this.#w(y));W(b)&&this.#f.push(b);const O=this.#e.on("cell:mouseout",()=>this.#k());W(O)&&this.#f.push(O),this.#f.push(I(p,"focusin",y=>this.#S(y))),this.#f.push(I(p,"focusout",()=>this.#k())),this.#f.push(I(this.#r,"keydown",y=>this.#y(y),!0));const k=this.#r.defaultView;k&&W(k.addEventListener)&&this.#f.push(I(k,"scroll",()=>this.hide(),!0))}#m(){const p=W(this.#e.get)?this.#e.get("tooltip"):null,b=p&&typeof p=="object"?p:{},O=Number.isFinite(b.delay)&&b.delay>=0?Number(b.delay):h,k=b.maxWidth;return{delay:O,hideDelay:u,maxWidth:typeof k=="number"&&Number.isFinite(k)?`${k}px`:typeof k=="string"&&k?k:null}}#g(p){const b=p&&p.cell?p.cell.tooltip:null;return!b||typeof b!="object"||Array.isArray(b)||!W(b.render)&&!W(b.mount)?null:b}#b(p){if(!p||!W(p.closest))return null;const b=p.closest(`.${o.row}`);if(!b)return null;const O=l(b);if(O<0)return null;const k=this.#t.rowAt(O);if(!k)return null;const y=p.getAttribute("data-col");if(!y)return null;const v=this.#t.columns.get(y);return v?{row:k,key:k.key,index:O,colId:y,column:v,value:this.#t.cellValue?this.#t.cellValue(k,v):void 0,text:this.#t.cellText?this.#t.cellText(k,v):"",cell:p,grid:this.#e}:null}#w(p){const b=p&&p.target;if(!this.#g(p&&p.column)){this.#k();return}this.#O(b)}#S(p){const b=p&&p.target;if(!b||!W(b.closest)||A(b,this.#n.root))return;const O=b.closest(`.${o.cell}`);if(!O||O!==b){this.#k();return}const k=O.getAttribute("data-col"),y=k?this.#t.columns.get(k):null;if(!this.#g(y)){this.#k();return}this.#O(O)}#y(p){!p||p.key!=="Escape"||p.defaultPrevented||this.#l&&(W(p.preventDefault)&&p.preventDefault(),this.hide())}#O(p){if(this.#p||!p||(this.#x(),this.#l&&this.#a===p))return;this.#L();const{delay:b}=this.#m();if(!b){this.#M(p);return}this.#d=setTimeout(()=>{this.#d=null,this.#M(p)},b)}#k(){if(this.#L(),!this.#l||this.#h!==null)return;const{hideDelay:p}=this.#m();this.#h=setTimeout(()=>{this.#h=null,this.hide()},p)}#j(){if(this.#o)return this.#o;const p=this.#r,b=B(p,"div",{class:[n,s.tooltip],attrs:{id:this.#s,role:"tooltip","data-open":"false"}});this.#i=B(p,"div",{class:s.body}),b.appendChild(this.#i),this.#f.push(I(b,"mouseenter",()=>this.#x())),this.#f.push(I(b,"mouseleave",()=>this.#k()));const O=p.body;return O&&W(O.appendChild)&&O.appendChild(b),this.#o=b,b}#A(p,b){const O=this.#i;if(_(O),p==null||p==="")return!1;if(typeof p=="string")return O.textContent=p,!0;if(typeof p=="object"){if(typeof p.nodeType=="number")return O.appendChild(p),!0;const k=p;if(typeof k.html=="string")return O.innerHTML=z(k.html),!0;if(k.title!==void 0||k.rows!==void 0||k.note!==void 0)return this.#T(k),!0}return H(`tooltip-content:${b}`,`Column '${b}' cell.tooltip render returned a value that is not an element, a { title, rows, note } spec, a { html } wrapper or a string, so nothing was shown.`),!1}#T(p){const b=this.#r,O=this.#i,k=v=>v==null?"":String(v);p.title!==void 0&&p.title!==null&&p.title!==""&&O.appendChild(B(b,"div",{class:s.title,text:k(p.title)}));const y=Array.isArray(p.rows)?p.rows:[];if(y.length){const v=B(b,"div",{class:s.rows});for(const R of y){if(!R||typeof R!="object")continue;const S=B(b,"div",{class:s.row});S.appendChild(B(b,"span",{class:s.label,text:k(R.label)})),S.appendChild(B(b,"span",{class:s.value,text:k(R.value)})),v.appendChild(S)}O.appendChild(v)}p.note!==void 0&&p.note!==null&&p.note!==""&&O.appendChild(B(b,"div",{class:s.note,text:k(p.note)}))}#M(p){if(this.#p)return;const b=this.#b(p);if(!b){this.hide();return}const O=this.#g(b.column);if(!O){this.hide();return}this.hide();const k=this.#j();r(k,this.#n&&this.#n.root);let y;if(W(O.render))try{y=O.render(b)}catch(S){H(`tooltip-render:${b.colId}`,`Column '${b.colId}' cell.tooltip render threw; no tooltip was shown.`,S);return}const v=this.#A(y,b.colId);if(W(O.mount))try{O.mount(this.#i,b),this.#u=O}catch(S){H(`tooltip-mount:${b.colId}`,`Column '${b.colId}' cell.tooltip mount threw; the tooltip was closed.`,S),this.hide();return}else if(!v)return;const{maxWidth:R}=this.#m();R&&(k.style.maxWidth=R),this.#a=p,this.#l=!0,k.setAttribute("data-open","true"),this.#C(p),this.#E(p)}#C(p){if(!W(p.setAttribute))return;const b=W(p.getAttribute)?p.getAttribute("aria-describedby"):null;this.#c={cell:p,previous:b},p.setAttribute("aria-describedby",b?`${b} ${this.#s}`:this.#s)}#E(p){const b=this.#o;if(!b||!W(p.getBoundingClientRect))return;const O=this.#r.defaultView;if(!O)return;const k=p.getBoundingClientRect(),y=W(b.getBoundingClientRect)?b.getBoundingClientRect():{width:0,height:0},v=O.innerWidth||0,R=O.innerHeight||0,S=y.width||0,x=y.height||0;let C=k.bottom+i;const P=k.top-i-x;C+x>R-i&&P>=i&&(C=P),R&&(C=Math.max(i,Math.min(C,Math.max(i,R-x-i))));let F=k.left;v&&(F=Math.min(F,Math.max(i,v-S-i))),F=Math.max(i,F),b.style.left=`${Math.round(F)}px`,b.style.top=`${Math.round(C)}px`}hide(){if(this.#L(),this.#x(),!this.#l)return;if(this.#l=!1,this.#u&&W(this.#u.unmount))try{this.#u.unmount(this.#i)}catch(b){H("tooltip-unmount","A cell.tooltip unmount threw while the tooltip was closing.",b)}this.#u=null,this.#i&&_(this.#i),this.#o&&this.#o.setAttribute("data-open","false");const p=this.#c;p&&W(p.cell.setAttribute)&&(p.previous?p.cell.setAttribute("aria-describedby",p.previous):W(p.cell.removeAttribute)&&p.cell.removeAttribute("aria-describedby")),this.#c=null,this.#a=null}#L(){this.#d!==null&&(clearTimeout(this.#d),this.#d=null)}#x(){this.#h!==null&&(clearTimeout(this.#h),this.#h=null)}destroy(){this.hide(),this.#p=!0;for(const p of this.#f)p();this.#f.length=0,this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}const f=c}),Fe("packages/dom/src/platform.js",function(e,K){"use strict";Object.defineProperty(e,"macLike",{enumerable:!0,get:function(){return Q}});function Q(){const $=globalThis.navigator,B=String($&&($.userAgentData?.platform||$.platform)||"");return/mac|iphone|ipad/i.test(B)}}),Fe("packages/dom/src/columnmenu.js",function(e,K){"use strict";Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"aggregateMenuItem",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"headerMenuItems",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"gridAcceptsEdits",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"columnAcceptsEdits",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"rangeChartConfig",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"chartableRange",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"applyMenuLayer",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"resolveMenuChain",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return b}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,_=K("packages/dom/src/platform.js").macLike,W=K("packages/core/src/i18n/index.js").defaultMessages,V=K("packages/dom/src/ui/contextmenu.js").ContextMenu,z=K("packages/core/src/compute/total.js"),w=z.aggregatesFor,A=z.totalLabel,g=10,l=150;function d(O,k){const y=(ee,ne)=>(O&&O.messages?O.messages:W).t(ee,ne),v=O.columns.get(k);if(!v)return[];const R=O.sort.get(),S=R.find(ee=>ee.col===k),x=v.layout&&v.layout.pin,C=O.state.get().group||[],P=C.includes(k);if(v.generated&&Array.isArray(v.groupedIds))return r(O,v,C);const F=!v.sort||v.sort.enabled!==!1,E=!v.filter||v.filter.enabled!==!1,D=[];F&&D.push({name:y("menu.sortAscending"),icon:"↑",disabled:S&&S.dir==="asc",action:()=>O.sort.set([{col:k,dir:"asc"}])},{name:y("menu.sortDescending"),icon:"↓",disabled:S&&S.dir==="desc",action:()=>O.sort.set([{col:k,dir:"desc"}])},{name:y("menu.clearSort"),disabled:!S,action:()=>O.sort.set(R.filter(ee=>ee.col!==k))},{separator:!0}),E&&D.push({name:y("menu.filterEllipsis"),action:()=>O.emit("column:filter:open",{colId:k})},{separator:!0}),D.push({name:y("menu.columnStatistics"),action:()=>O.emit("column:profile:open",{colId:k})},{separator:!0}),D.push({name:y("menu.pinColumn"),children:[{name:y("menu.pinStart"),disabled:x==="start",action:()=>O.columns.pin(k,"start")},{name:y("menu.pinEnd"),disabled:x==="end",action:()=>O.columns.pin(k,"end")},{name:y("menu.unpin"),disabled:!x,action:()=>O.columns.pin(k,null)}]});const N=!(v.layout&&(v.layout.movable===!1||v.layout.lockPosition)),M=!(v.layout&&v.layout.resizable===!1),j=ee=>{const ne=O.columns.get(ee);return Number(ne&&ne.layout&&ne.layout.width)||l},L=O.columns.visible().filter(ee=>!ee.generated).map(ee=>ee.id),G=L.indexOf(k);if(D.push({name:y("menu.sizeToFit"),action:()=>O.columns.autoSize(k)},{name:y("menu.sizeAllToFit"),action:()=>O.columns.fit()},{name:y("menu.width"),disabled:!M,children:[{name:y("menu.narrower"),disabled:!M,action:()=>O.columns.resize(k,Math.max(1,j(k)-g))},{name:y("menu.wider"),disabled:!M,action:()=>O.columns.resize(k,j(k)+g)},{name:y("menu.autosize"),disabled:!M,action:()=>O.columns.autoSize(k)}]},{separator:!0},{name:y("menu.moveColumn"),disabled:!N,children:[{name:y("menu.moveLeft"),disabled:!N||G<=0,action:()=>O.columns.move(k,Math.max(0,G-1))},{name:y("menu.moveRight"),disabled:!N||G<0||G>=L.length-1,action:()=>O.columns.move(k,Math.min(L.length-1,G+1))},{name:y("menu.moveToStart"),disabled:!N||G<=0,action:()=>O.columns.move(k,0)},{name:y("menu.moveToEnd"),disabled:!N||G<0||G>=L.length-1,action:()=>O.columns.move(k,L.length-1)}]},{separator:!0}),v.allowGroup!==!1&&D.push({name:y(P?"menu.ungroup":"menu.groupBy"),action:()=>O.columns.group(P?C.filter(ee=>ee!==k):[...C,k])}),C.length&&D.push({name:y("menu.expandAll"),action:()=>O.rows.expandAll()},{name:y("menu.collapseAll"),action:()=>O.rows.collapseAll()}),$(O.columns.groupColumns)){const ee=v.groupPath||[],ne=ee.length?ee[ee.length-1]:null,ie=[{name:y("columngroup.group"),disabled:L.length<2||G<0,action:()=>{const se=L[G+1]??L[G-1];if(!se)return;const he=(O.columns.get(se)||{}).groupPath||[],ce=he.length?he[he.length-1]:null;ce?O.columns.groupColumns([k],{groupId:ce}):O.columns.groupColumns([k,se],{title:y("columngroup.newGroup")})}}];ne&&ie.push({name:y("columngroup.dissolve"),action:()=>O.columns.dissolveGroup(ne)}),D.push({separator:!0},...ie)}const q=O.state&&$(O.state.get)?O.state.get().pivot:null,Y=q&&q.columns||[],J=Y.includes(k);if(v.allowPivot!==!1&&D.push({name:y(J?"menu.unpivot":"menu.pivotBy"),action:()=>O.columns.pivot(J?Y.filter(ee=>ee!==k):[...Y,k])}),v.allowTotal!==!1)if($(O.get)&&O.get("aggregateChooser")===!0)D.push(o(O,v,y));else{const ne=!!v.total;D.push({name:y(ne?"menu.stopTotalling":"menu.totalColumn"),action:()=>O.columns.setTotal(k,ne?null:"sum")})}return D.push({name:y("menu.hideColumn"),disabled:v.layout&&v.layout.lockVisible===!0,action:()=>O.columns.hide(k)}),D}function o(O,k,y){const v=k.id,R=typeof k.total=="string"?k.total:null,S=[{name:y("menu.aggregateNone"),checked:!k.total,action:()=>O.columns.setTotal(v,null)},{separator:!0},...w(k).map(x=>({name:A(x),checked:R===x,action:()=>O.columns.setTotal(v,x)})),{separator:!0},n(O,k,y,"group",y("menu.aggregateGroup")),n(O,k,y,"grand",y("menu.aggregateGrand"))];return{name:y("menu.aggregate"),children:S}}function n(O,k,y,v,R){const S=k.id,x=v==="grand"?k.grandTotal:k.groupTotal,C=typeof x=="string"?x:null,P=[{name:y("menu.aggregateSame"),checked:x==null,action:()=>O.columns.setTotal(S,null,{scope:v})},{separator:!0},...w(k).map(F=>({name:A(F),checked:C===F,action:()=>O.columns.setTotal(S,F,{scope:v})}))];return{name:R,children:P}}function t(O,k){const y=(C,P)=>(O&&O.messages?O.messages:W).t(C,P),v=O.columns.get(k);if(!v)return[];const R=O.redaction,S=!!(R&&R.has(k)),x=[];return R&&(x.push({name:y(S?"menu.stopRedacting":"menu.redactColumn"),action:()=>R.toggle(k)}),(R.list().length>1||R.active&&!S)&&x.push({name:y("menu.stopRedactingAll"),action:()=>R.clear()}),x.push({separator:!0})),x.push({name:y("menu.hideColumn"),disabled:v.layout&&v.layout.lockVisible===!0,action:()=>O.columns.hide(k)}),x}function r(O,k,y){const v=(P,F)=>(O&&O.messages?O.messages:W).t(P,F),R=y[0],S=O.sort.get(),x=R?S.find(P=>P.col===R):null,C=[];R&&C.push({name:v("menu.sortGroupsAscending"),icon:"↑",disabled:x&&x.dir==="asc",action:()=>O.sort.set([{col:R,dir:"asc"}])},{name:v("menu.sortGroupsDescending"),icon:"↓",disabled:x&&x.dir==="desc",action:()=>O.sort.set([{col:R,dir:"desc"}])},{separator:!0},{name:v("menu.filterGroups"),action:()=>O.emit("column:filter:open",{colId:k.id})},{separator:!0}),C.push({name:v("menu.expandAll"),action:()=>O.rows.expandAll()},{name:v("menu.collapseAll"),action:()=>O.rows.collapseAll()},{separator:!0});for(const P of y){const F=O.columns.get(P);C.push({name:`Remove "${F&&F.title||P}" from grouping`,action:()=>O.columns.group(y.filter(E=>E!==P))})}return C.push({name:v("menu.clearGrouping"),disabled:!y.length,action:()=>O.columns.group([])}),C}function s(){const O=globalThis.navigator&&globalThis.navigator.clipboard;return!!(O&&typeof O.readText=="function")}function h(O){return $(O.get)&&O.get("edit")===!1?!1:(O.columns&&$(O.columns.visible)?O.columns.visible():[]).some(y=>{const v=y&&y.edit;return v?v.enabled===void 0||$(v.enabled)?!0:v.enabled!==!1:!1})}function u(O,k){if($(O.get)&&O.get("edit")===!1)return!1;const y=k&&k.edit;return y?y.enabled===void 0||$(y.enabled)?!0:y.enabled!==!1:!1}const i=new Set(["number","currency","percent","integer"]);function m(O){const k=$(O.get)?O.get("rangeChart"):void 0;return k?$(k)?{enabled:!0,handler:k}:k&&typeof k=="object"&&$(k.onChart)?{enabled:!0,handler:k.onChart}:{enabled:!0,handler:null}:{enabled:!1,handler:null}}function c(O){const k=O.selection&&$(O.selection.ranges)?O.selection.ranges():[];if(!Array.isArray(k)||!k.length)return null;const y=k[k.length-1],v=$(O.columns.visible)?O.columns.visible():[],R=new Set(v.filter(S=>S&&i.has(S.type)).map(S=>S.id));return(y.columns||[]).some(S=>R.has(S))?y:null}function f(O,k){const y=(Y,J)=>(O&&O.messages?O.messages:W).t(Y,J),{colId:v,row:R}=k,S=O.selection.keys().length,x=O.selection.cells().length,C=(O.state&&$(O.state.get)?O.state.get().group:null)||[],P=O.ranges||null,F=_()?"Cmd":"Ctrl",E=()=>x||S||0,D=Y=>O.columns&&$(O.columns.get)?O.columns.get(Y):null,N=$(O.selection.cells)?O.selection.cells():[],M=[...new Set(N.map(Y=>Y&&Y.colId).filter(Boolean))];!M.length&&v&&M.push(v);const j=M.length?M.some(Y=>u(O,D(Y))):h(O),L=v?u(O,D(v)):!1,G=m(O),q=G.enabled?c(O):null;return[{name:x>1?`Copy ${x} cells`:y("menu.copy"),shortcut:`${F}+C`,disabled:!E(),action:()=>P&&x?P.copy():O.export.clipboard({rows:S?"selected":"range"})},{name:y("menu.copyWithHeaders"),disabled:!E(),action:()=>O.export.clipboard({headers:!0,rows:S?"selected":"range"})},...v==null?[]:[{name:y("menu.paste"),shortcut:`${F}+V`,disabled:!P||!j||!s(),action:()=>P&&P.paste()},{separator:!0},{name:y("menu.clearCells",{count:x||1}),shortcut:"Delete",disabled:!P||!j||!x,action:()=>P&&P.clear()},{name:y("menu.fillDown"),shortcut:`${F}+D`,disabled:!P||!j||x<2,action:()=>P&&P.fillDown()}],...q&&G.handler?[{name:"Chart selection",action:()=>G.handler(O,q)}]:[],{separator:!0},{name:"Export visible rows to CSV",action:()=>O.export.csv({rows:"visible",download:!0})},{name:`Export ${S} selected row${S===1?"":"s"} to CSV`,disabled:!S,action:()=>O.export.csv({rows:"selected",download:!0})},{name:"Export visible rows to Excel",action:()=>O.export.excel({rows:"visible",download:!0})},{name:`Export ${S} selected row${S===1?"":"s"} to Excel`,disabled:!S,action:()=>O.export.excel({rows:"selected",download:!0})},{name:"Copy visible rows",action:()=>O.export.clipboard({rows:"visible",headers:!0})},{name:"Print",action:()=>O.export.print()},...O.importer&&$(O.importer.openFile)?[{name:y("menu.importCsv"),action:()=>O.importer.openFile()}]:[],{separator:!0},...C.length?[{name:y("menu.expandAll"),action:()=>O.rows.expandAll()},{name:y("menu.collapseAll"),action:()=>O.rows.collapseAll()}]:[],{name:"Clear selection",disabled:!S,action:()=>O.selection.clear()},...$(O.get)&&O.get("rowDelete")===!0?[{name:y("menu.deleteRow",{count:S||1}),disabled:!S&&!R,action:()=>O.edit.deleteRows(S?void 0:R?R.key:void 0)}]:[],...v==null?[]:[{name:"Edit cell",disabled:!R||!v||!L,action:()=>R&&v&&O.edit.start(R.key,v)}]]}function a(O,k,y,v){if(O==null)return{items:k,spoke:!1,suppress:!1};if(O===!1)return{items:k,spoke:!0,suppress:!0};if(O===!0)return{items:k,spoke:!0,suppress:!1};if(Array.isArray(O))return{items:[...k,...O],spoke:!0,suppress:!1};if($(O)){const R=O(y,k);return{items:Array.isArray(R)?R:k,spoke:!0,suppress:!1}}return B(`menu-layer:${v}`,`${v} must be a boolean, an array of items or a (params, defaults) => items function; got ${typeof O}. Ignoring it.`),{items:k,spoke:!1,suppress:!1}}function p(O,k,y){let v=Array.isArray(O)?O:[],R=!1;for(const S of k){if(!S)continue;const x=a(S.layer,v,y,S.where);v=x.items,x.spoke&&(R=x.suppress)}return R?null:v}class b{#e=!0;#t=!0;#n;#r;#o=[];#i=null;#s=null;constructor(k){this.#n=k.grid,this.#e=k.cellMenu!==!1,this.#t=k.headerMenu!==!1,this.#i=$(k.items)?k.items:null,this.#s=$(k.headerItems)?k.headerItems:null,this.#r=new V({document:k.document,host:k.host,ctx:{grid:k.grid}})}mount(){this.#t&&this.#o.push(this.#n.on("column:menu:open",k=>{const y=String(k.colId),v=this.#c(y,d(this.#n,y));v.length&&this.#r.show({items:v,ctx:this.#u(y),anchor:k.element,placement:"below",returnFocus:k.element})})),this.#t&&this.#o.push(this.#n.on("header:contextmenu",k=>{const y=String(k.colId),v=this.#c(y,t(this.#n,y));v.length&&this.#r.show({items:v,ctx:this.#u(y),x:k.x,y:k.y,returnFocus:k.element})})),this.#o.push(this.#n.on("cell:contextmenu",k=>{const y=k.event;this.#e&&y&&$(y.preventDefault)&&y.preventDefault();const v=this.#l(k),R=f(this.#n,v),S=p(R,[{layer:this.#e===!1?!1:this.#i,where:"contextMenu"},{layer:this.#a(v.column),where:`column '${v.colId}' contextMenu`}],v);!S||!S.length||(!this.#e&&y&&$(y.preventDefault)&&y.preventDefault(),this.#r.show({items:S,ctx:v,x:y?y.clientX:void 0,y:y?y.clientY:void 0}))}))}#l(k){const y=this.#n.columns,v=k.column||(k.colId!=null&&y&&$(y.get)?y.get(k.colId):void 0),R=k.row,S=this.#n.rows,x=k.key!==void 0?k.key:R?R.key:void 0;return{key:x,colId:k.colId,value:k.value!==void 0||x===void 0||k.colId==null?k.value:S&&$(S.value)?S.value(x,k.colId):void 0,row:R,data:R?R.data:void 0,column:v,index:k.index!==void 0?k.index:k.rowIndex,grid:this.#n}}#a(k){if(!(!k||k.contextMenu===void 0||k.contextMenu===null))return k.contextMenu}#u(k){return{colId:k,column:this.#n.columns.get(k),grid:this.#n}}#c(k,y){return this.#s?p(y,[{layer:this.#s,where:"columnMenu"}],this.#u(k))||[]:y}destroy(){for(const k of this.#o)k();this.#o=[],this.#r.destroy()}}}),Fe("packages/dom/src/shortcutshelp.js",function(e,K){"use strict";Object.defineProperty(e,"HELP_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"ShortcutsHelp",{enumerable:!0,get:function(){return A}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/renderer/keyboard.js"),X=_.groupedShortcuts,W=_.SHORTCUT_IDS,V=K("packages/dom/src/platform.js").macLike,z="lat-shortcuts",w='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class A{#e;#t;#n=null;#r=null;#o=[];constructor(l){this.#e=l.grid,this.#t=l.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#i(l,d){const o=this.#e;return(o&&o.messages?o.messages:I).t(l,d)}#s(l){const d=W[l.combo];if(!d)return l.meaning;const o=`shortcut.${d}`,n=this.#i(o);return n===o?l.meaning:n}mount(){const l=this.#t.viewport?.root;if(!l||!$(l.addEventListener))return;const d=o=>{if(this.open||o.key!=="?")return;const n=o.target,t=n&&n.tagName;t==="INPUT"||t==="TEXTAREA"||n&&n.isContentEditable||(o.preventDefault(),o.stopPropagation(),this.show())};l.addEventListener("keydown",d,!0),this.#o.push(()=>l.removeEventListener("keydown",d,!0))}show(){const l=this.#l();if(!l)return;const d=l.ownerDocument;this.#r=d&&d.activeElement,l.style.display="",$(l.focus)&&l.focus(),this.#e.emit?.("shortcuts:opened",{})}hide(){if(!this.#n)return;this.#n.style.display="none";const l=this.#r;this.#r=null,l&&$(l.focus)&&l.focus(),this.#e.emit?.("shortcuts:closed",{})}#l(){if(this.#n)return this.#n;const l=this.#t.viewport?.overlays,d=l?.ownerDocument;if(!l||!d?.createElement)return null;const o=d.createElement("div");o.className=z,o.setAttribute("role","dialog"),o.setAttribute("aria-modal","true"),o.setAttribute("tabindex","-1");const n=`${z}-title`;o.setAttribute("aria-labelledby",n);const t=d.createElement("div");t.className=`${z}__head`;const r=d.createElement("h2");r.className=`${z}__title`,r.id=n,r.textContent=this.#i("shortcuts.title");const s=d.createElement("button");s.className=`${z}__close`,s.type="button",s.setAttribute("aria-label",this.#i("shortcuts.close")),s.textContent="×",t.appendChild(r),t.appendChild(s),o.appendChild(t);const h=d.createElement("div");h.className=`${z}__body`;for(const i of X())i.items.length&&h.appendChild(this.#a(d,i));o.appendChild(h);const u=d.createElement("p");return u.className=`${z}__hint`,u.textContent=this.#i("shortcuts.hint"),o.appendChild(u),l.appendChild(o),this.#n=o,this.#u(o,s),o}#a(l,d){const o=l.createElement("section");o.className=`${z}__group`;const n=l.createElement("h3");n.className=`${z}__group-title`,n.textContent=this.#i(d.messageKey),o.appendChild(n);const t=l.createElement("dl");t.className=`${z}__list`;const r=V();for(const s of d.items){const h=l.createElement("dt");h.className=`${z}__keys`,s.alternatives.forEach((i,m)=>{if(m>0){const c=l.createElement("span");c.className=`${z}__or`,c.textContent=this.#i("shortcuts.or"),h.appendChild(c)}i.forEach((c,f)=>{f>0&&h.appendChild(l.createTextNode("+"));const a=l.createElement("kbd");a.textContent=r&&c==="Ctrl"?this.#i("shortcuts.key.cmd"):c,h.appendChild(a)})});const u=l.createElement("dd");u.className=`${z}__meaning`,u.textContent=this.#s(s),t.appendChild(h),t.appendChild(u)}return o.appendChild(t),o}#u(l,d){const o=t=>{if(t.stopPropagation(),t.key==="Escape"){t.preventDefault(),this.hide();return}if(t.key!=="Tab")return;const r=[...l.querySelectorAll(w)];if(!r.length){t.preventDefault();return}const s=r[0],h=r[r.length-1],u=l.ownerDocument.activeElement;t.shiftKey&&(u===s||u===l)?(t.preventDefault(),h.focus()):!t.shiftKey&&u===h&&(t.preventDefault(),s.focus())},n=t=>{t.preventDefault?.(),this.hide()};l.addEventListener("keydown",o),d.addEventListener("click",n),this.#o.push(()=>{l.removeEventListener("keydown",o),d.removeEventListener("click",n)})}destroy(){for(const l of this.#o)l();this.#o=[],this.#n&&this.#n.parentNode&&this.#n.parentNode.removeChild(this.#n),this.#n=null,this.#r=null}}}),Fe("packages/dom/src/rowreorder.js",function(e,K){"use strict";Object.defineProperty(e,"HANDLE_CLASS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"MARKER_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DRAGGING_CLASS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"MANUAL_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"resolveRowTransfer",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"resolveRowReorder",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"RowReorder",{enumerable:!0,get:function(){return o}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/renderer/renderer.js").displayIndexOf,W="lat-rowdrag",H="lat-rowdrag-marker",V="lat-rowdrag-lifted",z="lat-manual-order",w=Object.freeze({sorted:"a11y.reorder.sorted",filtered:"a11y.reorder.filtered",grouped:"a11y.reorder.grouped","group-derived":"a11y.reorder.groupDerived","group-not-editable":"a11y.reorder.groupReadOnly",invalid:"a11y.reorder.invalid",vetoed:"a11y.reorder.vetoed"}),A=4,g=new Set;function l(n){if(!n)return null;const t=n===!0?{}:typeof n=="object"?n:null;return t?{send:t.send!==!1,receive:t.receive!==!1,mode:t.mode==="copy"?"copy":"move",group:typeof t.group=="string"?t.group:null}:null}function d(n){return n===!0?{column:null,manualOrder:!1,betweenGroups:!1}:!n||typeof n!="object"?null:{column:typeof n.column=="string"?n.column:null,manualOrder:n.manualOrder===!0,betweenGroups:n.betweenGroups===!0}}class o{#e;#t;#n;#r=null;#o=null;#i=null;#s=null;#l=null;#a=[];constructor(t){this.#e=t.grid,this.#t=t.renderer,this.#n=t.document,this.#r=d(t.grid.get("rowReorder")),this.#o=l(t.grid.get("rowTransfer"))}get active(){return this.#r!==null||this.#o!==null}get draggable(){return this.#r!==null}get grid(){return this.#e}get root(){return this.#t.viewport?.root||null}accepts(t){if(!this.#o||!this.#o.receive)return!1;const r=t&&t.transfer;return!r||!r.send?!1:r.group===this.#o.group}get transfer(){return this.#o}#u(t,r){const s=this.#e;return(s&&s.messages?s.messages:I).t(t,r)}#c(t,r){const s=this.#t&&this.#t.announce;$(s)&&s.call(this.#t,t,r)}#d(){if(!this.#r)return null;if(this.#r.column)return this.#r.column;const t=this.#e.columns.visible().filter(r=>!r.generated);return t.length?t[0].id:null}paint(){if(!this.draggable)return;const t=this.#d(),r=this.#t.viewport?.root;if(!t||!r)return;const s=r.querySelectorAll(`.lat-cell[data-col="${t}"]`);for(const h of s){if(h.querySelector(`.${W}`))continue;const u=h.parentNode;if(u&&$(u.getAttribute)&&u.getAttribute("data-pinned"))continue;const i=this.#n.createElement("span");i.className=W,i.setAttribute("data-role","row-drag"),i.setAttribute("aria-hidden","true"),i.setAttribute("title",this.#u("a11y.reorder.grab")),i.textContent="⠿",h.insertBefore(i,h.firstChild||null)}this.#f(r,t)}#h(){const t=this.#e.rowOrder;return!!(t&&$(t.manual)&&t.manual())}#f(t,r){const s=this.#h();if($(t.setAttribute)&&(s?t.setAttribute("data-row-order","manual"):t.removeAttribute("data-row-order")),!this.#r||!this.#r.manualOrder)return;const h=t.querySelector(`.lat-header-cell[data-col="${r}"]`);if(!h)return;let u=h.querySelector(`.${z}`);u||(u=this.#n.createElement("button"),u.className=z,u.setAttribute("type","button"),u.setAttribute("data-role","manual-order"),u.setAttribute("tabindex","-1"),u.textContent=this.#u("rowOrder.button"),u.addEventListener("click",m=>{m.stopPropagation?.(),this.toggleManual()}),u.addEventListener("pointerdown",m=>m.stopPropagation?.()),h.insertBefore(u,h.firstChild||null)),u.setAttribute("aria-pressed",s?"true":"false");const i=this.#u(s?"rowOrder.exit":"rowOrder.enter");u.setAttribute("title",i),u.setAttribute("aria-label",i)}toggleManual(){const t=this.#e.rowOrder;if(!t)return;const r=this.#h()?t.exit():t.enter({origin:"user"}),s=h=>{h&&h.reason&&this.#c(this.#u(w[h.reason]||"a11y.reorder.refused"),{repeat:!0}),this.paint()};r&&$(r.then)?r.then(s):s(r)}mount(){if(!this.active)return;g.add(this);const t=this.#t.viewport?.root;if(!t||!$(t.addEventListener))return;const r=m=>this.#p(m),s=m=>this.#m(m),h=()=>this.#g(),u=m=>this.#T(m);if(t.addEventListener("pointerdown",r),t.addEventListener("keydown",u),$(this.#e.on)){let m=this.#h();this.#a.push(this.#e.on("state:changed",c=>{!c||!Array.isArray(c.sections)||!c.sections.includes("rowOrder")||this.#h()!==m&&(m=this.#h(),this.#c(this.#u(m?"a11y.rowOrder.entered":"a11y.rowOrder.exited"),{repeat:!0}))}))}const i=this.#n.defaultView||this.#n;i.addEventListener?.("pointermove",s),i.addEventListener?.("pointerup",h),this.#a.push(()=>{t.removeEventListener("pointerdown",r),t.removeEventListener("keydown",u),i.removeEventListener?.("pointermove",s),i.removeEventListener?.("pointerup",h)})}#p(t){const r=t.target;if(!r||!$(r.closest)||!r.closest('[data-role="row-drag"]'))return;const s=r.closest(".lat-row"),h=s?X(s):-1;if(h<0)return;const u=this.#e.rows.get(h);if(!u||u.group)return;const i=this.#L();if(i&&!(this.#o&&this.#o.send)){this.#c(this.#u(i),{repeat:!0});return}t.preventDefault?.(),this.#i={key:u.key,from:h,at:h,x:t.clientX,y:t.clientY,armed:!1,hit:null,over:null,frame:null,pending:null}}#m(t){const r=this.#i;if(!r)return;if(!r.armed){if(Math.abs(t.clientX-r.x)+Math.abs(t.clientY-r.y)<A)return;r.armed=!0,this.#B(r),r.over=this,this.#e.emit("rowDrag:started",this.#b(r,this,r.from,r.key),"user")}this.#l&&this.#H(t.clientX,t.clientY);const s=this.#A(t.clientX,t.clientY);if(r.target=s,s!==this){this.#$(),s&&s.accepts(this)?(s.showDropTarget(t.clientX,t.clientY),r.hit=s.hitAt(t.clientX,t.clientY)):r.hit=null,this.#S(r,s),this.#y(r,s,r.hit?r.hit.at:null,r.hit?r.hit.overKey:null);return}const h=this.#x(t.clientX,t.clientY);if(this.#S(r,s),h<0){this.#y(r,this,null,null);return}r.at=h,this.#N(h);const u=this.#e.rows.get(h);this.#y(r,this,h,u?u.key:null)}#g(){const t=this.#i;this.#i=null,this.#$(),this.#U();for(const h of g)h.hideDropTarget();if(!t||(this.#O(t),!t.armed))return;const r=t.target;if(this.#e.emit("rowDrag:ended",this.#w(t),"user"),r&&r!==this){this.#j(t,r);return}if(t.at===t.from)return;const s=this.#L();if(s){this.#c(this.#u(s),{repeat:!0});return}this.#C(t.key,t.at)}#b(t,r,s,h){const u=this.#e.rows.byKey(t.key);return{key:t.key,data:u?u.data:null,over:r?r.grid:null,at:s,overKey:h}}#w(t){const r=t.target||null;if(r&&r!==this){if(!r.accepts(this))return{...this.#b(t,r,null,null),dropped:!1};const s=t.hit||{at:r.grid.rows.count(),overKey:null};return{...this.#b(t,r,s.at,s.overKey),dropped:!0}}if(r===this){const s=this.#e.rows.get(t.at);return{...this.#b(t,this,t.at,s?s.key:null),dropped:t.at!==t.from&&this.#L()===null}}return{...this.#b(t,null,null,null),dropped:!1}}#S(t,r){if(t.over===r)return;const s=t.over;t.over=r,s&&(this.#O(t),this.#e.emit("rowDrag:left",this.#b(t,s,null,null),"user"))}#y(t,r,s,h){t.pending={over:r,at:s,overKey:h},t.frame===null&&(t.frame=this.#k(()=>{t.frame=null;const u=t.pending;t.pending=null,!(!u||this.#i!==t)&&this.#e.emit("rowDrag:moved",this.#b(t,u.over,u.at,u.overKey),"user")}))}#O(t){t.pending=null,t.frame!==null&&(t.frame(),t.frame=null)}#k(t){const r=this.#n.defaultView||globalThis;if($(r.requestAnimationFrame)){const h=r.requestAnimationFrame(t);return()=>{$(r.cancelAnimationFrame)&&r.cancelAnimationFrame(h)}}const s=setTimeout(t,16);return()=>clearTimeout(s)}#j(t,r){if(!r.accepts(this)){this.#c(this.#u("a11y.transfer.refused"),{repeat:!0});return}const s=this.#e.rows.byKey(t.key);if(!s)return;const h=this.#o.mode,u=t.key,i=t.hit||{at:r.grid.rows.count(),overKey:null};let m=null;const c=r.receive(s.data,i.at,{overKey:i.overKey,source:this.#e,revalidate:()=>!!this.#e.rows.byKey(u),onCancel:a=>{m=a}}),f=a=>{if(a!==!0){const p=a===!1?"a11y.transfer.refused":m==="stale"?"a11y.transfer.stale":"a11y.transfer.declined";this.#c(this.#u(p),{repeat:!0});return}h==="move"?(this.#e.rows.apply({remove:[u]}),this.#e.emit("row:sent",{key:u,data:s.data,mode:h})):this.#e.emit("row:copied",{key:u,data:s.data,mode:h}),this.#c(this.#u(h==="copy"?"a11y.transfer.copied":"a11y.transfer.moved"),{repeat:!0})};c&&$(c.then)?c.then(f):f(c)}receive(t,r,s={}){const h=this.#e,u=t&&typeof t=="object"?{...t}:t,i=s.overKey??null,m=s.source||null,c=$(s.onCancel)?s.onCancel:null,f=()=>{const k=h.rows.totalCount(),y=h.rows.apply({add:[u],at:Math.max(0,r||0)}),v=h.rows.totalCount()>k;return v&&h.emit("row:received",{data:u,at:r,overKey:i,rejected:y?.rejected||[]}),v},a=()=>{if(i!==null){const k=h.rows.get(r);if(!k||k.key!==i)return!1}else r=h.rows.count();return!$(s.revalidate)||s.revalidate()},p=$(h.rendererHost)?h.rendererHost():null;if(!p||!$(p.gateBefore))return f();const b=c?h.on("rowReceive:cancelled",k=>c(k.reason)):null,O=p.gateBefore("beforeRowReceive","rowReceive:cancelled",{data:u,at:r,overKey:i,source:m,origin:"user"},f,a);return b&&(O&&$(O.then)?O.then(b,b):b()),O}hitAt(t,r){const s=this.#x(t,r);if(s<0)return{at:this.#e.rows.count(),overKey:null};const h=this.#e.rows.get(s);return{at:s,overKey:h?h.key:null}}showDropTarget(t,r){const s=this.root;s&&$(s.setAttribute)&&s.setAttribute("data-drop-target","")}hideDropTarget(){const t=this.root;t&&$(t.removeAttribute)&&t.removeAttribute("data-drop-target")}#A(t,r){const s=this.#n.elementFromPoint?this.#n.elementFromPoint(t,r):null,h=s&&$(s.closest)?s.closest(".lattice"):null;if(!h)return null;for(const u of g)if(u.root===h)return u;return null}#T(t){if(!t.altKey||!t.shiftKey)return;if(this.#r&&this.#r.manualOrder&&(t.code==="KeyM"||t.key==="M"||t.key==="m")){t.preventDefault?.(),t.stopPropagation?.(),this.toggleManual();return}const r=t.key==="ArrowUp"?-1:t.key==="ArrowDown"?1:0;if(!r)return;const s=this.#n.activeElement,h=s&&$(s.closest)?s.closest(".lat-row"):null,u=h?X(h):-1;if(u<0)return;t.preventDefault?.(),t.stopPropagation?.();const i=this.#L();if(i){this.#c(this.#u(i),{repeat:!0});return}const m=this.#e.rows.get(u);!m||m.group||this.#C(m.key,this.#M(u,r))}#M(t,r){const s=this.#e;if(r>0||!$(s.rows.groupHeadings))return t+r;const h=new Set(s.rows.groupHeadings(t).map(i=>i.key));let u=t+r;for(;u>=0;){const i=s.rows.get(u);if(!i||!h.has(i.key))break;u+=r}return u<0?t:u}#C(t,r){const s=this.#e.rows.count(),h=Math.max(0,Math.min(s-1,r)),u=this.#e.rows.move(t,h,{origin:"user"});u&&$(u.then)?u.then(i=>this.#E(i,s)):this.#E(u,s)}#E(t,r){if(!t){this.#c(this.#u("a11y.reorder.vetoed"),{repeat:!0});return}if(!t.moved){if(!t.reason||t.reason==="unchanged")return;const s=t.reason==="vetoed"&&t.detail&&t.detail!=="prevented"?t.detail:null,h=s?this.#u("a11y.reorder.vetoedBecause",{reason:s}):this.#u(w[t.reason]||"a11y.reorder.refused");this.#c(h,{repeat:!0});return}if(Array.isArray(t.regrouped)&&t.regrouped.length){const s=t.regrouped.map(h=>String(h.to??"")).join(" / ");this.#c(this.#u("a11y.reorder.regrouped",{group:s}),{repeat:!0});return}this.#c(this.#u("a11y.reorder.moved",{position:t.to+1,total:r}),{repeat:!0})}#L(){const t=this.#e,r=this.#r||{manualOrder:!1,betweenGroups:!1};if(t.sort.get().length)return r.manualOrder?"a11y.reorder.sortedManual":"a11y.reorder.sorted";if((t.state.get().group||[]).length&&!this.#h()&&!r.betweenGroups)return"a11y.reorder.grouped";const s=t.filters.get();return s&&Object.keys(s).length?"a11y.reorder.filtered":null}#x(t,r){const s=this.#n.elementFromPoint?this.#n.elementFromPoint(t,r):null,h=s&&$(s.closest)?s.closest(".lat-row"):null;return!h||$(h.getAttribute)&&h.getAttribute("data-pinned")?-1:X(h)}#B(t){const r=this.root,s=r&&$(r.querySelector)?r.querySelector(`.lat-row[data-index="${t.from}"]`):null;s&&$(s.classList?.add)&&s.classList.add(V);const h=this.#n.body;if(!h||!$(h.appendChild))return;const u=this.#d(),i=u&&$(this.#e.rows?.text)&&this.#e.rows.text(t.key,u)||this.#u("a11y.reorder.grab"),m=r&&this.#n.defaultView?.getComputedStyle?this.#n.defaultView.getComputedStyle(r):null,c=(a,p)=>m&&m.getPropertyValue(a).trim()||p,f=this.#n.createElement("div");f.textContent=String(i),f.setAttribute("aria-hidden","true"),f.setAttribute("data-role","row-drag-ghost"),f.style.cssText=["position:fixed","z-index:2147483647","pointer-events:none","top:0","left:0","white-space:nowrap",`padding:${c("--lattice-space","4px")} calc(${c("--lattice-space","4px")} * 2)`,`border-radius:${c("--lattice-radius-sm",c("--lattice-radius","4px"))}`,`border:${c("--lattice-border-width","1px")} solid ${c("--lattice-border-strong","#0003")}`,`background:${c("--lattice-background","#fff")}`,`color:${c("--lattice-foreground","#000")}`,`box-shadow:${c("--lattice-shadow-overlay","0 4px 12px rgba(0,0,0,.25)")}`,`font:${c("--lattice-font-size","13px")} ${c("--lattice-font-family","system-ui, sans-serif")}`].join(";"),h.appendChild(f),this.#l=f}#H(t,r){this.#l&&(this.#l.style.transform=`translate(${Math.round(t)+14}px, ${Math.round(r)+16}px)`)}#U(){this.#l&&(this.#l.parentNode&&this.#l.parentNode.removeChild(this.#l),this.#l=null);const t=this.root,r=t&&$(t.querySelectorAll)?t.querySelectorAll(`.${V}`):[];for(const s of r)s.classList.remove(V)}#N(t){const r=this.#t.viewport?.overlays;if(!r)return;this.#s||(this.#s=this.#n.createElement("div"),this.#s.className=H,r.appendChild(this.#s));const s=this.#t.viewport.root,h=s.querySelector(`.lat-row[data-index="${t}"]`)||s.querySelectorAll(".lat-row")[0];if(!h||!$(h.getBoundingClientRect))return;const u=h.getBoundingClientRect(),i=s.getBoundingClientRect(),m=this.#i&&t>this.#i.from;this.#s.style.display="",this.#s.style.top=`${Math.round((m?u.bottom:u.top)-i.top)}px`}#$(){this.#s&&(this.#s.style.display="none")}destroy(){g.delete(this);for(const t of this.#a)t();this.#a=[],this.#i&&this.#O(this.#i),this.#i=null,this.#U(),this.#s&&this.#s.parentNode&&this.#s.parentNode.removeChild(this.#s),this.#s=null}}}),Fe("packages/dom/src/alignedgrids.js",function(e,K){"use strict";Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return X}});const $=K("packages/core/src/internal/util.js").isFunction,B=["column:resized","column:moved","column:visible","column:pinned"];function I(W){return(W||[]).map(H=>({id:H.id,width:H.width,flex:H.flex,hidden:H.hidden,pin:H.pin===void 0?null:H.pin}))}class _{#e=new Set;#t=new Map;#n=!1;add(H){if(!H||this.#e.has(H))return;this.#e.add(H);const V=[];for(const w of B)V.push(H.on(w,()=>this.#r(H)));V.push(H.on("scroll",w=>this.#i(H,w))),V.push(H.on("destroy",()=>this.remove(H))),this.#t.set(H,V);const[z]=this.#e;z!==H&&this.#o(H,I(z.columns.state()))}remove(H){const V=this.#t.get(H);if(V)for(const z of V)z();this.#t.delete(H),this.#e.delete(H)}get size(){return this.#e.size}destroy(){for(const H of[...this.#e])this.remove(H)}#r(H){if(this.#n)return;const V=I(H.columns.state());this.#n=!0;try{for(const z of this.#e)z!==H&&this.#o(z,V)}finally{this.#n=!1}}#o(H,V){if(!H.columns||!$(H.columns.apply))return;const z=new Map((H.columns.state()||[]).map(A=>[A.id,A])),w=[];for(const A of V){const g=z.get(A.id);g&&(w.push({...g,...A}),z.delete(A.id))}for(const A of z.values())w.push(A);H.columns.apply(w)}#i(H,V){if(this.#n)return;const z=V&&typeof V.left=="number"?V.left:null;if(z!==null){this.#n=!0;try{for(const w of this.#e)w!==H&&w.scroll?.to?.({left:z})}finally{this.#n=!1}}}}function X(W){const H=new _;for(const V of W||[])H.add(V);return H}}),Fe("packages/dom/src/columntagbar.js",function(e,K){"use strict";Object.defineProperty(e,"BAR_CLASS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"resolveTagFilter",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"ColumnTagBar",{enumerable:!0,get:function(){return W}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_="lat-tagbar";function X(V){if(!V)return null;const z=V===!0?{}:typeof V=="object"?V:null;return z?{multiple:z.multiple===!0,label:typeof z.label=="string"?z.label:null}:null}class W{#e;#t;#n;#r=null;#o=null;#i=null;#s="\0";#l=[];constructor(z){this.#e=z.grid,this.#t=z.renderer,this.#n=z.document,this.#r=X(z.grid.get("columnTagFilter"))}get active(){return this.#r!==null}#a(z,w){const A=this.#e;return(A&&A.messages?A.messages:I).t(z,w)}mount(){if(!this.active)return;const z=this.#t.viewport,w=z?.root;if(!w||!$(w.insertBefore))return;const A=this.#n.createElement("div");A.className=_,A.setAttribute("role","toolbar"),A.setAttribute("aria-label",this.#a("tags.label"));const g=this.#n.createElement("label");g.className=`${_}__label`,g.textContent=this.#r.label||this.#a("tags.label");const l=this.#n.createElement("select");l.className=`${_}__select`,this.#r.multiple&&l.setAttribute("multiple","");const d=`${_}-select-${Math.abs(H(String(w.className)))}`;l.id=d,g.setAttribute("for",d),A.appendChild(g),A.appendChild(l),w.insertBefore(A,z.header||w.firstChild),this.#o=A,this.#i=l;const o=()=>{const t=this.#r.multiple?[...l.selectedOptions||[]].map(r=>r.value).filter(Boolean):l.value?[l.value]:[];this.#e.columns.showTagged(t),this.#u(t)};l.addEventListener("change",o),this.#l.push(()=>l.removeEventListener("change",o));const n=this.#e.on("model:changed",()=>this.refresh());this.#l.push(n),this.refresh()}#u(z){const w=this.#t&&this.#t.announce;if(!$(w))return;const A=z.length?z.join(", "):this.#a("tags.all");w.call(this.#t,this.#a("tags.showing",{tag:A}))}refresh(){if(!this.#i||!this.#o)return;const z=this.#e.columns.tags();if(this.#o.style.display=z.length?"":"none",!z.length)return;const w=z.join("\0");if(w===this.#s)return;this.#s=w;const A=this.#e.columns.activeTags();if(this.#i.replaceChildren&&this.#i.replaceChildren(),!this.#r.multiple){const g=this.#n.createElement("option");g.value="",g.textContent=this.#a("tags.all"),this.#i.appendChild(g)}for(const g of z){const l=this.#n.createElement("option");l.value=g,l.textContent=g,A.includes(g)&&(l.selected=!0),this.#i.appendChild(l)}this.#r.multiple||(this.#i.value=A.length?A[0]:"")}destroy(){for(const z of this.#l)z();this.#l=[],this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}function H(V){let z=0;for(let w=0;w<V.length;w++)z=z*31+V.charCodeAt(w)|0;return z}}),Fe("packages/dom/src/anomalychip.js",function(e,K){"use strict";Object.defineProperty(e,"CHIP_CLASS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"resolveAnomalySummary",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"AnomalyChip",{enumerable:!0,get:function(){return V}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_="lat-anomaly-chip";function X(z){if(!z)return null;const w=z===!0?{}:typeof z=="object"?z:null;return w?{column:typeof w.column=="string"?w.column:null,label:typeof w.label=="string"?w.label:null}:null}function W(z){return z?typeof z=="string"?{kind:z}:typeof z=="object"?z:null:null}function H(z,w){return z?Array.isArray(z.conditions)?z.conditions.some(A=>H(A,w)):z.col===w&&z.op==="eq"&&z.value===!0:!1}class V{#e;#t;#n;#r=null;#o=null;#i=null;#s=[];#l=!1;#a=!1;#u=null;#c=0;#d=null;constructor(w){this.#e=w.grid,this.#t=w.renderer,this.#n=w.document,this.#r=X(w.grid.get("anomalySummary"))}get active(){return this.#r!==null}#h(w,A){const g=this.#e;return(g&&g.messages?g.messages:I).t(w,A)}#f(){const w=this.#r&&this.#r.column;let A=null;for(const g of this.#e.columns.all()){const l=W(g.shadow);if(!l||l.kind!=="anomalyFlag")continue;const d=l.of||g.field||g.id;if(w){if(g.id===w||d===w)return this.#d=g.id,g}else A||(A=g,this.#d=g.id)}return w?null:A}#p(){if(!this.#d||!$(this.#e.rows&&this.#e.rows.forEach))return 0;let w=0;try{this.#e.rows.forEach(A=>{!A||A.group||A.key==null||this.#e.rows.value(A.key,this.#d)===!0&&w++})}catch{return 0}return w}mount(){if(!this.active)return;const w=this.#t.viewport,A=w&&w.root;if(!A||!$(A.insertBefore))return;const g=this.#n.createElement("div");g.className=_,g.setAttribute("role","status");const l=this.#n.createElement("button");l.className=`${_}__button`,l.setAttribute("type","button"),l.setAttribute("aria-pressed","false"),g.appendChild(l),A.insertBefore(g,w.header||A.firstChild),this.#o=g,this.#i=l;const d=()=>this.toggle();l.addEventListener("click",d),this.#s.push(()=>l.removeEventListener("click",d));for(const o of["filter:changed","rows:changed","model:changed"])this.#s.push(this.#e.on(o,()=>{this.#a||this.refresh()}));this.refresh()}toggle(){this.#l?this.#g():this.#m()}#m(){if(!this.#d)return;this.#u=this.#e.filters.get();const w={col:this.#d,op:"eq",value:!0},A=this.#u?{op:"and",conditions:[this.#u,w]}:w;this.#l=!0,this.#a=!0;try{this.#e.filters.set(A)}finally{this.#a=!1}this.refresh()}#g(){this.#l=!1,this.#a=!0;try{this.#e.filters.set(this.#u||null)}finally{this.#a=!1}this.#u=null,this.refresh()}refresh(){if(!this.#o||!this.#i)return;if(!this.#f()){this.#o.style.display="none";return}if(this.#l&&!H(this.#e.filters.get(),this.#d)&&(this.#l=!1,this.#u=null),this.#l){this.#b(this.#c,!0);return}const A=this.#p();if(this.#c=A,!A){this.#o.style.display="none";return}this.#b(A,!1)}#b(w,A){if(!this.#o||!this.#i)return;this.#o.style.display="",this.#o.setAttribute("data-active",A?"true":"false"),this.#i.setAttribute("aria-pressed",A?"true":"false");const g=this.#r&&this.#r.label,l=A?this.#h("anomaly.chipActive",{count:w}):g||this.#h("anomaly.chip",{count:w});this.#i.textContent=l}destroy(){for(const w of this.#s)w();this.#s=[],this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}}),Fe("packages/dom/src/rowform.js",function(e,K){"use strict";Object.defineProperty(e,"FORM_CLASS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"resolveRowForm",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"RowForm",{enumerable:!0,get:function(){return s}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,_=K("packages/core/src/i18n/index.js").defaultMessages,W=K("packages/core/src/model/rowkey.js").createRowKey,V=K("packages/dom/src/editors/index.js").createEditor,w=K("packages/dom/src/renderer/renderer.js").displayIndexOf,g=K("packages/dom/src/themeof.js").themeOf,l="lat-rowform",d='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';function o(h){if(!h)return null;const u=h===!0?{}:typeof h=="object"?h:null;if(!u)return null;const i=$(u.load)?u.load:null,m=Array.isArray(u.fields)&&u.fields.length?u.fields:null;return{timeout:r(u.timeout),container:u.container??null,mode:u.container?"inline":u.mode==="dialog"?"dialog":"drawer",load:i,create:$(u.create)?u.create:null,fields:m,title:u.title??null,width:typeof u.width=="string"?u.width:null,trigger:u.trigger===!1?"none":"dblclick"}}function n(h,u){const i=$(h)?h():h;return i?typeof i=="string"?u&&$(u.querySelector)?u.querySelector(i):null:i&&$(i.appendChild)?i:null:null}const t=2e3;function r(h){return h===!1||h===0?0:typeof h!="number"||!Number.isFinite(h)||h<=0?t:h}class s{#e;#t;#n;#r;#o=null;#i=null;#s=null;#l=null;#a=null;#u=!1;#c=null;#d=[];#h=null;#f=0;#p=null;#m=!1;#g=[];constructor(u){this.#e=u.grid,this.#t=u.renderer,this.#n=u.document,this.#r=u.registry||null,this.#o=o(u.grid.get("rowForm"))}get active(){return this.#o!==null}get open(){return!!this.#i&&this.#i.style.display!=="none"}#b(u,i){const m=this.#e;return(m&&m.messages?m.messages:_).t(u,i)}mount(){if(!this.active)return;const u=this.#t.viewport?.root;if(!u||!$(u.addEventListener)||this.#o.trigger==="none")return;const i=m=>{const c=m.target;if(!c||!$(c.closest)||c.closest(".lat-editor-host, .lat-editor--popup"))return;const f=c.closest(".lat-row"),a=f?w(f):-1;if(a<0)return;const p=this.#e.rows.get(a);!p||p.group||p.detail||(m.preventDefault?.(),m.stopPropagation?.(),this.openRow(p.key))};u.addEventListener("dblclick",i,!0),this.#g.push(()=>u.removeEventListener("dblclick",i,!0))}openRow(u){const i=this.#e.rows.byKey(u);if(!i)return!1;const m=this.#j();if(!m)return!1;this.#a=i,this.#u=!1,this.#k(),this.#h=this.#n.activeElement,m.style.display="",this.#N(m),this.#T(i);const c=this.#o.load;if(!c)this.#H(i.data);else{this.#L();const f=++this.#f;this.#M(f,a=>{this.#x(new Error(`Loading the record timed out after ${a}ms`),u,"form.loadTimeout")}),Promise.resolve().then(()=>c({row:i,data:i.data,key:u,grid:this.#e})).then(a=>{f!==this.#f||!this.open||(this.#E(),this.#H(a||i.data))}).catch(a=>{f!==this.#f||!this.open||(this.#E(),this.#x(a,u))})}return $(m.focus)&&m.focus(),this.#e.emit("form:opened",{key:u,row:i}),!0}openNew(u){const i=this.#j();if(!i)return!1;this.#f+=1,this.#E(),this.#a=null,this.#u=!0,this.#k(),this.open||(this.#h=this.#n.activeElement),i.style.display="",this.#N(i);const m=i.querySelector(`.${l}__title`);return m&&(m.textContent=this.#b("form.newTitle")),this.#H(u&&typeof u=="object"?{...u}:{}),$(i.focus)&&i.focus(),this.#e.emit("form:opened",{key:null,row:null,created:!0}),!0}close(){if(!this.#i)return;this.#f+=1,this.#E(),this.#ge(),this.#i.style.display="none";const u=this.#a?this.#a.key:null;this.#a=null,this.#u=!1,this.#k();const i=this.#h;this.#h=null,i&&$(i.focus)&&i.focus(),this.#e.emit("form:closed",{key:u})}save(){if(!this.#a&&!this.#u||!this.#d.length||this.#u&&this.#l&&this.#l.disabled)return!1;const u=this.#a?this.#a.key:null,i={},m={},c=[],f=[];for(const a of this.#d){const p=$(a.editor.commit)?a.editor.commit():{ok:!0,value:void 0};if(!p.ok)return this.#_(a,p.message),!1;if(i[a.field]=p.value,a.readOnly){f.push(a.field);continue}const b=a.initial;Object.is(b,p.value)||(m[a.field]=p.value,a.colId?c.push({key:u,colId:a.colId,value:p.value}):f.push(a.field))}return this.#u?this.#w(i):(c.length&&this.#e.edit.setCells(c,"cell",{origin:"form"}),this.#e.emit("form:saved",{key:u,values:i,changed:m,unmapped:f}),this.close(),!0)}#w(u){const i=this.#d.filter(f=>!f.colId).map(f=>f.field),m=this.#o.create;if(!m)return this.#S(u)?(this.#y(u,u,i),!0):(B("rowform:create:missing-key","rowForm could not add the new row: it carries no row key. Return the stored row, key included, from rowForm.create, or give the key a field or a default."),!1);this.#k(),this.#C(!1);const c=++this.#f;return this.#M(c,f=>{this.#O(new Error(`Adding the record timed out after ${f}ms`),u,!0)}),Promise.resolve().then(()=>m(u)).then(f=>{if(!(c!==this.#f||!this.open)){if(this.#E(),!this.#S(f)){B("rowform:create:missing-key","rowForm could not add the new row: it carries no row key. Return the stored row, key included, from rowForm.create, or give the key a field or a default."),this.#O(new Error("rowForm.create answered with a row that carries no row key"),u,!1);return}this.#y(f,u,i)}}).catch(f=>{c!==this.#f||!this.open||(this.#E(),this.#O(f,u,!1))}),!0}#S(u){if(!u||typeof u!="object")return!1;const i=W(this.#e.get("rowKey"),{warn:!1});return!i||i.stable===!1?!1:$(i.keyEmpty)?!i.keyEmpty(u):!0}#y(u,i,m){const c=this.#e,f=c.rows.apply({add:[u]}),a=f&&Array.isArray(f.added)?f.added[0]:null;if(!a){this.#O(new Error("The new row could not be added"),i,!1);return}const p=a.key;c.emit("form:saved",{key:p,values:i,changed:i,unmapped:m,created:!0}),this.close();const b=c.get("selection");(typeof b=="string"?b!=="none":b&&typeof b=="object"&&b.mode!=="none")&&c.selection&&$(c.selection.set)&&c.selection.set([p]),c.scroll&&$(c.scroll.toRow)&&c.scroll.toRow(p)}#O(u,i,m){this.#C(!0),this.#k();const c=this.#n.createElement("div");c.className=`${l}__failure`;const f=this.#n.createElement("p");f.className=`${l}__note ${l}__note--error`,f.setAttribute("role","alert"),f.textContent=this.#b("form.createFailed");const a=this.#n.createElement("button");a.className=`${l}__retry`,a.type="button",a.textContent=this.#b("form.retry"),a.addEventListener("click",()=>this.save()),c.appendChild(f),c.appendChild(a),$(this.#s.insertBefore)?this.#s.insertBefore(c,this.#s.firstChild):this.#s.appendChild(c),this.#c=c,this.#e.emit("form:error",{key:null,error:u,timedOut:m,created:!0})}#k(){const u=this.#c;this.#c=null,u&&u.parentNode&&u.parentNode.removeChild(u)}#j(){if(this.#i)return this.#i;const u=this.#t.viewport?.overlays,i=this.#n||u?.ownerDocument;if(!i?.createElement)return null;const m=n(this.#o.container,i),c=m||u;if(!c)return null;this.#o.container&&!m&&B("rowform:container","rowForm.container could not be resolved; the form opens over the grid instead."),this.#m=!!m;const f=i.createElement("div"),a=this.#m?"lattice ":"";f.className=`${a}${l} ${l}--${this.#m?"inline":this.#o.mode}`,f.setAttribute("role",this.#m?"region":"dialog"),this.#m||f.setAttribute("aria-modal","true"),f.setAttribute("tabindex","-1"),this.#o.width&&f.style.setProperty("--lattice-rowform-width",this.#o.width);const p=`${l}-title`;f.setAttribute("aria-labelledby",p);const b=i.createElement("div");b.className=`${l}__head`;const O=i.createElement("h2");O.className=`${l}__title`,O.id=p,b.appendChild(O);const k=i.createElement("div");k.className=`${l}__body`;const y=i.createElement("div");y.className=`${l}__foot`;const v=i.createElement("button");v.className=`${l}__cancel`,v.type="button",v.textContent=this.#b("form.cancel");const R=i.createElement("button");return R.className=`${l}__save`,R.type="button",R.textContent=this.#b("form.save"),y.appendChild(v),y.appendChild(R),f.appendChild(b),f.appendChild(k),f.appendChild(y),c.appendChild(f),this.#i=f,this.#s=k,this.#l=R,this.#A(f,R,v),f}#A(u,i,m){const c=p=>{if(p.stopPropagation(),p.key==="Escape"){p.preventDefault(),this.close();return}if(p.key!=="Tab"||this.#m)return;const b=[...u.querySelectorAll(d)];if(!b.length){p.preventDefault();return}const O=b[0],k=b[b.length-1],y=u.ownerDocument.activeElement;p.shiftKey&&(y===O||y===u)?(p.preventDefault(),k.focus()):!p.shiftKey&&y===k&&(p.preventDefault(),O.focus())},f=p=>{p.preventDefault?.(),this.save()},a=p=>{p.preventDefault?.(),this.close()};u.addEventListener("keydown",c),i.addEventListener("click",f),m.addEventListener("click",a),this.#g.push(()=>{u.removeEventListener("keydown",c),i.removeEventListener("click",f),m.removeEventListener("click",a)})}#T(u){const i=this.#i.querySelector(`.${l}__title`);if(!i)return;const m=this.#o.title;$(m)?i.textContent=String(m({row:u,data:u.data})??""):typeof m=="string"?i.textContent=m:i.textContent=this.#b("form.title")}#M(u,i){this.#E();const m=this.#o.timeout;if(!m)return;const c=this.#n.defaultView||globalThis;$(c.setTimeout)&&(this.#p=c.setTimeout(()=>{this.#p=null,!(u!==this.#f||!this.open)&&(this.#f+=1,i(m))},m))}#C(u){this.#l&&(this.#l.disabled=!u,u?this.#l.removeAttribute("aria-disabled"):this.#l.setAttribute("aria-disabled","true"))}#E(){if(this.#p===null)return;const u=this.#n.defaultView||globalThis;$(u.clearTimeout)&&u.clearTimeout(this.#p),this.#p=null}#L(){this.#ge(),this.#C(!1),this.#s.replaceChildren&&this.#s.replaceChildren();const u=this.#n.createElement("p");u.className=`${l}__note`,u.setAttribute("role","status"),u.textContent=this.#b("form.loading"),this.#s.appendChild(u)}#x(u,i,m="form.loadFailed"){this.#ge(),this.#C(!1),this.#s.replaceChildren&&this.#s.replaceChildren();const c=this.#n.createElement("p");c.className=`${l}__note ${l}__note--error`,c.setAttribute("role","alert"),c.textContent=this.#b(m);const f=this.#n.createElement("button");f.className=`${l}__retry`,f.type="button",f.textContent=this.#b("form.retry"),f.addEventListener("click",()=>this.openRow(i)),this.#s.appendChild(c),this.#s.appendChild(f),this.#e.emit("form:error",{key:i,error:u,timedOut:m==="form.loadTimeout"})}#B(){return this.#o.fields?this.#o.fields.map(u=>typeof u=="string"?{field:u}:u):this.#e.columns.all().filter(u=>!u.generated&&u.field).map(u=>({field:u.field,label:u.title,colId:u.id}))}#H(u){this.#ge(),this.#C(!0),this.#s.replaceChildren&&this.#s.replaceChildren();const i=u&&typeof u=="object"?u:{};for(const m of this.#B()){const c=m.field;if(!c)continue;const f=m.colId?this.#e.columns.get(m.colId):this.#se(c),a=Object.hasOwn(i,c)?i[c]:null,p=this.#n.createElement("div");p.className=`${l}__field`;const b=this.#n.createElement("label");b.className=`${l}__label`,b.textContent=String(m.label??(f&&f.title)??c);const O=this.#n.createElement("div");O.className=`${l}__control`,p.appendChild(b),p.appendChild(O),this.#s.appendChild(p);const k={field:c,colId:f?f.id:null,editor:null,initial:a,opener:null,wrap:p,readOnly:!1},v=!!(f&&(f.computed||f.generated))?null:V({grid:this.#e,column:this.#re(m,f,c),colId:f?f.id:c,row:this.#a,data:i,value:a,text:a==null?"":String(a),locale:this.#e.get("locale"),props:m.props||f&&f.edit&&f.edit.props,lookup:m.lookup||f&&f.lookup,document:this.#n,cell:O,overlay:this.#$(),stop:()=>this.#Y(k)},this.#r);if(!v){k.readOnly=!0,k.colId=null,k.editor={commit:()=>({ok:!0,value:k.initial})},this.#U(O,f,a),this.#d.push(k);continue}k.editor=v;try{$(v.value)&&(k.initial=v.value())}catch{}if(this.#d.push(k),v.popup===!0)this.#z(O,k);else{const R=$(v.element)?v.element():null;R&&O.appendChild(R)}}this.#d.length||B("rowform:no-fields","rowForm has no fields to show; the form opened with no controls. Check rowForm.fields, or the grid's columns when fields is absent.")}#U(u,i,m){const c=this.#n.createElement("div");c.className=`${l}__static`,c.setAttribute("aria-readonly","true");let f="";try{const a=i&&i.dataType&&i.dataType.format;$(a)&&(f=a({value:m,column:i,row:this.#a,data:this.#a?this.#a.data:null,locale:this.#e.get("locale")}))}catch{f=""}(f===""||f==null)&&(f=m==null?"":String(m)),c.textContent=f,u.appendChild(c)}#N(u){if(!this.#m)return;const i=this.#t.viewport?.root;if(!(!i||!$(i.getAttribute)))for(const m of["data-theme","data-density","dir"]){const c=m==="data-theme"?g(i):i.getAttribute(m);c?u.setAttribute(m,c):$(u.removeAttribute)&&u.removeAttribute(m)}}#$(){return this.#m?this.#n.body||this.#t.viewport.overlays:this.#t.viewport.overlays}#z(u,i){const m=this.#n.createElement("button");m.className=`${l}__opener`,m.type="button",i.opener=m,this.#le(i);const c=()=>{$(i.editor.attached)&&i.editor.attached()};m.addEventListener("click",c),this.#g.push(()=>m.removeEventListener("click",c)),u.appendChild(m)}#_(u,i){const m=u.wrap;m&&$(m.scrollIntoView)&&m.scrollIntoView({block:"nearest"});const c=u.opener||($(u.editor.focusTarget)?u.editor.focusTarget():null);c&&$(c.focus)&&c.focus();const f=this.#t&&this.#t.announce;$(f)&&i&&f.call(this.#t,String(i))}#Y(u){if(!u.opener||!u.editor)return;const i=$(u.editor.popupHandle)?u.editor.popupHandle():null;i&&$(i.hide)&&i.hide(),this.#le(u),$(u.opener.focus)&&u.opener.focus()}#le(u){if(!u.opener)return;let i="";try{const c=u.colId?this.#e.columns.get(u.colId):null,f=c&&c.dataType&&c.dataType.format;$(f)&&(i=f({value:$(u.editor.value)?u.editor.value():null,column:c,row:this.#a,data:this.#a?this.#a.data:null,locale:this.#e.get("locale")})),(i===""||i==null)&&$(u.editor.toClipboard)&&(i=u.editor.toClipboard())}catch{i=""}const m=i===""||i==null;u.opener.textContent=m?this.#b("form.choose"):String(i),u.opener.classList.toggle(`${l}__opener--empty`,m)}#re(u,i,m){const c=u.editor||u.type||u.lookup||u.props,f={...i&&i.edit?i.edit:{},enabled:!0};return u.editor&&(f.editor=u.editor),u.props&&(f.props=u.props),i&&!c?{...i,edit:f}:{...i||{id:m,field:m},type:u.type||i&&i.type||"text",lookup:u.lookup||i&&i.lookup||void 0,edit:f}}#se(u){for(const i of this.#e.columns.all())if(!i.generated&&i.field===u)return i;return null}#ge(){for(const u of this.#d)$(u.editor.destroy)&&u.editor.destroy();this.#d=[]}destroy(){this.#f+=1,this.#E(),this.#ge();for(const u of this.#g)u();this.#g=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null,this.#a=null}}}),Fe("packages/dom/src/toolpanelmount.js",function(e,K){"use strict";Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return C}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,I=K("packages/dom/src/ui/toolpanel.js"),_=I.ToolPanel,X=I.toolPanels,W=I.toolPanelTitles,H=I.toolPanelIcons,V=K("packages/dom/src/filters/index.js"),z=V.createFilter,w=V.filterFor,g=K("packages/dom/src/filters/text.js").TextFilter,l=K("packages/dom/src/filters/engineset.js"),d=l.EngineSetFilter,o=l.VALUE_LIMIT,n=K("packages/dom/src/editors/common.js"),t=n.CLS,r=n.documentFor,s=n.scannableRows,h=n.el,u=K("packages/dom/src/filtermenu.js"),i=u.mergeColumnFilter,m=u.branchFor,c=u.valueSource,f=u.isSetFilter,a=Object.freeze(["column:visible","column:moved","column:pinned","column:grouped","column:pivoted","filter:changed","model:changed","views:changed","sort:changed","history:changed","state:reset","cell:changed","formatting:changed"]);function p(P,F,E){const D=h(P,"div",{class:`${t.panel}__filterRefusal`});return D.appendChild(h(P,"div",{class:`${t.filter}__note`,text:E,attrs:{role:"note","data-warning":"filter:values-unsupported"}})),D.appendChild(F.element()),{get:()=>F.get(),set:N=>F.set(N),active:()=>F.active(),...$(F.clear)?{clear:()=>F.clear()}:{},destroy:()=>F.destroy(),element:()=>D}}function b(P){const{grid:F,container:E}=P||{};if(!F)throw new Error("[lattice] mountPanel needs a grid");if(!E||!E.appendChild)throw new Error("[lattice] mountPanel needs a container element");const D=$(P.panel)?P.panel:X[String(P.panel)];if(!D)throw new Error(`[lattice] unknown panel "${P.panel}"; known panels are ${Object.keys(X).join(", ")}`);const N=E.ownerDocument||r(E),M=x(F,N,P.announce),j=new D;j.init({document:N,host:M,grid:F,props:P.props||{}});const L=j.element();E.appendChild(L);const G=[];for(const q of a)$(F.on)&&G.push(F.on(q,()=>j.refresh()));return{element:L,refresh(){j.refresh()},destroy(){for(const q of G)q();G.length=0,$(j.destroy)&&j.destroy(),L&&L.parentNode&&L.parentNode.removeChild(L)}}}const O=260,k=30,y=`${t.panel}-dock`;function v(P,F,E){if(!P||!$(P.set))return;const D=m(E.filters.get(),F)||null,N=$(P.get)&&(!$(P.active)||P.active())&&P.get()||null;JSON.stringify(N)!==JSON.stringify(D)&&(D?P.set(D):$(P.clear)?P.clear():P.set(null))}function R(P,F){if(P==="insights"){const N=F&&$(F.get)?F.get("insights"):null;return{other:(N&&typeof N=="object"?N:{}).compareWith||null}}if(P!=="views")return{};const E=F&&$(F.get)?F.get("views"):null,D=E&&typeof E=="object"?E:{};return{allowSave:D.allowSave!==!1,showDiff:D.showDiff===!0,builtinTitle:D.builtinTitle,savedTitle:D.savedTitle}}function S(P){const F=P.pagination&&$(P.pagination.get)?P.pagination.get():null;return F&&Number.isFinite(F.total)?F.total:P.rows.count()}function x(P,F,E){const D=new Map;return{announce(N,M){$(E)&&E(N,M)},t(N,M){return P.messages.t(N,M)},grid:P,document:F,columns:()=>P.columns.all(),columnGroups:()=>P.state.get().columnGroups||[],groupColumns:(N,M)=>P.columns.groupColumns(N,M),ungroupColumn:N=>P.columns.ungroupColumn(N),renameGroup:(N,M)=>P.columns.renameGroup(N,M),dissolveGroup:N=>P.columns.dissolveGroup(N),showColumns:N=>P.columns.show(N),hideColumns:N=>P.columns.hide(N),groupBy:()=>P.state.get().group||[],setGroupBy:N=>P.columns.group(N),pivotBy:()=>(P.state.get().pivot||{}).columns||[],setPivotBy:N=>P.columns.pivot(N),valueColumns:()=>P.columns.all().filter(N=>N.total).map(N=>N.id),setValueColumns:N=>P.columns.totals(N),valueAggregation(N){const M=P.columns.get(N);return!M||!M.total?"sum":typeof M.total=="string"?M.total:"custom"},setValueAggregation(N,M){P.columns.setTotal(N,M)},quickFilter:()=>P.state.get().quick||"",setQuickFilter:N=>P.filters.quick(N),rowCount:()=>S(P),totalRowCount:()=>$(P.rows.totalCount)?P.rows.totalCount():P.rows.count(),formattableColumns:()=>P.columns.visible().filter(N=>!N.generated).map(N=>({id:N.id,title:String(N.title??N.id)})),formattingRules:N=>P.formatting.list(N),columnSamples:N=>{let M=N;if(!M||M==="*"){const G=P.columns.visible().find(q=>!q.generated);M=G?G.id:null}if(!M)return[];const j=[],L=new Set;for(const G of s(P)){const q=P.rows.value(G.key,M);if(q==null||q==="")continue;const Y=typeof q=="object"?j.length:q;if(!L.has(Y)&&(L.add(Y),j.push(q),j.length>=24))break}return j},profilableColumns:()=>P.columns.visible().filter(N=>!N.generated).map(N=>({id:N.id,title:String(N.title??N.id)})),columnProfile:N=>{const M=P.config().source;return((P.state.get().pivot||{}).columns||[]).length&&M&&typeof M=="object"&&$(M.aggregate)?null:P.statistics.profile(N)},columnProfileAsync:N=>P.statistics.profileAsync(N),reduceColumn:(N,M)=>P.statistics.reduce(N,M),columnCapability:N=>P.statistics.capability(N),regressionModel:N=>$(P.statistics.regressionModel)?P.statistics.regressionModel(N):null,insightsColumns:()=>P.columns.visible().filter(N=>!N.generated).map(N=>({id:N.id,title:String(N.title??N.id),type:N.type})),subsetVsPopulation:()=>P.statistics.subsetVsPopulation(),datasetVsDataset:N=>P.statistics.datasetVsDataset(N),compareGroups:(N,M)=>P.statistics.compareGroups(N,M),anomalies:N=>P.statistics.anomalies(N||{}),compareColumns:(N,M)=>{if(!N||!M||N===M)return null;const j=P.statistics.regression(N,M);return{n:j?j.n:0,pearson:P.statistics.correlation(N,M),spearman:P.statistics.spearman(N,M),kendall:P.statistics.kendall(N,M),covariance:P.statistics.covariance(N,M),slope:j?j.slope:null,intercept:j?j.intercept:null,r2:j?j.r2:null,stdError:j?j.stdError:null,weighted:P.statistics.weightedAverage(N,M)}},addRule:(N,M)=>P.formatting.add(N,M),removeRule:(N,M)=>P.formatting.remove(N,M),updateRule:(N,M,j)=>P.formatting.update(N,M,j),moveRule:(N,M,j)=>P.formatting.move(N,M,j),clearRules:N=>P.formatting.clear(N),views:()=>P.views.list(),activeId:()=>P.views.activeId,apply:N=>{P.views.apply(N)},saveAs:N=>P.views.save(N),rename:(N,M)=>P.views.rename(N,M),setDefault:N=>P.views.setDefault(N),clearDefault:()=>P.views.setDefault(null),remove:N=>P.views.remove(N),export:N=>P.views.export(N),diff:N=>P.views.diff(N),moveColumn(N,M,j){const L=P.columns.all().map(J=>J.id),G=L.indexOf(N),q=L.indexOf(M);if(G<0||q<0)return;let Y=j?q:q+1;G<Y&&(Y-=1),Y!==G&&P.columns.move(N,Y)},isFiltered(N){return m(P.filters.get(),N)!==null},clearFilter(N){P.filters.set(i(P.filters.get(),N,null));const M=D.get(N);M&&$(M.clear)?M.clear():M&&$(M.set)&&M.set(null)},clearAllFilters(){P.filters.set(null);for(const N of D.values())$(N.clear)?N.clear():$(N.set)&&N.set(null)},filterFor(N){if(D.has(N))return v(D.get(N),N,P),D.get(N);const M=P.columns.get(N);if(!M)return null;const j=M.filter&&M.filter.props&&M.filter.props.values,L=c(P),G=L?P.config().context??null:null,q=L?ne=>L.columnValues(N,{...ne||{},context:G}):null,Y={grid:P,column:M,colId:N,type:M.type,locale:P.get("locale"),props:{...M.filter&&M.filter.props,values:j||(M.lookup?void 0:L?()=>q({limit:o}).then(ne=>ne&&ne.supported?ne.values.map(ie=>ie.value):[]):()=>P.columns.distinct(N)),...L?{valueList:!1}:{}},lookup:M.lookup,document:F,value:ne=>P.rows.value(ne.row&&ne.row.key,N),rows:L?()=>[]:M.lookup?void 0:()=>s(P),changed:()=>{const ie=($(J.active)?J.active():!0)&&$(J.get)?J.get():null;P.filters.set(i(P.filters.get(),N,ie||null))},fetchValues:q};let J=null;const ee=L&&!j&&!M.lookup?w(M):null;if(ee&&f(ee)){const ne=L.columnValuesRefusal(N);if(ne){const ie=new g;ie.init({...Y,props:{...Y.props,valueList:!1}}),J=p(F,ie,P.messages.t("filter.valuesUnsupported",{column:M.title||N})),B(`filter:values-unsupported:${N}`,`the filter on column "${N}" cannot list its values: ${ne}. It offers the text condition editor instead.`)}else J=new d,J.init(Y)}else J=z(Y);return J&&(v(J,N,P),D.set(N,J)),J},destroyFilters(){for(const N of D.values())$(N.destroy)&&N.destroy();D.clear()}}}class C{#e;#t;#n;#r;#o;#i=null;#s=[];#l="right";#a=null;#u=!1;#c=!1;constructor(F){this.#e=F.grid,this.#t=F.document,this.#n=F.root,this.#o=x(F.grid,F.document,F.announce);const D=(F.panels||["columns","filters"]).map(N=>X[N]?{name:N,title:W[N]?F.grid.messages.t(W[N]):N,icon:H[N]||N,Ctor:X[N],props:R(N,F.grid)}:(B(`toolpanel:${N}`,`unknown tool panel "${N}"`),null)).filter(Boolean);this.#l=F.side==="left"?"left":"right",this.#r=new _,this.#r.init({document:F.document,host:this.#o,grid:F.grid,panels:D,actions:F.actions,icons:F.icons,side:this.#l,openPanel:F.openPanel})}mount(){const F=this.#t.createElement("div");F.className=`${y} ${y}--${this.#l}`,F.appendChild(this.#r.element()),this.#n.appendChild(F),this.#i=F;const E=this.#r.show.bind(this.#r),D=this.#r.hide.bind(this.#r);this.#r.show=N=>{const M=E(N);return this.#f(),M},this.#r.hide=()=>{D(),this.#f()};for(const N of[...a,"rows:paused","rows:resumed","rows:queued","annotation:changed"])this.#s.push(this.#e.on(N,()=>this.#r.refresh()));this.#s.push(this.#e.on("presentation:started",N=>{this.#u=!0;const M=N&&N.options&&Array.isArray(N.options.chrome)?N.options.chrome:[];this.#c=M.includes("toolPanel")})),this.#s.push(this.#e.on("presentation:ended",()=>{this.#u=!1,this.#c=!1})),this.#s.push(this.#e.on("toolpanel:focus",()=>this.open("columns"))),this.#s.push(this.#e.on("column:profile:open",N=>{const M=N&&N.colId,j=this.#r.panels.find(L=>L.name==="statistics");j&&M!=null&&(j.panel.column=String(M)),this.open("statistics")})),this.#f()}open(F){this.#r.show(F),this.#f()}close(){this.#r.hide(),this.#f()}toggle(F){this.#r.toggle(F),this.#f()}addAction(F){if(!(!F||!F.name)&&!this.#r.actions.some(E=>E.name===F.name)){if(this.#r.registerAction(F),this.#a&&!F.annotation){const E=this.#r.actions.find(D=>D.name===F.name);E&&this.#h(E.button)}else!this.#a&&F.annotation&&this.#u&&!this.#c&&this.#d();this.#f()}}removeAction(F){this.#r.removeAction(F)&&this.#f()}presentOnly(){return this.#a?!0:this.#r.actions.some(F=>F.annotation&&F.button)?(this.#d(),!0):!1}#d(){const F=this.#r;this.#a={hidden:[],reopen:F.openPanel||null},this.#a.reopen&&F.hide(),this.#h(F.body);for(const E of[...F.tabs?.children||[]])E!==F.actionGroup&&this.#h(E);for(const E of[...F.actionGroup?.children||[]]){const D=F.actions.find(N=>N.button===E);(!D||!D.annotation)&&this.#h(E)}this.#i&&this.#i.style&&(this.#i.style.display=""),this.#f()}presentRestore(){const F=this.#a;if(!F)return!1;this.#a=null;for(const E of F.hidden)E.el&&E.el.style&&(E.el.style.display=E.display);return F.reopen&&this.#r.show(F.reopen),this.#f(),!0}#h(F){if(!F||!F.style||!this.#a)return;const E=F.style.display||"";E!=="none"&&(F.style.display="none",this.#a.hidden.push({el:F,display:E}))}#f(){if(!this.#i)return;const F=!!this.#r.openPanel;this.#i.setAttribute("data-open",F?"true":"false"),this.#i.style.width=F?`${O}px`:"";const E=`${F?O:this.#p()}px`;this.#n.style.paddingLeft=this.#l==="left"?E:"",this.#n.style.paddingRight=this.#l==="left"?"":E,this.#n.style.setProperty("--lattice-dock-left",this.#l==="left"?E:"0px"),this.#n.style.setProperty("--lattice-dock-right",this.#l==="left"?"0px":E)}#p(){const F=this.#r&&$(this.#r.element)?this.#r.element().querySelector?.(`.${t.panel}__tabs`):null,E=F&&(F.offsetWidth||F.getBoundingClientRect?.().width)||0;return E>0?Math.ceil(E):k}destroy(){for(const F of this.#s)F();this.#s=[],this.#a=null,this.#o.destroyFilters(),this.#r.destroy(),this.#i&&this.#i.remove&&this.#i.remove(),this.#i=null,this.#n.style.paddingRight=""}}}),Fe("packages/dom/src/celledit.js",function(e,K){"use strict";Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return g}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,_=K("packages/dom/src/editors/index.js").createEditor,X=K("packages/dom/src/editors/common.js"),W=X.CLS,H=X.markInvalid,V=X.isEditable,w=K("packages/dom/src/detailhost.js").insideDetail,A=`${W.editor}-host`;class g{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=-1;#u=[];#c=null;#d=!1;constructor(t){this.#e=t.grid,this.#t=t.document,this.#n=t.renderer,this.#r=t.registry||null,this.#o=t.cellLayer||null}mount(){this.#u.push(this.#e.on("cell:edit:start",m=>this.open(m))),this.#u.push(this.#e.on("cell:edit:end",()=>this.close()));const t=this.#n.viewport.root,r=this.#e.get("edit"),s=r&&typeof r=="object"&&r.start||"double",h=m=>{if(w(m.target,t))return;const c=l(m.target,O=>O.getAttribute&&O.getAttribute("data-col"));if(!c)return;const f=l(c,O=>O.getAttribute&&O.getAttribute("data-key"));if(!f)return;const a=this.#e.rows.byKey(f.getAttribute("data-key"));if(!a||a.group)return;const p=c.getAttribute("data-col"),b=this.#e.columns.get(p);!b||!b.edit||!b.edit.enabled||this.#e.edit.start(a.key,p)},u=s==="key"?null:s==="single"?"click":"dblclick";u&&(t.addEventListener(u,h),this.#u.push(()=>t.removeEventListener(u,h)));const i=m=>{!this.#i||!this.#l||this.#p(m.target)||this.commit()};this.#t.addEventListener("mousedown",i,!0),this.#u.push(()=>this.#t.removeEventListener("mousedown",i,!0))}get target(){return this.#l}open(t){this.close();const r=t.key||t.row&&t.row.key,s=t.colId;if(!r||!s)return;const h=this.#e.columns.get(s),u=this.#e.rows.byKey(r);if(!h||!u||!V({column:h,edit:h.edit,row:u,value:this.#e.rows.value(r,s),grid:this.#e}))return;const i=this.#w(r,s);if(this.#c=i,!i){B("celledit.offscreen","cannot edit a row that is not rendered; scroll to it first.");return}const m=this.#e.permissions,c=!!(m&&$(m.isSecret)&&m.isSecret(s)),f=_({grid:this.#e,column:h,colId:s,row:u,data:u.data,value:c?null:this.#e.rows.value(r,s),text:c?"":this.#e.rows.text(r,s),locale:this.#e.get("locale"),props:h.edit&&h.edit.props,lookup:h.lookup,document:this.#t,cell:i,overlay:this.#n.viewport.overlays,onCommit:b=>this.#f({value:b,key:r,colId:s}),onCancel:()=>{this.#d=!0,this.#e.edit.stop(!0)},stop:b=>{this.#d||this.#e.edit.stop(b)}},this.#r);if(!f){B(`celledit.noeditor:${s}`,`column "${s}" has no editor.`);return}this.#i=f,this.#s=i,this.#l={key:r,colId:s},this.#d=!1,this.#a=this.#b(i);const a=f.element();f.popup?(this.#n.viewport.overlays.appendChild(a),d(a,i,this.#n.viewport.root)):i.replaceChildren(a),i.classList.add(A),$(f.attached)&&f.attached(),o(a);const p=b=>this.#h(b);a.addEventListener("keydown",p),this.#u.push(()=>a.removeEventListener("keydown",p))}#h(t){const r=t.key;if(r!=="Enter"&&r!=="Tab"&&r!=="Escape")return;if(t.preventDefault(),t.stopPropagation(),r==="Escape"){this.#e.edit.stop(!0);return}const s=r==="Enter"?this.#m(t.shiftKey?-1:1):this.#g(t.shiftKey?-1:1);this.commit()&&s&&this.#e.edit.start(s.key,s.colId)}#f(t){this.#d||(this.#d=!0,this.#e.edit.stop(!1,t))}commit(){if(!this.#i||!this.#l)return!1;if(this.#d)return!0;if($(this.#i.cancelOnClose)&&this.#i.cancelOnClose()===!0)return this.#d=!0,this.#e.edit.stop(!0),!0;const{key:t,colId:r}=this.#l;if($(this.#i.value)){const s=this.#i.value();if($(this.#i.validate)){const h=this.#i.validate(s);if(h!==!0){if(H(this.#c,h),$(this.#i.focusTarget)){const u=this.#i.focusTarget();u&&$(u.focus)&&u.focus()}return!1}H(this.#c,null)}this.#f({value:s,key:t,colId:r})}else this.#d=!0,this.#e.edit.stop(!1);return!0}#p(t){if(!t)return!1;const r=$(this.#i.element)?this.#i.element():null;if(r&&$(r.contains)&&r.contains(t))return!0;const s=this.#c;return!!(s&&$(s.contains)&&s.contains(t))}#m(t){if(!this.#l||this.#a<0)return null;for(let r=this.#a+t;r>=0&&r<this.#e.rows.count();r+=t){const s=this.#e.rows.get(r);if(s&&!s.group)return{key:s.key,colId:this.#l.colId}}return null}#g(t){if(!this.#l)return null;const r=this.#e.columns.visible(),s=r.findIndex(h=>h.id===this.#l.colId);for(let h=s+t;h>=0&&h<r.length;h+=t){const u=r[h];if(u.edit&&u.edit.enabled)return{key:this.#l.key,colId:u.id}}return null}#b(t){const r=l(t,h=>h.getAttribute&&h.getAttribute("data-index"));if(!r)return-1;const s=Number(r.getAttribute("data-index"));return Number.isFinite(s)?s:-1}#w(t,r){const s=this.#n.viewport.root;if(!s||!s.querySelectorAll)return null;for(const h of s.querySelectorAll(`[data-col="${r}"]`)){const u=l(h,i=>i.getAttribute&&i.getAttribute("data-key"));if(u&&u.getAttribute("data-key")===t)return h}return null}close(){this.#c&&H(this.#c,null);const t=this.#S();if(this.#i&&$(this.#i.destroy)&&this.#i.destroy(),this.#s){if(this.#s.classList.remove(A),this.#o&&$(this.#o.releaseCell)){const r=this.#l?this.#e.columns.get(this.#l.colId):null;this.#o.releaseCell(this.#s,r)}this.#s.replaceChildren&&this.#s.replaceChildren(),t&&this.#y(this.#s),this.#n.refresh({force:!0})}this.#i=null,this.#c=null,this.#s=null,this.#l=null,this.#a=-1,this.#d=!1}#S(){const t=this.#t.activeElement;if(!t||t===this.#t.body)return!1;const r=this.#i&&$(this.#i.element)?this.#i.element():null,s=h=>!!h&&$(h.contains)&&h.contains(t);return s(r)||s(this.#s)}#y(t){const s=$(t.hasAttribute)&&t.hasAttribute("tabindex")?t:this.#n.viewport.root;s&&$(s.focus)&&s.focus()}destroy(){this.close();for(const t of this.#u)t();this.#u=[]}}function l(n,t){let r=n;for(;r;){if(t(r))return r;r=r.parentNode}return null}function d(n,t,r){if(!$(t.getBoundingClientRect))return;const s=t.getBoundingClientRect(),h=r.getBoundingClientRect();n.style.position="absolute",n.style.top=`${Math.round(s.top-h.top)}px`,n.style.minWidth=`${Math.round(s.width)}px`,n.style.left=`${Math.round(s.left-h.left)}px`;const u=n.offsetWidth||Math.round(s.width),i=Math.round(s.left-h.left)+u-Math.round(h.width);i>0&&(n.style.left=`${Math.max(0,Math.round(s.left-h.left)-i)}px`)}function o(n){const t=n.querySelector&&n.querySelector("input, select, textarea, [tabindex]")||n;$(t.focus)&&t.focus(),$(t.select)&&t.select()}}),Fe("packages/dom/src/editbar.js",function(e,K){"use strict";Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return V}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,_=K("packages/dom/src/editors/index.js").createEditor,H=`${K("packages/dom/src/editors/common.js").CLS.editor}-bar`;class V{#e;#t;#n;#r=null;#o=null;#i=null;#s=null;#l=null;#a=null;#u=!1;#c=null;#d=[];constructor(w){this.#e=w.grid,this.#t=w.document,this.#n=w.root}mount(){const w=this.#t,A=w.createElement("div");A.className=H;const g=w.createElement("span");g.className=`${H}__ref`,g.textContent="";const l=w.createElement("div");l.className=`${H}__slot`;const d=w.createElement("span");d.className=`${H}__readonly`,A.appendChild(g),A.appendChild(l),this.#n.insertBefore(A,this.#n.firstChild),this.#r=A,this.#o=g,this.#i=l,this.#l=d;for(const o of["cell:clicked","cell:edit:start","selection:changed","model:changed","rows:changed"])this.#d.push(this.#e.on(o,n=>this.#f(n)))}bind(w,A){const g=this.#e.columns.get(A),l=w?this.#e.rows.byKey(w):null;this.#a=l&&g&&!l.group?{key:w,colId:A}:null,this.refresh()}refresh(){if(!this.#i||this.#u)return;if(this.#h(),!this.#a){this.#o.textContent="";return}const{key:w,colId:A}=this.#a,g=this.#e.columns.get(A);if(!g)return;if(this.#o.textContent=g.title||A,!!!(g.edit&&g.edit.enabled)){this.#l.textContent=this.#e.rows.text(w,A),this.#i.appendChild(this.#l);return}const d=this.#e.rows.byKey(w);if(!d)return;const o=_({grid:this.#e,column:g,colId:A,row:d,data:d.data,value:this.#e.rows.value(w,A),text:this.#e.rows.text(w,A),locale:this.#e.get("locale"),props:g.edit&&g.edit.props,lookup:g.lookup,document:this.#t,cell:this.#i,overlay:this.#n,stop:h=>h?this.cancel():this.commit(!0)});if(!o){B(`editbar.noeditor:${A}`,`column "${A}" has no editor.`),this.#l.textContent=this.#e.rows.text(w,A),this.#i.appendChild(this.#l);return}this.#s=o;const n=o.element();o.popup?(this.#l.textContent=this.#e.rows.text(w,A),this.#i.appendChild(this.#l)):this.#i.appendChild(n),$(o.attached)&&o.attached();const t=h=>this.#p(h),r=()=>{this.#u=!0},s=[n,this.#i];for(const h of s)h.addEventListener("keydown",t),h.addEventListener("input",r),h.addEventListener("change",r);this.#c=()=>{for(const h of s)h.removeEventListener("keydown",t),h.removeEventListener("input",r),h.removeEventListener("change",r)}}#h(){this.#c&&(this.#c(),this.#c=null),this.#s&&$(this.#s.destroy)&&this.#s.destroy(),this.#s=null,this.#i&&this.#i.replaceChildren&&this.#i.replaceChildren()}cancel(){this.#u=!1,this.refresh()}#f(w){if(w&&w.colId&&(w.key||w.row&&w.row.key)){this.bind(w.key||w.row.key,w.colId);return}this.refresh()}#p(w){if(w.key==="Enter"){w.preventDefault(),this.commit();return}w.key==="Escape"&&(w.preventDefault(),this.cancel())}commit(w){if(!this.#a||!this.#u&&!w)return!1;const{key:A,colId:g}=this.#a;if(!this.#s||!$(this.#s.value))return!1;const l=this.#s.value();return this.#u=!1,this.#e.edit.start(A,g),this.#e.edit.stop(!1,{value:l,key:A,colId:g}),this.refresh(),!0}destroy(){this.#h();for(const w of this.#d)w();this.#d=[],this.#r&&$(this.#r.remove)&&this.#r.remove(),this.#r=null,this.#i=null,this.#o=null,this.#a=null}}}),Fe("packages/dom/src/pastepreview.js",function(e,K){"use strict";Object.defineProperty(e,"PREVIEW_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"PastePreview",{enumerable:!0,get:function(){return z}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),X=_.el,W=_.clear,H="lat-pastepreview",V='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class z{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=null;#a=null;#u=[];constructor(A){this.#e=A.grid,this.#t=A.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#c(A,g){const l=this.#e;return(l&&l.messages?l.messages:I).t(A,g)}#d(A){const g=`paste.preview.reason.${A}`,l=this.#c(g);return l===g?A:l}#h(A){return A==null||A===""?"":String(A)}#f(A,g){const l=this.#e.columns&&$(this.#e.columns.get)?this.#e.columns.get(g):null;return`${l&&(l.title||l.headerName)||g} · ${A}`}show(A,g){const l=this.#w();if(!l)return!1;this.#l=g&&g.onConfirm,this.#a=g&&g.onCancel||null;const d=A&&A.changes||[],o=A&&A.rejected||[],n=d.filter(r=>r.changed);this.#p(n,o);const t=l.ownerDocument;return this.#s=t&&t.activeElement,l.style.display="",$(l.focus)&&l.focus(),this.#y(this.#c("a11y.paste.previewOpened",{count:n.length,changes:n.length,rejected:o.length}),{repeat:!0}),!0}#p(A,g){const l=this.#r.ownerDocument;W(this.#r);const d=X(l,"p",{class:`${H}__summary`,attrs:{role:"status"},text:this.#c("paste.preview.summary",{count:A.length,changes:A.length,rejected:g.length})});if(this.#r.appendChild(d),!A.length&&!g.length){this.#r.appendChild(X(l,"p",{class:`${H}__empty`,text:this.#c("paste.preview.empty")})),this.#o.disabled=!A.length;return}this.#o.disabled=!A.length,A.length&&(this.#r.appendChild(X(l,"h3",{class:`${H}__heading`,text:this.#c("paste.preview.changesHeading",{count:A.length})})),this.#r.appendChild(this.#m(l,A))),g.length&&(this.#r.appendChild(X(l,"h3",{class:`${H}__heading ${H}__heading--rejected`,text:this.#c("paste.preview.rejectedHeading",{count:g.length})})),this.#r.appendChild(this.#g(l,g)))}#m(A,g){const l=X(A,"tr",{children:[X(A,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),X(A,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colOld")}),X(A,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colNew")})]}),d=g.map(o=>X(A,"tr",{children:[X(A,"th",{attrs:{scope:"row"},text:this.#f(o.key,o.colId)}),X(A,"td",{class:`${H}__old`,text:this.#h(o.oldValue)}),X(A,"td",{class:`${H}__new`,text:this.#h(o.newValue)})]}));return X(A,"table",{class:`${H}__table`,children:[X(A,"thead",{children:[l]}),X(A,"tbody",{children:d})]})}#g(A,g){const l=X(A,"tr",{children:[X(A,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),X(A,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colReason")})]}),d=g.map(o=>X(A,"tr",{children:[X(A,"th",{attrs:{scope:"row"},text:this.#f(o.key,o.colId)}),X(A,"td",{class:`${H}__reason`,text:this.#d(o.reason)})]}));return X(A,"table",{class:`${H}__table ${H}__table--rejected`,children:[X(A,"thead",{children:[l]}),X(A,"tbody",{children:d})]})}confirm(){const A=this.#l;this.#b(),$(A)&&A()}cancel(){const A=this.#a;this.#b(),this.#y(this.#c("a11y.paste.cancelled"),{repeat:!0}),$(A)&&A()}#b(){if(!this.#n)return;this.#n.style.display="none",this.#l=null,this.#a=null;const A=this.#s;this.#s=null,A&&$(A.focus)&&A.focus()}#w(){if(this.#n)return this.#n;const A=this.#t.viewport&&this.#t.viewport.overlays,g=A&&A.ownerDocument;if(!A||!g||!$(g.createElement))return null;const l=`${H}-title`,d=X(g,"h2",{class:`${H}__title`,attrs:{id:l},text:this.#c("paste.preview.title")}),o=X(g,"div",{class:`${H}__body`}),n=X(g,"button",{class:`${H}__confirm`,attrs:{type:"button"},text:this.#c("paste.preview.confirm")}),t=X(g,"button",{class:`${H}__cancel`,attrs:{type:"button"},text:this.#c("paste.preview.cancel")}),r=X(g,"div",{class:`${H}__foot`,children:[t,n]}),s=X(g,"div",{class:H,attrs:{role:"dialog","aria-modal":"true",tabindex:"-1","aria-labelledby":l},children:[X(g,"div",{class:`${H}__head`,children:[d]}),o,r]});return A.appendChild(s),this.#n=s,this.#r=o,this.#o=n,this.#i=t,this.#S(s,n,t),s}#S(A,g,l){const d=t=>{if(t.stopPropagation(),t.key==="Escape"){t.preventDefault(),this.cancel();return}if(t.key!=="Tab")return;const r=[...A.querySelectorAll(V)].filter(i=>!i.disabled);if(!r.length){t.preventDefault();return}const s=r[0],h=r[r.length-1],u=A.ownerDocument.activeElement;t.shiftKey&&(u===s||u===A)?(t.preventDefault(),h.focus()):!t.shiftKey&&u===h&&(t.preventDefault(),s.focus())},o=t=>{t&&$(t.preventDefault)&&t.preventDefault(),this.confirm()},n=t=>{t&&$(t.preventDefault)&&t.preventDefault(),this.cancel()};A.addEventListener("keydown",d),g.addEventListener("click",o),l.addEventListener("click",n),this.#u.push(()=>{A.removeEventListener("keydown",d),g.removeEventListener("click",o),l.removeEventListener("click",n)})}#y(A,g){const l=this.#t&&this.#t.announce;$(l)&&l.call(this.#t,A,g)}destroy(){for(const A of this.#u)A();this.#u=[],this.#n&&this.#n.parentNode&&this.#n.parentNode.removeChild(this.#n),this.#n=null,this.#r=null,this.#o=null,this.#i=null,this.#s=null,this.#l=null,this.#a=null}}}),Fe("packages/dom/src/rangeselect.js",function(e,K){"use strict";Object.defineProperty(e,"RangeController",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/core/src/model/selection.js"),X=_.extendSeries,W=_.resolveSelectionConfig,H=K("packages/dom/src/renderer/textentry.js"),V=H.isTextEntry,z=H.isFindBarControl,A=K("packages/dom/src/pastepreview.js").PastePreview,g=K("packages/dom/src/columnmenu.js"),l=g.chartableRange,d=g.rangeChartConfig,o="lat-cell--range",n="lat-cell--range-edge",t=Object.freeze({top:"lat-cell--range-top",right:"lat-cell--range-right",bottom:"lat-cell--range-bottom",left:"lat-cell--range-left"}),r=3;class s{#e;#t;#n;#r=!1;#o=[];#i=null;#s=null;#l=null;#a=null;#u=null;constructor(i){this.#e=i.grid,this.#t=i.renderer,this.#n=i.document,this.#a=i.preview||null}mount(){const i=this.#t.viewport.root,m=p=>this.#c(p),c=p=>this.#d(p),f=()=>this.#h(),a=p=>this.#f(p);i.addEventListener("pointerdown",m),this.#n.addEventListener("pointermove",c),this.#n.addEventListener("pointerup",f),i.addEventListener("keydown",a),this.#o.push(()=>{i.removeEventListener("pointerdown",m),this.#n.removeEventListener("pointermove",c),this.#n.removeEventListener("pointerup",f),i.removeEventListener("keydown",a)});for(const p of["range:changed","rows:changed","model:changed","scroll"])this.#o.push(this.#e.on(p,()=>this.paint()));this.paint()}#c(i){if(i.button!==0)return;const m=i.target;if(!m||!$(m.closest))return;if(this.#r=!1,m.closest('[data-role="fill-handle"]')){if(this.#E())return;this.#i={mode:"fill",fromX:i.clientX,fromY:i.clientY,armed:!0};return}if(m.closest('[data-role="row-drag"]'))return;const c=this.#$(m);if(!c)return;if(i.shiftKey&&this.#e.selection.corner()){const a=this.#C(c);this.#e.selection.extendRange(a.rowIndex,a.colId),this.#i={mode:"select",fromX:i.clientX,fromY:i.clientY,armed:!0};return}const f=this.#M(c);this.#u=f,this.#e.selection.startRange(f.rowIndex,f.colId,{additive:i.ctrlKey||i.metaKey}),this.#i={mode:"select",fromX:i.clientX,fromY:i.clientY,armed:!1}}#d(i){const m=this.#i;if(!m)return;if(!m.armed){if(Math.abs(i.clientX-m.fromX)+Math.abs(i.clientY-m.fromY)<r)return;m.armed=!0}const c=this.#z(i.clientX,i.clientY);if(!c)return;if(m.mode==="fill"){this.#l=c,this.paint();return}const f=this.#C(c);this.#e.selection.extendRange(f.rowIndex,f.colId)}#h(){const i=this.#i;if(this.#i=null,!!i){if(i.mode==="fill"&&this.#l){const m=this.#l;this.#l=null,this.fillTo(m.rowIndex)}this.#l=null,this.paint()}}#f(i){if(this.#B()||z(i.target)||V(i.target))return;const m=i.ctrlKey||i.metaKey,c=i.key;if(m&&(c==="c"||c==="C")){this.copy(),i.preventDefault();return}if(m&&(c==="v"||c==="V")){this.paste(),i.preventDefault();return}if(m&&(c==="d"||c==="D")){this.fillDown(),i.preventDefault();return}if(m&&!i.altKey&&(c==="z"||c==="Z"||c==="y"||c==="Y")){const S=this.#e.edit;if(!S||S.undoShortcuts===!1)return;const x=c==="y"||c==="Y"||i.shiftKey;this.#y(x)&&i.preventDefault();return}if(c==="Delete"||c==="Backspace"){if(!this.#e.selection.cells().length&&this.#e.selection.keys().length&&this.#e.get("rowDelete")===!0){this.#e.edit.deleteRows(),i.preventDefault();return}if(this.#e.edit&&this.#e.edit.clearOnDelete===!1)return;this.clear(),i.preventDefault();return}if(i.altKey&&c==="F1"){this.chartSelection()&&i.preventDefault();return}if(!i.shiftKey)return;const f={ArrowDown:[1,0],ArrowUp:[-1,0],ArrowRight:[0,1],ArrowLeft:[0,-1]}[c];if(!f)return;if(m){const S=this.#N();if(!S)return;if(!this.#r){const E=this.#M(S);this.#u=E,this.#e.selection.startRange(E.rowIndex,E.colId,{additive:!0}),this.#r=!0}const x=this.#e.columns.visible().map(E=>E.id),C=x.indexOf(S.colId),P=this.#e.selection.corner()||{row:S.rowIndex,colId:S.colId},F=this.#C({rowIndex:Math.min(this.#e.rows.count()-1,Math.max(0,P.row+f[0])),colId:x[Math.min(x.length-1,Math.max(0,(C<0?0:C)+f[1]))]});this.#e.selection.extendRange(F.rowIndex,F.colId),i.preventDefault();return}this.#r=!1;const a=this.#e.selection.corner(),p=this.#N(),b=a||p;if(!b)return;if(!a&&p){const S=this.#M(p);this.#u=S,this.#e.selection.startRange(S.rowIndex,S.colId)}const O=this.#e.columns.visible().map(S=>S.id),k=O.indexOf(b.colId??b.colId),y=O[Math.min(O.length-1,Math.max(0,k+f[1]))],v=Math.min(this.#e.rows.count()-1,Math.max(0,(a?a.row:p.rowIndex)+f[0])),R=this.#C({rowIndex:v,colId:y});this.#e.selection.extendRange(R.rowIndex,R.colId),i.preventDefault()}async copy(){const i=this.#e.export.rangeText();if(!i)return this.#e.selection.ranges().length>1&&this.#e.emit("clipboard:copy",{text:"",ok:!1,rows:"range",reason:"discontiguous"},"user"),!1;const m=globalThis.navigator&&globalThis.navigator.clipboard;if(!m||!$(m.writeText))return!1;try{return await m.writeText(i),this.#e.emit("clipboard:copy",{text:i,ok:!0,rows:"range"},"user"),!0}catch{return this.#e.emit("clipboard:copy",{text:i,ok:!1,rows:"range"},"user"),!1}}async paste(){const i=globalThis.navigator&&globalThis.navigator.clipboard;if(!i||!$(i.readText))return 0;let m="";try{m=await i.readText()}catch{return 0}return this.pasteText(m)}pasteText(i){if(!i)return 0;const m=this.#e.selection.cells(),c=m.length?m[0]:this.#S();if(!c)return 0;const f=m.length>1?{rows:new Set(m.map(a=>a.key)).size,columns:new Set(m.map(a=>a.colId)).size}:void 0;if(this.#p()){const a=this.#e.edit.previewPaste(c,i,f);if(a.changes.length+a.rejected.length>1)return this.#m().show(a,{onConfirm:()=>this.#g(c,i,f)}),0}return this.#g(c,i,f)}#p(){const i=this.#e.edit;return!!(i&&i.pastePreview&&$(i.previewPaste))}#m(){return this.#a||(this.#a=new A({grid:this.#e,renderer:this.#t})),this.#a}#g(i,m,c){const f=this.#e.edit.pasteInto(i,m,c,{origin:"user"}),a=p=>this.#w(p?this.#b("a11y.range.written",{count:p}):this.#b("a11y.range.refused"),{repeat:!0});return f&&$(f.then)?f.then(a):a(f),f}#b(i,m){const c=this.#e;return(c&&c.messages?c.messages:I).t(i,m)}#w(i,m){const c=this.#t&&this.#t.announce;$(c)&&c.call(this.#t,i,m)}#S(){const i=this.#N();if(!i)return null;const m=this.#e.rows.get(i.rowIndex);return m?{key:m.key,colId:i.colId}:null}#y(i){const m=this.#e.history;return!(!m||!(i?m.canRedo():m.canUndo())||!(i?m.redo():m.undo()))}clear(){let i=this.#e.selection.cells();const m=this.#S(),c=this.#n&&this.#n.activeElement;if(!!(m&&c&&$(c.matches)&&c.matches('[data-col][tabindex="0"]'))&&!i.some(b=>b.key===m.key&&b.colId===m.colId)?i=[m]:i.length||(i=m?[m]:[]),!i.length)return 0;const a=this.#e.edit.setCells(i.map(b=>({key:b.key,colId:b.colId,value:null})),"cell",{origin:"user"}),p=b=>{b&&this.#w(this.#b("a11y.range.cleared",{count:b}),{repeat:!0})};return a&&$(a.then)?a.then(p):p(a),a}fillDown(){if(this.#e.selection.ranges().length>1)return 0;const i=this.#e.selection.cells();if(i.length<2)return 0;const m=[...new Set(i.map(a=>a.key))];if(m.length<2)return 0;const c=m[0],f=[];for(const{key:a,colId:p}of i)a!==c&&f.push({key:a,colId:p,value:this.#e.rows.value(c,p)});return this.#e.edit.setCells(f,"cell",{origin:"user"})}chartSelection(){const i=d(this.#e);if(!i.handler)return!1;const m=l(this.#e);return m?(i.handler(this.#e,m),!0):!1}fillTo(i){if(this.#e.selection.ranges().length>1)return 0;const m=this.#e.selection.cells();if(!m.length)return 0;const c=[...new Set(m.map(y=>y.key))],f=[...new Set(m.map(y=>y.colId))],a=this.#U(c[c.length-1]);if(a<0||i<=a)return 0;const p=[];for(let y=a+1;y<=i;y++){const v=this.#e.rows.get(y);if(!v)break;p.push(v)}if(!p.length)return 0;const b=[];for(const y of f){const v=c.map(S=>this.#e.rows.value(S,y)),R=this.#O(v,p,y);for(let S=0;S<p.length;S++)b.push({key:p[S].key,colId:y,value:R[S]})}const O=this.#e.edit.setCells(b,"cell",{origin:"user"}),k=this.#e.selection.corner();return k&&this.#e.selection.extendRange(i,k.colId),O}#O(i,m,c){const f=this.#e.get("selection"),a=f&&typeof f=="object"?f.fill:void 0;if($(a)){const p=this.#e.columns.get(c),b=m.map(k=>({row:k,column:p})),O=a({source:i,target:b,direction:"down"});if(Array.isArray(O)&&O.length===m.length)return O}return X(i,m.length)}paint(){const i=this.#t.viewport.root;if(!i||!i.querySelectorAll)return;const m=this.#e.selection,c=m.ranges().length>0,f=this.#l;for(const a of i.querySelectorAll("[data-col]")){const p=a.getAttribute("data-col"),b=a.parentNode,O=a.getAttribute?a.getAttribute("data-index"):null,k=O!==null&&O!==""?O:b&&b.getAttribute?b.getAttribute("data-index"):null;if(k===null||k==="")continue;const y=Number(k);if(!Number.isFinite(y)||y<0)continue;const v=c&&m.inRange(y,p),R=!!f&&this.#k(y,p,f);a.classList.toggle(o,v||R);const S=v||R?this.#j(y,p,m):null;a.classList.toggle(n,!!S&&S.any);for(const[x,C]of Object.entries(t))a.classList.toggle(C,!!S&&S[x])}this.#A()}#k(i,m,c){const f=this.#e.selection.cells();if(!f.length||!new Set(f.map(b=>b.colId)).has(m))return!1;const p=this.#U([...new Set(f.map(b=>b.key))].pop());return i>p&&i<=c.rowIndex}#j(i,m,c){const f=this.#e.columns.visible().map(k=>k.id),a=f.indexOf(m),p=a>0?f[a-1]:null,b=a>=0&&a<f.length-1?f[a+1]:null,O={top:!c.inRange(i-1,m),bottom:!c.inRange(i+1,m),left:!p||!c.inRange(i,p),right:!b||!c.inRange(i,b)};return O.any=O.top||O.bottom||O.left||O.right,O}#A(){const i=this.#e.selection.corner(),m=this.#t.viewport.overlays;if(!m)return;if(!i||this.#x()===!1||this.#e.selection.ranges().length>1||this.#E()){this.#s&&(this.#s.style.display="none");return}const c=this.#_(i.row,i.colId);if(!c||!$(c.getBoundingClientRect)){this.#s&&(this.#s.style.display="none");return}this.#s||(this.#s=this.#n.createElement("div"),this.#s.className="lat-fill-handle",this.#s.setAttribute("data-role","fill-handle"),this.#s.setAttribute("title",this.#b("a11y.fillHandle")),m.appendChild(this.#s));const f=c.getBoundingClientRect(),a=this.#t.viewport.root.getBoundingClientRect();this.#s.style.display="";const b=this.#t.viewport.rtl===!0?f.left:f.right;this.#s.style.left=`${Math.round(b-a.left)-4}px`,this.#s.style.top=`${Math.round(f.bottom-a.top)-4}px`}#T(i){const m=this.#t;return!i||typeof m.spanAt!="function"?null:m.spanAt(i.rowIndex,i.colId)}#M(i){const m=this.#T(i);return m?{rowIndex:m.row,colId:m.columnId}:i}#C(i){const m=this.#T(i);if(!m)return i;const c=this.#u,f=!!c&&c.rowIndex>=m.row+m.rows,a=this.#L(),p=c?a.indexOf(c.colId):-1,b=p>=0&&p>=m.col+m.cols;return{rowIndex:f?m.row:m.row+m.rows-1,colId:b?m.columnId:m.endColumnId}}#E(){const i=this.#e.selection.corner();if(!i)return!1;const m=this.#T({rowIndex:i.row,colId:i.colId});return!!m&&(m.rows>1||m.cols>1)}#L(){const i=this.#e.columns;return i&&$(i.visible)?i.visible().map(m=>m.id):[]}#x(){return W(this.#e.get("selection")).fillHandle}#B(){const i=this.#t.viewport.root;return!!(i&&i.querySelector&&i.querySelector(".lat-editor-host, .lat-editor--popup"))}#H(){const i=this.#e.selection.cells();return i.length?i[0]:null}#U(i){for(let m=0;m<this.#e.rows.count();m++){const c=this.#e.rows.get(m);if(c&&c.key===i)return m}return-1}#N(){const i=this.#t.viewport.root,m=i&&i.querySelector?i.querySelector('[data-col][tabindex="0"]'):null;return m?this.#$(m):null}#$(i){if(!i||!$(i.closest))return null;const m=i.closest("[data-col]");if(!m||!m.classList.contains("lat-cell"))return null;const c=m.closest("[data-index]");if(!c)return null;const f=Number(c.getAttribute("data-index"));return!Number.isFinite(f)||f<0?null:{rowIndex:f,colId:m.getAttribute("data-col")}}#z(i,m){const c=this.#n.elementFromPoint?this.#n.elementFromPoint(i,m):null;return c?this.#$(c):null}#_(i,m){const c=this.#t.viewport.root;if(!c||!c.querySelectorAll)return null;for(const f of c.querySelectorAll(`[data-col="${m}"]`)){const a=f.closest?f.closest("[data-index]"):null;if(a&&Number(a.getAttribute("data-index"))===i)return f}return null}destroy(){for(const i of this.#o)i();this.#o=[],this.#s&&$(this.#s.remove)&&this.#s.remove(),this.#s=null,this.#i=null,this.#l=null,this.#a&&$(this.#a.destroy)&&this.#a.destroy(),this.#a=null}}const h=s}),Fe("packages/dom/src/importer.js",function(e,K){"use strict";Object.defineProperty(e,"IMPORT_DIALOG_CLASS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ImportController",{enumerable:!0,get:function(){return s}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/core/src/import/index.js"),X=_.parseDelimited,W=_.inferColumns,H=_.mapRecords,V=_.readXlsx,z=_.looksLikeXlsx,w=K("packages/dom/src/editors/common.js"),A=w.el,g=w.clear,l=w.on,o=K("packages/dom/src/renderer/textentry.js").isTextEntry,n="lat-import",t='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',r=".csv,.tsv,.txt,.xlsx,text/csv,text/tab-separated-values,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";class s{#e;#t;#n;#r;#o=[];#i=null;#s=null;#l=null;#a=null;constructor(u){this.#e=u.grid,this.#t=u.renderer,this.#n=u.document;const i=u.settings&&typeof u.settings=="object"?u.settings:{};this.#r={file:i.file!==!1,drop:i.drop!==!1,paste:i.paste!==!1,mode:i.mode==="replace"?"replace":"append"},this.#u()}#u(){const u=this.#t&&this.#t.viewport?this.#t.viewport.root:null;u&&(this.#r.drop&&(this.#o.push(l(u,"dragover",i=>{i.dataTransfer&&[...i.dataTransfer.types||[]].includes("Files")&&(i.preventDefault(),u.classList.add("lat-import--dropzone"))})),this.#o.push(l(u,"dragleave",()=>u.classList.remove("lat-import--dropzone"))),this.#o.push(l(u,"drop",i=>{u.classList.remove("lat-import--dropzone");const m=i.dataTransfer&&i.dataTransfer.files&&i.dataTransfer.files[0];m&&(i.preventDefault(),this.#c(m))}))),this.#r.paste&&this.#o.push(l(u,"paste",i=>{if(o(i.target)||this.#e.edit.isEditing?.()||this.#e.selection&&this.#e.selection.cells().length)return;const m=i.clipboardData&&i.clipboardData.getData("text/plain");!m||!m.includes(`
|
|
57
|
-
`)||(i.preventDefault(),this.fromText(m))})))}openFile(){const u=A(this.#n,"input",{attrs:{type:"file",accept:r}});u.style.display="none",this.#o.push(l(u,"change",()=>{const i=u.files&&u.files[0];i&&this.#c(i),u.parentNode&&u.parentNode.removeChild(u)})),this.#n.body.appendChild(u),u.click()}#c(u){if($(u.arrayBuffer)){u.arrayBuffer().then(m=>{const c=new Uint8Array(m);if(z(c)){this.fromXlsx(c,u.name);return}this.fromText(new TextDecoder().decode(c),u.name)});return}if($(u.text)){u.text().then(m=>this.fromText(m,u.name));return}const i=new this.#n.defaultView.FileReader;i.onload=()=>this.fromText(String(i.result||""),u.name),i.readAsText(u)}async fromXlsx(u,i){const{header:m,rows:c}=await V(u);if(!m.length)return;const f=W(m,c,{columns:this.#e.columns.all()}),a=c.filter(p=>p.length!==m.length).length;this.#l={rows:c,columns:f,delimiter:null,name:i,warnings:a?[`${a} row(s) do not have ${m.length} columns`]:[]},this.#d()}fromText(u,i){const{header:m,rows:c,delimiter:f}=X(u);if(!m.length)return;const a=W(m,c,{columns:this.#e.columns.all()}),p=c.filter(b=>b.length!==m.length).length;this.#l={rows:c,columns:a,delimiter:f,name:i,warnings:p?[`${p} row(s) do not have ${m.length} columns`]:[]},this.#d()}#d(){this.#i||this.#p(),this.#m(),this.#a=this.#n.activeElement,this.#i.hidden=!1;const u=this.#i.querySelector(t);u&&$(u.focus)&&u.focus(),this.#h(this.#f("import.opened",{count:this.#l.rows.length}),{repeat:!0})}#h(u,i){const m=this.#t&&this.#t.announce;$(m)&&m.call(this.#t,u,i)}#f(u,i){return(this.#e&&this.#e.messages?this.#e.messages:I).t(u,i)}#p(){const u=this.#n,i=A(u,"div",{class:n,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#f("import.title"),hidden:!0}}),m=A(u,"div",{class:`${n}__panel`});m.appendChild(A(u,"h2",{class:`${n}__title`,text:this.#f("import.title")})),this.#s=A(u,"div",{class:`${n}__body`}),m.appendChild(this.#s);const c=A(u,"div",{class:`${n}__footer`}),f=A(u,"button",{class:`${n}__cancel`,text:this.#f("import.cancel"),attrs:{type:"button"}}),a=A(u,"button",{class:`${n}__confirm`,text:this.#f("import.confirm"),attrs:{type:"button"}});this.#o.push(l(f,"click",()=>this.close())),this.#o.push(l(a,"click",()=>this.#g())),c.appendChild(f),c.appendChild(a),m.appendChild(c),i.appendChild(m),this.#o.push(l(i,"keydown",b=>{if(b.key==="Escape"){b.preventDefault(),this.close();return}if(b.key!=="Tab")return;const O=[...i.querySelectorAll(t)].filter(v=>!v.hidden);if(!O.length)return;const k=O[0],y=O[O.length-1];b.shiftKey&&this.#n.activeElement===k?(b.preventDefault(),y.focus()):!b.shiftKey&&this.#n.activeElement===y&&(b.preventDefault(),k.focus())})),(this.#t.viewport&&this.#t.viewport.overlays||this.#n.body).appendChild(i),this.#i=i}#m(){const u=this.#n,i=g(this.#s),{rows:m,columns:c,name:f,warnings:a}=this.#l;i.appendChild(A(u,"p",{class:`${n}__summary`,text:this.#f("import.summary",{count:m.length,name:f||this.#f("import.clipboard")})}));for(const v of a)i.appendChild(A(u,"p",{class:`${n}__warning`,text:v}));const p=this.#e.columns.all().map(v=>v.field||v.id).filter(Boolean),b=A(u,"table",{class:`${n}__map`}),O=A(u,"tr",{});for(const v of["import.colSource","import.colField","import.colType"])O.appendChild(A(u,"th",{text:this.#f(v)}));b.appendChild(O),c.forEach((v,R)=>{const S=A(u,"tr",{});S.appendChild(A(u,"td",{text:v.source}));const x=A(u,"select",{attrs:{"data-col":String(R),"aria-label":this.#f("import.mapLabel",{source:v.source})}});x.appendChild(A(u,"option",{text:this.#f("import.skip"),attrs:{value:""}}));for(const P of p)x.appendChild(A(u,"option",{text:P,attrs:{value:P,selected:P===v.field?!0:null}}));v.field&&!p.includes(v.field)&&x.appendChild(A(u,"option",{text:v.field,attrs:{value:v.field,selected:!0}}));const C=A(u,"td",{});C.appendChild(x),S.appendChild(C),S.appendChild(A(u,"td",{class:`${n}__type`,text:v.type})),b.appendChild(S)}),i.appendChild(b);const k=A(u,"div",{class:`${n}__mode`}),y=A(u,"select",{attrs:{"aria-label":this.#f("import.modeLabel"),"data-mode":"mode"}});y.appendChild(A(u,"option",{text:this.#f("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),y.appendChild(A(u,"option",{text:this.#f("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),k.appendChild(A(u,"label",{text:this.#f("import.modeLabel")})),k.appendChild(y),i.appendChild(k)}#g(){const{rows:u,columns:i}=this.#l;for(const p of this.#i.querySelectorAll("select[data-col]")){const b=Number(p.getAttribute("data-col"));i[b]&&p.value!==void 0&&p.value!==null&&(i[b].field=p.value)}const m=this.#i.querySelector("select[data-mode]"),c=m?m.value:void 0,f=c==="replace"||c==="append"?c:this.#r.mode,a=H(u,i);this.#e.import.apply(a,{mode:f}),this.close(),this.#h(this.#f("import.done",{count:a.length}),{repeat:!0})}close(){this.#i&&(this.#i.hidden=!0),this.#l=null,this.#a&&$(this.#a.focus)&&this.#a.focus(),this.#a=null}destroy(){for(const u of this.#o)u();this.#o=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null}}}),Fe("packages/dom/src/historybar.js",function(e,K){"use strict";Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return A}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),X=_.el,W=_.on,H=_.clear,V=_.documentFor,z="lat-history";class w{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(l,d){return(this.messages&&typeof this.messages.t=="function"?this.messages:I).t(l,d)}init(l){this.messages=l&&l.messages||l&&l.grid&&l.grid.messages||I;const d=l||{};if(this.doc=V(d),this.host=d.host||{},this.props=d.props||{},this.root=X(this.doc,"div",{class:["lattice-tokens",z],attrs:{role:"group","aria-label":this.t("history.title")}}),this.undoButton=this.#e("undo","Undo","↶"),this.redoButton=this.#e("redo","Redo","↷"),this.root.appendChild(this.undoButton),this.root.appendChild(this.redoButton),this.props.timeline!==!1){const o=X(this.doc,"button",{class:`${z}__toggle`,text:"▾",attrs:{type:"button","aria-haspopup":"menu","aria-expanded":"false","aria-label":this.t("history.show")}});this.off.push(W(o,"click",()=>this.toggle())),this.root.appendChild(o),this.toggleButton=o,this.menu=X(this.doc,"div",{class:`${z}__menu`,attrs:{role:"menu"}}),this.menu.style.display="none",this.root.appendChild(this.menu)}this.refresh()}#e(l,d,o){const n=X(this.doc,"button",{class:`${z}__${l}`,attrs:{type:"button"},children:[X(this.doc,"span",{class:`${z}__glyph`,text:o,attrs:{"aria-hidden":"true"}}),X(this.doc,"span",{class:`${z}__label`,text:d})]});return this.off.push(W(n,"click",()=>{const t=this.host[l];$(t)&&t(),this.refresh()})),n}element(){return this.root}refresh(){if(!this.root)return;const l=this.host,d=$(l.canUndo)?l.canUndo():!1,o=$(l.canRedo)?l.canRedo():!1,n=$(l.peek)?l.peek("undo"):null,t=$(l.peek)?l.peek("redo"):null;this.#t(this.undoButton,"undo",d,n),this.#t(this.redoButton,"redo",o,t),this.open&&this.#n()}#t(l,d,o,n){if(!l)return;l.disabled=!o;const t=d==="undo",r=this.t(t?"history.undo":"history.redo"),s=l.querySelector(`.${z}__label`);s&&(s.textContent=r);const h=n&&n.label?this.t("history.described",{action:r,label:n.label}):r;l.setAttribute("title",o?h:this.t(t?"history.nothingToUndo":"history.nothingToRedo")),l.setAttribute("aria-label",o?h:this.t(t?"history.undoDisabled":"history.redoDisabled"))}toggle(){this.menu&&(this.open=!this.open,this.menu.style.display=this.open?"":"none",this.toggleButton&&this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open&&this.#n())}#n(){const l=this.menu;if(!l)return;H(l);const d=$(this.host.list)?this.host.list():[];if(!d.length){l.appendChild(X(this.doc,"p",{class:`${z}__empty`,text:this.t("history.empty")}));return}d.forEach((o,n)=>{const t=X(this.doc,"button",{class:`${z}__item`,attrs:{type:"button",role:"menuitem","data-type":o.type,"data-undone":o.undone?"true":null},children:[X(this.doc,"span",{class:`${z}__kind`,text:o.type}),X(this.doc,"span",{class:`${z}__text`,text:o.label||o.type})]});this.off.push(W(t,"click",()=>{const r=n+1;for(let s=0;s<r;s++)$(this.host.undo)&&this.host.undo();this.toggle(),this.refresh()})),l.appendChild(t)})}destroy(){for(const l of this.off)l();this.off=[],this.root&&$(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const A=w}),Fe("packages/dom/src/diffpaint.js",function(e,K){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"diffConfigured",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,_=K("packages/core/src/i18n/index.js").defaultMessages,X={changed:"lat-row--changed",added:"lat-row--added",removed:"lat-row--removed"},W="lat-cell--changed",H="lat-cell--added-column";class V{#e;#t;#n=[];constructor(g){this.#e=g.grid,this.#t=g.renderer}mount(){for(const g of["render:done","diff:changed","rows:changed","model:changed","cell:changed","scroll"])this.#n.push(this.#e.on(g,()=>this.paint()));this.paint()}paint(){const g=this.#t.viewport.root;if(!g||!g.querySelectorAll)return;const l=this.#e.diff,d=l&&l.enabled;for(const o of g.querySelectorAll("[data-key]")){const n=o.getAttribute("data-key"),t=d?l.statusOf(n):"unchanged";for(const s of Object.values(X))o.classList.remove(s);d&&X[t]&&o.classList.add(X[t]),o.setAttribute("data-diff",d?t:"");const r=d&&t==="changed";for(const s of o.querySelectorAll("[data-col]")){const h=s.getAttribute("data-col");if(s.classList.remove(W,H),s.removeAttribute("data-before"),!r)continue;const u=l.cellStatus(n,h);if(u==="changed"){s.classList.add(W);const i=this.#r(l,n,h);i===null?s.removeAttribute("title"):(s.setAttribute("data-before",i),s.setAttribute("title",this.#o("diff.before",{value:i})))}else u==="added-column"&&s.classList.add(H)}}}#r(g,l,d){const o=this.#e,n=o&&o.columns,t=n&&$(n.get)?n.get(d):null,r=o&&o.permissions;if(t&&r&&$(r.isSecret)&&r.isSecret(t))return null;const s=g.before(l,d);if(s==null)return this.#o("diff.empty");if(!t||!$(t.formatValue))return String(s);const h=$(g.beforeRow)?g.beforeRow(l):void 0,i={...(o.rows&&$(o.rows.byKey)?o.rows.byKey(l):null)||{},data:h===void 0?{}:h};try{const m=t.formatValue(s,i,i.data);return m==null?"":String(m)}catch(m){return B(`diff-before-format:${d}`,`the formatter for column "${d}" threw while formatting a previous value, so the diff hover shows the raw one.`,m),String(s)}}#o(g,l){const d=this.#e;return(d&&d.messages?d.messages:_).t(g,l)}destroy(){for(const l of this.#n)l();this.#n=[];const g=this.#t.viewport.root;if(!(!g||!g.querySelectorAll)){for(const l of g.querySelectorAll("[data-key]")){for(const d of Object.values(X))l.classList.remove(d);l.removeAttribute("data-diff")}for(const l of g.querySelectorAll("[data-col]"))l.classList.remove(W,H),l.removeAttribute("data-before")}}}function z(A){return!!(A&&A.diff&&($(A.diff)||typeof A.diff=="object"))}const w=V}),Fe("packages/dom/src/highlightpaint.js",function(e,K){"use strict";Object.defineProperty(e,"HighlightPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const $=K("packages/core/src/internal/util.js").isFunction,B="lat-cell--highlight",I="--lattice-cell-highlight";class _{#e;#t;#n=[];#r=null;#o=!1;#i;constructor(H){this.#e=H.grid,this.#t=H.renderer,this.#i=H.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("highlight:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#o)return;this.#o=!0;const H=()=>{this.#o=!1,this.paint()};$(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(H):$(this.#i.setTimeout)?this.#i.setTimeout(H,0):H()}paint(){const H=this.#t.viewport?.root;if(!H||!H.querySelectorAll)return;const V=this.#l();if(V){V.sweep();for(const z of H.querySelectorAll("[data-key]")){const w=z.getAttribute("data-key");for(const A of z.querySelectorAll("[data-col]")){const g=V.active?V.colourFor(w,A.getAttribute("data-col")):null;g?(A.classList.add(B),A.style.setProperty(I,g)):A.classList.contains(B)&&(A.classList.remove(B),A.style.removeProperty(I))}}this.#s(V)}}#s(H){this.#r!==null&&$(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const V=H.nextExpiry;if(!Number.isFinite(V)||!$(this.#i.setTimeout))return;const z=Math.max(0,V-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},z)}#l(){const H=this.#e.highlight;return H&&$(H.model)?H.model():null}destroy(){this.#r!==null&&$(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const V of this.#n)V();this.#n=[];const H=this.#t.viewport?.root;if(!(!H||!H.querySelectorAll))for(const V of H.querySelectorAll(`.${B}`))V.classList.remove(B),V.style.removeProperty(I)}}const X=_}),Fe("packages/dom/src/findpaint.js",function(e,K){"use strict";Object.defineProperty(e,"MATCH_CLASS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"CURRENT_CLASS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"FindPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const $=K("packages/core/src/internal/util.js").isFunction,B="lat-cell--find",I="lat-cell--find-current";class _{#e;#t;#n=[];#r=!1;#o=!1;#i;constructor(H){this.#e=H.grid,this.#t=H.renderer,this.#i=H.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("find:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#r)return;this.#r=!0;const H=()=>{this.#r=!1,this.paint()};$(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(H):$(this.#i.setTimeout)?this.#i.setTimeout(H,0):H()}paint(){const H=this.#t.viewport?.root;if(!H||!H.querySelectorAll)return;const V=this.#e.find;if(!V||!$(V.stateFor))return;const z=$(V.model)?V.model():null,w=!!z&&z.active;if(!w&&!this.#o)return;let A=!1;for(const g of H.querySelectorAll("[data-key]")){const l=g.getAttribute("data-key");for(const d of g.querySelectorAll("[data-col]")){const o=w?V.stateFor(l,d.getAttribute("data-col")):null;o?(A=!0,d.classList.add(B),d.classList.toggle(I,o==="current")):d.classList.contains(B)&&d.classList.remove(B,I)}}this.#o=A}destroy(){for(const V of this.#n)V();this.#n=[];const H=this.#t.viewport?.root;if(!(!H||!H.querySelectorAll)){for(const V of H.querySelectorAll(`.${B}`))V.classList.remove(B,I);this.#o=!1}}}const X=_}),Fe("packages/dom/src/findbar.js",function(e,K){"use strict";Object.defineProperty(e,"FIND_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"FindBar",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const Q=K("packages/dom/src/editors/common.js"),$=Q.el,B=Q.on,_=K("packages/dom/src/renderer/textentry.js").isTextEntry,W=K("packages/core/src/i18n/index.js").defaultMessages,V=K("packages/core/src/internal/util.js").isFunction,z="lat-find",w=12,A=120;class g{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=null;#f=!1;#p=!1;#m=null;#g=[];#b=null;#w=null;#S=!1;constructor(o){this.#e=o.grid,this.#t=o.renderer,this.#n=o.document||o.renderer.viewport?.document,this.#r=this.#n&&this.#n.defaultView||(typeof globalThis>"u"?{}:globalThis),this.#o=o.settings&&typeof o.settings=="object"?o.settings:{}}get open(){return!!this.#i&&this.#i.style.display!=="none"}get element(){return this.#i}t(o,n){const t=this.#e;return(t&&t.messages&&V(t.messages.t)?t.messages:W).t(o,n)}mount(){const o=this.#O();if(!o)return;o.attachUi({open:t=>this.show(t),close:()=>this.hide(),focus:()=>{this.#s&&this.#s.focus()}}),o.attachDriver({run:()=>this.#C()});const n=this.#t.viewport?.root;if(n&&V(n.addEventListener)&&this.#o.shortcut!==!1){const t=r=>{if(!(r.ctrlKey||r.metaKey)||r.altKey||r.shiftKey||r.key!=="f"&&r.key!=="F")return;const s=r.target;if(this.#s&&s===this.#s){r.preventDefault(),r.stopPropagation(),V(this.#s.select)&&this.#s.select();return}_(s)||(r.preventDefault(),r.stopPropagation(),this.show())};n.addEventListener("keydown",t,!0),this.#g.push(()=>n.removeEventListener("keydown",t,!0))}this.#g.push(this.#e.on("find:changed",()=>this.#L())),this.#g.push(this.#e.on("columns:changed",()=>this.#j())),this.#g.push(this.#e.on("column:visible",()=>this.#j()))}show(o){const n=this.#k();if(!n)return;const t=n.style.display!=="none";n.style.display="",t||this.#y(),this.#O().setOpen(!0),o!=null&&(this.#s.value=String(o),this.#T()),this.#s.focus(),V(this.#s.select)&&this.#s.select(),this.#L()}hide(){this.#H();const o=this.#O();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#y()),o&&(o.clear(),o.setOpen(!1));const n=this.#t.viewport?.root;if(!n||!(this.#i&&this.#n&&this.#n.activeElement&&V(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const s=(V(n.querySelector)?n.querySelector('[tabindex="0"]'):null)||n;V(s.focus)&&s.focus()}search(){this.#T()}destroy(){this.#S=!0,this.#H();for(const n of this.#g)n();this.#g=[];const o=this.#O();o&&(o.attachUi(null),o.attachDriver(null)),this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null}#y(){const o=this.#t;o&&V(o.invalidate)&&o.invalidate("size")}#O(){const o=this.#e&&this.#e.find;return o&&V(o.model)?o.model():null}#k(){if(this.#i)return this.#i;const o=this.#t.viewport,n=o?.root,t=this.#n;if(!n||!t||!V(n.insertBefore))return null;const r=$(t,"div",{class:z,attrs:{role:"search","aria-label":this.t("find.label")}});this.#s=$(t,"input",{class:`${z}__input`,attrs:{type:"text","aria-label":this.t("find.label"),placeholder:this.t("find.placeholder"),autocomplete:"off",spellcheck:"false"}}),this.#l=$(t,"span",{class:`${z}__count`,attrs:{"aria-hidden":"true"}}),this.#a=$(t,"span",{class:`${z}__scope`,attrs:{"aria-hidden":"true"}}),this.#a.style.display="none",this.#u=$(t,"span",{class:`${z}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const s=$(t,"button",{class:`${z}__nav ${z}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),h=$(t,"button",{class:`${z}__nav ${z}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=$(t,"button",{class:`${z}__toggle ${z}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=$(t,"button",{class:`${z}__toggle ${z}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#h=$(t,"select",{class:`${z}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const u=$(t,"button",{class:`${z}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),i=$(t,"div",{class:`${z}__options`,children:[this.#c,this.#d,this.#h]});for(const c of[this.#s,this.#l,this.#a,this.#u,s,h,u,i])r.appendChild(c);this.#g.push(B(this.#s,"input",()=>this.#A())),this.#g.push(B(s,"click",()=>this.#e.find.prev())),this.#g.push(B(h,"click",()=>this.#e.find.next())),this.#g.push(B(this.#c,"click",()=>{this.#f=!this.#f,this.#c.setAttribute("aria-pressed",String(this.#f)),this.#T()})),this.#g.push(B(this.#d,"click",()=>{this.#p=!this.#p,this.#d.setAttribute("aria-pressed",String(this.#p)),this.#T()})),this.#g.push(B(this.#h,"change",()=>{const c=this.#h.value;this.#m=c?String(c):null,this.#T()})),this.#g.push(B(u,"click",()=>this.hide()));const m=c=>{if(c.key==="Escape"){c.preventDefault(),c.stopPropagation(),this.hide();return}c.key==="Enter"&&c.target===this.#s&&(c.preventDefault(),c.stopPropagation(),this.#b!==null&&(this.#x(),this.#T()),c.shiftKey?this.#e.find.prev():this.#e.find.next())};return r.addEventListener("keydown",m),this.#g.push(()=>r.removeEventListener("keydown",m)),r.style.display="none",n.insertBefore(r,o.header||n.firstChild),this.#i=r,this.#j(),r}#j(){const o=this.#h;if(!o)return;const n=this.#n;for(;o.firstChild;)o.removeChild(o.firstChild);o.appendChild($(n,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const t=this.#e.columns,r=t&&V(t.visible)?t.visible():[];let s=!1;for(const h of r){if(!h||h.id===void 0)continue;const u=String(h.id);o.appendChild($(n,"option",{text:h.title||u,attrs:{value:u}})),u===this.#m&&(s=!0)}s||(this.#m=null),o.value=this.#m||""}#A(){const o=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):A;if(this.#x(),o===0||!V(this.#r.setTimeout)){this.#T();return}this.#b=this.#r.setTimeout(()=>{this.#b=null,this.#T()},o)}#T(){const o=this.#O();if(!o||this.#S)return;const n=this.#s?this.#s.value:"";if(!n){this.#B(),o.clear();return}o.begin(n,{caseSensitive:this.#f,wholeCell:this.#p,columns:this.#m?[this.#m]:null,from:this.#M()}),this.#C()}#M(){const o=this.#t&&this.#t.window,n=o&&Number.isFinite(o.first)?o.first:0;return Math.max(0,n)}#C(){if(this.#w!==null||this.#S)return;const o=()=>{this.#w=null,this.#E()};V(this.#r.requestAnimationFrame)?this.#w=this.#r.requestAnimationFrame(o):V(this.#r.setTimeout)?this.#w=this.#r.setTimeout(o,0):o()}#E(){const o=this.#O();!o||this.#S||!o.active||(o.stale&&o.rescan({from:this.#M()}),!o.complete&&(o.step(w)||this.#C()))}#L(){if(!this.#i||this.#S)return;const o=this.#e.find.count(),n=this.#O().active;let t="",r="idle";n&&(o.total===0?(t=o.complete?this.t("find.none"):this.t("find.searching"),r=o.complete?"none":"searching"):(t=this.t(o.complete?"find.count":"find.countPartial",{current:o.current,total:o.total}),r=o.complete?"matches":"searching")),this.#l.textContent=t,this.#i.setAttribute("data-state",r);const s=n&&o.windowed;this.#a.textContent=s?this.t("find.loadedRows"):"",this.#a.style.display=s?"":"none",n?o.complete&&(this.#u.textContent=o.total===0?this.t(s?"a11y.find.noneLoaded":"a11y.find.none"):this.t(s?"a11y.find.countLoaded":"a11y.find.count",{current:o.current,count:o.total})):this.#u.textContent=""}#x(){this.#b!==null&&V(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#b),this.#b=null}#B(){this.#w!==null&&(V(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#w):V(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#w),this.#w=null)}#H(){this.#x(),this.#B()}}const l=g}),Fe("packages/dom/src/redactpaint.js",function(e,K){"use strict";Object.defineProperty(e,"RedactionPainter",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return I}});const Q="lat-cell--redacted",$="lat-cell";class B{#e;#t;#n=[];constructor(X){this.#e=X.grid,this.#t=X.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.paint()}paint(){const X=this.#t.viewport?.root;if(!X||!X.querySelectorAll)return;const W=this.#e.redaction;if(!W)return;const H=W.active;for(const V of X.querySelectorAll(`.${$}[data-col]`))H&&W.has(V.getAttribute("data-col"))?V.classList.add(Q):V.classList.contains(Q)&&V.classList.remove(Q)}destroy(){for(const X of this.#n)X();this.#n=[]}}const I=B}),Fe("packages/dom/src/validationpaint.js",function(e,K){"use strict";Object.defineProperty(e,"ValidationPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const $=K("packages/dom/src/editors/common.js").markInvalid,B="lat-cell";function I(W,H){let V=W;for(;V;){if(H(V))return V;V=V.parentNode}return null}class _{#e;#t;#n=[];constructor(H){this.#e=H.grid,this.#t=H.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint()));for(const H of["validation:failed","validation:cleared","cell:changed"])this.#n.push(this.#e.on(H,()=>this.paint()));this.paint()}#r(H){const V=I(H,z=>z.getAttribute&&z.getAttribute("data-key")!==null);return V?V.getAttribute("data-key"):null}paint(){const H=this.#e.validation;if(!H||!H.active)return;const V=this.#t.viewport?.root;if(!(!V||!V.querySelectorAll))for(const z of V.querySelectorAll(`.${B}[data-col]`)){const w=z.getAttribute("data-col"),A=this.#r(z),g=A?H.errorFor(A,w):null;$(z,g?g.message:null)}}destroy(){for(const H of this.#n)H();this.#n=[]}}const X=_}),Fe("packages/dom/src/presentation.js",function(e,K){"use strict";Object.defineProperty(e,"CHROME",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PresentationController",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/dom/src/renderer/textentry.js").isTextEntry,X=K("packages/dom/src/renderer/viewport.js").CLASS,W="lat-presenting",H="lat-presenting--changing",V="lat-presenting__progress",z="lat-cell--dimmed",w=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class A{#e;#t;#n;#r=[];#o=null;#i=null;#s=null;constructor(d){this.#e=d.grid,this.#t=d.renderer,this.#n=d.maximiser||null}mount(){this.#r.push(this.#e.on("presentation:started",()=>this.#d())),this.#r.push(this.#e.on("presentation:changed",()=>this.#f())),this.#r.push(this.#e.on("presentation:scale",()=>this.#f())),this.#r.push(this.#e.on("presentation:ended",()=>this.#h())),this.#r.push(this.#e.on("presentation:view",o=>this.#a(o))),this.#r.push(this.#e.on("presentation:spotlight",()=>this.#p())),this.#r.push(this.#e.on("render:done",()=>this.#p())),this.#n&&$(this.#n.watch)&&this.#r.push(this.#n.watch(o=>{o||!this.#o||this.#o.maximised||this.#e.presentation?.active&&this.#e.presentation.stop()}));const d=this.#t.viewport?.root;if(d&&$(d.addEventListener)){const o=n=>this.#l(n);d.addEventListener("keydown",o),this.#r.push(()=>d.removeEventListener("keydown",o))}}#l(d){const o=this.#e.presentation;if(!o?.active)return;const n=d.ctrlKey||d.metaKey,t=d.key;if(t==="Escape"&&!this.#n){d.defaultPrevented||(o.stop(),d.preventDefault?.());return}if(n){t==="="||t==="+"?(o.nudge(1),d.preventDefault?.()):t==="-"||t==="_"?(o.nudge(-1),d.preventDefault?.()):t==="0"&&(o.setScale(1.5),d.preventDefault?.());return}if(!o.views.length||I(d.target))return;t==="ArrowRight"||t==="ArrowDown"||t==="PageDown"||t===" "?(o.step(1),d.preventDefault?.()):t==="ArrowLeft"||t==="ArrowUp"||t==="PageUp"?(o.step(-1),d.preventDefault?.()):t==="Home"?(o.goTo(0),d.preventDefault?.()):t==="End"?(o.goTo(o.views.length-1),d.preventDefault?.()):(t==="r"||t==="R")&&(o.reset(),d.preventDefault?.())}#a(d){!d||!d.viewId||(this.#u(),this.#e.views?.apply?.(d.viewId),this.#c(d))}#u(){const d=this.#t.viewport?.root;d?.classList&&(d.classList.remove(H),d.offsetWidth,d.classList.add(H))}#c(d){const o=this.#t.viewport?.overlays;if(!o||!this.#e.presentation.views.length)return;const n=o.ownerDocument;if(!n?.createElement)return;if(!this.#i){const s=n.createElement("div");s.className=V,s.setAttribute("role","status"),s.setAttribute("aria-live","polite"),o.appendChild(s),this.#i=s}const t=this.#e.views?.get?.(d.viewId),r=t&&t.name?t.name:"";this.#i.textContent=r?`${r} · ${(d.index||0)+1} / ${d.count||0}`:`${(d.index||0)+1} / ${d.count||0}`}#d(){if(this.#o){this.#f();return}const d=!!(this.#n&&this.#n.active());this.#n&&!d&&this.#n.enter();const o=new Set(this.#e.presentation?.options?.chrome||[]),n=[];for(const r of w){if(o.has(r)||r==="toolPanel"&&this.#S())continue;const s=this.#y(r);s&&s.style&&s.style.display!=="none"&&(s.style.display="none",n.push(s))}const t=this.#b();t&&t.style&&t.style.display!=="none"&&this.#w(t)&&(t.style.display="none",n.push(t)),this.#o={maximised:d,hidden:n},this.#t.viewport?.root?.classList?.add(W),this.#f(),this.#m()}#h(){const d=this.#o;this.#o=null;const o=this.#t.viewport?.root;if(o?.classList?.remove(W),o?.style?.removeProperty("--lattice-presentation-scale"),this.#g(),this.#i&&(this.#i.remove?.(),this.#i=null),o?.classList?.remove(H),this.#p(),d){const n=this.#e.toolPanel;n&&$(n.presentRestore)&&n.presentRestore();for(const t of d.hidden)t.style.display="";this.#n&&!d.maximised&&this.#n.active()&&this.#n.exit()}this.#t.invalidate?.("theme")}#f(){const d=this.#t.viewport?.root;!d||!d.style||(d.style.setProperty("--lattice-presentation-scale",String(this.#e.presentation.scale)),this.#t.invalidate?.("theme"))}#p(){const d=this.#t.viewport?.root;if(!d?.querySelectorAll)return;const o=this.#e.presentation?.active?this.#e.presentation.spotlight:null,n=o&&o.keys.length?new Set(o.keys):null,t=o&&o.colIds.length?new Set(o.colIds):null;for(const r of d.querySelectorAll("[data-key]")){const s=!n||n.has(r.getAttribute("data-key"));for(const h of r.querySelectorAll("[data-col]"))!o||s&&(!t||t.has(h.getAttribute("data-col")))?h.classList.remove(z):h.classList.add(z)}}#m(){this.#g();const d=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(d)||d<=0||!this.#e.presentation.views.length)return;const o=this.#t.viewport?.root?.ownerDocument?.defaultView;o?.setInterval&&(this.#s=o.setInterval(()=>{const n=this.#e.presentation;n.active&&n.goTo(n.index>=n.views.length-1?0:n.index+1)},Math.max(1e3,d)))}#g(){if(this.#s===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#s),this.#s=null}#b(){const d=this.#e.element;return!d||!$(d.querySelector)?null:d.querySelector(`.${X.statusBar}`)}#w(d){const o=d.children||[];for(const n of o)if(!n.style||n.style.display!=="none")return!1;return!0}#S(){const d=this.#e.toolPanel;return!!(d&&$(d.presentOnly)&&d.presentOnly())}#y(d){const o=this.#e.element;if(!o||!$(o.querySelector))return null;const n={toolPanel:".lat-panel-dock",statusBar:".lat-statusbar",editBar:".lat-editor-bar",historyBar:".lat-history",pagination:".lat-pagination"}[d];return n?o.querySelector(n):null}destroy(){this.#o&&this.#h();for(const d of this.#r)d();this.#r=[]}}const g=A}),Fe("packages/dom/src/capture.js",function(e,K){"use strict";Object.defineProperty(e,"isSafeImageSource",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"captureElement",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return H}});const $=K("packages/core/src/internal/util.js").isFunction,B=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function I(V,z,w){const A=w.getComputedStyle(V),g=z.style;if(g)for(let l=0;l<A.length;l++){const d=A[l];B.has(d)||g.setProperty(d,A.getPropertyValue(d),A.getPropertyPriority(d))}}function _(V,z,w){if(I(V,z,w),V.tagName==="CANVAS"&&$(V.toDataURL))try{const l=V.toDataURL("image/png"),d=z.style;d&&(d.setProperty("background-image",`url(${l})`),d.setProperty("background-size","100% 100%"),d.setProperty("background-repeat","no-repeat"))}catch{}const A=V.children||[],g=z.children||[];for(let l=0;l<A.length&&l<g.length;l++)_(A[l],g[l],w)}function X(V,z){if(!V||V.startsWith("data:")||V.startsWith("blob:"))return!0;try{return new URL(V,z).origin===z}catch{return!0}}async function W(V,z={}){const w=V.ownerDocument,A=w?.defaultView;if(!A||typeof A.getComputedStyle!="function")throw new Error("capture needs a browser document");const g=V.getBoundingClientRect(),l=Math.max(1,Math.ceil(g.width)),d=Math.max(1,Math.ceil(g.height)),o=Math.max(.1,Number(z.scale)||2),n=A.location?.origin||"";for(const m of V.querySelectorAll("img")){const c=m.getAttribute("src")||"";if(!X(c,n))throw new Error(`capture refused: the image at ${c} is on another origin and would taint the canvas. Serve it same-origin, inline it as a data: URL, or hide the column.`)}const t=V.cloneNode(!0);_(V,t,A),t.style.width=`${l}px`,t.style.height=`${d}px`,t.style.margin="0";const r=new A.XMLSerializer().serializeToString(t),s=`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${d}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${r}</div></foreignObject></svg>`,h=new A.Image;await new Promise((m,c)=>{h.onload=()=>m(void 0),h.onerror=()=>c(new Error("capture failed to rasterise the grid; a host element inside it may not serialise as XML")),h.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(s)}`});const u=w.createElement("canvas");u.width=Math.round(l*o),u.height=Math.round(d*o);const i=u.getContext("2d");if(!i)throw new Error("capture could not get a 2d context");return i.fillStyle=z.background||A.getComputedStyle(V).backgroundColor||"#ffffff",i.fillRect(0,0,u.width,u.height),i.drawImage(h,0,0,u.width,u.height),new Promise((m,c)=>{u.toBlob(f=>f?m({blob:f,width:u.width,height:u.height}):c(new Error("capture produced no image")),z.type||"image/png",z.quality)})}const H=W}),Fe("packages/dom/src/annotate.js",function(e,K){"use strict";Object.defineProperty(e,"TOOLS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"MARK_TYPES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.uid,I=Q.warnOnce,X=K("packages/dom/src/renderer/direction.js").signedX,W=Object.freeze(["pen","arrow","rect","highlight","erase"]),H=Object.freeze(["freehand","arrow","rect","highlight","text"]),V=Object.freeze({freehand:"pen",pen:"pen",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),z=Object.freeze({pen:"freehand",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),w=14,A="system-ui, -apple-system, sans-serif";function g(f,a){if(!f||typeof f!="object")return null;const p=V[f.type];if(!p)return null;const b=typeof f.id=="string"&&f.id?f.id:B("mark"),O=Array.isArray(f.points)?f.points:[],k=[];for(const v of O){const R=Number(v&&v.x),S=Number(v&&v.y);Number.isFinite(R)&&Number.isFinite(S)&&k.push({x:R,y:S})}const y=typeof f.colour=="string"&&f.colour?f.colour:a;if(p==="text"){const v=typeof f.text=="string"?f.text:"";if(!k.length||!v)return null;const R={id:b,tool:p,colour:y,points:[k[0]],text:v,region:l(f.region)},S=Number(f.fontSize);return Number.isFinite(S)&&S>0&&(R.fontSize=S),typeof f.background=="string"&&f.background&&(R.background=f.background),R}return k.length<2?null:{id:b,tool:p,colour:y,points:k,region:l(f.region)}}function l(f){return f==="start"||f==="end"?f:"centre"}function d(f){const a={id:f.id,type:z[f.tool]||f.tool,colour:f.colour,points:f.points.map(p=>({x:p.x,y:p.y}))};return(f.region==="start"||f.region==="end")&&(a.region=f.region),f.tool==="text"&&(a.text=f.text,f.fontSize!==void 0&&(a.fontSize=f.fontSize),f.background!==void 0&&(a.background=f.background)),a}const o="lat-annotate",n=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(f){return f==="arrow"||f==="rect"}function r(f,a){return{id:f,count:a,valueOf(){return this.count}}}const s=10;function h(f,a,p){const b=p.x-a.x,O=p.y-a.y,k=b*b+O*O;let y=k?((f.x-a.x)*b+(f.y-a.y)*O)/k:0;y=Math.max(0,Math.min(1,y));const v=a.x+y*b,R=a.y+y*O;return Math.hypot(f.x-v,f.y-R)}function u(f){const a=f.points;if(!a.length)return null;if(f.tool==="text"){const y=f.fontSize||w,v=(f.text||"").length*y*.6;return{x1:a[0].x,y1:a[0].y,x2:a[0].x+v,y2:a[0].y+y*1.2}}let p=1/0,b=1/0,O=-1/0,k=-1/0;for(const y of a)p=Math.min(p,y.x),b=Math.min(b,y.y),O=Math.max(O,y.x),k=Math.max(k,y.y);return{x1:p,y1:b,x2:O,y2:k}}function i(f,a){const p=u(f);if(!p)return 1/0;if(f.tool==="text"||f.tool==="rect"){if(a.x>=p.x1&&a.x<=p.x2&&a.y>=p.y1&&a.y<=p.y2)return 0;if(f.tool==="text")return 1/0}const b=f.points;if(f.tool==="rect"){const k=[{x:p.x1,y:p.y1},{x:p.x2,y:p.y1},{x:p.x2,y:p.y2},{x:p.x1,y:p.y2}];let y=1/0;for(let v=0;v<4;v++)y=Math.min(y,h(a,k[v],k[(v+1)%4]));return y}if(b.length===1)return Math.hypot(a.x-b[0].x,a.y-b[0].y);let O=1/0;for(let k=0;k<b.length-1;k++)O=Math.min(O,h(a,b[k],b[k+1]));return O}class m{#e;#t;#n=null;#r=null;#o=null;#i="#e0245e";#s=[];#l=null;#a=[];#u=null;#c=null;constructor(a){this.#e=a.grid,this.#t=a.renderer,this.#u=Array.isArray(a.seed)?a.seed:null}get tool(){return this.#o}get count(){return this.#s.length}mount(){this.#a.push(this.#e.on("scroll",()=>this.redraw())),this.#a.push(this.#e.on("render:done",()=>this.redraw())),this.#a.push(this.#e.on("presentation:ended",()=>{this.use(null),this.#m()})),this.#d(),this.#p(),this.#u&&this.#u.length&&this.replaceAll(this.#u),this.#u=null}add(a){const p=g(a,this.#i);return p?(p.durable=!0,this.#s.push(p),this.#T(),this.redraw(),this.#E(),r(p.id,this.#s.length)):(I("annotate.add.invalid",`annotate.add ignored a mark: it needs a known \`type\` (${H.join(", ")}) and at least two finite {x, y} points in content coordinates.`),r(null,this.#s.length))}list(){return this.#s.map(d)}remove(a){const p=this.#s.findIndex(b=>b.id===a);return p<0?(I("annotate.remove.unknown",`annotate.remove ignored an unknown id: "${a}".`),!1):(this.#s.splice(p,1),this.#c===a&&(this.#c=null),this.redraw(),this.#E(),!0)}replaceAll(a){const p=Array.isArray(a)?a:[];this.#s=p.map(b=>g(b,this.#i)).filter(Boolean);for(const b of this.#s)b.durable=!0;this.#s.length&&this.#T(),this.redraw(),this.#E()}#d(){const a=this.#t.viewport?.root;if(!a||!$(a.addEventListener))return;const p=b=>{if(!(!this.#o||!b)){if(b.key==="Escape"){this.use(null),b.preventDefault?.();return}if(this.#o==="erase"){if(b.key==="Tab"){this.#h(b);return}(b.key==="Delete"||b.key==="Backspace")&&this.#f(b)}}};a.addEventListener("keydown",p,!0),this.#a.push(()=>a.removeEventListener("keydown",p,!0))}#h(a){if(!this.#s.length){this.#x("a11y.annotate.noMarks");return}a.preventDefault?.();const p=this.#c?this.#s.findIndex(k=>k.id===this.#c):-1,b=a.shiftKey?-1:1,O=p<0?b>0?0:this.#s.length-1:(p+b+this.#s.length)%this.#s.length;this.#c=this.#s[O].id,this.redraw(),this.#x("a11y.annotate.focusedMark",{at:O+1,of:this.#s.length})}#f(a){if(!this.#c)return;a.preventDefault?.();const p=this.#c;this.remove(p),this.#x("a11y.annotate.erased")}#p(){const a=this.#n?.ownerDocument?.defaultView||this.#t.viewport?.root?.ownerDocument?.defaultView;if(!a||!$(a.matchMedia))return;let p=null;const b=()=>{const O=a.devicePixelRatio||1;let k;try{k=a.matchMedia(`(resolution: ${O}dppx)`)}catch{return}p=k;const y=()=>{this.redraw(),b()};$(k.addEventListener)?k.addEventListener("change",y,{once:!0}):$(k.addListener)&&k.addListener(y)};b(),this.#a.push(()=>{p=null})}use(a,p={}){const b=!!p.colour&&a===this.#o;p.colour&&(this.#i=String(p.colour));const O=a&&W.includes(a)?a:null;this.#o=O&&O===this.#o&&!b?null:O,this.#o!=="erase"&&(this.#c=null);const k=this.#o?this.#T():this.#n;return k&&(k.style.pointerEvents=this.#o?"auto":"none",k.style.cursor=this.#o?"crosshair":""),this.#E(),this.#o}undo(){const a=this.#s.pop();return a&&this.#c===a.id&&(this.#c=null),this.redraw(),this.#E(),this.#s.length}clear(){this.#s.length&&(this.#s=[],this.#c=null,this.redraw(),this.#E())}#m(){const a=this.#s.filter(p=>p.durable);a.length!==this.#s.length&&(this.#s=a,this.redraw(),this.#E())}redraw(){!this.#n&&this.#s.length&&this.#T();const a=this.#n,p=this.#r;if(!a||!p)return;this.#M();const{left:b,top:O}=this.#A();p.clearRect(0,0,a.width,a.height);const k=this.#l?[...this.#s,this.#l]:this.#s;for(const y of["centre","start","end"]){const v=k.filter(R=>l(R.region)===y);if(v.length){p.save(),this.#g(p,y),p.translate((y==="centre"?-b:0)||0,-O||0);for(const R of v)this.#y(p,R),R.id===this.#c&&this.#k(p,R);p.restore()}}}#g(a,p="centre"){const b=this.#n,O=this.#t.viewport?.bodyViewport;if(!$(b?.getBoundingClientRect)||!$(O?.getBoundingClientRect))return;const k=b.getBoundingClientRect(),y=O.getBoundingClientRect();if(!y.width||!y.height)return;const v=this.#b(p,y);v&&(a.beginPath(),a.rect(v.left-k.left,y.top-k.top,v.width,y.height),a.clip())}#b(a,p){const b=S=>{if(!$(S?.getBoundingClientRect))return null;const x=S.getBoundingClientRect();return x&&x.width>0?{left:x.left,width:x.width}:null},O=b(this.#t.viewport?.bodyStart),k=b(this.#t.viewport?.bodyEnd);if(a==="start")return O;if(a==="end")return k;let y=p.left,v=p.left+p.width;const R=p.left+p.width/2;for(const S of[O,k]){if(!S)continue;const x=S.left+S.width;S.left+S.width/2<R?y=Math.max(y,x):v=Math.min(v,S.left)}return v>y?{left:y,width:v-y}:null}#w(a){for(const[p,b]of[["start",this.#t.viewport?.bodyStart],["end",this.#t.viewport?.bodyEnd]]){if(!$(b?.getBoundingClientRect))continue;const O=b.getBoundingClientRect();if(O&&O.width>0&&a>=O.left&&a<O.left+O.width)return p}return"centre"}#S(a){const p=this.#t.viewport?.bodyViewport;if(!$(p?.getBoundingClientRect))return!0;const b=p.getBoundingClientRect();return!b.width||!b.height?!0:a.clientX>=b.left&&a.clientX<=b.right&&a.clientY>=b.top&&a.clientY<=b.bottom}#y(a,p){const b=p.points;if(!b.length)return;const O=this.#e.presentation?.scale||1;a.lineWidth=(n[p.tool]||3)*O,a.strokeStyle=p.colour,a.fillStyle=p.colour,a.lineCap="round",a.lineJoin="round",a.globalAlpha=p.tool==="highlight"?.32:1;const k=b[0],y=b[b.length-1];if(p.tool==="text"){const v=(p.fontSize||w)*O;a.font=`${v}px ${A}`,a.textBaseline="top";const R=p.text||"";if(p.background){let S=R.length*v*.6;if(typeof a.measureText=="function"){const x=a.measureText(R);x&&Number.isFinite(x.width)&&(S=x.width)}a.fillStyle=p.background,a.fillRect(k.x-v*.15,k.y-v*.1,S+v*.3,v*1.2)}a.fillStyle=p.colour,a.fillText(R,k.x,k.y),a.globalAlpha=1;return}if(p.tool==="rect")a.strokeRect(k.x,k.y,y.x-k.x,y.y-k.y);else if(p.tool==="arrow")a.beginPath(),a.moveTo(k.x,k.y),a.lineTo(y.x,y.y),a.stroke(),this.#O(a,k,y,a.lineWidth);else{a.beginPath(),a.moveTo(k.x,k.y);for(let v=1;v<b.length;v++)a.lineTo(b[v].x,b[v].y);a.stroke()}a.globalAlpha=1}#O(a,p,b,O){const k=Math.atan2(b.y-p.y,b.x-p.x),y=Math.max(8,O*3);a.beginPath(),a.moveTo(b.x,b.y),a.lineTo(b.x-y*Math.cos(k-Math.PI/7),b.y-y*Math.sin(k-Math.PI/7)),a.lineTo(b.x-y*Math.cos(k+Math.PI/7),b.y-y*Math.sin(k+Math.PI/7)),a.closePath(),a.fill()}#k(a,p){const b=u(p);if(!b||!$(a.strokeRect))return;const O=6;a.save(),a.setLineDash?.([4,3]),a.strokeStyle="#1a73e8",a.lineWidth=2,a.globalAlpha=1,a.strokeRect(b.x1-O,b.y1-O,b.x2-b.x1+O*2,b.y2-b.y1+O*2),a.restore()}#j(a,p){const b=this.#e.presentation?.scale||1,O=s*b;for(let k=this.#s.length-1;k>=0;k--){const y=this.#s[k];if(l(y.region)===p&&i(y,a)<=O)return y}return null}#A(){const a=$(this.#t.scrollPosition)?this.#t.scrollPosition():null,p=this.#t.viewport?.rtl===!0;return{left:X(a?.left||0,p),top:a?.top||0}}#T(){if(this.#n)return this.#n;const a=this.#t.viewport?.overlays,p=a?.ownerDocument;if(!a||!p?.createElement)return null;const b=p.createElement("canvas");return b.className=o,b.style.position="absolute",b.style.inset="0",b.style.pointerEvents="none",a.appendChild(b),this.#n=b,this.#r=b.getContext?b.getContext("2d"):null,this.#M(),this.#C(b),b}#M(){const a=this.#n,p=this.#t.viewport?.root;if(!a||!p?.getBoundingClientRect)return;const b=p.getBoundingClientRect(),k=a.ownerDocument?.defaultView?.devicePixelRatio||1,y=Math.max(1,Math.round(b.width*k)),v=Math.max(1,Math.round(b.height*k));a.width===y&&a.height===v||(a.width=y,a.height=v,a.style&&(a.style.width=`${Math.max(1,b.width)}px`,a.style.height=`${Math.max(1,b.height)}px`),this.#r?.setTransform(k,0,0,k,0,0))}#C(a){const p=(v,R="centre")=>{const S=a.getBoundingClientRect(),{left:x,top:C}=this.#A();return{x:v.clientX-S.left+(R==="centre"?x:0),y:v.clientY-S.top+C}},b=v=>{if(!this.#o||!this.#S(v))return;const R=this.#w(v.clientX);if(this.#o==="erase"){const S=this.#j(p(v,R),R);S&&(this.remove(S.id),this.#x("a11y.annotate.erased")),v.preventDefault?.();return}this.#l={id:B("mark"),tool:this.#o,colour:this.#i,points:[p(v,R)],region:R},a.setPointerCapture?.(v.pointerId),v.preventDefault?.()},O=v=>{if(!this.#l)return;const R=p(v,this.#l.region);t(this.#l.tool)&&this.#l.points.length>1&&this.#l.points.pop(),this.#l.points.push(R),this.redraw()},k=v=>{this.#l&&(this.#l.points.length>1&&this.#s.push(this.#l),this.#l=null,a.releasePointerCapture?.(v.pointerId),this.redraw(),this.#E())},y=v=>{if(!this.#o)return;const R=this.#t.viewport?.bodyViewport;if(!R)return;let S=!1;v.deltaY&&typeof R.scrollTop=="number"&&(R.scrollTop+=v.deltaY,S=!0),v.deltaX&&typeof R.scrollLeft=="number"&&(R.scrollLeft+=v.deltaX,S=!0),S&&v.preventDefault?.()};a.addEventListener("pointerdown",b),a.addEventListener("pointermove",O),a.addEventListener("pointerup",k),a.addEventListener("pointercancel",k),a.addEventListener("wheel",y,{passive:!1}),this.#a.push(()=>{a.removeEventListener("pointerdown",b),a.removeEventListener("pointermove",O),a.removeEventListener("pointerup",k),a.removeEventListener("pointercancel",k),a.removeEventListener("wheel",y)})}#E(){this.#e.emit?.("annotation:changed",{tool:this.#o,count:this.#s.length},"user")}#L(a,p){const b=this.#e.messages;return b&&$(b.t)?b.t(a,p):a}#x(a,p){this.#t.announce?.(this.#L(a,p),{repeat:!0})}destroy(){for(const a of this.#a)a();this.#a=[],this.#n?.remove?.(),this.#n=null,this.#r=null,this.#s=[]}}const c=m}),Fe("packages/dom/src/timelinebar.js",function(e,K){"use strict";Object.defineProperty(e,"agoLabel",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"clockLabel",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"TimelineBar",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return V}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_="lat-timeline";function X(z){if(!Number.isFinite(z)||z<1e3)return"now";const w=Math.round(z/1e3);if(w<60)return`${w}s ago`;const A=Math.round(w/60);return A<60?`${A}m ago`:`${Math.round(A/60)}h ago`}function W(z,w){return Number.isFinite(z)?new Date(z).toLocaleTimeString(w||void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}class H{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=[];constructor(w){this.#e=w.grid,this.#t=w.renderer}mount(){this.#s.push(this.#e.on("timeline:attached",()=>{this.#a(),this.refresh()})),this.#s.push(this.#e.on("timeline:detached",()=>this.#u())),this.#s.push(this.#e.on("timeline:seek",()=>this.refresh())),this.#s.push(this.#e.on("rows:changed",()=>this.refresh()))}refresh(){if(!this.#n||!this.#e.timeline.attached)return;const w=this.#e.timeline,A=w.depth,g=w.position;this.#r.max=String(Math.max(1,A)),this.#r.value=String(Math.max(0,A-g)),this.#r.disabled=A===0;const l=w.at(),d=w.live;this.#o&&(this.#o.textContent=d?this.#l("timeline.live"):X(Date.now()-(l||Date.now())),this.#o.setAttribute("data-live",d?"true":"false")),this.#i&&(this.#i.textContent=A===0?this.#l("timeline.recording"):W(l,this.#e.get("locale"))),this.#n.setAttribute("data-live",d?"true":"false")}#l(w,A){const g=this.#e;return(g&&g.messages?g.messages:I).t(w,A)}#a(){if(this.#n)return;const w=this.#t.viewport?.overlays,A=w?.ownerDocument;if(!w||!A?.createElement)return;const g=A.createElement("div");g.className=_;const l=A.createElement("span");l.className=`${_}__ago`,l.setAttribute("role","status"),l.setAttribute("aria-live","polite");const d=A.createElement("input");d.className=`${_}__range`,d.type="range",d.min="0",d.step="1",d.setAttribute("aria-label",this.#l("timeline.scrub"));const o=A.createElement("span");o.className=`${_}__clock`;const n=A.createElement("button");n.className=`${_}__live`,n.type="button",n.textContent=this.#l("timeline.goLive"),n.setAttribute("aria-label",this.#l("timeline.returnToPresent")),g.appendChild(l),g.appendChild(d),g.appendChild(o),g.appendChild(n),w.appendChild(g),this.#n=g,this.#r=d,this.#o=l,this.#i=o;const t=()=>{const h=this.#e.timeline.depth;this.#e.timeline.seek(h-Number(d.value))};d.addEventListener("input",t);const r=()=>this.#e.timeline.toLive();n.addEventListener("click",r);const s=h=>h.stopPropagation();d.addEventListener("keydown",s),this.#s.push(()=>{d.removeEventListener("input",t),n.removeEventListener("click",r),d.removeEventListener("keydown",s)})}#u(){this.#n&&($(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null,this.#i=null)}destroy(){for(const w of this.#s)w();this.#s=[],this.#u()}}const V=H}),Fe("packages/dom/src/commentpaint.js",function(e,K){"use strict";Object.defineProperty(e,"CommentPainter",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/renderer/direction.js").isRtlElement,W="lat-comment-mark",H="lat-cell--commented",V="lat-cell--commented-open";class z{#e;#t;#n=[];#r=[];constructor(g){this.#e=g.grid,this.#t=g.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("comment:indexLoaded",()=>this.paint())),this.#s(),this.paint()}paint(){const g=this.#e.comments;if(!g||!g.enabled)return;const l=this.#t.viewport?.root;if(!l||!l.querySelectorAll)return;const d=[];for(const o of l.querySelectorAll("[data-key]")){const n=o.getAttribute("data-key");if(n){d.push(n);for(const t of o.querySelectorAll("[data-col]")){const r=t.getAttribute("data-col"),s=g.at(n,r),h=!!(s&&s.count);t.classList.toggle(H,h),t.classList.toggle(V,h&&s.unresolved>0),this.#i(t,s,r)}}}(d.length!==this.#r.length||d.some((o,n)=>o!==this.#r[n]))&&(this.#r=d,g.request(d))}#o(g,l){const d=this.#e;return(d&&d.messages?d.messages:I).t(g,l)}#i(g,l,d){if(!l||!l.count){g.hasAttribute("aria-description")&&g.removeAttribute("aria-description");return}const o=l.count,n=l.unresolved,t=this.#o("count.comments",{count:o});g.setAttribute("aria-description",n>0?this.#o("comments.someUnresolved",{comments:t,unresolved:n}):this.#o("comments.allResolved",{comments:t}))}#s(){const g=this.#t.viewport?.root;if(!g||!$(g.addEventListener))return;const l=o=>{const n=this.#e.comments;if(!n||!n.enabled)return;const t=o.target&&$(o.target.closest)?o.target.closest("[data-col]"):null;if(!t||!t.classList.contains(H)||!this.#l(t,o))return;const r=t.closest("[data-key]"),s=r&&r.getAttribute("data-key");s&&(o.stopPropagation(),o.preventDefault(),n.open(s,t.getAttribute("data-col")))},d=o=>{const n=this.#e.comments;if(!n||!n.enabled||!o.altKey||o.key!=="m"&&o.key!=="M")return;const t=this.#t.viewport?.root?.querySelector?.("[data-col].lat-cell--focus")||(typeof document<"u"&&document.activeElement&&$(document.activeElement.closest)?document.activeElement.closest("[data-col]"):null);if(!t)return;const r=t.closest("[data-key]"),s=r&&r.getAttribute("data-key");s&&(o.preventDefault(),o.stopPropagation(),n.open(s,t.getAttribute("data-col")))};g.addEventListener("click",l,!0),g.addEventListener("keydown",d,!0),this.#n.push(()=>{g.removeEventListener("click",l,!0),g.removeEventListener("keydown",d,!0)})}#l(g,l){if(!$(g.getBoundingClientRect))return!1;const d=g.getBoundingClientRect(),o=Math.max(14,Math.min(24,d.height*.6));return(X(g)?l.clientX<=d.left+o:l.clientX>=d.right-o)&&l.clientY<=d.top+o}destroy(){for(const g of this.#n)g();this.#n=[]}}const w=z}),Fe("packages/dom/src/presencepaint.js",function(e,K){"use strict";Object.defineProperty(e,"PresencePainter",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/editors/common.js").cssEscape,H=K("packages/core/src/model/presence.js").CURSOR_LABEL_MS,V="lat-presence";class z{#e;#t;#n=null;#r=null;#o=new Set;#i=[];#s=null;constructor(g){this.#e=g.grid,this.#t=g.renderer}mount(){const g=this.#e.presence;if(!(!g||!g.enabled)){this.#i.push(this.#e.on("render:done",()=>this.paint()));for(const l of["presence:joined","presence:left","presence:updated"])this.#i.push(this.#e.on(l,d=>this.#l(l,d)));this.#a(),this.paint()}}#l(g,l){if(this.#h(),g==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const o=l&&l.peer;o&&(this.#r.textContent=this.#f(g==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:o.name}))}#a(){const g=this.#t.viewport?.overlays,l=g?.ownerDocument;if(!g||!l?.createElement)return;const d=this.#e.get("presence")||{},o=l.createElement("span");if(o.className=`${V}__live`,o.setAttribute("role","status"),o.setAttribute("aria-live","polite"),g.appendChild(o),this.#r=o,d.roster===!1)return;const n=l.createElement("div");n.className=V,d.roster&&d.roster.side==="start"&&n.setAttribute("data-side","start"),n.style.pointerEvents="auto",g.appendChild(n),this.#n=n}paint(){const g=this.#e.presence,l=this.#t.viewport?.root;if(!g||!g.enabled||!l?.querySelectorAll)return;this.#d(l);const d=g.peers(),o=[...d].sort((n,t)=>n.at-t.at);for(const n of o)for(const t of n.ranges||[])for(const r of t.rowIds||[])for(const s of t.columns||[])this.#c(l,r,s,n,"range");for(const n of o)n.cursor&&this.#c(l,n.cursor.rowId,n.cursor.colId,n,"cursor");for(const n of o)n.editing&&this.#c(l,n.editing.rowId,n.editing.colId,n,"edit");this.#h(),this.#u(d)}#u(g){if(this.#s!==null)return;const l=g.filter(n=>n.cursorFresh);if(!l.length)return;const o=Math.max(...l.map(n=>n.cursorAt||0))+H-Date.now();this.#s=setTimeout(()=>{this.#s=null,this.paint()},Math.max(50,o))}#c(g,l,d,o,n){const t=g.querySelector(`[data-key="${X(l)}"]`),r=t&&t.querySelector(`[data-col="${X(d)}"]`);r&&(r.setAttribute("data-presence",n),r.style.setProperty("--lat-peer",o.colour),r.setAttribute("data-peer-name",o.name),r.setAttribute("data-peer-initial",o.initials||(o.name||"?").slice(0,1).toUpperCase()),o.idle?r.setAttribute("data-peer-idle","true"):r.removeAttribute("data-peer-idle"),n==="cursor"&&o.cursorFresh&&r.setAttribute("data-peer-fresh","true"),this.#o.add(`${l}${d}`))}#d(g){if(this.#o.size){for(const l of g.querySelectorAll("[data-presence]"))l.removeAttribute("data-presence"),l.removeAttribute("data-peer-name"),l.removeAttribute("data-peer-initial"),l.removeAttribute("data-peer-fresh"),l.removeAttribute("data-peer-idle"),l.style.removeProperty("--lat-peer");this.#o.clear()}}#h(){if(!this.#n)return;const g=this.#n.ownerDocument,l=this.#e.presence.peers();if(this.#n.textContent="",!l.length){this.#n.toggleAttribute("data-empty",!0);return}this.#n.removeAttribute("data-empty");for(const o of l){const n=g.createElement("button");n.className=`${V}__peer`,n.type="button",n.style.setProperty("--lat-peer",o.colour),n.toggleAttribute("data-idle",!!o.idle),n.toggleAttribute("data-hidden",!!o.hidden);let t="presence.peer";o.hidden?t="presence.peerHidden":o.idle&&(t="presence.peerIdle"),n.setAttribute("aria-label",this.#f(t,{name:o.name}));const r=g.createElement("span");r.className=`${V}__dot`,r.setAttribute("aria-hidden","true"),r.textContent=o.initials||(o.name||"?").slice(0,1).toUpperCase(),n.appendChild(r);const s=g.createElement("span");s.className=`${V}__name`,s.textContent=o.name,n.appendChild(s),n.addEventListener("click",()=>this.#e.presence.jumpTo(o.id)),this.#n.appendChild(n)}const d=l.filter(o=>o.hidden).length;if(d){const o=g.createElement("span");o.className=`${V}__hidden`,o.textContent=this.#f("presence.hidden",{count:d}),this.#n.appendChild(o)}}announceRefusal(g){if(!this.#r)return;const l=g&&g.name?g.name:this.#f("presence.someoneElse");this.#r.textContent=this.#f("a11y.presence.refused",{name:l})}#f(g,l){const d=this.#e;return(d&&d.messages?d.messages:I).t(g,l)}destroy(){for(const l of this.#i)l();this.#i=[],this.#s!==null&&clearTimeout(this.#s),this.#s=null;const g=this.#t.viewport?.root;g?.querySelectorAll&&this.#d(g),this.#n&&$(this.#n.remove)&&this.#n.remove(),this.#r&&$(this.#r.remove)&&this.#r.remove(),this.#n=null,this.#r=null}}const w=z}),Fe("packages/dom/src/commentpanel.js",function(e,K){"use strict";Object.defineProperty(e,"relativeTime",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"renderBody",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"CommentPanel",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/editors/common.js").cssEscape,H=K("packages/core/src/model/comments.js").parseCellKey,V="lat-comments",z=/^(https?:|mailto:)/i,w='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function A(o,n){if(!Number.isFinite(o))return"";const t=Math.max(0,Math.round((n-o)/1e3));if(t<60)return"just now";const r=Math.round(t/60);if(r<60)return`${r}m ago`;const s=Math.round(r/60);return s<24?`${s}h ago`:`${Math.round(s/24)}d ago`}function g(o,n,t,r){n.textContent="";const s=String(t??"");if(!r){n.textContent=s;return}const h=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let u=0,i=h.exec(s);for(;i;){i.index>u&&n.appendChild(o.createTextNode(s.slice(u,i.index)));const m=i[0];if(m.startsWith("*")){const c=o.createElement("em");c.textContent=m.slice(1,-1),n.appendChild(c)}else if(m.startsWith("`")){const c=o.createElement("code");c.textContent=m.slice(1,-1),n.appendChild(c)}else{const c=m.indexOf("]("),f=m.slice(1,c),a=m.slice(c+2,-1);if(z.test(a)){const p=o.createElement("a");p.href=a,p.textContent=f,p.rel="noopener noreferrer",p.target="_blank",n.appendChild(p)}else n.appendChild(o.createTextNode(f))}u=i.index+m.length,i=h.exec(s)}u<s.length&&n.appendChild(o.createTextNode(s.slice(u)))}class l{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=[];constructor(n){this.#e=n.grid,this.#t=n.renderer}mount(){this.#l.push(this.#e.on("comment:threadOpened",n=>this.#a(n))),this.#l.push(this.#e.on("comment:threadClosed",()=>this.#u())),this.#l.push(this.#e.on("render:done",()=>{this.#w(),this.#y()})),this.#l.push(this.#e.on("stream:evicted",()=>this.#c()))}#a(n){const t=this.#t.viewport?.root?.ownerDocument;t&&(this.#s=t.activeElement||null,this.#i=this.#h(n.rowId,n.field),this.#n||this.#p(t),this.#n.setAttribute("data-open","true"),this.#w(),this.#y(),this.#o&&$(this.#o.focus)&&this.#o.focus())}#u(){if(!this.#n)return;this.#n.removeAttribute("data-open"),this.#i=null;const n=this.#s;this.#s=null,n&&$(n.focus)&&n.focus()}#c(){const n=this.#e.comments.openKey;if(!n)return;const{rowId:t}=H(n);this.#e.rows.byKey(t)||(this.#d("This row is no longer in the grid: it scrolled out of the live window."),this.#e.comments.close({reason:"evicted"}))}#d(n){if(!this.#r)return;const r=this.#r.ownerDocument.createElement("p");r.className=`${V}__note`,r.setAttribute("role","status"),r.textContent=n,this.#r.appendChild(r)}#h(n,t){const r=this.#t.viewport?.root;if(!r||!r.querySelector)return null;const s=r.querySelector(`[data-key="${X(n)}"]`);return s?s.querySelector(`[data-col="${t}"]`):null}#f(n,t){const r=this.#e;return(r&&r.messages?r.messages:I).t(n,t)}#p(n){const t=n.createElement("div");t.className=V,t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label",this.#f("comments.panel"));const r=n.createElement("header");r.className=`${V}__head`;const s=n.createElement("div");s.className=`${V}__title`,r.appendChild(s);const h=n.createElement("button");h.className=`${V}__resolve`,h.type="button",r.appendChild(h);const u=n.createElement("button");u.className=`${V}__close`,u.type="button",u.setAttribute("aria-label",this.#f("comments.close")),u.textContent="×",r.appendChild(u);const i=n.createElement("div");i.className=`${V}__list`,i.setAttribute("role","log"),i.setAttribute("aria-live","polite");const m=n.createElement("form");m.className=`${V}__composer`;const c=n.createElement("textarea");c.className=`${V}__input`,c.rows=2,c.setAttribute("aria-label",this.#f("comments.write"));const f=n.createElement("button");f.className=`${V}__send`,f.type="submit",f.textContent=this.#f("comments.post"),m.appendChild(c),m.appendChild(f),t.appendChild(r),t.appendChild(i),t.appendChild(m),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(t),this.#n=t,this.#r=i,this.#o=c,this.#m=s,this.#g=h;const a=k=>{k.preventDefault();const y=String(c.value||"").trim();y&&(c.value="",this.#e.comments.add(y))},p=()=>this.#e.comments.close(),b=()=>{this.#b()>0?this.#e.comments.resolve():this.#e.comments.unresolve()},O=k=>{if(k.stopPropagation(),k.key==="Escape"){k.preventDefault(),this.#e.comments.close();return}if(k.key!=="Tab")return;const y=[...t.querySelectorAll(w)].filter(x=>x.offsetParent!==null||x===c);if(!y.length)return;const v=y[0],R=y[y.length-1],S=t.ownerDocument.activeElement;k.shiftKey&&S===v?(k.preventDefault(),R.focus()):!k.shiftKey&&S===R&&(k.preventDefault(),v.focus())};m.addEventListener("submit",a),u.addEventListener("click",p),h.addEventListener("click",b),t.addEventListener("keydown",O),this.#l.push(()=>{m.removeEventListener("submit",a),u.removeEventListener("click",p),h.removeEventListener("click",b),t.removeEventListener("keydown",O)})}#m=null;#g=null;#b(){return(this.#e.comments.thread||[]).filter(t=>!t.resolved).length}#w(){const n=this.#e.comments;if(!this.#n||!n.openKey)return;const t=this.#n.ownerDocument,r=this.#e.get("comments")||{},s=Date.now(),h=n.openKey,{rowId:u,field:i}=H(h),m=this.#e.columns.get(i),c=this.#e.rows.byKey(u),f=$(r.rowLabel)&&c?r.rowLabel(c):u;if(this.#m.textContent=this.#f("comments.cellTitle",{column:m&&(m.title??m.id)||i,row:f}),this.#g.textContent=this.#b()>0?this.#f("comments.resolve"):this.#f("comments.reopen"),this.#r.textContent="",n.loading){this.#d(this.#f("comments.loading"));return}const a=n.thread||[];if(!a.length){this.#d(this.#f("comments.empty"));return}const p=c&&m?m.getValue(c.data,c):void 0;for(const b of a)this.#r.appendChild(this.#S(t,b,s,p,r))}#S(n,t,r,s,h){const u=n.createElement("article");u.className=`${V}__item`,t.pending&&u.setAttribute("data-pending","true"),t.resolved&&u.setAttribute("data-resolved","true");const i=n.createElement("div");i.className=`${V}__meta`;const m=n.createElement("span");m.className=`${V}__author`,m.textContent=t.author&&(t.author.name||t.author.initials)||this.#f("comments.unknownAuthor"),i.appendChild(m);const c=n.createElement("time");c.className=`${V}__time`;const f=A(t.at,r);c.textContent=t.edited?this.#f("comments.edited",{time:f}):f,i.appendChild(c),u.appendChild(i);const a=n.createElement("div");if(a.className=`${V}__body`,g(n,a,t.body,!!h.markdown),u.appendChild(a),t.value!==void 0&&!Object.is(t.value,s)){const O=n.createElement("p");O.className=`${V}__moved`,O.textContent=this.#f("comments.valueMoved",{was:String(t.value),now:String(s)}),u.appendChild(O)}const p=t.can||{},b=O=>p[O]!==!1;if(b("edit")||b("delete")){const O=n.createElement("div");if(O.className=`${V}__actions`,b("delete")){const k=n.createElement("button");k.type="button",k.className=`${V}__action`,k.textContent=this.#f("comments.delete"),k.addEventListener("click",()=>this.#e.comments.remove(t.id)),O.appendChild(k)}u.appendChild(O)}return u}#y(){if(!this.#n||!this.#e.comments.openKey)return;if((this.#e.get("comments")||{}).mode==="docked"){this.#n.setAttribute("data-docked","true");return}this.#n.removeAttribute("data-docked");const t=this.#e.comments.openKey,{rowId:r,field:s}=H(t),h=this.#h(r,s)||this.#i,u=this.#t.viewport?.root;if(!h||!u||!$(h.getBoundingClientRect))return;const i=h.getBoundingClientRect(),m=u.getBoundingClientRect(),c=this.#n.getBoundingClientRect();let f=i.bottom-m.top+4;f+c.height>m.height&&i.top-m.top>c.height&&(f=i.top-m.top-c.height-4);let a=i.left-m.left;a+c.width>m.width&&(a=Math.max(0,m.width-c.width-4)),this.#n.style.top=`${Math.max(0,f)}px`,this.#n.style.left=`${Math.max(0,a)}px`;const p=i.bottom<m.top||i.top>m.bottom;this.#n.toggleAttribute("data-offscreen",p)}destroy(){for(const n of this.#l)n();this.#l=[],this.#n&&$(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const d=l}),Fe("packages/dom/src/watermark.js",function(e,K){"use strict";Object.defineProperty(e,"WATERMARK_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"Watermark",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),X=_.el,W=_.on,H="lat-watermark",V="https://www.latticegrid.dev",z=["br","bl","tl","tr"],w=4e3;class A{#e;#t;#n;#r=null;#o=[];#i;#s=0;#l=null;constructor(d){this.#e=d.grid,this.#t=d.document,this.#n=d.element,this.#i=d.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),$(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const d=this.#e.licence&&this.#e.licence.ready;d&&$(d.then)&&d.then(()=>this.refresh(),()=>this.refresh())}refresh(){const d=this.#d();d&&!this.#r?(this.#h(),this.#u()):!d&&this.#r&&(this.#f(),this.#c())}#a(){const d=this.#i;if(!d||!$(d.matchMedia))return!1;try{return!!d.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),$(this.#i.setTimeout)&&(this.#a()||(this.#l=this.#i.setTimeout(()=>{if(this.#l=null,!this.#d()){this.#f();return}this.#s=(this.#s+1)%z.length,this.#f(),this.#h(),this.#u()},w)))}#c(){this.#l!==null&&$(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#l),this.#l=null}#d(){const d=this.#e.licence;return!!(d&&$(d.watermark)&&d.watermark())}#h(){const d=this.grid&&this.grid.messages?this.grid.messages:I,o=X(this.#t,"a",{class:`${H}__link`,text:d.t("licence.watermark"),attrs:{href:V,target:"_blank",rel:"noopener noreferrer"}}),n=X(this.#t,"span",{class:`${H}__free`,text:d.t("licence.watermark.free")});this.#r=X(this.#t,"div",{class:`${H} ${H}--${z[this.#s]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[o,n]}),this.#o.push(W(this.#r,"pointerdown",t=>{$(t.stopPropagation)&&t.stopPropagation()})),this.#n&&$(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#f(){this.#r&&$(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c();for(const d of this.#o)d();this.#o=[],this.#f()}}const g=A}),Fe("packages/dom/src/maximise.js",function(e,K){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const Q=K("packages/core/src/internal/util.js"),$=Q.warnOnce,B=Q.isFunction,I=K("packages/dom/src/editors/common.js"),_=I.el,X=I.on,H=K("packages/dom/src/themeof.js").themeOf,V="lat-maximised",z={position:"fixed",top:"0px",left:"0px",right:"0px",bottom:"0px",width:"auto",height:"auto",minWidth:"0px",minHeight:"0px",maxWidth:"none",maxHeight:"none",margin:"0px",zIndex:"2147483000"},w="lat-maximised-host",A="lat-maximise-placeholder";class g{#e;#t;#n;#r;#o;#i=null;#s=null;#l=new Set;#a=null;#u=!1;#c=null;constructor(o){this.#e=o.element,this.#t=o.document,this.#n=B(o.onChange)?o.onChange:null,this.#r=B(o.captureScroll)?o.captureScroll:null,this.#o=B(o.restoreScroll)?o.restoreScroll:null}active(){return this.#i!==null}enter(){if(this.active())return!0;const o=this.#e.parentNode;if(!o||!this.#t.body)return $("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=_(this.#t,"div",{class:A}),this.#i.style.visibility="hidden";const n=this.#e.offsetWidth,t=this.#e.offsetHeight;n&&(this.#i.style.width=`${n}px`),t&&(this.#i.style.height=`${t}px`);const r=this.#r?this.#r():null,s=B(this.#e.getAttribute)&&!this.#e.getAttribute("data-theme")?H(o):null;s&&(this.#e.setAttribute("data-theme",s),this.#u=!0),o.insertBefore(this.#i,this.#e),this.#d(()=>this.#t.body.appendChild(this.#e)),this.#a={};for(const[h,u]of Object.entries(z))this.#a[h]=this.#e.style[h]||"",this.#e.style[h]=u;return this.#c=this.#t.body.style?this.#t.body.style.overflow||"":null,this.#t.body.style&&(this.#t.body.style.overflow="hidden"),this.#e.classList.add(V),this.#t.body.classList&&this.#t.body.classList.add(w),r&&this.#o&&this.#o(r),this.#s=X(this.#t,"keydown",h=>this.#h(h)),this.#f(),!0}exit(){if(!this.active())return!1;const o=this.#r?this.#r():null,n=this.#i,t=n.parentNode;if(t&&B(t.insertBefore)&&this.#d(()=>t.insertBefore(this.#e,n)),B(n.remove)&&n.remove(),this.#i=null,this.#u&&(this.#e.removeAttribute("data-theme"),this.#u=!1),this.#a){for(const[r,s]of Object.entries(this.#a))this.#e.style[r]=s;this.#a=null}return this.#c!==null&&this.#t.body&&this.#t.body.style&&(this.#t.body.style.overflow=this.#c),this.#c=null,this.#e.classList.remove(V),this.#t.body&&this.#t.body.classList&&this.#t.body.classList.remove(w),o&&this.#o&&this.#o(o),this.#s&&this.#s(),this.#s=null,this.#f(),!0}toggle(){return this.active()?!this.exit():this.enter()}#d(o){const n=this.#t.activeElement,t=n&&n!==this.#t.body&&B(this.#e.contains)&&this.#e.contains(n)?n:null;o(),t&&B(t.focus)&&t.focus()}#h(o){!o||o.key!=="Escape"||o.defaultPrevented||this.exit()}#f(){this.#n&&this.#n();for(const o of this.#l)o(this.active())}watch(o){return B(o)?(this.#l.add(o),()=>this.#l.delete(o)):()=>{}}destroy(){this.exit()}}const l=g}),Fe("packages/dom/src/promptbar.js",function(e,K){"use strict";Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return t}});const Q=K("packages/dom/src/editors/common.js"),$=Q.documentFor,B=Q.el,I=Q.on,_=Q.clear,W=K("packages/core/src/i18n/index.js").defaultMessages,V=K("packages/core/src/internal/util.js").isFunction,z=K("packages/core/src/ai/schema.js"),w=z.describeGrid,A=z.promptText,g=K("packages/core/src/ai/intent.js"),l=g.applyPlan,d=g.buildPrompt,o=g.planIntent,n="lat-prompt";class t{#e;#t=null;#n=null;#r={};#o;#i={};#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=null;#f=null;#p=null;#m=null;#g=null;#b="idle";#w=0;#S=!1;#y=[];t(u,i){return(this.messages&&typeof this.messages.t=="function"?this.messages:W).t(u,i)}init(u={}){this.messages=u&&u.messages||u&&u.grid&&u.grid.messages||W,this.#e=$(u),this.#t=u.grid||null,this.#n=V(u.ask)?u.ask:null,this.#r=u.schemaOptions||{},this.#o=u.context,this.#i={onPlan:V(u.onPlan)?u.onPlan:null,onApply:V(u.onApply)?u.onApply:null,onError:V(u.onError)?u.onError:null},this.#s=B(this.#e,"div",{class:n,attrs:{"data-state":"idle",role:"search"}}),this.#O(u)}element(){return this.#s}refresh(){this.#S||!this.#s||this.#b!=="busy"&&this.#T()}destroy(){this.#S=!0,this.#w++;for(const u of this.#y)u();this.#y.length=0,this.#g=null,this.#s=null,this.#l=null,this.#a=null,this.#u=null,this.#c=null,this.#d=null,this.#h=null,this.#f=null,this.#p=null,this.#m=null}plan(){return this.#g}async ask(u){if(this.#S||this.#b==="busy")return null;const i=String(u??(this.#l&&this.#l.value)??"").trim();if(!i)return null;if(!this.#n)return this.#C("No model is wired up. Supply `ai.ask` to use the prompt bar."),null;const m=++this.#w;this.#k("busy"),this.#M("Thinking…");let c;try{const f=w(this.#t,this.#r),a=A(f);if(c=await this.#n({prompt:i,schema:f,schemaText:a,message:d(i,a),context:this.#o}),this.#S||m!==this.#w)return null;const p=o(c,f);return this.#j(p),p}catch(f){return this.#S||m!==this.#w||(this.#i.onError&&this.#i.onError(f),this.#C(f instanceof Error?f.message:String(f))),null}}apply(){const u=this.#g;if(this.#S||!u||!u.ok)return null;const i=this.#t?.ai,m=V(i?.apply)?i.apply(u):l(u,this.#t);return this.#i.onApply&&this.#i.onApply(m,u),this.#T(),this.#l&&(this.#l.value=""),m.failed.length?this.#C(`Applied ${m.applied.length}; ${m.failed.map(c=>`${c.type} failed: ${c.reason}`).join("; ")}`):this.#M(`Applied: ${u.describe()}`),m}discard(){this.#S||(this.#T(),this.#M("Discarded."))}#O(u){const i=this.#e,m=B(i,"div",{class:`${n}__row`});this.#l=B(i,"input",{class:`${n}__input`,attrs:{type:"text",placeholder:u.placeholder||"Ask for a view: “EMEA deals over 50k, biggest first”","aria-label":u.label||"Ask about this grid",autocomplete:"off"}}),this.#y.push(I(this.#l,"keydown",f=>{const a=f&&f.key;a==="Enter"?(V(f.preventDefault)&&f.preventDefault(),this.ask()):a==="Escape"&&this.#g&&(V(f.preventDefault)&&f.preventDefault(),this.discard())})),m.appendChild(this.#l),this.#a=B(i,"button",{class:`${n}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#y.push(I(this.#a,"click",()=>{this.ask()})),m.appendChild(this.#a),this.#s.appendChild(m),this.#u=B(i,"div",{class:`${n}__preview`,attrs:{hidden:!0}}),this.#c=B(i,"p",{class:`${n}__summary`}),this.#d=B(i,"ul",{class:`${n}__notes`});const c=B(i,"div",{class:`${n}__buttons`});this.#h=B(i,"button",{class:`${n}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#f=B(i,"button",{class:`${n}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#y.push(I(this.#h,"click",()=>{this.apply()})),this.#y.push(I(this.#f,"click",()=>{this.discard()})),c.appendChild(this.#h),c.appendChild(this.#f),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(c),this.#s.appendChild(this.#u),this.#p=B(i,"p",{class:`${n}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#m=B(i,"p",{class:`${n}__error`,attrs:{role:"alert",hidden:!0}}),this.#s.appendChild(this.#p),this.#s.appendChild(this.#m)}#k(u){if(this.#b=u,!this.#s)return;this.#s.setAttribute("data-state",u);const i=u==="busy";r(this.#l,i),r(this.#a,i),this.#a&&(this.#a.textContent=this.t(i?"prompt.asking":"prompt.ask")),s(this.#u,u!=="preview"),s(this.#m,u!=="error")}#j(u){const i=u;if(this.#i.onPlan&&this.#i.onPlan(u),!i.ok){this.#g=null;const m=i.rejected.length?i.rejected.map(c=>c.reason).join("; "):"nothing to do";this.#C(`I could not turn that into a change: ${m}`);return}this.#g=u,this.#M(""),this.#c&&(this.#c.textContent=i.describe()),this.#A(i.rejected),this.#k("preview")}#A(u){const i=this.#d;if(i){_(i),s(i,!u.length);for(const m of u.slice(0,6))i.appendChild(B(this.#e,"li",{class:`${n}__note`,text:m.reason}));u.length>6&&i.appendChild(B(this.#e,"li",{class:`${n}__note`,text:this.t("prompt.moreNotes",{count:u.length-6})}))}}#T(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&_(this.#d),this.#k("idle")}#M(u){this.#p&&(this.#p.textContent=u)}#C(u){this.#g=null,this.#M(""),this.#m&&(this.#m.textContent=u),this.#k("error")}}function r(h,u){h&&(h.disabled=u,u?h.setAttribute("disabled",""):h.removeAttribute("disabled"))}function s(h,u){h&&(h.hidden=u,u?h.setAttribute("hidden",""):h.removeAttribute("hidden"))}}),Fe("packages/dom/src/stat.js",function(e,K){"use strict";Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"bandTone",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return u}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.isObject,I=Q.warnOnce,X=K("packages/core/src/source/derive.js").reduceValues,H=K("packages/core/src/source/memory.js").isPipelineSettle,z=K("packages/core/src/i18n/index.js").defaultMessages,A=K("packages/dom/src/cell/icons.js").renderIconInto,g={root:"lat-stat",icon:"lat-stat__icon",body:"lat-stat__body",title:"lat-stat__title",value:"lat-stat__value",delta:"lat-stat__delta",interval:"lat-stat__interval",footer:"lat-stat__footer",note:"lat-stat__note"},l="unknown",d=new Set(["sum","min","max","avg","first","last","mode","median","p25","p75","p90","p95","p99","stddev","stddevP","mad","range","iqr","trimmedMean","winsorizedMean","geomean","harmean"]),o=Object.freeze({direction:"flat",change:null,percent:null});function n(a,p){if(!Number.isFinite(a)||!Number.isFinite(p))return o;const b=a-p,O=b>0?"up":b<0?"down":"flat",k=p===0?null:b/Math.abs(p)*100;return{direction:O,change:b,percent:k}}function t(a,p){return a==="flat"||p==="neither"?"flat":a===p?"good":"bad"}function r(a,p,b=null){if($(p)){const S=p(a,b);return S==="good"||S==="warn"||S==="bad"?S:null}if(!B(p))return null;const O=typeof a=="number"&&Number.isFinite(a)?a:null;if(O===null)return null;const k=Number.isFinite(Number(p.good))?Number(p.good):null,y=Number.isFinite(Number(p.warn))?Number(p.warn):null,v=String(p.direction||"up")==="down",R=S=>v?O<=S:O>=S;return k!==null&&R(k)?"good":y!==null&&R(y)?"warn":k===null&&y===null?null:"bad"}function s(a){return!($(a.value)||a.value!==void 0&&!B(a.value))}function h(a){return!a||!a.rows||!$(a.rows.totalCount)?!0:a.rows.totalCount()>0}function u(a){const p=B(a)?a:{},b=p.grid||null,O=c(p.container,b);if(!O)return I("stat.container","createStat needs a `container`: an element or a selector."),f();const k=O.ownerDocument||(typeof document>"u"?null:document);if(!k)return I("stat.document","createStat needs a document; it draws DOM."),f();const y=k.createElement("div");y.className=["lattice",g.root,p.class].filter(Boolean).join(" "),y.setAttribute("role","group");const v=k.createElement("div");v.className=g.title;const R=k.createElement("div");R.className=g.value;const S=k.createElement("div");S.className=g.interval;const x=k.createElement("div");x.className=g.delta;const C=k.createElement("div");C.className=g.footer;const P=k.createElement("div");if(P.className=g.note,P.hidden=!0,p.icon!=null&&p.icon!==""){const ee=k.createElement("span");ee.className=g.icon,ee.setAttribute("aria-hidden","true"),A(ee,p.icon,`stat:${p.title||"stat"}`),y.appendChild(ee);const ne=k.createElement("div");ne.className=g.body,ne.appendChild(v),ne.appendChild(R),ne.appendChild(P),ne.appendChild(S),ne.appendChild(x),ne.appendChild(C),y.appendChild(ne)}else y.appendChild(v),y.appendChild(R),y.appendChild(P),y.appendChild(S),y.appendChild(x),y.appendChild(C);O.appendChild(y);let E=null;const D=[];let N=!1;function M(){if($(p.value))return p.value(b);if(p.value!==void 0&&!B(p.value))return p.value;const ee=B(p.value)?p.value:p,ne=ee.of,ie=ee.fn||"sum",se=ee.show;return b?ie==="count"?L().length:ne?se?G(String(ne),String(ie),String(se)):j()==="filtered"&&b.statistics&&$(b.statistics.reduce)?b.statistics.reduce(String(ne),String(ie)):X(L().map(he=>m(he,String(ne))),String(ie)):null:null}function j(){return String(p.scope||"filtered")}function L(){if(!b||!b.rows)return[];const ee=j();if(ee==="all"){const ie=[];return $(b.rows.forEachAll)&&b.rows.forEachAll(se=>{se.group||ie.push(i(se))}),ie}if(ee==="selected")return(b.selection&&$(b.selection.rows)?b.selection.rows():[]).filter(Boolean).map(i);const ne=[];return $(b.rows.forEach)&&b.rows.forEach(ie=>{ie.group||ne.push(i(ie))}),ne}function G(ee,ne,ie){if(ne!=="min"&&ne!=="max")return I(`stat.show.${ne}`,`\`show\` needs \`fn: 'min'\` or \`fn: 'max'\`: "${ne}" reduces to a value that no single row holds, so there is no row to report from.`),null;let se=null,he=null;for(const ce of L()){const te=Number(m(ce,ee));Number.isFinite(te)&&(se===null||(ne==="max"?te>se:te<se))&&(se=te,he=ce)}return he===null?null:m(he,ie)}function q(ee){if($(p.format))return String(p.format(ee,b));if(ee==null)return p.empty??"—";const ne=B(p.value)?p.value:p,ie=ne.show||ne.of;if((ne.show?!0:d.has(String(ne.fn||"sum")))&&b&&ie&&$(b.columns?.get)){const he=b.columns.get(String(ie));if(he&&$(he.formatValue))return he.formatValue(ee)}return typeof ee=="number"?Number.isInteger(ee)?String(ee):ee.toFixed(p.decimals??2):String(ee)}function Y(ee){return ee?(b&&b.messages||z).t(`stat.tone.${ee}`):""}function J(){if(N)return;const ee=M(),ne=s(p)&&!!b&&!h(b),ie=ne?null:ee,se=$(p.baseline)?p.baseline(b):p.baseline;E=ie,v.textContent=p.title??"",v.hidden=!p.title,R.textContent=q(ie),P.hidden=!ne,ne&&(P.textContent=b.messages.t("stat.noData"));const he=ne||se===void 0||se===null?o:n(typeof ie=="number"?ie:null,Number(se)),ce=t(he.direction,p.goodWhen||"up");if(x.hidden=he.change===null,he.change!==null){const de=he.direction==="up"?"↑":he.direction==="down"?"↓":"→",ve=he.percent===null?q(Math.abs(he.change)):`${Math.abs(he.percent).toFixed(1)}%`;x.textContent=`${de} ${ve}`,x.setAttribute("data-tone",ce),x.setAttribute("data-direction",he.direction)}const te=$(p.interval)?p.interval(ie,b):null,oe=!!te&&Number.isFinite(te.lower)&&Number.isFinite(te.upper);S.hidden=!oe,oe&&(S.textContent=`${q(te.lower)} – ${q(te.upper)}`,Number.isFinite(te.confidence)&&S.setAttribute("title",`${Math.round(te.confidence*100)}%`));const fe=ne?l:p.bands?r(ie,p.bands,b):null;fe?y.setAttribute("data-tone",fe):y.removeAttribute("data-tone"),C.textContent=$(p.footer)?String(p.footer(ie,b)):p.footer??"",C.hidden=!C.textContent,y.setAttribute("aria-label",[p.title,R.textContent,ne?P.textContent:"",oe?S.textContent:"",he.change===null?"":x.textContent,he.change===null?"":Y(ce),C.textContent].filter(Boolean).join(", "))}if(b&&$(b.on)&&p.live!==!1)for(const ee of["rows:changed","filter:changed","selection:changed","model:changed"]){const ne=ie=>{ee==="model:changed"&&!H(ie)||J()};b.on(ee,ne),D.push(()=>$(b.off)&&b.off(ee,ne))}return J(),{element:()=>y,value:()=>E,refresh:J,destroy(){N=!0;for(const ee of D)try{ee()}catch{}D.length=0,y.remove()}}}function i(a){return B(a)&&"data"in a?a.data:a}function m(a,p){if(!B(a))return;if(!p.includes("."))return a[p];let b=a;for(const O of p.split(".")){if(!B(b))return;b=b[O]}return b}function c(a,p){if(a&&typeof a=="object")return a;if(typeof a!="string")return null;const b=p&&p.element&&p.element.ownerDocument||(typeof document>"u"?null:document);return b?b.querySelector(a):null}function f(){return{element:()=>null,value:()=>null,refresh(){},destroy(){}}}}),Fe("packages/dom/src/kpistrip.js",function(e,K){"use strict";Object.defineProperty(e,"KpiStrip",{enumerable:!0,get:function(){return X}});const $=K("packages/core/src/internal/util.js").isObject,I=K("packages/dom/src/stat.js").createStat,_={band:"lat-kpi-strip"};class X{#e;#t;#n;#r=null;#o=[];constructor({grid:H,document:V,kpis:z}){this.#e=H,this.#t=V,this.#n=Array.isArray(z)?z.filter($):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const V=this.#t.createElement("div");V.className=`lattice ${_.band}`,V.setAttribute("role","group"),V.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=V;for(const z of this.#n){const w=I({...z,grid:this.#e,container:V});this.#o.push(w)}}destroy(){for(const H of this.#o)try{H.destroy()}catch{}this.#o.length=0,this.#r&&(this.#r.remove(),this.#r=null)}}}),Fe("packages/dom/src/createGrid.js",function(e,K){"use strict";Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return Et}});const $=K("packages/core/src/index.js").createHeadlessGrid,I=K("packages/core/src/defaults.js").applyDefaults,X=K("packages/core/src/export/download.js").downloadBlob,W=K("packages/core/src/internal/util.js"),H=W.fail,V=W.isFunction,z=W.warnOnce,A=K("packages/dom/src/localviews.js").createLocalViewStorage,l=K("packages/dom/src/renderer/index.js").DomRenderer,o=K("packages/dom/src/cell/index.js").createCellLayer,n=K("packages/dom/src/cell/icons.js"),t=n.icon,r=n.iconNames,h=K("packages/dom/src/editors/index.js").editors,i=K("packages/dom/src/filters/index.js").filters,m=K("packages/dom/src/ui/index.js"),c=m.StatusBar,f=m.TooltipManager,a=m.Pagination,p=m.GroupByZone,O=K("packages/dom/src/ui/celltooltip.js").CellTooltips,y=K("packages/dom/src/filtermenu.js").FilterMenu,R=K("packages/dom/src/columnmenu.js").ColumnMenu,x=K("packages/dom/src/shortcutshelp.js").ShortcutsHelp,P=K("packages/dom/src/rowreorder.js").RowReorder,E=K("packages/dom/src/alignedgrids.js").AlignedGrids,N=K("packages/dom/src/columntagbar.js").ColumnTagBar,j=K("packages/dom/src/anomalychip.js").AnomalyChip,G=K("packages/dom/src/rowform.js").RowForm,q=K("packages/dom/src/toolpanelmount.js"),Y=q.ToolPanelDock,J=q.panelHost,ne=K("packages/dom/src/celledit.js").CellEditController,se=K("packages/dom/src/editbar.js").EditBar,ce=K("packages/dom/src/rangeselect.js").RangeController,oe=K("packages/core/src/model/selection.js").resolveSelectionConfig,de=K("packages/dom/src/importer.js").ImportController,Me=K("packages/dom/src/historybar.js").HistoryBar,Ce=K("packages/dom/src/diffpaint.js").DiffPainter,we=K("packages/dom/src/detailhost.js").DetailHost,Ne=K("packages/dom/src/highlightpaint.js").HighlightPainter,He=K("packages/dom/src/findpaint.js").FindPainter,Ae=K("packages/dom/src/findbar.js").FindBar,Ze=K("packages/dom/src/redactpaint.js").RedactionPainter,lt=K("packages/dom/src/validationpaint.js").ValidationPainter,gt=K("packages/dom/src/presentation.js").PresentationController,Pt=K("packages/dom/src/capture.js").captureElement,Mt=K("packages/dom/src/annotate.js").AnnotationLayer,Bt=K("packages/dom/src/timelinebar.js").TimelineBar,rt=K("packages/dom/src/commentpaint.js").CommentPainter,ke=K("packages/dom/src/presencepaint.js").PresencePainter,Ie=K("packages/dom/src/commentpanel.js").CommentPanel,Qe=K("packages/dom/src/watermark.js").Watermark,ge=K("packages/dom/src/maximise.js").Maximiser,Pe=K("packages/dom/src/promptbar.js").PromptBar,Be=K("packages/dom/src/kpistrip.js").KpiStrip;function _e(Ke,ht,it){const ct=ht==="redo"?"toolbar.redo":"toolbar.undo";return!it||!it.label?Ke(ct):Ke(ht==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:it.label})}const be=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],Ee=2e3;function ze(Ke,ht,it,ct){const St=ht.annotate===!0?Ve(Ke,ct):[];if(ht.actions===!1)return[];if(ht.actions===void 0&&ht.side!=="left")return St;const Rt=Array.isArray(ht.actions)?ht.actions:be,yt=(zt,tn)=>Ke.messages.t(zt,tn),Nt={undo:{name:"undo",title:()=>_e(yt,"undo",Ke.history.peek("undo")),icon:"undo",run:()=>Ke.history.undo(),enabled:()=>Ke.history.canUndo()},redo:{name:"redo",title:()=>_e(yt,"redo",Ke.history.peek("redo")),icon:"redo",run:()=>Ke.history.redo(),enabled:()=>Ke.history.canRedo()},export:{name:"export",title:()=>yt("toolbar.exportCsv"),icon:"download",run:()=>Ke.export.csv({download:!0,fileName:ht.exportName})},excel:{name:"excel",title:()=>yt("toolbar.exportExcel"),icon:"spreadsheet",run:()=>Ke.export.excel({download:!0,fileName:ht.exportName})},clipboard:{name:"clipboard",title:()=>yt("toolbar.clipboard"),icon:"copy",run:()=>Ke.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>yt("toolbar.print"),icon:"print",run:()=>Ke.export.print()},pause:{name:"pause",title:()=>{if(!Ke.updates.paused)return yt("toolbar.pause");const zt=Ke.updates.stats().pending;return zt?yt("toolbar.applyHeld",{count:zt}):yt("toolbar.resume")},icon:()=>Ke.updates.paused?"play":"pause",run:()=>Ke.updates.paused?Ke.updates.resume():Ke.updates.pause()},restore:{name:"restore",title:()=>yt("toolbar.restoreView"),icon:"restore",run:()=>Ke.state.reset(),enabled:()=>Ke.state.modified()},maximise:{name:"maximise",title:()=>yt(it&&it.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>it&&it.active()?"minimise":"maximise",run:()=>it.toggle()}};return it||delete Nt.maximise,Rt.map(zt=>zt==="-"?{name:"-",separator:!0}:typeof zt=="string"?Nt[zt]:!zt||typeof zt!="object"||!zt.name?null:{...zt,run:V(zt.run)?()=>zt.run({grid:Ke,keys:Ke.selection&&V(Ke.selection.keys)?Ke.selection.keys():[],cells:Ke.selection&&V(Ke.selection.cells)?Ke.selection.cells():[]}):void 0}).filter(Boolean).concat(St)}function Ve(Ke,ht){const it={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight",erase:"eraser"},ct=(Rt,yt)=>Ke.messages.t(Rt,yt),St=["pen","arrow","rect","highlight","erase"].map(Rt=>({name:Rt,title:()=>ct(`toolbar.annotate.${Rt}`),icon:it[Rt],run:()=>Ke.annotate?.use(Rt),active:()=>Ke.annotate?.tool===Rt,annotation:!0}));return St.push(Je(Ke,ct,ht)),St}function Je(Ke,ht,it){return{name:"clearAll",title:()=>ht("toolbar.annotate.clearAll"),icon:"trash",enabled:()=>(Ke.annotate?.count||0)>0,annotation:!0,run:()=>ot(Ke,ht,it)}}function ot(Ke,ht,it){const ct=Ke.toolPanel;if(!ct)return;const St=yt=>it?.announce?.(ht(yt),{repeat:!0});ct.removeAction("clearAll");const Rt=()=>{ct.removeAction("clearAllConfirm"),ct.removeAction("clearAllKeep"),ct.addAction(Je(Ke,ht,it))};ct.addAction({name:"clearAllConfirm",title:()=>ht("toolbar.annotate.clearAllConfirm"),icon:"trash",annotation:!0,run:()=>{Ke.annotate?.clear(),Rt(),St("a11y.annotate.cleared")}}),ct.addAction({name:"clearAllKeep",title:()=>ht("toolbar.annotate.clearAllKeep"),icon:"close",annotation:!0,run:()=>Rt()}),St("a11y.annotate.confirmClear")}const at=["pen","arrow","rect","highlight","erase","clearAll"];function st(Ke){let ht=null,it=null;return Ke.on("source:error",ct=>{const St=ct&&ct.error;it=String(St&&St.message||"").replace(/^\[lattice\]\s*/,"")||(Ke.messages?Ke.messages.t("overlay.error"):"Something went wrong")}),Ke.on("rows:changed",()=>{it=null}),{loadError:()=>it,rowCount:()=>{if(V(Ke.rows.matchCount))return Ke.rows.matchCount();const ct=Ke.pagination&&V(Ke.pagination.get)?Ke.pagination.get():null;return ct&&Number.isFinite(ct.total)?ct.total:Ke.rows.count()},totalRowCount:()=>V(Ke.rows.totalCount)?Ke.rows.totalCount():Ke.rows.count(),selectedAcrossSource:()=>{ht||(ht=V(Ke.rendererHost)?Ke.rendererHost():{});const ct=V(ht.selectionSummary)?ht.selectionSummary():null;return ct&&ct.predicate?{count:ct.count}:null},selectedCount:()=>{const ct=Ke.selection&&Ke.selection.keys?Ke.selection.keys():null;return ct?ct.length:0},rangeValues:()=>{const ct=Ke.selection;return!ct||!V(ct.cells)?[]:ct.cells().map(({key:St,colId:Rt})=>Ke.rows.value(St,Rt))},hiddenUnresolved:()=>V(Ke.comments&&Ke.comments.hiddenUnresolved)?Ke.comments.hiddenUnresolved():0,progress:()=>V(Ke.source&&Ke.source.progress)?Ke.source.progress():null,updateStats:()=>Ke.updates?Ke.updates.stats():null}}function wt(Ke,ht){for(const[it,ct]of Object.entries(h||{}))Ke.register("editor",it,ct);for(const[it,ct]of Object.entries(i||{}))Ke.register("filter",it,ct);for(const[it,ct]of Object.entries(ht.components||{}))Ke.register("component",it,ct);for(const[it,ct]of Object.entries(ht.pipes||{}))Ke.register("pipe",it,ct);for(const[it,ct]of Object.entries(ht.totalFns||{}))Ke.register("totalFn",it,ct)}function kt(Ke,ht,it,ct,St,Rt){const yt=[],Nt=ht.viewport;let zt=null;if(it.maximise!==!1&&(zt=new ge({element:Rt,document:ct,onChange:()=>ht.invalidate("all"),captureScroll:()=>ht.scrollState(),restoreScroll:ut=>ht.restoreScroll(ut)}),Ke.maximise=zt,yt.push(()=>zt.destroy())),it.statusBar){const ut=typeof it.statusBar=="object"?it.statusBar:{},vt=new c;vt.init({document:ct,host:st(Ke),panels:ut.panels,registry:ut.registry,locale:Ke.get("locale"),messages:Ke.messages}),Nt.statusBar.appendChild(vt.element());const Lt=()=>{const sn=Nt.statusBar.offsetHeight||Nt.statusBar.getBoundingClientRect?.().height||0;Nt.root.style.setProperty("--lattice-status-height",`${Math.ceil(sn)}px`)},Ht=()=>{vt.refresh(),Lt()},Kt=["rows:changed","model:changed","source:error","selection:changed","range:changed","rows:queued","rows:paused","rows:resumed","comment:added","comment:edited","comment:deleted","comment:indexLoaded"].map(sn=>Ke.on(sn,Ht));Ht(),Lt(),yt.push(()=>{for(const sn of Kt)sn();Nt.root.style.removeProperty("--lattice-status-height"),vt.destroy?.()})}const tn=oe(it.selection);if(tn.ranges){const ut=new ce({grid:Ke,renderer:ht,document:ct});ut.mount(),Ke.ranges=ut,yt.push(()=>ut.destroy())}if(it.import){const ut=new de({grid:Ke,renderer:ht,document:ct,settings:typeof it.import=="object"?it.import:{}});Ke.importer=ut,yt.push(()=>ut.destroy())}if(it.historyBar){const ut=typeof it.historyBar=="object"?it.historyBar.element:null,vt=new Me;vt.init({document:ct,host:{undo:()=>Ke.history.undo(),redo:()=>Ke.history.redo(),canUndo:()=>Ke.history.canUndo(),canRedo:()=>Ke.history.canRedo(),peek:Ht=>Ke.history.peek(Ht),list:()=>Ke.history.list()},props:typeof it.historyBar=="object"?it.historyBar:{}}),(ut||Nt.root).appendChild(vt.element());const Lt=[Ke.on("history:changed",()=>vt.refresh())];Ke.historyBar=vt,yt.push(()=>{for(const Ht of Lt)Ht();vt.destroy()})}if(it.diff){const ut=new Ce({grid:Ke,renderer:ht});ut.mount(),Ke.diffPainter=ut,yt.push(()=>ut.destroy())}if(it.ai&&V(it.ai.ask)){const ut=new Pe;ut.init({document:ct,grid:Ke,ask:it.ai.ask,schemaOptions:it.ai.schemaOptions,context:it.ai.context,placeholder:it.ai.placeholder});const vt=it.ai.element||Nt.root;vt===Nt.root?vt.insertBefore(ut.element(),vt.firstChild):vt.appendChild(ut.element()),Ke.promptBar=ut,yt.push(()=>ut.destroy())}if(it.groupPanel){const ut=typeof it.groupPanel=="object"?it.groupPanel:{},vt=new p;vt.init({document:ct,grid:Ke,host:J(Ke,ct,(Lt,Ht)=>ht.announce?.(Lt,Ht)),props:{header:Nt.header,hint:ut.hint}}),Nt.root.insertBefore(vt.element(),Nt.header),Ke.groupPanel=vt;for(const Lt of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])V(Ke.on)&&yt.push(Ke.on(Lt,()=>vt.refresh()));yt.push(()=>vt.destroy())}if(it.kpis){const ut=new Be({grid:Ke,document:ct,kpis:it.kpis});ut.active&&(ut.mount(),Nt.root.insertBefore(ut.element(),Nt.header),Ke.kpiStrip=ut,yt.push(()=>ut.destroy()))}if(it.toolPanel){const ut=typeof it.toolPanel=="object"?it.toolPanel:{},vt=new Y({grid:Ke,document:ct,root:Nt.root,panels:ut.panels,openPanel:ut.openPanel,side:ut.side,icons:ut.icons,actions:ze(Ke,ut,zt,ht),announce:(Lt,Ht)=>ht.announce?.(Lt,Ht)});vt.mount(),Ke.toolPanel=vt,yt.push(()=>vt.destroy()),ut.annotate===void 0&&(yt.push(Ke.on("presentation:started",()=>{for(const Lt of Ve(Ke,ht))vt.addAction(Lt)})),yt.push(Ke.on("presentation:ended",()=>{for(const Lt of at)vt.removeAction(Lt)})))}if(!!it.pagination&&(()=>{const ut=typeof it.pagination=="object"?it.pagination:{};return Ke.pagination.set({pageSize:Number(ut.pageSize)||100}),Ke.pagination.get().pageSize>0})()){const ut=typeof it.pagination=="object"?it.pagination:{},vt=new a;vt.init({document:ct,pageSize:ut.pageSize,pageSizes:ut.pageSizes,page:ut.page,total:ut.total,locale:Ke.get("locale"),messages:Ke.messages,onChange:({page:Kt,pageSize:sn})=>Ke.pagination.set({page:Kt,pageSize:sn})});const Lt=()=>{const Kt=Ke.pagination.get();vt.total=Kt.total,vt.counting=Kt.counting===!0,vt.hasMore=Kt.total==null&&Kt.pageCount>Kt.page+1,vt.page=Kt.page,vt.paint()};Ke.pagination.set({pageSize:vt.pageSize}),Lt();const Ht=["rows:changed","filter:changed","model:changed"].map(Kt=>Ke.on(Kt,Lt));Nt.statusBar.appendChild(vt.element()),yt.push(()=>{for(const Kt of Ht)Kt();vt.destroy?.()})}if(it.edit!==!1)if(it.editBar){const ut=new se({grid:Ke,document:ct,root:Nt.root});ut.mount(),Ke.editBar=ut,yt.push(()=>ut.destroy())}else{const ut=new ne({grid:Ke,document:ct,renderer:ht,registry:St,cellLayer:ht.cellLayer});ut.mount(),yt.push(()=>ut.destroy())}const dn=new y({grid:Ke,document:ct,layer:Nt.overlays,registry:St});dn.mount(),yt.push(()=>dn.destroy());const qt=new R({grid:Ke,document:ct,host:Nt.root,cellMenu:it.contextMenu!==!1,headerMenu:it.columnMenu!==!1,items:V(it.contextMenu)?it.contextMenu:void 0,headerItems:V(it.columnMenu)?it.columnMenu:void 0});if(qt.mount(),yt.push(()=>qt.destroy()),Array.isArray(it.alignedGrids)&&it.alignedGrids.length){const ut=new E;ut.add(Ke);for(const vt of it.alignedGrids)vt&&vt!==Ke&&ut.add(vt);yt.push(()=>ut.destroy())}const _t=new G({grid:Ke,renderer:ht,document:ct,registry:St});_t.active&&(_t.mount(),yt.push(()=>_t.destroy())),Object.defineProperty(Ke,"form",{configurable:!0,value:Object.freeze({open(ut){return _t.active?_t.openRow(ut):!1},openNew(ut){return _t.active?_t.openNew(ut):(z("rowform:off","grid.form.openNew() was called on a grid with no row form (rowForm is off, or no renderer is attached); nothing opened."),!1)},close(){_t.active&&_t.close()},save(){return _t.active?_t.save():!1},isOpen(){return _t.active?_t.open:!1}})}),yt.push(()=>{delete Ke.form}),Object.defineProperty(Ke,"icons",{configurable:!0,value:Object.freeze({get(ut){const vt=t(ut);return vt?{viewBox:vt.viewBox,paths:vt.paths.slice(),paint:vt.paint==="stroke"?"stroke":"fill"}:null},names(){return r()}})}),yt.push(()=>{delete Ke.icons});const Tt=new N({grid:Ke,renderer:ht,document:ct});Tt.active&&(Tt.mount(),yt.push(()=>Tt.destroy()));const $t=new j({grid:Ke,renderer:ht,document:ct});$t.active&&($t.mount(),yt.push(()=>$t.destroy()));const Ut=new P({grid:Ke,renderer:ht,document:ct});if(Ut.active){Ut.mount(),Ut.paint();const ut=Ke.on("render:done",()=>Ut.paint());yt.push(()=>{ut(),Ut.destroy()})}if(it.shortcuts!==!1){const ut=new x({grid:Ke,renderer:ht});ut.mount(),yt.push(()=>ut.destroy())}const Wt=new Ne({grid:Ke,renderer:ht,window:ct.defaultView||void 0});Wt.mount(),yt.push(()=>Wt.destroy());const Qt=new He({grid:Ke,renderer:ht,window:ct.defaultView||void 0});if(Qt.mount(),yt.push(()=>Qt.destroy()),it.find!==!1){const ut=new Ae({grid:Ke,renderer:ht,document:ct,settings:it.find});ut.mount(),yt.push(()=>ut.destroy())}const Yt=new Ze({grid:Ke,renderer:ht});Yt.mount(),yt.push(()=>Yt.destroy());const Jt=new lt({grid:Ke,renderer:ht});Jt.mount(),yt.push(()=>Jt.destroy());const rn=new gt({grid:Ke,renderer:ht,maximiser:zt});rn.mount(),yt.push(()=>rn.destroy());const en=new Bt({grid:Ke,renderer:ht});en.mount(),yt.push(()=>en.destroy()),it.environment||Ke.set("environment",()=>({userAgent:typeof navigator=="object"&&navigator?navigator.userAgent:void 0,hardwareConcurrency:typeof navigator=="object"&&navigator?navigator.hardwareConcurrency:void 0,devicePixelRatio:typeof window=="object"&&window?window.devicePixelRatio:void 0,viewport:typeof window=="object"&&window?{width:window.innerWidth,height:window.innerHeight}:void 0,crossOriginIsolated:typeof globalThis.crossOriginIsolated=="boolean"?globalThis.crossOriginIsolated:void 0}));let cn=null;for(const[ut,vt]of[["filter:changed","filter"],["sort:changed","sort"],["rows:changed","data"],["column:resized","resize"],["column:moved","columns"],["column:visible","columns"]])yt.push(Ke.on(ut,()=>{cn=vt}));yt.push(Ke.on("render:done",ut=>{Ke.diagnostics.render(cn||ut.cause,ut.phases),cn=null}));const ln=ct.defaultView;if(ln&&V(ln.requestAnimationFrame)){let ut=ln.requestAnimationFrame(function vt(Lt){Ke.diagnostics.frame(Lt),ut=ln.requestAnimationFrame(vt)});yt.push(()=>{V(ln.cancelAnimationFrame)&&ln.cancelAnimationFrame(ut)})}const yn=new ke({grid:Ke,renderer:ht});if(yn.mount(),yt.push(()=>yn.destroy()),yt.push(Ke.on("presence:lockRefused",ut=>yn.announceRefusal(ut.peer))),Ke.presence&&Ke.presence.enabled){for(const Lt of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])yt.push(Ke.on(Lt,()=>Ke.presence.publish()));let ut="";yt.push(Ke.on("render:done",()=>{const Lt=ht.focusState&&ht.focusState(),Ht=Lt?`${Lt.rowKey}${Lt.colId}`:"";Ht!==ut&&(ut=Ht,Ke.presence.publish())}));const vt=Rt.ownerDocument;if(vt&&V(vt.addEventListener)){const Lt=()=>Ke.presence.setPaused(vt.visibilityState==="hidden");vt.addEventListener("visibilitychange",Lt),Lt(),yt.push(()=>vt.removeEventListener("visibilitychange",Lt))}}const bn=new rt({grid:Ke,renderer:ht});bn.mount(),yt.push(()=>bn.destroy());const wn=new Ie({grid:Ke,renderer:ht});wn.mount(),yt.push(()=>wn.destroy()),yt.push(Ke.on("facet:computed",()=>ht.refreshHeader?.())),tn&&tn.headerCheckbox===!0&&yt.push(Ke.on("selection:changed",()=>ht.refreshHeader?.())),yt.push(Ke.on("facet:expanded",()=>ht.invalidate("columns"))),yt.push(Ke.on("model:changed",()=>ht.invalidate("rows")));const Zt=(ut,vt)=>ht.announce?.(ut,vt),hn=Ke.messages,Gt=(ut,vt)=>hn.t(ut,vt),gn=ut=>Gt("count.rows",{count:ut});yt.push(Ke.on("sort:changed",()=>{const ut=Ke.sort.get();if(!ut.length){Zt(Gt("a11y.sort.cleared"));return}const vt=ut.map(Lt=>{const Ht=Ke.columns.get(Lt.col);return Gt("a11y.sort.column",{column:Ht&&Ht.title||Lt.col,direction:Gt(Lt.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});Zt(Gt("a11y.sort.by",{columns:hn.list(vt)}))})),yt.push(Ke.on("filter:changed",()=>{const ut=Ke.rows.matchCount?Ke.rows.matchCount():Ke.rows.count();if(ut===null)return;const vt=Ke.rows.totalCount?Ke.rows.totalCount():ut;Zt(ut===vt?Gt("a11y.filter.cleared",{rows:gn(vt)}):Gt("a11y.filter.applied",{shown:gn(ut),total:gn(vt)}))})),yt.push(Ke.on("selection:changed",()=>{const ut=Ke.selection.keys().length;Zt(ut===0?Gt("a11y.selection.cleared"):Gt("a11y.selection.count",{count:ut}))})),yt.push(Ke.on("group:toggled",ut=>{const vt=Ke.rows.byKey?Ke.rows.byKey(ut.key):null,Lt=(vt&&(vt.groupLabel??vt.groupValue))??ut.key;Zt(Gt(ut.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:Lt,rows:gn(Ke.rows.count())}))})),yt.push(Ke.on("column:grouped",ut=>{const vt=Array.isArray(ut.columns)?ut.columns:[];if(!vt.length){Zt(Gt("a11y.group.cleared"));return}const Lt=vt.map(Ht=>{const Kt=Ke.columns.get(Ht);return Kt&&Kt.title||Ht});Zt(Gt("a11y.group.by",{columns:hn.list(Lt)}))})),yt.push(Ke.on("page:changed",ut=>{const vt=Number(ut.size)||0,Lt=Number(ut.total)||0,Ht=vt>0?Math.max(1,Math.ceil(Lt/vt)):1;Zt(Gt("a11y.page.position",{page:(Number(ut.page)||0)+1,pages:Ht}))}));let on={added:0,removed:0},Xt=null;const Ln=()=>{Xt=null;const ut=[];on.added&&ut.push(Gt("count.rowsAdded",{count:on.added})),on.removed&&ut.push(Gt("count.rowsRemoved",{count:on.removed})),on={added:0,removed:0},ut.length&&Zt(hn.list(ut))};yt.push(Ke.on("rows:changed",ut=>{if(!ut||typeof ut.added!="number")return;const vt=Number(ut.added)||0,Lt=Number(ut.removed)||0;!vt&&!Lt||(on.added+=vt,on.removed+=Lt,Xt||(Xt=setTimeout(Ln,Ee)))})),yt.push(()=>{Xt&&clearTimeout(Xt)}),yt.push(Ke.on("rows:paused",()=>{Xt&&(clearTimeout(Xt),Xt=null),on={added:0,removed:0},Zt(Gt("a11y.updates.paused"),{repeat:!0})})),yt.push(Ke.on("rows:resumed",()=>Zt(Gt("a11y.updates.resumed"),{repeat:!0})));let fn={count:0,first:null},pn=null;const Cn=()=>{pn=null;const{count:ut,first:vt}=fn;if(fn={count:0,first:null},!ut||!vt)return;const Lt=Ke.columns.get(vt.colId),Ht=Lt&&Lt.title||vt.colId,Kt=vt.reason?Gt("a11y.edit.reason",{reason:vt.reason}):"";if(ut===1){const sn=vt.restored===void 0||vt.restored===null||vt.restored===""?Gt("value.empty"):String(vt.restored);Zt(Gt("a11y.edit.refusedOne",{column:Ht,value:sn,reason:Kt}),{repeat:!0});return}Zt(Gt("a11y.edit.refusedMany",{count:ut,reason:Kt}),{repeat:!0})};yt.push(Ke.on("cell:reverted",ut=>{!ut||!ut.applied||(fn.count+=1,fn.first||(fn.first=ut),pn||(pn=setTimeout(Cn,150)))})),yt.push(()=>{pn&&clearTimeout(pn)}),yt.push(Ke.on("history:applied",ut=>{const vt=!!(ut&&ut.direction==="redo"),Lt=ut&&ut.step&&ut.step.label;Zt(Lt?Gt(vt?"a11y.history.redo":"a11y.history.undo",{label:Lt}):Gt(vt?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const vn=new Mt({grid:Ke,renderer:ht,seed:it.state&&Array.isArray(it.state.annotations)?it.state.annotations:null});vn.mount(),yt.push(()=>vn.destroy()),Ke.annotate=vn,Ke.capture=async(ut={})=>{const{blob:vt,width:Lt,height:Ht}=await Pt(ht.viewport.root,ut);return(ut.download===!0||ut.download!==!1&&ut.fileName)&&X(vt,ut.fileName||`${Ke.get("exportName")||"grid"}.png`),Ke.emit("presentation:captured",{width:Lt,height:Ht,bytes:vt.size,mimeType:vt.type,fileName:ut.fileName||null},"api"),vt};const En=new Qe({grid:Ke,document:ct,element:Nt.overlays,window:ct.defaultView||void 0});En.mount(),yt.push(()=>En.destroy());const Fn=new f({grid:Ke,document:ct,element:Nt.overlays});Fn.mount?.(),yt.push(()=>Fn.destroy?.());const Tn=new O({grid:Ke,host:Ke.rendererHost(),viewport:Nt,document:ct});return Tn.mount(),yt.push(()=>Tn.destroy()),yt}function mt(Ke){const ht=[],it=ct=>{if(ct&&(ct.__lattice&&ht.push(ct),ct.children))for(const St of ct.children)it(St)};return it(Ke),ht}function Et(Ke,ht={}){(!Ke||typeof Ke!="object"||!("appendChild"in Ke))&&H("createGrid needs a host element as its first argument."),ht=I(ht);const it=Ke.ownerDocument||(typeof document<"u"?document:null);it||H("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const ct=it.documentElement&&it.documentElement.lang,St=!ht.licence&&V(it.querySelector)?it.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,Rt={...ht};if(!ht.locale&&ct&&(Rt.locale=ct),St&&(Rt.licence=St),ht.views&&ht.views.local)if(ht.views.storage)z("views:local:ignored","[lattice] views.local is ignored because views.storage was also supplied; the explicit adapter wins.");else{const qt=ht.views.local===!0?{}:ht.views.local;Rt.views={...ht.views,storage:A(qt)}}const yt=$(Rt),Nt=yt.rendererHost();Nt.document=it,wt(Nt.registry,ht),Nt.cellLayer=o(Nt),Nt.detailHost=new we({grid:yt,document:Ke.ownerDocument||globalThis.document,createGrid:(qt,_t)=>Et(qt,_t)});const zt=new l(Ke,Nt),tn=yt.on("detail:toggled",()=>{Nt.detailHost.syncTarget(),Nt.detailHost.prune()}),mn=yt.on("config:changed",qt=>{qt&&qt.key==="detail"&&Nt.detailHost.reconfigure()});yt.on("destroy",()=>{tn(),mn(),Nt.detailHost.destroy()}),Nt.detailHost.syncTarget(),yt.attachRenderer(zt),zt.mount();const an=kt(yt,zt,ht,it,Nt.registry,Ke),dn=yt.destroy.bind(yt);return yt.destroy=()=>{for(const qt of an)try{qt()}catch{}Ke.__lattice===yt&&(Ke.__lattice=null),dn()},Ke.__lattice=yt,yt}}),Fe("packages/dom/src/hydrate.js",function(e,K){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"HYDRATE_CONFIG_ATTR",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"hydrateInto",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return f}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,I=K("packages/core/src/columns/datatypes.js"),_=I.BUILTIN_TYPES,X=I.parseNumberText,H=K("packages/core/src/columns/types/index.js").EXTENDED_TYPES,z=K("packages/core/src/format/boolean.js").toTriState,w=K("packages/core/src/format/date.js"),A=w.toIsoDate,g=w.toIsoDateTime,d=K("packages/dom/src/createGrid.js").createGrid,o=new Set([...Object.keys(_),...Object.keys(H)]);function n(a,p){for(const b of a.children)if(b.tagName===p.toUpperCase())return b;return null}function t(a,p){const b=[];for(const O of a.children)O.tagName===p.toUpperCase()&&b.push(O);return b}function r(a,p){const b=$(a.getAttribute)?a.getAttribute("data-field"):null;return b||String(a.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${p}`}function s(a){const p=a.trim();if(p==="")return null;if(p==="true"||p==="false")return p==="true";const b=Number(p);return Number.isFinite(b)&&p!==""?b:p}function h(a,p){return p==="text"?a===""?null:a:p==="boolean"?z(a):p==="number"?X(a):p==="date"||p==="dateString"?A(a):p==="datetime"?g(a):s(a)}function u(a){const p=n(a,"thead"),b=n(p||a,"tr"),k=(b?t(b,"th").length?t(b,"th"):t(b,"td"):[]).map((S,x)=>{const C=r(S,x),P={id:C,field:C,title:String(S.textContent||"").trim()||C},F=$(S.getAttribute)?S.getAttribute("data-type"):null;F&&(o.has(F)?P.type=F:B(`hydrate.unknownType:${F}`,`data-type "${F}" on column "${C}" is not a built-in type name, so it was ignored; the column falls back to sampled shape typing.`));const E=$(S.getAttribute)?S.getAttribute("data-format"):null;return E&&(P.format=E),P}),y=n(a,"tbody"),R=(y?t(y,"tr"):t(a,"tr").filter(S=>S!==b)).map((S,x)=>{const C=t(S,"td"),F={__row:($(S.getAttribute)?S.getAttribute("data-id"):null)||`row${x}`};return k.forEach((E,D)=>{F[E.field]=C[D]?E.type?h(String(C[D].textContent||""),E.type):s(String(C[D].textContent||"")):null}),F});return{columns:k,rows:R}}function i(a,p){if(p===void 0)return a;if(p!==null&&typeof p=="object"&&!Array.isArray(p)&&Array.isArray(p.only))return p.only;if(!Array.isArray(p))return p;const b=new Map;for(const k of p)if(k&&typeof k=="object"){const y=k.id??k.field;y!=null&&b.set(y,k)}const O=a.map(k=>{const y=b.get(k.id)??b.get(k.field);return y===void 0?k:{...k,...y}});for(const[k,y]of b)a.some(v=>v.id===k||v.field===k)||O.push({...y});return O}const m="data-lattice-hydrate-config";function c(a,p,b={}){const{columns:O,rows:k}=u(p);return d(a,{rowKey:"__row",...b,columns:i(O,b.columns),rows:b.rows!==void 0?b.rows:k})}function f(a,p={}){const b=a.ownerDocument.createElement("div");b.setAttribute("data-lattice-hydrated",""),a.removeAttribute("data-lattice-grid"),b.__latticeTable=a;try{b.setAttribute(m,JSON.stringify(p))}catch{b.setAttribute(m,"{}")}return a.parentNode.insertBefore(b,a),a.parentNode.removeChild(a),c(b,a,p)}}),Fe("packages/dom/src/autoinit.js",function(e,K){"use strict";Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return z}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/dom/src/createGrid.js").createGrid,X=K("packages/dom/src/hydrate.js").hydrateTable;function W(w,A){const g=[];return $(w.hasAttribute)&&w.hasAttribute(A)&&g.push(w),$(w.querySelectorAll)&&g.push(...w.querySelectorAll(`[${A}]`)),g}function H(w){const A=w.parentNode;if(!A||!A.children)return null;const g=[...A.children],l=g.indexOf(w),d=[g[l+1],g[l-1]];for(const o of d)if(o&&o.tagName==="SCRIPT"&&$(o.getAttribute)&&o.hasAttribute("data-lattice-config"))return o;return null}function V(w){const A=H(w);if(!A)return{};try{return JSON.parse(A.textContent||"{}")}catch(g){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",g),{}}}function z(w){const A=w||(typeof document<"u"?document:null);if(!A)return[];const g=[];for(const l of W(A,"data-lattice-grid")){if(l.__lattice)continue;const d=V(l);g.push(l.tagName==="TABLE"?X(l,d):I(l,d))}return g}}),Fe("packages/dom/src/index.js",function(e,K){"use strict";Object.defineProperty(e,"LatticeGrid",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return x}});const Q=K("packages/dom/src/createGrid.js"),$=Q.createGrid,B=K("packages/dom/src/hydrate.js"),I=B.hydrateTable,_=K("packages/dom/src/autoinit.js"),X=_.autoInit,W=K("packages/dom/src/localviews.js"),H=W.createLocalViewStorage,V=K("packages/core/src/index.js"),z=V.createHeadlessGrid,w=V.registerModules,A=V.setLicence,g=V.version,l=V.getVersion,d=V.serialiseState,o=V.restoreState,n=V.defaults;Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return Q.createGrid}}),Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return Q.gridElementsWithin}});const t=K("packages/dom/src/stat.js");Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return t.createStat}}),Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return t.deltaOf}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return t.toneOf}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return B.readTable}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return B.hydrateTable}}),Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return _.autoInit}}),Object.defineProperty(e,"createLocalViewStorage",{enumerable:!0,get:function(){return W.createLocalViewStorage}}),Object.defineProperty(e,"DEFAULT_VIEWS_KEY",{enumerable:!0,get:function(){return W.DEFAULT_VIEWS_KEY}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return V.createHeadlessGrid}}),Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return V.defaults}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return V.version}}),Object.defineProperty(e,"getVersion",{enumerable:!0,get:function(){return V.getVersion}}),Object.defineProperty(e,"Grid",{enumerable:!0,get:function(){return V.Grid}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return V.EventBus}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return V.Registry}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return V.sharedRegistry}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return V.registerModules}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return V.parseLicence}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return V.verifyLicence}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return V.licenceInfo}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return V.watermark}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return V.setLicence}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return V.licenceState}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return V.isLocalHost}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return V.matchesDomain}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return V.LicenceHolder}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return V.ColumnModel}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return V.buildGraph}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return V.Lookup}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return V.ValuePipeline}}),Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return V.compileFormat}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return V.compileMask}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return V.specToOoxml}}),Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return V.EXTENDED_TYPES}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return V.createRadixType}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return V.RADIX_PRESETS}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return V.parseRadix}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return V.formatRadix}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return V.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return V.registerUnitSystem}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return V.defineUnit}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return V.UNIT_SYSTEMS}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return V.parseUnit}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return V.formatUnit}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return V.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return V.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return V.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return V.convertMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return V.rateFunction}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return V.MISSING_RATE}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return V.Messages}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return V.createMessages}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return V.auditCatalogue}}),Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return V.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return V.MESSAGE_KEYS}}),Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return V.DEFAULT_LOCALE}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return V.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return V.resolveLocale}}),Object.defineProperty(e,"LOCALES",{enumerable:!0,get:function(){return V.LOCALES}}),Object.defineProperty(e,"resolveCatalogue",{enumerable:!0,get:function(){return V.resolveCatalogue}}),Object.defineProperty(e,"EN_US",{enumerable:!0,get:function(){return V.EN_US}}),Object.defineProperty(e,"FR_FR",{enumerable:!0,get:function(){return V.FR_FR}}),Object.defineProperty(e,"FR_CA",{enumerable:!0,get:function(){return V.FR_CA}}),Object.defineProperty(e,"IT_IT",{enumerable:!0,get:function(){return V.IT_IT}}),Object.defineProperty(e,"ES_ES",{enumerable:!0,get:function(){return V.ES_ES}}),Object.defineProperty(e,"PT_BR",{enumerable:!0,get:function(){return V.PT_BR}}),Object.defineProperty(e,"DE_DE",{enumerable:!0,get:function(){return V.DE_DE}}),Object.defineProperty(e,"NL_NL",{enumerable:!0,get:function(){return V.NL_NL}}),Object.defineProperty(e,"SV_SE",{enumerable:!0,get:function(){return V.SV_SE}}),Object.defineProperty(e,"DA_DK",{enumerable:!0,get:function(){return V.DA_DK}}),Object.defineProperty(e,"NB_NO",{enumerable:!0,get:function(){return V.NB_NO}}),Object.defineProperty(e,"FI_FI",{enumerable:!0,get:function(){return V.FI_FI}}),Object.defineProperty(e,"PL_PL",{enumerable:!0,get:function(){return V.PL_PL}}),Object.defineProperty(e,"CS_CZ",{enumerable:!0,get:function(){return V.CS_CZ}}),Object.defineProperty(e,"HU_HU",{enumerable:!0,get:function(){return V.HU_HU}}),Object.defineProperty(e,"RO_RO",{enumerable:!0,get:function(){return V.RO_RO}}),Object.defineProperty(e,"UK_UA",{enumerable:!0,get:function(){return V.UK_UA}}),Object.defineProperty(e,"EL_GR",{enumerable:!0,get:function(){return V.EL_GR}}),Object.defineProperty(e,"JA_JP",{enumerable:!0,get:function(){return V.JA_JP}}),Object.defineProperty(e,"AR",{enumerable:!0,get:function(){return V.AR}}),Object.defineProperty(e,"AR_SA",{enumerable:!0,get:function(){return V.AR_SA}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return V.ColumnStore}}),Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return V.Bitset}}),Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return V.Dictionary}}),Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return V.MultiValue}}),Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return V.MaskPool}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return V.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return V.sortMulti}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return V.evaluateFilters}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return V.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return V.testValue}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return V.groupByColumns}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return V.total}}),Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return V.TOTAL_FNS}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return V.pivot}}),Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return V.Window}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return V.openWindow}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return V.WINDOW_KINDS}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return V.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return V.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return V.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return V.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return V.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return V.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return V.anomalyCondition}}),Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return V.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return V.forecast}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return V.evaluateFormula}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return V.parseFormula}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return V.referencesOf}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return V.looksLikeFormula}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return V.FormulaError}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return V.FUNCTIONS}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return V.compileRules}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return V.ingest}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return V.ingestSync}}),Object.defineProperty(e,"createSource",{enumerable:!0,get:function(){return V.createSource}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return V.createMemorySource}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return V.createPagedSource}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return V.createRemoteSource}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return V.createStreamSource}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return V.createUrlSource}}),Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return V.PROTOCOL}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return V.createPushdownSource}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return V.planQuery}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return V.splitFilters}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return V.applyResidual}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return V.capabilitiesOf}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return V.resolveMutate}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return V.NO_CAPABILITIES}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return V.odataAdapter}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return V.filtersToOData}}),Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return V.conditionToOData}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return V.restAdapter}}),Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return V.DEFAULT_PARAMS}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return V.dfqlAdapter}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return V.duckdbAdapter}}),Object.defineProperty(e,"filtersToSql",{enumerable:!0,get:function(){return V.filtersToSql}}),Object.defineProperty(e,"graphqlAdapter",{enumerable:!0,get:function(){return V.graphqlAdapter}}),Object.defineProperty(e,"splunkAdapter",{enumerable:!0,get:function(){return V.splunkAdapter}}),Object.defineProperty(e,"clickhouseAdapter",{enumerable:!0,get:function(){return V.clickhouseAdapter}}),Object.defineProperty(e,"elasticsearchAdapter",{enumerable:!0,get:function(){return V.elasticsearchAdapter}}),Object.defineProperty(e,"RowModel",{enumerable:!0,get:function(){return V.RowModel}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return V.createRowKey}}),Object.defineProperty(e,"SelectionModel",{enumerable:!0,get:function(){return V.SelectionModel}}),Object.defineProperty(e,"RangeModel",{enumerable:!0,get:function(){return V.RangeModel}}),Object.defineProperty(e,"EditModel",{enumerable:!0,get:function(){return V.EditModel}}),Object.defineProperty(e,"ChangeModel",{enumerable:!0,get:function(){return V.ChangeModel}}),Object.defineProperty(e,"StateModel",{enumerable:!0,get:function(){return V.StateModel}}),Object.defineProperty(e,"STATE_VERSION",{enumerable:!0,get:function(){return V.STATE_VERSION}}),Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return V.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return V.restoreState}}),Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return V.VERSION}});const r=K("packages/dom/src/renderer/index.js");Object.defineProperty(e,"DomRenderer",{enumerable:!0,get:function(){return r.DomRenderer}});const s=K("packages/dom/src/filtermenu.js");Object.defineProperty(e,"FilterMenu",{enumerable:!0,get:function(){return s.FilterMenu}}),Object.defineProperty(e,"mergeColumnFilter",{enumerable:!0,get:function(){return s.mergeColumnFilter}}),Object.defineProperty(e,"branchFor",{enumerable:!0,get:function(){return s.branchFor}});const h=K("packages/dom/src/columnmenu.js");Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return h.ColumnMenu}}),Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return h.columnMenuItems}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return h.cellMenuItems}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return h.autoGroupMenuItems}});const u=K("packages/dom/src/alignedgrids.js");Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return u.AlignedGrids}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return u.alignGrids}}),Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return u.layoutState}});const i=K("packages/dom/src/toolpanelmount.js");Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return i.ToolPanelDock}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return i.panelHost}}),Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return i.mountPanel}});const m=K("packages/dom/src/celledit.js");Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return m.CellEditController}});const c=K("packages/dom/src/editbar.js");Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return c.EditBar}});const f=K("packages/dom/src/historybar.js");Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return f.HistoryBar}}),Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return f.HISTORY_CLS}});const a=K("packages/dom/src/diffpaint.js");Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return a.DiffPainter}});const p=K("packages/dom/src/viewpicker.js");Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return p.ViewPicker}}),Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return p.VIEW_CLS}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return p.summariseDiff}});const b=K("packages/dom/src/promptbar.js");Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return b.PromptBar}}),Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return b.PROMPT_CLASS}});const O=K("packages/dom/src/cell/index.js");Object.defineProperty(e,"createCellLayer",{enumerable:!0,get:function(){return O.createCellLayer}}),Object.defineProperty(e,"compileTemplate",{enumerable:!0,get:function(){return O.compileTemplate}}),Object.defineProperty(e,"compileVariant",{enumerable:!0,get:function(){return O.compileVariant}}),Object.defineProperty(e,"checkVariant",{enumerable:!0,get:function(){return O.checkVariant}}),Object.defineProperty(e,"VariantRegistry",{enumerable:!0,get:function(){return O.VariantRegistry}}),Object.defineProperty(e,"BUILTIN_RENDERERS",{enumerable:!0,get:function(){return O.BUILTIN_RENDERERS}}),Object.defineProperty(e,"BUILTIN_VARIANTS",{enumerable:!0,get:function(){return O.BUILTIN_VARIANTS}}),Object.defineProperty(e,"BUILTIN_PIPES",{enumerable:!0,get:function(){return O.BUILTIN_PIPES}}),Object.defineProperty(e,"sanitiseHtml",{enumerable:!0,get:function(){return O.sanitiseHtml}});const k=K("packages/dom/src/editors/index.js");Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return k.editors}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return k.createEditor}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return k.editorFor}}),Object.defineProperty(e,"BaseEditor",{enumerable:!0,get:function(){return k.BaseEditor}});const y=K("packages/dom/src/filters/index.js");Object.defineProperty(e,"filters",{enumerable:!0,get:function(){return y.filters}}),Object.defineProperty(e,"createFilter",{enumerable:!0,get:function(){return y.createFilter}}),Object.defineProperty(e,"filterFor",{enumerable:!0,get:function(){return y.filterFor}}),Object.defineProperty(e,"parseExpression",{enumerable:!0,get:function(){return y.parseExpression}}),Object.defineProperty(e,"ConditionFilter",{enumerable:!0,get:function(){return y.ConditionFilter}});const v=K("packages/dom/src/ui/index.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return v.StatusBar}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return v.ContextMenu}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return v.ToolPanel}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return v.TooltipManager}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return v.Pagination}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return v.OverlayLayer}});const R=K("packages/core/src/registry/licence.js");Object.defineProperty(e,"setLicense",{enumerable:!0,get:function(){return R.setLicence}}),Object.defineProperty(e,"licenseInfo",{enumerable:!0,get:function(){return R.licenceInfo}}),Object.defineProperty(e,"licenseState",{enumerable:!0,get:function(){return R.licenceState}});const S=Object.freeze({createGrid:$,createHeadlessGrid:z,defaults:n,registerModules:w,setLicence:A,version:g,autoInit:X,hydrateTable:I,serialiseState:d,restoreState:o,createLocalViewStorage:H}),x=S});try{Kn("packages/worker/src/inline.js").setWorkerSource('(function(Ot){"use strict";var ct=Object.create(null),lt=Object.create(null);function Ce(o,me){ct[o]=me}function at(o){var me=lt[o];if(me)return me;var ae=Object.create(null);lt[o]=ae;var he=ct[o];if(!he)throw new Error("[lattice] missing module: "+o);return he(ae,at),ae}Ce("packages/core/src/internal/util.js",function(o,me){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"pathSetter",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"escapeHtml",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"titleCase",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"expand",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return Se}});const ae="1.86.4";async function he(){return ae}const W="1.86.4",U=new Set,_=2e3;function Z(D){if(U.add(D),U.size>_){const x=U.values().next().value;x!==void 0&&U.delete(x)}}const E=[],z=500;function re(D,x,fe){E.push({key:D,level:x,message:fe.map(p=>typeof p=="string"?p:Y(p)).join(" "),at:Date.now()}),E.length>z&&E.shift()}function Y(D){if(D instanceof Error)return D.message;try{return JSON.stringify(D)}catch{return String(D)}}function se(){return E.map(D=>({...D}))}function te(D){if(D.length===0||typeof D[0]!="string")return D;const x=D[0].replace(/^\\[lattice\\]\\s*/,"");return x===D[0]?D:[x,...D.slice(1)]}function H(D,...x){if(U.has(D))return;Z(D);const fe=te(x);re(D,"warn",fe),console.warn("[lattice]",...fe)}function T(D,...x){if(U.has(D))return;Z(D);const fe=te(x);re(D,"info",fe),console.info("[lattice]",...fe)}function V(){U.clear(),E.length=0}function ne(D,x){const fe=new Error(`[lattice] ${D}`);throw x!==void 0&&(fe.cause=x),fe}function R(D,x){D||ne(x)}const j=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function i(D){return D!==null&&typeof D=="object"&&!Array.isArray(D)}function a(D){return typeof D=="function"}function s(D){return D==null}function h(D){return D==null||D===""}function u(D){return typeof D!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(D))?!0:!!(D.prototype&&Object.getOwnPropertyNames(D.prototype).length>1)}const t=new Map;function l(D){let x=t.get(D);if(x)return x;if(!D.includes("."))x=fe=>fe?.[D];else{const fe=D.split("."),p=fe.length;x=Q=>{let X=Q;for(let ce=0;ce<p;ce++){if(X==null)return;X=X[fe[ce]]}return X}}return t.set(D,x),x}const m=new Map;function e(D){let x=m.get(D);if(x)return x;if(!D.includes("."))x=(fe,p)=>{fe!=null&&(fe[D]=p)};else{const fe=D.split("."),p=fe.length-1;x=(Q,X)=>{let ce=Q;for(let le=0;le<p;le++){if(ce==null)return;const ge=fe[le];ce[ge]==null&&(ce[ge]={}),ce=ce[ge]}ce!=null&&(ce[fe[p]]=X)}}return m.set(D,x),x}function d(D,x){return l(x)(D)}function f(D,x,fe){e(x)(D,fe)}function r(D){return D?(D.includes(".")?D.slice(D.lastIndexOf(".")+1):D).replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/\\s+/g," ").trim().replace(/^./,fe=>fe.toUpperCase()):""}const n={"&":"&","<":"<",">":">",\'"\':""","\'":"'"};function c(D){const x=D==null?"":String(D);return/[&<>"\']/.test(x)?x.replace(/[&<>"\']/g,fe=>n[fe]):x}function g(D){return String(D).replace(/\\w\\S*/g,x=>x[0].toUpperCase()+x.slice(1).toLowerCase())}function A(D,x,fe){if(D!==void 0)return D===!0?{enabled:!0,...fe}:D===!1?{enabled:!1}:i(D)?D:{[x]:D,enabled:!0}}function P(D){return D==null?[]:Array.isArray(D)?D:[D]}const q=Object.freeze(new Set(["__proto__","constructor","prototype"]));function L(D,x){if(!i(D))return i(x)?{...x}:x;if(!i(x))return x===void 0?D:x;const fe={...D};for(const p of Object.keys(x)){if(q.has(p))continue;const Q=x[p];Q!==void 0&&(fe[p]=i(Q)&&i(fe[p])?L(fe[p],Q):Q)}return fe}function v(D,x){if(!i(D)||!i(x)||D===x)return x;const fe=Object.create(Object.getPrototypeOf(D));return Object.assign(fe,D,x),fe}class G{#t;#e=new Map;#n;constructor(x=256,fe=null){this.#t=x,this.#n=fe}get size(){return this.#e.size}get max(){return this.#t}set max(x){this.#t=x,this.#r()}has(x){return this.#e.has(x)}get(x){const fe=this.#e;if(!fe.has(x))return;const p=fe.get(x);return fe.delete(x),fe.set(x,p),p}peek(x){return this.#e.get(x)}set(x,fe){const p=this.#e;return p.has(x)&&p.delete(x),p.set(x,fe),this.#r(),fe}delete(x){const fe=this.#e.get(x);return this.#e.delete(x)&&this.#n&&this.#n(fe,x),fe}clear(){if(this.#n)for(const[x,fe]of this.#e)this.#n(fe,x);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const x=this.#e;for(;x.size>this.#t;){const fe=x.keys().next().value,p=x.get(fe);x.delete(fe),this.#n&&this.#n(p,fe)}}}const S=new Map;function N(D,x){const fe=`${D||""}|${x?JSON.stringify(x):""}`;let p=S.get(fe);return p||(p=new Intl.Collator(D||void 0,{numeric:!0,sensitivity:"variant",...x}),S.set(fe,p)),p}function I(D,x){if(D===x)return 0;if(D==null)return 1;if(x==null)return-1;if(typeof D=="number"&&typeof x=="number")return Number.isNaN(D)?Number.isNaN(x)?0:1:Number.isNaN(x)||D<x?-1:D>x?1:0;const fe=String(D),p=String(x);return fe<p?-1:fe>p?1:0}function K(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const B=typeof requestAnimationFrame=="function";function ee(D){return B?requestAnimationFrame(D):setTimeout(()=>D(K()),16)}function J(D){D!=null&&(B?cancelAnimationFrame(D):clearTimeout(D))}function ue(D){let x=null,fe=null;const p=()=>{x=null;const X=fe;fe=null,D(...X||[])},Q=(...X)=>{fe=X,x===null&&(x=ee(p))};return Q.cancel=()=>{J(x),x=null,fe=null},Q.flush=()=>{x!==null&&(J(x),p())},Q}function de(D,x){let fe=null,p=null;const Q=()=>{if(fe=null,p===null)return;const le=p;p=null,D(...le),X()},X=()=>{fe=setTimeout(Q,x),typeof fe?.unref=="function"&&fe.unref()},ce=(...le)=>{fe===null?(D(...le),X()):(p=le,clearTimeout(fe),X())};return ce.flush=()=>{if(fe!==null&&clearTimeout(fe),fe=null,p===null)return;const le=p;p=null,D(...le)},ce.cancel=()=>{fe!==null&&clearTimeout(fe),fe=null,p=null},ce.pending=()=>fe!==null||p!==null,ce}function Oe(D,x=50){return typeof requestIdleCallback=="function"?requestIdleCallback(D,{timeout:x}):setTimeout(()=>D({timeRemaining:()=>0,didTimeout:!0}),1)}let Ae=0;function Se(D="l"){return`${D}${(++Ae).toString(36)}`}}),Ce("packages/worker/src/transport.js",function(o,me){"use strict";Object.defineProperty(o,"PROTOCOL",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"OPS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"ERRORS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"packHandle",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"packHandles",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"TransportedDictionary",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const ae=me("packages/core/src/internal/util.js"),he=ae.collator,W=ae.isFunction,U=1,_=Object.freeze({SORT_COLUMN:"sortColumn",SORT_MULTI:"sortMulti",EVALUATE_FILTERS:"evaluateFilters",COMPACT:"compact",GROUP_BY_COLUMNS:"groupByColumns",TOTAL:"total",PIVOT:"pivot",FACET:"facet",COLUMNIZE:"columnize",COLLATE_STRING_RANKS:"collateStringRanks"}),Z=Object.freeze({READY:"ready",CANCEL:"cancel",PING:"ping"}),E=Object.freeze({NO_COMPUTE:"E_NO_COMPUTE",NO_KERNEL:"E_NO_KERNEL",ABORTED:"E_ABORTED",KERNEL:"E_KERNEL",PROTOCOL:"E_PROTOCOL"});function z(a){if(a==null)return null;const s=a.presence;return{id:a.id,kind:a.kind,nullable:!!a.nullable,values:a.values??null,presence:s?s.words??s:null,presenceBits:s?s.size??(s.words??s).length*8:0,dict:a.dict?re(a.dict):null,offsets:a.offsets??null,version:a.version??0}}function re(a){return Array.isArray(a)?a:W(a.values)?a.values():[]}function Y(a){const s=new Array(a.length);for(let h=0;h<a.length;h++)s[h]=z(a[h]);return s}class se{#t;#e;constructor(s,h){this.#t=s,this.#e=h}get words(){return this.#t}get size(){return this.#e}get(s){return(this.#t[s>>>3]&1<<(s&7))!==0}count(){const s=this.#t;let h=0;for(let u=0;u<s.length;u++){let t=s[u];for(;t;)t&=t-1,h++}return h}}class te{#t;#e=null;#n=0;#r=new Map;constructor(s){this.#t=s||[]}get size(){return this.#t.length}get version(){return this.#n}codeOf(s){if(this.#e===null){this.#e=new Map;for(let t=0;t<this.#t.length;t++)this.#e.set(this.#t[t],t)}const h=this.#e.get(s);if(h!==void 0)return h;const u=this.#t.length;return this.#t.push(s),this.#e.set(s,u),this.#n++,u}valueOf(s){return this.#t[s]}values(){return this.#t}ranks(s){const h=s||"",u=this.#r.get(h);if(u&&u.version===this.#n)return u.ranks;const t=this.#t.length,l=new Uint32Array(t);for(let r=0;r<t;r++)l[r]=r;const m=he(s).compare,e=this.#t,d=Array.from(l).sort((r,n)=>{const c=e[r],g=e[n];return c===g?0:c==null?1:g==null?-1:m(String(c),String(g))}),f=new Uint32Array(t);for(let r=0;r<d.length;r++)f[d[r]]=r;return this.#r.set(h,{version:this.#n,ranks:f}),f}}function H(a){if(a==null)return null;const s=a.presence?new se(a.presence,a.presenceBits||a.presence.length*8):null,h=a.dict?new te(a.dict):null,u=a.values,t=a.offsets??null,l=a.kind,m=e=>{if(s&&!s.get(e))return null;switch(l){case"dictionary":return h?h.valueOf(u[e]):u[e];case"bitset":return(u[e>>>3]&1<<(e&7))!==0;case"multi":{if(!t)return null;const d=t[e],f=t[e+1],r=new Array(f-d);for(let n=d;n<f;n++)r[n-d]=h?h.valueOf(u[n]):u[n];return r}default:return u[e]}};return{id:a.id,kind:l,nullable:a.nullable,values:u,presence:s,dict:h,offsets:t,get:m,version:a.version}}function T(a){const s=new Array(a.length);for(let h=0;h<a.length;h++)s[h]=H(a[h]);return s}function V(){const a=[],s=[];return{mask(h){for(let u=0;u<a.length;u++)if(a[u].length>=h){const t=a.splice(u,1)[0].subarray(0,h);return t.fill(0),t}return new Uint8Array(h)},indices(h){for(let u=0;u<s.length;u++)if(s[u].length>=h)return s.splice(u,1)[0].subarray(0,h);return new Uint32Array(h)},release(h){h&&(h instanceof Uint8Array?a.push(h):h instanceof Uint32Array&&s.push(h))},clear(){a.length=0,s.length=0}}}function ne(a){if(!ArrayBuffer.isView(a))return!1;const s=a.buffer;return s?typeof SharedArrayBuffer>"u"||!(s instanceof SharedArrayBuffer):!1}function R(a,s=[]){const h=u=>{if(!ne(u))return;const t=u.buffer;s.includes(t)||s.push(t)};if(a==null)return s;if(ArrayBuffer.isView(a))return h(a),s;if(Array.isArray(a)){for(const u of a)h(u);return s}if(typeof a=="object")for(const u of Object.keys(a)){const t=a[u];if(Array.isArray(t))for(const l of t)h(l);else h(t)}return s}function j(a,s=0){if(a==null)return!0;const h=typeof a;if(h==="function"||h==="symbol")return!1;if(h!=="object"||s>4||ArrayBuffer.isView(a)||a instanceof ArrayBuffer||a instanceof Date)return!0;if(Array.isArray(a)){for(const u of a)if(!j(u,s+1))return!1;return!0}for(const u of Object.keys(a))if(!j(a[u],s+1))return!1;return!0}function i(a,s=new Set){if(!a||typeof a!="object")return s;const h=a;typeof h.col=="string"&&s.add(h.col);const u=h.conditions;if(Array.isArray(u))for(const t of u)i(t,s);return s}}),Ce("packages/core/src/store/bitset.js",function(o,me){"use strict";Object.defineProperty(o,"Bitset",{enumerable:!0,get:function(){return he}});const ae=8;class he{static#t=new Uint8Array(256);static{for(let U=1;U<256;U++)he.#t[U]=he.#t[U>>1]+(U&1)}#e;#n;constructor(U=0){const _=Math.max(0,U|0);this.#n=_,this.#e=new Uint8Array(Math.ceil(_/ae))}get size(){return this.#n}get words(){return this.#e}get bytes(){return this.#e?this.#e.byteLength:0}get(U){return U<0||U>=this.#n?0:this.#e[U>>3]>>(U&7)&1}set(U){return U>=0&&U<this.#n&&(this.#e[U>>3]|=1<<(U&7)),this}clear(U){return U>=0&&U<this.#n&&(this.#e[U>>3]&=~(1<<(U&7))),this}assign(U,_){return _?this.set(U):this.clear(U)}fill(U=!1){return this.#e.fill(U?255:0),U&&this.#r(),this}grow(U){const _=Math.max(0,U|0);if(_<=this.#n)return this;const Z=Math.ceil(_/ae);if(Z>this.#e.length){const E=new Uint8Array(Z);E.set(this.#e),this.#e=E}return this.#n=_,this}count(){const U=this.#e,_=he.#t;let Z=0;for(let E=0;E<U.length;E++)Z+=_[U[E]];return Z}and(U){const _=U instanceof he?U.words:U,Z=this.#e,E=Math.min(Z.length,_.length);for(let z=0;z<E;z++)Z[z]&=_[z];for(let z=E;z<Z.length;z++)Z[z]=0;return this}or(U){const _=U instanceof he?U.words:U,Z=this.#e,E=Math.min(Z.length,_.length);for(let z=0;z<E;z++)Z[z]|=_[z];return this}not(){const U=this.#e;for(let _=0;_<U.length;_++)U[_]=~U[_]&255;return this.#r(),this}clone(){const U=new he(this.#n);return U.words.set(this.#e.subarray(0,U.words.length)),U}release(){this.#e=new Uint8Array(0),this.#n=0}#r(){const U=this.#n&7;if(U===0)return;const _=this.#n>>3;_<this.#e.length&&(this.#e[_]&=(1<<U)-1)}static from(U){const _=Array.isArray(U)?U:Array.from(U),Z=new he(_.length);for(let E=0;E<_.length;E++)_[E]&&Z.set(E);return Z}}}),Ce("packages/core/src/store/dictionary.js",function(o,me){"use strict";Object.defineProperty(o,"Dictionary",{enumerable:!0,get:function(){return U}});const ae=me("packages/core/src/internal/util.js"),he=ae.collator,W=ae.defaultCompare;class U{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(Z=[]){this.#t=[];for(let E=0;E<Z.length;E++){const z=Z[E];this.#e.has(z)||(this.#e.set(z,this.#t.length),this.#t.push(z))}}get size(){return this.#t.length}get version(){return this.#n}get bytes(){let Z=this.#t.length*8;for(let E=0;E<this.#t.length;E++){const z=this.#t[E];typeof z=="string"&&(Z+=z.length*2),Z+=16}return Z}codeOf(Z){const E=this.#e.get(Z);if(E!==void 0)return E;const z=this.#t.length;return this.#t.push(Z),this.#e.set(Z,z),this.#n++,z}lookup(Z){const E=this.#e.get(Z);return E===void 0?-1:E}has(Z){return this.#e.has(Z)}valueOf(Z){return this.#t[Z]}values(){return this.#t}ranks(Z){const E=Z||"";if(this.#r&&this.#i===this.#n&&this.#s===E)return this.#r;const z=this.#t.length,re=new Array(z);for(let H=0;H<z;H++)re[H]=H;const Y=he(Z).compare,se=this.#t;re.sort((H,T)=>this.#h(se[H],se[T],Y));const te=new Uint32Array(z);for(let H=0;H<z;H++)te[re[H]]=H;return this.#r=te,this.#i=this.#n,this.#s=E,te}#h(Z,E,z){return typeof Z=="string"&&typeof E=="string"?z(Z,E):W(Z,E)}}}),Ce("packages/core/src/store/multivalue.js",function(o,me){"use strict";Object.defineProperty(o,"MultiValue",{enumerable:!0,get:function(){return ae}});class ae{#t;#e;#n=0;#r=0;constructor(W={}){const U=Math.max(1,W.rows??16),_=Math.max(1,W.values??U);this.#t=new Int32Array(_),this.#e=new Uint32Array(U+1)}get values(){return this.#t}get offsets(){return this.#e}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#t.byteLength+this.#e.byteLength}count(W){return W<0||W>=this.#n?0:this.#e[W+1]-this.#e[W]}at(W){return W<0||W>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[W],this.#e[W+1])}has(W,U){if(W<0||W>=this.#n)return!1;const _=this.#t,Z=this.#e[W+1];for(let E=this.#e[W];E<Z;E++)if(_[E]===U)return!0;return!1}hasAny(W,U){for(let _=0;_<U.length;_++)if(this.has(W,U[_]))return!0;return!1}hasAll(W,U){for(let _=0;_<U.length;_++)if(!this.has(W,U[_]))return!1;return!0}hasNone(W,U){return!this.hasAny(W,U)}push(W){const U=this.#n,_=W.length;this.#i(U+1),this.#s(this.#r+_);const Z=this.#r;for(let E=0;E<_;E++)this.#t[Z+E]=W[E]|0;return this.#r+=_,this.#n=U+1,this.#e[U]=Z,this.#e[U+1]=this.#r,U}write(W,U){if(W===this.#n){this.push(U);return}if(W<0||W>this.#n)return;const _=this.#e[W],Z=this.#e[W+1],E=U.length;if(Z-_===E){for(let z=0;z<E;z++)this.#t[_+z]=U[z]|0;return}this.#h(W,U)}compact(W,U,_){const Z=this.#t,E=this.#e,z=this.#n,re=new Int32Array(Math.max(1,this.#r)),Y=new Uint32Array(U+1);let se=0;for(let te=0;te<z;te++){if(W[te]===_)continue;const H=E[te],T=E[te+1];Y[W[te]]=se;for(let V=H;V<T;V++)re[se++]=Z[V];Y[W[te]+1]=se}this.#t=re,this.#e=Y,this.#n=U,this.#r=se}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(W){if(W+1<=this.#e.length)return;let U=this.#e.length-1;for(;U<W;)U=U*2||16;const _=new Uint32Array(U+1);_.set(this.#e),this.#e=_}#s(W){if(W<=this.#t.length)return;let U=this.#t.length;for(;U<W;)U=U*2||16;const _=new Int32Array(U);_.set(this.#t),this.#t=_}#h(W,U){const _=this.#t,Z=this.#e,E=this.#n,z=U.length-(Z[W+1]-Z[W]),re=new Int32Array(Math.max(1,this.#r+z)),Y=new Uint32Array(Z.length);let se=0;for(let te=0;te<E;te++){if(Y[te]=se,te===W)for(let H=0;H<U.length;H++)re[se++]=U[H]|0;else for(let H=Z[te];H<Z[te+1];H++)re[se++]=_[H];Y[te+1]=se}this.#t=re,this.#e=Y,this.#r=se}}}),Ce("packages/core/src/compute/handle.js",function(o,me){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return j}});const ae=me("packages/core/src/internal/util.js"),he=ae.collator,W=ae.defaultCompare,U=ae.warnOnce;function _(i){const a=new Uint32Array(i);for(let s=0;s<i;s++)a[s]=s;return a}function Z(i,a){if(a&&typeof a.count=="number")return a.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const s=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):s?i.kind==="bitset"?typeof s.size=="number"?s.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(U(`count:${i.id}`,`column "${i.id}" is bitset-backed with no declared row count; assuming ${s.length*8}`),s.length*8):s.length:i.presence&&typeof i.presence.size=="number"?i.presence.size:0}const E=new WeakMap;function z(i){const a=i.constructor;if(!a)return"unknown";const s=E.get(a);if(s)return s;let h="unknown";try{let u=null;typeof a.from=="function"?u=a.from([!1,!0]):(u=new a(8),u.set(1));const t=u&&u.words;t&&t.length&&(t[0]===2?h="lsb":t[0]===64&&(h="msb"))}catch{h="unknown"}return E.set(a,h),h}function re(i){if(!i)return()=>0;const a=i instanceof Uint8Array?i:i.words;if(a instanceof Uint8Array){const s=i instanceof Uint8Array?"lsb":z(i);if(s==="lsb")return h=>a[h>>>3]>>>(h&7)&1;if(s==="msb")return h=>a[h>>>3]>>>7-(h&7)&1}return typeof i.get=="function"?s=>i.get(s)?1:0:()=>0}function Y(i){return!i||!i.presence?null:re(i.presence)}function se(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function te(i,a){return i?typeof i.valueOf=="function"?i.valueOf(a):typeof i.values=="function"?i.values()[a]:null:null}function H(i,a){const s=i.offsets,h=i.values;if(!s||!h)return[];const u=s[a],t=s[a+1];if(!(t>u))return[];const l=i.dict,m=new Array(t-u);for(let e=u;e<t;e++)m[e-u]=l?te(l,h[e]):h[e];return m}function T(i){if(!i)return()=>{};const a=i.values,s=Y(i),h=i.kind;if(h==="dictionary"){const u=i.dict;return s?t=>s(t)?te(u,a[t]):null:t=>te(u,a[t])}if(h==="bitset"){const u=re(a);return s?t=>s(t)?u(t)===1:null:t=>u(t)===1}if(h==="multi")return s?u=>s(u)?H(i,u):null:u=>H(i,u);if(!a&&typeof i.get=="function"){const u=i.get.bind(i);return t=>{const l=u(t);return l===void 0?null:l}}return s?u=>{if(!s(u))return null;const t=a[u];return t===void 0?null:t}:u=>{const t=a[u];return t===void 0?null:t}}function V(i,a){if(i<a)return-1;if(i>a)return 1;if(i===a){const u=Object.is(i,-0),t=Object.is(a,-0);return u===t?0:u?-1:1}const s=Number.isNaN(i),h=Number.isNaN(a);return s&&h?0:s?1:-1}function ne(i){const a=he(i);return(s,h)=>{if(s===h)return 0;const u=typeof s,t=typeof h;if(u==="string"&&t==="string")return a.compare(s,h);if(u==="number"&&t==="number")return V(s,h);if(u==="boolean"&&t==="boolean")return s===h?0:s?1:-1;if(s instanceof Date||h instanceof Date){const l=s instanceof Date?s.getTime():Number(s),m=h instanceof Date?h.getTime():Number(h);return V(l,m)}return W(s,h)}}function R(i,a){if(i&&typeof i.ranks=="function")return i.ranks(a);const s=i&&typeof i.values=="function"?i.values():[],h=s.length,u=ne(a),t=new Array(h);for(let m=0;m<h;m++)t[m]=m;t.sort((m,e)=>u(s[m],s[e])||m-e);const l=new Uint32Array(h);for(let m=0;m<h;m++)l[t[m]]=m;return l}function j(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Ce("packages/core/src/compute/sort.js",function(o,me){"use strict";Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return v}});const ae=me("packages/core/src/compute/handle.js"),he=ae.bitReader,W=ae.dictRanks,U=ae.dictSize,_=ae.identity,Z=ae.isMissing,E=ae.presenceReader,z=ae.rowCount,re=ae.valueComparator,Y=ae.valueReader,se=new Uint32Array(0),te=new ArrayBuffer(8),H=new Float64Array(te),T=new Uint32Array(te),V=(H[0]=-1,(T[1]&2147483648)!==0?1:0),ne=V===1?0:1;function R(S,N){H[0]=S;let I=T[V],K=T[ne];(I&2147483648)!==0?(I=~I>>>0,K=~K>>>0):I=(I^2147483648)>>>0,N[0]=K,N[1]=I}function j(S,N,I,K){if(K<2)return S;const B=new Uint32Array(256*8);for(let D=0;D<K;D++){const x=N[D],fe=I[D];B[x&255]++,B[256+(x>>>8&255)]++,B[512+(x>>>16&255)]++,B[768+(x>>>24&255)]++,B[1024+(fe&255)]++,B[1280+(fe>>>8&255)]++,B[1536+(fe>>>16&255)]++,B[1792+(fe>>>24&255)]++}let ee=S,J=N,ue=I,de=new Uint32Array(K),Oe=new Uint32Array(K),Ae=new Uint32Array(K);const Se=new Uint32Array(256);for(let D=0;D<8;D++){const x=D<<8,fe=(D&3)<<3,p=D>=4;let Q=!1;for(let le=0;le<256;le++)if(B[x+le]===K){Q=!0;break}if(Q)continue;let X=0;for(let le=0;le<256;le++)Se[le]=X,X+=B[x+le];for(let le=0;le<K;le++){const ge=J[le],Me=ue[le],be=(p?Me:ge)>>>fe&255,ye=Se[be]++;de[ye]=ee[le],Oe[ye]=ge,Ae[ye]=Me}let ce=ee;ee=de,de=ce,ce=J,J=Oe,Oe=ce,ce=ue,ue=Ae,Ae=ce}return ee}function i(S,N,I){if(I<2)return S;const K=new Uint32Array(256*4);for(let Oe=0;Oe<I;Oe++){const Ae=N[Oe];K[Ae&255]++,K[256+(Ae>>>8&255)]++,K[512+(Ae>>>16&255)]++,K[768+(Ae>>>24&255)]++}let B=S,ee=N,J=new Uint32Array(I),ue=new Uint32Array(I);const de=new Uint32Array(256);for(let Oe=0;Oe<4;Oe++){const Ae=Oe<<8,Se=Oe<<3;let D=!1;for(let p=0;p<256;p++)if(K[Ae+p]===I){D=!0;break}if(D)continue;let x=0;for(let p=0;p<256;p++)de[p]=x,x+=K[Ae+p];for(let p=0;p<I;p++){const Q=ee[p],X=de[Q>>>Se&255]++;J[X]=B[p],ue[X]=Q}let fe=B;B=J,J=fe,fe=ee,ee=ue,ue=fe}return B}function a(S,N,I,K){const B=new Uint32Array(K+1);for(let ue=0;ue<I;ue++)B[N[ue]]++;let ee=0;for(let ue=0;ue<=K;ue++){const de=B[ue];B[ue]=ee,ee+=de}const J=new Uint32Array(I);for(let ue=0;ue<I;ue++)J[B[N[ue]]++]=S[ue];return J}function s(S,N,I,K){return I<2?S:K<=65536||K<=I*2?a(S,N,I,K):i(S,N,I)}function h(S,N){return S.length===N&&S.byteOffset===0?S:Uint32Array.prototype.slice.call(S,0,N)}function u(S,N,I=!1){const K=N||_(S.length),B=K.length;if(B<2)return Uint32Array.from(K);const ee=new Uint32Array(B),J=new Uint32Array(B),ue=new Uint32Array(B),de=new Uint32Array(B),Oe=new Uint32Array(2);let Ae=0,Se=0;for(let fe=0;fe<B;fe++){const p=K[fe],Q=S[p];if(Number.isNaN(Q)){de[Se++]=p;continue}R(Q,Oe),I?(J[Ae]=~Oe[0]>>>0,ue[Ae]=~Oe[1]>>>0):(J[Ae]=Oe[0],ue[Ae]=Oe[1]),ee[Ae++]=p}const D=j(ee.subarray(0,Ae),J.subarray(0,Ae),ue.subarray(0,Ae),Ae);if(Se===0)return h(D,Ae);const x=new Uint32Array(B);return x.set(D.subarray(0,Ae),0),x.set(de.subarray(0,Se),Ae),x}function t(S,N,I=!1){const K=N||_(S.length),B=K.length;if(B<2)return Uint32Array.from(K);const ee=Uint32Array.from(K),J=new Uint32Array(B);for(let ue=0;ue<B;ue++){const de=(S[ee[ue]]^2147483648)>>>0;J[ue]=I?~de>>>0:de}return h(i(ee,J,B),B)}function l(S,N,I={}){const K=N||_(z(S,I)),B=K.length;if(B<2)return Uint32Array.from(K);const ee=W(S.dict,I.locale),J=S.values,ue=E(S),de=Math.max(U(S.dict),ee.length),Oe=de,Ae=Uint32Array.from(K),Se=new Uint32Array(B),D=!!I.descending;for(let x=0;x<B;x++){const fe=Ae[x];let p=ue&&ue(fe)===0?Oe:ee[J[fe]];p===void 0&&(p=Oe),Se[x]=D?Oe-p:p}return h(s(Ae,Se,B,de+1),B)}function m(S,N,I){const K=N.length;let B=Uint32Array.from(N);if(K<2)return B;let ee=new Uint32Array(K);for(let J=1;J<K;J<<=1){for(let de=0;de<K;de+=J<<1){const Oe=Math.min(de+J,K),Ae=Math.min(de+(J<<1),K);let Se=de,D=Oe,x=de;for(;Se<Oe&&D<Ae;)ee[x++]=I(S[B[Se]],S[B[D]])<=0?B[Se++]:B[D++];for(;Se<Oe;)ee[x++]=B[Se++];for(;D<Ae;)ee[x++]=B[D++]}const ue=B;B=ee,ee=ue}return B}function e(S,N,I){const K=he(S.values),B=N.length,ee=new Uint32Array(B),J=I?1:0;let ue=0;for(let de=0;de<B;de++)K(N[de])===J&&(ee[ue++]=N[de]);for(let de=0;de<B;de++)K(N[de])!==J&&(ee[ue++]=N[de]);return ee}function d(S,N){const I=S.values,K=S.kind;if((K==="object"||K===void 0)&&(Array.isArray(I)||ArrayBuffer.isView(I))&&!S.presence)return I;const ee=Y(S),J=new Array(z(S)||0);for(let ue=0;ue<N.length;ue++){const de=N[ue];J[de]=ee(de)}return J}function f(S,N){for(let I=0;I<N.length;I++)if(typeof S[N[I]]!="string")return!1;return!0}function r(S,N,I,K,B){const ee=S.length,J=Uint32Array.from(S);if(ee<2||K<1)return J;const ue=new Uint32Array(ee),de=K-1;for(let Oe=0;Oe<ee;Oe++){const Ae=I[N[Oe]];ue[Oe]=B?de-Ae:Ae}return h(s(J,ue,ee,K),ee)}function n(S,N,I){const K=re(I),B=new Array(N);for(let J=0;J<N;J++)B[J]=J;B.sort((J,ue)=>K(S[J],S[ue])||J-ue);const ee=new Uint32Array(N);for(let J=0;J<N;J++)ee[B[J]]=J;return ee}function c(S,N,I){const K=N.length,B=new Map,ee=[],J=new Uint32Array(K);for(let Oe=0;Oe<K;Oe++){const Ae=S[N[Oe]];let Se=B.get(Ae);Se===void 0&&(Se=ee.length,B.set(Ae,Se),ee.push(Ae)),J[Oe]=Se}const ue=ee.length,de=n(ee,ue,I.locale);return r(N,J,de,ue,!!I.descending)}function g(S,N,I){const K=d(S,N);if(N.length>=2&&f(K,N)){const J=S.stringRank;return J&&J.version===S.version&&J.usable(N,K,I.locale)?J.sort(N,I):c(K,N,I)}const B=re(I.locale),ee=I.descending?(J,ue)=>B(ue,J):B;return m(K,N,ee)}function A(S,N,I){const K=d(S,N),B=I.compare,J=!!I.descending?(ue,de)=>-B(ue,de,void 0,void 0,!0):(ue,de)=>B(ue,de,void 0,void 0,!1);return m(K,N,J)}function P(S,N){const I=N.length,K=E(S),B=S.values,ee=S.kind==="float64"&&!!B,J=S.kind==="object"||S.kind==="multi"||S.kind===void 0;if(!K&&!ee&&!J)return{present:N,absent:se};const ue=new Uint32Array(I),de=new Uint32Array(I);let Oe=0,Ae=0;if(K&&ee)for(let Se=0;Se<I;Se++){const D=N[Se];K(D)===1&&!Number.isNaN(B[D])?ue[Oe++]=D:de[Ae++]=D}else if(ee&&!K)for(let Se=0;Se<I;Se++){const D=N[Se];Number.isNaN(B[D])?de[Ae++]=D:ue[Oe++]=D}else if(K&&!J)for(let Se=0;Se<I;Se++){const D=N[Se];K(D)===1?ue[Oe++]=D:de[Ae++]=D}else{const Se=Y(S);for(let D=0;D<I;D++){const x=N[D];Z(Se(x))?de[Ae++]=x:ue[Oe++]=x}}return Ae===0?{present:N,absent:se}:{present:ue.subarray(0,Oe),absent:de.subarray(0,Ae)}}function q(S,N,I){if(N.length===0)return S;const K=new Uint32Array(S.length+N.length);return I?(K.set(N,0),K.set(S,N.length)):(K.set(S,0),K.set(N,S.length)),K}function L(S,N,I={}){const K=N||_(z(S,I));if(!S||K.length<2)return Uint32Array.from(K);const{present:B,absent:ee}=P(S,K);if(B.length===0)return Uint32Array.from(K);const J=!!I.descending;let ue;if(typeof I.compare=="function")ue=A(S,B,I);else switch(S.kind){case"float64":ue=u(S.values,B,J);break;case"int32":ue=t(S.values,B,J);break;case"dictionary":ue=l(S,B,I);break;case"bitset":ue=e(S,B,J);break;default:ue=g(S,B,I);break}return q(ue,ee,!!I.nullsFirst)}function v(S,N,I,K={}){const B=N||[],ee=B.length&&(B[0].handle||G(S,B[0].col))||S&&S[0];let J=I||_(z(ee,K));for(let ue=B.length-1;ue>=0;ue--){const de=B[ue],Oe=de.handle||G(S,de.col)||S&&S[ue];Oe&&(J=L(Oe,J,{descending:de.descending!==void 0?!!de.descending:de.dir==="desc",nullsFirst:!!de.nullsFirst,locale:de.locale!==void 0?de.locale:K.locale,compare:de.compare}))}return J instanceof Uint32Array?J:Uint32Array.from(J)}function G(S,N){if(!(!S||N===void 0)){for(let I=0;I<S.length;I++)if(S[I]&&S[I].id===N)return S[I]}}}),Ce("packages/core/src/store/stringrank.js",function(o,me){"use strict";Object.defineProperty(o,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"StringRankIndex",{enumerable:!0,get:function(){return _}});const ae=me("packages/core/src/compute/sort.js"),he=ae.collateStringRanks,W=ae.rankSortStrings,U=1e5;class _{#t=[];#e=new Map;#n;#r=0;#i=0;#s=-1;#h;#u=!1;#o=null;#c=-1;#l="\\0";constructor(E=U){this.#h=E>0?E:U,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(E){this.#s=E}get generation(){return this.#i}get size(){return this.#t.length}get capped(){return this.#u}get length(){return this.#r}get bytes(){let E=this.#n.byteLength;const z=this.#t;for(let re=0;re<z.length;re++)E+=z[re].length*2+24;return E}#a(E,z){const re=this.#e.get(E);if(re!==void 0)return re;if(this.#u)return-1;if(z&&this.#t.length>=this.#h)return this.#u=!0,-1;const Y=this.#t.length;return this.#t.push(E),this.#e.set(E,Y),this.#i++,Y}build(E,z){const re=z|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(re);for(let Y=0;Y<re;Y++){const se=E[Y],te=typeof se=="string"?this.#a(se,!1):-1;this.#n[Y]=te<0?0:te}this.#r=re}append(E,z,re){const Y=(z|0)+(re|0);if(Y>this.#n.length){const se=new Uint32Array(Y);se.set(this.#n.subarray(0,this.#r)),this.#n=se}for(let se=z|0;se<Y;se++){const te=E[se],H=typeof te=="string"?this.#a(te,!0):-1;this.#n[se]=H<0?0:H}this.#r=Math.max(this.#r,Y)}ranks(E){const z=E||"";if(this.#o&&this.#c===this.#i&&this.#l===z)return this.#o;const re=he(this.#t,this.#t.length,E);return this.#o=re,this.#c=this.#i,this.#l=z,re}usable(E,z,re){if(this.#u||this.#t.length===0)return!1;const Y=this.#n,se=this.#t,te=this.#r;for(let H=0;H<E.length;H++){const T=E[H];if(T>=te||se[Y[T]]!==z[T])return!1}return!0}sort(E,z){const re=this.ranks(z.locale),Y=this.#t.length,se=E.length,te=new Uint32Array(se),H=this.#n;for(let T=0;T<se;T++)te[T]=H[E[T]];return W(E,te,re,Y,!!z.descending)}}}),Ce("packages/core/src/store/columnstore.js",function(o,me){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"toFloat",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ColumnHandle",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"ColumnStore",{enumerable:!0,get:function(){return l}});const ae=me("packages/core/src/internal/util.js"),he=ae.warnOnce,W=ae.isFunction,U=ae.pathGetter,Z=me("packages/core/src/store/bitset.js").Bitset,z=me("packages/core/src/store/dictionary.js").Dictionary,Y=me("packages/core/src/store/multivalue.js").MultiValue,te=me("packages/core/src/store/stringrank.js").StringRankIndex,H=4294967295,T=1024,V=5e3,ne=.2,R=new Set(["float64","int32","bitset","dictionary","object","multi"]);function j(m){return m==null}function i(m){if(typeof m=="number")return m;if(m instanceof Date)return m.getTime();if(typeof m=="boolean")return m?1:0;const e=Number(m);return Number.isNaN(e)&&typeof m=="string"?Date.parse(m):e}function a(m){const e=i(m);return Number.isFinite(e)?e|0:0}function s(m){return j(m)?[]:Array.isArray(m)?m:[m]}function h(m,e){switch(m.kind){case"float64":case"int32":return m.buf[e];case"bitset":return m.bits.get(e)===1;case"dictionary":return m.dict.valueOf(m.buf[e]);case"multi":{const d=m.mv.at(e),f=new Array(d.length);for(let r=0;r<d.length;r++)f[r]=m.dict.valueOf(d[r]);return f}default:return m.buf[e]}}function u(m,e){switch(m.kind){case"float64":case"int32":return m.values[e];case"bitset":return(m.values[e>>3]&1<<(e&7))!==0;case"dictionary":return(m.table||[])[m.values[e]];case"multi":{const d=m.offsets[e],f=m.offsets[e+1],r=m.table||[],n=new Array(f-d);for(let c=d;c<f;c++)n[c-d]=r[m.values[c]];return n}default:return m.values[e]}}class t{#t;#e;#n;#r;#i;#s;#h;#u=!1;#o=null;#c=null;#l=null;#a=null;#d=null;#w;#b;#k=-1;#m=null;#p=0;#f=0;#y=null;#O=null;#g=!1;constructor(e,d){this.#t=e.id;const f=R.has(e.kind)?e.kind:"object";e.kind&&!R.has(e.kind)&&he(`store.kind.${e.id}`,`column "${e.id}" declares unknown storage kind "${e.kind}"; falling back to object`),this.#n=f,this.#e=f,this.#r=e.nullable!==!1,this.#h=e.dictionary??null,this.#s=d,this.#i=W(e.read)?e.read:U(e.field||e.id),this.#w=e.stringRankIndex!=="off",this.#b=typeof e.stringRankMaxDistinct=="number"?e.stringRankMaxDistinct:0,this.#y=new Map}get id(){return this.#t}get kind(){return this.#u?this.#e:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#g?null:this.#u?this.#e==="bitset"?this.#c.words:this.#e==="multi"?this.#l.values:this.#o:this.#N().values}get presence(){return this.#g||!this.#r?null:this.#u?this.#m:this.#N().presence}get dict(){return this.#g||!this.#u?null:this.#e==="dictionary"||this.#e==="multi"?this.#a:null}get stringRank(){if(this.#g||!this.#w||this.kind!=="object")return null;const e=this.values,d=this.#s.physical();if(!e||d===0)return null;if(this.#d===null){if(typeof e[0]!="string")return null;const f=new te(this.#S());return f.build(e,d),f.version=this.#f,this.#d=f,this.#k=this.#f,f.capped?null:f}return this.#d.length<d&&this.#d.append(e,this.#d.length,d-this.#d.length),this.#d.version=this.#f,this.#k=this.#f,this.#d.capped?null:this.#d}#S(){return this.#b}#j(){this.#d=null,this.#k=-1}get offsets(){return this.#g||!this.#u||this.#e!=="multi"?null:this.#l.offsets}get version(){return this.#f}get bytes(){let e=0;return this.#o&&(e+=this.#o.byteLength??this.#o.length*8),this.#c&&(e+=this.#c.bytes),this.#l&&(e+=this.#l.bytes),this.#m&&(e+=this.#m.bytes),this.#a&&(e+=this.#a.bytes),this.#y&&(e+=this.#y.size*24),e}get(e){if(!this.#g&&!(e<0||e>=this.#s.physical())){if(!this.#u)return this.#M(e);if(this.#r&&this.#m.get(e)===0)return null;switch(this.#e){case"float64":case"int32":return this.#o[e];case"bitset":return this.#c.get(e)===1;case"dictionary":return this.#a.valueOf(this.#o[e]);case"multi":{const d=this.#l.at(e),f=new Array(d.length);for(let r=0;r<d.length;r++)f[r]=this.#a.valueOf(d[r]);return f}default:return this.#o[e]}}}set(e,d){this.#g||(this.#u?this.#A(e,d):this.#y.set(e,d===void 0?null:d),this.#d&&this.#j(),this.#f++)}read(e){return this.#i(e)}appendColumn(e,d,f){if(this.#g||f<=0)return;if(!this.#u){this.#f++;return}const r=this.#i,n=this.#r,c=this.#m;let g=!1;switch(this.#e){case"float64":{const A=this.#o;for(let P=0;P<f;P++){const q=r(e[P]);if(typeof q=="number"){n&&c.set(d+P),A[d+P]=q;continue}const L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A[d+P]=L?NaN:i(q)}break}case"int32":{const A=this.#o;for(let P=0;P<f;P++){const q=r(e[P]),L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A[d+P]=L?0:a(q)}break}case"bitset":{const A=this.#c;for(let P=0;P<f;P++){const q=r(e[P]),L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A.assign(d+P,!L&&!!q)}break}case"dictionary":{const A=this.#o,P=this.#a;for(let q=0;q<f;q++){const L=r(e[q]),v=L==null;n?c.assign(d+q,!v):v&&(g=!0),A[d+q]=v?0:P.codeOf(L)}break}case"multi":{const A=this.#l,P=this.#a;for(let q=0;q<f;q++){const L=r(e[q]),v=L==null;n?c.assign(d+q,!v):v&&(g=!0);const G=s(L),S=new Array(G.length);for(let N=0;N<G.length;N++)S[N]=P.codeOf(G[N]);A.write(d+q,S)}break}default:{const A=this.#o;for(let P=0;P<f;P++){const q=r(e[P]),L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A[d+P]=L?null:q}break}}g&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#d&&this.#e==="object"&&(this.#d.append(this.#o,d,f),this.#d.version=this.#f+1,this.#k=this.#f+1),this.#f++}appendPacked(e,d,f){if(this.#g||f<=0||!e)return;if(!this.#u){this.#f++;return}const r=this.#m,n=e.presence;if(r)if(n)for(let g=0;g<f;g++)r.assign(d+g,(n[g>>3]&1<<(g&7))!==0);else for(let g=0;g<f;g++)r.set(d+g);const c=e.kind===this.#e;if(c&&(this.#e==="float64"||this.#e==="int32")){this.#o.set(e.values,d),this.#f++;return}if(c&&this.#e==="bitset"){const g=e.values;for(let A=0;A<f;A++)this.#c.assign(d+A,(g[A>>3]&1<<(A&7))!==0);this.#f++;return}if(c&&this.#e==="dictionary"){const g=e.table||[],A=new Uint32Array(g.length);for(let v=0;v<g.length;v++)A[v]=this.#a.codeOf(g[v]);const P=e.values,q=this.#o,L=r;for(let v=0;v<f;v++){if(L&&(n&&(n[v>>3]&1<<(v&7))===0)){q[d+v]=0;continue}q[d+v]=A[P[v]]??0}this.#f++;return}if(c&&this.#e==="multi"){const g=e.table||[],A=new Uint32Array(g.length);for(let L=0;L<g.length;L++)A[L]=this.#a.codeOf(g[L]);const P=e.values,q=e.offsets;for(let L=0;L<f;L++){const v=q[L],G=q[L+1],S=new Array(G-v);for(let N=v;N<G;N++)S[N-v]=A[P[N]]??0;this.#l.write(d+L,S)}this.#f++;return}for(let g=0;g<f;g++){const A=n?(n[g>>3]&1<<(g&7))===0:e.kind==="object"?e.values[g]===null:!1;this.#A(d+g,A?null:u(e,g))}this.#f++}touch(){this.#f++}columnarise(e,d){if(this.#u||this.#g)return;const f=new Array(d);for(let r=0;r<d;r++)f[r]=this.#M(r);this.#e=this.#n,this.#u=!0,this.#P(e);for(let r=0;r<d;r++)this.#A(r,f[r]);this.#y.clear(),this.#O=null,this.#j(),this.#f++}grow(e){if(!(!this.#u||this.#g||e<=this.#p)){switch(this.#e){case"float64":case"int32":case"dictionary":{const d=new this.#o.constructor(e);d.set(this.#o),this.#o=d;break}case"bitset":this.#c.grow(e);break;case"multi":break;default:this.#o.length=e;break}this.#m&&this.#m.grow(e),this.#p=e,this.#f++}}convert(e){if(this.#g||!R.has(e)||(this.#n=e,!this.#u||e===this.#e))return!1;const d={kind:this.#e,buf:this.#o,bits:this.#c,mv:this.#l,dict:this.#a},f=this.#s.physical(),r=this.#m;this.#e=e,this.#P(this.#p);for(let n=0;n<f;n++){const c=r!==null&&r.get(n)===0;c&&e!=="multi"||this.#A(n,c?null:h(d,n))}return this.#j(),this.#f++,!0}compact(e,d,f){if(!this.#g){if(this.#j(),!this.#u){const r=this.#y;if(r.size){const n=new Map;for(const[c,g]of r)e[c]!==H&&n.set(e[c],g);this.#y=n}this.#O=null,this.#f++;return}switch(this.#e){case"float64":case"int32":case"dictionary":case"object":{const r=this.#o;for(let n=0;n<d;n++)e[n]!==H&&(r[e[n]]=r[n]);if(this.#e==="object")for(let n=f;n<d;n++)r[n]=void 0;break}case"bitset":{const r=this.#c;for(let n=0;n<d;n++)e[n]!==H&&r.assign(e[n],r.get(n)===1);for(let n=f;n<d;n++)r.clear(n);break}case"multi":this.#l.compact(e,f,H);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<d;n++)e[n]!==H&&r.assign(e[n],r.get(n)===1);for(let n=f;n<d;n++)r.clear(n)}this.#f++}}release(){this.#g||(this.#g=!0,this.#o=null,this.#c&&this.#c.release(),this.#c=null,this.#l&&this.#l.release(),this.#l=null,this.#m&&this.#m.release(),this.#m=null,this.#a=null,this.#d=null,this.#y=new Map,this.#O=null,this.#p=0,this.#f++)}#P(e){const d=Math.max(1,e);switch(this.#o=null,this.#c=null,this.#l=null,this.#e){case"float64":this.#o=new Float64Array(d);break;case"int32":this.#o=new Int32Array(d);break;case"bitset":this.#c=new Z(d);break;case"dictionary":this.#o=new Uint32Array(d),this.#a=this.#a??new z(this.#h??[]);break;case"multi":this.#l=new Y({rows:d,values:d}),this.#a=this.#a??new z(this.#h??[]);break;default:this.#o=new Array(d);break}this.#e!=="dictionary"&&this.#e!=="multi"&&(this.#a=null),this.#r&&(this.#m?this.#m.grow(d):this.#m=new Z(d)),this.#p=d}#A(e,d){const f=j(d);switch(this.#r?this.#m.assign(e,!f):f&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#e){case"float64":this.#o[e]=f?NaN:i(d);break;case"int32":this.#o[e]=f?0:a(d);break;case"bitset":this.#c.assign(e,!f&&!!d);break;case"dictionary":this.#o[e]=f?0:this.#a.codeOf(d);break;case"multi":{const r=s(d),n=new Array(r.length);for(let c=0;c<r.length;c++)n[c]=this.#a.codeOf(r[c]);this.#l.write(e,n);break}default:this.#o[e]=f?null:d;break}}#M(e){if(this.#y.has(e))return this.#y.get(e);const d=this.#i(this.#s.rowAt(e));return d===void 0?null:d}#N(){if(this.#O&&this.#O.version===this.#f)return this.#O;const e=this.#s.physical(),d=new Array(e),f=this.#r?new Z(e):null;for(let r=0;r<e;r++){const n=this.#M(r);d[r]=n,f&&!j(n)&&f.set(r)}return this.#O={version:this.#f,values:d,presence:f},this.#O}}class l{#t;#e=new Map;#n=[];#r=[];#i=0;#s=0;#h=0;#u=0;#o=new Z(0);#c=!1;#l=!0;#a;#d;#w;#b=!1;constructor(e,d={}){this.#t=Array.isArray(e)?e:[],this.#d=Math.max(1,d.initialCapacity??T),this.#l=d.retainSource!==!1,this.#a=this.#l?d.columnarBelow??V:0,this.#w=d.compactRatio??ne;const f={rowAt:r=>this.#r[r],physical:()=>this.#i};for(const r of this.#t){if(!r||!r.id)continue;if(this.#e.has(r.id)){he(`store.dup.${r.id}`,`duplicate column id "${r.id}" in the store schema; ignoring the second`);continue}const n=new t(r,f);this.#e.set(r.id,n),this.#n.push(n)}this.#a<=0&&this.#p()}get count(){return this.#h}get physical(){return this.#i}get capacity(){return this.#c?this.#s:this.#r.length}get tombstones(){return this.#u}get columnar(){return this.#c}get destroyed(){return this.#b}get bytes(){let e=this.#o.bytes+this.#r.length*8;for(const d of this.#n)e+=d.bytes;return e}append(e){const d=this.#i;if(this.#b||!e)return{from:d,to:d};const f=e.length|0;if(f===0)return{from:d,to:d};if(this.#l)for(let n=0;n<f;n++)this.#r[d+n]=e[n];if(this.#i=d+f,this.#h+=f,this.#o.grow(this.#i),!this.#c){if(this.#i>=this.#a)this.#p();else for(const n of this.#n)n.touch();return{from:d,to:this.#i}}this.#k(this.#i);const r=this.#n;for(let n=0;n<r.length;n++)r[n].appendColumn(e,d,f);return{from:d,to:this.#i}}appendPacked(e,d){const f=this.#i;if(this.#b||!e)return{from:f,to:f};const r=e.count|0;if(r===0)return{from:f,to:f};if(this.#l&&d)for(let c=0;c<r;c++)this.#r[f+c]=d[c];this.#i=f+r,this.#h+=r,this.#o.grow(this.#i),this.#c||this.#p(),this.#k(this.#i);const n=new Map;for(const c of e.columns)n.set(c.id,c);for(const c of this.#n){const g=n.get(c.id);g?c.appendPacked(g,f,r):c.grow(this.#s)}return{from:f,to:this.#i}}source(e){if(this.#l)return this.#r[e];if(!(e<0||e>=this.#i))return this.#m(e)}setSource(e,d){this.#b||e<0||e>=this.#i||this.#l&&(this.#r[e]=d)}get(e,d){const f=this.#e.get(e);return f?f.get(d):void 0}set(e,d,f){if(this.#b||d<0||d>=this.#i)return;const r=this.#e.get(e);if(!r){he(`store.set.${e}`,`set() on unknown column "${e}"`);return}r.set(d,f)}remove(e){return this.#b||e<0||e>=this.#i||this.#o.get(e)===1?!1:(this.#o.set(e),this.#u++,this.#h--,!0)}live(e){return e<0||e>=this.#i?!1:this.#o.get(e)===0}compact(e={}){if(this.#b||this.#u===0||!e.force&&this.#u/this.#i<this.#w)return null;const d=this.#i,f=new Uint32Array(d);let r=0;for(let n=0;n<d;n++)f[n]=this.#o.get(n)===1?H:r++;for(const n of this.#n)n.compact(f,d,r);if(this.#l){const n=this.#r;for(let c=0;c<d;c++)f[c]!==H&&(n[f[c]]=n[c]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new Z(Math.max(this.#s,r)),f}column(e){return this.#e.get(e)}columns(){return this.#n.slice()}liveIndices(){const e=new Uint32Array(this.#h);if(this.#u===0){for(let f=0;f<this.#i;f++)e[f]=f;return e}let d=0;for(let f=0;f<this.#i;f++)this.#o.get(f)===0&&(e[d++]=f);return e}convert(e,d){const f=this.#e.get(e);return f?f.convert(d):!1}destroy(){if(!this.#b){this.#b=!0;for(const e of this.#n)e.release();this.#e.clear(),this.#n.length=0,this.#r.length=0,this.#o.release(),this.#i=0,this.#h=0,this.#u=0,this.#s=0}}#k(e){if(e<=this.#s)return;let d=this.#s||this.#d;for(;d<e;)d*=2;for(const f of this.#n)f.grow(d);this.#o.grow(d),this.#s=d}#m(e){const d={};for(const f of this.#n)d[f.id]=f.get(e);return d}#p(){if(this.#c)return;let e=this.#d;for(;e<this.#i;)e*=2;this.#c=!0,this.#s=e,this.#o.grow(e);for(const d of this.#n)d.columnarise(e,this.#i)}}}),Ce("packages/core/src/store/ingest.js",function(o,me){"use strict";Object.defineProperty(o,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"inferKind",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return R}});const ae=me("packages/core/src/internal/util.js"),he=ae.now,W=ae.nextFrame,U=ae.infoOnce,_=ae.warnOnce,Z=ae.isFunction,E=ae.pathGetter,re=me("packages/core/src/store/columnstore.js").ColumnStore,Y=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function se(j,i={}){if(i.multi)return"multi";if(j.length===0)return"object";let a=0,s=0,h=0,u=0,t=0;for(let m=0;m<j.length;m++){const e=j[m];typeof e=="number"?a++:typeof e=="boolean"?s++:typeof e=="string"?h++:e instanceof Date?u++:Array.isArray(e)&&t++}const l=j.length;return a===l?"float64":s===l?"bitset":u===l?"float64":h===l?"text":t===l?"multi":"object"}function te(j,i,a){return i<=0||j<a*i?"dictionary":"object"}function H(j,i,a){const s=new Map,h=new Map;for(const c of j){if(c.computed)continue;const g=Z(c.read)?c.read:E(c.field||c.id);h.set(c.id,g),s.set(c.id,g)}const u=i?.order??[],t=i?.fns??{},l=i?.deps??{},m=i?.wrapDeps??null,e=u.filter(c=>Z(t[c])),d=e.some(c=>l[c]==="*");let f=new WeakMap;const r=c=>{const g={};if(d)for(const[A,P]of h)g[A]=P(c);for(const A of e){const P=l[A];let q;if(P==="*")q=g;else{q={};const L=P||[];for(let v=0;v<L.length;v++){const G=L[v];q[G]=G in g?g[G]:h.get(G)?.(c)}}g[A]=t[A](m?m(q,A):q,{data:c,row:null,column:null,grid:null,context:a})}return g},n=c=>{if(c===null||typeof c!="object"&&typeof c!="function")return r(c);let g=f.get(c);return g===void 0&&(g=r(c),f.set(c,g)),g};for(const c of e)s.set(c,g=>n(g)[c]);return{readers:s,reset(){f=new WeakMap}}}class T{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(i,a){this.spec=i,this.read=a,this.kind="object",this.inferred=!1,this.nullable=i.nullable!==!1}}class V{#t;#e=[];#n=null;#r;#i=0;#s;#h=!1;#u=!1;#o=0;#c;constructor(i,a={},s={}){this.#t=Array.isArray(i)?i:Array.from(i||[]),this.#s={...Y,...s};const h=a.columns??[];this.#r=H(h,a.computed??null,a.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(h,a.computed??null),this.#n=new re(this.#e.map(u=>({id:u.spec.id,kind:u.kind,nullable:u.nullable,read:u.read,dictionary:u.spec.dictionary})),{initialCapacity:this.#s.initialCapacity,columnarBelow:this.#s.columnarBelow})}get store(){return this.#n}get done(){return this.#h||this.#u}get progress(){return this.#i}slice(){if(this.done)return!1;if(this.#s.signal?.aborted)return this.#u=!0,!1;const i=he(),{chunkMs:a,chunkRows:s}=this.#s,h=this.#t.length;do{const u=Math.min(this.#i+s,h);this.#n.append(this.#t.slice(this.#i,u)),this.#a(this.#i,u),this.#i=u,this.#r.reset(),this.#w(!1)}while(this.#i<h&&he()-i<a);return this.#o+=he()-i,this.#s.onProgress?.({loaded:this.#i,total:h}),this.#i>=h?(this.#w(!0),this.#h=!0,!1):!0}cancel(){this.#u=!0}result(){return{store:this.#n,schema:this.#e.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,read:i.read,dictionary:i.spec.dictionary})),decisions:this.#e.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,inferred:i.inferred,distinct:i.candidate||i.change?this.#d(i):null,change:i.change,reason:i.reason})),count:this.#n.count,elapsed:this.#o,cancelled:this.#u}}#l(i,a){const s=this.#t,h=Math.min(this.#s.sampleSize,s.length),u=this.#s.dictionaryRatio,t=a?.pure instanceof Set?a.pure:new Set(a?.pure??a?.order??[]);for(const l of i){if(!l||!l.id)continue;if(l.computed&&(l.pure===!1||a&&!t.has(l.id))){_(`ingest.impure.${l.id}`,`column "${l.id}" is an impure computed column and is not materialised into the store`);continue}const m=this.#r.readers.get(l.id)??(Z(l.read)?l.read:E(l.field||l.id)),e=new T(l,m);if(l.kind)e.kind=l.kind,e.reason="declared by the caller";else if(l.dictionary)e.kind=l.multi?"multi":"dictionary",e.reason="value table supplied (lookup column)";else{const d=[];for(let r=0;r<h&&d.length<this.#s.sampleSize;r++){const n=m(s[r]);n!=null&&d.push(n)}e.inferred=!0;const f=se(d,{multi:l.multi});if(f==="text"){const r=new Set(d).size;e.kind=te(r,d.length,u),e.candidate=this.#c,e.reason=`sampled ${r} distinct in ${d.length}`}else e.kind=f,e.reason=`inferred from ${d.length} sampled values`,f==="object"&&d.length&&U(`ingest.mixed.${l.id}`,`column "${l.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);e.kind==="object"&&e.candidate&&(e.distinct=new Set(d))}this.#e.push(e)}}#a(i,a){const s=this.#t;for(const h of this.#e){if(!h.candidate||!h.distinct)continue;const u=h.distinct;for(let t=i;t<a;t++){const l=h.read(s[t]);l!=null&&u.add(l)}}}#d(i){if(i.distinct)return i.distinct.size;const a=this.#n.column(i.spec.id);return a?.dict?a.dict.size:0}#w(i){const a=this.#s.dictionaryRatio,s=this.#t.length;for(const h of this.#e){if(!h.candidate)continue;const u=this.#d(h);if(h.kind==="dictionary"&&u>=a*s){const t=this.#n.column(h.spec.id);h.distinct=new Set(t?.dict?t.dict.values():[]),this.#n.convert(h.spec.id,"object"),h.kind="object",h.change="demoted",h.reason=`${u} distinct values is at or above ${a*100}% of ${s} rows`;continue}if(h.kind==="object"&&u>=a*s){h.candidate=!1,h.distinct=null,h.reason=`${u} distinct values is at or above ${a*100}% of ${s} rows`;continue}i&&h.kind==="object"&&u<a*s&&(this.#n.convert(h.spec.id,"dictionary"),h.kind="dictionary",h.change=h.change==="demoted"?null:"promoted",h.reason=`${u} distinct values is below ${a*100}% of ${s} rows`,h.distinct=null),i&&(h.candidate=!1)}}}async function ne(j,i={},a={}){const s=new V(j,i,a),h=a.scheduler?.frame??W;for(;s.slice();)await new Promise(u=>{h(u)});return s.result()}function R(j,i={},a={}){const s=new V(j,i,{...a,chunkMs:1/0});for(;s.slice(););return s.result()}}),Ce("packages/core/src/store/columnpack.js",function(o,me){"use strict";Object.defineProperty(o,"isPortableSchema",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"packChunk",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"packedTransfers",{enumerable:!0,get:function(){return V}});const he=me("packages/core/src/internal/util.js").pathGetter,W=me("packages/core/src/store/ingest.js"),U=W.inferKind,_=W.decideText,Z=W.INGEST_DEFAULTS,z=me("packages/core/src/store/columnstore.js").toFloat,re=new Set(["float64","int32","bitset","dictionary","object","multi"]);function Y(ne){if(!Array.isArray(ne)||ne.length===0)return!1;for(const R of ne)if(!R||typeof R.id!="string"||typeof R.field!="string"||R.field===""||R.kind&&!re.has(R.kind))return!1;return!0}function se(ne){const R=z(ne);return Number.isFinite(R)?R|0:0}function te(ne){return ne==null?[]:Array.isArray(ne)?ne:[ne]}function H(ne,R,j,i){if(ne.kind)return ne.kind;const a=[];for(let u=0;u<R.length&&a.length<Z.sampleSize;u++){const t=R[u];t!=null&&a.push(t)}const s=U(a,{multi:ne.multi});if(s!=="text")return s;const h=new Set(a).size;return _(h,a.length,i)}function T(ne,R,j={}){const i=R.length|0,a=j.dictionaryRatio??Z.dictionaryRatio,s=[];for(const h of ne){const u=he(h.field||h.id),t=h.nullable!==!1,l=new Array(i);for(let r=0;r<i;r++){const n=u(R[r]);l[r]=n===void 0?null:n}const m=H(h,l,i,a),e=t?new Uint8Array(i+7>>3):null,d=r=>{e&&(e[r>>3]|=1<<(r&7))};let f;switch(m){case"float64":{const r=new Float64Array(i);for(let n=0;n<i;n++){const c=l[n],g=c===null;g||d(n),r[n]=g?NaN:z(c)}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"int32":{const r=new Int32Array(i);for(let n=0;n<i;n++){const c=l[n],g=c===null;g||d(n),r[n]=g?0:se(c)}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"bitset":{const r=new Uint8Array(i+7>>3);for(let n=0;n<i;n++){const c=l[n],g=c===null;g||d(n),!g&&c&&(r[n>>3]|=1<<(n&7))}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"dictionary":{const r=new Uint32Array(i),n=[],c=new Map;for(let g=0;g<i;g++){const A=l[g];if(A===null){r[g]=0;continue}d(g);let P=c.get(A);P===void 0&&(P=n.length,n.push(A),c.set(A,P)),r[g]=P}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:n};break}case"multi":{const r=[],n=new Map,c=new Uint32Array(i+1),g=[];for(let A=0;A<i;A++){const P=l[A];c[A]=g.length,P===null||d(A);const L=te(P);for(let v=0;v<L.length;v++){const G=L[v];let S=n.get(G);S===void 0&&(S=r.length,r.push(G),n.set(G,S)),g.push(S)}}c[i]=g.length,f={id:h.id,kind:m,nullable:t,values:Int32Array.from(g),presence:e,offsets:c,table:r};break}default:{const r=new Array(i);for(let n=0;n<i;n++){const c=l[n];c!==null&&d(n),r[n]=c}f={id:h.id,kind:"object",nullable:t,values:r,presence:e,offsets:null,table:null};break}}s.push(f)}return{count:i,columns:s}}function V(ne){const R=[];if(!ne||!Array.isArray(ne.columns))return R;const j=i=>{ArrayBuffer.isView(i)&&i.buffer&&!R.includes(i.buffer)&&R.push(i.buffer)};for(const i of ne.columns)j(i.values),j(i.presence),j(i.offsets);return R}}),Ce("packages/core/src/compute/sortspec.js",function(o,me){"use strict";Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return _}});function ae(Z){return{locale:Z===void 0?void 0:String(Z),numeric:!0,sensitivity:"variant"}}function he(Z){return!!Z&&typeof Z.compare!="function"}function W(Z){if(!Z)return!0;for(let E=0;E<Z.length;E++)if(!he(Z[E]))return!1;return!0}function U(Z,E){const z=Z.col!==void 0?Z.col:Z.handle&&Z.handle.id,re=Z.locale!==void 0?Z.locale:E;return{col:z,descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,collation:ae(re)}}function _(Z,E){const z=Z||[],re=new Array(z.length);for(let Y=0;Y<z.length;Y++)re[Y]=U(z[Y],E);return re}}),Ce("packages/core/src/format/date.js",function(o,me){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return R}});const ae=me("packages/core/src/internal/util.js"),he=ae.isNil,W=ae.warnOnce,U=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function _(j){const i=[];let a=0,s="";const h=()=>{s&&(i.push({token:null,text:s}),s="")};for(;a<j.length;){const u=j[a];if(u==="\'"){if(j[a+1]==="\'"){s+="\'",a+=2;continue}const l=j.indexOf("\'",a+1);if(l===-1){s+=j.slice(a+1),a=j.length;continue}s+=j.slice(a+1,l),a=l+1;continue}const t=U.find(l=>j.startsWith(l,a));if(t){h(),i.push({token:t,text:t}),a+=t.length;continue}/[A-Za-z]/.test(u)&&W(`date.pattern.token:${u}`,`the date pattern "${j}" contains \'${u}\', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${U.join(" ")}.`),s+=u,a+=1}return h(),i}const Z=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function E(j){if(he(j)||j==="")return null;if(j instanceof Date)return Number.isNaN(j.getTime())?null:j;if(typeof j=="number")return Number.isNaN(j)?null:new Date(j);if(typeof j=="string"){const i=Z.exec(j.trim());if(i){const[,s,h,u,t="0",l="0",m="0"]=i;return new Date(+s,+h-1,+u,+t,+l,+m)}const a=new Date(j);return Number.isNaN(a.getTime())?null:a}return null}function z(j,i){return String(j).padStart(i,"0")}function re(j){if(!j)return s=>({year:s.getFullYear(),month:s.getMonth()+1,day:s.getDate(),hour:s.getHours(),minute:s.getMinutes(),second:s.getSeconds(),ms:s.getMilliseconds(),weekday:s.getDay()});const i=new Intl.DateTimeFormat("en-US",{timeZone:j,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),a={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return s=>{const h={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:s.getMilliseconds(),weekday:0};for(const u of i.formatToParts(s))switch(u.type){case"year":h.year=Number(u.value);break;case"month":h.month=Number(u.value);break;case"day":h.day=Number(u.value);break;case"hour":h.hour=Number(u.value)%24;break;case"minute":h.minute=Number(u.value);break;case"second":h.second=Number(u.value);break;case"weekday":h.weekday=a[u.value]??0;break;default:break}return h}}function Y(j,i,a){const s=_(j),h=re(a),u=new Set(s.filter(d=>d.token).map(d=>d.token)),t=u.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:a}):null,l=u.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:a}):null,m=u.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:a}):null,e=u.has("EEEE")?new Intl.DateTimeFormat(i,{weekday:"long",timeZone:a}):null;return d=>{const f=h(d);let r="";for(const n of s){if(!n.token){r+=n.text;continue}switch(n.token){case"yyyy":r+=z(f.year,4);break;case"yy":r+=z(f.year%100,2);break;case"MMMM":r+=l.format(d);break;case"MMM":r+=t.format(d);break;case"MM":r+=z(f.month,2);break;case"M":r+=String(f.month);break;case"dd":r+=z(f.day,2);break;case"d":r+=String(f.day);break;case"EEEE":r+=e.format(d);break;case"EEE":r+=m.format(d);break;case"HH":r+=z(f.hour,2);break;case"H":r+=String(f.hour);break;case"hh":r+=z(f.hour%12===0?12:f.hour%12,2);break;case"h":r+=String(f.hour%12===0?12:f.hour%12);break;case"mm":r+=z(f.minute,2);break;case"m":r+=String(f.minute);break;case"ss":r+=z(f.second,2);break;case"s":r+=String(f.second);break;case"SSS":r+=z(f.ms,3);break;case"a":r+=f.hour<12?"AM":"PM";break;default:r+=n.text;break}}return r}}const se=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function te(j,i){const a=j||{},s=a.locale||i||void 0,h=a.nullDisplay??"",u=a.timeZone;let t;if(a.pattern)t=Y(a.pattern,s,u);else if(a.dateStyle||a.timeStyle){const f={timeZone:u};a.dateStyle&&(f.dateStyle=a.dateStyle),a.timeStyle&&(f.timeStyle=a.timeStyle);const r=new Intl.DateTimeFormat(s,f);t=n=>r.format(n)}else{const f=new Intl.DateTimeFormat(s,{dateStyle:"medium",timeZone:u});t=r=>f.format(r)}const l=a.relative?new Intl.RelativeTimeFormat(s,{numeric:"auto"}):null,e=(typeof a.relative=="object"&&a.relative?a.relative.threshold??7:7)*24*36e5,d=(f,r)=>{const n=E(f);if(!n)return h;if(l){const c=r&&typeof r.now=="number"?r.now:Date.now(),g=n.getTime()-c;if(Math.abs(g)<e){for(const[A,P]of se)if(Math.abs(g)>=P||A==="second")return l.format(Math.round(g/P),A)}}return t(n)};return d.spec=a,d}function H(j){if(he(j)||j==="")return null;if(typeof j=="string"){const s=/^(\\d{4}-\\d{2}-\\d{2})/.exec(j.trim());if(s)return s[1];const h=E(j);return h?H(h):null}const i=E(j);if(!i)return null;const a=s=>String(s).padStart(2,"0");return`${i.getFullYear()}-${a(i.getMonth()+1)}-${a(i.getDate())}`}function T(j,i){if(he(j)||j==="")return null;if(typeof j=="string"){const s=j.trim();if(V.test(s)){const t=E(s);return t?ne(t,i):null}const h=/^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(s);if(h){const[,t,l,m,e]=h;return`${t}T${l}:${m}${e&&e!=="00"?`:${e}`:""}`}if(/^\\d{4}-\\d{2}-\\d{2}$/.test(s))return`${s}T00:00`;const u=E(s);return u?T(u):null}const a=E(j);return a?ne(a,i):null}const V=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function ne(j,i){const a=t=>String(t).padStart(2,"0");if(i)try{const t=new Intl.DateTimeFormat("en-CA",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(j).reduce((e,d)=>(d.type!=="literal"&&(e[d.type]=d.value),e),{}),l=t.hour==="24"?"00":t.hour,m=Number(t.second);return`${t.year}-${t.month}-${t.day}T${l}:${t.minute}`+(m?`:${t.second}`:"")}catch{}const s=`${j.getFullYear()}-${a(j.getMonth()+1)}-${a(j.getDate())}`,h=j.getSeconds(),u=`${a(j.getHours())}:${a(j.getMinutes())}${h?`:${a(h)}`:""}`;return`${s}T${u}`}function R(j,i){const a=he(j)||j===""?null:String(j),s=he(i)||i===""?null:String(i);return a===null?s===null?0:1:s===null||a<s?-1:a>s?1:0}}),Ce("packages/core/src/compute/filter.js",function(o,me){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"wallMs",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"itemwisePredicate",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(o,"declareOperators",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"declaredOperator",{enumerable:!0,get:function(){return fe}});const ae=me("packages/core/src/internal/util.js"),he=ae.isBlank,W=ae.toArray,U=ae.warnOnce,_=me("packages/core/src/format/date.js"),Z=_.toDate,E=_.toIsoDate,z=me("packages/core/src/compute/handle.js"),re=z.bitReader,Y=z.dictSize,se=z.dictValue,te=z.presenceReader,H=z.valueComparator,T=z.valueReader,V=/^\\d{4}-\\d{2}-\\d{2}$/,ne="\\0null\\0";function R(p,Q){const X=p&&p.pool;if(X){const ce=X.mask||X.acquireMask||X.acquire||X.take;if(typeof ce=="function"){const le=ce.call(X,Q);if(le&&le.length>=Q)return le}}return new Uint8Array(Q)}function j(p,Q){const X=p&&p.pool;if(!X||!Q)return;const ce=X.release||X.releaseMask||X.free||X.recycle;typeof ce=="function"&&ce.call(X,Q)}function i(p,Q,X){return p.fill(X,0,Q),p}function a(p){return p==null||typeof p=="number"&&Number.isNaN(p)}function s(p,Q){if(p==null)return p;if(Q==="number")return typeof p=="number"?p:Number(p);if(Q==="date"||Q==="dateString"){const X=E(p);return X===null?h(p):X}return Q==="boolean"?typeof p=="boolean"?p:p==="true"||p===1?!0:p==="false"||p===0?!1:!!p:p}function h(p){return p instanceof Date?p.getTime():typeof p=="number"?p:Date.parse(String(p))}function u(p){return typeof p=="number"?p:p instanceof Date?p.getTime():p==null||p===""?NaN:Number(p)}function t(p,Q){const X=typeof p=="string"?p:String(p);return Q?X:X.toLowerCase()}function l(p,Q){return p==null?ne:typeof p=="string"?Q?p:p.toLowerCase():p instanceof Date?p.getTime():p}function m(p,Q,X){const ce=new Set;for(const le of W(p)){const ge=s(le,X);ce.add(l(ge,Q)),typeof ge=="string"&&ge!==""&&Number.isFinite(Number(ge))?ce.add(Number(ge)):typeof ge=="number"&&Number.isFinite(ge)&&ce.add(l(String(ge),Q))}return ce}function e(p,Q,X){if(p==null||Q===null||Q===void 0)return p==null&&Q==null;const ce=typeof p,le=typeof Q;return ce==="string"&&le==="string"?X?p===Q:p.toLowerCase()===Q.toLowerCase():p instanceof Date||Q instanceof Date?h(p)===h(Q):ce==="number"&&le==="number"?p===Q||Number.isNaN(p)&&Number.isNaN(Q):ce==="number"&&le==="string"?p===Number(Q):ce==="string"&&le==="number"?Number(p)===Q:ce==="boolean"||le==="boolean"?p===Q:Array.isArray(p)&&Array.isArray(Q)?p.length===Q.length&&p.every((ge,Me)=>e(ge,Q[Me],X)):p===Q}function d(p,Q){try{if(p instanceof RegExp){const X=p.flags.replace(/[gy]/g,"");return new RegExp(p.source,Q||X.includes("i")?X:`${X}i`)}return new RegExp(String(p),Q?"":"i")}catch(X){return U(`regex:${String(p)}`,`filter operator "matches" received an invalid pattern: ${String(p)}`,X),null}}function f(p,Q){if(p&&p.type==="datetime"&&r.has(p.op))return P(p,Q);const X=q(p,Q),ce=p&&p.type;return ce!=="date"&&ce!=="dateString"?X:le=>X(typeof le=="string"&&V.test(le)?le:E(le)??le)}const r=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),n=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{1,3})\\d*)?)?)?$/,c=new Map;function g(p,Q){let X=c.get(Q);if(X===void 0){try{X=new Intl.DateTimeFormat("en-CA",{timeZone:Q,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{X=null}c.set(Q,X)}if(!X)return null;const ce={};for(const le of X.formatToParts(p))le.type!=="literal"&&(ce[le.type]=le.value);return ce}function A(p,Q){if(p==null||p==="")return null;if(typeof p=="string"){const ge=n.exec(p.trim());if(ge)return Date.UTC(+ge[1],+ge[2]-1,+ge[3],+(ge[4]||0),+(ge[5]||0),+(ge[6]||0),+(ge[7]||"0").padEnd(3,"0"))}const X=Z(p);if(!X)return null;const ce=X.getUTCMilliseconds(),le=Q?g(X,Q):null;return le?Date.UTC(+le.year,+le.month-1,+le.day,le.hour==="24"?0:+le.hour,+le.minute,+le.second,ce):Date.UTC(X.getFullYear(),X.getMonth(),X.getDate(),X.getHours(),X.getMinutes(),X.getSeconds(),ce)}function P(p,Q){const X=typeof p.timeZone=="string"&&p.timeZone?p.timeZone:void 0,ce=Me=>A(Me,X),le=Array.isArray(p.value)?p.value.map(ce):ce(p.value),ge=q({...p,type:"number",value:le},Q);return Me=>ge(A(Me))}function q(p,Q){const X=p&&p.op,ce=!!(p&&p.caseSensitive),le=p&&p.type,ge=H(Q),Me=be=>ye=>!be(ye);switch(X){case"eq":{const be=s(p.value,le);return ye=>e(ye,be,ce)}case"ne":{const be=s(p.value,le);return ye=>!e(ye,be,ce)}case"lt":case"lte":case"gt":case"gte":{const be=s(p.value,le);if(a(be))return()=>!1;const ye=X==="lt"?-1:X==="lte"?0:X==="gt"?1:2;return Re=>{if(a(Re))return!1;const Ne=ge(Re,be);return ye===-1?Ne<0:ye===0?Ne<=0:ye===1?Ne>0:Ne>=0}}case"between":case"notBetween":{const be=W(p.value),ye=s(be[0],le),Re=s(be[1],le),Ne=p.bounds||"[]",Ee=Ne.charAt(0)!=="(",Be=Ne.charAt(1)!==")";if(a(ye)||a(Re))return X==="between"?()=>!1:()=>!0;const ze=We=>{if(a(We))return!1;const Xe=ge(We,ye),Ye=ge(We,Re);return(Ee?Xe>=0:Xe>0)&&(Be?Ye<=0:Ye<0)};return X==="between"?ze:Me(ze)}case"in":case"notIn":{const be=m(p.value,ce,le),ye=Re=>be.has(l(Re,ce));return X==="in"?ye:Me(ye)}case"contains":case"notContains":{const be=t(s(p.value,le),ce),ye=Re=>Re==null?!1:t(Re,ce).includes(be);return X==="contains"?ye:Me(ye)}case"startsWith":{const be=t(s(p.value,le),ce);return ye=>ye==null?!1:t(ye,ce).startsWith(be)}case"endsWith":{const be=t(s(p.value,le),ce);return ye=>ye==null?!1:t(ye,ce).endsWith(be)}case"matches":{const be=d(p.value,ce);return be?ye=>ye==null?!1:be.test(String(ye)):()=>!1}case"blank":return be=>he(be)||Array.isArray(be)&&be.length===0;case"notBlank":return be=>!(he(be)||Array.isArray(be)&&be.length===0);case"containsAny":case"containsNone":{const be=m(p.value,ce,le),ye=Re=>{const Ne=Re==null?[]:W(Re);for(let Ee=0;Ee<Ne.length;Ee++)if(be.has(l(Ne[Ee],ce)))return!0;return!1};return X==="containsAny"?ye:Me(ye)}case"containsAll":{const be=W(p.value).map(ye=>l(s(ye,le),ce));return ye=>{const Re=ye==null?[]:W(ye);if(be.length===0)return!0;const Ne=new Set(Re.map(Ee=>l(Ee,ce)));for(let Ee=0;Ee<be.length;Ee++)if(!Ne.has(be[Ee]))return!1;return!0}}default:{const be=fe(X);return be?be.compile(p.value):(U(`op:${String(X)}`,`unknown filter operator "${String(X)}"; the condition is refused rather than matching every row`),()=>!1)}}}function L(p,Q,X){return f(Q,X)(p)}const v=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),G=new Set(["containsAny","containsAll","containsNone"]);function S(p,Q,X){const ce=p&&p.op,le=v[ce]||ce,ge=f({...p,op:le,type:Q.type},X),Me=Q.items,be=ye=>{const Re=Me(ye);if(!Re)return!1;for(let Ne=0;Ne<Re.length;Ne++)if(ge(Re[Ne]))return!0;return!1};return v[ce]?ye=>!be(ye):be}function N(p,Q,X,ce){const le=te(p);if(le){const be=Q?1:0;for(let ye=0;ye<ce;ye++)X[ye]=le(ye)===be?1:0;return X}const ge=p.kind;if(ge==="float64"||ge==="int32"||ge==="bitset")return i(X,ce,Q?1:0);const Me=T(p);for(let be=0;be<ce;be++){const ye=Me(be),Re=he(ye)||Array.isArray(ye)&&ye.length===0;X[be]=Re===Q?0:1}return X}function I(p,Q,X,ce){const le=p.dict,ge=Y(le),Me=new Uint8Array(ge);for(let Ne=0;Ne<ge;Ne++)Me[Ne]=Q(se(le,Ne))?1:0;const be=p.values,ye=te(p);if(!ye){for(let Ne=0;Ne<ce;Ne++)X[Ne]=Me[be[Ne]];return X}const Re=Q(null)?1:0;for(let Ne=0;Ne<ce;Ne++)X[Ne]=ye(Ne)===1?Me[be[Ne]]:Re;return X}function K(p,Q,X,ce){const le=re(p.values),ge=Q(!0)?1:0,Me=Q(!1)?1:0,be=te(p);if(!be){for(let Re=0;Re<ce;Re++)X[Re]=le(Re)===1?ge:Me;return X}const ye=Q(null)?1:0;for(let Re=0;Re<ce;Re++)X[Re]=be(Re)===0?ye:le(Re)===1?ge:Me;return X}function B(p,Q,X,ce,le){const ge=p.values,Me=Q.type,be=Q.op;let ye=!0;switch(be){case"eq":case"ne":{const Ne=u(s(Q.value,Me)),Ee=typeof Q.value=="number"&&Number.isNaN(Q.value),Be=be==="ne"?1:0;if(Ee)for(let ze=0;ze<le;ze++)ce[ze]=(Number.isNaN(ge[ze])?1:0)^Be;else for(let ze=0;ze<le;ze++)ce[ze]=(ge[ze]===Ne?1:0)^Be;break}case"lt":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]<Ne?1:0;break}case"lte":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]<=Ne?1:0;break}case"gt":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]>Ne?1:0;break}case"gte":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]>=Ne?1:0;break}case"between":case"notBetween":{const Ne=W(Q.value),Ee=u(s(Ne[0],Me)),Be=u(s(Ne[1],Me)),ze=Q.bounds||"[]",We=ze.charAt(0)!=="(",Xe=ze.charAt(1)!==")",Ye=be==="notBetween"?1:0;if(We&&Xe)for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>=Ee&ge[Ie]<=Be?1:0)^Ye;else if(We)for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>=Ee&ge[Ie]<Be?1:0)^Ye;else if(Xe)for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>Ee&ge[Ie]<=Be?1:0)^Ye;else for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>Ee&ge[Ie]<Be?1:0)^Ye;break}case"in":case"notIn":{const Ne=new Set;for(const Be of W(Q.value)){const ze=u(s(Be,Me));Number.isNaN(ze)||Ne.add(ze)}const Ee=be==="notIn"?1:0;for(let Be=0;Be<le;Be++)ce[Be]=(Ne.has(ge[Be])?1:0)^Ee;break}default:ye=!1;break}if(!ye)return!1;const Re=te(p);if(Re){const Ne=X(null)?1:0;for(let Ee=0;Ee<le;Ee++)Re(Ee)===0&&(ce[Ee]=Ne)}return!0}function ee(p,Q,X,ce){const le=T(p);for(let ge=0;ge<ce;ge++)X[ge]=Q(le(ge))?1:0;return X}function J(p,Q,X){const ce=Q.count|0,le=X||R(Q,ce);if(!p)return i(le,ce,1);const ge=typeof Q.handle=="function"?Q.handle(p.col):void 0,Me=typeof Q.custom=="function"?Q.custom:null;if(!ge){if(Me){for(let Ne=0;Ne<ce;Ne++)le[Ne]=Me(p,Ne)?1:0;return le}return U(`filter:col:${String(p.col)}`,`filter references unknown column "${String(p.col)}"; the condition is refused rather than matching every row`),i(le,ce,0)}const be=p.op;if(be==="blank"||be==="notBlank")return N(ge,be==="notBlank",le,ce);const ye=typeof Q.itemwise=="function"?Q.itemwise(p.col):null;if(ye&&!fe(be)&&!G.has(be))return ee(ge,S(p,ye,Q.locale),le,ce);const Re=f(p,Q.locale);switch(ge.kind){case"dictionary":return I(ge,Re,le,ce);case"bitset":return K(ge,Re,le,ce);case"float64":case"int32":return B(ge,p,Re,le,ce)?le:ee(ge,Re,le,ce);default:return ee(ge,Re,le,ce)}}function ue(p,Q,X){if(!p)return i(R(Q,X),X,1);if(Array.isArray(p.conditions)){const ce=p.conditions.filter(Me=>Me!=null),le=p.op==="or"?"or":p.op==="not"?"not":"and";if(ce.length===0)return i(R(Q,X),X,1);const ge=ue(ce[0],Q,X);for(let Me=1;Me<ce.length;Me++){const be=ue(ce[Me],Q,X);if(le==="or")for(let ye=0;ye<X;ye++)ge[ye]|=be[ye];else for(let ye=0;ye<X;ye++)ge[ye]&=be[ye];j(Q,be)}if(le==="not")for(let Me=0;Me<X;Me++)ge[Me]^=1;return ge}return J(p,Q,R(Q,X))}function de(p,Q){return ue(p,Q,Q.count|0)}function Oe(p,Q){if(!p||!Q)return p||null;const X=p;if(Array.isArray(X.conditions)){if((X.op==="or"?"or":X.op==="not"?"not":"and")!=="and")return Ae(X,Q)?null:p;const le=[];for(const ge of X.conditions){const Me=Oe(ge,Q);Me&&le.push(Me)}return le.length?{...X,op:"and",conditions:le}:null}return X.col===Q?null:p}function Ae(p,Q){if(!p||typeof p!="object")return!1;const X=p;if(X.col===Q)return!0;if(Array.isArray(X.conditions)){for(const ce of X.conditions)if(Ae(ce,Q))return!0}return!1}function Se(p,Q,X){if(X&&X.length>=Q){let Me=0;for(let be=0;be<Q;be++)p[be]&&(X[Me++]=be);return X.subarray(0,Me)}let ce=0;for(let Me=0;Me<Q;Me++)ce+=p[Me]?1:0;const le=new Uint32Array(ce);let ge=0;for(let Me=0;Me<Q;Me++)p[Me]&&(le[ge++]=Me);return le}const D=new Map;function x(p){if(!(!p||typeof p!="object"))for(const[Q,X]of Object.entries(p))X&&typeof X.compile=="function"&&D.set(Q,X)}function fe(p){return typeof p=="string"?D.get(p):void 0}}),Ce("packages/core/src/compute/group.js",function(o,me){"use strict";Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return te}});const ae=me("packages/core/src/compute/handle.js"),he=ae.dictSize,W=ae.identity,U=ae.presenceReader,_=ae.rowCount,Z=ae.valueReader,E="",z="\\0",re=1<<20;function Y(H,T,V,ne){const R=H.length,j=H.map(t=>Z(t)),i=Array.isArray(ne)&&ne.some(Boolean),a=i?j.map((t,l)=>ne[l]?m=>ne[l](t(m)):t):j;if(!i&&R>0&&H.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=H.map(m=>he(m.dict)+1);let l=1;for(let m=0;m<R;m++)l*=t[m];if(l<=Number.MAX_SAFE_INTEGER){const m=H.map(r=>r.values),e=H.map(r=>U(r)),d=r=>{let n=0;for(let c=0;c<R;c++){const g=e[c],A=g&&g(r)===0?t[c]-1:m[c][r];n=n*t[c]+A}return n},f=new Float64Array(V);for(let r=0;r<V;r++)f[r]=d(T[r]);return{packed:f,strings:null,product:l,readers:a,keyOf:d}}}const h=t=>{let l="";for(let m=0;m<R;m++){const e=a[m](t);l+=(m===0?"":E)+(e==null?z:String(e))}return l},u=new Array(V);for(let t=0;t<V;t++)u[t]=h(T[t]);return{packed:null,strings:u,product:1/0,readers:a,keyOf:h}}function se(H,T,V,ne){const R=new Uint32Array(ne+1);for(let s=0;s<V;s++)R[T[s]+1]++;for(let s=0;s<ne;s++)R[s+1]+=R[s];const j=new Uint32Array(V),i=R.slice(0,ne);for(let s=0;s<V;s++)j[i[T[s]]++]=H[s];const a=new Array(ne);for(let s=0;s<ne;s++)a[s]=j.subarray(R[s],R[s+1]);return a}function te(H,T,V={}){const ne=H||[],R=T||W(_(ne[0],V)),j=R.length;if(ne.length===0||j===0)return{keys:[],buckets:[]};const{packed:i,strings:a,product:s,readers:h}=Y(ne,R,j,V.project),u=new Uint32Array(j);let t=0,l=null;if(i&&s<=Math.max(1024,Math.min(re,j*4))){const f=s,r=new Int32Array(f).fill(-1);for(let n=0;n<j;n++)r[i[n]]=0;for(let n=0;n<f;n++)r[n]===0&&(r[n]=t++);for(let n=0;n<j;n++)u[n]=r[i[n]];l=new Float64Array(t);for(let n=0;n<f;n++)r[n]>=0&&(l[r[n]]=n)}else if(i){const f=new Map;for(let r=0;r<j;r++){const n=i[r];let c=f.get(n);c===void 0&&(c=t++,f.set(n,c)),u[r]=c}l=new Float64Array(t);for(const[r,n]of f)l[n]=r}else{const f=new Map;for(let r=0;r<j;r++){const n=a[r];let c=f.get(n);c===void 0&&(c=t++,f.set(n,c)),u[r]=c}}const m=se(R,u,j,t),e=new Array(t);for(let f=0;f<t;f++){const r=m[f][0],n=new Array(h.length);for(let c=0;c<h.length;c++)n[c]=h[c](r);e[f]=n}const d={keys:e,buckets:m};return l&&(d.packed=l),d}}),Ce("packages/core/src/compute/facet.js",function(o,me){"use strict";Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return r}});const ae=me("packages/core/src/compute/handle.js"),he=ae.presenceReader,W=ae.valueReader,U=ae.dictSize,_=ae.dictValue,Z=Object.freeze(["equal","quantile","log"]),E=Object.freeze(["hour","day","week","month","quarter","year"]),z=20,re=50,Y=1e4;function se(n,c){if(!n)return"none";const g=c;if(g&&(g.multi===!0||typeof g.items=="function"))return"category";const A=c&&c.base;if(A==="date"||A==="datetime"||A==="time"||A==="dateString")return"date";switch(n.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return A==="number"?"numeric":A==="boolean"?"boolean":A==="text"?"category":"none"}}function te(n){const c=n.values,g=n.kind;if((g==="float64"||g==="int32")&&c)return P=>c[P];const A=W(n);return P=>H(A(P))}function H(n){if(typeof n=="number")return n;if(n instanceof Date)return n.getTime();if(n==null||n==="")return NaN;if(typeof n=="boolean")return n?1:0;if(typeof n=="string"){const c=Number(n);if(Number.isFinite(c))return c;const g=Date.parse(n);return Number.isFinite(g)?g:NaN}return NaN}function T(n,c,g,A=re){if(!n)return{cardinality:0,exact:!0};if(n.dict)return{cardinality:U(n.dict),exact:!0};if(n.kind==="bitset")return{cardinality:2,exact:!0};const P=W(n),q=c?c.length:g,L=new Set;for(let v=0;v<q;v++){const G=P(c?c[v]:v);if(G!=null&&(L.add(G),L.size>A))return{cardinality:L.size,exact:!1}}return{cardinality:L.size,exact:!0}}const V=36e5,ne=864e5;function R(n,c=z){const g=Number.isFinite(n)&&n>0?n:0,A=Math.max(1,c)*2;return g/V<=A?"hour":g/ne<=A?"day":g/(7*ne)<=A?"week":g/(30*ne)<=A?"month":g/(91*ne)<=A?"quarter":"year"}function j(n,c){if(!Number.isFinite(n))return NaN;const g=new Date(n);switch(c){case"hour":return g.setMinutes(0,0,0),g.getTime();case"day":return g.setHours(0,0,0,0),g.getTime();case"week":{g.setHours(0,0,0,0);const A=(g.getDay()+6)%7;return g.setDate(g.getDate()-A),g.getTime()}case"month":return g.setDate(1),g.setHours(0,0,0,0),g.getTime();case"quarter":return g.setMonth(Math.floor(g.getMonth()/3)*3,1),g.setHours(0,0,0,0),g.getTime();default:return g.setMonth(0,1),g.setHours(0,0,0,0),g.getTime()}}function i(n,c){const g=new Date(n);switch(c){case"hour":g.setHours(g.getHours()+1);break;case"day":g.setDate(g.getDate()+1);break;case"week":g.setDate(g.getDate()+7);break;case"month":g.setMonth(g.getMonth()+1);break;case"quarter":g.setMonth(g.getMonth()+3);break;default:g.setFullYear(g.getFullYear()+1);break}return g.getTime()}function a(n,c,g){const A=te(n),P=he(n),q=c?c.length:g;let L=1/0,v=-1/0,G=0,S=0;for(let N=0;N<q;N++){const I=c?c[N]:N;if(P&&!P(I)){G++;continue}const K=A(I);if(!Number.isFinite(K)){G++;continue}K<L&&(L=K),K>v&&(v=K),S++}return{min:L,max:v,nulls:G,finite:S}}function s(n,c,g,A){const P=te(n),q=he(n),L=c?c.length:g,v=L>A?L/A:1,G=[];for(let N=0;N<L;N+=v){const I=c?c[Math.floor(N)]:Math.floor(N);if(q&&!q(I))continue;const K=P(I);Number.isFinite(K)&&G.push(K)}const S=Float64Array.from(G);return S.sort(),S}function h(n,c,g,A={}){const P=A.kind||se(n,A.type);return P==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:P==="boolean"?u(n,c,g):P==="category"?t(n,c,g,A):l(n,c,g,P,A)}function u(n,c,g){const A=he(n);let P=0;if(A){const L=c?c.length:g;for(let v=0;v<L;v++)A(c?c[v]:v)||P++}const q=[{value:!1,label:"false"},{value:!0,label:"true"}];return P>0&&q.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:q}}function t(n,c,g,A){const P=A.cardinalityLimit??re,{cardinality:q}=T(n,c,g,P);if(q>P&&(A.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:q};const L=W(n),v=c?c.length:g,G=new Map;let S=0;for(let ee=0;ee<v;ee++){const J=L(c?c[ee]:ee);if(J==null||J===""){S++;continue}if(Array.isArray(J)){if(!J.length){S++;continue}for(const ue of J)G.set(ue,(G.get(ue)||0)+1);continue}G.set(J,(G.get(J)||0)+1)}let N=[...G.entries()];A.order==="alpha"?N.sort((ee,J)=>String(ee[0]).localeCompare(String(J[0]))):N.sort((ee,J)=>J[1]-ee[1]);let I=0,K=0;if(N.length>P){K=N.length-P;for(let ee=P;ee<N.length;ee++)I+=N[ee][1];N=N.slice(0,P)}const B=N.map(([ee])=>({value:ee,label:String(ee)}));return I>0&&B.push({remainder:!0,label:`Other (${K} values)`}),S>0&&B.push({null:!0,label:"Empty"}),{kind:"category",buckets:B,cardinality:q}}function l(n,c,g,A,P){const{min:q,max:L,nulls:v,finite:G}=a(n,c,g);if(!G)return{kind:A,buckets:v?[{null:!0,label:"Empty"}]:[],empty:!0};const S=Math.max(1,Math.floor(P.buckets||z));let N=[];if(A==="date"){const K=E.includes(P.granularity)?P.granularity:R(L-q,S);let B=j(q,K);for(;B<=L&&N.length<4096;){const ee=i(B,K);if(!(ee>B))break;N.push({from:B,to:ee}),B=ee}return{kind:A,buckets:m(N,v),granularity:K}}const I=Z.includes(P.strategy)?P.strategy:"equal";if(I==="quantile"){const K=s(n,c,g,Y);if(K.length){const B=[K[0]];for(let ee=1;ee<S;ee++){const J=K[Math.min(K.length-1,Math.floor(ee/S*K.length))];J>B[B.length-1]&&B.push(J)}B.push(L);for(let ee=0;ee<B.length-1;ee++)N.push({from:B[ee],to:B[ee+1]})}}else if(I==="log"&&q>0){const K=Math.log10(q),ee=(Math.log10(L)-K)/S||1;for(let J=0;J<S;J++)N.push({from:10**(K+J*ee),to:10**(K+(J+1)*ee)})}if(!N.length){const K=(L-q)/S||1;for(let B=0;B<S;B++)N.push({from:q+B*K,to:q+(B+1)*K})}return N[N.length-1].to=L,{kind:A,buckets:m(N,v),strategy:I,min:q,max:L}}function m(n,c){return c>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,c,g,A,P){const q=A&&A.buckets||[],L=P&&P.length>=q.length?P.subarray(0,q.length):new Uint32Array(q.length);if(L.fill(0),!n||!q.length)return L;const v=q.length-1,G=!!q[v]&&q[v].null===!0,S=c?c.length:g;if(A.kind==="boolean"){const ee=W(n);for(let J=0;J<S;J++){const ue=ee(c?c[J]:J);if(ue==null){G&&L[v]++;continue}L[ue?1:0]++}return L}if(A.kind==="category"){const ee=new Map;for(let de=0;de<q.length;de++)!q[de].null&&!q[de].remainder&&ee.set(q[de].value,de);const J=q.findIndex(de=>de.remainder),ue=W(n);for(let de=0;de<S;de++){const Oe=ue(c?c[de]:de);if(Oe==null||Oe===""){G&&L[v]++;continue}if(Array.isArray(Oe)){if(!Oe.length){G&&L[v]++;continue}for(const Se of Oe){const D=ee.get(Se);D!==void 0?L[D]++:J>=0&&L[J]++}continue}const Ae=ee.get(Oe);Ae!==void 0?L[Ae]++:J>=0&&L[J]++}return L}const N=G?q.length-1:q.length,I=new Float64Array(N+1);for(let ee=0;ee<N;ee++)I[ee]=q[ee].from;I[N]=N?q[N-1].to:0;const K=te(n),B=he(n);for(let ee=0;ee<S;ee++){const J=c?c[ee]:ee;if(B&&!B(J)){G&&L[v]++;continue}const ue=K(J);if(!Number.isFinite(ue)){G&&L[v]++;continue}const de=d(I,N,ue);de>=0&&L[de]++}return L}function d(n,c,g){if(!c||g<n[0])return-1;if(g>=n[c])return g===n[c]?c-1:-1;let A=0,P=c-1;for(;A<P;){const q=A+P+1>>>1;g>=n[q]?A=q:P=q-1}return A}function f(n,c,g,A={}){const P=A.bounds||h(n,A.boundsIndices??c,g,A);return{bounds:P,counts:e(n,c,g,P)}}const r=f}),Ce("packages/core/src/compute/special.js",function(o,me){"use strict";Object.defineProperty(o,"logGamma",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"incompleteBeta",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return ne}});const ae=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),he=3e-12,W=1e-300;function U(R){if(R<.5)return Math.log(Math.PI/Math.sin(Math.PI*R))-U(1-R);const j=R-1;let i=.9999999999998099;const a=j+7.5;for(let s=0;s<ae.length;s++)i+=ae[s]/(j+s+1);return .5*Math.log(2*Math.PI)+(j+.5)*Math.log(a)-a+Math.log(i)}function _(R,j,i){const a=R+j,s=R+1,h=R-1;let u=1,t=1-a*i/s;Math.abs(t)<W&&(t=W),t=1/t;let l=t;for(let m=1;m<=300;m++){const e=2*m;let d=m*(j-m)*i/((h+e)*(R+e));t=1+d*t,Math.abs(t)<W&&(t=W),u=1+d/u,Math.abs(u)<W&&(u=W),t=1/t,l*=t*u,d=-(R+m)*(a+m)*i/((R+e)*(s+e)),t=1+d*t,Math.abs(t)<W&&(t=W),u=1+d/u,Math.abs(u)<W&&(u=W),t=1/t;const f=t*u;if(l*=f,Math.abs(f-1)<he)break}return l}function Z(R,j,i){if(!(R>0)||!(j>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const a=Math.exp(U(R+j)-U(R)-U(j)+R*Math.log(i)+j*Math.log(1-i));return i<(R+1)/(R+j+2)?a*_(R,j,i)/R:1-a*_(j,R,1-i)/j}function E(R){if(!(R>0)||!(R<1))return R===0?-1/0:R===1?1/0:Number.NaN;const j=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],i=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],a=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],s=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],h=.02425;let u,t,l;R<h?(u=Math.sqrt(-2*Math.log(R)),l=(((((a[0]*u+a[1])*u+a[2])*u+a[3])*u+a[4])*u+a[5])/((((s[0]*u+s[1])*u+s[2])*u+s[3])*u+1)):R<=1-h?(u=R-.5,t=u*u,l=(((((j[0]*t+j[1])*t+j[2])*t+j[3])*t+j[4])*t+j[5])*u/(((((i[0]*t+i[1])*t+i[2])*t+i[3])*t+i[4])*t+1)):(u=Math.sqrt(-2*Math.log(1-R)),l=-(((((a[0]*u+a[1])*u+a[2])*u+a[3])*u+a[4])*u+a[5])/((((s[0]*u+s[1])*u+s[2])*u+s[3])*u+1));const e=(.5*z(-l/Math.SQRT2)-R)*Math.sqrt(2*Math.PI)*Math.exp(l*l/2);return l-e/(1+l*e/2)}function z(R){const j=Math.abs(R),i=2/(2+j),a=4*i-2,s=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let h=0,u=0,t;for(let m=s.length-1;m>0;m--)t=u,u=a*u-h+s[m],h=t;const l=i*Math.exp(-j*j+.5*(s[0]+a*u)-h);return R>=0?l:2-l}function re(R){return .5*z(-R/Math.SQRT2)}function Y(R,j){if(!(j>0)||!Number.isFinite(R))return Number.NaN;const i=.5*Z(j/2,.5,j/(j+R*R));return R>0?1-i:i}function se(R,j){if(!(R>0)||!(R<1)||!(j>0))return Number.NaN;if(j>1e7)return E(R);let i=-1e4,a=1e4,s=E(R);const h=U(j/2)+U(.5)-U((j+1)/2);for(let u=0;u<60;u++){const t=Y(s,j);t<R?i=s:a=s;const l=Math.exp(-((j+1)/2)*Math.log(1+s*s/j)-h)/Math.sqrt(j),m=l>0?(t-R)/l:0;if(Math.abs(m)<1e-12)break;const e=s-m;if(s=e>i&&e<a&&Number.isFinite(e)?e:(i+a)/2,a-i<1e-12)break}return s}function te(R,j){let i=R,a=1/R,s=a;for(let h=0;h<300&&(i+=1,s*=j/i,a+=s,!(Math.abs(s)<Math.abs(a)*he));h++);return a*Math.exp(-j+R*Math.log(j)-U(R))}function H(R,j){let i=j+1-R,a=1/W,s=1/i,h=s;for(let u=1;u<=300;u++){const t=-u*(u-R);i+=2,s=t*s+i,Math.abs(s)<W&&(s=W),a=i+t/a,Math.abs(a)<W&&(a=W),s=1/s;const l=s*a;if(h*=l,Math.abs(l-1)<he)break}return Math.exp(-j+R*Math.log(j)-U(R))*h}function T(R,j){return!(R>0)||!(j>=0)||!Number.isFinite(j)?Number.NaN:j===0?0:j<R+1?te(R,j):1-H(R,j)}function V(R,j){return j>0?T(j/2,R/2):Number.NaN}function ne(R,j){const i=V(R,j);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Ce("packages/core/src/compute/linalg.js",function(o,me){"use strict";Object.defineProperty(o,"cholesky",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"choleskySolve",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"choleskyInverse",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return Z}});function ae(E){const z=E.length,re=Array.from({length:z},()=>new Array(z).fill(0));for(let Y=0;Y<z;Y++)for(let se=0;se<=Y;se++){let te=E[Y][se];for(let H=0;H<se;H++)te-=re[Y][H]*re[se][H];if(Y===se){if(!(te>0))return null;re[Y][se]=Math.sqrt(te)}else re[Y][se]=te/re[se][se]}return re}function he(E,z){const re=E.length,Y=new Array(re).fill(0);for(let te=0;te<re;te++){let H=z[te];for(let T=0;T<te;T++)H-=E[te][T]*Y[T];Y[te]=H/E[te][te]}const se=new Array(re).fill(0);for(let te=re-1;te>=0;te--){let H=Y[te];for(let T=te+1;T<re;T++)H-=E[T][te]*se[T];se[te]=H/E[te][te]}return se}function W(E){const z=E.length,re=Array.from({length:z},()=>new Array(z).fill(0));for(let Y=0;Y<z;Y++){const se=new Array(z).fill(0);se[Y]=1;const te=he(E,se);for(let H=0;H<z;H++)re[H][Y]=te[H]}return re}function U(E,z,re){const Y=E.length,se=Y?E[0].length:0,te=Array.from({length:se},()=>new Array(se).fill(0)),H=new Array(se).fill(0);for(let T=0;T<Y;T++){const V=re?re[T]:1,ne=E[T];for(let R=0;R<se;R++){const j=V*ne[R];H[R]+=j*z[T];for(let i=R;i<se;i++)te[R][i]+=j*ne[i]}}for(let T=0;T<se;T++)for(let V=0;V<T;V++)te[T][V]=te[V][T];return{xtwx:te,xtwy:H}}function _(E,z){return E.map(re=>re.reduce((Y,se,te)=>Y+se*z[te],0))}function Z(E,z){let re=0;for(let Y=0;Y<E.length;Y++){let se=0;for(let te=0;te<E.length;te++)se+=z[Y][te]*E[te];re+=E[Y]*se}return re}}),Ce("packages/core/src/compute/sketch.js",function(o,me){"use strict";Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return te}});class ae{#t=0;#e=0;#n=0;static get errorBound(){return Object.freeze({kind:"exact",metric:"none",value:0,statement:"mean and variance match a full recompute to float rounding"})}get count(){return this.#t}add(T){if(!Number.isFinite(T))return;this.#t++;const V=T-this.#e;this.#e+=V/this.#t,this.#n+=V*(T-this.#e)}merge(T){if(T.#t===0)return;if(this.#t===0){this.#t=T.#t,this.#e=T.#e,this.#n=T.#n;return}const V=this.#t+T.#t,ne=T.#e-this.#e;this.#e+=ne*(T.#t/V),this.#n+=T.#n+ne*ne*(this.#t*T.#t/V),this.#t=V}mean(){return this.#t?this.#e:null}variance(){return this.#t>1?this.#n/(this.#t-1):null}varianceP(){return this.#t?this.#n/this.#t:null}stddev(){const T=this.variance();return T===null?null:Math.sqrt(T)}stddevP(){const T=this.varianceP();return T===null?null:Math.sqrt(T)}}class he{#t=[];#e=0;#n;#r;constructor(T,V=Math.random){if(!(T>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(T),this.#r=V}static get errorBound(){return Object.freeze({kind:"probabilistic",metric:"none",value:0,statement:"uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators"})}get seen(){return this.#e}get size(){return this.#t.length}add(T){if(!Number.isFinite(T))return;if(this.#e++,this.#t.length<this.#n){this.#t.push(T);return}const V=Math.floor(this.#r()*this.#e);V<this.#n&&(this.#t[V]=T)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let T=0;for(const V of this.#t)T+=V;return T/this.#t.length}quantile(T){const V=this.#t.length;if(!V)return null;const ne=this.#t.slice().sort((a,s)=>a-s);if(V===1)return ne[0];const R=(V-1)*Math.min(1,Math.max(0,T)),j=Math.floor(R),i=Math.ceil(R);return j===i?ne[j]:ne[j]+(R-j)*(ne[i]-ne[j])}}function W(H){return H^=H>>>16,H=Math.imul(H,2246822507),H^=H>>>13,H=Math.imul(H,3266489909),H^=H>>>15,H>>>0}function U(H){if(typeof H=="number"){const ne=new DataView(new ArrayBuffer(8));return ne.setFloat64(0,H===0?0:H),W(ne.getUint32(0)^ne.getUint32(4))}const T=typeof H=="string"?H:String(H);let V=2166136261;for(let ne=0;ne<T.length;ne++)V^=T.charCodeAt(ne),V=Math.imul(V,16777619);return W(V)}class _{#t;#e;#n;constructor(T=14){const V=Math.floor(T);if(V<4||V>16)throw new RangeError("HLL precision must be 4..16");this.#t=V,this.#e=1<<V,this.#n=new Uint8Array(this.#e)}static errorBoundFor(T=14){const V=1<<Math.floor(T),ne=1.04/Math.sqrt(V);return Object.freeze({kind:"probabilistic",metric:"relative",value:ne,statement:`distinct count within ~${(ne*100).toFixed(2)}% relative standard error (m=${V} buckets)`})}errorBound(){return _.errorBoundFor(this.#t)}add(T){const V=U(T),ne=V&this.#e-1,R=V>>>this.#t|1<<32-this.#t;let j=1,i=R;for(;(i&1)===0;)j++,i>>>=1;j>this.#n[ne]&&(this.#n[ne]=j)}count(){const T=this.#e,V=32-this.#t,ne=new Float64Array(V+2);for(let i=0;i<T;i++)ne[this.#n[i]]++;let R=T*z(1-ne[V+1]/T);for(let i=V;i>=1;i--)R=.5*(R+ne[i]);R+=T*E(ne[0]/T);const j=Z*T*T/R;return Math.round(j)}}const Z=.5/Math.log(2);function E(H){if(H===1)return 1/0;let T=1,V=H,ne;do H*=H,ne=V,V+=H*T,T+=T;while(V!==ne);return V}function z(H){if(H===0||H===1)return 0;let T=1,V=1-H,ne;do H=Math.sqrt(H),ne=V,T*=.5,V-=(1-H)**2*T;while(V!==ne);return V/3}class re{#t=new Map;#e;#n=0;constructor(T){if(!(T>0))throw new RangeError("Space-Saving capacity must be positive");this.#e=Math.floor(T)}errorBoundFor(T){const V=T/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:V,statement:`each count overestimates the truth by at most N/m = ${V.toFixed(2)} (N=${T}, m=${this.#e})`})}get seen(){return this.#n}add(T){this.#n++;const V=this.#t.get(T);if(V){V.count++;return}if(this.#t.size<this.#e){this.#t.set(T,{count:1,error:0});return}let ne,R=1/0;for(const[j,i]of this.#t)i.count<R&&(R=i.count,ne=j);this.#t.delete(ne),this.#t.set(T,{count:R+1,error:R})}top(T=this.#e){return[...this.#t.entries()].map(([ne,R])=>({item:ne,count:R.count,error:R.error})).sort((ne,R)=>R.count-ne.count).slice(0,Math.max(0,Math.floor(T)))}}class Y{#t;#e=[[]];#n=0;#r;#i;constructor(T=200,V=Math.random){this.#t=Math.max(8,Math.floor(T)),this.#r=V,this.#i=2/3}static errorBoundFor(T=200){const V=1/Math.max(8,Math.floor(T));return Object.freeze({kind:"probabilistic",metric:"rank",value:V,statement:`queried quantile\'s true rank within ~${(V*100).toFixed(2)}% of N of the requested rank (k=${T})`})}errorBound(){return Y.errorBoundFor(this.#t)}get count(){return this.#n}#s(T){const ne=this.#e.length-1-T,R=Math.ceil(this.#t*this.#i**ne);return Math.max(2,R)}add(T){Number.isFinite(T)&&(this.#n++,this.#e[0].push(T),this.#e[0].length>=this.#s(0)&&this.#h(0))}#h(T){const V=this.#e[T];V.sort((j,i)=>j-i),T+1>=this.#e.length&&this.#e.push([]);const ne=this.#e[T+1],R=this.#r()<.5?0:1;for(let j=R;j<V.length;j+=2)ne.push(V[j]);this.#e[T]=[];for(let j=0;j<this.#e.length;j++)if(this.#e[j].length>=this.#s(j)){this.#h(j);return}}#u(){const T=[];for(let V=0;V<this.#e.length;V++){const ne=1<<V;for(const R of this.#e[V])T.push({v:R,w:ne})}return T}quantile(T){const V=this.#u();if(!V.length)return null;V.sort((i,a)=>i.v-a.v);let ne=0;for(const i of V)ne+=i.w;const R=Math.min(1,Math.max(0,T))*ne;let j=0;for(const i of V)if(j+=i.w,j>=R)return i.v;return V[V.length-1].v}rank(T){let V=0;for(let ne=0;ne<this.#e.length;ne++){const R=1<<ne;for(const j of this.#e[ne])j<=T&&(V+=R)}return V}}const se=Object.freeze({distinct:_.errorBoundFor(14),median:Y.errorBoundFor(200),p25:Y.errorBoundFor(200),p75:Y.errorBoundFor(200),p90:Y.errorBoundFor(200),p95:Y.errorBoundFor(200),p99:Y.errorBoundFor(200),iqr:Y.errorBoundFor(200),topK:Object.freeze({kind:"deterministic",metric:"absolute",value:0,statement:"each count overestimates the truth by at most N/m; top-K exact when the K-th item exceeds N/m"})}),te={Welford:ae,Reservoir:he,HyperLogLog:_,SpaceSaving:re,KLL:Y,hash32:U,SKETCH_BOUNDS:se}}),Ce("packages/core/src/compute/statistics.js",function(o,me){"use strict";Object.defineProperty(o,"KENDALL_LIMIT",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"numbers",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"frequencies",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"herfindahl",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"entropy",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"evenness",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"topShare",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"gini",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"moments",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"quantileSorted",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"quantile",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"STAT_FNS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"weightedAverage",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"extremeRow",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"correlation",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"fitLinearModel",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(o,"autocorrelations",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"spearman",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(o,"kendall",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(o,"seriesStats",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(o,"D2_N2",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(o,"D4_N2",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(o,"movingRanges",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(o,"withinSigma",{enumerable:!0,get:function(){return We}}),Object.defineProperty(o,"capability",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(o,"controlLimits",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(o,"westernElectricViolations",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(o,"nelsonViolations",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(o,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(o,"controlViolations",{enumerable:!0,get:function(){return At}}),Object.defineProperty(o,"countOutside",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(o,"histogram",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(o,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(o,"meanInterval",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(o,"proportionInterval",{enumerable:!0,get:function(){return St}}),Object.defineProperty(o,"slopeInterval",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(o,"capabilityInterval",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(o,"standardizedMeanDifference",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(o,"normalTotalVariation",{enumerable:!0,get:function(){return dt}}),Object.defineProperty(o,"frequencyMap",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(o,"categoricalDistance",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(o,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return st}}),Object.defineProperty(o,"compareColumn",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(o,"isNumericColumn",{enumerable:!0,get:function(){return gt}}),Object.defineProperty(o,"populationRead",{enumerable:!0,get:function(){return Rt}});const ae=me("packages/core/src/compute/handle.js"),he=ae.presenceReader,W=ae.valueReader,U=me("packages/core/src/compute/special.js"),_=U.studentTQuantile,Z=U.studentT,E=U.normalQuantile,z=U.normalCdf,re=U.chiSquareUpperTail,Y=me("packages/core/src/compute/linalg.js"),se=Y.cholesky,te=Y.choleskySolve,H=Y.choleskyInverse,T=Y.normalEquations,V=Y.quadForm,R=me("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,j=5e3,i=Object.freeze({variance:"rescan",varianceP:"rescan",stddev:"rescan",stddevP:"rescan",sumSquares:"rescan",weightedAvg:"rescan",median:"rescan",p25:"rescan",p75:"rescan",p90:"rescan",p95:"rescan",p99:"rescan",iqr:"rescan",mode:"rescan",distinct:"rescan",range:"rescan",skewness:"rescan",kurtosis:"rescan",geomean:"rescan",harmean:"rescan",mad:"rescan",argmin:"rescan",argmax:"rescan",hhi:"rescan",entropy:"rescan",evenness:"rescan",top3Share:"rescan",top10Share:"rescan",gini:"rescan",trimmedMean:"rescan",winsorizedMean:"rescan",robustOutliers:"rescan",jarqueBera:"rescan",passRate:"rescan",failureCount:"rescan"}),a=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:R.distinct}),median:Object.freeze({sketch:"KLL",bound:R.median}),p25:Object.freeze({sketch:"KLL",bound:R.p25}),p75:Object.freeze({sketch:"KLL",bound:R.p75}),p90:Object.freeze({sketch:"KLL",bound:R.p90}),p95:Object.freeze({sketch:"KLL",bound:R.p95}),p99:Object.freeze({sketch:"KLL",bound:R.p99}),iqr:Object.freeze({sketch:"KLL",bound:R.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:R.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:R.topK})});function s(b){const k=b==="sum"||b==="avg"||b==="countValues"||b==="min"||b==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,b)?i[b]:null,y=Object.prototype.hasOwnProperty.call(a,b)?a[b]:null;return{stat:b,exact:k,approximate:y}}function h(b,k){const y=k.length,w=new Float64Array(y);let O=0;if(b&&(b.kind==="float64"||b.kind==="int32")){const F=b.values,C=he(b);for(let ie=0;ie<y;ie++){const oe=k[ie];if(C&&C(oe)!==1)continue;const ke=F[oe];Number.isNaN(ke)||(w[O++]=ke)}return w.subarray(0,O)}const $=W(b);for(let F=0;F<y;F++){const C=$(k[F]);if(C==null||C==="")continue;const ie=typeof C=="number"?C:Number(C);Number.isFinite(ie)&&(w[O++]=ie)}return w.subarray(0,O)}function u(b,k){const y=new Map,w=W(b);let O=0;for(let $=0;$<k.length;$++){const F=w(k[$]);if(F==null||F===""||typeof F=="number"&&Number.isNaN(F))continue;const C=typeof F=="object"?String(F):F;y.set(C,(y.get(C)||0)+1),O++}const M=[...y.values()].sort(($,F)=>F-$);return{counts:M,total:O,distinct:M.length}}function t(b){return b.total>0?b.counts.map(k=>k/b.total):[]}function l(b,k){const y=u(b,k);if(!y.total)return null;let w=0;for(const O of t(y))w+=O*O;return w}function m(b,k){const y=u(b,k);if(!y.total)return null;let w=0;for(const O of t(y))O>0&&(w-=O*Math.log2(O));return w}function e(b,k){const y=u(b,k);if(!y.total||y.distinct<2)return y.total?1:null;let w=0;for(const O of t(y))O>0&&(w-=O*Math.log2(O));return w/Math.log2(y.distinct)}function d(b,k,y=3){const w=u(b,k);if(!w.total)return null;const O=Math.max(1,Math.floor(y));let M=0;for(let $=0;$<Math.min(O,w.counts.length);$++)M+=w.counts[$];return M/w.total}function f(b,k){const y=h(b,k),w=y.length;if(!w)return null;const O=y.slice().sort();if(O[0]<0)return null;let M=0,$=0;for(let F=0;F<w;F++)M+=O[F],$+=(F+1)*O[F];return M===0?0:2*$/(w*M)-(w+1)/w}function r(b){let k=0,y=0,w=0;for(let O=0;O<b.length;O++){const M=b[O];k++;const $=M-y;y+=$/k,w+=$*(M-y)}return{n:k,mean:y,m2:w}}function n(b,k){const y=b.length;if(!y)return NaN;if(y===1)return b[0];const w=(y-1)*Math.min(1,Math.max(0,k)),O=Math.floor(w),M=Math.ceil(w);return O===M?b[O]:b[O]+(w-O)*(b[M]-b[O])}function c(b,k){if(!b.length)return NaN;const y=b.slice().sort();return n(y,k)}function g(b,k){const y=W(b);let w=0,O=0,M=0;for(let $=0;$<k.length;$++){const F=y(k[$]);if(F==null||F==="")continue;const C=String(F).toUpperCase();C==="PASS"?w++:C==="FAIL"?O++:C==="WARN"&&M++}return{pass:w+M,fail:O,warn:M,judged:w+M+O}}const A=Object.freeze({hhi:(b,k)=>l(b,k),entropy:(b,k)=>m(b,k),evenness:(b,k)=>e(b,k),top3Share:(b,k)=>d(b,k,3),top10Share:(b,k)=>d(b,k,10),gini:(b,k)=>f(b,k),trimmedMean:(b,k)=>G(h(b,k),.1),winsorizedMean:(b,k)=>S(h(b,k),.1),robustOutliers:(b,k)=>N(h(b,k),3.5),jarqueBera:(b,k)=>I(h(b,k)),variance:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>1?w/(y-1):null},varianceP:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>0?w/y:null},stddev:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>1?Math.sqrt(w/(y-1)):null},stddevP:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>0?Math.sqrt(w/y):null},median:(b,k)=>{const y=h(b,k);return y.length?c(y,.5):null},p25:(b,k)=>{const y=h(b,k);return y.length?c(y,.25):null},p75:(b,k)=>{const y=h(b,k);return y.length?c(y,.75):null},p90:(b,k)=>{const y=h(b,k);return y.length?c(y,.9):null},p95:(b,k)=>{const y=h(b,k);return y.length?c(y,.95):null},p99:(b,k)=>{const y=h(b,k);return y.length?c(y,.99):null},iqr:(b,k)=>{const y=h(b,k);if(!y.length)return null;const w=y.slice().sort();return n(w,.75)-n(w,.25)},mad:(b,k)=>{const y=h(b,k);if(!y.length)return null;const w=c(y,.5),O=new Float64Array(y.length);for(let M=0;M<y.length;M++)O[M]=Math.abs(y[M]-w);return c(O,.5)},range:(b,k)=>{const y=h(b,k);if(!y.length)return null;let w=1/0,O=-1/0;for(let M=0;M<y.length;M++)y[M]<w&&(w=y[M]),y[M]>O&&(O=y[M]);return O-w},distinct:(b,k)=>{const y=W(b),w=new Set;for(let O=0;O<k.length;O++){const M=y(k[O]);M==null||M===""||w.add(M instanceof Date?M.getTime():M)}return w.size},mode:(b,k)=>{const y=W(b),w=new Map;for(let $=0;$<k.length;$++){const F=y(k[$]);if(F==null||F==="")continue;const C=F instanceof Date?F.getTime():F;w.set(C,(w.get(C)||0)+1)}let O=null,M=1;for(const[$,F]of w)F>M&&(M=F,O=$);return O},skewness:(b,k)=>{const y=h(b,k),{n:w,mean:O,m2:M}=r(y);if(w<3||M<=0)return null;const $=Math.sqrt(M/(w-1));let F=0;for(let C=0;C<y.length;C++)F+=((y[C]-O)/$)**3;return w/((w-1)*(w-2))*F},kurtosis:(b,k)=>{const y=h(b,k),{n:w,mean:O,m2:M}=r(y);if(w<4||M<=0)return null;const $=Math.sqrt(M/(w-1));let F=0;for(let oe=0;oe<y.length;oe++)F+=((y[oe]-O)/$)**4;const C=w*(w+1)/((w-1)*(w-2)*(w-3)),ie=3*(w-1)**2/((w-2)*(w-3));return C*F-ie},geomean:(b,k)=>{const y=h(b,k);if(!y.length)return null;let w=0;for(let O=0;O<y.length;O++){if(y[O]<=0)return null;w+=Math.log(y[O])}return Math.exp(w/y.length)},harmean:(b,k)=>{const y=h(b,k);if(!y.length)return null;let w=0;for(let O=0;O<y.length;O++){if(y[O]===0)return null;w+=1/y[O]}return y.length/w},sumSquares:(b,k)=>{const y=h(b,k);let w=0;for(let O=0;O<y.length;O++)w+=y[O]*y[O];return w},passRate:(b,k)=>{const{pass:y,judged:w}=g(b,k);return w?y/w:null},failureCount:(b,k)=>g(b,k).fail}),P=Object.freeze({hhi:"Concentration (HHI)",entropy:"Entropy",evenness:"Evenness",top3Share:"Top 3 share",top10Share:"Top 10 share",gini:"Gini coefficient",trimmedMean:"Trimmed mean",winsorizedMean:"Winsorized mean",robustOutliers:"Outliers (robust)",jarqueBera:"Jarque–Bera",median:"Median",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function q(b,k,y){const w=W(b),O=W(k);let M=0,$=0;for(let F=0;F<y.length;F++){const C=y[F],ie=Number(w(C)),oe=Number(O(C));!Number.isFinite(ie)||!Number.isFinite(oe)||(M+=ie*oe,$+=oe)}return $===0?null:M/$}function L(b,k,y){const w=W(b);let O=null,M=y?-1/0:1/0;for(let $=0;$<k.length;$++){const F=k[$],C=Number(w(F));Number.isFinite(C)&&(y?C>M:C<M)&&(M=C,O=F)}return O}function v(b,k,y){const w=W(b),O=W(k);let M=0,$=0,F=0,C=0,ie=0,oe=0;for(let pe=0;pe<y.length;pe++){const ve=y[pe],Le=Number(w(ve)),we=Number(O(ve));!Number.isFinite(Le)||!Number.isFinite(we)||(M++,$+=Le,F+=we,C+=Le*Le,ie+=we*we,oe+=Le*we)}if(M<2)return null;const ke=M*oe-$*F,je=Math.sqrt((M*C-$*$)*(M*ie-F*F));if(je===0)return null;const Pe=ke/je;return Math.max(-1,Math.min(1,Pe))}function G(b,k=.1){const y=b.length;if(!y)return null;const w=Array.from(b).sort((F,C)=>F-C),O=Math.floor(y*Math.min(.49,Math.max(0,k))),M=w.slice(O,y-O);if(!M.length)return n(w,.5);let $=0;for(const F of M)$+=F;return $/M.length}function S(b,k=.1){const y=b.length;if(!y)return null;const w=Array.from(b).sort((C,ie)=>C-ie),O=Math.floor(y*Math.min(.49,Math.max(0,k))),M=w[O],$=w[y-1-O];let F=0;for(const C of w)F+=Math.min($,Math.max(M,C));return F/y}function N(b,k=3.5){if(!b.length)return null;const w=Array.from(b).sort((C,ie)=>C-ie),O=n(w,.5),M=w.map(C=>Math.abs(C-O)).sort((C,ie)=>C-ie),$=n(M,.5);if($===0)return null;let F=0;for(const C of w)Math.abs(.6745*(C-O)/$)>k&&F++;return F}function I(b){const k=b.length;if(k<8)return null;let y=0;for(const C of b)y+=C;y/=k;let w=0,O=0,M=0;for(const C of b){const ie=C-y;w+=ie*ie,O+=ie*ie*ie,M+=ie*ie*ie*ie}if(w/=k,O/=k,M/=k,w===0)return null;const $=O/w**1.5,F=M/(w*w)-3;return k/6*($*$+F*F/4)}function K(b,k,y){const w=[];let O=0;for(let C=0;C<b.length;C++){const ie=Number(b[C]),oe=Number(k[C]);!Number.isFinite(ie)||!Number.isFinite(oe)||oe<=0||(w.push([ie,oe]),O+=oe)}if(!w.length||O<=0)return null;if(w.sort((C,ie)=>C[0]-ie[0]),w.length===1)return w[0][0];const M=[];let $=0;for(const[,C]of w)M.push(($+C/2)/O),$+=C;const F=Math.max(0,Math.min(1,y));if(F<=M[0])return w[0][0];if(F>=M[M.length-1])return w[w.length-1][0];for(let C=1;C<M.length;C++){if(F>M[C])continue;const ie=M[C]-M[C-1],oe=ie>0?(F-M[C-1])/ie:0;return w[C-1][0]+(w[C][0]-w[C-1][0])*oe}return w[w.length-1][0]}function B(b,k,y){const w=W(b),O=W(k),M=new Float64Array(y.length),$=new Float64Array(y.length);let F=0;for(let C=0;C<y.length;C++){const ie=y[C],oe=Number(w(ie)),ke=Number(O(ie));!Number.isFinite(oe)||!Number.isFinite(ke)||(M[F]=oe,$[F]=ke,F++)}return{xs:M.subarray(0,F),ys:$.subarray(0,F),n:F}}function ee(b,k,y,w=!1){const{xs:O,ys:M,n:$}=B(b,k,y);if($<2)return null;let F=0,C=0;for(let oe=0;oe<$;oe++)F+=O[oe],C+=M[oe];F/=$,C/=$;let ie=0;for(let oe=0;oe<$;oe++)ie+=(O[oe]-F)*(M[oe]-C);return ie/(w?$:$-1)}function J(b,k,y){const{xs:w,ys:O,n:M}=B(b,k,y);if(M<2)return null;let $=0,F=0;for(let Le=0;Le<M;Le++)$+=w[Le],F+=O[Le];$/=M,F/=M;let C=0,ie=0,oe=0;for(let Le=0;Le<M;Le++){const we=w[Le]-$,De=O[Le]-F;C+=we*we,ie+=we*De,oe+=De*De}if(C===0)return null;const ke=ie/C,je=F-ke*$,Pe=oe===0?1:Math.max(0,Math.min(1,ie*ie/(C*oe))),pe=Math.max(0,oe-ke*ie),ve=M>2?Math.sqrt(pe/(M-2)/C):0;return{slope:ke,intercept:je,r2:Pe,stdError:ve,n:M}}const ue=new Set(["ols","wls","robust"]),de=new Set(["quantile"]),Oe=new Set(["ridge","lasso","elasticnet","mixed","gls"]),Ae=1.345;function Se(b,k,y){const{xtwx:w,xtwy:O}=T(b,k,y),M=se(w);if(!M)return null;const $=te(M,O),F=H(M),C=D(b,$),ie=k.map((oe,ke)=>oe-C[ke]);return{beta:$,cov:F,fitted:C,residuals:ie}}function D(b,k){return b.map(y=>y.reduce((w,O,M)=>w+O*k[M],0))}function x(b,k){const y=b.length,w=b.map(ie=>ie[k]),O=b.map(ie=>[1,...ie.filter((oe,ke)=>ke!==k)]),M=Se(O,w,null);if(!M)return 1;const $=w.reduce((ie,oe)=>ie+oe,0)/y;let F=0,C=0;for(let ie=0;ie<y;ie++)F+=M.residuals[ie]**2,C+=(w[ie]-$)**2;return C===0?1:Math.max(0,Math.min(1,1-F/C))}function fe(b){const k=[...b].sort((O,M)=>O-M),y=p(k),w=b.map(O=>Math.abs(O-y)).sort((O,M)=>O-M);return p(w)/.6745}function p(b){const k=b.length;if(!k)return 0;const y=Math.floor(k/2);return k%2?b[y]:(b[y-1]+b[y])/2}function Q(b,k,y={}){const w=y.method||"ols";if(Oe.has(w))throw new Error(`[lattice] regression method "${w}" is out of scope; use ols, wls or robust.`);if(de.has(w))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!ue.has(w))throw new Error(`[lattice] unknown regression method "${w}"; use ols, wls or robust.`);const O=Array.isArray(k)?k.length:0,M=O&&Array.isArray(b[0])?b[0].length:0,$=M+1;if(!(O>$))return null;for(let Te=0;Te<O;Te++){if(!Number.isFinite(k[Te])||!Array.isArray(b[Te])||b[Te].length!==M)return null;for(let Fe=0;Fe<M;Fe++)if(!Number.isFinite(b[Te][Fe]))return null}let F=null;if(w==="wls"){if(F=y.weights,!Array.isArray(F)||F.length!==O)return null;for(let Te=0;Te<O;Te++)if(!(F[Te]>0)||!Number.isFinite(F[Te]))return null}const C=b.map(Te=>[1,...Te]);let ie,oe=null;if(w==="robust"){if(ie=Se(C,k,null),!ie)return null;for(let Te=0;Te<50;Te++){const Fe=fe(ie.residuals);if(!(Fe>0))break;const Ue=ie.residuals.map(Ge=>{const xe=Math.abs(Ge/Fe);return xe<=Ae?1:Ae/xe}),qe=Se(C,k,Ue);if(!qe)return null;const Je=qe.beta.reduce((Ge,xe,it)=>Math.max(Ge,Math.abs(xe-ie.beta[it])),0);if(ie=qe,oe=Ue,Je<1e-10)break}}else if(ie=Se(C,k,F),!ie)return null;const ke=w==="robust"?oe:F,{beta:je,cov:Pe,fitted:pe,residuals:ve}=ie;let Le=0,we=0,De=0;for(let Te=0;Te<O;Te++){const Fe=ke?ke[Te]:1;Le+=Fe*ve[Te]**2,we+=Fe,De+=Fe*k[Te]}const $e=De/we;let Ke=0;for(let Te=0;Te<O;Te++){const Fe=ke?ke[Te]:1;Ke+=Fe*(k[Te]-$e)**2}const He=O-$,Qe=Le/He,Ve=Ke===0?1:Math.max(0,Math.min(1,1-Le/Ke)),ut=1-(1-Ve)*(O-1)/He,nt=Array.isArray(y.names)&&y.names.length===M?y.names:b[0].map((Te,Fe)=>`x${Fe+1}`),Ze=tt(y.confidence),rt=He>0?_(1-(1-Ze)/2,He):1/0,Lt=je.map((Te,Fe)=>{const Ue=Math.sqrt(Math.max(0,Qe*Pe[Fe][Fe])),qe=Ue>0?Te/Ue:Te===0?0:1/0,Je=Number.isFinite(qe)?2*(1-Z(Math.abs(qe),He)):0,Ge=Number.isFinite(rt)?rt*Ue:null;return{name:Fe===0?"(intercept)":nt[Fe-1],estimate:Te,stdError:Ue,t:qe,p:Math.max(0,Math.min(1,Je)),lower:Ge===null?null:Te-Ge,upper:Ge===null?null:Te+Ge}}),bt=new Array(O),yt=new Array(O);for(let Te=0;Te<O;Te++){const Fe=ke?ke[Te]:1,Ue=Math.max(0,Math.min(1,Fe*V(C[Te],Pe)));bt[Te]=Ue;const qe=(1-Ue)**2;yt[Te]=qe>0&&Qe>0?ve[Te]**2/($*Qe)*(Ue/qe):null}const Ft=b[0].map((Te,Fe)=>{if(M<2)return 1;const Ue=x(b,Fe);return Ue>=1?1/0:1/(1-Ue)});let pt=null;{const Te=ve.map(Ue=>Ue*Ue),Fe=Se(C,Te,null);if(Fe){const Ue=Te.reduce((et,Ct)=>et+Ct,0)/O;let qe=0,Je=0;for(let et=0;et<O;et++)qe+=Fe.residuals[et]**2,Je+=(Te[et]-Ue)**2;const Ge=Je===0?0:Math.max(0,Math.min(1,1-qe/Je)),xe=O*Ge,it=re(xe,M);pt={statistic:xe,df:M,p:it,heteroscedastic:it<.05}}}let wt=null;if(M===1){const Te=b.map((Fe,Ue)=>Ue).sort((Fe,Ue)=>b[Fe][0]-b[Ue][0]);wt={confidence:Ze,points:Te.map(Fe=>{const Ue=C[Fe],qe=Math.sqrt(Math.max(0,Qe*V(Ue,Pe)));return{x:b[Fe][0],yhat:pe[Fe],lower:pe[Fe]-rt*qe,upper:pe[Fe]+rt*qe}})}}return{method:w,coefficients:Lt,r2:Ve,adjR2:ut,n:O,df:He,sigma2:Qe,fitted:pe,residuals:ve,leverage:bt,cooksD:yt,vif:Ft,heteroscedasticity:pt,band:wt,weights:ke?[...ke]:null}}function X(b){const k=b.length,y=Array.from({length:k},(M,$)=>$).sort((M,$)=>b[M]-b[$]),w=new Float64Array(k);let O=0;for(;O<k;){let M=O;for(;M+1<k&&b[y[M+1]]===b[y[O]];)M++;const $=(O+M)/2+1;for(let F=O;F<=M;F++)w[y[F]]=$;O=M+1}return w}const ce=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function le(b){const k=[.01,.05,.1],y=[ce["1%"],ce["5%"],ce["10%"]];if(b<=y[0]){const M=(Math.log(k[1])-Math.log(k[0]))/(y[1]-y[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(k[0])+M*(b-y[0]))))}if(b>=y[2]){const M=(Math.log(k[2])-Math.log(k[1]))/(y[2]-y[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(k[2])+M*(b-y[2]))))}const w=b<y[1]?0:1,O=(b-y[w])/(y[w+1]-y[w]);return Math.exp(Math.log(k[w])+O*(Math.log(k[w+1])-Math.log(k[w])))}function ge(b,k,y,w){const O=y-w,M=w+3,$=new Array(O),F=new Array(O);let C=!0,ie=w;for(let pe=0;pe<O;pe++){const ve=w+pe,Le=new Float64Array(M);Le[0]=1,Le[1]=pe+1,Le[2]=b[ve];for(let we=1;we<=w;we++)Le[2+we]=k[ve-we];for(let we=1;we<M;we++)Number.isFinite(Le[we])||(ie=Math.min(ie,we-3));$[pe]=Le,F[pe]=k[ve],Number.isFinite(F[pe])||(C=!1)}if(!C)return 0;const{xtwx:oe,xtwy:ke}=T($,F,null);let je=0,Pe=1/0;for(let pe=0;pe<=ie;pe++){const ve=pe+3;if(!(O>ve))continue;const Le=new Array(ve);for(let Ve=0;Ve<ve;Ve++)Le[Ve]=oe[Ve].slice(0,ve);const we=se(Le);if(!we)continue;const De=te(we,ke.slice(0,ve));let $e=0;for(let Ve=0;Ve<O;Ve++){const ut=$[Ve];let nt=0;for(let Ze=0;Ze<ve;Ze++)nt+=ut[Ze]*De[Ze];$e+=(F[Ve]-nt)**2}const He=$e/(O-ve)*(O-ve);if(!(He>0))continue;const Qe=O*Math.log(He/O)+2*ve;Qe<Pe&&(Pe=Qe,je=pe)}return je}function Me(b,k={}){const y=[];for(let Pe=0;Pe<b.length;Pe++){const pe=Number(b[Pe]);Number.isFinite(pe)&&y.push(pe)}const w=y.length,O=w-1;if(w<8||O<6)return null;const M=new Array(O);for(let Pe=0;Pe<O;Pe++)M[Pe]=y[Pe+1]-y[Pe];let $=Number.isFinite(k.maxlag)?Math.floor(k.maxlag):Math.ceil(12*(w/100)**.25);$=Math.max(0,Math.min($,Math.floor((O-5)/2)));const F=(Pe,pe)=>{const ve=[],Le=[];for(let we=pe;we<O;we++){const De=[we-pe+1,y[we]];for(let $e=1;$e<=Pe;$e++)De.push(M[we-$e]);ve.push(De),Le.push(M[we])}return Q(ve,Le,{method:"ols"})},C=ge(y,M,O,$),ie=F(C,C);if(!ie||!ie.coefficients[2])return null;const oe=ie.coefficients[2].t,ke=le(oe),je=oe<ce["5%"];return{statistic:oe,usedLag:C,nobs:O-C,criticalValues:{...ce},pValue:ke,pApproximate:!0,stationary:je,verdict:je?"stationary":"non-stationary",regression:"ct"}}function be(b,k={}){const y=[];for(let je=0;je<b.length;je++){const Pe=Number(b[je]);Number.isFinite(Pe)&&y.push(Pe)}const w=y.length;if(w<3)return null;let O=Number.isFinite(k.maxlag)?Math.floor(k.maxlag):Math.min(10,w-1);O=Math.max(1,Math.min(O,w-1));let M=0;for(const je of y)M+=je;M/=w;const $=y.map(je=>je-M);let F=0;for(const je of $)F+=je*je;F/=w;const C=new Array(O+1).fill(0);C[0]=1;for(let je=1;je<=O;je++){let Pe=0;for(let pe=je;pe<w;pe++)Pe+=$[pe]*$[pe-je];C[je]=F>0?Pe/w/F:0}const ie=new Array(O+1).fill(0);ie[0]=1;let oe=[];for(let je=1;je<=O;je++){let Pe=C[je];for(let we=1;we<je;we++)Pe-=oe[we-1]*C[je-we];let pe=1;for(let we=1;we<je;we++)pe-=oe[we-1]*C[we];const ve=pe!==0?Pe/pe:0,Le=new Array(je);for(let we=1;we<je;we++)Le[we-1]=oe[we-1]-ve*oe[je-1-we];Le[je-1]=ve,ie[je]=ve,oe=Le}const ke=1.96/Math.sqrt(w);return{acf:C,pacf:ie,bounds:{upper:ke,lower:-ke},n:w,nlags:O,approximate:!0}}function ye(b,k,y){const{xs:w,ys:O,n:M}=B(b,k,y);if(M<2)return null;const $=X(w),F=X(O);let C=0,ie=0;for(let Pe=0;Pe<M;Pe++)C+=$[Pe],ie+=F[Pe];C/=M,ie/=M;let oe=0,ke=0,je=0;for(let Pe=0;Pe<M;Pe++){const pe=$[Pe]-C,ve=F[Pe]-ie;oe+=pe*ve,ke+=pe*pe,je+=ve*ve}return ke===0||je===0?null:Math.max(-1,Math.min(1,oe/Math.sqrt(ke*je)))}function Re(b,k,y){const{xs:w,ys:O,n:M}=B(b,k,y);if(M<2||M>j)return null;let $=0,F=0,C=0,ie=0;for(let je=0;je<M;je++)for(let Pe=je+1;Pe<M;Pe++){const pe=Math.sign(w[je]-w[Pe]),ve=Math.sign(O[je]-O[Pe]),Le=pe*ve;Le>0?$++:Le<0?F++:pe===0&&ve===0||(pe===0?C++:ie++)}const oe=$+F+ie,ke=$+F+C;return oe===0||ke===0?null:($-F)/Math.sqrt(oe*ke)}function Ne(b,k={}){const y=b.length;if(y<2)return null;const w=b[0],O=b[y-1],M=[];for(let we=1;we<y;we++){const De=b[we-1];De!==0&&M.push((b[we]-De)/Math.abs(De))}let $=null;if(M.length>1){let we=0;for(const $e of M)we+=$e;we/=M.length;let De=0;for(const $e of M)De+=($e-we)**2;$=Math.sqrt(De/(M.length-1))}const F=Number(k.periodsPerYear)>0?Number(k.periodsPerYear):null;let C=b[0],ie=0,oe=0,ke=0,je=0;for(let we=1;we<y;we++){if(b[we]>C){C=b[we],ie=we;continue}if(C<=0)continue;const De=(C-b[we])/C;De>oe&&(oe=De,ke=ie,je=we)}let Pe=null;if(y>2){let we=0;for(let Ke=0;Ke<y;Ke++)we+=b[Ke];we/=y;let De=0,$e=0;for(let Ke=0;Ke<y;Ke++){const He=b[Ke]-we;$e+=He*He,Ke>0&&(De+=He*(b[Ke-1]-we))}Pe=$e>0?De/$e:null}let pe=0,ve=0;for(const we of M)we>0?pe++:we<0&&ve++;let Le=null;if(w>0&&O>0){const we=(O/w)**(1/(y-1))-1;Le=F?(1+we)**F-1:we}return{n:y,first:w,last:O,change:O-w,changePercent:w===0?null:(O-w)/Math.abs(w)*100,volatility:$,annualisedVolatility:$!==null&&F?$*Math.sqrt(F):null,growth:Le,maxDrawdown:oe,maxDrawdownFrom:ke,maxDrawdownTo:je,autocorrelation:Pe,upDays:pe,downDays:ve}}const Ee=1.128,Be=3.267;function ze(b){const k=b.length;if(k<2)return null;const y=[];for(let O=1;O<k;O++)y.push(Math.abs(b[O]-b[O-1]));const w=y.reduce((O,M)=>O+M,0)/y.length;return{ranges:y,centre:w,upper:Be*w,lower:0}}function We(b){const k=b.length;if(k<2)return null;let y=0;for(let O=1;O<k;O++)y+=Math.abs(b[O]-b[O-1]);const w=y/(k-1);return{sigma:w/Ee,meanRange:w}}function Xe(b,k){const y=b.length;if(y<2||!k)return null;const w=Number.isFinite(Number(k.lower))?Number(k.lower):null,O=Number.isFinite(Number(k.upper))?Number(k.upper):null;if(w===null&&O===null)return null;let M=0;for(let pe=0;pe<y;pe++)M+=b[pe];M/=y;let $=0;for(let pe=0;pe<y;pe++)$+=(b[pe]-M)**2;const F=Math.sqrt($/(y-1)),C=We(b),ie=C?C.sigma:null,oe=pe=>{if(!pe||pe<=0)return{index:null,k:null};const Le=w!==null&&O!==null?(O-w)/(6*pe):null,we=O!==null?(O-M)/(3*pe):1/0,De=w!==null?(M-w)/(3*pe):1/0;return{index:Le,k:Math.min(we,De)}},ke=oe(ie),je=oe(F);let Pe=0;for(let pe=0;pe<y;pe++){if(w!==null&&b[pe]<w){Pe++;continue}O!==null&&b[pe]>O&&Pe++}return{n:y,mean:M,lower:w,upper:O,target:Number.isFinite(Number(k.target))?Number(k.target):null,sigmaWithin:ie,sigmaOverall:F,cp:ke.index,cpk:ke.k,pp:je.index,ppk:je.k,outOfSpec:Pe,defectRate:y?Pe/y:null}}function Ye(b){const k=b.length;if(k<2)return null;const y=We(b);if(!y||!(y.sigma>0))return null;let w=0;for(let O=0;O<k;O++)w+=b[O];return w/=k,{centre:w,sigma:y.sigma,upper:w+3*y.sigma,lower:w-3*y.sigma}}function Ie(b,k){if(!k||!(k.sigma>0))return[];const y=b.length,{centre:w,sigma:O}=k,M=F=>(b[F]-w)/O,$=[];for(let F=0;F<y;F++){if(Math.abs(M(F))>3&&$.push({index:F,rule:1,description:"beyond three sigma"}),F>=2)for(const C of[1,-1]){let ie=0;for(let oe=F-2;oe<=F;oe++)M(oe)*C>2&&ie++;if(ie>=2){$.push({index:F,rule:2,description:"two of three past two sigma"});break}}if(F>=4)for(const C of[1,-1]){let ie=0;for(let oe=F-4;oe<=F;oe++)M(oe)*C>1&&ie++;if(ie>=4){$.push({index:F,rule:3,description:"four of five past one sigma"});break}}if(F>=7)for(const C of[1,-1]){let ie=!0;for(let oe=F-7;oe<=F;oe++)if(M(oe)*C<=0){ie=!1;break}if(ie){$.push({index:F,rule:4,description:"eight in a row on one side"});break}}}return $}function ft(b,k){if(!k||!(k.sigma>0))return[];const y=b.length,{centre:w,sigma:O}=k,M=C=>(b[C]-w)/O,$=(C,ie,oe,ke)=>{for(const je of[1,-1]){let Pe=0;for(let pe=C;pe<=ie;pe++)M(pe)*je>oe&&Pe++;if(Pe>=ke)return!0}return!1},F=[];for(let C=0;C<y;C++){if(Math.abs(M(C))>3&&F.push({index:C,rule:1,description:"beyond three sigma"}),C>=8)for(const ie of[1,-1]){let oe=!0;for(let ke=C-8;ke<=C;ke++)if(M(ke)*ie<=0){oe=!1;break}if(oe){F.push({index:C,rule:2,description:"nine in a row on one side"});break}}if(C>=5)for(const ie of[1,-1]){let oe=!0;for(let ke=C-4;ke<=C;ke++)if((b[ke]-b[ke-1])*ie<=0){oe=!1;break}if(oe){F.push({index:C,rule:3,description:ie>0?"six rising":"six falling"});break}}if(C>=13){let ie=!0;for(let oe=C-12;oe<=C;oe++){const ke=b[oe]-b[oe-1],je=b[oe+1<=C?oe+1:oe]-b[oe];if(oe+1>C)break;if(ke===0||je===0||ke>0==je>0){ie=!1;break}}ie&&F.push({index:C,rule:4,description:"fourteen alternating"})}if(C>=2&&$(C-2,C,2,2)&&F.push({index:C,rule:5,description:"two of three past two sigma"}),C>=4&&$(C-4,C,1,4)&&F.push({index:C,rule:6,description:"four of five past one sigma"}),C>=14){let ie=!0;for(let oe=C-14;oe<=C;oe++)if(Math.abs(M(oe))>=1){ie=!1;break}ie&&F.push({index:C,rule:7,description:"fifteen within one sigma"})}if(C>=7){let ie=!0;for(let oe=C-7;oe<=C;oe++)if(Math.abs(M(oe))<=1){ie=!1;break}ie&&F.push({index:C,rule:8,description:"eight beyond one sigma"})}}return F}const jt=Object.freeze(["westernElectric","nelson"]);function At(b,k,y="westernElectric"){return String(y)==="nelson"?ft(b,k):Ie(b,k)}function Mt(b,k,y){let w=0;for(let O=0;O<b.length;O++)(b[O]<k||b[O]>y)&&w++;return w}function Pt(b,k,y,w=20){const O=b.length;if(!O)return[];const M=b[0],$=b[O-1];if($===M)return[{from:M,to:$,count:O}];const F=y-k,C=1.5*F;let ie=F>0?Math.max(M,k-C):M,oe=F>0?Math.min($,y+C):$;oe>ie||(ie=M,oe=$);const ke=F>0?2*F/Math.cbrt(O):(oe-ie)/(Math.ceil(Math.log2(O))+1),je=ke>0?Math.min(w,Math.max(1,Math.ceil((oe-ie)/ke))):1,Pe=(oe-ie)/je,pe=[];for(let ve=0;ve<je;ve++)pe.push({from:ie+ve*Pe,to:ie+(ve+1)*Pe,count:0});for(let ve=0;ve<O;ve++){const Le=Math.min(je-1,Math.max(0,Math.floor((b[ve]-ie)/Pe)));pe[Le].count++}return pe[0].from=M,pe[je-1].to=$,pe}const _e=.95;function tt(b){const k=Number(b);return Number.isFinite(k)&&k>0&&k<1?k:_e}function Nt(b,k=_e){const y=b.length;if(y<2)return null;let w=0;for(let oe=0;oe<y;oe++)w+=b[oe];const O=w/y;let M=0;for(let oe=0;oe<y;oe++){const ke=b[oe]-O;M+=ke*ke}const $=Math.sqrt(M/(y-1)),F=tt(k),ie=_(1-(1-F)/2,y-1)*$/Math.sqrt(y);return{mean:O,lower:O-ie,upper:O+ie,margin:ie,n:y,confidence:F}}function St(b,k,y=_e){const w=Number(b),O=Number(k);if(!(O>0)||!(w>=0)||w>O)return null;const M=tt(y),$=E(1-(1-M)/2),F=w/O,C=$*$,ie=1+C/O,oe=(F+C/(2*O))/ie,ke=$/ie*Math.sqrt(F*(1-F)/O+C/(4*O*O));return{proportion:F,lower:Math.max(0,oe-ke),upper:Math.min(1,oe+ke),n:O,confidence:M}}function vt(b,k=_e){if(!b||!(b.n>2)||!Number.isFinite(b.stdError))return null;const y=tt(k),O=_(1-(1-y)/2,b.n-2)*b.stdError;return{slope:b.slope,lower:b.slope-O,upper:b.slope+O,margin:O,confidence:y}}function Tt(b,k,y=_e){const w=Number(b),O=Number(k);if(!Number.isFinite(w)||!(O>1))return null;const M=tt(y),F=E(1-(1-M)/2)*Math.sqrt(1/(9*O)+w*w/(2*(O-1)));return{index:w,lower:w-F,upper:w+F,margin:F,n:O,confidence:M}}function ht(b,k){return!b||!(b.sd>0)||!Number.isFinite(k)||!Number.isFinite(b.mean)?null:(k-b.mean)/b.sd}function dt(b){return Number.isFinite(b)?Math.min(1,Math.max(0,2*z(Math.abs(b)/2)-1)):0}function ot(b,k){const y=new Map,w=W(b);let O=0;for(let M=0;M<k.length;M++){const $=w(k[M]);if($==null||$===""||typeof $=="number"&&Number.isNaN($))continue;const F=$ instanceof Date?$.getTime():typeof $=="object"?String($):$;y.set(F,(y.get(F)||0)+1),O++}return{map:y,total:O}}function mt(b,k,y,w){if(!(k>0)||!(w>0))return null;let O=0;const M=new Set(b.keys());for(const $ of y.keys())M.add($);for(const $ of M){const F=(b.get($)||0)/k,C=(y.get($)||0)/w;O+=Math.abs(F-C)}return O/2}const st=10;function Et(b,k,y){if(y&&y.numeric){const F=h(b,k),{n:C,mean:ie}=r(F),oe=C>0?ht({mean:y.mean,sd:y.sd},ie):null;return{measure:"standardizedMeanDifference",magnitude:oe,distance:oe===null?0:dt(oe),direction:oe===null?0:Math.sign(oe),subsetN:C,populationN:y.n||0,reliable:C>=st}}const{map:O,total:M}=ot(b,k),$=mt(O,M,y.map,y.total);return{measure:"categoricalTotalVariation",magnitude:$,distance:$===null?0:$,direction:0,subsetN:M,populationN:y.total||0,reliable:M>=st}}function gt(b,k){if(b&&(b.kind==="float64"||b.kind==="int32"))return!0;const y=W(b);let w=0,O=0;for(let M=0;M<k.length&&w<200;M++){const $=y(k[M]);if($==null||$==="")continue;if($ instanceof Date)return!1;w++;const F=typeof $=="number"?$:Number($);Number.isFinite(F)&&O++}return w===0?!1:O/w>=.9}function Rt(b,k){if(gt(b,k)){const O=h(b,k),{n:M,mean:$,m2:F}=r(O);return{numeric:!0,mean:$,sd:M>0?Math.sqrt(F/M):0,n:M}}const{map:y,total:w}=ot(b,k);return{numeric:!1,map:y,total:w}}}),Ce("packages/core/src/compute/total.js",function(o,me){"use strict";Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"aggregatesFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"aggregateAllowed",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return f}});const ae=me("packages/core/src/internal/util.js"),he=ae.isFunction,W=ae.warnOnce,U=me("packages/core/src/compute/handle.js"),_=U.presenceReader,Z=U.valueComparator,E=U.valueReader,z=me("packages/core/src/compute/statistics.js"),re=z.STAT_FNS,Y=z.STAT_LABELS;function se(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function te(r,n){const c=n.length;let g=0;if(se(r)){const P=r.values,q=_(r);if(!q){for(let L=0;L<c;L++){const v=P[n[L]];Number.isNaN(v)||(g+=v)}return g}for(let L=0;L<c;L++){const v=n[L];if(q(v)===1){const G=P[v];Number.isNaN(G)||(g+=G)}}return g}const A=E(r);for(let P=0;P<c;P++){const q=s(A(n[P]));q!==null&&(g+=q)}return g}te.kernel=!0;function H(r,n){const c=n.length;let g=0;if(se(r)){const P=r.values,q=_(r);if(!q){for(let L=0;L<c;L++)Number.isNaN(P[n[L]])||g++;return g}for(let L=0;L<c;L++){const v=n[L];q(v)===1&&!Number.isNaN(P[v])&&g++}return g}const A=E(r);for(let P=0;P<c;P++){const q=A(n[P]);q!=null&&!(typeof q=="number"&&Number.isNaN(q))&&g++}return g}H.kernel=!0;function T(r,n){return n.length}T.kernel=!0;function V(r,n){const c=H(r,n);return c===0?null:te(r,n)/c}V.kernel=!0;function ne(r,n,c,g){const A=n.length;if(se(r)){const v=r.values,G=_(r);let S=null;if(!G){for(let N=0;N<A;N++){const I=v[n[N]];Number.isNaN(I)||(S===null||(c<0?I<S:I>S))&&(S=I)}return S}for(let N=0;N<A;N++){const I=n[N];if(G(I)===0)continue;const K=v[I];Number.isNaN(K)||(S===null||(c<0?K<S:K>S))&&(S=K)}return S}const P=E(r),q=Z(g);let L=null;for(let v=0;v<A;v++){const G=P(n[v]);G==null||typeof G=="number"&&Number.isNaN(G)||(L===null||(c<0?q(G,L)<0:q(G,L)>0))&&(L=G)}return L}function R(r,n,c){return ne(r,n,-1,c&&c.locale)}R.kernel=!0;function j(r,n,c){return ne(r,n,1,c&&c.locale)}j.kernel=!0;function i(r,n){return n.length===0?null:E(r)(n[0])}i.kernel=!0;function a(r,n){return n.length===0?null:E(r)(n[n.length-1])}a.kernel=!0;function s(r){if(typeof r=="number")return Number.isNaN(r)?null:r;if(r==null||r===""||typeof r=="boolean")return null;if(r instanceof Date)return r.getTime();const n=Number(r);return Number.isNaN(n)?null:n}const h={sum:te,min:R,max:j,avg:V,count:T,first:i,last:a,countValues:H,...re},u=Object.freeze({...Y,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function t(r){return r?typeof r=="string"?u[r]||r:"Total":""}const l=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function m(r){const n=r&&r.dataType&&r.dataType.totals&&r.dataType.totals.supported;if(Array.isArray(n))return n.slice();const c=l.filter(g=>g in h);for(const g of Object.keys(h))c.includes(g)||c.push(g);return c}function e(r,n){return typeof n!="string"?!0:m(r).includes(n)}function d(r,n){const c=E(r),g=[];for(let A=0;A<n.length;A++){const P=c(n[A]);P!=null&&g.push(P)}return g}function f(r,n,c,g){const A=n||[];if(typeof c=="string"){const P=h[c];return P?P(r,A,g):(W(`total:${c}`,`unknown total function "${c}"; register it in config.totalFns`),null)}return he(c)?c.kernel===!0?c(r,A,g):c(d(r,A),g||{}):null}}),Ce("packages/core/src/compute/pivot.js",function(o,me){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return j}});const he=me("packages/core/src/internal/util.js").warnOnce,U=me("packages/core/src/compute/handle.js").valueComparator,Z=me("packages/core/src/compute/group.js").packKeys,z=me("packages/core/src/compute/total.js").total,re="|",Y="/",se=2e3;function te(s,h,u){return`${s}${re}${h}${re}${u}`}function H(s,h){let u="";for(let t=0;t<s.length;t++){const l=s[t];u+=(t===0?"":h)+(l==null?"":String(l))}return u}function T(s,h,u={}){const t=u.separator||Y,l=h.length,{keyOf:m,readers:e}=Z(s,h,0),d=new Map,f=[],r=[];for(let L=0;L<l;L++){const v=h[L],G=m(v);if(d.has(G))continue;d.set(G,f.length),r.push(G);const S=new Array(e.length);for(let N=0;N<e.length;N++)S[N]=e[N](v);f.push(S)}const n=U(u.locale),c=f.map((L,v)=>v);c.sort((L,v)=>{const G=f[L],S=f[v];for(let N=0;N<G.length;N++){const I=V(G[N],S[N],n);if(I!==0)return I}return L-v});const g=new Array(c.length),A=new Array(c.length),P=new Map;for(let L=0;L<c.length;L++){const v=c[L];g[L]=f[v],A[L]=H(f[v],t),P.set(r[v],L)}return{keys:g,paths:A,idOf:L=>{const v=P.get(m(L));return v===void 0?-1:v}}}function V(s,h,u){const t=s==null,l=h==null;return t||l?t&&l?0:t?1:-1:u(s,h)}function ne(s){const h=s.values||s.totals||[];if(h.length&&typeof h[0]=="object"&&h[0]!==null)return h.filter(m=>m&&m.handle);const u=typeof s.handle=="function"?s.handle:null;if(!u)return h.length&&he("pivot:handles","pivot was given total column ids but no handle(colId) resolver, so no cell values were reduced. Pass values: [{ colId, handle, fn }] or opts.handle."),[];const t=typeof s.totalOf=="function"?s.totalOf:null,l=[];for(const m of h){const e=u(m);e&&l.push({colId:m,handle:e,fn:t?t(m):"sum"})}return l}function R(s,h,u){if(Array.isArray(s)){const t=u||{};return{...t,pivotHandles:s,order:h||null,groups:t.groups||null}}return s||{}}function j(s,h,u){const t=R(s,h,u),l=t.separator||Y,m=ne(t),e=t.maxColumns===void 0?se:t.maxColumns,d=t.groups&&t.groups.buckets?t.groups:null,f=d?d.buckets:[t.order||new Uint32Array(0)],r=t.groupPaths||(d?d.keys.map(G=>H(G,l)):[""]),n=a(f),{keys:c,paths:g,idOf:A}=T(t.pivotHandles||[],n,t),P=g.length*Math.max(1,m.length),q=i(g,m,l);if(e&&P>e){const G=new Map;return{keys:c,paths:g,fields:q,groupPaths:r,columns:P,values:G,cells:G,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${P} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:P,maxColumns:e}}}const L=new Map,v=g.length;for(let G=0;G<f.length;G++){const S=f[G],N=r[G]===void 0?"":r[G],I=S.length;if(I===0)continue;const K=new Int32Array(I),B=new Uint32Array(v+1);for(let ue=0;ue<I;ue++){const de=A(S[ue]);K[ue]=de,de>=0&&B[de+1]++}for(let ue=0;ue<v;ue++)B[ue+1]+=B[ue];const ee=new Uint32Array(I),J=B.slice(0,v);for(let ue=0;ue<I;ue++){const de=K[ue];de>=0&&(ee[J[de]++]=S[ue])}for(let ue=0;ue<v;ue++){const de=B[ue],Oe=B[ue+1];if(Oe===de)continue;const Ae=ee.subarray(de,Oe);for(let Se=0;Se<m.length;Se++){const D=m[Se],x=z(D.handle,Ae,D.fn,t.totalContext||{locale:t.locale});L.set(te(N,g[ue],D.colId),x)}}}return{keys:c,paths:g,fields:q,groupPaths:r,columns:P,values:L,cells:L,error:null}}function i(s,h,u){if(h.length===0)return s.slice();const t=[];for(const l of s)for(const m of h)t.push(`${l}${u}${m.colId}`);return t}function a(s){if(s.length===1)return s[0]||new Uint32Array(0);let h=0;for(const l of s)h+=l?l.length:0;const u=new Uint32Array(h);let t=0;for(const l of s)!l||l.length===0||(u.set(l,t),t+=l.length);return u}}),Ce("packages/core/src/compute/pivotmatrix.js",function(o,me){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return j}});const he=me("packages/core/src/compute/handle.js").valueComparator,U=me("packages/core/src/compute/total.js").total,Z=me("packages/core/src/compute/group.js").packKeys,E=me("packages/core/src/compute/pivot.js"),z=E.joinPath,re=E.DEFAULT_PATH_SEPARATOR,Y=E.DEFAULT_MAX_COLUMNS,se="";function te(i,a,s={}){const h=s.separator||re,u=i||[],t=a instanceof Uint32Array?a:Uint32Array.from(a||[]),l=t.length;if(u.length===0)return{tuples:[[]],paths:[se],buckets:[t]};const{keyOf:m,readers:e}=Z(u,t,0),d=new Map,f=[],r=[],n=[];for(let L=0;L<l;L++){const v=t[L],G=m(v);let S=d.get(G);if(S===void 0){S=f.length,d.set(G,S),r.push(G);const N=new Array(e.length);for(let I=0;I<e.length;I++)N[I]=e[I](v);f.push(N),n.push([])}n[S].push(v)}const c=he(s.locale),g=f.map((L,v)=>v);g.sort((L,v)=>{const G=f[L],S=f[v];for(let N=0;N<G.length;N++){const I=H(G[N],S[N],c);if(I!==0)return I}return L-v});const A=new Array(g.length),P=new Array(g.length),q=new Array(g.length);for(let L=0;L<g.length;L++){const v=g[L];A[L]=f[v],P[L]=z(f[v],h),q[L]=Uint32Array.from(n[v])}return{tuples:A,paths:P,buckets:q}}function H(i,a,s){const h=i==null,u=a==null;return h||u?h&&u?0:h?1:-1:s(i,a)}function T(i,a,s){const h=[];for(let u=0;u<i.length;u++)s.has(i[u])&&h.push(i[u]);return Uint32Array.from(h)}function V(i,a,s,h){return{value:a.length?U(i,a,s,h):null,leaves:a,count:a.length}}function ne(i){const a=i&&i.opts||{},s=a.separator||re,h=a.totalContext||{locale:a.locale},u=(i.measures||[]).filter(P=>P&&P.handle),t=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),l=te(i.rowHandles||[],t,{...a,separator:s}),m=te(i.columnHandles||[],t,{...a,separator:s}),e=a.maxColumns===void 0?Y:a.maxColumns,d=m.paths.length*Math.max(1,u.length),f=new Map;if(e&&d>e)return{rowAxis:l,columnAxis:m,measures:u.map(P=>({colId:P.colId,fn:P.fn})),body:f,rowMargin:f,columnMargin:f,grand:f,columns:d,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${d} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:d,maxColumns:e}};const r=new Map,n=new Map,c=new Map,g=new Map,A=m.buckets.map(P=>new Set(P));for(let P=0;P<m.paths.length;P++){const q=m.buckets[P],L=m.paths[P];for(const v of u)c.set(j(L,v.colId),V(v.handle,q,v.fn,h))}for(let P=0;P<l.paths.length;P++){const q=l.buckets[P],L=l.paths[P];for(const v of u)n.set(j(L,v.colId),V(v.handle,q,v.fn,h));for(let v=0;v<m.paths.length;v++){const G=T(q,m.buckets[v],A[v]);if(G.length===0)continue;const S=m.paths[v];for(const N of u)r.set(R(L,S,N.colId),V(N.handle,G,N.fn,h))}}for(const P of u)g.set(P.colId,V(P.handle,t,P.fn,h));return{rowAxis:l,columnAxis:m,measures:u.map(P=>({colId:P.colId,fn:P.fn})),body:r,rowMargin:n,columnMargin:c,grand:g,columns:d,error:null}}function R(i,a,s){return`${i}\\0${a}\\0${s}`}function j(i,a){return`${i}\\0${a}`}}),Ce("packages/core/src/compute/reference.js",function(o,me){"use strict";Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ne}});const he=me("packages/core/src/internal/util.js").getPath,W=me("packages/core/src/compute/handle.js"),U=W.isMissing,_=W.valueComparator,E=me("packages/core/src/compute/filter.js").testValue,z="",re="\\0";function Y(i,a){const s=a.includes(".")?he(i,a):i?.[a];return s===void 0?null:s}function se(i,a,s={}){const h=a||[];let u=i.map((t,l)=>l);if(h.length===0)return u;for(let t=h.length-1;t>=0;t--)u=te(i,u,h[t],s);return u}function te(i,a,s,h){const u=s.locale!==void 0?s.locale:h.locale,t=_(u),l=s.descending!==void 0?!!s.descending:s.dir==="desc",m=[],e=[];for(const r of a){const n=Y(i[r],s.col);U(n)?e.push(r):m.push(r)}const d=new Map;for(let r=0;r<m.length;r++)d.set(m[r],r);const f=(r,n)=>{const c=Y(i[r],s.col),g=Y(i[n],s.col);let A;return typeof s.compare=="function"?(A=s.compare(c,g,i[r],i[n],l),l&&(A=-A)):A=l?t(g,c):t(c,g),A!==0?A:d.get(r)-d.get(n)};return m.sort(f),s.nullsFirst?e.concat(m):m.concat(e)}function H(i,a,s={}){const h=[];for(let u=0;u<i.length;u++)T(i[u],a,s,u)&&h.push(u);return h}function T(i,a,s,h){if(!a)return!0;if(Array.isArray(a.conditions)){const u=a.conditions.filter(l=>l!=null);if(u.length===0)return!0;if(a.op==="or")return u.some(l=>T(i,l,s,h));const t=u.every(l=>T(i,l,s,h));return a.op==="not"?!t:t}return a.col===void 0&&typeof s.custom=="function"?!!s.custom(a,i,h):E(Y(i,a.col),a,s.locale)}function V(i,a,s,h){const u=s||i.map((e,d)=>d),t=new Map,l=[],m=[];for(const e of u){const d=a.map((n,c)=>{const g=Y(i[e],n);return h&&h[c]?h[c](g):g}),f=d.map(n=>n==null?re:String(n)).join(z);let r=t.get(f);r===void 0&&(r=l.length,t.set(f,r),l.push(d),m.push([])),m[r].push(e)}return{keys:l,buckets:m}}function ne(i,a,s={}){const h=_(s.locale),u=i.filter(l=>!U(l)),t=u.map(R).filter(l=>l!==null);switch(a){case"count":return i.length;case"countValues":return u.length;case"sum":return t.reduce((l,m)=>l+m,0);case"avg":return u.length===0?null:t.reduce((l,m)=>l+m,0)/u.length;case"min":return u.length===0?null:u.reduce((l,m)=>h(m,l)<0?m:l);case"max":return u.length===0?null:u.reduce((l,m)=>h(m,l)>0?m:l);case"first":return i.length===0?null:j(i[0]);case"last":return i.length===0?null:j(i[i.length-1]);default:return null}}function R(i){if(typeof i=="number")return Number.isNaN(i)?null:i;if(i==null||i===""||typeof i=="boolean")return null;if(i instanceof Date)return i.getTime();const a=Number(i);return Number.isNaN(a)?null:a}function j(i){return i===void 0?null:i}}),Ce("packages/core/src/compute/windowed.js",function(o,me){"use strict";Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return Z}});const he=me("packages/core/src/compute/sketch.js").Welford;class W{#t;#e;#n=[];#r;#i;constructor(z,re=0,Y=Date.now){if(z!=="count"&&z!=="time"&&z!=="session")throw new RangeError(`unknown window kind: ${z}`);if((z==="count"||z==="time")&&!(re>0))throw new RangeError(`a ${z} window needs a positive span`);this.#t=z,this.#e=Math.floor(re),this.#r=Y,this.#i=Y()}get size(){return this.#n.length}push(z,re=this.#r()){Number.isFinite(z)&&(this.#n.push({t:re,v:z}),this.#s(re))}#s(z){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const re=z-this.#e;for(;this.#n.length&&this.#n[0].t<re;)this.#n.shift()}}spec(){const z=this.#t==="session"?this.#r()-this.#i:this.#e;return{kind:this.#t,span:z,size:this.#n.length}}values(){return this.#n.map(z=>z.v)}aggregate(){const z=this.spec();if(!this.#n.length)return{over:z,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const re=new he;let Y=0,se=1/0,te=-1/0;for(const{v:H}of this.#n)Y+=H,H<se&&(se=H),H>te&&(te=H),re.add(H);return{over:z,count:this.#n.length,sum:Y,mean:re.mean(),min:se,max:te,variance:re.variance(),stddev:re.stddev()}}reduce(z){const re=this.aggregate(),Y={sum:re.sum,avg:re.mean,mean:re.mean,min:re.min,max:re.max,count:re.count,variance:re.variance,stddev:re.stddev};if(!(z in Y))throw new RangeError(`unknown windowed aggregate: ${z}`);return{value:Y[z],over:re.over}}}const U=Object.freeze(["count","time","session"]);function _(E,z=Date.now){const re=E.kind==="time"&&E.minutes!=null?E.minutes*6e4:E.span??0;return new W(E.kind,re,z)}const Z={Window:W,WINDOW_KINDS:U,openWindow:_}}),Ce("packages/core/src/compute/anomaly.js",function(o,me){"use strict";Object.defineProperty(o,"MAD_SCALE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return h}});const he=me("packages/core/src/compute/statistics.js").quantileSorted,U=me("packages/core/src/compute/special.js").logGamma,_=.6745,Z=3.5,E=1.5,z=.975,re=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function Y(u){if(!u.length)return null;const l=Array.from(u,Number).sort((f,r)=>f-r),m=he(l,.5),e=l.map(f=>Math.abs(f-m)).sort((f,r)=>f-r),d=he(e,.5);return{median:m,mad:d}}function se(u,t={}){const l=Number.isFinite(t.threshold)?t.threshold:Z,m=u.length,e=new Array(m).fill(null),d=new Array(m).fill(!1),f=[];for(let c=0;c<m;c++){const g=Number(u[c]);Number.isFinite(g)&&f.push(g)}if(!f.length)return{median:null,mad:null,threshold:l,scores:e,flags:d,flagged:0};const r=Y(f);if(r.mad===0)return{median:r.median,mad:0,threshold:l,scores:e,flags:d,flagged:0};let n=0;for(let c=0;c<m;c++){const g=Number(u[c]);if(!Number.isFinite(g))continue;const A=_*(g-r.median)/r.mad;e[c]=A,Math.abs(A)>l&&(d[c]=!0,n++)}return{median:r.median,mad:r.mad,threshold:l,scores:e,flags:d,flagged:n}}function te(u,t={}){const l=Number.isFinite(t.k)?t.k:E,m=[];for(let n=0;n<u.length;n++){const c=Number(u[n]);Number.isFinite(c)&&m.push(c)}if(!m.length)return null;const e=m.sort((n,c)=>n-c),d=he(e,.25),f=he(e,.75),r=f-d;return{q1:d,q3:f,iqr:r,lower:d-l*r,upper:f+l*r,k:l}}function H(u,t){if(t<=0)return 0;const l=U(u);if(t<u+1){let c=u,g=1/u,A=g;for(let P=0;P<1e3&&(c+=1,A*=t/c,g+=A,!(Math.abs(A)<Math.abs(g)*1e-15));P++);return g*Math.exp(-t+u*Math.log(t)-l)}const m=1e-300;let e=t+1-u,d=1/m,f=1/e,r=f;for(let c=1;c<1e3;c++){const g=-c*(c-u);e+=2,f=g*f+e,Math.abs(f)<m&&(f=m),d=e+g/d,Math.abs(d)<m&&(d=m),f=1/f;const A=f*d;if(r*=A,Math.abs(A-1)<1e-15)break}return 1-Math.exp(-t+u*Math.log(t)-l)*r}function T(u,t){return u<=0?0:H(t/2,u/2)}function V(u,t=z){if(!(t>0)||!(t<1))return NaN;let l=0,m=Math.max(1,u);for(;T(m,u)<t;)m*=2;for(let e=0;e<200;e++){const d=(l+m)/2;if(T(d,u)<t?l=d:m=d,m-l<1e-10)break}return(l+m)/2}function ne(u){const t=u.length,l=u.map((m,e)=>{const d=m.slice();for(let f=0;f<t;f++)d.push(e===f?1:0);return d});for(let m=0;m<t;m++){let e=m;for(let f=m+1;f<t;f++)Math.abs(l[f][m])>Math.abs(l[e][m])&&(e=f);if(Math.abs(l[e][m])<1e-12)return null;if(e!==m){const f=l[e];l[e]=l[m],l[m]=f}const d=l[m][m];for(let f=0;f<2*t;f++)l[m][f]/=d;for(let f=0;f<t;f++){if(f===m)continue;const r=l[f][m];if(r!==0)for(let n=0;n<2*t;n++)l[f][n]-=r*l[m][n]}}return l.map(m=>m.slice(t))}function R(u,t){const l=u.length,m=new Array(t).fill(0);for(const f of u)for(let r=0;r<t;r++)m[r]+=f[r];for(let f=0;f<t;f++)m[f]/=l;const e=Array.from({length:t},()=>new Array(t).fill(0));for(const f of u)for(let r=0;r<t;r++){const n=f[r]-m[r];for(let c=r;c<t;c++)e[r][c]+=n*(f[c]-m[c])}const d=l>1?l-1:1;for(let f=0;f<t;f++)for(let r=f;r<t;r++)e[f][r]/=d,e[r][f]=e[f][r];return{mean:m,cov:e}}function j(u,t={}){const l=Number.isFinite(t.p)?t.p:z,m=Number.isFinite(t.ridge)?t.ridge:1e-6,e=u.length;if(!e)return null;const d=u[0].length;if(!d)return null;const f=new Array(e).fill(null),r=new Array(e).fill(null),n=new Array(e).fill(!1),c=[],g=[];for(let N=0;N<e;N++){const I=u[N];let K=I.length===d;const B=new Array(d);for(let ee=0;K&&ee<d;ee++){const J=Number(I[ee]);Number.isFinite(J)?B[ee]=J:K=!1}K&&(c.push(N),g.push(B))}const A=d,P=V(A,l);if(g.length<=d)return{center:[],df:A,cutoff:P,singular:!0,used:g.length,distances:f,squared:r,flags:n,flagged:0};const{mean:q,cov:L}=R(g,d);let v=ne(L),G=!1;if(!v){G=!0;let N=0;for(let B=0;B<d;B++)N+=L[B][B];const I=N/d*m||m,K=L.map((B,ee)=>B.map((J,ue)=>ee===ue?J+I:J));if(v=ne(K),!v)return{center:q,df:A,cutoff:P,singular:!0,used:g.length,distances:f,squared:r,flags:n,flagged:0}}let S=0;for(let N=0;N<g.length;N++){const I=g[N],K=new Array(d);for(let J=0;J<d;J++)K[J]=I[J]-q[J];let B=0;for(let J=0;J<d;J++){let ue=0;for(let de=0;de<d;de++)ue+=v[J][de]*K[de];B+=K[J]*ue}B<0&&(B=0);const ee=c[N];r[ee]=B,f[ee]=Math.sqrt(B),B>P&&(n[ee]=!0,S++)}return{center:q,df:A,cutoff:P,singular:G,used:g.length,distances:f,squared:r,flags:n,flagged:S}}const i=20,a=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function s(u,t={}){const l=t.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",m=Number.isFinite(t.windowLen)&&t.windowLen>=1?Math.floor(t.windowLen):i,e=Number.isFinite(t.threshold)?t.threshold:Z,d=Number.isFinite(t.k)?t.k:E,f=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):m,r=u.length,n=new Array(r).fill(null),c=new Array(r).fill(!1);let g=0;for(let A=0;A<r;A++){const P=Number(u[A]);if(!Number.isFinite(P))continue;const q=Math.max(0,A-m+1),L=[];for(let v=q;v<=A;v++){const G=Number(u[v]);Number.isFinite(G)&&L.push(G)}if(!(L.length<f))if(l==="rollingIqr"){const v=te(L,{k:d});if(!v)continue;(P<v.lower||P>v.upper)&&(c[A]=!0,g++)}else{const v=Y(L);if(!v||v.mad===0)continue;const G=_*(P-v.median)/v.mad;n[A]=G,Math.abs(G)>e&&(c[A]=!0,g++)}}return{method:l,windowLen:m,minPeriods:f,threshold:e,k:d,scores:n,flags:c,flagged:g}}function h(u={}){const t=u||{},l=t.field;if(typeof l!="string"||!l)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const m=t.method||"modifiedZScore";if(!(re.includes(m)||a.includes(m))||m==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method \'${m}\'`);const d=typeof t.orderBy=="string"?t.orderBy:null,f=t.latest===!0,r=a.includes(m),n=c=>Number(c==null?NaN:c[l]);return c=>{const g=Array.isArray(c)?c.slice():[...c];d&&g.sort((v,G)=>{const S=v?.[d],N=G?.[d];return S===N?0:S==null?-1:N==null?1:S<N?-1:1});const A=g.map(n);let P,q;if(r)({flags:P,scores:q}=s(A,{method:m,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(m==="iqr"){const v=te(A,{k:t.k});P=A.map(G=>v?Number.isFinite(G)&&(G<v.lower||G>v.upper):!1),q=A.map(()=>null)}else({flags:P,scores:q}=se(A,{threshold:t.threshold}));if(f){const v=P.length-1;return v<0||!P[v]?!1:{method:m,field:l,flagged:[{row:g[v],score:q[v]}]}}const L=[];for(let v=0;v<P.length;v++)P[v]&&L.push({row:g[v],score:q[v]});return L.length?{method:m,field:l,flagged:L}:!1}}}),Ce("packages/core/src/compute/forecast.js",function(o,me){"use strict";Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return u}});const ae=me("packages/core/src/compute/special.js"),he=ae.normalQuantile,W=ae.studentTQuantile,_=me("packages/core/src/internal/util.js").warnOnce,Z=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),E=1e-4,z=1-1e-4;function re(t){const l=[];for(let m=0;m<t.length;m++){const e=t[m];if(e!==null&&typeof e=="object"){const d=Number.isFinite(e.at)?e.at:m,f=Number.isFinite(e.value)?e.value:null;l.push({at:d,value:f})}else l.push({at:m,value:Number.isFinite(e)?Number(e):null})}return l}function Y(t){const l=t.filter(r=>r.value!==null),m=l[0],e=l[l.length-1],d=e.at-m.at,f=l.length>1&&d>0?d/(l.length-1):1;return{lastAt:e.at,step:f}}function se(t){return Math.min(z,Math.max(E,t))}function te(t,l=E,m=z,e=80){const d=(Math.sqrt(5)-1)/2;let f=l,r=m,n=r-d*(r-f),c=f+d*(r-f),g=t(n),A=t(c);for(let P=0;P<e;P++)g<A?(r=c,c=n,A=g,n=r-d*(r-f),g=t(n)):(f=n,n=c,g=A,c=f+d*(r-f),A=t(c));return(f+r)/2}function H(t,l){let m=null,e=0,d=0;for(let f=0;f<t.length;f++){const r=t[f];if(r!==null){if(m===null){m=r;continue}e+=(r-m)**2,d+=1,m=l*r+(1-l)*m}}return{level:m,sse:e,m:d}}function T(t,l,m){let e=null,d=null,f=0,r=0;for(let n=0;n<t.length;n++){const c=t[n];if(c===null){e!==null&&d!==null&&(e+=d);continue}if(e===null){e=c;continue}d===null&&(d=c-e);const g=e+d;f+=(c-g)**2,r+=1;const A=e;e=l*c+(1-l)*(A+d),d=m*(e-A)+(1-m)*d}return{level:e,trend:d,sse:f,m:r}}function V(t,l,m,e,d){const f=t.length;if(f<2*l)return null;const r=G=>{let S=0,N=0;for(let I=G;I<G+l&&I<f;I++)t[I]!==null&&(S+=t[I],N+=1);return N?S/N:null},n=r(0),c=r(l);if(n===null||c===null)return null;let g=n,A=(c-n)/l;const P=new Array(l).fill(0);for(let G=0;G<l;G++)P[G]=t[G]===null?0:t[G]-g;const q=P.reduce((G,S)=>G+S,0)/l;for(let G=0;G<l;G++)P[G]-=q;let L=0,v=0;for(let G=l;G<f;G++){const S=G%l,N=P[S],I=t[G];if(I===null){g+=A;continue}const K=g+A+N;L+=(I-K)**2,v+=1;const B=g;g=m*(I-N)+(1-m)*(g+A),A=e*(g-B)+(1-e)*A,P[S]=d*(I-g)+(1-d)*N}return{level:g,trend:A,season:P,phase:(f-1)%l,sse:L,count:v}}function ne(t,l,m){let e=1;for(const f of l)e+=f*f;const d=Math.sqrt(t*e);return{se:d,margin:m*d}}function R(t,l={}){if(!t||typeof t.length!="number"||t.length===0)return null;const m=Z.includes(l.method)?l.method:"linear",e=Math.max(1,Math.floor(Number(l.horizon)||1)),d=Number.isFinite(l.confidence)&&l.confidence>0&&l.confidence<1?l.confidence:.95,f=1-(1-d)/2,r=re(t),n=r.map(L=>L.value),c=n.filter(L=>L!==null),g=c.length,{lastAt:A,step:P}=g?Y(r):{lastAt:0,step:1},q=L=>A+L*P;return m==="linear"?j(r,g,e,d,f,q):m==="movingAverage"?i(c,g,e,d,f,l,q):m==="ses"?a(n,g,e,d,f,l,q):m==="holt"?s(n,g,e,d,f,l,q):h(n,g,e,d,f,l,q)}function j(t,l,m,e,d,f){if(l<2)return null;let r=0,n=0;for(const I of t)I.value!==null&&(r+=I.at,n+=I.value);r/=l,n/=l;let c=0,g=0,A=0;for(const I of t){if(I.value===null)continue;const K=I.at-r,B=I.value-n;c+=K*K,g+=K*B,A+=B*B}if(c===0)return null;const P=g/c,q=n-P*r,L=A===0?1:Math.max(0,Math.min(1,g*g/(c*A))),v=Math.max(0,A-P*g),G=l>2?Math.sqrt(v/(l-2)):null,S=l>2?W(d,l-2):null,N=[];for(let I=1;I<=m;I++){const K=f(I),B=q+P*K;let ee=null,J=null,ue=null,de=null,Oe=null;if(G!==null){const Ae=1/l+(K-r)**2/c,Se=G*Math.sqrt(1+Ae),D=G*Math.sqrt(Ae);Oe=Se,ee=B-S*Se,J=B+S*Se,ue=B-S*D,de=B+S*D}N.push({step:I,at:K,mean:B,lower:ee,upper:J,lowerMean:ue,upperMean:de,se:Oe})}return{method:"linear",horizon:m,confidence:e,n:l,sigma:G,r2:L,params:{slope:P,intercept:q},points:N}}function i(t,l,m,e,d,f,r){if(l<1)return null;const n=Math.max(1,Math.min(l,Math.floor(Number(f.windowLen)||l))),c=t.slice(l-n);let g=0;for(const G of c)g+=G;const A=g/n;let P=null,q=null;if(n>1){let G=0;for(const N of c)G+=(N-A)**2;P=Math.sqrt(G/(n-1))*Math.sqrt(1+1/n),q=W(d,n-1)}const L=P===null?null:q*P,v=[];for(let G=1;G<=m;G++)v.push({step:G,at:r(G),mean:A,lower:L===null?null:A-L,upper:L===null?null:A+L,se:P});return{method:"movingAverage",horizon:m,confidence:e,n:l,sigma:P===null?null:P,params:{windowLen:n},points:v}}function a(t,l,m,e,d,f,r){if(l<1)return null;let n=Number.isFinite(f.alpha)?se(f.alpha):null;n===null&&(n=te(q=>H(t,q).sse));const c=H(t,n),g=he(d),A=c.m>0?c.sse/c.m:null,P=[];for(let q=1;q<=m;q++){const L=c.level;let v=null,G=null,S=null;if(A!==null){const N=[];for(let K=1;K<q;K++)N.push(n);const I=ne(A,N,g);S=I.se,v=L-I.margin,G=L+I.margin}P.push({step:q,at:r(q),mean:L,lower:v,upper:G,se:S})}return{method:"ses",horizon:m,confidence:e,n:l,sigma:A===null?null:Math.sqrt(A),params:{alpha:n},points:P}}function s(t,l,m,e,d,f,r){if(l<2)return null;let n=Number.isFinite(f.alpha)?se(f.alpha):null,c=Number.isFinite(f.beta)?se(f.beta):null;if(n===null||c===null){let v=n===null?.5:n,G=c===null?.5:c;for(let S=0;S<6;S++)n===null&&(v=te(N=>T(t,N,G).sse)),c===null&&(G=te(N=>T(t,v,N).sse));n=n===null?v:n,c=c===null?G:c}const g=T(t,n,c),A=he(d),P=g.m>0?g.sse/g.m:null,q=n*c,L=[];for(let v=1;v<=m;v++){const G=g.level+v*g.trend;let S=null,N=null,I=null;if(P!==null){const K=[];for(let ee=1;ee<v;ee++)K.push(n+ee*q);const B=ne(P,K,A);I=B.se,S=G-B.margin,N=G+B.margin}L.push({step:v,at:r(v),mean:G,lower:S,upper:N,se:I})}return{method:"holt",horizon:m,confidence:e,n:l,sigma:P===null?null:Math.sqrt(P),params:{alpha:n,beta:c},points:L}}function h(t,l,m,e,d,f,r){const n=Math.floor(Number(f.period));if(!(n>=2))return _("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(l<2*n)return null;let c=Number.isFinite(f.alpha)?se(f.alpha):null,g=Number.isFinite(f.beta)?se(f.beta):null,A=Number.isFinite(f.gamma)?se(f.gamma):null;const P=(I,K,B)=>{const ee=V(t,n,I,K,B);return ee?ee.sse:1/0};if(c===null||g===null||A===null){let I=c===null?.5:c,K=g===null?.5:g,B=A===null?.5:A;for(let ee=0;ee<8;ee++)c===null&&(I=te(J=>P(J,K,B))),g===null&&(K=te(J=>P(I,J,B))),A===null&&(B=te(J=>P(I,K,J)));c=c===null?I:c,g=g===null?K:g,A=A===null?B:A}const q=V(t,n,c,g,A);if(!q)return null;const L=he(d),v=q.count>0?q.sse/q.count:null,G=c*g,S=A*(1-c),N=[];for(let I=1;I<=m;I++){const K=q.season[(q.phase+I)%n],B=q.level+I*q.trend+K;let ee=null,J=null,ue=null;if(v!==null){const de=[];for(let Ae=1;Ae<I;Ae++)de.push(c+Ae*G+(Ae%n===0?S:0));const Oe=ne(v,de,L);ue=Oe.se,ee=B-Oe.margin,J=B+Oe.margin}N.push({step:I,at:r(I),mean:B,lower:ee,upper:J,se:ue})}return{method:"holtWinters",horizon:m,confidence:e,n:l,sigma:v===null?null:Math.sqrt(v),params:{alpha:c,beta:g,gamma:A,period:n},points:N}}const u={FORECAST_METHODS:Z,forecast:R}}),Ce("packages/core/src/compute/index.js",function(o,me){"use strict";const ae=me("packages/core/src/compute/sort.js");Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return ae.sortColumn}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return ae.sortMulti}}),Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return ae.radixSortFloat64}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return ae.radixSortInt32}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return ae.rankSortDictionary}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return ae.mergeSortComparator}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return ae.collateStringRanks}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return ae.rankSortStrings}});const he=me("packages/core/src/compute/sortspec.js");Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return he.collationDescriptor}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he.isPortableSort}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return he.isPortableSortSet}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return he.describeSortEntry}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return he.describeSort}});const W=me("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return W.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return W.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return W.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return W.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return W.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return W.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return W.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return W.mentionsColumn}});const U=me("packages/core/src/compute/group.js");Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return U.groupByColumns}}),Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return U.packKeys}});const _=me("packages/core/src/compute/facet.js");Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return _.facet}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return _.computeBounds}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return _.countInto}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return _.bucketOf}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return _.facetKind}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return _.cardinalityOf}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return _.pickGranularity}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return _.floorTo}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return _.advance}}),Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return _.STRATEGIES}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return _.GRANULARITIES}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return _.DEFAULT_BUCKETS}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return _.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return _.QUANTILE_SAMPLE}});const Z=me("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return Z.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return Z.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return Z.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return Z.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return Z.collectValues}});const E=me("packages/core/src/compute/pivot.js");Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return E.pivot}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return E.resolvePivotKeys}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return E.pivotKey}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return E.joinPath}}),Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return E.KEY_DELIMITER}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return E.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return E.DEFAULT_MAX_COLUMNS}});const z=me("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return z.pivotMatrix}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return z.resolveAxis}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return z.cellKey}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return z.marginKey}}),Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return z.GRAND_PATH}});const re=me("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return re.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return re.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return re.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return re.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return re.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return re.referenceValue}});const Y=me("packages/core/src/compute/handle.js");Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return Y.identity}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return Y.rowCount}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return Y.presenceReader}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return Y.bitReader}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return Y.valueReader}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return Y.valueComparator}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Y.numericTotalOrder}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return Y.dictRanks}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return Y.dictSize}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return Y.dictValue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return Y.multiValue}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return Y.isMissing}});const se=me("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return se.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return se.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return se.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return se.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return se.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return se.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return se.SKETCH_BOUNDS}});const te=me("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return te.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return te.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return te.openWindow}});const H=me("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return H.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return H.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return H.maintenanceOf}});const T=me("packages/core/src/compute/anomaly.js");Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return T.ANOMALY_METHODS}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return T.modifiedZScores}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return T.iqrFences}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return T.mahalanobis}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return T.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return T.rollingAnomalies}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return T.anomalyCondition}});const V=me("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return V.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return V.forecast}})}),Ce("packages/worker/src/kernel.js",function(o,me){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"setCompute",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"dispatch",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"handleMessage",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"installKernel",{enumerable:!0,get:function(){return s}});const ae=me("packages/worker/src/transport.js"),he=ae.PROTOCOL,W=ae.OPS,U=ae.CONTROL,_=ae.ERRORS,Z=ae.unpackHandle,E=ae.unpackHandles,z=ae.createMaskPool,re=ae.collectTransfers,Y=me("packages/core/src/store/columnpack.js"),se=Y.packChunk,te=Y.packedTransfers;let H=null,T=null,V=null;async function ne(h){if(H)return H;if(!T){const u=h||(()=>Promise.resolve(me("packages/core/src/compute/index.js")));T=Promise.resolve().then(u).then(t=>(H=t,t)).catch(t=>(V=t,H=null,null))}return T}function R(h){H=h,T=h?Promise.resolve(h):null,V=h?null:V}function j(h,u,t){const l=new Map;for(const m of h)m&&l.set(m.id,m);return{handle(m){return l.get(m)},count:u,pool:z(),locale:t}}function i(h,u){const{op:t,args:l}=h;if(t===W.COLUMNIZE)return se(l.schema||[],l.rows||[],l.opts||{});const m=u[t];if(typeof m!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=_.NO_KERNEL,e}switch(t){case W.COLLATE_STRING_RANKS:return m(l.table||[],(l.table||[]).length,l.locale);case W.SORT_COLUMN:return m(Z(l.handle),l.order??null,l.opts||{});case W.SORT_MULTI:{const e=E(l.handles||[]),d=(l.entries||[]).map(f=>({...f,handle:e[f.index]}));return m(e,d,l.order??null)}case W.EVALUATE_FILTERS:return m(l.filters,j(E(l.handles||[]),l.count,l.locale));case W.COMPACT:return m(l.mask,l.count,void 0);case W.GROUP_BY_COLUMNS:return m(E(l.handles||[]),l.order??null,l.opts||{});case W.TOTAL:return m(Z(l.handle),l.indices??null,l.fn);case W.PIVOT:return m(E(l.handles||[]),l.order??null,l.opts||{});case W.FACET:return m(Z(l.handle),l.indices??null,l.count,l.opts||{});default:{const e=new Error(`[lattice] unknown worker op \'${t}\'`);throw e.code=_.PROTOCOL,e}}}async function a(h,u={}){if(!h||h.lattice!==he)return null;const{id:t,op:l}=h;if(l===U.CANCEL)return u.cancelled?.add(h.target),null;if(l===U.PING)return{reply:{lattice:he,id:t,ok:!0,result:"pong"},transfer:[]};if(l===W.COLUMNIZE){if(u.cancelled?.has(t))return u.cancelled.delete(t),null;try{const e=se(h.args.schema||[],h.args.rows||[],h.args.opts||{});return u.cancelled?.has(t)?(u.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:_.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:te(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||_.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}const m=await ne(u.loader);if(!m)return{reply:{lattice:he,id:t,ok:!1,error:{code:_.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${V?V.message:"module not found"}`}},transfer:[]};if(u.cancelled?.has(t))return u.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:_.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(h,m);return u.cancelled?.has(t)?(u.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:_.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:re(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||_.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}function s(h,u={}){const t=new Set,l=async m=>{const e=await a(m.data,{loader:u.loader,cancelled:t});e&&h.postMessage(e.reply,e.transfer)};return h.addEventListener("message",l),ne(u.loader).then(m=>{h.postMessage({lattice:he,id:0,op:U.READY,compute:!!m})}),()=>h.removeEventListener("message",l)}});var kt=at("packages/worker/src/kernel.js");Ot.__latticeKernel=kt})(typeof globalThis<"u"?globalThis:this);\n\n__latticeKernel.installKernel(self);\n',{type:"classic"})}catch{}const Xe=Kn("packages/dom/src/index.js"),no=Xe.createGrid,ro=Xe.gridElementsWithin,io=Xe.createStat,oo=Xe.deltaOf,so=Xe.toneOf,ao=Xe.readTable,lo=Xe.hydrateTable,uo=Xe.autoInit,co=Xe.createLocalViewStorage,ho=Xe.DEFAULT_VIEWS_KEY,fo=Xe.createHeadlessGrid,po=Xe.defaults,mo=Xe.version,go=Xe.getVersion,yo=Xe.Grid,bo=Xe.EventBus,wo=Xe.Registry,vo=Xe.sharedRegistry,ko=Xe.registerModules,So=Xe.parseLicence,Oo=Xe.verifyLicence,Ao=Xe.licenceInfo,jo=Xe.watermark,Po=Xe.setLicence,Co=Xe.licenceState,Eo=Xe.isLocalHost,To=Xe.matchesDomain,Mo=Xe.LicenceHolder,No=Xe.ColumnModel,Ro=Xe.buildGraph,Lo=Xe.Lookup,Fo=Xe.ValuePipeline,xo=Xe.compileFormat,$o=Xe.compileMask,Io=Xe.specToOoxml,Do=Xe.EXTENDED_TYPES,zo=Xe.createRadixType,Bo=Xe.RADIX_PRESETS,Uo=Xe.parseRadix,Vo=Xe.formatRadix,Ho=Xe.createUnitType,Go=Xe.registerUnitSystem,Ko=Xe.defineUnit,Wo=Xe.UNIT_SYSTEMS,_o=Xe.parseUnit,qo=Xe.formatUnit,Zo=Xe.createCurrencyType,Yo=Xe.parseMoney,Xo=Xe.formatMoney,Qo=Xe.convertMoney,Jo=Xe.rateFunction,es=Xe.MISSING_RATE,ts=Xe.Messages,ns=Xe.createMessages,rs=Xe.auditCatalogue,is=Xe.EN_GB,os=Xe.MESSAGE_KEYS,ss=Xe.DEFAULT_LOCALE,as=Xe.formatList,ls=Xe.resolveLocale,us=Xe.LOCALES,cs=Xe.resolveCatalogue,ds=Xe.EN_US,hs=Xe.FR_FR,fs=Xe.FR_CA,ps=Xe.IT_IT,ms=Xe.ES_ES,gs=Xe.PT_BR,ys=Xe.DE_DE,bs=Xe.NL_NL,ws=Xe.SV_SE,vs=Xe.DA_DK,ks=Xe.NB_NO,Ss=Xe.FI_FI,Os=Xe.PL_PL,As=Xe.CS_CZ,js=Xe.HU_HU,Ps=Xe.RO_RO,Cs=Xe.UK_UA,Es=Xe.EL_GR,Ts=Xe.JA_JP,Ms=Xe.AR,Ns=Xe.AR_SA,Rs=Xe.ColumnStore,Ls=Xe.Bitset,Fs=Xe.Dictionary,xs=Xe.MultiValue,$s=Xe.MaskPool,Is=Xe.sortColumn,Ds=Xe.sortMulti,zs=Xe.evaluateFilters,Bs=Xe.compact,Us=Xe.testValue,Vs=Xe.groupByColumns,Hs=Xe.total,Gs=Xe.TOTAL_FNS,Ks=Xe.pivot,Ws=Xe.Window,_s=Xe.openWindow,qs=Xe.WINDOW_KINDS,Zs=Xe.ANOMALY_METHODS,Ys=Xe.modifiedZScores,Xs=Xe.iqrFences,Qs=Xe.mahalanobis,Js=Xe.ROLLING_ANOMALY_METHODS,ea=Xe.rollingAnomalies,ta=Xe.anomalyCondition,na=Xe.FORECAST_METHODS,ra=Xe.forecast,ia=Xe.evaluateFormula,oa=Xe.parseFormula,sa=Xe.referencesOf,aa=Xe.looksLikeFormula,la=Xe.FormulaError,ua=Xe.FUNCTIONS,ca=Xe.compileRules,da=Xe.ingest,ha=Xe.ingestSync,fa=Xe.createSource,pa=Xe.createMemorySource,ma=Xe.createPagedSource,ga=Xe.createRemoteSource,ya=Xe.createStreamSource,ba=Xe.createUrlSource,wa=Xe.PROTOCOL,va=Xe.createPushdownSource,ka=Xe.planQuery,Sa=Xe.splitFilters,Oa=Xe.applyResidual,Aa=Xe.capabilitiesOf,ja=Xe.resolveMutate,Pa=Xe.NO_CAPABILITIES,Ca=Xe.odataAdapter,Ea=Xe.filtersToOData,Ta=Xe.conditionToOData,Ma=Xe.restAdapter,Na=Xe.DEFAULT_PARAMS,Ra=Xe.dfqlAdapter,La=Xe.duckdbAdapter,Fa=Xe.filtersToSql,xa=Xe.graphqlAdapter,$a=Xe.splunkAdapter,Ia=Xe.clickhouseAdapter,Da=Xe.elasticsearchAdapter,za=Xe.RowModel,Ba=Xe.createRowKey,Ua=Xe.SelectionModel,Va=Xe.RangeModel,Ha=Xe.EditModel,Ga=Xe.ChangeModel,Ka=Xe.StateModel,Wa=Xe.STATE_VERSION,_a=Xe.serialiseState,qa=Xe.restoreState,Za=Xe.VERSION,Ya=Xe.DomRenderer,Xa=Xe.FilterMenu,Qa=Xe.mergeColumnFilter,Ja=Xe.branchFor,el=Xe.ColumnMenu,tl=Xe.columnMenuItems,nl=Xe.cellMenuItems,rl=Xe.autoGroupMenuItems,il=Xe.AlignedGrids,ol=Xe.alignGrids,sl=Xe.layoutState,al=Xe.ToolPanelDock,ll=Xe.panelHost,ul=Xe.mountPanel,cl=Xe.CellEditController,dl=Xe.EditBar,hl=Xe.HistoryBar,fl=Xe.HISTORY_CLS,pl=Xe.DiffPainter,ml=Xe.ViewPicker,gl=Xe.VIEW_CLS,yl=Xe.summariseDiff,bl=Xe.PromptBar,wl=Xe.PROMPT_CLASS,vl=Xe.createCellLayer,kl=Xe.compileTemplate,Sl=Xe.compileVariant,Ol=Xe.checkVariant,Al=Xe.VariantRegistry,jl=Xe.BUILTIN_RENDERERS,Pl=Xe.BUILTIN_VARIANTS,Cl=Xe.BUILTIN_PIPES,El=Xe.sanitiseHtml,Tl=Xe.editors,Ml=Xe.createEditor,Nl=Xe.editorFor,Rl=Xe.BaseEditor,Ll=Xe.filters,Fl=Xe.createFilter,xl=Xe.filterFor,$l=Xe.parseExpression,Il=Xe.ConditionFilter,Dl=Xe.StatusBar,zl=Xe.ContextMenu,Bl=Xe.ToolPanel,Ul=Xe.TooltipManager,Vl=Xe.Pagination,Hl=Xe.OverlayLayer,Gl=Xe.LatticeGrid,Kl=Xe.setLicense,Wl=Xe.licenseInfo,_l=Xe.licenseState;var ql=Xe.default;export{Zs as ANOMALY_METHODS,Ms as AR,Ns as AR_SA,il as AlignedGrids,Cl as BUILTIN_PIPES,jl as BUILTIN_RENDERERS,Pl as BUILTIN_VARIANTS,Rl as BaseEditor,Ls as Bitset,As as CS_CZ,cl as CellEditController,Ga as ChangeModel,el as ColumnMenu,No as ColumnModel,Rs as ColumnStore,Il as ConditionFilter,zl as ContextMenu,vs as DA_DK,ss as DEFAULT_LOCALE,Na as DEFAULT_PARAMS,ho as DEFAULT_VIEWS_KEY,ys as DE_DE,Fs as Dictionary,pl as DiffPainter,Ya as DomRenderer,Es as EL_GR,is as EN_GB,ds as EN_US,ms as ES_ES,Do as EXTENDED_TYPES,dl as EditBar,Ha as EditModel,bo as EventBus,Ss as FI_FI,na as FORECAST_METHODS,fs as FR_CA,hs as FR_FR,ua as FUNCTIONS,Xa as FilterMenu,la as FormulaError,yo as Grid,fl as HISTORY_CLS,js as HU_HU,hl as HistoryBar,ps as IT_IT,Ts as JA_JP,us as LOCALES,Gl as LatticeGrid,Mo as LicenceHolder,Lo as Lookup,os as MESSAGE_KEYS,es as MISSING_RATE,$s as MaskPool,ts as Messages,xs as MultiValue,ks as NB_NO,bs as NL_NL,Pa as NO_CAPABILITIES,Hl as OverlayLayer,Os as PL_PL,wl as PROMPT_CLASS,wa as PROTOCOL,gs as PT_BR,Vl as Pagination,bl as PromptBar,Bo as RADIX_PRESETS,Js as ROLLING_ANOMALY_METHODS,Ps as RO_RO,Va as RangeModel,wo as Registry,za as RowModel,Wa as STATE_VERSION,ws as SV_SE,Ua as SelectionModel,Ka as StateModel,Dl as StatusBar,Gs as TOTAL_FNS,Bl as ToolPanel,al as ToolPanelDock,Ul as TooltipManager,Cs as UK_UA,Wo as UNIT_SYSTEMS,Za as VERSION,gl as VIEW_CLS,Fo as ValuePipeline,Al as VariantRegistry,ml as ViewPicker,qs as WINDOW_KINDS,Ws as Window,ol as alignGrids,ta as anomalyCondition,Oa as applyResidual,rs as auditCatalogue,rl as autoGroupMenuItems,uo as autoInit,Ja as branchFor,Ro as buildGraph,Aa as capabilitiesOf,nl as cellMenuItems,Ol as checkVariant,Ia as clickhouseAdapter,tl as columnMenuItems,Bs as compact,xo as compileFormat,$o as compileMask,ca as compileRules,kl as compileTemplate,Sl as compileVariant,Ta as conditionToOData,Qo as convertMoney,vl as createCellLayer,Zo as createCurrencyType,Ml as createEditor,Fl as createFilter,no as createGrid,fo as createHeadlessGrid,co as createLocalViewStorage,pa as createMemorySource,ns as createMessages,ma as createPagedSource,va as createPushdownSource,zo as createRadixType,ga as createRemoteSource,Ba as createRowKey,fa as createSource,io as createStat,ya as createStreamSource,Ho as createUnitType,ba as createUrlSource,ql as default,po as defaults,Ko as defineUnit,oo as deltaOf,Ra as dfqlAdapter,La as duckdbAdapter,Nl as editorFor,Tl as editors,Da as elasticsearchAdapter,zs as evaluateFilters,ia as evaluateFormula,xl as filterFor,Ll as filters,Ea as filtersToOData,Fa as filtersToSql,ra as forecast,as as formatList,Xo as formatMoney,Vo as formatRadix,qo as formatUnit,go as getVersion,xa as graphqlAdapter,ro as gridElementsWithin,Vs as groupByColumns,lo as hydrateTable,da as ingest,ha as ingestSync,Xs as iqrFences,Eo as isLocalHost,sl as layoutState,Ao as licenceInfo,Co as licenceState,Wl as licenseInfo,_l as licenseState,aa as looksLikeFormula,Qs as mahalanobis,To as matchesDomain,Qa as mergeColumnFilter,Ys as modifiedZScores,ul as mountPanel,Ca as odataAdapter,_s as openWindow,ll as panelHost,$l as parseExpression,oa as parseFormula,So as parseLicence,Yo as parseMoney,Uo as parseRadix,_o as parseUnit,Ks as pivot,ka as planQuery,Jo as rateFunction,ao as readTable,sa as referencesOf,ko as registerModules,Go as registerUnitSystem,cs as resolveCatalogue,ls as resolveLocale,ja as resolveMutate,Ma as restAdapter,qa as restoreState,ea as rollingAnomalies,El as sanitiseHtml,_a as serialiseState,Po as setLicence,Kl as setLicense,vo as sharedRegistry,Is as sortColumn,Ds as sortMulti,Io as specToOoxml,Sa as splitFilters,$a as splunkAdapter,yl as summariseDiff,Us as testValue,so as toneOf,Hs as total,Oo as verifyLicence,mo as version,jo as watermark};
|
|
57
|
+
`)||(i.preventDefault(),this.fromText(m))})))}openFile(){const u=A(this.#n,"input",{attrs:{type:"file",accept:r}});u.style.display="none",this.#o.push(l(u,"change",()=>{const i=u.files&&u.files[0];i&&this.#c(i),u.parentNode&&u.parentNode.removeChild(u)})),this.#n.body.appendChild(u),u.click()}#c(u){if($(u.arrayBuffer)){u.arrayBuffer().then(m=>{const c=new Uint8Array(m);if(z(c)){this.fromXlsx(c,u.name);return}this.fromText(new TextDecoder().decode(c),u.name)});return}if($(u.text)){u.text().then(m=>this.fromText(m,u.name));return}const i=new this.#n.defaultView.FileReader;i.onload=()=>this.fromText(String(i.result||""),u.name),i.readAsText(u)}async fromXlsx(u,i){const{header:m,rows:c}=await V(u);if(!m.length)return;const f=W(m,c,{columns:this.#e.columns.all()}),a=c.filter(p=>p.length!==m.length).length;this.#l={rows:c,columns:f,delimiter:null,name:i,warnings:a?[`${a} row(s) do not have ${m.length} columns`]:[]},this.#d()}fromText(u,i){const{header:m,rows:c,delimiter:f}=X(u);if(!m.length)return;const a=W(m,c,{columns:this.#e.columns.all()}),p=c.filter(b=>b.length!==m.length).length;this.#l={rows:c,columns:a,delimiter:f,name:i,warnings:p?[`${p} row(s) do not have ${m.length} columns`]:[]},this.#d()}#d(){this.#i||this.#p(),this.#m(),this.#a=this.#n.activeElement,this.#i.hidden=!1;const u=this.#i.querySelector(t);u&&$(u.focus)&&u.focus(),this.#h(this.#f("import.opened",{count:this.#l.rows.length}),{repeat:!0})}#h(u,i){const m=this.#t&&this.#t.announce;$(m)&&m.call(this.#t,u,i)}#f(u,i){return(this.#e&&this.#e.messages?this.#e.messages:I).t(u,i)}#p(){const u=this.#n,i=A(u,"div",{class:n,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#f("import.title"),hidden:!0}}),m=A(u,"div",{class:`${n}__panel`});m.appendChild(A(u,"h2",{class:`${n}__title`,text:this.#f("import.title")})),this.#s=A(u,"div",{class:`${n}__body`}),m.appendChild(this.#s);const c=A(u,"div",{class:`${n}__footer`}),f=A(u,"button",{class:`${n}__cancel`,text:this.#f("import.cancel"),attrs:{type:"button"}}),a=A(u,"button",{class:`${n}__confirm`,text:this.#f("import.confirm"),attrs:{type:"button"}});this.#o.push(l(f,"click",()=>this.close())),this.#o.push(l(a,"click",()=>this.#g())),c.appendChild(f),c.appendChild(a),m.appendChild(c),i.appendChild(m),this.#o.push(l(i,"keydown",b=>{if(b.key==="Escape"){b.preventDefault(),this.close();return}if(b.key!=="Tab")return;const O=[...i.querySelectorAll(t)].filter(v=>!v.hidden);if(!O.length)return;const k=O[0],y=O[O.length-1];b.shiftKey&&this.#n.activeElement===k?(b.preventDefault(),y.focus()):!b.shiftKey&&this.#n.activeElement===y&&(b.preventDefault(),k.focus())})),(this.#t.viewport&&this.#t.viewport.overlays||this.#n.body).appendChild(i),this.#i=i}#m(){const u=this.#n,i=g(this.#s),{rows:m,columns:c,name:f,warnings:a}=this.#l;i.appendChild(A(u,"p",{class:`${n}__summary`,text:this.#f("import.summary",{count:m.length,name:f||this.#f("import.clipboard")})}));for(const v of a)i.appendChild(A(u,"p",{class:`${n}__warning`,text:v}));const p=this.#e.columns.all().map(v=>v.field||v.id).filter(Boolean),b=A(u,"table",{class:`${n}__map`}),O=A(u,"tr",{});for(const v of["import.colSource","import.colField","import.colType"])O.appendChild(A(u,"th",{text:this.#f(v)}));b.appendChild(O),c.forEach((v,R)=>{const S=A(u,"tr",{});S.appendChild(A(u,"td",{text:v.source}));const x=A(u,"select",{attrs:{"data-col":String(R),"aria-label":this.#f("import.mapLabel",{source:v.source})}});x.appendChild(A(u,"option",{text:this.#f("import.skip"),attrs:{value:""}}));for(const P of p)x.appendChild(A(u,"option",{text:P,attrs:{value:P,selected:P===v.field?!0:null}}));v.field&&!p.includes(v.field)&&x.appendChild(A(u,"option",{text:v.field,attrs:{value:v.field,selected:!0}}));const C=A(u,"td",{});C.appendChild(x),S.appendChild(C),S.appendChild(A(u,"td",{class:`${n}__type`,text:v.type})),b.appendChild(S)}),i.appendChild(b);const k=A(u,"div",{class:`${n}__mode`}),y=A(u,"select",{attrs:{"aria-label":this.#f("import.modeLabel"),"data-mode":"mode"}});y.appendChild(A(u,"option",{text:this.#f("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),y.appendChild(A(u,"option",{text:this.#f("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),k.appendChild(A(u,"label",{text:this.#f("import.modeLabel")})),k.appendChild(y),i.appendChild(k)}#g(){const{rows:u,columns:i}=this.#l;for(const p of this.#i.querySelectorAll("select[data-col]")){const b=Number(p.getAttribute("data-col"));i[b]&&p.value!==void 0&&p.value!==null&&(i[b].field=p.value)}const m=this.#i.querySelector("select[data-mode]"),c=m?m.value:void 0,f=c==="replace"||c==="append"?c:this.#r.mode,a=H(u,i);this.#e.import.apply(a,{mode:f}),this.close(),this.#h(this.#f("import.done",{count:a.length}),{repeat:!0})}close(){this.#i&&(this.#i.hidden=!0),this.#l=null,this.#a&&$(this.#a.focus)&&this.#a.focus(),this.#a=null}destroy(){for(const u of this.#o)u();this.#o=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null}}}),Fe("packages/dom/src/historybar.js",function(e,K){"use strict";Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return A}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),X=_.el,W=_.on,H=_.clear,V=_.documentFor,z="lat-history";class w{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(l,d){return(this.messages&&typeof this.messages.t=="function"?this.messages:I).t(l,d)}init(l){this.messages=l&&l.messages||l&&l.grid&&l.grid.messages||I;const d=l||{};if(this.doc=V(d),this.host=d.host||{},this.props=d.props||{},this.root=X(this.doc,"div",{class:["lattice-tokens",z],attrs:{role:"group","aria-label":this.t("history.title")}}),this.undoButton=this.#e("undo","Undo","↶"),this.redoButton=this.#e("redo","Redo","↷"),this.root.appendChild(this.undoButton),this.root.appendChild(this.redoButton),this.props.timeline!==!1){const o=X(this.doc,"button",{class:`${z}__toggle`,text:"▾",attrs:{type:"button","aria-haspopup":"menu","aria-expanded":"false","aria-label":this.t("history.show")}});this.off.push(W(o,"click",()=>this.toggle())),this.root.appendChild(o),this.toggleButton=o,this.menu=X(this.doc,"div",{class:`${z}__menu`,attrs:{role:"menu"}}),this.menu.style.display="none",this.root.appendChild(this.menu)}this.refresh()}#e(l,d,o){const n=X(this.doc,"button",{class:`${z}__${l}`,attrs:{type:"button"},children:[X(this.doc,"span",{class:`${z}__glyph`,text:o,attrs:{"aria-hidden":"true"}}),X(this.doc,"span",{class:`${z}__label`,text:d})]});return this.off.push(W(n,"click",()=>{const t=this.host[l];$(t)&&t(),this.refresh()})),n}element(){return this.root}refresh(){if(!this.root)return;const l=this.host,d=$(l.canUndo)?l.canUndo():!1,o=$(l.canRedo)?l.canRedo():!1,n=$(l.peek)?l.peek("undo"):null,t=$(l.peek)?l.peek("redo"):null;this.#t(this.undoButton,"undo",d,n),this.#t(this.redoButton,"redo",o,t),this.open&&this.#n()}#t(l,d,o,n){if(!l)return;l.disabled=!o;const t=d==="undo",r=this.t(t?"history.undo":"history.redo"),s=l.querySelector(`.${z}__label`);s&&(s.textContent=r);const h=n&&n.label?this.t("history.described",{action:r,label:n.label}):r;l.setAttribute("title",o?h:this.t(t?"history.nothingToUndo":"history.nothingToRedo")),l.setAttribute("aria-label",o?h:this.t(t?"history.undoDisabled":"history.redoDisabled"))}toggle(){this.menu&&(this.open=!this.open,this.menu.style.display=this.open?"":"none",this.toggleButton&&this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open&&this.#n())}#n(){const l=this.menu;if(!l)return;H(l);const d=$(this.host.list)?this.host.list():[];if(!d.length){l.appendChild(X(this.doc,"p",{class:`${z}__empty`,text:this.t("history.empty")}));return}d.forEach((o,n)=>{const t=X(this.doc,"button",{class:`${z}__item`,attrs:{type:"button",role:"menuitem","data-type":o.type,"data-undone":o.undone?"true":null},children:[X(this.doc,"span",{class:`${z}__kind`,text:o.type}),X(this.doc,"span",{class:`${z}__text`,text:o.label||o.type})]});this.off.push(W(t,"click",()=>{const r=n+1;for(let s=0;s<r;s++)$(this.host.undo)&&this.host.undo();this.toggle(),this.refresh()})),l.appendChild(t)})}destroy(){for(const l of this.off)l();this.off=[],this.root&&$(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const A=w}),Fe("packages/dom/src/diffpaint.js",function(e,K){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"diffConfigured",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,_=K("packages/core/src/i18n/index.js").defaultMessages,X={changed:"lat-row--changed",added:"lat-row--added",removed:"lat-row--removed"},W="lat-cell--changed",H="lat-cell--added-column";class V{#e;#t;#n=[];constructor(g){this.#e=g.grid,this.#t=g.renderer}mount(){for(const g of["render:done","diff:changed","rows:changed","model:changed","cell:changed","scroll"])this.#n.push(this.#e.on(g,()=>this.paint()));this.paint()}paint(){const g=this.#t.viewport.root;if(!g||!g.querySelectorAll)return;const l=this.#e.diff,d=l&&l.enabled;for(const o of g.querySelectorAll("[data-key]")){const n=o.getAttribute("data-key"),t=d?l.statusOf(n):"unchanged";for(const s of Object.values(X))o.classList.remove(s);d&&X[t]&&o.classList.add(X[t]),o.setAttribute("data-diff",d?t:"");const r=d&&t==="changed";for(const s of o.querySelectorAll("[data-col]")){const h=s.getAttribute("data-col");if(s.classList.remove(W,H),s.removeAttribute("data-before"),!r)continue;const u=l.cellStatus(n,h);if(u==="changed"){s.classList.add(W);const i=this.#r(l,n,h);i===null?s.removeAttribute("title"):(s.setAttribute("data-before",i),s.setAttribute("title",this.#o("diff.before",{value:i})))}else u==="added-column"&&s.classList.add(H)}}}#r(g,l,d){const o=this.#e,n=o&&o.columns,t=n&&$(n.get)?n.get(d):null,r=o&&o.permissions;if(t&&r&&$(r.isSecret)&&r.isSecret(t))return null;const s=g.before(l,d);if(s==null)return this.#o("diff.empty");if(!t||!$(t.formatValue))return String(s);const h=$(g.beforeRow)?g.beforeRow(l):void 0,i={...(o.rows&&$(o.rows.byKey)?o.rows.byKey(l):null)||{},data:h===void 0?{}:h};try{const m=t.formatValue(s,i,i.data);return m==null?"":String(m)}catch(m){return B(`diff-before-format:${d}`,`the formatter for column "${d}" threw while formatting a previous value, so the diff hover shows the raw one.`,m),String(s)}}#o(g,l){const d=this.#e;return(d&&d.messages?d.messages:_).t(g,l)}destroy(){for(const l of this.#n)l();this.#n=[];const g=this.#t.viewport.root;if(!(!g||!g.querySelectorAll)){for(const l of g.querySelectorAll("[data-key]")){for(const d of Object.values(X))l.classList.remove(d);l.removeAttribute("data-diff")}for(const l of g.querySelectorAll("[data-col]"))l.classList.remove(W,H),l.removeAttribute("data-before")}}}function z(A){return!!(A&&A.diff&&($(A.diff)||typeof A.diff=="object"))}const w=V}),Fe("packages/dom/src/highlightpaint.js",function(e,K){"use strict";Object.defineProperty(e,"HighlightPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const $=K("packages/core/src/internal/util.js").isFunction,B="lat-cell--highlight",I="--lattice-cell-highlight";class _{#e;#t;#n=[];#r=null;#o=!1;#i;constructor(H){this.#e=H.grid,this.#t=H.renderer,this.#i=H.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("highlight:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#o)return;this.#o=!0;const H=()=>{this.#o=!1,this.paint()};$(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(H):$(this.#i.setTimeout)?this.#i.setTimeout(H,0):H()}paint(){const H=this.#t.viewport?.root;if(!H||!H.querySelectorAll)return;const V=this.#l();if(V){V.sweep();for(const z of H.querySelectorAll("[data-key]")){const w=z.getAttribute("data-key");for(const A of z.querySelectorAll("[data-col]")){const g=V.active?V.colourFor(w,A.getAttribute("data-col")):null;g?(A.classList.add(B),A.style.setProperty(I,g)):A.classList.contains(B)&&(A.classList.remove(B),A.style.removeProperty(I))}}this.#s(V)}}#s(H){this.#r!==null&&$(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const V=H.nextExpiry;if(!Number.isFinite(V)||!$(this.#i.setTimeout))return;const z=Math.max(0,V-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},z)}#l(){const H=this.#e.highlight;return H&&$(H.model)?H.model():null}destroy(){this.#r!==null&&$(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const V of this.#n)V();this.#n=[];const H=this.#t.viewport?.root;if(!(!H||!H.querySelectorAll))for(const V of H.querySelectorAll(`.${B}`))V.classList.remove(B),V.style.removeProperty(I)}}const X=_}),Fe("packages/dom/src/findpaint.js",function(e,K){"use strict";Object.defineProperty(e,"MATCH_CLASS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"CURRENT_CLASS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"FindPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const $=K("packages/core/src/internal/util.js").isFunction,B="lat-cell--find",I="lat-cell--find-current";class _{#e;#t;#n=[];#r=!1;#o=!1;#i;constructor(H){this.#e=H.grid,this.#t=H.renderer,this.#i=H.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("find:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#r)return;this.#r=!0;const H=()=>{this.#r=!1,this.paint()};$(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(H):$(this.#i.setTimeout)?this.#i.setTimeout(H,0):H()}paint(){const H=this.#t.viewport?.root;if(!H||!H.querySelectorAll)return;const V=this.#e.find;if(!V||!$(V.stateFor))return;const z=$(V.model)?V.model():null,w=!!z&&z.active;if(!w&&!this.#o)return;let A=!1;for(const g of H.querySelectorAll("[data-key]")){const l=g.getAttribute("data-key");for(const d of g.querySelectorAll("[data-col]")){const o=w?V.stateFor(l,d.getAttribute("data-col")):null;o?(A=!0,d.classList.add(B),d.classList.toggle(I,o==="current")):d.classList.contains(B)&&d.classList.remove(B,I)}}this.#o=A}destroy(){for(const V of this.#n)V();this.#n=[];const H=this.#t.viewport?.root;if(!(!H||!H.querySelectorAll)){for(const V of H.querySelectorAll(`.${B}`))V.classList.remove(B,I);this.#o=!1}}}const X=_}),Fe("packages/dom/src/findbar.js",function(e,K){"use strict";Object.defineProperty(e,"FIND_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"FindBar",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const Q=K("packages/dom/src/editors/common.js"),$=Q.el,B=Q.on,_=K("packages/dom/src/renderer/textentry.js").isTextEntry,W=K("packages/core/src/i18n/index.js").defaultMessages,V=K("packages/core/src/internal/util.js").isFunction,z="lat-find",w=12,A=120;class g{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=null;#f=!1;#p=!1;#m=null;#g=[];#b=null;#w=null;#S=!1;constructor(o){this.#e=o.grid,this.#t=o.renderer,this.#n=o.document||o.renderer.viewport?.document,this.#r=this.#n&&this.#n.defaultView||(typeof globalThis>"u"?{}:globalThis),this.#o=o.settings&&typeof o.settings=="object"?o.settings:{}}get open(){return!!this.#i&&this.#i.style.display!=="none"}get element(){return this.#i}t(o,n){const t=this.#e;return(t&&t.messages&&V(t.messages.t)?t.messages:W).t(o,n)}mount(){const o=this.#O();if(!o)return;o.attachUi({open:t=>this.show(t),close:()=>this.hide(),focus:()=>{this.#s&&this.#s.focus()}}),o.attachDriver({run:()=>this.#C()});const n=this.#t.viewport?.root;if(n&&V(n.addEventListener)&&this.#o.shortcut!==!1){const t=r=>{if(!(r.ctrlKey||r.metaKey)||r.altKey||r.shiftKey||r.key!=="f"&&r.key!=="F")return;const s=r.target;if(this.#s&&s===this.#s){r.preventDefault(),r.stopPropagation(),V(this.#s.select)&&this.#s.select();return}_(s)||(r.preventDefault(),r.stopPropagation(),this.show())};n.addEventListener("keydown",t,!0),this.#g.push(()=>n.removeEventListener("keydown",t,!0))}this.#g.push(this.#e.on("find:changed",()=>this.#L())),this.#g.push(this.#e.on("columns:changed",()=>this.#j())),this.#g.push(this.#e.on("column:visible",()=>this.#j()))}show(o){const n=this.#k();if(!n)return;const t=n.style.display!=="none";n.style.display="",t||this.#y(),this.#O().setOpen(!0),o!=null&&(this.#s.value=String(o),this.#T()),this.#s.focus(),V(this.#s.select)&&this.#s.select(),this.#L()}hide(){this.#H();const o=this.#O();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#y()),o&&(o.clear(),o.setOpen(!1));const n=this.#t.viewport?.root;if(!n||!(this.#i&&this.#n&&this.#n.activeElement&&V(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const s=(V(n.querySelector)?n.querySelector('[tabindex="0"]'):null)||n;V(s.focus)&&s.focus()}search(){this.#T()}destroy(){this.#S=!0,this.#H();for(const n of this.#g)n();this.#g=[];const o=this.#O();o&&(o.attachUi(null),o.attachDriver(null)),this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null}#y(){const o=this.#t;o&&V(o.invalidate)&&o.invalidate("size")}#O(){const o=this.#e&&this.#e.find;return o&&V(o.model)?o.model():null}#k(){if(this.#i)return this.#i;const o=this.#t.viewport,n=o?.root,t=this.#n;if(!n||!t||!V(n.insertBefore))return null;const r=$(t,"div",{class:z,attrs:{role:"search","aria-label":this.t("find.label")}});this.#s=$(t,"input",{class:`${z}__input`,attrs:{type:"text","aria-label":this.t("find.label"),placeholder:this.t("find.placeholder"),autocomplete:"off",spellcheck:"false"}}),this.#l=$(t,"span",{class:`${z}__count`,attrs:{"aria-hidden":"true"}}),this.#a=$(t,"span",{class:`${z}__scope`,attrs:{"aria-hidden":"true"}}),this.#a.style.display="none",this.#u=$(t,"span",{class:`${z}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const s=$(t,"button",{class:`${z}__nav ${z}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),h=$(t,"button",{class:`${z}__nav ${z}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=$(t,"button",{class:`${z}__toggle ${z}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=$(t,"button",{class:`${z}__toggle ${z}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#h=$(t,"select",{class:`${z}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const u=$(t,"button",{class:`${z}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),i=$(t,"div",{class:`${z}__options`,children:[this.#c,this.#d,this.#h]});for(const c of[this.#s,this.#l,this.#a,this.#u,s,h,u,i])r.appendChild(c);this.#g.push(B(this.#s,"input",()=>this.#A())),this.#g.push(B(s,"click",()=>this.#e.find.prev())),this.#g.push(B(h,"click",()=>this.#e.find.next())),this.#g.push(B(this.#c,"click",()=>{this.#f=!this.#f,this.#c.setAttribute("aria-pressed",String(this.#f)),this.#T()})),this.#g.push(B(this.#d,"click",()=>{this.#p=!this.#p,this.#d.setAttribute("aria-pressed",String(this.#p)),this.#T()})),this.#g.push(B(this.#h,"change",()=>{const c=this.#h.value;this.#m=c?String(c):null,this.#T()})),this.#g.push(B(u,"click",()=>this.hide()));const m=c=>{if(c.key==="Escape"){c.preventDefault(),c.stopPropagation(),this.hide();return}c.key==="Enter"&&c.target===this.#s&&(c.preventDefault(),c.stopPropagation(),this.#b!==null&&(this.#x(),this.#T()),c.shiftKey?this.#e.find.prev():this.#e.find.next())};return r.addEventListener("keydown",m),this.#g.push(()=>r.removeEventListener("keydown",m)),r.style.display="none",n.insertBefore(r,o.header||n.firstChild),this.#i=r,this.#j(),r}#j(){const o=this.#h;if(!o)return;const n=this.#n;for(;o.firstChild;)o.removeChild(o.firstChild);o.appendChild($(n,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const t=this.#e.columns,r=t&&V(t.visible)?t.visible():[];let s=!1;for(const h of r){if(!h||h.id===void 0)continue;const u=String(h.id);o.appendChild($(n,"option",{text:h.title||u,attrs:{value:u}})),u===this.#m&&(s=!0)}s||(this.#m=null),o.value=this.#m||""}#A(){const o=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):A;if(this.#x(),o===0||!V(this.#r.setTimeout)){this.#T();return}this.#b=this.#r.setTimeout(()=>{this.#b=null,this.#T()},o)}#T(){const o=this.#O();if(!o||this.#S)return;const n=this.#s?this.#s.value:"";if(!n){this.#B(),o.clear();return}o.begin(n,{caseSensitive:this.#f,wholeCell:this.#p,columns:this.#m?[this.#m]:null,from:this.#M()}),this.#C()}#M(){const o=this.#t&&this.#t.window,n=o&&Number.isFinite(o.first)?o.first:0;return Math.max(0,n)}#C(){if(this.#w!==null||this.#S)return;const o=()=>{this.#w=null,this.#E()};V(this.#r.requestAnimationFrame)?this.#w=this.#r.requestAnimationFrame(o):V(this.#r.setTimeout)?this.#w=this.#r.setTimeout(o,0):o()}#E(){const o=this.#O();!o||this.#S||!o.active||(o.stale&&o.rescan({from:this.#M()}),!o.complete&&(o.step(w)||this.#C()))}#L(){if(!this.#i||this.#S)return;const o=this.#e.find.count(),n=this.#O().active;let t="",r="idle";n&&(o.total===0?(t=o.complete?this.t("find.none"):this.t("find.searching"),r=o.complete?"none":"searching"):(t=this.t(o.complete?"find.count":"find.countPartial",{current:o.current,total:o.total}),r=o.complete?"matches":"searching")),this.#l.textContent=t,this.#i.setAttribute("data-state",r);const s=n&&o.windowed;this.#a.textContent=s?this.t("find.loadedRows"):"",this.#a.style.display=s?"":"none",n?o.complete&&(this.#u.textContent=o.total===0?this.t(s?"a11y.find.noneLoaded":"a11y.find.none"):this.t(s?"a11y.find.countLoaded":"a11y.find.count",{current:o.current,count:o.total})):this.#u.textContent=""}#x(){this.#b!==null&&V(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#b),this.#b=null}#B(){this.#w!==null&&(V(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#w):V(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#w),this.#w=null)}#H(){this.#x(),this.#B()}}const l=g}),Fe("packages/dom/src/redactpaint.js",function(e,K){"use strict";Object.defineProperty(e,"RedactionPainter",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return I}});const Q="lat-cell--redacted",$="lat-cell";class B{#e;#t;#n=[];constructor(X){this.#e=X.grid,this.#t=X.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.paint()}paint(){const X=this.#t.viewport?.root;if(!X||!X.querySelectorAll)return;const W=this.#e.redaction;if(!W)return;const H=W.active;for(const V of X.querySelectorAll(`.${$}[data-col]`))H&&W.has(V.getAttribute("data-col"))?V.classList.add(Q):V.classList.contains(Q)&&V.classList.remove(Q)}destroy(){for(const X of this.#n)X();this.#n=[]}}const I=B}),Fe("packages/dom/src/validationpaint.js",function(e,K){"use strict";Object.defineProperty(e,"ValidationPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const $=K("packages/dom/src/editors/common.js").markInvalid,B="lat-cell";function I(W,H){let V=W;for(;V;){if(H(V))return V;V=V.parentNode}return null}class _{#e;#t;#n=[];constructor(H){this.#e=H.grid,this.#t=H.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint()));for(const H of["validation:failed","validation:cleared","cell:changed"])this.#n.push(this.#e.on(H,()=>this.paint()));this.paint()}#r(H){const V=I(H,z=>z.getAttribute&&z.getAttribute("data-key")!==null);return V?V.getAttribute("data-key"):null}paint(){const H=this.#e.validation;if(!H||!H.active)return;const V=this.#t.viewport?.root;if(!(!V||!V.querySelectorAll))for(const z of V.querySelectorAll(`.${B}[data-col]`)){const w=z.getAttribute("data-col"),A=this.#r(z),g=A?H.errorFor(A,w):null;$(z,g?g.message:null)}}destroy(){for(const H of this.#n)H();this.#n=[]}}const X=_}),Fe("packages/dom/src/presentation.js",function(e,K){"use strict";Object.defineProperty(e,"CHROME",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PresentationController",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/dom/src/renderer/textentry.js").isTextEntry,X=K("packages/dom/src/renderer/viewport.js").CLASS,W="lat-presenting",H="lat-presenting--changing",V="lat-presenting__progress",z="lat-cell--dimmed",w=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class A{#e;#t;#n;#r=[];#o=null;#i=null;#s=null;constructor(d){this.#e=d.grid,this.#t=d.renderer,this.#n=d.maximiser||null}mount(){this.#r.push(this.#e.on("presentation:started",()=>this.#d())),this.#r.push(this.#e.on("presentation:changed",()=>this.#f())),this.#r.push(this.#e.on("presentation:scale",()=>this.#f())),this.#r.push(this.#e.on("presentation:ended",()=>this.#h())),this.#r.push(this.#e.on("presentation:view",o=>this.#a(o))),this.#r.push(this.#e.on("presentation:spotlight",()=>this.#p())),this.#r.push(this.#e.on("render:done",()=>this.#p())),this.#n&&$(this.#n.watch)&&this.#r.push(this.#n.watch(o=>{o||!this.#o||this.#o.maximised||this.#e.presentation?.active&&this.#e.presentation.stop()}));const d=this.#t.viewport?.root;if(d&&$(d.addEventListener)){const o=n=>this.#l(n);d.addEventListener("keydown",o),this.#r.push(()=>d.removeEventListener("keydown",o))}}#l(d){const o=this.#e.presentation;if(!o?.active)return;const n=d.ctrlKey||d.metaKey,t=d.key;if(t==="Escape"&&!this.#n){d.defaultPrevented||(o.stop(),d.preventDefault?.());return}if(n){t==="="||t==="+"?(o.nudge(1),d.preventDefault?.()):t==="-"||t==="_"?(o.nudge(-1),d.preventDefault?.()):t==="0"&&(o.setScale(1.5),d.preventDefault?.());return}if(!o.views.length||I(d.target))return;t==="ArrowRight"||t==="ArrowDown"||t==="PageDown"||t===" "?(o.step(1),d.preventDefault?.()):t==="ArrowLeft"||t==="ArrowUp"||t==="PageUp"?(o.step(-1),d.preventDefault?.()):t==="Home"?(o.goTo(0),d.preventDefault?.()):t==="End"?(o.goTo(o.views.length-1),d.preventDefault?.()):(t==="r"||t==="R")&&(o.reset(),d.preventDefault?.())}#a(d){!d||!d.viewId||(this.#u(),this.#e.views?.apply?.(d.viewId),this.#c(d))}#u(){const d=this.#t.viewport?.root;d?.classList&&(d.classList.remove(H),d.offsetWidth,d.classList.add(H))}#c(d){const o=this.#t.viewport?.overlays;if(!o||!this.#e.presentation.views.length)return;const n=o.ownerDocument;if(!n?.createElement)return;if(!this.#i){const s=n.createElement("div");s.className=V,s.setAttribute("role","status"),s.setAttribute("aria-live","polite"),o.appendChild(s),this.#i=s}const t=this.#e.views?.get?.(d.viewId),r=t&&t.name?t.name:"";this.#i.textContent=r?`${r} · ${(d.index||0)+1} / ${d.count||0}`:`${(d.index||0)+1} / ${d.count||0}`}#d(){if(this.#o){this.#f();return}const d=!!(this.#n&&this.#n.active());this.#n&&!d&&this.#n.enter();const o=new Set(this.#e.presentation?.options?.chrome||[]),n=[];for(const r of w){if(o.has(r)||r==="toolPanel"&&this.#S())continue;const s=this.#y(r);s&&s.style&&s.style.display!=="none"&&(s.style.display="none",n.push(s))}const t=this.#b();t&&t.style&&t.style.display!=="none"&&this.#w(t)&&(t.style.display="none",n.push(t)),this.#o={maximised:d,hidden:n},this.#t.viewport?.root?.classList?.add(W),this.#f(),this.#m()}#h(){const d=this.#o;this.#o=null;const o=this.#t.viewport?.root;if(o?.classList?.remove(W),o?.style?.removeProperty("--lattice-presentation-scale"),this.#g(),this.#i&&(this.#i.remove?.(),this.#i=null),o?.classList?.remove(H),this.#p(),d){const n=this.#e.toolPanel;n&&$(n.presentRestore)&&n.presentRestore();for(const t of d.hidden)t.style.display="";this.#n&&!d.maximised&&this.#n.active()&&this.#n.exit()}this.#t.invalidate?.("theme")}#f(){const d=this.#t.viewport?.root;!d||!d.style||(d.style.setProperty("--lattice-presentation-scale",String(this.#e.presentation.scale)),this.#t.invalidate?.("theme"))}#p(){const d=this.#t.viewport?.root;if(!d?.querySelectorAll)return;const o=this.#e.presentation?.active?this.#e.presentation.spotlight:null,n=o&&o.keys.length?new Set(o.keys):null,t=o&&o.colIds.length?new Set(o.colIds):null;for(const r of d.querySelectorAll("[data-key]")){const s=!n||n.has(r.getAttribute("data-key"));for(const h of r.querySelectorAll("[data-col]"))!o||s&&(!t||t.has(h.getAttribute("data-col")))?h.classList.remove(z):h.classList.add(z)}}#m(){this.#g();const d=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(d)||d<=0||!this.#e.presentation.views.length)return;const o=this.#t.viewport?.root?.ownerDocument?.defaultView;o?.setInterval&&(this.#s=o.setInterval(()=>{const n=this.#e.presentation;n.active&&n.goTo(n.index>=n.views.length-1?0:n.index+1)},Math.max(1e3,d)))}#g(){if(this.#s===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#s),this.#s=null}#b(){const d=this.#e.element;return!d||!$(d.querySelector)?null:d.querySelector(`.${X.statusBar}`)}#w(d){const o=d.children||[];for(const n of o)if(!n.style||n.style.display!=="none")return!1;return!0}#S(){const d=this.#e.toolPanel;return!!(d&&$(d.presentOnly)&&d.presentOnly())}#y(d){const o=this.#e.element;if(!o||!$(o.querySelector))return null;const n={toolPanel:".lat-panel-dock",statusBar:".lat-statusbar",editBar:".lat-editor-bar",historyBar:".lat-history",pagination:".lat-pagination"}[d];return n?o.querySelector(n):null}destroy(){this.#o&&this.#h();for(const d of this.#r)d();this.#r=[]}}const g=A}),Fe("packages/dom/src/capture.js",function(e,K){"use strict";Object.defineProperty(e,"isSafeImageSource",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"captureElement",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return H}});const $=K("packages/core/src/internal/util.js").isFunction,B=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function I(V,z,w){const A=w.getComputedStyle(V),g=z.style;if(g)for(let l=0;l<A.length;l++){const d=A[l];B.has(d)||g.setProperty(d,A.getPropertyValue(d),A.getPropertyPriority(d))}}function _(V,z,w){if(I(V,z,w),V.tagName==="CANVAS"&&$(V.toDataURL))try{const l=V.toDataURL("image/png"),d=z.style;d&&(d.setProperty("background-image",`url(${l})`),d.setProperty("background-size","100% 100%"),d.setProperty("background-repeat","no-repeat"))}catch{}const A=V.children||[],g=z.children||[];for(let l=0;l<A.length&&l<g.length;l++)_(A[l],g[l],w)}function X(V,z){if(!V||V.startsWith("data:")||V.startsWith("blob:"))return!0;try{return new URL(V,z).origin===z}catch{return!0}}async function W(V,z={}){const w=V.ownerDocument,A=w?.defaultView;if(!A||typeof A.getComputedStyle!="function")throw new Error("capture needs a browser document");const g=V.getBoundingClientRect(),l=Math.max(1,Math.ceil(g.width)),d=Math.max(1,Math.ceil(g.height)),o=Math.max(.1,Number(z.scale)||2),n=A.location?.origin||"";for(const m of V.querySelectorAll("img")){const c=m.getAttribute("src")||"";if(!X(c,n))throw new Error(`capture refused: the image at ${c} is on another origin and would taint the canvas. Serve it same-origin, inline it as a data: URL, or hide the column.`)}const t=V.cloneNode(!0);_(V,t,A),t.style.width=`${l}px`,t.style.height=`${d}px`,t.style.margin="0";const r=new A.XMLSerializer().serializeToString(t),s=`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${d}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${r}</div></foreignObject></svg>`,h=new A.Image;await new Promise((m,c)=>{h.onload=()=>m(void 0),h.onerror=()=>c(new Error("capture failed to rasterise the grid; a host element inside it may not serialise as XML")),h.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(s)}`});const u=w.createElement("canvas");u.width=Math.round(l*o),u.height=Math.round(d*o);const i=u.getContext("2d");if(!i)throw new Error("capture could not get a 2d context");return i.fillStyle=z.background||A.getComputedStyle(V).backgroundColor||"#ffffff",i.fillRect(0,0,u.width,u.height),i.drawImage(h,0,0,u.width,u.height),new Promise((m,c)=>{u.toBlob(f=>f?m({blob:f,width:u.width,height:u.height}):c(new Error("capture produced no image")),z.type||"image/png",z.quality)})}const H=W}),Fe("packages/dom/src/annotate.js",function(e,K){"use strict";Object.defineProperty(e,"TOOLS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"MARK_TYPES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.uid,I=Q.warnOnce,X=K("packages/dom/src/renderer/direction.js").signedX,W=Object.freeze(["pen","arrow","rect","highlight","erase"]),H=Object.freeze(["freehand","arrow","rect","highlight","text"]),V=Object.freeze({freehand:"pen",pen:"pen",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),z=Object.freeze({pen:"freehand",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),w=14,A="system-ui, -apple-system, sans-serif";function g(f,a){if(!f||typeof f!="object")return null;const p=V[f.type];if(!p)return null;const b=typeof f.id=="string"&&f.id?f.id:B("mark"),O=Array.isArray(f.points)?f.points:[],k=[];for(const v of O){const R=Number(v&&v.x),S=Number(v&&v.y);Number.isFinite(R)&&Number.isFinite(S)&&k.push({x:R,y:S})}const y=typeof f.colour=="string"&&f.colour?f.colour:a;if(p==="text"){const v=typeof f.text=="string"?f.text:"";if(!k.length||!v)return null;const R={id:b,tool:p,colour:y,points:[k[0]],text:v,region:l(f.region)},S=Number(f.fontSize);return Number.isFinite(S)&&S>0&&(R.fontSize=S),typeof f.background=="string"&&f.background&&(R.background=f.background),R}return k.length<2?null:{id:b,tool:p,colour:y,points:k,region:l(f.region)}}function l(f){return f==="start"||f==="end"?f:"centre"}function d(f){const a={id:f.id,type:z[f.tool]||f.tool,colour:f.colour,points:f.points.map(p=>({x:p.x,y:p.y}))};return(f.region==="start"||f.region==="end")&&(a.region=f.region),f.tool==="text"&&(a.text=f.text,f.fontSize!==void 0&&(a.fontSize=f.fontSize),f.background!==void 0&&(a.background=f.background)),a}const o="lat-annotate",n=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(f){return f==="arrow"||f==="rect"}function r(f,a){return{id:f,count:a,valueOf(){return this.count}}}const s=10;function h(f,a,p){const b=p.x-a.x,O=p.y-a.y,k=b*b+O*O;let y=k?((f.x-a.x)*b+(f.y-a.y)*O)/k:0;y=Math.max(0,Math.min(1,y));const v=a.x+y*b,R=a.y+y*O;return Math.hypot(f.x-v,f.y-R)}function u(f){const a=f.points;if(!a.length)return null;if(f.tool==="text"){const y=f.fontSize||w,v=(f.text||"").length*y*.6;return{x1:a[0].x,y1:a[0].y,x2:a[0].x+v,y2:a[0].y+y*1.2}}let p=1/0,b=1/0,O=-1/0,k=-1/0;for(const y of a)p=Math.min(p,y.x),b=Math.min(b,y.y),O=Math.max(O,y.x),k=Math.max(k,y.y);return{x1:p,y1:b,x2:O,y2:k}}function i(f,a){const p=u(f);if(!p)return 1/0;if(f.tool==="text"||f.tool==="rect"){if(a.x>=p.x1&&a.x<=p.x2&&a.y>=p.y1&&a.y<=p.y2)return 0;if(f.tool==="text")return 1/0}const b=f.points;if(f.tool==="rect"){const k=[{x:p.x1,y:p.y1},{x:p.x2,y:p.y1},{x:p.x2,y:p.y2},{x:p.x1,y:p.y2}];let y=1/0;for(let v=0;v<4;v++)y=Math.min(y,h(a,k[v],k[(v+1)%4]));return y}if(b.length===1)return Math.hypot(a.x-b[0].x,a.y-b[0].y);let O=1/0;for(let k=0;k<b.length-1;k++)O=Math.min(O,h(a,b[k],b[k+1]));return O}class m{#e;#t;#n=null;#r=null;#o=null;#i="#e0245e";#s=[];#l=null;#a=[];#u=null;#c=null;constructor(a){this.#e=a.grid,this.#t=a.renderer,this.#u=Array.isArray(a.seed)?a.seed:null}get tool(){return this.#o}get count(){return this.#s.length}mount(){this.#a.push(this.#e.on("scroll",()=>this.redraw())),this.#a.push(this.#e.on("render:done",()=>this.redraw())),this.#a.push(this.#e.on("presentation:ended",()=>{this.use(null),this.#m()})),this.#d(),this.#p(),this.#u&&this.#u.length&&this.replaceAll(this.#u),this.#u=null}add(a){const p=g(a,this.#i);return p?(p.durable=!0,this.#s.push(p),this.#T(),this.redraw(),this.#E(),r(p.id,this.#s.length)):(I("annotate.add.invalid",`annotate.add ignored a mark: it needs a known \`type\` (${H.join(", ")}) and at least two finite {x, y} points in content coordinates.`),r(null,this.#s.length))}list(){return this.#s.map(d)}remove(a){const p=this.#s.findIndex(b=>b.id===a);return p<0?(I("annotate.remove.unknown",`annotate.remove ignored an unknown id: "${a}".`),!1):(this.#s.splice(p,1),this.#c===a&&(this.#c=null),this.redraw(),this.#E(),!0)}replaceAll(a){const p=Array.isArray(a)?a:[];this.#s=p.map(b=>g(b,this.#i)).filter(Boolean);for(const b of this.#s)b.durable=!0;this.#s.length&&this.#T(),this.redraw(),this.#E()}#d(){const a=this.#t.viewport?.root;if(!a||!$(a.addEventListener))return;const p=b=>{if(!(!this.#o||!b)){if(b.key==="Escape"){this.use(null),b.preventDefault?.();return}if(this.#o==="erase"){if(b.key==="Tab"){this.#h(b);return}(b.key==="Delete"||b.key==="Backspace")&&this.#f(b)}}};a.addEventListener("keydown",p,!0),this.#a.push(()=>a.removeEventListener("keydown",p,!0))}#h(a){if(!this.#s.length){this.#x("a11y.annotate.noMarks");return}a.preventDefault?.();const p=this.#c?this.#s.findIndex(k=>k.id===this.#c):-1,b=a.shiftKey?-1:1,O=p<0?b>0?0:this.#s.length-1:(p+b+this.#s.length)%this.#s.length;this.#c=this.#s[O].id,this.redraw(),this.#x("a11y.annotate.focusedMark",{at:O+1,of:this.#s.length})}#f(a){if(!this.#c)return;a.preventDefault?.();const p=this.#c;this.remove(p),this.#x("a11y.annotate.erased")}#p(){const a=this.#n?.ownerDocument?.defaultView||this.#t.viewport?.root?.ownerDocument?.defaultView;if(!a||!$(a.matchMedia))return;let p=null;const b=()=>{const O=a.devicePixelRatio||1;let k;try{k=a.matchMedia(`(resolution: ${O}dppx)`)}catch{return}p=k;const y=()=>{this.redraw(),b()};$(k.addEventListener)?k.addEventListener("change",y,{once:!0}):$(k.addListener)&&k.addListener(y)};b(),this.#a.push(()=>{p=null})}use(a,p={}){const b=!!p.colour&&a===this.#o;p.colour&&(this.#i=String(p.colour));const O=a&&W.includes(a)?a:null;this.#o=O&&O===this.#o&&!b?null:O,this.#o!=="erase"&&(this.#c=null);const k=this.#o?this.#T():this.#n;return k&&(k.style.pointerEvents=this.#o?"auto":"none",k.style.cursor=this.#o?"crosshair":""),this.#E(),this.#o}undo(){const a=this.#s.pop();return a&&this.#c===a.id&&(this.#c=null),this.redraw(),this.#E(),this.#s.length}clear(){this.#s.length&&(this.#s=[],this.#c=null,this.redraw(),this.#E())}#m(){const a=this.#s.filter(p=>p.durable);a.length!==this.#s.length&&(this.#s=a,this.redraw(),this.#E())}redraw(){!this.#n&&this.#s.length&&this.#T();const a=this.#n,p=this.#r;if(!a||!p)return;this.#M();const{left:b,top:O}=this.#A();p.clearRect(0,0,a.width,a.height);const k=this.#l?[...this.#s,this.#l]:this.#s;for(const y of["centre","start","end"]){const v=k.filter(R=>l(R.region)===y);if(v.length){p.save(),this.#g(p,y),p.translate((y==="centre"?-b:0)||0,-O||0);for(const R of v)this.#y(p,R),R.id===this.#c&&this.#k(p,R);p.restore()}}}#g(a,p="centre"){const b=this.#n,O=this.#t.viewport?.bodyViewport;if(!$(b?.getBoundingClientRect)||!$(O?.getBoundingClientRect))return;const k=b.getBoundingClientRect(),y=O.getBoundingClientRect();if(!y.width||!y.height)return;const v=this.#b(p,y);v&&(a.beginPath(),a.rect(v.left-k.left,y.top-k.top,v.width,y.height),a.clip())}#b(a,p){const b=S=>{if(!$(S?.getBoundingClientRect))return null;const x=S.getBoundingClientRect();return x&&x.width>0?{left:x.left,width:x.width}:null},O=b(this.#t.viewport?.bodyStart),k=b(this.#t.viewport?.bodyEnd);if(a==="start")return O;if(a==="end")return k;let y=p.left,v=p.left+p.width;const R=p.left+p.width/2;for(const S of[O,k]){if(!S)continue;const x=S.left+S.width;S.left+S.width/2<R?y=Math.max(y,x):v=Math.min(v,S.left)}return v>y?{left:y,width:v-y}:null}#w(a){for(const[p,b]of[["start",this.#t.viewport?.bodyStart],["end",this.#t.viewport?.bodyEnd]]){if(!$(b?.getBoundingClientRect))continue;const O=b.getBoundingClientRect();if(O&&O.width>0&&a>=O.left&&a<O.left+O.width)return p}return"centre"}#S(a){const p=this.#t.viewport?.bodyViewport;if(!$(p?.getBoundingClientRect))return!0;const b=p.getBoundingClientRect();return!b.width||!b.height?!0:a.clientX>=b.left&&a.clientX<=b.right&&a.clientY>=b.top&&a.clientY<=b.bottom}#y(a,p){const b=p.points;if(!b.length)return;const O=this.#e.presentation?.scale||1;a.lineWidth=(n[p.tool]||3)*O,a.strokeStyle=p.colour,a.fillStyle=p.colour,a.lineCap="round",a.lineJoin="round",a.globalAlpha=p.tool==="highlight"?.32:1;const k=b[0],y=b[b.length-1];if(p.tool==="text"){const v=(p.fontSize||w)*O;a.font=`${v}px ${A}`,a.textBaseline="top";const R=p.text||"";if(p.background){let S=R.length*v*.6;if(typeof a.measureText=="function"){const x=a.measureText(R);x&&Number.isFinite(x.width)&&(S=x.width)}a.fillStyle=p.background,a.fillRect(k.x-v*.15,k.y-v*.1,S+v*.3,v*1.2)}a.fillStyle=p.colour,a.fillText(R,k.x,k.y),a.globalAlpha=1;return}if(p.tool==="rect")a.strokeRect(k.x,k.y,y.x-k.x,y.y-k.y);else if(p.tool==="arrow")a.beginPath(),a.moveTo(k.x,k.y),a.lineTo(y.x,y.y),a.stroke(),this.#O(a,k,y,a.lineWidth);else{a.beginPath(),a.moveTo(k.x,k.y);for(let v=1;v<b.length;v++)a.lineTo(b[v].x,b[v].y);a.stroke()}a.globalAlpha=1}#O(a,p,b,O){const k=Math.atan2(b.y-p.y,b.x-p.x),y=Math.max(8,O*3);a.beginPath(),a.moveTo(b.x,b.y),a.lineTo(b.x-y*Math.cos(k-Math.PI/7),b.y-y*Math.sin(k-Math.PI/7)),a.lineTo(b.x-y*Math.cos(k+Math.PI/7),b.y-y*Math.sin(k+Math.PI/7)),a.closePath(),a.fill()}#k(a,p){const b=u(p);if(!b||!$(a.strokeRect))return;const O=6;a.save(),a.setLineDash?.([4,3]),a.strokeStyle="#1a73e8",a.lineWidth=2,a.globalAlpha=1,a.strokeRect(b.x1-O,b.y1-O,b.x2-b.x1+O*2,b.y2-b.y1+O*2),a.restore()}#j(a,p){const b=this.#e.presentation?.scale||1,O=s*b;for(let k=this.#s.length-1;k>=0;k--){const y=this.#s[k];if(l(y.region)===p&&i(y,a)<=O)return y}return null}#A(){const a=$(this.#t.scrollPosition)?this.#t.scrollPosition():null,p=this.#t.viewport?.rtl===!0;return{left:X(a?.left||0,p),top:a?.top||0}}#T(){if(this.#n)return this.#n;const a=this.#t.viewport?.overlays,p=a?.ownerDocument;if(!a||!p?.createElement)return null;const b=p.createElement("canvas");return b.className=o,b.style.position="absolute",b.style.inset="0",b.style.pointerEvents="none",a.appendChild(b),this.#n=b,this.#r=b.getContext?b.getContext("2d"):null,this.#M(),this.#C(b),b}#M(){const a=this.#n,p=this.#t.viewport?.root;if(!a||!p?.getBoundingClientRect)return;const b=p.getBoundingClientRect(),k=a.ownerDocument?.defaultView?.devicePixelRatio||1,y=Math.max(1,Math.round(b.width*k)),v=Math.max(1,Math.round(b.height*k));a.width===y&&a.height===v||(a.width=y,a.height=v,a.style&&(a.style.width=`${Math.max(1,b.width)}px`,a.style.height=`${Math.max(1,b.height)}px`),this.#r?.setTransform(k,0,0,k,0,0))}#C(a){const p=(v,R="centre")=>{const S=a.getBoundingClientRect(),{left:x,top:C}=this.#A();return{x:v.clientX-S.left+(R==="centre"?x:0),y:v.clientY-S.top+C}},b=v=>{if(!this.#o||!this.#S(v))return;const R=this.#w(v.clientX);if(this.#o==="erase"){const S=this.#j(p(v,R),R);S&&(this.remove(S.id),this.#x("a11y.annotate.erased")),v.preventDefault?.();return}this.#l={id:B("mark"),tool:this.#o,colour:this.#i,points:[p(v,R)],region:R},a.setPointerCapture?.(v.pointerId),v.preventDefault?.()},O=v=>{if(!this.#l)return;const R=p(v,this.#l.region);t(this.#l.tool)&&this.#l.points.length>1&&this.#l.points.pop(),this.#l.points.push(R),this.redraw()},k=v=>{this.#l&&(this.#l.points.length>1&&this.#s.push(this.#l),this.#l=null,a.releasePointerCapture?.(v.pointerId),this.redraw(),this.#E())},y=v=>{if(!this.#o)return;const R=this.#t.viewport?.bodyViewport;if(!R)return;let S=!1;v.deltaY&&typeof R.scrollTop=="number"&&(R.scrollTop+=v.deltaY,S=!0),v.deltaX&&typeof R.scrollLeft=="number"&&(R.scrollLeft+=v.deltaX,S=!0),S&&v.preventDefault?.()};a.addEventListener("pointerdown",b),a.addEventListener("pointermove",O),a.addEventListener("pointerup",k),a.addEventListener("pointercancel",k),a.addEventListener("wheel",y,{passive:!1}),this.#a.push(()=>{a.removeEventListener("pointerdown",b),a.removeEventListener("pointermove",O),a.removeEventListener("pointerup",k),a.removeEventListener("pointercancel",k),a.removeEventListener("wheel",y)})}#E(){this.#e.emit?.("annotation:changed",{tool:this.#o,count:this.#s.length},"user")}#L(a,p){const b=this.#e.messages;return b&&$(b.t)?b.t(a,p):a}#x(a,p){this.#t.announce?.(this.#L(a,p),{repeat:!0})}destroy(){for(const a of this.#a)a();this.#a=[],this.#n?.remove?.(),this.#n=null,this.#r=null,this.#s=[]}}const c=m}),Fe("packages/dom/src/timelinebar.js",function(e,K){"use strict";Object.defineProperty(e,"agoLabel",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"clockLabel",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"TimelineBar",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return V}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_="lat-timeline";function X(z){if(!Number.isFinite(z)||z<1e3)return"now";const w=Math.round(z/1e3);if(w<60)return`${w}s ago`;const A=Math.round(w/60);return A<60?`${A}m ago`:`${Math.round(A/60)}h ago`}function W(z,w){return Number.isFinite(z)?new Date(z).toLocaleTimeString(w||void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}class H{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=[];constructor(w){this.#e=w.grid,this.#t=w.renderer}mount(){this.#s.push(this.#e.on("timeline:attached",()=>{this.#a(),this.refresh()})),this.#s.push(this.#e.on("timeline:detached",()=>this.#u())),this.#s.push(this.#e.on("timeline:seek",()=>this.refresh())),this.#s.push(this.#e.on("rows:changed",()=>this.refresh()))}refresh(){if(!this.#n||!this.#e.timeline.attached)return;const w=this.#e.timeline,A=w.depth,g=w.position;this.#r.max=String(Math.max(1,A)),this.#r.value=String(Math.max(0,A-g)),this.#r.disabled=A===0;const l=w.at(),d=w.live;this.#o&&(this.#o.textContent=d?this.#l("timeline.live"):X(Date.now()-(l||Date.now())),this.#o.setAttribute("data-live",d?"true":"false")),this.#i&&(this.#i.textContent=A===0?this.#l("timeline.recording"):W(l,this.#e.get("locale"))),this.#n.setAttribute("data-live",d?"true":"false")}#l(w,A){const g=this.#e;return(g&&g.messages?g.messages:I).t(w,A)}#a(){if(this.#n)return;const w=this.#t.viewport?.overlays,A=w?.ownerDocument;if(!w||!A?.createElement)return;const g=A.createElement("div");g.className=_;const l=A.createElement("span");l.className=`${_}__ago`,l.setAttribute("role","status"),l.setAttribute("aria-live","polite");const d=A.createElement("input");d.className=`${_}__range`,d.type="range",d.min="0",d.step="1",d.setAttribute("aria-label",this.#l("timeline.scrub"));const o=A.createElement("span");o.className=`${_}__clock`;const n=A.createElement("button");n.className=`${_}__live`,n.type="button",n.textContent=this.#l("timeline.goLive"),n.setAttribute("aria-label",this.#l("timeline.returnToPresent")),g.appendChild(l),g.appendChild(d),g.appendChild(o),g.appendChild(n),w.appendChild(g),this.#n=g,this.#r=d,this.#o=l,this.#i=o;const t=()=>{const h=this.#e.timeline.depth;this.#e.timeline.seek(h-Number(d.value))};d.addEventListener("input",t);const r=()=>this.#e.timeline.toLive();n.addEventListener("click",r);const s=h=>h.stopPropagation();d.addEventListener("keydown",s),this.#s.push(()=>{d.removeEventListener("input",t),n.removeEventListener("click",r),d.removeEventListener("keydown",s)})}#u(){this.#n&&($(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null,this.#i=null)}destroy(){for(const w of this.#s)w();this.#s=[],this.#u()}}const V=H}),Fe("packages/dom/src/commentpaint.js",function(e,K){"use strict";Object.defineProperty(e,"CommentPainter",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/renderer/direction.js").isRtlElement,W="lat-comment-mark",H="lat-cell--commented",V="lat-cell--commented-open";class z{#e;#t;#n=[];#r=[];constructor(g){this.#e=g.grid,this.#t=g.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("comment:indexLoaded",()=>this.paint())),this.#s(),this.paint()}paint(){const g=this.#e.comments;if(!g||!g.enabled)return;const l=this.#t.viewport?.root;if(!l||!l.querySelectorAll)return;const d=[];for(const o of l.querySelectorAll("[data-key]")){const n=o.getAttribute("data-key");if(n){d.push(n);for(const t of o.querySelectorAll("[data-col]")){const r=t.getAttribute("data-col"),s=g.at(n,r),h=!!(s&&s.count);t.classList.toggle(H,h),t.classList.toggle(V,h&&s.unresolved>0),this.#i(t,s,r)}}}(d.length!==this.#r.length||d.some((o,n)=>o!==this.#r[n]))&&(this.#r=d,g.request(d))}#o(g,l){const d=this.#e;return(d&&d.messages?d.messages:I).t(g,l)}#i(g,l,d){if(!l||!l.count){g.hasAttribute("aria-description")&&g.removeAttribute("aria-description");return}const o=l.count,n=l.unresolved,t=this.#o("count.comments",{count:o});g.setAttribute("aria-description",n>0?this.#o("comments.someUnresolved",{comments:t,unresolved:n}):this.#o("comments.allResolved",{comments:t}))}#s(){const g=this.#t.viewport?.root;if(!g||!$(g.addEventListener))return;const l=o=>{const n=this.#e.comments;if(!n||!n.enabled)return;const t=o.target&&$(o.target.closest)?o.target.closest("[data-col]"):null;if(!t||!t.classList.contains(H)||!this.#l(t,o))return;const r=t.closest("[data-key]"),s=r&&r.getAttribute("data-key");s&&(o.stopPropagation(),o.preventDefault(),n.open(s,t.getAttribute("data-col")))},d=o=>{const n=this.#e.comments;if(!n||!n.enabled||!o.altKey||o.key!=="m"&&o.key!=="M")return;const t=this.#t.viewport?.root?.querySelector?.("[data-col].lat-cell--focus")||(typeof document<"u"&&document.activeElement&&$(document.activeElement.closest)?document.activeElement.closest("[data-col]"):null);if(!t)return;const r=t.closest("[data-key]"),s=r&&r.getAttribute("data-key");s&&(o.preventDefault(),o.stopPropagation(),n.open(s,t.getAttribute("data-col")))};g.addEventListener("click",l,!0),g.addEventListener("keydown",d,!0),this.#n.push(()=>{g.removeEventListener("click",l,!0),g.removeEventListener("keydown",d,!0)})}#l(g,l){if(!$(g.getBoundingClientRect))return!1;const d=g.getBoundingClientRect(),o=Math.max(14,Math.min(24,d.height*.6));return(X(g)?l.clientX<=d.left+o:l.clientX>=d.right-o)&&l.clientY<=d.top+o}destroy(){for(const g of this.#n)g();this.#n=[]}}const w=z}),Fe("packages/dom/src/presencepaint.js",function(e,K){"use strict";Object.defineProperty(e,"PresencePainter",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/editors/common.js").cssEscape,H=K("packages/core/src/model/presence.js").CURSOR_LABEL_MS,V="lat-presence";class z{#e;#t;#n=null;#r=null;#o=new Set;#i=[];#s=null;constructor(g){this.#e=g.grid,this.#t=g.renderer}mount(){const g=this.#e.presence;if(!(!g||!g.enabled)){this.#i.push(this.#e.on("render:done",()=>this.paint()));for(const l of["presence:joined","presence:left","presence:updated"])this.#i.push(this.#e.on(l,d=>this.#l(l,d)));this.#a(),this.paint()}}#l(g,l){if(this.#h(),g==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const o=l&&l.peer;o&&(this.#r.textContent=this.#f(g==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:o.name}))}#a(){const g=this.#t.viewport?.overlays,l=g?.ownerDocument;if(!g||!l?.createElement)return;const d=this.#e.get("presence")||{},o=l.createElement("span");if(o.className=`${V}__live`,o.setAttribute("role","status"),o.setAttribute("aria-live","polite"),g.appendChild(o),this.#r=o,d.roster===!1)return;const n=l.createElement("div");n.className=V,d.roster&&d.roster.side==="start"&&n.setAttribute("data-side","start"),n.style.pointerEvents="auto",g.appendChild(n),this.#n=n}paint(){const g=this.#e.presence,l=this.#t.viewport?.root;if(!g||!g.enabled||!l?.querySelectorAll)return;this.#d(l);const d=g.peers(),o=[...d].sort((n,t)=>n.at-t.at);for(const n of o)for(const t of n.ranges||[])for(const r of t.rowIds||[])for(const s of t.columns||[])this.#c(l,r,s,n,"range");for(const n of o)n.cursor&&this.#c(l,n.cursor.rowId,n.cursor.colId,n,"cursor");for(const n of o)n.editing&&this.#c(l,n.editing.rowId,n.editing.colId,n,"edit");this.#h(),this.#u(d)}#u(g){if(this.#s!==null)return;const l=g.filter(n=>n.cursorFresh);if(!l.length)return;const o=Math.max(...l.map(n=>n.cursorAt||0))+H-Date.now();this.#s=setTimeout(()=>{this.#s=null,this.paint()},Math.max(50,o))}#c(g,l,d,o,n){const t=g.querySelector(`[data-key="${X(l)}"]`),r=t&&t.querySelector(`[data-col="${X(d)}"]`);r&&(r.setAttribute("data-presence",n),r.style.setProperty("--lat-peer",o.colour),r.setAttribute("data-peer-name",o.name),r.setAttribute("data-peer-initial",o.initials||(o.name||"?").slice(0,1).toUpperCase()),o.idle?r.setAttribute("data-peer-idle","true"):r.removeAttribute("data-peer-idle"),n==="cursor"&&o.cursorFresh&&r.setAttribute("data-peer-fresh","true"),this.#o.add(`${l}${d}`))}#d(g){if(this.#o.size){for(const l of g.querySelectorAll("[data-presence]"))l.removeAttribute("data-presence"),l.removeAttribute("data-peer-name"),l.removeAttribute("data-peer-initial"),l.removeAttribute("data-peer-fresh"),l.removeAttribute("data-peer-idle"),l.style.removeProperty("--lat-peer");this.#o.clear()}}#h(){if(!this.#n)return;const g=this.#n.ownerDocument,l=this.#e.presence.peers();if(this.#n.textContent="",!l.length){this.#n.toggleAttribute("data-empty",!0);return}this.#n.removeAttribute("data-empty");for(const o of l){const n=g.createElement("button");n.className=`${V}__peer`,n.type="button",n.style.setProperty("--lat-peer",o.colour),n.toggleAttribute("data-idle",!!o.idle),n.toggleAttribute("data-hidden",!!o.hidden);let t="presence.peer";o.hidden?t="presence.peerHidden":o.idle&&(t="presence.peerIdle"),n.setAttribute("aria-label",this.#f(t,{name:o.name}));const r=g.createElement("span");r.className=`${V}__dot`,r.setAttribute("aria-hidden","true"),r.textContent=o.initials||(o.name||"?").slice(0,1).toUpperCase(),n.appendChild(r);const s=g.createElement("span");s.className=`${V}__name`,s.textContent=o.name,n.appendChild(s),n.addEventListener("click",()=>this.#e.presence.jumpTo(o.id)),this.#n.appendChild(n)}const d=l.filter(o=>o.hidden).length;if(d){const o=g.createElement("span");o.className=`${V}__hidden`,o.textContent=this.#f("presence.hidden",{count:d}),this.#n.appendChild(o)}}announceRefusal(g){if(!this.#r)return;const l=g&&g.name?g.name:this.#f("presence.someoneElse");this.#r.textContent=this.#f("a11y.presence.refused",{name:l})}#f(g,l){const d=this.#e;return(d&&d.messages?d.messages:I).t(g,l)}destroy(){for(const l of this.#i)l();this.#i=[],this.#s!==null&&clearTimeout(this.#s),this.#s=null;const g=this.#t.viewport?.root;g?.querySelectorAll&&this.#d(g),this.#n&&$(this.#n.remove)&&this.#n.remove(),this.#r&&$(this.#r.remove)&&this.#r.remove(),this.#n=null,this.#r=null}}const w=z}),Fe("packages/dom/src/commentpanel.js",function(e,K){"use strict";Object.defineProperty(e,"relativeTime",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"renderBody",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"CommentPanel",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/editors/common.js").cssEscape,H=K("packages/core/src/model/comments.js").parseCellKey,V="lat-comments",z=/^(https?:|mailto:)/i,w='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function A(o,n){if(!Number.isFinite(o))return"";const t=Math.max(0,Math.round((n-o)/1e3));if(t<60)return"just now";const r=Math.round(t/60);if(r<60)return`${r}m ago`;const s=Math.round(r/60);return s<24?`${s}h ago`:`${Math.round(s/24)}d ago`}function g(o,n,t,r){n.textContent="";const s=String(t??"");if(!r){n.textContent=s;return}const h=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let u=0,i=h.exec(s);for(;i;){i.index>u&&n.appendChild(o.createTextNode(s.slice(u,i.index)));const m=i[0];if(m.startsWith("*")){const c=o.createElement("em");c.textContent=m.slice(1,-1),n.appendChild(c)}else if(m.startsWith("`")){const c=o.createElement("code");c.textContent=m.slice(1,-1),n.appendChild(c)}else{const c=m.indexOf("]("),f=m.slice(1,c),a=m.slice(c+2,-1);if(z.test(a)){const p=o.createElement("a");p.href=a,p.textContent=f,p.rel="noopener noreferrer",p.target="_blank",n.appendChild(p)}else n.appendChild(o.createTextNode(f))}u=i.index+m.length,i=h.exec(s)}u<s.length&&n.appendChild(o.createTextNode(s.slice(u)))}class l{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=[];constructor(n){this.#e=n.grid,this.#t=n.renderer}mount(){this.#l.push(this.#e.on("comment:threadOpened",n=>this.#a(n))),this.#l.push(this.#e.on("comment:threadClosed",()=>this.#u())),this.#l.push(this.#e.on("render:done",()=>{this.#w(),this.#y()})),this.#l.push(this.#e.on("stream:evicted",()=>this.#c()))}#a(n){const t=this.#t.viewport?.root?.ownerDocument;t&&(this.#s=t.activeElement||null,this.#i=this.#h(n.rowId,n.field),this.#n||this.#p(t),this.#n.setAttribute("data-open","true"),this.#w(),this.#y(),this.#o&&$(this.#o.focus)&&this.#o.focus())}#u(){if(!this.#n)return;this.#n.removeAttribute("data-open"),this.#i=null;const n=this.#s;this.#s=null,n&&$(n.focus)&&n.focus()}#c(){const n=this.#e.comments.openKey;if(!n)return;const{rowId:t}=H(n);this.#e.rows.byKey(t)||(this.#d("This row is no longer in the grid: it scrolled out of the live window."),this.#e.comments.close({reason:"evicted"}))}#d(n){if(!this.#r)return;const r=this.#r.ownerDocument.createElement("p");r.className=`${V}__note`,r.setAttribute("role","status"),r.textContent=n,this.#r.appendChild(r)}#h(n,t){const r=this.#t.viewport?.root;if(!r||!r.querySelector)return null;const s=r.querySelector(`[data-key="${X(n)}"]`);return s?s.querySelector(`[data-col="${t}"]`):null}#f(n,t){const r=this.#e;return(r&&r.messages?r.messages:I).t(n,t)}#p(n){const t=n.createElement("div");t.className=V,t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label",this.#f("comments.panel"));const r=n.createElement("header");r.className=`${V}__head`;const s=n.createElement("div");s.className=`${V}__title`,r.appendChild(s);const h=n.createElement("button");h.className=`${V}__resolve`,h.type="button",r.appendChild(h);const u=n.createElement("button");u.className=`${V}__close`,u.type="button",u.setAttribute("aria-label",this.#f("comments.close")),u.textContent="×",r.appendChild(u);const i=n.createElement("div");i.className=`${V}__list`,i.setAttribute("role","log"),i.setAttribute("aria-live","polite");const m=n.createElement("form");m.className=`${V}__composer`;const c=n.createElement("textarea");c.className=`${V}__input`,c.rows=2,c.setAttribute("aria-label",this.#f("comments.write"));const f=n.createElement("button");f.className=`${V}__send`,f.type="submit",f.textContent=this.#f("comments.post"),m.appendChild(c),m.appendChild(f),t.appendChild(r),t.appendChild(i),t.appendChild(m),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(t),this.#n=t,this.#r=i,this.#o=c,this.#m=s,this.#g=h;const a=k=>{k.preventDefault();const y=String(c.value||"").trim();y&&(c.value="",this.#e.comments.add(y))},p=()=>this.#e.comments.close(),b=()=>{this.#b()>0?this.#e.comments.resolve():this.#e.comments.unresolve()},O=k=>{if(k.stopPropagation(),k.key==="Escape"){k.preventDefault(),this.#e.comments.close();return}if(k.key!=="Tab")return;const y=[...t.querySelectorAll(w)].filter(x=>x.offsetParent!==null||x===c);if(!y.length)return;const v=y[0],R=y[y.length-1],S=t.ownerDocument.activeElement;k.shiftKey&&S===v?(k.preventDefault(),R.focus()):!k.shiftKey&&S===R&&(k.preventDefault(),v.focus())};m.addEventListener("submit",a),u.addEventListener("click",p),h.addEventListener("click",b),t.addEventListener("keydown",O),this.#l.push(()=>{m.removeEventListener("submit",a),u.removeEventListener("click",p),h.removeEventListener("click",b),t.removeEventListener("keydown",O)})}#m=null;#g=null;#b(){return(this.#e.comments.thread||[]).filter(t=>!t.resolved).length}#w(){const n=this.#e.comments;if(!this.#n||!n.openKey)return;const t=this.#n.ownerDocument,r=this.#e.get("comments")||{},s=Date.now(),h=n.openKey,{rowId:u,field:i}=H(h),m=this.#e.columns.get(i),c=this.#e.rows.byKey(u),f=$(r.rowLabel)&&c?r.rowLabel(c):u;if(this.#m.textContent=this.#f("comments.cellTitle",{column:m&&(m.title??m.id)||i,row:f}),this.#g.textContent=this.#b()>0?this.#f("comments.resolve"):this.#f("comments.reopen"),this.#r.textContent="",n.loading){this.#d(this.#f("comments.loading"));return}const a=n.thread||[];if(!a.length){this.#d(this.#f("comments.empty"));return}const p=c&&m?m.getValue(c.data,c):void 0;for(const b of a)this.#r.appendChild(this.#S(t,b,s,p,r))}#S(n,t,r,s,h){const u=n.createElement("article");u.className=`${V}__item`,t.pending&&u.setAttribute("data-pending","true"),t.resolved&&u.setAttribute("data-resolved","true");const i=n.createElement("div");i.className=`${V}__meta`;const m=n.createElement("span");m.className=`${V}__author`,m.textContent=t.author&&(t.author.name||t.author.initials)||this.#f("comments.unknownAuthor"),i.appendChild(m);const c=n.createElement("time");c.className=`${V}__time`;const f=A(t.at,r);c.textContent=t.edited?this.#f("comments.edited",{time:f}):f,i.appendChild(c),u.appendChild(i);const a=n.createElement("div");if(a.className=`${V}__body`,g(n,a,t.body,!!h.markdown),u.appendChild(a),t.value!==void 0&&!Object.is(t.value,s)){const O=n.createElement("p");O.className=`${V}__moved`,O.textContent=this.#f("comments.valueMoved",{was:String(t.value),now:String(s)}),u.appendChild(O)}const p=t.can||{},b=O=>p[O]!==!1;if(b("edit")||b("delete")){const O=n.createElement("div");if(O.className=`${V}__actions`,b("delete")){const k=n.createElement("button");k.type="button",k.className=`${V}__action`,k.textContent=this.#f("comments.delete"),k.addEventListener("click",()=>this.#e.comments.remove(t.id)),O.appendChild(k)}u.appendChild(O)}return u}#y(){if(!this.#n||!this.#e.comments.openKey)return;if((this.#e.get("comments")||{}).mode==="docked"){this.#n.setAttribute("data-docked","true");return}this.#n.removeAttribute("data-docked");const t=this.#e.comments.openKey,{rowId:r,field:s}=H(t),h=this.#h(r,s)||this.#i,u=this.#t.viewport?.root;if(!h||!u||!$(h.getBoundingClientRect))return;const i=h.getBoundingClientRect(),m=u.getBoundingClientRect(),c=this.#n.getBoundingClientRect();let f=i.bottom-m.top+4;f+c.height>m.height&&i.top-m.top>c.height&&(f=i.top-m.top-c.height-4);let a=i.left-m.left;a+c.width>m.width&&(a=Math.max(0,m.width-c.width-4)),this.#n.style.top=`${Math.max(0,f)}px`,this.#n.style.left=`${Math.max(0,a)}px`;const p=i.bottom<m.top||i.top>m.bottom;this.#n.toggleAttribute("data-offscreen",p)}destroy(){for(const n of this.#l)n();this.#l=[],this.#n&&$(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const d=l}),Fe("packages/dom/src/watermark.js",function(e,K){"use strict";Object.defineProperty(e,"WATERMARK_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"Watermark",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),X=_.el,W=_.on,H="lat-watermark",V="https://www.latticegrid.dev",z=["br","bl","tl","tr"],w=4e3;class A{#e;#t;#n;#r=null;#o=[];#i;#s=0;#l=null;constructor(d){this.#e=d.grid,this.#t=d.document,this.#n=d.element,this.#i=d.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),$(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const d=this.#e.licence&&this.#e.licence.ready;d&&$(d.then)&&d.then(()=>this.refresh(),()=>this.refresh())}refresh(){const d=this.#d();d&&!this.#r?(this.#h(),this.#u()):!d&&this.#r&&(this.#f(),this.#c())}#a(){const d=this.#i;if(!d||!$(d.matchMedia))return!1;try{return!!d.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),$(this.#i.setTimeout)&&(this.#a()||(this.#l=this.#i.setTimeout(()=>{if(this.#l=null,!this.#d()){this.#f();return}this.#s=(this.#s+1)%z.length,this.#f(),this.#h(),this.#u()},w)))}#c(){this.#l!==null&&$(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#l),this.#l=null}#d(){const d=this.#e.licence;return!!(d&&$(d.watermark)&&d.watermark())}#h(){const d=this.grid&&this.grid.messages?this.grid.messages:I,o=X(this.#t,"a",{class:`${H}__link`,text:d.t("licence.watermark"),attrs:{href:V,target:"_blank",rel:"noopener noreferrer"}}),n=X(this.#t,"span",{class:`${H}__free`,text:d.t("licence.watermark.free")});this.#r=X(this.#t,"div",{class:`${H} ${H}--${z[this.#s]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[o,n]}),this.#o.push(W(this.#r,"pointerdown",t=>{$(t.stopPropagation)&&t.stopPropagation()})),this.#n&&$(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#f(){this.#r&&$(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c();for(const d of this.#o)d();this.#o=[],this.#f()}}const g=A}),Fe("packages/dom/src/maximise.js",function(e,K){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const Q=K("packages/core/src/internal/util.js"),$=Q.warnOnce,B=Q.isFunction,I=K("packages/dom/src/editors/common.js"),_=I.el,X=I.on,H=K("packages/dom/src/themeof.js").themeOf,V="lat-maximised",z={position:"fixed",top:"0px",left:"0px",right:"0px",bottom:"0px",width:"auto",height:"auto",minWidth:"0px",minHeight:"0px",maxWidth:"none",maxHeight:"none",margin:"0px",zIndex:"2147483000"},w="lat-maximised-host",A="lat-maximise-placeholder";class g{#e;#t;#n;#r;#o;#i=null;#s=null;#l=new Set;#a=null;#u=!1;#c=null;constructor(o){this.#e=o.element,this.#t=o.document,this.#n=B(o.onChange)?o.onChange:null,this.#r=B(o.captureScroll)?o.captureScroll:null,this.#o=B(o.restoreScroll)?o.restoreScroll:null}active(){return this.#i!==null}enter(){if(this.active())return!0;const o=this.#e.parentNode;if(!o||!this.#t.body)return $("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=_(this.#t,"div",{class:A}),this.#i.style.visibility="hidden";const n=this.#e.offsetWidth,t=this.#e.offsetHeight;n&&(this.#i.style.width=`${n}px`),t&&(this.#i.style.height=`${t}px`);const r=this.#r?this.#r():null,s=B(this.#e.getAttribute)&&!this.#e.getAttribute("data-theme")?H(o):null;s&&(this.#e.setAttribute("data-theme",s),this.#u=!0),o.insertBefore(this.#i,this.#e),this.#d(()=>this.#t.body.appendChild(this.#e)),this.#a={};for(const[h,u]of Object.entries(z))this.#a[h]=this.#e.style[h]||"",this.#e.style[h]=u;return this.#c=this.#t.body.style?this.#t.body.style.overflow||"":null,this.#t.body.style&&(this.#t.body.style.overflow="hidden"),this.#e.classList.add(V),this.#t.body.classList&&this.#t.body.classList.add(w),r&&this.#o&&this.#o(r),this.#s=X(this.#t,"keydown",h=>this.#h(h)),this.#f(),!0}exit(){if(!this.active())return!1;const o=this.#r?this.#r():null,n=this.#i,t=n.parentNode;if(t&&B(t.insertBefore)&&this.#d(()=>t.insertBefore(this.#e,n)),B(n.remove)&&n.remove(),this.#i=null,this.#u&&(this.#e.removeAttribute("data-theme"),this.#u=!1),this.#a){for(const[r,s]of Object.entries(this.#a))this.#e.style[r]=s;this.#a=null}return this.#c!==null&&this.#t.body&&this.#t.body.style&&(this.#t.body.style.overflow=this.#c),this.#c=null,this.#e.classList.remove(V),this.#t.body&&this.#t.body.classList&&this.#t.body.classList.remove(w),o&&this.#o&&this.#o(o),this.#s&&this.#s(),this.#s=null,this.#f(),!0}toggle(){return this.active()?!this.exit():this.enter()}#d(o){const n=this.#t.activeElement,t=n&&n!==this.#t.body&&B(this.#e.contains)&&this.#e.contains(n)?n:null;o(),t&&B(t.focus)&&t.focus()}#h(o){!o||o.key!=="Escape"||o.defaultPrevented||this.exit()}#f(){this.#n&&this.#n();for(const o of this.#l)o(this.active())}watch(o){return B(o)?(this.#l.add(o),()=>this.#l.delete(o)):()=>{}}destroy(){this.exit()}}const l=g}),Fe("packages/dom/src/promptbar.js",function(e,K){"use strict";Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return t}});const Q=K("packages/dom/src/editors/common.js"),$=Q.documentFor,B=Q.el,I=Q.on,_=Q.clear,W=K("packages/core/src/i18n/index.js").defaultMessages,V=K("packages/core/src/internal/util.js").isFunction,z=K("packages/core/src/ai/schema.js"),w=z.describeGrid,A=z.promptText,g=K("packages/core/src/ai/intent.js"),l=g.applyPlan,d=g.buildPrompt,o=g.planIntent,n="lat-prompt";class t{#e;#t=null;#n=null;#r={};#o;#i={};#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=null;#f=null;#p=null;#m=null;#g=null;#b="idle";#w=0;#S=!1;#y=[];t(u,i){return(this.messages&&typeof this.messages.t=="function"?this.messages:W).t(u,i)}init(u={}){this.messages=u&&u.messages||u&&u.grid&&u.grid.messages||W,this.#e=$(u),this.#t=u.grid||null,this.#n=V(u.ask)?u.ask:null,this.#r=u.schemaOptions||{},this.#o=u.context,this.#i={onPlan:V(u.onPlan)?u.onPlan:null,onApply:V(u.onApply)?u.onApply:null,onError:V(u.onError)?u.onError:null},this.#s=B(this.#e,"div",{class:n,attrs:{"data-state":"idle",role:"search"}}),this.#O(u)}element(){return this.#s}refresh(){this.#S||!this.#s||this.#b!=="busy"&&this.#T()}destroy(){this.#S=!0,this.#w++;for(const u of this.#y)u();this.#y.length=0,this.#g=null,this.#s=null,this.#l=null,this.#a=null,this.#u=null,this.#c=null,this.#d=null,this.#h=null,this.#f=null,this.#p=null,this.#m=null}plan(){return this.#g}async ask(u){if(this.#S||this.#b==="busy")return null;const i=String(u??(this.#l&&this.#l.value)??"").trim();if(!i)return null;if(!this.#n)return this.#C("No model is wired up. Supply `ai.ask` to use the prompt bar."),null;const m=++this.#w;this.#k("busy"),this.#M("Thinking…");let c;try{const f=w(this.#t,this.#r),a=A(f);if(c=await this.#n({prompt:i,schema:f,schemaText:a,message:d(i,a),context:this.#o}),this.#S||m!==this.#w)return null;const p=o(c,f);return this.#j(p),p}catch(f){return this.#S||m!==this.#w||(this.#i.onError&&this.#i.onError(f),this.#C(f instanceof Error?f.message:String(f))),null}}apply(){const u=this.#g;if(this.#S||!u||!u.ok)return null;const i=this.#t?.ai,m=V(i?.apply)?i.apply(u):l(u,this.#t);return this.#i.onApply&&this.#i.onApply(m,u),this.#T(),this.#l&&(this.#l.value=""),m.failed.length?this.#C(`Applied ${m.applied.length}; ${m.failed.map(c=>`${c.type} failed: ${c.reason}`).join("; ")}`):this.#M(`Applied: ${u.describe()}`),m}discard(){this.#S||(this.#T(),this.#M("Discarded."))}#O(u){const i=this.#e,m=B(i,"div",{class:`${n}__row`});this.#l=B(i,"input",{class:`${n}__input`,attrs:{type:"text",placeholder:u.placeholder||"Ask for a view: “EMEA deals over 50k, biggest first”","aria-label":u.label||"Ask about this grid",autocomplete:"off"}}),this.#y.push(I(this.#l,"keydown",f=>{const a=f&&f.key;a==="Enter"?(V(f.preventDefault)&&f.preventDefault(),this.ask()):a==="Escape"&&this.#g&&(V(f.preventDefault)&&f.preventDefault(),this.discard())})),m.appendChild(this.#l),this.#a=B(i,"button",{class:`${n}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#y.push(I(this.#a,"click",()=>{this.ask()})),m.appendChild(this.#a),this.#s.appendChild(m),this.#u=B(i,"div",{class:`${n}__preview`,attrs:{hidden:!0}}),this.#c=B(i,"p",{class:`${n}__summary`}),this.#d=B(i,"ul",{class:`${n}__notes`});const c=B(i,"div",{class:`${n}__buttons`});this.#h=B(i,"button",{class:`${n}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#f=B(i,"button",{class:`${n}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#y.push(I(this.#h,"click",()=>{this.apply()})),this.#y.push(I(this.#f,"click",()=>{this.discard()})),c.appendChild(this.#h),c.appendChild(this.#f),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(c),this.#s.appendChild(this.#u),this.#p=B(i,"p",{class:`${n}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#m=B(i,"p",{class:`${n}__error`,attrs:{role:"alert",hidden:!0}}),this.#s.appendChild(this.#p),this.#s.appendChild(this.#m)}#k(u){if(this.#b=u,!this.#s)return;this.#s.setAttribute("data-state",u);const i=u==="busy";r(this.#l,i),r(this.#a,i),this.#a&&(this.#a.textContent=this.t(i?"prompt.asking":"prompt.ask")),s(this.#u,u!=="preview"),s(this.#m,u!=="error")}#j(u){const i=u;if(this.#i.onPlan&&this.#i.onPlan(u),!i.ok){this.#g=null;const m=i.rejected.length?i.rejected.map(c=>c.reason).join("; "):"nothing to do";this.#C(`I could not turn that into a change: ${m}`);return}this.#g=u,this.#M(""),this.#c&&(this.#c.textContent=i.describe()),this.#A(i.rejected),this.#k("preview")}#A(u){const i=this.#d;if(i){_(i),s(i,!u.length);for(const m of u.slice(0,6))i.appendChild(B(this.#e,"li",{class:`${n}__note`,text:m.reason}));u.length>6&&i.appendChild(B(this.#e,"li",{class:`${n}__note`,text:this.t("prompt.moreNotes",{count:u.length-6})}))}}#T(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&_(this.#d),this.#k("idle")}#M(u){this.#p&&(this.#p.textContent=u)}#C(u){this.#g=null,this.#M(""),this.#m&&(this.#m.textContent=u),this.#k("error")}}function r(h,u){h&&(h.disabled=u,u?h.setAttribute("disabled",""):h.removeAttribute("disabled"))}function s(h,u){h&&(h.hidden=u,u?h.setAttribute("hidden",""):h.removeAttribute("hidden"))}}),Fe("packages/dom/src/stat.js",function(e,K){"use strict";Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"bandTone",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return u}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.isObject,I=Q.warnOnce,X=K("packages/core/src/source/derive.js").reduceValues,H=K("packages/core/src/source/memory.js").isPipelineSettle,z=K("packages/core/src/i18n/index.js").defaultMessages,A=K("packages/dom/src/cell/icons.js").renderIconInto,g={root:"lat-stat",icon:"lat-stat__icon",body:"lat-stat__body",title:"lat-stat__title",value:"lat-stat__value",delta:"lat-stat__delta",interval:"lat-stat__interval",footer:"lat-stat__footer",note:"lat-stat__note"},l="unknown",d=new Set(["sum","min","max","avg","first","last","mode","median","p25","p75","p90","p95","p99","stddev","stddevP","mad","range","iqr","trimmedMean","winsorizedMean","geomean","harmean"]),o=Object.freeze({direction:"flat",change:null,percent:null});function n(a,p){if(!Number.isFinite(a)||!Number.isFinite(p))return o;const b=a-p,O=b>0?"up":b<0?"down":"flat",k=p===0?null:b/Math.abs(p)*100;return{direction:O,change:b,percent:k}}function t(a,p){return a==="flat"||p==="neither"?"flat":a===p?"good":"bad"}function r(a,p,b=null){if($(p)){const S=p(a,b);return S==="good"||S==="warn"||S==="bad"?S:null}if(!B(p))return null;const O=typeof a=="number"&&Number.isFinite(a)?a:null;if(O===null)return null;const k=Number.isFinite(Number(p.good))?Number(p.good):null,y=Number.isFinite(Number(p.warn))?Number(p.warn):null,v=String(p.direction||"up")==="down",R=S=>v?O<=S:O>=S;return k!==null&&R(k)?"good":y!==null&&R(y)?"warn":k===null&&y===null?null:"bad"}function s(a){return!($(a.value)||a.value!==void 0&&!B(a.value))}function h(a){return!a||!a.rows||!$(a.rows.totalCount)?!0:a.rows.totalCount()>0}function u(a){const p=B(a)?a:{},b=p.grid||null,O=c(p.container,b);if(!O)return I("stat.container","createStat needs a `container`: an element or a selector."),f();const k=O.ownerDocument||(typeof document>"u"?null:document);if(!k)return I("stat.document","createStat needs a document; it draws DOM."),f();const y=k.createElement("div");y.className=["lattice",g.root,p.class].filter(Boolean).join(" "),y.setAttribute("role","group");const v=k.createElement("div");v.className=g.title;const R=k.createElement("div");R.className=g.value;const S=k.createElement("div");S.className=g.interval;const x=k.createElement("div");x.className=g.delta;const C=k.createElement("div");C.className=g.footer;const P=k.createElement("div");if(P.className=g.note,P.hidden=!0,p.icon!=null&&p.icon!==""){const ee=k.createElement("span");ee.className=g.icon,ee.setAttribute("aria-hidden","true"),A(ee,p.icon,`stat:${p.title||"stat"}`),y.appendChild(ee);const ne=k.createElement("div");ne.className=g.body,ne.appendChild(v),ne.appendChild(R),ne.appendChild(P),ne.appendChild(S),ne.appendChild(x),ne.appendChild(C),y.appendChild(ne)}else y.appendChild(v),y.appendChild(R),y.appendChild(P),y.appendChild(S),y.appendChild(x),y.appendChild(C);O.appendChild(y);let E=null;const D=[];let N=!1;function M(){if($(p.value))return p.value(b);if(p.value!==void 0&&!B(p.value))return p.value;const ee=B(p.value)?p.value:p,ne=ee.of,ie=ee.fn||"sum",se=ee.show;return b?ie==="count"?L().length:ne?se?G(String(ne),String(ie),String(se)):j()==="filtered"&&b.statistics&&$(b.statistics.reduce)?b.statistics.reduce(String(ne),String(ie)):X(L().map(he=>m(he,String(ne))),String(ie)):null:null}function j(){return String(p.scope||"filtered")}function L(){if(!b||!b.rows)return[];const ee=j();if(ee==="all"){const ie=[];return $(b.rows.forEachAll)&&b.rows.forEachAll(se=>{se.group||ie.push(i(se))}),ie}if(ee==="selected")return(b.selection&&$(b.selection.rows)?b.selection.rows():[]).filter(Boolean).map(i);const ne=[];return $(b.rows.forEach)&&b.rows.forEach(ie=>{ie.group||ne.push(i(ie))}),ne}function G(ee,ne,ie){if(ne!=="min"&&ne!=="max")return I(`stat.show.${ne}`,`\`show\` needs \`fn: 'min'\` or \`fn: 'max'\`: "${ne}" reduces to a value that no single row holds, so there is no row to report from.`),null;let se=null,he=null;for(const ce of L()){const te=Number(m(ce,ee));Number.isFinite(te)&&(se===null||(ne==="max"?te>se:te<se))&&(se=te,he=ce)}return he===null?null:m(he,ie)}function q(ee){if($(p.format))return String(p.format(ee,b));if(ee==null)return p.empty??"—";const ne=B(p.value)?p.value:p,ie=ne.show||ne.of;if((ne.show?!0:d.has(String(ne.fn||"sum")))&&b&&ie&&$(b.columns?.get)){const he=b.columns.get(String(ie));if(he&&$(he.formatValue))return he.formatValue(ee)}return typeof ee=="number"?Number.isInteger(ee)?String(ee):ee.toFixed(p.decimals??2):String(ee)}function Y(ee){return ee?(b&&b.messages||z).t(`stat.tone.${ee}`):""}function J(){if(N)return;const ee=M(),ne=s(p)&&!!b&&!h(b),ie=ne?null:ee,se=$(p.baseline)?p.baseline(b):p.baseline;E=ie,v.textContent=p.title??"",v.hidden=!p.title,R.textContent=q(ie),P.hidden=!ne,ne&&(P.textContent=b.messages.t("stat.noData"));const he=ne||se===void 0||se===null?o:n(typeof ie=="number"?ie:null,Number(se)),ce=t(he.direction,p.goodWhen||"up");if(x.hidden=he.change===null,he.change!==null){const de=he.direction==="up"?"↑":he.direction==="down"?"↓":"→",ve=he.percent===null?q(Math.abs(he.change)):`${Math.abs(he.percent).toFixed(1)}%`;x.textContent=`${de} ${ve}`,x.setAttribute("data-tone",ce),x.setAttribute("data-direction",he.direction)}const te=$(p.interval)?p.interval(ie,b):null,oe=!!te&&Number.isFinite(te.lower)&&Number.isFinite(te.upper);S.hidden=!oe,oe&&(S.textContent=`${q(te.lower)} – ${q(te.upper)}`,Number.isFinite(te.confidence)&&S.setAttribute("title",`${Math.round(te.confidence*100)}%`));const fe=ne?l:p.bands?r(ie,p.bands,b):null;fe?y.setAttribute("data-tone",fe):y.removeAttribute("data-tone"),C.textContent=$(p.footer)?String(p.footer(ie,b)):p.footer??"",C.hidden=!C.textContent,y.setAttribute("aria-label",[p.title,R.textContent,ne?P.textContent:"",oe?S.textContent:"",he.change===null?"":x.textContent,he.change===null?"":Y(ce),C.textContent].filter(Boolean).join(", "))}if(b&&$(b.on)&&p.live!==!1)for(const ee of["rows:changed","filter:changed","selection:changed","model:changed"]){const ne=ie=>{ee==="model:changed"&&!H(ie)||J()};b.on(ee,ne),D.push(()=>$(b.off)&&b.off(ee,ne))}return J(),{element:()=>y,value:()=>E,refresh:J,destroy(){N=!0;for(const ee of D)try{ee()}catch{}D.length=0,y.remove()}}}function i(a){return B(a)&&"data"in a?a.data:a}function m(a,p){if(!B(a))return;if(!p.includes("."))return a[p];let b=a;for(const O of p.split(".")){if(!B(b))return;b=b[O]}return b}function c(a,p){if(a&&typeof a=="object")return a;if(typeof a!="string")return null;const b=p&&p.element&&p.element.ownerDocument||(typeof document>"u"?null:document);return b?b.querySelector(a):null}function f(){return{element:()=>null,value:()=>null,refresh(){},destroy(){}}}}),Fe("packages/dom/src/kpistrip.js",function(e,K){"use strict";Object.defineProperty(e,"KpiStrip",{enumerable:!0,get:function(){return X}});const $=K("packages/core/src/internal/util.js").isObject,I=K("packages/dom/src/stat.js").createStat,_={band:"lat-kpi-strip"};class X{#e;#t;#n;#r=null;#o=[];constructor({grid:H,document:V,kpis:z}){this.#e=H,this.#t=V,this.#n=Array.isArray(z)?z.filter($):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const V=this.#t.createElement("div");V.className=`lattice ${_.band}`,V.setAttribute("role","group"),V.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=V;for(const z of this.#n){const w=I({...z,grid:this.#e,container:V});this.#o.push(w)}}destroy(){for(const H of this.#o)try{H.destroy()}catch{}this.#o.length=0,this.#r&&(this.#r.remove(),this.#r=null)}}}),Fe("packages/dom/src/createGrid.js",function(e,K){"use strict";Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return Et}});const $=K("packages/core/src/index.js").createHeadlessGrid,I=K("packages/core/src/defaults.js").applyDefaults,X=K("packages/core/src/export/download.js").downloadBlob,W=K("packages/core/src/internal/util.js"),H=W.fail,V=W.isFunction,z=W.warnOnce,A=K("packages/dom/src/localviews.js").createLocalViewStorage,l=K("packages/dom/src/renderer/index.js").DomRenderer,o=K("packages/dom/src/cell/index.js").createCellLayer,n=K("packages/dom/src/cell/icons.js"),t=n.icon,r=n.iconNames,h=K("packages/dom/src/editors/index.js").editors,i=K("packages/dom/src/filters/index.js").filters,m=K("packages/dom/src/ui/index.js"),c=m.StatusBar,f=m.TooltipManager,a=m.Pagination,p=m.GroupByZone,O=K("packages/dom/src/ui/celltooltip.js").CellTooltips,y=K("packages/dom/src/filtermenu.js").FilterMenu,R=K("packages/dom/src/columnmenu.js").ColumnMenu,x=K("packages/dom/src/shortcutshelp.js").ShortcutsHelp,P=K("packages/dom/src/rowreorder.js").RowReorder,E=K("packages/dom/src/alignedgrids.js").AlignedGrids,N=K("packages/dom/src/columntagbar.js").ColumnTagBar,j=K("packages/dom/src/anomalychip.js").AnomalyChip,G=K("packages/dom/src/rowform.js").RowForm,q=K("packages/dom/src/toolpanelmount.js"),Y=q.ToolPanelDock,J=q.panelHost,ne=K("packages/dom/src/celledit.js").CellEditController,se=K("packages/dom/src/editbar.js").EditBar,ce=K("packages/dom/src/rangeselect.js").RangeController,oe=K("packages/core/src/model/selection.js").resolveSelectionConfig,de=K("packages/dom/src/importer.js").ImportController,Me=K("packages/dom/src/historybar.js").HistoryBar,Ce=K("packages/dom/src/diffpaint.js").DiffPainter,we=K("packages/dom/src/detailhost.js").DetailHost,Ne=K("packages/dom/src/highlightpaint.js").HighlightPainter,He=K("packages/dom/src/findpaint.js").FindPainter,Ae=K("packages/dom/src/findbar.js").FindBar,Ze=K("packages/dom/src/redactpaint.js").RedactionPainter,lt=K("packages/dom/src/validationpaint.js").ValidationPainter,gt=K("packages/dom/src/presentation.js").PresentationController,Pt=K("packages/dom/src/capture.js").captureElement,Mt=K("packages/dom/src/annotate.js").AnnotationLayer,Bt=K("packages/dom/src/timelinebar.js").TimelineBar,rt=K("packages/dom/src/commentpaint.js").CommentPainter,ke=K("packages/dom/src/presencepaint.js").PresencePainter,Ie=K("packages/dom/src/commentpanel.js").CommentPanel,Qe=K("packages/dom/src/watermark.js").Watermark,ge=K("packages/dom/src/maximise.js").Maximiser,Pe=K("packages/dom/src/promptbar.js").PromptBar,Be=K("packages/dom/src/kpistrip.js").KpiStrip;function _e(Ke,ht,it){const ct=ht==="redo"?"toolbar.redo":"toolbar.undo";return!it||!it.label?Ke(ct):Ke(ht==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:it.label})}const be=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],Ee=2e3;function ze(Ke,ht,it,ct){const St=ht.annotate===!0?Ve(Ke,ct):[];if(ht.actions===!1)return[];if(ht.actions===void 0&&ht.side!=="left")return St;const Rt=Array.isArray(ht.actions)?ht.actions:be,yt=(zt,tn)=>Ke.messages.t(zt,tn),Nt={undo:{name:"undo",title:()=>_e(yt,"undo",Ke.history.peek("undo")),icon:"undo",run:()=>Ke.history.undo(),enabled:()=>Ke.history.canUndo()},redo:{name:"redo",title:()=>_e(yt,"redo",Ke.history.peek("redo")),icon:"redo",run:()=>Ke.history.redo(),enabled:()=>Ke.history.canRedo()},export:{name:"export",title:()=>yt("toolbar.exportCsv"),icon:"download",run:()=>Ke.export.csv({download:!0,fileName:ht.exportName})},excel:{name:"excel",title:()=>yt("toolbar.exportExcel"),icon:"spreadsheet",run:()=>Ke.export.excel({download:!0,fileName:ht.exportName})},clipboard:{name:"clipboard",title:()=>yt("toolbar.clipboard"),icon:"copy",run:()=>Ke.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>yt("toolbar.print"),icon:"print",run:()=>Ke.export.print()},pause:{name:"pause",title:()=>{if(!Ke.updates.paused)return yt("toolbar.pause");const zt=Ke.updates.stats().pending;return zt?yt("toolbar.applyHeld",{count:zt}):yt("toolbar.resume")},icon:()=>Ke.updates.paused?"play":"pause",run:()=>Ke.updates.paused?Ke.updates.resume():Ke.updates.pause()},restore:{name:"restore",title:()=>yt("toolbar.restoreView"),icon:"restore",run:()=>Ke.state.reset(),enabled:()=>Ke.state.modified()},maximise:{name:"maximise",title:()=>yt(it&&it.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>it&&it.active()?"minimise":"maximise",run:()=>it.toggle()}};return it||delete Nt.maximise,Rt.map(zt=>zt==="-"?{name:"-",separator:!0}:typeof zt=="string"?Nt[zt]:!zt||typeof zt!="object"||!zt.name?null:{...zt,run:V(zt.run)?()=>zt.run({grid:Ke,keys:Ke.selection&&V(Ke.selection.keys)?Ke.selection.keys():[],cells:Ke.selection&&V(Ke.selection.cells)?Ke.selection.cells():[]}):void 0}).filter(Boolean).concat(St)}function Ve(Ke,ht){const it={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight",erase:"eraser"},ct=(Rt,yt)=>Ke.messages.t(Rt,yt),St=["pen","arrow","rect","highlight","erase"].map(Rt=>({name:Rt,title:()=>ct(`toolbar.annotate.${Rt}`),icon:it[Rt],run:()=>Ke.annotate?.use(Rt),active:()=>Ke.annotate?.tool===Rt,annotation:!0}));return St.push(Je(Ke,ct,ht)),St}function Je(Ke,ht,it){return{name:"clearAll",title:()=>ht("toolbar.annotate.clearAll"),icon:"trash",enabled:()=>(Ke.annotate?.count||0)>0,annotation:!0,run:()=>ot(Ke,ht,it)}}function ot(Ke,ht,it){const ct=Ke.toolPanel;if(!ct)return;const St=yt=>it?.announce?.(ht(yt),{repeat:!0});ct.removeAction("clearAll");const Rt=()=>{ct.removeAction("clearAllConfirm"),ct.removeAction("clearAllKeep"),ct.addAction(Je(Ke,ht,it))};ct.addAction({name:"clearAllConfirm",title:()=>ht("toolbar.annotate.clearAllConfirm"),icon:"trash",annotation:!0,run:()=>{Ke.annotate?.clear(),Rt(),St("a11y.annotate.cleared")}}),ct.addAction({name:"clearAllKeep",title:()=>ht("toolbar.annotate.clearAllKeep"),icon:"close",annotation:!0,run:()=>Rt()}),St("a11y.annotate.confirmClear")}const at=["pen","arrow","rect","highlight","erase","clearAll"];function st(Ke){let ht=null,it=null;return Ke.on("source:error",ct=>{const St=ct&&ct.error;it=String(St&&St.message||"").replace(/^\[lattice\]\s*/,"")||(Ke.messages?Ke.messages.t("overlay.error"):"Something went wrong")}),Ke.on("rows:changed",()=>{it=null}),{loadError:()=>it,rowCount:()=>{if(V(Ke.rows.matchCount))return Ke.rows.matchCount();const ct=Ke.pagination&&V(Ke.pagination.get)?Ke.pagination.get():null;return ct&&Number.isFinite(ct.total)?ct.total:Ke.rows.count()},totalRowCount:()=>V(Ke.rows.totalCount)?Ke.rows.totalCount():Ke.rows.count(),selectedAcrossSource:()=>{ht||(ht=V(Ke.rendererHost)?Ke.rendererHost():{});const ct=V(ht.selectionSummary)?ht.selectionSummary():null;return ct&&ct.predicate?{count:ct.count}:null},selectedCount:()=>{const ct=Ke.selection&&Ke.selection.keys?Ke.selection.keys():null;return ct?ct.length:0},rangeValues:()=>{const ct=Ke.selection;return!ct||!V(ct.cells)?[]:ct.cells().map(({key:St,colId:Rt})=>Ke.rows.value(St,Rt))},hiddenUnresolved:()=>V(Ke.comments&&Ke.comments.hiddenUnresolved)?Ke.comments.hiddenUnresolved():0,progress:()=>V(Ke.source&&Ke.source.progress)?Ke.source.progress():null,updateStats:()=>Ke.updates?Ke.updates.stats():null}}function wt(Ke,ht){for(const[it,ct]of Object.entries(h||{}))Ke.register("editor",it,ct);for(const[it,ct]of Object.entries(i||{}))Ke.register("filter",it,ct);for(const[it,ct]of Object.entries(ht.components||{}))Ke.register("component",it,ct);for(const[it,ct]of Object.entries(ht.pipes||{}))Ke.register("pipe",it,ct);for(const[it,ct]of Object.entries(ht.totalFns||{}))Ke.register("totalFn",it,ct)}function kt(Ke,ht,it,ct,St,Rt){const yt=[],Nt=ht.viewport;let zt=null;if(it.maximise!==!1&&(zt=new ge({element:Rt,document:ct,onChange:()=>ht.invalidate("all"),captureScroll:()=>ht.scrollState(),restoreScroll:ut=>ht.restoreScroll(ut)}),Ke.maximise=zt,yt.push(()=>zt.destroy())),it.statusBar){const ut=typeof it.statusBar=="object"?it.statusBar:{},vt=new c;vt.init({document:ct,host:st(Ke),panels:ut.panels,registry:ut.registry,locale:Ke.get("locale"),messages:Ke.messages}),Nt.statusBar.appendChild(vt.element());const Lt=()=>{const sn=Nt.statusBar.offsetHeight||Nt.statusBar.getBoundingClientRect?.().height||0;Nt.root.style.setProperty("--lattice-status-height",`${Math.ceil(sn)}px`)},Ht=()=>{vt.refresh(),Lt()},Kt=["rows:changed","model:changed","source:error","selection:changed","range:changed","rows:queued","rows:paused","rows:resumed","comment:added","comment:edited","comment:deleted","comment:indexLoaded"].map(sn=>Ke.on(sn,Ht));Ht(),Lt(),yt.push(()=>{for(const sn of Kt)sn();Nt.root.style.removeProperty("--lattice-status-height"),vt.destroy?.()})}const tn=oe(it.selection);if(tn.ranges){const ut=new ce({grid:Ke,renderer:ht,document:ct});ut.mount(),Ke.ranges=ut,yt.push(()=>ut.destroy())}if(it.import){const ut=new de({grid:Ke,renderer:ht,document:ct,settings:typeof it.import=="object"?it.import:{}});Ke.importer=ut,yt.push(()=>ut.destroy())}if(it.historyBar){const ut=typeof it.historyBar=="object"?it.historyBar.element:null,vt=new Me;vt.init({document:ct,host:{undo:()=>Ke.history.undo(),redo:()=>Ke.history.redo(),canUndo:()=>Ke.history.canUndo(),canRedo:()=>Ke.history.canRedo(),peek:Ht=>Ke.history.peek(Ht),list:()=>Ke.history.list()},props:typeof it.historyBar=="object"?it.historyBar:{}}),(ut||Nt.root).appendChild(vt.element());const Lt=[Ke.on("history:changed",()=>vt.refresh())];Ke.historyBar=vt,yt.push(()=>{for(const Ht of Lt)Ht();vt.destroy()})}if(it.diff){const ut=new Ce({grid:Ke,renderer:ht});ut.mount(),Ke.diffPainter=ut,yt.push(()=>ut.destroy())}if(it.ai&&V(it.ai.ask)){const ut=new Pe;ut.init({document:ct,grid:Ke,ask:it.ai.ask,schemaOptions:it.ai.schemaOptions,context:it.ai.context,placeholder:it.ai.placeholder});const vt=it.ai.element||Nt.root;vt===Nt.root?vt.insertBefore(ut.element(),vt.firstChild):vt.appendChild(ut.element()),Ke.promptBar=ut,yt.push(()=>ut.destroy())}if(it.groupPanel){const ut=typeof it.groupPanel=="object"?it.groupPanel:{},vt=new p;vt.init({document:ct,grid:Ke,host:J(Ke,ct,(Lt,Ht)=>ht.announce?.(Lt,Ht)),props:{header:Nt.header,hint:ut.hint}}),Nt.root.insertBefore(vt.element(),Nt.header),Ke.groupPanel=vt;for(const Lt of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])V(Ke.on)&&yt.push(Ke.on(Lt,()=>vt.refresh()));yt.push(()=>vt.destroy())}if(it.kpis){const ut=new Be({grid:Ke,document:ct,kpis:it.kpis});ut.active&&(ut.mount(),Nt.root.insertBefore(ut.element(),Nt.header),Ke.kpiStrip=ut,yt.push(()=>ut.destroy()))}if(it.toolPanel){const ut=typeof it.toolPanel=="object"?it.toolPanel:{},vt=new Y({grid:Ke,document:ct,root:Nt.root,panels:ut.panels,openPanel:ut.openPanel,side:ut.side,icons:ut.icons,actions:ze(Ke,ut,zt,ht),announce:(Lt,Ht)=>ht.announce?.(Lt,Ht)});vt.mount(),Ke.toolPanel=vt,yt.push(()=>vt.destroy()),ut.annotate===void 0&&(yt.push(Ke.on("presentation:started",()=>{for(const Lt of Ve(Ke,ht))vt.addAction(Lt)})),yt.push(Ke.on("presentation:ended",()=>{for(const Lt of at)vt.removeAction(Lt)})))}if(!!it.pagination&&(()=>{const ut=typeof it.pagination=="object"?it.pagination:{};return Ke.pagination.set({pageSize:Number(ut.pageSize)||100}),Ke.pagination.get().pageSize>0})()){const ut=typeof it.pagination=="object"?it.pagination:{},vt=new a;vt.init({document:ct,pageSize:ut.pageSize,pageSizes:ut.pageSizes,page:ut.page,total:ut.total,locale:Ke.get("locale"),messages:Ke.messages,onChange:({page:Kt,pageSize:sn})=>Ke.pagination.set({page:Kt,pageSize:sn})});const Lt=()=>{const Kt=Ke.pagination.get();vt.total=Kt.total,vt.counting=Kt.counting===!0,vt.hasMore=Kt.total==null&&Kt.pageCount>Kt.page+1,vt.page=Kt.page,vt.paint()};Ke.pagination.set({pageSize:vt.pageSize}),Lt();const Ht=["rows:changed","filter:changed","model:changed"].map(Kt=>Ke.on(Kt,Lt));Nt.statusBar.appendChild(vt.element()),yt.push(()=>{for(const Kt of Ht)Kt();vt.destroy?.()})}if(it.edit!==!1)if(it.editBar){const ut=new se({grid:Ke,document:ct,root:Nt.root});ut.mount(),Ke.editBar=ut,yt.push(()=>ut.destroy())}else{const ut=new ne({grid:Ke,document:ct,renderer:ht,registry:St,cellLayer:ht.cellLayer});ut.mount(),yt.push(()=>ut.destroy())}const dn=new y({grid:Ke,document:ct,layer:Nt.overlays,registry:St});dn.mount(),yt.push(()=>dn.destroy());const qt=new R({grid:Ke,document:ct,host:Nt.root,cellMenu:it.contextMenu!==!1,headerMenu:it.columnMenu!==!1,items:V(it.contextMenu)?it.contextMenu:void 0,headerItems:V(it.columnMenu)?it.columnMenu:void 0});if(qt.mount(),yt.push(()=>qt.destroy()),Array.isArray(it.alignedGrids)&&it.alignedGrids.length){const ut=new E;ut.add(Ke);for(const vt of it.alignedGrids)vt&&vt!==Ke&&ut.add(vt);yt.push(()=>ut.destroy())}const _t=new G({grid:Ke,renderer:ht,document:ct,registry:St});_t.active&&(_t.mount(),yt.push(()=>_t.destroy())),Object.defineProperty(Ke,"form",{configurable:!0,value:Object.freeze({open(ut){return _t.active?_t.openRow(ut):!1},openNew(ut){return _t.active?_t.openNew(ut):(z("rowform:off","grid.form.openNew() was called on a grid with no row form (rowForm is off, or no renderer is attached); nothing opened."),!1)},close(){_t.active&&_t.close()},save(){return _t.active?_t.save():!1},isOpen(){return _t.active?_t.open:!1}})}),yt.push(()=>{delete Ke.form}),Object.defineProperty(Ke,"icons",{configurable:!0,value:Object.freeze({get(ut){const vt=t(ut);return vt?{viewBox:vt.viewBox,paths:vt.paths.slice(),paint:vt.paint==="stroke"?"stroke":"fill"}:null},names(){return r()}})}),yt.push(()=>{delete Ke.icons});const Tt=new N({grid:Ke,renderer:ht,document:ct});Tt.active&&(Tt.mount(),yt.push(()=>Tt.destroy()));const $t=new j({grid:Ke,renderer:ht,document:ct});$t.active&&($t.mount(),yt.push(()=>$t.destroy()));const Ut=new P({grid:Ke,renderer:ht,document:ct});if(Ut.active){Ut.mount(),Ut.paint();const ut=Ke.on("render:done",()=>Ut.paint());yt.push(()=>{ut(),Ut.destroy()})}if(it.shortcuts!==!1){const ut=new x({grid:Ke,renderer:ht});ut.mount(),yt.push(()=>ut.destroy())}const Wt=new Ne({grid:Ke,renderer:ht,window:ct.defaultView||void 0});Wt.mount(),yt.push(()=>Wt.destroy());const Qt=new He({grid:Ke,renderer:ht,window:ct.defaultView||void 0});if(Qt.mount(),yt.push(()=>Qt.destroy()),it.find!==!1){const ut=new Ae({grid:Ke,renderer:ht,document:ct,settings:it.find});ut.mount(),yt.push(()=>ut.destroy())}const Yt=new Ze({grid:Ke,renderer:ht});Yt.mount(),yt.push(()=>Yt.destroy());const Jt=new lt({grid:Ke,renderer:ht});Jt.mount(),yt.push(()=>Jt.destroy());const rn=new gt({grid:Ke,renderer:ht,maximiser:zt});rn.mount(),yt.push(()=>rn.destroy());const en=new Bt({grid:Ke,renderer:ht});en.mount(),yt.push(()=>en.destroy()),it.environment||Ke.set("environment",()=>({userAgent:typeof navigator=="object"&&navigator?navigator.userAgent:void 0,hardwareConcurrency:typeof navigator=="object"&&navigator?navigator.hardwareConcurrency:void 0,devicePixelRatio:typeof window=="object"&&window?window.devicePixelRatio:void 0,viewport:typeof window=="object"&&window?{width:window.innerWidth,height:window.innerHeight}:void 0,crossOriginIsolated:typeof globalThis.crossOriginIsolated=="boolean"?globalThis.crossOriginIsolated:void 0}));let cn=null;for(const[ut,vt]of[["filter:changed","filter"],["sort:changed","sort"],["rows:changed","data"],["column:resized","resize"],["column:moved","columns"],["column:visible","columns"]])yt.push(Ke.on(ut,()=>{cn=vt}));yt.push(Ke.on("render:done",ut=>{Ke.diagnostics.render(cn||ut.cause,ut.phases),cn=null}));const ln=ct.defaultView;if(ln&&V(ln.requestAnimationFrame)){let ut=ln.requestAnimationFrame(function vt(Lt){Ke.diagnostics.frame(Lt),ut=ln.requestAnimationFrame(vt)});yt.push(()=>{V(ln.cancelAnimationFrame)&&ln.cancelAnimationFrame(ut)})}const yn=new ke({grid:Ke,renderer:ht});if(yn.mount(),yt.push(()=>yn.destroy()),yt.push(Ke.on("presence:lockRefused",ut=>yn.announceRefusal(ut.peer))),Ke.presence&&Ke.presence.enabled){for(const Lt of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])yt.push(Ke.on(Lt,()=>Ke.presence.publish()));let ut="";yt.push(Ke.on("render:done",()=>{const Lt=ht.focusState&&ht.focusState(),Ht=Lt?`${Lt.rowKey}${Lt.colId}`:"";Ht!==ut&&(ut=Ht,Ke.presence.publish())}));const vt=Rt.ownerDocument;if(vt&&V(vt.addEventListener)){const Lt=()=>Ke.presence.setPaused(vt.visibilityState==="hidden");vt.addEventListener("visibilitychange",Lt),Lt(),yt.push(()=>vt.removeEventListener("visibilitychange",Lt))}}const bn=new rt({grid:Ke,renderer:ht});bn.mount(),yt.push(()=>bn.destroy());const wn=new Ie({grid:Ke,renderer:ht});wn.mount(),yt.push(()=>wn.destroy()),yt.push(Ke.on("facet:computed",()=>ht.refreshHeader?.())),tn&&tn.headerCheckbox===!0&&yt.push(Ke.on("selection:changed",()=>ht.refreshHeader?.())),yt.push(Ke.on("facet:expanded",()=>ht.invalidate("columns"))),yt.push(Ke.on("model:changed",()=>ht.invalidate("rows")));const Zt=(ut,vt)=>ht.announce?.(ut,vt),hn=Ke.messages,Gt=(ut,vt)=>hn.t(ut,vt),gn=ut=>Gt("count.rows",{count:ut});yt.push(Ke.on("sort:changed",()=>{const ut=Ke.sort.get();if(!ut.length){Zt(Gt("a11y.sort.cleared"));return}const vt=ut.map(Lt=>{const Ht=Ke.columns.get(Lt.col);return Gt("a11y.sort.column",{column:Ht&&Ht.title||Lt.col,direction:Gt(Lt.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});Zt(Gt("a11y.sort.by",{columns:hn.list(vt)}))})),yt.push(Ke.on("filter:changed",()=>{const ut=Ke.rows.matchCount?Ke.rows.matchCount():Ke.rows.count();if(ut===null)return;const vt=Ke.rows.totalCount?Ke.rows.totalCount():ut;Zt(ut===vt?Gt("a11y.filter.cleared",{rows:gn(vt)}):Gt("a11y.filter.applied",{shown:gn(ut),total:gn(vt)}))})),yt.push(Ke.on("selection:changed",()=>{const ut=Ke.selection.keys().length;Zt(ut===0?Gt("a11y.selection.cleared"):Gt("a11y.selection.count",{count:ut}))})),yt.push(Ke.on("group:toggled",ut=>{const vt=Ke.rows.byKey?Ke.rows.byKey(ut.key):null,Lt=(vt&&(vt.groupLabel??vt.groupValue))??ut.key;Zt(Gt(ut.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:Lt,rows:gn(Ke.rows.count())}))})),yt.push(Ke.on("column:grouped",ut=>{const vt=Array.isArray(ut.columns)?ut.columns:[];if(!vt.length){Zt(Gt("a11y.group.cleared"));return}const Lt=vt.map(Ht=>{const Kt=Ke.columns.get(Ht);return Kt&&Kt.title||Ht});Zt(Gt("a11y.group.by",{columns:hn.list(Lt)}))})),yt.push(Ke.on("page:changed",ut=>{const vt=Number(ut.size)||0,Lt=Number(ut.total)||0,Ht=vt>0?Math.max(1,Math.ceil(Lt/vt)):1;Zt(Gt("a11y.page.position",{page:(Number(ut.page)||0)+1,pages:Ht}))}));let on={added:0,removed:0},Xt=null;const Ln=()=>{Xt=null;const ut=[];on.added&&ut.push(Gt("count.rowsAdded",{count:on.added})),on.removed&&ut.push(Gt("count.rowsRemoved",{count:on.removed})),on={added:0,removed:0},ut.length&&Zt(hn.list(ut))};yt.push(Ke.on("rows:changed",ut=>{if(!ut||typeof ut.added!="number")return;const vt=Number(ut.added)||0,Lt=Number(ut.removed)||0;!vt&&!Lt||(on.added+=vt,on.removed+=Lt,Xt||(Xt=setTimeout(Ln,Ee)))})),yt.push(()=>{Xt&&clearTimeout(Xt)}),yt.push(Ke.on("rows:paused",()=>{Xt&&(clearTimeout(Xt),Xt=null),on={added:0,removed:0},Zt(Gt("a11y.updates.paused"),{repeat:!0})})),yt.push(Ke.on("rows:resumed",()=>Zt(Gt("a11y.updates.resumed"),{repeat:!0})));let fn={count:0,first:null},pn=null;const Cn=()=>{pn=null;const{count:ut,first:vt}=fn;if(fn={count:0,first:null},!ut||!vt)return;const Lt=Ke.columns.get(vt.colId),Ht=Lt&&Lt.title||vt.colId,Kt=vt.reason?Gt("a11y.edit.reason",{reason:vt.reason}):"";if(ut===1){const sn=vt.restored===void 0||vt.restored===null||vt.restored===""?Gt("value.empty"):String(vt.restored);Zt(Gt("a11y.edit.refusedOne",{column:Ht,value:sn,reason:Kt}),{repeat:!0});return}Zt(Gt("a11y.edit.refusedMany",{count:ut,reason:Kt}),{repeat:!0})};yt.push(Ke.on("cell:reverted",ut=>{!ut||!ut.applied||(fn.count+=1,fn.first||(fn.first=ut),pn||(pn=setTimeout(Cn,150)))})),yt.push(()=>{pn&&clearTimeout(pn)}),yt.push(Ke.on("history:applied",ut=>{const vt=!!(ut&&ut.direction==="redo"),Lt=ut&&ut.step&&ut.step.label;Zt(Lt?Gt(vt?"a11y.history.redo":"a11y.history.undo",{label:Lt}):Gt(vt?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const vn=new Mt({grid:Ke,renderer:ht,seed:it.state&&Array.isArray(it.state.annotations)?it.state.annotations:null});vn.mount(),yt.push(()=>vn.destroy()),Ke.annotate=vn,Ke.capture=async(ut={})=>{const{blob:vt,width:Lt,height:Ht}=await Pt(ht.viewport.root,ut);return(ut.download===!0||ut.download!==!1&&ut.fileName)&&X(vt,ut.fileName||`${Ke.get("exportName")||"grid"}.png`),Ke.emit("presentation:captured",{width:Lt,height:Ht,bytes:vt.size,mimeType:vt.type,fileName:ut.fileName||null},"api"),vt};const En=new Qe({grid:Ke,document:ct,element:Nt.overlays,window:ct.defaultView||void 0});En.mount(),yt.push(()=>En.destroy());const Fn=new f({grid:Ke,document:ct,element:Nt.overlays});Fn.mount?.(),yt.push(()=>Fn.destroy?.());const Tn=new O({grid:Ke,host:Ke.rendererHost(),viewport:Nt,document:ct});return Tn.mount(),yt.push(()=>Tn.destroy()),yt}function mt(Ke){const ht=[],it=ct=>{if(ct&&(ct.__lattice&&ht.push(ct),ct.children))for(const St of ct.children)it(St)};return it(Ke),ht}function Et(Ke,ht={}){(!Ke||typeof Ke!="object"||!("appendChild"in Ke))&&H("createGrid needs a host element as its first argument."),ht=I(ht);const it=Ke.ownerDocument||(typeof document<"u"?document:null);it||H("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const ct=it.documentElement&&it.documentElement.lang,St=!ht.licence&&V(it.querySelector)?it.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,Rt={...ht};if(!ht.locale&&ct&&(Rt.locale=ct),St&&(Rt.licence=St),ht.views&&ht.views.local)if(ht.views.storage)z("views:local:ignored","[lattice] views.local is ignored because views.storage was also supplied; the explicit adapter wins.");else{const qt=ht.views.local===!0?{}:ht.views.local;Rt.views={...ht.views,storage:A(qt)}}const yt=$(Rt),Nt=yt.rendererHost();Nt.document=it,wt(Nt.registry,ht),Nt.cellLayer=o(Nt),Nt.detailHost=new we({grid:yt,document:Ke.ownerDocument||globalThis.document,createGrid:(qt,_t)=>Et(qt,_t)});const zt=new l(Ke,Nt),tn=yt.on("detail:toggled",()=>{Nt.detailHost.syncTarget(),Nt.detailHost.prune()}),mn=yt.on("config:changed",qt=>{qt&&qt.key==="detail"&&Nt.detailHost.reconfigure()});yt.on("destroy",()=>{tn(),mn(),Nt.detailHost.destroy()}),Nt.detailHost.syncTarget(),yt.attachRenderer(zt),zt.mount();const an=kt(yt,zt,ht,it,Nt.registry,Ke),dn=yt.destroy.bind(yt);return yt.destroy=()=>{for(const qt of an)try{qt()}catch{}Ke.__lattice===yt&&(Ke.__lattice=null),dn()},Ke.__lattice=yt,yt}}),Fe("packages/dom/src/hydrate.js",function(e,K){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"HYDRATE_CONFIG_ATTR",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"hydrateInto",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return f}});const Q=K("packages/core/src/internal/util.js"),$=Q.isFunction,B=Q.warnOnce,I=K("packages/core/src/columns/datatypes.js"),_=I.BUILTIN_TYPES,X=I.parseNumberText,H=K("packages/core/src/columns/types/index.js").EXTENDED_TYPES,z=K("packages/core/src/format/boolean.js").toTriState,w=K("packages/core/src/format/date.js"),A=w.toIsoDate,g=w.toIsoDateTime,d=K("packages/dom/src/createGrid.js").createGrid,o=new Set([...Object.keys(_),...Object.keys(H)]);function n(a,p){for(const b of a.children)if(b.tagName===p.toUpperCase())return b;return null}function t(a,p){const b=[];for(const O of a.children)O.tagName===p.toUpperCase()&&b.push(O);return b}function r(a,p){const b=$(a.getAttribute)?a.getAttribute("data-field"):null;return b||String(a.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${p}`}function s(a){const p=a.trim();if(p==="")return null;if(p==="true"||p==="false")return p==="true";const b=Number(p);return Number.isFinite(b)&&p!==""?b:p}function h(a,p){return p==="text"?a===""?null:a:p==="boolean"?z(a):p==="number"?X(a):p==="date"||p==="dateString"?A(a):p==="datetime"?g(a):s(a)}function u(a){const p=n(a,"thead"),b=n(p||a,"tr"),k=(b?t(b,"th").length?t(b,"th"):t(b,"td"):[]).map((S,x)=>{const C=r(S,x),P={id:C,field:C,title:String(S.textContent||"").trim()||C},F=$(S.getAttribute)?S.getAttribute("data-type"):null;F&&(o.has(F)?P.type=F:B(`hydrate.unknownType:${F}`,`data-type "${F}" on column "${C}" is not a built-in type name, so it was ignored; the column falls back to sampled shape typing.`));const E=$(S.getAttribute)?S.getAttribute("data-format"):null;return E&&(P.format=E),P}),y=n(a,"tbody"),R=(y?t(y,"tr"):t(a,"tr").filter(S=>S!==b)).map((S,x)=>{const C=t(S,"td"),F={__row:($(S.getAttribute)?S.getAttribute("data-id"):null)||`row${x}`};return k.forEach((E,D)=>{F[E.field]=C[D]?E.type?h(String(C[D].textContent||""),E.type):s(String(C[D].textContent||"")):null}),F});return{columns:k,rows:R}}function i(a,p){if(p===void 0)return a;if(p!==null&&typeof p=="object"&&!Array.isArray(p)&&Array.isArray(p.only))return p.only;if(!Array.isArray(p))return p;const b=new Map;for(const k of p)if(k&&typeof k=="object"){const y=k.id??k.field;y!=null&&b.set(y,k)}const O=a.map(k=>{const y=b.get(k.id)??b.get(k.field);return y===void 0?k:{...k,...y}});for(const[k,y]of b)a.some(v=>v.id===k||v.field===k)||O.push({...y});return O}const m="data-lattice-hydrate-config";function c(a,p,b={}){const{columns:O,rows:k}=u(p);return d(a,{rowKey:"__row",...b,columns:i(O,b.columns),rows:b.rows!==void 0?b.rows:k})}function f(a,p={}){const b=a.ownerDocument.createElement("div");b.setAttribute("data-lattice-hydrated",""),a.removeAttribute("data-lattice-grid"),b.__latticeTable=a;try{b.setAttribute(m,JSON.stringify(p))}catch{b.setAttribute(m,"{}")}return a.parentNode.insertBefore(b,a),a.parentNode.removeChild(a),c(b,a,p)}}),Fe("packages/dom/src/autoinit.js",function(e,K){"use strict";Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return z}});const $=K("packages/core/src/internal/util.js").isFunction,I=K("packages/dom/src/createGrid.js").createGrid,X=K("packages/dom/src/hydrate.js").hydrateTable;function W(w,A){const g=[];return $(w.hasAttribute)&&w.hasAttribute(A)&&g.push(w),$(w.querySelectorAll)&&g.push(...w.querySelectorAll(`[${A}]`)),g}function H(w){const A=w.parentNode;if(!A||!A.children)return null;const g=[...A.children],l=g.indexOf(w),d=[g[l+1],g[l-1]];for(const o of d)if(o&&o.tagName==="SCRIPT"&&$(o.getAttribute)&&o.hasAttribute("data-lattice-config"))return o;return null}function V(w){const A=H(w);if(!A)return{};try{return JSON.parse(A.textContent||"{}")}catch(g){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",g),{}}}function z(w){const A=w||(typeof document<"u"?document:null);if(!A)return[];const g=[];for(const l of W(A,"data-lattice-grid")){if(l.__lattice)continue;const d=V(l);g.push(l.tagName==="TABLE"?X(l,d):I(l,d))}return g}}),Fe("packages/dom/src/index.js",function(e,K){"use strict";Object.defineProperty(e,"LatticeGrid",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return x}});const Q=K("packages/dom/src/createGrid.js"),$=Q.createGrid,B=K("packages/dom/src/hydrate.js"),I=B.hydrateTable,_=K("packages/dom/src/autoinit.js"),X=_.autoInit,W=K("packages/dom/src/localviews.js"),H=W.createLocalViewStorage,V=K("packages/core/src/index.js"),z=V.createHeadlessGrid,w=V.registerModules,A=V.setLicence,g=V.version,l=V.getVersion,d=V.serialiseState,o=V.restoreState,n=V.defaults;Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return Q.createGrid}}),Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return Q.gridElementsWithin}});const t=K("packages/dom/src/stat.js");Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return t.createStat}}),Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return t.deltaOf}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return t.toneOf}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return B.readTable}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return B.hydrateTable}}),Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return _.autoInit}}),Object.defineProperty(e,"createLocalViewStorage",{enumerable:!0,get:function(){return W.createLocalViewStorage}}),Object.defineProperty(e,"DEFAULT_VIEWS_KEY",{enumerable:!0,get:function(){return W.DEFAULT_VIEWS_KEY}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return V.createHeadlessGrid}}),Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return V.defaults}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return V.version}}),Object.defineProperty(e,"getVersion",{enumerable:!0,get:function(){return V.getVersion}}),Object.defineProperty(e,"Grid",{enumerable:!0,get:function(){return V.Grid}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return V.EventBus}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return V.Registry}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return V.sharedRegistry}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return V.registerModules}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return V.parseLicence}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return V.verifyLicence}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return V.licenceInfo}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return V.watermark}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return V.setLicence}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return V.licenceState}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return V.isLocalHost}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return V.matchesDomain}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return V.LicenceHolder}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return V.ColumnModel}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return V.buildGraph}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return V.Lookup}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return V.ValuePipeline}}),Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return V.compileFormat}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return V.compileMask}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return V.specToOoxml}}),Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return V.EXTENDED_TYPES}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return V.createRadixType}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return V.RADIX_PRESETS}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return V.parseRadix}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return V.formatRadix}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return V.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return V.registerUnitSystem}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return V.defineUnit}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return V.UNIT_SYSTEMS}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return V.parseUnit}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return V.formatUnit}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return V.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return V.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return V.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return V.convertMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return V.rateFunction}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return V.MISSING_RATE}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return V.Messages}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return V.createMessages}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return V.auditCatalogue}}),Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return V.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return V.MESSAGE_KEYS}}),Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return V.DEFAULT_LOCALE}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return V.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return V.resolveLocale}}),Object.defineProperty(e,"LOCALES",{enumerable:!0,get:function(){return V.LOCALES}}),Object.defineProperty(e,"resolveCatalogue",{enumerable:!0,get:function(){return V.resolveCatalogue}}),Object.defineProperty(e,"EN_US",{enumerable:!0,get:function(){return V.EN_US}}),Object.defineProperty(e,"FR_FR",{enumerable:!0,get:function(){return V.FR_FR}}),Object.defineProperty(e,"FR_CA",{enumerable:!0,get:function(){return V.FR_CA}}),Object.defineProperty(e,"IT_IT",{enumerable:!0,get:function(){return V.IT_IT}}),Object.defineProperty(e,"ES_ES",{enumerable:!0,get:function(){return V.ES_ES}}),Object.defineProperty(e,"PT_BR",{enumerable:!0,get:function(){return V.PT_BR}}),Object.defineProperty(e,"DE_DE",{enumerable:!0,get:function(){return V.DE_DE}}),Object.defineProperty(e,"NL_NL",{enumerable:!0,get:function(){return V.NL_NL}}),Object.defineProperty(e,"SV_SE",{enumerable:!0,get:function(){return V.SV_SE}}),Object.defineProperty(e,"DA_DK",{enumerable:!0,get:function(){return V.DA_DK}}),Object.defineProperty(e,"NB_NO",{enumerable:!0,get:function(){return V.NB_NO}}),Object.defineProperty(e,"FI_FI",{enumerable:!0,get:function(){return V.FI_FI}}),Object.defineProperty(e,"PL_PL",{enumerable:!0,get:function(){return V.PL_PL}}),Object.defineProperty(e,"CS_CZ",{enumerable:!0,get:function(){return V.CS_CZ}}),Object.defineProperty(e,"HU_HU",{enumerable:!0,get:function(){return V.HU_HU}}),Object.defineProperty(e,"RO_RO",{enumerable:!0,get:function(){return V.RO_RO}}),Object.defineProperty(e,"UK_UA",{enumerable:!0,get:function(){return V.UK_UA}}),Object.defineProperty(e,"EL_GR",{enumerable:!0,get:function(){return V.EL_GR}}),Object.defineProperty(e,"JA_JP",{enumerable:!0,get:function(){return V.JA_JP}}),Object.defineProperty(e,"AR",{enumerable:!0,get:function(){return V.AR}}),Object.defineProperty(e,"AR_SA",{enumerable:!0,get:function(){return V.AR_SA}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return V.ColumnStore}}),Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return V.Bitset}}),Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return V.Dictionary}}),Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return V.MultiValue}}),Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return V.MaskPool}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return V.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return V.sortMulti}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return V.evaluateFilters}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return V.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return V.testValue}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return V.groupByColumns}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return V.total}}),Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return V.TOTAL_FNS}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return V.pivot}}),Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return V.Window}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return V.openWindow}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return V.WINDOW_KINDS}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return V.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return V.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return V.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return V.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return V.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return V.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return V.anomalyCondition}}),Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return V.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return V.forecast}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return V.evaluateFormula}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return V.parseFormula}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return V.referencesOf}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return V.looksLikeFormula}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return V.FormulaError}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return V.FUNCTIONS}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return V.compileRules}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return V.ingest}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return V.ingestSync}}),Object.defineProperty(e,"createSource",{enumerable:!0,get:function(){return V.createSource}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return V.createMemorySource}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return V.createPagedSource}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return V.createRemoteSource}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return V.createStreamSource}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return V.createUrlSource}}),Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return V.PROTOCOL}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return V.createPushdownSource}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return V.planQuery}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return V.splitFilters}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return V.applyResidual}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return V.capabilitiesOf}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return V.resolveMutate}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return V.NO_CAPABILITIES}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return V.odataAdapter}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return V.filtersToOData}}),Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return V.conditionToOData}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return V.restAdapter}}),Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return V.DEFAULT_PARAMS}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return V.dfqlAdapter}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return V.duckdbAdapter}}),Object.defineProperty(e,"filtersToSql",{enumerable:!0,get:function(){return V.filtersToSql}}),Object.defineProperty(e,"graphqlAdapter",{enumerable:!0,get:function(){return V.graphqlAdapter}}),Object.defineProperty(e,"splunkAdapter",{enumerable:!0,get:function(){return V.splunkAdapter}}),Object.defineProperty(e,"clickhouseAdapter",{enumerable:!0,get:function(){return V.clickhouseAdapter}}),Object.defineProperty(e,"elasticsearchAdapter",{enumerable:!0,get:function(){return V.elasticsearchAdapter}}),Object.defineProperty(e,"RowModel",{enumerable:!0,get:function(){return V.RowModel}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return V.createRowKey}}),Object.defineProperty(e,"SelectionModel",{enumerable:!0,get:function(){return V.SelectionModel}}),Object.defineProperty(e,"RangeModel",{enumerable:!0,get:function(){return V.RangeModel}}),Object.defineProperty(e,"EditModel",{enumerable:!0,get:function(){return V.EditModel}}),Object.defineProperty(e,"ChangeModel",{enumerable:!0,get:function(){return V.ChangeModel}}),Object.defineProperty(e,"StateModel",{enumerable:!0,get:function(){return V.StateModel}}),Object.defineProperty(e,"STATE_VERSION",{enumerable:!0,get:function(){return V.STATE_VERSION}}),Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return V.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return V.restoreState}}),Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return V.VERSION}});const r=K("packages/dom/src/renderer/index.js");Object.defineProperty(e,"DomRenderer",{enumerable:!0,get:function(){return r.DomRenderer}});const s=K("packages/dom/src/filtermenu.js");Object.defineProperty(e,"FilterMenu",{enumerable:!0,get:function(){return s.FilterMenu}}),Object.defineProperty(e,"mergeColumnFilter",{enumerable:!0,get:function(){return s.mergeColumnFilter}}),Object.defineProperty(e,"branchFor",{enumerable:!0,get:function(){return s.branchFor}});const h=K("packages/dom/src/columnmenu.js");Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return h.ColumnMenu}}),Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return h.columnMenuItems}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return h.cellMenuItems}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return h.autoGroupMenuItems}});const u=K("packages/dom/src/alignedgrids.js");Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return u.AlignedGrids}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return u.alignGrids}}),Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return u.layoutState}});const i=K("packages/dom/src/toolpanelmount.js");Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return i.ToolPanelDock}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return i.panelHost}}),Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return i.mountPanel}});const m=K("packages/dom/src/celledit.js");Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return m.CellEditController}});const c=K("packages/dom/src/editbar.js");Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return c.EditBar}});const f=K("packages/dom/src/historybar.js");Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return f.HistoryBar}}),Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return f.HISTORY_CLS}});const a=K("packages/dom/src/diffpaint.js");Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return a.DiffPainter}});const p=K("packages/dom/src/viewpicker.js");Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return p.ViewPicker}}),Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return p.VIEW_CLS}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return p.summariseDiff}});const b=K("packages/dom/src/promptbar.js");Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return b.PromptBar}}),Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return b.PROMPT_CLASS}});const O=K("packages/dom/src/cell/index.js");Object.defineProperty(e,"createCellLayer",{enumerable:!0,get:function(){return O.createCellLayer}}),Object.defineProperty(e,"compileTemplate",{enumerable:!0,get:function(){return O.compileTemplate}}),Object.defineProperty(e,"compileVariant",{enumerable:!0,get:function(){return O.compileVariant}}),Object.defineProperty(e,"checkVariant",{enumerable:!0,get:function(){return O.checkVariant}}),Object.defineProperty(e,"VariantRegistry",{enumerable:!0,get:function(){return O.VariantRegistry}}),Object.defineProperty(e,"BUILTIN_RENDERERS",{enumerable:!0,get:function(){return O.BUILTIN_RENDERERS}}),Object.defineProperty(e,"BUILTIN_VARIANTS",{enumerable:!0,get:function(){return O.BUILTIN_VARIANTS}}),Object.defineProperty(e,"BUILTIN_PIPES",{enumerable:!0,get:function(){return O.BUILTIN_PIPES}}),Object.defineProperty(e,"sanitiseHtml",{enumerable:!0,get:function(){return O.sanitiseHtml}});const k=K("packages/dom/src/editors/index.js");Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return k.editors}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return k.createEditor}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return k.editorFor}}),Object.defineProperty(e,"BaseEditor",{enumerable:!0,get:function(){return k.BaseEditor}});const y=K("packages/dom/src/filters/index.js");Object.defineProperty(e,"filters",{enumerable:!0,get:function(){return y.filters}}),Object.defineProperty(e,"createFilter",{enumerable:!0,get:function(){return y.createFilter}}),Object.defineProperty(e,"filterFor",{enumerable:!0,get:function(){return y.filterFor}}),Object.defineProperty(e,"parseExpression",{enumerable:!0,get:function(){return y.parseExpression}}),Object.defineProperty(e,"ConditionFilter",{enumerable:!0,get:function(){return y.ConditionFilter}});const v=K("packages/dom/src/ui/index.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return v.StatusBar}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return v.ContextMenu}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return v.ToolPanel}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return v.TooltipManager}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return v.Pagination}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return v.OverlayLayer}});const R=K("packages/core/src/registry/licence.js");Object.defineProperty(e,"setLicense",{enumerable:!0,get:function(){return R.setLicence}}),Object.defineProperty(e,"licenseInfo",{enumerable:!0,get:function(){return R.licenceInfo}}),Object.defineProperty(e,"licenseState",{enumerable:!0,get:function(){return R.licenceState}});const S=Object.freeze({createGrid:$,createHeadlessGrid:z,defaults:n,registerModules:w,setLicence:A,version:g,autoInit:X,hydrateTable:I,serialiseState:d,restoreState:o,createLocalViewStorage:H}),x=S});try{Kn("packages/worker/src/inline.js").setWorkerSource('(function(Ot){"use strict";var ct=Object.create(null),lt=Object.create(null);function Ce(o,me){ct[o]=me}function at(o){var me=lt[o];if(me)return me;var ae=Object.create(null);lt[o]=ae;var he=ct[o];if(!he)throw new Error("[lattice] missing module: "+o);return he(ae,at),ae}Ce("packages/core/src/internal/util.js",function(o,me){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"pathSetter",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"escapeHtml",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"titleCase",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"expand",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return Se}});const ae="1.86.5";async function he(){return ae}const W="1.86.5",U=new Set,_=2e3;function Z(D){if(U.add(D),U.size>_){const x=U.values().next().value;x!==void 0&&U.delete(x)}}const E=[],z=500;function re(D,x,fe){E.push({key:D,level:x,message:fe.map(p=>typeof p=="string"?p:Y(p)).join(" "),at:Date.now()}),E.length>z&&E.shift()}function Y(D){if(D instanceof Error)return D.message;try{return JSON.stringify(D)}catch{return String(D)}}function se(){return E.map(D=>({...D}))}function te(D){if(D.length===0||typeof D[0]!="string")return D;const x=D[0].replace(/^\\[lattice\\]\\s*/,"");return x===D[0]?D:[x,...D.slice(1)]}function H(D,...x){if(U.has(D))return;Z(D);const fe=te(x);re(D,"warn",fe),console.warn("[lattice]",...fe)}function T(D,...x){if(U.has(D))return;Z(D);const fe=te(x);re(D,"info",fe),console.info("[lattice]",...fe)}function V(){U.clear(),E.length=0}function ne(D,x){const fe=new Error(`[lattice] ${D}`);throw x!==void 0&&(fe.cause=x),fe}function R(D,x){D||ne(x)}const j=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function i(D){return D!==null&&typeof D=="object"&&!Array.isArray(D)}function a(D){return typeof D=="function"}function s(D){return D==null}function h(D){return D==null||D===""}function u(D){return typeof D!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(D))?!0:!!(D.prototype&&Object.getOwnPropertyNames(D.prototype).length>1)}const t=new Map;function l(D){let x=t.get(D);if(x)return x;if(!D.includes("."))x=fe=>fe?.[D];else{const fe=D.split("."),p=fe.length;x=Q=>{let X=Q;for(let ce=0;ce<p;ce++){if(X==null)return;X=X[fe[ce]]}return X}}return t.set(D,x),x}const m=new Map;function e(D){let x=m.get(D);if(x)return x;if(!D.includes("."))x=(fe,p)=>{fe!=null&&(fe[D]=p)};else{const fe=D.split("."),p=fe.length-1;x=(Q,X)=>{let ce=Q;for(let le=0;le<p;le++){if(ce==null)return;const ge=fe[le];ce[ge]==null&&(ce[ge]={}),ce=ce[ge]}ce!=null&&(ce[fe[p]]=X)}}return m.set(D,x),x}function d(D,x){return l(x)(D)}function f(D,x,fe){e(x)(D,fe)}function r(D){return D?(D.includes(".")?D.slice(D.lastIndexOf(".")+1):D).replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/\\s+/g," ").trim().replace(/^./,fe=>fe.toUpperCase()):""}const n={"&":"&","<":"<",">":">",\'"\':""","\'":"'"};function c(D){const x=D==null?"":String(D);return/[&<>"\']/.test(x)?x.replace(/[&<>"\']/g,fe=>n[fe]):x}function g(D){return String(D).replace(/\\w\\S*/g,x=>x[0].toUpperCase()+x.slice(1).toLowerCase())}function A(D,x,fe){if(D!==void 0)return D===!0?{enabled:!0,...fe}:D===!1?{enabled:!1}:i(D)?D:{[x]:D,enabled:!0}}function P(D){return D==null?[]:Array.isArray(D)?D:[D]}const q=Object.freeze(new Set(["__proto__","constructor","prototype"]));function L(D,x){if(!i(D))return i(x)?{...x}:x;if(!i(x))return x===void 0?D:x;const fe={...D};for(const p of Object.keys(x)){if(q.has(p))continue;const Q=x[p];Q!==void 0&&(fe[p]=i(Q)&&i(fe[p])?L(fe[p],Q):Q)}return fe}function v(D,x){if(!i(D)||!i(x)||D===x)return x;const fe=Object.create(Object.getPrototypeOf(D));return Object.assign(fe,D,x),fe}class G{#t;#e=new Map;#n;constructor(x=256,fe=null){this.#t=x,this.#n=fe}get size(){return this.#e.size}get max(){return this.#t}set max(x){this.#t=x,this.#r()}has(x){return this.#e.has(x)}get(x){const fe=this.#e;if(!fe.has(x))return;const p=fe.get(x);return fe.delete(x),fe.set(x,p),p}peek(x){return this.#e.get(x)}set(x,fe){const p=this.#e;return p.has(x)&&p.delete(x),p.set(x,fe),this.#r(),fe}delete(x){const fe=this.#e.get(x);return this.#e.delete(x)&&this.#n&&this.#n(fe,x),fe}clear(){if(this.#n)for(const[x,fe]of this.#e)this.#n(fe,x);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const x=this.#e;for(;x.size>this.#t;){const fe=x.keys().next().value,p=x.get(fe);x.delete(fe),this.#n&&this.#n(p,fe)}}}const S=new Map;function N(D,x){const fe=`${D||""}|${x?JSON.stringify(x):""}`;let p=S.get(fe);return p||(p=new Intl.Collator(D||void 0,{numeric:!0,sensitivity:"variant",...x}),S.set(fe,p)),p}function I(D,x){if(D===x)return 0;if(D==null)return 1;if(x==null)return-1;if(typeof D=="number"&&typeof x=="number")return Number.isNaN(D)?Number.isNaN(x)?0:1:Number.isNaN(x)||D<x?-1:D>x?1:0;const fe=String(D),p=String(x);return fe<p?-1:fe>p?1:0}function K(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const B=typeof requestAnimationFrame=="function";function ee(D){return B?requestAnimationFrame(D):setTimeout(()=>D(K()),16)}function J(D){D!=null&&(B?cancelAnimationFrame(D):clearTimeout(D))}function ue(D){let x=null,fe=null;const p=()=>{x=null;const X=fe;fe=null,D(...X||[])},Q=(...X)=>{fe=X,x===null&&(x=ee(p))};return Q.cancel=()=>{J(x),x=null,fe=null},Q.flush=()=>{x!==null&&(J(x),p())},Q}function de(D,x){let fe=null,p=null;const Q=()=>{if(fe=null,p===null)return;const le=p;p=null,D(...le),X()},X=()=>{fe=setTimeout(Q,x),typeof fe?.unref=="function"&&fe.unref()},ce=(...le)=>{fe===null?(D(...le),X()):(p=le,clearTimeout(fe),X())};return ce.flush=()=>{if(fe!==null&&clearTimeout(fe),fe=null,p===null)return;const le=p;p=null,D(...le)},ce.cancel=()=>{fe!==null&&clearTimeout(fe),fe=null,p=null},ce.pending=()=>fe!==null||p!==null,ce}function Oe(D,x=50){return typeof requestIdleCallback=="function"?requestIdleCallback(D,{timeout:x}):setTimeout(()=>D({timeRemaining:()=>0,didTimeout:!0}),1)}let Ae=0;function Se(D="l"){return`${D}${(++Ae).toString(36)}`}}),Ce("packages/worker/src/transport.js",function(o,me){"use strict";Object.defineProperty(o,"PROTOCOL",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"OPS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"ERRORS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"packHandle",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"packHandles",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"TransportedDictionary",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const ae=me("packages/core/src/internal/util.js"),he=ae.collator,W=ae.isFunction,U=1,_=Object.freeze({SORT_COLUMN:"sortColumn",SORT_MULTI:"sortMulti",EVALUATE_FILTERS:"evaluateFilters",COMPACT:"compact",GROUP_BY_COLUMNS:"groupByColumns",TOTAL:"total",PIVOT:"pivot",FACET:"facet",COLUMNIZE:"columnize",COLLATE_STRING_RANKS:"collateStringRanks"}),Z=Object.freeze({READY:"ready",CANCEL:"cancel",PING:"ping"}),E=Object.freeze({NO_COMPUTE:"E_NO_COMPUTE",NO_KERNEL:"E_NO_KERNEL",ABORTED:"E_ABORTED",KERNEL:"E_KERNEL",PROTOCOL:"E_PROTOCOL"});function z(a){if(a==null)return null;const s=a.presence;return{id:a.id,kind:a.kind,nullable:!!a.nullable,values:a.values??null,presence:s?s.words??s:null,presenceBits:s?s.size??(s.words??s).length*8:0,dict:a.dict?re(a.dict):null,offsets:a.offsets??null,version:a.version??0}}function re(a){return Array.isArray(a)?a:W(a.values)?a.values():[]}function Y(a){const s=new Array(a.length);for(let h=0;h<a.length;h++)s[h]=z(a[h]);return s}class se{#t;#e;constructor(s,h){this.#t=s,this.#e=h}get words(){return this.#t}get size(){return this.#e}get(s){return(this.#t[s>>>3]&1<<(s&7))!==0}count(){const s=this.#t;let h=0;for(let u=0;u<s.length;u++){let t=s[u];for(;t;)t&=t-1,h++}return h}}class te{#t;#e=null;#n=0;#r=new Map;constructor(s){this.#t=s||[]}get size(){return this.#t.length}get version(){return this.#n}codeOf(s){if(this.#e===null){this.#e=new Map;for(let t=0;t<this.#t.length;t++)this.#e.set(this.#t[t],t)}const h=this.#e.get(s);if(h!==void 0)return h;const u=this.#t.length;return this.#t.push(s),this.#e.set(s,u),this.#n++,u}valueOf(s){return this.#t[s]}values(){return this.#t}ranks(s){const h=s||"",u=this.#r.get(h);if(u&&u.version===this.#n)return u.ranks;const t=this.#t.length,l=new Uint32Array(t);for(let r=0;r<t;r++)l[r]=r;const m=he(s).compare,e=this.#t,d=Array.from(l).sort((r,n)=>{const c=e[r],g=e[n];return c===g?0:c==null?1:g==null?-1:m(String(c),String(g))}),f=new Uint32Array(t);for(let r=0;r<d.length;r++)f[d[r]]=r;return this.#r.set(h,{version:this.#n,ranks:f}),f}}function H(a){if(a==null)return null;const s=a.presence?new se(a.presence,a.presenceBits||a.presence.length*8):null,h=a.dict?new te(a.dict):null,u=a.values,t=a.offsets??null,l=a.kind,m=e=>{if(s&&!s.get(e))return null;switch(l){case"dictionary":return h?h.valueOf(u[e]):u[e];case"bitset":return(u[e>>>3]&1<<(e&7))!==0;case"multi":{if(!t)return null;const d=t[e],f=t[e+1],r=new Array(f-d);for(let n=d;n<f;n++)r[n-d]=h?h.valueOf(u[n]):u[n];return r}default:return u[e]}};return{id:a.id,kind:l,nullable:a.nullable,values:u,presence:s,dict:h,offsets:t,get:m,version:a.version}}function T(a){const s=new Array(a.length);for(let h=0;h<a.length;h++)s[h]=H(a[h]);return s}function V(){const a=[],s=[];return{mask(h){for(let u=0;u<a.length;u++)if(a[u].length>=h){const t=a.splice(u,1)[0].subarray(0,h);return t.fill(0),t}return new Uint8Array(h)},indices(h){for(let u=0;u<s.length;u++)if(s[u].length>=h)return s.splice(u,1)[0].subarray(0,h);return new Uint32Array(h)},release(h){h&&(h instanceof Uint8Array?a.push(h):h instanceof Uint32Array&&s.push(h))},clear(){a.length=0,s.length=0}}}function ne(a){if(!ArrayBuffer.isView(a))return!1;const s=a.buffer;return s?typeof SharedArrayBuffer>"u"||!(s instanceof SharedArrayBuffer):!1}function R(a,s=[]){const h=u=>{if(!ne(u))return;const t=u.buffer;s.includes(t)||s.push(t)};if(a==null)return s;if(ArrayBuffer.isView(a))return h(a),s;if(Array.isArray(a)){for(const u of a)h(u);return s}if(typeof a=="object")for(const u of Object.keys(a)){const t=a[u];if(Array.isArray(t))for(const l of t)h(l);else h(t)}return s}function j(a,s=0){if(a==null)return!0;const h=typeof a;if(h==="function"||h==="symbol")return!1;if(h!=="object"||s>4||ArrayBuffer.isView(a)||a instanceof ArrayBuffer||a instanceof Date)return!0;if(Array.isArray(a)){for(const u of a)if(!j(u,s+1))return!1;return!0}for(const u of Object.keys(a))if(!j(a[u],s+1))return!1;return!0}function i(a,s=new Set){if(!a||typeof a!="object")return s;const h=a;typeof h.col=="string"&&s.add(h.col);const u=h.conditions;if(Array.isArray(u))for(const t of u)i(t,s);return s}}),Ce("packages/core/src/store/bitset.js",function(o,me){"use strict";Object.defineProperty(o,"Bitset",{enumerable:!0,get:function(){return he}});const ae=8;class he{static#t=new Uint8Array(256);static{for(let U=1;U<256;U++)he.#t[U]=he.#t[U>>1]+(U&1)}#e;#n;constructor(U=0){const _=Math.max(0,U|0);this.#n=_,this.#e=new Uint8Array(Math.ceil(_/ae))}get size(){return this.#n}get words(){return this.#e}get bytes(){return this.#e?this.#e.byteLength:0}get(U){return U<0||U>=this.#n?0:this.#e[U>>3]>>(U&7)&1}set(U){return U>=0&&U<this.#n&&(this.#e[U>>3]|=1<<(U&7)),this}clear(U){return U>=0&&U<this.#n&&(this.#e[U>>3]&=~(1<<(U&7))),this}assign(U,_){return _?this.set(U):this.clear(U)}fill(U=!1){return this.#e.fill(U?255:0),U&&this.#r(),this}grow(U){const _=Math.max(0,U|0);if(_<=this.#n)return this;const Z=Math.ceil(_/ae);if(Z>this.#e.length){const E=new Uint8Array(Z);E.set(this.#e),this.#e=E}return this.#n=_,this}count(){const U=this.#e,_=he.#t;let Z=0;for(let E=0;E<U.length;E++)Z+=_[U[E]];return Z}and(U){const _=U instanceof he?U.words:U,Z=this.#e,E=Math.min(Z.length,_.length);for(let z=0;z<E;z++)Z[z]&=_[z];for(let z=E;z<Z.length;z++)Z[z]=0;return this}or(U){const _=U instanceof he?U.words:U,Z=this.#e,E=Math.min(Z.length,_.length);for(let z=0;z<E;z++)Z[z]|=_[z];return this}not(){const U=this.#e;for(let _=0;_<U.length;_++)U[_]=~U[_]&255;return this.#r(),this}clone(){const U=new he(this.#n);return U.words.set(this.#e.subarray(0,U.words.length)),U}release(){this.#e=new Uint8Array(0),this.#n=0}#r(){const U=this.#n&7;if(U===0)return;const _=this.#n>>3;_<this.#e.length&&(this.#e[_]&=(1<<U)-1)}static from(U){const _=Array.isArray(U)?U:Array.from(U),Z=new he(_.length);for(let E=0;E<_.length;E++)_[E]&&Z.set(E);return Z}}}),Ce("packages/core/src/store/dictionary.js",function(o,me){"use strict";Object.defineProperty(o,"Dictionary",{enumerable:!0,get:function(){return U}});const ae=me("packages/core/src/internal/util.js"),he=ae.collator,W=ae.defaultCompare;class U{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(Z=[]){this.#t=[];for(let E=0;E<Z.length;E++){const z=Z[E];this.#e.has(z)||(this.#e.set(z,this.#t.length),this.#t.push(z))}}get size(){return this.#t.length}get version(){return this.#n}get bytes(){let Z=this.#t.length*8;for(let E=0;E<this.#t.length;E++){const z=this.#t[E];typeof z=="string"&&(Z+=z.length*2),Z+=16}return Z}codeOf(Z){const E=this.#e.get(Z);if(E!==void 0)return E;const z=this.#t.length;return this.#t.push(Z),this.#e.set(Z,z),this.#n++,z}lookup(Z){const E=this.#e.get(Z);return E===void 0?-1:E}has(Z){return this.#e.has(Z)}valueOf(Z){return this.#t[Z]}values(){return this.#t}ranks(Z){const E=Z||"";if(this.#r&&this.#i===this.#n&&this.#s===E)return this.#r;const z=this.#t.length,re=new Array(z);for(let H=0;H<z;H++)re[H]=H;const Y=he(Z).compare,se=this.#t;re.sort((H,T)=>this.#h(se[H],se[T],Y));const te=new Uint32Array(z);for(let H=0;H<z;H++)te[re[H]]=H;return this.#r=te,this.#i=this.#n,this.#s=E,te}#h(Z,E,z){return typeof Z=="string"&&typeof E=="string"?z(Z,E):W(Z,E)}}}),Ce("packages/core/src/store/multivalue.js",function(o,me){"use strict";Object.defineProperty(o,"MultiValue",{enumerable:!0,get:function(){return ae}});class ae{#t;#e;#n=0;#r=0;constructor(W={}){const U=Math.max(1,W.rows??16),_=Math.max(1,W.values??U);this.#t=new Int32Array(_),this.#e=new Uint32Array(U+1)}get values(){return this.#t}get offsets(){return this.#e}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#t.byteLength+this.#e.byteLength}count(W){return W<0||W>=this.#n?0:this.#e[W+1]-this.#e[W]}at(W){return W<0||W>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[W],this.#e[W+1])}has(W,U){if(W<0||W>=this.#n)return!1;const _=this.#t,Z=this.#e[W+1];for(let E=this.#e[W];E<Z;E++)if(_[E]===U)return!0;return!1}hasAny(W,U){for(let _=0;_<U.length;_++)if(this.has(W,U[_]))return!0;return!1}hasAll(W,U){for(let _=0;_<U.length;_++)if(!this.has(W,U[_]))return!1;return!0}hasNone(W,U){return!this.hasAny(W,U)}push(W){const U=this.#n,_=W.length;this.#i(U+1),this.#s(this.#r+_);const Z=this.#r;for(let E=0;E<_;E++)this.#t[Z+E]=W[E]|0;return this.#r+=_,this.#n=U+1,this.#e[U]=Z,this.#e[U+1]=this.#r,U}write(W,U){if(W===this.#n){this.push(U);return}if(W<0||W>this.#n)return;const _=this.#e[W],Z=this.#e[W+1],E=U.length;if(Z-_===E){for(let z=0;z<E;z++)this.#t[_+z]=U[z]|0;return}this.#h(W,U)}compact(W,U,_){const Z=this.#t,E=this.#e,z=this.#n,re=new Int32Array(Math.max(1,this.#r)),Y=new Uint32Array(U+1);let se=0;for(let te=0;te<z;te++){if(W[te]===_)continue;const H=E[te],T=E[te+1];Y[W[te]]=se;for(let V=H;V<T;V++)re[se++]=Z[V];Y[W[te]+1]=se}this.#t=re,this.#e=Y,this.#n=U,this.#r=se}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(W){if(W+1<=this.#e.length)return;let U=this.#e.length-1;for(;U<W;)U=U*2||16;const _=new Uint32Array(U+1);_.set(this.#e),this.#e=_}#s(W){if(W<=this.#t.length)return;let U=this.#t.length;for(;U<W;)U=U*2||16;const _=new Int32Array(U);_.set(this.#t),this.#t=_}#h(W,U){const _=this.#t,Z=this.#e,E=this.#n,z=U.length-(Z[W+1]-Z[W]),re=new Int32Array(Math.max(1,this.#r+z)),Y=new Uint32Array(Z.length);let se=0;for(let te=0;te<E;te++){if(Y[te]=se,te===W)for(let H=0;H<U.length;H++)re[se++]=U[H]|0;else for(let H=Z[te];H<Z[te+1];H++)re[se++]=_[H];Y[te+1]=se}this.#t=re,this.#e=Y,this.#r=se}}}),Ce("packages/core/src/compute/handle.js",function(o,me){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return j}});const ae=me("packages/core/src/internal/util.js"),he=ae.collator,W=ae.defaultCompare,U=ae.warnOnce;function _(i){const a=new Uint32Array(i);for(let s=0;s<i;s++)a[s]=s;return a}function Z(i,a){if(a&&typeof a.count=="number")return a.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const s=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):s?i.kind==="bitset"?typeof s.size=="number"?s.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(U(`count:${i.id}`,`column "${i.id}" is bitset-backed with no declared row count; assuming ${s.length*8}`),s.length*8):s.length:i.presence&&typeof i.presence.size=="number"?i.presence.size:0}const E=new WeakMap;function z(i){const a=i.constructor;if(!a)return"unknown";const s=E.get(a);if(s)return s;let h="unknown";try{let u=null;typeof a.from=="function"?u=a.from([!1,!0]):(u=new a(8),u.set(1));const t=u&&u.words;t&&t.length&&(t[0]===2?h="lsb":t[0]===64&&(h="msb"))}catch{h="unknown"}return E.set(a,h),h}function re(i){if(!i)return()=>0;const a=i instanceof Uint8Array?i:i.words;if(a instanceof Uint8Array){const s=i instanceof Uint8Array?"lsb":z(i);if(s==="lsb")return h=>a[h>>>3]>>>(h&7)&1;if(s==="msb")return h=>a[h>>>3]>>>7-(h&7)&1}return typeof i.get=="function"?s=>i.get(s)?1:0:()=>0}function Y(i){return!i||!i.presence?null:re(i.presence)}function se(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function te(i,a){return i?typeof i.valueOf=="function"?i.valueOf(a):typeof i.values=="function"?i.values()[a]:null:null}function H(i,a){const s=i.offsets,h=i.values;if(!s||!h)return[];const u=s[a],t=s[a+1];if(!(t>u))return[];const l=i.dict,m=new Array(t-u);for(let e=u;e<t;e++)m[e-u]=l?te(l,h[e]):h[e];return m}function T(i){if(!i)return()=>{};const a=i.values,s=Y(i),h=i.kind;if(h==="dictionary"){const u=i.dict;return s?t=>s(t)?te(u,a[t]):null:t=>te(u,a[t])}if(h==="bitset"){const u=re(a);return s?t=>s(t)?u(t)===1:null:t=>u(t)===1}if(h==="multi")return s?u=>s(u)?H(i,u):null:u=>H(i,u);if(!a&&typeof i.get=="function"){const u=i.get.bind(i);return t=>{const l=u(t);return l===void 0?null:l}}return s?u=>{if(!s(u))return null;const t=a[u];return t===void 0?null:t}:u=>{const t=a[u];return t===void 0?null:t}}function V(i,a){if(i<a)return-1;if(i>a)return 1;if(i===a){const u=Object.is(i,-0),t=Object.is(a,-0);return u===t?0:u?-1:1}const s=Number.isNaN(i),h=Number.isNaN(a);return s&&h?0:s?1:-1}function ne(i){const a=he(i);return(s,h)=>{if(s===h)return 0;const u=typeof s,t=typeof h;if(u==="string"&&t==="string")return a.compare(s,h);if(u==="number"&&t==="number")return V(s,h);if(u==="boolean"&&t==="boolean")return s===h?0:s?1:-1;if(s instanceof Date||h instanceof Date){const l=s instanceof Date?s.getTime():Number(s),m=h instanceof Date?h.getTime():Number(h);return V(l,m)}return W(s,h)}}function R(i,a){if(i&&typeof i.ranks=="function")return i.ranks(a);const s=i&&typeof i.values=="function"?i.values():[],h=s.length,u=ne(a),t=new Array(h);for(let m=0;m<h;m++)t[m]=m;t.sort((m,e)=>u(s[m],s[e])||m-e);const l=new Uint32Array(h);for(let m=0;m<h;m++)l[t[m]]=m;return l}function j(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Ce("packages/core/src/compute/sort.js",function(o,me){"use strict";Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return v}});const ae=me("packages/core/src/compute/handle.js"),he=ae.bitReader,W=ae.dictRanks,U=ae.dictSize,_=ae.identity,Z=ae.isMissing,E=ae.presenceReader,z=ae.rowCount,re=ae.valueComparator,Y=ae.valueReader,se=new Uint32Array(0),te=new ArrayBuffer(8),H=new Float64Array(te),T=new Uint32Array(te),V=(H[0]=-1,(T[1]&2147483648)!==0?1:0),ne=V===1?0:1;function R(S,N){H[0]=S;let I=T[V],K=T[ne];(I&2147483648)!==0?(I=~I>>>0,K=~K>>>0):I=(I^2147483648)>>>0,N[0]=K,N[1]=I}function j(S,N,I,K){if(K<2)return S;const B=new Uint32Array(256*8);for(let D=0;D<K;D++){const x=N[D],fe=I[D];B[x&255]++,B[256+(x>>>8&255)]++,B[512+(x>>>16&255)]++,B[768+(x>>>24&255)]++,B[1024+(fe&255)]++,B[1280+(fe>>>8&255)]++,B[1536+(fe>>>16&255)]++,B[1792+(fe>>>24&255)]++}let ee=S,J=N,ue=I,de=new Uint32Array(K),Oe=new Uint32Array(K),Ae=new Uint32Array(K);const Se=new Uint32Array(256);for(let D=0;D<8;D++){const x=D<<8,fe=(D&3)<<3,p=D>=4;let Q=!1;for(let le=0;le<256;le++)if(B[x+le]===K){Q=!0;break}if(Q)continue;let X=0;for(let le=0;le<256;le++)Se[le]=X,X+=B[x+le];for(let le=0;le<K;le++){const ge=J[le],Me=ue[le],be=(p?Me:ge)>>>fe&255,ye=Se[be]++;de[ye]=ee[le],Oe[ye]=ge,Ae[ye]=Me}let ce=ee;ee=de,de=ce,ce=J,J=Oe,Oe=ce,ce=ue,ue=Ae,Ae=ce}return ee}function i(S,N,I){if(I<2)return S;const K=new Uint32Array(256*4);for(let Oe=0;Oe<I;Oe++){const Ae=N[Oe];K[Ae&255]++,K[256+(Ae>>>8&255)]++,K[512+(Ae>>>16&255)]++,K[768+(Ae>>>24&255)]++}let B=S,ee=N,J=new Uint32Array(I),ue=new Uint32Array(I);const de=new Uint32Array(256);for(let Oe=0;Oe<4;Oe++){const Ae=Oe<<8,Se=Oe<<3;let D=!1;for(let p=0;p<256;p++)if(K[Ae+p]===I){D=!0;break}if(D)continue;let x=0;for(let p=0;p<256;p++)de[p]=x,x+=K[Ae+p];for(let p=0;p<I;p++){const Q=ee[p],X=de[Q>>>Se&255]++;J[X]=B[p],ue[X]=Q}let fe=B;B=J,J=fe,fe=ee,ee=ue,ue=fe}return B}function a(S,N,I,K){const B=new Uint32Array(K+1);for(let ue=0;ue<I;ue++)B[N[ue]]++;let ee=0;for(let ue=0;ue<=K;ue++){const de=B[ue];B[ue]=ee,ee+=de}const J=new Uint32Array(I);for(let ue=0;ue<I;ue++)J[B[N[ue]]++]=S[ue];return J}function s(S,N,I,K){return I<2?S:K<=65536||K<=I*2?a(S,N,I,K):i(S,N,I)}function h(S,N){return S.length===N&&S.byteOffset===0?S:Uint32Array.prototype.slice.call(S,0,N)}function u(S,N,I=!1){const K=N||_(S.length),B=K.length;if(B<2)return Uint32Array.from(K);const ee=new Uint32Array(B),J=new Uint32Array(B),ue=new Uint32Array(B),de=new Uint32Array(B),Oe=new Uint32Array(2);let Ae=0,Se=0;for(let fe=0;fe<B;fe++){const p=K[fe],Q=S[p];if(Number.isNaN(Q)){de[Se++]=p;continue}R(Q,Oe),I?(J[Ae]=~Oe[0]>>>0,ue[Ae]=~Oe[1]>>>0):(J[Ae]=Oe[0],ue[Ae]=Oe[1]),ee[Ae++]=p}const D=j(ee.subarray(0,Ae),J.subarray(0,Ae),ue.subarray(0,Ae),Ae);if(Se===0)return h(D,Ae);const x=new Uint32Array(B);return x.set(D.subarray(0,Ae),0),x.set(de.subarray(0,Se),Ae),x}function t(S,N,I=!1){const K=N||_(S.length),B=K.length;if(B<2)return Uint32Array.from(K);const ee=Uint32Array.from(K),J=new Uint32Array(B);for(let ue=0;ue<B;ue++){const de=(S[ee[ue]]^2147483648)>>>0;J[ue]=I?~de>>>0:de}return h(i(ee,J,B),B)}function l(S,N,I={}){const K=N||_(z(S,I)),B=K.length;if(B<2)return Uint32Array.from(K);const ee=W(S.dict,I.locale),J=S.values,ue=E(S),de=Math.max(U(S.dict),ee.length),Oe=de,Ae=Uint32Array.from(K),Se=new Uint32Array(B),D=!!I.descending;for(let x=0;x<B;x++){const fe=Ae[x];let p=ue&&ue(fe)===0?Oe:ee[J[fe]];p===void 0&&(p=Oe),Se[x]=D?Oe-p:p}return h(s(Ae,Se,B,de+1),B)}function m(S,N,I){const K=N.length;let B=Uint32Array.from(N);if(K<2)return B;let ee=new Uint32Array(K);for(let J=1;J<K;J<<=1){for(let de=0;de<K;de+=J<<1){const Oe=Math.min(de+J,K),Ae=Math.min(de+(J<<1),K);let Se=de,D=Oe,x=de;for(;Se<Oe&&D<Ae;)ee[x++]=I(S[B[Se]],S[B[D]])<=0?B[Se++]:B[D++];for(;Se<Oe;)ee[x++]=B[Se++];for(;D<Ae;)ee[x++]=B[D++]}const ue=B;B=ee,ee=ue}return B}function e(S,N,I){const K=he(S.values),B=N.length,ee=new Uint32Array(B),J=I?1:0;let ue=0;for(let de=0;de<B;de++)K(N[de])===J&&(ee[ue++]=N[de]);for(let de=0;de<B;de++)K(N[de])!==J&&(ee[ue++]=N[de]);return ee}function d(S,N){const I=S.values,K=S.kind;if((K==="object"||K===void 0)&&(Array.isArray(I)||ArrayBuffer.isView(I))&&!S.presence)return I;const ee=Y(S),J=new Array(z(S)||0);for(let ue=0;ue<N.length;ue++){const de=N[ue];J[de]=ee(de)}return J}function f(S,N){for(let I=0;I<N.length;I++)if(typeof S[N[I]]!="string")return!1;return!0}function r(S,N,I,K,B){const ee=S.length,J=Uint32Array.from(S);if(ee<2||K<1)return J;const ue=new Uint32Array(ee),de=K-1;for(let Oe=0;Oe<ee;Oe++){const Ae=I[N[Oe]];ue[Oe]=B?de-Ae:Ae}return h(s(J,ue,ee,K),ee)}function n(S,N,I){const K=re(I),B=new Array(N);for(let J=0;J<N;J++)B[J]=J;B.sort((J,ue)=>K(S[J],S[ue])||J-ue);const ee=new Uint32Array(N);for(let J=0;J<N;J++)ee[B[J]]=J;return ee}function c(S,N,I){const K=N.length,B=new Map,ee=[],J=new Uint32Array(K);for(let Oe=0;Oe<K;Oe++){const Ae=S[N[Oe]];let Se=B.get(Ae);Se===void 0&&(Se=ee.length,B.set(Ae,Se),ee.push(Ae)),J[Oe]=Se}const ue=ee.length,de=n(ee,ue,I.locale);return r(N,J,de,ue,!!I.descending)}function g(S,N,I){const K=d(S,N);if(N.length>=2&&f(K,N)){const J=S.stringRank;return J&&J.version===S.version&&J.usable(N,K,I.locale)?J.sort(N,I):c(K,N,I)}const B=re(I.locale),ee=I.descending?(J,ue)=>B(ue,J):B;return m(K,N,ee)}function A(S,N,I){const K=d(S,N),B=I.compare,J=!!I.descending?(ue,de)=>-B(ue,de,void 0,void 0,!0):(ue,de)=>B(ue,de,void 0,void 0,!1);return m(K,N,J)}function P(S,N){const I=N.length,K=E(S),B=S.values,ee=S.kind==="float64"&&!!B,J=S.kind==="object"||S.kind==="multi"||S.kind===void 0;if(!K&&!ee&&!J)return{present:N,absent:se};const ue=new Uint32Array(I),de=new Uint32Array(I);let Oe=0,Ae=0;if(K&&ee)for(let Se=0;Se<I;Se++){const D=N[Se];K(D)===1&&!Number.isNaN(B[D])?ue[Oe++]=D:de[Ae++]=D}else if(ee&&!K)for(let Se=0;Se<I;Se++){const D=N[Se];Number.isNaN(B[D])?de[Ae++]=D:ue[Oe++]=D}else if(K&&!J)for(let Se=0;Se<I;Se++){const D=N[Se];K(D)===1?ue[Oe++]=D:de[Ae++]=D}else{const Se=Y(S);for(let D=0;D<I;D++){const x=N[D];Z(Se(x))?de[Ae++]=x:ue[Oe++]=x}}return Ae===0?{present:N,absent:se}:{present:ue.subarray(0,Oe),absent:de.subarray(0,Ae)}}function q(S,N,I){if(N.length===0)return S;const K=new Uint32Array(S.length+N.length);return I?(K.set(N,0),K.set(S,N.length)):(K.set(S,0),K.set(N,S.length)),K}function L(S,N,I={}){const K=N||_(z(S,I));if(!S||K.length<2)return Uint32Array.from(K);const{present:B,absent:ee}=P(S,K);if(B.length===0)return Uint32Array.from(K);const J=!!I.descending;let ue;if(typeof I.compare=="function")ue=A(S,B,I);else switch(S.kind){case"float64":ue=u(S.values,B,J);break;case"int32":ue=t(S.values,B,J);break;case"dictionary":ue=l(S,B,I);break;case"bitset":ue=e(S,B,J);break;default:ue=g(S,B,I);break}return q(ue,ee,!!I.nullsFirst)}function v(S,N,I,K={}){const B=N||[],ee=B.length&&(B[0].handle||G(S,B[0].col))||S&&S[0];let J=I||_(z(ee,K));for(let ue=B.length-1;ue>=0;ue--){const de=B[ue],Oe=de.handle||G(S,de.col)||S&&S[ue];Oe&&(J=L(Oe,J,{descending:de.descending!==void 0?!!de.descending:de.dir==="desc",nullsFirst:!!de.nullsFirst,locale:de.locale!==void 0?de.locale:K.locale,compare:de.compare}))}return J instanceof Uint32Array?J:Uint32Array.from(J)}function G(S,N){if(!(!S||N===void 0)){for(let I=0;I<S.length;I++)if(S[I]&&S[I].id===N)return S[I]}}}),Ce("packages/core/src/store/stringrank.js",function(o,me){"use strict";Object.defineProperty(o,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"StringRankIndex",{enumerable:!0,get:function(){return _}});const ae=me("packages/core/src/compute/sort.js"),he=ae.collateStringRanks,W=ae.rankSortStrings,U=1e5;class _{#t=[];#e=new Map;#n;#r=0;#i=0;#s=-1;#h;#u=!1;#o=null;#c=-1;#l="\\0";constructor(E=U){this.#h=E>0?E:U,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(E){this.#s=E}get generation(){return this.#i}get size(){return this.#t.length}get capped(){return this.#u}get length(){return this.#r}get bytes(){let E=this.#n.byteLength;const z=this.#t;for(let re=0;re<z.length;re++)E+=z[re].length*2+24;return E}#a(E,z){const re=this.#e.get(E);if(re!==void 0)return re;if(this.#u)return-1;if(z&&this.#t.length>=this.#h)return this.#u=!0,-1;const Y=this.#t.length;return this.#t.push(E),this.#e.set(E,Y),this.#i++,Y}build(E,z){const re=z|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(re);for(let Y=0;Y<re;Y++){const se=E[Y],te=typeof se=="string"?this.#a(se,!1):-1;this.#n[Y]=te<0?0:te}this.#r=re}append(E,z,re){const Y=(z|0)+(re|0);if(Y>this.#n.length){const se=new Uint32Array(Y);se.set(this.#n.subarray(0,this.#r)),this.#n=se}for(let se=z|0;se<Y;se++){const te=E[se],H=typeof te=="string"?this.#a(te,!0):-1;this.#n[se]=H<0?0:H}this.#r=Math.max(this.#r,Y)}ranks(E){const z=E||"";if(this.#o&&this.#c===this.#i&&this.#l===z)return this.#o;const re=he(this.#t,this.#t.length,E);return this.#o=re,this.#c=this.#i,this.#l=z,re}usable(E,z,re){if(this.#u||this.#t.length===0)return!1;const Y=this.#n,se=this.#t,te=this.#r;for(let H=0;H<E.length;H++){const T=E[H];if(T>=te||se[Y[T]]!==z[T])return!1}return!0}sort(E,z){const re=this.ranks(z.locale),Y=this.#t.length,se=E.length,te=new Uint32Array(se),H=this.#n;for(let T=0;T<se;T++)te[T]=H[E[T]];return W(E,te,re,Y,!!z.descending)}}}),Ce("packages/core/src/store/columnstore.js",function(o,me){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"toFloat",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ColumnHandle",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"ColumnStore",{enumerable:!0,get:function(){return l}});const ae=me("packages/core/src/internal/util.js"),he=ae.warnOnce,W=ae.isFunction,U=ae.pathGetter,Z=me("packages/core/src/store/bitset.js").Bitset,z=me("packages/core/src/store/dictionary.js").Dictionary,Y=me("packages/core/src/store/multivalue.js").MultiValue,te=me("packages/core/src/store/stringrank.js").StringRankIndex,H=4294967295,T=1024,V=5e3,ne=.2,R=new Set(["float64","int32","bitset","dictionary","object","multi"]);function j(m){return m==null}function i(m){if(typeof m=="number")return m;if(m instanceof Date)return m.getTime();if(typeof m=="boolean")return m?1:0;const e=Number(m);return Number.isNaN(e)&&typeof m=="string"?Date.parse(m):e}function a(m){const e=i(m);return Number.isFinite(e)?e|0:0}function s(m){return j(m)?[]:Array.isArray(m)?m:[m]}function h(m,e){switch(m.kind){case"float64":case"int32":return m.buf[e];case"bitset":return m.bits.get(e)===1;case"dictionary":return m.dict.valueOf(m.buf[e]);case"multi":{const d=m.mv.at(e),f=new Array(d.length);for(let r=0;r<d.length;r++)f[r]=m.dict.valueOf(d[r]);return f}default:return m.buf[e]}}function u(m,e){switch(m.kind){case"float64":case"int32":return m.values[e];case"bitset":return(m.values[e>>3]&1<<(e&7))!==0;case"dictionary":return(m.table||[])[m.values[e]];case"multi":{const d=m.offsets[e],f=m.offsets[e+1],r=m.table||[],n=new Array(f-d);for(let c=d;c<f;c++)n[c-d]=r[m.values[c]];return n}default:return m.values[e]}}class t{#t;#e;#n;#r;#i;#s;#h;#u=!1;#o=null;#c=null;#l=null;#a=null;#d=null;#w;#b;#k=-1;#m=null;#p=0;#f=0;#y=null;#O=null;#g=!1;constructor(e,d){this.#t=e.id;const f=R.has(e.kind)?e.kind:"object";e.kind&&!R.has(e.kind)&&he(`store.kind.${e.id}`,`column "${e.id}" declares unknown storage kind "${e.kind}"; falling back to object`),this.#n=f,this.#e=f,this.#r=e.nullable!==!1,this.#h=e.dictionary??null,this.#s=d,this.#i=W(e.read)?e.read:U(e.field||e.id),this.#w=e.stringRankIndex!=="off",this.#b=typeof e.stringRankMaxDistinct=="number"?e.stringRankMaxDistinct:0,this.#y=new Map}get id(){return this.#t}get kind(){return this.#u?this.#e:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#g?null:this.#u?this.#e==="bitset"?this.#c.words:this.#e==="multi"?this.#l.values:this.#o:this.#N().values}get presence(){return this.#g||!this.#r?null:this.#u?this.#m:this.#N().presence}get dict(){return this.#g||!this.#u?null:this.#e==="dictionary"||this.#e==="multi"?this.#a:null}get stringRank(){if(this.#g||!this.#w||this.kind!=="object")return null;const e=this.values,d=this.#s.physical();if(!e||d===0)return null;if(this.#d===null){if(typeof e[0]!="string")return null;const f=new te(this.#S());return f.build(e,d),f.version=this.#f,this.#d=f,this.#k=this.#f,f.capped?null:f}return this.#d.length<d&&this.#d.append(e,this.#d.length,d-this.#d.length),this.#d.version=this.#f,this.#k=this.#f,this.#d.capped?null:this.#d}#S(){return this.#b}#j(){this.#d=null,this.#k=-1}get offsets(){return this.#g||!this.#u||this.#e!=="multi"?null:this.#l.offsets}get version(){return this.#f}get bytes(){let e=0;return this.#o&&(e+=this.#o.byteLength??this.#o.length*8),this.#c&&(e+=this.#c.bytes),this.#l&&(e+=this.#l.bytes),this.#m&&(e+=this.#m.bytes),this.#a&&(e+=this.#a.bytes),this.#y&&(e+=this.#y.size*24),e}get(e){if(!this.#g&&!(e<0||e>=this.#s.physical())){if(!this.#u)return this.#M(e);if(this.#r&&this.#m.get(e)===0)return null;switch(this.#e){case"float64":case"int32":return this.#o[e];case"bitset":return this.#c.get(e)===1;case"dictionary":return this.#a.valueOf(this.#o[e]);case"multi":{const d=this.#l.at(e),f=new Array(d.length);for(let r=0;r<d.length;r++)f[r]=this.#a.valueOf(d[r]);return f}default:return this.#o[e]}}}set(e,d){this.#g||(this.#u?this.#A(e,d):this.#y.set(e,d===void 0?null:d),this.#d&&this.#j(),this.#f++)}read(e){return this.#i(e)}appendColumn(e,d,f){if(this.#g||f<=0)return;if(!this.#u){this.#f++;return}const r=this.#i,n=this.#r,c=this.#m;let g=!1;switch(this.#e){case"float64":{const A=this.#o;for(let P=0;P<f;P++){const q=r(e[P]);if(typeof q=="number"){n&&c.set(d+P),A[d+P]=q;continue}const L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A[d+P]=L?NaN:i(q)}break}case"int32":{const A=this.#o;for(let P=0;P<f;P++){const q=r(e[P]),L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A[d+P]=L?0:a(q)}break}case"bitset":{const A=this.#c;for(let P=0;P<f;P++){const q=r(e[P]),L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A.assign(d+P,!L&&!!q)}break}case"dictionary":{const A=this.#o,P=this.#a;for(let q=0;q<f;q++){const L=r(e[q]),v=L==null;n?c.assign(d+q,!v):v&&(g=!0),A[d+q]=v?0:P.codeOf(L)}break}case"multi":{const A=this.#l,P=this.#a;for(let q=0;q<f;q++){const L=r(e[q]),v=L==null;n?c.assign(d+q,!v):v&&(g=!0);const G=s(L),S=new Array(G.length);for(let N=0;N<G.length;N++)S[N]=P.codeOf(G[N]);A.write(d+q,S)}break}default:{const A=this.#o;for(let P=0;P<f;P++){const q=r(e[P]),L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A[d+P]=L?null:q}break}}g&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#d&&this.#e==="object"&&(this.#d.append(this.#o,d,f),this.#d.version=this.#f+1,this.#k=this.#f+1),this.#f++}appendPacked(e,d,f){if(this.#g||f<=0||!e)return;if(!this.#u){this.#f++;return}const r=this.#m,n=e.presence;if(r)if(n)for(let g=0;g<f;g++)r.assign(d+g,(n[g>>3]&1<<(g&7))!==0);else for(let g=0;g<f;g++)r.set(d+g);const c=e.kind===this.#e;if(c&&(this.#e==="float64"||this.#e==="int32")){this.#o.set(e.values,d),this.#f++;return}if(c&&this.#e==="bitset"){const g=e.values;for(let A=0;A<f;A++)this.#c.assign(d+A,(g[A>>3]&1<<(A&7))!==0);this.#f++;return}if(c&&this.#e==="dictionary"){const g=e.table||[],A=new Uint32Array(g.length);for(let v=0;v<g.length;v++)A[v]=this.#a.codeOf(g[v]);const P=e.values,q=this.#o,L=r;for(let v=0;v<f;v++){if(L&&(n&&(n[v>>3]&1<<(v&7))===0)){q[d+v]=0;continue}q[d+v]=A[P[v]]??0}this.#f++;return}if(c&&this.#e==="multi"){const g=e.table||[],A=new Uint32Array(g.length);for(let L=0;L<g.length;L++)A[L]=this.#a.codeOf(g[L]);const P=e.values,q=e.offsets;for(let L=0;L<f;L++){const v=q[L],G=q[L+1],S=new Array(G-v);for(let N=v;N<G;N++)S[N-v]=A[P[N]]??0;this.#l.write(d+L,S)}this.#f++;return}for(let g=0;g<f;g++){const A=n?(n[g>>3]&1<<(g&7))===0:e.kind==="object"?e.values[g]===null:!1;this.#A(d+g,A?null:u(e,g))}this.#f++}touch(){this.#f++}columnarise(e,d){if(this.#u||this.#g)return;const f=new Array(d);for(let r=0;r<d;r++)f[r]=this.#M(r);this.#e=this.#n,this.#u=!0,this.#P(e);for(let r=0;r<d;r++)this.#A(r,f[r]);this.#y.clear(),this.#O=null,this.#j(),this.#f++}grow(e){if(!(!this.#u||this.#g||e<=this.#p)){switch(this.#e){case"float64":case"int32":case"dictionary":{const d=new this.#o.constructor(e);d.set(this.#o),this.#o=d;break}case"bitset":this.#c.grow(e);break;case"multi":break;default:this.#o.length=e;break}this.#m&&this.#m.grow(e),this.#p=e,this.#f++}}convert(e){if(this.#g||!R.has(e)||(this.#n=e,!this.#u||e===this.#e))return!1;const d={kind:this.#e,buf:this.#o,bits:this.#c,mv:this.#l,dict:this.#a},f=this.#s.physical(),r=this.#m;this.#e=e,this.#P(this.#p);for(let n=0;n<f;n++){const c=r!==null&&r.get(n)===0;c&&e!=="multi"||this.#A(n,c?null:h(d,n))}return this.#j(),this.#f++,!0}compact(e,d,f){if(!this.#g){if(this.#j(),!this.#u){const r=this.#y;if(r.size){const n=new Map;for(const[c,g]of r)e[c]!==H&&n.set(e[c],g);this.#y=n}this.#O=null,this.#f++;return}switch(this.#e){case"float64":case"int32":case"dictionary":case"object":{const r=this.#o;for(let n=0;n<d;n++)e[n]!==H&&(r[e[n]]=r[n]);if(this.#e==="object")for(let n=f;n<d;n++)r[n]=void 0;break}case"bitset":{const r=this.#c;for(let n=0;n<d;n++)e[n]!==H&&r.assign(e[n],r.get(n)===1);for(let n=f;n<d;n++)r.clear(n);break}case"multi":this.#l.compact(e,f,H);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<d;n++)e[n]!==H&&r.assign(e[n],r.get(n)===1);for(let n=f;n<d;n++)r.clear(n)}this.#f++}}release(){this.#g||(this.#g=!0,this.#o=null,this.#c&&this.#c.release(),this.#c=null,this.#l&&this.#l.release(),this.#l=null,this.#m&&this.#m.release(),this.#m=null,this.#a=null,this.#d=null,this.#y=new Map,this.#O=null,this.#p=0,this.#f++)}#P(e){const d=Math.max(1,e);switch(this.#o=null,this.#c=null,this.#l=null,this.#e){case"float64":this.#o=new Float64Array(d);break;case"int32":this.#o=new Int32Array(d);break;case"bitset":this.#c=new Z(d);break;case"dictionary":this.#o=new Uint32Array(d),this.#a=this.#a??new z(this.#h??[]);break;case"multi":this.#l=new Y({rows:d,values:d}),this.#a=this.#a??new z(this.#h??[]);break;default:this.#o=new Array(d);break}this.#e!=="dictionary"&&this.#e!=="multi"&&(this.#a=null),this.#r&&(this.#m?this.#m.grow(d):this.#m=new Z(d)),this.#p=d}#A(e,d){const f=j(d);switch(this.#r?this.#m.assign(e,!f):f&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#e){case"float64":this.#o[e]=f?NaN:i(d);break;case"int32":this.#o[e]=f?0:a(d);break;case"bitset":this.#c.assign(e,!f&&!!d);break;case"dictionary":this.#o[e]=f?0:this.#a.codeOf(d);break;case"multi":{const r=s(d),n=new Array(r.length);for(let c=0;c<r.length;c++)n[c]=this.#a.codeOf(r[c]);this.#l.write(e,n);break}default:this.#o[e]=f?null:d;break}}#M(e){if(this.#y.has(e))return this.#y.get(e);const d=this.#i(this.#s.rowAt(e));return d===void 0?null:d}#N(){if(this.#O&&this.#O.version===this.#f)return this.#O;const e=this.#s.physical(),d=new Array(e),f=this.#r?new Z(e):null;for(let r=0;r<e;r++){const n=this.#M(r);d[r]=n,f&&!j(n)&&f.set(r)}return this.#O={version:this.#f,values:d,presence:f},this.#O}}class l{#t;#e=new Map;#n=[];#r=[];#i=0;#s=0;#h=0;#u=0;#o=new Z(0);#c=!1;#l=!0;#a;#d;#w;#b=!1;constructor(e,d={}){this.#t=Array.isArray(e)?e:[],this.#d=Math.max(1,d.initialCapacity??T),this.#l=d.retainSource!==!1,this.#a=this.#l?d.columnarBelow??V:0,this.#w=d.compactRatio??ne;const f={rowAt:r=>this.#r[r],physical:()=>this.#i};for(const r of this.#t){if(!r||!r.id)continue;if(this.#e.has(r.id)){he(`store.dup.${r.id}`,`duplicate column id "${r.id}" in the store schema; ignoring the second`);continue}const n=new t(r,f);this.#e.set(r.id,n),this.#n.push(n)}this.#a<=0&&this.#p()}get count(){return this.#h}get physical(){return this.#i}get capacity(){return this.#c?this.#s:this.#r.length}get tombstones(){return this.#u}get columnar(){return this.#c}get destroyed(){return this.#b}get bytes(){let e=this.#o.bytes+this.#r.length*8;for(const d of this.#n)e+=d.bytes;return e}append(e){const d=this.#i;if(this.#b||!e)return{from:d,to:d};const f=e.length|0;if(f===0)return{from:d,to:d};if(this.#l)for(let n=0;n<f;n++)this.#r[d+n]=e[n];if(this.#i=d+f,this.#h+=f,this.#o.grow(this.#i),!this.#c){if(this.#i>=this.#a)this.#p();else for(const n of this.#n)n.touch();return{from:d,to:this.#i}}this.#k(this.#i);const r=this.#n;for(let n=0;n<r.length;n++)r[n].appendColumn(e,d,f);return{from:d,to:this.#i}}appendPacked(e,d){const f=this.#i;if(this.#b||!e)return{from:f,to:f};const r=e.count|0;if(r===0)return{from:f,to:f};if(this.#l&&d)for(let c=0;c<r;c++)this.#r[f+c]=d[c];this.#i=f+r,this.#h+=r,this.#o.grow(this.#i),this.#c||this.#p(),this.#k(this.#i);const n=new Map;for(const c of e.columns)n.set(c.id,c);for(const c of this.#n){const g=n.get(c.id);g?c.appendPacked(g,f,r):c.grow(this.#s)}return{from:f,to:this.#i}}source(e){if(this.#l)return this.#r[e];if(!(e<0||e>=this.#i))return this.#m(e)}setSource(e,d){this.#b||e<0||e>=this.#i||this.#l&&(this.#r[e]=d)}get(e,d){const f=this.#e.get(e);return f?f.get(d):void 0}set(e,d,f){if(this.#b||d<0||d>=this.#i)return;const r=this.#e.get(e);if(!r){he(`store.set.${e}`,`set() on unknown column "${e}"`);return}r.set(d,f)}remove(e){return this.#b||e<0||e>=this.#i||this.#o.get(e)===1?!1:(this.#o.set(e),this.#u++,this.#h--,!0)}live(e){return e<0||e>=this.#i?!1:this.#o.get(e)===0}compact(e={}){if(this.#b||this.#u===0||!e.force&&this.#u/this.#i<this.#w)return null;const d=this.#i,f=new Uint32Array(d);let r=0;for(let n=0;n<d;n++)f[n]=this.#o.get(n)===1?H:r++;for(const n of this.#n)n.compact(f,d,r);if(this.#l){const n=this.#r;for(let c=0;c<d;c++)f[c]!==H&&(n[f[c]]=n[c]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new Z(Math.max(this.#s,r)),f}column(e){return this.#e.get(e)}columns(){return this.#n.slice()}liveIndices(){const e=new Uint32Array(this.#h);if(this.#u===0){for(let f=0;f<this.#i;f++)e[f]=f;return e}let d=0;for(let f=0;f<this.#i;f++)this.#o.get(f)===0&&(e[d++]=f);return e}convert(e,d){const f=this.#e.get(e);return f?f.convert(d):!1}destroy(){if(!this.#b){this.#b=!0;for(const e of this.#n)e.release();this.#e.clear(),this.#n.length=0,this.#r.length=0,this.#o.release(),this.#i=0,this.#h=0,this.#u=0,this.#s=0}}#k(e){if(e<=this.#s)return;let d=this.#s||this.#d;for(;d<e;)d*=2;for(const f of this.#n)f.grow(d);this.#o.grow(d),this.#s=d}#m(e){const d={};for(const f of this.#n)d[f.id]=f.get(e);return d}#p(){if(this.#c)return;let e=this.#d;for(;e<this.#i;)e*=2;this.#c=!0,this.#s=e,this.#o.grow(e);for(const d of this.#n)d.columnarise(e,this.#i)}}}),Ce("packages/core/src/store/ingest.js",function(o,me){"use strict";Object.defineProperty(o,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"inferKind",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return R}});const ae=me("packages/core/src/internal/util.js"),he=ae.now,W=ae.nextFrame,U=ae.infoOnce,_=ae.warnOnce,Z=ae.isFunction,E=ae.pathGetter,re=me("packages/core/src/store/columnstore.js").ColumnStore,Y=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function se(j,i={}){if(i.multi)return"multi";if(j.length===0)return"object";let a=0,s=0,h=0,u=0,t=0;for(let m=0;m<j.length;m++){const e=j[m];typeof e=="number"?a++:typeof e=="boolean"?s++:typeof e=="string"?h++:e instanceof Date?u++:Array.isArray(e)&&t++}const l=j.length;return a===l?"float64":s===l?"bitset":u===l?"float64":h===l?"text":t===l?"multi":"object"}function te(j,i,a){return i<=0||j<a*i?"dictionary":"object"}function H(j,i,a){const s=new Map,h=new Map;for(const c of j){if(c.computed)continue;const g=Z(c.read)?c.read:E(c.field||c.id);h.set(c.id,g),s.set(c.id,g)}const u=i?.order??[],t=i?.fns??{},l=i?.deps??{},m=i?.wrapDeps??null,e=u.filter(c=>Z(t[c])),d=e.some(c=>l[c]==="*");let f=new WeakMap;const r=c=>{const g={};if(d)for(const[A,P]of h)g[A]=P(c);for(const A of e){const P=l[A];let q;if(P==="*")q=g;else{q={};const L=P||[];for(let v=0;v<L.length;v++){const G=L[v];q[G]=G in g?g[G]:h.get(G)?.(c)}}g[A]=t[A](m?m(q,A):q,{data:c,row:null,column:null,grid:null,context:a})}return g},n=c=>{if(c===null||typeof c!="object"&&typeof c!="function")return r(c);let g=f.get(c);return g===void 0&&(g=r(c),f.set(c,g)),g};for(const c of e)s.set(c,g=>n(g)[c]);return{readers:s,reset(){f=new WeakMap}}}class T{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(i,a){this.spec=i,this.read=a,this.kind="object",this.inferred=!1,this.nullable=i.nullable!==!1}}class V{#t;#e=[];#n=null;#r;#i=0;#s;#h=!1;#u=!1;#o=0;#c;constructor(i,a={},s={}){this.#t=Array.isArray(i)?i:Array.from(i||[]),this.#s={...Y,...s};const h=a.columns??[];this.#r=H(h,a.computed??null,a.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(h,a.computed??null),this.#n=new re(this.#e.map(u=>({id:u.spec.id,kind:u.kind,nullable:u.nullable,read:u.read,dictionary:u.spec.dictionary})),{initialCapacity:this.#s.initialCapacity,columnarBelow:this.#s.columnarBelow})}get store(){return this.#n}get done(){return this.#h||this.#u}get progress(){return this.#i}slice(){if(this.done)return!1;if(this.#s.signal?.aborted)return this.#u=!0,!1;const i=he(),{chunkMs:a,chunkRows:s}=this.#s,h=this.#t.length;do{const u=Math.min(this.#i+s,h);this.#n.append(this.#t.slice(this.#i,u)),this.#a(this.#i,u),this.#i=u,this.#r.reset(),this.#w(!1)}while(this.#i<h&&he()-i<a);return this.#o+=he()-i,this.#s.onProgress?.({loaded:this.#i,total:h}),this.#i>=h?(this.#w(!0),this.#h=!0,!1):!0}cancel(){this.#u=!0}result(){return{store:this.#n,schema:this.#e.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,read:i.read,dictionary:i.spec.dictionary})),decisions:this.#e.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,inferred:i.inferred,distinct:i.candidate||i.change?this.#d(i):null,change:i.change,reason:i.reason})),count:this.#n.count,elapsed:this.#o,cancelled:this.#u}}#l(i,a){const s=this.#t,h=Math.min(this.#s.sampleSize,s.length),u=this.#s.dictionaryRatio,t=a?.pure instanceof Set?a.pure:new Set(a?.pure??a?.order??[]);for(const l of i){if(!l||!l.id)continue;if(l.computed&&(l.pure===!1||a&&!t.has(l.id))){_(`ingest.impure.${l.id}`,`column "${l.id}" is an impure computed column and is not materialised into the store`);continue}const m=this.#r.readers.get(l.id)??(Z(l.read)?l.read:E(l.field||l.id)),e=new T(l,m);if(l.kind)e.kind=l.kind,e.reason="declared by the caller";else if(l.dictionary)e.kind=l.multi?"multi":"dictionary",e.reason="value table supplied (lookup column)";else{const d=[];for(let r=0;r<h&&d.length<this.#s.sampleSize;r++){const n=m(s[r]);n!=null&&d.push(n)}e.inferred=!0;const f=se(d,{multi:l.multi});if(f==="text"){const r=new Set(d).size;e.kind=te(r,d.length,u),e.candidate=this.#c,e.reason=`sampled ${r} distinct in ${d.length}`}else e.kind=f,e.reason=`inferred from ${d.length} sampled values`,f==="object"&&d.length&&U(`ingest.mixed.${l.id}`,`column "${l.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);e.kind==="object"&&e.candidate&&(e.distinct=new Set(d))}this.#e.push(e)}}#a(i,a){const s=this.#t;for(const h of this.#e){if(!h.candidate||!h.distinct)continue;const u=h.distinct;for(let t=i;t<a;t++){const l=h.read(s[t]);l!=null&&u.add(l)}}}#d(i){if(i.distinct)return i.distinct.size;const a=this.#n.column(i.spec.id);return a?.dict?a.dict.size:0}#w(i){const a=this.#s.dictionaryRatio,s=this.#t.length;for(const h of this.#e){if(!h.candidate)continue;const u=this.#d(h);if(h.kind==="dictionary"&&u>=a*s){const t=this.#n.column(h.spec.id);h.distinct=new Set(t?.dict?t.dict.values():[]),this.#n.convert(h.spec.id,"object"),h.kind="object",h.change="demoted",h.reason=`${u} distinct values is at or above ${a*100}% of ${s} rows`;continue}if(h.kind==="object"&&u>=a*s){h.candidate=!1,h.distinct=null,h.reason=`${u} distinct values is at or above ${a*100}% of ${s} rows`;continue}i&&h.kind==="object"&&u<a*s&&(this.#n.convert(h.spec.id,"dictionary"),h.kind="dictionary",h.change=h.change==="demoted"?null:"promoted",h.reason=`${u} distinct values is below ${a*100}% of ${s} rows`,h.distinct=null),i&&(h.candidate=!1)}}}async function ne(j,i={},a={}){const s=new V(j,i,a),h=a.scheduler?.frame??W;for(;s.slice();)await new Promise(u=>{h(u)});return s.result()}function R(j,i={},a={}){const s=new V(j,i,{...a,chunkMs:1/0});for(;s.slice(););return s.result()}}),Ce("packages/core/src/store/columnpack.js",function(o,me){"use strict";Object.defineProperty(o,"isPortableSchema",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"packChunk",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"packedTransfers",{enumerable:!0,get:function(){return V}});const he=me("packages/core/src/internal/util.js").pathGetter,W=me("packages/core/src/store/ingest.js"),U=W.inferKind,_=W.decideText,Z=W.INGEST_DEFAULTS,z=me("packages/core/src/store/columnstore.js").toFloat,re=new Set(["float64","int32","bitset","dictionary","object","multi"]);function Y(ne){if(!Array.isArray(ne)||ne.length===0)return!1;for(const R of ne)if(!R||typeof R.id!="string"||typeof R.field!="string"||R.field===""||R.kind&&!re.has(R.kind))return!1;return!0}function se(ne){const R=z(ne);return Number.isFinite(R)?R|0:0}function te(ne){return ne==null?[]:Array.isArray(ne)?ne:[ne]}function H(ne,R,j,i){if(ne.kind)return ne.kind;const a=[];for(let u=0;u<R.length&&a.length<Z.sampleSize;u++){const t=R[u];t!=null&&a.push(t)}const s=U(a,{multi:ne.multi});if(s!=="text")return s;const h=new Set(a).size;return _(h,a.length,i)}function T(ne,R,j={}){const i=R.length|0,a=j.dictionaryRatio??Z.dictionaryRatio,s=[];for(const h of ne){const u=he(h.field||h.id),t=h.nullable!==!1,l=new Array(i);for(let r=0;r<i;r++){const n=u(R[r]);l[r]=n===void 0?null:n}const m=H(h,l,i,a),e=t?new Uint8Array(i+7>>3):null,d=r=>{e&&(e[r>>3]|=1<<(r&7))};let f;switch(m){case"float64":{const r=new Float64Array(i);for(let n=0;n<i;n++){const c=l[n],g=c===null;g||d(n),r[n]=g?NaN:z(c)}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"int32":{const r=new Int32Array(i);for(let n=0;n<i;n++){const c=l[n],g=c===null;g||d(n),r[n]=g?0:se(c)}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"bitset":{const r=new Uint8Array(i+7>>3);for(let n=0;n<i;n++){const c=l[n],g=c===null;g||d(n),!g&&c&&(r[n>>3]|=1<<(n&7))}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"dictionary":{const r=new Uint32Array(i),n=[],c=new Map;for(let g=0;g<i;g++){const A=l[g];if(A===null){r[g]=0;continue}d(g);let P=c.get(A);P===void 0&&(P=n.length,n.push(A),c.set(A,P)),r[g]=P}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:n};break}case"multi":{const r=[],n=new Map,c=new Uint32Array(i+1),g=[];for(let A=0;A<i;A++){const P=l[A];c[A]=g.length,P===null||d(A);const L=te(P);for(let v=0;v<L.length;v++){const G=L[v];let S=n.get(G);S===void 0&&(S=r.length,r.push(G),n.set(G,S)),g.push(S)}}c[i]=g.length,f={id:h.id,kind:m,nullable:t,values:Int32Array.from(g),presence:e,offsets:c,table:r};break}default:{const r=new Array(i);for(let n=0;n<i;n++){const c=l[n];c!==null&&d(n),r[n]=c}f={id:h.id,kind:"object",nullable:t,values:r,presence:e,offsets:null,table:null};break}}s.push(f)}return{count:i,columns:s}}function V(ne){const R=[];if(!ne||!Array.isArray(ne.columns))return R;const j=i=>{ArrayBuffer.isView(i)&&i.buffer&&!R.includes(i.buffer)&&R.push(i.buffer)};for(const i of ne.columns)j(i.values),j(i.presence),j(i.offsets);return R}}),Ce("packages/core/src/compute/sortspec.js",function(o,me){"use strict";Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return _}});function ae(Z){return{locale:Z===void 0?void 0:String(Z),numeric:!0,sensitivity:"variant"}}function he(Z){return!!Z&&typeof Z.compare!="function"}function W(Z){if(!Z)return!0;for(let E=0;E<Z.length;E++)if(!he(Z[E]))return!1;return!0}function U(Z,E){const z=Z.col!==void 0?Z.col:Z.handle&&Z.handle.id,re=Z.locale!==void 0?Z.locale:E;return{col:z,descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,collation:ae(re)}}function _(Z,E){const z=Z||[],re=new Array(z.length);for(let Y=0;Y<z.length;Y++)re[Y]=U(z[Y],E);return re}}),Ce("packages/core/src/format/date.js",function(o,me){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return R}});const ae=me("packages/core/src/internal/util.js"),he=ae.isNil,W=ae.warnOnce,U=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function _(j){const i=[];let a=0,s="";const h=()=>{s&&(i.push({token:null,text:s}),s="")};for(;a<j.length;){const u=j[a];if(u==="\'"){if(j[a+1]==="\'"){s+="\'",a+=2;continue}const l=j.indexOf("\'",a+1);if(l===-1){s+=j.slice(a+1),a=j.length;continue}s+=j.slice(a+1,l),a=l+1;continue}const t=U.find(l=>j.startsWith(l,a));if(t){h(),i.push({token:t,text:t}),a+=t.length;continue}/[A-Za-z]/.test(u)&&W(`date.pattern.token:${u}`,`the date pattern "${j}" contains \'${u}\', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${U.join(" ")}.`),s+=u,a+=1}return h(),i}const Z=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function E(j){if(he(j)||j==="")return null;if(j instanceof Date)return Number.isNaN(j.getTime())?null:j;if(typeof j=="number")return Number.isNaN(j)?null:new Date(j);if(typeof j=="string"){const i=Z.exec(j.trim());if(i){const[,s,h,u,t="0",l="0",m="0"]=i;return new Date(+s,+h-1,+u,+t,+l,+m)}const a=new Date(j);return Number.isNaN(a.getTime())?null:a}return null}function z(j,i){return String(j).padStart(i,"0")}function re(j){if(!j)return s=>({year:s.getFullYear(),month:s.getMonth()+1,day:s.getDate(),hour:s.getHours(),minute:s.getMinutes(),second:s.getSeconds(),ms:s.getMilliseconds(),weekday:s.getDay()});const i=new Intl.DateTimeFormat("en-US",{timeZone:j,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),a={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return s=>{const h={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:s.getMilliseconds(),weekday:0};for(const u of i.formatToParts(s))switch(u.type){case"year":h.year=Number(u.value);break;case"month":h.month=Number(u.value);break;case"day":h.day=Number(u.value);break;case"hour":h.hour=Number(u.value)%24;break;case"minute":h.minute=Number(u.value);break;case"second":h.second=Number(u.value);break;case"weekday":h.weekday=a[u.value]??0;break;default:break}return h}}function Y(j,i,a){const s=_(j),h=re(a),u=new Set(s.filter(d=>d.token).map(d=>d.token)),t=u.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:a}):null,l=u.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:a}):null,m=u.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:a}):null,e=u.has("EEEE")?new Intl.DateTimeFormat(i,{weekday:"long",timeZone:a}):null;return d=>{const f=h(d);let r="";for(const n of s){if(!n.token){r+=n.text;continue}switch(n.token){case"yyyy":r+=z(f.year,4);break;case"yy":r+=z(f.year%100,2);break;case"MMMM":r+=l.format(d);break;case"MMM":r+=t.format(d);break;case"MM":r+=z(f.month,2);break;case"M":r+=String(f.month);break;case"dd":r+=z(f.day,2);break;case"d":r+=String(f.day);break;case"EEEE":r+=e.format(d);break;case"EEE":r+=m.format(d);break;case"HH":r+=z(f.hour,2);break;case"H":r+=String(f.hour);break;case"hh":r+=z(f.hour%12===0?12:f.hour%12,2);break;case"h":r+=String(f.hour%12===0?12:f.hour%12);break;case"mm":r+=z(f.minute,2);break;case"m":r+=String(f.minute);break;case"ss":r+=z(f.second,2);break;case"s":r+=String(f.second);break;case"SSS":r+=z(f.ms,3);break;case"a":r+=f.hour<12?"AM":"PM";break;default:r+=n.text;break}}return r}}const se=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function te(j,i){const a=j||{},s=a.locale||i||void 0,h=a.nullDisplay??"",u=a.timeZone;let t;if(a.pattern)t=Y(a.pattern,s,u);else if(a.dateStyle||a.timeStyle){const f={timeZone:u};a.dateStyle&&(f.dateStyle=a.dateStyle),a.timeStyle&&(f.timeStyle=a.timeStyle);const r=new Intl.DateTimeFormat(s,f);t=n=>r.format(n)}else{const f=new Intl.DateTimeFormat(s,{dateStyle:"medium",timeZone:u});t=r=>f.format(r)}const l=a.relative?new Intl.RelativeTimeFormat(s,{numeric:"auto"}):null,e=(typeof a.relative=="object"&&a.relative?a.relative.threshold??7:7)*24*36e5,d=(f,r)=>{const n=E(f);if(!n)return h;if(l){const c=r&&typeof r.now=="number"?r.now:Date.now(),g=n.getTime()-c;if(Math.abs(g)<e){for(const[A,P]of se)if(Math.abs(g)>=P||A==="second")return l.format(Math.round(g/P),A)}}return t(n)};return d.spec=a,d}function H(j){if(he(j)||j==="")return null;if(typeof j=="string"){const s=/^(\\d{4}-\\d{2}-\\d{2})/.exec(j.trim());if(s)return s[1];const h=E(j);return h?H(h):null}const i=E(j);if(!i)return null;const a=s=>String(s).padStart(2,"0");return`${i.getFullYear()}-${a(i.getMonth()+1)}-${a(i.getDate())}`}function T(j,i){if(he(j)||j==="")return null;if(typeof j=="string"){const s=j.trim();if(V.test(s)){const t=E(s);return t?ne(t,i):null}const h=/^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(s);if(h){const[,t,l,m,e]=h;return`${t}T${l}:${m}${e&&e!=="00"?`:${e}`:""}`}if(/^\\d{4}-\\d{2}-\\d{2}$/.test(s))return`${s}T00:00`;const u=E(s);return u?T(u):null}const a=E(j);return a?ne(a,i):null}const V=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function ne(j,i){const a=t=>String(t).padStart(2,"0");if(i)try{const t=new Intl.DateTimeFormat("en-CA",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(j).reduce((e,d)=>(d.type!=="literal"&&(e[d.type]=d.value),e),{}),l=t.hour==="24"?"00":t.hour,m=Number(t.second);return`${t.year}-${t.month}-${t.day}T${l}:${t.minute}`+(m?`:${t.second}`:"")}catch{}const s=`${j.getFullYear()}-${a(j.getMonth()+1)}-${a(j.getDate())}`,h=j.getSeconds(),u=`${a(j.getHours())}:${a(j.getMinutes())}${h?`:${a(h)}`:""}`;return`${s}T${u}`}function R(j,i){const a=he(j)||j===""?null:String(j),s=he(i)||i===""?null:String(i);return a===null?s===null?0:1:s===null||a<s?-1:a>s?1:0}}),Ce("packages/core/src/compute/filter.js",function(o,me){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"wallMs",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"itemwisePredicate",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(o,"declareOperators",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"declaredOperator",{enumerable:!0,get:function(){return fe}});const ae=me("packages/core/src/internal/util.js"),he=ae.isBlank,W=ae.toArray,U=ae.warnOnce,_=me("packages/core/src/format/date.js"),Z=_.toDate,E=_.toIsoDate,z=me("packages/core/src/compute/handle.js"),re=z.bitReader,Y=z.dictSize,se=z.dictValue,te=z.presenceReader,H=z.valueComparator,T=z.valueReader,V=/^\\d{4}-\\d{2}-\\d{2}$/,ne="\\0null\\0";function R(p,Q){const X=p&&p.pool;if(X){const ce=X.mask||X.acquireMask||X.acquire||X.take;if(typeof ce=="function"){const le=ce.call(X,Q);if(le&&le.length>=Q)return le}}return new Uint8Array(Q)}function j(p,Q){const X=p&&p.pool;if(!X||!Q)return;const ce=X.release||X.releaseMask||X.free||X.recycle;typeof ce=="function"&&ce.call(X,Q)}function i(p,Q,X){return p.fill(X,0,Q),p}function a(p){return p==null||typeof p=="number"&&Number.isNaN(p)}function s(p,Q){if(p==null)return p;if(Q==="number")return typeof p=="number"?p:Number(p);if(Q==="date"||Q==="dateString"){const X=E(p);return X===null?h(p):X}return Q==="boolean"?typeof p=="boolean"?p:p==="true"||p===1?!0:p==="false"||p===0?!1:!!p:p}function h(p){return p instanceof Date?p.getTime():typeof p=="number"?p:Date.parse(String(p))}function u(p){return typeof p=="number"?p:p instanceof Date?p.getTime():p==null||p===""?NaN:Number(p)}function t(p,Q){const X=typeof p=="string"?p:String(p);return Q?X:X.toLowerCase()}function l(p,Q){return p==null?ne:typeof p=="string"?Q?p:p.toLowerCase():p instanceof Date?p.getTime():p}function m(p,Q,X){const ce=new Set;for(const le of W(p)){const ge=s(le,X);ce.add(l(ge,Q)),typeof ge=="string"&&ge!==""&&Number.isFinite(Number(ge))?ce.add(Number(ge)):typeof ge=="number"&&Number.isFinite(ge)&&ce.add(l(String(ge),Q))}return ce}function e(p,Q,X){if(p==null||Q===null||Q===void 0)return p==null&&Q==null;const ce=typeof p,le=typeof Q;return ce==="string"&&le==="string"?X?p===Q:p.toLowerCase()===Q.toLowerCase():p instanceof Date||Q instanceof Date?h(p)===h(Q):ce==="number"&&le==="number"?p===Q||Number.isNaN(p)&&Number.isNaN(Q):ce==="number"&&le==="string"?p===Number(Q):ce==="string"&&le==="number"?Number(p)===Q:ce==="boolean"||le==="boolean"?p===Q:Array.isArray(p)&&Array.isArray(Q)?p.length===Q.length&&p.every((ge,Me)=>e(ge,Q[Me],X)):p===Q}function d(p,Q){try{if(p instanceof RegExp){const X=p.flags.replace(/[gy]/g,"");return new RegExp(p.source,Q||X.includes("i")?X:`${X}i`)}return new RegExp(String(p),Q?"":"i")}catch(X){return U(`regex:${String(p)}`,`filter operator "matches" received an invalid pattern: ${String(p)}`,X),null}}function f(p,Q){if(p&&p.type==="datetime"&&r.has(p.op))return P(p,Q);const X=q(p,Q),ce=p&&p.type;return ce!=="date"&&ce!=="dateString"?X:le=>X(typeof le=="string"&&V.test(le)?le:E(le)??le)}const r=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),n=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{1,3})\\d*)?)?)?$/,c=new Map;function g(p,Q){let X=c.get(Q);if(X===void 0){try{X=new Intl.DateTimeFormat("en-CA",{timeZone:Q,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{X=null}c.set(Q,X)}if(!X)return null;const ce={};for(const le of X.formatToParts(p))le.type!=="literal"&&(ce[le.type]=le.value);return ce}function A(p,Q){if(p==null||p==="")return null;if(typeof p=="string"){const ge=n.exec(p.trim());if(ge)return Date.UTC(+ge[1],+ge[2]-1,+ge[3],+(ge[4]||0),+(ge[5]||0),+(ge[6]||0),+(ge[7]||"0").padEnd(3,"0"))}const X=Z(p);if(!X)return null;const ce=X.getUTCMilliseconds(),le=Q?g(X,Q):null;return le?Date.UTC(+le.year,+le.month-1,+le.day,le.hour==="24"?0:+le.hour,+le.minute,+le.second,ce):Date.UTC(X.getFullYear(),X.getMonth(),X.getDate(),X.getHours(),X.getMinutes(),X.getSeconds(),ce)}function P(p,Q){const X=typeof p.timeZone=="string"&&p.timeZone?p.timeZone:void 0,ce=Me=>A(Me,X),le=Array.isArray(p.value)?p.value.map(ce):ce(p.value),ge=q({...p,type:"number",value:le},Q);return Me=>ge(A(Me))}function q(p,Q){const X=p&&p.op,ce=!!(p&&p.caseSensitive),le=p&&p.type,ge=H(Q),Me=be=>ye=>!be(ye);switch(X){case"eq":{const be=s(p.value,le);return ye=>e(ye,be,ce)}case"ne":{const be=s(p.value,le);return ye=>!e(ye,be,ce)}case"lt":case"lte":case"gt":case"gte":{const be=s(p.value,le);if(a(be))return()=>!1;const ye=X==="lt"?-1:X==="lte"?0:X==="gt"?1:2;return Re=>{if(a(Re))return!1;const Ne=ge(Re,be);return ye===-1?Ne<0:ye===0?Ne<=0:ye===1?Ne>0:Ne>=0}}case"between":case"notBetween":{const be=W(p.value),ye=s(be[0],le),Re=s(be[1],le),Ne=p.bounds||"[]",Ee=Ne.charAt(0)!=="(",Be=Ne.charAt(1)!==")";if(a(ye)||a(Re))return X==="between"?()=>!1:()=>!0;const ze=We=>{if(a(We))return!1;const Xe=ge(We,ye),Ye=ge(We,Re);return(Ee?Xe>=0:Xe>0)&&(Be?Ye<=0:Ye<0)};return X==="between"?ze:Me(ze)}case"in":case"notIn":{const be=m(p.value,ce,le),ye=Re=>be.has(l(Re,ce));return X==="in"?ye:Me(ye)}case"contains":case"notContains":{const be=t(s(p.value,le),ce),ye=Re=>Re==null?!1:t(Re,ce).includes(be);return X==="contains"?ye:Me(ye)}case"startsWith":{const be=t(s(p.value,le),ce);return ye=>ye==null?!1:t(ye,ce).startsWith(be)}case"endsWith":{const be=t(s(p.value,le),ce);return ye=>ye==null?!1:t(ye,ce).endsWith(be)}case"matches":{const be=d(p.value,ce);return be?ye=>ye==null?!1:be.test(String(ye)):()=>!1}case"blank":return be=>he(be)||Array.isArray(be)&&be.length===0;case"notBlank":return be=>!(he(be)||Array.isArray(be)&&be.length===0);case"containsAny":case"containsNone":{const be=m(p.value,ce,le),ye=Re=>{const Ne=Re==null?[]:W(Re);for(let Ee=0;Ee<Ne.length;Ee++)if(be.has(l(Ne[Ee],ce)))return!0;return!1};return X==="containsAny"?ye:Me(ye)}case"containsAll":{const be=W(p.value).map(ye=>l(s(ye,le),ce));return ye=>{const Re=ye==null?[]:W(ye);if(be.length===0)return!0;const Ne=new Set(Re.map(Ee=>l(Ee,ce)));for(let Ee=0;Ee<be.length;Ee++)if(!Ne.has(be[Ee]))return!1;return!0}}default:{const be=fe(X);return be?be.compile(p.value):(U(`op:${String(X)}`,`unknown filter operator "${String(X)}"; the condition is refused rather than matching every row`),()=>!1)}}}function L(p,Q,X){return f(Q,X)(p)}const v=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),G=new Set(["containsAny","containsAll","containsNone"]);function S(p,Q,X){const ce=p&&p.op,le=v[ce]||ce,ge=f({...p,op:le,type:Q.type},X),Me=Q.items,be=ye=>{const Re=Me(ye);if(!Re)return!1;for(let Ne=0;Ne<Re.length;Ne++)if(ge(Re[Ne]))return!0;return!1};return v[ce]?ye=>!be(ye):be}function N(p,Q,X,ce){const le=te(p);if(le){const be=Q?1:0;for(let ye=0;ye<ce;ye++)X[ye]=le(ye)===be?1:0;return X}const ge=p.kind;if(ge==="float64"||ge==="int32"||ge==="bitset")return i(X,ce,Q?1:0);const Me=T(p);for(let be=0;be<ce;be++){const ye=Me(be),Re=he(ye)||Array.isArray(ye)&&ye.length===0;X[be]=Re===Q?0:1}return X}function I(p,Q,X,ce){const le=p.dict,ge=Y(le),Me=new Uint8Array(ge);for(let Ne=0;Ne<ge;Ne++)Me[Ne]=Q(se(le,Ne))?1:0;const be=p.values,ye=te(p);if(!ye){for(let Ne=0;Ne<ce;Ne++)X[Ne]=Me[be[Ne]];return X}const Re=Q(null)?1:0;for(let Ne=0;Ne<ce;Ne++)X[Ne]=ye(Ne)===1?Me[be[Ne]]:Re;return X}function K(p,Q,X,ce){const le=re(p.values),ge=Q(!0)?1:0,Me=Q(!1)?1:0,be=te(p);if(!be){for(let Re=0;Re<ce;Re++)X[Re]=le(Re)===1?ge:Me;return X}const ye=Q(null)?1:0;for(let Re=0;Re<ce;Re++)X[Re]=be(Re)===0?ye:le(Re)===1?ge:Me;return X}function B(p,Q,X,ce,le){const ge=p.values,Me=Q.type,be=Q.op;let ye=!0;switch(be){case"eq":case"ne":{const Ne=u(s(Q.value,Me)),Ee=typeof Q.value=="number"&&Number.isNaN(Q.value),Be=be==="ne"?1:0;if(Ee)for(let ze=0;ze<le;ze++)ce[ze]=(Number.isNaN(ge[ze])?1:0)^Be;else for(let ze=0;ze<le;ze++)ce[ze]=(ge[ze]===Ne?1:0)^Be;break}case"lt":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]<Ne?1:0;break}case"lte":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]<=Ne?1:0;break}case"gt":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]>Ne?1:0;break}case"gte":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]>=Ne?1:0;break}case"between":case"notBetween":{const Ne=W(Q.value),Ee=u(s(Ne[0],Me)),Be=u(s(Ne[1],Me)),ze=Q.bounds||"[]",We=ze.charAt(0)!=="(",Xe=ze.charAt(1)!==")",Ye=be==="notBetween"?1:0;if(We&&Xe)for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>=Ee&ge[Ie]<=Be?1:0)^Ye;else if(We)for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>=Ee&ge[Ie]<Be?1:0)^Ye;else if(Xe)for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>Ee&ge[Ie]<=Be?1:0)^Ye;else for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>Ee&ge[Ie]<Be?1:0)^Ye;break}case"in":case"notIn":{const Ne=new Set;for(const Be of W(Q.value)){const ze=u(s(Be,Me));Number.isNaN(ze)||Ne.add(ze)}const Ee=be==="notIn"?1:0;for(let Be=0;Be<le;Be++)ce[Be]=(Ne.has(ge[Be])?1:0)^Ee;break}default:ye=!1;break}if(!ye)return!1;const Re=te(p);if(Re){const Ne=X(null)?1:0;for(let Ee=0;Ee<le;Ee++)Re(Ee)===0&&(ce[Ee]=Ne)}return!0}function ee(p,Q,X,ce){const le=T(p);for(let ge=0;ge<ce;ge++)X[ge]=Q(le(ge))?1:0;return X}function J(p,Q,X){const ce=Q.count|0,le=X||R(Q,ce);if(!p)return i(le,ce,1);const ge=typeof Q.handle=="function"?Q.handle(p.col):void 0,Me=typeof Q.custom=="function"?Q.custom:null;if(!ge){if(Me){for(let Ne=0;Ne<ce;Ne++)le[Ne]=Me(p,Ne)?1:0;return le}return U(`filter:col:${String(p.col)}`,`filter references unknown column "${String(p.col)}"; the condition is refused rather than matching every row`),i(le,ce,0)}const be=p.op;if(be==="blank"||be==="notBlank")return N(ge,be==="notBlank",le,ce);const ye=typeof Q.itemwise=="function"?Q.itemwise(p.col):null;if(ye&&!fe(be)&&!G.has(be))return ee(ge,S(p,ye,Q.locale),le,ce);const Re=f(p,Q.locale);switch(ge.kind){case"dictionary":return I(ge,Re,le,ce);case"bitset":return K(ge,Re,le,ce);case"float64":case"int32":return B(ge,p,Re,le,ce)?le:ee(ge,Re,le,ce);default:return ee(ge,Re,le,ce)}}function ue(p,Q,X){if(!p)return i(R(Q,X),X,1);if(Array.isArray(p.conditions)){const ce=p.conditions.filter(Me=>Me!=null),le=p.op==="or"?"or":p.op==="not"?"not":"and";if(ce.length===0)return i(R(Q,X),X,1);const ge=ue(ce[0],Q,X);for(let Me=1;Me<ce.length;Me++){const be=ue(ce[Me],Q,X);if(le==="or")for(let ye=0;ye<X;ye++)ge[ye]|=be[ye];else for(let ye=0;ye<X;ye++)ge[ye]&=be[ye];j(Q,be)}if(le==="not")for(let Me=0;Me<X;Me++)ge[Me]^=1;return ge}return J(p,Q,R(Q,X))}function de(p,Q){return ue(p,Q,Q.count|0)}function Oe(p,Q){if(!p||!Q)return p||null;const X=p;if(Array.isArray(X.conditions)){if((X.op==="or"?"or":X.op==="not"?"not":"and")!=="and")return Ae(X,Q)?null:p;const le=[];for(const ge of X.conditions){const Me=Oe(ge,Q);Me&&le.push(Me)}return le.length?{...X,op:"and",conditions:le}:null}return X.col===Q?null:p}function Ae(p,Q){if(!p||typeof p!="object")return!1;const X=p;if(X.col===Q)return!0;if(Array.isArray(X.conditions)){for(const ce of X.conditions)if(Ae(ce,Q))return!0}return!1}function Se(p,Q,X){if(X&&X.length>=Q){let Me=0;for(let be=0;be<Q;be++)p[be]&&(X[Me++]=be);return X.subarray(0,Me)}let ce=0;for(let Me=0;Me<Q;Me++)ce+=p[Me]?1:0;const le=new Uint32Array(ce);let ge=0;for(let Me=0;Me<Q;Me++)p[Me]&&(le[ge++]=Me);return le}const D=new Map;function x(p){if(!(!p||typeof p!="object"))for(const[Q,X]of Object.entries(p))X&&typeof X.compile=="function"&&D.set(Q,X)}function fe(p){return typeof p=="string"?D.get(p):void 0}}),Ce("packages/core/src/compute/group.js",function(o,me){"use strict";Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return te}});const ae=me("packages/core/src/compute/handle.js"),he=ae.dictSize,W=ae.identity,U=ae.presenceReader,_=ae.rowCount,Z=ae.valueReader,E="",z="\\0",re=1<<20;function Y(H,T,V,ne){const R=H.length,j=H.map(t=>Z(t)),i=Array.isArray(ne)&&ne.some(Boolean),a=i?j.map((t,l)=>ne[l]?m=>ne[l](t(m)):t):j;if(!i&&R>0&&H.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=H.map(m=>he(m.dict)+1);let l=1;for(let m=0;m<R;m++)l*=t[m];if(l<=Number.MAX_SAFE_INTEGER){const m=H.map(r=>r.values),e=H.map(r=>U(r)),d=r=>{let n=0;for(let c=0;c<R;c++){const g=e[c],A=g&&g(r)===0?t[c]-1:m[c][r];n=n*t[c]+A}return n},f=new Float64Array(V);for(let r=0;r<V;r++)f[r]=d(T[r]);return{packed:f,strings:null,product:l,readers:a,keyOf:d}}}const h=t=>{let l="";for(let m=0;m<R;m++){const e=a[m](t);l+=(m===0?"":E)+(e==null?z:String(e))}return l},u=new Array(V);for(let t=0;t<V;t++)u[t]=h(T[t]);return{packed:null,strings:u,product:1/0,readers:a,keyOf:h}}function se(H,T,V,ne){const R=new Uint32Array(ne+1);for(let s=0;s<V;s++)R[T[s]+1]++;for(let s=0;s<ne;s++)R[s+1]+=R[s];const j=new Uint32Array(V),i=R.slice(0,ne);for(let s=0;s<V;s++)j[i[T[s]]++]=H[s];const a=new Array(ne);for(let s=0;s<ne;s++)a[s]=j.subarray(R[s],R[s+1]);return a}function te(H,T,V={}){const ne=H||[],R=T||W(_(ne[0],V)),j=R.length;if(ne.length===0||j===0)return{keys:[],buckets:[]};const{packed:i,strings:a,product:s,readers:h}=Y(ne,R,j,V.project),u=new Uint32Array(j);let t=0,l=null;if(i&&s<=Math.max(1024,Math.min(re,j*4))){const f=s,r=new Int32Array(f).fill(-1);for(let n=0;n<j;n++)r[i[n]]=0;for(let n=0;n<f;n++)r[n]===0&&(r[n]=t++);for(let n=0;n<j;n++)u[n]=r[i[n]];l=new Float64Array(t);for(let n=0;n<f;n++)r[n]>=0&&(l[r[n]]=n)}else if(i){const f=new Map;for(let r=0;r<j;r++){const n=i[r];let c=f.get(n);c===void 0&&(c=t++,f.set(n,c)),u[r]=c}l=new Float64Array(t);for(const[r,n]of f)l[n]=r}else{const f=new Map;for(let r=0;r<j;r++){const n=a[r];let c=f.get(n);c===void 0&&(c=t++,f.set(n,c)),u[r]=c}}const m=se(R,u,j,t),e=new Array(t);for(let f=0;f<t;f++){const r=m[f][0],n=new Array(h.length);for(let c=0;c<h.length;c++)n[c]=h[c](r);e[f]=n}const d={keys:e,buckets:m};return l&&(d.packed=l),d}}),Ce("packages/core/src/compute/facet.js",function(o,me){"use strict";Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return r}});const ae=me("packages/core/src/compute/handle.js"),he=ae.presenceReader,W=ae.valueReader,U=ae.dictSize,_=ae.dictValue,Z=Object.freeze(["equal","quantile","log"]),E=Object.freeze(["hour","day","week","month","quarter","year"]),z=20,re=50,Y=1e4;function se(n,c){if(!n)return"none";const g=c;if(g&&(g.multi===!0||typeof g.items=="function"))return"category";const A=c&&c.base;if(A==="date"||A==="datetime"||A==="time"||A==="dateString")return"date";switch(n.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return A==="number"?"numeric":A==="boolean"?"boolean":A==="text"?"category":"none"}}function te(n){const c=n.values,g=n.kind;if((g==="float64"||g==="int32")&&c)return P=>c[P];const A=W(n);return P=>H(A(P))}function H(n){if(typeof n=="number")return n;if(n instanceof Date)return n.getTime();if(n==null||n==="")return NaN;if(typeof n=="boolean")return n?1:0;if(typeof n=="string"){const c=Number(n);if(Number.isFinite(c))return c;const g=Date.parse(n);return Number.isFinite(g)?g:NaN}return NaN}function T(n,c,g,A=re){if(!n)return{cardinality:0,exact:!0};if(n.dict)return{cardinality:U(n.dict),exact:!0};if(n.kind==="bitset")return{cardinality:2,exact:!0};const P=W(n),q=c?c.length:g,L=new Set;for(let v=0;v<q;v++){const G=P(c?c[v]:v);if(G!=null&&(L.add(G),L.size>A))return{cardinality:L.size,exact:!1}}return{cardinality:L.size,exact:!0}}const V=36e5,ne=864e5;function R(n,c=z){const g=Number.isFinite(n)&&n>0?n:0,A=Math.max(1,c)*2;return g/V<=A?"hour":g/ne<=A?"day":g/(7*ne)<=A?"week":g/(30*ne)<=A?"month":g/(91*ne)<=A?"quarter":"year"}function j(n,c){if(!Number.isFinite(n))return NaN;const g=new Date(n);switch(c){case"hour":return g.setMinutes(0,0,0),g.getTime();case"day":return g.setHours(0,0,0,0),g.getTime();case"week":{g.setHours(0,0,0,0);const A=(g.getDay()+6)%7;return g.setDate(g.getDate()-A),g.getTime()}case"month":return g.setDate(1),g.setHours(0,0,0,0),g.getTime();case"quarter":return g.setMonth(Math.floor(g.getMonth()/3)*3,1),g.setHours(0,0,0,0),g.getTime();default:return g.setMonth(0,1),g.setHours(0,0,0,0),g.getTime()}}function i(n,c){const g=new Date(n);switch(c){case"hour":g.setHours(g.getHours()+1);break;case"day":g.setDate(g.getDate()+1);break;case"week":g.setDate(g.getDate()+7);break;case"month":g.setMonth(g.getMonth()+1);break;case"quarter":g.setMonth(g.getMonth()+3);break;default:g.setFullYear(g.getFullYear()+1);break}return g.getTime()}function a(n,c,g){const A=te(n),P=he(n),q=c?c.length:g;let L=1/0,v=-1/0,G=0,S=0;for(let N=0;N<q;N++){const I=c?c[N]:N;if(P&&!P(I)){G++;continue}const K=A(I);if(!Number.isFinite(K)){G++;continue}K<L&&(L=K),K>v&&(v=K),S++}return{min:L,max:v,nulls:G,finite:S}}function s(n,c,g,A){const P=te(n),q=he(n),L=c?c.length:g,v=L>A?L/A:1,G=[];for(let N=0;N<L;N+=v){const I=c?c[Math.floor(N)]:Math.floor(N);if(q&&!q(I))continue;const K=P(I);Number.isFinite(K)&&G.push(K)}const S=Float64Array.from(G);return S.sort(),S}function h(n,c,g,A={}){const P=A.kind||se(n,A.type);return P==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:P==="boolean"?u(n,c,g):P==="category"?t(n,c,g,A):l(n,c,g,P,A)}function u(n,c,g){const A=he(n);let P=0;if(A){const L=c?c.length:g;for(let v=0;v<L;v++)A(c?c[v]:v)||P++}const q=[{value:!1,label:"false"},{value:!0,label:"true"}];return P>0&&q.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:q}}function t(n,c,g,A){const P=A.cardinalityLimit??re,{cardinality:q}=T(n,c,g,P);if(q>P&&(A.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:q};const L=W(n),v=c?c.length:g,G=new Map;let S=0;for(let ee=0;ee<v;ee++){const J=L(c?c[ee]:ee);if(J==null||J===""){S++;continue}if(Array.isArray(J)){if(!J.length){S++;continue}for(const ue of J)G.set(ue,(G.get(ue)||0)+1);continue}G.set(J,(G.get(J)||0)+1)}let N=[...G.entries()];A.order==="alpha"?N.sort((ee,J)=>String(ee[0]).localeCompare(String(J[0]))):N.sort((ee,J)=>J[1]-ee[1]);let I=0,K=0;if(N.length>P){K=N.length-P;for(let ee=P;ee<N.length;ee++)I+=N[ee][1];N=N.slice(0,P)}const B=N.map(([ee])=>({value:ee,label:String(ee)}));return I>0&&B.push({remainder:!0,label:`Other (${K} values)`}),S>0&&B.push({null:!0,label:"Empty"}),{kind:"category",buckets:B,cardinality:q}}function l(n,c,g,A,P){const{min:q,max:L,nulls:v,finite:G}=a(n,c,g);if(!G)return{kind:A,buckets:v?[{null:!0,label:"Empty"}]:[],empty:!0};const S=Math.max(1,Math.floor(P.buckets||z));let N=[];if(A==="date"){const K=E.includes(P.granularity)?P.granularity:R(L-q,S);let B=j(q,K);for(;B<=L&&N.length<4096;){const ee=i(B,K);if(!(ee>B))break;N.push({from:B,to:ee}),B=ee}return{kind:A,buckets:m(N,v),granularity:K}}const I=Z.includes(P.strategy)?P.strategy:"equal";if(I==="quantile"){const K=s(n,c,g,Y);if(K.length){const B=[K[0]];for(let ee=1;ee<S;ee++){const J=K[Math.min(K.length-1,Math.floor(ee/S*K.length))];J>B[B.length-1]&&B.push(J)}B.push(L);for(let ee=0;ee<B.length-1;ee++)N.push({from:B[ee],to:B[ee+1]})}}else if(I==="log"&&q>0){const K=Math.log10(q),ee=(Math.log10(L)-K)/S||1;for(let J=0;J<S;J++)N.push({from:10**(K+J*ee),to:10**(K+(J+1)*ee)})}if(!N.length){const K=(L-q)/S||1;for(let B=0;B<S;B++)N.push({from:q+B*K,to:q+(B+1)*K})}return N[N.length-1].to=L,{kind:A,buckets:m(N,v),strategy:I,min:q,max:L}}function m(n,c){return c>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,c,g,A,P){const q=A&&A.buckets||[],L=P&&P.length>=q.length?P.subarray(0,q.length):new Uint32Array(q.length);if(L.fill(0),!n||!q.length)return L;const v=q.length-1,G=!!q[v]&&q[v].null===!0,S=c?c.length:g;if(A.kind==="boolean"){const ee=W(n);for(let J=0;J<S;J++){const ue=ee(c?c[J]:J);if(ue==null){G&&L[v]++;continue}L[ue?1:0]++}return L}if(A.kind==="category"){const ee=new Map;for(let de=0;de<q.length;de++)!q[de].null&&!q[de].remainder&&ee.set(q[de].value,de);const J=q.findIndex(de=>de.remainder),ue=W(n);for(let de=0;de<S;de++){const Oe=ue(c?c[de]:de);if(Oe==null||Oe===""){G&&L[v]++;continue}if(Array.isArray(Oe)){if(!Oe.length){G&&L[v]++;continue}for(const Se of Oe){const D=ee.get(Se);D!==void 0?L[D]++:J>=0&&L[J]++}continue}const Ae=ee.get(Oe);Ae!==void 0?L[Ae]++:J>=0&&L[J]++}return L}const N=G?q.length-1:q.length,I=new Float64Array(N+1);for(let ee=0;ee<N;ee++)I[ee]=q[ee].from;I[N]=N?q[N-1].to:0;const K=te(n),B=he(n);for(let ee=0;ee<S;ee++){const J=c?c[ee]:ee;if(B&&!B(J)){G&&L[v]++;continue}const ue=K(J);if(!Number.isFinite(ue)){G&&L[v]++;continue}const de=d(I,N,ue);de>=0&&L[de]++}return L}function d(n,c,g){if(!c||g<n[0])return-1;if(g>=n[c])return g===n[c]?c-1:-1;let A=0,P=c-1;for(;A<P;){const q=A+P+1>>>1;g>=n[q]?A=q:P=q-1}return A}function f(n,c,g,A={}){const P=A.bounds||h(n,A.boundsIndices??c,g,A);return{bounds:P,counts:e(n,c,g,P)}}const r=f}),Ce("packages/core/src/compute/special.js",function(o,me){"use strict";Object.defineProperty(o,"logGamma",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"incompleteBeta",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return ne}});const ae=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),he=3e-12,W=1e-300;function U(R){if(R<.5)return Math.log(Math.PI/Math.sin(Math.PI*R))-U(1-R);const j=R-1;let i=.9999999999998099;const a=j+7.5;for(let s=0;s<ae.length;s++)i+=ae[s]/(j+s+1);return .5*Math.log(2*Math.PI)+(j+.5)*Math.log(a)-a+Math.log(i)}function _(R,j,i){const a=R+j,s=R+1,h=R-1;let u=1,t=1-a*i/s;Math.abs(t)<W&&(t=W),t=1/t;let l=t;for(let m=1;m<=300;m++){const e=2*m;let d=m*(j-m)*i/((h+e)*(R+e));t=1+d*t,Math.abs(t)<W&&(t=W),u=1+d/u,Math.abs(u)<W&&(u=W),t=1/t,l*=t*u,d=-(R+m)*(a+m)*i/((R+e)*(s+e)),t=1+d*t,Math.abs(t)<W&&(t=W),u=1+d/u,Math.abs(u)<W&&(u=W),t=1/t;const f=t*u;if(l*=f,Math.abs(f-1)<he)break}return l}function Z(R,j,i){if(!(R>0)||!(j>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const a=Math.exp(U(R+j)-U(R)-U(j)+R*Math.log(i)+j*Math.log(1-i));return i<(R+1)/(R+j+2)?a*_(R,j,i)/R:1-a*_(j,R,1-i)/j}function E(R){if(!(R>0)||!(R<1))return R===0?-1/0:R===1?1/0:Number.NaN;const j=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],i=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],a=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],s=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],h=.02425;let u,t,l;R<h?(u=Math.sqrt(-2*Math.log(R)),l=(((((a[0]*u+a[1])*u+a[2])*u+a[3])*u+a[4])*u+a[5])/((((s[0]*u+s[1])*u+s[2])*u+s[3])*u+1)):R<=1-h?(u=R-.5,t=u*u,l=(((((j[0]*t+j[1])*t+j[2])*t+j[3])*t+j[4])*t+j[5])*u/(((((i[0]*t+i[1])*t+i[2])*t+i[3])*t+i[4])*t+1)):(u=Math.sqrt(-2*Math.log(1-R)),l=-(((((a[0]*u+a[1])*u+a[2])*u+a[3])*u+a[4])*u+a[5])/((((s[0]*u+s[1])*u+s[2])*u+s[3])*u+1));const e=(.5*z(-l/Math.SQRT2)-R)*Math.sqrt(2*Math.PI)*Math.exp(l*l/2);return l-e/(1+l*e/2)}function z(R){const j=Math.abs(R),i=2/(2+j),a=4*i-2,s=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let h=0,u=0,t;for(let m=s.length-1;m>0;m--)t=u,u=a*u-h+s[m],h=t;const l=i*Math.exp(-j*j+.5*(s[0]+a*u)-h);return R>=0?l:2-l}function re(R){return .5*z(-R/Math.SQRT2)}function Y(R,j){if(!(j>0)||!Number.isFinite(R))return Number.NaN;const i=.5*Z(j/2,.5,j/(j+R*R));return R>0?1-i:i}function se(R,j){if(!(R>0)||!(R<1)||!(j>0))return Number.NaN;if(j>1e7)return E(R);let i=-1e4,a=1e4,s=E(R);const h=U(j/2)+U(.5)-U((j+1)/2);for(let u=0;u<60;u++){const t=Y(s,j);t<R?i=s:a=s;const l=Math.exp(-((j+1)/2)*Math.log(1+s*s/j)-h)/Math.sqrt(j),m=l>0?(t-R)/l:0;if(Math.abs(m)<1e-12)break;const e=s-m;if(s=e>i&&e<a&&Number.isFinite(e)?e:(i+a)/2,a-i<1e-12)break}return s}function te(R,j){let i=R,a=1/R,s=a;for(let h=0;h<300&&(i+=1,s*=j/i,a+=s,!(Math.abs(s)<Math.abs(a)*he));h++);return a*Math.exp(-j+R*Math.log(j)-U(R))}function H(R,j){let i=j+1-R,a=1/W,s=1/i,h=s;for(let u=1;u<=300;u++){const t=-u*(u-R);i+=2,s=t*s+i,Math.abs(s)<W&&(s=W),a=i+t/a,Math.abs(a)<W&&(a=W),s=1/s;const l=s*a;if(h*=l,Math.abs(l-1)<he)break}return Math.exp(-j+R*Math.log(j)-U(R))*h}function T(R,j){return!(R>0)||!(j>=0)||!Number.isFinite(j)?Number.NaN:j===0?0:j<R+1?te(R,j):1-H(R,j)}function V(R,j){return j>0?T(j/2,R/2):Number.NaN}function ne(R,j){const i=V(R,j);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Ce("packages/core/src/compute/linalg.js",function(o,me){"use strict";Object.defineProperty(o,"cholesky",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"choleskySolve",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"choleskyInverse",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return Z}});function ae(E){const z=E.length,re=Array.from({length:z},()=>new Array(z).fill(0));for(let Y=0;Y<z;Y++)for(let se=0;se<=Y;se++){let te=E[Y][se];for(let H=0;H<se;H++)te-=re[Y][H]*re[se][H];if(Y===se){if(!(te>0))return null;re[Y][se]=Math.sqrt(te)}else re[Y][se]=te/re[se][se]}return re}function he(E,z){const re=E.length,Y=new Array(re).fill(0);for(let te=0;te<re;te++){let H=z[te];for(let T=0;T<te;T++)H-=E[te][T]*Y[T];Y[te]=H/E[te][te]}const se=new Array(re).fill(0);for(let te=re-1;te>=0;te--){let H=Y[te];for(let T=te+1;T<re;T++)H-=E[T][te]*se[T];se[te]=H/E[te][te]}return se}function W(E){const z=E.length,re=Array.from({length:z},()=>new Array(z).fill(0));for(let Y=0;Y<z;Y++){const se=new Array(z).fill(0);se[Y]=1;const te=he(E,se);for(let H=0;H<z;H++)re[H][Y]=te[H]}return re}function U(E,z,re){const Y=E.length,se=Y?E[0].length:0,te=Array.from({length:se},()=>new Array(se).fill(0)),H=new Array(se).fill(0);for(let T=0;T<Y;T++){const V=re?re[T]:1,ne=E[T];for(let R=0;R<se;R++){const j=V*ne[R];H[R]+=j*z[T];for(let i=R;i<se;i++)te[R][i]+=j*ne[i]}}for(let T=0;T<se;T++)for(let V=0;V<T;V++)te[T][V]=te[V][T];return{xtwx:te,xtwy:H}}function _(E,z){return E.map(re=>re.reduce((Y,se,te)=>Y+se*z[te],0))}function Z(E,z){let re=0;for(let Y=0;Y<E.length;Y++){let se=0;for(let te=0;te<E.length;te++)se+=z[Y][te]*E[te];re+=E[Y]*se}return re}}),Ce("packages/core/src/compute/sketch.js",function(o,me){"use strict";Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return te}});class ae{#t=0;#e=0;#n=0;static get errorBound(){return Object.freeze({kind:"exact",metric:"none",value:0,statement:"mean and variance match a full recompute to float rounding"})}get count(){return this.#t}add(T){if(!Number.isFinite(T))return;this.#t++;const V=T-this.#e;this.#e+=V/this.#t,this.#n+=V*(T-this.#e)}merge(T){if(T.#t===0)return;if(this.#t===0){this.#t=T.#t,this.#e=T.#e,this.#n=T.#n;return}const V=this.#t+T.#t,ne=T.#e-this.#e;this.#e+=ne*(T.#t/V),this.#n+=T.#n+ne*ne*(this.#t*T.#t/V),this.#t=V}mean(){return this.#t?this.#e:null}variance(){return this.#t>1?this.#n/(this.#t-1):null}varianceP(){return this.#t?this.#n/this.#t:null}stddev(){const T=this.variance();return T===null?null:Math.sqrt(T)}stddevP(){const T=this.varianceP();return T===null?null:Math.sqrt(T)}}class he{#t=[];#e=0;#n;#r;constructor(T,V=Math.random){if(!(T>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(T),this.#r=V}static get errorBound(){return Object.freeze({kind:"probabilistic",metric:"none",value:0,statement:"uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators"})}get seen(){return this.#e}get size(){return this.#t.length}add(T){if(!Number.isFinite(T))return;if(this.#e++,this.#t.length<this.#n){this.#t.push(T);return}const V=Math.floor(this.#r()*this.#e);V<this.#n&&(this.#t[V]=T)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let T=0;for(const V of this.#t)T+=V;return T/this.#t.length}quantile(T){const V=this.#t.length;if(!V)return null;const ne=this.#t.slice().sort((a,s)=>a-s);if(V===1)return ne[0];const R=(V-1)*Math.min(1,Math.max(0,T)),j=Math.floor(R),i=Math.ceil(R);return j===i?ne[j]:ne[j]+(R-j)*(ne[i]-ne[j])}}function W(H){return H^=H>>>16,H=Math.imul(H,2246822507),H^=H>>>13,H=Math.imul(H,3266489909),H^=H>>>15,H>>>0}function U(H){if(typeof H=="number"){const ne=new DataView(new ArrayBuffer(8));return ne.setFloat64(0,H===0?0:H),W(ne.getUint32(0)^ne.getUint32(4))}const T=typeof H=="string"?H:String(H);let V=2166136261;for(let ne=0;ne<T.length;ne++)V^=T.charCodeAt(ne),V=Math.imul(V,16777619);return W(V)}class _{#t;#e;#n;constructor(T=14){const V=Math.floor(T);if(V<4||V>16)throw new RangeError("HLL precision must be 4..16");this.#t=V,this.#e=1<<V,this.#n=new Uint8Array(this.#e)}static errorBoundFor(T=14){const V=1<<Math.floor(T),ne=1.04/Math.sqrt(V);return Object.freeze({kind:"probabilistic",metric:"relative",value:ne,statement:`distinct count within ~${(ne*100).toFixed(2)}% relative standard error (m=${V} buckets)`})}errorBound(){return _.errorBoundFor(this.#t)}add(T){const V=U(T),ne=V&this.#e-1,R=V>>>this.#t|1<<32-this.#t;let j=1,i=R;for(;(i&1)===0;)j++,i>>>=1;j>this.#n[ne]&&(this.#n[ne]=j)}count(){const T=this.#e,V=32-this.#t,ne=new Float64Array(V+2);for(let i=0;i<T;i++)ne[this.#n[i]]++;let R=T*z(1-ne[V+1]/T);for(let i=V;i>=1;i--)R=.5*(R+ne[i]);R+=T*E(ne[0]/T);const j=Z*T*T/R;return Math.round(j)}}const Z=.5/Math.log(2);function E(H){if(H===1)return 1/0;let T=1,V=H,ne;do H*=H,ne=V,V+=H*T,T+=T;while(V!==ne);return V}function z(H){if(H===0||H===1)return 0;let T=1,V=1-H,ne;do H=Math.sqrt(H),ne=V,T*=.5,V-=(1-H)**2*T;while(V!==ne);return V/3}class re{#t=new Map;#e;#n=0;constructor(T){if(!(T>0))throw new RangeError("Space-Saving capacity must be positive");this.#e=Math.floor(T)}errorBoundFor(T){const V=T/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:V,statement:`each count overestimates the truth by at most N/m = ${V.toFixed(2)} (N=${T}, m=${this.#e})`})}get seen(){return this.#n}add(T){this.#n++;const V=this.#t.get(T);if(V){V.count++;return}if(this.#t.size<this.#e){this.#t.set(T,{count:1,error:0});return}let ne,R=1/0;for(const[j,i]of this.#t)i.count<R&&(R=i.count,ne=j);this.#t.delete(ne),this.#t.set(T,{count:R+1,error:R})}top(T=this.#e){return[...this.#t.entries()].map(([ne,R])=>({item:ne,count:R.count,error:R.error})).sort((ne,R)=>R.count-ne.count).slice(0,Math.max(0,Math.floor(T)))}}class Y{#t;#e=[[]];#n=0;#r;#i;constructor(T=200,V=Math.random){this.#t=Math.max(8,Math.floor(T)),this.#r=V,this.#i=2/3}static errorBoundFor(T=200){const V=1/Math.max(8,Math.floor(T));return Object.freeze({kind:"probabilistic",metric:"rank",value:V,statement:`queried quantile\'s true rank within ~${(V*100).toFixed(2)}% of N of the requested rank (k=${T})`})}errorBound(){return Y.errorBoundFor(this.#t)}get count(){return this.#n}#s(T){const ne=this.#e.length-1-T,R=Math.ceil(this.#t*this.#i**ne);return Math.max(2,R)}add(T){Number.isFinite(T)&&(this.#n++,this.#e[0].push(T),this.#e[0].length>=this.#s(0)&&this.#h(0))}#h(T){const V=this.#e[T];V.sort((j,i)=>j-i),T+1>=this.#e.length&&this.#e.push([]);const ne=this.#e[T+1],R=this.#r()<.5?0:1;for(let j=R;j<V.length;j+=2)ne.push(V[j]);this.#e[T]=[];for(let j=0;j<this.#e.length;j++)if(this.#e[j].length>=this.#s(j)){this.#h(j);return}}#u(){const T=[];for(let V=0;V<this.#e.length;V++){const ne=1<<V;for(const R of this.#e[V])T.push({v:R,w:ne})}return T}quantile(T){const V=this.#u();if(!V.length)return null;V.sort((i,a)=>i.v-a.v);let ne=0;for(const i of V)ne+=i.w;const R=Math.min(1,Math.max(0,T))*ne;let j=0;for(const i of V)if(j+=i.w,j>=R)return i.v;return V[V.length-1].v}rank(T){let V=0;for(let ne=0;ne<this.#e.length;ne++){const R=1<<ne;for(const j of this.#e[ne])j<=T&&(V+=R)}return V}}const se=Object.freeze({distinct:_.errorBoundFor(14),median:Y.errorBoundFor(200),p25:Y.errorBoundFor(200),p75:Y.errorBoundFor(200),p90:Y.errorBoundFor(200),p95:Y.errorBoundFor(200),p99:Y.errorBoundFor(200),iqr:Y.errorBoundFor(200),topK:Object.freeze({kind:"deterministic",metric:"absolute",value:0,statement:"each count overestimates the truth by at most N/m; top-K exact when the K-th item exceeds N/m"})}),te={Welford:ae,Reservoir:he,HyperLogLog:_,SpaceSaving:re,KLL:Y,hash32:U,SKETCH_BOUNDS:se}}),Ce("packages/core/src/compute/statistics.js",function(o,me){"use strict";Object.defineProperty(o,"KENDALL_LIMIT",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"numbers",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"frequencies",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"herfindahl",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"entropy",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"evenness",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"topShare",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"gini",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"moments",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"quantileSorted",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"quantile",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"STAT_FNS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"weightedAverage",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"extremeRow",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"correlation",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"fitLinearModel",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(o,"autocorrelations",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"spearman",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(o,"kendall",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(o,"seriesStats",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(o,"D2_N2",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(o,"D4_N2",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(o,"movingRanges",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(o,"withinSigma",{enumerable:!0,get:function(){return We}}),Object.defineProperty(o,"capability",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(o,"controlLimits",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(o,"westernElectricViolations",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(o,"nelsonViolations",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(o,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(o,"controlViolations",{enumerable:!0,get:function(){return At}}),Object.defineProperty(o,"countOutside",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(o,"histogram",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(o,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(o,"meanInterval",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(o,"proportionInterval",{enumerable:!0,get:function(){return St}}),Object.defineProperty(o,"slopeInterval",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(o,"capabilityInterval",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(o,"standardizedMeanDifference",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(o,"normalTotalVariation",{enumerable:!0,get:function(){return dt}}),Object.defineProperty(o,"frequencyMap",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(o,"categoricalDistance",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(o,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return st}}),Object.defineProperty(o,"compareColumn",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(o,"isNumericColumn",{enumerable:!0,get:function(){return gt}}),Object.defineProperty(o,"populationRead",{enumerable:!0,get:function(){return Rt}});const ae=me("packages/core/src/compute/handle.js"),he=ae.presenceReader,W=ae.valueReader,U=me("packages/core/src/compute/special.js"),_=U.studentTQuantile,Z=U.studentT,E=U.normalQuantile,z=U.normalCdf,re=U.chiSquareUpperTail,Y=me("packages/core/src/compute/linalg.js"),se=Y.cholesky,te=Y.choleskySolve,H=Y.choleskyInverse,T=Y.normalEquations,V=Y.quadForm,R=me("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,j=5e3,i=Object.freeze({variance:"rescan",varianceP:"rescan",stddev:"rescan",stddevP:"rescan",sumSquares:"rescan",weightedAvg:"rescan",median:"rescan",p25:"rescan",p75:"rescan",p90:"rescan",p95:"rescan",p99:"rescan",iqr:"rescan",mode:"rescan",distinct:"rescan",range:"rescan",skewness:"rescan",kurtosis:"rescan",geomean:"rescan",harmean:"rescan",mad:"rescan",argmin:"rescan",argmax:"rescan",hhi:"rescan",entropy:"rescan",evenness:"rescan",top3Share:"rescan",top10Share:"rescan",gini:"rescan",trimmedMean:"rescan",winsorizedMean:"rescan",robustOutliers:"rescan",jarqueBera:"rescan",passRate:"rescan",failureCount:"rescan"}),a=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:R.distinct}),median:Object.freeze({sketch:"KLL",bound:R.median}),p25:Object.freeze({sketch:"KLL",bound:R.p25}),p75:Object.freeze({sketch:"KLL",bound:R.p75}),p90:Object.freeze({sketch:"KLL",bound:R.p90}),p95:Object.freeze({sketch:"KLL",bound:R.p95}),p99:Object.freeze({sketch:"KLL",bound:R.p99}),iqr:Object.freeze({sketch:"KLL",bound:R.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:R.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:R.topK})});function s(b){const k=b==="sum"||b==="avg"||b==="countValues"||b==="min"||b==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,b)?i[b]:null,y=Object.prototype.hasOwnProperty.call(a,b)?a[b]:null;return{stat:b,exact:k,approximate:y}}function h(b,k){const y=k.length,w=new Float64Array(y);let O=0;if(b&&(b.kind==="float64"||b.kind==="int32")){const F=b.values,C=he(b);for(let ie=0;ie<y;ie++){const oe=k[ie];if(C&&C(oe)!==1)continue;const ke=F[oe];Number.isNaN(ke)||(w[O++]=ke)}return w.subarray(0,O)}const $=W(b);for(let F=0;F<y;F++){const C=$(k[F]);if(C==null||C==="")continue;const ie=typeof C=="number"?C:Number(C);Number.isFinite(ie)&&(w[O++]=ie)}return w.subarray(0,O)}function u(b,k){const y=new Map,w=W(b);let O=0;for(let $=0;$<k.length;$++){const F=w(k[$]);if(F==null||F===""||typeof F=="number"&&Number.isNaN(F))continue;const C=typeof F=="object"?String(F):F;y.set(C,(y.get(C)||0)+1),O++}const M=[...y.values()].sort(($,F)=>F-$);return{counts:M,total:O,distinct:M.length}}function t(b){return b.total>0?b.counts.map(k=>k/b.total):[]}function l(b,k){const y=u(b,k);if(!y.total)return null;let w=0;for(const O of t(y))w+=O*O;return w}function m(b,k){const y=u(b,k);if(!y.total)return null;let w=0;for(const O of t(y))O>0&&(w-=O*Math.log2(O));return w}function e(b,k){const y=u(b,k);if(!y.total||y.distinct<2)return y.total?1:null;let w=0;for(const O of t(y))O>0&&(w-=O*Math.log2(O));return w/Math.log2(y.distinct)}function d(b,k,y=3){const w=u(b,k);if(!w.total)return null;const O=Math.max(1,Math.floor(y));let M=0;for(let $=0;$<Math.min(O,w.counts.length);$++)M+=w.counts[$];return M/w.total}function f(b,k){const y=h(b,k),w=y.length;if(!w)return null;const O=y.slice().sort();if(O[0]<0)return null;let M=0,$=0;for(let F=0;F<w;F++)M+=O[F],$+=(F+1)*O[F];return M===0?0:2*$/(w*M)-(w+1)/w}function r(b){let k=0,y=0,w=0;for(let O=0;O<b.length;O++){const M=b[O];k++;const $=M-y;y+=$/k,w+=$*(M-y)}return{n:k,mean:y,m2:w}}function n(b,k){const y=b.length;if(!y)return NaN;if(y===1)return b[0];const w=(y-1)*Math.min(1,Math.max(0,k)),O=Math.floor(w),M=Math.ceil(w);return O===M?b[O]:b[O]+(w-O)*(b[M]-b[O])}function c(b,k){if(!b.length)return NaN;const y=b.slice().sort();return n(y,k)}function g(b,k){const y=W(b);let w=0,O=0,M=0;for(let $=0;$<k.length;$++){const F=y(k[$]);if(F==null||F==="")continue;const C=String(F).toUpperCase();C==="PASS"?w++:C==="FAIL"?O++:C==="WARN"&&M++}return{pass:w+M,fail:O,warn:M,judged:w+M+O}}const A=Object.freeze({hhi:(b,k)=>l(b,k),entropy:(b,k)=>m(b,k),evenness:(b,k)=>e(b,k),top3Share:(b,k)=>d(b,k,3),top10Share:(b,k)=>d(b,k,10),gini:(b,k)=>f(b,k),trimmedMean:(b,k)=>G(h(b,k),.1),winsorizedMean:(b,k)=>S(h(b,k),.1),robustOutliers:(b,k)=>N(h(b,k),3.5),jarqueBera:(b,k)=>I(h(b,k)),variance:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>1?w/(y-1):null},varianceP:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>0?w/y:null},stddev:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>1?Math.sqrt(w/(y-1)):null},stddevP:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>0?Math.sqrt(w/y):null},median:(b,k)=>{const y=h(b,k);return y.length?c(y,.5):null},p25:(b,k)=>{const y=h(b,k);return y.length?c(y,.25):null},p75:(b,k)=>{const y=h(b,k);return y.length?c(y,.75):null},p90:(b,k)=>{const y=h(b,k);return y.length?c(y,.9):null},p95:(b,k)=>{const y=h(b,k);return y.length?c(y,.95):null},p99:(b,k)=>{const y=h(b,k);return y.length?c(y,.99):null},iqr:(b,k)=>{const y=h(b,k);if(!y.length)return null;const w=y.slice().sort();return n(w,.75)-n(w,.25)},mad:(b,k)=>{const y=h(b,k);if(!y.length)return null;const w=c(y,.5),O=new Float64Array(y.length);for(let M=0;M<y.length;M++)O[M]=Math.abs(y[M]-w);return c(O,.5)},range:(b,k)=>{const y=h(b,k);if(!y.length)return null;let w=1/0,O=-1/0;for(let M=0;M<y.length;M++)y[M]<w&&(w=y[M]),y[M]>O&&(O=y[M]);return O-w},distinct:(b,k)=>{const y=W(b),w=new Set;for(let O=0;O<k.length;O++){const M=y(k[O]);M==null||M===""||w.add(M instanceof Date?M.getTime():M)}return w.size},mode:(b,k)=>{const y=W(b),w=new Map;for(let $=0;$<k.length;$++){const F=y(k[$]);if(F==null||F==="")continue;const C=F instanceof Date?F.getTime():F;w.set(C,(w.get(C)||0)+1)}let O=null,M=1;for(const[$,F]of w)F>M&&(M=F,O=$);return O},skewness:(b,k)=>{const y=h(b,k),{n:w,mean:O,m2:M}=r(y);if(w<3||M<=0)return null;const $=Math.sqrt(M/(w-1));let F=0;for(let C=0;C<y.length;C++)F+=((y[C]-O)/$)**3;return w/((w-1)*(w-2))*F},kurtosis:(b,k)=>{const y=h(b,k),{n:w,mean:O,m2:M}=r(y);if(w<4||M<=0)return null;const $=Math.sqrt(M/(w-1));let F=0;for(let oe=0;oe<y.length;oe++)F+=((y[oe]-O)/$)**4;const C=w*(w+1)/((w-1)*(w-2)*(w-3)),ie=3*(w-1)**2/((w-2)*(w-3));return C*F-ie},geomean:(b,k)=>{const y=h(b,k);if(!y.length)return null;let w=0;for(let O=0;O<y.length;O++){if(y[O]<=0)return null;w+=Math.log(y[O])}return Math.exp(w/y.length)},harmean:(b,k)=>{const y=h(b,k);if(!y.length)return null;let w=0;for(let O=0;O<y.length;O++){if(y[O]===0)return null;w+=1/y[O]}return y.length/w},sumSquares:(b,k)=>{const y=h(b,k);let w=0;for(let O=0;O<y.length;O++)w+=y[O]*y[O];return w},passRate:(b,k)=>{const{pass:y,judged:w}=g(b,k);return w?y/w:null},failureCount:(b,k)=>g(b,k).fail}),P=Object.freeze({hhi:"Concentration (HHI)",entropy:"Entropy",evenness:"Evenness",top3Share:"Top 3 share",top10Share:"Top 10 share",gini:"Gini coefficient",trimmedMean:"Trimmed mean",winsorizedMean:"Winsorized mean",robustOutliers:"Outliers (robust)",jarqueBera:"Jarque–Bera",median:"Median",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function q(b,k,y){const w=W(b),O=W(k);let M=0,$=0;for(let F=0;F<y.length;F++){const C=y[F],ie=Number(w(C)),oe=Number(O(C));!Number.isFinite(ie)||!Number.isFinite(oe)||(M+=ie*oe,$+=oe)}return $===0?null:M/$}function L(b,k,y){const w=W(b);let O=null,M=y?-1/0:1/0;for(let $=0;$<k.length;$++){const F=k[$],C=Number(w(F));Number.isFinite(C)&&(y?C>M:C<M)&&(M=C,O=F)}return O}function v(b,k,y){const w=W(b),O=W(k);let M=0,$=0,F=0,C=0,ie=0,oe=0;for(let pe=0;pe<y.length;pe++){const ve=y[pe],Le=Number(w(ve)),we=Number(O(ve));!Number.isFinite(Le)||!Number.isFinite(we)||(M++,$+=Le,F+=we,C+=Le*Le,ie+=we*we,oe+=Le*we)}if(M<2)return null;const ke=M*oe-$*F,je=Math.sqrt((M*C-$*$)*(M*ie-F*F));if(je===0)return null;const Pe=ke/je;return Math.max(-1,Math.min(1,Pe))}function G(b,k=.1){const y=b.length;if(!y)return null;const w=Array.from(b).sort((F,C)=>F-C),O=Math.floor(y*Math.min(.49,Math.max(0,k))),M=w.slice(O,y-O);if(!M.length)return n(w,.5);let $=0;for(const F of M)$+=F;return $/M.length}function S(b,k=.1){const y=b.length;if(!y)return null;const w=Array.from(b).sort((C,ie)=>C-ie),O=Math.floor(y*Math.min(.49,Math.max(0,k))),M=w[O],$=w[y-1-O];let F=0;for(const C of w)F+=Math.min($,Math.max(M,C));return F/y}function N(b,k=3.5){if(!b.length)return null;const w=Array.from(b).sort((C,ie)=>C-ie),O=n(w,.5),M=w.map(C=>Math.abs(C-O)).sort((C,ie)=>C-ie),$=n(M,.5);if($===0)return null;let F=0;for(const C of w)Math.abs(.6745*(C-O)/$)>k&&F++;return F}function I(b){const k=b.length;if(k<8)return null;let y=0;for(const C of b)y+=C;y/=k;let w=0,O=0,M=0;for(const C of b){const ie=C-y;w+=ie*ie,O+=ie*ie*ie,M+=ie*ie*ie*ie}if(w/=k,O/=k,M/=k,w===0)return null;const $=O/w**1.5,F=M/(w*w)-3;return k/6*($*$+F*F/4)}function K(b,k,y){const w=[];let O=0;for(let C=0;C<b.length;C++){const ie=Number(b[C]),oe=Number(k[C]);!Number.isFinite(ie)||!Number.isFinite(oe)||oe<=0||(w.push([ie,oe]),O+=oe)}if(!w.length||O<=0)return null;if(w.sort((C,ie)=>C[0]-ie[0]),w.length===1)return w[0][0];const M=[];let $=0;for(const[,C]of w)M.push(($+C/2)/O),$+=C;const F=Math.max(0,Math.min(1,y));if(F<=M[0])return w[0][0];if(F>=M[M.length-1])return w[w.length-1][0];for(let C=1;C<M.length;C++){if(F>M[C])continue;const ie=M[C]-M[C-1],oe=ie>0?(F-M[C-1])/ie:0;return w[C-1][0]+(w[C][0]-w[C-1][0])*oe}return w[w.length-1][0]}function B(b,k,y){const w=W(b),O=W(k),M=new Float64Array(y.length),$=new Float64Array(y.length);let F=0;for(let C=0;C<y.length;C++){const ie=y[C],oe=Number(w(ie)),ke=Number(O(ie));!Number.isFinite(oe)||!Number.isFinite(ke)||(M[F]=oe,$[F]=ke,F++)}return{xs:M.subarray(0,F),ys:$.subarray(0,F),n:F}}function ee(b,k,y,w=!1){const{xs:O,ys:M,n:$}=B(b,k,y);if($<2)return null;let F=0,C=0;for(let oe=0;oe<$;oe++)F+=O[oe],C+=M[oe];F/=$,C/=$;let ie=0;for(let oe=0;oe<$;oe++)ie+=(O[oe]-F)*(M[oe]-C);return ie/(w?$:$-1)}function J(b,k,y){const{xs:w,ys:O,n:M}=B(b,k,y);if(M<2)return null;let $=0,F=0;for(let Le=0;Le<M;Le++)$+=w[Le],F+=O[Le];$/=M,F/=M;let C=0,ie=0,oe=0;for(let Le=0;Le<M;Le++){const we=w[Le]-$,De=O[Le]-F;C+=we*we,ie+=we*De,oe+=De*De}if(C===0)return null;const ke=ie/C,je=F-ke*$,Pe=oe===0?1:Math.max(0,Math.min(1,ie*ie/(C*oe))),pe=Math.max(0,oe-ke*ie),ve=M>2?Math.sqrt(pe/(M-2)/C):0;return{slope:ke,intercept:je,r2:Pe,stdError:ve,n:M}}const ue=new Set(["ols","wls","robust"]),de=new Set(["quantile"]),Oe=new Set(["ridge","lasso","elasticnet","mixed","gls"]),Ae=1.345;function Se(b,k,y){const{xtwx:w,xtwy:O}=T(b,k,y),M=se(w);if(!M)return null;const $=te(M,O),F=H(M),C=D(b,$),ie=k.map((oe,ke)=>oe-C[ke]);return{beta:$,cov:F,fitted:C,residuals:ie}}function D(b,k){return b.map(y=>y.reduce((w,O,M)=>w+O*k[M],0))}function x(b,k){const y=b.length,w=b.map(ie=>ie[k]),O=b.map(ie=>[1,...ie.filter((oe,ke)=>ke!==k)]),M=Se(O,w,null);if(!M)return 1;const $=w.reduce((ie,oe)=>ie+oe,0)/y;let F=0,C=0;for(let ie=0;ie<y;ie++)F+=M.residuals[ie]**2,C+=(w[ie]-$)**2;return C===0?1:Math.max(0,Math.min(1,1-F/C))}function fe(b){const k=[...b].sort((O,M)=>O-M),y=p(k),w=b.map(O=>Math.abs(O-y)).sort((O,M)=>O-M);return p(w)/.6745}function p(b){const k=b.length;if(!k)return 0;const y=Math.floor(k/2);return k%2?b[y]:(b[y-1]+b[y])/2}function Q(b,k,y={}){const w=y.method||"ols";if(Oe.has(w))throw new Error(`[lattice] regression method "${w}" is out of scope; use ols, wls or robust.`);if(de.has(w))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!ue.has(w))throw new Error(`[lattice] unknown regression method "${w}"; use ols, wls or robust.`);const O=Array.isArray(k)?k.length:0,M=O&&Array.isArray(b[0])?b[0].length:0,$=M+1;if(!(O>$))return null;for(let Te=0;Te<O;Te++){if(!Number.isFinite(k[Te])||!Array.isArray(b[Te])||b[Te].length!==M)return null;for(let Fe=0;Fe<M;Fe++)if(!Number.isFinite(b[Te][Fe]))return null}let F=null;if(w==="wls"){if(F=y.weights,!Array.isArray(F)||F.length!==O)return null;for(let Te=0;Te<O;Te++)if(!(F[Te]>0)||!Number.isFinite(F[Te]))return null}const C=b.map(Te=>[1,...Te]);let ie,oe=null;if(w==="robust"){if(ie=Se(C,k,null),!ie)return null;for(let Te=0;Te<50;Te++){const Fe=fe(ie.residuals);if(!(Fe>0))break;const Ue=ie.residuals.map(Ge=>{const xe=Math.abs(Ge/Fe);return xe<=Ae?1:Ae/xe}),qe=Se(C,k,Ue);if(!qe)return null;const Je=qe.beta.reduce((Ge,xe,it)=>Math.max(Ge,Math.abs(xe-ie.beta[it])),0);if(ie=qe,oe=Ue,Je<1e-10)break}}else if(ie=Se(C,k,F),!ie)return null;const ke=w==="robust"?oe:F,{beta:je,cov:Pe,fitted:pe,residuals:ve}=ie;let Le=0,we=0,De=0;for(let Te=0;Te<O;Te++){const Fe=ke?ke[Te]:1;Le+=Fe*ve[Te]**2,we+=Fe,De+=Fe*k[Te]}const $e=De/we;let Ke=0;for(let Te=0;Te<O;Te++){const Fe=ke?ke[Te]:1;Ke+=Fe*(k[Te]-$e)**2}const He=O-$,Qe=Le/He,Ve=Ke===0?1:Math.max(0,Math.min(1,1-Le/Ke)),ut=1-(1-Ve)*(O-1)/He,nt=Array.isArray(y.names)&&y.names.length===M?y.names:b[0].map((Te,Fe)=>`x${Fe+1}`),Ze=tt(y.confidence),rt=He>0?_(1-(1-Ze)/2,He):1/0,Lt=je.map((Te,Fe)=>{const Ue=Math.sqrt(Math.max(0,Qe*Pe[Fe][Fe])),qe=Ue>0?Te/Ue:Te===0?0:1/0,Je=Number.isFinite(qe)?2*(1-Z(Math.abs(qe),He)):0,Ge=Number.isFinite(rt)?rt*Ue:null;return{name:Fe===0?"(intercept)":nt[Fe-1],estimate:Te,stdError:Ue,t:qe,p:Math.max(0,Math.min(1,Je)),lower:Ge===null?null:Te-Ge,upper:Ge===null?null:Te+Ge}}),bt=new Array(O),yt=new Array(O);for(let Te=0;Te<O;Te++){const Fe=ke?ke[Te]:1,Ue=Math.max(0,Math.min(1,Fe*V(C[Te],Pe)));bt[Te]=Ue;const qe=(1-Ue)**2;yt[Te]=qe>0&&Qe>0?ve[Te]**2/($*Qe)*(Ue/qe):null}const Ft=b[0].map((Te,Fe)=>{if(M<2)return 1;const Ue=x(b,Fe);return Ue>=1?1/0:1/(1-Ue)});let pt=null;{const Te=ve.map(Ue=>Ue*Ue),Fe=Se(C,Te,null);if(Fe){const Ue=Te.reduce((et,Ct)=>et+Ct,0)/O;let qe=0,Je=0;for(let et=0;et<O;et++)qe+=Fe.residuals[et]**2,Je+=(Te[et]-Ue)**2;const Ge=Je===0?0:Math.max(0,Math.min(1,1-qe/Je)),xe=O*Ge,it=re(xe,M);pt={statistic:xe,df:M,p:it,heteroscedastic:it<.05}}}let wt=null;if(M===1){const Te=b.map((Fe,Ue)=>Ue).sort((Fe,Ue)=>b[Fe][0]-b[Ue][0]);wt={confidence:Ze,points:Te.map(Fe=>{const Ue=C[Fe],qe=Math.sqrt(Math.max(0,Qe*V(Ue,Pe)));return{x:b[Fe][0],yhat:pe[Fe],lower:pe[Fe]-rt*qe,upper:pe[Fe]+rt*qe}})}}return{method:w,coefficients:Lt,r2:Ve,adjR2:ut,n:O,df:He,sigma2:Qe,fitted:pe,residuals:ve,leverage:bt,cooksD:yt,vif:Ft,heteroscedasticity:pt,band:wt,weights:ke?[...ke]:null}}function X(b){const k=b.length,y=Array.from({length:k},(M,$)=>$).sort((M,$)=>b[M]-b[$]),w=new Float64Array(k);let O=0;for(;O<k;){let M=O;for(;M+1<k&&b[y[M+1]]===b[y[O]];)M++;const $=(O+M)/2+1;for(let F=O;F<=M;F++)w[y[F]]=$;O=M+1}return w}const ce=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function le(b){const k=[.01,.05,.1],y=[ce["1%"],ce["5%"],ce["10%"]];if(b<=y[0]){const M=(Math.log(k[1])-Math.log(k[0]))/(y[1]-y[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(k[0])+M*(b-y[0]))))}if(b>=y[2]){const M=(Math.log(k[2])-Math.log(k[1]))/(y[2]-y[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(k[2])+M*(b-y[2]))))}const w=b<y[1]?0:1,O=(b-y[w])/(y[w+1]-y[w]);return Math.exp(Math.log(k[w])+O*(Math.log(k[w+1])-Math.log(k[w])))}function ge(b,k,y,w){const O=y-w,M=w+3,$=new Array(O),F=new Array(O);let C=!0,ie=w;for(let pe=0;pe<O;pe++){const ve=w+pe,Le=new Float64Array(M);Le[0]=1,Le[1]=pe+1,Le[2]=b[ve];for(let we=1;we<=w;we++)Le[2+we]=k[ve-we];for(let we=1;we<M;we++)Number.isFinite(Le[we])||(ie=Math.min(ie,we-3));$[pe]=Le,F[pe]=k[ve],Number.isFinite(F[pe])||(C=!1)}if(!C)return 0;const{xtwx:oe,xtwy:ke}=T($,F,null);let je=0,Pe=1/0;for(let pe=0;pe<=ie;pe++){const ve=pe+3;if(!(O>ve))continue;const Le=new Array(ve);for(let Ve=0;Ve<ve;Ve++)Le[Ve]=oe[Ve].slice(0,ve);const we=se(Le);if(!we)continue;const De=te(we,ke.slice(0,ve));let $e=0;for(let Ve=0;Ve<O;Ve++){const ut=$[Ve];let nt=0;for(let Ze=0;Ze<ve;Ze++)nt+=ut[Ze]*De[Ze];$e+=(F[Ve]-nt)**2}const He=$e/(O-ve)*(O-ve);if(!(He>0))continue;const Qe=O*Math.log(He/O)+2*ve;Qe<Pe&&(Pe=Qe,je=pe)}return je}function Me(b,k={}){const y=[];for(let Pe=0;Pe<b.length;Pe++){const pe=Number(b[Pe]);Number.isFinite(pe)&&y.push(pe)}const w=y.length,O=w-1;if(w<8||O<6)return null;const M=new Array(O);for(let Pe=0;Pe<O;Pe++)M[Pe]=y[Pe+1]-y[Pe];let $=Number.isFinite(k.maxlag)?Math.floor(k.maxlag):Math.ceil(12*(w/100)**.25);$=Math.max(0,Math.min($,Math.floor((O-5)/2)));const F=(Pe,pe)=>{const ve=[],Le=[];for(let we=pe;we<O;we++){const De=[we-pe+1,y[we]];for(let $e=1;$e<=Pe;$e++)De.push(M[we-$e]);ve.push(De),Le.push(M[we])}return Q(ve,Le,{method:"ols"})},C=ge(y,M,O,$),ie=F(C,C);if(!ie||!ie.coefficients[2])return null;const oe=ie.coefficients[2].t,ke=le(oe),je=oe<ce["5%"];return{statistic:oe,usedLag:C,nobs:O-C,criticalValues:{...ce},pValue:ke,pApproximate:!0,stationary:je,verdict:je?"stationary":"non-stationary",regression:"ct"}}function be(b,k={}){const y=[];for(let je=0;je<b.length;je++){const Pe=Number(b[je]);Number.isFinite(Pe)&&y.push(Pe)}const w=y.length;if(w<3)return null;let O=Number.isFinite(k.maxlag)?Math.floor(k.maxlag):Math.min(10,w-1);O=Math.max(1,Math.min(O,w-1));let M=0;for(const je of y)M+=je;M/=w;const $=y.map(je=>je-M);let F=0;for(const je of $)F+=je*je;F/=w;const C=new Array(O+1).fill(0);C[0]=1;for(let je=1;je<=O;je++){let Pe=0;for(let pe=je;pe<w;pe++)Pe+=$[pe]*$[pe-je];C[je]=F>0?Pe/w/F:0}const ie=new Array(O+1).fill(0);ie[0]=1;let oe=[];for(let je=1;je<=O;je++){let Pe=C[je];for(let we=1;we<je;we++)Pe-=oe[we-1]*C[je-we];let pe=1;for(let we=1;we<je;we++)pe-=oe[we-1]*C[we];const ve=pe!==0?Pe/pe:0,Le=new Array(je);for(let we=1;we<je;we++)Le[we-1]=oe[we-1]-ve*oe[je-1-we];Le[je-1]=ve,ie[je]=ve,oe=Le}const ke=1.96/Math.sqrt(w);return{acf:C,pacf:ie,bounds:{upper:ke,lower:-ke},n:w,nlags:O,approximate:!0}}function ye(b,k,y){const{xs:w,ys:O,n:M}=B(b,k,y);if(M<2)return null;const $=X(w),F=X(O);let C=0,ie=0;for(let Pe=0;Pe<M;Pe++)C+=$[Pe],ie+=F[Pe];C/=M,ie/=M;let oe=0,ke=0,je=0;for(let Pe=0;Pe<M;Pe++){const pe=$[Pe]-C,ve=F[Pe]-ie;oe+=pe*ve,ke+=pe*pe,je+=ve*ve}return ke===0||je===0?null:Math.max(-1,Math.min(1,oe/Math.sqrt(ke*je)))}function Re(b,k,y){const{xs:w,ys:O,n:M}=B(b,k,y);if(M<2||M>j)return null;let $=0,F=0,C=0,ie=0;for(let je=0;je<M;je++)for(let Pe=je+1;Pe<M;Pe++){const pe=Math.sign(w[je]-w[Pe]),ve=Math.sign(O[je]-O[Pe]),Le=pe*ve;Le>0?$++:Le<0?F++:pe===0&&ve===0||(pe===0?C++:ie++)}const oe=$+F+ie,ke=$+F+C;return oe===0||ke===0?null:($-F)/Math.sqrt(oe*ke)}function Ne(b,k={}){const y=b.length;if(y<2)return null;const w=b[0],O=b[y-1],M=[];for(let we=1;we<y;we++){const De=b[we-1];De!==0&&M.push((b[we]-De)/Math.abs(De))}let $=null;if(M.length>1){let we=0;for(const $e of M)we+=$e;we/=M.length;let De=0;for(const $e of M)De+=($e-we)**2;$=Math.sqrt(De/(M.length-1))}const F=Number(k.periodsPerYear)>0?Number(k.periodsPerYear):null;let C=b[0],ie=0,oe=0,ke=0,je=0;for(let we=1;we<y;we++){if(b[we]>C){C=b[we],ie=we;continue}if(C<=0)continue;const De=(C-b[we])/C;De>oe&&(oe=De,ke=ie,je=we)}let Pe=null;if(y>2){let we=0;for(let Ke=0;Ke<y;Ke++)we+=b[Ke];we/=y;let De=0,$e=0;for(let Ke=0;Ke<y;Ke++){const He=b[Ke]-we;$e+=He*He,Ke>0&&(De+=He*(b[Ke-1]-we))}Pe=$e>0?De/$e:null}let pe=0,ve=0;for(const we of M)we>0?pe++:we<0&&ve++;let Le=null;if(w>0&&O>0){const we=(O/w)**(1/(y-1))-1;Le=F?(1+we)**F-1:we}return{n:y,first:w,last:O,change:O-w,changePercent:w===0?null:(O-w)/Math.abs(w)*100,volatility:$,annualisedVolatility:$!==null&&F?$*Math.sqrt(F):null,growth:Le,maxDrawdown:oe,maxDrawdownFrom:ke,maxDrawdownTo:je,autocorrelation:Pe,upDays:pe,downDays:ve}}const Ee=1.128,Be=3.267;function ze(b){const k=b.length;if(k<2)return null;const y=[];for(let O=1;O<k;O++)y.push(Math.abs(b[O]-b[O-1]));const w=y.reduce((O,M)=>O+M,0)/y.length;return{ranges:y,centre:w,upper:Be*w,lower:0}}function We(b){const k=b.length;if(k<2)return null;let y=0;for(let O=1;O<k;O++)y+=Math.abs(b[O]-b[O-1]);const w=y/(k-1);return{sigma:w/Ee,meanRange:w}}function Xe(b,k){const y=b.length;if(y<2||!k)return null;const w=Number.isFinite(Number(k.lower))?Number(k.lower):null,O=Number.isFinite(Number(k.upper))?Number(k.upper):null;if(w===null&&O===null)return null;let M=0;for(let pe=0;pe<y;pe++)M+=b[pe];M/=y;let $=0;for(let pe=0;pe<y;pe++)$+=(b[pe]-M)**2;const F=Math.sqrt($/(y-1)),C=We(b),ie=C?C.sigma:null,oe=pe=>{if(!pe||pe<=0)return{index:null,k:null};const Le=w!==null&&O!==null?(O-w)/(6*pe):null,we=O!==null?(O-M)/(3*pe):1/0,De=w!==null?(M-w)/(3*pe):1/0;return{index:Le,k:Math.min(we,De)}},ke=oe(ie),je=oe(F);let Pe=0;for(let pe=0;pe<y;pe++){if(w!==null&&b[pe]<w){Pe++;continue}O!==null&&b[pe]>O&&Pe++}return{n:y,mean:M,lower:w,upper:O,target:Number.isFinite(Number(k.target))?Number(k.target):null,sigmaWithin:ie,sigmaOverall:F,cp:ke.index,cpk:ke.k,pp:je.index,ppk:je.k,outOfSpec:Pe,defectRate:y?Pe/y:null}}function Ye(b){const k=b.length;if(k<2)return null;const y=We(b);if(!y||!(y.sigma>0))return null;let w=0;for(let O=0;O<k;O++)w+=b[O];return w/=k,{centre:w,sigma:y.sigma,upper:w+3*y.sigma,lower:w-3*y.sigma}}function Ie(b,k){if(!k||!(k.sigma>0))return[];const y=b.length,{centre:w,sigma:O}=k,M=F=>(b[F]-w)/O,$=[];for(let F=0;F<y;F++){if(Math.abs(M(F))>3&&$.push({index:F,rule:1,description:"beyond three sigma"}),F>=2)for(const C of[1,-1]){let ie=0;for(let oe=F-2;oe<=F;oe++)M(oe)*C>2&&ie++;if(ie>=2){$.push({index:F,rule:2,description:"two of three past two sigma"});break}}if(F>=4)for(const C of[1,-1]){let ie=0;for(let oe=F-4;oe<=F;oe++)M(oe)*C>1&&ie++;if(ie>=4){$.push({index:F,rule:3,description:"four of five past one sigma"});break}}if(F>=7)for(const C of[1,-1]){let ie=!0;for(let oe=F-7;oe<=F;oe++)if(M(oe)*C<=0){ie=!1;break}if(ie){$.push({index:F,rule:4,description:"eight in a row on one side"});break}}}return $}function ft(b,k){if(!k||!(k.sigma>0))return[];const y=b.length,{centre:w,sigma:O}=k,M=C=>(b[C]-w)/O,$=(C,ie,oe,ke)=>{for(const je of[1,-1]){let Pe=0;for(let pe=C;pe<=ie;pe++)M(pe)*je>oe&&Pe++;if(Pe>=ke)return!0}return!1},F=[];for(let C=0;C<y;C++){if(Math.abs(M(C))>3&&F.push({index:C,rule:1,description:"beyond three sigma"}),C>=8)for(const ie of[1,-1]){let oe=!0;for(let ke=C-8;ke<=C;ke++)if(M(ke)*ie<=0){oe=!1;break}if(oe){F.push({index:C,rule:2,description:"nine in a row on one side"});break}}if(C>=5)for(const ie of[1,-1]){let oe=!0;for(let ke=C-4;ke<=C;ke++)if((b[ke]-b[ke-1])*ie<=0){oe=!1;break}if(oe){F.push({index:C,rule:3,description:ie>0?"six rising":"six falling"});break}}if(C>=13){let ie=!0;for(let oe=C-12;oe<=C;oe++){const ke=b[oe]-b[oe-1],je=b[oe+1<=C?oe+1:oe]-b[oe];if(oe+1>C)break;if(ke===0||je===0||ke>0==je>0){ie=!1;break}}ie&&F.push({index:C,rule:4,description:"fourteen alternating"})}if(C>=2&&$(C-2,C,2,2)&&F.push({index:C,rule:5,description:"two of three past two sigma"}),C>=4&&$(C-4,C,1,4)&&F.push({index:C,rule:6,description:"four of five past one sigma"}),C>=14){let ie=!0;for(let oe=C-14;oe<=C;oe++)if(Math.abs(M(oe))>=1){ie=!1;break}ie&&F.push({index:C,rule:7,description:"fifteen within one sigma"})}if(C>=7){let ie=!0;for(let oe=C-7;oe<=C;oe++)if(Math.abs(M(oe))<=1){ie=!1;break}ie&&F.push({index:C,rule:8,description:"eight beyond one sigma"})}}return F}const jt=Object.freeze(["westernElectric","nelson"]);function At(b,k,y="westernElectric"){return String(y)==="nelson"?ft(b,k):Ie(b,k)}function Mt(b,k,y){let w=0;for(let O=0;O<b.length;O++)(b[O]<k||b[O]>y)&&w++;return w}function Pt(b,k,y,w=20){const O=b.length;if(!O)return[];const M=b[0],$=b[O-1];if($===M)return[{from:M,to:$,count:O}];const F=y-k,C=1.5*F;let ie=F>0?Math.max(M,k-C):M,oe=F>0?Math.min($,y+C):$;oe>ie||(ie=M,oe=$);const ke=F>0?2*F/Math.cbrt(O):(oe-ie)/(Math.ceil(Math.log2(O))+1),je=ke>0?Math.min(w,Math.max(1,Math.ceil((oe-ie)/ke))):1,Pe=(oe-ie)/je,pe=[];for(let ve=0;ve<je;ve++)pe.push({from:ie+ve*Pe,to:ie+(ve+1)*Pe,count:0});for(let ve=0;ve<O;ve++){const Le=Math.min(je-1,Math.max(0,Math.floor((b[ve]-ie)/Pe)));pe[Le].count++}return pe[0].from=M,pe[je-1].to=$,pe}const _e=.95;function tt(b){const k=Number(b);return Number.isFinite(k)&&k>0&&k<1?k:_e}function Nt(b,k=_e){const y=b.length;if(y<2)return null;let w=0;for(let oe=0;oe<y;oe++)w+=b[oe];const O=w/y;let M=0;for(let oe=0;oe<y;oe++){const ke=b[oe]-O;M+=ke*ke}const $=Math.sqrt(M/(y-1)),F=tt(k),ie=_(1-(1-F)/2,y-1)*$/Math.sqrt(y);return{mean:O,lower:O-ie,upper:O+ie,margin:ie,n:y,confidence:F}}function St(b,k,y=_e){const w=Number(b),O=Number(k);if(!(O>0)||!(w>=0)||w>O)return null;const M=tt(y),$=E(1-(1-M)/2),F=w/O,C=$*$,ie=1+C/O,oe=(F+C/(2*O))/ie,ke=$/ie*Math.sqrt(F*(1-F)/O+C/(4*O*O));return{proportion:F,lower:Math.max(0,oe-ke),upper:Math.min(1,oe+ke),n:O,confidence:M}}function vt(b,k=_e){if(!b||!(b.n>2)||!Number.isFinite(b.stdError))return null;const y=tt(k),O=_(1-(1-y)/2,b.n-2)*b.stdError;return{slope:b.slope,lower:b.slope-O,upper:b.slope+O,margin:O,confidence:y}}function Tt(b,k,y=_e){const w=Number(b),O=Number(k);if(!Number.isFinite(w)||!(O>1))return null;const M=tt(y),F=E(1-(1-M)/2)*Math.sqrt(1/(9*O)+w*w/(2*(O-1)));return{index:w,lower:w-F,upper:w+F,margin:F,n:O,confidence:M}}function ht(b,k){return!b||!(b.sd>0)||!Number.isFinite(k)||!Number.isFinite(b.mean)?null:(k-b.mean)/b.sd}function dt(b){return Number.isFinite(b)?Math.min(1,Math.max(0,2*z(Math.abs(b)/2)-1)):0}function ot(b,k){const y=new Map,w=W(b);let O=0;for(let M=0;M<k.length;M++){const $=w(k[M]);if($==null||$===""||typeof $=="number"&&Number.isNaN($))continue;const F=$ instanceof Date?$.getTime():typeof $=="object"?String($):$;y.set(F,(y.get(F)||0)+1),O++}return{map:y,total:O}}function mt(b,k,y,w){if(!(k>0)||!(w>0))return null;let O=0;const M=new Set(b.keys());for(const $ of y.keys())M.add($);for(const $ of M){const F=(b.get($)||0)/k,C=(y.get($)||0)/w;O+=Math.abs(F-C)}return O/2}const st=10;function Et(b,k,y){if(y&&y.numeric){const F=h(b,k),{n:C,mean:ie}=r(F),oe=C>0?ht({mean:y.mean,sd:y.sd},ie):null;return{measure:"standardizedMeanDifference",magnitude:oe,distance:oe===null?0:dt(oe),direction:oe===null?0:Math.sign(oe),subsetN:C,populationN:y.n||0,reliable:C>=st}}const{map:O,total:M}=ot(b,k),$=mt(O,M,y.map,y.total);return{measure:"categoricalTotalVariation",magnitude:$,distance:$===null?0:$,direction:0,subsetN:M,populationN:y.total||0,reliable:M>=st}}function gt(b,k){if(b&&(b.kind==="float64"||b.kind==="int32"))return!0;const y=W(b);let w=0,O=0;for(let M=0;M<k.length&&w<200;M++){const $=y(k[M]);if($==null||$==="")continue;if($ instanceof Date)return!1;w++;const F=typeof $=="number"?$:Number($);Number.isFinite(F)&&O++}return w===0?!1:O/w>=.9}function Rt(b,k){if(gt(b,k)){const O=h(b,k),{n:M,mean:$,m2:F}=r(O);return{numeric:!0,mean:$,sd:M>0?Math.sqrt(F/M):0,n:M}}const{map:y,total:w}=ot(b,k);return{numeric:!1,map:y,total:w}}}),Ce("packages/core/src/compute/total.js",function(o,me){"use strict";Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"aggregatesFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"aggregateAllowed",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return f}});const ae=me("packages/core/src/internal/util.js"),he=ae.isFunction,W=ae.warnOnce,U=me("packages/core/src/compute/handle.js"),_=U.presenceReader,Z=U.valueComparator,E=U.valueReader,z=me("packages/core/src/compute/statistics.js"),re=z.STAT_FNS,Y=z.STAT_LABELS;function se(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function te(r,n){const c=n.length;let g=0;if(se(r)){const P=r.values,q=_(r);if(!q){for(let L=0;L<c;L++){const v=P[n[L]];Number.isNaN(v)||(g+=v)}return g}for(let L=0;L<c;L++){const v=n[L];if(q(v)===1){const G=P[v];Number.isNaN(G)||(g+=G)}}return g}const A=E(r);for(let P=0;P<c;P++){const q=s(A(n[P]));q!==null&&(g+=q)}return g}te.kernel=!0;function H(r,n){const c=n.length;let g=0;if(se(r)){const P=r.values,q=_(r);if(!q){for(let L=0;L<c;L++)Number.isNaN(P[n[L]])||g++;return g}for(let L=0;L<c;L++){const v=n[L];q(v)===1&&!Number.isNaN(P[v])&&g++}return g}const A=E(r);for(let P=0;P<c;P++){const q=A(n[P]);q!=null&&!(typeof q=="number"&&Number.isNaN(q))&&g++}return g}H.kernel=!0;function T(r,n){return n.length}T.kernel=!0;function V(r,n){const c=H(r,n);return c===0?null:te(r,n)/c}V.kernel=!0;function ne(r,n,c,g){const A=n.length;if(se(r)){const v=r.values,G=_(r);let S=null;if(!G){for(let N=0;N<A;N++){const I=v[n[N]];Number.isNaN(I)||(S===null||(c<0?I<S:I>S))&&(S=I)}return S}for(let N=0;N<A;N++){const I=n[N];if(G(I)===0)continue;const K=v[I];Number.isNaN(K)||(S===null||(c<0?K<S:K>S))&&(S=K)}return S}const P=E(r),q=Z(g);let L=null;for(let v=0;v<A;v++){const G=P(n[v]);G==null||typeof G=="number"&&Number.isNaN(G)||(L===null||(c<0?q(G,L)<0:q(G,L)>0))&&(L=G)}return L}function R(r,n,c){return ne(r,n,-1,c&&c.locale)}R.kernel=!0;function j(r,n,c){return ne(r,n,1,c&&c.locale)}j.kernel=!0;function i(r,n){return n.length===0?null:E(r)(n[0])}i.kernel=!0;function a(r,n){return n.length===0?null:E(r)(n[n.length-1])}a.kernel=!0;function s(r){if(typeof r=="number")return Number.isNaN(r)?null:r;if(r==null||r===""||typeof r=="boolean")return null;if(r instanceof Date)return r.getTime();const n=Number(r);return Number.isNaN(n)?null:n}const h={sum:te,min:R,max:j,avg:V,count:T,first:i,last:a,countValues:H,...re},u=Object.freeze({...Y,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function t(r){return r?typeof r=="string"?u[r]||r:"Total":""}const l=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function m(r){const n=r&&r.dataType&&r.dataType.totals&&r.dataType.totals.supported;if(Array.isArray(n))return n.slice();const c=l.filter(g=>g in h);for(const g of Object.keys(h))c.includes(g)||c.push(g);return c}function e(r,n){return typeof n!="string"?!0:m(r).includes(n)}function d(r,n){const c=E(r),g=[];for(let A=0;A<n.length;A++){const P=c(n[A]);P!=null&&g.push(P)}return g}function f(r,n,c,g){const A=n||[];if(typeof c=="string"){const P=h[c];return P?P(r,A,g):(W(`total:${c}`,`unknown total function "${c}"; register it in config.totalFns`),null)}return he(c)?c.kernel===!0?c(r,A,g):c(d(r,A),g||{}):null}}),Ce("packages/core/src/compute/pivot.js",function(o,me){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return j}});const he=me("packages/core/src/internal/util.js").warnOnce,U=me("packages/core/src/compute/handle.js").valueComparator,Z=me("packages/core/src/compute/group.js").packKeys,z=me("packages/core/src/compute/total.js").total,re="|",Y="/",se=2e3;function te(s,h,u){return`${s}${re}${h}${re}${u}`}function H(s,h){let u="";for(let t=0;t<s.length;t++){const l=s[t];u+=(t===0?"":h)+(l==null?"":String(l))}return u}function T(s,h,u={}){const t=u.separator||Y,l=h.length,{keyOf:m,readers:e}=Z(s,h,0),d=new Map,f=[],r=[];for(let L=0;L<l;L++){const v=h[L],G=m(v);if(d.has(G))continue;d.set(G,f.length),r.push(G);const S=new Array(e.length);for(let N=0;N<e.length;N++)S[N]=e[N](v);f.push(S)}const n=U(u.locale),c=f.map((L,v)=>v);c.sort((L,v)=>{const G=f[L],S=f[v];for(let N=0;N<G.length;N++){const I=V(G[N],S[N],n);if(I!==0)return I}return L-v});const g=new Array(c.length),A=new Array(c.length),P=new Map;for(let L=0;L<c.length;L++){const v=c[L];g[L]=f[v],A[L]=H(f[v],t),P.set(r[v],L)}return{keys:g,paths:A,idOf:L=>{const v=P.get(m(L));return v===void 0?-1:v}}}function V(s,h,u){const t=s==null,l=h==null;return t||l?t&&l?0:t?1:-1:u(s,h)}function ne(s){const h=s.values||s.totals||[];if(h.length&&typeof h[0]=="object"&&h[0]!==null)return h.filter(m=>m&&m.handle);const u=typeof s.handle=="function"?s.handle:null;if(!u)return h.length&&he("pivot:handles","pivot was given total column ids but no handle(colId) resolver, so no cell values were reduced. Pass values: [{ colId, handle, fn }] or opts.handle."),[];const t=typeof s.totalOf=="function"?s.totalOf:null,l=[];for(const m of h){const e=u(m);e&&l.push({colId:m,handle:e,fn:t?t(m):"sum"})}return l}function R(s,h,u){if(Array.isArray(s)){const t=u||{};return{...t,pivotHandles:s,order:h||null,groups:t.groups||null}}return s||{}}function j(s,h,u){const t=R(s,h,u),l=t.separator||Y,m=ne(t),e=t.maxColumns===void 0?se:t.maxColumns,d=t.groups&&t.groups.buckets?t.groups:null,f=d?d.buckets:[t.order||new Uint32Array(0)],r=t.groupPaths||(d?d.keys.map(G=>H(G,l)):[""]),n=a(f),{keys:c,paths:g,idOf:A}=T(t.pivotHandles||[],n,t),P=g.length*Math.max(1,m.length),q=i(g,m,l);if(e&&P>e){const G=new Map;return{keys:c,paths:g,fields:q,groupPaths:r,columns:P,values:G,cells:G,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${P} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:P,maxColumns:e}}}const L=new Map,v=g.length;for(let G=0;G<f.length;G++){const S=f[G],N=r[G]===void 0?"":r[G],I=S.length;if(I===0)continue;const K=new Int32Array(I),B=new Uint32Array(v+1);for(let ue=0;ue<I;ue++){const de=A(S[ue]);K[ue]=de,de>=0&&B[de+1]++}for(let ue=0;ue<v;ue++)B[ue+1]+=B[ue];const ee=new Uint32Array(I),J=B.slice(0,v);for(let ue=0;ue<I;ue++){const de=K[ue];de>=0&&(ee[J[de]++]=S[ue])}for(let ue=0;ue<v;ue++){const de=B[ue],Oe=B[ue+1];if(Oe===de)continue;const Ae=ee.subarray(de,Oe);for(let Se=0;Se<m.length;Se++){const D=m[Se],x=z(D.handle,Ae,D.fn,t.totalContext||{locale:t.locale});L.set(te(N,g[ue],D.colId),x)}}}return{keys:c,paths:g,fields:q,groupPaths:r,columns:P,values:L,cells:L,error:null}}function i(s,h,u){if(h.length===0)return s.slice();const t=[];for(const l of s)for(const m of h)t.push(`${l}${u}${m.colId}`);return t}function a(s){if(s.length===1)return s[0]||new Uint32Array(0);let h=0;for(const l of s)h+=l?l.length:0;const u=new Uint32Array(h);let t=0;for(const l of s)!l||l.length===0||(u.set(l,t),t+=l.length);return u}}),Ce("packages/core/src/compute/pivotmatrix.js",function(o,me){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return j}});const he=me("packages/core/src/compute/handle.js").valueComparator,U=me("packages/core/src/compute/total.js").total,Z=me("packages/core/src/compute/group.js").packKeys,E=me("packages/core/src/compute/pivot.js"),z=E.joinPath,re=E.DEFAULT_PATH_SEPARATOR,Y=E.DEFAULT_MAX_COLUMNS,se="";function te(i,a,s={}){const h=s.separator||re,u=i||[],t=a instanceof Uint32Array?a:Uint32Array.from(a||[]),l=t.length;if(u.length===0)return{tuples:[[]],paths:[se],buckets:[t]};const{keyOf:m,readers:e}=Z(u,t,0),d=new Map,f=[],r=[],n=[];for(let L=0;L<l;L++){const v=t[L],G=m(v);let S=d.get(G);if(S===void 0){S=f.length,d.set(G,S),r.push(G);const N=new Array(e.length);for(let I=0;I<e.length;I++)N[I]=e[I](v);f.push(N),n.push([])}n[S].push(v)}const c=he(s.locale),g=f.map((L,v)=>v);g.sort((L,v)=>{const G=f[L],S=f[v];for(let N=0;N<G.length;N++){const I=H(G[N],S[N],c);if(I!==0)return I}return L-v});const A=new Array(g.length),P=new Array(g.length),q=new Array(g.length);for(let L=0;L<g.length;L++){const v=g[L];A[L]=f[v],P[L]=z(f[v],h),q[L]=Uint32Array.from(n[v])}return{tuples:A,paths:P,buckets:q}}function H(i,a,s){const h=i==null,u=a==null;return h||u?h&&u?0:h?1:-1:s(i,a)}function T(i,a,s){const h=[];for(let u=0;u<i.length;u++)s.has(i[u])&&h.push(i[u]);return Uint32Array.from(h)}function V(i,a,s,h){return{value:a.length?U(i,a,s,h):null,leaves:a,count:a.length}}function ne(i){const a=i&&i.opts||{},s=a.separator||re,h=a.totalContext||{locale:a.locale},u=(i.measures||[]).filter(P=>P&&P.handle),t=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),l=te(i.rowHandles||[],t,{...a,separator:s}),m=te(i.columnHandles||[],t,{...a,separator:s}),e=a.maxColumns===void 0?Y:a.maxColumns,d=m.paths.length*Math.max(1,u.length),f=new Map;if(e&&d>e)return{rowAxis:l,columnAxis:m,measures:u.map(P=>({colId:P.colId,fn:P.fn})),body:f,rowMargin:f,columnMargin:f,grand:f,columns:d,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${d} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:d,maxColumns:e}};const r=new Map,n=new Map,c=new Map,g=new Map,A=m.buckets.map(P=>new Set(P));for(let P=0;P<m.paths.length;P++){const q=m.buckets[P],L=m.paths[P];for(const v of u)c.set(j(L,v.colId),V(v.handle,q,v.fn,h))}for(let P=0;P<l.paths.length;P++){const q=l.buckets[P],L=l.paths[P];for(const v of u)n.set(j(L,v.colId),V(v.handle,q,v.fn,h));for(let v=0;v<m.paths.length;v++){const G=T(q,m.buckets[v],A[v]);if(G.length===0)continue;const S=m.paths[v];for(const N of u)r.set(R(L,S,N.colId),V(N.handle,G,N.fn,h))}}for(const P of u)g.set(P.colId,V(P.handle,t,P.fn,h));return{rowAxis:l,columnAxis:m,measures:u.map(P=>({colId:P.colId,fn:P.fn})),body:r,rowMargin:n,columnMargin:c,grand:g,columns:d,error:null}}function R(i,a,s){return`${i}\\0${a}\\0${s}`}function j(i,a){return`${i}\\0${a}`}}),Ce("packages/core/src/compute/reference.js",function(o,me){"use strict";Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ne}});const he=me("packages/core/src/internal/util.js").getPath,W=me("packages/core/src/compute/handle.js"),U=W.isMissing,_=W.valueComparator,E=me("packages/core/src/compute/filter.js").testValue,z="",re="\\0";function Y(i,a){const s=a.includes(".")?he(i,a):i?.[a];return s===void 0?null:s}function se(i,a,s={}){const h=a||[];let u=i.map((t,l)=>l);if(h.length===0)return u;for(let t=h.length-1;t>=0;t--)u=te(i,u,h[t],s);return u}function te(i,a,s,h){const u=s.locale!==void 0?s.locale:h.locale,t=_(u),l=s.descending!==void 0?!!s.descending:s.dir==="desc",m=[],e=[];for(const r of a){const n=Y(i[r],s.col);U(n)?e.push(r):m.push(r)}const d=new Map;for(let r=0;r<m.length;r++)d.set(m[r],r);const f=(r,n)=>{const c=Y(i[r],s.col),g=Y(i[n],s.col);let A;return typeof s.compare=="function"?(A=s.compare(c,g,i[r],i[n],l),l&&(A=-A)):A=l?t(g,c):t(c,g),A!==0?A:d.get(r)-d.get(n)};return m.sort(f),s.nullsFirst?e.concat(m):m.concat(e)}function H(i,a,s={}){const h=[];for(let u=0;u<i.length;u++)T(i[u],a,s,u)&&h.push(u);return h}function T(i,a,s,h){if(!a)return!0;if(Array.isArray(a.conditions)){const u=a.conditions.filter(l=>l!=null);if(u.length===0)return!0;if(a.op==="or")return u.some(l=>T(i,l,s,h));const t=u.every(l=>T(i,l,s,h));return a.op==="not"?!t:t}return a.col===void 0&&typeof s.custom=="function"?!!s.custom(a,i,h):E(Y(i,a.col),a,s.locale)}function V(i,a,s,h){const u=s||i.map((e,d)=>d),t=new Map,l=[],m=[];for(const e of u){const d=a.map((n,c)=>{const g=Y(i[e],n);return h&&h[c]?h[c](g):g}),f=d.map(n=>n==null?re:String(n)).join(z);let r=t.get(f);r===void 0&&(r=l.length,t.set(f,r),l.push(d),m.push([])),m[r].push(e)}return{keys:l,buckets:m}}function ne(i,a,s={}){const h=_(s.locale),u=i.filter(l=>!U(l)),t=u.map(R).filter(l=>l!==null);switch(a){case"count":return i.length;case"countValues":return u.length;case"sum":return t.reduce((l,m)=>l+m,0);case"avg":return u.length===0?null:t.reduce((l,m)=>l+m,0)/u.length;case"min":return u.length===0?null:u.reduce((l,m)=>h(m,l)<0?m:l);case"max":return u.length===0?null:u.reduce((l,m)=>h(m,l)>0?m:l);case"first":return i.length===0?null:j(i[0]);case"last":return i.length===0?null:j(i[i.length-1]);default:return null}}function R(i){if(typeof i=="number")return Number.isNaN(i)?null:i;if(i==null||i===""||typeof i=="boolean")return null;if(i instanceof Date)return i.getTime();const a=Number(i);return Number.isNaN(a)?null:a}function j(i){return i===void 0?null:i}}),Ce("packages/core/src/compute/windowed.js",function(o,me){"use strict";Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return Z}});const he=me("packages/core/src/compute/sketch.js").Welford;class W{#t;#e;#n=[];#r;#i;constructor(z,re=0,Y=Date.now){if(z!=="count"&&z!=="time"&&z!=="session")throw new RangeError(`unknown window kind: ${z}`);if((z==="count"||z==="time")&&!(re>0))throw new RangeError(`a ${z} window needs a positive span`);this.#t=z,this.#e=Math.floor(re),this.#r=Y,this.#i=Y()}get size(){return this.#n.length}push(z,re=this.#r()){Number.isFinite(z)&&(this.#n.push({t:re,v:z}),this.#s(re))}#s(z){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const re=z-this.#e;for(;this.#n.length&&this.#n[0].t<re;)this.#n.shift()}}spec(){const z=this.#t==="session"?this.#r()-this.#i:this.#e;return{kind:this.#t,span:z,size:this.#n.length}}values(){return this.#n.map(z=>z.v)}aggregate(){const z=this.spec();if(!this.#n.length)return{over:z,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const re=new he;let Y=0,se=1/0,te=-1/0;for(const{v:H}of this.#n)Y+=H,H<se&&(se=H),H>te&&(te=H),re.add(H);return{over:z,count:this.#n.length,sum:Y,mean:re.mean(),min:se,max:te,variance:re.variance(),stddev:re.stddev()}}reduce(z){const re=this.aggregate(),Y={sum:re.sum,avg:re.mean,mean:re.mean,min:re.min,max:re.max,count:re.count,variance:re.variance,stddev:re.stddev};if(!(z in Y))throw new RangeError(`unknown windowed aggregate: ${z}`);return{value:Y[z],over:re.over}}}const U=Object.freeze(["count","time","session"]);function _(E,z=Date.now){const re=E.kind==="time"&&E.minutes!=null?E.minutes*6e4:E.span??0;return new W(E.kind,re,z)}const Z={Window:W,WINDOW_KINDS:U,openWindow:_}}),Ce("packages/core/src/compute/anomaly.js",function(o,me){"use strict";Object.defineProperty(o,"MAD_SCALE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return h}});const he=me("packages/core/src/compute/statistics.js").quantileSorted,U=me("packages/core/src/compute/special.js").logGamma,_=.6745,Z=3.5,E=1.5,z=.975,re=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function Y(u){if(!u.length)return null;const l=Array.from(u,Number).sort((f,r)=>f-r),m=he(l,.5),e=l.map(f=>Math.abs(f-m)).sort((f,r)=>f-r),d=he(e,.5);return{median:m,mad:d}}function se(u,t={}){const l=Number.isFinite(t.threshold)?t.threshold:Z,m=u.length,e=new Array(m).fill(null),d=new Array(m).fill(!1),f=[];for(let c=0;c<m;c++){const g=Number(u[c]);Number.isFinite(g)&&f.push(g)}if(!f.length)return{median:null,mad:null,threshold:l,scores:e,flags:d,flagged:0};const r=Y(f);if(r.mad===0)return{median:r.median,mad:0,threshold:l,scores:e,flags:d,flagged:0};let n=0;for(let c=0;c<m;c++){const g=Number(u[c]);if(!Number.isFinite(g))continue;const A=_*(g-r.median)/r.mad;e[c]=A,Math.abs(A)>l&&(d[c]=!0,n++)}return{median:r.median,mad:r.mad,threshold:l,scores:e,flags:d,flagged:n}}function te(u,t={}){const l=Number.isFinite(t.k)?t.k:E,m=[];for(let n=0;n<u.length;n++){const c=Number(u[n]);Number.isFinite(c)&&m.push(c)}if(!m.length)return null;const e=m.sort((n,c)=>n-c),d=he(e,.25),f=he(e,.75),r=f-d;return{q1:d,q3:f,iqr:r,lower:d-l*r,upper:f+l*r,k:l}}function H(u,t){if(t<=0)return 0;const l=U(u);if(t<u+1){let c=u,g=1/u,A=g;for(let P=0;P<1e3&&(c+=1,A*=t/c,g+=A,!(Math.abs(A)<Math.abs(g)*1e-15));P++);return g*Math.exp(-t+u*Math.log(t)-l)}const m=1e-300;let e=t+1-u,d=1/m,f=1/e,r=f;for(let c=1;c<1e3;c++){const g=-c*(c-u);e+=2,f=g*f+e,Math.abs(f)<m&&(f=m),d=e+g/d,Math.abs(d)<m&&(d=m),f=1/f;const A=f*d;if(r*=A,Math.abs(A-1)<1e-15)break}return 1-Math.exp(-t+u*Math.log(t)-l)*r}function T(u,t){return u<=0?0:H(t/2,u/2)}function V(u,t=z){if(!(t>0)||!(t<1))return NaN;let l=0,m=Math.max(1,u);for(;T(m,u)<t;)m*=2;for(let e=0;e<200;e++){const d=(l+m)/2;if(T(d,u)<t?l=d:m=d,m-l<1e-10)break}return(l+m)/2}function ne(u){const t=u.length,l=u.map((m,e)=>{const d=m.slice();for(let f=0;f<t;f++)d.push(e===f?1:0);return d});for(let m=0;m<t;m++){let e=m;for(let f=m+1;f<t;f++)Math.abs(l[f][m])>Math.abs(l[e][m])&&(e=f);if(Math.abs(l[e][m])<1e-12)return null;if(e!==m){const f=l[e];l[e]=l[m],l[m]=f}const d=l[m][m];for(let f=0;f<2*t;f++)l[m][f]/=d;for(let f=0;f<t;f++){if(f===m)continue;const r=l[f][m];if(r!==0)for(let n=0;n<2*t;n++)l[f][n]-=r*l[m][n]}}return l.map(m=>m.slice(t))}function R(u,t){const l=u.length,m=new Array(t).fill(0);for(const f of u)for(let r=0;r<t;r++)m[r]+=f[r];for(let f=0;f<t;f++)m[f]/=l;const e=Array.from({length:t},()=>new Array(t).fill(0));for(const f of u)for(let r=0;r<t;r++){const n=f[r]-m[r];for(let c=r;c<t;c++)e[r][c]+=n*(f[c]-m[c])}const d=l>1?l-1:1;for(let f=0;f<t;f++)for(let r=f;r<t;r++)e[f][r]/=d,e[r][f]=e[f][r];return{mean:m,cov:e}}function j(u,t={}){const l=Number.isFinite(t.p)?t.p:z,m=Number.isFinite(t.ridge)?t.ridge:1e-6,e=u.length;if(!e)return null;const d=u[0].length;if(!d)return null;const f=new Array(e).fill(null),r=new Array(e).fill(null),n=new Array(e).fill(!1),c=[],g=[];for(let N=0;N<e;N++){const I=u[N];let K=I.length===d;const B=new Array(d);for(let ee=0;K&&ee<d;ee++){const J=Number(I[ee]);Number.isFinite(J)?B[ee]=J:K=!1}K&&(c.push(N),g.push(B))}const A=d,P=V(A,l);if(g.length<=d)return{center:[],df:A,cutoff:P,singular:!0,used:g.length,distances:f,squared:r,flags:n,flagged:0};const{mean:q,cov:L}=R(g,d);let v=ne(L),G=!1;if(!v){G=!0;let N=0;for(let B=0;B<d;B++)N+=L[B][B];const I=N/d*m||m,K=L.map((B,ee)=>B.map((J,ue)=>ee===ue?J+I:J));if(v=ne(K),!v)return{center:q,df:A,cutoff:P,singular:!0,used:g.length,distances:f,squared:r,flags:n,flagged:0}}let S=0;for(let N=0;N<g.length;N++){const I=g[N],K=new Array(d);for(let J=0;J<d;J++)K[J]=I[J]-q[J];let B=0;for(let J=0;J<d;J++){let ue=0;for(let de=0;de<d;de++)ue+=v[J][de]*K[de];B+=K[J]*ue}B<0&&(B=0);const ee=c[N];r[ee]=B,f[ee]=Math.sqrt(B),B>P&&(n[ee]=!0,S++)}return{center:q,df:A,cutoff:P,singular:G,used:g.length,distances:f,squared:r,flags:n,flagged:S}}const i=20,a=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function s(u,t={}){const l=t.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",m=Number.isFinite(t.windowLen)&&t.windowLen>=1?Math.floor(t.windowLen):i,e=Number.isFinite(t.threshold)?t.threshold:Z,d=Number.isFinite(t.k)?t.k:E,f=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):m,r=u.length,n=new Array(r).fill(null),c=new Array(r).fill(!1);let g=0;for(let A=0;A<r;A++){const P=Number(u[A]);if(!Number.isFinite(P))continue;const q=Math.max(0,A-m+1),L=[];for(let v=q;v<=A;v++){const G=Number(u[v]);Number.isFinite(G)&&L.push(G)}if(!(L.length<f))if(l==="rollingIqr"){const v=te(L,{k:d});if(!v)continue;(P<v.lower||P>v.upper)&&(c[A]=!0,g++)}else{const v=Y(L);if(!v||v.mad===0)continue;const G=_*(P-v.median)/v.mad;n[A]=G,Math.abs(G)>e&&(c[A]=!0,g++)}}return{method:l,windowLen:m,minPeriods:f,threshold:e,k:d,scores:n,flags:c,flagged:g}}function h(u={}){const t=u||{},l=t.field;if(typeof l!="string"||!l)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const m=t.method||"modifiedZScore";if(!(re.includes(m)||a.includes(m))||m==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method \'${m}\'`);const d=typeof t.orderBy=="string"?t.orderBy:null,f=t.latest===!0,r=a.includes(m),n=c=>Number(c==null?NaN:c[l]);return c=>{const g=Array.isArray(c)?c.slice():[...c];d&&g.sort((v,G)=>{const S=v?.[d],N=G?.[d];return S===N?0:S==null?-1:N==null?1:S<N?-1:1});const A=g.map(n);let P,q;if(r)({flags:P,scores:q}=s(A,{method:m,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(m==="iqr"){const v=te(A,{k:t.k});P=A.map(G=>v?Number.isFinite(G)&&(G<v.lower||G>v.upper):!1),q=A.map(()=>null)}else({flags:P,scores:q}=se(A,{threshold:t.threshold}));if(f){const v=P.length-1;return v<0||!P[v]?!1:{method:m,field:l,flagged:[{row:g[v],score:q[v]}]}}const L=[];for(let v=0;v<P.length;v++)P[v]&&L.push({row:g[v],score:q[v]});return L.length?{method:m,field:l,flagged:L}:!1}}}),Ce("packages/core/src/compute/forecast.js",function(o,me){"use strict";Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return u}});const ae=me("packages/core/src/compute/special.js"),he=ae.normalQuantile,W=ae.studentTQuantile,_=me("packages/core/src/internal/util.js").warnOnce,Z=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),E=1e-4,z=1-1e-4;function re(t){const l=[];for(let m=0;m<t.length;m++){const e=t[m];if(e!==null&&typeof e=="object"){const d=Number.isFinite(e.at)?e.at:m,f=Number.isFinite(e.value)?e.value:null;l.push({at:d,value:f})}else l.push({at:m,value:Number.isFinite(e)?Number(e):null})}return l}function Y(t){const l=t.filter(r=>r.value!==null),m=l[0],e=l[l.length-1],d=e.at-m.at,f=l.length>1&&d>0?d/(l.length-1):1;return{lastAt:e.at,step:f}}function se(t){return Math.min(z,Math.max(E,t))}function te(t,l=E,m=z,e=80){const d=(Math.sqrt(5)-1)/2;let f=l,r=m,n=r-d*(r-f),c=f+d*(r-f),g=t(n),A=t(c);for(let P=0;P<e;P++)g<A?(r=c,c=n,A=g,n=r-d*(r-f),g=t(n)):(f=n,n=c,g=A,c=f+d*(r-f),A=t(c));return(f+r)/2}function H(t,l){let m=null,e=0,d=0;for(let f=0;f<t.length;f++){const r=t[f];if(r!==null){if(m===null){m=r;continue}e+=(r-m)**2,d+=1,m=l*r+(1-l)*m}}return{level:m,sse:e,m:d}}function T(t,l,m){let e=null,d=null,f=0,r=0;for(let n=0;n<t.length;n++){const c=t[n];if(c===null){e!==null&&d!==null&&(e+=d);continue}if(e===null){e=c;continue}d===null&&(d=c-e);const g=e+d;f+=(c-g)**2,r+=1;const A=e;e=l*c+(1-l)*(A+d),d=m*(e-A)+(1-m)*d}return{level:e,trend:d,sse:f,m:r}}function V(t,l,m,e,d){const f=t.length;if(f<2*l)return null;const r=G=>{let S=0,N=0;for(let I=G;I<G+l&&I<f;I++)t[I]!==null&&(S+=t[I],N+=1);return N?S/N:null},n=r(0),c=r(l);if(n===null||c===null)return null;let g=n,A=(c-n)/l;const P=new Array(l).fill(0);for(let G=0;G<l;G++)P[G]=t[G]===null?0:t[G]-g;const q=P.reduce((G,S)=>G+S,0)/l;for(let G=0;G<l;G++)P[G]-=q;let L=0,v=0;for(let G=l;G<f;G++){const S=G%l,N=P[S],I=t[G];if(I===null){g+=A;continue}const K=g+A+N;L+=(I-K)**2,v+=1;const B=g;g=m*(I-N)+(1-m)*(g+A),A=e*(g-B)+(1-e)*A,P[S]=d*(I-g)+(1-d)*N}return{level:g,trend:A,season:P,phase:(f-1)%l,sse:L,count:v}}function ne(t,l,m){let e=1;for(const f of l)e+=f*f;const d=Math.sqrt(t*e);return{se:d,margin:m*d}}function R(t,l={}){if(!t||typeof t.length!="number"||t.length===0)return null;const m=Z.includes(l.method)?l.method:"linear",e=Math.max(1,Math.floor(Number(l.horizon)||1)),d=Number.isFinite(l.confidence)&&l.confidence>0&&l.confidence<1?l.confidence:.95,f=1-(1-d)/2,r=re(t),n=r.map(L=>L.value),c=n.filter(L=>L!==null),g=c.length,{lastAt:A,step:P}=g?Y(r):{lastAt:0,step:1},q=L=>A+L*P;return m==="linear"?j(r,g,e,d,f,q):m==="movingAverage"?i(c,g,e,d,f,l,q):m==="ses"?a(n,g,e,d,f,l,q):m==="holt"?s(n,g,e,d,f,l,q):h(n,g,e,d,f,l,q)}function j(t,l,m,e,d,f){if(l<2)return null;let r=0,n=0;for(const I of t)I.value!==null&&(r+=I.at,n+=I.value);r/=l,n/=l;let c=0,g=0,A=0;for(const I of t){if(I.value===null)continue;const K=I.at-r,B=I.value-n;c+=K*K,g+=K*B,A+=B*B}if(c===0)return null;const P=g/c,q=n-P*r,L=A===0?1:Math.max(0,Math.min(1,g*g/(c*A))),v=Math.max(0,A-P*g),G=l>2?Math.sqrt(v/(l-2)):null,S=l>2?W(d,l-2):null,N=[];for(let I=1;I<=m;I++){const K=f(I),B=q+P*K;let ee=null,J=null,ue=null,de=null,Oe=null;if(G!==null){const Ae=1/l+(K-r)**2/c,Se=G*Math.sqrt(1+Ae),D=G*Math.sqrt(Ae);Oe=Se,ee=B-S*Se,J=B+S*Se,ue=B-S*D,de=B+S*D}N.push({step:I,at:K,mean:B,lower:ee,upper:J,lowerMean:ue,upperMean:de,se:Oe})}return{method:"linear",horizon:m,confidence:e,n:l,sigma:G,r2:L,params:{slope:P,intercept:q},points:N}}function i(t,l,m,e,d,f,r){if(l<1)return null;const n=Math.max(1,Math.min(l,Math.floor(Number(f.windowLen)||l))),c=t.slice(l-n);let g=0;for(const G of c)g+=G;const A=g/n;let P=null,q=null;if(n>1){let G=0;for(const N of c)G+=(N-A)**2;P=Math.sqrt(G/(n-1))*Math.sqrt(1+1/n),q=W(d,n-1)}const L=P===null?null:q*P,v=[];for(let G=1;G<=m;G++)v.push({step:G,at:r(G),mean:A,lower:L===null?null:A-L,upper:L===null?null:A+L,se:P});return{method:"movingAverage",horizon:m,confidence:e,n:l,sigma:P===null?null:P,params:{windowLen:n},points:v}}function a(t,l,m,e,d,f,r){if(l<1)return null;let n=Number.isFinite(f.alpha)?se(f.alpha):null;n===null&&(n=te(q=>H(t,q).sse));const c=H(t,n),g=he(d),A=c.m>0?c.sse/c.m:null,P=[];for(let q=1;q<=m;q++){const L=c.level;let v=null,G=null,S=null;if(A!==null){const N=[];for(let K=1;K<q;K++)N.push(n);const I=ne(A,N,g);S=I.se,v=L-I.margin,G=L+I.margin}P.push({step:q,at:r(q),mean:L,lower:v,upper:G,se:S})}return{method:"ses",horizon:m,confidence:e,n:l,sigma:A===null?null:Math.sqrt(A),params:{alpha:n},points:P}}function s(t,l,m,e,d,f,r){if(l<2)return null;let n=Number.isFinite(f.alpha)?se(f.alpha):null,c=Number.isFinite(f.beta)?se(f.beta):null;if(n===null||c===null){let v=n===null?.5:n,G=c===null?.5:c;for(let S=0;S<6;S++)n===null&&(v=te(N=>T(t,N,G).sse)),c===null&&(G=te(N=>T(t,v,N).sse));n=n===null?v:n,c=c===null?G:c}const g=T(t,n,c),A=he(d),P=g.m>0?g.sse/g.m:null,q=n*c,L=[];for(let v=1;v<=m;v++){const G=g.level+v*g.trend;let S=null,N=null,I=null;if(P!==null){const K=[];for(let ee=1;ee<v;ee++)K.push(n+ee*q);const B=ne(P,K,A);I=B.se,S=G-B.margin,N=G+B.margin}L.push({step:v,at:r(v),mean:G,lower:S,upper:N,se:I})}return{method:"holt",horizon:m,confidence:e,n:l,sigma:P===null?null:Math.sqrt(P),params:{alpha:n,beta:c},points:L}}function h(t,l,m,e,d,f,r){const n=Math.floor(Number(f.period));if(!(n>=2))return _("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(l<2*n)return null;let c=Number.isFinite(f.alpha)?se(f.alpha):null,g=Number.isFinite(f.beta)?se(f.beta):null,A=Number.isFinite(f.gamma)?se(f.gamma):null;const P=(I,K,B)=>{const ee=V(t,n,I,K,B);return ee?ee.sse:1/0};if(c===null||g===null||A===null){let I=c===null?.5:c,K=g===null?.5:g,B=A===null?.5:A;for(let ee=0;ee<8;ee++)c===null&&(I=te(J=>P(J,K,B))),g===null&&(K=te(J=>P(I,J,B))),A===null&&(B=te(J=>P(I,K,J)));c=c===null?I:c,g=g===null?K:g,A=A===null?B:A}const q=V(t,n,c,g,A);if(!q)return null;const L=he(d),v=q.count>0?q.sse/q.count:null,G=c*g,S=A*(1-c),N=[];for(let I=1;I<=m;I++){const K=q.season[(q.phase+I)%n],B=q.level+I*q.trend+K;let ee=null,J=null,ue=null;if(v!==null){const de=[];for(let Ae=1;Ae<I;Ae++)de.push(c+Ae*G+(Ae%n===0?S:0));const Oe=ne(v,de,L);ue=Oe.se,ee=B-Oe.margin,J=B+Oe.margin}N.push({step:I,at:r(I),mean:B,lower:ee,upper:J,se:ue})}return{method:"holtWinters",horizon:m,confidence:e,n:l,sigma:v===null?null:Math.sqrt(v),params:{alpha:c,beta:g,gamma:A,period:n},points:N}}const u={FORECAST_METHODS:Z,forecast:R}}),Ce("packages/core/src/compute/index.js",function(o,me){"use strict";const ae=me("packages/core/src/compute/sort.js");Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return ae.sortColumn}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return ae.sortMulti}}),Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return ae.radixSortFloat64}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return ae.radixSortInt32}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return ae.rankSortDictionary}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return ae.mergeSortComparator}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return ae.collateStringRanks}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return ae.rankSortStrings}});const he=me("packages/core/src/compute/sortspec.js");Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return he.collationDescriptor}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he.isPortableSort}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return he.isPortableSortSet}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return he.describeSortEntry}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return he.describeSort}});const W=me("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return W.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return W.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return W.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return W.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return W.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return W.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return W.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return W.mentionsColumn}});const U=me("packages/core/src/compute/group.js");Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return U.groupByColumns}}),Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return U.packKeys}});const _=me("packages/core/src/compute/facet.js");Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return _.facet}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return _.computeBounds}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return _.countInto}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return _.bucketOf}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return _.facetKind}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return _.cardinalityOf}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return _.pickGranularity}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return _.floorTo}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return _.advance}}),Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return _.STRATEGIES}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return _.GRANULARITIES}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return _.DEFAULT_BUCKETS}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return _.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return _.QUANTILE_SAMPLE}});const Z=me("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return Z.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return Z.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return Z.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return Z.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return Z.collectValues}});const E=me("packages/core/src/compute/pivot.js");Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return E.pivot}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return E.resolvePivotKeys}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return E.pivotKey}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return E.joinPath}}),Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return E.KEY_DELIMITER}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return E.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return E.DEFAULT_MAX_COLUMNS}});const z=me("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return z.pivotMatrix}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return z.resolveAxis}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return z.cellKey}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return z.marginKey}}),Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return z.GRAND_PATH}});const re=me("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return re.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return re.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return re.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return re.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return re.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return re.referenceValue}});const Y=me("packages/core/src/compute/handle.js");Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return Y.identity}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return Y.rowCount}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return Y.presenceReader}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return Y.bitReader}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return Y.valueReader}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return Y.valueComparator}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Y.numericTotalOrder}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return Y.dictRanks}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return Y.dictSize}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return Y.dictValue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return Y.multiValue}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return Y.isMissing}});const se=me("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return se.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return se.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return se.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return se.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return se.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return se.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return se.SKETCH_BOUNDS}});const te=me("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return te.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return te.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return te.openWindow}});const H=me("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return H.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return H.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return H.maintenanceOf}});const T=me("packages/core/src/compute/anomaly.js");Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return T.ANOMALY_METHODS}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return T.modifiedZScores}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return T.iqrFences}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return T.mahalanobis}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return T.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return T.rollingAnomalies}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return T.anomalyCondition}});const V=me("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return V.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return V.forecast}})}),Ce("packages/worker/src/kernel.js",function(o,me){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"setCompute",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"dispatch",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"handleMessage",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"installKernel",{enumerable:!0,get:function(){return s}});const ae=me("packages/worker/src/transport.js"),he=ae.PROTOCOL,W=ae.OPS,U=ae.CONTROL,_=ae.ERRORS,Z=ae.unpackHandle,E=ae.unpackHandles,z=ae.createMaskPool,re=ae.collectTransfers,Y=me("packages/core/src/store/columnpack.js"),se=Y.packChunk,te=Y.packedTransfers;let H=null,T=null,V=null;async function ne(h){if(H)return H;if(!T){const u=h||(()=>Promise.resolve(me("packages/core/src/compute/index.js")));T=Promise.resolve().then(u).then(t=>(H=t,t)).catch(t=>(V=t,H=null,null))}return T}function R(h){H=h,T=h?Promise.resolve(h):null,V=h?null:V}function j(h,u,t){const l=new Map;for(const m of h)m&&l.set(m.id,m);return{handle(m){return l.get(m)},count:u,pool:z(),locale:t}}function i(h,u){const{op:t,args:l}=h;if(t===W.COLUMNIZE)return se(l.schema||[],l.rows||[],l.opts||{});const m=u[t];if(typeof m!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=_.NO_KERNEL,e}switch(t){case W.COLLATE_STRING_RANKS:return m(l.table||[],(l.table||[]).length,l.locale);case W.SORT_COLUMN:return m(Z(l.handle),l.order??null,l.opts||{});case W.SORT_MULTI:{const e=E(l.handles||[]),d=(l.entries||[]).map(f=>({...f,handle:e[f.index]}));return m(e,d,l.order??null)}case W.EVALUATE_FILTERS:return m(l.filters,j(E(l.handles||[]),l.count,l.locale));case W.COMPACT:return m(l.mask,l.count,void 0);case W.GROUP_BY_COLUMNS:return m(E(l.handles||[]),l.order??null,l.opts||{});case W.TOTAL:return m(Z(l.handle),l.indices??null,l.fn);case W.PIVOT:return m(E(l.handles||[]),l.order??null,l.opts||{});case W.FACET:return m(Z(l.handle),l.indices??null,l.count,l.opts||{});default:{const e=new Error(`[lattice] unknown worker op \'${t}\'`);throw e.code=_.PROTOCOL,e}}}async function a(h,u={}){if(!h||h.lattice!==he)return null;const{id:t,op:l}=h;if(l===U.CANCEL)return u.cancelled?.add(h.target),null;if(l===U.PING)return{reply:{lattice:he,id:t,ok:!0,result:"pong"},transfer:[]};if(l===W.COLUMNIZE){if(u.cancelled?.has(t))return u.cancelled.delete(t),null;try{const e=se(h.args.schema||[],h.args.rows||[],h.args.opts||{});return u.cancelled?.has(t)?(u.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:_.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:te(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||_.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}const m=await ne(u.loader);if(!m)return{reply:{lattice:he,id:t,ok:!1,error:{code:_.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${V?V.message:"module not found"}`}},transfer:[]};if(u.cancelled?.has(t))return u.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:_.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(h,m);return u.cancelled?.has(t)?(u.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:_.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:re(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||_.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}function s(h,u={}){const t=new Set,l=async m=>{const e=await a(m.data,{loader:u.loader,cancelled:t});e&&h.postMessage(e.reply,e.transfer)};return h.addEventListener("message",l),ne(u.loader).then(m=>{h.postMessage({lattice:he,id:0,op:U.READY,compute:!!m})}),()=>h.removeEventListener("message",l)}});var kt=at("packages/worker/src/kernel.js");Ot.__latticeKernel=kt})(typeof globalThis<"u"?globalThis:this);\n\n__latticeKernel.installKernel(self);\n',{type:"classic"})}catch{}const Xe=Kn("packages/dom/src/index.js"),no=Xe.createGrid,ro=Xe.gridElementsWithin,io=Xe.createStat,oo=Xe.deltaOf,so=Xe.toneOf,ao=Xe.readTable,lo=Xe.hydrateTable,uo=Xe.autoInit,co=Xe.createLocalViewStorage,ho=Xe.DEFAULT_VIEWS_KEY,fo=Xe.createHeadlessGrid,po=Xe.defaults,mo=Xe.version,go=Xe.getVersion,yo=Xe.Grid,bo=Xe.EventBus,wo=Xe.Registry,vo=Xe.sharedRegistry,ko=Xe.registerModules,So=Xe.parseLicence,Oo=Xe.verifyLicence,Ao=Xe.licenceInfo,jo=Xe.watermark,Po=Xe.setLicence,Co=Xe.licenceState,Eo=Xe.isLocalHost,To=Xe.matchesDomain,Mo=Xe.LicenceHolder,No=Xe.ColumnModel,Ro=Xe.buildGraph,Lo=Xe.Lookup,Fo=Xe.ValuePipeline,xo=Xe.compileFormat,$o=Xe.compileMask,Io=Xe.specToOoxml,Do=Xe.EXTENDED_TYPES,zo=Xe.createRadixType,Bo=Xe.RADIX_PRESETS,Uo=Xe.parseRadix,Vo=Xe.formatRadix,Ho=Xe.createUnitType,Go=Xe.registerUnitSystem,Ko=Xe.defineUnit,Wo=Xe.UNIT_SYSTEMS,_o=Xe.parseUnit,qo=Xe.formatUnit,Zo=Xe.createCurrencyType,Yo=Xe.parseMoney,Xo=Xe.formatMoney,Qo=Xe.convertMoney,Jo=Xe.rateFunction,es=Xe.MISSING_RATE,ts=Xe.Messages,ns=Xe.createMessages,rs=Xe.auditCatalogue,is=Xe.EN_GB,os=Xe.MESSAGE_KEYS,ss=Xe.DEFAULT_LOCALE,as=Xe.formatList,ls=Xe.resolveLocale,us=Xe.LOCALES,cs=Xe.resolveCatalogue,ds=Xe.EN_US,hs=Xe.FR_FR,fs=Xe.FR_CA,ps=Xe.IT_IT,ms=Xe.ES_ES,gs=Xe.PT_BR,ys=Xe.DE_DE,bs=Xe.NL_NL,ws=Xe.SV_SE,vs=Xe.DA_DK,ks=Xe.NB_NO,Ss=Xe.FI_FI,Os=Xe.PL_PL,As=Xe.CS_CZ,js=Xe.HU_HU,Ps=Xe.RO_RO,Cs=Xe.UK_UA,Es=Xe.EL_GR,Ts=Xe.JA_JP,Ms=Xe.AR,Ns=Xe.AR_SA,Rs=Xe.ColumnStore,Ls=Xe.Bitset,Fs=Xe.Dictionary,xs=Xe.MultiValue,$s=Xe.MaskPool,Is=Xe.sortColumn,Ds=Xe.sortMulti,zs=Xe.evaluateFilters,Bs=Xe.compact,Us=Xe.testValue,Vs=Xe.groupByColumns,Hs=Xe.total,Gs=Xe.TOTAL_FNS,Ks=Xe.pivot,Ws=Xe.Window,_s=Xe.openWindow,qs=Xe.WINDOW_KINDS,Zs=Xe.ANOMALY_METHODS,Ys=Xe.modifiedZScores,Xs=Xe.iqrFences,Qs=Xe.mahalanobis,Js=Xe.ROLLING_ANOMALY_METHODS,ea=Xe.rollingAnomalies,ta=Xe.anomalyCondition,na=Xe.FORECAST_METHODS,ra=Xe.forecast,ia=Xe.evaluateFormula,oa=Xe.parseFormula,sa=Xe.referencesOf,aa=Xe.looksLikeFormula,la=Xe.FormulaError,ua=Xe.FUNCTIONS,ca=Xe.compileRules,da=Xe.ingest,ha=Xe.ingestSync,fa=Xe.createSource,pa=Xe.createMemorySource,ma=Xe.createPagedSource,ga=Xe.createRemoteSource,ya=Xe.createStreamSource,ba=Xe.createUrlSource,wa=Xe.PROTOCOL,va=Xe.createPushdownSource,ka=Xe.planQuery,Sa=Xe.splitFilters,Oa=Xe.applyResidual,Aa=Xe.capabilitiesOf,ja=Xe.resolveMutate,Pa=Xe.NO_CAPABILITIES,Ca=Xe.odataAdapter,Ea=Xe.filtersToOData,Ta=Xe.conditionToOData,Ma=Xe.restAdapter,Na=Xe.DEFAULT_PARAMS,Ra=Xe.dfqlAdapter,La=Xe.duckdbAdapter,Fa=Xe.filtersToSql,xa=Xe.graphqlAdapter,$a=Xe.splunkAdapter,Ia=Xe.clickhouseAdapter,Da=Xe.elasticsearchAdapter,za=Xe.RowModel,Ba=Xe.createRowKey,Ua=Xe.SelectionModel,Va=Xe.RangeModel,Ha=Xe.EditModel,Ga=Xe.ChangeModel,Ka=Xe.StateModel,Wa=Xe.STATE_VERSION,_a=Xe.serialiseState,qa=Xe.restoreState,Za=Xe.VERSION,Ya=Xe.DomRenderer,Xa=Xe.FilterMenu,Qa=Xe.mergeColumnFilter,Ja=Xe.branchFor,el=Xe.ColumnMenu,tl=Xe.columnMenuItems,nl=Xe.cellMenuItems,rl=Xe.autoGroupMenuItems,il=Xe.AlignedGrids,ol=Xe.alignGrids,sl=Xe.layoutState,al=Xe.ToolPanelDock,ll=Xe.panelHost,ul=Xe.mountPanel,cl=Xe.CellEditController,dl=Xe.EditBar,hl=Xe.HistoryBar,fl=Xe.HISTORY_CLS,pl=Xe.DiffPainter,ml=Xe.ViewPicker,gl=Xe.VIEW_CLS,yl=Xe.summariseDiff,bl=Xe.PromptBar,wl=Xe.PROMPT_CLASS,vl=Xe.createCellLayer,kl=Xe.compileTemplate,Sl=Xe.compileVariant,Ol=Xe.checkVariant,Al=Xe.VariantRegistry,jl=Xe.BUILTIN_RENDERERS,Pl=Xe.BUILTIN_VARIANTS,Cl=Xe.BUILTIN_PIPES,El=Xe.sanitiseHtml,Tl=Xe.editors,Ml=Xe.createEditor,Nl=Xe.editorFor,Rl=Xe.BaseEditor,Ll=Xe.filters,Fl=Xe.createFilter,xl=Xe.filterFor,$l=Xe.parseExpression,Il=Xe.ConditionFilter,Dl=Xe.StatusBar,zl=Xe.ContextMenu,Bl=Xe.ToolPanel,Ul=Xe.TooltipManager,Vl=Xe.Pagination,Hl=Xe.OverlayLayer,Gl=Xe.LatticeGrid,Kl=Xe.setLicense,Wl=Xe.licenseInfo,_l=Xe.licenseState;var ql=Xe.default;export{Zs as ANOMALY_METHODS,Ms as AR,Ns as AR_SA,il as AlignedGrids,Cl as BUILTIN_PIPES,jl as BUILTIN_RENDERERS,Pl as BUILTIN_VARIANTS,Rl as BaseEditor,Ls as Bitset,As as CS_CZ,cl as CellEditController,Ga as ChangeModel,el as ColumnMenu,No as ColumnModel,Rs as ColumnStore,Il as ConditionFilter,zl as ContextMenu,vs as DA_DK,ss as DEFAULT_LOCALE,Na as DEFAULT_PARAMS,ho as DEFAULT_VIEWS_KEY,ys as DE_DE,Fs as Dictionary,pl as DiffPainter,Ya as DomRenderer,Es as EL_GR,is as EN_GB,ds as EN_US,ms as ES_ES,Do as EXTENDED_TYPES,dl as EditBar,Ha as EditModel,bo as EventBus,Ss as FI_FI,na as FORECAST_METHODS,fs as FR_CA,hs as FR_FR,ua as FUNCTIONS,Xa as FilterMenu,la as FormulaError,yo as Grid,fl as HISTORY_CLS,js as HU_HU,hl as HistoryBar,ps as IT_IT,Ts as JA_JP,us as LOCALES,Gl as LatticeGrid,Mo as LicenceHolder,Lo as Lookup,os as MESSAGE_KEYS,es as MISSING_RATE,$s as MaskPool,ts as Messages,xs as MultiValue,ks as NB_NO,bs as NL_NL,Pa as NO_CAPABILITIES,Hl as OverlayLayer,Os as PL_PL,wl as PROMPT_CLASS,wa as PROTOCOL,gs as PT_BR,Vl as Pagination,bl as PromptBar,Bo as RADIX_PRESETS,Js as ROLLING_ANOMALY_METHODS,Ps as RO_RO,Va as RangeModel,wo as Registry,za as RowModel,Wa as STATE_VERSION,ws as SV_SE,Ua as SelectionModel,Ka as StateModel,Dl as StatusBar,Gs as TOTAL_FNS,Bl as ToolPanel,al as ToolPanelDock,Ul as TooltipManager,Cs as UK_UA,Wo as UNIT_SYSTEMS,Za as VERSION,gl as VIEW_CLS,Fo as ValuePipeline,Al as VariantRegistry,ml as ViewPicker,qs as WINDOW_KINDS,Ws as Window,ol as alignGrids,ta as anomalyCondition,Oa as applyResidual,rs as auditCatalogue,rl as autoGroupMenuItems,uo as autoInit,Ja as branchFor,Ro as buildGraph,Aa as capabilitiesOf,nl as cellMenuItems,Ol as checkVariant,Ia as clickhouseAdapter,tl as columnMenuItems,Bs as compact,xo as compileFormat,$o as compileMask,ca as compileRules,kl as compileTemplate,Sl as compileVariant,Ta as conditionToOData,Qo as convertMoney,vl as createCellLayer,Zo as createCurrencyType,Ml as createEditor,Fl as createFilter,no as createGrid,fo as createHeadlessGrid,co as createLocalViewStorage,pa as createMemorySource,ns as createMessages,ma as createPagedSource,va as createPushdownSource,zo as createRadixType,ga as createRemoteSource,Ba as createRowKey,fa as createSource,io as createStat,ya as createStreamSource,Ho as createUnitType,ba as createUrlSource,ql as default,po as defaults,Ko as defineUnit,oo as deltaOf,Ra as dfqlAdapter,La as duckdbAdapter,Nl as editorFor,Tl as editors,Da as elasticsearchAdapter,zs as evaluateFilters,ia as evaluateFormula,xl as filterFor,Ll as filters,Ea as filtersToOData,Fa as filtersToSql,ra as forecast,as as formatList,Xo as formatMoney,Vo as formatRadix,qo as formatUnit,go as getVersion,xa as graphqlAdapter,ro as gridElementsWithin,Vs as groupByColumns,lo as hydrateTable,da as ingest,ha as ingestSync,Xs as iqrFences,Eo as isLocalHost,sl as layoutState,Ao as licenceInfo,Co as licenceState,Wl as licenseInfo,_l as licenseState,aa as looksLikeFormula,Qs as mahalanobis,To as matchesDomain,Qa as mergeColumnFilter,Ys as modifiedZScores,ul as mountPanel,Ca as odataAdapter,_s as openWindow,ll as panelHost,$l as parseExpression,oa as parseFormula,So as parseLicence,Yo as parseMoney,Uo as parseRadix,_o as parseUnit,Ks as pivot,ka as planQuery,Jo as rateFunction,ao as readTable,sa as referencesOf,ko as registerModules,Go as registerUnitSystem,cs as resolveCatalogue,ls as resolveLocale,ja as resolveMutate,Ma as restAdapter,qa as restoreState,ea as rollingAnomalies,El as sanitiseHtml,_a as serialiseState,Po as setLicence,Kl as setLicense,vo as sharedRegistry,Is as sortColumn,Ds as sortMulti,Io as specToOoxml,Sa as splitFilters,$a as splunkAdapter,yl as summariseDiff,Us as testValue,so as toneOf,Hs as total,Oo as verifyLicence,mo as version,jo as watermark};
|
|
58
58
|
|
|
59
59
|
//# sourceMappingURL=lattice-grid.esm.min.js.map
|