@toclocoinc/lattice-grid 1.80.0 → 1.81.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/angular/package.json +1 -1
- package/docs/API.html +4 -4
- package/docs/THEMING.md +6 -3
- package/docs/api/adapters.html +1 -1
- package/docs/api/ai.html +1 -1
- package/docs/api/alarms.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/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/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-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-hexbin.d.ts +1 -1
- package/modules/chart-hexbin.esm.min.js +1 -1
- package/modules/chart-hexbin.min.cjs +1 -1
- package/modules/chart-hexbin.min.js +1 -1
- package/modules/chart-hexmap.d.ts +1 -1
- package/modules/chart-hexmap.esm.min.js +1 -1
- package/modules/chart-hexmap.min.cjs +1 -1
- package/modules/chart-hexmap.min.js +1 -1
- package/modules/chart-icicle.d.ts +1 -1
- package/modules/chart-icicle.esm.min.js +1 -1
- package/modules/chart-icicle.min.cjs +1 -1
- package/modules/chart-icicle.min.js +1 -1
- package/modules/chart-markermap.d.ts +1 -1
- package/modules/chart-markermap.esm.min.js +1 -1
- package/modules/chart-markermap.min.cjs +1 -1
- package/modules/chart-markermap.min.js +1 -1
- package/modules/chart-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-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-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-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-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/charts.d.ts +1 -1
- package/modules/charts.esm.min.js +2 -2
- package/modules/charts.min.cjs +2 -2
- package/modules/charts.min.js +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/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/antd5.css +23 -0
- package/modules/presets/bootstrap5.css +46 -5
- package/modules/presets/fluent2.css +31 -4
- package/modules/presets/material3.css +53 -5
- 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
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Lattice Grid 1.
|
|
2
|
+
* Lattice Grid 1.81.0, webcomponent module
|
|
3
3
|
* Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
|
|
4
4
|
* https://latticegrid.dev
|
|
5
5
|
*/
|
|
6
|
-
var dr=Object.create(null),fr=Object.create(null);function xe(e,K){dr[e]=K}function Gn(e){var K=fr[e];if(K)return K;var X=Object.create(null);fr[e]=X;var L=dr[e];if(!L)throw new Error("[lattice] missing module: "+e);return L(X,Gn),X}xe("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 v}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return i}}),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 f}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return d}}),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 w}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return te}});const X="1.80.0";async function L(){return X}const B="1.80.0",F=new Set,W=2e3;function Q(ne){if(F.add(ne),F.size>W){const ie=F.values().next().value;ie!==void 0&&F.delete(ie)}}const G=[],H=500;function U(ne,ie,ae){G.push({key:ne,level:ie,message:ae.map(re=>typeof re=="string"?re:D(re)).join(" "),at:Date.now()}),G.length>H&&G.shift()}function D(ne){if(ne instanceof Error)return ne.message;try{return JSON.stringify(ne)}catch{return String(ne)}}function v(){return G.map(ne=>({...ne}))}function S(ne){if(ne.length===0||typeof ne[0]!="string")return ne;const ie=ne[0].replace(/^\[lattice\]\s*/,"");return ie===ne[0]?ne:[ie,...ne.slice(1)]}function y(ne,...ie){if(F.has(ne))return;Q(ne);const ae=S(ie);U(ne,"warn",ae),console.warn("[lattice]",...ae)}function l(ne,...ie){if(F.has(ne))return;Q(ne);const ae=S(ie);U(ne,"info",ae),console.info("[lattice]",...ae)}function c(){F.clear(),G.length=0}function i(ne,ie){const ae=new Error(`[lattice] ${ne}`);throw ie!==void 0&&(ae.cause=ie),ae}function n(ne,ie){ne||i(ie)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function r(ne){return ne!==null&&typeof ne=="object"&&!Array.isArray(ne)}function s(ne){return typeof ne=="function"}function f(ne){return ne==null}function u(ne){return ne==null||ne===""}function o(ne){return typeof ne!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(ne))?!0:!!(ne.prototype&&Object.getOwnPropertyNames(ne.prototype).length>1)}const g=new Map;function d(ne){let ie=g.get(ne);if(ie)return ie;if(!ne.includes("."))ie=ae=>ae?.[ne];else{const ae=ne.split("."),re=ae.length;ie=se=>{let le=se;for(let fe=0;fe<re;fe++){if(le==null)return;le=le[ae[fe]]}return le}}return g.set(ne,ie),ie}const h=new Map;function a(ne){let ie=h.get(ne);if(ie)return ie;if(!ne.includes("."))ie=(ae,re)=>{ae!=null&&(ae[ne]=re)};else{const ae=ne.split("."),re=ae.length-1;ie=(se,le)=>{let fe=se;for(let be=0;be<re;be++){if(fe==null)return;const Le=ae[be];fe[Le]==null&&(fe[Le]={}),fe=fe[Le]}fe!=null&&(fe[ae[re]]=le)}}return h.set(ne,ie),ie}function p(ne,ie){return d(ie)(ne)}function w(ne,ie,ae){a(ie)(ne,ae)}function k(ne){return ne?(ne.includes(".")?ne.slice(ne.lastIndexOf(".")+1):ne).replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/\s+/g," ").trim().replace(/^./,ae=>ae.toUpperCase()):""}const m={"&":"&","<":"<",">":">",'"':""","'":"'"};function b(ne){const ie=ne==null?"":String(ne);return/[&<>"']/.test(ie)?ie.replace(/[&<>"']/g,ae=>m[ae]):ie}function C(ne){return String(ne).replace(/\w\S*/g,ie=>ie[0].toUpperCase()+ie.slice(1).toLowerCase())}function M(ne,ie,ae){if(ne!==void 0)return ne===!0?{enabled:!0,...ae}:ne===!1?{enabled:!1}:r(ne)?ne:{[ie]:ne,enabled:!0}}function P(ne){return ne==null?[]:Array.isArray(ne)?ne:[ne]}const x=Object.freeze(new Set(["__proto__","constructor","prototype"]));function E(ne,ie){if(!r(ne))return r(ie)?{...ie}:ie;if(!r(ie))return ie===void 0?ne:ie;const ae={...ne};for(const re of Object.keys(ie)){if(x.has(re))continue;const se=ie[re];se!==void 0&&(ae[re]=r(se)&&r(ae[re])?E(ae[re],se):se)}return ae}function A(ne,ie){if(!r(ne)||!r(ie)||ne===ie)return ie;const ae=Object.create(Object.getPrototypeOf(ne));return Object.assign(ae,ne,ie),ae}class j{#e;#t=new Map;#n;constructor(ie=256,ae=null){this.#e=ie,this.#n=ae}get size(){return this.#t.size}get max(){return this.#e}set max(ie){this.#e=ie,this.#r()}has(ie){return this.#t.has(ie)}get(ie){const ae=this.#t;if(!ae.has(ie))return;const re=ae.get(ie);return ae.delete(ie),ae.set(ie,re),re}peek(ie){return this.#t.get(ie)}set(ie,ae){const re=this.#t;return re.has(ie)&&re.delete(ie),re.set(ie,ae),this.#r(),ae}delete(ie){const ae=this.#t.get(ie);return this.#t.delete(ie)&&this.#n&&this.#n(ae,ie),ae}clear(){if(this.#n)for(const[ie,ae]of this.#t)this.#n(ae,ie);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const ie=this.#t;for(;ie.size>this.#e;){const ae=ie.keys().next().value,re=ie.get(ae);ie.delete(ae),this.#n&&this.#n(re,ae)}}}const $=new Map;function z(ne,ie){const ae=`${ne||""}|${ie?JSON.stringify(ie):""}`;let re=$.get(ae);return re||(re=new Intl.Collator(ne||void 0,{numeric:!0,sensitivity:"variant",...ie}),$.set(ae,re)),re}function T(ne,ie){if(ne===ie)return 0;if(ne==null)return 1;if(ie==null)return-1;if(typeof ne=="number"&&typeof ie=="number")return Number.isNaN(ne)?Number.isNaN(ie)?0:1:Number.isNaN(ie)||ne<ie?-1:ne>ie?1:0;const ae=String(ne),re=String(ie);return ae<re?-1:ae>re?1:0}function R(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const O=typeof requestAnimationFrame=="function";function I(ne){return O?requestAnimationFrame(ne):setTimeout(()=>ne(R()),16)}function q(ne){ne!=null&&(O?cancelAnimationFrame(ne):clearTimeout(ne))}function Z(ne){let ie=null,ae=null;const re=()=>{ie=null;const le=ae;ae=null,ne(...le||[])},se=(...le)=>{ae=le,ie===null&&(ie=I(re))};return se.cancel=()=>{q(ie),ie=null,ae=null},se.flush=()=>{ie!==null&&(q(ie),re())},se}function _(ne,ie){let ae=null,re=null;const se=()=>{if(ae=null,re===null)return;const be=re;re=null,ne(...be),le()},le=()=>{ae=setTimeout(se,ie),typeof ae?.unref=="function"&&ae.unref()},fe=(...be)=>{ae===null?(ne(...be),le()):(re=be,clearTimeout(ae),le())};return fe.flush=()=>{if(ae!==null&&clearTimeout(ae),ae=null,re===null)return;const be=re;re=null,ne(...be)},fe.cancel=()=>{ae!==null&&clearTimeout(ae),ae=null,re=null},fe.pending=()=>ae!==null||re!==null,fe}function J(ne,ie=50){return typeof requestIdleCallback=="function"?requestIdleCallback(ne,{timeout:ie}):setTimeout(()=>ne({timeRemaining:()=>0,didTimeout:!0}),1)}let ee=0;function te(ne="l"){return`${ne}${(++ee).toString(36)}`}}),xe("packages/core/src/formatting/rules.js",function(e,K){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return y}}),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 C}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,F=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),W=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),Q=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 G(M,P){const x=Number(M),E=Number(P);if(M!==null&&M!==""&&P!==null&&P!==""&&Number.isFinite(x)&&Number.isFinite(E))return x<E?-1:x>E?1:0;const j=String(M??"").toLowerCase(),$=String(P??"").toLowerCase();return j<$?-1:j>$?1:0}function H(M){return M==null||M===""}function U(M,P){if(!P||typeof P!="object")return!1;const{op:x}=P,E=P.value,A=P.value2;switch(x){case"blank":return H(M);case"notBlank":return!H(M);case"true":return M===!0;case"false":return M===!1;default:break}if(H(M))return!1;switch(x){case"eq":return G(M,E)===0;case"ne":return G(M,E)!==0;case"gt":return G(M,E)>0;case"gte":return G(M,E)>=0;case"lt":return G(M,E)<0;case"lte":return G(M,E)<=0;case"between":return G(M,E)>=0&&G(M,A)<=0;case"outside":return G(M,E)<0||G(M,A)>0;case"contains":return String(M).toLowerCase().includes(String(E??"").toLowerCase());case"notContains":return!String(M).toLowerCase().includes(String(E??"").toLowerCase());case"startsWith":return String(M).toLowerCase().startsWith(String(E??"").toLowerCase());case"endsWith":return String(M).toLowerCase().endsWith(String(E??"").toLowerCase());default:return!1}}function D(M,P,x){const E=q=>{const Z=String(q).replace("#",""),_=Z.length===3?Z.split("").map(J=>J+J).join(""):Z;return[0,2,4].map(J=>parseInt(_.slice(J,J+2),16)||0)},[A,j,$]=E(M),[z,T,R]=E(P),O=Math.max(0,Math.min(1,x)),I=(q,Z)=>Math.round(q+(Z-q)*O);return`#${[I(A,z),I(j,T),I($,R)].map(q=>q.toString(16).padStart(2,"0")).join("")}`}function v(M){const P=[];for(const z of M||[]){if(z==null||z==="")continue;const T=z instanceof Date?z.getTime():Number(z);Number.isFinite(T)&&P.push(T)}if(!P.length)return null;P.sort((z,T)=>z-T);let x=0,E=0,A=0;for(const z of P){x++;const T=z-E;E+=T/x,A+=T*(z-E)}const j=S(P,.25),$=S(P,.75);return{n:P.length,min:P[0],max:P[P.length-1],mean:E,stddev:P.length>1?Math.sqrt(A/(P.length-1)):0,median:S(P,.5),q1:j,q3:$,iqr:$-j,sorted:P}}function S(M,P){if(!M.length)return 0;const x=(M.length-1)*Math.max(0,Math.min(1,P)),E=Math.floor(x),A=Math.ceil(x);return E===A?M[E]:M[E]+(x-E)*(M[A]-M[E])}function y(M){for(const P of Array.isArray(M)?M:[])if(!(!P||typeof P!="object")&&(P.when&&W.includes(P.when.op)||P.scale&&P.scale.from||P.dataBar&&!(Number.isFinite(Number(P.dataBar.min))&&Number.isFinite(Number(P.dataBar.max)))||P.iconSet&&!Array.isArray(P.iconSet.thresholds)))return!0;return!1}function l(M,P){const x=Number(M.value),E=A=>S(P.sorted,A);switch(M.op){case"topPercent":{const A=c(x,10);return{op:"gte",value:E(1-A)}}case"bottomPercent":{const A=c(x,10);return{op:"lte",value:E(A)}}case"topN":{const A=Math.max(1,Math.floor(x)||1),j=Math.max(0,P.sorted.length-A);return{op:"gte",value:P.sorted[j]}}case"bottomN":{const A=Math.max(1,Math.floor(x)||1),j=Math.min(P.sorted.length-1,A-1);return{op:"lte",value:P.sorted[j]}}case"aboveMean":return{op:"gt",value:P.mean};case"belowMean":return{op:"lt",value:P.mean};case"aboveMedian":return{op:"gt",value:P.median};case"belowMedian":return{op:"lt",value:P.median};case"zAbove":return P.stddev?{op:"gte",value:P.mean+(Number.isFinite(x)?x:2)*P.stddev}:null;case"zBelow":return P.stddev?{op:"lte",value:P.mean-(Number.isFinite(x)?x:2)*P.stddev}:null;case"outlier":{const A=(Number.isFinite(x)&&x>0?x:1.5)*P.iqr;return P.iqr?{op:"outside",value:P.q1-A,value2:P.q3+A}:null}default:return null}}function c(M,P){const x=Number.isFinite(M)?M:P,E=x>1?x/100:x;return Math.max(0,Math.min(1,E))}function i(M,P){if(M.from==="minmax")return{...M,min:P.min,max:P.max};if(M.from==="quantile")return{...M,min:S(P.sorted,c(Number(M.low),5)),max:S(P.sorted,c(Number(M.high),95))};if(M.from==="stddev"){const x=Number.isFinite(Number(M.deviations))?Number(M.deviations):2;return{...M,min:P.mean-x*P.stddev,max:P.mean+x*P.stddev}}return M}function n(M,P){const x=Array.isArray(M)?M:[];return!P||!P.n?x.map(E=>E&&y([E])?{...E,enabled:!1}:E):x.map(E=>{if(!E||typeof E!="object")return E;if(E.scale&&E.scale.from)return{...E,scale:i(E.scale,P)};if(E.dataBar)return{...E,dataBar:t(E.dataBar,P)};if(E.iconSet)return{...E,iconSet:r(E.iconSet,P)};if(!E.when||!W.includes(E.when.op))return E;const A=l(E.when,P);return A?{...E,when:A}:{...E,enabled:!1}})}function t(M,P){const x=Number.isFinite(Number(M.min))?Number(M.min):void 0,E=Number.isFinite(Number(M.max))?Number(M.max):void 0;if(x!==void 0&&E!==void 0)return{...M,min:x,max:E};if(M.from==="quantile")return{...M,min:x??S(P.sorted,c(Number(M.low),5)),max:E??S(P.sorted,c(Number(M.high),95))};if(M.from==="stddev"){const A=Number.isFinite(Number(M.deviations))?Number(M.deviations):2;return{...M,min:x??P.mean-A*P.stddev,max:E??P.mean+A*P.stddev}}return{...M,min:x??P.min,max:E??P.max}}function r(M,P){if(Array.isArray(M.thresholds))return M;const x=s(M),E=[];for(let A=1;A<x;A++)E.push(S(P.sorted,A/x));return{...M,thresholds:E}}function s(M){if(Array.isArray(M.icons)&&M.icons.length>=2)return M.icons.length;if(Number.isFinite(Number(M.count))&&Number(M.count)>=2)return Math.floor(Number(M.count));const P=a[M.set];return P?P.length:3}function f(M){return`url("data:image/svg+xml,${encodeURIComponent(M)}")`}function u(M){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${M}"/></svg>`}function o(M,P){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${P==="up"?"8,2 14,13 2,13":P==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${M}"/></svg>`}function g(M,P){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 E=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${P*16} 16">`;for(let A=0;A<P;A++){const j=A<M?"#f5a623":"#d0d0d0";E+=`<path transform="translate(${A*16},0)" d="${x}" fill="${j}"/>`}return`${E}</svg>`}const d=Object.freeze([o("#c0392b","down"),o("#e0a800","right"),o("#2e7d32","up")]),h=Object.freeze([u("#d13438"),u("#f5a623"),u("#2e9e44")]),a=Object.freeze({arrows:d,trafficLights:h,ratings:Object.freeze([1,2,3,4,5].map(M=>g(M,5)))}),p=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function w(M){if(Array.isArray(M.icons)&&M.icons.length>=2)return M.icons.map(E=>/^\s*(url\(|data:|<)/.test(String(E))&&String(E).trim().startsWith("<")?f(String(E)):String(E));const P=M.set||"arrows";if(P==="ratings"){const E=s(M),A=[];for(let j=1;j<=E;j++)A.push(f(g(j,E)));return A}const x=a[P];return x?x.map(f):(B(`iconSet:${P}`,`unknown icon set '${P}'; falling back to arrows.`),d.map(f))}function k(M){const P=Number(M.min),E=Number(M.max)-P,A=M.colour||M.color||"#5b9bd5",j=M.negativeColour||M.negativeColor||"#d13438",$=M.direction==="rtl"?"left":"right",z=R=>Math.max(0,Math.min(1,(R-P)/E))*100,T=E?Math.max(0,Math.min(100,(0-P)/E*100)):0;return R=>{if(H(R))return null;const O=Number(R);if(!Number.isFinite(O)||!E)return null;const I=z(O),q=Math.min(I,T),Z=Math.max(I,T),_=O>=0?A:j;return{backgroundImage:`linear-gradient(to ${$}, transparent ${q}%, ${_} ${q}%, ${_} ${Z}%, transparent ${Z}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function m(M){const P=w(M),x=M.reverse?[...P].reverse():P,E=(Array.isArray(M.thresholds)?M.thresholds:[]).map(Number).filter(Number.isFinite),A=Number.isFinite(Number(M.size))?Number(M.size):16,j=M.set==="ratings"?A*s(M):A;return $=>{if(H($))return null;const z=Number($);if(!Number.isFinite(z))return null;let T=0;for(const O of E)z>=O&&T++;const R=x[Math.min(T,x.length-1)];return R?{backgroundImage:R,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${j}px ${A}px`,paddingLeft:`${j+4}px`}:null}}function b(M){const P=Array.isArray(M.colours)&&M.colours.length>=2?M.colours:["#f8f9fa","#1a6bc7"],x=Number(M.min),E=Number(M.max),A=E-x,j=P.length-1,$=[];for(let T=0;T<=j;T++)$.push(j?T/j:0);const z=Number(M.mid);if(M.mid!==void 0&&M.mid!==null)if(P.length%2===0)B("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${P.length} were given, so "mid" was ignored.`);else if(Number.isFinite(z)&&A&&z>Math.min(x,E)&&z<Math.max(x,E)){const T=j/2,R=Math.max(0,Math.min(1,(z-x)/A));for(let O=0;O<=j;O++)$[O]=O<=T?T?O/T*R:R:R+(O-T)/(j-T)*(1-R)}else Number.isFinite(z)&&B("formatting.scale.mid.range",`a scale's "mid" (${z}) is outside its min..max range, so it was ignored.`);return T=>{const R=Number(T);if(!Number.isFinite(R)||!A)return null;const O=Math.max(0,Math.min(1,(R-x)/A));let I=0;for(;I<j-1&&O>$[I+1];)I++;const q=$[I+1]-$[I],Z=q>0?(O-$[I])/q:0;return{background:D(P[I],P[I+1],Math.max(0,Math.min(1,Z)))}}}function C(M,P=null){const x=y(M)?n(M,P):M,E=(Array.isArray(x)?x:[]).filter(j=>j&&typeof j=="object");if(!E.length)return()=>null;const A=E.map(j=>j.scale?{scale:b(j.scale),enabled:j.enabled!==!1}:j.dataBar?{scale:k(j.dataBar),enabled:j.enabled!==!1}:j.iconSet?{scale:m(j.iconSet),enabled:j.enabled!==!1}:{when:j.when,style:j.style,stop:j.stopIfTrue!==!1,enabled:j.enabled!==!1});return j=>{const $=j?j.value:void 0;let z=null;for(const T of A){if(!T.enabled)continue;if(T.scale){const O=T.scale($);O&&(z={...z||{},...O});continue}if(!U($,T.when))continue;const R=L(T.style)?T.style(j):T.style;if(R&&(z={...z||{},...R}),T.stop)break}return z}}}),xe("packages/core/src/formula/parse.js",function(e,K){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return t}});const X="num",L="str",B="ref",F="name",W="op",Q="end",G=["<=",">=","<>","!="],H="+-*/^%(),<>=";class U extends Error{constructor(s,f){super(s),this.name="FormulaError",this.at=f}}function D(r){const s=[];let f=0;for(;f<r.length;){const u=r[f];if(u===" "||u===" "||u===`
|
|
6
|
+
var dr=Object.create(null),fr=Object.create(null);function xe(e,K){dr[e]=K}function Gn(e){var K=fr[e];if(K)return K;var X=Object.create(null);fr[e]=X;var L=dr[e];if(!L)throw new Error("[lattice] missing module: "+e);return L(X,Gn),X}xe("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 v}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return i}}),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 f}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return d}}),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 w}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return te}});const X="1.81.0";async function L(){return X}const B="1.81.0",F=new Set,W=2e3;function Q(ne){if(F.add(ne),F.size>W){const ie=F.values().next().value;ie!==void 0&&F.delete(ie)}}const G=[],H=500;function U(ne,ie,ae){G.push({key:ne,level:ie,message:ae.map(re=>typeof re=="string"?re:D(re)).join(" "),at:Date.now()}),G.length>H&&G.shift()}function D(ne){if(ne instanceof Error)return ne.message;try{return JSON.stringify(ne)}catch{return String(ne)}}function v(){return G.map(ne=>({...ne}))}function S(ne){if(ne.length===0||typeof ne[0]!="string")return ne;const ie=ne[0].replace(/^\[lattice\]\s*/,"");return ie===ne[0]?ne:[ie,...ne.slice(1)]}function y(ne,...ie){if(F.has(ne))return;Q(ne);const ae=S(ie);U(ne,"warn",ae),console.warn("[lattice]",...ae)}function l(ne,...ie){if(F.has(ne))return;Q(ne);const ae=S(ie);U(ne,"info",ae),console.info("[lattice]",...ae)}function c(){F.clear(),G.length=0}function i(ne,ie){const ae=new Error(`[lattice] ${ne}`);throw ie!==void 0&&(ae.cause=ie),ae}function n(ne,ie){ne||i(ie)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function r(ne){return ne!==null&&typeof ne=="object"&&!Array.isArray(ne)}function s(ne){return typeof ne=="function"}function f(ne){return ne==null}function u(ne){return ne==null||ne===""}function o(ne){return typeof ne!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(ne))?!0:!!(ne.prototype&&Object.getOwnPropertyNames(ne.prototype).length>1)}const g=new Map;function d(ne){let ie=g.get(ne);if(ie)return ie;if(!ne.includes("."))ie=ae=>ae?.[ne];else{const ae=ne.split("."),re=ae.length;ie=se=>{let le=se;for(let fe=0;fe<re;fe++){if(le==null)return;le=le[ae[fe]]}return le}}return g.set(ne,ie),ie}const h=new Map;function a(ne){let ie=h.get(ne);if(ie)return ie;if(!ne.includes("."))ie=(ae,re)=>{ae!=null&&(ae[ne]=re)};else{const ae=ne.split("."),re=ae.length-1;ie=(se,le)=>{let fe=se;for(let be=0;be<re;be++){if(fe==null)return;const Le=ae[be];fe[Le]==null&&(fe[Le]={}),fe=fe[Le]}fe!=null&&(fe[ae[re]]=le)}}return h.set(ne,ie),ie}function p(ne,ie){return d(ie)(ne)}function w(ne,ie,ae){a(ie)(ne,ae)}function k(ne){return ne?(ne.includes(".")?ne.slice(ne.lastIndexOf(".")+1):ne).replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/\s+/g," ").trim().replace(/^./,ae=>ae.toUpperCase()):""}const m={"&":"&","<":"<",">":">",'"':""","'":"'"};function b(ne){const ie=ne==null?"":String(ne);return/[&<>"']/.test(ie)?ie.replace(/[&<>"']/g,ae=>m[ae]):ie}function C(ne){return String(ne).replace(/\w\S*/g,ie=>ie[0].toUpperCase()+ie.slice(1).toLowerCase())}function M(ne,ie,ae){if(ne!==void 0)return ne===!0?{enabled:!0,...ae}:ne===!1?{enabled:!1}:r(ne)?ne:{[ie]:ne,enabled:!0}}function P(ne){return ne==null?[]:Array.isArray(ne)?ne:[ne]}const x=Object.freeze(new Set(["__proto__","constructor","prototype"]));function E(ne,ie){if(!r(ne))return r(ie)?{...ie}:ie;if(!r(ie))return ie===void 0?ne:ie;const ae={...ne};for(const re of Object.keys(ie)){if(x.has(re))continue;const se=ie[re];se!==void 0&&(ae[re]=r(se)&&r(ae[re])?E(ae[re],se):se)}return ae}function A(ne,ie){if(!r(ne)||!r(ie)||ne===ie)return ie;const ae=Object.create(Object.getPrototypeOf(ne));return Object.assign(ae,ne,ie),ae}class j{#e;#t=new Map;#n;constructor(ie=256,ae=null){this.#e=ie,this.#n=ae}get size(){return this.#t.size}get max(){return this.#e}set max(ie){this.#e=ie,this.#r()}has(ie){return this.#t.has(ie)}get(ie){const ae=this.#t;if(!ae.has(ie))return;const re=ae.get(ie);return ae.delete(ie),ae.set(ie,re),re}peek(ie){return this.#t.get(ie)}set(ie,ae){const re=this.#t;return re.has(ie)&&re.delete(ie),re.set(ie,ae),this.#r(),ae}delete(ie){const ae=this.#t.get(ie);return this.#t.delete(ie)&&this.#n&&this.#n(ae,ie),ae}clear(){if(this.#n)for(const[ie,ae]of this.#t)this.#n(ae,ie);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const ie=this.#t;for(;ie.size>this.#e;){const ae=ie.keys().next().value,re=ie.get(ae);ie.delete(ae),this.#n&&this.#n(re,ae)}}}const $=new Map;function z(ne,ie){const ae=`${ne||""}|${ie?JSON.stringify(ie):""}`;let re=$.get(ae);return re||(re=new Intl.Collator(ne||void 0,{numeric:!0,sensitivity:"variant",...ie}),$.set(ae,re)),re}function T(ne,ie){if(ne===ie)return 0;if(ne==null)return 1;if(ie==null)return-1;if(typeof ne=="number"&&typeof ie=="number")return Number.isNaN(ne)?Number.isNaN(ie)?0:1:Number.isNaN(ie)||ne<ie?-1:ne>ie?1:0;const ae=String(ne),re=String(ie);return ae<re?-1:ae>re?1:0}function R(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const O=typeof requestAnimationFrame=="function";function I(ne){return O?requestAnimationFrame(ne):setTimeout(()=>ne(R()),16)}function q(ne){ne!=null&&(O?cancelAnimationFrame(ne):clearTimeout(ne))}function Z(ne){let ie=null,ae=null;const re=()=>{ie=null;const le=ae;ae=null,ne(...le||[])},se=(...le)=>{ae=le,ie===null&&(ie=I(re))};return se.cancel=()=>{q(ie),ie=null,ae=null},se.flush=()=>{ie!==null&&(q(ie),re())},se}function _(ne,ie){let ae=null,re=null;const se=()=>{if(ae=null,re===null)return;const be=re;re=null,ne(...be),le()},le=()=>{ae=setTimeout(se,ie),typeof ae?.unref=="function"&&ae.unref()},fe=(...be)=>{ae===null?(ne(...be),le()):(re=be,clearTimeout(ae),le())};return fe.flush=()=>{if(ae!==null&&clearTimeout(ae),ae=null,re===null)return;const be=re;re=null,ne(...be)},fe.cancel=()=>{ae!==null&&clearTimeout(ae),ae=null,re=null},fe.pending=()=>ae!==null||re!==null,fe}function J(ne,ie=50){return typeof requestIdleCallback=="function"?requestIdleCallback(ne,{timeout:ie}):setTimeout(()=>ne({timeRemaining:()=>0,didTimeout:!0}),1)}let ee=0;function te(ne="l"){return`${ne}${(++ee).toString(36)}`}}),xe("packages/core/src/formatting/rules.js",function(e,K){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return y}}),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 C}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,F=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),W=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),Q=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 G(M,P){const x=Number(M),E=Number(P);if(M!==null&&M!==""&&P!==null&&P!==""&&Number.isFinite(x)&&Number.isFinite(E))return x<E?-1:x>E?1:0;const j=String(M??"").toLowerCase(),$=String(P??"").toLowerCase();return j<$?-1:j>$?1:0}function H(M){return M==null||M===""}function U(M,P){if(!P||typeof P!="object")return!1;const{op:x}=P,E=P.value,A=P.value2;switch(x){case"blank":return H(M);case"notBlank":return!H(M);case"true":return M===!0;case"false":return M===!1;default:break}if(H(M))return!1;switch(x){case"eq":return G(M,E)===0;case"ne":return G(M,E)!==0;case"gt":return G(M,E)>0;case"gte":return G(M,E)>=0;case"lt":return G(M,E)<0;case"lte":return G(M,E)<=0;case"between":return G(M,E)>=0&&G(M,A)<=0;case"outside":return G(M,E)<0||G(M,A)>0;case"contains":return String(M).toLowerCase().includes(String(E??"").toLowerCase());case"notContains":return!String(M).toLowerCase().includes(String(E??"").toLowerCase());case"startsWith":return String(M).toLowerCase().startsWith(String(E??"").toLowerCase());case"endsWith":return String(M).toLowerCase().endsWith(String(E??"").toLowerCase());default:return!1}}function D(M,P,x){const E=q=>{const Z=String(q).replace("#",""),_=Z.length===3?Z.split("").map(J=>J+J).join(""):Z;return[0,2,4].map(J=>parseInt(_.slice(J,J+2),16)||0)},[A,j,$]=E(M),[z,T,R]=E(P),O=Math.max(0,Math.min(1,x)),I=(q,Z)=>Math.round(q+(Z-q)*O);return`#${[I(A,z),I(j,T),I($,R)].map(q=>q.toString(16).padStart(2,"0")).join("")}`}function v(M){const P=[];for(const z of M||[]){if(z==null||z==="")continue;const T=z instanceof Date?z.getTime():Number(z);Number.isFinite(T)&&P.push(T)}if(!P.length)return null;P.sort((z,T)=>z-T);let x=0,E=0,A=0;for(const z of P){x++;const T=z-E;E+=T/x,A+=T*(z-E)}const j=S(P,.25),$=S(P,.75);return{n:P.length,min:P[0],max:P[P.length-1],mean:E,stddev:P.length>1?Math.sqrt(A/(P.length-1)):0,median:S(P,.5),q1:j,q3:$,iqr:$-j,sorted:P}}function S(M,P){if(!M.length)return 0;const x=(M.length-1)*Math.max(0,Math.min(1,P)),E=Math.floor(x),A=Math.ceil(x);return E===A?M[E]:M[E]+(x-E)*(M[A]-M[E])}function y(M){for(const P of Array.isArray(M)?M:[])if(!(!P||typeof P!="object")&&(P.when&&W.includes(P.when.op)||P.scale&&P.scale.from||P.dataBar&&!(Number.isFinite(Number(P.dataBar.min))&&Number.isFinite(Number(P.dataBar.max)))||P.iconSet&&!Array.isArray(P.iconSet.thresholds)))return!0;return!1}function l(M,P){const x=Number(M.value),E=A=>S(P.sorted,A);switch(M.op){case"topPercent":{const A=c(x,10);return{op:"gte",value:E(1-A)}}case"bottomPercent":{const A=c(x,10);return{op:"lte",value:E(A)}}case"topN":{const A=Math.max(1,Math.floor(x)||1),j=Math.max(0,P.sorted.length-A);return{op:"gte",value:P.sorted[j]}}case"bottomN":{const A=Math.max(1,Math.floor(x)||1),j=Math.min(P.sorted.length-1,A-1);return{op:"lte",value:P.sorted[j]}}case"aboveMean":return{op:"gt",value:P.mean};case"belowMean":return{op:"lt",value:P.mean};case"aboveMedian":return{op:"gt",value:P.median};case"belowMedian":return{op:"lt",value:P.median};case"zAbove":return P.stddev?{op:"gte",value:P.mean+(Number.isFinite(x)?x:2)*P.stddev}:null;case"zBelow":return P.stddev?{op:"lte",value:P.mean-(Number.isFinite(x)?x:2)*P.stddev}:null;case"outlier":{const A=(Number.isFinite(x)&&x>0?x:1.5)*P.iqr;return P.iqr?{op:"outside",value:P.q1-A,value2:P.q3+A}:null}default:return null}}function c(M,P){const x=Number.isFinite(M)?M:P,E=x>1?x/100:x;return Math.max(0,Math.min(1,E))}function i(M,P){if(M.from==="minmax")return{...M,min:P.min,max:P.max};if(M.from==="quantile")return{...M,min:S(P.sorted,c(Number(M.low),5)),max:S(P.sorted,c(Number(M.high),95))};if(M.from==="stddev"){const x=Number.isFinite(Number(M.deviations))?Number(M.deviations):2;return{...M,min:P.mean-x*P.stddev,max:P.mean+x*P.stddev}}return M}function n(M,P){const x=Array.isArray(M)?M:[];return!P||!P.n?x.map(E=>E&&y([E])?{...E,enabled:!1}:E):x.map(E=>{if(!E||typeof E!="object")return E;if(E.scale&&E.scale.from)return{...E,scale:i(E.scale,P)};if(E.dataBar)return{...E,dataBar:t(E.dataBar,P)};if(E.iconSet)return{...E,iconSet:r(E.iconSet,P)};if(!E.when||!W.includes(E.when.op))return E;const A=l(E.when,P);return A?{...E,when:A}:{...E,enabled:!1}})}function t(M,P){const x=Number.isFinite(Number(M.min))?Number(M.min):void 0,E=Number.isFinite(Number(M.max))?Number(M.max):void 0;if(x!==void 0&&E!==void 0)return{...M,min:x,max:E};if(M.from==="quantile")return{...M,min:x??S(P.sorted,c(Number(M.low),5)),max:E??S(P.sorted,c(Number(M.high),95))};if(M.from==="stddev"){const A=Number.isFinite(Number(M.deviations))?Number(M.deviations):2;return{...M,min:x??P.mean-A*P.stddev,max:E??P.mean+A*P.stddev}}return{...M,min:x??P.min,max:E??P.max}}function r(M,P){if(Array.isArray(M.thresholds))return M;const x=s(M),E=[];for(let A=1;A<x;A++)E.push(S(P.sorted,A/x));return{...M,thresholds:E}}function s(M){if(Array.isArray(M.icons)&&M.icons.length>=2)return M.icons.length;if(Number.isFinite(Number(M.count))&&Number(M.count)>=2)return Math.floor(Number(M.count));const P=a[M.set];return P?P.length:3}function f(M){return`url("data:image/svg+xml,${encodeURIComponent(M)}")`}function u(M){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${M}"/></svg>`}function o(M,P){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${P==="up"?"8,2 14,13 2,13":P==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${M}"/></svg>`}function g(M,P){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 E=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${P*16} 16">`;for(let A=0;A<P;A++){const j=A<M?"#f5a623":"#d0d0d0";E+=`<path transform="translate(${A*16},0)" d="${x}" fill="${j}"/>`}return`${E}</svg>`}const d=Object.freeze([o("#c0392b","down"),o("#e0a800","right"),o("#2e7d32","up")]),h=Object.freeze([u("#d13438"),u("#f5a623"),u("#2e9e44")]),a=Object.freeze({arrows:d,trafficLights:h,ratings:Object.freeze([1,2,3,4,5].map(M=>g(M,5)))}),p=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function w(M){if(Array.isArray(M.icons)&&M.icons.length>=2)return M.icons.map(E=>/^\s*(url\(|data:|<)/.test(String(E))&&String(E).trim().startsWith("<")?f(String(E)):String(E));const P=M.set||"arrows";if(P==="ratings"){const E=s(M),A=[];for(let j=1;j<=E;j++)A.push(f(g(j,E)));return A}const x=a[P];return x?x.map(f):(B(`iconSet:${P}`,`unknown icon set '${P}'; falling back to arrows.`),d.map(f))}function k(M){const P=Number(M.min),E=Number(M.max)-P,A=M.colour||M.color||"#5b9bd5",j=M.negativeColour||M.negativeColor||"#d13438",$=M.direction==="rtl"?"left":"right",z=R=>Math.max(0,Math.min(1,(R-P)/E))*100,T=E?Math.max(0,Math.min(100,(0-P)/E*100)):0;return R=>{if(H(R))return null;const O=Number(R);if(!Number.isFinite(O)||!E)return null;const I=z(O),q=Math.min(I,T),Z=Math.max(I,T),_=O>=0?A:j;return{backgroundImage:`linear-gradient(to ${$}, transparent ${q}%, ${_} ${q}%, ${_} ${Z}%, transparent ${Z}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function m(M){const P=w(M),x=M.reverse?[...P].reverse():P,E=(Array.isArray(M.thresholds)?M.thresholds:[]).map(Number).filter(Number.isFinite),A=Number.isFinite(Number(M.size))?Number(M.size):16,j=M.set==="ratings"?A*s(M):A;return $=>{if(H($))return null;const z=Number($);if(!Number.isFinite(z))return null;let T=0;for(const O of E)z>=O&&T++;const R=x[Math.min(T,x.length-1)];return R?{backgroundImage:R,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${j}px ${A}px`,paddingLeft:`${j+4}px`}:null}}function b(M){const P=Array.isArray(M.colours)&&M.colours.length>=2?M.colours:["#f8f9fa","#1a6bc7"],x=Number(M.min),E=Number(M.max),A=E-x,j=P.length-1,$=[];for(let T=0;T<=j;T++)$.push(j?T/j:0);const z=Number(M.mid);if(M.mid!==void 0&&M.mid!==null)if(P.length%2===0)B("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${P.length} were given, so "mid" was ignored.`);else if(Number.isFinite(z)&&A&&z>Math.min(x,E)&&z<Math.max(x,E)){const T=j/2,R=Math.max(0,Math.min(1,(z-x)/A));for(let O=0;O<=j;O++)$[O]=O<=T?T?O/T*R:R:R+(O-T)/(j-T)*(1-R)}else Number.isFinite(z)&&B("formatting.scale.mid.range",`a scale's "mid" (${z}) is outside its min..max range, so it was ignored.`);return T=>{const R=Number(T);if(!Number.isFinite(R)||!A)return null;const O=Math.max(0,Math.min(1,(R-x)/A));let I=0;for(;I<j-1&&O>$[I+1];)I++;const q=$[I+1]-$[I],Z=q>0?(O-$[I])/q:0;return{background:D(P[I],P[I+1],Math.max(0,Math.min(1,Z)))}}}function C(M,P=null){const x=y(M)?n(M,P):M,E=(Array.isArray(x)?x:[]).filter(j=>j&&typeof j=="object");if(!E.length)return()=>null;const A=E.map(j=>j.scale?{scale:b(j.scale),enabled:j.enabled!==!1}:j.dataBar?{scale:k(j.dataBar),enabled:j.enabled!==!1}:j.iconSet?{scale:m(j.iconSet),enabled:j.enabled!==!1}:{when:j.when,style:j.style,stop:j.stopIfTrue!==!1,enabled:j.enabled!==!1});return j=>{const $=j?j.value:void 0;let z=null;for(const T of A){if(!T.enabled)continue;if(T.scale){const O=T.scale($);O&&(z={...z||{},...O});continue}if(!U($,T.when))continue;const R=L(T.style)?T.style(j):T.style;if(R&&(z={...z||{},...R}),T.stop)break}return z}}}),xe("packages/core/src/formula/parse.js",function(e,K){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return t}});const X="num",L="str",B="ref",F="name",W="op",Q="end",G=["<=",">=","<>","!="],H="+-*/^%(),<>=";class U extends Error{constructor(s,f){super(s),this.name="FormulaError",this.at=f}}function D(r){const s=[];let f=0;for(;f<r.length;){const u=r[f];if(u===" "||u===" "||u===`
|
|
7
7
|
`||u==="\r"){f++;continue}if(u>="0"&&u<="9"){f=S(r,f,s);continue}if(u==="."&&r[f+1]>="0"&&r[f+1]<="9"){f=S(r,f,s);continue}if(u==='"'||u==="'"){f=y(r,f,s);continue}if(u==="["){const g=r.indexOf("]",f+1);if(g<0)throw new U("a [column reference] was opened and never closed",f);s.push({kind:B,value:r.slice(f+1,g).trim(),at:f}),f=g+1;continue}if(v(u)){f=l(r,f,s);continue}const o=r.slice(f,f+2);if(G.includes(o)){s.push({kind:W,value:o==="!="?"<>":o,at:f}),f+=2;continue}if(H.includes(u)){s.push({kind:W,value:u,at:f}),f++;continue}throw new U(`unexpected character ${JSON.stringify(u)}`,f)}return s.push({kind:Q,value:null,at:r.length}),s}function v(r){return/[A-Za-z_À-]/.test(r)}function S(r,s,f){let u=s,o=!1;for(;u<r.length;){const g=r[u];if(g>="0"&&g<="9"){u++;continue}if(g==="."&&!o){o=!0,u++;continue}if((g==="e"||g==="E")&&/[0-9+-]/.test(r[u+1]||"")){for(u+=2;u<r.length&&r[u]>="0"&&r[u]<="9";)u++;break}break}return f.push({kind:X,value:Number(r.slice(s,u)),at:s}),u}function y(r,s,f){const u=r[s];let o=s+1,g="";for(;o<r.length;){if(r[o]===u){if(r[o+1]===u){g+=u,o+=2;continue}return f.push({kind:L,value:g,at:s}),o+1}g+=r[o],o++}throw new U("a string was opened and never closed",s)}function l(r,s,f){let u=s;for(;u<r.length&&/[A-Za-z0-9_.À-]/.test(r[u]);)u++;const o=r.slice(s,u);let g=u;for(;g<r.length&&r[g]===" ";)g++;return f.push({kind:r[g]==="("?F:B,value:o,at:s}),u}const c={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function i(r){const s=String(r??"").replace(/^\s*=/,"");if(!s.trim())throw new U("the formula is empty");const f=D(s);let u=0;const o=()=>f[u],g=()=>f[u++],d=b=>{const C=o();if(C.kind!==W||C.value!==b)throw new U(`expected ${JSON.stringify(b)}`,C.at);u++},h=b=>{let C=a();for(;;){const M=o();if(M.kind!==W)break;const P=c[M.value];if(!P||P<b)break;u++;const x=h(M.value==="^"?P:P+1);C={kind:"bin",op:M.value,left:C,right:x}}return C},a=()=>{const b=o();return b.kind===W&&(b.value==="-"||b.value==="+")?(u++,{kind:"unary",op:b.value,arg:a()}):p()},p=()=>{let b=w();for(;o().kind===W&&o().value==="%";)u++,b={kind:"unary",op:"%",arg:b};return b},w=()=>{const b=g();if(b.kind===X)return{kind:"num",value:b.value};if(b.kind===L)return{kind:"str",value:b.value};if(b.kind===B)return{kind:"ref",name:b.value};if(b.kind===F){d("(");const C=[];if(!(o().kind===W&&o().value===")"))for(;;){if(C.push(h(1)),o().kind===W&&o().value===","){u++;continue}break}return d(")"),{kind:"call",name:String(b.value).toUpperCase(),args:C}}if(b.kind===W&&b.value==="("){const C=h(1);return d(")"),C}throw b.kind===Q?new U("the formula ends unexpectedly",b.at):new U(`unexpected ${JSON.stringify(b.value)}`,b.at)},k=h(1),m=o();if(m.kind!==Q)throw new U(`unexpected ${JSON.stringify(m.value)}: is an operator missing?`,m.at);return k}function n(r){const s=new Set,f=u=>{if(!(!u||typeof u!="object")){if(u.kind==="ref"){s.add(String(u.name));return}if(u.kind==="bin"){f(u.left),f(u.right);return}if(u.kind==="unary"){f(u.arg);return}if(u.kind==="call")for(const o of u.args)f(o)}};return f(r),[...s]}function t(r){return typeof r=="string"&&/^\s*=/.test(r)&&r.trim()!=="="}}),xe("packages/core/src/formula/evaluate.js",function(e,K){"use strict";Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return S}});const L=K("packages/core/src/formula/parse.js").FormulaError;function B(y){if(y==null||y==="")return 0;if(typeof y=="boolean")return y?1:0;if(y instanceof Date)return y.getTime();const l=typeof y=="number"?y:Number(String(y).replace(/[,\s]/g,""));if(!Number.isFinite(l))throw new L(`${JSON.stringify(y)} is not a number`);return l}function F(y){return y==null?"":String(y)}function W(y){if(typeof y=="boolean")return y;if(y==null||y==="")return!1;if(typeof y=="number")return y!==0;const l=String(y).trim().toLowerCase();return l==="false"||l==="no"||l==="0"?!1:l!==""}function Q(y){const l=[];for(const c of y){if(Array.isArray(c)){for(const i of c)i!=null&&i!==""&&l.push(B(i));continue}c==null||c===""||l.push(B(c))}return l}function G(y,l){const c=10**l,i=y*c;return Math.sign(i)*Math.round(Math.abs(i)+Number.EPSILON*Math.abs(i))/c}function H(y,l){if(!y.length)return 0;const c=y.slice().sort((r,s)=>r-s),i=(c.length-1)*Math.min(1,Math.max(0,l)),n=Math.floor(i),t=Math.ceil(i);return n===t?c[n]:c[n]+(i-n)*(c[t]-c[n])}function U(y,l){let c=0,i=0,n=0;for(const r of y){c++;const s=r-i;i+=s/c,n+=s*(r-i)}const t=l?c-1:c;return t>0?Math.sqrt(n/t):0}const D={SUM:y=>Q(y).reduce((l,c)=>l+c,0),AVERAGE:y=>{const l=Q(y);return l.length?l.reduce((c,i)=>c+i,0)/l.length:0},MIN:y=>{const l=Q(y);return l.length?Math.min(...l):0},MAX:y=>{const l=Q(y);return l.length?Math.max(...l):0},COUNT:y=>Q(y).length,PRODUCT:y=>Q(y).reduce((l,c)=>l*c,1),ROUND:y=>G(B(y[0]),y.length>1?B(y[1]):0),ROUNDDOWN:y=>{const l=10**(y.length>1?B(y[1]):0),c=B(y[0])*l;return(c<0?Math.ceil(c):Math.floor(c))/l},ROUNDUP:y=>{const l=10**(y.length>1?B(y[1]):0),c=B(y[0])*l;return(c<0?Math.floor(c):Math.ceil(c))/l},ABS:y=>Math.abs(B(y[0])),FLOOR:y=>Math.floor(B(y[0])),CEILING:y=>Math.ceil(B(y[0])),SQRT:y=>Math.sqrt(B(y[0])),POWER:y=>B(y[0])**B(y[1]),MOD:y=>{const l=B(y[1]);if(l===0)throw new L("MOD by zero");return(B(y[0])%l+l)%l},IF:y=>W(y[0])?y[1]:y.length>2?y[2]:!1,AND:y=>y.every(W),OR:y=>y.some(W),NOT:y=>!W(y[0]),COALESCE:y=>y.find(l=>l!=null&&l!=="")??null,CONCAT:y=>y.map(F).join(""),LEN:y=>F(y[0]).length,UPPER:y=>F(y[0]).toUpperCase(),LOWER:y=>F(y[0]).toLowerCase(),TRIM:y=>F(y[0]).trim(),LEFT:y=>F(y[0]).slice(0,y.length>1?B(y[1]):1),RIGHT:y=>{const l=y.length>1?B(y[1]):1;return l<=0?"":F(y[0]).slice(-l)},MEDIAN:y=>H(Q(y),.5),PERCENTILE:y=>{const l=B(y[y.length-1]);return H(Q(y.slice(0,-1)),l>1?l/100:l)},QUARTILE1:y=>H(Q(y),.25),QUARTILE3:y=>H(Q(y),.75),STDEV:y=>U(Q(y),!0),STDEVP:y=>U(Q(y),!1),VAR:y=>{const l=U(Q(y),!0);return l*l},VARP:y=>{const l=U(Q(y),!1);return l*l},COUNTDISTINCT:y=>{const l=new Set;for(const c of y){const i=Array.isArray(c)?c:[c];for(const n of i)n!=null&&n!==""&&l.add(n)}return l.size},IQR:y=>{const l=Q(y);return H(l,.75)-H(l,.25)}};D.AVG=D.AVERAGE,D.CEIL=D.CEILING,D.POW=D.POWER,D.STDEVS=D.STDEV,D.PERCENTILEINC=D.PERCENTILE;function v(y,l){const c=Number(y),i=Number(l);if(y!==null&&y!==""&&l!==null&&l!==""&&Number.isFinite(c)&&Number.isFinite(i))return c<i?-1:c>i?1:0;const t=F(y).toLowerCase(),r=F(l).toLowerCase();return t<r?-1:t>r?1:0}function S(y,l={}){const c=typeof l.lookup=="function"?l.lookup:null,i=l.functions?{...D,...l.functions}:D,n=t=>{switch(t.kind){case"num":return t.value;case"str":return t.value;case"ref":{if(!c)throw new L(`there is no column called ${JSON.stringify(t.name)} here`);const r=c(String(t.name));if(r===void 0)throw new L(`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 v(n(t.left),n(t.right))===0;if(r==="<>")return v(n(t.left),n(t.right))!==0;if(r==="<")return v(n(t.left),n(t.right))<0;if(r==="<=")return v(n(t.left),n(t.right))<=0;if(r===">")return v(n(t.left),n(t.right))>0;if(r===">=")return v(n(t.left),n(t.right))>=0;const s=B(n(t.left)),f=B(n(t.right));if(r==="+")return s+f;if(r==="-")return s-f;if(r==="*")return s*f;if(r==="^")return s**f;if(r==="/"){if(f===0)throw new L("division by zero");return s/f}throw new L(`unknown operator ${JSON.stringify(r)}`)}case"call":{const r=i[t.name];if(typeof r!="function")throw new L(`there is no function called ${t.name}`);return r(t.args.map(n),l)}default:throw new L("the formula could not be read")}};return n(y)}}),xe("packages/core/src/formula/index.js",function(e,K){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"rowLookup",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return v}});const X=K("packages/core/src/formula/parse.js"),L=X.parseFormula,B=X.referencesOf,F=X.looksLikeFormula,W=X.FormulaError,Q=X.tokenise,G=K("packages/core/src/formula/evaluate.js"),H=G.evaluateAst,U=G.FUNCTIONS;function D(S){const{grid:y,row:l,data:c}=S||{},i=f=>String(f).toLowerCase().replace(/[\s_-]/g,""),n=y&&y.columns&&typeof y.columns.all=="function"?y.columns.all():[],t=y&&y.permissions,r=t&&typeof t.isReadable=="function"?f=>t.isReadable(f):()=>!0,s=new Set;for(const f of n)r(f)||(s.add(i(f.id)),f.field&&s.add(i(f.field)),f.title&&s.add(i(f.title)));return f=>{const u=i(f);if(s.has(u))throw new W(`"${f}" cannot be read`);for(const o of n)if(i(o.id)===u||o.field&&i(o.field)===u||o.title&&i(o.title)===u)return l&&y.rows&&typeof y.rows.value=="function"?y.rows.value(l.key,o.id):c?c[o.field||o.id]:void 0;if(c&&typeof c=="object"){for(const o of Object.keys(c))if(i(o)===u){if(!r(o))throw new W(`"${f}" cannot be read`);return c[o]}}}}function v(S,y={}){try{const l=L(S);return{ok:!0,value:H(l,{lookup:D(y),functions:y.formulaFunctions}),references:B(l)}}catch(l){return{ok:!1,error:l instanceof W?l.message:"the formula could not be read",at:l instanceof W?l.at:void 0}}}}),xe("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 U}});const X=K("packages/core/src/internal/util.js"),L=X.isObject,B=X.merge,F=X.warnOnce;let W=null;class Q extends Error{}function G(D,v=new Set){if(Array.isArray(D)){if(v.has(D))throw new Q;v.add(D);const y=D.map(l=>G(l,v));return v.delete(D),y}if(!L(D)||Object.getPrototypeOf(D)!==Object.prototype&&Object.getPrototypeOf(D)!==null)return D;if(v.has(D))throw new Q;v.add(D);const S={};for(const[y,l]of Object.entries(D))S[y]=G(l,v);return v.delete(D),S}function H(D){if(D===void 0)return G(W??{});if(D===null)return W=null,{};if(!L(D))return F("defaults:type",`defaults() expects a configuration object, or null to clear it, but got ${Array.isArray(D)?"an array":typeof D}. The call was ignored and the defaults are unchanged.`),G(W??{});try{W=G(D)}catch(v){if(!(v instanceof Q))throw v;return F("defaults:cyclic","defaults() expects a configuration object with no circular references, but the object passed refers back to itself. The call was ignored and the defaults are unchanged."),G(W??{})}return G(W)}function U(D){return W===null?D:B(G(W),D)}}),xe("packages/core/src/events/names.js",function(e,K){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"isKnownEvent",{enumerable:!0,get:function(){return B}});const X=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"]),L=new Set(X);function B(F){return F==="*"||L.has(F)}}),xe("packages/core/src/events/bus.js",function(e,K){"use strict";Object.defineProperty(e,"WILDCARD",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return l}});const X=K("packages/core/src/internal/util.js"),L=X.warnOnce,B=X.uid,F=X.DEV,Q=K("packages/core/src/events/names.js").isKnownEvent,G="*";function H(c,i){!F||Q(i)||L(`bus.unknown:${i}`,`${c}('${i}') subscribes to an event the grid never raises, so the handler will never fire. Check the name against the EventName list — a common cause is a near miss such as 'row:click' for 'row:clicked'.`)}const U=new Set(["api","user","init","ai"]),D=new WeakMap;function v(c){let i=D.get(c);return i||(i=B("h"),D.set(c,i)),i}function S(){return typeof performance=="object"&&performance?performance.now():Date.now()}function y(c){if(!c||typeof c!="object")return{};const i={};for(const[n,t]of Object.entries(c))n!=="grid"&&(t==null?i[n]=String(t):Array.isArray(t)?i[n]=`[${t.length}]`:typeof t=="object"?i[n]=t.key?`row ${t.key}`:"{…}":typeof t=="function"?i[n]="[function]":i[n]=String(t).slice(0,60));return i}class l{#e=new Map;#t=!1;#n=[];#r=200;#o=new Map;#i=null;#s=!1;#l=0;constructor(i=null){this.#i=i}attach(i){this.#i=i}get grid(){return this.#i}get destroyed(){return this.#s}on(i,n){if(typeof n!="function")return L(`bus.handler:${i}`,`on('${i}') needs a function; ignored.`),()=>{};H("on",i);let t=this.#e.get(i);return t||(t=[],this.#e.set(i,t)),t.push(n),()=>this.off(i,n)}once(i,n){if(typeof n!="function")return L(`bus.handler:${i}`,`once('${i}') needs a function; ignored.`),()=>{};H("once",i);const t=r=>{this.off(i,n),n(r)};return this.#o.set(n,t),this.on(i,t)}off(i,n){if(n===void 0){this.#e.delete(i);return}const t=this.#e.get(i);if(!t)return;const r=this.#o.get(n),s=r&&t.includes(r)?r:n,f=t.indexOf(s);f>=0&&t.splice(f,1),r&&s===r&&this.#o.delete(n),t.length===0&&this.#e.delete(i)}count(i){const n=this.#e.get(i),t=i===G?null:this.#e.get(G);return(n?n.length:0)+(t?t.length:0)}#a(i,n,t,r,s){this.#n.push({type:i,origin:n,listeners:(r?r.length:0)+(s?s.length:0),payload:y(t),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(i,n){this.#t=!!i,Number.isFinite(n)&&n>0&&(this.#r=Math.floor(n)),i||(this.#n=[])}eventLog(){return this.#n.map(i=>({...i}))}clearEventLog(){this.#n=[]}counts(){const i={};for(const[n,t]of this.#e)i[n]=t.length;return i}emit(i,n,t){const r=t??(n&&n.origin),s=U.has(r)?r:"api",f={...n||null,type:i,origin:s,grid:this.#i};if(this.#s)return f;const u=this.#e.get(i),o=i===G?void 0:this.#e.get(G);if(this.#t&&this.#a(i,s,n,u,o),!u&&!o)return f;const g=this.#t?S():0;this.#l++;try{u&&this.#u(u.slice(),f,i),o&&this.#u(o.slice(),f,G)}finally{this.#l--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=S()-g)}return f}emitBefore(i,n,t){const r=t??(n&&n.origin),s=U.has(r)?r:"user";let f=!1,u=null;const o=w=>{f=!0,w!=null&&u===null&&(u=String(w))},g={...n||null,type:i,origin:s,grid:this.#i,get defaultPrevented(){return f},get reason(){return u},preventDefault(w){o(w)}};if(this.#s)return!0;const d=this.#e.get(i);this.#t&&this.#a(i,s,n,d,void 0);const h=d?d.slice():[];if(h.length===0)return!0;const a=()=>(f&&u===null&&(u="prevented"),f&&n&&typeof n=="object"&&(n.reason=u),!f),p=[];for(const w of h)try{const k=w(g);k&&typeof k.then=="function"?p.push(k):k===!1&&o("prevented")}catch(k){o("error"),L(`bus.beforeThrow:${i}:${v(w)}`,`a '${i}' before-handler threw; the action was cancelled.`,k)}return p.length===0?a():Promise.allSettled(p).then(w=>{for(const k of w)k.status==="rejected"?(o("error"),L(`bus.beforeReject:${i}`,`a '${i}' before-handler rejected; the action was cancelled.`,k.reason)):k.value===!1&&o("prevented");return a()})}#u(i,n,t){for(let r=0;r<i.length;r++)try{i[r](n)}catch(s){L(`bus.throw:${t}:${v(i[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}}}),xe("packages/core/src/registry/licence.js",function(e,K){"use strict";Object.defineProperty(e,"PRODUCT",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"LICENCE_VERSION",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"PUBLIC_KEY",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"fromBase64Url",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"toBase64Url",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"asciiBytes",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"hasEd25519",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"currentHost",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return C}});const L=K("packages/core/src/internal/util.js").warnOnce,B="lattice-grid",F=1,W="LG1",Q=64,G="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",H="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",U=(()=>{const M=new Int16Array(128).fill(-1);for(let P=0;P<H.length;P++)M[H.charCodeAt(P)]=P;return M[43]=62,M[47]=63,M})();function D(M){if(typeof M!="string")return null;let P="";for(let z=0;z<M.length;z++){const T=M.charCodeAt(z);if(T!==61){if(T>127||U[T]<0)return null;P+=M[z]}}const x=P.length;if(x%4===1)return null;const E=new Uint8Array(Math.floor(x*3/4));let A=0,j=0,$=0;for(let z=0;z<x;z++)A=A<<6|U[P.charCodeAt(z)],j+=6,j>=8&&(j-=8,E[$++]=A>>j&255);return $===E.length?E:E.subarray(0,$)}function v(M){let P="",x=0;for(;x+2<M.length;x+=3){const A=M[x]<<16|M[x+1]<<8|M[x+2];P+=H[A>>18&63]+H[A>>12&63]+H[A>>6&63]+H[A&63]}const E=M.length-x;if(E===1){const A=M[x]<<16;P+=H[A>>18&63]+H[A>>12&63]}else if(E===2){const A=M[x]<<16|M[x+1]<<8;P+=H[A>>18&63]+H[A>>12&63]+H[A>>6&63]}return P}function S(M){const P=new Uint8Array(M.length);for(let x=0;x<M.length;x++)P[x]=M.charCodeAt(x)&127;return P}function y(M){if(typeof TextDecoder=="function")return new TextDecoder().decode(M);let P="";for(let x=0;x<M.length;x++)P+=String.fromCharCode(M[x]);return P}function l(M){const P={ok:!1,reason:"malformed",product:null,issuedTo:null,expires:null,features:[],deployments:[],version:0,message:null,signature:null,raw:typeof M=="string"?M:""};if(typeof M!="string"||M.length===0)return{...P,reason:"missing"};const x=M.trim(),E=x.split(".");if(E.length!==3)return P;const[A,j,$]=E;if(A!==W)return{...P,reason:"prefix"};const z=D(j),T=D($);if(!z||!T)return P;let R;try{R=JSON.parse(y(z))}catch{return P}return R===null||typeof R!="object"?P:{ok:!0,reason:null,product:typeof R.p=="string"?R.p:null,issuedTo:typeof R.t=="string"?R.t:null,expires:typeof R.e=="string"?R.e:null,features:Array.isArray(R.f)?R.f.slice():[],deployments:Array.isArray(R.d)?R.d.slice():[],version:typeof R.v=="number"?R.v:0,message:S(j),signature:T,raw:x}}function c(M,P){if(!M)return!1;const x=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(M)?`${M}T23:59:59.999Z`:M);return Number.isNaN(x)?!0:P>x}let i=null,n=null,t=null;function r(){const M=globalThis.crypto;return M&&M.subtle?M.subtle:null}async function s(M){if(i&&n===M)return i;const P=r();if(!P)return null;const x=D(M);if(!x)return null;try{const E=await P.importKey("raw",x,{name:"Ed25519"},!1,["verify"]);return i=E,n=M,E}catch{return null}}async function f(){return t!==null||(t=await s(G)!==null),t}async function u(M,P={}){const x=P.warn!==!1,E=P.product||B,A=P.publicKey||G,j=P.now??Date.now(),$=l(M);if(!$.ok){const q=$.reason==="missing"?"missing":"malformed";return x&&L(`licence.${q}`,q==="missing"?"no licence key supplied. The grid renders in full and carries a trial watermark on any host other than localhost. Get a key at latticegrid.dev.":"licence key could not be read. The grid will render with a watermark."),{valid:!1,reason:q}}const z={product:$.product||void 0,issuedTo:$.issuedTo||void 0,expires:$.expires||void 0};if($.product!==E)return x&&L("licence.product",`licence key is for '${$.product}', not '${E}'. The grid will render with a watermark.`),{valid:!1,...z,reason:"product"};if(c($.expires,j))return x&&L("licence.expired",`licence expired on ${$.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...z,reason:"expired"};const T=P.host??g(),R=$.deployments||[];if(R.length&&T&&!o(T)&&!d(T,R))return x&&L("licence.domain",`licence key is not valid for ${T}; it covers ${R.join(", ")}. The grid will render with a watermark.`),{valid:!1,...z,reason:"domain"};const O=await s(A);if(!O){const q=!!$.signature&&$.signature.length===Q;return x&&L("licence.algorithm","this host does not provide crypto.subtle Ed25519, so the licence signature could not be verified. A structural check was used instead."),q?{valid:!0,...z,reason:"unverified"}:{valid:!1,...z,reason:"signature"}}let I=!1;try{I=await r().verify({name:"Ed25519"},O,$.signature,$.message)}catch{I=!1}return I?{valid:!0,...z}:(x&&L("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...z,reason:"signature"})}function o(M){const P=String(M??g()??"").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 g(){const M=globalThis.location;return M&&typeof M.hostname=="string"?M.hostname:null}function d(M,P){const x=h(M);return!x||!Array.isArray(P)?!1:P.some(E=>{const A=h(E);if(!A)return!1;if(A==="*")return!0;if(A.startsWith("*.")){const j=A.slice(2);return x===j||x.endsWith(`.${j}`)}return x===A})}function h(M){return String(M??"").trim().toLowerCase().replace(/\.$/,"")}class a{#e="";#t={valid:!1,reason:"missing"};#n=null;#r=null;#o;#i=new Set;constructor(P={}){this.#o=P}set(P){this.#e=typeof P=="string"?P.trim():"";const x=l(this.#e);return this.#t=x.ok?{valid:!c(x.expires,Date.now())&&x.product===(this.#o.product||B),product:x.product||void 0,issuedTo:x.issuedTo||void 0,expires:x.expires||void 0,reason:"pending"}:{valid:!1,reason:x.reason||"malformed"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const P=this.#e;return this.#n=u(P,this.#o).then(x=>{if(this.#e===P){this.#t=x;for(const E of this.#i)E(x)}return x}),this.#n}onSettled(P){return this.#i.add(P),()=>this.#i.delete(P)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!o(this.#r)}setHost(P){this.#r=P}state(){return this.#t.valid?"licensed":o(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing"},this.#n=null,this.#i.clear()}}const p=new a;function w(M){return p.set(M)}function k(){return p.info()}function m(){return p.watermark()}function b(){return p.state()}function C(){return p}}),xe("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 U}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return t}});const X=K("packages/core/src/internal/util.js"),L=X.warnOnce,B=X.isFunction,F=X.DEV,W=K("packages/core/src/registry/licence.js"),Q=W.LicenceHolder,G=W.sharedLicence,H=["renderer","editor","filter","dataType","totalFn","pipe","component"],U=["all","header","body","totals","panels"];class D{#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 f of H)this.#t.set(f,new Map);this.#o=s.holder||G(),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,f={}){f.licence&&this.setLicence(f.licence),f.grid!==void 0&&(this.#s=f.grid);const u=Array.isArray(s)?s:[s],o=[];for(const g of u){if(!g||typeof g!="object"||typeof g.name!="string"||!g.name){L("registry.module.shape","registerModules received something that is not a module; ignored.");continue}if(this.#e.has(g.name)){F&&this.#c(this.#e.get(g.name),g);continue}if(!B(g.install)){L(`registry.module.install:${g.name}`,`module '${g.name}' has no install() and was ignored.`);continue}const d={registry:this,grid:this.#s};try{g.install(d)}catch(h){L(`registry.module.throw:${g.name}`,`module '${g.name}' threw during install; it was not registered.`,h);continue}this.#e.set(g.name,g);for(const h of v(g))this.#n.add(h);o.push(g.name),this.#d({reason:"module",name:g.name,capabilities:this.capabilities(),regions:l(g)})}return o}unregisterModule(s){const f=this.#e.get(s);if(!f)return!1;if(B(f.uninstall))try{f.uninstall({registry:this,grid:this.#s})}catch(u){L(`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(f)}),!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 f of v(s))this.#n.add(f)}#c(s,f){!s||s===f||S(s,f)||L(`registry.module.reconfigure:${f.name}`,`module '${f.name}' was re-registered with different options; the first registration is kept and this call was ignored. Unregister it first if you mean to replace it.`)}capabilities(){return[...this.#n].sort()}can(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 f of[...this.#r])try{f(s)}catch(u){L("registry.onChange.throw","a registry change handler threw.",u)}}register(s,f,u){const o=this.#t.get(s);if(!o){L(`registry.kind:${s}`,`unknown registry kind '${s}'; expected one of ${H.join(", ")}.`);return}if(!f||typeof f!="string"){L(`registry.name:${s}`,`register('${s}', ...) needs a name.`);return}o.has(f)&&o.get(f)!==u&&L(`registry.replace:${s}:${f}`,`'${f}' was already registered as a ${s} and has been replaced.`),o.set(f,u),this.#d({reason:"register",name:f,kind:s,capabilities:this.capabilities(),regions:c(s)})}registerAll(s,f){if(f)for(const u of Object.keys(f))this.register(s,u,f[u])}get(s,f){const u=this.#t.get(s);return u?u.get(f):void 0}names(s){const f=this.#t.get(s);return f?[...f.keys()]:[]}#f(s,f){const u=this.#t.get(s).get(f);return u!==void 0?u:this.#t.get("component").get(f)}renderer(s){return this.#f("renderer",s)}editor(s){return this.#f("editor",s)}filter(s){return this.#f("filter",s)}dataType(s){return this.get("dataType",s)}totalFn(s){return this.get("totalFn",s)}pipe(s){return this.get("pipe",s)}setLicence(s){return this.#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[f,u]of[...this.#a])u===s&&(this.#r.delete(f),this.#a.delete(f));if(this.#s===s){const f=this.#l.size?[...this.#l][this.#l.size-1]:null;this.#s=f}this.#l.size===0&&this.#i&&(this.#i(),this.#i=null)}}destroy(s){if(s!=null){this.detach(s);return}for(const f of[...this.#e.keys()])this.unregisterModule(f);this.#r.clear(),this.#a.clear(),this.#l.clear(),this.#i&&this.#i(),this.#i=null,this.#s=null}}function v(r){const s=r.capabilities,f=Array.isArray(s)?s.filter(u=>typeof u=="string"):[];return[r.name,...f]}function S(r,s){return r.install!==s.install||r.uninstall!==s.uninstall||(r.version||"")!==(s.version||"")?!1:y(v(r),v(s))&&y(l(r),l(s))}function y(r,s){const f=new Set(r),u=new Set(s);if(f.size!==u.size)return!1;for(const o of f)if(!u.has(o))return!1;return!0}function l(r){const s=r.regions;return!Array.isArray(s)||s.length===0?["all"]:s.filter(f=>U.includes(f))}function c(r){switch(r){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const i=new D;function n(){return i}function t(r,s={}){return i.registerModules(r,s)}}),xe("packages/core/src/format/number.js",function(e,K){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return B}});const L=K("packages/core/src/internal/util.js").isNil;function B(F,W){const Q=F||{},G=Q.locale||W||void 0,H=Q.style||"decimal",U=typeof Q.scale=="number"?Q.scale:1,D=Q.nullDisplay??"",v=Q.zeroDisplay,S=Q.prefix||"",y=Q.suffix||"",l=Q.negative||"minus",c=Q.signed===!0,i={style:H,notation:Q.notation||"standard"};H==="currency"&&(i.currency=Q.currency||"USD",Q.currencyDisplay&&(i.currencyDisplay=Q.currencyDisplay)),typeof Q.decimals=="number"?(i.minimumFractionDigits=Q.decimals,i.maximumFractionDigits=Q.decimals):(typeof Q.minDecimals=="number"&&(i.minimumFractionDigits=Q.minDecimals),typeof Q.maxDecimals=="number"&&(i.maximumFractionDigits=Q.maxDecimals),i.minimumFractionDigits>(i.maximumFractionDigits??20)&&(i.maximumFractionDigits=i.minimumFractionDigits)),Q.thousandsSeparator===!1&&(i.useGrouping=!1),i.notation==="compact"&&(i.compactDisplay=Q.compactDisplay||"short");const n=new Intl.NumberFormat(G,i),t=typeof Q.thousandsSeparator=="string"?Q.thousandsSeparator:null,r=typeof Q.decimalSeparator=="string"?Q.decimalSeparator:null;let s=",",f=".";if(t||r)for(const a of n.formatToParts(12345.6))a.type==="group"?s=a.value:a.type==="decimal"&&(f=a.value);const u=a=>{let p=a;return t&&(p=p.split(s).join("")),r&&(p=p.split(f).join("")),t&&(p=p.split("").join(t)),r&&(p=p.split("").join(r)),p},o=!!(t||r),g=S!==""&&H==="currency",d=a=>{let p;if(g){const w=n.formatToParts(a);let k=!1;p="";for(const m of w)p+=m.value,!k&&m.type==="currency"&&(p+=S,k=!0);k||(p=S+p)}else p=S+n.format(a);return o&&(p=u(p)),p+y},h=a=>{if(L(a)||a==="")return D;const p=typeof a=="number"?a:Number(a);if(Number.isNaN(p))return D;const w=U===1?p:p*U;return w===0&&v!==void 0?v:w<0?l==="parentheses"?`(${d(-w)})`:l==="suffix"?`${d(-w)}-`:d(w):c&&w>0?`+${d(w)}`:d(w)};return h.negativeClass=Q.negativeClass||null,h.spec=Q,h}}),xe("packages/core/src/format/date.js",function(e,K){"use strict";Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"toIsoDate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"toIsoDateTime",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"compareIso",{enumerable:!0,get:function(){return n}});const X=K("packages/core/src/internal/util.js"),L=X.isNil,B=X.warnOnce,F=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function W(t){const r=[];let s=0,f="";const u=()=>{f&&(r.push({token:null,text:f}),f="")};for(;s<t.length;){const o=t[s];if(o==="'"){if(t[s+1]==="'"){f+="'",s+=2;continue}const d=t.indexOf("'",s+1);if(d===-1){f+=t.slice(s+1),s=t.length;continue}f+=t.slice(s+1,d),s=d+1;continue}const g=F.find(d=>t.startsWith(d,s));if(g){u(),r.push({token:g,text:g}),s+=g.length;continue}/[A-Za-z]/.test(o)&&B(`date.pattern.token:${o}`,`the date pattern "${t}" contains '${o}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${F.join(" ")}.`),f+=o,s+=1}return u(),r}const Q=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function G(t){if(L(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=Q.exec(t.trim());if(r){const[,f,u,o,g="0",d="0",h="0"]=r;return new Date(+f,+u-1,+o,+g,+d,+h)}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 U(t){if(!t)return f=>({year:f.getFullYear(),month:f.getMonth()+1,day:f.getDate(),hour:f.getHours(),minute:f.getMinutes(),second:f.getSeconds(),ms:f.getMilliseconds(),weekday:f.getDay()});const 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 f=>{const u={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:f.getMilliseconds(),weekday:0};for(const o of r.formatToParts(f))switch(o.type){case"year":u.year=Number(o.value);break;case"month":u.month=Number(o.value);break;case"day":u.day=Number(o.value);break;case"hour":u.hour=Number(o.value)%24;break;case"minute":u.minute=Number(o.value);break;case"second":u.second=Number(o.value);break;case"weekday":u.weekday=s[o.value]??0;break;default:break}return u}}function D(t,r,s){const f=W(t),u=U(s),o=new Set(f.filter(p=>p.token).map(p=>p.token)),g=o.has("MMM")?new Intl.DateTimeFormat(r,{month:"short",timeZone:s}):null,d=o.has("MMMM")?new Intl.DateTimeFormat(r,{month:"long",timeZone:s}):null,h=o.has("EEE")?new Intl.DateTimeFormat(r,{weekday:"short",timeZone:s}):null,a=o.has("EEEE")?new Intl.DateTimeFormat(r,{weekday:"long",timeZone:s}):null;return p=>{const w=u(p);let k="";for(const m of f){if(!m.token){k+=m.text;continue}switch(m.token){case"yyyy":k+=H(w.year,4);break;case"yy":k+=H(w.year%100,2);break;case"MMMM":k+=d.format(p);break;case"MMM":k+=g.format(p);break;case"MM":k+=H(w.month,2);break;case"M":k+=String(w.month);break;case"dd":k+=H(w.day,2);break;case"d":k+=String(w.day);break;case"EEEE":k+=a.format(p);break;case"EEE":k+=h.format(p);break;case"HH":k+=H(w.hour,2);break;case"H":k+=String(w.hour);break;case"hh":k+=H(w.hour%12===0?12:w.hour%12,2);break;case"h":k+=String(w.hour%12===0?12:w.hour%12);break;case"mm":k+=H(w.minute,2);break;case"m":k+=String(w.minute);break;case"ss":k+=H(w.second,2);break;case"s":k+=String(w.second);break;case"SSS":k+=H(w.ms,3);break;case"a":k+=w.hour<12?"AM":"PM";break;default:k+=m.text;break}}return k}}const v=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function S(t,r){const s=t||{},f=s.locale||r||void 0,u=s.nullDisplay??"",o=s.timeZone;let g;if(s.pattern)g=D(s.pattern,f,o);else if(s.dateStyle||s.timeStyle){const w={timeZone:o};s.dateStyle&&(w.dateStyle=s.dateStyle),s.timeStyle&&(w.timeStyle=s.timeStyle);const k=new Intl.DateTimeFormat(f,w);g=m=>k.format(m)}else{const w=new Intl.DateTimeFormat(f,{dateStyle:"medium",timeZone:o});g=k=>w.format(k)}const d=s.relative?new Intl.RelativeTimeFormat(f,{numeric:"auto"}):null,a=(typeof s.relative=="object"&&s.relative?s.relative.threshold??7:7)*24*36e5,p=(w,k)=>{const m=G(w);if(!m)return u;if(d){const b=k&&typeof k.now=="number"?k.now:Date.now(),C=m.getTime()-b;if(Math.abs(C)<a){for(const[M,P]of v)if(Math.abs(C)>=P||M==="second")return d.format(Math.round(C/P),M)}}return g(m)};return p.spec=s,p}function y(t){if(L(t)||t==="")return null;if(typeof t=="string"){const f=/^(\d{4}-\d{2}-\d{2})/.exec(t.trim());if(f)return f[1];const u=G(t);return u?y(u):null}const r=G(t);if(!r)return null;const s=f=>String(f).padStart(2,"0");return`${r.getFullYear()}-${s(r.getMonth()+1)}-${s(r.getDate())}`}function l(t,r){if(L(t)||t==="")return null;if(typeof t=="string"){const f=t.trim();if(c.test(f)){const g=G(f);return g?i(g,r):null}const u=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(f);if(u){const[,g,d,h,a]=u;return`${g}T${d}:${h}${a&&a!=="00"?`:${a}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(f))return`${f}T00:00`;const o=G(f);return o?l(o):null}const s=G(t);return s?i(s,r):null}const c=/(?:Z|[+-]\d{2}:?\d{2})$/i;function i(t,r){const s=g=>String(g).padStart(2,"0");if(r)try{const g=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),{}),d=g.hour==="24"?"00":g.hour,h=Number(g.second);return`${g.year}-${g.month}-${g.day}T${d}:${g.minute}`+(h?`:${g.second}`:"")}catch{}const f=`${t.getFullYear()}-${s(t.getMonth()+1)}-${s(t.getDate())}`,u=t.getSeconds(),o=`${s(t.getHours())}:${s(t.getMinutes())}${u?`:${s(u)}`:""}`;return`${f}T${o}`}function n(t,r){const s=L(t)||t===""?null:String(t),f=L(r)||r===""?null:String(r);return s===null?f===null?0:1:f===null||s<f?-1:s>f?1:0}}),xe("packages/core/src/format/boolean.js",function(e,K){"use strict";Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return Q}});const L=K("packages/core/src/internal/util.js").isNil,B={true:"☑",false:"☐",null:""},F={true:"◉",false:"◯",null:""};function W(G){if(L(G)||G==="")return null;if(typeof G=="boolean")return G;if(typeof G=="number")return G!==0;const H=String(G).trim().toLowerCase();return H==="true"||H==="yes"||H==="y"||H==="1"?!0:H==="false"||H==="no"||H==="n"||H==="0"?!1:null}function Q(G,H){const U=G||{},D=U.display||"text",v=U.trueLabel??"Yes",S=U.falseLabel??"No",y=U.nullLabel??"";let l=v,c=S;const i=y;D==="checkbox"?(l=B.true,c=B.false):D==="switch"?(l=F.true,c=F.false):D==="icon"&&(l=U.trueIcon??v,c=U.falseIcon??S);const n=t=>{const r=W(t);return r===null?i:r?l:c};return n.display=D,n.labels={true:v,false:S,null:y},n.locale=H,n.spec=U,n}}),xe("packages/core/src/format/text.js",function(e,K){"use strict";Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return F}});const X=K("packages/core/src/internal/util.js"),L=X.isNil,B=X.titleCase;function F(W,Q){const G=W||{},H=G.locale||Q||void 0,U=G.nullDisplay??"",D=G.emptyDisplay??"",v=G.transform||"none",S=typeof G.truncate=="number"?{chars:G.truncate}:G.truncate||null,y=S?S.chars:0,l=S?S.ellipsis??"…":"",c=n=>{switch(v){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}},i=n=>{if(L(n))return U;let t=typeof n=="string"?n:String(n);return t===""?D:(v!=="none"&&(t=c(t)),y>0&&t.length>y&&(t=t.slice(0,y)+l),t)};return i.spec=G,i}}),xe("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 F}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return Q}});const X=new Set(["0","#","?",",","."]),L="\0";function B(H){const U=[];let D="",v=!1;for(let S=0;S<H.length;S++){const y=H[S];if(y==="\\"){D+=y+(H[S+1]??""),S+=1;continue}if(y==='"'){v=!v,D+=y;continue}if(y===";"&&!v){U.push(D),D="";continue}D+=y}return U.push(D),U}function F(H){let U="",D="",v="",S=1,y=!1,l=!1;const c=g=>{l?D+=g:U+=g};for(let g=0;g<H.length;g++){const d=H[g];if(d==="\\"){c(H[g+1]??""),g+=1;continue}if(d==='"'){const h=H.indexOf('"',g+1);c(h===-1?H.slice(g+1):H.slice(g+1,h)),g=h===-1?H.length:h;continue}if(d==="%"){S*=100,c("%");continue}if(d==="@"){y=!0,c("\0");continue}if(X.has(d)){v+=d,l=!0;continue}c(d)}let i=-1;for(let g=v.length-1;g>=0;g--){const d=v[g];if(d==="0"||d==="#"||d==="?"){i=g;break}}let n=!1,t="";for(let g=0;g<v.length;g++){const d=v[g];if(d===","){g>i?S/=1e3:n=!0;continue}t+=d}const r=t.indexOf("."),s=r===-1?t:t.slice(0,r),f=r===-1?"":t.slice(r+1);let u=0;for(const g of s)g==="0"&&(u+=1);let o=0;for(const g of f)g==="0"&&(o+=1);return{prefix:U,suffix:D,minInt:u,minDec:o,maxDec:f.length,grouping:n,scale:S,hasNumber:i!==-1,isText:y}}function W(H,U){const D=new Intl.NumberFormat(U,{minimumIntegerDigits:Math.max(H.minInt,1),minimumFractionDigits:H.minDec,maximumFractionDigits:Math.max(H.maxDec,H.minDec),useGrouping:H.grouping}),{prefix:v,suffix:S,scale:y,hasNumber:l}=H;return c=>{if(!l)return v+S;const i=y===1?c:c*y;return v+D.format(i)+S}}function Q(H,U){const v=B(String(H)).map(F),S=v.map(t=>W(t,U)),y=0,l=v.length>1?1:-1,c=v.length>2?2:-1,i=v.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 i===-1?String(t):(v[i].prefix+v[i].suffix).split("\0").join(String(t));t=r}return t===0&&c!==-1?S[c](0):t<0&&l!==-1?S[l](-t):S[y](t)};return n.spec={mask:H},{format:n,ooxml:G(String(H))}}function G(H){return H.trim()}}),xe("packages/core/src/format/shorthand.js",function(e,K){"use strict";Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return G}});const X=["currency","number","percent","date","boolean","text","relative"],L=/[#0?@;"\\]/,B=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function F(H){return typeof H!="string"||H===""||Q(H)?!1:L.test(H)}function W(H){return typeof H!="string"||H===""||Q(H)?!1:B.test(H)}function Q(H){const U=H.indexOf(":"),D=U===-1?H:H.slice(0,U);return X.includes(D)?D:null}function G(H){const U=Q(H);if(!U)return null;const D=H.indexOf(":"),v=D===-1?"":H.slice(D+1),S=v===""?[]:v.split(":");switch(U){case"currency":{const y={type:"number",style:"currency",currency:S[0]||"USD"};return S[1]!==void 0&&S[1]!==""&&(y.decimals=Number(S[1])),y}case"number":{const y={type:"number",style:"decimal"};return S[0]!==void 0&&S[0]!==""&&(y.decimals=Number(S[0])),y}case"percent":{const y={type:"number",style:"percent"};return S[0]!==void 0&&S[0]!==""&&(y.decimals=Number(S[0])),y}case"date":return{type:"date",pattern:v||void 0};case"relative":return{type:"date",relative:!0};case"boolean":{const y=v.split("/"),l={type:"boolean",display:"text"};return y[0]!==void 0&&y[0]!==""&&(l.trueLabel=y[0]),y[1]!==void 0&&y[1]!==""&&(l.falseLabel=y[1]),y[2]!==void 0&&(l.nullLabel=y[2]),l}case"text":{const y={type:"text"};return S[0]&&(y.transform=S[0]),S[1]!==void 0&&S[1]!==""&&(y.truncate=Number(S[1])),y}default:return null}}}),xe("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 k}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.isObject,F=X.warnOnce,W=K("packages/core/src/format/number.js"),Q=W.compileNumber,G=K("packages/core/src/format/date.js"),H=G.compileDate,U=G.scanPattern,D=K("packages/core/src/format/boolean.js"),v=D.compileBoolean,S=K("packages/core/src/format/text.js"),y=S.compileText,l=K("packages/core/src/format/mask.js"),c=l.compileMask,i=K("packages/core/src/format/shorthand.js"),n=i.parseShorthand,t=i.looksLikeMask,r=i.looksLikeDatePattern;Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return W.compileNumber}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return G.compileDate}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return G.compilePattern}}),Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return G.scanPattern}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return G.toDate}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return D.compileBoolean}}),Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return D.toTriState}}),Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return S.compileText}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return l.compileMask}}),Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return l.splitSections}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return l.parseSection}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return i.parseShorthand}}),Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return i.looksLikeMask}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return i.looksLikeDatePattern}});const s=new Set(["decimal","currency","percent","unit"]),f=new Set(["type","locale"]),u={number:new Set(["style","currency","currencyDisplay","decimals","minDecimals","maxDecimals","thousandsSeparator","decimalSeparator","notation","compactDisplay","negative","negativeClass","signed","prefix","suffix","zeroDisplay","nullDisplay","messages","scale"]),date:new Set(["pattern","dateStyle","timeStyle","timeZone","relative","nullDisplay"]),boolean:new Set(["display","trueLabel","falseLabel","nullLabel","trueIcon","falseIcon"]),text:new Set(["transform","truncate","nullDisplay","emptyDisplay"])},o=new Set(["number","date","boolean","text"]);function g(M,P){const x=M.type;if(x===void 0||o.has(x)||!s.has(String(x)))return;const E=P?`"${P}"`:"with no id";F(`format:unknown-style-key:${P||""}:${x}`,`column ${E} 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 d(M,P,x){const E=u[P],A=x?`"${x}"`:"with no id";for(const j of M){if(f.has(j)||E.has(j))continue;const $=Object.keys(u).find(z=>z!==P&&u[z].has(j));$?F(`format:inapplicable:${x||""}:${j}`,`column ${A} has format key "${j}", which applies to a ${$} column, not the ${P} column it was applied to; it is ignored.`):F(`format:unknown:${x||""}:${j}`,`column ${A} has an unrecognised format key "${j}" for its ${P} format; it is ignored.`)}}function h(M){if(M.type==="number"||M.type==="date"||M.type==="boolean"||M.type==="text")return!0;const P=s.has(String(M.style));return!!(M.pattern||M.dateStyle||M.timeStyle||M.relative||M.timeZone||M.trueLabel||M.falseLabel||M.display||M.trueIcon||M.falseIcon||M.transform||M.truncate||M.emptyDisplay||P||M.currency||M.decimals!==void 0||M.minDecimals!==void 0||M.maxDecimals!==void 0||M.notation||M.negative||M.scale!==void 0||M.prefix||M.suffix||M.zeroDisplay!==void 0)}function a(M,P){if(M.type==="number"||M.type==="date"||M.type==="boolean"||M.type==="text")return M.type;if(M.pattern||M.dateStyle||M.timeStyle||M.relative||M.timeZone)return"date";if(M.trueLabel||M.falseLabel||M.display||M.trueIcon||M.falseIcon)return"boolean";if(M.transform||M.truncate||M.emptyDisplay)return"text";if(M.style||M.currency||M.decimals!==void 0||M.minDecimals!==void 0||M.maxDecimals!==void 0||M.notation||M.negative||M.scale!==void 0||M.prefix||M.suffix||M.zeroDisplay!==void 0)return"number";const x=P&&P.base;return x==="number"?"number":x==="date"||x==="dateString"?"date":x==="boolean"?"boolean":"text"}function p(M,P=null,x=void 0,E=void 0,A=void 0){if(M==null||M==="")return null;const j=B(M)?Object.keys(M):null;if(typeof M=="function"){const T=(R,O)=>String(M({...O||{},value:R,locale:x})??"");return T.ooxml=P&&P.excel||"General",T}if(typeof M=="string"){if(t(M)){const{format:R,ooxml:O}=c(M,x);return R.ooxml=O,R}const T=n(M)||(r(M)?{type:"date",pattern:M}:null);return T?p(T,P,x,E,A):(F(`format:${M}`,`unrecognised format string "${M}"; the value will be stringified`),null)}if(!B(M))return F("format:shape","format must be a spec object or a string; ignoring",M),null;if(P&&L(P.format)&&!h(M)||P&&L(P.format)&&Array.isArray(P.formatPatterns)&&M.type===void 0)return null;const $=a(M,P);$==="date"&&E&&M.timeZone===void 0&&(M={...M,timeZone:E}),g(M,A),d(j||Object.keys(M),$,A);let z;switch($){case"number":z=Q(M,x);break;case"date":z=H(M,x);break;case"boolean":z=v(M,x);break;default:z=y(M,x);break}return z.ooxml=k(M,$,x,P),z.kind=$,z}const w={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 k(M,P,x=void 0,E=null){if(P==="date"){if(M.pattern){let T="";for(const R of U(M.pattern))T+=R.token?w[R.token]??R.text:R.text;return T}return E&&E.excel||"yyyy-mm-dd"}if(P==="boolean")return"General";if(P==="text")return"@";if(M.notation==="compact"||M.notation==="scientific")return"General";const A=typeof M.decimals=="number"?M.decimals:typeof M.minDecimals=="number"?M.minDecimals:M.style==="currency"?2:0;let $=`${M.thousandsSeparator===!1?"":"#,#"}#0${A>0?`.${"0".repeat(A)}`:""}`,z="";return M.style==="currency"&&(z+=m(C(M.currency||"USD",x))),M.prefix&&(z+=m(M.prefix)),$=z+$,M.style==="percent"&&($=`${$}%`),M.suffix&&($+=m(M.suffix)),M.negative==="parentheses"?`${$};(${$})`:M.negative==="suffix"?`${$};${$}-`:$}function m(M){return`"${String(M).split('"').join("")}"`}const b=new Map;function C(M,P){const x=`${M}|${P||""}`;let E=b.get(x);if(E!==void 0)return E;E=M;try{const j=new Intl.NumberFormat(P,{style:"currency",currency:M}).formatToParts(0).find($=>$.type==="currency");j&&(E=j.value)}catch{}return b.set(x,E),E}}),xe("packages/core/src/columns/types/temporal.js",function(e,K){"use strict";Object.defineProperty(e,"MS_SECOND",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"MS_MINUTE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"MS_HOUR",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"MS_DAY",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MS_WEEK",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toTimeMs",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"zonedParts",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"zoneOffsetAt",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"instantFromParts",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"toEpochMs",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"toDurationMs",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return le}}),Object.defineProperty(e,"zoneAbbrev",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"resolveZoneName",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"timestampGroupProjector",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(e,"TEMPORAL_INFERENCE_ORDER",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Qe}});const X=K("packages/core/src/internal/util.js"),L=X.isNil,B=X.isFunction,F=K("packages/core/src/format/date.js"),W=F.toDate,Q=F.compilePattern,G=F.compileDate,H=F.toIsoDateTime,U=F.compareIso,D=864e5,v=Object.freeze({}),S=1e3,y=60*S,l=60*y,c=24*l,i=7*c,n=new WeakMap;function t(Te,_e){const Ke=Te&&Te.locale||"",tt=Te&&Te.column;if(!tt)return Ke?{locale:Ke}:v;const it=n.get(tt);if(it&&it.locale===Ke)return it.bag;const ht=tt.typeOptions||tt[_e]||(r(tt.format)?tt.format:null),yt={...ht||v,locale:ht&&ht.locale||Ke||void 0};return n.set(tt,{locale:Ke,bag:yt}),yt}function r(Te){return Te!==null&&typeof Te=="object"&&!Array.isArray(Te)&&!(Te instanceof Date)}function s(Te,_e){const Ke=Te===null||Number.isNaN(Te)?null:Te,tt=_e===null||Number.isNaN(_e)?null:_e;return Ke===null?tt===null?0:1:tt===null||Ke<tt?-1:Ke>tt?1:0}const f=/^(\d{1,2})(?:\s*[:.h]\s*(\d{1,2})(?:\s*[:.]\s*(\d{1,2})(?:[.,](\d{1,3}))?)?)?\s*(a\.?m\.?|p\.?m\.?|a|p)?$/i,u=/^(\d{3,6})$/;function o(Te,_e,Ke,tt){return!(Te>=0&&Te<=23)||!(_e>=0&&_e<=59)||!(Ke>=0&&Ke<=59)||!(tt>=0&&tt<=999)?null:Te*l+_e*y+Ke*S+tt}function g(Te){if(L(Te))return null;const _e=String(Te).trim();if(_e==="")return null;const Ke=u.exec(_e);if(Ke){const Ct=Ke[1];if(Ct.length===5)return null;const Tt=Ct.length===3?1:2;return o(Number(Ct.slice(0,Tt)),Number(Ct.slice(Tt,Tt+2)),Number(Ct.slice(Tt+2,Tt+4)||0),0)}const tt=f.exec(_e);if(!tt)return null;let it=Number(tt[1]);const ht=Number(tt[2]||0),yt=Number(tt[3]||0),St=tt[4]?Number(tt[4].padEnd(3,"0")):0,At=tt[5]?tt[5][0].toLowerCase():null;if(At){if(it<1||it>12)return null;it=it%12,At==="p"&&(it+=12)}return o(it,ht,yt,St)}function d(Te){return L(Te)||Te===""?null:typeof Te=="number"?Number.isFinite(Te)?(Te%c+c)%c:null:Te instanceof Date?Number.isNaN(Te.getTime())?null:Te.getHours()*l+Te.getMinutes()*y+Te.getSeconds()*S+Te.getMilliseconds():g(Te)}const h=new Map;function a(Te){const _e=Te.pattern||"",Ke=Te.timeStyle||(Te.seconds?"medium":"short"),tt=`${Te.locale||""}|${_e}|${Ke}`;let it=h.get(tt);if(it)return it;if(_e)it=Q(_e,Te.locale||void 0,"UTC");else{const ht=new Intl.DateTimeFormat(Te.locale||void 0,{timeStyle:Ke,timeZone:"UTC"});it=yt=>ht.format(yt)}return h.set(tt,it),it}function p(Te,_e){const Ke=_e||v;if(Te==null||typeof Te!="number"||!Number.isFinite(Te))return Ke.nullDisplay??"";const tt=(Te%c+c)%c;return a(Ke)(new Date(tt))}function w(Te){return Te instanceof Date?!Number.isNaN(Te.getTime()):typeof Te=="number"?Number.isFinite(Te)&&Te>=0&&Te<c:typeof Te!="string"||!Te.includes(":")?!1:g(Te)!==null}function k(Te){const _e=d(Te);return _e==null?"":p(_e,{pattern:_e%S===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const m=new Map;function b(Te){const _e=Te||"";let Ke=m.get(_e);return Ke||(Ke=new Intl.DateTimeFormat("en-GB",{timeZone:Te||void 0,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),m.set(_e,Ke)),Ke}function C(Te,_e){const Ke={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const tt of b(_e).formatToParts(new Date(Te)))tt.type==="year"?Ke.year=Number(tt.value):tt.type==="month"?Ke.month=Number(tt.value):tt.type==="day"?Ke.day=Number(tt.value):tt.type==="hour"?Ke.hour=Number(tt.value)%24:tt.type==="minute"?Ke.minute=Number(tt.value):tt.type==="second"&&(Ke.second=Number(tt.value));return Ke}function M(Te,_e){const Ke=C(Te,_e);return Date.UTC(Ke.year,Ke.month-1,Ke.day,Ke.hour,Ke.minute,Ke.second,0)-Math.floor(Te/1e3)*1e3}function P(Te,_e){const Ke=Te.hour||0,tt=Te.minute||0,it=Te.second||0,ht=Te.ms||0;if(!_e)return new Date(Te.year,Te.month-1,Te.day,Ke,tt,it,ht).getTime();const yt=Date.UTC(Te.year,Te.month-1,Te.day,Ke,tt,it,ht);let St=yt-M(yt,_e);return St=yt-M(St,_e),St}const x=/(?:Z|[+-]\d{2}:?\d{2})$/i,E=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function A(Te,_e){if(L(Te))return null;const Ke=String(Te).trim();if(Ke==="")return null;const tt=_e&&_e.timeZone||void 0;if(!x.test(Ke)){const it=E.exec(Ke);if(it){const ht=(it[4]||"").trim(),yt=ht===""?0:g(ht);if(yt===null)return null;const St=P({year:Number(it[1]),month:Number(it[2]),day:Number(it[3]),hour:Math.floor(yt/l),minute:Math.floor(yt/y)%60,second:Math.floor(yt/S)%60,ms:yt%S},tt);return Number.isNaN(St)?null:new Date(St)}}return W(Ke)}function j(Te){if(typeof Te=="number")return Number.isFinite(Te)?Te:null;const _e=W(Te);return _e?_e.getTime():null}const $=new Map;function z(Te){const _e=[Te.locale||"",Te.pattern||"",Te.dateStyle||"",Te.timeStyle||"",Te.timeZone||"",Te.seconds?"1":""].join("|");let Ke=$.get(_e);if(Ke)return Ke;const tt=Te.pattern?{type:"date",pattern:Te.pattern,timeZone:Te.timeZone}:{type:"date",dateStyle:Te.dateStyle||"medium",timeStyle:Te.timeStyle||(Te.seconds?"medium":"short"),timeZone:Te.timeZone};return Ke=G(tt,Te.locale||void 0),$.set(_e,Ke),Ke}function T(Te,_e){const Ke=_e||v,tt=j(Te);return tt==null?Ke.nullDisplay??"":z(Ke)(tt)}function R(Te){return Te instanceof Date?!Number.isNaN(Te.getTime()):typeof Te!="string"||!E.test(Te.trim())?!1:A(Te)!==null}const O=Object.freeze([{key:"w",ms:i,intl:"week",long:["week","weeks"],names:["w","wk","wks","week","weeks"]},{key:"d",ms:c,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:y,intl:"minute",long:["minute","minutes"],names:["m","min","mins","minute","minutes"]},{key:"s",ms:S,intl:"second",long:["second","seconds"],names:["s","sec","secs","second","seconds"]},{key:"ms",ms:1,intl:"millisecond",long:["millisecond","milliseconds"],names:["ms","msec","msecs","milli","millis","millisecond","milliseconds"]}]),I=new Map;for(const Te of O)for(const _e of Te.names)I.set(_e,Te);const q=Object.freeze(O.filter(Te=>Te.key!=="w")),Z=/^(\d+(?:\.\d+)?)\s*([a-z]+)\s*(?:,\s*)?/,_=/^\d+(?:\.\d+)?$/,J=/^(\d+):([0-5]?\d)(?::([0-5]?\d))?(?:\.(\d{1,3}))?$/;function ee(Te){const _e=Te&&Te.defaultUnit?I.get(String(Te.defaultUnit).toLowerCase()):null;return _e?_e.ms:y}function te(Te){return(Te&&Te.defaultUnit?I.get(String(Te.defaultUnit).toLowerCase()):null)||I.get("m")}function ne(Te,_e){if(L(Te))return null;let Ke=String(Te).trim().toLowerCase();if(Ke==="")return null;let tt=1;if(Ke[0]==="-"?(tt=-1,Ke=Ke.slice(1).trim()):Ke[0]==="+"&&(Ke=Ke.slice(1).trim()),Ke==="")return null;const it=J.exec(Ke);if(it){const At=it[3]!==void 0,Ct=Number(it[1])*l+Number(it[2])*y+(At?Number(it[3])*S:0)+(it[4]?Number(it[4].padEnd(3,"0")):0);return tt*Ct}if(_.test(Ke))return Math.round(tt*Number(Ke)*ee(_e||v));let ht=Ke,yt=0,St=0;for(;ht!=="";){const At=Z.exec(ht);if(!At)return null;const Ct=I.get(At[2]);if(!Ct)return null;yt+=Number(At[1])*Ct.ms,ht=ht.slice(At[0].length),St++}return St===0?null:Math.round(tt*yt)}function ie(Te){return L(Te)||Te===""?null:typeof Te=="number"?Number.isFinite(Te)?Te:null:ne(Te)}const ae=new Map;function re(Te,_e,Ke){const tt=`${Ke||""}|${_e.intl}`;let it=ae.get(tt);if(it===void 0){try{it=new Intl.NumberFormat(Ke||void 0,{style:"unit",unit:_e.intl,unitDisplay:"long"})}catch{it=null}ae.set(tt,it)}return it?it.format(Te):`${Te} ${Te===1?_e.long[0]:_e.long[1]}`}function se(Te,_e){return String(Te).padStart(_e,"0")}function le(Te,_e){const Ke=_e||v;if(Te==null||typeof Te!="number"||!Number.isFinite(Te))return Ke.nullDisplay??"";const tt=Ke.style||"short",it=Te<0;let ht=Math.round(Math.abs(Te));const yt=it?"-":"";if(ht===0&&Ke.zeroDisplay!=null)return Ke.zeroDisplay;if(tt==="clock"){const Tt=Math.floor(ht/l),Dt=Math.floor(ht/y)%60,Bt=Math.floor(ht/S)%60;return`${yt}${se(Tt,2)}:${se(Dt,2)}:${se(Bt,2)}`}if(ht===0){const Tt=te(Ke);return tt==="long"?re(0,Tt,Ke.locale):`0${Tt.key}`}const St=Ke.weeks===!0?O:q,At=typeof Ke.maxUnits=="number"&&Ke.maxUnits>0?Ke.maxUnits:Ke.maxUnits===void 0?2:1/0,Ct=[];for(const Tt of St){if(Ct.length>=At)break;const Dt=Math.floor(ht/Tt.ms);Dt!==0&&(ht-=Dt*Tt.ms,Ct.push(tt==="long"?re(Dt,Tt,Ke.locale):`${Dt}${Tt.key}`))}return yt+Ct.join(" ")}function fe(Te){if(typeof Te!="string")return!1;const _e=Te.trim();return _e===""||J.test(_e)||!/[a-z]/i.test(_e)?!1:ne(_e)!==null}const be=Date.UTC(1899,11,30),Le=new Map;function we(Te,_e){const Ke=Te||"";let tt=Le.get(Ke);tt||(tt=new Intl.DateTimeFormat("en-GB",{timeZone:Te||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),Le.set(Ke,tt));const it=typeof _e=="number"?_e:Date.now();for(const ht of tt.formatToParts(new Date(it)))if(ht.type==="timeZoneName")return ht.value;return""}function Re(Te){if(Te)return Te;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function ge(Te,_e){const Ke=Re(Te),tt=we(Te,_e);return tt?`${Ke} (${tt})`:Ke}function he(Te,_e){if(Te&&Te.timeZone)return Te.timeZone;const Ke=_e&&_e.grid;return(Ke&&B(Ke.get)?Ke.get("timeZone"):void 0)||void 0}function Oe(Te,_e){const Ke=_e||v,tt=j(Te);if(tt==null)return Ke.nullDisplay??"";const it=z(Ke)(tt);if(!Ke.showOrigin)return it;const ht=Ke.originZone;return ht?ht===(Ke.timeZone||Re(Ke.timeZone))?it:`${it} (${ge(ht,tt)})`:`${it} (no origin recorded)`}function Ee(Te,_e,Ke,tt){if(_e==="instant"||!_e)return Te;const it=C(Te,Ke);if(_e==="month")return P({year:it.year,month:it.month,day:1},Ke);if(_e==="week"){const ht=tt>=1&&tt<=7?tt:1,St=((new Date(Date.UTC(it.year,it.month-1,it.day)).getUTCDay()+6)%7+1-ht+7)%7,At=new Date(Date.UTC(it.year,it.month-1,it.day-St));return P({year:At.getUTCFullYear(),month:At.getUTCMonth()+1,day:At.getUTCDate()},Ke)}return P({year:it.year,month:it.month,day:it.day},Ke)}function Ie(Te,_e){const Ke=Te&&Te.group,tt=Ke&&Ke.granularity||"day";if(tt==="instant")return null;const it=Ke&&Ke.weekStart;return ht=>typeof ht=="number"?Ee(ht,tt,_e,it):ht}const ze={time:{base:"number",storage:"float64",matches:w,format:Te=>p(d(Te.value),t(Te,"time")),parse:Te=>g(Te.text),compare:(Te,_e)=>s(d(Te),d(_e)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:Te=>{const _e=d(Te);return _e===null?null:_e/D},toStorage:Te=>d(Te),toClipboard:k,fromClipboard:g},datetime:{base:"dateString",storage:"dictionary",matches:R,format:Te=>T(Te.value,t(Te,"datetime")),parse:Te=>H(A(Te.text,t(Te,"datetime"))??Te.text),compare:U,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(Te,_e)=>H(Te,_e&&_e.timeZone),toClipboard:Te=>L(Te)?"":String(Te),fromClipboard:Te=>H(Te)},duration:{base:"number",storage:"float64",matches:fe,format:Te=>le(ie(Te.value),t(Te,"duration")),parse:Te=>ne(Te.text,t(Te,"duration")),compare:(Te,_e)=>s(ie(Te),ie(_e)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:Te=>{const _e=ie(Te);return _e===null?null:_e/D},toStorage:Te=>ie(Te),toClipboard:Te=>le(ie(Te),{style:"short",maxUnits:-1}),fromClipboard:Te=>ne(Te)},timestamp:{base:"number",storage:"float64",format:Te=>{const _e=t(Te,"timestamp");return Oe(Te.value,{..._e,timeZone:he(_e,Te)})},parse:Te=>{const _e=t(Te,"timestamp"),Ke=A(Te.text,{timeZone:he(_e,Te)});return Ke?Ke.getTime():null},compare:(Te,_e)=>s(j(Te),j(_e)),groupProjector:(Te,_e)=>Ie(Te,_e),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(Te,_e)=>{const Ke=j(Te);if(Ke==null)return null;const tt=C(Ke,_e&&_e.timeZone||void 0);return(Date.UTC(tt.year,tt.month-1,tt.day,tt.hour,tt.minute,tt.second)-be)/D},toStorage:Te=>j(Te),toClipboard:Te=>{const _e=j(Te);return _e==null?"":new Date(_e).toISOString()},fromClipboard:Te=>j(Te)}},Ye=["datetime","time","duration"],Qe=ze}),xe("packages/core/src/columns/types/network.js",function(e,K){"use strict";Object.defineProperty(e,"toUint32",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"isIpv4",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"compareIpv4",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"packCidr",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"cidrParts",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return i}}),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 f}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"addressCount",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ipv6Groups",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"isIpv6",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return A}});const X=K("packages/core/src/internal/util.js"),L=X.isNil,B=X.Lru,F=4294967295,W=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function Q(j){if(L(j))return null;if(typeof j=="string")return G(j);const $=Number(j);return Number.isFinite($)?$<0?$<-2147483648?null:$>>>0:$>F?null:Math.trunc($)>>>0:null}function G(j){if(L(j))return null;const $=String(j).trim();if($==="")return null;const z=W.exec($);if(!z)return null;let T=0;for(let R=1;R<=4;R++){const O=z[R];if(O.length>1&&O.charCodeAt(0)===48)return null;const I=Number(O);if(I>255)return null;T=T*256+I}return T}function H(j){const $=Q(j);return $===null?"":`${$>>>24&255}.${$>>>16&255}.${$>>>8&255}.${$&255}`}function U(j){return typeof j=="string"&&G(j)!==null}function D(j,$){const z=Q(j),T=Q($);return z===null?T===null?0:1:T===null||z<T?-1:z>T?1:0}const v=64,S=F*v+32,y=/^(?:0|[1-9]\d?)$/;function l(j,$){return j*v+$}function c(j){if(L(j))return null;if(typeof j=="string"){const T=i(j);return T===null?null:c(T)}if(typeof j=="object"){const T=Q(j.address),R=Number(j.prefix);return T===null||!Number.isInteger(R)||R<0||R>32?null:{address:T,prefix:R}}const $=Number(j);if(!Number.isInteger($)||$<0||$>S)return null;const z=$%v;return z>32?null:{address:($-z)/v,prefix:z}}function i(j){if(L(j))return null;const $=String(j).trim();if($==="")return null;const z=$.indexOf("/");if(z<0)return null;const T=G($.slice(0,z));if(T===null)return null;const R=$.slice(z+1).trim();if(!y.test(R))return null;const O=Number(R);return O>32?null:l(T,O)}function n(j){const $=c(j);return $?`${H($.address)}/${$.prefix}`:""}function t(j){return typeof j=="string"&&i(j)!==null}function r(j,$){const z=c(j),T=c($);return z?T?z.address!==T.address?z.address<T.address?-1:1:z.prefix-T.prefix:-1:T?1:0}function s(j){return j===0?0:4294967295<<32-j>>>0}function f(j){const $=c(j);return $?($.address&s($.prefix))>>>0:null}function u(j){const $=c(j);return $?($.address&s($.prefix)|~s($.prefix)>>>0)>>>0:null}function o(j){const $=c(j);return $?2**(32-$.prefix):null}function g(j){const $=c(j);return $?$.prefix===32?1:$.prefix===31?2:2**(32-$.prefix)-2:null}function d(j,$){const z=c(j);if(!z)return!1;const T=Q($);if(T===null)return!1;const R=s(z.prefix);return(T&R)>>>0===(z.address&R)>>>0}function h(j,$){const z=f(j),T=f($);return z===null||T===null?!1:z<=u($)&&T<=u(j)}const a=/^[0-9a-fA-F]{1,4}$/,p=new B(512);function w(j){if(L(j))return null;let $=String(j).trim();if($==="")return null;const z=$.indexOf("%");if(z>=0&&($=$.slice(0,z)),$==="")return null;if($.indexOf(".")>=0){const Z=$.lastIndexOf(":");if(Z<0)return null;const _=G($.slice(Z+1));if(_===null)return null;$=`${$.slice(0,Z+1)}${(_>>>16&65535).toString(16)}:${(_&65535).toString(16)}`}const T=$.split("::");if(T.length>2)return null;const R=k(T[0]);if(R===null)return null;if(T.length===1)return R.length===8?R:null;const O=k(T[1]);if(O===null)return null;const I=8-R.length-O.length;if(I<1)return null;const q=R.slice();for(let Z=0;Z<I;Z++)q.push(0);for(const Z of O)q.push(Z);return q}function k(j){if(j==="")return[];const $=[];for(const z of j.split(":")){if(!a.test(z))return null;$.push(parseInt(z,16))}return $}function m(j){if(typeof j!="string")return w(j);if(p.has(j))return p.get(j);const $=w(j);return p.set(j,$),$}function b(j){if(j[0]===0&&j[1]===0&&j[2]===0&&j[3]===0&&j[4]===0&&j[5]===65535)return`::ffff:${H((j[6]<<16|j[7])>>>0)}`;let $=-1,z=0,T=-1,R=0;for(let q=0;q<8;q++)j[q]===0?(T<0?(T=q,R=1):R++,R>z&&(z=R,$=T)):(T=-1,R=0);if(z<2)return j.map(q=>q.toString(16)).join(":");const O=j.slice(0,$).map(q=>q.toString(16)).join(":"),I=j.slice($+z).map(q=>q.toString(16)).join(":");return`${O}::${I}`}function C(j){const $=w(j);return $===null?null:b($)}function M(j){return C(j)??""}function P(j){return typeof j=="string"&&j.indexOf(":")>=0&&w(j)!==null}function x(j,$){const z=m(j),T=m($);if(!z)return T?1:0;if(!T)return-1;for(let R=0;R<8;R++)if(z[R]!==T[R])return z[R]<T[R]?-1:1;return 0}const E=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:U,parse:j=>G(j.text),compare:D,format:j=>H(j.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:j=>Q(j),toClipboard:j=>H(j),fromClipboard:j=>G(j)},cidr:{base:"number",storage:"float64",matches:t,parse:j=>i(j.text),compare:r,format:j=>n(j.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:j=>{const $=c(j);return $===null?null:l($.address,$.prefix)},toClipboard:j=>n(j),fromClipboard:j=>i(j)},ipv6:{base:"text",storage:"dictionary",matches:P,parse:j=>C(j.text),compare:x,format:j=>M(j.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",toStorage:j=>C(j),toClipboard:j=>M(j),fromClipboard:j=>C(j)}}),A=E}),xe("packages/core/src/i18n/catalogue.js",function(e,K){"use strict";Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return L}});const X=Object.freeze({"count.rows":{one:"{count} row",other:"{count} rows"},"count.comments":{one:"{count} comment",other:"{count} comments"},"comments.someUnresolved":"{comments}, {unresolved} unresolved","comments.allResolved":"{comments}, all resolved","count.unresolvedComments":{one:"{count} unresolved comment",other:"{count} unresolved comments"},"count.items":{one:"{count} item",other:"{count} items"},"count.keys":{one:"{count} key",other:"{count} keys"},"count.values":{one:"value",other:"values"},"count.waiting":{one:"{count} waiting",other:"{count} waiting"},"count.rowsAdded":{one:"{count} row added",other:"{count} rows added"},"count.rowsRemoved":{one:"{count} row removed",other:"{count} rows removed"},"value.empty":"empty","a11y.sort.cleared":"Sort cleared","a11y.sort.by":"Sorted by {columns}","a11y.sort.column":"{column} {direction}","a11y.sort.ascending":"ascending","a11y.sort.descending":"descending","a11y.filter.cleared":"Filter cleared, {rows}","a11y.filter.applied":"Filtered to {shown} of {total}","a11y.find.count":{one:"{current} of {count} match",other:"{current} of {count} matches"},"a11y.find.countLoaded":{one:"{current} of {count} match in loaded rows",other:"{current} of {count} matches in loaded rows"},"a11y.find.none":"No matches","a11y.find.noneLoaded":"No matches in loaded rows","a11y.selection.cleared":"Selection cleared","a11y.selection.count":{one:"{count} row selected",other:"{count} rows selected"},"tabs.tablist":"Tabs","a11y.tabs.selected":"{label} tab selected","a11y.scrollbar.horizontal":"Horizontal scrollbar","a11y.scrollbar.vertical":"Vertical scrollbar","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","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"},"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","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":"Next / previous cell, wrapping across rows","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.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","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.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.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.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.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.geomap":"Map","chart.type.sankey":"Sankey","chart.type.chord":"Chord","chart.type.network":"Network","chart.type.stream":"Stream","chart.type.marimekko":"Marimekko","chart.type.violin":"Violin","chart.type.gantt":"Gantt","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"}),L=Object.freeze(Object.keys(X))}),xe("packages/core/src/i18n/format.js",function(e,K){"use strict";Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"formatMessage",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"lookup",{enumerable:!0,get:function(){return S}});const L=K("packages/core/src/internal/util.js").isFunction,B=/\{(\w+)\}/g,F=new Map,W=new Map;function Q(y){const l=y||"";if(F.has(l))return F.get(l);let c=null;try{c=new Intl.PluralRules(y||void 0)}catch{c=null}return F.set(l,c),c}function G(y,l,c="conjunction"){const i=Array.isArray(y)?y.filter(r=>r!=null&&r!==""):[];if(i.length===0)return"";if(i.length===1)return String(i[0]);const n=`${l||""}|${c}`;let t=W.get(n);if(t===void 0){try{t=new Intl.ListFormat(l||void 0,{style:"long",type:c})}catch{t=null}W.set(n,t)}return t?t.format(i.map(String)):i.map(String).join(", ")}function H(y,l){return y==null?"":typeof y=="number"?Number.isFinite(y)?y.toLocaleString(l||void 0,{maximumFractionDigits:20}):"":String(y)}function U(y,l,c){if(typeof y=="string")return y;if(!y||typeof y!="object")return"";const i=l&&typeof l.count=="number"?l.count:null;if(i===null)return y.other??"";const n=Q(c),t=n?n.select(i):i===1?"one":"other";return y[t]??y.other??""}function D(y,l={},c){const i=U(y,l,c);return i?i.replace(B,(n,t)=>Object.prototype.hasOwnProperty.call(l,t)?H(l[t],c):n):""}function v(y,l,c="en-GB"){return typeof y=="string"&&y?y:typeof l=="string"&&l?l:c}function S(y,l){const c=y?y[l]:void 0;return c==null||L(c)?l:c}}),xe("packages/core/src/i18n/index.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"defaultMessages",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return i}});const X=K("packages/core/src/i18n/catalogue.js"),L=X.EN_GB,B=X.MESSAGE_KEYS,F=K("packages/core/src/i18n/format.js"),W=F.formatMessage,Q=F.formatList,G=F.lookup,H=F.resolveLocale,U=K("packages/core/src/internal/util.js"),D=U.isFunction,v=U.warnOnce;Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return X.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return X.MESSAGE_KEYS}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return F.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return F.resolveLocale}});const S="en-GB";class y{#e=S;#t=L;constructor(t={}){this.configure(t)}configure(t={}){this.#e=H(t.locale,t.declared,S);const r=t.messages;if(!r||typeof r!="object"){this.#t=L;return}const s=Object.keys(r).filter(f=>!(f in L));s.length&&v(`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={...L,...r}}get locale(){return this.#e}t(t,r){return W(G(this.#t,t),r||{},this.#e)}list(t,r){return Q(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 y;function c(n){return n instanceof y?n:new y(n||{})}function i(n){const t=n&&typeof n=="object"?n:{},r=B.filter(f=>{const u=t[f];return u==null||u===""||D(u)}),s=Object.keys(t).filter(f=>!(f in L));return{missing:r,unknown:s}}}),xe("packages/core/src/columns/types/structured.js",function(e,K){"use strict";Object.defineProperty(e,"MASK_DEFAULTS",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"canonicalJson",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"parseJsonText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const X=K("packages/core/src/internal/util.js"),L=X.isNil,B=X.isObject,W=K("packages/core/src/i18n/index.js").defaultMessages,Q=Object.freeze({char:"•",length:8,fixedLength:!0,lastVisible:0,emptyDisplay:""});function G(n,t){const r=t||{},s=r.emptyDisplay??Q.emptyDisplay;if(L(n)||n==="")return s;const u=[...typeof r.char=="string"&&r.char!==""?r.char:Q.char][0]||Q.char,o=r.fixedLength??Q.fixedLength,g=Number.isFinite(r.length)&&Number(r.length)>0?Math.floor(Number(r.length)):Q.length,d=typeof n=="string"?n:typeof n=="number"||typeof n=="boolean"||typeof n=="bigint"?String(n):null;let h=0;if(d!==null){const a=Number.isFinite(r.lastVisible)?Math.floor(Number(r.lastVisible)):Q.lastVisible,p=[...d];if(h=a>0&&a<p.length?a:0,h>0){const w=p.slice(p.length-h).join(""),k=Math.max(1,(o?g:p.length)-h);return u.repeat(k)+w}return u.repeat(o?g:Math.max(1,p.length))}return u.repeat(g)}const H=48;function U(n){try{const t=JSON.stringify(n);return t===void 0?null:t}catch{return null}}function D(n,t){if(L(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=U(n);if(s!==null&&s.length<=r)return s;if(Array.isArray(n)){const u=n.length;return`[${W.t("count.items",{count:u})}]`}const f=Object.keys(n).length;return`{${W.t("count.keys",{count:f})}}`}function v(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(o=>v(o,s)).join(",")}]`:`{${Object.keys(n).sort().map(o=>`${JSON.stringify(o)}:${v(n[o],s)}`).join(",")}}`)}function S(n,t){if(L(n))return L(t)?0:1;if(L(t))return-1;const r=v(n),s=v(t);return r<s?-1:r>s?1:0}function y(n){if(L(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 c=Object.freeze({json:{base:"object",storage:"object",format:n=>D(n&&n.value,l(n&&n.column)),parse:n=>y(n&&n.text),compare:S,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:n=>{if(L(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=>y(n)},secret:{base:"text",storage:"object",format:n=>G(n&&n.value,l(n&&n.column)),parse:n=>{const t=n&&n.text;return L(t)||String(t)===""?null:String(t)},compare:(n,t)=>{const r=L(n)||n==="",s=L(t)||t==="";return r===s?0:r?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:n=>G(n),fromClipboard:n=>L(n)||String(n)===""?null:String(n)}}),i=c}),xe("packages/core/src/columns/types/unit.js",function(e,K){"use strict";Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return T}});const X=K("packages/core/src/internal/util.js"),L=X.isNil,B=X.warnOnce;function F(R,O,I,q){return Object.freeze({symbol:R,factor:O,aliases:Object.freeze(I||[]),binary:!!(q&&q.binary),prefix:q&&q.prefix||null,auto:!(q&&q.auto===!1)})}function W(R,O,I,q){return F(R,O,I,q)}const Q=Object.freeze({data:Object.freeze([F("B",1,["byte","bytes"]),F("kB",1e3,["kilobyte","kilobytes"],{prefix:"k"}),F("KiB",1024,["kibibyte","kibibytes"],{binary:!0,prefix:"k"}),F("MB",1e6,["megabyte","megabytes"],{prefix:"m"}),F("MiB",1024**2,["mebibyte","mebibytes"],{binary:!0,prefix:"m"}),F("GB",1e9,["gigabyte","gigabytes"],{prefix:"g"}),F("GiB",1024**3,["gibibyte","gibibytes"],{binary:!0,prefix:"g"}),F("TB",1e12,["terabyte","terabytes"],{prefix:"t"}),F("TiB",1024**4,["tebibyte","tebibytes"],{binary:!0,prefix:"t"}),F("PB",1e15,["petabyte","petabytes"],{prefix:"p"})]),bitrate:Object.freeze([F("bps",1,["bit","bits","bit/s","b/s"]),F("kbps",1e3,["kbit","kbits","kbit/s","kb/s","kilobit","kilobits"],{prefix:"k"}),F("Mbps",1e6,["mbit","mbits","mbit/s","mb/s","megabit","megabits"],{prefix:"m"}),F("Gbps",1e9,["gbit","gbits","gbit/s","gb/s","gigabit","gigabits"],{prefix:"g"}),F("Tbps",1e12,["tbit","tbits","tbit/s","tb/s","terabit","terabits"],{prefix:"t"})]),length:Object.freeze([F("nm",1e-9,["nanometre","nanometres","nanometer","nanometers"]),F("µm",1e-6,["um","micrometre","micrometres","micrometer","micrometers","micron","microns"]),F("mm",.001,["millimetre","millimetres","millimeter","millimeters"]),F("cm",.01,["centimetre","centimetres","centimeter","centimeters"]),F("in",.0254,["inch","inches"],{auto:!1}),F("ft",.3048,["foot","feet"],{auto:!1}),F("yd",.9144,["yard","yards"],{auto:!1}),F("m",1,["metre","metres","meter","meters"]),F("km",1e3,["kilometre","kilometres","kilometer","kilometers"]),F("mi",1609.344,["mile","miles"],{auto:!1}),F("nmi",1852,["nauticalmile","nauticalmiles"],{auto:!1})]),mass:Object.freeze([F("mg",.001,["milligram","milligrams"]),F("g",1,["gram","grams"]),F("oz",28.349523125,["ounce","ounces"],{auto:!1}),F("lb",453.59237,["pound","pounds","lbs"],{auto:!1}),F("kg",1e3,["kilogram","kilograms"]),F("st",6350.29318,["stone"],{auto:!1}),F("t",1e6,["tonne","tonnes","ton"],{auto:!1}),F("ton (US)",907184.74,["ton","shortton"],{auto:!1}),F("ton (UK)",10160469088e-4,["ton","longton"],{auto:!1})]),duration:Object.freeze([F("ns",1e-9,["nsec","nsecs","nanosecond","nanoseconds"]),F("µs",1e-6,["us","usec","usecs","microsecond","microseconds"]),F("ms",.001,["msec","msecs","millisecond","milliseconds"]),F("s",1,["sec","secs","second","seconds"]),F("m",60,["min","mins","minute","minutes"]),F("h",3600,["hr","hrs","hour","hours"]),F("d",86400,["day","days"])]),speed:Object.freeze([F("mm/s",.001,["millimetre/s","millimeter/s"]),F("ft/s",.3048,["fps","foot/s","feet/s"],{auto:!1}),F("km/h",1/3.6,["kph","kmh","kilometre/h","kilometer/h"],{auto:!1}),F("mph",.44704,["mile/h","miles/h"],{auto:!1}),F("kn",1852/3600,["knot","knots"],{auto:!1}),F("m/s",1,["metre/s","meter/s","mps"]),F("km/s",1e3,["kilometre/s","kilometer/s"])]),acceleration:Object.freeze([F("mm/s²",.001,["mm/s2"]),F("ft/s²",.3048,["ft/s2"],{auto:!1}),F("m/s²",1,["m/s2","metre/s2","meter/s2"]),F("g",9.80665,["gee","gravity"],{auto:!1})]),area:Object.freeze([F("mm²",1e-6,["mm2"]),F("cm²",1e-4,["cm2"]),F("in²",64516e-8,["in2","sqin"],{auto:!1}),F("ft²",.09290304,["ft2","sqft"],{auto:!1}),F("yd²",.83612736,["yd2","sqyd"],{auto:!1}),F("m²",1,["m2","sqm"]),F("ha",1e4,["hectare","hectares"],{auto:!1}),F("ac",4046.8564224,["acre","acres"],{auto:!1}),F("km²",1e6,["km2","sqkm"])]),volume:Object.freeze([F("µL",1e-6,["ul","microlitre","microliter"]),F("mL",.001,["millilitre","milliliter"]),F("fl oz (US)",.0295735295625,["fl oz","usfloz"],{auto:!1}),F("fl oz (imp)",.0284130625,["fl oz","impfloz"],{auto:!1}),F("L",1,["litre","litres","liter","liters"]),F("gal (US)",3.785411784,["gal","usgal","usgallon"],{auto:!1}),F("gal (imp)",4.54609,["gal","impgal","impgallon"],{auto:!1}),F("m³",1e3,["m3","cubicmetre","cubicmeter","kl"],{auto:!1}),F("bbl",158.987294928,["barrel","barrels"],{auto:!1})]),energy:Object.freeze([F("eV",1602176634e-28,["electronvolt","electronvolts"],{auto:!1}),F("J",1,["joule","joules"]),F("cal",4.184,["calorie","calories"],{auto:!1}),F("kJ",1e3,["kilojoule","kilojoules"]),F("BTU",1055.05585262,["btu"],{auto:!1}),F("kcal",4184,["kilocalorie","kilocalories","Cal"],{auto:!1}),F("MJ",1e6,["megajoule","megajoules"]),F("kWh",36e5,["kilowatthour","kilowatthours"],{auto:!1}),F("GJ",1e9,["gigajoule","gigajoules"]),F("MWh",36e8,["megawatthour","megawatthours"],{auto:!1})]),power:Object.freeze([F("mW",.001,["milliwatt","milliwatts"]),F("W",1,["watt","watts"]),F("BTU/h",1055.05585262/3600,["btuh","btu/h"],{auto:!1}),F("kW",1e3,["kilowatt","kilowatts"]),F("hp",745.6998715822702,["horsepower"],{auto:!1}),F("MW",1e6,["megawatt","megawatts"]),F("GW",1e9,["gigawatt","gigawatts"])]),force:Object.freeze([F("mN",.001,["millinewton","millinewtons"]),F("N",1,["newton","newtons"]),F("lbf",4.4482216152605,["poundforce"],{auto:!1}),F("kgf",9.80665,["kilogramforce"],{auto:!1}),F("kN",1e3,["kilonewton","kilonewtons"]),F("MN",1e6,["meganewton","meganewtons"])]),pressure:Object.freeze([F("Pa",1,["pascal","pascals"]),F("mbar",100,["millibar"],{auto:!1}),F("inH₂O",249.0889,["inh2o"],{auto:!1}),F("mmHg",133.322387415,["torr"],{auto:!1}),F("kPa",1e3,["kilopascal","kilopascals"]),F("inHg",3386.388640341,["inhg"],{auto:!1}),F("psi",6894.757293168361,["lbf/in2"],{auto:!1}),F("bar",1e5,[],{auto:!1}),F("atm",101325,["atmosphere","atmospheres"],{auto:!1}),F("MPa",1e6,["megapascal","megapascals"]),F("GPa",1e9,["gigapascal","gigapascals"])]),torque:Object.freeze([F("N·m",1,["nm","n.m","newtonmetre","newtonmeter"]),F("lbf·ft",1.3558179483314003,["lbfft","lbf.ft","ftlb","ft-lb"],{auto:!1}),F("kN·m",1e3,["knm","kn.m"],{auto:!1}),F("MN·m",1e6,["mnm","mn.m"],{auto:!1})]),density:Object.freeze([F("kg/m³",1,["kg/m3"]),F("lb/ft³",16.01846337396014,["lb/ft3","pcf"],{auto:!1}),F("g/cm³",1e3,["g/cm3","g/ml","kg/l"],{auto:!1}),F("t/m³",1e3,["t/m3"],{auto:!1})]),flow:Object.freeze([F("L/min",1/6e4,["lpm","l/min"],{auto:!1}),F("m³/h",1/3600,["m3/h","cmh"],{auto:!1}),F("gpm (US)",.003785411784/60,["gpm","usgpm"],{auto:!1}),F("gpm (imp)",.00454609/60,["gpm","impgpm"],{auto:!1}),F("cfm",.0004719474432,["ft3/min"],{auto:!1}),F("L/s",.001,["lps","l/s"],{auto:!1}),F("m³/s",1,["m3/s","cms"])]),angle:Object.freeze([F("″",Math.PI/648e3,["arcsec","arcsecond","arcseconds"],{auto:!1}),F("′",Math.PI/10800,["arcmin","arcminute","arcminutes"],{auto:!1}),F("mrad",.001,["milliradian","milliradians"],{auto:!1}),F("mil",Math.PI/3200,["nato-mil"],{auto:!1}),F("°",Math.PI/180,["deg","degree","degrees"],{auto:!1}),F("gon",Math.PI/200,["grad","gradian","gradians"],{auto:!1}),F("rad",1,["radian","radians"]),F("turn",2*Math.PI,["rev","revolution","revolutions"],{auto:!1})]),angularVelocity:Object.freeze([F("°/s",Math.PI/180,["degps","deg/s","degrees/s"],{auto:!1}),F("rad/s",1,["radps","radians/s"]),F("rpm",2*Math.PI/60,["rev/min","r/min","revolutions/min"],{auto:!1}),F("rps",2*Math.PI,["rev/s","r/s","revolutions/s"],{auto:!1})]),fraction:Object.freeze([F("ppt",1e-12,["partspertrillion"],{auto:!1}),F("ppb",1e-9,["partsperbillion"]),F("ppm",1e-6,["partspermillion"]),F("bp",1e-4,["bps-finance","basispoint","basispoints","bips"],{auto:!1}),F("‰",.001,["permille","permil"],{auto:!1}),F("%",.01,["pct","percent"]),F("×",1,["x","ratio","times"])]),molarity:Object.freeze([F("pM",1e-12,["picomolar","picomolarity"]),F("nM",1e-9,["nanomolar","nanomolarity"]),F("µM",1e-6,["um-molar","micromolar","micromolarity"]),F("mM",.001,["millimolar","millimolarity"]),F("M",1,["molar","mol/l","mol/L","molarity"]),F("mol/m³",.001,["mol/m3"],{auto:!1})]),massFlow:Object.freeze([F("mg/s",1e-6,["milligrams/s"]),F("g/s",.001,["grams/s"]),F("kg/h",1/3600,["kilograms/h","kgph"],{auto:!1}),F("kg/s",1,["kilograms/s","kgps"]),F("t/h",1e3/3600,["tonnes/h","tph"],{auto:!1}),F("lb/h",.45359237/3600,["pounds/h","pph"],{auto:!1}),F("t/s",1e3,["tonnes/s"],{auto:!1})]),viscosity:Object.freeze([F("µPa·s",1e-6,["upas","micropascalsecond"]),F("cP",.001,["centipoise"],{auto:!1}),F("mPa·s",.001,["mpas","millipascalsecond"]),F("P",.1,["poise"],{auto:!1}),F("Pa·s",1,["pas","pascalsecond"])]),kinematicViscosity:Object.freeze([F("cSt",1e-6,["centistokes","centistoke"]),F("mm²/s",1e-6,["mm2/s"],{auto:!1}),F("St",1e-4,["stokes","stoke"],{auto:!1}),F("m²/s",1,["m2/s"])]),thermalConductivity:Object.freeze([F("mW/(m·K)",.001,["mw/mk"]),F("W/(m·K)",1,["w/mk","wmk"]),F("kW/(m·K)",1e3,["kw/mk"],{auto:!1}),F("BTU/(hr·ft·°F)",1.730734666,["btu/hrftf"],{auto:!1})]),specificHeat:Object.freeze([F("J/(kg·K)",1,["j/kgk","jkgk"]),F("kJ/(kg·K)",1e3,["kj/kgk"]),F("cal/(g·°C)",4184,["cal/gc"],{auto:!1})]),doseRate:Object.freeze([F("nSv/h",1e-9,["nsvh"]),F("µSv/h",1e-6,["usv/h","usvh"]),F("mSv/h",.001,["msvh"]),F("Sv/h",1,["svh"]),F("mSv/a",.001/8766,["msv/year","msvpa"],{auto:!1})])}),G=Symbol("ambiguous"),H=new Map,U=new Map;function D(R,O){const I=String(R||"").trim();if(!I)throw new Error("[lattice] a unit system needs a name");if(Q[I]||U.has(I))throw new Error(`[lattice] unit system "${I}" already exists`);const q=[...O||[]];if(!q.length)throw new Error(`[lattice] unit system "${I}" has no units`);if(!q.some(_=>_.factor===1))throw new Error(`[lattice] unit system "${I}" has no base unit (none with factor 1)`);const Z=new Set;for(const _ of q){if(Z.has(_.symbol))throw new Error(`[lattice] unit system "${I}" declares "${_.symbol}" twice`);Z.add(_.symbol)}return U.set(I,Object.freeze(q)),H.delete(I),I}function v(){return[...Object.keys(Q),...U.keys()]}function S(R){const O=y(R);return O?O.units:[]}function y(R){const O=String(R||""),I=H.get(O);if(I!==void 0)return I;const q=Q[O]||U.get(O);if(!q)return H.set(O,null),null;const Z=Object.freeze([...q].sort((ne,ie)=>ne.factor-ie.factor)),_=new Map,J=new Map,ee=(ne,ie)=>{const ae=_.get(ne);ae===void 0?_.set(ne,ie):ae!==ie&&_.set(ne,G)};for(const ne of Z){ee(ne.symbol.toLowerCase(),ne);for(const ie of ne.aliases)ee(ie.toLowerCase(),ne);if(ne.prefix){const ie=J.get(ne.prefix)||[];ie.push(ne),J.set(ne.prefix,ie)}}const te={units:Z,byToken:_,byPrefix:J,decimal:Z.filter(ne=>!ne.binary&&ne.auto),binary:Z.some(ne=>ne.binary)?Z.filter(ne=>(ne.binary||ne.factor===1)&&ne.auto):null};return H.set(O,te),te}function l(R,O){return O&&R.binary||R.decimal}function c(R,O){const I=y(R);if(!I||L(O))return null;const q=I.units.find(_=>_.symbol===String(O));if(q)return q;const Z=I.byToken.get(String(O).trim().toLowerCase());return Z&&Z!==G?Z:null}const i=new WeakMap;function n(R){const O=R||{};if(typeof O=="object"&&O!==null){const _=i.get(O);if(_!==void 0)return _}const I=O.system||"data",q=y(I);let Z=null;if(!q)B(`unit:system:${I}`,`unknown unit system "${I}"; known systems are ${v().join(", ")}`);else{let _=O.unit?c(I,O.unit):null;_||(O.unit&&B(`unit:unit:${I}:${O.unit}`,`unknown unit "${O.unit}" in system "${I}"; falling back to ${q.units[0].symbol}`),_=q.units.find(J=>J.factor===1)||q.units[0]),Z={index:q,base:_,binary:O.binary===!0}}return typeof O=="object"&&O!==null&&i.set(O,Z),Z}const t=new WeakMap;function r(R,O){if(!R||!O||!Array.isArray(R.compound)||R.compound.length===0)return null;const I=t.get(R);if(I!==void 0)return I;const q=new Set,Z=[];for(const J of R.compound){const ee=c(R.system||"data",J);if(!ee){B(`unit:compound:${R.system}:${J}`,`unknown compound unit "${J}" in system "${R.system||"data"}"; ignoring it`);continue}q.has(ee.symbol)||(q.add(ee.symbol),Z.push(ee))}Z.sort((J,ee)=>ee.factor-J.factor);const _=Z.length>=2?Z:null;return t.set(R,_),_}function s(R,O,I){return O===I||O.factor===I.factor?R:R*O.factor/I.factor}const f=new Map;function u(R){const O=R||"",I=f.get(O);if(I)return I;const q={group:",",decimal:"."};try{for(const Z of new Intl.NumberFormat(R||void 0).formatToParts(12345.6))Z.type==="group"?q.group=Z.value:Z.type==="decimal"&&(q.decimal=Z.value)}catch{}return f.set(O,q),q}const o=/[\s ]/g,g=/^[+-]?[\d '’ .,]*(?:[eE][+-]?\d+)?/,d=/^[^\d+\-(.,\s]+\s*/,h=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function a(R,O){const{group:I,decimal:q}=u(O);let Z=String(R).replace(o,"");if(Z==="")return null;const _=q?Z.indexOf(q):-1;if(I&&I!==q){if(_>=0&&Z.indexOf(I,_+q.length)>=0)return null;Z=Z.split(I).join("")}if(q&&q!=="."&&(Z=Z.split(q).join(".")),!h.test(Z))return null;const J=Number(Z);return Number.isFinite(J)?J:null}function p(R,O,I){const q=String(R).trim().replace(/\.$/,"");if(q==="")return null;const Z=O.units.find(ie=>ie.symbol===q);if(Z)return Z;const _=q.toLowerCase(),J=O.byToken.get(_);if(J===G)return null;if(J)return J;const ee=O.byPrefix.get(_);if(!ee||!ee.length)return null;const te=l(O,I),ne=ee.filter(ie=>te.includes(ie));return ne.length===1?ne[0]:null}function w(R,O,I,q){let Z=R,_=0,J=!1,ee=!1;for(;Z!=="";){const te=g.exec(Z)[0];if(te==="")return null;const ne=a(te,q&&q.locale);if(ne===null)return null;Z=Z.slice(te.length).trim();const ie=Z.search(/[+-]?[\d]/),ae=(ie>=0?Z.slice(0,ie):Z).trim();if(Z=ie>=0?Z.slice(ie).trim():"",ae===""){if(J)return null;ee=!0,_+=s(ne,I[0],O.base)}else{const re=p(ae,O.index,O.binary);if(!re)return null;_+=s(ne,re,O.base)}if(J=!0,ee&&Z!=="")return null}return J?_:null}function k(R,O){if(L(R))return null;if(typeof R=="number")return Number.isFinite(R)?R:null;const I=n(O);if(!I)return null;let q=String(R).trim();if(q==="")return null;let Z=!1;q.startsWith("(")&&q.endsWith(")")&&(Z=!0,q=q.slice(1,-1).trim());const _=r(O,I);if(_){q.startsWith("-")&&(Z=!0,q=q.slice(1).trim());const se=w(q,I,_,O);return se===null?null:Z?-se:se}let J=null;const ee=d.exec(q);if(ee&&ee[0]){const se=p(ee[0].trim(),I.index,I.binary);se&&(J=se,q=q.slice(ee[0].length).trim())}const te=g.exec(q)[0],ne=a(te,O&&O.locale);if(ne===null)return null;const ie=q.slice(te.length).trim();if(J&&ie!=="")return null;const ae=J||(ie===""?I.base:p(ie,I.index,I.binary));if(!ae)return null;const re=s(ne,ae,I.base);return Z?-re:re}const m=new Map;function b(R,O,I,q){const Z=`${R||""}|${O}|${I}|${q?1:0}`;let _=m.get(Z);return _||(_=new Intl.NumberFormat(R||void 0,{minimumFractionDigits:O,maximumFractionDigits:I,useGrouping:q}),m.set(Z,_)),_}function C(R,O){if(!Number.isFinite(R)||R===0)return Math.max(0,O-1);const I=Math.floor(Math.log10(Math.abs(R)));return Math.min(20,Math.max(0,O-1-I))}function M(R,O){if(!Number.isFinite(R)||R===0)return R;const I=Math.ceil(Math.log10(Math.abs(R))),q=10**(O-I);return Math.round(R*q)/q}function P(R,O,I){if(!I||I===O.base.symbol)return O.base;if(I!=="auto")return x(O,I);if(R===0||!Number.isFinite(R))return O.base;const q=Math.abs(R)*O.base.factor,Z=l(O.index,O.binary);let _=Z[0];for(const te of Z)q>=te.factor&&(_=te);if(q>=_.factor)return _;let J=_;for(const te of O.index.units)te.binary!==O.binary&&te.factor!==1||te.factor<=q&&te.factor>(J===_?0:J.factor)&&(J=te);if(J!==_)return J;let ee=_;for(const te of O.index.units)te.binary!==O.binary&&te.factor!==1||te.factor<ee.factor&&(ee=te);return ee.factor<O.base.factor?ee:O.base}function x(R,O){const I=R.index.units.find(Z=>Z.symbol===O);if(I)return I;const q=R.index.byToken.get(String(O).toLowerCase());return q&&q!==G?q:(B(`unit:display:${O}`,`unknown display unit "${O}"; rendering in ${R.base.symbol}`),R.base)}function E(R,O,I,q){const Z=R<0;let _=Math.abs(R)*O.base.factor;const J=typeof q.decimals=="number"?q.decimals:q.minDecimals??0,ee=typeof q.decimals=="number"?q.decimals:q.maxDecimals??Math.max(J,2),te=q.space??" ",ne=[];for(let ae=0;ae<I.length;ae++){const re=I[ae],se=ae===I.length-1;let le=se?_/re.factor:Math.floor(_/re.factor);if(_-=le*re.factor,se){const be=10**ee;le=Math.round(le*be)/be+0}const fe=se?b(q.locale,J,ee,q.group!==!1):b(q.locale,0,0,q.group!==!1);ne.push(`${fe.format(le)}${te}${re.symbol}`)}const ie=ne.join(" ");return Z?`-${ie}`:ie}function A(R,O){const I=O||{},q=I.nullDisplay??"";if(L(R)||R==="")return q;const Z=typeof R=="number"?R:Number(R);if(!Number.isFinite(Z))return q;const _=n(I);if(!_)return String(Z);const J=r(I,_);if(J)return E(Z,_,J,I);const ee=typeof I.significantFigures=="number"&&I.significantFigures>0?I.significantFigures:0,te=ee?M(Z,ee):Z,ne=P(te,_,I.display),ie=s(te,_.base,ne);let ae=typeof I.decimals=="number"?I.decimals:I.minDecimals??0,re=typeof I.decimals=="number"?I.decimals:I.maxDecimals??Math.max(ae,2);ee&&(ae=C(ie,ee),re=ae);const se=b(I.locale,ae,re,I.group!==!1).format(ie),le=I.space??" ";return I.placement==="prefix"?`${ne.symbol}${I.space??""}${se}`:`${se}${le}${ne.symbol}`}function j(R,O){const I=L(R)||Number.isNaN(R)?null:Number(R),q=L(O)||Number.isNaN(O)?null:Number(O);return I===null||Number.isNaN(I)?q===null||Number.isNaN(q)?0:1:q===null||Number.isNaN(q)||I<q?-1:I>q?1:0}function $(R){const O=typeof R.decimals=="number"&&R.decimals>0?`.${"0".repeat(R.decimals)}`:"";return`${typeof R.decimals=="number"?`#,##0${O}`:"#,##0.##"}" ${R.symbol}"`}function z(R){const O={system:"data",...R||{}},I=n(O),q=I?I.base.symbol:String(O.unit||""),Z=Object.freeze({...O,unit:q}),_=Object.freeze({...Z,display:q,decimals:void 0,minDecimals:0,maxDecimals:20,group:!1}),J=new Map([[Z.locale||"",Z]]),ee=te=>{const ne=te||"";let ie=J.get(ne);return ie||(ie=Object.freeze({...Z,locale:te||void 0}),J.set(ne,ie)),ie};return{base:"number",extends:"number",storage:"float64",unitConfig:Z,format:te=>A(te.value,te.locale?ee(te.locale):Z),parse:te=>k(te.text,te.locale?ee(te.locale):Z),compare:j,defaults:{filter:"number",editor:"unit",align:"end",total:O.total||"sum"},...O.totals?{totals:O.totals}:{},excel:O.excel||$({decimals:O.decimals,symbol:q}),toStorage:te=>typeof te=="number"?Number.isFinite(te)?te:null:typeof te=="string"?k(te,Z):L(te)?null:k(String(te),Z),toClipboard:te=>A(te,_),fromClipboard:te=>k(te,Z)}}const T=z}),xe("packages/core/src/columns/types/engineering.js",function(e,K){"use strict";Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return W}});const L=K("packages/core/src/internal/util.js").isNil,F=K("packages/core/src/columns/types/unit.js").createUnitType;function W(H){const U=2*Math.PI/H;return D=>{let v=0,S=0,y=0;for(const c of D||[]){if(L(c))continue;const i=Number(c);Number.isFinite(i)&&(v+=Math.cos(i*U),S+=Math.sin(i*U),y+=1)}return!y||Math.hypot(v,S)/y<1e-12?null:(Math.atan2(S,v)/U%H+H)%H}}function Q(H){return{supported:["sum","avg","min","max","count","countValues"],implement:{avg:W(H)}}}const G=Object.freeze({metres:F({system:"length",unit:"m",display:"auto",maxDecimals:3}),millimetres:F({system:"length",unit:"mm",maxDecimals:2}),kilometres:F({system:"length",unit:"km",maxDecimals:3}),grams:F({system:"mass",unit:"g",display:"auto",maxDecimals:3}),kilograms:F({system:"mass",unit:"kg",maxDecimals:3}),tonnes:F({system:"mass",unit:"t",maxDecimals:3}),seconds:F({system:"duration",unit:"s",display:"auto",maxDecimals:3}),milliseconds:F({system:"duration",unit:"ms",maxDecimals:3}),hours:F({system:"duration",unit:"h",maxDecimals:2}),speed:F({system:"speed",unit:"m/s",display:"auto",maxDecimals:2}),kph:F({system:"speed",unit:"km/h",maxDecimals:1}),mph:F({system:"speed",unit:"mph",maxDecimals:1}),knots:F({system:"speed",unit:"kn",maxDecimals:1}),acceleration:F({system:"acceleration",unit:"m/s²",maxDecimals:3}),area:F({system:"area",unit:"m²",display:"auto",maxDecimals:2}),hectares:F({system:"area",unit:"ha",maxDecimals:4}),volume:F({system:"volume",unit:"L",display:"auto",maxDecimals:3}),cubicMetres:F({system:"volume",unit:"m³",maxDecimals:3}),energy:F({system:"energy",unit:"J",display:"auto",maxDecimals:3}),kilowattHours:F({system:"energy",unit:"kWh",maxDecimals:2}),power:F({system:"power",unit:"W",display:"auto",maxDecimals:2}),kilowatts:F({system:"power",unit:"kW",maxDecimals:2}),force:F({system:"force",unit:"N",display:"auto",maxDecimals:2}),pressure:F({system:"pressure",unit:"Pa",display:"auto",maxDecimals:2}),bar:F({system:"pressure",unit:"bar",maxDecimals:3}),psi:F({system:"pressure",unit:"psi",maxDecimals:1}),torque:F({system:"torque",unit:"N·m",maxDecimals:2}),density:F({system:"density",unit:"kg/m³",maxDecimals:2}),flow:F({system:"flow",unit:"m³/s",maxDecimals:4}),litresPerMinute:F({system:"flow",unit:"L/min",maxDecimals:1}),radians:F({system:"angle",unit:"rad",maxDecimals:4,totals:Q(2*Math.PI)}),degrees:F({system:"angle",unit:"°",maxDecimals:2,totals:Q(360)}),rpm:F({system:"angularVelocity",unit:"rpm",maxDecimals:0}),angularVelocity:F({system:"angularVelocity",unit:"rad/s",maxDecimals:3}),ppm:F({system:"fraction",unit:"ppm",maxDecimals:2}),ppb:F({system:"fraction",unit:"ppb",maxDecimals:2}),basisPoints:F({system:"fraction",unit:"bp",maxDecimals:1}),molarity:F({system:"molarity",unit:"M",display:"auto",maxDecimals:3}),massFlow:F({system:"massFlow",unit:"kg/s",maxDecimals:3}),tonnesPerHour:F({system:"massFlow",unit:"t/h",maxDecimals:2}),viscosity:F({system:"viscosity",unit:"Pa·s",display:"auto",maxDecimals:3}),kinematicViscosity:F({system:"kinematicViscosity",unit:"cSt",maxDecimals:2}),thermalConductivity:F({system:"thermalConductivity",unit:"W/(m·K)",maxDecimals:3}),specificHeat:F({system:"specificHeat",unit:"J/(kg·K)",maxDecimals:1}),doseRate:F({system:"doseRate",unit:"µSv/h",display:"auto",maxDecimals:2})})}),xe("packages/core/src/columns/types/si.js",function(e,K){"use strict";Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const X=K("packages/core/src/columns/types/unit.js"),L=X.defineUnit,B=X.registerUnitSystem,F=X.createUnitType,W=Object.freeze([Object.freeze({symbol:"f",name:"femto",factor:1e-15}),Object.freeze({symbol:"p",name:"pico",factor:1e-12}),Object.freeze({symbol:"n",name:"nano",factor:1e-9}),Object.freeze({symbol:"µ",name:"micro",factor:1e-6}),Object.freeze({symbol:"m",name:"milli",factor:.001}),Object.freeze({symbol:"c",name:"centi",factor:.01}),Object.freeze({symbol:"",name:"",factor:1}),Object.freeze({symbol:"k",name:"kilo",factor:1e3}),Object.freeze({symbol:"M",name:"mega",factor:1e6}),Object.freeze({symbol:"G",name:"giga",factor:1e9}),Object.freeze({symbol:"T",name:"tera",factor:1e12}),Object.freeze({symbol:"P",name:"peta",factor:1e15})]),Q=Object.freeze(["p","n","µ","m","","k","M","G"]);function G(S){const y=String(S.base),l=new Set([...S.prefixes||Q,""]),c=[];for(const i of W){if(!l.has(i.symbol))continue;const n=`${i.symbol}${y}`,t=[];if(S.name){t.push(`${i.name}${S.name}`,`${i.name}${S.name}s`);const r=i.name.slice(-1);if(r&&S.name.startsWith(r)){const s=`${i.name.slice(0,-1)}${S.name}`;t.push(s,`${s}s`)}}i.symbol==="µ"&&t.push(`u${y}`),i.factor===1&&S.aliases&&t.push(...S.aliases),c.push(L(n,i.factor,t))}for(const i of S.extra||[])c.push(i);return c}function H(S,y){const l=G(y);return B(S,l)}function U(S,y,l){return H(S,y),F({system:S,unit:y.base,display:"auto",maxDecimals:3,...l||{}})}const D=Object.freeze({voltage:U("voltage",{base:"V",name:"volt"}),current:U("current",{base:"A",name:"amp",aliases:["ampere","amperes"]}),resistance:U("resistance",{base:"Ω",name:"ohm",aliases:["ohm","ohms","R"],prefixes:["m","","k","M","G"]}),capacitance:U("capacitance",{base:"F",name:"farad",prefixes:["f","p","n","µ","m",""]}),inductance:U("inductance",{base:"H",name:"henry",prefixes:["p","n","µ","m",""]}),charge:U("charge",{base:"C",name:"coulomb",prefixes:["p","n","µ","m",""],extra:[L("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),L("Ah",3600,["amphour","amphours"],{auto:!1})]}),conductance:U("conductance",{base:"S",name:"siemens",prefixes:["n","µ","m","","k"]}),fluxDensity:U("fluxDensity",{base:"T",name:"tesla",prefixes:["n","µ","m",""],extra:[L("G",1e-4,["gauss"],{auto:!1})]}),luminousFlux:U("luminousFlux",{base:"lm",name:"lumen",prefixes:["m","","k"]}),illuminance:U("illuminance",{base:"lx",name:"lux",prefixes:["m","","k"]}),luminousIntensity:U("luminousIntensity",{base:"cd",name:"candela",prefixes:["m","","k"]}),substance:U("substance",{base:"mol",name:"mole",prefixes:["n","µ","m","","k"]}),absorbedDose:U("absorbedDose",{base:"Gy",name:"gray",prefixes:["µ","m",""]}),equivalentDose:U("equivalentDose",{base:"Sv",name:"sievert",prefixes:["n","µ","m",""]}),radioactivity:U("radioactivity",{base:"Bq",name:"becquerel",prefixes:["","k","M","G","T"],extra:[L("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:U("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),v=U}),xe("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 F}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const L=K("packages/core/src/internal/util.js").isNil,B=Object.freeze({C:Object.freeze({symbol:"°C",aliases:["c","°c","celsius","centigrade"],toKelvin:c=>c+273.15,fromKelvin:c=>c-273.15}),F:Object.freeze({symbol:"°F",aliases:["f","°f","fahrenheit"],toKelvin:c=>(c+459.67)*(5/9),fromKelvin:c=>c*(9/5)-459.67}),K:Object.freeze({symbol:"K",aliases:["k","kelvin"],toKelvin:c=>c,fromKelvin:c=>c}),R:Object.freeze({symbol:"°R",aliases:["r","°r","rankine"],toKelvin:c=>c*(5/9),fromKelvin:c=>c*(9/5)})});function F(c){if(L(c))return null;const i=String(c).trim();if(i==="")return null;for(const[t,r]of Object.entries(B))if(i===t||i===r.symbol)return{key:t,scale:r};const n=i.toLowerCase();for(const[t,r]of Object.entries(B))if(r.aliases.includes(n))return{key:t,scale:r};return null}function W(c,i,n){const t=F(i),r=F(n);return!t||!r||!Number.isFinite(Number(c))?null:t.key===r.key?Number(c):r.scale.fromKelvin(t.scale.toKelvin(Number(c)))}const Q=new Map;function G(c,i,n){const t=`${c||""}|${i}|${n}`;let r=Q.get(t);return r||(r=new Intl.NumberFormat(c||void 0,{minimumFractionDigits:i,maximumFractionDigits:n}),Q.set(t,r)),r}function H(c,i){const n=i||{},t=n.nullDisplay??"";if(L(c)||c==="")return t;const r=Number(c);if(!Number.isFinite(r))return t;const s=F(n.scale||"C");if(!s)return String(r);const f=F(n.display||n.scale||"C")||s,u=f.key===s.key?r:f.scale.fromKelvin(s.scale.toKelvin(r)),o=typeof n.decimals=="number"?n.decimals:null,g=o??n.minDecimals??0,d=o??n.maxDecimals??1;return`${G(n.locale,g,d).format(u)}${n.space??" "}${f.scale.symbol}`}const U=/^[+-]?[\d\s., ]*\d/;function D(c,i){const n=String(c).trim();if(n==="")return null;const t=new Intl.NumberFormat(i||void 0).formatToParts(1.1).find(u=>u.type==="decimal")?.value||".",r=t===","?".":",",s=n.split(r).join("").split(/[\s ]/).join("").replace(t,"."),f=Number(s);return Number.isFinite(f)?f:null}function v(c,i){if(L(c))return null;const n=i||{},t=F(n.scale||"C");if(!t)return null;if(typeof c=="number")return Number.isFinite(c)?c:null;let r=String(c).trim();if(r==="")return null;let s=!1;r.startsWith("(")&&r.endsWith(")")&&(s=!0,r=r.slice(1,-1).trim());const f=U.exec(r);if(!f)return null;const u=D(f[0],n.locale);if(u===null)return null;const o=r.slice(f[0].length).trim();if(o==="")return s?-u:u;const g=F(o);if(!g)return null;const d=g.key===t.key?u:t.scale.fromKelvin(g.scale.toKelvin(u));return s?-d:d}function S(c){const i=Object.freeze({scale:"C",...c||{}}),t=(F(i.scale)||F("C")).scale.symbol,r=Object.freeze({...i,display:i.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),s=new Map([[i.locale||"",i]]),f=u=>{const o=u||"";let g=s.get(o);return g||(g=Object.freeze({...i,locale:u||void 0}),s.set(o,g)),g};return{base:"number",extends:"number",storage:"float64",temperatureConfig:i,format:u=>H(u.value,u.locale?f(u.locale):i),parse:u=>v(u.text,u.locale?f(u.locale):i),defaults:{filter:"number",editor:"temperature",align:"end",total:"avg"},totals:{supported:["avg","min","max","count","countValues"]},excel:i.excel||`#,##0${typeof i.decimals=="number"&&i.decimals>0?`.${"0".repeat(i.decimals)}`:".#"}" ${t}"`,toStorage:u=>typeof u=="number"?Number.isFinite(u)?u:null:typeof u=="string"?v(u,i):L(u)?null:v(String(u),i),toClipboard:u=>H(u,r),fromClipboard:u=>v(u,i)}}const y=Object.freeze({celsius:S({scale:"C"}),fahrenheit:S({scale:"F"}),kelvin:S({scale:"K"})}),l=S}),xe("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 f}}),Object.defineProperty(e,"radixRange",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"radixName",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normaliseRadixOptions",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"compileRadixFormat",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"compileRadixParse",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"parseRadixResult",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return E}});const X=K("packages/core/src/internal/util.js"),L=X.isNil,B=X.warnOnce,F=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}),W=Object.freeze({2:1,8:3,16:4}),Q=Object.freeze({2:"0b",8:"0o",16:"0x"}),G=Object.freeze({2:4,8:3,16:2}),H=Object.freeze({2:/^[01]+$/,8:/^[0-7]+$/,16:/^[0-9a-f]+$/i}),U=Object.freeze({2:"binary",8:"octal",16:"hexadecimal"}),D=Object.freeze([[/^0x/i,16],[/^0b/i,2],[/^0o/i,8],[/^#/,16]]),v=/[\s\u00a0\u202f_,']/g,S=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,y=Object.freeze([8,16,32,53]),l=new WeakSet,c=new WeakMap,i=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(A){if(A==null)return 16;const j=typeof A=="string"?A.toLowerCase():A,$=F[j];return $||(B(`radix:base:${String(A)}`,`unsupported radix ${String(A)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function f(A,j){return Math.ceil(A/W[j])}function u(A,j){if(!A)return j?{min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}:{min:0,max:Number.MAX_SAFE_INTEGER};if(!j)return{min:0,max:2**A-1};const $=2**(A-1);return{min:-$,max:$-1}}function o(A){return U[A]||"hexadecimal"}function g(A){if(typeof A=="string"){const j=r[A];return j||B(`radix:preset:${A}`,`unknown radix preset "${A}"; known presets are ${Object.keys(r).join(", ")}`),{...j||{}}}if(A&&typeof A.preset=="string"){const j=r[A.preset];return j||B(`radix:preset:${A.preset}`,`unknown radix preset "${A.preset}"; known presets are ${Object.keys(r).join(", ")}`),{...j||{},...A}}return A||{}}function d(A){const j=g(A),$=s(j.radix),z=W[$];let T=null;if(j.bitWidth!==void 0&&j.bitWidth!==null&&j.bitWidth!==!1){const te=Number(j.bitWidth);y.includes(te)?T=te:B(`radix:width:${String(j.bitWidth)}`,`unsupported bitWidth ${String(j.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let R=j.signed!==!1;!R&&T===null&&(B("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),T=32);const O=j.prefix===void 0||j.prefix===!0?Q[$]:j.prefix===!1?"":String(j.prefix);let I=0;j.pad===!0?I=T?f(T,$):0:typeof j.pad=="number"&&j.pad>0&&(I=Math.floor(j.pad));let q=0;j.group===!0?q=G[$]:typeof j.group=="number"&&j.group>0&&(q=Math.floor(j.group));const Z=u(T,R),_=typeof j.min=="number"?Math.max(Z.min,j.min):Z.min,J=typeof j.max=="number"?Math.min(Z.max,j.max):Z.max,ee=Object.freeze({radix:$,bits:z,prefix:O,uppercase:j.uppercase!==!1,pad:I,group:q,groupSeparator:typeof j.groupSeparator=="string"?j.groupSeparator:" ",bitWidth:T,signed:R,min:_,max:J<_?_:J,nullDisplay:typeof j.nullDisplay=="string"?j.nullDisplay:"",name:o($)});return l.add(ee),ee}function h(A){if(A&&l.has(A))return A;if(typeof A=="string"){let j=i.get(A);return j||(j=d(A),i.set(A,j)),j}if(A&&typeof A=="object"){let j=c.get(A);return j||(j=d(A),c.set(A,j)),j}return h("hex")}function a(A){return A<0?-Math.round(-A):Math.round(A)}function p(A,j,$){if(j<=0||A.length<=j)return A;const z=A.length%j||j,T=[A.slice(0,z)];for(let R=z;R<A.length;R+=j)T.push(A.slice(R,R+j));return T.join($)}function w(A){const j=h(A),{radix:$,prefix:z,uppercase:T,pad:R,group:O,groupSeparator:I,signed:q,bitWidth:Z,nullDisplay:_}=j,J=Z?2**Z:0,ee=te=>{if(L(te)||te==="")return _;const ne=typeof te=="number"?te:Number(te);if(!Number.isFinite(ne))return _;const ie=a(ne);let ae="",re=ie;ie<0&&(q?(ae="-",re=-ie):re=(ie%J+J)%J);let se=re.toString($);return se=T?se.toUpperCase():se.toLowerCase(),R>0&&se.length<R&&(se=se.padStart(R,"0")),O>0&&(se=p(se,O,I)),ae+z+se};return ee.options=j,ee}function k(A,j){const $=h(j);let z=n.get($);return z||(z=w($),n.set($,z)),z(A)}function m(A){const j=h(A),{radix:$,groupSeparator:z,signed:T,min:R,max:O}=j,I=H[$],q=Z=>{if(L(Z))return{ok:!0,value:null,reason:"blank"};let _=String(Z);if(z&&z!==""&&(_=_.split(z).join("")),_=_.replace(v,""),_==="")return{ok:!0,value:null,reason:"blank"};let J=!1;if((_[0]==="-"||_[0]==="+")&&(J=_[0]==="-",_=_.slice(1)),_==="")return{ok:!1,value:null,reason:"digits"};let ee=null;for(const[ne,ie]of D){const ae=ne.exec(_);if(!ae)continue;const re=_.slice(ae[0].length);if(re==="")break;if(!H[ie].test(re))return{ok:!1,value:null,reason:"digits"};ee=parseInt(re,ie);break}if(ee===null)if(I.test(_))ee=parseInt(_,$);else if(S.test(_))ee=Number(_);else return{ok:!1,value:null,reason:"digits"};if(!Number.isFinite(ee))return{ok:!1,value:null,reason:"digits"};const te=a(J?-ee:ee);return!T&&te<0?{ok:!1,value:te,reason:"negative"}:te<R||te>O?{ok:!1,value:te,reason:"range"}:{ok:!0,value:te,reason:"ok"}};return q.options=j,q}function b(A,j){const $=h(j);let z=t.get($);return z||(z=m($),t.set($,z)),z(A)}function C(A,j){const $=b(A,j);return $.ok?$.value:null}function M(A,j){const $=L(A)||Number.isNaN(A)?null:Number(A),z=L(j)||Number.isNaN(j)?null:Number(j);return $===null?z===null?0:1:z===null||$<z?-1:$>z?1:0}function P(A){const j=A.min>=-2147483648&&A.max<=2147483647;return A.bitWidth&&j?"int32":"float64"}function x(A){const j=d(A),$=w(j),z=m(j);return{base:"number",extends:"number",storage:P(j),matches:null,format:T=>$(T.value),parse:T=>{const R=z(T.text);return R.ok?R.value:null},compare:M,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:T=>$(T),fromClipboard:T=>{const R=z(T);return R.ok?R.value:null},radix:j,formatValue:$,parseText:z}}const E=x}),xe("packages/core/src/columns/types/aggregable.js",function(e,K){"use strict";Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"weightedMean",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"logarithmicSum",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"logarithmicMean",{enumerable:!0,get:function(){return W}});const L=K("packages/core/src/internal/util.js").isNil;function B(D){const v=[];for(const S of D||[]){if(L(S))continue;const y=Number(S);Number.isFinite(y)&&v.push(y)}return v}function F(D){return v=>{const S=B(v);if(!S.length)return null;let y=0;for(const l of S)y+=10**(l/D);return D*Math.log10(y)}}function W(D){return v=>{const S=B(v);if(!S.length)return null;let y=0;for(const l of S)y+=10**(l/D);return D*Math.log10(y/S.length)}}function Q(D,v){const S=v&&v.column,l=(S&&S.typeOptions||{}).weight,c=v&&v.valueAt;if(!l||typeof c!="function")return null;let i=0,n=0;for(let t=0;t<D.length;t++){if(L(D[t]))continue;const r=Number(D[t]);if(!Number.isFinite(r))continue;const s=c(l,t);if(L(s))continue;const f=Number(s);!Number.isFinite(f)||f<=0||(i+=r*f,n+=f)}return n===0?null:i/n}function G(D={}){const v=D.factor===20?20:10,S=typeof D.suffix=="string"?D.suffix:"",y=Number.isInteger(D.decimals)?D.decimals:1;return{base:"number",storage:"float64",name:D.name||"logarithmic",format:l=>{const c=l&&l.value;return L(c)||!Number.isFinite(Number(c))?"":`${Number(c).toFixed(y)}${S}`},parse:l=>{const c=String((l&&l.text)??"").replace(S,"").trim();if(!c)return null;const i=Number(c);return Number.isFinite(i)?i:null},defaults:{align:"end",filter:"number"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:{sum:F(v),avg:W(v)}}}}function H(D={}){const v=Number.isInteger(D.decimals)?D.decimals:1,S=D.percent===!0;return{base:"number",storage:"float64",name:D.name||"ratio",format:y=>{const l=y&&y.value;return L(l)||!Number.isFinite(Number(l))?"":S?`${Number(l).toFixed(v)}%`:Number(l).toFixed(v)},parse:y=>{const l=String((y&&y.text)??"").replace("%","").trim();if(!l)return null;const c=Number(l);return Number.isFinite(c)?c:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:Q}}}}const U=Object.freeze({decibel:G({name:"decibel",factor:10,suffix:" dB"}),decibelAmplitude:G({name:"decibelAmplitude",factor:20,suffix:" dB"}),ratio:H({name:"ratio"}),percentRate:H({name:"percentRate",percent:!0})})}),xe("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 F}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"moneyToText",{enumerable:!0,get:function(){return i}}),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 f}});const L=K("packages/core/src/internal/util.js").isNil,B="⚠ no rate";function F(u){if(L(u))return null;const o=String(u).trim().toUpperCase();return o===""?null:o}function W(u){if(L(u))return null;if(typeof u=="object"&&!Array.isArray(u)){const o=Number(u.amount),g=F(u.code);return!g||!Number.isFinite(o)?null:{amount:o,code:g}}if(Array.isArray(u)&&u.length===2){const o=Number(u[0]),g=F(u[1]);return!g||!Number.isFinite(o)?null:{amount:o,code:g}}return null}const Q=Object.freeze({$:"USD","€":"EUR","£":"GBP","¥":"JPY","₹":"INR","₩":"KRW","₽":"RUB","₺":"TRY","₴":"UAH","₪":"ILS"}),G=Object.freeze({USD:"$",EUR:"€",GBP:"£",JPY:"¥",INR:"₹",KRW:"₩",RUB:"₽",TRY:"₺",UAH:"₴",ILS:"₪"}),H=/[+-]?[\d\s., ]*\d/;function U(u,o){const g=String(u).trim();if(g==="")return null;const d=new Intl.NumberFormat(o||void 0).formatToParts(1.1).find(w=>w.type==="decimal")?.value||".",h=d===","?".":",",a=g.split(h).join("").split(/[\s ]/).join("").replace(d,"."),p=Number(a);return Number.isFinite(p)?p:null}function D(u,o){const g=o||{},d=F(g.code);if(L(u))return null;const h=W(u);if(h)return h;if(typeof u=="number")return Number.isFinite(u)&&d?{amount:u,code:d}: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 w=null;for(const[P,x]of Object.entries(Q)){if(a.startsWith(P)){w=x,a=a.slice(P.length).trim();break}if(a.endsWith(P)){w=x,a=a.slice(0,-P.length).trim();break}}const k=H.exec(a);if(!k)return null;const m=U(k[0],g.locale);if(m===null)return null;const b=(a.slice(0,k.index)+" "+a.slice(k.index+k[0].length)).trim();!w&&b!==""&&(w=F(b));const C=w||d;return C?{amount:p?-m:m,code:C}:null}function v(u,o){if(typeof u=="function")return(g,d)=>{if(g===d)return 1;const h=u(g,d);return typeof h=="number"&&Number.isFinite(h)&&h>0?h:null};if(u&&typeof u=="object"){const g=u;return(d,h)=>{if(d===h)return 1;const a=Number(g[d]),p=Number(g[h]);return!Number.isFinite(a)||!Number.isFinite(p)||a<=0||p<=0?null:p/a}}return(g,d)=>g===d?1:null}function S(u,o,g){if(!u)return null;if(u.code===o)return u.amount;const d=g(u.code,o);return d===null?null:u.amount*d}const y=new Map;function l(u,o,g){const d=`${u||""}|${o}|${g??""}`;let h=y.get(d);if(!h){const a={style:"currency",currency:o};typeof g=="number"&&(a.minimumFractionDigits=g,a.maximumFractionDigits=g);try{h={fmt:new Intl.NumberFormat(u||void 0,a),currency:!0}}catch{h={fmt:new Intl.NumberFormat(u||void 0,typeof g=="number"?{minimumFractionDigits:g,maximumFractionDigits:g}:{}),currency:!1}}y.set(d,h)}return h}function c(u,o){const g=o||{},d=g.nullDisplay??"",h=W(u);if(!h)return d;const a=F(g.display)||h.code;let p=h.amount,w=h.code;if(a!==h.code){const b=g.rateFn||v(g.rates,g.rateBase),C=S(h,a,b);if(C===null)return`${g.missingRate??B} ${h.code}→${a}`;p=C,w=a}const{fmt:k,currency:m}=l(g.locale,w,g.decimals);return m?k.format(p):`${k.format(p)} ${w}`}function i(u){const o=W(u);return o?`${o.amount} ${o.code}`:""}function n(u){const o=u||{},g=F(o.display),d=o.rateFn||v(o.rates,o.rateBase);return(h,a)=>{const p=W(h),w=W(a);if(!p&&!w)return 0;if(!p)return 1;if(!w)return-1;if(g){const k=S(p,g,d),m=S(w,g,d);if(k!==null&&m!==null)return k===m?0:k<m?-1:1}return p.code===w.code?p.amount===w.amount?0:p.amount<w.amount?-1:1:p.code<w.code?-1:1}}function t(u){const o=u||{},g=(h,a)=>{const p=[];for(const C of h||[]){const M=W(C);M&&p.push(M)}if(!p.length)return null;if(new Set(p.map(C=>C.code)).size===1){const C=p[0].code;return{amount:a(p.map(M=>M.amount)),code:C}}const k=F(o.display);if(!k)return`${o.missingRate??B}: mixed currencies, no display currency set`;const m=o.rateFn||v(o.rates,o.rateBase),b=[];for(const C of p){const M=S(C,k,m);if(M===null)return`${o.missingRate??B}: ${C.code}→${k}`;b.push(M)}return{amount:a(b),code:k}},d=h=>h.reduce((a,p)=>a+p,0);return{sum:h=>g(h,d),avg:h=>g(h,a=>d(a)/a.length),min:h=>g(h,a=>Math.min(...a)),max:h=>g(h,a=>Math.max(...a))}}function r(u){const o=Object.freeze({code:"USD",...u||{}}),g=v(o.rates,o.rateBase),d=Object.freeze({...o,rateFn:g}),h=t(d),a=n(d),p=new Map([[o.locale||"",d]]),w=b=>{const C=b||"";let M=p.get(C);return M||(M=Object.freeze({...d,locale:b||void 0}),p.set(C,M)),M},k=G[F(o.display||o.code)]||"",m=typeof o.decimals=="number"&&o.decimals>0?`.${"0".repeat(o.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:d,format:b=>c(b.value,b.locale?w(b.locale):d),parse:b=>D(b.text,b.locale?w(b.locale):d),compare:a,defaults:{filter:"number",editor:"currency",align:"end",total:"sum"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:h},excel:o.excel||(k?`"${k}"#,##0${m}`:`#,##0${m}`),toStorage:b=>{const C=W(b);return C||(typeof b=="string"||typeof b=="number"?D(b,d):null)},toClipboard:b=>i(b),fromClipboard:b=>D(b,d)}}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})}),f=r}),xe("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 U}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return c}}),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 f}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return P}});const X=K("packages/core/src/columns/types/temporal.js"),L=X.TEMPORAL_TYPES,B=K("packages/core/src/columns/types/network.js"),F=B.NETWORK_TYPES,W=K("packages/core/src/columns/types/structured.js"),Q=W.STRUCTURED_TYPES,G=K("packages/core/src/columns/types/unit.js"),H=G.createUnitType,U=G.UNIT_SYSTEMS,D=G.parseUnit,v=G.formatUnit,S=G.registerUnitSystem,y=G.unitSystemNames,l=G.unitsOf,c=G.defineUnit,i=K("packages/core/src/columns/types/engineering.js"),n=i.ENGINEERING_TYPES,t=K("packages/core/src/columns/types/si.js"),r=t.SI_TYPES,s=t.createSiType,f=t.createSiSystem,u=t.siUnits,o=t.SI_PREFIXES,g=K("packages/core/src/columns/types/temperature.js"),d=g.TEMPERATURE_TYPES,h=g.createTemperatureType,a=g.convertTemperature,p=g.formatTemperature,w=g.parseTemperature,k=g.TEMPERATURE_SCALES,m=K("packages/core/src/columns/types/radix.js"),b=m.createRadixType,C=m.RADIX_PRESETS,M=m.parseRadix,P=m.formatRadix,x=K("packages/core/src/columns/types/aggregable.js"),E=x.AGGREGABLE_TYPES,A=K("packages/core/src/columns/types/currency.js"),j=A.CURRENCY_TYPES,$=A.createCurrencyType,z=A.parseMoney,T=A.formatMoney,R=A.convertMoney,O=A.toMoney,I=A.rateFunction,q=A.moneyComparator,Z=A.normaliseCode,_=A.MISSING_RATE;Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return G.findUnit}}),Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return i.ENGINEERING_TYPES}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return i.circularMean}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return g.TEMPERATURE_TYPES}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return g.createTemperatureType}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return g.convertTemperature}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return g.formatTemperature}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return g.parseTemperature}}),Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return g.TEMPERATURE_SCALES}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return g.findScale}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return A.CURRENCY_TYPES}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return A.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return A.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return A.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return A.convertMoney}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return A.toMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return A.rateFunction}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return A.moneyComparator}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return A.normaliseCode}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return A.MISSING_RATE}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return X.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 W.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 X.parseTime}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return X.formatTime}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return X.parseDateTime}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return X.formatDateTime}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return X.parseDuration}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return X.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 W.maskValue}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return W.summariseJson}});const J=Object.freeze({...L,...F,...Q,...E,hex:b(C.hex),hex8:b(C.hex8),hex16:b(C.hex16),hex32:b(C.hex32),binary:b(C.binary),binary8:b(C.binary8),octal:b(C.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,...d,...j});{const ee=new Set;for(const te of[L,F,Q,E,n,r,d,j])for(const ne of Object.keys(te)){if(ee.has(ne))throw new Error(`[lattice] data type "${ne}" is declared twice`);ee.add(ne)}}}),xe("packages/core/src/compute/handle.js",function(e,K){"use strict";Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return t}});const X=K("packages/core/src/internal/util.js"),L=X.collator,B=X.defaultCompare,F=X.warnOnce;function W(r){const s=new Uint32Array(r);for(let f=0;f<r;f++)s[f]=f;return s}function Q(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 f=r.values;return r.kind==="multi"&&r.offsets?Math.max(0,r.offsets.length-1):f?r.kind==="bitset"?typeof f.size=="number"?f.size:r.presence&&typeof r.presence.size=="number"?r.presence.size:(F(`count:${r.id}`,`column "${r.id}" is bitset-backed with no declared row count; assuming ${f.length*8}`),f.length*8):f.length:r.presence&&typeof r.presence.size=="number"?r.presence.size:0}const G=new WeakMap;function H(r){const s=r.constructor;if(!s)return"unknown";const f=G.get(s);if(f)return f;let u="unknown";try{let o=null;typeof s.from=="function"?o=s.from([!1,!0]):(o=new s(8),o.set(1));const g=o&&o.words;g&&g.length&&(g[0]===2?u="lsb":g[0]===64&&(u="msb"))}catch{u="unknown"}return G.set(s,u),u}function U(r){if(!r)return()=>0;const s=r instanceof Uint8Array?r:r.words;if(s instanceof Uint8Array){const f=r instanceof Uint8Array?"lsb":H(r);if(f==="lsb")return u=>s[u>>>3]>>>(u&7)&1;if(f==="msb")return u=>s[u>>>3]>>>7-(u&7)&1}return typeof r.get=="function"?f=>r.get(f)?1:0:()=>0}function D(r){return!r||!r.presence?null:U(r.presence)}function v(r){return r?typeof r.size=="number"?r.size:typeof r.values=="function"?r.values().length:0:0}function S(r,s){return r?typeof r.valueOf=="function"?r.valueOf(s):typeof r.values=="function"?r.values()[s]:null:null}function y(r,s){const f=r.offsets,u=r.values;if(!f||!u)return[];const o=f[s],g=f[s+1];if(!(g>o))return[];const d=r.dict,h=new Array(g-o);for(let a=o;a<g;a++)h[a-o]=d?S(d,u[a]):u[a];return h}function l(r){if(!r)return()=>{};const s=r.values,f=D(r),u=r.kind;if(u==="dictionary"){const o=r.dict;return f?g=>f(g)?S(o,s[g]):null:g=>S(o,s[g])}if(u==="bitset"){const o=U(s);return f?g=>f(g)?o(g)===1:null:g=>o(g)===1}if(u==="multi")return f?o=>f(o)?y(r,o):null:o=>y(r,o);if(!s&&typeof r.get=="function"){const o=r.get.bind(r);return g=>{const d=o(g);return d===void 0?null:d}}return f?o=>{if(!f(o))return null;const g=s[o];return g===void 0?null:g}:o=>{const g=s[o];return g===void 0?null:g}}function c(r,s){if(r<s)return-1;if(r>s)return 1;if(r===s){const o=Object.is(r,-0),g=Object.is(s,-0);return o===g?0:o?-1:1}const f=Number.isNaN(r),u=Number.isNaN(s);return f&&u?0:f?1:-1}function i(r){const s=L(r);return(f,u)=>{if(f===u)return 0;const o=typeof f,g=typeof u;if(o==="string"&&g==="string")return s.compare(f,u);if(o==="number"&&g==="number")return c(f,u);if(o==="boolean"&&g==="boolean")return f===u?0:f?1:-1;if(f instanceof Date||u instanceof Date){const d=f instanceof Date?f.getTime():Number(f),h=u instanceof Date?u.getTime():Number(u);return c(d,h)}return B(f,u)}}function n(r,s){if(r&&typeof r.ranks=="function")return r.ranks(s);const f=r&&typeof r.values=="function"?r.values():[],u=f.length,o=i(s),g=new Array(u);for(let h=0;h<u;h++)g[h]=h;g.sort((h,a)=>o(f[h],f[a])||h-a);const d=new Uint32Array(u);for(let h=0;h<u;h++)d[g[h]]=h;return d}function t(r){return r==null||typeof r=="number"&&Number.isNaN(r)}}),xe("packages/core/src/compute/filter.js",function(e,K){"use strict";Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"itemwisePredicate",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"declareOperators",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"declaredOperator",{enumerable:!0,get:function(){return Z}});const X=K("packages/core/src/internal/util.js"),L=X.isBlank,B=X.toArray,F=X.warnOnce,Q=K("packages/core/src/format/date.js").toIsoDate,G=K("packages/core/src/compute/handle.js"),H=G.bitReader,U=G.dictSize,D=G.dictValue,v=G.presenceReader,S=G.valueComparator,y=G.valueReader,l=/^\d{4}-\d{2}-\d{2}$/,c="\0null\0";function i(_,J){const ee=_&&_.pool;if(ee){const te=ee.mask||ee.acquireMask||ee.acquire||ee.take;if(typeof te=="function"){const ne=te.call(ee,J);if(ne&&ne.length>=J)return ne}}return new Uint8Array(J)}function n(_,J){const ee=_&&_.pool;if(!ee||!J)return;const te=ee.release||ee.releaseMask||ee.free||ee.recycle;typeof te=="function"&&te.call(ee,J)}function t(_,J,ee){return _.fill(ee,0,J),_}function r(_){return _==null||typeof _=="number"&&Number.isNaN(_)}function s(_,J){if(_==null)return _;if(J==="number")return typeof _=="number"?_:Number(_);if(J==="date"||J==="dateString"){const ee=Q(_);return ee===null?f(_):ee}return J==="boolean"?typeof _=="boolean"?_:_==="true"||_===1?!0:_==="false"||_===0?!1:!!_:_}function f(_){return _ instanceof Date?_.getTime():typeof _=="number"?_:Date.parse(String(_))}function u(_){return typeof _=="number"?_:_ instanceof Date?_.getTime():_==null||_===""?NaN:Number(_)}function o(_,J){const ee=typeof _=="string"?_:String(_);return J?ee:ee.toLowerCase()}function g(_,J){return _==null?c:typeof _=="string"?J?_:_.toLowerCase():_ instanceof Date?_.getTime():_}function d(_,J,ee){const te=new Set;for(const ne of B(_)){const ie=s(ne,ee);te.add(g(ie,J)),typeof ie=="string"&&ie!==""&&Number.isFinite(Number(ie))?te.add(Number(ie)):typeof ie=="number"&&Number.isFinite(ie)&&te.add(g(String(ie),J))}return te}function h(_,J,ee){if(_==null||J===null||J===void 0)return _==null&&J==null;const te=typeof _,ne=typeof J;return te==="string"&&ne==="string"?ee?_===J:_.toLowerCase()===J.toLowerCase():_ instanceof Date||J instanceof Date?f(_)===f(J):te==="number"&&ne==="number"?_===J||Number.isNaN(_)&&Number.isNaN(J):te==="number"&&ne==="string"?_===Number(J):te==="string"&&ne==="number"?Number(_)===J:te==="boolean"||ne==="boolean"?_===J:Array.isArray(_)&&Array.isArray(J)?_.length===J.length&&_.every((ie,ae)=>h(ie,J[ae],ee)):_===J}function a(_,J){try{if(_ instanceof RegExp){const ee=_.flags.replace(/[gy]/g,"");return new RegExp(_.source,J||ee.includes("i")?ee:`${ee}i`)}return new RegExp(String(_),J?"":"i")}catch(ee){return F(`regex:${String(_)}`,`filter operator "matches" received an invalid pattern: ${String(_)}`,ee),null}}function p(_,J){const ee=w(_,J),te=_&&_.type;return te!=="date"&&te!=="dateString"?ee:ne=>ee(typeof ne=="string"&&l.test(ne)?ne:Q(ne)??ne)}function w(_,J){const ee=_&&_.op,te=!!(_&&_.caseSensitive),ne=_&&_.type,ie=S(J),ae=re=>se=>!re(se);switch(ee){case"eq":{const re=s(_.value,ne);return se=>h(se,re,te)}case"ne":{const re=s(_.value,ne);return se=>!h(se,re,te)}case"lt":case"lte":case"gt":case"gte":{const re=s(_.value,ne);if(r(re))return()=>!1;const se=ee==="lt"?-1:ee==="lte"?0:ee==="gt"?1:2;return le=>{if(r(le))return!1;const fe=ie(le,re);return se===-1?fe<0:se===0?fe<=0:se===1?fe>0:fe>=0}}case"between":case"notBetween":{const re=B(_.value),se=s(re[0],ne),le=s(re[1],ne),fe=_.bounds||"[]",be=fe.charAt(0)!=="(",Le=fe.charAt(1)!==")";if(r(se)||r(le))return ee==="between"?()=>!1:()=>!0;const we=Re=>{if(r(Re))return!1;const ge=ie(Re,se),he=ie(Re,le);return(be?ge>=0:ge>0)&&(Le?he<=0:he<0)};return ee==="between"?we:ae(we)}case"in":case"notIn":{const re=d(_.value,te,ne),se=le=>re.has(g(le,te));return ee==="in"?se:ae(se)}case"contains":case"notContains":{const re=o(s(_.value,ne),te),se=le=>le==null?!1:o(le,te).includes(re);return ee==="contains"?se:ae(se)}case"startsWith":{const re=o(s(_.value,ne),te);return se=>se==null?!1:o(se,te).startsWith(re)}case"endsWith":{const re=o(s(_.value,ne),te);return se=>se==null?!1:o(se,te).endsWith(re)}case"matches":{const re=a(_.value,te);return re?se=>se==null?!1:re.test(String(se)):()=>!1}case"blank":return re=>L(re)||Array.isArray(re)&&re.length===0;case"notBlank":return re=>!(L(re)||Array.isArray(re)&&re.length===0);case"containsAny":case"containsNone":{const re=d(_.value,te,ne),se=le=>{const fe=le==null?[]:B(le);for(let be=0;be<fe.length;be++)if(re.has(g(fe[be],te)))return!0;return!1};return ee==="containsAny"?se:ae(se)}case"containsAll":{const re=B(_.value).map(se=>g(s(se,ne),te));return se=>{const le=se==null?[]:B(se);if(re.length===0)return!0;const fe=new Set(le.map(be=>g(be,te)));for(let be=0;be<re.length;be++)if(!fe.has(re[be]))return!1;return!0}}default:{const re=Z(ee);return re?re.compile(_.value):(F(`op:${String(ee)}`,`unknown filter operator "${String(ee)}"; the condition is refused rather than matching every row`),()=>!1)}}}function k(_,J,ee){return p(J,ee)(_)}const m=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),b=new Set(["containsAny","containsAll","containsNone"]);function C(_,J,ee){const te=_&&_.op,ne=m[te]||te,ie=p({..._,op:ne,type:J.type},ee),ae=J.items,re=se=>{const le=ae(se);if(!le)return!1;for(let fe=0;fe<le.length;fe++)if(ie(le[fe]))return!0;return!1};return m[te]?se=>!re(se):re}function M(_,J,ee,te){const ne=v(_);if(ne){const re=J?1:0;for(let se=0;se<te;se++)ee[se]=ne(se)===re?1:0;return ee}const ie=_.kind;if(ie==="float64"||ie==="int32"||ie==="bitset")return t(ee,te,J?1:0);const ae=y(_);for(let re=0;re<te;re++){const se=ae(re),le=L(se)||Array.isArray(se)&&se.length===0;ee[re]=le===J?0:1}return ee}function P(_,J,ee,te){const ne=_.dict,ie=U(ne),ae=new Uint8Array(ie);for(let fe=0;fe<ie;fe++)ae[fe]=J(D(ne,fe))?1:0;const re=_.values,se=v(_);if(!se){for(let fe=0;fe<te;fe++)ee[fe]=ae[re[fe]];return ee}const le=J(null)?1:0;for(let fe=0;fe<te;fe++)ee[fe]=se(fe)===1?ae[re[fe]]:le;return ee}function x(_,J,ee,te){const ne=H(_.values),ie=J(!0)?1:0,ae=J(!1)?1:0,re=v(_);if(!re){for(let le=0;le<te;le++)ee[le]=ne(le)===1?ie:ae;return ee}const se=J(null)?1:0;for(let le=0;le<te;le++)ee[le]=re(le)===0?se:ne(le)===1?ie:ae;return ee}function E(_,J,ee,te,ne){const ie=_.values,ae=J.type,re=J.op;let se=!0;switch(re){case"eq":case"ne":{const fe=u(s(J.value,ae)),be=typeof J.value=="number"&&Number.isNaN(J.value),Le=re==="ne"?1:0;if(be)for(let we=0;we<ne;we++)te[we]=(Number.isNaN(ie[we])?1:0)^Le;else for(let we=0;we<ne;we++)te[we]=(ie[we]===fe?1:0)^Le;break}case"lt":{const fe=u(s(J.value,ae));for(let be=0;be<ne;be++)te[be]=ie[be]<fe?1:0;break}case"lte":{const fe=u(s(J.value,ae));for(let be=0;be<ne;be++)te[be]=ie[be]<=fe?1:0;break}case"gt":{const fe=u(s(J.value,ae));for(let be=0;be<ne;be++)te[be]=ie[be]>fe?1:0;break}case"gte":{const fe=u(s(J.value,ae));for(let be=0;be<ne;be++)te[be]=ie[be]>=fe?1:0;break}case"between":case"notBetween":{const fe=B(J.value),be=u(s(fe[0],ae)),Le=u(s(fe[1],ae)),we=J.bounds||"[]",Re=we.charAt(0)!=="(",ge=we.charAt(1)!==")",he=re==="notBetween"?1:0;if(Re&&ge)for(let Oe=0;Oe<ne;Oe++)te[Oe]=(ie[Oe]>=be&ie[Oe]<=Le?1:0)^he;else if(Re)for(let Oe=0;Oe<ne;Oe++)te[Oe]=(ie[Oe]>=be&ie[Oe]<Le?1:0)^he;else if(ge)for(let Oe=0;Oe<ne;Oe++)te[Oe]=(ie[Oe]>be&ie[Oe]<=Le?1:0)^he;else for(let Oe=0;Oe<ne;Oe++)te[Oe]=(ie[Oe]>be&ie[Oe]<Le?1:0)^he;break}case"in":case"notIn":{const fe=new Set;for(const Le of B(J.value)){const we=u(s(Le,ae));Number.isNaN(we)||fe.add(we)}const be=re==="notIn"?1:0;for(let Le=0;Le<ne;Le++)te[Le]=(fe.has(ie[Le])?1:0)^be;break}default:se=!1;break}if(!se)return!1;const le=v(_);if(le){const fe=ee(null)?1:0;for(let be=0;be<ne;be++)le(be)===0&&(te[be]=fe)}return!0}function A(_,J,ee,te){const ne=y(_);for(let ie=0;ie<te;ie++)ee[ie]=J(ne(ie))?1:0;return ee}function j(_,J,ee){const te=J.count|0,ne=ee||i(J,te);if(!_)return t(ne,te,1);const ie=typeof J.handle=="function"?J.handle(_.col):void 0,ae=typeof J.custom=="function"?J.custom:null;if(!ie){if(ae){for(let fe=0;fe<te;fe++)ne[fe]=ae(_,fe)?1:0;return ne}return F(`filter:col:${String(_.col)}`,`filter references unknown column "${String(_.col)}"; the condition is refused rather than matching every row`),t(ne,te,0)}const re=_.op;if(re==="blank"||re==="notBlank")return M(ie,re==="notBlank",ne,te);const se=typeof J.itemwise=="function"?J.itemwise(_.col):null;if(se&&!Z(re)&&!b.has(re))return A(ie,C(_,se,J.locale),ne,te);const le=p(_,J.locale);switch(ie.kind){case"dictionary":return P(ie,le,ne,te);case"bitset":return x(ie,le,ne,te);case"float64":case"int32":return E(ie,_,le,ne,te)?ne:A(ie,le,ne,te);default:return A(ie,le,ne,te)}}function $(_,J,ee){if(!_)return t(i(J,ee),ee,1);if(Array.isArray(_.conditions)){const te=_.conditions.filter(ae=>ae!=null),ne=_.op==="or"?"or":_.op==="not"?"not":"and";if(te.length===0)return t(i(J,ee),ee,1);const ie=$(te[0],J,ee);for(let ae=1;ae<te.length;ae++){const re=$(te[ae],J,ee);if(ne==="or")for(let se=0;se<ee;se++)ie[se]|=re[se];else for(let se=0;se<ee;se++)ie[se]&=re[se];n(J,re)}if(ne==="not")for(let ae=0;ae<ee;ae++)ie[ae]^=1;return ie}return j(_,J,i(J,ee))}function z(_,J){return $(_,J,J.count|0)}function T(_,J){if(!_||!J)return _||null;const ee=_;if(Array.isArray(ee.conditions)){if((ee.op==="or"?"or":ee.op==="not"?"not":"and")!=="and")return R(ee,J)?null:_;const ne=[];for(const ie of ee.conditions){const ae=T(ie,J);ae&&ne.push(ae)}return ne.length?{...ee,op:"and",conditions:ne}:null}return ee.col===J?null:_}function R(_,J){if(!_||typeof _!="object")return!1;const ee=_;if(ee.col===J)return!0;if(Array.isArray(ee.conditions)){for(const te of ee.conditions)if(R(te,J))return!0}return!1}function O(_,J,ee){if(ee&&ee.length>=J){let ae=0;for(let re=0;re<J;re++)_[re]&&(ee[ae++]=re);return ee.subarray(0,ae)}let te=0;for(let ae=0;ae<J;ae++)te+=_[ae]?1:0;const ne=new Uint32Array(te);let ie=0;for(let ae=0;ae<J;ae++)_[ae]&&(ne[ie++]=ae);return ne}const I=new Map;function q(_){if(!(!_||typeof _!="object"))for(const[J,ee]of Object.entries(_))ee&&typeof ee.compile=="function"&&I.set(J,ee)}function Z(_){return typeof _=="string"?I.get(_):void 0}}),xe("packages/core/src/columns/datatypes.js",function(e,K){"use strict";Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"parseNumberText",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"BUILTIN_TYPES",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"INFERENCE_ORDER",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"createTypeRegistry",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"comparatorFor",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"storageKind",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"typeLabel",{enumerable:!0,get:function(){return j}});const X=K("packages/core/src/internal/util.js"),L=X.collator,B=X.defaultCompare,F=X.isNil,W=X.isObject,Q=X.isFunction,G=X.fail,H=X.titleCase,U=K("packages/core/src/format/date.js"),D=U.toDate,v=U.toIsoDate,S=U.compareIso,l=K("packages/core/src/format/boolean.js").toTriState,i=K("packages/core/src/columns/types/index.js").EXTENDED_TYPES,n=K("packages/core/src/formula/index.js"),t=n.evaluateFormula,r=n.looksLikeFormula,f=K("packages/core/src/compute/filter.js").declareOperators,u=/^\d{4}-\d{2}-\d{2}$/;function o($){return $.getHours()===0&&$.getMinutes()===0&&$.getSeconds()===0&&$.getMilliseconds()===0}const g=new Map;function d($){const z=$||"",T=g.get(z);if(T)return T;const R={group:",",decimal:"."};try{for(const O of new Intl.NumberFormat($||void 0).formatToParts(12345.6))O.type==="group"?R.group=O.value:O.type==="decimal"&&(R.decimal=O.value)}catch{}return g.set(z,R),R}const h=/\d\s*[*/^]\s*[\d.(]/;function a($,z){if(F($))return null;let T=String($).trim();if(T===""||T.startsWith("=")||h.test(T))return null;let R=1;T.startsWith("(")&&T.endsWith(")")&&(R=-1,T=T.slice(1,-1));const O=T.endsWith("%"),{group:I,decimal:q}=d(z);if(T=T.replace(/[\s\u00a0\u202f\u2009']/g,""),I&&I!=="."&&I!==","&&(T=T.split(I).join("")),T=T.replace(/[^0-9eE+\-.,]/g,""),q===","?T=T.split(".").join("").replace(",","."):T=T.split(",").join(""),T===""||T==="-"||T==="+")return null;const Z=Number(T);return Number.isNaN(Z)?null:R*(O?Z/100:Z)}function p($,z){const T=F($)||Number.isNaN($)?null:Number($),R=F(z)||Number.isNaN(z)?null:Number(z);return T===null?R===null?0:1:R===null||T<R?-1:T>R?1:0}function w($,z){const T=l($),R=l(z);return T===null?R===null?0:1:R===null?-1:T===R?0:T?1:-1}function k($,z){const T=D($),R=D(z);if(!T)return R?1:0;if(!R)return-1;const O=T.getTime(),I=R.getTime();return O<I?-1:O>I?1:0}const m=new Map;function b($){const z=D($.value);if(!z)return"";const T=$.locale||"";let R=m.get(T);return R||(R=new Intl.DateTimeFormat($.locale||void 0,{dateStyle:"medium"}),m.set(T,R)),R.format(z)}const C={boolean:{base:"boolean",storage:"bitset",matches:$=>typeof $=="boolean",parse:$=>l($.text),compare:w,format:$=>l($.value)===null?"":l($.value)?"Yes":"No",defaults:{filter:"set",editor:"checkbox",align:"center"},excel:"General",toClipboard:$=>l($)===null?"":String(l($)),fromClipboard:$=>l($)},number:{base:"number",storage:"float64",matches:$=>typeof $=="number"&&!Number.isNaN($),parse:$=>{if(r($.text)){const z=t($.text,$);if(!z.ok)return null;const T=Number(z.value);return Number.isFinite(T)?T:null}return a($.text,$.locale)},compare:p,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:$=>F($)?"":String($),fromClipboard:($,z)=>a($,z&&z.locale)},date:{base:"dateString",storage:"dictionary",matches:$=>typeof $=="string"&&u.test($)&&!Number.isNaN(Date.parse($))||$ instanceof Date&&!Number.isNaN($.getTime())&&o($),parse:$=>v($.text),compare:S,format:b,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:$=>v($),toClipboard:$=>F($)?"":String($),fromClipboard:$=>v($)},dateString:{base:"dateString",storage:"dictionary",matches:$=>typeof $=="string"&&u.test($)&&!Number.isNaN(Date.parse($)),parse:$=>v($.text),compare:S,format:b,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:$=>v($),toClipboard:$=>F($)?"":String($),fromClipboard:$=>v($)},text:{base:"text",storage:"dictionary",matches:$=>typeof $=="string",parse:$=>$.text===""?null:String($.text),compare:($,z)=>F($)?F(z)?0:1:F(z)?-1:L().compare(String($),String(z)),defaults:{filter:"text",editor:"text",align:"start"},excel:"@",toClipboard:$=>F($)?"":String($),fromClipboard:$=>$},image:{base:"text",storage:"dictionary",parse:$=>$.text===""||$.text==null?null:String($.text).trim(),compare:($,z)=>F($)?F(z)?0:1:F(z)?-1:L().compare(String($),String(z)),defaults:{filter:"text",editor:"text",align:"center",render:"image"},excel:"@",toClipboard:$=>F($)?"":String($),fromClipboard:$=>$},lookup:{base:"text",storage:"dictionary",parse:$=>{if($.text===""||$.text==null)return null;const z=$.column&&$.column.lookup,T=z&&Q(z.options)?z.options():null;if(!T)return $.text;const R=String($.text),O=T.find(Z=>String(Z.id)===R);if(O)return O.id;const I=R.trim().toLowerCase(),q=T.find(Z=>String(Z.label).toLowerCase()===I);return q?q.id:$.text},compare:B,defaults:{filter:"set",editor:"select",align:"start"},excel:"@",multiStorage:"multi",toClipboard:$=>F($)?"":String($),fromClipboard:$=>$},object:{base:"object",storage:"object",matches:$=>$!==null&&typeof $=="object"&&!($ instanceof Date),parse:$=>{try{return $.text===""?null:JSON.parse($.text)}catch{return $.text}},compare:($,z)=>B($,z),format:$=>{const z=$.value;if(F(z))return"";if(typeof z=="string")return z;try{return JSON.stringify(z)}catch{return String(z)}},defaults:{filter:"none",editor:"none",align:"start"},excel:"@",toClipboard:$=>F($)?"":typeof $=="string"?$:JSON.stringify($),fromClipboard:$=>$}},M=["boolean","number","date","dateString","datetime","text","object"];function P($,z,T,R){const O=T.get($);if(O)return O;R.includes($)&&G(`circular data type extends chain: ${[...R,$].join(" → ")}`);const I=z[$];I||G(`unknown data type "${$}"`);let q=null;I.extends&&(q=P(I.extends,z,T,[...R,$]));const Z={...q||{},...I,name:$,defaults:{...q&&q.defaults||{},...I.defaults||{}}};return Z.base||(Z.base=q&&q.base||"text"),Z.storage||(Z.storage=q&&q.storage||"object"),T.set($,Z),Z}function x($,z){const T={...C,...i};if(z&&typeof z.dataType=="function"&&typeof z.names=="function")for(const O of z.names("dataType")){const I=z.dataType(O);I&&(T[O]=I)}if(W($))for(const[O,I]of Object.entries($))T[O]=I;const R=new Map;for(const O of M)P(O,T,R,[]);P("lookup",T,R,[]);for(const O of Object.keys(T))P(O,T,R,[]);for(const O of R.values())f(O.operators);return R}function E($,z){if($.base==="text"&&(!$.compare||$.compare===C.text.compare)){const T=L(z);return(R,O)=>F(R)?F(O)?0:1:F(O)?-1:T.compare(String(R),String(O))}return $.compare||B}function A($,z){return z?$.multiStorage||"multi":$.storage||"object"}function j($){return H(String($).replace(/([a-z])([A-Z])/g,"$1 $2"))}}),xe("packages/core/src/columns/infer.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_SAMPLE",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"inferFromValues",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"inferColumnType",{enumerable:!0,get:function(){return Q}});const X=K("packages/core/src/internal/util.js"),L=X.infoOnce,B=X.isNil,F=100;function W(G,H,U={}){const D=U.sampleSize??F,v=[];for(let S=0;S<G.length&&v.length<D;S++){const y=G[S];B(y)||typeof y=="number"&&Number.isNaN(y)||v.push(y)}if(v.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[S,y]of H){if(typeof y.matches!="function")continue;let l=!0;for(let c=0;c<v.length;c++)if(!y.matches(v[c])){l=!1;break}if(l)return{type:S,unanimous:!0,sampled:v.length}}return U.quiet||L(`infer:${U.colId||"?"}`,`column "${U.colId||"?"}" has mixed or ambiguous values and was inferred as "text". Declare \`type\` on the column to get correct sorting, filtering and export.`),{type:"text",unanimous:!1,sampled:v.length}}function Q(G,H,U,D,v={}){const S=v.sampleSize??F,y=[];for(let l=0;l<H.length&&y.length<S;l++){const c=U(H[l]);B(c)||typeof c=="number"&&Number.isNaN(c)||y.push(c)}return W(y,D,{...v,colId:G}).type}}),xe("packages/core/src/columns/graph.js",function(e,K){"use strict";Object.defineProperty(e,"WHOLE_ROW",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"declarationOf",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"affectedBy",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return D}});const X=K("packages/core/src/internal/util.js"),L=X.DEV,B=X.fail,F=X.isFunction,W=X.warnOnce,Q="*";function G(v){const S=v.value||{};if(!F(S.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const l=S.pure!==!1;return S.deps===Q?{computed:!0,wholeRow:!0,deps:[],pure:l}:Array.isArray(S.deps)?{computed:!0,wholeRow:!1,deps:S.deps.slice(),pure:l}:(W(`deps:missing:${v.id}`,`computed column "${v.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(v){const S=new Map;for(const g of v)S.set(g.id,g);const y=new Map,l=new Map,c=new Set,i=new Set,n=new Set,t=new Set;for(const g of v){const d=G(g);if(!d.computed){y.set(g.id,[]);continue}i.add(g.id),(d.pure?n:t).add(g.id),d.wholeRow&&c.add(g.id);const h=[],a=[];for(const p of d.deps)(S.has(p)?h:a).push(p);y.set(g.id,h),a.length&&l.set(g.id,a)}for(const g of n)for(const d of y.get(g))t.has(d)&&B(`pure computed column "${g}" depends on impure column "${d}". Mark it \`value.pure: false\` or make the dependency pure.`);const r=[],s=new Map,f=[],u=g=>{const d=s.get(g);if(d!=="done"){if(d==="open"){const h=f.indexOf(g);B(`circular column dependency: ${[...f.slice(h),g].join(" → ")}`)}s.set(g,"open"),f.push(g);for(const h of y.get(g)||[])S.has(h)&&u(h);f.pop(),s.set(g,"done"),r.push(g)}};for(const g of v)u(g.id);const o=new Map;for(const g of v)o.set(g.id,[]);for(const g of v)for(const d of y.get(g.id)||[]){const h=o.get(d);h&&!h.includes(g.id)&&h.push(g.id)}if(c.size)for(const g of v){if(i.has(g.id))continue;const d=o.get(g.id);for(const h of c)d.includes(h)||d.push(h)}return{order:r,dependents:o,pure:n,impure:t,computed:i,deps:y,wholeRow:c,external:l,index:S}}function U(v,S){const y=Array.isArray(S)?S:[S],l=new Set,c=[...y];for(;c.length;){const i=c.shift();for(const n of v.dependents.get(i)||[])l.has(n)||(l.add(n),c.push(n))}for(const i of y)l.delete(i);return v.order.filter(i=>l.has(i))}function D(v,S,y){if(!L)return v;const l=S instanceof Set?S:new Set(S);return new Proxy(v,{get(c,i){return typeof i=="string"&&!l.has(i)&&!Object.hasOwn(c,i)&&W(`undeclared:${y}:${i}`,`computed column "${y}" read undeclared dependency "${i}". Add it to \`value.deps\` or the value will go stale.`),c[i]}})}}),xe("packages/core/src/model/rowkey.js",function(e,K){"use strict";Object.defineProperty(e,"KEY_DEPENDENT_FEATURES",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"compositeKey",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"warnMissingKeys",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"groupPathKey",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"splitPathKey",{enumerable:!0,get:function(){return c}});const X=K("packages/core/src/internal/util.js"),L=X.warnOnce,B=X.pathGetter,F=X.isFunction,W=X.isBlank,Q=["changes (rows.apply / rows.queue)","streaming dedupe","selection persistence","remote reload","cell comments"],G="";function H(i){if(i===null)return"\0n";if(i===void 0)return"\0u";const n=typeof i;if(n==="string")return i;if(n==="number"||n==="bigint"||n==="boolean")return String(i);if(i instanceof Date)return`\0d${i.getTime()}`;try{return`\0o${JSON.stringify(i)}`}catch{return"\0o?"}}function U(i){if(i.length===1)return H(i[0]);let n="";for(let t=0;t<i.length;t++)t&&(n+=G),n+=H(i[t]);return n}function D(i,n={}){const t=n.warn!==!1;if(F(i)){const r=i;return{stable:!0,fields:[],disabled:[],key(s,f){try{const u=r(s);return Array.isArray(u)?U(u):H(u)}catch(u){return L("rowKey.throw","rowKey function threw; falling back to index identity for the affected rows.",u),`#${f??-1}`}},keyEmpty(s){try{const f=r(s);return Array.isArray(f)?f.length===0||f.some(W):W(f)}catch{return!1}},missingFields(){return[]}}}if(Array.isArray(i)&&i.length>0){const r=i.filter(u=>typeof u=="string"),s=r.map(u=>B(u)),f=s.length;return{stable:!0,fields:r,disabled:[],key(u){const o=new Array(f);for(let g=0;g<f;g++)o[g]=s[g](u);return U(o)},keyEmpty(u){for(let o=0;o<f;o++)if(W(s[o](u)))return!0;return!1},missingFields(u){const o=[];for(let g=0;g<f;g++)W(s[g](u))&&o.push(r[g]);return o}}}if(typeof i=="string"&&i.length>0){const r=B(i);return{stable:!0,fields:[i],disabled:[],key(s){return H(r(s))},keyEmpty(s){return W(r(s))},missingFields(s){return W(r(s))?[i]:[]}}}return t&&L("rowKey.missing",`no rowKey configured, so rows are identified by object identity. This disables: ${Q.join(", ")}. Set rowKey to a field name, an array of field names, or a function.`),{stable:!1,fields:[],disabled:Q.slice(),key(r,s){if(r===null||typeof r!="object")return`#${s??0}:${String(r)}`;let f=v.get(r);return f===void 0&&(f=`#${S++}`,v.set(r,f)),f}}}const v=new WeakMap;let S=0;function y(i,n){if(!i||i.stable===!1||!F(i.keyEmpty)||!Array.isArray(n)||n.length===0)return;let t=0,r=null,s;for(let g=0;g<n.length;g++){const d=n[g];i.keyEmpty(d)&&(t++,r===null&&(r=F(i.missingFields)?i.missingFields(d):[],s=d))}if(t===0)return;const f=i.fields.length?i.fields.join(","):"(function)",u=r&&r.length?r.join(", "):i.fields.length?i.fields.join(", "):"the rowKey function",o=s!==null&&typeof s=="object"?Object.keys(s).join(", ")||"(no fields)":String(s);L(`rowKey.emptyValue:${f}`,`rowKey ${u} is missing on ${t} of ${n.length} rows; the first such row has: ${o}. Rows without a key value collapse onto one key, so selection, edits and rows.apply updates land on whichever row now shares it. Set rowKey to a field present on every row, or fix the source data.`)}function l(i){return U(i)}function c(i){return i.split(G)}}),xe("packages/core/src/columns/lookup.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_SEPARATOR",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"normaliseOption",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"flattenOptions",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return i}});const X=K("packages/core/src/internal/util.js"),L=X.collator,B=X.defaultCompare,F=X.isFunction,W=X.isNil,Q=X.warnOnce,H=K("packages/core/src/model/rowkey.js").compositeKey,U=", ",D="";function v(n,t,r,s){if(n===null||typeof n!="object")return{id:n,label:n==null?"":String(n)};const f=n[t],u=n[r],o={id:f,label:u==null?String(f??""):String(u)};n.disabled&&(o.disabled=!0),n.variant&&(o.variant=n.variant),n.icon&&(o.icon=n.icon);const g=s?n[s]:n.group;return g!==void 0&&(o.group=g),o}function S(n,t,r=0,s=[],f=[]){for(const u of n||[]){const o=u&&typeof u=="object"?u[t]:null;if(f.push({raw:u,depth:r,path:s}),Array.isArray(o)&&o.length){const g=String(u&&typeof u=="object"?u.label??u.name??u.id??"":u);S(o,t,r+1,[...s,g],f)}}return f}function y(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&F(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;#f=new Map;constructor(t,r={}){this.#e=t||{},this.#t=r.colId||"?",this.#n=r.locale,this.#r=r.onChange||null,this.#c=L(this.#n),Array.isArray(this.#e.options)?this.#h(this.#e.options):this.#e.options===void 0&&(this.#a="ready")}get colId(){return this.#t}get version(){return this.#l}get state(){return this.#a}get ready(){return this.#a==="ready"}get multiple(){return this.#e.multiple===!0}get separator(){return this.#e.separator??U}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=L(t)}#h(t){const r=this.#e,s=r.valueKey||"id",f=r.labelKey||"label",u=r.childrenKey||"children";this.#o=S(t,u).map(o=>{const g=v(o.raw,s,f,r.groupKey);return o.depth&&(g.depth=o.depth,g.path=o.path),g}),this.#i=new Map,this.#s=new Map,this.#o.forEach((o,g)=>{this.#i.set(o.id,o),this.#s.set(o.id,g)}),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(y(t))return this.#u=this.#p(t),this.#u;if(!F(t))return Q(`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",Q(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,s),this.#u=Promise.resolve([]),this.#u}return!r||!F(r.then)?(this.#h(r),this.#u=Promise.resolve(this.#o),this.#r&&this.#r(this),this.#u):(this.#u=r.then(s=>(this.#h(s),this.#r&&this.#r(this),this.#o),s=>(this.#a="error",Q(`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.#h(this.#e.options),this.#r&&this.#r(this),Promise.resolve(this.#o)):this.load()}#p(t){if(this.#d)return Promise.resolve(this.#o);const r=this.#e,s=r.valueKey||"id",f=r.labelKey||"label",u=r.groupKey,o=F(t.map)?t.map:null,g=h=>v(o?o(h):h,s,f,u).id,d=h=>this.#m(h,o,s,f,u);return t.router.subscribe(t.predicate,d,{rowKey:g}),this.#d=()=>{F(t.router.detach)&&t.router.detach(d)},this.#a="ready",Promise.resolve(this.#o)}#m(t,r,s,f,u){const o=t&&t.add||[],g=t&&t.update||[],d=t&&t.remove||[];if(!(!o.length&&!g.length&&!d.length)){for(const h of o)this.#g(h,r,s,f,u);for(const h of g)this.#g(h,r,s,f,u);for(const h of d){if(!this.#f.has(h))continue;const a=this.#f.get(h);this.#f.delete(h),this.#i.delete(a);const p=this.#o.findIndex(w=>w.id===a);p>=0&&this.#o.splice(p,1)}this.#s=new Map(this.#o.map((h,a)=>[h.id,a])),this.#a="ready",this.#l+=1,this.#r&&this.#r(this)}}#g(t,r,s,f,u){const o=v(r?r(t):t,s,f,u);this.#f.set(H([o.id]),o.id);const g=this.#o.findIndex(d=>d.id===o.id);g>=0?this.#o[g]=o:this.#o.push(o),this.#i.set(o.id,o)}destroy(){this.#d&&(this.#d(),this.#d=null)}search(t,r){const s=this.#e;if(!F(s.search)){const o=String(t||"").toLowerCase();return Promise.resolve(o===""?this.#o:this.#o.filter(g=>g.label.toLowerCase().includes(o)))}const f=s.valueKey||"id",u=s.labelKey||"label";return Promise.resolve(s.search(t,r)).then(o=>(o||[]).map(g=>v(g,f,u,s.groupKey)))}option(t){return this.#i.get(t)}has(t){return this.#i.has(t)}label(t){if(W(t)||t==="")return"";const r=this.#i.get(t);if(r)return r.label;if(this.#a==="loading"||this.#a==="idle")return"";this.allowCustom||Q(`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 F(s)?String(s(t)??""):typeof s=="string"?s:String(t)}text(t){if(this.multiple){const r=c(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,f)=>B(s.id,f.id));const r=this.#c;return this.#o.slice().sort((s,f)=>r.compare(s.label,f.label))}comparator(){const t=this.sortBy,r=this.multiple,s=this.#c,f=this.#s;if(r&&t==="count")return(o,g)=>c(o).length-c(g).length;const u=r?o=>c(o)[0]:o=>o;return t==="value"?(o,g)=>B(u(o),u(g)):t==="optionOrder"?(o,g)=>{const d=f.has(u(o))?f.get(u(o)):Number.MAX_SAFE_INTEGER,h=f.has(u(g))?f.get(u(g)):Number.MAX_SAFE_INTEGER;return d-h}:(o,g)=>{const d=u(o),h=u(g);return W(d)?W(h)?0:1:W(h)?-1:s.compare(this.label(d),this.label(h))}}groupKey(t){return this.multiple?c(t).map(s=>String(s)).sort().join(D):W(t)?"":String(t)}countValues(t){return this.multiple?c(t).length:W(t)?0:1}contains(t,r,s){const f=this.multiple?c(t):W(t)?[]:[t],u=Array.isArray(r)?r:[r];switch(s){case"containsAll":return u.every(o=>f.includes(o));case"containsNone":return!u.some(o=>f.includes(o));default:return u.some(o=>f.includes(o))}}exportText(t,r="label"){return r==="value"?this.multiple?c(t).join(this.separator):W(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?c(s).includes(r.id):s===r.id}))}}function c(n){return Array.isArray(n)?n:W(n)||n===""?[]:[n]}function i(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}}),xe("packages/core/src/columns/value.js",function(e,K){"use strict";Object.defineProperty(e,"compileDisplay",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"warnImpureUse",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return y}});const X=K("packages/core/src/internal/util.js"),L=X.getPath,B=X.isFunction,F=X.isNil,W=X.Lru,Q=X.warnOnce,H=K("packages/core/src/columns/graph.js").depsProxy,U="\0";function D(n,t={}){const r=t.locale,s=t.grid??null,f=t.context,u=n.value&&n.value.format,o=n.formatter||null,g=n.dataType&&n.dataType.format,d=n.lookup||null,h=(a,p,w)=>({value:a,data:w,row:p,column:n,colId:n.id,grid:s,context:f,locale:r});if(B(u))return(a,p,w)=>{const k=u(h(a,p,w));return k==null?"":String(k)};if(o){if(d){const a=o.kind==="text";return(p,w,k)=>o(a?d.text(p):p,h(p,w,k))}return(a,p,w)=>o(a,h(a,p,w))}return B(g)?(a,p,w)=>{const k=g(h(a,p,w));return k==null?"":String(k)}:d?a=>d.text(a):a=>F(a)?"":typeof a=="string"?a:String(a)}function v(n,t){!n||!n.value||n.value.pure!==!1||Q(`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 S{#e;#t;#n;#r;#o;#i;#s=new W(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||y}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 f=s?this.#l(s):null;for(const u of[...this.#s.keys()]){const o=String(u).split(U);o.length===3&&(r&&!r.has(o[0])||f&&!f.has(o[2])||this.#s.delete(u))}}#l(t){const r=new Set,s=this.#t,f=[...t];for(;f.length;){const u=f.pop();if(!r.has(u)){r.add(u);for(const o of s?s.dependents.get(u)||[]:[])f.push(o)}}return r}value(t,r,s){const f=typeof t=="string"?this.#e.get(t):t;if(!f)return;if(!f.computed)return this.#u(f,r,s);if(f.value.pure!==!1&&this.#i&&s&&s.physical!=null&&this.#i.has(f.id))return this.#i.get(f.id,s.physical);if(f.volatile)return this.compute(f,r,s);if(f.value.pure===!1)return this.compute(f,r,s);const u=`${this.#a(r,s)}${U}${f.id}`;if(this.#s.has(u))return this.#s.get(u);const o=this.compute(f,r,s);return this.#s.set(u,o),o}#a(t,r){return`${this.#o(t,r)}${U}${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):L(r,t.field)}compute(t,r,s){const f=this.#t,u=f&&f.wholeRow.has(t.id);let o;if(u)o=r??{};else{o={};const d=f&&f.deps.get(t.id)||[];for(const a of d)o[a]=this.value(a,r,s);const h=f&&f.external.get(t.id)||[];for(const a of h)o[a]=L(r,a);o=H(o,[...d,...h],t.id)}const g={data:r,row:s,column:t,grid:this.#n,context:this.#r};return t.value.compute(o,g)}values(t,r){const s={},f=this.#t?this.#t.order:[...this.#e.keys()];for(const u of f)s[u]=this.value(u,t,r);return s}text(t,r,s){const f=typeof t=="string"?this.#e.get(t):t;return f?f.formatValue(this.value(f,r,s),s,r):""}key(t,r,s){const f=typeof t=="string"?this.#e.get(t):t;if(!f)return"";const u=this.value(f,r,s);return B(f.value.key)?String(f.value.key(this.#c(f,u,r,s))):f.lookup?f.lookup.groupKey(u):F(u)?"":String(u)}quickFilterText(t,r,s){const f=typeof t=="string"?this.#e.get(t):t;if(!f)return"";if(B(f.value.quickFilterText)){const u=this.value(f,r,s);return String(f.value.quickFilterText(this.#c(f,u,r,s))??"")}return this.text(f,r,s)}#c(t,r,s,f){return{value:r,data:s,row:f,column:t,colId:t.id,grid:this.#n,context:this.#r}}parse(t,r,s,f){const u=typeof t=="string"?this.#e.get(t):t;if(!u)return r;const o={text:r,value:this.value(u,s,f),data:s,row:f,column:u,grid:this.#n,context:this.#r,locale:this.#n&&B(this.#n.get)?this.#n.get("locale"):void 0,formulaFunctions:this.#n&&B(this.#n.get)?this.#n.get("formulaFunctions"):void 0};return B(u.value.parse)?u.value.parse(o):u.dataType&&B(u.dataType.parse)?u.dataType.parse(o):r}validate(t,r,s,f,u){const o=typeof t=="string"?this.#e.get(t):t;if(!o||!B(o.edit.validate))return!0;const g=o.edit.validate({value:r,oldValue:s,data:f,row:u,column:o,grid:this.#n,context:this.#r});return g===!0||g===void 0?!0:String(g)}apply(t,r,s,f){const u=typeof t=="string"?this.#e.get(t):t;if(!u)return!1;const o=this.value(u,s,f);if(B(u.value.apply)){const g=u.value.apply({value:r,oldValue:o,data:s,row:f,column:u,grid:this.#n,context:this.#r});return this.#d(u,s,f),g!==!1}return u.field?o===r?!1:(u.write(s,r),this.#d(u,s,f),!0):(Q(`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,f){const u=typeof t=="string"?this.#e.get(t):t;if(!u)return{ok:!1,value:void 0,oldValue:void 0,changed:!1,error:"unknown column"};const o=this.value(u,s,f),g=this.parse(u,r,s,f),d=this.validate(u,g,o,s,f);if(d!==!0)return{ok:!1,value:g,oldValue:o,changed:!1,error:d};const h=this.apply(u,g,s,f);return{ok:!0,value:g,oldValue:o,changed:h}}#d(t,r,s){if(this.#s.size===0)return;const f=this.#a(r,s);this.#s.delete(`${f}${U}${t.id}`);for(const u of this.#t?this.#t.dependents.get(t.id)||[]:[])this.#s.delete(`${f}${U}${u}`)}}function y(n,t){return t&&t.key!=null?String(t.key):l(n)}function l(n){if(n&&typeof n=="object"){let t=c.get(n);return t===void 0&&(t=`#${i++}`,c.set(n,t)),t}return String(n)}const c=new WeakMap;let i=0}),xe("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 F}}),Object.defineProperty(e,"HISTORY_TICK_MAX_MS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"HISTORY_TICK_MIN_MS",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"historyTickFor",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"SHADOW_KINDS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"ROLLING_KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"FIT_SHADOW_KINDS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"DEFAULT_ANOMALY_THRESHOLD",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"SPEC_STATUS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"POSITIONAL_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"SHADOW_LABELS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"specStatusOf",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ShadowTracker",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shadowsIn",{enumerable:!0,get:function(){return o}});const L=K("packages/core/src/internal/util.js").warnOnce,B=2e5,F=20,W=1e3,Q=50;function G(g){return Math.min(W,Math.max(Q,Math.floor(g)))}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"]),U=Object.freeze(["rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta"]),D=Object.freeze(["fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),v=.6745,S=3.5,y=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),l=Object.freeze(["rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag"]),c=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 i(g,d){if(!d)return null;const h=Number.isFinite(Number(d.lower))?Number(d.lower):null,a=Number.isFinite(Number(d.upper))?Number(d.upper):null;if(h===null&&a===null||!Number.isFinite(g))return null;if(h!==null&&g<h||a!==null&&g>a)return y.FAIL;const p=Number.isFinite(Number(d.warnLower))?Number(d.warnLower):null,w=Number.isFinite(Number(d.warnUpper))?Number(d.warnUpper):null;return p!==null&&g<p||w!==null&&g>w?y.WARN:y.PASS}function n(g,d,h){if(!d||typeof d!="object")return null;if(d.kind!=="time")return d.kind!==void 0&&L(`shadow.history.window.kind:${g}`,`a 'history' shadow's 'window' only accepts {kind: 'time', span}; '${d.kind}' is not honoured (a plain count is already what 'depth' means, and a session has no span to divide into buckets), so it reported the original, unwindowed history.`),null;const a=d.minutes!=null?Number(d.minutes)*6e4:Number(d.span);if(!(a>0))return L(`shadow.history.window.span:${g}`,"a 'history' shadow's time window needs a positive 'span' (ms) or 'minutes'; it had none, so it reported the original, unwindowed history."),null;const p=Math.max(2,Math.floor(h)||F);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;#f=new Map;#h=null;#p=null;#m=null;constructor(d){this.#e=d.colId,this.#a=Math.max(2,d.depth||F),this.#u=Math.max(1,d.max||B),this.#c=d.now||(()=>Date.now()),this.#d=n(this.#e,d.historyWindow,this.#a),this.#d&&(this.#h=Math.floor(this.#c()/this.#d.bucketMs))}get colId(){return this.#e}get forgotten(){return this.#l}get size(){return this.#n.size}get historyWindow(){return this.#d}observe(d,h){const a=u(h);if(a===null)return;if(!this.#n.has(d)){this.#p=null,this.#m=null,this.#g(),this.#t.set(d,a),this.#n.set(d,a),this.#r.set(d,0),this.#o.set(d,this.#c()),this.#i.set(d,[a]),this.#d&&this.#f.set(d,[a]),this.#s.set(d,0);return}const p=this.#n.get(d);if(p===a)return;this.#p=null,this.#m=null,this.#n.set(d,a),this.#r.set(d,(this.#r.get(d)||0)+1),this.#o.set(d,this.#c());const w=this.#i.get(d)||[];w.push(a),w.length>this.#a&&w.splice(0,w.length-this.#a),this.#i.set(d,w);const k=Math.sign(a-p),m=this.#s.get(d)||0;this.#s.set(d,Math.sign(m)===k?m+k:k)}#g(){if(this.#n.size<this.#u)return;const d=this.#n.keys().next().value;d!==void 0&&(this.#t.delete(d),this.#n.delete(d),this.#r.delete(d),this.#o.delete(d),this.#i.delete(d),this.#f.delete(d),this.#s.delete(d),this.#l++)}rebase(){for(const[d,h]of this.#n)this.#t.set(d,h);this.#p=null,this.#m=null}reset(){this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#o.clear(),this.#i.clear(),this.#f.clear(),this.#s.clear(),this.#l=0,this.#p=null,this.#m=null,this.#d&&(this.#h=Math.floor(this.#c()/this.#d.bucketMs))}retain(d){const h=d instanceof Set?d:new Set(d);let a=0;for(const p of[...this.#n.keys()])h.has(p)||(this.#t.delete(p),this.#n.delete(p),this.#r.delete(p),this.#o.delete(p),this.#i.delete(p),this.#f.delete(p),this.#s.delete(p),a++);return a&&(this.#p=null,this.#m=null),a}advanceHistoryWindow(d=this.#c()){const h=this.#d;if(!h)return 0;const a=Math.floor(d/h.bucketMs),p=a-this.#h;if(!(p>0))return 0;const w=Math.min(p,this.#a);for(const[k,m]of this.#f){const b=this.#n.get(k);for(let C=0;C<w;C++)m.push(b);m.length>this.#a&&m.splice(0,m.length-this.#a)}return this.#h=a,p}read(d,h,a,p){switch(d){case"updates":return this.#r.has(h)?this.#r.get(h):0;case"updatedAt":{const w=this.#o.get(h);return w===void 0?null:new Date(w)}case"sinceUpdate":{const w=this.#o.get(h);return w===void 0?null:this.#c()-w}case"firstValue":return this.#t.has(h)?this.#t.get(h):null;case"delta":return this.#n.has(h)?this.#n.get(h)-this.#t.get(h):null;case"deltaPercent":{if(!this.#n.has(h))return null;const w=this.#t.get(h);return w?(this.#n.get(h)-w)/Math.abs(w)*100:null}case"rate":{const w=this.#i.get(h),k=this.#o.get(h);if(!w||w.length<2||k===void 0)return null;const m=this.#c()-k,b=w[w.length-1]-w[w.length-2];return m>0?b/m*1e3:b}case"history":return this.#d?this.#f.has(h)?[...this.#f.get(h)]:null:this.#i.has(h)?[...this.#i.get(h)]:null;case"streak":return this.#s.has(h)?this.#s.get(h):0;case"specStatus":return this.#n.has(h)?i(this.#n.get(h),p):null;default:return l.includes(d)?this.#k(d,h,a,p):null}}#y(d){if(d){if(this.#m&&this.#m.only===d)return this.#m.view;const h=this.#w(d);return this.#m={only:d,view:h},h}return this.#p?this.#p:(this.#p=this.#w(null),this.#p)}#w(d){const h=[];for(const[x,E]of this.#n)d&&!d.has(x)||h.push(E);const a=h.sort((x,E)=>x-E);let p=0,w=0,k=0,m=0;for(const x of a){m+=x,p++;const E=x-w;w+=E/p,k+=E*(x-w)}const b=[];for(const[x,E]of this.#t)d&&!d.has(x)||b.push(E);const C=p?r(a):0,M=a.map(x=>Math.abs(x-C)).sort((x,E)=>x-E),P=p?r(M):0;return{sorted:a,baseline:b.sort((x,E)=>x-E),sum:m,mean:p?w:0,sd:p>1?Math.sqrt(k/(p-1)):0,median:C,mad:P}}#k(d,h,a,p){if(!this.#n.has(h)||a&&!a.has(h))return null;const w=this.#n.get(h),k=this.#y(a),m=k.sorted.length;if(!m)return null;switch(d){case"rank":return m-f(k.sorted,w)+1;case"rankAsc":return s(k.sorted,w)+1;case"rankChange":{if(!this.#t.has(h)||!k.baseline.length)return null;const b=k.baseline.length-f(k.baseline,this.#t.get(h))+1,C=m-f(k.sorted,w)+1;return b-C}case"percentile":return f(k.sorted,w)/m*100;case"quartile":{const b=f(k.sorted,w)/m;return Math.min(4,Math.max(1,Math.ceil(b*4)))}case"zScore":return k.sd?(w-k.mean)/k.sd:null;case"anomalyScore":return k.mad?v*(w-k.median)/k.mad:null;case"anomalyFlag":{if(!k.mad)return null;const b=p&&Number.isFinite(Number(p.threshold))?Number(p.threshold):S;return Math.abs(v*(w-k.median)/k.mad)>b}case"shareOfTotal":return k.sum?w/k.sum*100:null;default:return null}}}function r(g){const d=g.length;if(!d)return 0;const h=(d-1)*.5,a=Math.floor(h),p=Math.ceil(h);return a===p?g[a]:g[a]+(h-a)*(g[p]-g[a])}function s(g,d){let h=0,a=g.length;for(;h<a;){const p=h+a>>1;g[p]<d?h=p+1:a=p}return h}function f(g,d){let h=0,a=g.length;for(;h<a;){const p=h+a>>1;g[p]<=d?h=p+1:a=p}return h}function u(g){if(g==null||g==="")return null;if(g instanceof Date){const h=g.getTime();return Number.isFinite(h)?h:null}const d=typeof g=="number"?g:Number(g);return Number.isFinite(d)?d:null}function o(g){const d=[];for(const h of g||[]){const a=h.shadow;if(!a)continue;const p=typeof a=="string"?{kind:a}:a,w=p.kind;H.includes(w)&&(U.includes(w)||D.includes(w)||d.push({colId:h.id||h.field,of:p.of||h.field||h.id,kind:w,depth:p.depth,historyWindow:w==="history"?p.window:void 0}))}return d}}),xe("packages/core/src/columns/model.js",function(e,K){"use strict";Object.defineProperty(e,"BUILTIN_DEFAULTS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"normaliseAlign",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"normaliseVAlign",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"expandColumn",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"flattenTree",{enumerable:!0,get:function(){return ne}});const X=K("packages/core/src/internal/util.js"),L=X.expand,B=X.fail,F=X.getPath,W=X.humanise,Q=X.isFunction,G=X.isObject,H=X.merge,U=X.pathGetter,D=X.pathSetter,v=X.toArray,S=X.uid,y=X.warnOnce,c=K("packages/core/src/format/index.js").compileFormat,i=K("packages/core/src/columns/datatypes.js"),n=i.comparatorFor,t=i.createTypeRegistry,r=i.storageKind,s=K("packages/core/src/columns/infer.js"),f=s.inferColumnType,u=s.DEFAULT_SAMPLE,o=K("packages/core/src/columns/graph.js"),g=o.buildGraph,d=o.affectedBy,a=K("packages/core/src/columns/lookup.js").createLookup,p=K("packages/core/src/columns/value.js"),w=p.compileDisplay,k=p.ValuePipeline,m=p.warnImpureUse,C=K("packages/core/src/model/shadow.js").FIT_SHADOW_KINDS,M=Object.freeze({geometry:"geometry",list:"list"}),P={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"},E=new Set(["start","center","end","left","right"]);function A(ae){if(typeof ae!="string")return;const re=ae.toLowerCase();return x[re]?x[re]:E.has(re)?re:void 0}function j(ae){if(typeof ae!="string")return;const re=ae.toLowerCase();return re==="center"||re==="centre"?"middle":re==="top"||re==="middle"||re==="bottom"?re:void 0}const $=["cell","layout","header"];function z(ae){if(!G(ae))return{};const re={...ae},se=(le,fe)=>{if(ae[le]===void 0)return;const be=L(ae[le],fe);be&&$.includes(le)&&!G(ae[le])&&delete be.enabled,re[le]=be};return se("sort","direction"),se("filter","type"),se("cell","render"),se("edit","editor"),se("layout","width"),se("group","index"),se("pivot","index"),se("header","render"),se("facet","strategy"),re}function T(ae,re){const se={...ae||{}},le=G(re)&&G(re.layout)&&re.layout.width!==void 0;return se.fit==="content"&&!le&&delete se.width,se}const R=new Set(["allowGroup","allowPivot","allowTotal","cell","colSpan","contextMenu","diff","edit","export","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"]),O=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function I(ae,re,se,le){const fe=se==="columnGroup"?"column group":"column";for(const be of Object.keys(ae))re.has(be)||y(`${se}.unknown:${be}`,`'${be}' is not a configuration key this grid recognises, so it had no effect on ${fe} "${le}". Check the spelling against the reference.`)}function q(ae,re){const se=re&&Q(ae.defaultsFor)?ae.defaultsFor(re):null,le={...ae.defaults||{},...G(se)?se:{}},fe={};return le.align&&(fe.align=le.align,fe.cell={align:le.align},fe.header={align:le.align}),le.filter&&(fe.filter=le.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:le.filter}),le.editor&&(fe.edit=le.editor==="none"?{editor:null}:{editor:le.editor}),le.total&&(fe.total=le.total),le.render&&(fe.cell={...fe.cell||{},render:le.render}),ae.export&&(fe.export={...ae.export}),fe}function Z(ae){if(typeof ae=="string")return ae.trim()?[ae.trim()]:[];if(!Array.isArray(ae))return[];const re=[];for(const se of ae){if(typeof se!="string")continue;const le=se.trim();le&&!re.includes(le)&&re.push(le)}return re}class _{#e=new Map;#t=[];#n=[];#r;#o;#i;#s;#l;#a;#u(re,se,le){const fe=this.#c(re,se,le);if(typeof fe!="string"||!this.#d)return fe??null;const be=se&&se.totals&&se.totals.implement;if(be&&Q(be[fe])){const we=be[fe];return we.totalName=fe,we}const Le=this.#d.totalFn?.(fe);return Q(Le)?Le:fe}#c(re,se,le){if(typeof re!="string")return re;const fe=se&&se.totals&&se.totals.supported;if(!Array.isArray(fe)||fe.includes(re))return re;const be=fe.length?fe.join(", "):"none";return B(`column "${le}" is typed ${se.name||"a type"}, for which the total "${re}" is not meaningful. Supported: ${be}. Aggregating it anyway would produce a confident wrong number.`),re}#d;#f;#h;#p;#m;#g;#y=!1;#w;#k;constructor(re={}){this.#o=z(re.columnDefaults||{}),this.#i=re.columnPresets||{},this.#l=re.locale,this.#s=re.timeZone,this.#a=j(re.verticalAlign),this.#d=re.registry||null,this.#f=re.grid||null,this.#h=re.context,this.#w=re.sampleSize??u,this.#k=re.onChange||null,this.#g=Q(re.rowKey)?re.rowKey:void 0,this.#r=t(re.dataTypes,this.#d);const{leaves:se,groups:le}=ne(re.columns||[]);this.#n=le;for(const fe of se){const be=this.#b(fe.def,null);if(be.groupPath=fe.path,this.#e.has(be.id)){y(`columns.duplicate:${be.id}`,`two columns resolve to the id '${be.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}fe.column=be,this.#e.set(be.id,be),this.#t.push(be.id)}this.#S(re.stored||null)}#b(re,se){I(re,R,"column",re.id||re.field||"(unnamed)");const le=z(re),fe=v(re.preset),be=fe.map(Qe=>{const Te=this.#i[Qe];return Te?z(Te):(y(`preset:${Qe}`,`unknown column preset "${Qe}"; ignoring`),{})}),Le=this.#P(le,be,se),we=this.#r.get(Le)||this.#r.get("text");if(!this.#r.has(Le)&&re.type){const Qe=M[Le];y(`type:${Le}`,`unknown data type "${Le}"; falling back to "text"`+(Qe?`. It is registered by importing '@toclocoinc/lattice-grid/modules/${Qe}'.`:""))}const Re=Q(we.items)?this.#j(le,be,re.id||re.field||"(unnamed)"):null;let ge=P;ge=H(ge,this.#o),re.type!==!1&&(ge=H(ge,q(we,Re)));for(const Qe of be)ge=H(ge,Qe);ge=H(ge,le);const he=ge.edit;he&&he.editor&&he.enabled!==!0&&!Q(he.enabled)&&(re.edit||{}).editor&&y(`column.editor-not-enabled:${re.id||re.field}`,`column '${re.id||re.field}' names the editor '${he.editor}' but does not enable editing, so it stays read-only. Add \`enabled: true\`, or use \`edit: true\` and set \`editor\` alongside it.`);const Oe=re.id||re.field||S("col");if(re.shadow&&!Q(ge.value&&ge.value.compute)){const Qe=typeof re.shadow=="string"?{kind:re.shadow}:re.shadow,Te=Qe.of||re.field||Oe,_e=C.includes(Qe.kind),Ke=_e?Qe.model||Qe:null,tt=_e&&Ke?[...Array.isArray(Ke.predictors)?Ke.predictors:[],Ke.response].filter(Boolean):null;ge.value={...ge.value||{},deps:tt&&tt.length?tt:Qe.orderBy&&Qe.orderBy!==Te?[Te,Qe.orderBy]:[Te],pure:!1,compute:(it,ht)=>{const yt=ht.grid&&ht.grid.statistics;if(!yt)return null;const St=ht.row&&ht.row.key||yt.keyOf(ht.data);if(!St)return null;if(_e){if(!Q(yt.fitShadow))return null;const At=Qe.model?{...Qe.model,threshold:Qe.threshold}:Qe;return yt.fitShadow(Qe.kind,St,At)}return yt.shadow(Te,Qe.kind,St,Qe.scope,Qe)}}}if(re.running&&!Q(ge.value&&ge.value.compute)){const Qe=typeof re.running=="string"?{kind:re.running}:re.running,Te=Qe.of||re.field||Oe;ge.value={...ge.value||{},deps:[Te],pure:!1,compute:(_e,Ke)=>{const tt=Ke.grid&&Ke.grid.statistics;if(!tt||!Q(tt.running))return null;const it=Ke.row&&Ke.row.key||tt.keyOf(Ke.data);return it?tt.running(Te,Qe.kind||"total",it):null}},re.sort===void 0&&(ge.sort={...ge.sort||{},enabled:!1})}const Ee=re.field??(Q(ge.value&&ge.value.compute)?null:re.id??null),Ie=Q(ge.value&&ge.value.compute),ze={id:Oe,field:Ee,shadow:re.shadow||null,running:re.running||null,spec:re.spec||null,validation:re.validation||null,volatile:!!(re.shadow||re.running),title:ge.title??W(Ee||Oe),type:we.name,dataType:we,itemType:Re,nullable:ge.nullable!==!1,align:A(le.cell&&le.cell.align||le.align||ge.cell&&ge.cell.align||ge.align||we.defaults&&we.defaults.align)||"start",verticalAlign:j(le.cell&&le.cell.verticalAlign||le.verticalAlign||ge.cell&&ge.cell.verticalAlign||ge.verticalAlign)||this.#a,rowSpan:Q(ge.rowSpan)?ge.rowSpan:null,colSpan:Q(ge.colSpan)?ge.colSpan:null,value:{pure:!0,...ge.value||{}},cell:{...ge.cell||{}},edit:{...ge.edit||{}},sort:{...ge.sort||{}},filter:{...ge.filter||{}},group:{enabled:!1,index:-1,explode:!1,...ge.group||{}},pivot:{enabled:!1,index:-1,...ge.pivot||{}},total:this.#u(ge.total,we,re.id||re.field||"(unnamed)"),groupTotal:ge.groupTotal===void 0?null:this.#u(ge.groupTotal,we,re.id||re.field||"(unnamed)"),grandTotal:ge.grandTotal===void 0?null:this.#u(ge.grandTotal,we,re.id||re.field||"(unnamed)"),tags:Z(ge.tags),typeOptions:ge.typeOptions??null,...G(ge[Le])?{[Le]:ge[Le]}:{},layout:T(ge.layout,le),header:{...ge.header||{}},contextMenu:ge.contextMenu===void 0?null:ge.contextMenu,facet:{...ge.facet||{}},export:{...ge.export||{}},allowGroup:ge.allowGroup!==!1,allowPivot:ge.allowPivot!==!1,allowTotal:ge.allowTotal!==!1,quickFilter:ge.quickFilter!==!1,def:re,format:ge.format,presets:fe,inferred:se!=null&&!re.type,computed:Ie,diff:re.diff===void 0?void 0:!!re.diff,read:Ee?U(Ee):null,write:Ee?D(Ee):null};ze.cell.align=A(le.cell&&le.cell.align)||ze.align,ze.header.align=A(le.header&&le.header.align)||ze.align;const Ye=ge.lookup||null;return ze.lookup=Ye?a({id:Oe,lookup:Ye},{locale:this.#l,onChange:()=>{this.#k&&this.#k("lookup",{colId:Oe})}}):null,ze.group.explode&&ze.lookup&&ze.lookup.multiple&&y(`explode:${Oe}`,`column "${Oe}" has \`group.explode\`, so rows appear under each of their values and totals double-count. Group footers should be annotated accordingly.`),this.#O(ze),ze}#O(re){re.formatter=c(re.format,re.dataType,this.#l,this.#s,re.id),re.formatValue=w(re,{locale:this.#l,grid:this.#f,context:this.#h}),re.itemCompare=re.itemType?n(re.itemType,this.#l):null,re.compare=Q(re.value.compare)?re.value.compare:re.lookup?re.lookup.comparator():Q(re.dataType.compareFor)?re.dataType.compareFor(re):n(re.dataType,this.#l),re.excel=re.formatter&&re.formatter.ooxml||re.dataType&&re.dataType.excel||"General",re.storeKind=r(re.dataType,!!(re.lookup&&re.lookup.multiple))}#j(re,se,le){let fe=G(re.typeOptions)?re.typeOptions:null;for(let Re=se.length-1;!fe&&Re>=0;Re--)G(se[Re].typeOptions)&&(fe=se[Re].typeOptions);!fe&&G(this.#o.typeOptions)&&(fe=this.#o.typeOptions);const be=fe&&fe.of!==void 0?fe.of:"text",Le=typeof be=="string"?this.#r.get(be):void 0;return Le&&!Q(Le.items)&&Le.storage!=="object"?Le:(y(`type:of:${String(be)}`,`column "${le}" names "${String(be)}" as its item type (typeOptions.of), which is not ${Le?"a scalar data type":"a known data type"}; its items are read as text.`),this.#r.get("text"))}#P(re,se,le){if(re.type===!1)return"text";if(re.type)return re.type;for(let fe=se.length-1;fe>=0;fe--)if(se[fe].type)return se[fe].type;if(this.#o.type)return this.#o.type;if(re.shadow){const fe=typeof re.shadow=="string"?re.shadow:re.shadow.kind;if(fe==="fitInfluence")return"boolean";if(fe==="fitPredicted"||fe==="fitResidual"||fe==="fitStdResidual"||fe==="fitLeverage"||fe==="fitCooksD"||fe==="tsTrend"||fe==="tsSeasonal"||fe==="tsResidual"||fe==="tsCoverage"||fe==="tsSmoothed"||fe==="tsSmoothingAlpha"||fe==="tsSmoothingBeta")return"number"}return le||(re.lookup?"lookup":"text")}#S(re){const se=this.all();this.#p=g(se),this.#m?this.#m.setGraph(this.#p):this.#m=new k({columns:this.#e,graph:this.#p,grid:this.#f,context:this.#h,stored:re||null,rowKey:this.#g});const le=this.#m;for(const fe of se)fe.getValue=(be,Le)=>le.value(fe,be,Le)}all(){return this.#t.map(re=>this.#e.get(re))}visible(){return this.all().filter(re=>!re.layout.hidden)}get(re){return this.#e.get(re)}groups(){const re=se=>{const le=[];for(const fe of se)Array.isArray(fe.columns)?le.push({...fe,columns:re(fe.columns)}):fe.column&&le.push(fe.column);return le};return re(this.#n)}graph(){return this.#p}pipeline(){return this.#m}types(){return this.#r}affectedBy(re){return d(this.#p,re)}value(re,se,le){return this.#m.value(re,se,le)}text(re,se,le){return this.#m.text(re,se,le)}checkImpure(re,se){m(this.#e.get(re),se)}setLocale(re){this.#l=re;for(const se of this.all())se.lookup&&se.lookup.setLocale(re),this.#O(se);this.#k&&this.#k("locale",{locale:re})}infer(re){const se={};if(this.#y||!Array.isArray(re)||re.length===0)return se;this.#y=!0;let le=!1;for(const fe of this.all()){const be=fe.def;if(be.type!==void 0||!fe.field||fe.computed||fe.lookup||this.#M(fe))continue;const Le=fe.read||(ge=>F(ge,fe.field)),we=f(fe.id,re,Le,this.#r,{sampleSize:this.#w});if(we===fe.type)continue;se[fe.id]=we;const Re=this.#b(be,we);Re.groupPath=fe.groupPath,Re.layout={...Re.layout,...J(fe.layout)},this.#e.set(fe.id,Re),ie(this.#n,fe.id,Re),le=!0}return le&&this.#S(null),se}redecorate(re,se,le={}){const fe=this.#e.get(re);if(!fe){y(`redecorate:${re}`,`columns.decorate('${re}', …): no column with id '${re}'.`);return}const be=fe.def||{},Le={...G(be.cell)?be.cell:{}};Le.decoration=se??void 0,le&&"variant"in le&&(Le.variant=le.variant);const we={...be,cell:Le},Re=this.#b(we,fe.type);return Re.groupPath=fe.groupPath,Re.layout={...Re.layout,...J(fe.layout)},fe.lookup&&fe.lookup!==Re.lookup&&Q(fe.lookup.destroy)&&fe.lookup.destroy(),this.#e.set(re,Re),ie(this.#n,re,Re),this.#S(null),this.#k&&this.#k("decorate",{colId:re}),Re}destroy(){for(const re of this.#e.values())re.lookup&&Q(re.lookup.destroy)&&re.lookup.destroy()}#M(re){for(const se of re.presets){const le=this.#i[se];if(le&&le.type)return!0}return!!this.#o.type}#A(re){return!re.computed&&Q(re.dataType&&re.dataType.toStorage)}storeReader(re){if(re.computed)return se=>this.#m.value(re,se,null);if(this.#A(re)){const se=re.dataType.toStorage,le={timeZone:re.timeZone||this.#s,colId:re.id,itemType:re.itemType||null};return fe=>se(re.read(fe),le)}return re.read}storeValue(re,se){if(!(!re||re.computed)&&Q(re.read))return this.storeReader(re)(se)}storeSchema(){const re=[];for(const se of this.all()){if(se.computed&&se.value.pure===!1||!se.computed&&!se.field)continue;const le=this.storeReader(se);let fe=null;!se.computed&&!this.#A(se)&&typeof se.field=="string"&&!se.lookup&&(fe=se.field);const be={id:se.id,kind:se.storeKind,nullable:se.nullable,read:le};fe!==null&&(be.field=fe),se.lookup&&(be.dictionary=se.lookup.dictionary()),re.push(be)}return re}state(){return this.all().map(re=>({id:re.id,width:re.layout.width,flex:re.layout.flex||void 0,hidden:!!re.layout.hidden,pin:re.layout.pin??null,sort:re.sort.direction??null,sortIndex:re.sort.direction?re.sort.order??0:null,groupIndex:re.group.enabled?re.group.index??0:null,pivotIndex:re.pivot.enabled?re.pivot.index??0:null,total:typeof re.total=="string"?re.total:null,groupTotal:typeof re.groupTotal=="string"?re.groupTotal:void 0,grandTotal:typeof re.grandTotal=="string"?re.grandTotal:void 0,decoration:re.cell&&re.cell.decoration!=null?ee(re.cell.decoration):void 0,variant:re.cell&&re.cell.variant!=null?ee(re.cell.variant):void 0}))}applyState(re,se={}){const le={applied:[],skipped:[]},fe=Array.isArray(re)?re:re&&re.columns||[],be=!Array.isArray(re)&&re&&re.columnOrder||null;for(const we of fe){if(!we||!we.id){le.skipped.push({key:"?",reason:"no id"});continue}let Re=this.#e.get(we.id);if(!Re){le.skipped.push({key:we.id,reason:"unknown column"});continue}if(Object.hasOwn(we,"decoration")||Object.hasOwn(we,"variant")){const ge=Re.cell?Re.cell.decoration:void 0,he=we.decoration??null,Oe=Object.hasOwn(we,"variant"),Ee=Oe&&!te(Re.cell?Re.cell.variant:void 0,we.variant);(!te(ge,he)||Ee)&&(this.redecorate(we.id,he,Oe?{variant:we.variant??void 0}:{}),Re=this.#e.get(we.id)||Re)}we.width!=null&&(Re.layout.width=we.width),we.flex!=null&&(Re.layout.flex=we.flex),we.hidden!=null&&(Re.layout.hidden=!!we.hidden),we.pin!==void 0&&(Re.layout.pin=we.pin),we.sort!==void 0&&(Re.sort.direction=we.sort),we.sortIndex!=null&&(Re.sort.order=we.sortIndex),we.groupIndex!=null&&(Re.group.enabled=!0,Re.group.index=we.groupIndex),we.pivotIndex!=null&&(Re.pivot.enabled=!0,Re.pivot.index=we.pivotIndex),we.total!==void 0&&(Re.total=we.total),we.groupTotal!==void 0&&(Re.groupTotal=we.groupTotal),we.grandTotal!==void 0&&(Re.grandTotal=we.grandTotal),le.applied.push(we.id)}const Le=be||(se&&se.keepOrder?[]:fe.map(we=>we&&we.id).filter(Boolean));if(Le.length){const we=Le.filter(ge=>this.#e.has(ge)),Re=this.#t.filter(ge=>!we.includes(ge));this.#t=[...we,...Re]}return this.#k&&this.#k("state",le),le}move(re,se){this.#E(re,se)&&(this.#L(),this.#k&&this.#k("move",{id:re,to:se}))}reorder(re){const se={applied:[],skipped:[]},le=[];let fe=0;for(const be of Array.isArray(re)?re:[]){const Le=fe++;this.#E(be,Le)&&(se.applied.push(be),le.push({id:be,to:Le}))}if(!le.length)return se;if(this.#L(),this.#k)for(const be of le)this.#k("move",be);return se}#E(re,se){const le=this.#t.indexOf(re);if(le===-1||Math.max(0,Math.min(Number(se)||0,this.#t.length-1))===le)return!1;const be=this.#e.get(re);if(be.layout.movable===!1||be.layout.lockPosition)return y(`move:${re}`,`column "${re}" is not movable; the move was ignored`),!1;const Le=this.#R(re,se);return Le?(y(`move.married:${Le}`,`band "${Le}" declares marryChildren, so its columns stay together; the move was ignored`),!1):(this.#t.splice(le,1),this.#t.splice(Math.max(0,Math.min(se,this.#t.length)),0,re),!0)}#R(re,se){if(!this.#n||!this.#n.length)return null;const le=this.#t.filter(we=>we!==re),fe=Math.max(0,Math.min(se,le.length)),be=(we,Re)=>{if(Array.isArray(we.columns)){for(const he of we.columns)be(he,Re);return Re}const ge=we.column?we.column.id:we.id;return ge&&Re.push(ge),Re},Le=we=>{for(const Re of we){if(!Array.isArray(Re.columns))continue;if(Re.marryChildren===!0){const he=be(Re,[]),Oe=he.includes(re),Ee=he.map(Ie=>le.indexOf(Ie)).filter(Ie=>Ie>=0);if(Ee.length){const Ie=Math.min(...Ee),ze=Math.max(...Ee);if(Oe?fe<Ie||fe>ze+1:fe>Ie&&fe<=ze)return Re.id}}const ge=Le(Re.columns);if(ge)return ge}return null};return Le(this.#n)}#L(){const re=new Map(this.#t.map((fe,be)=>[fe,be])),se=fe=>{if(!Array.isArray(fe.columns)){const Le=fe.column?fe.column.id:fe.id;return re.has(Le)?re.get(Le):1/0}let be=1/0;for(const Le of fe.columns)be=Math.min(be,se(Le));return be},le=fe=>{fe.sort((be,Le)=>se(be)-se(Le));for(const be of fe)Array.isArray(be.columns)&&le(be.columns)};le(this.#n)}#x(re){const se=le=>{for(let fe=0;fe<le.length;fe++){const be=le[fe];if(Array.isArray(be.columns)){const Le=se(be.columns);if(Le)return Le}else if(be.column&&be.column.id===re)return le.splice(fe,1)[0]}return null};return se(this.#n)}#I(re){const se=[];for(let le=re.length-1;le>=0;le--){const fe=re[le];Array.isArray(fe.columns)&&(se.push(...this.#I(fe.columns)),fe.columns.length===0&&(se.push(fe.id),re.splice(le,1)))}return se}#z(){const re=(se,le)=>{for(const fe of se)Array.isArray(fe.columns)?re(fe.columns,[...le,fe.id]):fe.column&&(fe.column.groupPath=le)};re(this.#n,[])}#$(re){const se=new Set(re),le=this.#t.filter(we=>se.has(we));if(!le.length)return;const fe=Math.min(...le.map(we=>this.#t.indexOf(we))),be=this.#t.slice(0,fe).filter(we=>!se.has(we)),Le=this.#t.slice(fe).filter(we=>!se.has(we));this.#t=[...be,...le,...Le]}#N(re){const se=[],le=fe=>{if(Array.isArray(fe.columns))for(const be of fe.columns)le(be);else fe.column&&se.push(fe.column.id)};return le(re),se}#H(re){const se=le=>{for(const fe of le){if(!Array.isArray(fe.columns))continue;if(fe.id===re)return{node:fe,parent:le};const be=se(fe.columns);if(be)return be}return null};return se(this.#n)}groupColumns(re,se={}){const le=v(re).filter(Re=>this.#e.has(Re));if(!le.length)return y("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const Re of le)if(this.#e.get(Re).layout.lockPosition)return y(`columns.group.locked:${Re}`,`column "${Re}" is position-locked and cannot be grouped.`),null;const fe=se.groupId?this.#H(se.groupId):null;if(se.groupId&&!fe)return y(`columns.group.unknown:${se.groupId}`,`no band "${se.groupId}" to add to; nothing was grouped.`),null;let be=null;if(!fe&&se.id!=null&&(be=String(se.id),this.#H(be)||this.#e.has(be)))return y(`columns.group.idtaken:${be}`,`band id "${be}" is already in use; nothing was grouped.`),null;const Le=le.map(Re=>this.#x(Re)).filter(Boolean);if(!Le.length)return null;let we;if(fe)fe.node.columns.push(...Le),we=fe.node.id;else{const Re={id:be||S("grp"),title:se.title||"",collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Le},ge=Number.isInteger(se.at)?Math.max(0,Math.min(se.at,this.#n.length)):this.#n.length;this.#n.splice(ge,0,Re),we=Re.id}return this.#I(this.#n),this.#$(le),this.#z(),this.#L(),this.#k&&this.#k("columngroup",{action:"formed",groupId:we,ids:le}),we}ungroupColumn(re){const se=this.#e.get(re);if(!se){y(`columns.ungroup.unknown:${re}`,`no column "${re}" to ungroup.`);return}const le=se.groupPath||[];if(!le.length)return;const fe=le[le.length-1],be=this.#H(fe);if(!be)return;const Le=this.#x(re);if(!Le)return;const we=be.parent.indexOf(be.node);be.parent.splice(we+1,0,Le);const Re=this.#I(this.#n),ge=this.#N(be.node);if(ge.length){this.#$(ge);const he=Math.max(...ge.map(Ee=>this.#t.indexOf(Ee))),Oe=this.#t.filter(Ee=>Ee!==re);Oe.splice(he+1,0,re),this.#t=Oe}this.#z(),this.#L(),this.#k&&this.#k("columngroup",{action:"removed",id:re,dissolved:Re})}renameGroup(re,se){const le=this.#H(re);if(!le){y(`columns.group.rename:${re}`,`no band "${re}" to rename.`);return}le.node.title=String(se??""),this.#k&&this.#k("columngroup",{action:"renamed",groupId:re,title:le.node.title})}dissolveGroup(re){const se=this.#H(re);if(!se){y(`columns.group.dissolve:${re}`,`no band "${re}" to dissolve.`);return}const le=se.parent.indexOf(se.node);se.parent.splice(le,1,...se.node.columns),this.#z(),this.#L(),this.#k&&this.#k("columngroup",{action:"dissolved",groupId:re})}moveGroup(re,se){const le=this.#H(re);if(!le){y(`columns.group.move:${re}`,`no band "${re}" to move.`);return}const fe=le.parent,be=fe.indexOf(le.node);be!==-1&&(fe.splice(be,1),fe.splice(Math.max(0,Math.min(se,fe.length)),0,le.node),this.#B(),this.#z(),this.#k&&this.#k("columngroup",{action:"moved",groupId:re,to:se}))}#B(){const re=[],se=fe=>{for(const be of fe)Array.isArray(be.columns)?se(be.columns):be.column&&re.push(be.column.id)};se(this.#n);const le=new Set(re);this.#t=[...re,...this.#t.filter(fe=>!le.has(fe))]}groupTree(){const re=le=>le.map(fe=>Array.isArray(fe.columns)?{id:fe.id,title:fe.title||"",collapsible:!!fe.collapsible,openByDefault:fe.openByDefault!==!1,columns:re(fe.columns)}:fe.column?fe.column.id:null).filter(fe=>fe!==null),se=re(this.#n);return se.some(le=>le&&typeof le=="object")?se:[]}applyGroupTree(re){if(!Array.isArray(re))return;const se=new Set,le=be=>{const Le=[];for(const we of be)if(we&&typeof we=="object"&&Array.isArray(we.columns)){const Re=le(we.columns);if(!Re.length)continue;Le.push({id:we.id||S("grp"),title:we.title||"",collapsible:we.collapsible===!0,openByDefault:we.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Re})}else if(typeof we=="string"){const Re=this.#e.get(we);Re&&!se.has(we)&&(se.add(we),Le.push({column:Re,path:[]}))}return Le},fe=le(re);for(const be of this.#t){if(se.has(be))continue;const Le=this.#e.get(be);Le&&fe.push({column:Le,path:[]})}this.#n=fe,this.#z(),this.#L(),this.#k&&this.#k("columngroup",{action:"applied"})}show(re){this.#W(re,!1)}hide(re){this.#W(re,!0)}#W(re,se){const le=[];for(const fe of v(re)){const be=this.#e.get(fe);if(be){if(se&&be.layout.lockVisible){y(`lockVisible:${fe}`,`column "${fe}" is \`layout.lockVisible\` and cannot be hidden`);continue}be.layout.hidden!==se&&(be.layout.hidden=se,le.push(fe))}}le.length&&this.#k&&this.#k("visible",{ids:le,hidden:se})}pin(re,se){const le=this.#e.get(re);le&&(le.layout.pin=se??null,this.#k&&this.#k("pin",{id:re,side:le.layout.pin}))}resize(re,se){const le=this.#e.get(re);if(!le)return;if(le.layout.resizable===!1){y(`resize:${re}`,`column "${re}" is not resizable; the resize was ignored`);return}const fe=le.layout.min??0,be=le.layout.max;let Le=Math.max(fe,se);be!=null&&(Le=Math.min(be,Le)),le.layout.width=Le,le.layout.flex=0,this.#k&&this.#k("resize",{id:re,width:Le})}}function J(ae){const re={};return ae.width!=null&&(re.width=ae.width),ae.hidden!=null&&(re.hidden=ae.hidden),ae.pin!==void 0&&(re.pin=ae.pin),re}function ee(ae){if(ae===null||typeof ae!="object")return ae;try{return structuredClone(ae)}catch{}try{return JSON.parse(JSON.stringify(ae))}catch{return ae}}function te(ae,re){const se=ae??null,le=re??null;if(se===le)return!0;if(se===null||le===null)return!1;if(typeof se!="object"||typeof le!="object")return se===le;try{return JSON.stringify(se)===JSON.stringify(le)}catch{return!1}}function ne(ae){const re=[],se=(fe,be)=>{const Le=[];for(const we of fe){if(!G(we)){B("a column definition must be an object");continue}if(Array.isArray(we.columns)){I(we,O,"columnGroup",we.title||we.id||"(unnamed)");const Re={id:we.id||S("grp"),title:we.title||"",collapsible:we.collapsible===!0,openByDefault:we.openByDefault!==!1,showWhen:we.showWhen||"always",marryChildren:we.marryChildren===!0,header:we.header||{},def:we,columns:[]};Re.columns=se(we.columns,[...be,Re.id]),Le.push(Re)}else{const Re={def:we,path:be};re.push(Re),Le.push(Re)}}return Le},le=se(ae,[]);return{leaves:re,groups:le}}function ie(ae,re,se){for(const le of ae){if(le.columns){if(ie(le.columns,re,se))return!0;continue}if(le.column&&le.column.id===re)return le.column=se,!0}return!1}}),xe("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 Q}}),Object.defineProperty(e,"warnOnAbsurdGrouping",{enumerable:!0,get:function(){return G}});const L=K("packages/core/src/internal/util.js").warnOnce,B="__lattice_group",F=240,W=.5;function Q(H){const{columns:U,groupBy:D}=H,v=D.map(l=>U.get(l)).filter(Boolean),S=v.length?v.map(l=>l.title||l.id).join(" > "):"Group",y=H.config&&H.config.autoGroupColumnWidth||F;return{id:B,field:null,title:S,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group"},edit:{enabled:!1},sort:{enabled:!0,direction:null},filter:{enabled:!0},groupedIds:D.slice(),group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:y,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,c){return c&&c.group?c.groupValue:null},formatValue(l,c){if(!c||!c.group)return"";if(c.grandTotal)return H.config&&H.config.grandTotalLabel||"Total";const i=v[Math.min(c.level||0,v.length-1)];return i&&typeof i.formatValue=="function"?i.formatValue(l,c):l==null?"":String(l)}}}function G(H,U,D){!H.length||D<100||U<D*W||L(`grouping.cardinality:${H.join(",")}`,`grouping by ${H.join(", ")} produced ${U} groups for ${D} 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.`)}}),xe("packages/core/src/columns/selectcolumn.js",function(e,K){"use strict";Object.defineProperty(e,"SELECT_COLUMN_ID",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createSelectionColumn",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return F}});const X="__lattice_select",L=44;function B(W){const Q=W.selection||{},G=W.config&&W.config.selectionColumnWidth||L;return{id:X,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:G,min:G,max:G,pin:W.config&&W.config.selectionColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,headerCheckbox:Q.headerCheckbox===!0,def:{},getValue(H,U){return U?U.selected:!1},formatValue(){return""}}}const F=B}),xe("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 U}});const L=K("packages/core/src/internal/util.js").isFunction,B="__lattice_rownumber",F=40,W=9,Q=22;function G(D){const v=String(Math.max(1,Math.trunc(Math.abs(D))||1)).length;return Math.max(F,v*W+Q)}function H(D){const v=D.rowNumbers,S=v&&typeof v=="object"?v:{},y=Number.isFinite(S.start)?S.start:1,l=Number.isFinite(S.width)?S.width:G((D.maxNumber||0)+y),c=L(D.rank)?D.rank:()=>null;return{id:B,field:null,title:typeof S.title=="string"?S.title:"",type:"number",dataType:{base:"number"},nullable:!0,align:"end",generated:!0,control:!0,value:{pure:!0},cell:{align:"end"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:l,min:l,max:l,pin:"start",hidden:!1,resizable:S.width==null,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(i,n){const t=c(n);return t==null?null:t-1+y},formatValue(i){return i==null?"":String(i)}}}const U=H}),xe("packages/core/src/model/detail.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_DETAIL_HEIGHT",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"DEFAULT_CACHE_LIMIT",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"resolveDetail",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"DetailModel",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return H}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,F=240,W=10;function Q(U){if(!U)return null;const D=U===!0?{}:U;return D.enabled===!1?null:!L(D.rows)&&!D.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:D.render||null,config:D.config||null,rows:L(D.rows)?D.rows:null,height:D.height??F,cacheLimit:Number.isFinite(D.cacheLimit)?Math.max(0,D.cacheLimit):W,isMaster:L(D.isMaster)?D.isMaster:null,target:D.target||null,onCreate:L(D.onCreate)?D.onCreate:null,path:typeof D.path=="string"?D.path:null}}class G{#e;#t=new Set;#n;#r=0;constructor(D){this.#e=D.config,this.#n=L(D.onChange)?D.onChange:()=>{}}get config(){return this.#e}get inline(){return!this.#e.target}isMaster(D){if(!D||D.group||D.detail)return!1;const v=this.#e.isMaster;return v?!!v(D.data,D):!0}isOpen(D){return this.#t.has(D)}keys(){return[...this.#t]}activeKey(){for(const D of this.#t)return D;return null}heightOf(D){const v=this.#e.height;return L(v)?Number(v(D))||F:v==="auto"?F:Number(v)||F}open(D){return this.#t.has(D)?!1:(this.inline||this.#t.clear(),this.#t.add(D),this.#o(),!0)}close(D){return this.#t.delete(D)?(this.#o(),!0):!1}toggle(D){return this.#t.has(D)?(this.close(D),!1):(this.open(D),!0)}closeAll(){this.#t.size&&(this.#t.clear(),this.#o())}prune(D){if(!this.#t.size||!L(D))return;let v=!1;for(const S of[...this.#t])D(S)||(this.#t.delete(S),v=!0);v&&this.#o()}signature(){return`${this.#r}`}set(D){this.#t.clear();const v=Array.isArray(D)?D:[];for(const S of this.inline?v:v.slice(0,1))this.#t.add(S);this.#o()}#o(){this.#r++,this.#n()}}const H=G}),xe("packages/core/src/compute/special.js",function(e,K){"use strict";Object.defineProperty(e,"logGamma",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"incompleteBeta",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"normalQuantile",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"normalCdf",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"studentT",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"studentTQuantile",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"regularizedGammaP",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chiSquareUpperTail",{enumerable:!0,get:function(){return i}});const X=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),L=3e-12,B=1e-300;function F(n){if(n<.5)return Math.log(Math.PI/Math.sin(Math.PI*n))-F(1-n);const t=n-1;let r=.9999999999998099;const s=t+7.5;for(let f=0;f<X.length;f++)r+=X[f]/(t+f+1);return .5*Math.log(2*Math.PI)+(t+.5)*Math.log(s)-s+Math.log(r)}function W(n,t,r){const s=n+t,f=n+1,u=n-1;let o=1,g=1-s*r/f;Math.abs(g)<B&&(g=B),g=1/g;let d=g;for(let h=1;h<=300;h++){const a=2*h;let p=h*(t-h)*r/((u+a)*(n+a));g=1+p*g,Math.abs(g)<B&&(g=B),o=1+p/o,Math.abs(o)<B&&(o=B),g=1/g,d*=g*o,p=-(n+h)*(s+h)*r/((n+a)*(f+a)),g=1+p*g,Math.abs(g)<B&&(g=B),o=1+p/o,Math.abs(o)<B&&(o=B),g=1/g;const w=g*o;if(d*=w,Math.abs(w-1)<L)break}return d}function Q(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(F(n+t)-F(n)-F(t)+n*Math.log(r)+t*Math.log(1-r));return r<(n+1)/(n+t+2)?s*W(n,t,r)/n:1-s*W(t,n,1-r)/t}function G(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],f=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],u=.02425;let o,g,d;n<u?(o=Math.sqrt(-2*Math.log(n)),d=(((((s[0]*o+s[1])*o+s[2])*o+s[3])*o+s[4])*o+s[5])/((((f[0]*o+f[1])*o+f[2])*o+f[3])*o+1)):n<=1-u?(o=n-.5,g=o*o,d=(((((t[0]*g+t[1])*g+t[2])*g+t[3])*g+t[4])*g+t[5])*o/(((((r[0]*g+r[1])*g+r[2])*g+r[3])*g+r[4])*g+1)):(o=Math.sqrt(-2*Math.log(1-n)),d=-(((((s[0]*o+s[1])*o+s[2])*o+s[3])*o+s[4])*o+s[5])/((((f[0]*o+f[1])*o+f[2])*o+f[3])*o+1));const a=(.5*H(-d/Math.SQRT2)-n)*Math.sqrt(2*Math.PI)*Math.exp(d*d/2);return d-a/(1+d*a/2)}function H(n){const t=Math.abs(n),r=2/(2+t),s=4*r-2,f=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let u=0,o=0,g;for(let h=f.length-1;h>0;h--)g=o,o=s*o-u+f[h],u=g;const d=r*Math.exp(-t*t+.5*(f[0]+s*o)-u);return n>=0?d:2-d}function U(n){return .5*H(-n/Math.SQRT2)}function D(n,t){if(!(t>0)||!Number.isFinite(n))return Number.NaN;const r=.5*Q(t/2,.5,t/(t+n*n));return n>0?1-r:r}function v(n,t){if(!(n>0)||!(n<1)||!(t>0))return Number.NaN;if(t>1e7)return G(n);let r=-1e4,s=1e4,f=G(n);const u=F(t/2)+F(.5)-F((t+1)/2);for(let o=0;o<60;o++){const g=D(f,t);g<n?r=f:s=f;const d=Math.exp(-((t+1)/2)*Math.log(1+f*f/t)-u)/Math.sqrt(t),h=d>0?(g-n)/d:0;if(Math.abs(h)<1e-12)break;const a=f-h;if(f=a>r&&a<s&&Number.isFinite(a)?a:(r+s)/2,s-r<1e-12)break}return f}function S(n,t){let r=n,s=1/n,f=s;for(let u=0;u<300&&(r+=1,f*=t/r,s+=f,!(Math.abs(f)<Math.abs(s)*L));u++);return s*Math.exp(-t+n*Math.log(t)-F(n))}function y(n,t){let r=t+1-n,s=1/B,f=1/r,u=f;for(let o=1;o<=300;o++){const g=-o*(o-n);r+=2,f=g*f+r,Math.abs(f)<B&&(f=B),s=r+g/s,Math.abs(s)<B&&(s=B),f=1/f;const d=f*s;if(u*=d,Math.abs(d-1)<L)break}return Math.exp(-t+n*Math.log(t)-F(n))*u}function l(n,t){return!(n>0)||!(t>=0)||!Number.isFinite(t)?Number.NaN:t===0?0:t<n+1?S(n,t):1-y(n,t)}function c(n,t){return t>0?l(t/2,n/2):Number.NaN}function i(n,t){const r=c(n,t);return Number.isNaN(r)?Number.NaN:Math.min(1,Math.max(0,1-r))}}),xe("packages/core/src/compute/linalg.js",function(e,K){"use strict";Object.defineProperty(e,"cholesky",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"choleskySolve",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"choleskyInverse",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"normalEquations",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"matVec",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"quadForm",{enumerable:!0,get:function(){return Q}});function X(G){const H=G.length,U=Array.from({length:H},()=>new Array(H).fill(0));for(let D=0;D<H;D++)for(let v=0;v<=D;v++){let S=G[D][v];for(let y=0;y<v;y++)S-=U[D][y]*U[v][y];if(D===v){if(!(S>0))return null;U[D][v]=Math.sqrt(S)}else U[D][v]=S/U[v][v]}return U}function L(G,H){const U=G.length,D=new Array(U).fill(0);for(let S=0;S<U;S++){let y=H[S];for(let l=0;l<S;l++)y-=G[S][l]*D[l];D[S]=y/G[S][S]}const v=new Array(U).fill(0);for(let S=U-1;S>=0;S--){let y=D[S];for(let l=S+1;l<U;l++)y-=G[l][S]*v[l];v[S]=y/G[S][S]}return v}function B(G){const H=G.length,U=Array.from({length:H},()=>new Array(H).fill(0));for(let D=0;D<H;D++){const v=new Array(H).fill(0);v[D]=1;const S=L(G,v);for(let y=0;y<H;y++)U[y][D]=S[y]}return U}function F(G,H,U){const D=G.length,v=D?G[0].length:0,S=Array.from({length:v},()=>new Array(v).fill(0)),y=new Array(v).fill(0);for(let l=0;l<D;l++){const c=U?U[l]:1,i=G[l];for(let n=0;n<v;n++){const t=c*i[n];y[n]+=t*H[l];for(let r=n;r<v;r++)S[n][r]+=t*i[r]}}for(let l=0;l<v;l++)for(let c=0;c<l;c++)S[l][c]=S[c][l];return{xtwx:S,xtwy:y}}function W(G,H){return G.map(U=>U.reduce((D,v,S)=>D+v*H[S],0))}function Q(G,H){let U=0;for(let D=0;D<G.length;D++){let v=0;for(let S=0;S<G.length;S++)v+=H[D][S]*G[S];U+=G[D]*v}return U}}),xe("packages/core/src/compute/sketch.js",function(e,K){"use strict";Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});class X{#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 c=l-this.#t;this.#t+=c/this.#e,this.#n+=c*(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 c=this.#e+l.#e,i=l.#t-this.#t;this.#t+=i*(l.#e/c),this.#n+=l.#n+i*i*(this.#e*l.#e/c),this.#e=c}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 L{#e=[];#t=0;#n;#r;constructor(l,c=Math.random){if(!(l>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(l),this.#r=c}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 c=Math.floor(this.#r()*this.#t);c<this.#n&&(this.#e[c]=l)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let l=0;for(const c of this.#e)l+=c;return l/this.#e.length}quantile(l){const c=this.#e.length;if(!c)return null;const i=this.#e.slice().sort((s,f)=>s-f);if(c===1)return i[0];const n=(c-1)*Math.min(1,Math.max(0,l)),t=Math.floor(n),r=Math.ceil(n);return t===r?i[t]:i[t]+(n-t)*(i[r]-i[t])}}function B(y){return y^=y>>>16,y=Math.imul(y,2246822507),y^=y>>>13,y=Math.imul(y,3266489909),y^=y>>>15,y>>>0}function F(y){if(typeof y=="number"){const i=new DataView(new ArrayBuffer(8));return i.setFloat64(0,y===0?0:y),B(i.getUint32(0)^i.getUint32(4))}const l=typeof y=="string"?y:String(y);let c=2166136261;for(let i=0;i<l.length;i++)c^=l.charCodeAt(i),c=Math.imul(c,16777619);return B(c)}class W{#e;#t;#n;constructor(l=14){const c=Math.floor(l);if(c<4||c>16)throw new RangeError("HLL precision must be 4..16");this.#e=c,this.#t=1<<c,this.#n=new Uint8Array(this.#t)}static errorBoundFor(l=14){const c=1<<Math.floor(l),i=1.04/Math.sqrt(c);return Object.freeze({kind:"probabilistic",metric:"relative",value:i,statement:`distinct count within ~${(i*100).toFixed(2)}% relative standard error (m=${c} buckets)`})}errorBound(){return W.errorBoundFor(this.#e)}add(l){const c=F(l),i=c&this.#t-1,n=c>>>this.#e|1<<32-this.#e;let t=1,r=n;for(;(r&1)===0;)t++,r>>>=1;t>this.#n[i]&&(this.#n[i]=t)}count(){const l=this.#t,c=32-this.#e,i=new Float64Array(c+2);for(let r=0;r<l;r++)i[this.#n[r]]++;let n=l*H(1-i[c+1]/l);for(let r=c;r>=1;r--)n=.5*(n+i[r]);n+=l*G(i[0]/l);const t=Q*l*l/n;return Math.round(t)}}const Q=.5/Math.log(2);function G(y){if(y===1)return 1/0;let l=1,c=y,i;do y*=y,i=c,c+=y*l,l+=l;while(c!==i);return c}function H(y){if(y===0||y===1)return 0;let l=1,c=1-y,i;do y=Math.sqrt(y),i=c,l*=.5,c-=(1-y)**2*l;while(c!==i);return c/3}class U{#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 c=l/this.#t;return Object.freeze({kind:"deterministic",metric:"absolute",value:c,statement:`each count overestimates the truth by at most N/m = ${c.toFixed(2)} (N=${l}, m=${this.#t})`})}get seen(){return this.#n}add(l){this.#n++;const c=this.#e.get(l);if(c){c.count++;return}if(this.#e.size<this.#t){this.#e.set(l,{count:1,error:0});return}let i,n=1/0;for(const[t,r]of this.#e)r.count<n&&(n=r.count,i=t);this.#e.delete(i),this.#e.set(l,{count:n+1,error:n})}top(l=this.#t){return[...this.#e.entries()].map(([i,n])=>({item:i,count:n.count,error:n.error})).sort((i,n)=>n.count-i.count).slice(0,Math.max(0,Math.floor(l)))}}class D{#e;#t=[[]];#n=0;#r;#o;constructor(l=200,c=Math.random){this.#e=Math.max(8,Math.floor(l)),this.#r=c,this.#o=2/3}static errorBoundFor(l=200){const c=1/Math.max(8,Math.floor(l));return Object.freeze({kind:"probabilistic",metric:"rank",value:c,statement:`queried quantile's true rank within ~${(c*100).toFixed(2)}% of N of the requested rank (k=${l})`})}errorBound(){return D.errorBoundFor(this.#e)}get count(){return this.#n}#i(l){const i=this.#t.length-1-l,n=Math.ceil(this.#e*this.#o**i);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 c=this.#t[l];c.sort((t,r)=>t-r),l+1>=this.#t.length&&this.#t.push([]);const i=this.#t[l+1],n=this.#r()<.5?0:1;for(let t=n;t<c.length;t+=2)i.push(c[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 c=0;c<this.#t.length;c++){const i=1<<c;for(const n of this.#t[c])l.push({v:n,w:i})}return l}quantile(l){const c=this.#l();if(!c.length)return null;c.sort((r,s)=>r.v-s.v);let i=0;for(const r of c)i+=r.w;const n=Math.min(1,Math.max(0,l))*i;let t=0;for(const r of c)if(t+=r.w,t>=n)return r.v;return c[c.length-1].v}rank(l){let c=0;for(let i=0;i<this.#t.length;i++){const n=1<<i;for(const t of this.#t[i])t<=l&&(c+=n)}return c}}const v=Object.freeze({distinct:W.errorBoundFor(14),median:D.errorBoundFor(200),p25:D.errorBoundFor(200),p75:D.errorBoundFor(200),p90:D.errorBoundFor(200),p95:D.errorBoundFor(200),p99:D.errorBoundFor(200),iqr:D.errorBoundFor(200),topK:Object.freeze({kind:"deterministic",metric:"absolute",value:0,statement:"each count overestimates the truth by at most N/m; top-K exact when the K-th item exceeds N/m"})}),S={Welford:X,Reservoir:L,HyperLogLog:W,SpaceSaving:U,KLL:D,hash32:F,SKETCH_BOUNDS:v}}),xe("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 f}}),Object.defineProperty(e,"numbers",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"frequencies",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"entropy",{enumerable:!0,get:function(){return h}}),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 w}}),Object.defineProperty(e,"moments",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"quantileSorted",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"quantile",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"STAT_FNS",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"STAT_LABELS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"extremeRow",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"correlation",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"trimmedMean",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"winsorizedMean",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"modifiedZOutliers",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"jarqueBera",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"covariance",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"regression",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"fitLinearModel",{enumerable:!0,get:function(){return se}}),Object.defineProperty(e,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"kendall",{enumerable:!0,get:function(){return he}}),Object.defineProperty(e,"seriesStats",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(e,"D2_N2",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"D4_N2",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"movingRanges",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(e,"withinSigma",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(e,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return tt}}),Object.defineProperty(e,"controlViolations",{enumerable:!0,get:function(){return it}}),Object.defineProperty(e,"countOutside",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(e,"histogram",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(e,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return St}}),Object.defineProperty(e,"meanInterval",{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(e,"proportionInterval",{enumerable:!0,get:function(){return Tt}}),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 Xe}}),Object.defineProperty(e,"normalTotalVariation",{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(e,"frequencyMap",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(e,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(e,"compareColumn",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(e,"isNumericColumn",{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(e,"populationRead",{enumerable:!0,get:function(){return nt}});const X=K("packages/core/src/compute/handle.js"),L=X.presenceReader,B=X.valueReader,F=K("packages/core/src/compute/special.js"),W=F.studentTQuantile,Q=F.studentT,G=F.normalQuantile,H=F.normalCdf,U=F.chiSquareUpperTail,D=K("packages/core/src/compute/linalg.js"),v=D.cholesky,S=D.choleskySolve,y=D.choleskyInverse,l=D.normalEquations,c=D.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 f(ye){const ke=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:ke,approximate:Se}}function u(ye,ke){const Se=ke.length,Ae=new Float64Array(Se);let Fe=0;if(ye&&(ye.kind==="float64"||ye.kind==="int32")){const Pe=ye.values,Ne=L(ye);for(let De=0;De<Se;De++){const qe=ke[De];if(Ne&&Ne(qe)!==1)continue;const ot=Pe[qe];Number.isNaN(ot)||(Ae[Fe++]=ot)}return Ae.subarray(0,Fe)}const Me=B(ye);for(let Pe=0;Pe<Se;Pe++){const Ne=Me(ke[Pe]);if(Ne==null||Ne==="")continue;const De=typeof Ne=="number"?Ne:Number(Ne);Number.isFinite(De)&&(Ae[Fe++]=De)}return Ae.subarray(0,Fe)}function o(ye,ke){const Se=new Map,Ae=B(ye);let Fe=0;for(let Me=0;Me<ke.length;Me++){const Pe=Ae(ke[Me]);if(Pe==null||Pe===""||typeof Pe=="number"&&Number.isNaN(Pe))continue;const Ne=typeof Pe=="object"?String(Pe):Pe;Se.set(Ne,(Se.get(Ne)||0)+1),Fe++}const me=[...Se.values()].sort((Me,Pe)=>Pe-Me);return{counts:me,total:Fe,distinct:me.length}}function g(ye){return ye.total>0?ye.counts.map(ke=>ke/ye.total):[]}function d(ye,ke){const Se=o(ye,ke);if(!Se.total)return null;let Ae=0;for(const Fe of g(Se))Ae+=Fe*Fe;return Ae}function h(ye,ke){const Se=o(ye,ke);if(!Se.total)return null;let Ae=0;for(const Fe of g(Se))Fe>0&&(Ae-=Fe*Math.log2(Fe));return Ae}function a(ye,ke){const Se=o(ye,ke);if(!Se.total||Se.distinct<2)return Se.total?1:null;let Ae=0;for(const Fe of g(Se))Fe>0&&(Ae-=Fe*Math.log2(Fe));return Ae/Math.log2(Se.distinct)}function p(ye,ke,Se=3){const Ae=o(ye,ke);if(!Ae.total)return null;const Fe=Math.max(1,Math.floor(Se));let me=0;for(let Me=0;Me<Math.min(Fe,Ae.counts.length);Me++)me+=Ae.counts[Me];return me/Ae.total}function w(ye,ke){const Se=u(ye,ke),Ae=Se.length;if(!Ae)return null;const Fe=Se.slice().sort();if(Fe[0]<0)return null;let me=0,Me=0;for(let Pe=0;Pe<Ae;Pe++)me+=Fe[Pe],Me+=(Pe+1)*Fe[Pe];return me===0?0:2*Me/(Ae*me)-(Ae+1)/Ae}function k(ye){let ke=0,Se=0,Ae=0;for(let Fe=0;Fe<ye.length;Fe++){const me=ye[Fe];ke++;const Me=me-Se;Se+=Me/ke,Ae+=Me*(me-Se)}return{n:ke,mean:Se,m2:Ae}}function m(ye,ke){const Se=ye.length;if(!Se)return NaN;if(Se===1)return ye[0];const Ae=(Se-1)*Math.min(1,Math.max(0,ke)),Fe=Math.floor(Ae),me=Math.ceil(Ae);return Fe===me?ye[Fe]:ye[Fe]+(Ae-Fe)*(ye[me]-ye[Fe])}function b(ye,ke){if(!ye.length)return NaN;const Se=ye.slice().sort();return m(Se,ke)}function C(ye,ke){const Se=B(ye);let Ae=0,Fe=0,me=0;for(let Me=0;Me<ke.length;Me++){const Pe=Se(ke[Me]);if(Pe==null||Pe==="")continue;const Ne=String(Pe).toUpperCase();Ne==="PASS"?Ae++:Ne==="FAIL"?Fe++:Ne==="WARN"&&me++}return{pass:Ae+me,fail:Fe,warn:me,judged:Ae+me+Fe}}const M=Object.freeze({hhi:(ye,ke)=>d(ye,ke),entropy:(ye,ke)=>h(ye,ke),evenness:(ye,ke)=>a(ye,ke),top3Share:(ye,ke)=>p(ye,ke,3),top10Share:(ye,ke)=>p(ye,ke,10),gini:(ye,ke)=>w(ye,ke),trimmedMean:(ye,ke)=>j(u(ye,ke),.1),winsorizedMean:(ye,ke)=>$(u(ye,ke),.1),robustOutliers:(ye,ke)=>z(u(ye,ke),3.5),jarqueBera:(ye,ke)=>T(u(ye,ke)),variance:(ye,ke)=>{const{n:Se,m2:Ae}=k(u(ye,ke));return Se>1?Ae/(Se-1):null},varianceP:(ye,ke)=>{const{n:Se,m2:Ae}=k(u(ye,ke));return Se>0?Ae/Se:null},stddev:(ye,ke)=>{const{n:Se,m2:Ae}=k(u(ye,ke));return Se>1?Math.sqrt(Ae/(Se-1)):null},stddevP:(ye,ke)=>{const{n:Se,m2:Ae}=k(u(ye,ke));return Se>0?Math.sqrt(Ae/Se):null},median:(ye,ke)=>{const Se=u(ye,ke);return Se.length?b(Se,.5):null},p25:(ye,ke)=>{const Se=u(ye,ke);return Se.length?b(Se,.25):null},p75:(ye,ke)=>{const Se=u(ye,ke);return Se.length?b(Se,.75):null},p90:(ye,ke)=>{const Se=u(ye,ke);return Se.length?b(Se,.9):null},p95:(ye,ke)=>{const Se=u(ye,ke);return Se.length?b(Se,.95):null},p99:(ye,ke)=>{const Se=u(ye,ke);return Se.length?b(Se,.99):null},iqr:(ye,ke)=>{const Se=u(ye,ke);if(!Se.length)return null;const Ae=Se.slice().sort();return m(Ae,.75)-m(Ae,.25)},mad:(ye,ke)=>{const Se=u(ye,ke);if(!Se.length)return null;const Ae=b(Se,.5),Fe=new Float64Array(Se.length);for(let me=0;me<Se.length;me++)Fe[me]=Math.abs(Se[me]-Ae);return b(Fe,.5)},range:(ye,ke)=>{const Se=u(ye,ke);if(!Se.length)return null;let Ae=1/0,Fe=-1/0;for(let me=0;me<Se.length;me++)Se[me]<Ae&&(Ae=Se[me]),Se[me]>Fe&&(Fe=Se[me]);return Fe-Ae},distinct:(ye,ke)=>{const Se=B(ye),Ae=new Set;for(let Fe=0;Fe<ke.length;Fe++){const me=Se(ke[Fe]);me==null||me===""||Ae.add(me instanceof Date?me.getTime():me)}return Ae.size},mode:(ye,ke)=>{const Se=B(ye),Ae=new Map;for(let Me=0;Me<ke.length;Me++){const Pe=Se(ke[Me]);if(Pe==null||Pe==="")continue;const Ne=Pe instanceof Date?Pe.getTime():Pe;Ae.set(Ne,(Ae.get(Ne)||0)+1)}let Fe=null,me=1;for(const[Me,Pe]of Ae)Pe>me&&(me=Pe,Fe=Me);return Fe},skewness:(ye,ke)=>{const Se=u(ye,ke),{n:Ae,mean:Fe,m2:me}=k(Se);if(Ae<3||me<=0)return null;const Me=Math.sqrt(me/(Ae-1));let Pe=0;for(let Ne=0;Ne<Se.length;Ne++)Pe+=((Se[Ne]-Fe)/Me)**3;return Ae/((Ae-1)*(Ae-2))*Pe},kurtosis:(ye,ke)=>{const Se=u(ye,ke),{n:Ae,mean:Fe,m2:me}=k(Se);if(Ae<4||me<=0)return null;const Me=Math.sqrt(me/(Ae-1));let Pe=0;for(let qe=0;qe<Se.length;qe++)Pe+=((Se[qe]-Fe)/Me)**4;const Ne=Ae*(Ae+1)/((Ae-1)*(Ae-2)*(Ae-3)),De=3*(Ae-1)**2/((Ae-2)*(Ae-3));return Ne*Pe-De},geomean:(ye,ke)=>{const Se=u(ye,ke);if(!Se.length)return null;let Ae=0;for(let Fe=0;Fe<Se.length;Fe++){if(Se[Fe]<=0)return null;Ae+=Math.log(Se[Fe])}return Math.exp(Ae/Se.length)},harmean:(ye,ke)=>{const Se=u(ye,ke);if(!Se.length)return null;let Ae=0;for(let Fe=0;Fe<Se.length;Fe++){if(Se[Fe]===0)return null;Ae+=1/Se[Fe]}return Se.length/Ae},sumSquares:(ye,ke)=>{const Se=u(ye,ke);let Ae=0;for(let Fe=0;Fe<Se.length;Fe++)Ae+=Se[Fe]*Se[Fe];return Ae},passRate:(ye,ke)=>{const{pass:Se,judged:Ae}=C(ye,ke);return Ae?Se/Ae:null},failureCount:(ye,ke)=>C(ye,ke).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 x(ye,ke,Se){const Ae=B(ye),Fe=B(ke);let me=0,Me=0;for(let Pe=0;Pe<Se.length;Pe++){const Ne=Se[Pe],De=Number(Ae(Ne)),qe=Number(Fe(Ne));!Number.isFinite(De)||!Number.isFinite(qe)||(me+=De*qe,Me+=qe)}return Me===0?null:me/Me}function E(ye,ke,Se){const Ae=B(ye);let Fe=null,me=Se?-1/0:1/0;for(let Me=0;Me<ke.length;Me++){const Pe=ke[Me],Ne=Number(Ae(Pe));Number.isFinite(Ne)&&(Se?Ne>me:Ne<me)&&(me=Ne,Fe=Pe)}return Fe}function A(ye,ke,Se){const Ae=B(ye),Fe=B(ke);let me=0,Me=0,Pe=0,Ne=0,De=0,qe=0;for(let st=0;st<Se.length;st++){const wt=Se[st],ct=Number(Ae(wt)),pt=Number(Fe(wt));!Number.isFinite(ct)||!Number.isFinite(pt)||(me++,Me+=ct,Pe+=pt,Ne+=ct*ct,De+=pt*pt,qe+=ct*pt)}if(me<2)return null;const ot=me*qe-Me*Pe,ut=Math.sqrt((me*Ne-Me*Me)*(me*De-Pe*Pe));if(ut===0)return null;const dt=ot/ut;return Math.max(-1,Math.min(1,dt))}function j(ye,ke=.1){const Se=ye.length;if(!Se)return null;const Ae=Array.from(ye).sort((Pe,Ne)=>Pe-Ne),Fe=Math.floor(Se*Math.min(.49,Math.max(0,ke))),me=Ae.slice(Fe,Se-Fe);if(!me.length)return m(Ae,.5);let Me=0;for(const Pe of me)Me+=Pe;return Me/me.length}function $(ye,ke=.1){const Se=ye.length;if(!Se)return null;const Ae=Array.from(ye).sort((Ne,De)=>Ne-De),Fe=Math.floor(Se*Math.min(.49,Math.max(0,ke))),me=Ae[Fe],Me=Ae[Se-1-Fe];let Pe=0;for(const Ne of Ae)Pe+=Math.min(Me,Math.max(me,Ne));return Pe/Se}function z(ye,ke=3.5){if(!ye.length)return null;const Ae=Array.from(ye).sort((Ne,De)=>Ne-De),Fe=m(Ae,.5),me=Ae.map(Ne=>Math.abs(Ne-Fe)).sort((Ne,De)=>Ne-De),Me=m(me,.5);if(Me===0)return null;let Pe=0;for(const Ne of Ae)Math.abs(.6745*(Ne-Fe)/Me)>ke&&Pe++;return Pe}function T(ye){const ke=ye.length;if(ke<8)return null;let Se=0;for(const Ne of ye)Se+=Ne;Se/=ke;let Ae=0,Fe=0,me=0;for(const Ne of ye){const De=Ne-Se;Ae+=De*De,Fe+=De*De*De,me+=De*De*De*De}if(Ae/=ke,Fe/=ke,me/=ke,Ae===0)return null;const Me=Fe/Ae**1.5,Pe=me/(Ae*Ae)-3;return ke/6*(Me*Me+Pe*Pe/4)}function R(ye,ke,Se){const Ae=[];let Fe=0;for(let Ne=0;Ne<ye.length;Ne++){const De=Number(ye[Ne]),qe=Number(ke[Ne]);!Number.isFinite(De)||!Number.isFinite(qe)||qe<=0||(Ae.push([De,qe]),Fe+=qe)}if(!Ae.length||Fe<=0)return null;if(Ae.sort((Ne,De)=>Ne[0]-De[0]),Ae.length===1)return Ae[0][0];const me=[];let Me=0;for(const[,Ne]of Ae)me.push((Me+Ne/2)/Fe),Me+=Ne;const Pe=Math.max(0,Math.min(1,Se));if(Pe<=me[0])return Ae[0][0];if(Pe>=me[me.length-1])return Ae[Ae.length-1][0];for(let Ne=1;Ne<me.length;Ne++){if(Pe>me[Ne])continue;const De=me[Ne]-me[Ne-1],qe=De>0?(Pe-me[Ne-1])/De:0;return Ae[Ne-1][0]+(Ae[Ne][0]-Ae[Ne-1][0])*qe}return Ae[Ae.length-1][0]}function O(ye,ke,Se){const Ae=B(ye),Fe=B(ke),me=new Float64Array(Se.length),Me=new Float64Array(Se.length);let Pe=0;for(let Ne=0;Ne<Se.length;Ne++){const De=Se[Ne],qe=Number(Ae(De)),ot=Number(Fe(De));!Number.isFinite(qe)||!Number.isFinite(ot)||(me[Pe]=qe,Me[Pe]=ot,Pe++)}return{xs:me.subarray(0,Pe),ys:Me.subarray(0,Pe),n:Pe}}function I(ye,ke,Se,Ae=!1){const{xs:Fe,ys:me,n:Me}=O(ye,ke,Se);if(Me<2)return null;let Pe=0,Ne=0;for(let qe=0;qe<Me;qe++)Pe+=Fe[qe],Ne+=me[qe];Pe/=Me,Ne/=Me;let De=0;for(let qe=0;qe<Me;qe++)De+=(Fe[qe]-Pe)*(me[qe]-Ne);return De/(Ae?Me:Me-1)}function q(ye,ke,Se){const{xs:Ae,ys:Fe,n:me}=O(ye,ke,Se);if(me<2)return null;let Me=0,Pe=0;for(let ct=0;ct<me;ct++)Me+=Ae[ct],Pe+=Fe[ct];Me/=me,Pe/=me;let Ne=0,De=0,qe=0;for(let ct=0;ct<me;ct++){const pt=Ae[ct]-Me,jt=Fe[ct]-Pe;Ne+=pt*pt,De+=pt*jt,qe+=jt*jt}if(Ne===0)return null;const ot=De/Ne,ut=Pe-ot*Me,dt=qe===0?1:Math.max(0,Math.min(1,De*De/(Ne*qe))),st=Math.max(0,qe-ot*De),wt=me>2?Math.sqrt(st/(me-2)/Ne):0;return{slope:ot,intercept:ut,r2:dt,stdError:wt,n:me}}const Z=new Set(["ols","wls","robust"]),_=new Set(["quantile"]),J=new Set(["ridge","lasso","elasticnet","mixed","gls"]),ee=1.345;function te(ye,ke,Se){const{xtwx:Ae,xtwy:Fe}=l(ye,ke,Se),me=v(Ae);if(!me)return null;const Me=S(me,Fe),Pe=y(me),Ne=ne(ye,Me),De=ke.map((qe,ot)=>qe-Ne[ot]);return{beta:Me,cov:Pe,fitted:Ne,residuals:De}}function ne(ye,ke){return ye.map(Se=>Se.reduce((Ae,Fe,me)=>Ae+Fe*ke[me],0))}function ie(ye,ke){const Se=ye.length,Ae=ye.map(De=>De[ke]),Fe=ye.map(De=>[1,...De.filter((qe,ot)=>ot!==ke)]),me=te(Fe,Ae,null);if(!me)return 1;const Me=Ae.reduce((De,qe)=>De+qe,0)/Se;let Pe=0,Ne=0;for(let De=0;De<Se;De++)Pe+=me.residuals[De]**2,Ne+=(Ae[De]-Me)**2;return Ne===0?1:Math.max(0,Math.min(1,1-Pe/Ne))}function ae(ye){const ke=[...ye].sort((Fe,me)=>Fe-me),Se=re(ke),Ae=ye.map(Fe=>Math.abs(Fe-Se)).sort((Fe,me)=>Fe-me);return re(Ae)/.6745}function re(ye){const ke=ye.length;if(!ke)return 0;const Se=Math.floor(ke/2);return ke%2?ye[Se]:(ye[Se-1]+ye[Se])/2}function se(ye,ke,Se={}){const Ae=Se.method||"ols";if(J.has(Ae))throw new Error(`[lattice] regression method "${Ae}" is out of scope; use ols, wls or robust.`);if(_.has(Ae))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!Z.has(Ae))throw new Error(`[lattice] unknown regression method "${Ae}"; use ols, wls or robust.`);const Fe=Array.isArray(ke)?ke.length:0,me=Fe&&Array.isArray(ye[0])?ye[0].length:0,Me=me+1;if(!(Fe>Me))return null;for(let Pt=0;Pt<Fe;Pt++){if(!Number.isFinite(ke[Pt])||!Array.isArray(ye[Pt])||ye[Pt].length!==me)return null;for(let Ft=0;Ft<me;Ft++)if(!Number.isFinite(ye[Pt][Ft]))return null}let Pe=null;if(Ae==="wls"){if(Pe=Se.weights,!Array.isArray(Pe)||Pe.length!==Fe)return null;for(let Pt=0;Pt<Fe;Pt++)if(!(Pe[Pt]>0)||!Number.isFinite(Pe[Pt]))return null}const Ne=ye.map(Pt=>[1,...Pt]);let De,qe=null;if(Ae==="robust"){if(De=te(Ne,ke,null),!De)return null;for(let Pt=0;Pt<50;Pt++){const Ft=ae(De.residuals);if(!(Ft>0))break;const zt=De.residuals.map(Yt=>{const Qt=Math.abs(Yt/Ft);return Qt<=ee?1:ee/Qt}),Kt=te(Ne,ke,zt);if(!Kt)return null;const Xt=Kt.beta.reduce((Yt,Qt,rn)=>Math.max(Yt,Math.abs(Qt-De.beta[rn])),0);if(De=Kt,qe=zt,Xt<1e-10)break}}else if(De=te(Ne,ke,Pe),!De)return null;const ot=Ae==="robust"?qe:Pe,{beta:ut,cov:dt,fitted:st,residuals:wt}=De;let ct=0,pt=0,jt=0;for(let Pt=0;Pt<Fe;Pt++){const Ft=ot?ot[Pt]:1;ct+=Ft*wt[Pt]**2,pt+=Ft,jt+=Ft*ke[Pt]}const He=jt/pt;let lt=0;for(let Pt=0;Pt<Fe;Pt++){const Ft=ot?ot[Pt]:1;lt+=Ft*(ke[Pt]-He)**2}const rt=Fe-Me,vt=ct/rt,Nt=lt===0?1:Math.max(0,Math.min(1,1-ct/lt)),$t=1-(1-Nt)*(Fe-1)/rt,gt=Array.isArray(Se.names)&&Se.names.length===me?Se.names:ye[0].map((Pt,Ft)=>`x${Ft+1}`),Rt=At(Se.confidence),Ut=rt>0?W(1-(1-Rt)/2,rt):1/0,Jt=ut.map((Pt,Ft)=>{const zt=Math.sqrt(Math.max(0,vt*dt[Ft][Ft])),Kt=zt>0?Pt/zt:Pt===0?0:1/0,Xt=Number.isFinite(Kt)?2*(1-Q(Math.abs(Kt),rt)):0,Yt=Number.isFinite(Ut)?Ut*zt:null;return{name:Ft===0?"(intercept)":gt[Ft-1],estimate:Pt,stdError:zt,t:Kt,p:Math.max(0,Math.min(1,Xt)),lower:Yt===null?null:Pt-Yt,upper:Yt===null?null:Pt+Yt}}),pn=new Array(Fe),an=new Array(Fe);for(let Pt=0;Pt<Fe;Pt++){const Ft=ot?ot[Pt]:1,zt=Math.max(0,Math.min(1,Ft*c(Ne[Pt],dt)));pn[Pt]=zt;const Kt=(1-zt)**2;an[Pt]=Kt>0&&vt>0?wt[Pt]**2/(Me*vt)*(zt/Kt):null}const dn=ye[0].map((Pt,Ft)=>{if(me<2)return 1;const zt=ie(ye,Ft);return zt>=1?1/0:1/(1-zt)});let qt=null;{const Pt=wt.map(zt=>zt*zt),Ft=te(Ne,Pt,null);if(Ft){const zt=Pt.reduce((en,cn)=>en+cn,0)/Fe;let Kt=0,Xt=0;for(let en=0;en<Fe;en++)Kt+=Ft.residuals[en]**2,Xt+=(Pt[en]-zt)**2;const Yt=Xt===0?0:Math.max(0,Math.min(1,1-Kt/Xt)),Qt=Fe*Yt,rn=U(Qt,me);qt={statistic:Qt,df:me,p:rn,heteroscedastic:rn<.05}}}let _t=null;if(me===1){const Pt=ye.map((Ft,zt)=>zt).sort((Ft,zt)=>ye[Ft][0]-ye[zt][0]);_t={confidence:Rt,points:Pt.map(Ft=>{const zt=Ne[Ft],Kt=Math.sqrt(Math.max(0,vt*c(zt,dt)));return{x:ye[Ft][0],yhat:st[Ft],lower:st[Ft]-Ut*Kt,upper:st[Ft]+Ut*Kt}})}}return{method:Ae,coefficients:Jt,r2:Nt,adjR2:$t,n:Fe,df:rt,sigma2:vt,fitted:st,residuals:wt,leverage:pn,cooksD:an,vif:dn,heteroscedasticity:qt,band:_t,weights:ot?[...ot]:null}}function le(ye){const ke=ye.length,Se=Array.from({length:ke},(me,Me)=>Me).sort((me,Me)=>ye[me]-ye[Me]),Ae=new Float64Array(ke);let Fe=0;for(;Fe<ke;){let me=Fe;for(;me+1<ke&&ye[Se[me+1]]===ye[Se[Fe]];)me++;const Me=(Fe+me)/2+1;for(let Pe=Fe;Pe<=me;Pe++)Ae[Se[Pe]]=Me;Fe=me+1}return Ae}const fe=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function be(ye){const ke=[.01,.05,.1],Se=[fe["1%"],fe["5%"],fe["10%"]];if(ye<=Se[0]){const me=(Math.log(ke[1])-Math.log(ke[0]))/(Se[1]-Se[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(ke[0])+me*(ye-Se[0]))))}if(ye>=Se[2]){const me=(Math.log(ke[2])-Math.log(ke[1]))/(Se[2]-Se[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(ke[2])+me*(ye-Se[2]))))}const Ae=ye<Se[1]?0:1,Fe=(ye-Se[Ae])/(Se[Ae+1]-Se[Ae]);return Math.exp(Math.log(ke[Ae])+Fe*(Math.log(ke[Ae+1])-Math.log(ke[Ae])))}function Le(ye,ke,Se,Ae){const Fe=Se-Ae,me=Ae+3,Me=new Array(Fe),Pe=new Array(Fe);let Ne=!0,De=Ae;for(let st=0;st<Fe;st++){const wt=Ae+st,ct=new Float64Array(me);ct[0]=1,ct[1]=st+1,ct[2]=ye[wt];for(let pt=1;pt<=Ae;pt++)ct[2+pt]=ke[wt-pt];for(let pt=1;pt<me;pt++)Number.isFinite(ct[pt])||(De=Math.min(De,pt-3));Me[st]=ct,Pe[st]=ke[wt],Number.isFinite(Pe[st])||(Ne=!1)}if(!Ne)return 0;const{xtwx:qe,xtwy:ot}=l(Me,Pe,null);let ut=0,dt=1/0;for(let st=0;st<=De;st++){const wt=st+3;if(!(Fe>wt))continue;const ct=new Array(wt);for(let Nt=0;Nt<wt;Nt++)ct[Nt]=qe[Nt].slice(0,wt);const pt=v(ct);if(!pt)continue;const jt=S(pt,ot.slice(0,wt));let He=0;for(let Nt=0;Nt<Fe;Nt++){const $t=Me[Nt];let gt=0;for(let Rt=0;Rt<wt;Rt++)gt+=$t[Rt]*jt[Rt];He+=(Pe[Nt]-gt)**2}const rt=He/(Fe-wt)*(Fe-wt);if(!(rt>0))continue;const vt=Fe*Math.log(rt/Fe)+2*wt;vt<dt&&(dt=vt,ut=st)}return ut}function we(ye,ke={}){const Se=[];for(let dt=0;dt<ye.length;dt++){const st=Number(ye[dt]);Number.isFinite(st)&&Se.push(st)}const Ae=Se.length,Fe=Ae-1;if(Ae<8||Fe<6)return null;const me=new Array(Fe);for(let dt=0;dt<Fe;dt++)me[dt]=Se[dt+1]-Se[dt];let Me=Number.isFinite(ke.maxlag)?Math.floor(ke.maxlag):Math.ceil(12*(Ae/100)**.25);Me=Math.max(0,Math.min(Me,Math.floor((Fe-5)/2)));const Pe=(dt,st)=>{const wt=[],ct=[];for(let pt=st;pt<Fe;pt++){const jt=[pt-st+1,Se[pt]];for(let He=1;He<=dt;He++)jt.push(me[pt-He]);wt.push(jt),ct.push(me[pt])}return se(wt,ct,{method:"ols"})},Ne=Le(Se,me,Fe,Me),De=Pe(Ne,Ne);if(!De||!De.coefficients[2])return null;const qe=De.coefficients[2].t,ot=be(qe),ut=qe<fe["5%"];return{statistic:qe,usedLag:Ne,nobs:Fe-Ne,criticalValues:{...fe},pValue:ot,pApproximate:!0,stationary:ut,verdict:ut?"stationary":"non-stationary",regression:"ct"}}function Re(ye,ke={}){const Se=[];for(let ut=0;ut<ye.length;ut++){const dt=Number(ye[ut]);Number.isFinite(dt)&&Se.push(dt)}const Ae=Se.length;if(Ae<3)return null;let Fe=Number.isFinite(ke.maxlag)?Math.floor(ke.maxlag):Math.min(10,Ae-1);Fe=Math.max(1,Math.min(Fe,Ae-1));let me=0;for(const ut of Se)me+=ut;me/=Ae;const Me=Se.map(ut=>ut-me);let Pe=0;for(const ut of Me)Pe+=ut*ut;Pe/=Ae;const Ne=new Array(Fe+1).fill(0);Ne[0]=1;for(let ut=1;ut<=Fe;ut++){let dt=0;for(let st=ut;st<Ae;st++)dt+=Me[st]*Me[st-ut];Ne[ut]=Pe>0?dt/Ae/Pe:0}const De=new Array(Fe+1).fill(0);De[0]=1;let qe=[];for(let ut=1;ut<=Fe;ut++){let dt=Ne[ut];for(let pt=1;pt<ut;pt++)dt-=qe[pt-1]*Ne[ut-pt];let st=1;for(let pt=1;pt<ut;pt++)st-=qe[pt-1]*Ne[pt];const wt=st!==0?dt/st:0,ct=new Array(ut);for(let pt=1;pt<ut;pt++)ct[pt-1]=qe[pt-1]-wt*qe[ut-1-pt];ct[ut-1]=wt,De[ut]=wt,qe=ct}const ot=1.96/Math.sqrt(Ae);return{acf:Ne,pacf:De,bounds:{upper:ot,lower:-ot},n:Ae,nlags:Fe,approximate:!0}}function ge(ye,ke,Se){const{xs:Ae,ys:Fe,n:me}=O(ye,ke,Se);if(me<2)return null;const Me=le(Ae),Pe=le(Fe);let Ne=0,De=0;for(let dt=0;dt<me;dt++)Ne+=Me[dt],De+=Pe[dt];Ne/=me,De/=me;let qe=0,ot=0,ut=0;for(let dt=0;dt<me;dt++){const st=Me[dt]-Ne,wt=Pe[dt]-De;qe+=st*wt,ot+=st*st,ut+=wt*wt}return ot===0||ut===0?null:Math.max(-1,Math.min(1,qe/Math.sqrt(ot*ut)))}function he(ye,ke,Se){const{xs:Ae,ys:Fe,n:me}=O(ye,ke,Se);if(me<2||me>t)return null;let Me=0,Pe=0,Ne=0,De=0;for(let ut=0;ut<me;ut++)for(let dt=ut+1;dt<me;dt++){const st=Math.sign(Ae[ut]-Ae[dt]),wt=Math.sign(Fe[ut]-Fe[dt]),ct=st*wt;ct>0?Me++:ct<0?Pe++:st===0&&wt===0||(st===0?Ne++:De++)}const qe=Me+Pe+De,ot=Me+Pe+Ne;return qe===0||ot===0?null:(Me-Pe)/Math.sqrt(qe*ot)}function Oe(ye,ke={}){const Se=ye.length;if(Se<2)return null;const Ae=ye[0],Fe=ye[Se-1],me=[];for(let pt=1;pt<Se;pt++){const jt=ye[pt-1];jt!==0&&me.push((ye[pt]-jt)/Math.abs(jt))}let Me=null;if(me.length>1){let pt=0;for(const He of me)pt+=He;pt/=me.length;let jt=0;for(const He of me)jt+=(He-pt)**2;Me=Math.sqrt(jt/(me.length-1))}const Pe=Number(ke.periodsPerYear)>0?Number(ke.periodsPerYear):null;let Ne=ye[0],De=0,qe=0,ot=0,ut=0;for(let pt=1;pt<Se;pt++){if(ye[pt]>Ne){Ne=ye[pt],De=pt;continue}if(Ne<=0)continue;const jt=(Ne-ye[pt])/Ne;jt>qe&&(qe=jt,ot=De,ut=pt)}let dt=null;if(Se>2){let pt=0;for(let lt=0;lt<Se;lt++)pt+=ye[lt];pt/=Se;let jt=0,He=0;for(let lt=0;lt<Se;lt++){const rt=ye[lt]-pt;He+=rt*rt,lt>0&&(jt+=rt*(ye[lt-1]-pt))}dt=He>0?jt/He:null}let st=0,wt=0;for(const pt of me)pt>0?st++:pt<0&&wt++;let ct=null;if(Ae>0&&Fe>0){const pt=(Fe/Ae)**(1/(Se-1))-1;ct=Pe?(1+pt)**Pe-1:pt}return{n:Se,first:Ae,last:Fe,change:Fe-Ae,changePercent:Ae===0?null:(Fe-Ae)/Math.abs(Ae)*100,volatility:Me,annualisedVolatility:Me!==null&&Pe?Me*Math.sqrt(Pe):null,growth:ct,maxDrawdown:qe,maxDrawdownFrom:ot,maxDrawdownTo:ut,autocorrelation:dt,upDays:st,downDays:wt}}const Ee=1.128,Ie=3.267;function ze(ye){const ke=ye.length;if(ke<2)return null;const Se=[];for(let Fe=1;Fe<ke;Fe++)Se.push(Math.abs(ye[Fe]-ye[Fe-1]));const Ae=Se.reduce((Fe,me)=>Fe+me,0)/Se.length;return{ranges:Se,centre:Ae,upper:Ie*Ae,lower:0}}function Ye(ye){const ke=ye.length;if(ke<2)return null;let Se=0;for(let Fe=1;Fe<ke;Fe++)Se+=Math.abs(ye[Fe]-ye[Fe-1]);const Ae=Se/(ke-1);return{sigma:Ae/Ee,meanRange:Ae}}function Qe(ye,ke){const Se=ye.length;if(Se<2||!ke)return null;const Ae=Number.isFinite(Number(ke.lower))?Number(ke.lower):null,Fe=Number.isFinite(Number(ke.upper))?Number(ke.upper):null;if(Ae===null&&Fe===null)return null;let me=0;for(let st=0;st<Se;st++)me+=ye[st];me/=Se;let Me=0;for(let st=0;st<Se;st++)Me+=(ye[st]-me)**2;const Pe=Math.sqrt(Me/(Se-1)),Ne=Ye(ye),De=Ne?Ne.sigma:null,qe=st=>{if(!st||st<=0)return{index:null,k:null};const ct=Ae!==null&&Fe!==null?(Fe-Ae)/(6*st):null,pt=Fe!==null?(Fe-me)/(3*st):1/0,jt=Ae!==null?(me-Ae)/(3*st):1/0;return{index:ct,k:Math.min(pt,jt)}},ot=qe(De),ut=qe(Pe);let dt=0;for(let st=0;st<Se;st++){if(Ae!==null&&ye[st]<Ae){dt++;continue}Fe!==null&&ye[st]>Fe&&dt++}return{n:Se,mean:me,lower:Ae,upper:Fe,target:Number.isFinite(Number(ke.target))?Number(ke.target):null,sigmaWithin:De,sigmaOverall:Pe,cp:ot.index,cpk:ot.k,pp:ut.index,ppk:ut.k,outOfSpec:dt,defectRate:Se?dt/Se:null}}function Te(ye){const ke=ye.length;if(ke<2)return null;const Se=Ye(ye);if(!Se||!(Se.sigma>0))return null;let Ae=0;for(let Fe=0;Fe<ke;Fe++)Ae+=ye[Fe];return Ae/=ke,{centre:Ae,sigma:Se.sigma,upper:Ae+3*Se.sigma,lower:Ae-3*Se.sigma}}function _e(ye,ke){if(!ke||!(ke.sigma>0))return[];const Se=ye.length,{centre:Ae,sigma:Fe}=ke,me=Pe=>(ye[Pe]-Ae)/Fe,Me=[];for(let Pe=0;Pe<Se;Pe++){if(Math.abs(me(Pe))>3&&Me.push({index:Pe,rule:1,description:"beyond three sigma"}),Pe>=2)for(const Ne of[1,-1]){let De=0;for(let qe=Pe-2;qe<=Pe;qe++)me(qe)*Ne>2&&De++;if(De>=2){Me.push({index:Pe,rule:2,description:"two of three past two sigma"});break}}if(Pe>=4)for(const Ne of[1,-1]){let De=0;for(let qe=Pe-4;qe<=Pe;qe++)me(qe)*Ne>1&&De++;if(De>=4){Me.push({index:Pe,rule:3,description:"four of five past one sigma"});break}}if(Pe>=7)for(const Ne of[1,-1]){let De=!0;for(let qe=Pe-7;qe<=Pe;qe++)if(me(qe)*Ne<=0){De=!1;break}if(De){Me.push({index:Pe,rule:4,description:"eight in a row on one side"});break}}}return Me}function Ke(ye,ke){if(!ke||!(ke.sigma>0))return[];const Se=ye.length,{centre:Ae,sigma:Fe}=ke,me=Ne=>(ye[Ne]-Ae)/Fe,Me=(Ne,De,qe,ot)=>{for(const ut of[1,-1]){let dt=0;for(let st=Ne;st<=De;st++)me(st)*ut>qe&&dt++;if(dt>=ot)return!0}return!1},Pe=[];for(let Ne=0;Ne<Se;Ne++){if(Math.abs(me(Ne))>3&&Pe.push({index:Ne,rule:1,description:"beyond three sigma"}),Ne>=8)for(const De of[1,-1]){let qe=!0;for(let ot=Ne-8;ot<=Ne;ot++)if(me(ot)*De<=0){qe=!1;break}if(qe){Pe.push({index:Ne,rule:2,description:"nine in a row on one side"});break}}if(Ne>=5)for(const De of[1,-1]){let qe=!0;for(let ot=Ne-4;ot<=Ne;ot++)if((ye[ot]-ye[ot-1])*De<=0){qe=!1;break}if(qe){Pe.push({index:Ne,rule:3,description:De>0?"six rising":"six falling"});break}}if(Ne>=13){let De=!0;for(let qe=Ne-12;qe<=Ne;qe++){const ot=ye[qe]-ye[qe-1],ut=ye[qe+1<=Ne?qe+1:qe]-ye[qe];if(qe+1>Ne)break;if(ot===0||ut===0||ot>0==ut>0){De=!1;break}}De&&Pe.push({index:Ne,rule:4,description:"fourteen alternating"})}if(Ne>=2&&Me(Ne-2,Ne,2,2)&&Pe.push({index:Ne,rule:5,description:"two of three past two sigma"}),Ne>=4&&Me(Ne-4,Ne,1,4)&&Pe.push({index:Ne,rule:6,description:"four of five past one sigma"}),Ne>=14){let De=!0;for(let qe=Ne-14;qe<=Ne;qe++)if(Math.abs(me(qe))>=1){De=!1;break}De&&Pe.push({index:Ne,rule:7,description:"fifteen within one sigma"})}if(Ne>=7){let De=!0;for(let qe=Ne-7;qe<=Ne;qe++)if(Math.abs(me(qe))<=1){De=!1;break}De&&Pe.push({index:Ne,rule:8,description:"eight beyond one sigma"})}}return Pe}const tt=Object.freeze(["westernElectric","nelson"]);function it(ye,ke,Se="westernElectric"){return String(Se)==="nelson"?Ke(ye,ke):_e(ye,ke)}function ht(ye,ke,Se){let Ae=0;for(let Fe=0;Fe<ye.length;Fe++)(ye[Fe]<ke||ye[Fe]>Se)&&Ae++;return Ae}function yt(ye,ke,Se,Ae=20){const Fe=ye.length;if(!Fe)return[];const me=ye[0],Me=ye[Fe-1];if(Me===me)return[{from:me,to:Me,count:Fe}];const Pe=Se-ke,Ne=1.5*Pe;let De=Pe>0?Math.max(me,ke-Ne):me,qe=Pe>0?Math.min(Me,Se+Ne):Me;qe>De||(De=me,qe=Me);const ot=Pe>0?2*Pe/Math.cbrt(Fe):(qe-De)/(Math.ceil(Math.log2(Fe))+1),ut=ot>0?Math.min(Ae,Math.max(1,Math.ceil((qe-De)/ot))):1,dt=(qe-De)/ut,st=[];for(let wt=0;wt<ut;wt++)st.push({from:De+wt*dt,to:De+(wt+1)*dt,count:0});for(let wt=0;wt<Fe;wt++){const ct=Math.min(ut-1,Math.max(0,Math.floor((ye[wt]-De)/dt)));st[ct].count++}return st[0].from=me,st[ut-1].to=Me,st}const St=.95;function At(ye){const ke=Number(ye);return Number.isFinite(ke)&&ke>0&&ke<1?ke:St}function Ct(ye,ke=St){const Se=ye.length;if(Se<2)return null;let Ae=0;for(let qe=0;qe<Se;qe++)Ae+=ye[qe];const Fe=Ae/Se;let me=0;for(let qe=0;qe<Se;qe++){const ot=ye[qe]-Fe;me+=ot*ot}const Me=Math.sqrt(me/(Se-1)),Pe=At(ke),De=W(1-(1-Pe)/2,Se-1)*Me/Math.sqrt(Se);return{mean:Fe,lower:Fe-De,upper:Fe+De,margin:De,n:Se,confidence:Pe}}function Tt(ye,ke,Se=St){const Ae=Number(ye),Fe=Number(ke);if(!(Fe>0)||!(Ae>=0)||Ae>Fe)return null;const me=At(Se),Me=G(1-(1-me)/2),Pe=Ae/Fe,Ne=Me*Me,De=1+Ne/Fe,qe=(Pe+Ne/(2*Fe))/De,ot=Me/De*Math.sqrt(Pe*(1-Pe)/Fe+Ne/(4*Fe*Fe));return{proportion:Pe,lower:Math.max(0,qe-ot),upper:Math.min(1,qe+ot),n:Fe,confidence:me}}function Dt(ye,ke=St){if(!ye||!(ye.n>2)||!Number.isFinite(ye.stdError))return null;const Se=At(ke),Fe=W(1-(1-Se)/2,ye.n-2)*ye.stdError;return{slope:ye.slope,lower:ye.slope-Fe,upper:ye.slope+Fe,margin:Fe,confidence:Se}}function Bt(ye,ke,Se=St){const Ae=Number(ye),Fe=Number(ke);if(!Number.isFinite(Ae)||!(Fe>1))return null;const me=At(Se),Pe=G(1-(1-me)/2)*Math.sqrt(1/(9*Fe)+Ae*Ae/(2*(Fe-1)));return{index:Ae,lower:Ae-Pe,upper:Ae+Pe,margin:Pe,n:Fe,confidence:me}}function Xe(ye,ke){return!ye||!(ye.sd>0)||!Number.isFinite(ke)||!Number.isFinite(ye.mean)?null:(ke-ye.mean)/ye.sd}function Ge(ye){return Number.isFinite(ye)?Math.min(1,Math.max(0,2*H(Math.abs(ye)/2)-1)):0}function ue(ye,ke){const Se=new Map,Ae=B(ye);let Fe=0;for(let me=0;me<ke.length;me++){const Me=Ae(ke[me]);if(Me==null||Me===""||typeof Me=="number"&&Number.isNaN(Me))continue;const Pe=Me instanceof Date?Me.getTime():typeof Me=="object"?String(Me):Me;Se.set(Pe,(Se.get(Pe)||0)+1),Fe++}return{map:Se,total:Fe}}function pe(ye,ke,Se,Ae){if(!(ke>0)||!(Ae>0))return null;let Fe=0;const me=new Set(ye.keys());for(const Me of Se.keys())me.add(Me);for(const Me of me){const Pe=(ye.get(Me)||0)/ke,Ne=(Se.get(Me)||0)/Ae;Fe+=Math.abs(Pe-Ne)}return Fe/2}const ve=10;function Ue(ye,ke,Se){if(Se&&Se.numeric){const Pe=u(ye,ke),{n:Ne,mean:De}=k(Pe),qe=Ne>0?Xe({mean:Se.mean,sd:Se.sd},De):null;return{measure:"standardizedMeanDifference",magnitude:qe,distance:qe===null?0:Ge(qe),direction:qe===null?0:Math.sign(qe),subsetN:Ne,populationN:Se.n||0,reliable:Ne>=ve}}const{map:Fe,total:me}=ue(ye,ke),Me=pe(Fe,me,Se.map,Se.total);return{measure:"categoricalTotalVariation",magnitude:Me,distance:Me===null?0:Me,direction:0,subsetN:me,populationN:Se.total||0,reliable:me>=ve}}function Ve(ye,ke){if(ye&&(ye.kind==="float64"||ye.kind==="int32"))return!0;const Se=B(ye);let Ae=0,Fe=0;for(let me=0;me<ke.length&&Ae<200;me++){const Me=Se(ke[me]);if(Me==null||Me==="")continue;if(Me instanceof Date)return!1;Ae++;const Pe=typeof Me=="number"?Me:Number(Me);Number.isFinite(Pe)&&Fe++}return Ae===0?!1:Fe/Ae>=.9}function nt(ye,ke){if(Ve(ye,ke)){const Fe=u(ye,ke),{n:me,mean:Me,m2:Pe}=k(Fe);return{numeric:!0,mean:Me,sd:me>0?Math.sqrt(Pe/me):0,n:me}}const{map:Se,total:Ae}=ue(ye,ke);return{numeric:!1,map:Se,total:Ae}}}),xe("packages/core/src/compute/total.js",function(e,K){"use strict";Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"aggregatesFor",{enumerable:!0,get:function(){return h}}),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 w}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,F=K("packages/core/src/compute/handle.js"),W=F.presenceReader,Q=F.valueComparator,G=F.valueReader,H=K("packages/core/src/compute/statistics.js"),U=H.STAT_FNS,D=H.STAT_LABELS;function v(k){return!!k&&(k.kind==="float64"||k.kind==="int32")}function S(k,m){const b=m.length;let C=0;if(v(k)){const P=k.values,x=W(k);if(!x){for(let E=0;E<b;E++){const A=P[m[E]];Number.isNaN(A)||(C+=A)}return C}for(let E=0;E<b;E++){const A=m[E];if(x(A)===1){const j=P[A];Number.isNaN(j)||(C+=j)}}return C}const M=G(k);for(let P=0;P<b;P++){const x=f(M(m[P]));x!==null&&(C+=x)}return C}S.kernel=!0;function y(k,m){const b=m.length;let C=0;if(v(k)){const P=k.values,x=W(k);if(!x){for(let E=0;E<b;E++)Number.isNaN(P[m[E]])||C++;return C}for(let E=0;E<b;E++){const A=m[E];x(A)===1&&!Number.isNaN(P[A])&&C++}return C}const M=G(k);for(let P=0;P<b;P++){const x=M(m[P]);x!=null&&!(typeof x=="number"&&Number.isNaN(x))&&C++}return C}y.kernel=!0;function l(k,m){return m.length}l.kernel=!0;function c(k,m){const b=y(k,m);return b===0?null:S(k,m)/b}c.kernel=!0;function i(k,m,b,C){const M=m.length;if(v(k)){const A=k.values,j=W(k);let $=null;if(!j){for(let z=0;z<M;z++){const T=A[m[z]];Number.isNaN(T)||($===null||(b<0?T<$:T>$))&&($=T)}return $}for(let z=0;z<M;z++){const T=m[z];if(j(T)===0)continue;const R=A[T];Number.isNaN(R)||($===null||(b<0?R<$:R>$))&&($=R)}return $}const P=G(k),x=Q(C);let E=null;for(let A=0;A<M;A++){const j=P(m[A]);j==null||typeof j=="number"&&Number.isNaN(j)||(E===null||(b<0?x(j,E)<0:x(j,E)>0))&&(E=j)}return E}function n(k,m,b){return i(k,m,-1,b&&b.locale)}n.kernel=!0;function t(k,m,b){return i(k,m,1,b&&b.locale)}t.kernel=!0;function r(k,m){return m.length===0?null:G(k)(m[0])}r.kernel=!0;function s(k,m){return m.length===0?null:G(k)(m[m.length-1])}s.kernel=!0;function f(k){if(typeof k=="number")return Number.isNaN(k)?null:k;if(k==null||k===""||typeof k=="boolean")return null;if(k instanceof Date)return k.getTime();const m=Number(k);return Number.isNaN(m)?null:m}const u={sum:S,min:n,max:t,avg:c,count:l,first:r,last:s,countValues:y,...U},o=Object.freeze({...D,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function g(k){return k?typeof k=="string"?o[k]||k:"Total":""}const d=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function h(k){const m=k&&k.dataType&&k.dataType.totals&&k.dataType.totals.supported;if(Array.isArray(m))return m.slice();const b=d.filter(C=>C in u);for(const C of Object.keys(u))b.includes(C)||b.push(C);return b}function a(k,m){return typeof m!="string"?!0:h(k).includes(m)}function p(k,m){const b=G(k),C=[];for(let M=0;M<m.length;M++){const P=b(m[M]);P!=null&&C.push(P)}return C}function w(k,m,b,C){const M=m||[];if(typeof b=="string"){const P=u[b];return P?P(k,M,C):(B(`total:${b}`,`unknown total function "${b}"; register it in config.totalFns`),null)}return L(b)?b.kernel===!0?b(k,M,C):b(p(k,M),C||{}):null}}),xe("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 F}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Q}});const L=K("packages/core/src/compute/sketch.js").Welford;class B{#e;#t;#n=[];#r;#o;constructor(H,U=0,D=Date.now){if(H!=="count"&&H!=="time"&&H!=="session")throw new RangeError(`unknown window kind: ${H}`);if((H==="count"||H==="time")&&!(U>0))throw new RangeError(`a ${H} window needs a positive span`);this.#e=H,this.#t=Math.floor(U),this.#r=D,this.#o=D()}get size(){return this.#n.length}push(H,U=this.#r()){Number.isFinite(H)&&(this.#n.push({t:U,v:H}),this.#i(U))}#i(H){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const U=H-this.#t;for(;this.#n.length&&this.#n[0].t<U;)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 U=new L;let D=0,v=1/0,S=-1/0;for(const{v:y}of this.#n)D+=y,y<v&&(v=y),y>S&&(S=y),U.add(y);return{over:H,count:this.#n.length,sum:D,mean:U.mean(),min:v,max:S,variance:U.variance(),stddev:U.stddev()}}reduce(H){const U=this.aggregate(),D={sum:U.sum,avg:U.mean,mean:U.mean,min:U.min,max:U.max,count:U.count,variance:U.variance,stddev:U.stddev};if(!(H in D))throw new RangeError(`unknown windowed aggregate: ${H}`);return{value:D[H],over:U.over}}}const F=Object.freeze(["count","time","session"]);function W(G,H=Date.now){const U=G.kind==="time"&&G.minutes!=null?G.minutes*6e4:G.span??0;return new B(G.kind,U,H)}const Q={Window:B,WINDOW_KINDS:F,openWindow:W}}),xe("packages/core/src/compute/rolling.js",function(e,K){"use strict";Object.defineProperty(e,"ROLLING_WINDOW_FIELDS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"rollingWindow",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"cumulativeToDate",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"periodOverPeriod",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"QUANTILE_SPAN_CAP",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"rollingQuantile",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"seasonalDecompose",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"exponentialSmoothing",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const L=K("packages/core/src/compute/windowed.js").openWindow,F=K("packages/core/src/compute/sketch.js").KLL,W=Object.freeze({rollingSum:"sum",rollingAvg:"avg",rollingMin:"min",rollingMax:"max"});function Q(o,g,d,h){if(o.kind==="count"){const a=Math.max(1,Math.floor(o.span||0));return{coverage:Math.min(1,g/a),partial:g<a}}if(o.kind==="time"){const a=o.minutes!=null?o.minutes*6e4:o.span||0;if(!(a>0))return{coverage:1,partial:!1};const p=d-h;return{coverage:Math.min(1,p/a),partial:p<a}}return{coverage:null,partial:!1}}function G(o,g){const d=L(g),h=new Map,a=o.length?o[0].at:0;for(let p=0;p<o.length;p++){const{key:w,at:k,value:m}=o[p];Number.isFinite(m)&&d.push(m,k);const b=d.aggregate(),C=Q(g,b.count,k,a);w!=null&&h.set(String(w),{sum:b.sum,avg:b.mean,min:b.min,max:b.max,count:b.count,coverage:C.coverage,partial:C.partial})}return h}function H(o){const g=new Map;let d=0;for(const{key:h,value:a}of o)Number.isFinite(a)&&(d+=a),h!=null&&g.set(String(h),d);return g}function U(o,g=1){const d=new Map,h=Math.max(1,Math.floor(g));for(let a=0;a<o.length;a++){const{key:p,value:w}=o[a];if(p==null)continue;const k=a>=h?o[a-h].value:null,m=Number.isFinite(w)?w:null,b=Number.isFinite(k)?k:null;d.set(String(p),m!==null&&b!==null?m-b:null)}return d}const D=4096;function v(o){let g=o>>>0;return()=>{g+=1831565813;let d=g;return d=Math.imul(d^d>>>15,d|1),d^=d+Math.imul(d^d>>>7,d|61),((d^d>>>14)>>>0)/4294967296}}function S(o,g){const d=o.length;if(d===1)return o[0];const h=(d-1)*g,a=Math.floor(h),p=Math.ceil(h);return a===p?o[a]:o[a]+(h-a)*(o[p]-o[a])}function y(o,g,d={}){const h=Math.min(1,Math.max(0,d.q==null?.5:d.q)),a=Math.max(1,Math.floor(d.cap==null?D:d.cap)),p=v(d.seed==null?2654435769:d.seed),w=new Map,k=o.length?o[0].at:0;if(g.kind==="session"){const b=new F(200,p);let C=0;for(const{key:M,value:P}of o)Number.isFinite(P)&&(b.add(P),C++),M!=null&&w.set(String(M),{value:C?b.quantile(h):null,approx:C>0,count:C,coverage:null,partial:!1});return w}const m=L(g);for(const{key:b,at:C,value:M}of o){Number.isFinite(M)&&m.push(M,C);const P=m.values(),x=P.length;let E=null,A=!1;if(x)if(x<=a)E=S([...P].sort(($,z)=>$-z),h);else{const $=new F(200,p);for(const z of P)$.add(z);E=$.quantile(h),A=!0}const j=Q(g,x,C,k);b!=null&&w.set(String(b),{value:E,approx:A,count:x,coverage:j.coverage,partial:j.partial})}return w}function l(o,g){const d=o.length,h=new Array(d).fill(null),a=Math.floor(g/2),p=g%2===0;for(let w=0;w<d;w++){if(w-a<0||w+a>=d)continue;let k=0,m=!0;if(p)for(let b=-a;b<=a;b++){const C=o[w+b];if(!Number.isFinite(C)){m=!1;break}k+=b===-a||b===a?C*.5:C}else for(let b=-a;b<=a;b++){const C=o[w+b];if(!Number.isFinite(C)){m=!1;break}k+=C}m&&(h[w]=k/g)}return h}function c(o,g){const d=new Map,h=Math.floor(Number(g&&g.period));if(!(h>=2))return d;const a=g&&g.model==="multiplicative",p=o.length,w=o.map(A=>Number.isFinite(A.value)?A.value:null),k=l(w,h),m=new Array(p).fill(null);for(let A=0;A<p;A++){const j=k[A],$=w[A];j===null||$===null||(a?j!==0&&(m[A]=$/j):m[A]=$-j)}const b=new Array(h).fill(0),C=new Array(h).fill(0);for(let A=0;A<p;A++){if(m[A]===null)continue;const j=A%h;b[j]+=m[A],C[j]+=1}const M=a?1:0,P=b.map((A,j)=>C[j]?A/C[j]:M),x=P.reduce((A,j)=>A+j,0)/h,E=a?P.map(A=>x!==0?A/x:1):P.map(A=>A-x);for(let A=0;A<p;A++){const{key:j}=o[A];if(j==null)continue;const $=k[A],z=E[A%h],T=w[A];let R=null;$!==null&&T!==null&&(R=a?$*z!==0?T/($*z):null:T-$-z),d.set(String(j),{trend:$,seasonal:T===null?null:z,residual:R,coverage:$===null?0:1,partial:$===null})}return d}function i(o,g,d,h=80){const a=(Math.sqrt(5)-1)/2;let p=g,w=d,k=w-a*(w-p),m=p+a*(w-p),b=o(k),C=o(m);for(let M=0;M<h;M++)b<C?(w=m,m=k,C=b,k=w-a*(w-p),b=o(k)):(p=k,k=m,b=C,m=p+a*(w-p),C=o(m));return(p+w)/2}const n=1e-4,t=1-1e-4;function r(o,g){const d=o.length,h=new Array(d).fill(null),a=new Array(d).fill(null);let p=null,w=0;for(let k=0;k<d;k++){const m=o[k];if(!Number.isFinite(m)){p!==null&&(a[k]=p,h[k]=p);continue}if(p===null){p=m,a[k]=m,h[k]=m;continue}a[k]=p,w+=(m-p)**2,p=g*m+(1-g)*p,h[k]=p}return{smoothed:h,fitted:a,sse:w}}function s(o,g,d){const h=o.length,a=new Array(h).fill(null),p=new Array(h).fill(null);let w=null,k=null,m=0;for(let b=0;b<h;b++){const C=o[b];if(!Number.isFinite(C)){w!==null&&(w+=k,a[b]=w);continue}if(w===null){w=C,a[b]=C;continue}if(k===null){k=C-w;const x=w+k;p[b]=x,m+=(C-x)**2;const E=w;w=g*C+(1-g)*(E+k),k=d*(w-E)+(1-d)*k,a[b]=w;continue}const M=w+k;p[b]=M,m+=(C-M)**2;const P=w;w=g*C+(1-g)*(P+k),k=d*(w-P)+(1-d)*k,a[b]=w}return{smoothed:a,fitted:p,sse:m}}function f(o,g={}){const d=new Map,h=g.method==="holt",a=o.map(M=>Number.isFinite(M.value)?M.value:null),p=a.filter(M=>M!==null).length,w=M=>Math.min(t,Math.max(n,M)),k=()=>{for(const{key:M}of o)M!=null&&d.set(String(M),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return d};if(p<(h?2:1))return k();let m=Number.isFinite(g.alpha)?w(g.alpha):null,b=h&&Number.isFinite(g.beta)?w(g.beta):null;if(h){if(m===null||b===null){let M=m===null?.5:m,P=b===null?.5:b;for(let x=0;x<6;x++)m===null&&(M=i(E=>s(a,E,P).sse,n,t)),b===null&&(P=i(E=>s(a,M,E).sse,n,t));m=m===null?M:m,b=b===null?P:b}}else m===null&&(m=i(M=>r(a,M).sse,n,t));const C=h?s(a,m,b):r(a,m);for(let M=0;M<o.length;M++){const{key:P}=o[M];P!=null&&d.set(String(P),{smoothed:C.smoothed[M],fitted:C.fitted[M],alpha:m,beta:h?b:null,sse:C.sse})}return d}const u={ROLLING_WINDOW_FIELDS:W,QUANTILE_SPAN_CAP:D,rollingWindow:G,rollingQuantile:y,cumulativeToDate:H,periodOverPeriod:U,seasonalDecompose:c,exponentialSmoothing:f}}),xe("packages/core/src/compute/compare.js",function(e,K){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"pooledStandardMeanDifference",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"numericSummary",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"bothNumeric",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"compareColumnAcross",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"compareDatasets",{enumerable:!0,get:function(){return l}});const X=K("packages/core/src/compute/statistics.js"),L=X.numbers,B=X.moments,F=X.frequencyMap,W=X.categoricalDistance,Q=X.normalTotalVariation,G=X.isNumericColumn,H=X.SUBSET_RELIABILITY_FLOOR,U=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function D(c,i){if(!c||!i||!(c.n>0)||!(i.n>0)||!Number.isFinite(c.mean)||!Number.isFinite(i.mean))return null;const n=(c.n*c.sd*c.sd+i.n*i.sd*i.sd)/(c.n+i.n);return n>0?(c.mean-i.mean)/Math.sqrt(n):null}function v(c,i){const n=L(c,i),{n:t,mean:r,m2:s}=B(n),f=t>0?Math.sqrt(s/t):0;return{mean:r,sd:f,n:t}}function S(c,i,n,t){return G(c,i)&&G(n,t)}function y(c,i,n,t){if(S(c,i,n,t)){const u=v(c,i),o=v(n,t),g=D(u,o);return{measure:U.numeric,magnitude:g,distance:g===null?0:Q(g),direction:g===null?0:Math.sign(g),nA:u.n,nB:o.n,reliable:u.n>=H&&o.n>=H}}const r=F(c,i),s=F(n,t),f=W(r.map,r.total,s.map,s.total);return{measure:U.categorical,magnitude:f,distance:f===null?0:f,direction:0,nA:r.total,nB:s.total,reliable:r.total>=H&&s.total>=H}}function l(c,i,n={}){const t=new Set(c.columns),r=new Set(i.columns),s=c.columns.filter(d=>r.has(d)),f=Array.isArray(n.columns)&&n.columns.length?s.filter(d=>n.columns.includes(d)):s,u=c.indices(),o=i.indices(),g=[];for(const d of f){const h=c.handle(d),a=i.handle(d);if(!h||!a)continue;const p=y(h,u,a,o);g.push({column:d,name:c.name&&c.name(d)||i.name&&i.name(d)||d,measure:p.measure,magnitude:p.magnitude,distance:p.distance,direction:p.direction,nA:p.nA,nB:p.nB,reliable:p.reliable})}return g.sort((d,h)=>h.distance-d.distance||Math.abs(h.magnitude||0)-Math.abs(d.magnitude||0)),{ranked:g,nA:u.length,nB:o.length,unmatched:{onlyA:c.columns.filter(d=>!r.has(d)),onlyB:i.columns.filter(d=>!t.has(d))},measures:U}}}),xe("packages/core/src/compute/anomaly.js",function(e,K){"use strict";Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"robustSpread",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return c}}),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 f}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return u}});const L=K("packages/core/src/compute/statistics.js").quantileSorted,F=K("packages/core/src/compute/special.js").logGamma,W=.6745,Q=3.5,G=1.5,H=.975,U=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function D(o){if(!o.length)return null;const d=Array.from(o,Number).sort((w,k)=>w-k),h=L(d,.5),a=d.map(w=>Math.abs(w-h)).sort((w,k)=>w-k),p=L(a,.5);return{median:h,mad:p}}function v(o,g={}){const d=Number.isFinite(g.threshold)?g.threshold:Q,h=o.length,a=new Array(h).fill(null),p=new Array(h).fill(!1),w=[];for(let b=0;b<h;b++){const C=Number(o[b]);Number.isFinite(C)&&w.push(C)}if(!w.length)return{median:null,mad:null,threshold:d,scores:a,flags:p,flagged:0};const k=D(w);if(k.mad===0)return{median:k.median,mad:0,threshold:d,scores:a,flags:p,flagged:0};let m=0;for(let b=0;b<h;b++){const C=Number(o[b]);if(!Number.isFinite(C))continue;const M=W*(C-k.median)/k.mad;a[b]=M,Math.abs(M)>d&&(p[b]=!0,m++)}return{median:k.median,mad:k.mad,threshold:d,scores:a,flags:p,flagged:m}}function S(o,g={}){const d=Number.isFinite(g.k)?g.k:G,h=[];for(let m=0;m<o.length;m++){const b=Number(o[m]);Number.isFinite(b)&&h.push(b)}if(!h.length)return null;const a=h.sort((m,b)=>m-b),p=L(a,.25),w=L(a,.75),k=w-p;return{q1:p,q3:w,iqr:k,lower:p-d*k,upper:w+d*k,k:d}}function y(o,g){if(g<=0)return 0;const d=F(o);if(g<o+1){let b=o,C=1/o,M=C;for(let P=0;P<1e3&&(b+=1,M*=g/b,C+=M,!(Math.abs(M)<Math.abs(C)*1e-15));P++);return C*Math.exp(-g+o*Math.log(g)-d)}const h=1e-300;let a=g+1-o,p=1/h,w=1/a,k=w;for(let b=1;b<1e3;b++){const C=-b*(b-o);a+=2,w=C*w+a,Math.abs(w)<h&&(w=h),p=a+C/p,Math.abs(p)<h&&(p=h),w=1/w;const M=w*p;if(k*=M,Math.abs(M-1)<1e-15)break}return 1-Math.exp(-g+o*Math.log(g)-d)*k}function l(o,g){return o<=0?0:y(g/2,o/2)}function c(o,g=H){if(!(g>0)||!(g<1))return NaN;let d=0,h=Math.max(1,o);for(;l(h,o)<g;)h*=2;for(let a=0;a<200;a++){const p=(d+h)/2;if(l(p,o)<g?d=p:h=p,h-d<1e-10)break}return(d+h)/2}function i(o){const g=o.length,d=o.map((h,a)=>{const p=h.slice();for(let w=0;w<g;w++)p.push(a===w?1:0);return p});for(let h=0;h<g;h++){let a=h;for(let w=h+1;w<g;w++)Math.abs(d[w][h])>Math.abs(d[a][h])&&(a=w);if(Math.abs(d[a][h])<1e-12)return null;if(a!==h){const w=d[a];d[a]=d[h],d[h]=w}const p=d[h][h];for(let w=0;w<2*g;w++)d[h][w]/=p;for(let w=0;w<g;w++){if(w===h)continue;const k=d[w][h];if(k!==0)for(let m=0;m<2*g;m++)d[w][m]-=k*d[h][m]}}return d.map(h=>h.slice(g))}function n(o,g){const d=o.length,h=new Array(g).fill(0);for(const w of o)for(let k=0;k<g;k++)h[k]+=w[k];for(let w=0;w<g;w++)h[w]/=d;const a=Array.from({length:g},()=>new Array(g).fill(0));for(const w of o)for(let k=0;k<g;k++){const m=w[k]-h[k];for(let b=k;b<g;b++)a[k][b]+=m*(w[b]-h[b])}const p=d>1?d-1:1;for(let w=0;w<g;w++)for(let k=w;k<g;k++)a[w][k]/=p,a[k][w]=a[w][k];return{mean:h,cov:a}}function t(o,g={}){const d=Number.isFinite(g.p)?g.p:H,h=Number.isFinite(g.ridge)?g.ridge:1e-6,a=o.length;if(!a)return null;const p=o[0].length;if(!p)return null;const w=new Array(a).fill(null),k=new Array(a).fill(null),m=new Array(a).fill(!1),b=[],C=[];for(let z=0;z<a;z++){const T=o[z];let R=T.length===p;const O=new Array(p);for(let I=0;R&&I<p;I++){const q=Number(T[I]);Number.isFinite(q)?O[I]=q:R=!1}R&&(b.push(z),C.push(O))}const M=p,P=c(M,d);if(C.length<=p)return{center:[],df:M,cutoff:P,singular:!0,used:C.length,distances:w,squared:k,flags:m,flagged:0};const{mean:x,cov:E}=n(C,p);let A=i(E),j=!1;if(!A){j=!0;let z=0;for(let O=0;O<p;O++)z+=E[O][O];const T=z/p*h||h,R=E.map((O,I)=>O.map((q,Z)=>I===Z?q+T:q));if(A=i(R),!A)return{center:x,df:M,cutoff:P,singular:!0,used:C.length,distances:w,squared:k,flags:m,flagged:0}}let $=0;for(let z=0;z<C.length;z++){const T=C[z],R=new Array(p);for(let q=0;q<p;q++)R[q]=T[q]-x[q];let O=0;for(let q=0;q<p;q++){let Z=0;for(let _=0;_<p;_++)Z+=A[q][_]*R[_];O+=R[q]*Z}O<0&&(O=0);const I=b[z];k[I]=O,w[I]=Math.sqrt(O),O>P&&(m[I]=!0,$++)}return{center:x,df:M,cutoff:P,singular:j,used:C.length,distances:w,squared:k,flags:m,flagged:$}}const r=20,s=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function f(o,g={}){const d=g.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",h=Number.isFinite(g.windowLen)&&g.windowLen>=1?Math.floor(g.windowLen):r,a=Number.isFinite(g.threshold)?g.threshold:Q,p=Number.isFinite(g.k)?g.k:G,w=Number.isFinite(g.minPeriods)&&g.minPeriods>=1?Math.floor(g.minPeriods):h,k=o.length,m=new Array(k).fill(null),b=new Array(k).fill(!1);let C=0;for(let M=0;M<k;M++){const P=Number(o[M]);if(!Number.isFinite(P))continue;const x=Math.max(0,M-h+1),E=[];for(let A=x;A<=M;A++){const j=Number(o[A]);Number.isFinite(j)&&E.push(j)}if(!(E.length<w))if(d==="rollingIqr"){const A=S(E,{k:p});if(!A)continue;(P<A.lower||P>A.upper)&&(b[M]=!0,C++)}else{const A=D(E);if(!A||A.mad===0)continue;const j=W*(P-A.median)/A.mad;m[M]=j,Math.abs(j)>a&&(b[M]=!0,C++)}}return{method:d,windowLen:h,minPeriods:w,threshold:a,k:p,scores:m,flags:b,flagged:C}}function u(o={}){const g=o||{},d=g.field;if(typeof d!="string"||!d)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const h=g.method||"modifiedZScore";if(!(U.includes(h)||s.includes(h))||h==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${h}'`);const p=typeof g.orderBy=="string"?g.orderBy:null,w=g.latest===!0,k=s.includes(h),m=b=>Number(b==null?NaN:b[d]);return b=>{const C=Array.isArray(b)?b.slice():[...b];p&&C.sort((A,j)=>{const $=A?.[p],z=j?.[p];return $===z?0:$==null?-1:z==null?1:$<z?-1:1});const M=C.map(m);let P,x;if(k)({flags:P,scores:x}=f(M,{method:h,windowLen:g.windowLen,threshold:g.threshold,k:g.k,minPeriods:g.minPeriods}));else if(h==="iqr"){const A=S(M,{k:g.k});P=M.map(j=>A?Number.isFinite(j)&&(j<A.lower||j>A.upper):!1),x=M.map(()=>null)}else({flags:P,scores:x}=v(M,{threshold:g.threshold}));if(w){const A=P.length-1;return A<0||!P[A]?!1:{method:h,field:d,flagged:[{row:C[A],score:x[A]}]}}const E=[];for(let A=0;A<P.length;A++)P[A]&&E.push({row:C[A],score:x[A]});return E.length?{method:h,field:d,flagged:E}:!1}}}),xe("packages/core/src/compute/forecast.js",function(e,K){"use strict";Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const X=K("packages/core/src/compute/special.js"),L=X.normalQuantile,B=X.studentTQuantile,W=K("packages/core/src/internal/util.js").warnOnce,Q=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),G=1e-4,H=1-1e-4;function U(g){const d=[];for(let h=0;h<g.length;h++){const a=g[h];if(a!==null&&typeof a=="object"){const p=Number.isFinite(a.at)?a.at:h,w=Number.isFinite(a.value)?a.value:null;d.push({at:p,value:w})}else d.push({at:h,value:Number.isFinite(a)?Number(a):null})}return d}function D(g){const d=g.filter(k=>k.value!==null),h=d[0],a=d[d.length-1],p=a.at-h.at,w=d.length>1&&p>0?p/(d.length-1):1;return{lastAt:a.at,step:w}}function v(g){return Math.min(H,Math.max(G,g))}function S(g,d=G,h=H,a=80){const p=(Math.sqrt(5)-1)/2;let w=d,k=h,m=k-p*(k-w),b=w+p*(k-w),C=g(m),M=g(b);for(let P=0;P<a;P++)C<M?(k=b,b=m,M=C,m=k-p*(k-w),C=g(m)):(w=m,m=b,C=M,b=w+p*(k-w),M=g(b));return(w+k)/2}function y(g,d){let h=null,a=0,p=0;for(let w=0;w<g.length;w++){const k=g[w];if(k!==null){if(h===null){h=k;continue}a+=(k-h)**2,p+=1,h=d*k+(1-d)*h}}return{level:h,sse:a,m:p}}function l(g,d,h){let a=null,p=null,w=0,k=0;for(let m=0;m<g.length;m++){const b=g[m];if(b===null){a!==null&&p!==null&&(a+=p);continue}if(a===null){a=b;continue}p===null&&(p=b-a);const C=a+p;w+=(b-C)**2,k+=1;const M=a;a=d*b+(1-d)*(M+p),p=h*(a-M)+(1-h)*p}return{level:a,trend:p,sse:w,m:k}}function c(g,d,h,a,p){const w=g.length;if(w<2*d)return null;const k=j=>{let $=0,z=0;for(let T=j;T<j+d&&T<w;T++)g[T]!==null&&($+=g[T],z+=1);return z?$/z:null},m=k(0),b=k(d);if(m===null||b===null)return null;let C=m,M=(b-m)/d;const P=new Array(d).fill(0);for(let j=0;j<d;j++)P[j]=g[j]===null?0:g[j]-C;const x=P.reduce((j,$)=>j+$,0)/d;for(let j=0;j<d;j++)P[j]-=x;let E=0,A=0;for(let j=d;j<w;j++){const $=j%d,z=P[$],T=g[j];if(T===null){C+=M;continue}const R=C+M+z;E+=(T-R)**2,A+=1;const O=C;C=h*(T-z)+(1-h)*(C+M),M=a*(C-O)+(1-a)*M,P[$]=p*(T-C)+(1-p)*z}return{level:C,trend:M,season:P,phase:(w-1)%d,sse:E,count:A}}function i(g,d,h){let a=1;for(const w of d)a+=w*w;const p=Math.sqrt(g*a);return{se:p,margin:h*p}}function n(g,d={}){if(!g||typeof g.length!="number"||g.length===0)return null;const h=Q.includes(d.method)?d.method:"linear",a=Math.max(1,Math.floor(Number(d.horizon)||1)),p=Number.isFinite(d.confidence)&&d.confidence>0&&d.confidence<1?d.confidence:.95,w=1-(1-p)/2,k=U(g),m=k.map(E=>E.value),b=m.filter(E=>E!==null),C=b.length,{lastAt:M,step:P}=C?D(k):{lastAt:0,step:1},x=E=>M+E*P;return h==="linear"?t(k,C,a,p,w,x):h==="movingAverage"?r(b,C,a,p,w,d,x):h==="ses"?s(m,C,a,p,w,d,x):h==="holt"?f(m,C,a,p,w,d,x):u(m,C,a,p,w,d,x)}function t(g,d,h,a,p,w){if(d<2)return null;let k=0,m=0;for(const T of g)T.value!==null&&(k+=T.at,m+=T.value);k/=d,m/=d;let b=0,C=0,M=0;for(const T of g){if(T.value===null)continue;const R=T.at-k,O=T.value-m;b+=R*R,C+=R*O,M+=O*O}if(b===0)return null;const P=C/b,x=m-P*k,E=M===0?1:Math.max(0,Math.min(1,C*C/(b*M))),A=Math.max(0,M-P*C),j=d>2?Math.sqrt(A/(d-2)):null,$=d>2?B(p,d-2):null,z=[];for(let T=1;T<=h;T++){const R=w(T),O=x+P*R;let I=null,q=null,Z=null,_=null,J=null;if(j!==null){const ee=1/d+(R-k)**2/b,te=j*Math.sqrt(1+ee),ne=j*Math.sqrt(ee);J=te,I=O-$*te,q=O+$*te,Z=O-$*ne,_=O+$*ne}z.push({step:T,at:R,mean:O,lower:I,upper:q,lowerMean:Z,upperMean:_,se:J})}return{method:"linear",horizon:h,confidence:a,n:d,sigma:j,r2:E,params:{slope:P,intercept:x},points:z}}function r(g,d,h,a,p,w,k){if(d<1)return null;const m=Math.max(1,Math.min(d,Math.floor(Number(w.windowLen)||d))),b=g.slice(d-m);let C=0;for(const j of b)C+=j;const M=C/m;let P=null,x=null;if(m>1){let j=0;for(const z of b)j+=(z-M)**2;P=Math.sqrt(j/(m-1))*Math.sqrt(1+1/m),x=B(p,m-1)}const E=P===null?null:x*P,A=[];for(let j=1;j<=h;j++)A.push({step:j,at:k(j),mean:M,lower:E===null?null:M-E,upper:E===null?null:M+E,se:P});return{method:"movingAverage",horizon:h,confidence:a,n:d,sigma:P===null?null:P,params:{windowLen:m},points:A}}function s(g,d,h,a,p,w,k){if(d<1)return null;let m=Number.isFinite(w.alpha)?v(w.alpha):null;m===null&&(m=S(x=>y(g,x).sse));const b=y(g,m),C=L(p),M=b.m>0?b.sse/b.m:null,P=[];for(let x=1;x<=h;x++){const E=b.level;let A=null,j=null,$=null;if(M!==null){const z=[];for(let R=1;R<x;R++)z.push(m);const T=i(M,z,C);$=T.se,A=E-T.margin,j=E+T.margin}P.push({step:x,at:k(x),mean:E,lower:A,upper:j,se:$})}return{method:"ses",horizon:h,confidence:a,n:d,sigma:M===null?null:Math.sqrt(M),params:{alpha:m},points:P}}function f(g,d,h,a,p,w,k){if(d<2)return null;let m=Number.isFinite(w.alpha)?v(w.alpha):null,b=Number.isFinite(w.beta)?v(w.beta):null;if(m===null||b===null){let A=m===null?.5:m,j=b===null?.5:b;for(let $=0;$<6;$++)m===null&&(A=S(z=>l(g,z,j).sse)),b===null&&(j=S(z=>l(g,A,z).sse));m=m===null?A:m,b=b===null?j:b}const C=l(g,m,b),M=L(p),P=C.m>0?C.sse/C.m:null,x=m*b,E=[];for(let A=1;A<=h;A++){const j=C.level+A*C.trend;let $=null,z=null,T=null;if(P!==null){const R=[];for(let I=1;I<A;I++)R.push(m+I*x);const O=i(P,R,M);T=O.se,$=j-O.margin,z=j+O.margin}E.push({step:A,at:k(A),mean:j,lower:$,upper:z,se:T})}return{method:"holt",horizon:h,confidence:a,n:d,sigma:P===null?null:Math.sqrt(P),params:{alpha:m,beta:b},points:E}}function u(g,d,h,a,p,w,k){const m=Math.floor(Number(w.period));if(!(m>=2))return W("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(d<2*m)return null;let b=Number.isFinite(w.alpha)?v(w.alpha):null,C=Number.isFinite(w.beta)?v(w.beta):null,M=Number.isFinite(w.gamma)?v(w.gamma):null;const P=(T,R,O)=>{const I=c(g,m,T,R,O);return I?I.sse:1/0};if(b===null||C===null||M===null){let T=b===null?.5:b,R=C===null?.5:C,O=M===null?.5:M;for(let I=0;I<8;I++)b===null&&(T=S(q=>P(q,R,O))),C===null&&(R=S(q=>P(T,q,O))),M===null&&(O=S(q=>P(T,R,q)));b=b===null?T:b,C=C===null?R:C,M=M===null?O:M}const x=c(g,m,b,C,M);if(!x)return null;const E=L(p),A=x.count>0?x.sse/x.count:null,j=b*C,$=M*(1-b),z=[];for(let T=1;T<=h;T++){const R=x.season[(x.phase+T)%m],O=x.level+T*x.trend+R;let I=null,q=null,Z=null;if(A!==null){const _=[];for(let ee=1;ee<T;ee++)_.push(b+ee*j+(ee%m===0?$:0));const J=i(A,_,E);Z=J.se,I=O-J.margin,q=O+J.margin}z.push({step:T,at:k(T),mean:O,lower:I,upper:q,se:Z})}return{method:"holtWinters",horizon:h,confidence:a,n:d,sigma:A===null?null:Math.sqrt(A),params:{alpha:b,beta:C,gamma:M,period:m},points:z}}const o={FORECAST_METHODS:Q,forecast:n}}),xe("packages/core/src/compute/hypothesis.js",function(e,K){"use strict";Object.defineProperty(e,"GROUP_TESTS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"NORMALITY_ALPHA",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"HL_PAIR_LIMIT",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"welchTTest",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"mannWhitneyUTest",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"chiSquareTest",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"compareGroups",{enumerable:!0,get:function(){return E}});const L=K("packages/core/src/internal/util.js").warnOnce,F=K("packages/core/src/compute/handle.js").valueReader,W=K("packages/core/src/compute/statistics.js"),Q=W.numbers,G=W.moments,H=W.frequencyMap,U=W.categoricalDistance,D=W.isNumericColumn,v=W.jarqueBera,S=W.proportionInterval,y=W.SUBSET_RELIABILITY_FLOOR,c=K("packages/core/src/compute/compare.js").pooledStandardMeanDifference,i=K("packages/core/src/compute/special.js"),n=i.studentT,t=i.studentTQuantile,r=i.normalCdf,s=i.normalQuantile,f=i.chiSquareUpperTail,u=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),o=.05,g=2e6;function d(A){const j=Number(A);return Number.isFinite(j)&&j>0&&j<1?j:.95}function h(A){const{n:j,mean:$,m2:z}=G(A);return{mean:$,sd:j>0?Math.sqrt(z/j):0,n:j}}function a(A,j){const $=A.length;if($<2)return 0;let z=0;for(let T=0;T<$;T++){const R=A[T]-j;z+=R*R}return z/($-1)}function p(A,j){return{name:"pooledStandardMeanDifference",value:c(h(A),h(j))}}function w(A,j,$){const z=A.length,T=j.length;if(z<2||T<2)return null;const R=d($),{mean:O}=G(A),{mean:I}=G(j),q=a(A,O),Z=a(j,I),_=q/z+Z/T;if(!(_>0))return null;const J=Math.sqrt(_),ee=(O-I)/J,te=q/z*(q/z)/(z-1),ne=Z/T*(Z/T)/(T-1),ie=_*_/(te+ne),ae=Math.min(1,Math.max(0,2*(1-n(Math.abs(ee),ie)))),re=O-I,se=t(1-(1-R)/2,ie)*J;return{test:u.WELCH,statistic:ee,statisticName:"t",df:ie,pValue:ae,interval:{estimate:re,lower:re-se,upper:re+se,confidence:R,method:"welch-t (difference of means)"},effectSize:p(A,j),nA:z,nB:T,reliable:z>=y&&T>=y,method:"Welch's t-test (unequal variances; Welch–Satterthwaite df)"}}function k(A){const j=A.length;if(j===0)return Number.NaN;const $=j>>1;return j%2?A[$]:(A[$-1]+A[$])/2}function m(A,j,$){const z=A.length,T=j.length,R=z*T;if(R===0||R>g)return null;const O=new Float64Array(R);let I=0;for(let te=0;te<z;te++)for(let ne=0;ne<T;ne++)O[I++]=A[te]-j[ne];O.sort();const q=k(O),Z=Math.sqrt(z*T*(z+T+1)/12),_=s(1-(1-$)/2);let J=Math.round(R/2-_*Z);J>=0||(J=0);const ee=Math.floor((R-1)/2);return J>ee&&(J=ee),{estimate:q,lower:O[J],upper:O[R-1-J],confidence:$,method:"hodges-lehmann (normal approximation)"}}function b(A,j,$){const z=A.length,T=j.length;if(z<1||T<1)return null;const R=d($),O=z+T,I=new Array(O);for(let ae=0;ae<z;ae++)I[ae]={v:A[ae],g:0};for(let ae=0;ae<T;ae++)I[z+ae]={v:j[ae],g:1};I.sort((ae,re)=>ae.v-re.v);let q=0,Z=0,_=0;for(;_<O;){let ae=_;for(;ae<O&&I[ae].v===I[_].v;)ae++;const re=ae-_,se=(_+1+ae)/2;for(let le=_;le<ae;le++)I[le].g===0&&(q+=se);Z+=re*re*re-re,_=ae}const J=q-z*(z+1)/2,ee=z*T/2,te=z*T/12*(O+1-Z/(O*(O-1)));let ne=1;if(te>0){const ae=Math.max(0,Math.abs(J-ee)-.5);ne=Math.min(1,2*r(-ae/Math.sqrt(te)))}const ie=m(A,j,R);return{test:u.MANN_WHITNEY,statistic:J,statisticName:"U",df:null,pValue:ne,interval:ie,effectSize:p(A,j),nA:z,nB:T,reliable:z>=y&&T>=y,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function C(A,j,$,z,T){const R=S(A,j,T),O=S($,z,T);if(!R||!O)return null;const I=R.proportion-O.proportion,q=I-Math.sqrt((R.proportion-R.lower)**2+(O.upper-O.proportion)**2),Z=I+Math.sqrt((R.upper-R.proportion)**2+(O.proportion-O.lower)**2);return{lower:q,upper:Z}}function M(A,j,$,z,T,R={}){if(!(j>0)||!(z>0))return null;const O=new Set([...A.keys(),...$.keys()]),I=O.size;if(I<2)return null;const q=j+z;let Z=0;for(const ne of O){const ie=A.get(ne)||0,ae=$.get(ne)||0,re=ie+ae,se=j*re/q,le=z*re/q;se>0&&(Z+=(ie-se)*(ie-se)/se),le>0&&(Z+=(ae-le)*(ae-le)/le)}const _=I-1,J=f(Z,_);let ee=null;R.category!==void 0&&O.has(R.category)?ee=R.category:I===2&&([ee]=[...O]);let te=null;if(ee!==null){const ne=C(A.get(ee)||0,j,$.get(ee)||0,z,d(T));ne&&(te={estimate:(A.get(ee)||0)/j-($.get(ee)||0)/z,lower:ne.lower,upper:ne.upper,confidence:d(T),method:"newcombe (difference in this category's share)",category:ee})}return{test:u.CHI_SQUARE,statistic:Z,statisticName:"chiSquare",df:_,pValue:J,interval:te,effectSize:{name:"categoricalTotalVariation",value:U(A,j,$,z)},nA:j,nB:z,reliable:j>=y&&z>=y,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function P(A){return A==null||A===""||typeof A=="number"&&Number.isNaN(A)?null:A instanceof Date?A.getTime():typeof A=="object"?String(A):A}function x(A,j,$){if($===u.WELCH||$===u.MANN_WHITNEY)return{test:$,chosenBy:"override",reason:`caller override: ${$}`};const z=v(A),T=v(j),R=z===null?null:Math.exp(-z/2),O=T===null?null:Math.exp(-T/2);return R!==null&&R<o||O!==null&&O<o?{test:u.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${o})`}:{test:u.WELCH,chosenBy:"auto",reason:R!==null||O!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function E(A,j,$,z={}){if(!A||!j)return null;const T=d(z.confidence),R=F(j);let O;if(Array.isArray(z.groups)&&z.groups.length===2)O=[P(z.groups[0]),P(z.groups[1])];else{const{map:ae}=H(j,$),re=[...ae.entries()].sort((se,le)=>le[1]-se[1]).slice(0,2).map(se=>se[0]);if(re.length<2)return L("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;O=re}const[I,q]=O;if(I===null||q===null||I===q)return L("compareGroups:distinct","[lattice] compareGroups: the two groups must be two distinct, present values."),null;const Z=[],_=[];for(let ae=0;ae<$.length;ae++){const re=P(R($[ae]));re===I?Z.push($[ae]):re===q&&_.push($[ae])}if(Z.length===0||_.length===0)return L("compareGroups:empty","[lattice] compareGroups: one of the two groups has no rows in the current set."),null;const J=z.test&&z.test!=="auto"?String(z.test):null,ee=D(A,Z.concat(_));let te,ne,ie;if(J===u.CHI_SQUARE||!J&&!ee){ne=J?"override":"auto",ie=J?"caller override: chiSquare":"column family: categorical";const ae=H(A,Z),re=H(A,_);te=M(ae.map,ae.total,re.map,re.total,T,{category:z.category})}else{if((J===u.WELCH||J===u.MANN_WHITNEY)&&!ee)return L("compareGroups:numeric-override",`[lattice] compareGroups: ${J} needs a numeric column, but the column is not numeric.`),null;const ae=Q(A,Z),re=Q(A,_),se=x(ae,re,J);ne=se.chosenBy,ie=se.reason,te=se.test===u.MANN_WHITNEY?b(ae,re,T):w(ae,re,T)}return te?{...te,chosenBy:ne,reason:ie,groups:[I,q]}:(L("compareGroups:degenerate","[lattice] compareGroups: the chosen test had too little to work with (too few values, or no variation)."),null)}}),xe("packages/core/src/columns/detailcolumn.js",function(e,K){"use strict";Object.defineProperty(e,"DETAIL_COLUMN_ID",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createDetailColumn",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return F}});const X="__lattice_detail",L=36;function B(W){const Q=W.config&&W.config.detailColumnWidth||L;return{id:X,field:null,title:"",type:"text",dataType:{base:"text"},nullable:!0,align:"center",generated:!0,control:!0,detailExpander:!0,value:{pure:!0},cell:{render:"detailExpander",align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:Q,min:Q,max:Q,pin:W.config&&W.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(G,H){return!!(H&&H.expanded)},formatValue(){return""}}}const F=B}),xe("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 W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Q}});const L=K("packages/core/src/internal/util.js").isFunction,B="__lattice_tree",F=260;function W(G){const H=G.tree||{},U=G.config&&G.config.treeColumnWidth||F,D=()=>(G.columns&&L(G.columns.visible)?G.columns.visible():[]).find(l=>!l.generated)||null,v=(y,l)=>{if(l&&l.group)return l.groupValue;if(L(H.label))return H.label(y,l);if(typeof H.label=="string")return y==null?null:y[H.label];const c=D();return c&&L(c.getValue)?c.getValue(y,l):null},S=()=>{if(H.title)return H.title;const y=typeof H.label=="string"?G.columns&&L(G.columns.get)?G.columns.get(H.label):null:D();return y&&(y.title||y.id)||"Hierarchy"};return{id:B,get title(){return S()},field:null,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group"},edit:{enabled:!1},sort:{enabled:!0,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:U,min:140,pin:G.config&&G.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(y,l){return v(y,l)},formatValue(y,l){if(l&&l.grandTotal)return G.config&&G.config.grandTotalLabel||"Total";if(y==null)return"";if(!H.label){const c=D();if(c&&L(c.formatValue))return c.formatValue(y,l)}return String(y)}}}const Q=W}),xe("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 W}});const L=K("packages/core/src/internal/util.js").warnOnce,B="__lattice_pivot",F=500;function W(U){const{pivot:D,valueColumns:v,config:S}=U,y=D&&D.paths||[],l=U.separator||S&&S.pivot&&S.pivot.separator||" | ",c=S&&S.pivot&&S.pivot.maxColumns||F;if(!y.length||!v.length)return{tree:[],leaves:[],error:null};const i=Q(S),n=y.length*v.length+(i?v.length:0);if(n>c){const s=`pivot would generate ${n} columns, above the limit of ${c}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return L(`pivot.maxColumns:${n}`,s),{tree:[],leaves:[],error:s}}const t=[],r=[];for(const s of y){const f=[];for(const u of v){const o=H(s,u,l);f.push(o),r.push(o)}f.length===1?(f[0].title=String(s),t.push(f[0])):t.push({id:`${B}:group:${s}`,title:String(s),columns:f,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(i){const s=v.map(u=>G(u,S));r.push(...s);const f=S&&S.pivot&&S.pivot.totalsLabel||"Total";if(s.length===1)s[0].title=f,i==="before"?t.unshift(s[0]):t.push(s[0]);else{const u={id:`${B}:group:__totals`,title:f,columns:s,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};i==="before"?t.unshift(u):t.push(u)}}return{tree:t,leaves:r,error:null}}function Q(U){const D=U&&U.pivot&&U.pivot.groupTotals;return D==="before"||D==="after"?D:null}function G(U,D){return{id:`${B}:__total${D&&D.pivot&&D.pivot.separator||" | "}${U.id}`,field:null,title:U.title||U.id,type:U.type,dataType:U.dataType,nullable:!0,align:U.align,generated:!0,pivot:{enabled:!1,index:0,sourceId:U.id,total:!0},value:{pure:!0},cell:{align:U.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:U.total,lookup:null,layout:{width:U.layout&&U.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(v,S){const y=S&&S.totals;return y&&Object.hasOwn(y,U.id)?y[U.id]:null},formatValue(v,S){return v==null?"":U.formatValue?U.formatValue(v,S):String(v)}}}function H(U,D,v){return{id:`${B}:${U}${v}${D.id}`,field:null,title:D.title||D.id,type:D.type,dataType:D.dataType,nullable:!0,align:D.align,generated:!0,pivot:{enabled:!1,index:0,path:U,sourceId:D.id},value:{pure:!0},cell:{align:D.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:D.total,lookup:null,layout:{width:D.layout&&D.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(){return null},formatValue(S,y){return S==null?"":D.formatValue?D.formatValue(S,y):String(S)}}}}),xe("packages/core/src/compute/group.js",function(e,K){"use strict";Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return S}});const X=K("packages/core/src/compute/handle.js"),L=X.dictSize,B=X.identity,F=X.presenceReader,W=X.rowCount,Q=X.valueReader,G="",H="\0",U=1<<20;function D(y,l,c,i){const n=y.length,t=y.map(g=>Q(g)),r=Array.isArray(i)&&i.some(Boolean),s=r?t.map((g,d)=>i[d]?h=>i[d](g(h)):g):t;if(!r&&n>0&&y.every(g=>g&&g.kind==="dictionary"&&g.dict)){const g=y.map(h=>L(h.dict)+1);let d=1;for(let h=0;h<n;h++)d*=g[h];if(d<=Number.MAX_SAFE_INTEGER){const h=y.map(k=>k.values),a=y.map(k=>F(k)),p=k=>{let m=0;for(let b=0;b<n;b++){const C=a[b],M=C&&C(k)===0?g[b]-1:h[b][k];m=m*g[b]+M}return m},w=new Float64Array(c);for(let k=0;k<c;k++)w[k]=p(l[k]);return{packed:w,strings:null,product:d,readers:s,keyOf:p}}}const u=g=>{let d="";for(let h=0;h<n;h++){const a=s[h](g);d+=(h===0?"":G)+(a==null?H:String(a))}return d},o=new Array(c);for(let g=0;g<c;g++)o[g]=u(l[g]);return{packed:null,strings:o,product:1/0,readers:s,keyOf:u}}function v(y,l,c,i){const n=new Uint32Array(i+1);for(let f=0;f<c;f++)n[l[f]+1]++;for(let f=0;f<i;f++)n[f+1]+=n[f];const t=new Uint32Array(c),r=n.slice(0,i);for(let f=0;f<c;f++)t[r[l[f]]++]=y[f];const s=new Array(i);for(let f=0;f<i;f++)s[f]=t.subarray(n[f],n[f+1]);return s}function S(y,l,c={}){const i=y||[],n=l||B(W(i[0],c)),t=n.length;if(i.length===0||t===0)return{keys:[],buckets:[]};const{packed:r,strings:s,product:f,readers:u}=D(i,n,t,c.project),o=new Uint32Array(t);let g=0,d=null;if(r&&f<=Math.max(1024,Math.min(U,t*4))){const w=f,k=new Int32Array(w).fill(-1);for(let m=0;m<t;m++)k[r[m]]=0;for(let m=0;m<w;m++)k[m]===0&&(k[m]=g++);for(let m=0;m<t;m++)o[m]=k[r[m]];d=new Float64Array(g);for(let m=0;m<w;m++)k[m]>=0&&(d[k[m]]=m)}else if(r){const w=new Map;for(let k=0;k<t;k++){const m=r[k];let b=w.get(m);b===void 0&&(b=g++,w.set(m,b)),o[k]=b}d=new Float64Array(g);for(const[k,m]of w)d[m]=k}else{const w=new Map;for(let k=0;k<t;k++){const m=s[k];let b=w.get(m);b===void 0&&(b=g++,w.set(m,b)),o[k]=b}}const h=v(n,o,t,g),a=new Array(g);for(let w=0;w<g;w++){const k=h[w][0],m=new Array(u.length);for(let b=0;b<u.length;b++)m[b]=u[b](k);a[w]=m}const p={keys:a,buckets:h};return d&&(p.packed=d),p}}),xe("packages/core/src/compute/pivot.js",function(e,K){"use strict";Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return t}});const L=K("packages/core/src/internal/util.js").warnOnce,F=K("packages/core/src/compute/handle.js").valueComparator,Q=K("packages/core/src/compute/group.js").packKeys,H=K("packages/core/src/compute/total.js").total,U="|",D="/",v=2e3;function S(f,u,o){return`${f}${U}${u}${U}${o}`}function y(f,u){let o="";for(let g=0;g<f.length;g++){const d=f[g];o+=(g===0?"":u)+(d==null?"":String(d))}return o}function l(f,u,o={}){const g=o.separator||D,d=u.length,{keyOf:h,readers:a}=Q(f,u,0),p=new Map,w=[],k=[];for(let E=0;E<d;E++){const A=u[E],j=h(A);if(p.has(j))continue;p.set(j,w.length),k.push(j);const $=new Array(a.length);for(let z=0;z<a.length;z++)$[z]=a[z](A);w.push($)}const m=F(o.locale),b=w.map((E,A)=>A);b.sort((E,A)=>{const j=w[E],$=w[A];for(let z=0;z<j.length;z++){const T=c(j[z],$[z],m);if(T!==0)return T}return E-A});const C=new Array(b.length),M=new Array(b.length),P=new Map;for(let E=0;E<b.length;E++){const A=b[E];C[E]=w[A],M[E]=y(w[A],g),P.set(k[A],E)}return{keys:C,paths:M,idOf:E=>{const A=P.get(h(E));return A===void 0?-1:A}}}function c(f,u,o){const g=f==null,d=u==null;return g||d?g&&d?0:g?1:-1:o(f,u)}function i(f){const u=f.values||f.totals||[];if(u.length&&typeof u[0]=="object"&&u[0]!==null)return u.filter(h=>h&&h.handle);const o=typeof f.handle=="function"?f.handle:null;if(!o)return u.length&&L("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 g=typeof f.totalOf=="function"?f.totalOf:null,d=[];for(const h of u){const a=o(h);a&&d.push({colId:h,handle:a,fn:g?g(h):"sum"})}return d}function n(f,u,o){if(Array.isArray(f)){const g=o||{};return{...g,pivotHandles:f,order:u||null,groups:g.groups||null}}return f||{}}function t(f,u,o){const g=n(f,u,o),d=g.separator||D,h=i(g),a=g.maxColumns===void 0?v:g.maxColumns,p=g.groups&&g.groups.buckets?g.groups:null,w=p?p.buckets:[g.order||new Uint32Array(0)],k=g.groupPaths||(p?p.keys.map(j=>y(j,d)):[""]),m=s(w),{keys:b,paths:C,idOf:M}=l(g.pivotHandles||[],m,g),P=C.length*Math.max(1,h.length),x=r(C,h,d);if(a&&P>a){const j=new Map;return{keys:b,paths:C,fields:x,groupPaths:k,columns:P,values:j,cells:j,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 E=new Map,A=C.length;for(let j=0;j<w.length;j++){const $=w[j],z=k[j]===void 0?"":k[j],T=$.length;if(T===0)continue;const R=new Int32Array(T),O=new Uint32Array(A+1);for(let Z=0;Z<T;Z++){const _=M($[Z]);R[Z]=_,_>=0&&O[_+1]++}for(let Z=0;Z<A;Z++)O[Z+1]+=O[Z];const I=new Uint32Array(T),q=O.slice(0,A);for(let Z=0;Z<T;Z++){const _=R[Z];_>=0&&(I[q[_]++]=$[Z])}for(let Z=0;Z<A;Z++){const _=O[Z],J=O[Z+1];if(J===_)continue;const ee=I.subarray(_,J);for(let te=0;te<h.length;te++){const ne=h[te],ie=H(ne.handle,ee,ne.fn,g.totalContext||{locale:g.locale});E.set(S(z,C[Z],ne.colId),ie)}}}return{keys:b,paths:C,fields:x,groupPaths:k,columns:P,values:E,cells:E,error:null}}function r(f,u,o){if(u.length===0)return f.slice();const g=[];for(const d of f)for(const h of u)g.push(`${d}${o}${h.colId}`);return g}function s(f){if(f.length===1)return f[0]||new Uint32Array(0);let u=0;for(const d of f)u+=d?d.length:0;const o=new Uint32Array(u);let g=0;for(const d of f)!d||d.length===0||(o.set(d,g),g+=d.length);return o}}),xe("packages/core/src/store/bitset.js",function(e,K){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return L}});const X=8;class L{static#e=new Uint8Array(256);static{for(let F=1;F<256;F++)L.#e[F]=L.#e[F>>1]+(F&1)}#t;#n;constructor(F=0){const W=Math.max(0,F|0);this.#n=W,this.#t=new Uint8Array(Math.ceil(W/X))}get size(){return this.#n}get words(){return this.#t}get bytes(){return this.#t?this.#t.byteLength:0}get(F){return F<0||F>=this.#n?0:this.#t[F>>3]>>(F&7)&1}set(F){return F>=0&&F<this.#n&&(this.#t[F>>3]|=1<<(F&7)),this}clear(F){return F>=0&&F<this.#n&&(this.#t[F>>3]&=~(1<<(F&7))),this}assign(F,W){return W?this.set(F):this.clear(F)}fill(F=!1){return this.#t.fill(F?255:0),F&&this.#r(),this}grow(F){const W=Math.max(0,F|0);if(W<=this.#n)return this;const Q=Math.ceil(W/X);if(Q>this.#t.length){const G=new Uint8Array(Q);G.set(this.#t),this.#t=G}return this.#n=W,this}count(){const F=this.#t,W=L.#e;let Q=0;for(let G=0;G<F.length;G++)Q+=W[F[G]];return Q}and(F){const W=F instanceof L?F.words:F,Q=this.#t,G=Math.min(Q.length,W.length);for(let H=0;H<G;H++)Q[H]&=W[H];for(let H=G;H<Q.length;H++)Q[H]=0;return this}or(F){const W=F instanceof L?F.words:F,Q=this.#t,G=Math.min(Q.length,W.length);for(let H=0;H<G;H++)Q[H]|=W[H];return this}not(){const F=this.#t;for(let W=0;W<F.length;W++)F[W]=~F[W]&255;return this.#r(),this}clone(){const F=new L(this.#n);return F.words.set(this.#t.subarray(0,F.words.length)),F}release(){this.#t=new Uint8Array(0),this.#n=0}#r(){const F=this.#n&7;if(F===0)return;const W=this.#n>>3;W<this.#t.length&&(this.#t[W]&=(1<<F)-1)}static from(F){const W=Array.isArray(F)?F:Array.from(F),Q=new L(W.length);for(let G=0;G<W.length;G++)W[G]&&Q.set(G);return Q}}}),xe("packages/core/src/store/dictionary.js",function(e,K){"use strict";Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return F}});const X=K("packages/core/src/internal/util.js"),L=X.collator,B=X.defaultCompare;class F{#e;#t=new Map;#n=0;#r=null;#o=-1;#i="\0";constructor(Q=[]){this.#e=[];for(let G=0;G<Q.length;G++){const H=Q[G];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 Q=this.#e.length*8;for(let G=0;G<this.#e.length;G++){const H=this.#e[G];typeof H=="string"&&(Q+=H.length*2),Q+=16}return Q}codeOf(Q){const G=this.#t.get(Q);if(G!==void 0)return G;const H=this.#e.length;return this.#e.push(Q),this.#t.set(Q,H),this.#n++,H}lookup(Q){const G=this.#t.get(Q);return G===void 0?-1:G}has(Q){return this.#t.has(Q)}valueOf(Q){return this.#e[Q]}values(){return this.#e}ranks(Q){const G=Q||"";if(this.#r&&this.#o===this.#n&&this.#i===G)return this.#r;const H=this.#e.length,U=new Array(H);for(let y=0;y<H;y++)U[y]=y;const D=L(Q).compare,v=this.#e;U.sort((y,l)=>this.#s(v[y],v[l],D));const S=new Uint32Array(H);for(let y=0;y<H;y++)S[U[y]]=y;return this.#r=S,this.#o=this.#n,this.#i=G,S}#s(Q,G,H){return typeof Q=="string"&&typeof G=="string"?H(Q,G):B(Q,G)}}}),xe("packages/core/src/store/multivalue.js",function(e,K){"use strict";Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return X}});class X{#e;#t;#n=0;#r=0;constructor(B={}){const F=Math.max(1,B.rows??16),W=Math.max(1,B.values??F);this.#e=new Int32Array(W),this.#t=new Uint32Array(F+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,F){if(B<0||B>=this.#n)return!1;const W=this.#e,Q=this.#t[B+1];for(let G=this.#t[B];G<Q;G++)if(W[G]===F)return!0;return!1}hasAny(B,F){for(let W=0;W<F.length;W++)if(this.has(B,F[W]))return!0;return!1}hasAll(B,F){for(let W=0;W<F.length;W++)if(!this.has(B,F[W]))return!1;return!0}hasNone(B,F){return!this.hasAny(B,F)}push(B){const F=this.#n,W=B.length;this.#o(F+1),this.#i(this.#r+W);const Q=this.#r;for(let G=0;G<W;G++)this.#e[Q+G]=B[G]|0;return this.#r+=W,this.#n=F+1,this.#t[F]=Q,this.#t[F+1]=this.#r,F}write(B,F){if(B===this.#n){this.push(F);return}if(B<0||B>this.#n)return;const W=this.#t[B],Q=this.#t[B+1],G=F.length;if(Q-W===G){for(let H=0;H<G;H++)this.#e[W+H]=F[H]|0;return}this.#s(B,F)}compact(B,F,W){const Q=this.#e,G=this.#t,H=this.#n,U=new Int32Array(Math.max(1,this.#r)),D=new Uint32Array(F+1);let v=0;for(let S=0;S<H;S++){if(B[S]===W)continue;const y=G[S],l=G[S+1];D[B[S]]=v;for(let c=y;c<l;c++)U[v++]=Q[c];D[B[S]+1]=v}this.#e=U,this.#t=D,this.#n=F,this.#r=v}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 F=this.#t.length-1;for(;F<B;)F=F*2||16;const W=new Uint32Array(F+1);W.set(this.#t),this.#t=W}#i(B){if(B<=this.#e.length)return;let F=this.#e.length;for(;F<B;)F=F*2||16;const W=new Int32Array(F);W.set(this.#e),this.#e=W}#s(B,F){const W=this.#e,Q=this.#t,G=this.#n,H=F.length-(Q[B+1]-Q[B]),U=new Int32Array(Math.max(1,this.#r+H)),D=new Uint32Array(Q.length);let v=0;for(let S=0;S<G;S++){if(D[S]=v,S===B)for(let y=0;y<F.length;y++)U[v++]=F[y]|0;else for(let y=Q[S];y<Q[S+1];y++)U[v++]=W[y];D[S+1]=v}this.#e=U,this.#t=D,this.#r=v}}}),xe("packages/core/src/compute/sort.js",function(e,K){"use strict";Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return A}});const X=K("packages/core/src/compute/handle.js"),L=X.bitReader,B=X.dictRanks,F=X.dictSize,W=X.identity,Q=X.isMissing,G=X.presenceReader,H=X.rowCount,U=X.valueComparator,D=X.valueReader,v=new Uint32Array(0),S=new ArrayBuffer(8),y=new Float64Array(S),l=new Uint32Array(S),c=(y[0]=-1,(l[1]&2147483648)!==0?1:0),i=c===1?0:1;function n($,z){y[0]=$;let T=l[c],R=l[i];(T&2147483648)!==0?(T=~T>>>0,R=~R>>>0):T=(T^2147483648)>>>0,z[0]=R,z[1]=T}function t($,z,T,R){if(R<2)return $;const O=new Uint32Array(256*8);for(let ne=0;ne<R;ne++){const ie=z[ne],ae=T[ne];O[ie&255]++,O[256+(ie>>>8&255)]++,O[512+(ie>>>16&255)]++,O[768+(ie>>>24&255)]++,O[1024+(ae&255)]++,O[1280+(ae>>>8&255)]++,O[1536+(ae>>>16&255)]++,O[1792+(ae>>>24&255)]++}let I=$,q=z,Z=T,_=new Uint32Array(R),J=new Uint32Array(R),ee=new Uint32Array(R);const te=new Uint32Array(256);for(let ne=0;ne<8;ne++){const ie=ne<<8,ae=(ne&3)<<3,re=ne>=4;let se=!1;for(let be=0;be<256;be++)if(O[ie+be]===R){se=!0;break}if(se)continue;let le=0;for(let be=0;be<256;be++)te[be]=le,le+=O[ie+be];for(let be=0;be<R;be++){const Le=q[be],we=Z[be],Re=(re?we:Le)>>>ae&255,ge=te[Re]++;_[ge]=I[be],J[ge]=Le,ee[ge]=we}let fe=I;I=_,_=fe,fe=q,q=J,J=fe,fe=Z,Z=ee,ee=fe}return I}function r($,z,T){if(T<2)return $;const R=new Uint32Array(256*4);for(let J=0;J<T;J++){const ee=z[J];R[ee&255]++,R[256+(ee>>>8&255)]++,R[512+(ee>>>16&255)]++,R[768+(ee>>>24&255)]++}let O=$,I=z,q=new Uint32Array(T),Z=new Uint32Array(T);const _=new Uint32Array(256);for(let J=0;J<4;J++){const ee=J<<8,te=J<<3;let ne=!1;for(let re=0;re<256;re++)if(R[ee+re]===T){ne=!0;break}if(ne)continue;let ie=0;for(let re=0;re<256;re++)_[re]=ie,ie+=R[ee+re];for(let re=0;re<T;re++){const se=I[re],le=_[se>>>te&255]++;q[le]=O[re],Z[le]=se}let ae=O;O=q,q=ae,ae=I,I=Z,Z=ae}return O}function s($,z,T,R){const O=new Uint32Array(R+1);for(let Z=0;Z<T;Z++)O[z[Z]]++;let I=0;for(let Z=0;Z<=R;Z++){const _=O[Z];O[Z]=I,I+=_}const q=new Uint32Array(T);for(let Z=0;Z<T;Z++)q[O[z[Z]]++]=$[Z];return q}function f($,z,T,R){return T<2?$:R<=65536||R<=T*2?s($,z,T,R):r($,z,T)}function u($,z){return $.length===z&&$.byteOffset===0?$:Uint32Array.prototype.slice.call($,0,z)}function o($,z,T=!1){const R=z||W($.length),O=R.length;if(O<2)return Uint32Array.from(R);const I=new Uint32Array(O),q=new Uint32Array(O),Z=new Uint32Array(O),_=new Uint32Array(O),J=new Uint32Array(2);let ee=0,te=0;for(let ae=0;ae<O;ae++){const re=R[ae],se=$[re];if(Number.isNaN(se)){_[te++]=re;continue}n(se,J),T?(q[ee]=~J[0]>>>0,Z[ee]=~J[1]>>>0):(q[ee]=J[0],Z[ee]=J[1]),I[ee++]=re}const ne=t(I.subarray(0,ee),q.subarray(0,ee),Z.subarray(0,ee),ee);if(te===0)return u(ne,ee);const ie=new Uint32Array(O);return ie.set(ne.subarray(0,ee),0),ie.set(_.subarray(0,te),ee),ie}function g($,z,T=!1){const R=z||W($.length),O=R.length;if(O<2)return Uint32Array.from(R);const I=Uint32Array.from(R),q=new Uint32Array(O);for(let Z=0;Z<O;Z++){const _=($[I[Z]]^2147483648)>>>0;q[Z]=T?~_>>>0:_}return u(r(I,q,O),O)}function d($,z,T={}){const R=z||W(H($,T)),O=R.length;if(O<2)return Uint32Array.from(R);const I=B($.dict,T.locale),q=$.values,Z=G($),_=Math.max(F($.dict),I.length),J=_,ee=Uint32Array.from(R),te=new Uint32Array(O),ne=!!T.descending;for(let ie=0;ie<O;ie++){const ae=ee[ie];let re=Z&&Z(ae)===0?J:I[q[ae]];re===void 0&&(re=J),te[ie]=ne?J-re:re}return u(f(ee,te,O,_+1),O)}function h($,z,T){const R=z.length;let O=Uint32Array.from(z);if(R<2)return O;let I=new Uint32Array(R);for(let q=1;q<R;q<<=1){for(let _=0;_<R;_+=q<<1){const J=Math.min(_+q,R),ee=Math.min(_+(q<<1),R);let te=_,ne=J,ie=_;for(;te<J&&ne<ee;)I[ie++]=T($[O[te]],$[O[ne]])<=0?O[te++]:O[ne++];for(;te<J;)I[ie++]=O[te++];for(;ne<ee;)I[ie++]=O[ne++]}const Z=O;O=I,I=Z}return O}function a($,z,T){const R=L($.values),O=z.length,I=new Uint32Array(O),q=T?1:0;let Z=0;for(let _=0;_<O;_++)R(z[_])===q&&(I[Z++]=z[_]);for(let _=0;_<O;_++)R(z[_])!==q&&(I[Z++]=z[_]);return I}function p($,z){const T=$.values,R=$.kind;if((R==="object"||R===void 0)&&(Array.isArray(T)||ArrayBuffer.isView(T))&&!$.presence)return T;const I=D($),q=new Array(H($)||0);for(let Z=0;Z<z.length;Z++){const _=z[Z];q[_]=I(_)}return q}function w($,z){for(let T=0;T<z.length;T++)if(typeof $[z[T]]!="string")return!1;return!0}function k($,z,T,R,O){const I=$.length,q=Uint32Array.from($);if(I<2||R<1)return q;const Z=new Uint32Array(I),_=R-1;for(let J=0;J<I;J++){const ee=T[z[J]];Z[J]=O?_-ee:ee}return u(f(q,Z,I,R),I)}function m($,z,T){const R=U(T),O=new Array(z);for(let q=0;q<z;q++)O[q]=q;O.sort((q,Z)=>R($[q],$[Z])||q-Z);const I=new Uint32Array(z);for(let q=0;q<z;q++)I[O[q]]=q;return I}function b($,z,T){const R=z.length,O=new Map,I=[],q=new Uint32Array(R);for(let J=0;J<R;J++){const ee=$[z[J]];let te=O.get(ee);te===void 0&&(te=I.length,O.set(ee,te),I.push(ee)),q[J]=te}const Z=I.length,_=m(I,Z,T.locale);return k(z,q,_,Z,!!T.descending)}function C($,z,T){const R=p($,z);if(z.length>=2&&w(R,z)){const q=$.stringRank;return q&&q.version===$.version&&q.usable(z,R,T.locale)?q.sort(z,T):b(R,z,T)}const O=U(T.locale),I=T.descending?(q,Z)=>O(Z,q):O;return h(R,z,I)}function M($,z,T){const R=p($,z),O=T.compare,q=!!T.descending?(Z,_)=>-O(Z,_,void 0,void 0,!0):(Z,_)=>O(Z,_,void 0,void 0,!1);return h(R,z,q)}function P($,z){const T=z.length,R=G($),O=$.values,I=$.kind==="float64"&&!!O,q=$.kind==="object"||$.kind==="multi"||$.kind===void 0;if(!R&&!I&&!q)return{present:z,absent:v};const Z=new Uint32Array(T),_=new Uint32Array(T);let J=0,ee=0;if(R&&I)for(let te=0;te<T;te++){const ne=z[te];R(ne)===1&&!Number.isNaN(O[ne])?Z[J++]=ne:_[ee++]=ne}else if(I&&!R)for(let te=0;te<T;te++){const ne=z[te];Number.isNaN(O[ne])?_[ee++]=ne:Z[J++]=ne}else if(R&&!q)for(let te=0;te<T;te++){const ne=z[te];R(ne)===1?Z[J++]=ne:_[ee++]=ne}else{const te=D($);for(let ne=0;ne<T;ne++){const ie=z[ne];Q(te(ie))?_[ee++]=ie:Z[J++]=ie}}return ee===0?{present:z,absent:v}:{present:Z.subarray(0,J),absent:_.subarray(0,ee)}}function x($,z,T){if(z.length===0)return $;const R=new Uint32Array($.length+z.length);return T?(R.set(z,0),R.set($,z.length)):(R.set($,0),R.set(z,$.length)),R}function E($,z,T={}){const R=z||W(H($,T));if(!$||R.length<2)return Uint32Array.from(R);const{present:O,absent:I}=P($,R);if(O.length===0)return Uint32Array.from(R);const q=!!T.descending;let Z;if(typeof T.compare=="function")Z=M($,O,T);else switch($.kind){case"float64":Z=o($.values,O,q);break;case"int32":Z=g($.values,O,q);break;case"dictionary":Z=d($,O,T);break;case"bitset":Z=a($,O,q);break;default:Z=C($,O,T);break}return x(Z,I,!!T.nullsFirst)}function A($,z,T,R={}){const O=z||[],I=O.length&&(O[0].handle||j($,O[0].col))||$&&$[0];let q=T||W(H(I,R));for(let Z=O.length-1;Z>=0;Z--){const _=O[Z],J=_.handle||j($,_.col)||$&&$[Z];J&&(q=E(J,q,{descending:_.descending!==void 0?!!_.descending:_.dir==="desc",nullsFirst:!!_.nullsFirst,locale:_.locale!==void 0?_.locale:R.locale,compare:_.compare}))}return q instanceof Uint32Array?q:Uint32Array.from(q)}function j($,z){if(!(!$||z===void 0)){for(let T=0;T<$.length;T++)if($[T]&&$[T].id===z)return $[T]}}}),xe("packages/core/src/store/stringrank.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"StringRankIndex",{enumerable:!0,get:function(){return W}});const X=K("packages/core/src/compute/sort.js"),L=X.collateStringRanks,B=X.rankSortStrings,F=1e5;class W{#e=[];#t=new Map;#n;#r=0;#o=0;#i=-1;#s;#l=!1;#a=null;#u=-1;#c="\0";constructor(G=F){this.#s=G>0?G:F,this.#n=new Uint32Array(0)}get version(){return this.#i}set version(G){this.#i=G}get generation(){return this.#o}get size(){return this.#e.length}get capped(){return this.#l}get length(){return this.#r}get bytes(){let G=this.#n.byteLength;const H=this.#e;for(let U=0;U<H.length;U++)G+=H[U].length*2+24;return G}#d(G,H){const U=this.#t.get(G);if(U!==void 0)return U;if(this.#l)return-1;if(H&&this.#e.length>=this.#s)return this.#l=!0,-1;const D=this.#e.length;return this.#e.push(G),this.#t.set(G,D),this.#o++,D}build(G,H){const U=H|0;this.#e=[],this.#t=new Map,this.#o=0,this.#l=!1,this.#a=null,this.#u=-1,this.#n=new Uint32Array(U);for(let D=0;D<U;D++){const v=G[D],S=typeof v=="string"?this.#d(v,!1):-1;this.#n[D]=S<0?0:S}this.#r=U}append(G,H,U){const D=(H|0)+(U|0);if(D>this.#n.length){const v=new Uint32Array(D);v.set(this.#n.subarray(0,this.#r)),this.#n=v}for(let v=H|0;v<D;v++){const S=G[v],y=typeof S=="string"?this.#d(S,!0):-1;this.#n[v]=y<0?0:y}this.#r=Math.max(this.#r,D)}ranks(G){const H=G||"";if(this.#a&&this.#u===this.#o&&this.#c===H)return this.#a;const U=L(this.#e,this.#e.length,G);return this.#a=U,this.#u=this.#o,this.#c=H,U}usable(G,H,U){if(this.#l||this.#e.length===0)return!1;const D=this.#n,v=this.#e,S=this.#r;for(let y=0;y<G.length;y++){const l=G[y];if(l>=S||v[D[l]]!==H[l])return!1}return!0}sort(G,H){const U=this.ranks(H.locale),D=this.#e.length,v=G.length,S=new Uint32Array(v),y=this.#n;for(let l=0;l<v;l++)S[l]=y[G[l]];return B(G,S,U,D,!!H.descending)}}}),xe("packages/core/src/store/columnstore.js",function(e,K){"use strict";Object.defineProperty(e,"REMOVED",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"toFloat",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ColumnHandle",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return d}});const X=K("packages/core/src/internal/util.js"),L=X.warnOnce,B=X.isFunction,F=X.pathGetter,Q=K("packages/core/src/store/bitset.js").Bitset,H=K("packages/core/src/store/dictionary.js").Dictionary,D=K("packages/core/src/store/multivalue.js").MultiValue,S=K("packages/core/src/store/stringrank.js").StringRankIndex,y=4294967295,l=1024,c=5e3,i=.2,n=new Set(["float64","int32","bitset","dictionary","object","multi"]);function t(h){return h==null}function r(h){if(typeof h=="number")return h;if(h instanceof Date)return h.getTime();if(typeof h=="boolean")return h?1:0;const a=Number(h);return Number.isNaN(a)&&typeof h=="string"?Date.parse(h):a}function s(h){const a=r(h);return Number.isFinite(a)?a|0:0}function f(h){return t(h)?[]:Array.isArray(h)?h:[h]}function u(h,a){switch(h.kind){case"float64":case"int32":return h.buf[a];case"bitset":return h.bits.get(a)===1;case"dictionary":return h.dict.valueOf(h.buf[a]);case"multi":{const p=h.mv.at(a),w=new Array(p.length);for(let k=0;k<p.length;k++)w[k]=h.dict.valueOf(p[k]);return w}default:return h.buf[a]}}function o(h,a){switch(h.kind){case"float64":case"int32":return h.values[a];case"bitset":return(h.values[a>>3]&1<<(a&7))!==0;case"dictionary":return(h.table||[])[h.values[a]];case"multi":{const p=h.offsets[a],w=h.offsets[a+1],k=h.table||[],m=new Array(w-p);for(let b=p;b<w;b++)m[b-p]=k[h.values[b]];return m}default:return h.values[a]}}class g{#e;#t;#n;#r;#o;#i;#s;#l=!1;#a=null;#u=null;#c=null;#d=null;#f=null;#h;#p;#m=-1;#g=null;#y=0;#w=0;#k=null;#b=null;#O=!1;constructor(a,p){this.#e=a.id;const w=n.has(a.kind)?a.kind:"object";a.kind&&!n.has(a.kind)&&L(`store.kind.${a.id}`,`column "${a.id}" declares unknown storage kind "${a.kind}"; falling back to object`),this.#n=w,this.#t=w,this.#r=a.nullable!==!1,this.#s=a.dictionary??null,this.#i=p,this.#o=B(a.read)?a.read:F(a.field||a.id),this.#h=a.stringRankIndex!=="off",this.#p=typeof a.stringRankMaxDistinct=="number"?a.stringRankMaxDistinct:0,this.#k=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.#E().values}get presence(){return this.#O||!this.#r?null:this.#l?this.#g:this.#E().presence}get dict(){return this.#O||!this.#l?null:this.#t==="dictionary"||this.#t==="multi"?this.#d:null}get stringRank(){if(this.#O||!this.#h||this.kind!=="object")return null;const a=this.values,p=this.#i.physical();if(!a||p===0)return null;if(this.#f===null){if(typeof a[0]!="string")return null;const w=new S(this.#j());return w.build(a,p),w.version=this.#w,this.#f=w,this.#m=this.#w,w.capped?null:w}return this.#f.length<p&&this.#f.append(a,this.#f.length,p-this.#f.length),this.#f.version=this.#w,this.#m=this.#w,this.#f.capped?null:this.#f}#j(){return this.#p}#P(){this.#f=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.#k&&(a+=this.#k.size*24),a}get(a){if(!this.#O&&!(a<0||a>=this.#i.physical())){if(!this.#l)return this.#A(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),w=new Array(p.length);for(let k=0;k<p.length;k++)w[k]=this.#d.valueOf(p[k]);return w}default:return this.#a[a]}}}set(a,p){this.#O||(this.#l?this.#M(a,p):this.#k.set(a,p===void 0?null:p),this.#f&&this.#P(),this.#w++)}read(a){return this.#o(a)}appendColumn(a,p,w){if(this.#O||w<=0)return;if(!this.#l){this.#w++;return}const k=this.#o,m=this.#r,b=this.#g;let C=!1;switch(this.#t){case"float64":{const M=this.#a;for(let P=0;P<w;P++){const x=k(a[P]);if(typeof x=="number"){m&&b.set(p+P),M[p+P]=x;continue}const E=x==null;m?b.assign(p+P,!E):E&&(C=!0),M[p+P]=E?NaN:r(x)}break}case"int32":{const M=this.#a;for(let P=0;P<w;P++){const x=k(a[P]),E=x==null;m?b.assign(p+P,!E):E&&(C=!0),M[p+P]=E?0:s(x)}break}case"bitset":{const M=this.#u;for(let P=0;P<w;P++){const x=k(a[P]),E=x==null;m?b.assign(p+P,!E):E&&(C=!0),M.assign(p+P,!E&&!!x)}break}case"dictionary":{const M=this.#a,P=this.#d;for(let x=0;x<w;x++){const E=k(a[x]),A=E==null;m?b.assign(p+x,!A):A&&(C=!0),M[p+x]=A?0:P.codeOf(E)}break}case"multi":{const M=this.#c,P=this.#d;for(let x=0;x<w;x++){const E=k(a[x]),A=E==null;m?b.assign(p+x,!A):A&&(C=!0);const j=f(E),$=new Array(j.length);for(let z=0;z<j.length;z++)$[z]=P.codeOf(j[z]);M.write(p+x,$)}break}default:{const M=this.#a;for(let P=0;P<w;P++){const x=k(a[P]),E=x==null;m?b.assign(p+P,!E):E&&(C=!0),M[p+P]=E?null:x}break}}C&&L(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#f&&this.#t==="object"&&(this.#f.append(this.#a,p,w),this.#f.version=this.#w+1,this.#m=this.#w+1),this.#w++}appendPacked(a,p,w){if(this.#O||w<=0||!a)return;if(!this.#l){this.#w++;return}const k=this.#g,m=a.presence;if(k)if(m)for(let C=0;C<w;C++)k.assign(p+C,(m[C>>3]&1<<(C&7))!==0);else for(let C=0;C<w;C++)k.set(p+C);const b=a.kind===this.#t;if(b&&(this.#t==="float64"||this.#t==="int32")){this.#a.set(a.values,p),this.#w++;return}if(b&&this.#t==="bitset"){const C=a.values;for(let M=0;M<w;M++)this.#u.assign(p+M,(C[M>>3]&1<<(M&7))!==0);this.#w++;return}if(b&&this.#t==="dictionary"){const C=a.table||[],M=new Uint32Array(C.length);for(let A=0;A<C.length;A++)M[A]=this.#d.codeOf(C[A]);const P=a.values,x=this.#a,E=k;for(let A=0;A<w;A++){if(E&&(m&&(m[A>>3]&1<<(A&7))===0)){x[p+A]=0;continue}x[p+A]=M[P[A]]??0}this.#w++;return}if(b&&this.#t==="multi"){const C=a.table||[],M=new Uint32Array(C.length);for(let E=0;E<C.length;E++)M[E]=this.#d.codeOf(C[E]);const P=a.values,x=a.offsets;for(let E=0;E<w;E++){const A=x[E],j=x[E+1],$=new Array(j-A);for(let z=A;z<j;z++)$[z-A]=M[P[z]]??0;this.#c.write(p+E,$)}this.#w++;return}for(let C=0;C<w;C++){const M=m?(m[C>>3]&1<<(C&7))===0:a.kind==="object"?a.values[C]===null:!1;this.#M(p+C,M?null:o(a,C))}this.#w++}touch(){this.#w++}columnarise(a,p){if(this.#l||this.#O)return;const w=new Array(p);for(let k=0;k<p;k++)w[k]=this.#A(k);this.#t=this.#n,this.#l=!0,this.#S(a);for(let k=0;k<p;k++)this.#M(k,w[k]);this.#k.clear(),this.#b=null,this.#P(),this.#w++}grow(a){if(!(!this.#l||this.#O||a<=this.#y)){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.#y=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},w=this.#i.physical(),k=this.#g;this.#t=a,this.#S(this.#y);for(let m=0;m<w;m++){const b=k!==null&&k.get(m)===0;b&&a!=="multi"||this.#M(m,b?null:u(p,m))}return this.#P(),this.#w++,!0}compact(a,p,w){if(!this.#O){if(this.#P(),!this.#l){const k=this.#k;if(k.size){const m=new Map;for(const[b,C]of k)a[b]!==y&&m.set(a[b],C);this.#k=m}this.#b=null,this.#w++;return}switch(this.#t){case"float64":case"int32":case"dictionary":case"object":{const k=this.#a;for(let m=0;m<p;m++)a[m]!==y&&(k[a[m]]=k[m]);if(this.#t==="object")for(let m=w;m<p;m++)k[m]=void 0;break}case"bitset":{const k=this.#u;for(let m=0;m<p;m++)a[m]!==y&&k.assign(a[m],k.get(m)===1);for(let m=w;m<p;m++)k.clear(m);break}case"multi":this.#c.compact(a,w,y);break;default:break}if(this.#g){const k=this.#g;for(let m=0;m<p;m++)a[m]!==y&&k.assign(a[m],k.get(m)===1);for(let m=w;m<p;m++)k.clear(m)}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.#f=null,this.#k=new Map,this.#b=null,this.#y=0,this.#w++)}#S(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 Q(p);break;case"dictionary":this.#a=new Uint32Array(p),this.#d=this.#d??new H(this.#s??[]);break;case"multi":this.#c=new D({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 Q(p)),this.#y=p}#M(a,p){const w=t(p);switch(this.#r?this.#g.assign(a,!w):w&&L(`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]=w?NaN:r(p);break;case"int32":this.#a[a]=w?0:s(p);break;case"bitset":this.#u.assign(a,!w&&!!p);break;case"dictionary":this.#a[a]=w?0:this.#d.codeOf(p);break;case"multi":{const k=f(p),m=new Array(k.length);for(let b=0;b<k.length;b++)m[b]=this.#d.codeOf(k[b]);this.#c.write(a,m);break}default:this.#a[a]=w?null:p;break}}#A(a){if(this.#k.has(a))return this.#k.get(a);const p=this.#o(this.#i.rowAt(a));return p===void 0?null:p}#E(){if(this.#b&&this.#b.version===this.#w)return this.#b;const a=this.#i.physical(),p=new Array(a),w=this.#r?new Q(a):null;for(let k=0;k<a;k++){const m=this.#A(k);p[k]=m,w&&!t(m)&&w.set(k)}return this.#b={version:this.#w,values:p,presence:w},this.#b}}class d{#e;#t=new Map;#n=[];#r=[];#o=0;#i=0;#s=0;#l=0;#a=new Q(0);#u=!1;#c=!0;#d;#f;#h;#p=!1;constructor(a,p={}){this.#e=Array.isArray(a)?a:[],this.#f=Math.max(1,p.initialCapacity??l),this.#c=p.retainSource!==!1,this.#d=this.#c?p.columnarBelow??c:0,this.#h=p.compactRatio??i;const w={rowAt:k=>this.#r[k],physical:()=>this.#o};for(const k of this.#e){if(!k||!k.id)continue;if(this.#t.has(k.id)){L(`store.dup.${k.id}`,`duplicate column id "${k.id}" in the store schema; ignoring the second`);continue}const m=new g(k,w);this.#t.set(k.id,m),this.#n.push(m)}this.#d<=0&&this.#y()}get count(){return this.#s}get physical(){return this.#o}get capacity(){return this.#u?this.#i:this.#r.length}get tombstones(){return this.#l}get columnar(){return this.#u}get destroyed(){return this.#p}get bytes(){let 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 w=a.length|0;if(w===0)return{from:p,to:p};if(this.#c)for(let m=0;m<w;m++)this.#r[p+m]=a[m];if(this.#o=p+w,this.#s+=w,this.#a.grow(this.#o),!this.#u){if(this.#o>=this.#d)this.#y();else for(const m of this.#n)m.touch();return{from:p,to:this.#o}}this.#m(this.#o);const k=this.#n;for(let m=0;m<k.length;m++)k[m].appendColumn(a,p,w);return{from:p,to:this.#o}}appendPacked(a,p){const w=this.#o;if(this.#p||!a)return{from:w,to:w};const k=a.count|0;if(k===0)return{from:w,to:w};if(this.#c&&p)for(let b=0;b<k;b++)this.#r[w+b]=p[b];this.#o=w+k,this.#s+=k,this.#a.grow(this.#o),this.#u||this.#y(),this.#m(this.#o);const m=new Map;for(const b of a.columns)m.set(b.id,b);for(const b of this.#n){const C=m.get(b.id);C?b.appendPacked(C,w,k):b.grow(this.#i)}return{from:w,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 w=this.#t.get(a);return w?w.get(p):void 0}set(a,p,w){if(this.#p||p<0||p>=this.#o)return;const k=this.#t.get(a);if(!k){L(`store.set.${a}`,`set() on unknown column "${a}"`);return}k.set(p,w)}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.#h)return null;const p=this.#o,w=new Uint32Array(p);let k=0;for(let m=0;m<p;m++)w[m]=this.#a.get(m)===1?y:k++;for(const m of this.#n)m.compact(w,p,k);if(this.#c){const m=this.#r;for(let b=0;b<p;b++)w[b]!==y&&(m[w[b]]=m[b]);m.length=k}return this.#o=k,this.#s=k,this.#l=0,this.#a=new Q(Math.max(this.#i,k)),w}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 w=0;w<this.#o;w++)a[w]=w;return a}let p=0;for(let w=0;w<this.#o;w++)this.#a.get(w)===0&&(a[p++]=w);return a}convert(a,p){const w=this.#t.get(a);return w?w.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.#f;for(;p<a;)p*=2;for(const w of this.#n)w.grow(p);this.#a.grow(p),this.#i=p}#g(a){const p={};for(const w of this.#n)p[w.id]=w.get(a);return p}#y(){if(this.#u)return;let a=this.#f;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)}}}),xe("packages/core/src/store/pool.js",function(e,K){"use strict";Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"sharedPool",{enumerable:!0,get:function(){return W}});const X=64,L=8;function B(G){let H=X;for(;H<G;)H*=2;return H}class F{#e=new Map;#t=new WeakSet;#n;#r=0;#o={acquired:0,reused:0,released:0};constructor(H={}){this.#n=H.limit??L}get bytes(){return this.#r}mask(H){const U=new Uint8Array(this.#i(H),0,H);return U.fill(0),U}indices(H){return new Uint32Array(this.#i(H*4),0,H)}release(H){if(!H||!H.buffer)return!1;const U=H.buffer;if(!this.#t.has(U))return!1;this.#t.delete(U),this.#o.released++;const D=U.byteLength;let v=this.#e.get(D);return v||this.#e.set(D,v=[]),v.length>=this.#n||(v.push(U),this.#r+=D),!0}releaseAll(H){for(const U of H)this.release(U)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#o,retained:this.#r}}#i(H){const U=B(H),D=this.#e.get(U);this.#o.acquired++;let v;return D&&D.length?(v=D.pop(),this.#r-=U,this.#o.reused++):v=new ArrayBuffer(U),this.#t.add(v),v}}function W(){return Q??=new F,Q}let Q=null}),xe("packages/core/src/compute/sortspec.js",function(e,K){"use strict";Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return W}});function X(Q){return{locale:Q===void 0?void 0:String(Q),numeric:!0,sensitivity:"variant"}}function L(Q){return!!Q&&typeof Q.compare!="function"}function B(Q){if(!Q)return!0;for(let G=0;G<Q.length;G++)if(!L(Q[G]))return!1;return!0}function F(Q,G){const H=Q.col!==void 0?Q.col:Q.handle&&Q.handle.id,U=Q.locale!==void 0?Q.locale:G;return{col:H,descending:Q.descending!==void 0?!!Q.descending:Q.dir==="desc",nullsFirst:!!Q.nullsFirst,collation:X(U)}}function W(Q,G){const H=Q||[],U=new Array(H.length);for(let D=0;D<H.length;D++)U[D]=F(H[D],G);return U}}),xe("packages/core/src/compute/facet.js",function(e,K){"use strict";Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"orderedReader",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"toNumeric",{enumerable:!0,get:function(){return y}}),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 w}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const X=K("packages/core/src/compute/handle.js"),L=X.presenceReader,B=X.valueReader,F=X.dictSize,W=X.dictValue,Q=Object.freeze(["equal","quantile","log"]),G=Object.freeze(["hour","day","week","month","quarter","year"]),H=20,U=50,D=1e4;function v(m,b){if(!m)return"none";const C=b;if(C&&(C.multi===!0||typeof C.items=="function"))return"category";const M=b&&b.base;if(M==="date"||M==="datetime"||M==="time"||M==="dateString")return"date";switch(m.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return M==="number"?"numeric":M==="boolean"?"boolean":M==="text"?"category":"none"}}function S(m){const b=m.values,C=m.kind;if((C==="float64"||C==="int32")&&b)return P=>b[P];const M=B(m);return P=>y(M(P))}function y(m){if(typeof m=="number")return m;if(m instanceof Date)return m.getTime();if(m==null||m==="")return NaN;if(typeof m=="boolean")return m?1:0;if(typeof m=="string"){const b=Number(m);if(Number.isFinite(b))return b;const C=Date.parse(m);return Number.isFinite(C)?C:NaN}return NaN}function l(m,b,C,M=U){if(!m)return{cardinality:0,exact:!0};if(m.dict)return{cardinality:F(m.dict),exact:!0};if(m.kind==="bitset")return{cardinality:2,exact:!0};const P=B(m),x=b?b.length:C,E=new Set;for(let A=0;A<x;A++){const j=P(b?b[A]:A);if(j!=null&&(E.add(j),E.size>M))return{cardinality:E.size,exact:!1}}return{cardinality:E.size,exact:!0}}const c=36e5,i=864e5;function n(m,b=H){const C=Number.isFinite(m)&&m>0?m:0,M=Math.max(1,b)*2;return C/c<=M?"hour":C/i<=M?"day":C/(7*i)<=M?"week":C/(30*i)<=M?"month":C/(91*i)<=M?"quarter":"year"}function t(m,b){if(!Number.isFinite(m))return NaN;const C=new Date(m);switch(b){case"hour":return C.setMinutes(0,0,0),C.getTime();case"day":return C.setHours(0,0,0,0),C.getTime();case"week":{C.setHours(0,0,0,0);const M=(C.getDay()+6)%7;return C.setDate(C.getDate()-M),C.getTime()}case"month":return C.setDate(1),C.setHours(0,0,0,0),C.getTime();case"quarter":return C.setMonth(Math.floor(C.getMonth()/3)*3,1),C.setHours(0,0,0,0),C.getTime();default:return C.setMonth(0,1),C.setHours(0,0,0,0),C.getTime()}}function r(m,b){const C=new Date(m);switch(b){case"hour":C.setHours(C.getHours()+1);break;case"day":C.setDate(C.getDate()+1);break;case"week":C.setDate(C.getDate()+7);break;case"month":C.setMonth(C.getMonth()+1);break;case"quarter":C.setMonth(C.getMonth()+3);break;default:C.setFullYear(C.getFullYear()+1);break}return C.getTime()}function s(m,b,C){const M=S(m),P=L(m),x=b?b.length:C;let E=1/0,A=-1/0,j=0,$=0;for(let z=0;z<x;z++){const T=b?b[z]:z;if(P&&!P(T)){j++;continue}const R=M(T);if(!Number.isFinite(R)){j++;continue}R<E&&(E=R),R>A&&(A=R),$++}return{min:E,max:A,nulls:j,finite:$}}function f(m,b,C,M){const P=S(m),x=L(m),E=b?b.length:C,A=E>M?E/M:1,j=[];for(let z=0;z<E;z+=A){const T=b?b[Math.floor(z)]:Math.floor(z);if(x&&!x(T))continue;const R=P(T);Number.isFinite(R)&&j.push(R)}const $=Float64Array.from(j);return $.sort(),$}function u(m,b,C,M={}){const P=M.kind||v(m,M.type);return P==="none"||!m?{kind:"none",buckets:[],suppressed:"type"}:P==="boolean"?o(m,b,C):P==="category"?g(m,b,C,M):d(m,b,C,P,M)}function o(m,b,C){const M=L(m);let P=0;if(M){const E=b?b.length:C;for(let A=0;A<E;A++)M(b?b[A]:A)||P++}const x=[{value:!1,label:"false"},{value:!0,label:"true"}];return P>0&&x.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:x}}function g(m,b,C,M){const P=M.cardinalityLimit??U,{cardinality:x}=l(m,b,C,P);if(x>P&&(M.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:x};const E=B(m),A=b?b.length:C,j=new Map;let $=0;for(let I=0;I<A;I++){const q=E(b?b[I]:I);if(q==null||q===""){$++;continue}if(Array.isArray(q)){if(!q.length){$++;continue}for(const Z of q)j.set(Z,(j.get(Z)||0)+1);continue}j.set(q,(j.get(q)||0)+1)}let z=[...j.entries()];M.order==="alpha"?z.sort((I,q)=>String(I[0]).localeCompare(String(q[0]))):z.sort((I,q)=>q[1]-I[1]);let T=0,R=0;if(z.length>P){R=z.length-P;for(let I=P;I<z.length;I++)T+=z[I][1];z=z.slice(0,P)}const O=z.map(([I])=>({value:I,label:String(I)}));return T>0&&O.push({remainder:!0,label:`Other (${R} values)`}),$>0&&O.push({null:!0,label:"Empty"}),{kind:"category",buckets:O,cardinality:x}}function d(m,b,C,M,P){const{min:x,max:E,nulls:A,finite:j}=s(m,b,C);if(!j)return{kind:M,buckets:A?[{null:!0,label:"Empty"}]:[],empty:!0};const $=Math.max(1,Math.floor(P.buckets||H));let z=[];if(M==="date"){const R=G.includes(P.granularity)?P.granularity:n(E-x,$);let O=t(x,R);for(;O<=E&&z.length<4096;){const I=r(O,R);if(!(I>O))break;z.push({from:O,to:I}),O=I}return{kind:M,buckets:h(z,A),granularity:R}}const T=Q.includes(P.strategy)?P.strategy:"equal";if(T==="quantile"){const R=f(m,b,C,D);if(R.length){const O=[R[0]];for(let I=1;I<$;I++){const q=R[Math.min(R.length-1,Math.floor(I/$*R.length))];q>O[O.length-1]&&O.push(q)}O.push(E);for(let I=0;I<O.length-1;I++)z.push({from:O[I],to:O[I+1]})}}else if(T==="log"&&x>0){const R=Math.log10(x),I=(Math.log10(E)-R)/$||1;for(let q=0;q<$;q++)z.push({from:10**(R+q*I),to:10**(R+(q+1)*I)})}if(!z.length){const R=(E-x)/$||1;for(let O=0;O<$;O++)z.push({from:x+O*R,to:x+(O+1)*R})}return z[z.length-1].to=E,{kind:M,buckets:h(z,A),strategy:T,min:x,max:E}}function h(m,b){return b>0?[...m,{null:!0,label:"Empty"}]:m}function a(m,b,C,M,P){const x=M&&M.buckets||[],E=P&&P.length>=x.length?P.subarray(0,x.length):new Uint32Array(x.length);if(E.fill(0),!m||!x.length)return E;const A=x.length-1,j=!!x[A]&&x[A].null===!0,$=b?b.length:C;if(M.kind==="boolean"){const I=B(m);for(let q=0;q<$;q++){const Z=I(b?b[q]:q);if(Z==null){j&&E[A]++;continue}E[Z?1:0]++}return E}if(M.kind==="category"){const I=new Map;for(let _=0;_<x.length;_++)!x[_].null&&!x[_].remainder&&I.set(x[_].value,_);const q=x.findIndex(_=>_.remainder),Z=B(m);for(let _=0;_<$;_++){const J=Z(b?b[_]:_);if(J==null||J===""){j&&E[A]++;continue}if(Array.isArray(J)){if(!J.length){j&&E[A]++;continue}for(const te of J){const ne=I.get(te);ne!==void 0?E[ne]++:q>=0&&E[q]++}continue}const ee=I.get(J);ee!==void 0?E[ee]++:q>=0&&E[q]++}return E}const z=j?x.length-1:x.length,T=new Float64Array(z+1);for(let I=0;I<z;I++)T[I]=x[I].from;T[z]=z?x[z-1].to:0;const R=S(m),O=L(m);for(let I=0;I<$;I++){const q=b?b[I]:I;if(O&&!O(q)){j&&E[A]++;continue}const Z=R(q);if(!Number.isFinite(Z)){j&&E[A]++;continue}const _=p(T,z,Z);_>=0&&E[_]++}return E}function p(m,b,C){if(!b||C<m[0])return-1;if(C>=m[b])return C===m[b]?b-1:-1;let M=0,P=b-1;for(;M<P;){const x=M+P+1>>>1;C>=m[x]?M=x:P=x-1}return M}function w(m,b,C,M={}){const P=M.bounds||u(m,M.boundsIndices??b,C,M);return{bounds:P,counts:a(m,b,C,P)}}const k=w}),xe("packages/core/src/compute/pivotmatrix.js",function(e,K){"use strict";Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return t}});const L=K("packages/core/src/compute/handle.js").valueComparator,F=K("packages/core/src/compute/total.js").total,Q=K("packages/core/src/compute/group.js").packKeys,G=K("packages/core/src/compute/pivot.js"),H=G.joinPath,U=G.DEFAULT_PATH_SEPARATOR,D=G.DEFAULT_MAX_COLUMNS,v="";function S(r,s,f={}){const u=f.separator||U,o=r||[],g=s instanceof Uint32Array?s:Uint32Array.from(s||[]),d=g.length;if(o.length===0)return{tuples:[[]],paths:[v],buckets:[g]};const{keyOf:h,readers:a}=Q(o,g,0),p=new Map,w=[],k=[],m=[];for(let E=0;E<d;E++){const A=g[E],j=h(A);let $=p.get(j);if($===void 0){$=w.length,p.set(j,$),k.push(j);const z=new Array(a.length);for(let T=0;T<a.length;T++)z[T]=a[T](A);w.push(z),m.push([])}m[$].push(A)}const b=L(f.locale),C=w.map((E,A)=>A);C.sort((E,A)=>{const j=w[E],$=w[A];for(let z=0;z<j.length;z++){const T=y(j[z],$[z],b);if(T!==0)return T}return E-A});const M=new Array(C.length),P=new Array(C.length),x=new Array(C.length);for(let E=0;E<C.length;E++){const A=C[E];M[E]=w[A],P[E]=H(w[A],u),x[E]=Uint32Array.from(m[A])}return{tuples:M,paths:P,buckets:x}}function y(r,s,f){const u=r==null,o=s==null;return u||o?u&&o?0:u?1:-1:f(r,s)}function l(r,s,f){const u=[];for(let o=0;o<r.length;o++)f.has(r[o])&&u.push(r[o]);return Uint32Array.from(u)}function c(r,s,f,u){return{value:s.length?F(r,s,f,u):null,leaves:s,count:s.length}}function i(r){const s=r&&r.opts||{},f=s.separator||U,u=s.totalContext||{locale:s.locale},o=(r.measures||[]).filter(P=>P&&P.handle),g=r.leaves instanceof Uint32Array?r.leaves:Uint32Array.from(r.leaves||[]),d=S(r.rowHandles||[],g,{...s,separator:f}),h=S(r.columnHandles||[],g,{...s,separator:f}),a=s.maxColumns===void 0?D:s.maxColumns,p=h.paths.length*Math.max(1,o.length),w=new Map;if(a&&p>a)return{rowAxis:d,columnAxis:h,measures:o.map(P=>({colId:P.colId,fn:P.fn})),body:w,rowMargin:w,columnMargin:w,grand:w,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 k=new Map,m=new Map,b=new Map,C=new Map,M=h.buckets.map(P=>new Set(P));for(let P=0;P<h.paths.length;P++){const x=h.buckets[P],E=h.paths[P];for(const A of o)b.set(t(E,A.colId),c(A.handle,x,A.fn,u))}for(let P=0;P<d.paths.length;P++){const x=d.buckets[P],E=d.paths[P];for(const A of o)m.set(t(E,A.colId),c(A.handle,x,A.fn,u));for(let A=0;A<h.paths.length;A++){const j=l(x,h.buckets[A],M[A]);if(j.length===0)continue;const $=h.paths[A];for(const z of o)k.set(n(E,$,z.colId),c(z.handle,j,z.fn,u))}}for(const P of o)C.set(P.colId,c(P.handle,g,P.fn,u));return{rowAxis:d,columnAxis:h,measures:o.map(P=>({colId:P.colId,fn:P.fn})),body:k,rowMargin:m,columnMargin:b,grand:C,columns:p,error:null}}function n(r,s,f){return`${r}\0${s}\0${f}`}function t(r,s){return`${r}\0${s}`}}),xe("packages/core/src/compute/reference.js",function(e,K){"use strict";Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return i}});const L=K("packages/core/src/internal/util.js").getPath,B=K("packages/core/src/compute/handle.js"),F=B.isMissing,W=B.valueComparator,G=K("packages/core/src/compute/filter.js").testValue,H="",U="\0";function D(r,s){const f=s.includes(".")?L(r,s):r?.[s];return f===void 0?null:f}function v(r,s,f={}){const u=s||[];let o=r.map((g,d)=>d);if(u.length===0)return o;for(let g=u.length-1;g>=0;g--)o=S(r,o,u[g],f);return o}function S(r,s,f,u){const o=f.locale!==void 0?f.locale:u.locale,g=W(o),d=f.descending!==void 0?!!f.descending:f.dir==="desc",h=[],a=[];for(const k of s){const m=D(r[k],f.col);F(m)?a.push(k):h.push(k)}const p=new Map;for(let k=0;k<h.length;k++)p.set(h[k],k);const w=(k,m)=>{const b=D(r[k],f.col),C=D(r[m],f.col);let M;return typeof f.compare=="function"?(M=f.compare(b,C,r[k],r[m],d),d&&(M=-M)):M=d?g(C,b):g(b,C),M!==0?M:p.get(k)-p.get(m)};return h.sort(w),f.nullsFirst?a.concat(h):h.concat(a)}function y(r,s,f={}){const u=[];for(let o=0;o<r.length;o++)l(r[o],s,f,o)&&u.push(o);return u}function l(r,s,f,u){if(!s)return!0;if(Array.isArray(s.conditions)){const o=s.conditions.filter(d=>d!=null);if(o.length===0)return!0;if(s.op==="or")return o.some(d=>l(r,d,f,u));const g=o.every(d=>l(r,d,f,u));return s.op==="not"?!g:g}return s.col===void 0&&typeof f.custom=="function"?!!f.custom(s,r,u):G(D(r,s.col),s,f.locale)}function c(r,s,f,u){const o=f||r.map((a,p)=>p),g=new Map,d=[],h=[];for(const a of o){const p=s.map((m,b)=>{const C=D(r[a],m);return u&&u[b]?u[b](C):C}),w=p.map(m=>m==null?U:String(m)).join(H);let k=g.get(w);k===void 0&&(k=d.length,g.set(w,k),d.push(p),h.push([])),h[k].push(a)}return{keys:d,buckets:h}}function i(r,s,f={}){const u=W(f.locale),o=r.filter(d=>!F(d)),g=o.map(n).filter(d=>d!==null);switch(s){case"count":return r.length;case"countValues":return o.length;case"sum":return g.reduce((d,h)=>d+h,0);case"avg":return o.length===0?null:g.reduce((d,h)=>d+h,0)/o.length;case"min":return o.length===0?null:o.reduce((d,h)=>u(h,d)<0?h:d);case"max":return o.length===0?null:o.reduce((d,h)=>u(h,d)>0?h:d);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}}),xe("packages/core/src/compute/index.js",function(e,K){"use strict";const X=K("packages/core/src/compute/sort.js");Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return X.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return X.sortMulti}}),Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return X.radixSortFloat64}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return X.radixSortInt32}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return X.rankSortDictionary}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return X.mergeSortComparator}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return X.collateStringRanks}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return X.rankSortStrings}});const L=K("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return L.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return L.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return L.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return L.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return L.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 F=K("packages/core/src/compute/group.js");Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return F.groupByColumns}}),Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return F.packKeys}});const W=K("packages/core/src/compute/facet.js");Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return W.facet}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return W.computeBounds}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return W.countInto}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return W.bucketOf}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return W.facetKind}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return W.cardinalityOf}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return W.pickGranularity}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return W.floorTo}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return W.advance}}),Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return W.STRATEGIES}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return W.GRANULARITIES}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return W.DEFAULT_BUCKETS}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return W.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return W.QUANTILE_SAMPLE}});const Q=K("packages/core/src/compute/total.js");Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return Q.TOTAL_FNS}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return Q.TOTAL_LABELS}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return Q.totalLabel}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return Q.total}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return Q.collectValues}});const G=K("packages/core/src/compute/pivot.js");Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return G.pivot}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return G.resolvePivotKeys}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return G.pivotKey}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return G.joinPath}}),Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return G.KEY_DELIMITER}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return G.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return G.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 U=K("packages/core/src/compute/reference.js");Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return U.referenceSort}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return U.referenceFilter}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return U.referenceGroup}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return U.referenceTotal}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return U.referencePasses}}),Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return U.referenceValue}});const D=K("packages/core/src/compute/handle.js");Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return D.identity}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return D.rowCount}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return D.presenceReader}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return D.bitReader}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return D.valueReader}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return D.valueComparator}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return D.numericTotalOrder}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return D.dictRanks}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return D.dictSize}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return D.dictValue}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return D.multiValue}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return D.isMissing}});const v=K("packages/core/src/compute/sketch.js");Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return v.Welford}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return v.Reservoir}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return v.HyperLogLog}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return v.SpaceSaving}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return v.KLL}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return v.hash32}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return v.SKETCH_BOUNDS}});const S=K("packages/core/src/compute/windowed.js");Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return S.Window}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return S.WINDOW_KINDS}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return S.openWindow}});const y=K("packages/core/src/compute/statistics.js");Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return y.MAINTENANCE}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return y.APPROXIMATE}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return y.maintenanceOf}});const 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 c=K("packages/core/src/compute/forecast.js");Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return c.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return c.forecast}})}),xe("packages/core/src/source/rows.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_ROW_HEIGHT",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"KEY_SEP",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"createRowFactory",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"RowFactory",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"pinnedRow",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"lazyRowView",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"groupPathElement",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"groupKey",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"groupPrefixKeys",{enumerable:!0,get:function(){return l}});const X=K("packages/core/src/internal/util.js"),L=X.warnOnce,B=X.isFunction,F=32,W="\0";function Q(c){return new G(c)}class G{#e;#t;constructor(i){this.#e=B(i&&i.rowKey)?i.rowKey:null;const n=i&&i.config?i.config.rowHeight:void 0;this.#t=typeof n=="number"||B(n)?n:F}get keyed(){return this.#e!==null}keyOf(i,n){if(this.#e){const t=this.#e(i);if(t!=null)return String(t)}else L("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(i){return B(this.#t)?Number(this.#t(i))||F:this.#t}leaf(i,n,t=0,r=null){const s={key:this.keyOf(i,n),data:i,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(i){const n={key:y(i.keyPath||i.path),data:null,level:i.level,parent:i.parent||null,children:[],group:!0,expanded:i.expanded!==!1,leafCount:i.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:i.column,groupValue:i.value,groupPath:i.path,hasChildren:i.hasChildren!==!1};return i.totals&&(n.totals=i.totals),n.height=this.heightOf(n),n}footer(i){const n={key:`${i.key}${W}footer`,data:null,level:i.level,parent:i,group:!0,footer:!0,expanded:!1,leafCount:i.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:i.groupColumn,groupValue:i.groupValue,groupPath:i.groupPath,hasChildren:!1,totals:i.totals};return n.height=this.heightOf(n),n}detail(i,n){return{key:`${i.key}${W}detail`,data:i.data,level:i.level+1,parent:i,group:!1,detail:!0,expanded:!1,leafCount:0,height:n,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:i.key}}grandTotal(i,n){const t={key:`${W}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:i};return t.height=this.heightOf(t),t}skeleton(i,n=0,t=!1){const r={key:`${W}pending${W}${i}`,data:null,level:n,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:i,selected:!1,physical:null,pending:!0};return t&&(r.loadError=!0),r.height=this.heightOf(r),r}}function H(c,i,n,t){return{key:`${W}pinned${W}${n}${W}${i}`,data:c,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:t,index:null,selected:!1,physical:null,hasChildren:!1,pinned:n}}function U(c,i){return new Proxy([],{get(n,t,r){if(t==="length")return c();if(typeof t=="string"){const s=Number(t);if(Number.isInteger(s)&&s>=0)return i(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<c()}return Reflect.has(n,t)}})}function D(c){return c==null?"":String(c)}const v="";function S(c){if(c==null)return v;const i=String(c);return i.startsWith(v)?v+i:i}function y(c){const i=c||[];let n="g";for(let t=0;t<i.length;t++)n+=W+S(i[t]);return n}function l(c){const i=new Array(c.length),n=[];for(let t=0;t<c.length;t++)n.push(c[t]),i[t]=y(n);return i}}),xe("packages/core/src/source/handles.js",function(e,K){"use strict";Object.defineProperty(e,"HandleProvider",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"createHandleProvider",{enumerable:!0,get:function(){return W}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce;class F{#e;#t;#n;#r=new Map;#o=0;constructor(G,H,U){this.#e=G,this.#t=H,this.#n=L(U)?U:()=>!1}get store(){const G=this.#e.store;return G&&L(G.column)?G:null}invalidate(){this.#o++}handle(G){const H=this.store;if(H){const S=H.column(G);if(S)return S}const U=this.#r.get(G);if(U&&U.builtAt===this.#o)return U.handle;const D=this.#i(G);if(!D)return;if(H&&this.#n()){B(`source.dropped.${G}`,`column "${G}" 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 v=this.#s(D);return this.#r.set(G,{handle:v,builtAt:this.#o}),v}#i(G){const H=this.#e.columns;return H&&L(H.get)?H.get(G):void 0}#s(G){const H=this.#t()||[],U=H.length,D=new Array(U),v=L(G.getValue)?y=>G.getValue(y):y=>y?.[G.field||G.id];for(let y=0;y<U;y++)D[y]=H[y]===void 0?void 0:v(H[y]);const S=this.#o;return{id:G.id,kind:"object",nullable:!1,values:D,presence:null,dict:null,offsets:null,get(y){return D[y]},version:S}}}function W(Q,G,H){return new F(Q,G,H)}}),xe("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 F}}),Object.defineProperty(e,"MAGNITUDE_LIMIT",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"isIncremental",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"RunningTotal",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const L=K("packages/core/src/store/columnstore.js").toFloat,B=Object.freeze(["sum","avg","countValues","min","max"]),F=Object.freeze(["float64"]),W=1e15;function Q(D,v){return typeof D!="string"||!B.includes(D)?!1:!!v&&F.includes(v.kind)}function G(D){if(D==null)return null;const v=L(D);return Number.isNaN(v)?null:v}class H{#e;#t=0;#n=0;#r=0;#o=1/0;#i=-1/0;#s=!1;#l=!1;constructor(v){this.#e=v}get valid(){return this.#s&&!this.#l}get fn(){return this.#e}seed(v){this.#a();for(let S=0;S<v.length;S++){const y=G(v[S]);y!==null&&this.#u(y)}this.#s=!0}seedColumn(v,S,y){this.#a();for(let l=0;l<y.length;l++){const c=y[l];if(S&&S(c)===0)continue;const i=v[c];Number.isNaN(i)||this.#u(i)}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(v){if(!Number.isFinite(v)){this.#l=!0;return}const S=this.#t+v;this.#n+=Math.abs(this.#t)>=Math.abs(v)?this.#t-S+v:v-S+this.#t,this.#t=S,this.#r++,v<this.#o&&(this.#o=v),v>this.#i&&(this.#i=v)}#c(v){const S=this.#t-v;this.#n+=Math.abs(this.#t)>=Math.abs(v)?this.#t-S-v:-v-S+this.#t,this.#t=S,this.#r--}update(v,S){if(!this.#s)return!1;const y=G(v),l=G(S);return y===null&&l===null?!0:y!==null&&!Number.isFinite(y)||l!==null&&!Number.isFinite(l)?!1:this.#e==="min"||this.#e==="max"?y===null||l===null?!1:this.#e==="min"?l<this.#o?(this.#o=l,!0):y>this.#o:l>this.#i?(this.#i=l,!0):y<this.#i:Math.abs(this.#t)>W?!1:(y!==null&&this.#c(y),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 U=H}),xe("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 F}}),Object.defineProperty(e,"warnWherePageRelative",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"warnWhereNotApplied",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"warnWhereOverThreshold",{enumerable:!0,get:function(){return D}}),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 f}}),Object.defineProperty(e,"relativeTokenHelp",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isResolvableRelative",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"resolveRelativeCondition",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"isGroup",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"forEachCondition",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"mapConditions",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"normaliseFilterSet",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"buildFilterSet",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"wireFilters",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"querySignature",{enumerable:!0,get:function(){return b}});const L=K("packages/core/src/internal/util.js").warnOnce,B="source.remote.hostFilter",F="source.where.pageRelative";function W(P,x){!Array.isArray(P)||!P.length||L(F,`filters.where (${P.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 Q(P){const x=(P||{}).config;!x||!x.hostFilter||L(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 G="source.where.notApplied";function H(P,x){L(`${G}:${P}`,`filters.where("${P}") 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 U="source.where.overThreshold";function D(P,x,E,A){!Array.isArray(P)||!P.length||L(`${U}:${x}`,`filters.where (${P.join(", ")}) is not applied to the ${x} pushdown source:`,E===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${E.toLocaleString()} rows, at or past the whereRowLimit of ${A.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 v=new Map;function S(P){let x=v.get(P);return x||(x=new Intl.DateTimeFormat("en-US",{timeZone:P,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),v.set(P,x)),x}function y(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function l(P,x){const E=S(x).formatToParts(new Date(P)),A={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const j of E)j.type==="year"?A.y=+j.value:j.type==="month"?A.m=+j.value:j.type==="day"?A.d=+j.value:j.type==="hour"?A.h=+j.value%24:j.type==="minute"?A.mi=+j.value:j.type==="second"&&(A.s=+j.value);return A}function c(P,x){const E=l(P,x);return Date.UTC(E.y,E.m-1,E.d,E.h,E.mi,E.s)-Math.floor(P/1e3)*1e3}function i(P,x,E,A){const j=Date.UTC(P,x-1,E),$=j-c(j,A);return j-c($,A)}function n(P,x,E){const A=new Date(Date.UTC(P.y,P.m-1,P.d+x));return i(A.getUTCFullYear(),A.getUTCMonth()+1,A.getUTCDate(),E)}const t=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function r(P,x){if(typeof P!="string")return null;const E=P.trim().toLowerCase().replace(/[\s_-]+/g,""),A=/^last(\d*|n)days?$/.exec(E);if(A){const j=A[1]==="n"?"":A[1],$=Number(j||x);return!Number.isFinite($)||$<=0?null:{kind:"lastNDays",n:Math.floor($)}}switch(E){case"today":return{kind:"today",n:0};case"yesterday":return{kind:"yesterday",n:0};case"thisweek":return{kind:"thisWeek",n:0};case"thismonth":return{kind:"thisMonth",n:0};case"thisquarter":return{kind:"thisQuarter",n:0};case"thisyear":return{kind:"thisYear",n:0};case"quartertodate":case"qtd":return{kind:"quarterToDate",n:0};case"yeartodate":case"ytd":return{kind:"yearToDate",n:0};default:return null}}function s(P,x={}){const E=r(P,x.n);if(!E)return null;const A=x.tz||y(),j=x.now instanceof Date?x.now.getTime():typeof x.now=="number"?x.now:Date.now(),$=l(j,A),z=i($.y,$.m,$.d,A),T=n($,1,A);let R=z,O=T;switch(E.kind){case"today":break;case"yesterday":R=n($,-1,A),O=z;break;case"lastNDays":O=x.includeToday?T:z,R=n($,x.includeToday?-(E.n-1):-E.n,A);break;case"thisWeek":{const I=Number.isFinite(x.weekStartsOn)?Number(x.weekStartsOn):1,Z=(new Date(Date.UTC($.y,$.m-1,$.d)).getUTCDay()-I+7)%7;R=n($,-Z,A),O=n($,-Z+7,A);break}case"thisMonth":R=i($.y,$.m,1,A),O=i($.m===12?$.y+1:$.y,$.m===12?1:$.m+1,1,A);break;case"thisQuarter":case"quarterToDate":{const I=Math.floor(($.m-1)/3)*3+1;R=i($.y,I,1,A),O=E.kind==="quarterToDate"?T:I===10?i($.y+1,1,1,A):i($.y,I+3,1,A);break}case"thisYear":case"yearToDate":R=i($.y,1,1,A),O=E.kind==="yearToDate"?T:i($.y+1,1,1,A);break;default:return null}return{from:new Date(R).toISOString(),to:new Date(O).toISOString(),bounds:"[)",tz:A,relative:E.kind==="lastNDays"?`last${E.n}Days`:E.kind,n:E.n}}function f(P){if(!P||typeof P!="object")return null;const x=P.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(P.op==="relative"&&typeof P.value=="string")return{token:P.value,n:void 0};const E=P.meta;return E&&typeof E.relative=="string"&&P.value===void 0?{token:E.relative,n:typeof E.n=="number"?E.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 o(P){const x=f(P);return x?r(x.token,x.n)!==null:!1}function g(P,x={}){const E=f(P);if(!E)return P;const A=s(E.token,{...x,n:E.n});return A?{...P,type:P.type||"date",op:"between",value:[A.from,A.to],bounds:P.bounds||A.bounds,meta:{...P.meta||{},relative:A.relative,tz:A.tz}}:(L(`source.relative.${E.token}`,`unknown relative date token "${E.token}"; sending the condition unresolved.`,u()),P)}function d(P){return!!P&&typeof P=="object"&&Array.isArray(P.conditions)}function h(P,x){if(P){if(d(P)){for(const E of P.conditions)h(E,x);return}x(P)}}function a(P,x){if(!P)return null;if(!d(P))return x(P);const E=P;let A=!1;const j=[];for(const $ of E.conditions){const z=a($,x);z!==$&&(A=!0),z&&j.push(z)}return!A&&j.length===E.conditions.length?P:j.length?{...E,conditions:j}:null}function p(P){if(!P)return null;if(!d(P))return P;const x=P,E=[];for(const A of x.conditions){const j=p(A);j&&E.push(j)}return E.length?{op:x.op,conditions:E}:null}function w(P){const x=p(P);return x?d(x)&&x.op==="and"?x:{op:"and",conditions:[x]}:null}function k(P){const x=(P||[]).filter(Boolean);return x.length?{op:"and",conditions:x}:null}function m(P,x={}){const E=a(P,A=>g(A,x));return w(E)}function b(P){const x=C(P.filters??null);return JSON.stringify([x,P.sort??null,P.quick??"",P.groupBy??null,P.pivotBy??null,M(P.context)])}function C(P){if(!P)return null;if(d(P)){const A=P;return{op:A.op,conditions:A.conditions.map(C)}}const x=P,E=x.meta&&typeof x.meta.relative=="string"?x.meta.relative:f(x)?.token;return{col:x.col,op:x.op,bounds:x.bounds??null,caseSensitive:x.caseSensitive??!1,value:E?`rel:${E}`:x.value??null}}function M(P){if(P==null)return null;try{return JSON.parse(JSON.stringify(P))}catch{return L("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),xe("packages/core/src/source/tree.js",function(e,K){"use strict";Object.defineProperty(e,"SYNTHETIC",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"buildFromPath",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"buildFromParentKey",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"assignLevels",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"resolveTree",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"buildTree",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return y}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,F="",W="\0tree:";function Q(l,c){return{physical:l,key:c,level:0,children:[],value:void 0}}function G(l,c){const i=[],n=new Map;for(let t=0;t<l.length;t++){const r=l[t],s=c.pathOf(r),f=Array.isArray(s)?s.map(o=>String(o)):[];if(!f.length){const o=Q(r,c.keyOf(r));i.push(o);continue}let u=null;for(let o=0;o<f.length;o++){const g=f.slice(0,o+1).join(F),d=o===f.length-1;let h=n.get(g);h&&d&&h.physical===-1&&(h.physical=r,h.key=c.keyOf(r)),h||(h=Q(d?r:-1,d?c.keyOf(r):W+g),h.level=o,h.value=f[o],n.set(g,h),u?u.children.push(h):i.push(h)),u=h}}return{roots:i,nodes:n}}function H(l,c){const i=new Map,n=[];for(let f=0;f<l.length;f++){const u=l[f],o=c.keyOf(u),g=Q(u,o);i.set(o,g);const d=c.parentOf(u);d!=null&&d!==""&&n.push({node:g,parent:String(d)})}let t=null;const r=new Map;for(const{node:f,parent:u}of n){const o=i.get(u);if(o){r.set(f.key,o);continue}c.orphans&&c.orphans!=="root"&&(t||(t=Q(-1,`${W}orphans`),t.value=c.orphans),r.set(f.key,t))}const s=[];for(const f of i.values()){const u=r.get(f.key);u?u.children.push(f):s.push(f)}return t&&t.children.length&&s.push(t),{roots:U(s,i,c.orphans,t),nodes:i}}function U(l,c,i,n){const t=new Set,r=[...l];for(;r.length;){const g=r.pop();if(!t.has(g.key)){t.add(g.key);for(const d of g.children)r.push(d)}}const s=[];for(const g of c.values())t.has(g.key)||s.push(g);if(!s.length)return l;const f=!!i&&i!=="root";B("tree.cycle",`tree.parentKey produced ${s.length} row(s) inside a parent cycle; `+(f?`they are shown under "${i}".`:"they are shown at the root."));for(const g of s)g.children=g.children.filter(d=>t.has(d.key));if(!f)return[...l,...s];let u=n;const o=[...l];return u||(u=Q(-1,`${W}orphans`),u.value=i,o.push(u)),u.children.push(...s),o}function D(l){let c=0;const i=(n,t)=>{for(const r of n)r.level=t,t>c&&(c=t),r.children.length&&i(r.children,t+1)};return i(l,0),c}function v(l,c){if(!l||typeof l!="object")return null;const i=l.path,n=l.parentKey,t=L(l.hasChildren)?r=>!!l.hasChildren(c.dataAt(r)):null;if(L(i))return{mode:"path",pathOf:r=>i(c.dataAt(r)),keyOf:c.keyOf,declaresChildren:t};if(n!=null){const r=L(n)?n:s=>s?.[n];return{mode:"parentKey",parentOf:s=>r(c.dataAt(s)),keyOf:c.keyOf,orphans:l.orphans||"root",declaresChildren:t}}return B("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function S(l,c){const i=c.mode==="path"?G(l,c):H(l,c),n=D(i.roots);return{...i,depth:n}}function y(l,c){const i=new Map,n=t=>{for(let r=0;r<t.length;r++){const s=t[r];if(s.physical>=0){const f=c?c(s.physical):!1,u=f&&s.children.length===0;i.set(s.physical,{level:s.level,posinset:r+1,setsize:t.length,hasChildren:s.children.length>0||f,lazy:u})}s.children.length&&n(s.children)}};return n(l),i}}),xe("packages/core/src/source/memory.js",function(e,K){"use strict";Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"quickMatcher",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"MemorySource",{enumerable:!0,get:function(){return T}});const X=K("packages/core/src/internal/util.js"),L=X.Lru,B=X.warnOnce,F=X.fail,W=X.isFunction,Q=X.defaultCompare,G=X.mergeRow,H=K("packages/core/src/source/rows.js"),U=H.createRowFactory,D=H.groupKey,v=H.groupPathElement,S=H.groupPrefixKeys,y=H.lazyRowView,c=K("packages/core/src/source/handles.js").createHandleProvider,i=K("packages/core/src/compute/incremental.js"),n=i.RunningTotal,t=i.isIncremental,s=K("packages/core/src/compute/handle.js").presenceReader,f=K("packages/core/src/source/filterwire.js"),u=f.querySignature,o=f.mapConditions,g=f.resolveRelativeCondition,d=K("packages/core/src/source/tree.js"),h=d.buildTree,a=d.resolveTree,p=d.indexTree,w=Object.freeze(["filter","sort","group","total","pivot","flatten"]),k=Object.freeze(["pipeline:sort","pipeline:sort:error"]);function m(R){const O=R&&typeof R=="object"?R.reason:null;return typeof O=="string"&&k.includes(O)}const b=Object.freeze([]);function C(R,O){if(!R)return null;const I=O==="grand"?R.grandTotal:R.groupTotal;return I??R.total}function M(R){return!!R&&!R.running}function P(R){if(R)return R.value&&W(R.value.compare)?R.value.compare:W(R.compare)?R.compare:void 0}function x(R){const O=R&&R.dataType;return!O||!W(O.items)?null:{items:O.items,type:R.itemType&&R.itemType.name||"text"}}function E(R){return!!R&&(typeof R=="object"||typeof R=="function")&&W(R.then)}const A=new Uint32Array(0),j=4096;function $(R,O){return new T(R,O)}function z(R,O){if(O==="regex")try{const I=new RegExp(R,"iu");return q=>I.test(q)}catch{return I=>I.includes(R)}if(O==="fuzzy"){const I=[...R].filter(q=>q!==" ");return I.length?q=>{let Z=0;for(let _=0;_<q.length&&Z<I.length;_++)q[_]===I[Z]&&Z++;return Z===I.length}:()=>!0}if(O==="words"){const I=R.split(/\s+/).filter(Boolean);return I.length?q=>I.every(Z=>q.includes(Z)):()=>!0}return I=>I.includes(R)}class T{mode="memory";#e;#t;#n;#r=!1;#o=null;#i;#s;#l=new Map;#a=!1;#u=0;#c=0;#d=new Map;#f=new Map;#h;#p=null;#m=T.#g();static#g(){return{slots:[],groupHeadings:b,unnumbered:b,pivot:null,inlineLeaves:null,matchCount:0,grand:null,grandLeaves:0,groupLeaves:null}}#y=new Map;#w=null;#k=new Map;#b=-1;#O=[];#j=new Map;#P=-1;#S=[];#M=null;#A=null;#E=null;#R=null;#L=null;#x=null;#I=null;#z=null;#$=Symbol("unset");#N=new Map;#H=null;get#B(){return this.#m.slots}set#B(O){this.#m.slots=O}get#W(){return this.#m.inlineLeaves}set#W(O){this.#m.inlineLeaves=O}get#ie(){return this.#m.groupHeadings}set#ie(O){this.#m.groupHeadings=O}get#re(){return this.#m.unnumbered}set#re(O){this.#m.unnumbered=O}get#le(){return this.#m.pivot}set#le(O){this.#m.pivot=O}constructor(O,I){this.#t=O||{mode:"memory"},this.#e=I||{};const q=this.#e.config||{};this.#n=this.#t.rows||q.rows||[],this.#i=U(this.#e),this.#s=c(this.#e,()=>this.#n,()=>this.#r),this.#h=new L(Number(q.rowCacheSize)||j);for(const Z of w)this.#l.set(Z,{key:null,result:null,id:0,computed:!1})}count(){this.#X();const O=this.#ue();return O?O.length:this.#B.length}#ue(){const O=Number(this.#V("pageSize",0))||0;if(O<=0)return null;const I=this.#B.length,q=Math.max(1,Math.ceil(I/O)),_=Math.min(Math.max(0,Number(this.#V("page",0))||0),q-1)*O;return{offset:_,length:Math.max(0,Math.min(O,I-_))}}pageInfo(){this.#X();const O=Number(this.#V("pageSize",0))||0,I=this.#B.length;if(O<=0)return{page:0,pageSize:0,total:I,pageCount:1};const q=Math.max(1,Math.ceil(I/O));return{page:Math.min(Math.max(0,Number(this.#V("page",0))||0),q-1),pageSize:O,total:I,pageCount:q}}totalCount(){return this.#Me().length}matchCount(){return this.#X(),this.#m.matchCount}at(O){this.#X();const I=this.#ue();if(I)return O<0||O>=I.length?void 0:this.#He(I.offset+O,O);if(!(O<0||O>=this.#B.length))return this.#He(O,O)}byKey(O){this.#X(),this.#p||this.#_();const I=this.#p.get(O);if(I!==void 0)return this.#Ne(I);for(let q=0;q<this.#B.length;q++){const Z=this.#B[q];if(typeof Z!="number"&&Z&&Z.key===O)return this.#He(q)}}loaded(O){return O>=0&&O<this.count()}hint(O,I){}display(){return this.#X(),this.#H||(this.#H=this.#xt()),this.#H}invalidateQuickText(){this.#N.clear(),this.invalidate("filter")}invalidate(O){const I=w.indexOf(O);I<0&&F(`unknown pipeline stage "${O}"; expected one of ${w.join(", ")}`);for(let q=I;q<w.length;q++){const Z=this.#l.get(w[q]);Z.key=null,Z.computed=!1}this.#H=null}apply(O){const I=[],q={added:[],updated:[],removed:[],rejected:I};if(!O)return q;let Z=!1;const _=new Set;if(O.remove&&O.remove.length)for(const J of O.remove){const ee=this.#D(J);if(ee===void 0){I.push({operation:"remove",id:this.#q(J),reason:"unknown-id"});continue}q.removed.push(this.#i.keyOf(this.#r?this.#$e(ee):this.#n[ee],ee)),this.#r||(this.#n[ee]=void 0),this.#h.delete(ee),this.#N.delete(ee),Z=!0}if(O.update&&O.update.length){const J=this.#k.size||this.#Te()?this.#st():null,ee=this.#j.size?this.#nt():null,te=ee&&ee.length?this.#st():null;for(const ne of O.update){const ie=this.#D(ne);if(ie===void 0){I.push({operation:"update",id:this.#te(ne),reason:"unknown-id"});continue}const ae=this.#r?this.#o&&this.#o.has(ie)?this.#o.get(ie):this.#$e(ie):this.#n[ie],re=G(ae,ne);for(const se of this.#Pe(ae,re))_.add(se);if(this.#r||(this.#n[ie]=re),J&&this.#Pt(J,ie,ae,re),te&&this.#Ge(ee,te,ie,ae,re),this.#p){const se=this.#i.keyOf(ae,ie),le=this.#i.keyOf(re,ie);se!==le&&(this.#p.delete(se),this.#p.set(le,ie))}this.#h.delete(ie),this.#N.delete(ie),q.updated.push(this.#Ne(ie))}}if(O.add&&O.add.length&&this.#r){typeof O.at=="number"&&O.at<this.#et()&&(this.#h.clear(),this.#N.clear()),this.#p=null;for(const J of O.add){const ee=this.#K(this.#te(J));ee!==void 0&&q.added.push(this.#Ne(ee))}Z=!0}else if(O.add&&O.add.length){const J=typeof O.at=="number"?O.at:this.#n.length,ee=this.#n.length;let te=O.add===this.#n?O.add.slice():O.add;if(this.#i.keyed){const ne=[];for(const ie of te){const ae=this.#te(ie);if(this.#D(ae)!==void 0){I.push({operation:"add",id:ae,reason:"duplicate-id"});continue}ne.push(ie)}ne.length!==te.length&&(te=ne)}if(!te.length)return q;if(J>=ee)for(let ne=0;ne<te.length;ne++)this.#n.push(te[ne]);else this.#n.splice(J,0,...te),this.#h.clear(),this.#N.clear();for(let ne=0;ne<te.length;ne++)q.added.push(this.#Ne(J>=ee?ee+ne:J+ne));Z=!0}return this.#u++,Z&&(this.#p=null,this.#ye()),this.#s.invalidate(),this.#H=null,Z||this.#me(_)?(this.#c++,this.invalidate("filter")):this.invalidate("total"),this.#qe("rows:changed",{companion:!0,added:q.added.length,updated:q.updated.length,removed:q.removed.length}),this.#o=null,q}groupHeadingsAt(O){this.#X();const I=this.#ie;if(!I.length||!Number.isInteger(O)||O<0)return b;let q=0,Z=I.length-1,_=-1;for(;q<=Z;){const ee=q+Z>>1;I[ee].at<=O?(_=ee,q=ee+1):Z=ee-1}if(_<0)return b;const J=[];for(let ee=I[_].row;ee;ee=ee.parent)J.push(ee);return J.reverse(),J}unnumberedRowCount(O){this.#X();const I=this.#re;if(!I.length||!Number.isInteger(O)||O<0)return 0;let q=0,Z=I.length-1,_=-1;for(;q<=Z;){const J=q+Z>>1;I[J].at<=O?(_=J,q=J+1):Z=J-1}return _+1}moveRow(O,I){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 q=this.#n;if(!Number.isInteger(O)||!Number.isInteger(I)||O<0||O>=q.length)return!1;const Z=Math.max(0,Math.min(q.length-1,I));if(Z===O)return!1;const[_]=q.splice(O,1);return q.splice(Z,0,_),this.#u++,this.#c++,this.#p=null,this.#h.clear(),this.#N.clear(),this.#ye(),this.#s.invalidate(),this.#H=null,this.invalidate("filter"),this.#qe("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(O){this.#he(),this.#u++,this.#c++,this.#p=null,this.#N.clear(),this.#h.clear(),this.#ye(),this.#s.invalidate(),this.invalidate("filter"),this.#qe("model:changed",{reason:"reload"})}destroy(){this.#he(),this.#h.clear(),this.#N.clear(),this.#p=null,this.#B=[],this.#W=null,this.#H=null,this.#ye();for(const O of w)this.#l.set(O,{key:null,result:null,id:0,computed:!1})}#he(){for(const{controller:O}of this.#y.values())try{O.abort()}catch{}this.#y.clear()}setRows(O){this.#n=O||[],this.#r=!1,this.#u++,this.#c++,this.#p=null,this.#N.clear(),this.#h.clear(),this.#ye(),this.#s.invalidate(),this.invalidate("filter")}notePriorRows(O){this.#o=O||null}releaseSource(){this.#r=!0,this.#n=[],this.#p=null,this.#h.clear(),this.#N.clear(),this.#s.invalidate()}data(){if(!this.#r)return this.#n;const O=this.#e.store;if(!O||!W(O.source))return this.#n;const I=O.physical||0,q=new Array(I);for(let Z=0;Z<I;Z++)q[Z]=O.live&&!O.live(Z)?void 0:O.source(Z);return q}#we(){const O=this.#V("detail",null);return!O||!W(O.isOpen)||O.inline===!1?null:O}#pe(){const O=(this.#e.config||{}).tree;return this.#$!==O&&(this.#$=O,this.#z=a(O,{dataAt:I=>this.#$e(I),keyOf:I=>this.#i.keyOf(this.#$e(I),I)})),this.#z}#be(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#be())return null;this.#X();const O=this.#m.grand;return O?this.#i.grandTotal(O,this.#C(this.#m.grandLeaves)):null}pivot(){return this.#X(),this.#le}pivotMatrix(){this.#X();const O=this.#m.groupLeaves,I=(this.#e.compute||{}).pivotMatrix;if(!W(I))return null;const q=this.#V("groupBy",[]),Z=this.#V("pivotBy",[]);if(!q.length&&!Z.length)return null;const _=this.#st().map(ee=>({colId:ee.id,handle:this.#s.handle(ee.id),fn:C(ee,"group")})).filter(ee=>ee.handle&&ee.fn),J=this.#e.config||{};return I({rowHandles:q.map(ee=>this.#s.handle(ee)).filter(Boolean),columnHandles:Z.map(ee=>this.#s.handle(ee)).filter(Boolean),measures:_,leaves:O||new Uint32Array(0),opts:{locale:J.locale,separator:(J.pivot||{}).separator,maxColumns:(J.pivot||{}).maxColumns}})}keysForLeaves(O){const I=[];if(!O)return I;for(let q=0;q<O.length;q++){const Z=this.#Ne(O[q]);Z&&Z.key!=null&&I.push(String(Z.key))}return I}leavesOf(O){this.#X();const I=this.#l.get("group"),q=I&&I.result;if(!q||!q.nodes)return[];const Z=q.nodes.get(O);if(!Z)return[];const _=[],J=ee=>{const te=ee.row&&ee.row.children;if(te&&te.length){for(const ne of te){const ie=q.nodes.get(ne.key);ie&&J(ie)}return}if(ee.leaves)for(let ne=0;ne<ee.leaves.length;ne++)_.push(this.#Ne(ee.leaves[ne]))};return J(Z),_}#q(O){return typeof O=="string"?O:this.#te(O)}#te(O){try{return this.#i.keyOf(O,-1)}catch{return"(unkeyed)"}}#D(O){if(typeof O=="string")return this.#K(O);if(this.#i.keyed){const q=this.#i.keyOf(O,-1),Z=this.#K(q);if(Z!==void 0)return Z}if(this.#r)return;const I=this.#n.indexOf(O);return I>=0?I:void 0}#K(O){return this.#p||this.#_(),this.#p.get(O)}#_(){this.#p=new Map;const O=this.#et(),I=this.#e.store,q=I&&W(I.live)?Z=>I.live(Z):null;for(let Z=0;Z<O;Z++){if(q&&!q(Z))continue;const _=this.#$e(Z);_!==void 0&&this.#p.set(this.#i.keyOf(_,Z),Z)}}#Pe(O,I){const q=[];for(const Z of this.#oe())this.#Ue(Z)&&this.#ne(Z,O,I,new Set)&&q.push(Z);return q}#ne(O,I,q,Z){if(Z.has(O))return!1;Z.add(O);const _=this.#Ue(O);if(!_)return!1;const J=_.value&&_.value.deps;return Array.isArray(J)&&J.length?J.some(ee=>this.#ne(String(ee),I,q,Z)):W(_.getValue)?!Object.is(_.getValue(I),_.getValue(q)):!1}#oe(){const O=new Set;for(const q of this.#V("sort",[]))O.add(q.col);for(const q of this.#V("groupBy",[]))O.add(q);const I=q=>{if(q){if(Array.isArray(q.conditions)){q.conditions.forEach(I);return}q.col&&O.add(q.col)}};return I(this.#V("filters",null)),[...O]}#me(O){if(!O.size)return!1;if(this.#V("quick",""))return!0;for(const I of this.#oe())if(O.has(I))return!0;return!1}#X(){if(!this.#a){this.#a=!0;try{this.#ke()}finally{this.#a=!1}}}pipelineRunning(){return this.#a}#ke(){const O=this.#Z("filter",()=>this.#de(),()=>this.#je()),I=this.#ce(O),q=this.#Z("group",()=>this.#Ie(),()=>this.#dt(I)),Z=this.#Z("total",()=>this.#We(),()=>this.#tt(q));this.#Z("pivot",()=>this.#Ve(),()=>this.#vt(q)),this.#Z("flatten",()=>this.#Ee(),()=>this.#Ct(q)),this.#Le(q,Z)}#ce(O){const I=this.#l.get("sort"),q=this.#v();if(I.computed&&I.key===q&&!this.#y.has("sort"))return I.result;const Z=this.#y.get("sort");return Z&&Z.key===q?I.result:I.result&&this.#G(O)?(this.#T(O,q),I.result):this.#Z("sort",()=>q,()=>this.#De(O))}#se(){if(this.#w===null){const O=this.#e.pipelineWorker,I=W(O)?O():null;this.#w=I||!1}return this.#w||null}#Ce(){const O=this.#V("sort",[]);if(!Array.isArray(O)||!O.length)return null;const I=(this.#e.config||{}).locale,q=[],Z=[];for(const _ of O){const J=this.#Ue(_.col);if(J&&J.running)continue;if(J&&J.value&&W(J.value.compare))return null;const ee=this.#s.handle(_.col);if(!ee)return null;q.push({col:_.col,descending:_.dir==="desc",nullsFirst:!!_.nullsFirst,locale:I}),Z.push(ee)}return q.length?{entries:q,handles:Z,locale:I}:null}#G(O){if(this.#fe())return!1;const I=this.#se();if(!I)return!1;const q=Number(I.threshold);return Number.isFinite(q)&&O.length<q?!1:!!this.#Ce()}#T(O,I){const q=this.#se(),Z=q&&this.#Ce();if(!Z){this.#Z("sort",()=>I,()=>this.#De(O));return}const _=new AbortController;this.#y.set("sort",{key:I,controller:_});const J=Z.entries.length===1?q.sortColumn(Z.handles[0],O,{descending:Z.entries[0].descending,nullsFirst:Z.entries[0].nullsFirst,locale:Z.locale,signal:_.signal,key:"sort"}):q.sortMulti(Z.handles,Z.entries.map((ee,te)=>({...ee,handle:Z.handles[te]})),O,{signal:_.signal,key:"sort"});if(!E(J)){this.#y.delete("sort"),this.#Z("sort",()=>I,()=>J);return}J.then(ee=>this.#U(I,ee),ee=>this.#ae("sort",I,ee))}#U(O,I){const q=this.#y.get("sort");if(!(!q||q.key!==O)){if(this.#v()!==O){this.#y.delete("sort");return}this.#y.delete("sort"),this.#Z("sort",()=>O,()=>I),this.#H=null,this.#X(),this.#qe("model:changed",{reason:k[0]})}}#ae(O,I,q){const Z=this.#y.get(O);if(!(!Z||Z.key!==I)&&(this.#y.delete(O),!(q&&q.name==="AbortError")&&O==="sort"&&this.#v()===I)){const _=this.#Z("filter",()=>this.#de(),()=>this.#je());this.#Z("sort",()=>I,()=>this.#De(_)),this.#H=null,this.#X(),B("source.pipeline.sort","off-thread sort failed; recomputed on the main thread.",q),this.#qe("model:changed",{reason:k[1]})}}#Le(O,I){const q=O&&O.leaves?O.leaves.length:this.#m.slots.length;this.#m.matchCount=q,this.#m.grand=I&&I.grand||null,this.#m.grandLeaves=O&&O.leaves?O.leaves.length:0,this.#m.groupLeaves=O&&O.leaves?O.leaves:null}#Z(O,I,q){const Z=this.#l.get(O),_=I();return Z.computed&&Z.key===_||(Z.result=q(),Z.key=_,Z.computed=!0,Z.id++,O==="flatten"&&(this.#H=null)),Z.result}#Y(O){return this.#l.get(O).id}#de(){const O=(this.#e.config||{}).hostFilter,I=O&&W(O.active)&&O.active()?1:0,q=this.#V("where",null),Z=q?q.version:0,_=this.#lt("filter.sig",`${this.#kt()}`,()=>u({filters:this.#V("filters",null),quick:this.#V("quick",""),quickMode:this.#V("quickMode","contains")}));return`${this.#c}|${_}|${I}|${Z}`}#v(){const O=this.#fe();return`${this.#Y("filter")}|${JSON.stringify(this.#V("sort",[]))}`+(O?`|manual:${O.version}`:"")}#fe(){const O=this.#V("rowOrder",null);return O&&Array.isArray(O.keys)?O:null}#Oe(O,I){this.#p||this.#_();const q=this.#p,Z=this.#et(),_=I.keys.length,J=new Float64Array(Z);for(let ee=0;ee<Z;ee++)J[ee]=_+ee;for(let ee=0;ee<_;ee++){const te=q.get(I.keys[ee]);te!==void 0&&(J[te]=ee)}return Uint32Array.from(O).sort((ee,te)=>J[ee]-J[te])}orderedKeys(){this.#p||this.#_();const O=this.#p,I=new Map;for(const[ee,te]of O)I.set(te,ee);const q=Uint32Array.from([...I.keys()]).sort(),Z=this.#fe(),_=Z?this.#Oe(q,Z):this.#De(q),J=new Array(_.length);for(let ee=0;ee<_.length;ee++)J[ee]=I.get(_[ee]);return J}#Ie(){return`${this.#Y("sort")}|${JSON.stringify(this.#V("groupBy",[]))}`}#We(){const O=this.#Je()?"f":"a",I=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#Y("group")}|${JSON.stringify(this.#V("totals",[]))}|${O}${I}|${this.#u}`}#Ve(){return`${this.#Y("group")}|${JSON.stringify(this.#V("pivotBy",[]))}`}#Ee(){const I=this.#Xe()||!this.#be()?this.#Y("total"):"x",q=`${this.#kt()}`,Z=this.#lt("flatten.keys",q,()=>{const J=this.#V("expanded",null);return J?[...J].sort().join(""):"*"}),_=this.#lt("flatten.detail",q,()=>{const J=this.#V("detail",null);return J&&W(J.signature)?J.signature():""});return`${I}|${this.#Y("pivot")}|${Z}|${_}`}#Xe(){const O=this.#V("groupBy",[]);return Array.isArray(O)&&O.length>0}stageState(){const O=[];for(const[I,q]of this.#l){const Z=q.result;O.push({stage:I,materialised:!!q.computed,bytes:Z&&typeof Z.byteLength=="number"?Z.byteLength:null,rows:Z&&typeof Z.length=="number"?Z.length:null,rebuilds:q.id})}return O}facetIndices(O){return this.#je(O||null)}facetRows(O){const I=this.facetIndices(O),q=[];for(let Z=0;Z<I.length;Z++){const _=this.#Ne(I[Z]);_&&q.push(_)}return q}invalidateRows(){this.#h.clear(),this.#N.clear(),this.#H=null}invalidateHandles(){this.#s.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#Me()}filteredIndices(){const O=this.#l.get("filter");if(O&&O.computed&&O.key===this.#de())return O.result||this.#Me();this.#X();const I=this.#l.get("filter");return(I&&I.computed?I.result:null)||this.#Me()}unfilteredRows(){const O=this.#Me(),I=[];for(let q=0;q<O.length;q++){const Z=this.#Ne(O[q]);Z&&I.push(Z)}return I}#je(O=null){const I=this.#Me(),q=this.#V("filters",null),Z=O?this.#Ke("pruneColumn")(q,O):q,_=this.#Et(Z),J=String(this.#V("quick","")||"").trim().toLowerCase(),ee=J?z(J,String(this.#V("quickMode","contains")||"contains")):null,te=(this.#e.config||{}).hostFilter,ne=!!(te&&W(te.active)&&te.active()),ie=this.#V("where",null),ae=!!(ie&&ie.active);if(!_&&!J&&!ne&&!ae)return I;let re=null;_&&(re=this.#Ke("evaluateFilters")(_,{handle:be=>this.#s.handle(be),count:this.#et(),pool:this.#e.pool,locale:(this.#e.config||{}).locale,itemwise:be=>x(this.#Ue(be))}));const se=new Uint32Array(I.length);let le=0;for(let fe=0;fe<I.length;fe++){const be=I[fe];if(!(re&&!re[be])&&!(ee&&!this.#ht(be,ee))){if(ne||ae){const Le=this.#Ne(be);if(ne&&!te.passes(Le)||ae&&!ie.passes(Le.data,Le.key))continue}se[le++]=be}}if(re){const fe=(this.#e.compute||{}).releaseMask;W(fe)&&fe({pool:this.#e.pool},re)}return se.subarray(0,le)}handleFor(O){return this.#s.handle(O)}#De(O){const I=this.#fe();if(I)return this.#Oe(O,I);const q=this.#V("sort",[]).filter(J=>{const ee=this.#Ue(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(!q.length)return O;const Z=(this.#e.config||{}).locale;if(q.length===1){const J=q[0],ee=this.#s.handle(J.col);if(!ee)return B(`source.sort.${J.col}`,`sort ignores unknown column "${J.col}".`),O;const te=this.#Ue(J.col);return this.#Ke("sortColumn")(ee,O,{descending:J.dir==="desc",nullsFirst:J.nullsFirst,locale:Z,compare:P(te)})}const _=[];for(const J of q){const ee=this.#s.handle(J.col);if(!ee){B(`source.sort.${J.col}`,`sort ignores unknown column "${J.col}".`);continue}_.push({handle:ee,descending:J.dir==="desc",nullsFirst:J.nullsFirst,locale:Z,compare:P(this.#Ue(J.col))})}return _.length?this.#Ke("sortMulti")(_.map(J=>J.handle),_,O):O}#dt(O){const I=this.#V("groupBy",[]),q=this.#pe();if(q&&!I.length){const fe=h(O,q);return this.#x=p(fe.roots,q.declaresChildren),{roots:null,leaves:O,nodes:new Map,tree:fe}}if(this.#x=null,q&&I.length&&B("tree.grouped","grouping is active on a grid configured with `tree`; the grouping wins and the hierarchy is not shown."),!I.length)return{roots:null,leaves:O,nodes:new Map};const Z=(this.#e.config||{}).timeZone,_=[],J=[];let ee=!1;for(const fe of I){const be=this.#s.handle(fe);if(!be){B(`source.group.${fe}`,`grouping ignores unknown column "${fe}".`);continue}_.push(be);const Le=this.#Ue(fe),we=Le&&Le.dataType;if(we&&W(we.groupProjector)){const Re=Le.typeOptions&&Le.typeOptions.timeZone||Le.timeZone||Z||void 0,ge=we.groupProjector(Le,Re);J.push(ge||null),ge&&(ee=!0)}else J.push(null)}if(!_.length)return{roots:null,leaves:O,nodes:new Map};const{keys:te,buckets:ne}=this.#Ke("groupByColumns")(_,O,{locale:(this.#e.config||{}).locale,project:ee?J:void 0}),ie=this.#V("pivotBy",[]).length>0,ae=[],re=new Map;for(let fe=0;fe<ne.length;fe++){const be=te[fe];let Le=null;const we=[];for(let Re=0;Re<be.length;Re++){we.push(v(be[Re]));const ge=D(we),he=Re===be.length-1;let Oe=re.get(ge);if(!Oe){const Ee=this.#i.group({path:[...we],column:I[Re],value:be[Re],level:Re,parent:Le,expanded:ie&&he?!1:this.#pt(ge,{key:ge,column:I[Re],value:be[Re],level:Re,path:[...we]}),hasChildren:!(ie&&he)});Oe={row:Ee,leaves:null},re.set(ge,Oe),Le?Le.children.push(Ee):ae.push(Ee)}Oe.row.leafCount+=ne[fe].length,Re===be.length-1&&(Oe.leaves=ne[fe]),Le=Oe.row}}const se=this.#V("sort",[])||[],le=(fe,be)=>{if(!fe||fe.length<2){if(fe)for(const ge of fe)le(ge.children,be+1);return}const Le=I[be],we=se.find(ge=>ge.col===Le),Re=we&&we.dir==="desc"?-1:1;fe.sort((ge,he)=>Re*Q(ge.groupValue,he.groupValue));for(const ge of fe)le(ge.children,be+1)};return le(ae,0),{roots:ae,leaves:O,nodes:re,keys:te,buckets:ne}}#_e(O,I){const q=new Map,Z=new Map,_=J=>{const ee=J.physical>=0?[J.physical]:[];for(const te of J.children)ee.push(..._(te));if(J.children.length){const te=this.#at(I,Uint32Array.from(ee),null);J.physical>=0?q.set(J.physical,te):Z.set(J.key,te)}return ee};for(const J of O.roots)_(J);return{byPhysical:q,byKey:Z}}#tt(O){const I=this.#st();if(!I.length)return this.#A=null,this.#E=null,{grand:null};const q={id:this.#Y("group"),columns:I.map(se=>se.id).join("")},Z=this.#A&&this.#A.id===q.id&&this.#A.columns===q.columns,_=this.#Te()&&Z?this.#M:null,J=_?I.filter(se=>_.has(se.id)):I,ee=Z?this.#E:null,te=this.#Je()?null:this.#ze(),ne=this.#ge(I),ie=se=>{const le=O.nodes.get(se.key);let fe=le&&le.leaves?le.leaves:null;if(se.children&&se.children.length){const we=se.children.map(ie);let Re=0;for(const Oe of we)Re+=Oe.length;const ge=new Uint32Array(Re);let he=0;for(const Oe of we)ge.set(Oe,he),he+=Oe.length;fe=ge}fe=fe||new Uint32Array(0);const be=te?te.get(se.key)||A:fe,Le=this.#ft(se,_?J:I,be,ne);return se.totals=_?{...se.totals,...Le}:Le,fe};if(O.roots&&J.length)for(const se of O.roots)ie(se);if(this.#I=O.tree?this.#_e(O.tree,I):null,this.#A=q,this.#M=this.#Te()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#O.length=0,this.#E=null,{grand:null};const re=te?this.#rt():O.leaves;return this.#E=this.#Q(I,re,_,ee),{grand:this.#E}}#Q(O,I,q,Z){const _={},J=this.#Y("group");J!==this.#b&&(this.#xe(),this.#b=J);const ee=this.#O;this.#O=[];for(const te of O){if(!M(te))continue;const ne=this.#s.handle(te.id);if(!ne)continue;const ie=C(te,"grand");if(!t(ie,ne)){if(q&&!q.has(te.id)&&Z&&te.id in Z){_[te.id]=Z[te.id];continue}_[te.id]=this.#at([te],I,null,"grand")[te.id];continue}let ae=this.#k.get(te.id);if((!ae||ae.fn!==ie)&&(ae=new n(ie),this.#k.set(te.id,ae)),ae.valid){let re=!0;for(const se of ee)if(se.colId===te.id&&!ae.update(se.before,se.after)){re=!1;break}if(re){_[te.id]=ae.value();continue}ae.invalidate()}ae.seedColumn(ne.values,s(ne),I),_[te.id]=ae.valid?ae.value():this.#at([te],I,null,"grand")[te.id]}return _}#ge(O){const I=this.#Y("group");I!==this.#P&&(this.#j.clear(),this.#P=I);const q=new Map;for(const _ of O){if(!M(_))continue;const J=this.#s.handle(_.id),ee=C(_,"group");t(ee,J)&&q.set(_.id,{fn:ee})}if(!q.size)return this.#S.length=0,q;const Z=this.#S;this.#S=[];for(const _ of Z){const{beforeKeys:J,afterKeys:ee,colDeltas:te}=_,ne=J.length?new Set(J):null,ie=ee.length?new Set(ee):null;for(const{colId:ae,before:re,after:se}of te)if(q.has(ae)){for(const le of J)ie&&ie.has(le)||this.#Ae(le,ae,re,null);for(const le of ee)ne&&ne.has(le)||this.#Ae(le,ae,null,se);for(const le of J)ie&&!ie.has(le)||this.#Ae(le,ae,re,se)}}return q}#Ae(O,I,q,Z){const _=this.#j.get(O),J=_&&_.get(I);!J||!J.valid||J.update(q,Z)||J.invalidate()}#ft(O,I,q,Z){if(!Z||!Z.size)return this.#at(I,q,O);const _={};let J=null,ee=this.#j.get(O.key);for(const te of I){const ne=Z.get(te.id);if(!ne){(J||(J=[])).push(te);continue}const ie=this.#s.handle(te.id);if(!ie)continue;ee||(ee=new Map,this.#j.set(O.key,ee));let ae=ee.get(te.id);if((!ae||ae.fn!==ne.fn)&&(ae=new n(ne.fn),ee.set(te.id,ae)),ae.valid||ae.seedColumn(ie.values,s(ie),q),ae.valid){_[te.id]=ae.value();continue}(J||(J=[])).push(te)}return J&&Object.assign(_,this.#at(J,q,O)),_}#Pt(O,I,q,Z){const _=!this.#Je()||this.#wt(I);for(const J of O){const ee=J.getValue;if(!W(ee))continue;const te=ee(q),ne=ee(Z);Object.is(te,ne)||(this.#M&&this.#M.add(J.id),_&&this.#k.has(J.id)&&this.#O.push({colId:J.id,before:te,after:ne}))}}#nt(){const O=this.#V("groupBy",[]),I=[];for(const q of O){const Z=this.#Ue(q);Z&&I.push(Z)}return I}#Qe(O,I){const q=new Array(O.length);for(let Z=0;Z<O.length;Z++){const _=O[Z].getValue;q[Z]=v(W(_)?_(I):void 0)}return q}#Ge(O,I,q,Z,_){if(this.#Je()&&!this.#wt(q))return;const J=S(this.#Qe(O,Z)),ee=S(this.#Qe(O,_)),te=J.length!==ee.length||J.some((ie,ae)=>ie!==ee[ae]),ne=[];for(const ie of I){const ae=ie.getValue;if(!W(ae))continue;const re=ae(Z),se=ae(_);!te&&Object.is(re,se)||ne.push({colId:ie.id,before:re,after:se})}!ne.length&&!te||this.#S.push({beforeKeys:J,afterKeys:ee,colDeltas:ne})}#wt(O){const I=this.#l.get("filter"),q=I&&I.computed?I.result:null;if(!q)return!0;let Z=0,_=q.length-1;for(;Z<=_;){const J=Z+_>>1,ee=q[J];if(ee===O)return!0;ee<O?Z=J+1:_=J-1}return!1}#Je(){return(this.#e.config||{}).totalFilteredOnly!==!1}#C(O){return this.#Je()?O:this.#rt().length}#rt(){return(!this.#R||this.#R.version!==this.#c)&&(this.#R={version:this.#c,indices:this.#Me()}),this.#R.indices}#ze(){const O=this.#V("groupBy",[]),I=`${this.#c}|${JSON.stringify(O)}`;if(this.#L&&this.#L.key===I)return this.#L.map;const q=new Map,Z=[];for(const _ of O){const J=this.#s.handle(_);J&&Z.push(J)}if(Z.length){const _=this.#rt(),{keys:J,buckets:ee}=this.#Ke("groupByColumns")(Z,_,{locale:(this.#e.config||{}).locale}),te=new Map;for(let ne=0;ne<ee.length;ne++){const ie=J[ne],ae=[];for(let re=0;re<ie.length;re++){ae.push(v(ie[re]));const se=D(ae);let le=te.get(se);le||(le=[],te.set(se,le));for(let fe=0;fe<ee[ne].length;fe++)le.push(ee[ne][fe])}}for(const[ne,ie]of te)q.set(ne,Uint32Array.from(ie))}return this.#L={key:I,map:q},q}#Te(){return!!(this.#e.config||{}).totalOnlyChangedColumns}#ye(){this.#xe(),this.#it(),this.#M=null,this.#A=null,this.#E=null}#xe(){this.#k.clear(),this.#O.length=0,this.#b=-1}#it(){this.#j.clear(),this.#S.length=0,this.#P=-1}#vt(O){const I=this.#V("pivotBy",[]);if(!I.length)return this.#le=null,null;const q=(this.#e.compute||{}).pivot;if(!W(q))return B("source.pivot.kernel","pivot requested but ctx.compute.pivot is not available; showing unpivoted rows."),this.#le=null,null;const Z=I.map(J=>this.#s.handle(J)).filter(Boolean),_=this.#st();return this.#le=q(Z,O.leaves,{groups:O.keys&&O.buckets?{keys:O.keys,buckets:O.buckets}:null,totals:_.map(J=>J.id),handle:J=>this.#s.handle(J),totalOf:J=>C(_.find(ee=>ee.id===J),"group"),separator:((this.#e.config||{}).pivot||{}).separator,maxColumns:((this.#e.config||{}).pivot||{}).maxColumns})||null,this.#le}#Ct(O){const I=this.#l.get("total").result,q=!!(this.#e.config||{}).groupFooter,Z=this.#we();if(O.tree)return this.#ot(O,I,Z);if(!O.roots&&!Z){if(I&&I.grand&&!this.#be()){const ie=this.#i.grandTotal(I.grand,this.#C(O.leaves.length));if(this.#W===O.leaves&&Array.isArray(this.#B))this.#B[this.#B.length-1]=ie;else{const ae=Array.from(O.leaves);ae.push(ie),this.#B=ae,this.#W=O.leaves}this.#re=[{at:this.#B.length-1}]}else this.#W=null,this.#B=O.leaves,this.#re=b;return this.#ie=b,this.#B}const _=[],J=[],ee=[],te=ie=>{if(_.push(ie),!Z)return;const ae=this.#Ne(ie);!ae||!Z.isOpen(ae.key)||(ae.master=!0,ae.expanded=!0,ee.push({at:_.length}),_.push(this.#i.detail(ae,Z.heightOf(ae))))};if(!O.roots){for(let ie=0;ie<O.leaves.length;ie++)te(O.leaves[ie]);return I&&I.grand&&!this.#be()&&(ee.push({at:_.length}),_.push(this.#i.grandTotal(I.grand,this.#C(O.leaves.length)))),this.#W=null,this.#ie=b,this.#re=ee.length?ee:b,this.#B=_,_}const ne=(ie,ae,re)=>{if(ie.expanded=ie.hasChildren===!1?!1:this.#pt(ie.key,{key:ie.key,column:ie.groupColumn,value:ie.groupValue,level:ie.level,path:ie.groupPath}),ie.posinset=ae+1,ie.setsize=re,J.push({at:_.length,row:ie}),ee.push({at:_.length}),_.push(ie),!!ie.expanded){if(ie.children&&ie.children.length)for(let se=0;se<ie.children.length;se++)ne(ie.children[se],se,ie.children.length);else{const se=O.nodes.get(ie.key),le=se&&se.leaves?se.leaves:null;if(le)for(let fe=0;fe<le.length;fe++)te(le[fe])}q&&ie.totals&&(ee.push({at:_.length}),_.push(this.#i.footer(ie)))}};for(let ie=0;ie<O.roots.length;ie++)ne(O.roots[ie],ie,O.roots.length);return I&&I.grand&&!this.#be()&&(ee.push({at:_.length}),_.push(this.#i.grandTotal(I.grand,this.#C(O.leaves.length)))),this.#ie=J,this.#re=ee,this.#B=_,_}#Me(){const O=this.#e.store;if(O&&W(O.liveIndices))return O.liveIndices();const I=new Uint32Array(this.#n.length);let q=0;for(let Z=0;Z<this.#n.length;Z++)this.#n[Z]!==void 0&&(I[q++]=Z);return I.subarray(0,q)}#et(){const O=this.#e.store;return O&&typeof O.physical=="number"?O.physical:this.#n.length}#$e(O){const I=this.#e.store;return I&&W(I.source)?I.source(O):this.#n[O]}#He(O,I=O){const q=this.#B[O];if(typeof q!="number")return q.index=I,q;const Z=this.#Ne(q);return Z.index=I,Z}#Ne(O){let I=this.#h.get(O);I||(I=this.#i.leaf(this.#$e(O),O),this.#h.set(O,I));const q=this.#x?this.#x.get(O):null;if(q){I.level=q.level,I.posinset=q.posinset,I.setsize=q.setsize,I.hasChildren=q.hasChildren,I.expanded=q.hasChildren&&!q.lazy&&this.#pt(I.key);const Z=this.#I?this.#I.byPhysical.get(O):void 0;Z?I.totals=Z:I.totals&&(I.totals=null)}else I.hasChildren&&(I.level=0,I.hasChildren=!1,I.expanded=!1,I.posinset=void 0,I.setsize=void 0);return I}#ot(O,I,q){const Z=[],_=[],J=te=>{if(te.leafCount!==void 0)return te.leafCount;let ne=te.physical>=0?1:0;for(const ie of te.children)ne+=J(ie);return te.leafCount=ne,ne},ee=te=>{const ne=this.#pt(te.key);if(te.physical>=0){if(Z.push(te.physical),q&&q.isOpen(this.#Ne(te.physical).key)){const ie=this.#Ne(te.physical);_.push({at:Z.length}),Z.push(this.#i.detail(ie,q.heightOf(ie)))}}else Z.push(this.#i.group({path:[te.key],column:null,value:te.value,level:te.level,parent:null,expanded:ne,hasChildren:te.children.length>0,leafCount:J(te),totals:this.#I?this.#I.byKey.get(te.key):void 0}));if(ne)for(const ie of te.children)ee(ie)};for(const te of O.tree.roots)ee(te);return I&&I.grand&&!this.#be()&&(_.push({at:Z.length}),Z.push(this.#i.grandTotal(I.grand,this.#C(O.leaves.length)))),this.#W=null,this.#ie=b,this.#re=_.length?_:b,this.#B=Z,Z}#xt(){return y(()=>this.count(),O=>this.at(O))}#ht(O,I){let q=this.#N.get(O);if(q===void 0){const Z=this.#$e(O),_=this.#ut(),J=[],ee=this.#e.columnHidden;for(const te of _){if(te.quickFilter===!1||W(ee)&&ee(te.id))continue;const ne=te.value&&W(te.value.quickFilterText)?te.value.quickFilterText({value:void 0,data:Z,row:null,column:te,colId:te.id,grid:null,context:this.#V("context",null)}):null,ie=ne??(W(te.formatValue)?te.formatValue(W(te.getValue)?te.getValue(Z):void 0):"");ie!=null&&ie!==""&&J.push(String(ie))}q=J.join(" ").toLowerCase(),this.#N.set(O,q)}return I(q)}#st(){const O=this.#V("totals",[]),I=O&&O.length?new Set(O):null;return this.#ut().filter(q=>I?I.has(q.id):!!(q.total||q.groupTotal||q.grandTotal))}#at(O,I,q,Z="group"){const _={},J=(this.#e.compute||{}).total;for(const ee of O){if(!M(ee))continue;const te=this.#s.handle(ee.id);if(!te)continue;const ne=C(ee,Z);if(ne)if(W(ne)){const ie=new Array(I.length);for(let ae=0;ae<I.length;ae++)ie[ae]=te.get(I[ae]);_[ee.id]=ne(ie,{row:q,column:ee,grid:this.#e.grid||null,context:this.#V("context",null),valueAt:(ae,re)=>{const se=this.#s.handle(ae);return se&&re>=0&&re<I.length?se.get(I[re]):null}})}else W(J)&&(_[ee.id]=J(te,I,ne))}return _}#Et(O){if(!O)return O;const I=this.#e.config||{},q={tz:I.timeZone,weekStartsOn:I.weekStartsOn};return o(O,Z=>{const _=g(Z,q);if(_&&_.type)return _;const J=this.#Ue(_&&_.col),ee=J&&(J.dataType?.base||J.type);return ee?{..._,type:ee}:_})}#pt(O,I){const q=this.#V("expanded",null);return q?W(q.has)?q.has(O,I):Array.prototype.includes.call(q,O):!0}#V(O,I){if(O==="context"||!W(this.#e.stateVersion))return this.#mt(O,I);const q=this.#Be(O),Z=this.#d.get(O);if(Z&&Z.version===q)return Z.value;const _=this.#mt(O,I);return this.#d.set(O,{version:q,value:_}),_}#mt(O,I){const q=this.#e.state;if(q&&W(q[O])){const Z=q[O]();return Z??I}return I}#kt(){const O=this.#e.stateVersion;return W(O)?O():0}#Tt(){const O=this.#e.columnsVersion,I=this.#e.permissionsVersion;return`${W(O)?O():0}|${W(I)?I():0}`}#Be(O){return O==="totals"?this.#Tt():`${this.#kt()}`}#lt(O,I,q){if(!W(this.#e.stateVersion))return q();const Z=this.#f.get(O);if(Z&&Z.version===I)return Z.key;const _=q();return this.#f.set(O,{version:I,key:_}),_}#Ke(O){const I=(this.#e.compute||{})[O];return W(I)||F(`ctx.compute.${O} is required by the memory source pipeline`),I}#ut(){const O=this.#e.columns;return O&&W(O.all)?O.all():[]}#Ue(O){const I=this.#e.columns;return I&&W(I.get)?I.get(O):void 0}#qe(O,I){const q=this.#e.emit;W(q)&&q(O,I)}}}),xe("packages/core/src/source/abort.js",function(e,K){"use strict";Object.defineProperty(e,"SupersededError",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"RequestToken",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"AbortScope",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createAbortScope",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"isAbortError",{enumerable:!0,get:function(){return W}});class X extends Error{constructor(G,H="superseded"){super(`[lattice] request ${G?`"${G}" `:""}${H}`),this.name="SupersededError",this.superseded=!0,this.key=G}}class L{#e;constructor(G,H,U,D){this.#e=G,this.key=H,this.controller=U,this.signal=U.signal,this.seq=D}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(G){this.signal.aborted||this.controller.abort(new X(this.key,G)),this.#e.settle(this)}}class B{#e=new Map;#t=0;begin(G="",H="superseded"){const U=this.#e.get(G);U&&!U.signal.aborted&&U.controller.abort(new X(G,H));const D=new L(this,G,new AbortController,++this.#t);return this.#e.set(G,D),D}tokenFor(G){return this.#e.get(G)}pending(G=""){const H=this.#e.get(G);return!!H&&!H.signal.aborted}get size(){return this.#e.size}settle(G){this.#e.get(G.key)===G&&this.#e.delete(G.key)}abort(G="",H="superseded"){const U=this.#e.get(G);U&&U.abort(H)}abortAll(G="superseded"){for(const H of[...this.#e.values()])H.abort(G);this.#e.clear()}}function F(){return new B}function W(Q){if(!Q||typeof Q!="object")return!1;const G=Q;return G.superseded===!0||G.name==="AbortError"||G.name==="SupersededError"}}),xe("packages/core/src/source/blockcache.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_PAGE_SIZE",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DEFAULT_MAX_CACHED_PAGES",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return F}});const X=100,L=32;class B{constructor(Q){this.id=Q,this.rows=null,this.state="pending",this.token=null,this.error=null}}class F{#e=new Map;#t;#n;#r=0;#o=-1;constructor(Q={}){this.#t=Math.max(1,Math.floor(Number(Q.pageSize)||X)),this.#n=Math.max(1,Math.floor(Number(Q.maxCachedPages)||L))}get pageSize(){return this.#t}get maxBlocks(){return this.#n}get size(){return this.#e.size}blockOf(Q){return Math.floor(Q/this.#t)}rangeOf(Q){return{start:Q*this.#t,end:(Q+1)*this.#t}}has(Q){return this.#e.has(Q)}pending(Q){const G=this.#e.get(Q);return!!G&&G.state==="pending"}loaded(Q){const G=this.#e.get(Q);return!!G&&G.state==="loaded"}begin(Q,G){let H=this.#e.get(Q);return H||(H=new B(Q)),H.state="pending",H.token=G,H.error=null,this.#i(Q,H),H}fill(Q,G){const H=this.#e.get(Q)||new B(Q);H.rows=G,H.state="loaded",H.token=null,this.#i(Q,H)}failed(Q,G){const H=this.#e.get(Q)||new B(Q);H.state="error",H.error=G,H.token=null,this.#i(Q,H)}delete(Q){return this.#e.delete(Q)}rowAt(Q){const G=this.blockOf(Q),H=this.#e.get(G);if(!(!H||H.state!=="loaded"||!H.rows))return this.#i(G,H),H.rows[Q-G*this.#t]}rowLoaded(Q){const G=this.blockOf(Q),H=this.#e.get(G);return!!H&&H.state==="loaded"&&!!H.rows&&Q-G*this.#t<H.rows.length}erroredAt(Q){const G=this.#e.get(this.blockOf(Q));return!!G&&G.state==="error"}loadedExtent(){let Q=0;for(const G of this.#e.values()){if(G.state!=="loaded"||!G.rows)continue;const H=G.id*this.#t+G.rows.length;H>Q&&(Q=H)}return Q}fillOf(Q){const G=this.#e.get(Q);return G&&G.state==="loaded"&&G.rows?G.rows.length:null}protect(Q,G){this.#r=this.blockOf(Math.max(0,Q)),this.#o=this.blockOf(Math.max(0,G))}evict(){const Q=[];if(this.#e.size<=this.#n)return Q;for(const[G,H]of this.#e){if(this.#e.size-Q.length<=this.#n)break;G>=this.#r&&G<=this.#o||H.state!=="pending"&&Q.push(G)}for(const G of Q)this.#e.delete(G);return Q}ids(){return[...this.#e.keys()]}clear(){this.#e.clear()}#i(Q,G){this.#e.delete(Q),this.#e.set(Q,G)}}}),xe("packages/core/src/source/pagewindow.js",function(e,K){"use strict";Object.defineProperty(e,"pageWindow",{enumerable:!0,get:function(){return X}});function X(L,B,F,W){const Q=Math.floor(Number(L)||0);if(Q<=0)return null;const G=Math.max(0,Math.floor(Number(B)||0)),H=Math.max(0,Math.floor(Number(F)||0));if(W){const U=Math.max(1,Math.ceil(H/Q)),D=Math.min(G,U-1),v=D*Q;return{page:D,pageSize:Q,offset:v,length:Math.max(0,Math.min(Q,H-v)),pageCount:U,total:H}}return{page:G,pageSize:Q,offset:G*Q,length:Q,pageCount:Math.max(G+2,Math.ceil(H/Q)),total:null}}}),xe("packages/core/src/source/paged.js",function(e,K){"use strict";Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PagedSource",{enumerable:!0,get:function(){return o}});const X=K("packages/core/src/internal/util.js"),L=X.Lru,B=X.isFunction,F=X.warnOnce,W=X.settleDebounce,Q=K("packages/core/src/source/abort.js"),G=Q.createAbortScope,H=Q.isAbortError,U=K("packages/core/src/source/blockcache.js"),D=U.BlockCache,v=U.DEFAULT_PAGE_SIZE,S=U.DEFAULT_MAX_CACHED_PAGES,l=K("packages/core/src/source/rows.js").createRowFactory,c=K("packages/core/src/source/filterwire.js"),i=c.wireFilters,n=c.querySignature,t=c.warnHostFilterNotApplied,s=K("packages/core/src/source/pagewindow.js").pageWindow,f=120;function u(g,d){return new o(g,d)}class o{mode="paged";#e;#t;#n;#r=G();#o;#i;#s=new Map;#l=null;#a=!1;#u=0;#c="";#d={start:0,end:0};#f;#h=!1;#p=0;#m="";constructor(d,h){this.#e=d||{mode:"paged"},this.#t=h||{},this.#n=new D({pageSize:this.#e.pageSize||v,maxCachedPages:this.#e.maxCachedPages||S}),this.#o=l(this.#t),this.#i=new L(this.#n.pageSize*4),this.#f=W((a,p)=>this.#k(a,p),f),this.#c=this.#S(),B(this.#e.fetch)||F("source.paged.fetch",'source.mode "paged" requires a fetch function; the grid will stay empty.'),t(this.#t)}count(){const d=this.#y();return d?d.length:this.#g()}#g(){if(this.#j(),this.#l!==null)return this.#l;const d=Math.max(this.#u,this.#n.loadedExtent());return this.#a?d:d+this.#n.pageSize}matchCount(){return this.#g()}totalCount(){return this.#g()}pageInfo(){const d=this.#y();if(!d){const h=this.#g();return{page:0,pageSize:0,total:this.exact()?h:null,pageCount:1,counting:!1}}return{page:d.page,pageSize:d.pageSize,total:d.total,pageCount:d.pageCount,counting:d.total===null&&this.#r.size>0&&this.#u===0&&this.#n.loadedExtent()===0}}#y(){const d=this.#g(),h=s(this.#A("pageSize",0),this.#A("page",0),d,this.exact());if(!h)return this.#m="",null;const a=`${this.#p}:${h.offset}:${h.length}`;if(a!==this.#m&&!this.#h&&(this.#m=a,h.length>0)){const p=h.offset+h.length-1;this.#d={start:h.offset,end:p},this.#k(h.offset,p)}return h}at(d){const h=this.#y();if(h){if(d<0||d>=h.length)return;const a=this.#w(h.offset+d);return a&&(a.index=d),a}return this.#w(d)}#w(d){if(d<0||d>=this.#g())return;const h=this.#i.get(d);if(h&&(h.data!==null||!this.#n.rowLoaded(d)))return h;const a=this.#n.rowAt(d);if(a===void 0){const w=this.#o.skeleton(d,0,this.#n.erroredAt(d));return this.#i.set(d,w),w}const p=this.#o.leaf(a,d);return p.index=d,this.#i.set(d,p),this.#s.set(p.key,d),p}byKey(d){const h=this.#s.get(d);return h===void 0?void 0:this.#w(h)}loaded(d){const h=this.#y();return h?d>=0&&d<h.length&&this.#n.rowLoaded(h.offset+d):this.#n.rowLoaded(d)}hint(d,h){if(this.#h)return;const a=this.#j();let p=Math.max(0,Math.floor(d)),w=Math.max(p,Math.floor(h));const k=this.#y();if(k){if(k.length===0)return;p=k.offset,w=k.offset+k.length-1}this.#d={start:p,end:w},this.#n.protect(p,w);for(const m of this.#n.evict())this.#O(m);this.#f(p,w),a&&this.#f.flush()}#k(d,h){if(this.#h)return;this.#n.protect(d,h);const a=this.#n.blockOf(d),p=this.#n.blockOf(h);for(let w=a;w<=p&&!(this.#l!==null&&w*this.#n.pageSize>=this.#l);w++)this.#n.has(w)||this.#b(w)}apply(d){const h={added:[],updated:[],removed:[]};if(!d)return h;if(d.update)for(const a of d.update){const p=this.#o.keyOf(a,-1),w=this.#s.get(p);if(w===void 0)continue;const k=this.#o.leaf(a,w);k.index=w,this.#i.set(w,k),h.updated.push(k)}return(d.add&&d.add.length||d.remove&&d.remove.length)&&this.reload(),h}reload(d){this.#P("reload"),this.#f.cancel(),this.hint(this.#d.start,this.#d.end)}destroy(){this.#h=!0,this.#f.cancel(),this.#r.abortAll("destroyed"),this.#n.clear(),this.#i.clear(),this.#s.clear()}exact(){return this.#l!==null||this.#a}pending(){return this.#r.size}async#b(d){if(!B(this.#e.fetch))return;const h=this.#r.begin(`block:${d}`);this.#n.begin(d,h);const{start:a,end:p}=this.#n.rangeOf(d),w=this.#c;try{const k=await this.#e.fetch({range:{start:a,end:p},sort:this.#A("sort",[]),filters:i(this.#A("filters",null),this.#M()),quick:this.#A("quick","")||void 0,context:this.#A("context",null),signal:h.signal});if(!h.current||w!==this.#c||this.#h)return;h.settle();const m=k&&k.rows||[];this.#n.fill(d,m);for(let C=0;C<m.length;C++)this.#i.delete(a+C);const b=k&&typeof k.total=="number"?k.total:k&&typeof k.count=="number"?k.count:null;b!==null?(this.#l=b,this.#a=!0):m.length<this.#n.pageSize?(this.#a=!0,this.#l=a+m.length):this.#u=Math.max(this.#u,a+m.length),this.#E("model:changed",{reason:"page",block:d,from:a,to:a+m.length}),this.#E("rows:changed",{companion:!0,reason:"page",block:d,from:a,to:a+m.length})}catch(k){if(h.settle(),H(k))return;this.#n.failed(d,k);for(let m=a;m<p;m++)this.#i.delete(m);this.#E("model:changed",{reason:"page-error",block:d,range:{start:a,end:p}}),this.#E("source:error",{error:k,block:d,range:{start:a,end:p}})}}#O(d){const{start:h,end:a}=this.#n.rangeOf(d);for(let p=h;p<a;p++){const w=this.#i.peek(p);w&&this.#s.delete(w.key),this.#i.delete(p)}}#j(){const d=this.#S();return d===this.#c?!1:(this.#c=d,this.#P("query"),!0)}#P(d){this.#r.abortAll(d),this.#n.clear(),this.#i.clear(),this.#s.clear(),this.#l=null,this.#a=!1,this.#u=0,this.#p++,this.#E("model:changed",{reason:d})}#S(){return n({filters:this.#A("filters",null),sort:this.#A("sort",[]),quick:this.#A("quick",""),context:this.#A("context",null)})}#M(){const d=this.#t.config||{};return{tz:d.timeZone,weekStartsOn:d.weekStartsOn}}#A(d,h){const a=this.#t.state;if(a&&B(a[d])){const p=a[d]();return p??h}return h}#E(d,h){const a=this.#t.emit;B(a)&&a(d,h)}}}),xe("packages/core/src/source/aggregates.js",function(e,K){"use strict";Object.defineProperty(e,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"pushableAggregates",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"fillAggregateSql",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"resolveAggregatesConfig",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"routeAggregate",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"resolveAggregatePlan",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"groupKeysPushable",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"pushdownDocRows",{enumerable:!0,get:function(){return U}});const X=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 L(){const D=new Set;for(const[v,S]of Object.entries(X))S.pushable&&D.add(v);return D}function B(D,v,S){let y=D.split("%c").join(v);return S!==void 0&&(y=y.split("%w").join(S)),y}function F(D){const v=D||{},S=v.default==="engine"||v.default==="engine-if-identical"?v.default:"client",y={};if(v.overrides&&typeof v.overrides=="object")for(const[l,c]of Object.entries(v.overrides))(c==="engine"||c==="client")&&(y[l]=c);return{default:S,overrides:y}}function W(D,v){const S=X[D];if(!S||!S.pushable)return"client";const y=v.overrides[D];return y==="engine"||y==="client"?y:v.default==="client"?"client":v.default==="engine-if-identical"?S.class==="identical"?"engine":"client":"engine"}function Q(D,v){const S=F(v),y=[],l=[];for(const c of D||[]){const i=X[c.fn],n=W(c.fn,S),t={id:c.id,col:c.col,fn:c.fn,class:i?i.class:"fallback"};c.weight!==void 0&&(t.weight=c.weight),c.params!==void 0&&(t.params=c.params),n==="engine"?y.push(t):(t.reason=i&&!i.pushable?i.note||"the engine cannot express this stat":"client by config",l.push(t))}return{engine:y,client:l,config:S}}const G=/^[A-Za-z_][A-Za-z0-9_$]*$/;function H(D,v=[]){return(D||[]).every(y=>{if(typeof y=="string")return G.test(y);if(!y||typeof y!="object")return!1;const l=y;return Array.isArray(v)&&v.includes(l.bucket)&&typeof l.col=="string"&&G.test(l.col)&&typeof l.size=="number"&&Number.isFinite(l.size)&&l.size>0})}function U(){return Object.entries(X).map(([D,v])=>({stat:D,class:v.class,sql:v.sql?B(v.sql,"col",v.twoColumn?"weight":void 0):"",note:v.note||(v.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),xe("packages/core/src/source/pushdown.js",function(e,K){"use strict";Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"LEAF_COUNT_ID",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"PIVOT_UNSUPPORTED",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"GROUP_UNSUPPORTED",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"UNGROUPED_LEVEL",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return R}});const X=K("packages/core/src/internal/util.js"),L=X.defaultCompare,B=X.isFunction,F=X.toArray,W=X.warnOnce,Q=K("packages/core/src/source/filterwire.js"),G=Q.isGroup,H=Q.warnWherePageRelative,U=Q.warnWhereOverThreshold,D=K("packages/core/src/source/aggregates.js"),v=D.resolveAggregatePlan,S=D.groupKeysPushable,y=D.STAT_PUSHDOWN,c=K("packages/core/src/source/abort.js").SupersededError;function i(O){const I=O&&O.signal;if(!I||!I.aborted)return;const q=I.reason;throw q instanceof Error?q:new c("","superseded before it was sent")}const n=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,pivot:!1,mutate:!1});function t(O){if(!O||typeof O!="object")return!1;const I=O.returning==="row"||O.returning==="key"?O.returning:"none";return{append:O.append===!0,update:O.update===!0,delete:O.delete===!0,returning:I}}function r(O,I){if(!O||typeof I!="string")return;if(!I.includes("."))return O[I];let q=O;for(const Z of I.split(".")){if(q===null||typeof q!="object")return;q=q[Z]}return q}function s(O){if(O===!0)return!0;if(!O||typeof O!="object")return!1;const I=O;return I.enabled===!1?!1:I.enabled===!0||B(I.commit)}function f(O){const I={...n,...O||{}};return I.operators=new Set(I.operators||[]),I.mutate=t(I.mutate),I}function u(O,I){return!O||!O.op||!I.operators.size?!1:I.operators.has(O.op)}function o(O,I){if(!O)return{pushed:null,residual:null};if(!I.filter)return{pushed:null,residual:O};if(I.filter==="term"){if(G(O)){const J=O.conditions||[];if(String(O.op)!=="and")return{pushed:null,residual:O};const ee=J.findIndex(ne=>!G(ne)&&u(ne,I));if(ee<0)return{pushed:null,residual:O};const te=J.filter((ne,ie)=>ie!==ee);return{pushed:J[ee],residual:te.length?{op:"and",conditions:te}:null}}return u(O,I)?{pushed:O,residual:null}:{pushed:null,residual:O}}if(!G(O))return u(O,I)?{pushed:O,residual:null}:{pushed:null,residual:O};if(String(O.op)!=="and")return(O.conditions||[]).every(ee=>G(ee)?o(ee,I).residual===null:u(ee,I))?{pushed:O,residual:null}:{pushed:null,residual:O};const q=[],Z=[];for(const J of O.conditions||[]){if(G(J)){if(I.filter==="flat"){Z.push(J);continue}const ee=o(J,I);ee.pushed&&q.push(ee.pushed),ee.residual&&Z.push(ee.residual);continue}(u(J,I)?q:Z).push(J)}const _=J=>J.length===0?null:J.length===1?J[0]:{op:"and",conditions:J};return{pushed:_(q),residual:_(Z)}}const g="__lattice_leaves";function d(O){return O.aggregates?O.aggregates instanceof Set?O.aggregates:new Set(F(O.aggregates)):new Set}function h(O){const I=d(O);return I.size?I.has("count")?O.filter!=="tree"||!O.operators||!O.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 a(O,I,q,Z,_,J,ee){const te=Array.isArray(O.groupBy)?O.groupBy:[],ne=Array.isArray(O.groupPath)?O.groupPath:[],ie=Array.isArray(O.groupValues)?O.groupValues:null;if(!I.group){const ae=h(I);if(ae)return ae}return S(te)?q.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":Z?_?J?"a host `where` predicate can only run in the browser, over rows the engine grouped":ee?"fullDataset holds the whole matching set, so the grid groups it itself":!ie||ie.length!==ne.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 p="pushdown:pivot-unsupported",w="pushdown:group-unsupported",k=Symbol("lattice.remote.ungroupedLevel");function m(O,I,q,Z,_,J){const ee=Array.isArray(O.pivotBy)?O.pivotBy:[],te=Array.isArray(O.groupBy)?O.groupBy:[],ne=Array.isArray(O.groupPath)?O.groupPath:[],ie=Array.isArray(O.groupValues)?O.groupValues:null;return I.pivot?S(ee)?te.length&&!S(te)?"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":Z?_?J?"a host `where` predicate can only run in the browser, over rows the engine pivoted":!ie||ie.length!==ne.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 b(O,I,q=!1){const Z=o(O.filters||null,I),_=[];Z.residual&&_.push("filter");const J=O.sort||[],ee=J.length===0||I.sort==="multi"&&J.length>=1||I.sort==="single"&&J.length===1;!ee&&J.length&&_.push("sort");const te=O.quick?String(O.quick):"",ne=!te||!!I.quick;ne||_.push("quick");const ie=O.where&&O.where.active?O.where:null;ie&&_.push("where");const ae={filters:Z.residual,sort:ee?null:J,quick:ne?"":te,where:ie},re=!!q,se=Array.isArray(O.groupBy)&&O.groupBy.length>0,le=se?a(O,I,Z,ee,ne,ie,re):"",fe=O.pivotMode!==!1&&Array.isArray(O.pivotBy)&&O.pivotBy.length>0,be=fe?m(O,I,Z,ee,ne,ie):"",Le=fe&&be==="";fe&&!Le&&_.push("pivot");const we=fe?Le&&se:se&&le==="";se&&!fe&&!we&&_.push("group");const Re=(we||Le)&&Array.isArray(O.groupValues)?O.groupValues.length:0,ge=we||fe?!1:re||!!(ae.filters||ae.sort||ae.quick||ae.where)||!I.range;return{pushed:{...O,filters:Z.pushed,sort:ee?J:[],quick:ne?te:"",range:ge?null:O.range},residual:ae,needsAll:ge,unpushed:_,full:re,grouped:we,groupLevel:Re,groupReason:fe?"":le,pivoted:Le,pivotReason:be}}function C(O){const I=Array.isArray(O.totals)?O.totals:[],q=O.totalFns&&typeof O.totalFns=="object"?O.totalFns:{},Z=[],_=[];for(const J of I){const ee=String(J),te=typeof q[ee]=="string"?q[ee]:null,ne=te?y[te]:null;te?!ne||!ne.pushable||!ne.sql?_.push({id:ee,fn:te,class:ne?ne.class:"fallback",reason:ne&&ne.note?ne.note:`the pushdown map cannot express "${te}"`}):ne.twoColumn?_.push({id:ee,fn:te,class:ne.class,reason:`"${te}" reduces two columns, and a grouped request carries no weight column`}):Z.push({id:ee,col:ee,fn:te,class:ne.class}):_.push({id:ee,fn:null,class:"fallback",reason:"the column totals with a host function, so there is no named statistic to push"})}return{engine:Z,client:_}}const M=Object.freeze({items:O=>O==null?[]:Array.isArray(O)?O:[O]});function P(O,I,q){if(!I)return O;let Z=O;if(I.filters&&B(q.evaluateFilters)){const _=Z,J={count:Z.length,handle:ne=>({id:ne,get:ie=>r(_[ie],ne)}),itemwise:ne=>_.some(ie=>Array.isArray(r(ie,ne)))?M:null},ee=q.evaluateFilters(I.filters,J),te=[];for(let ne=0;ne<Z.length;ne++)ee[ne]&&te.push(Z[ne]);Z=te}if(I.where&&I.where.active&&(I.whole||H(I.where.names,"pushdown"),Z=Z.filter(_=>I.where.passes(_))),I.quick){const _=I.quick.toLowerCase();Z=Z.filter(J=>{if(!J||typeof J!="object")return!1;for(const ee of Object.values(J))if(ee!=null&&String(ee).toLowerCase().includes(_))return!0;return!1})}if(I.sort&&I.sort.length&&B(q.sortMulti)){const _=[...new Set(I.sort.map(ne=>ne.col))],J=Z,ee=_.map(ne=>({id:ne,get:ie=>r(J[ie],ne)})),te=q.sortMulti(ee,I.sort.map(ne=>({col:ne.col,dir:ne.dir})),Uint32Array.from({length:Z.length},(ne,ie)=>ie),{});Z=Array.from(te,ne=>J[ne])}return Z}function x(O){return JSON.stringify({filters:O.filters||null,sort:O.sort||[],quick:O.quick||"",groupBy:O.groupBy||[],groupPath:O.groupPath||[],context:O.context??null})}function E(O){if(!O||typeof O!="object")return 16;let I="";try{I=JSON.stringify(O)}catch{return 200}return I.length*2+64}function A(O){const I=O||{};return{enabled:!!I.enabled,maxRows:Number.isFinite(I.maxRows)?I.maxRows:1e6,maxBytesEstimate:Number.isFinite(I.maxBytesEstimate)?I.maxBytesEstimate:512*1024*1024}}const j=5e4;function $(O){return Number.isFinite(O)&&O>=0?O:j}function z(O){return!!O&&B(O.then)}async function T(O){if(!O||O.total!==void 0||!z(O.pendingTotal))return O;const I=await O.pendingTotal,{pendingTotal:q,...Z}=O;return typeof I=="number"?{...Z,total:I}:Z}function R(O={}){const I=O.adapter;if(!I||!B(I.execute))return W("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{...O,mode:"remote",fetch:async()=>({rows:[],total:0})};const q=f(I.capabilities),Z=I.capabilities&&Object.getOwnPropertyDescriptor(I.capabilities,"operators");Z&&B(Z.get)&&Object.defineProperty(q,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(I.capabilities.operators||[]),set:()=>{}});const _=I.name||"adapter";let J=null;const ee=()=>B(I.ready)?(J||(J=Promise.resolve(I.ready()).then(()=>{Object.assign(q,f(I.capabilities))},Xe=>{throw J=null,Xe})),J):null,te=A(O.fullDataset),ne=!!O.allowPartialResults,ie=$(O.whereRowLimit);let ae=null;const re=O.aggregates;let se=null,le=null,fe=null,be=null,Le=null,we,Re=null,ge=0,he=null;const Oe=()=>!te.enabled||!se?null:(he!==se.key&&(ge++,he=se.key),{rows:se.rows,version:ge}),Ee=async Xe=>{const Ge=Xe.where&&Xe.where.active?Xe.where:null;if(!Ge)return{request:Xe,probe:null};const{where:ue,...pe}=Xe,ve=b(pe,q,te.enabled);if(ve.needsAll)return{request:Xe,probe:null};const Ue=x(ve.pushed);let Ve=null;return(!ae||ae.key!==Ue)&&(q.total?(i(Xe),Ve=await T(await I.execute(ve.pushed,Xe)),ae={key:Ue,size:Ve&&typeof Ve.total=="number"?Ve.total:null}):ae={key:Ue,size:null}),ae.size!==null&&ae.size<ie?{request:Xe,probe:null}:(U(Ge.names,_,ae.size,ie),{request:pe,probe:Ve})},Ie=async(Xe,Ge)=>{Re=null;const ue=C(Xe.pushed);fe={engine:ue.engine,client:ue.client,groupBy:Xe.pushed.groupBy},ue.client.length&&W(`source.pushdown.group.totals.${_}.${ue.client.map(Ue=>Ue.id).join(".")}`,`the ${_} adapter cannot compute the group subtotal for ${ue.client.map(Ue=>`"${Ue.id}" (${Ue.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 pe=await I.executeGroupLevel(Xe.pushed,ue.engine,Ge)||{};let ve=pe.rows||[];return!q.range&&Ge.range&&(ve=ve.slice(Ge.range.start,Ge.range.end)),Te(pe),pe.total===void 0?{rows:ve}:{rows:ve,total:pe.total}},ze=new Map,Ye=64,Qe=async(Xe,Ge)=>{Re=null;const ue=Xe.pushed,pe=ue.groupBy,ve=Array.isArray(ue.groupValues)?ue.groupValues:[],Ue=ve.length,Ve=[...ue.filters?[ue.filters]:[],...pe.slice(0,Ue).map((ct,pt)=>({col:ct,op:"eq",value:ve[pt]===void 0?null:ve[pt],caseSensitive:!0}))],nt=Ve.length===0?null:Ve.length===1?Ve[0]:{op:"and",conditions:Ve},ye=Ge.range?Ge.range.start:0;if(Ue>=pe.length){const ct={...ue,filters:nt,groupBy:[],groupPath:[],groupValues:[],totals:[],totalFns:{}},pt=await T(await I.execute(ct,Ge))||{};let jt=pt.rows||[];return!q.range&&Ge.range&&(jt=jt.slice(Ge.range.start,Ge.range.end)),typeof pt.total=="number"?{rows:jt,total:pt.total}:{rows:jt}}const ke=pe[Ue],Se=C(ue),Ae=d(q),Fe=Se.engine.filter(ct=>Ae.has(ct.fn)),me=[...Se.engine.filter(ct=>!Ae.has(ct.fn)).map(ct=>({id:ct.id,fn:ct.fn,class:ct.class,reason:`the ${_} adapter does not compute "${ct.fn}"`})),...Se.client];fe={engine:Fe,client:me,groupBy:pe},me.length&&W(`source.pushdown.group.totals.${_}.${me.map(ct=>ct.id).join(".")}`,`the ${_} adapter cannot compute the group subtotal for ${me.map(ct=>`"${ct.id}" (${ct.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 Me=[...Fe.map(ct=>({id:ct.id,col:ct.col,fn:ct.fn})),{id:g,col:ke,fn:"count"}],Pe={...ue,filters:nt,range:null},Ne=JSON.stringify([x(Pe),ve,ke,Me]);let De=ye>0?ze.get(Ne):void 0;if(!De){for(De=Promise.resolve(I.executeGroupedAggregates(Pe,[ke],Me)),ze.delete(Ne),ze.set(Ne,De);ze.size>Ye;)ze.delete(ze.keys().next().value);De.catch(()=>{ze.get(Ne)===De&&ze.delete(Ne)})}const qe=await De||[];i(Ge);const ot=ct=>{const pt={};for(const jt of Fe)pt[jt.id]=ct?ct[jt.id]:void 0;return pt},ut=(ue.sort||[]).find(ct=>ct&&ct.col===ke),dt=ut&&ut.dir==="desc"?-1:1,st=qe.filter(ct=>ct&&ct.level===1).map(ct=>({[ke]:ct.keys[0]===void 0?null:ct.keys[0],leafCount:Number(ct.values&&ct.values[g])||0,totals:ot(ct.values)})).sort((ct,pt)=>dt*L(ct[ke],pt[ke]));if(Ue===0){const ct=qe.find(jt=>jt&&jt.level===0),pt=ct?Number(ct.values&&ct.values[g]):NaN;Te({matchCount:Number.isFinite(pt)?pt:st.reduce((jt,He)=>jt+He.leafCount,0),...ct?{grand:ot(ct.values)}:{}})}const wt=Ge.range?Ge.range.end:st.length;return{rows:st.slice(ye,wt),total:st.length}},Te=Xe=>{typeof Xe.matchCount=="number"&&(be=Xe.matchCount,Le=Xe.grand?{totals:Xe.grand,leafCount:Xe.matchCount}:null,we===void 0&&B(I.unfilteredCount)&&(we=null,Promise.resolve(I.unfilteredCount()).then(Ge=>{we=typeof Ge=="number"?Ge:null}).catch(Ge=>{W(`source.pushdown.group.unfiltered.${_}`,`the ${_} adapter could not count the unfiltered set (${Ge&&Ge.message?Ge.message:Ge}), so "N of M" falls back to the display count for its denominator.`)})))},_e=async(Xe,Ge)=>{Re=null;const ue=C(Xe.pushed);fe={engine:ue.engine,client:ue.client,groupBy:Xe.pushed.groupBy,pivotBy:Xe.pushed.pivotBy},ue.client.length&&W(`source.pushdown.pivot.totals.${_}.${ue.client.map(nt=>nt.id).join(".")}`,`the ${_} adapter cannot compute the pivot cells for ${ue.client.map(nt=>`"${nt.id}" (${nt.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 pe=await I.executePivotLevel(Xe.pushed,ue.engine,Ge)||{};let ve=pe.rows||[];!q.range&&Ge.range&&(ve=ve.slice(Ge.range.start,Ge.range.end)),Te(pe);const Ue=pe.pivot&&typeof pe.pivot=="object"?pe.pivot:{},Ve={cells:Array.isArray(Ue.cells)?Ue.cells:[],...Array.isArray(Ue.axis)?{axis:Ue.axis}:{}};return pe.total===void 0?{rows:ve,pivot:Ve}:{rows:ve,total:pe.total,pivot:Ve}},Ke=Xe=>{W(`source.pushdown.pivot.${_}.${Xe}`,`pushdown:pivot-unsupported: the ${_} adapter cannot pivot this query because ${Xe}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);const Ge=new Error(`[lattice] ${p}: the ${_} adapter cannot pivot this query because ${Xe}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);throw Ge.code=p,Ge.reason=Xe,Ge},tt=(Xe,Ge)=>{const ue={key:Ge,state:"pending",value:null};return Re=ue,Xe.then(pe=>(Re===ue&&(Re={key:Ge,state:"settled",value:typeof pe=="number"?pe:null}),pe),pe=>{throw Re===ue&&(Re={key:Ge,state:"failed",value:null}),pe})},it=async Xe=>{const Ge=ee();Ge&&await Ge;const pe=Xe&&Xe.pivotMode!==!1&&Array.isArray(Xe.pivotBy)&&Xe.pivotBy.length>0?{request:Xe,probe:null}:await Ee(Xe);i(Xe);let ve=b(pe.request,q,te.enabled);if(q.group&&ve.grouped&&!ve.pivoted&&!B(I.executeGroupLevel)&&(W(`source.pushdown.group.method.${_}`,`the ${_} 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.`),ve=b(pe.request,{...q,group:!1,aggregates:null},te.enabled)),ve.pivoted&&!B(I.executePivotLevel)&&(ve=b(pe.request,{...q,pivot:!1},te.enabled),ve.pivotReason="the adapter declares the `pivot` capability but has no `executePivotLevel(query, aggregates, request)`"),ve.grouped&&!ve.pivoted&&!q.group&&!B(I.executeGroupedAggregates)&&(W(`source.pushdown.group.aggregates.method.${_}`,`the ${_} 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\`.`),ve=b(pe.request,{...q,aggregates:null},te.enabled)),le=ve,ve.pivoted)return _e(ve,Xe);if(ve.pivotReason&&Ke(ve.pivotReason),ve.grouped)return q.group?Ie(ve,Xe):Qe(ve,Xe);const Ve=!!ve.groupReason&&!ve.full;Ve?W(`source.pushdown.group-unsupported.${_}.${ve.groupReason}`,`pushdown:group-unsupported: the ${_} adapter was not asked to group this query because ${ve.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.`):ve.groupReason&&W(`source.pushdown.group.${_}.${ve.groupReason}`,`the ${_} adapter was not asked to group this query because ${ve.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 nt=Me=>Ve?{...Me,[k]:!0}:Me;if(!ve.needsAll){const Me=pe.probe||await I.execute(ve.pushed,Xe),Pe=Me.rows||[];return z(Me.pendingTotal)&&Me.total===void 0?nt({rows:Pe,pendingTotal:tt(Me.pendingTotal,x(ve.pushed))}):(Re=null,!q.total&&Me.total===void 0?nt({rows:Pe}):nt({rows:Pe,total:Me.total??Pe.length}))}ve.unpushed.length&&W(`source.pushdown.residual.${_}.${ve.unpushed.join(".")}`,`the ${_} adapter cannot push ${ve.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 ye=x(ve.pushed);if(!se||se.key!==ye){const Me=await T(await I.execute(ve.pushed,Xe));Re=null;const Pe=Me.rows||[];if(ve.full){const Ne=typeof Me.total=="number"?Math.max(Me.total,Pe.length):Pe.length;if(Ne>te.maxRows)throw new Error(`[lattice] fullDataset refused: the ${_} adapter's matching set is ${Ne.toLocaleString()} rows, past the configured maxRows of ${te.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 De=Pe.length*E(Pe[0]);if(De>te.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${_} adapter's matching set is an estimated ${Math.round(De/(1024*1024)).toLocaleString()} MB across ${Pe.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(te.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 Me.total=="number"&&Pe.length<Me.total){const Ne=!!(ve.residual.filters||ve.residual.quick||ve.residual.sort&&ve.residual.sort.length);if(Ne&&!ne)throw new Error(`[lattice] the ${_} adapter returned ${Pe.length} of ${Me.total} matching rows when asked for the whole result, and the query has residual ${ve.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.`);Ne?W(`source.pushdown.partial.residual.${_}`,`the ${_} adapter returned ${Pe.length} of ${Me.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.`):W(`source.pushdown.partial.${_}`,`the ${_} adapter returned ${Pe.length} of ${Me.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}se={key:ye,rows:Pe,total:typeof Me.total=="number"?Me.total:null}}let ke=ve;if(ve.residual.where){const Me=se.total??se.rows.length;if(Me>=ie){U(ve.residual.where.names,_,Me,ie);const{where:Pe,...Ne}=pe.request;ke=b(Ne,q,te.enabled),le=ke}}const Se=se.total!==null&&se.rows.length>=se.total,Ae=P(se.rows,{...ke.residual,whole:Se},O.compute||{}),Fe=Xe.range?Xe.range.start:0,me=Xe.range?Xe.range.end:Ae.length;return nt({rows:Ae.slice(Fe,me),total:Ae.length})},ht=async(Xe,Ge)=>{const ue=ee();ue&&await ue;const pe=b(Xe,q,te.enabled);le=pe;const ve=v(Ge,re),Ue=Array.isArray(Xe.groupBy)?Xe.groupBy:[],Ve=Ue.length>0,nt=!pe.residual.filters&&!pe.residual.quick,ye=!Ve||S(Ue,q.buckets);let ke=ve.engine,Se=ve.client;if(q.aggregates&&ke.length){const Me=q.aggregates instanceof Set?q.aggregates:new Set(F(q.aggregates)),Pe=ke.filter(Ne=>!Me.has(Ne.fn));Pe.length&&(ke=ke.filter(Ne=>Me.has(Ne.fn)),Se=[...Pe.map(Ne=>({...Ne,reason:`the ${_} adapter does not compute "${Ne.fn}"`})),...Se])}const Ae=Me=>{Se=[...ke.map(Pe=>({...Pe,reason:Me})),...Se],ke=[]};ke.length&&!nt?Ae(pe.residual.quick&&!pe.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)"):ke.length&&!ye&&Ae("a grouping key the engine cannot form forces all-client (no mixed provenance)");let Fe={},me;return ke.length&&(B(Ve?I.executeGroupedAggregates:I.executeAggregates)?Ve?me=await I.executeGroupedAggregates(pe.pushed,Ue,ke)||[]:Fe=await I.executeAggregates(pe.pushed,ke)||{}:(W(`source.pushdown.aggregates.${_}${Ve?".grouped":""}`,`the ${_} adapter cannot compute ${Ve?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),Ae(`adapter cannot compute ${Ve?"grouped ":""}aggregates`))),fe={engine:ke,client:Se,...Ve?{groupBy:Ue}:{}},{values:Fe,engine:ke,client:Se,...me!==void 0?{groups:me}:{}}},yt=s(O.edit),St=O.edit&&typeof O.edit=="object"&&B(O.edit.commit);let At=O.edit;if(yt&&!St)if(q.mutate&&q.mutate.update){const Xe=Ge=>{if(!q.mutate||!q.mutate.update)throw new Error(`[lattice] the ${_} 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 ue={kind:"update",key:String(Ge.key),patch:{[Ge.colId]:Ge.value}};return I.mutate(ue,Ge.request||{})};At={...O.edit===!0?{}:O.edit,commit:Xe}}else W(`source.pushdown.readonly.${_}`,`edit is enabled but the ${_} 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 Ct=yt&&q.mutate&&(q.mutate.append||q.mutate.delete)?{append:q.mutate.append===!0,remove:q.mutate.delete===!0,returning:q.mutate.returning,mutate:(Xe,Ge)=>I.mutate(Xe,Ge||{})}:null,Tt=async Xe=>{const Ge=ee();Ge&&await Ge;const{range:ue,signal:pe,export:ve,...Ue}=Xe||{},Ve={...Ue,groupBy:[],groupPath:[],groupValues:[],pivotBy:[],pivotMode:!1,totals:[]};return{plan:b(Ve,q,te.enabled),signal:pe}};async function*Dt(Xe,Ge={}){const{plan:ue,signal:pe}=await Tt(Xe),ve=Math.max(1,Math.floor(Number(Ge.pageSize))||5e3),Ue={signal:pe,stream:!0};if(!ue.needsAll)for(let ye=0;;ye+=ve){i(Ue);const ke=await I.execute({...ue.pushed,range:{start:ye,end:ye+ve}},Ue);ke&&z(ke.pendingTotal)&&ke.pendingTotal.then(null,()=>{});const Se=ke&&ke.rows||[];if(Se.length&&(yield Se),Se.length<ve)return}i(Ue);const Ve=await T(await I.execute({...ue.pushed,range:void 0},Ue)),nt=P(Ve&&Ve.rows||[],{...ue.residual,whole:!0},O.compute||{});for(let ye=0;ye<nt.length;ye+=ve)yield nt.slice(ye,ye+ve)}return{...O,edit:At,rowMutate:Ct,mode:"remote",fetch:it,aggregate:ht,countMatching:async Xe=>{const{plan:Ge,signal:ue}=await Tt(Xe);if(!Ge.needsAll&&q.total){i({signal:ue});const ve=await T(await I.execute({...Ge.pushed,range:{start:0,end:0}},{signal:ue}));if(ve&&typeof ve.total=="number")return ve.total}let pe=0;for await(const ve of Dt(Xe))pe+=ve.length;return pe},streamMatching:Dt,lastPlan:()=>le?{...le,...fe?{aggregates:fe}:{},...Re?{total:{deferred:!0,state:Re.state,value:Re.value}}:{}}:null,fullFrame:Oe,counts:()=>({match:be,total:we??null,pending:!!Re&&Re.state==="pending"}),grandTotals:()=>Le}}}),xe("packages/core/src/source/remote.js",function(e,K){"use strict";Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return E}});const X=K("packages/core/src/internal/util.js"),L=X.Lru,B=X.isFunction,F=X.warnOnce,W=X.settleDebounce,Q=K("packages/core/src/source/abort.js"),G=Q.createAbortScope,H=Q.isAbortError,U=K("packages/core/src/source/blockcache.js"),D=U.BlockCache,v=U.DEFAULT_PAGE_SIZE,S=U.DEFAULT_MAX_CACHED_PAGES,y=K("packages/core/src/source/rows.js"),l=y.createRowFactory,c=y.groupKey,i=K("packages/core/src/source/filterwire.js"),n=i.wireFilters,t=i.querySignature,r=i.warnHostFilterNotApplied,f=K("packages/core/src/source/pagewindow.js").pageWindow,o=K("packages/core/src/source/memory.js").MemorySource,d=K("packages/core/src/compute/handle.js").valueComparator,h=K("packages/core/src/compute/pivot.js"),a=h.pivotKey,p=h.joinPath,w=h.DEFAULT_PATH_SEPARATOR,m=K("packages/core/src/source/pushdown.js").UNGROUPED_LEVEL,b=1,C=120;function M(A,j,$){for(let z=0;z<Math.max(A.length,j.length);z++){const T=A[z],R=j[z],O=T==null,I=R==null;if(O||I){if(O&&I)continue;return O?1:-1}const q=$(T,R);if(q!==0)return q}return 0}function P(A,j){return new E(A,j)}class x{constructor(j,$,z,T){this.path=j,this.keyPath=T||j,this.values=[],this.level=$,this.key=c(this.keyPath),this.cache=new D(z),this.count=null,this.complete=!1,this.counting=!1,this.children=new Map,this.row=null,this.flat=!1}}class E{mode="remote";#e;#t;#n;#r;#o=new Map;#i=new Set;#s=G();#l;#a;#u=new Map;#c=[];#d=null;#f="";#h;#p=!1;#m=0;#g="";#y=null;#w=-1;constructor(j,$){this.#e=j||{mode:"remote"},this.#t=$||{},B(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#R(),this.unfilteredIndices=()=>this.#L(),this.handleFor=O=>this.#x(O),this.display=()=>this.#I(),this.grandTotalRow=()=>this.#$(),this.unfilteredRows=()=>this.#B(),this.facetIndices=O=>this.#z(O));const z=this.#e.counts;B(z)&&(this.matchCount=()=>this.#N("match"),this.totalCount=()=>this.#N("total"));const T=this.#e.grandTotals;B(T)&&(this.grandTotalRow=()=>this.#H());const R=this.#e;B(R.countMatching)&&B(R.streamMatching)&&(this.selectionQuery=()=>this.#W(),this.countMatching=O=>R.countMatching(O),this.streamMatching=(O,I)=>R.streamMatching(O,I),this.loadedRows=()=>this.#ie(),this.resident=()=>this.#A()!==null),this.#n={pageSize:this.#e.pageSize||v,maxCachedPages:this.#e.maxCachedPages||S},this.#l=l(this.#t),this.#a=new L(this.#n.pageSize*4),this.#h=W((O,I)=>this.#S(O,I),C),this.#r=new x([],0,this.#n),this.#o.set(this.#r.key,this.#r),this.#f=this.#me(),B(this.#e.fetch)||F("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#Ce()}count(){const j=this.#O();return j?j.length:this.#k()}#k(){const j=this.#A();return j?j.count():(this.#ne(),this.#q(this.#r))}#b(){if(this.#A())return!0;const j=$=>{if($.count===null&&!$.complete)return!1;for(const z of $.children.values())if(this.#X(z.key)&&!j(z))return!1;return!0};return j(this.#r)}pageInfo(){const j=this.#O(),$=this.totalPending();if(!j){const z=this.#k();return{page:0,pageSize:0,total:this.#b()?z:null,pageCount:1,counting:$}}return{page:j.page,pageSize:j.pageSize,total:j.total,pageCount:j.pageCount,counting:$||j.total===null&&this.#s.size>0&&this.#r.cache.loadedExtent()===0}}#O(){const j=this.#k(),$=f(this.#T("pageSize",0),this.#T("page",0),j,this.#b());if(!$)return this.#g="",null;const z=`${this.#m}:${$.offset}:${$.length}`;return z!==this.#g&&!this.#p&&(this.#g=z,$.length>0&&!this.#A()&&this.#S($.offset,$.offset+$.length-1)),$}at(j){const $=this.#O();if($){if(j<0||j>=$.length)return;const z=this.#j($.offset+j);return z&&(z.index=j),z}return this.#j(j)}#j(j){const $=this.#A();if($)return $.at(j);if(this.#ne(),j<0||j>=this.#k())return;const z=this.#D(this.#r,j);if(!z)return;const T=this.#K(z.node,z.local);return T&&(T.index=j),T||this.#l.skeleton(j,z.node.level,z.node.cache.erroredAt(z.local))}byKey(j){const $=this.#A();if($)return $.byKey(j);const z=this.#u.get(j);if(!z)return;const T=z.lastIndexOf(":"),R=this.#o.get(z.slice(0,T));return R&&this.#K(R,Number(z.slice(T+1)))||void 0}loaded(j){const $=this.#O();if($){if(j<0||j>=$.length)return!1;j+=$.offset}const z=this.#A();if(z)return z.loaded(j);if(j<0||j>=this.#k())return!1;const T=this.#D(this.#r,j);return!!T&&T.node.cache.rowLoaded(T.local)}hint(j,$){if(this.#p)return;const z=this.#ne();let T=Math.max(0,Math.floor(j)),R=Math.max(T,Math.floor($));const O=this.#O();if(O){if(O.length===0)return;T=O.offset,R=O.offset+O.length-1}for(const[I,q]of this.#P(T,R)){I.cache.protect(q.min,q.max);for(const Z of I.cache.evict())this.#Pe(I,Z)}this.#h(T,R),z&&this.#h.flush()}#P(j,$){const z=this.#k(),T=new Map;for(let R=j;R<=$&&R<z;R++){const O=this.#D(this.#r,R);if(!O)continue;const I=T.get(O.node);I?(I.min=Math.min(I.min,O.local),I.max=Math.max(I.max,O.local)):T.set(O.node,{min:O.local,max:O.local})}return T.size||T.set(this.#r,{min:j,max:j}),T}#S(j,$){if(!this.#p)for(const[z,T]of this.#P(j,$)){z.cache.protect(T.min,T.max);const R=z.cache.blockOf(T.min),O=z.cache.blockOf(T.max);for(let I=R;I<=O&&!(z.count!==null&&I*z.cache.pageSize>=z.count);I++)z.cache.has(I)||this.#le(z,I)}}apply(j){const $={added:[],updated:[],removed:[]};if(!j)return $;if(j.update)for(const z of j.update){const T=this.#u.get(this.#l.keyOf(z,-1));if(!T)continue;this.#a.delete(T);const R=T.lastIndexOf(":"),O=this.#o.get(T.slice(0,R));if(!O)continue;const I=Number(T.slice(R+1)),q=O.cache.blockOf(I);if(!O.cache.loaded(q))continue;const{start:Z}=O.cache.rangeOf(q),_=[];for(let ee=Z;ee<Z+O.cache.pageSize;ee++){const te=O.cache.rowAt(ee);if(te===void 0)break;_.push(ee===I?z:te)}O.cache.fill(q,_);const J=this.#K(O,I);J&&$.updated.push(J)}return(j.add&&j.add.length||j.remove&&j.remove.length)&&this.reload({keepExpanded:!0}),$}reload(j){this.#s.abortAll("reload"),this.#h.cancel(),j&&j.keepExpanded===!1&&this.#i.clear(),this.#oe(),this.#U("model:changed",{reason:"reload"})}destroy(){this.#p=!0,this.#h.cancel(),this.#s.abortAll("destroyed"),this.#oe(),this.#o.clear(),this.#i.clear(),this.#y&&B(this.#y.destroy)&&this.#y.destroy(),this.#y=null}expand(j){this.#i.has(j)||(this.#i.add(j),this.#U("group:toggled",{key:j,expanded:!0}),this.#U("model:changed",{reason:"expand",key:j}))}collapse(j){this.#i.delete(j)&&(this.#U("group:toggled",{key:j,expanded:!1}),this.#U("model:changed",{reason:"collapse",key:j}))}expandedKeys(){return[...this.#i]}pivotFields(){return this.#c}pivot(){this.#ne();const j=this.#d;if(!j||!j.keys.size||!this.#T("pivotBy",[]).length)return null;if(!j.result){const $=d((this.#t.config||{}).locale),z=[...j.keys.entries()].sort((R,O)=>M(R[1],O[1],$)),T=z.map(([R])=>R);j.result={keys:z.map(([,R])=>R),paths:T,fields:this.#pe(T),groupPaths:[],columns:T.length*Math.max(1,this.#ke().length),values:j.cells,cells:j.cells,error:null}}return j.result}invalidateHandles(){this.#y&&(B(this.#y.invalidateHandles)&&this.#y.invalidateHandles(),B(this.#y.invalidate)&&this.#y.invalidate("filter"))}#M(){const j=this.#e.fullFrame;return B(j)?j():null}#A(){const j=this.#M();return j?(this.#y||(this.#y=new o({mode:"memory"},this.#E())),j.version!==this.#w&&(this.#y.setRows(j.rows),this.#w=j.version),this.#y):null}#E(){const j=this.#t,$=j.state||{};return{...j,state:{...$,page:()=>0,pageSize:()=>0}}}#R(){const j=this.#A();return j?j.filteredIndices():new Uint32Array(0)}#L(){const j=this.#A();return j?j.unfilteredIndices():new Uint32Array(0)}#x(j){const $=this.#A();return $?$.handleFor(j):void 0}#I(){const j=this.#A();return j?j.display():[]}#z(j){const $=this.#A();return $&&B($.facetIndices)?$.facetIndices(j):new Uint32Array(0)}#$(){const j=this.#A();return j&&B(j.grandTotalRow)?j.grandTotalRow():null}#N(j){const $=this.#A();if($){const O=j==="match"?$.matchCount:$.totalCount;if(B(O))return O.call($)}const z=this.#e.counts,T=B(z)?z():null,R=T?T[j]:null;return typeof R=="number"?R:this.#k()}#H(){const j=this.#A();if(j&&B(j.grandTotalRow))return j.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const z=this.#e.grandTotals,T=B(z)?z():null;return!T||!T.totals?null:this.#l.grandTotal(T.totals,T.leafCount||0)}#B(){const j=this.#A();if(j&&B(j.unfilteredRows))return j.unfilteredRows();const $=[],z=this.count();for(let T=0;T<z;T++){const R=this.at(T);R&&$.push(R)}return $}#W(){const j=this.#T("quick",""),$={protocol:b,groupPath:[],groupValues:[],groupBy:[],totals:[],totalFns:{},pivotBy:[],pivotMode:!1,filters:n(this.#T("filters",null),this.#G()),sort:this.#T("sort",[]),context:this.#T("context",null)};j&&($.quick=j);const z=this.#T("where",null);return z&&z.active&&($.where=z),$}#ie(){const j=this.#T("groupBy",[]).length,$=[];for(const z of this.#o.values())if(!(z.level!==j&&!z.flat))for(const T of z.cache.ids()){if(!z.cache.loaded(T))continue;const{start:R,end:O}=z.cache.rangeOf(T);for(let I=R;I<O&&z.cache.rowLoaded(I);I++){const q=this.#K(z,I);q&&!q.group&&$.push(q)}}return $}#re(j,$,z){const{start:T,end:R}=j.cache.rangeOf($),O=this.#T("groupBy",[]),I=this.#T("pivotBy",[]),q=this.#T("quick",""),Z=this.#ke(),_={protocol:b,range:{start:T,end:R},groupPath:j.path,groupValues:j.values,groupBy:O,totals:Z,totalFns:this.#ce(Z),pivotBy:I,pivotMode:I.length>0,filters:n(this.#T("filters",null),this.#G()),sort:this.#T("sort",[]),context:this.#T("context",null),signal:z};q&&(_.quick=q);const J=this.#T("where",null);return J&&J.active&&(_.where=J),_}async#le(j,$){if(!B(this.#e.fetch))return;const z=this.#s.begin(`${j.key}:${$}`);j.cache.begin($,z);const T=this.#f,{start:R}=j.cache.rangeOf($);try{const O=await this.#e.fetch(this.#re(j,$,z.signal));if(!z.current||T!==this.#f||this.#p)return;z.settle();const I=O&&O.rows||[];if(!!(O&&O[m])&&!j.flat){j.flat=!0,j.children.clear();for(const[J,ee]of[...this.#u])ee.startsWith(`${j.key}:`)&&(this.#a.delete(ee),this.#u.delete(J))}j.cache.fill($,I);for(let J=0;J<I.length;J++)this.#a.delete(`${j.key}:${R+J}`);const Z=O&&typeof O.count=="number"?O.count:O&&typeof O.total=="number"?O.total:null,_=O&&B(O.pendingTotal?.then)?O.pendingTotal:null;Z!==null?(j.count=Z,j.complete=!0):I.length<j.cache.pageSize?(j.count=R+I.length,j.complete=!0):_&&(j.counting=!0),O&&Array.isArray(O.pivotFields)&&this.#he(O.pivotFields),O&&O.pivot&&typeof O.pivot=="object"&&this.#be(O.pivot),this.#U("model:changed",{reason:"page",groupPath:j.path,block:$}),this.#U("rows:changed",{companion:!0,reason:"page",groupPath:j.path,block:$}),_&&this.#ue(j,_,T)}catch(O){if(z.settle(),H(O))return;j.cache.failed($,O);const{end:I}=j.cache.rangeOf($);for(let q=R;q<I;q++)this.#a.delete(`${j.key}:${q}`);this.#U("model:changed",{reason:"page-error",groupPath:j.path,block:$}),this.#U("source:error",{error:O,groupPath:j.path,block:$})}}async#ue(j,$,z){let T;try{T=await $}catch(R){if(z!==this.#f||this.#p)return;j.counting=!1,H(R)||this.#U("source:error",{error:R,groupPath:j.path});return}z!==this.#f||this.#p||(j.counting=!1,typeof T=="number"&&(j.count=T,j.complete=!0,this.#U("source:total",{total:T,groupPath:j.path}),this.#U("model:changed",{reason:"total",count:T,groupPath:j.path})))}totalPending(){return this.#r.counting===!0}#he(j){j.length===this.#c.length&&j.every(($,z)=>$===this.#c[z])||(this.#c=j,this.#U("column:pivoted",{pivotFields:j,remote:!0}))}#we(){const j=this.#t.config||{};return j.pivot&&j.pivot.separator||w}#pe(j){const $=this.#we(),z=this.#ke();if(!z.length)return j.slice();const T=[];for(const R of j)for(const O of z)T.push(`${R}${$}${O}`);return T}#be(j){const $=this.#we();this.#d||(this.#d={keys:new Map,cells:new Map,result:null});const z=this.#d;let T=!1;const R=I=>{const q=Array.isArray(I)?I:[I],Z=p(q,$);return z.keys.has(Z)||(z.keys.set(Z,q),T=!0),Z},O=this.#T("groupBy",[]).length>0;for(const I of Array.isArray(j.axis)?j.axis:[])R(I);for(const I of Array.isArray(j.cells)?j.cells:[]){if(!I||typeof I!="object")continue;const q=R(I.pivot);if(O&&!(Array.isArray(I.group)&&I.group.length))continue;const Z=p(Array.isArray(I.group)?I.group:[],$);for(const[_,J]of Object.entries(I.values||{}))z.cells.set(a(Z,q,_),J)}z.result=null,T&&this.#he((this.pivot()||{fields:[]}).fields)}#q(j){let $=this.#te(j);for(const z of j.children.values())this.#X(z.key)&&($+=this.#q(z));return $}#te(j){if(j.count!==null)return j.count;const $=j.cache.loadedExtent();return j.complete?$:j.row&&j.row.leafCount>0?j.level>=this.#T("groupBy",[]).length?Math.max($,j.row.leafCount):$===0?1:Math.min($+j.cache.pageSize,Math.max($,j.row.leafCount)):$+j.cache.pageSize}#D(j,$){let z=$,T=0;const R=[...j.children.entries()].filter(([,I])=>this.#X(I.key)).sort((I,q)=>I[0]-q[0]);for(const[I,q]of R){const Z=I-T+1;if(z<Z)return{node:j,local:T+z};z-=Z,T=I+1;const _=this.#q(q);if(z<_)return this.#D(q,z);z-=_}const O=this.#te(j);return T+z<O?{node:j,local:T+z}:null}#K(j,$){const z=`${j.key}:${$}`,T=this.#a.get(z);if(T)return T;const R=j.cache.rowAt($);if(R===void 0)return null;const O=this.#T("groupBy",[]);let I;if(j.level<O.length&&!j.flat){const q=O[j.level],Z=this.#d!==null&&j.level===O.length-1&&this.#T("pivotBy",[]).length>0,_=this.#se(R,q),J=_==null,ee=[...j.path,J?"":String(_)],te=[...j.keyPath,J?null:String(_)];if(I=this.#l.group({path:ee,keyPath:te,column:q,value:_,level:j.level,parent:j.row,leafCount:Number(R.leafCount)||0,expanded:Z?!1:this.#X(c(te)),...Z?{hasChildren:!1}:{}}),I.totals=this.#_(R),I.data=R,!Z){let ne=this.#o.get(I.key);ne?ne.row=I:(ne=new x(ee,j.level+1,this.#n,te),ne.row=I,this.#o.set(ne.key,ne)),ne.values=[...j.values,_],j.children.set($,ne)}}else I=this.#l.leaf(R,$,j.level,j.row);return this.#a.set(z,I),this.#u.set(I.key,z),I}#_(j){const $=j||{};if($.totals&&typeof $.totals=="object")return $.totals;const z={};for(const T of this.#ke())Object.hasOwn($,T)&&(z[T]=$[T]);return z}#Pe(j,$){const{start:z,end:T}=j.cache.rangeOf($);for(let R=z;R<T;R++){const O=`${j.key}:${R}`,I=this.#a.peek(O);I&&this.#u.delete(I.key),this.#a.delete(O)}}#ne(){const j=this.#me();return j===this.#f?!1:(this.#f=j,this.#s.abortAll("query"),this.#oe(),this.#U("model:changed",{reason:"query"}),!0)}#oe(){for(const j of this.#o.values())j.cache.clear(),j.count=null,j.complete=!1,j.counting=!1,j.children.clear(),j.flat=!1;this.#a.clear(),this.#u.clear(),this.#m++,this.#d=null}#me(){const j=this.#T("where",null);return`${t({filters:this.#T("filters",null),sort:this.#T("sort",[]),quick:this.#T("quick",""),groupBy:this.#T("groupBy",[]),pivotBy:this.#T("pivotBy",[]),context:this.#T("context",null)})}|${j?j.version:0}`}#X(j){const $=this.#T("expanded",null);return $?B($.has)?$.has(j):Array.prototype.includes.call($,j):this.#i.has(j)}#ke(){const j=this.#T("totals",[]);if(j&&j.length)return[...j];const $=this.#t.columns;return!$||!B($.all)?[]:$.all().filter(z=>!!z.total).map(z=>z.id)}#ce(j){const $=this.#t.columns,z={};if(!$||!B($.get))return z;for(const T of j){const R=$.get(T);if(!R)continue;const O=R.groupTotal!=null?R.groupTotal:R.total;typeof O=="string"&&(z[T]=O)}return z}#se(j,$){const z=this.#t.columns,T=z&&B(z.get)?z.get($):void 0;return T&&B(T.getValue)?T.getValue(j):j?.[$]}#Ce(){r(this.#t)}#G(){const j=this.#t.config||{};return{tz:j.timeZone,weekStartsOn:j.weekStartsOn}}#T(j,$){const z=this.#t.state;if(z&&B(z[j])){const T=z[j]();return T??$}return $}#U(j,$){const z=this.#t.emit;B(z)&&z(j,$)}}}),xe("packages/core/src/source/gapbuffer.js",function(e,K){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return L}});const X=64;class L{#e;#t=0;#n=0;constructor(F=X){this.#e=new Uint32Array(Math.max(1,F)),this.#n=this.#e.length}static from(F,W=X){const Q=new L(F.length+Math.max(1,W));return Q.#e.set(F,0),Q.#t=F.length,Q.#n=Q.#e.length,Q}get length(){return this.#t+(this.#e.length-this.#n)}get capacity(){return this.#e.length}at(F){return F<0||F>=this.length?0:F<this.#t?this.#e[F]:this.#e[F+(this.#n-this.#t)]}insert(F,W){const Q=F<0?0:F>this.length?this.length:F;this.#r(Q),this.#t===this.#n&&this.#o(),this.#e[this.#t++]=W}push(F){this.insert(this.length,F)}removeAt(F){return!Number.isInteger(F)||F<0||F>=this.length?!1:(this.#r(F),this.#n++,!0)}toArray(){const F=new Uint32Array(this.length);return F.set(this.#e.subarray(0,this.#t),0),F.set(this.#e.subarray(this.#n),this.#t),F}clear(){this.#t=0,this.#n=this.#e.length}#r(F){if(F!==this.#t)if(F<this.#t){const W=this.#t-F;this.#e.copyWithin(this.#n-W,F,this.#t),this.#t=F,this.#n-=W}else{const W=F-this.#t;this.#e.copyWithin(this.#t,this.#n,this.#n+W),this.#t=F,this.#n+=W}}#o(){const F=this.#e.length-this.#n,W=new Uint32Array(Math.max(this.#e.length*2,this.#e.length+X));W.set(this.#e.subarray(0,this.#t),0),W.set(this.#e.subarray(this.#n),W.length-F),this.#e=W,this.#n=W.length-F}}}),xe("packages/core/src/store/ingest.js",function(e,K){"use strict";Object.defineProperty(e,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"inferKind",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"decideText",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"createReaders",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"Ingest",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return n}});const X=K("packages/core/src/internal/util.js"),L=X.now,B=X.nextFrame,F=X.infoOnce,W=X.warnOnce,Q=X.isFunction,G=X.pathGetter,U=K("packages/core/src/store/columnstore.js").ColumnStore,D=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function v(t,r={}){if(r.multi)return"multi";if(t.length===0)return"object";let s=0,f=0,u=0,o=0,g=0;for(let h=0;h<t.length;h++){const a=t[h];typeof a=="number"?s++:typeof a=="boolean"?f++:typeof a=="string"?u++:a instanceof Date?o++:Array.isArray(a)&&g++}const d=t.length;return s===d?"float64":f===d?"bitset":o===d?"float64":u===d?"text":g===d?"multi":"object"}function S(t,r,s){return r<=0||t<s*r?"dictionary":"object"}function y(t,r,s){const f=new Map,u=new Map;for(const b of t){if(b.computed)continue;const C=Q(b.read)?b.read:G(b.field||b.id);u.set(b.id,C),f.set(b.id,C)}const o=r?.order??[],g=r?.fns??{},d=r?.deps??{},h=r?.wrapDeps??null,a=o.filter(b=>Q(g[b])),p=a.some(b=>d[b]==="*");let w=new WeakMap;const k=b=>{const C={};if(p)for(const[M,P]of u)C[M]=P(b);for(const M of a){const P=d[M];let x;if(P==="*")x=C;else{x={};const E=P||[];for(let A=0;A<E.length;A++){const j=E[A];x[j]=j in C?C[j]:u.get(j)?.(b)}}C[M]=g[M](h?h(x,M):x,{data:b,row:null,column:null,grid:null,context:s})}return C},m=b=>{if(b===null||typeof b!="object"&&typeof b!="function")return k(b);let C=w.get(b);return C===void 0&&(C=k(b),w.set(b,C)),C};for(const b of a)f.set(b,C=>m(C)[b]);return{readers:f,reset(){w=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 c{#e;#t=[];#n=null;#r;#o=0;#i;#s=!1;#l=!1;#a=0;#u;constructor(r,s={},f={}){this.#e=Array.isArray(r)?r:Array.from(r||[]),this.#i={...D,...f};const u=s.columns??[];this.#r=y(u,s.computed??null,s.context),this.#u=this.#e.length>=this.#i.columnarBelow,this.#c(u,s.computed??null),this.#n=new U(this.#t.map(o=>({id:o.spec.id,kind:o.kind,nullable:o.nullable,read:o.read,dictionary:o.spec.dictionary})),{initialCapacity:this.#i.initialCapacity,columnarBelow:this.#i.columnarBelow})}get store(){return this.#n}get done(){return this.#s||this.#l}get progress(){return this.#o}slice(){if(this.done)return!1;if(this.#i.signal?.aborted)return this.#l=!0,!1;const r=L(),{chunkMs:s,chunkRows:f}=this.#i,u=this.#e.length;do{const o=Math.min(this.#o+f,u);this.#n.append(this.#e.slice(this.#o,o)),this.#d(this.#o,o),this.#o=o,this.#r.reset(),this.#h(!1)}while(this.#o<u&&L()-r<s);return this.#a+=L()-r,this.#i.onProgress?.({loaded:this.#o,total:u}),this.#o>=u?(this.#h(!0),this.#s=!0,!1):!0}cancel(){this.#l=!0}result(){return{store:this.#n,schema:this.#t.map(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.#f(r):null,change:r.change,reason:r.reason})),count:this.#n.count,elapsed:this.#a,cancelled:this.#l}}#c(r,s){const f=this.#e,u=Math.min(this.#i.sampleSize,f.length),o=this.#i.dictionaryRatio,g=s?.pure instanceof Set?s.pure:new Set(s?.pure??s?.order??[]);for(const d of r){if(!d||!d.id)continue;if(d.computed&&(d.pure===!1||s&&!g.has(d.id))){W(`ingest.impure.${d.id}`,`column "${d.id}" is an impure computed column and is not materialised into the store`);continue}const h=this.#r.readers.get(d.id)??(Q(d.read)?d.read:G(d.field||d.id)),a=new l(d,h);if(d.kind)a.kind=d.kind,a.reason="declared by the caller";else if(d.dictionary)a.kind=d.multi?"multi":"dictionary",a.reason="value table supplied (lookup column)";else{const p=[];for(let k=0;k<u&&p.length<this.#i.sampleSize;k++){const m=h(f[k]);m!=null&&p.push(m)}a.inferred=!0;const w=v(p,{multi:d.multi});if(w==="text"){const k=new Set(p).size;a.kind=S(k,p.length,o),a.candidate=this.#u,a.reason=`sampled ${k} distinct in ${p.length}`}else a.kind=w,a.reason=`inferred from ${p.length} sampled values`,w==="object"&&p.length&&F(`ingest.mixed.${d.id}`,`column "${d.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 f=this.#e;for(const u of this.#t){if(!u.candidate||!u.distinct)continue;const o=u.distinct;for(let g=r;g<s;g++){const d=u.read(f[g]);d!=null&&o.add(d)}}}#f(r){if(r.distinct)return r.distinct.size;const s=this.#n.column(r.spec.id);return s?.dict?s.dict.size:0}#h(r){const s=this.#i.dictionaryRatio,f=this.#e.length;for(const u of this.#t){if(!u.candidate)continue;const o=this.#f(u);if(u.kind==="dictionary"&&o>=s*f){const g=this.#n.column(u.spec.id);u.distinct=new Set(g?.dict?g.dict.values():[]),this.#n.convert(u.spec.id,"object"),u.kind="object",u.change="demoted",u.reason=`${o} distinct values is at or above ${s*100}% of ${f} rows`;continue}if(u.kind==="object"&&o>=s*f){u.candidate=!1,u.distinct=null,u.reason=`${o} distinct values is at or above ${s*100}% of ${f} rows`;continue}r&&u.kind==="object"&&o<s*f&&(this.#n.convert(u.spec.id,"dictionary"),u.kind="dictionary",u.change=u.change==="demoted"?null:"promoted",u.reason=`${o} distinct values is below ${s*100}% of ${f} rows`,u.distinct=null),r&&(u.candidate=!1)}}}async function i(t,r={},s={}){const f=new c(t,r,s),u=s.scheduler?.frame??B;for(;f.slice();)await new Promise(o=>{u(o)});return f.result()}function n(t,r={},s={}){const f=new c(t,r,{...s,chunkMs:1/0});for(;f.slice(););return f.result()}}),xe("packages/core/src/store/columnpack.js",function(e,K){"use strict";Object.defineProperty(e,"isPortableSchema",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"packChunk",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"packedTransfers",{enumerable:!0,get:function(){return c}});const L=K("packages/core/src/internal/util.js").pathGetter,B=K("packages/core/src/store/ingest.js"),F=B.inferKind,W=B.decideText,Q=B.INGEST_DEFAULTS,H=K("packages/core/src/store/columnstore.js").toFloat,U=new Set(["float64","int32","bitset","dictionary","object","multi"]);function D(i){if(!Array.isArray(i)||i.length===0)return!1;for(const n of i)if(!n||typeof n.id!="string"||typeof n.field!="string"||n.field===""||n.kind&&!U.has(n.kind))return!1;return!0}function v(i){const n=H(i);return Number.isFinite(n)?n|0:0}function S(i){return i==null?[]:Array.isArray(i)?i:[i]}function y(i,n,t,r){if(i.kind)return i.kind;const s=[];for(let o=0;o<n.length&&s.length<Q.sampleSize;o++){const g=n[o];g!=null&&s.push(g)}const f=F(s,{multi:i.multi});if(f!=="text")return f;const u=new Set(s).size;return W(u,s.length,r)}function l(i,n,t={}){const r=n.length|0,s=t.dictionaryRatio??Q.dictionaryRatio,f=[];for(const u of i){const o=L(u.field||u.id),g=u.nullable!==!1,d=new Array(r);for(let k=0;k<r;k++){const m=o(n[k]);d[k]=m===void 0?null:m}const h=y(u,d,r,s),a=g?new Uint8Array(r+7>>3):null,p=k=>{a&&(a[k>>3]|=1<<(k&7))};let w;switch(h){case"float64":{const k=new Float64Array(r);for(let m=0;m<r;m++){const b=d[m],C=b===null;C||p(m),k[m]=C?NaN:H(b)}w={id:u.id,kind:h,nullable:g,values:k,presence:a,offsets:null,table:null};break}case"int32":{const k=new Int32Array(r);for(let m=0;m<r;m++){const b=d[m],C=b===null;C||p(m),k[m]=C?0:v(b)}w={id:u.id,kind:h,nullable:g,values:k,presence:a,offsets:null,table:null};break}case"bitset":{const k=new Uint8Array(r+7>>3);for(let m=0;m<r;m++){const b=d[m],C=b===null;C||p(m),!C&&b&&(k[m>>3]|=1<<(m&7))}w={id:u.id,kind:h,nullable:g,values:k,presence:a,offsets:null,table:null};break}case"dictionary":{const k=new Uint32Array(r),m=[],b=new Map;for(let C=0;C<r;C++){const M=d[C];if(M===null){k[C]=0;continue}p(C);let P=b.get(M);P===void 0&&(P=m.length,m.push(M),b.set(M,P)),k[C]=P}w={id:u.id,kind:h,nullable:g,values:k,presence:a,offsets:null,table:m};break}case"multi":{const k=[],m=new Map,b=new Uint32Array(r+1),C=[];for(let M=0;M<r;M++){const P=d[M];b[M]=C.length,P===null||p(M);const E=S(P);for(let A=0;A<E.length;A++){const j=E[A];let $=m.get(j);$===void 0&&($=k.length,k.push(j),m.set(j,$)),C.push($)}}b[r]=C.length,w={id:u.id,kind:h,nullable:g,values:Int32Array.from(C),presence:a,offsets:b,table:k};break}default:{const k=new Array(r);for(let m=0;m<r;m++){const b=d[m];b!==null&&p(m),k[m]=b}w={id:u.id,kind:"object",nullable:g,values:k,presence:a,offsets:null,table:null};break}}f.push(w)}return{count:r,columns:f}}function c(i){const n=[];if(!i||!Array.isArray(i.columns))return n;const t=r=>{ArrayBuffer.isView(r)&&r.buffer&&!n.includes(r.buffer)&&n.push(r.buffer)};for(const r of i.columns)t(r.values),t(r.presence),t(r.offsets);return n}}),xe("packages/core/src/source/stream.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_PROMOTE_BELOW",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"StreamSource",{enumerable:!0,get:function(){return P}});const X=K("packages/core/src/internal/util.js"),L=X.Lru,B=X.isFunction,F=X.now,W=X.nextFrame,Q=X.cancelFrame,G=X.whenIdle,H=X.defaultCompare,U=X.warnOnce,D=X.infoOnce,v=X.getPath,S=K("packages/core/src/source/abort.js"),y=S.createAbortScope,l=S.isAbortError,c=K("packages/core/src/source/rows.js"),i=c.createRowFactory,n=c.lazyRowView,r=K("packages/core/src/source/gapbuffer.js").GapBuffer,f=K("packages/core/src/source/memory.js").createMemorySource,o=K("packages/core/src/source/filterwire.js").querySignature,d=K("packages/core/src/store/columnpack.js").isPortableSchema,h=25e4,a=Symbol("lattice.stream.storeBacked"),p=8,w=.1,k=1e3,m=50;function b(x){return Math.min(k,Math.max(m,Math.floor(x/4)))}function C(x){if(x instanceof Date)return x.getTime();if(typeof x=="number")return Number.isFinite(x)?x:NaN;if(typeof x=="string"){const E=x.trim();if(!E)return NaN;const A=Date.parse(E);return Number.isNaN(A)?Number(E):A}return NaN}function M(x,E){return new P(x,E)}class P{mode="stream";writesStore=!0;#e;#t;#n=[];#r=null;#o=[];#i=null;#s;#l;#a=new Map;#u=y();#c={loaded:0,estimated:void 0};#d=null;#f=0;#h=0;#p=0;#m=0;#g=null;#y=null;#w=null;#k=!1;#b=!1;#O=!1;#j=!1;#P="";#S=0;#M=0;#A=0;#E=null;#R=1/0;#L=!1;#x=null;#I=null;#z=null;#$=null;#N=!1;#H=0;#B=0;#W=!1;constructor(E,A){this.#e=E||{mode:"stream"},this.#t=A||{},this.#s=i(this.#t),this.#l=new L(4096),this.#P=this.#Q();const j=(this.#t.config||{}).ingest;this.#N=!!j&&j.retainSource===!1,B(this.#e.open)||U("source.stream.open",'source.mode "stream" requires an open function; the grid will stay empty.'),this.#e.autoStart!==!1&&queueMicrotask(()=>this.start());const $=Number(this.#e.poll);Number.isFinite($)&&$>0&&(this.#$=setInterval(()=>{this.#j||this.reload()},$),this.#$&&B(this.#$.unref)&&this.#$.unref()),this.#re()}#ie(){const E=Number(this.#e.maxAge);return Number.isFinite(E)&&E>0?E:0}#re(){const E=this.#ie();if(!E)return;const A=this.#e.ageBy;B(A)?this.#I=A:typeof A=="string"&&A?this.#I=j=>v(j,A):this.#I=null,this.#E=[],this.#x=setInterval(()=>{this.#j||this.#le()&&(this.#ce(),this.#fe())},b(E)),this.#x&&B(this.#x.unref)&&this.#x.unref()}#le(){const E=this.#ie();return!E||!this.#E?!1:this.#L?!0:this.#R<Date.now()-E*(1+w)}#ue(E,A){if(!this.#E)return;const j=this.#I?C(this.#I(A)):Date.now();this.#E[E]=j,Number.isNaN(j)||(j<this.#R&&(this.#R=j),j<Date.now()-this.#ie()&&(this.#L=!0))}#he(){return this.#ge("groupBy",[]).length>0?!0:!!this.#ge("pivotMode",!1)&&this.#ge("pivotBy",[]).length>0}#we(){if(this.#g||this.#j)return;const E=this.#he();if(E&&!this.#y){this.#y=f({mode:"memory",rows:this.#n},this.#pe()),this.#k=!1;return}!E&&this.#y&&(this.#y.destroy(),this.#y=null)}#pe(){if(this.#w)return this.#w;const E=this,A={liveIndices:()=>E.#be(),live:j=>E.#n[j]!==void 0,source:j=>E.#Ee(j),get physical(){return E.#n.length}};return this.#N&&(A.column=j=>{const $=E.#t.store;return $&&B($.column)?$.column(j):void 0}),this.#w=Object.create(this.#t,{store:{value:A,enumerable:!0,configurable:!0}}),this.#w}#be(){const E=new Uint32Array(this.#n.length);let A=0;for(let j=0;j<this.#n.length;j++)this.#n[j]!==void 0&&(E[A++]=j);return E.subarray(0,A)}#q(){return this.#g?this.#g:this.#y?(this.#k&&(this.#k=!1,this.#y.setRows(this.#n)),this.#y):null}invalidate(E="filter"){if(this.#g){this.#g.invalidate(E);return}this.#we(),this.#y&&this.#y.invalidate(E),(E==="filter"||E==="sort")&&this.#T()}count(){const E=this.#q();return E?E.count():this.#r?this.#r.length:this.#S}matchCount(){const E=this.#q();return E&&B(E.matchCount)?E.matchCount():this.#r?this.#r.length:this.#S}totalCount(){const E=this.#q();return E&&B(E.totalCount)?E.totalCount():this.#S}unfilteredRows(){const E=this.#q();if(E&&B(E.unfilteredRows))return E.unfilteredRows();const A=[];for(let j=0;j<this.#n.length;j++){if(!this.#n[j])continue;const $=this.#je(j);$&&A.push($)}return A}at(E){const A=this.#q();if(A)return A.at(E);if(E<0||E>=this.count())return;const j=this.#r?this.#r.at(E):E,$=this.#je(j);return $.index=E,$}byKey(E){const A=this.#q();if(A)return A.byKey(E);const j=this.#a.get(E);return j===void 0?void 0:this.#je(j)}leavesOf(E){const A=this.#q();return A&&B(A.leavesOf)?A.leavesOf(E):[]}loaded(E){return E>=0&&E<this.count()}hint(E,A){if(this.#g){this.#g.hint(E,A);return}this.#te(),this.#p=Math.max(0,Math.floor(E))}#te(){this.#j||this.#Q()===this.#P||this.reload()}display(){const E=this.#q();return E?E.display():n(()=>this.count(),A=>this.at(A))}apply(E){if(this.#g)return this.#g.apply(E);const A={added:[],updated:[],removed:[]};if(!E)return A;if(E.update){let j=!1;for(const $ of E.update){const z=this.#a.get(this.#s.keyOf($,-1));if(z===void 0)continue;const T=this.#Le(z);this.#N?this.#Xe(z,$):this.#n[z]=$,this.#l.delete(z),this.#Z(z,T),this.#E&&(this.#ue(z,$),j=!0),this.#k=!0,A.updated.push(this.#je(z))}j&&this.#ce()}if(E.add&&E.add.length){const j=this.#X(E.add);for(const $ of j)A.added.push(this.#je($))}return E.remove&&E.remove.length&&U("source.stream.remove","removing rows from a live stream is not supported; reload instead."),this.#fe(),A}reload(E){this.#u.abortAll("reload"),this.#tt(),this.#y&&(this.#y.destroy(),this.#y=null),this.#k=!1,this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear(),this.#g=null,this.#S=0,this.#M=0,this.#A=0,this.#E&&(this.#E=[]),this.#R=1/0,this.#L=!1,this.#b=!1,this.#O=!1,this.#c={loaded:0,estimated:void 0},this.#P=this.#Q(),this.#Ae("model:changed",{reason:"reload"}),this.start()}destroy(){this.#j=!0,this.#$!==null&&(clearInterval(this.#$),this.#$=null),this.#x!==null&&(clearInterval(this.#x),this.#x=null),this.#E=null,this.#u.abortAll("destroyed"),this.#tt(),this.#d!==null&&(this.#Ve(this.#d),this.#d=null),this.#y&&(this.#y.destroy(),this.#y=null),this.#g&&this.#g.destroy(),this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear()}async start(){if(this.#O||this.#j||!B(this.#e.open))return;this.#O=!0;const E=this.#u.begin("stream");this.#T(),this.#we();let A;try{A=this.#e.open({sort:this.#ge("sort",[]),filters:this.#ge("filters",null),quick:this.#ge("quick","")||void 0,context:this.#ge("context",null),signal:E.signal})}catch($){this.#Ae("source:error",{error:$});return}const j=B(A[Symbol.asyncIterator])?A[Symbol.asyncIterator]():A[Symbol.iterator]();this.#z=j;try{for(;;){const $=await j.next();if(!E.current||this.#j)return;if($.done){this.#v();return}if(await this.#D($.value,E),!E.current||this.#j)return;if($.value&&$.value.done){this.#v();return}if(await this.#Oe(),!E.current||this.#j)return}}catch($){if(l($))return;this.#Ae("source:error",{error:$})}finally{E.settle()}}progress(){return{loaded:this.#c.loaded,estimated:this.#c.estimated,done:this.#b,live:this.#S,evicted:this.#M}}promoted(){return this.#g!==null}memorySource(){return this.#g}invalidateHandles(){const E=this.#q();E&&(B(E.invalidateHandles)&&E.invalidateHandles(),B(E.invalidate)&&E.invalidate("sort"))}renderCount(){return this.#f}ingestStats(){return{worker:this.#H,inline:this.#B,storeBacked:this.#N}}#D(E,A){if(!E)return;const j=E.rows;if(j&&j.length&&this.#_(j))return this.#ne(E,A);const $=F();j&&j.length&&(this.#X(j),this.#B++),this.#K(E),this.#h+=F()-$,this.#fe()}#K(E){this.#c.loaded=E.progress&&typeof E.progress.loaded=="number"?E.progress.loaded:this.#n.length,E.progress&&typeof E.progress.estimated=="number"&&(this.#c.estimated=E.progress.estimated)}#_(E){if(this.#W||this.#g)return!1;const A=this.#oe();if(!A)return!1;const j=this.#t.store;if(!j||!B(j.appendPacked))return!1;const $=this.#me();return!$||!d($)?(this.#W=!0,D("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):E.length<A.threshold?!1:!this.#Pe(E)}#Pe(E){if(!this.#s.keyed)return!1;const A=new Set;for(let j=0;j<E.length;j++){const $=this.#s.keyOf(E[j],this.#n.length+j);if($!=null){if(A.has($)||this.#a.has($))return!0;A.add($)}}return!1}async#ne(E,A){const j=E.rows,$=this.#oe(),z=this.#me();let T;try{T=await $.columnize(z,j,{key:"ingest:stream",signal:A&&A.signal})}catch(Z){if(l(Z)||(U("source.stream.columnize","worker columnization failed; columnizing on the main thread",Z),this.#W=!0,A&&(!A.current||this.#j)))return;this.#X(j),this.#B++,this.#K(E),this.#fe();return}if(A&&(!A.current||this.#j))return;const R=this.#t.store,O=this.#N?void 0:j,{from:I}=R.appendPacked(T,O),q=T.count|0;for(let Z=0;Z<q;Z++){const _=I+Z,J=j[Z],ee=this.#s.keyed?this.#s.keyOf(J,_):null;if(this.#n[_]=this.#N?a:J,this.#S++,this.#ue(_,J),ee!==null&&this.#a.set(ee,_),!this.#r||!this.#U(_))continue;const te=this.#Y(_);this.#r.insert(te,_),te<=this.#p&&this.#m++}this.#k=!0,this.#ce(),this.#H++,this.#K(E),this.#fe()}#oe(){const E=this.#t.ingestWorker;return B(E)?E():null}#me(){const E=this.#t.storeSchema;return B(E)?E():null}#X(E){const A=[],j=this.#t.store,$=new Array(E.length),z=[],T=new Set;for(let O=0;O<E.length;O++){const I=this.#s.keyed?this.#s.keyOf(E[O],this.#n.length+z.length):null;$[O]=I,!(I!==null&&(this.#a.has(I)||T.has(I)))&&(I!==null&&T.add(I),z.push(E[O]))}let R=z.length&&j&&B(j.append)?j.append(z).from:this.#n.length;for(let O=0;O<E.length;O++){const I=E[O],q=$[O];if(q!==null&&this.#a.has(q)){const J=this.#a.get(q),ee=this.#Le(J);this.#N||(this.#n[J]=I,j&&B(j.setSource)&&j.setSource(J,I)),this.#Xe(J,I),this.#l.delete(J),this.#ue(J,I),this.#Z(J,ee);continue}const Z=R++;if(this.#n[Z]=this.#N?a:I,this.#S++,this.#ue(Z,I),q!==null&&this.#a.set(q,Z),A.push(Z),!this.#r||!this.#U(Z))continue;const _=this.#Y(Z);this.#r.insert(_,Z),_<=this.#p&&this.#m++}return this.#k=!0,this.#ce(),A}#ke(E){const A=this.#n[E];let j=!1;if(this.#r){const R=this.#G(E);R>=0&&R<=this.#p&&(j=!0)}else E<=this.#p&&(j=!0);const $=A===a?this.#Ee(E):A,z=this.#s.keyed?this.#s.keyOf($,E):null;z!==null&&this.#a.get(z)===E&&this.#a.delete(z),this.#n[E]=void 0,this.#E&&(this.#E[E]=NaN),this.#l.delete(E);const T=this.#t.store;return T&&B(T.remove)&&T.remove(E),this.#S--,j}#ce(){let E=0,A=0;const j=this.#Ce();E+=j.dropped,A+=j.aboveAnchor;const $=this.#se();E+=$.dropped,A+=$.aboveAnchor,E&&(this.#k=!0,this.#M+=E,this.#T(),this.#m-=A,this.#Ae("stream:evicted",{evicted:E,total:this.#M,live:this.#S}))}#se(){const E=this.#e.maxRows;if(!Number.isFinite(E)||E<=0||this.#S<=E)return{dropped:0,aboveAnchor:0};const A=Math.max(1,Math.floor(E*(1-w)));let j=0,$=0;for(;this.#S>A&&this.#A<this.#n.length;){const z=this.#A++;this.#n[z]!==void 0&&(this.#ke(z)&&$++,j++)}return{dropped:j,aboveAnchor:$}}#Ce(){const E=this.#ie();if(!E||!this.#E||!this.#le())return{dropped:0,aboveAnchor:0};const A=Date.now()-E;let j=0,$=0,z=1/0;for(let T=this.#A;T<this.#n.length;T++){if(this.#n[T]===void 0)continue;const R=this.#E[T];if(!(Number.isNaN(R)||R===void 0)){if(R>=A){R<z&&(z=R);continue}this.#ke(T)&&$++,j++}}for(this.#R=z,this.#L=!1;this.#A<this.#n.length&&this.#n[this.#A]===void 0;)this.#A++;return{dropped:j,aboveAnchor:$}}#G(E){if(!this.#r)return E;for(let A=0;A<this.#r.length;A++)if(this.#r.at(A)===E)return A;return-1}#T(){this.#o=this.#ge("sort",[]),this.#i=this.#ge("filters",null);const E=Number.isFinite(this.#e.maxRows)&&this.#e.maxRows>0||this.#ie()>0,A=this.#ge("where",null),j=(this.#t.config||{}).hostFilter,$=!!(A&&A.active)||!!(j&&B(j.active)&&j.active());if(!(E||this.#o.length>0||!!this.#i||!!this.#ge("quick","")||$)){this.#r=null;return}this.#r=new r(Math.max(64,this.#n.length+64));for(let T=0;T<this.#n.length;T++)this.#n[T]!==void 0&&this.#U(T)&&this.#r.insert(this.#Y(T),T)}#U(E){const A=this.#Ee(E);if(this.#i&&!this.#ae(this.#i,A))return!1;const j=String(this.#ge("quick","")||"").toLowerCase();if(j&&!this.#dt(A).includes(j))return!1;const $=(this.#t.config||{}).hostFilter;if($&&B($.active)&&$.active()&&!$.passes(this.#je(E)))return!1;const z=this.#ge("where",null);if(z&&z.active){const T=this.#je(E);if(!z.passes(T.data,T.key))return!1}return!0}#ae(E,A){if(!E)return!0;const j=E;if(Array.isArray(j.conditions))return j.op==="or"?j.conditions.some(T=>this.#ae(T,A)):j.op==="not"?!j.conditions.some(T=>this.#ae(T,A)):j.conditions.every(T=>this.#ae(T,A));const $=E,z=(this.#t.compute||{}).testValue;return B(z)?!!z(this.#De(A,$.col),$,(this.#t.config||{}).locale):(U("source.stream.testValue","ctx.compute.testValue is unavailable; streamed rows are not filtered client-side."),!0)}#Le(E){if(!this.#r)return-1;if(!this.#o.length)return this.#G(E);let A=0,j=this.#r.length;for(;A<j;){const $=A+j>>>1;this.#de(this.#r.at($),E)<0?A=$+1:j=$}for(let $=A;$<this.#r.length;$++){const z=this.#r.at($);if(z===E)return $;if(this.#de(z,E)>0)break}return this.#G(E)}#Z(E,A){if(!this.#r||!this.#o.length)return;const j=this.#U(E);if(A>=0&&this.#r.at(A)===E)this.#r.removeAt(A),A<=this.#p&&this.#m--;else if(A>=0)return;if(!j)return;const $=this.#Y(E);this.#r.insert($,E),$<=this.#p&&this.#m++}#Y(E){if(!this.#r||!this.#o.length)return this.#r?this.#r.length:0;let A=0,j=this.#r.length;for(;A<j;){const $=A+j>>>1;this.#de(E,this.#r.at($))<0?j=$:A=$+1}return A}#de(E,A){const j=this.#Ee(E),$=this.#Ee(A);for(const z of this.#o){const T=this.#_e(z.col),R=this.#De(j,z.col),O=this.#De($,z.col),q=(T&&T.value&&B(T.value.compare)?T.value.compare:H)(R,O);if(q!==0)return z.dir==="desc"?-q:q}return 0}#v(){this.#b=!0,this.#c.loaded=this.#c.loaded||this.#n.length;const E=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:h;!this.#N&&this.#n.length<E&&(this.#g=f({mode:"memory",rows:this.#n},this.#t),this.#x!==null&&(clearInterval(this.#x),this.#x=null),this.#y&&(this.#y.destroy(),this.#y=null)),this.#fe(),this.#Ae("stream:end",{loaded:this.#n.length,promoted:this.#g!==null,threshold:E})}#fe(){this.#d!==null||this.#j||(this.#d=this.#We(()=>{this.#d=null,this.#f++;const E=this.#m;this.#m=0,this.#h=0,this.#Ae("stream:chunk",{loaded:this.#c.loaded,estimated:this.#c.estimated,count:this.count(),renders:this.#f}),this.#Ae("model:changed",{reason:"stream",shiftAboveViewport:E,anchor:this.#p}),this.#Ae("rows:changed",{companion:!0,reason:"stream"})}))}#Oe(){return this.#f===0||this.#h<this.#Ie()?Promise.resolve():(this.#h=0,new Promise(E=>{const A=(this.#t.scheduler||{}).idle;B(A)?A(()=>E()):G(()=>E())}))}#Ie(){return typeof this.#e.coalesceMs=="number"&&this.#e.coalesceMs>0?this.#e.coalesceMs:p}#We(E){const A=this.#t.scheduler||{};return B(A.frame)?A.frame(E):W(E)}#Ve(E){const A=this.#t.scheduler||{};B(A.cancel)?A.cancel(E):Q(E)}#Ee(E){const A=this.#n[E];if(A!==void 0&&A!==a)return A;if(A===void 0)return;const j=this.#t.store;return j&&B(j.source)?j.source(E):void 0}#Xe(E,A){const j=this.#t.store;if(!j||!B(j.set))return;const $=this.#me();if(Array.isArray($))for(const z of $){if(!z||!z.id)continue;const T=B(z.read)?z.read:R=>v(R,z.field||z.id);j.set(z.id,E,T(A))}}#je(E){let A=this.#l.get(E);return A||(A=this.#s.leaf(this.#Ee(E),E),this.#l.set(E,A)),A}#De(E,A){const j=this.#_e(A);return j&&B(j.getValue)?j.getValue(E):E?.[A]}#dt(E){const A=this.#t.columns,j=A&&B(A.all)?A.all():[],$=[];for(const z of j){const T=B(z.getValue)?z.getValue(E):void 0;T!=null&&T!==""&&$.push(String(T))}return $.join(" ").toLowerCase()}#_e(E){const A=this.#t.columns;return A&&B(A.get)?A.get(E):void 0}#tt(){const E=this.#z;if(this.#z=null,E&&B(E.return))try{E.return()}catch{}}#Q(){return o({context:this.#ge("context",null)})}#ge(E,A){const j=this.#t.state;if(j&&B(j[E])){const $=j[E]();return $??A}return A}#Ae(E,A){const j=this.#t.emit;B(j)&&j(E,A)}}}),xe("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 v}});const X=K("packages/core/src/internal/util.js"),L=X.warnOnce,B=X.isObject,F=X.isFunction,W=X.getPath,G=K("packages/core/src/source/abort.js").isAbortError,H=500,U=new Set(["application/x-ndjson","application/ndjson","application/jsonlines","application/jsonl","application/x-jsonlines","text/x-ndjson"]),D=Symbol("lattice.url.skip");function v(d,h={}){const a=B(h)?h:{},p=F(a.fetch)?a.fetch:typeof globalThis<"u"&&F(globalThis.fetch)?globalThis.fetch:null,w=a.format==="json"||a.format==="ndjson"?a.format:void 0,k=typeof a.rowsPath=="string"&&a.rowsPath?a.rowsPath:void 0,m=F(a.map)?a.map:void 0,b=B(a.headers)?a.headers:void 0,C=Number.isFinite(a.batchSize)&&a.batchSize>0?Math.floor(a.batchSize):H,M=a.lenient===!0,P=Number.isFinite(a.poll)&&a.poll>0?Math.floor(a.poll):void 0,x=typeof d=="string"&&d.length>0;x||L("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*E(j={}){if(!x)return;if(!p)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const $=j&&j.signal;let z;try{z=await p(d,b?{signal:$,headers:b}:{signal:$})}catch(O){throw G(O)?O:new Error(`[lattice] createUrlSource: request to ${d} failed — ${O&&O.message||O}`)}if(!z||!z.ok){const O=z?z.status:"no response";throw new Error(`[lattice] createUrlSource: ${O} for ${d}`)}const T=S(d,w,z),R=z.body&&F(z.body.getReader)?z.body.getReader():null;try{if(!R){const q=await z.text();(T||c(q,d))==="ndjson"?yield*f(null,null,q,0,z,d,C,M):yield*s(q,d,k,m);return}const O=new TextDecoder("utf-8");if(T==="json"){yield*s(await r(R,O,""),d,k,m);return}if(T==="ndjson"){yield*f(R,O,"",0,z,d,C,M);return}const I=await i(R,O,d);I.format==="json"?yield*s(await r(R,O,I.seed),d,k,m):yield*f(R,O,I.seed,I.bytes,z,d,C,M)}finally{if(R&&F(R.cancel))try{await R.cancel()}catch{}}}const A={mode:"stream",open:E,autoStart:a.autoStart!==!1};return P!==void 0&&(A.poll=P),Number.isFinite(a.maxRows)&&(A.maxRows=a.maxRows),Number.isFinite(a.maxAge)&&(A.maxAge=a.maxAge),(typeof a.ageBy=="string"||F(a.ageBy))&&(A.ageBy=a.ageBy),Number.isFinite(a.coalesceMs)&&(A.coalesceMs=a.coalesceMs),Number.isFinite(a.promoteToMemoryBelow)&&(A.promoteToMemoryBelow=a.promoteToMemoryBelow),A}function S(d,h,a){if(h)return h;const p=y(d);if(p)return p;const w=a&&a.headers&&F(a.headers.get)?a.headers.get("content-type"):null;return l(w)}function y(d){const h=String(d).split(/[?#]/)[0].toLowerCase();if(h.endsWith(".ndjson")||h.endsWith(".jsonl"))return"ndjson";if(h.endsWith(".json"))return"json"}function l(d){if(!d)return;const h=d.split(";")[0].trim().toLowerCase();if(U.has(h))return"ndjson";if(h==="application/json"||h==="text/json"||h.endsWith("+json"))return"json"}function c(d,h){const a=d.replace(/^\s+/,""),p=n(a);if(p==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${h} — pass opts.format: 'json' | 'ndjson'.`);return p}async function i(d,h,a){let p="",w=0;for(;;){const{value:m,done:b}=await d.read();if(m&&(w+=m.byteLength,p+=h.decode(m,{stream:!0})),b){p+=h.decode();break}const C=p.replace(/^\s+/,"");if(C){if(C[0]==="[")return{format:"json",seed:p,bytes:w};if(C[0]!=="{"||p.indexOf(`
|
|
8
8
|
`)!==-1)break}}const k=n(p.replace(/^\s+/,""));if(k==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${a} — pass opts.format: 'json' | 'ndjson'.`);return{format:k,seed:p,bytes:w}}function n(d){if(!d||d[0]==="[")return"json";if(d[0]!=="{")return"error";const h=d.indexOf(`
|
|
9
9
|
`);if(h===-1)return"json";let a=d.slice(0,h);return a.endsWith("\r")&&(a=a.slice(0,-1)),t(a)?"ndjson":"json"}function t(d){try{return JSON.parse(d),!0}catch{return!1}}async function r(d,h,a){let p=a;for(;;){const{value:w,done:k}=await d.read();if(w&&(p+=h.decode(w,{stream:!0})),k)break}return p+=h.decode(),p}function*s(d,h,a,p){let w;try{w=JSON.parse(d)}catch(m){throw new Error(`[lattice] createUrlSource: ${h} is not valid JSON — ${m.message}`)}let k=a!==void 0?W(w,a):w;if(p&&(k=p(k)),!Array.isArray(k)){const m=a!==void 0||p?"":"; pass opts.rowsPath or opts.map to select the array";throw new Error(`[lattice] createUrlSource: ${h} did not resolve to an array${m}.`)}yield{rows:k,progress:{loaded:k.length,estimated:k.length}}}async function*f(d,h,a,p,w,k,m,b){const C=g(w);let M=a||"",P=p||0,x=0,E=0,A=[];function*j(){let z;for(;(z=M.indexOf(`
|
|
@@ -56,6 +56,6 @@ ${ee}[data-heat-side="low"]{background-color:color-mix(in srgb, var(--lattice-va
|
|
|
56
56
|
`);return E===M?!1:(h.value=a.slice(0,b)+E+a.slice(C),this.#r(Math.max(b,p+(d?-k.length:k.length)),Math.max(b,w+x)),this.revalidate(),!0)}#r(d,h){const a=this.input;a&&(a.selectionStart=d,a.selectionEnd=h===void 0?d:h,G(a.setSelectionRange)&&a.setSelectionRange(a.selectionStart,a.selectionEnd))}format(d){const h=this.input;if(!h||this.language!=="json")return!1;const a=i(h.value);if(!a.ok)return this.revalidate(),!1;if(a.value===null&&h.value.trim()==="")return!1;try{const p=JSON.stringify(a.value,null,d===void 0?this.indent:d);return p===void 0?!1:(h.value=p,this.#r(p.length),this.revalidate(),!0)}catch{return!1}}revalidate(){const d=this.input?this.input.value:"",h=s(d,this.language);this.lastResult=h;const a=this.errorNode;return a&&(a.textContent=h.ok?"":f(h),a.classList.toggle(v.errorOn,!h.ok)),this.input&&(h.ok?this.input.removeAttribute("aria-invalid"):this.input.setAttribute("aria-invalid","true"),h.ok||!a?this.input.removeAttribute("aria-errormessage"):(a.id||(a.id=H("lat-err")),this.input.setAttribute("aria-errormessage",a.id))),h}text(){return this.input?this.input.value:""}readValue(){const d=this.text();if(d.trim()==="")return null;if(this.language!=="json"||(this.props.parseOnCommit??!0)!==!0)return d;const a=i(d);return a.ok?a.value:d}checkValue(d){if(this.props.allowInvalid===!0)return!0;const h=this.revalidate();return h.ok?!0:f(h)}toClipboard(){return this.text()}fromClipboard(d){const h=d==null?"":String(d);return this.input&&(this.input.value=h),this.revalidate(),h.trim()===""?{ok:!0,value:null}:this.language!=="json"?{ok:!0,value:h}:{ok:!0,value:D(h)}}destroy(){for(const d of this.#e)d();this.#e.length=0,this.input=null,this.errorNode=null,this.formatButton=null,super.destroy()}}const o=u}),xe("packages/dom/src/editors/unit.js",function(e,K){"use strict";Object.defineProperty(e,"presentUnit",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const X=K("packages/dom/src/editors/common.js"),L=X.BaseEditor,B=X.CLS,F=X.el,W=X.on,G=K("packages/core/src/internal/util.js").isFunction,H=K("packages/core/src/columns/types/unit.js"),U=H.parseUnit,D=H.formatUnit,v=H.findUnit;function S(c,i){return D(c,i)}class y extends L{input=null;hint=null;opts=null;#e=[];buildOptions(){const i=this.props,n=this.params.column&&this.params.column.dataType||null,t=n&&n.unitConfig||{};return{system:i.system||t.system||"data",unit:i.unit??t.unit,binary:i.binary===!0||i.binary===void 0&&t.binary===!0,display:i.display??t.display,locale:this.params.locale,group:!1,minDecimals:0,maxDecimals:20}}build(){const i=this.props;this.opts=this.buildOptions();const n=this.symbol(),t=`${this.id}-unit`,r=F(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:i.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":n?t:null}});r.value=S(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 i.step=="number"?i.step:0;return s>0&&this.#e.push(W(r,"keydown",f=>{f.key==="ArrowUp"?(G(f.preventDefault)&&f.preventDefault(),this.nudge(s)):f.key==="ArrowDown"&&(G(f.preventDefault)&&f.preventDefault(),this.nudge(-s))})),this.hint=F(this.doc,"span",{class:`${B.editor}__suffix`,text:n,attrs:{id:t,"aria-hidden":"true"}}),F(this.doc,"div",{class:`${B.editor}__unit`,children:[r,this.hint]})}symbol(){const i=v(this.opts.system,this.opts.unit);return i?i.symbol:String(this.opts.unit||"")}focusTarget(){return this.input}attached(){super.attached();const i=this.input;i&&!this.params.key&&this.props.selectOnFocus!==!1&&G(i.select)&&i.select()}nudge(i){const n=U(this.input?this.input.value:"",this.opts);let t=(n??0)+i;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=S(t,this.opts))}readValue(){const i=this.input?this.input.value:"";if(String(i).trim()==="")return null;const n=U(i,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(i){if(i===null)return!0;if(typeof i!="number"||Number.isNaN(i)){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"&&i<n)return`Must be ${this.describe(n)} or more`;if(typeof t=="number"&&i>t)return`Must be ${this.describe(t)} or less`}return!0}describe(i){return D(i,{...this.opts,display:this.opts.unit,group:!0,maxDecimals:4})}toClipboard(){return D(this.readValue(),{...this.opts,display:this.opts.unit})}fromClipboard(i){const n=i==null?"":String(i);if(n.trim()==="")return{ok:!0,value:null};const t=U(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 i of this.#e)i();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const l=y}),xe("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 X=K("packages/dom/src/editors/common.js"),L=X.BaseEditor,B=X.CLS,F=X.el,W=X.on,Q=K("packages/core/src/internal/util.js"),G=Q.isFunction,H=Q.uid,U=K("packages/core/src/columns/types/radix.js"),D=U.compileRadixFormat,v=U.compileRadixParse,S=U.normaliseRadixOptions,y=U.radixRange,l=Object.freeze({root:"lat-editor__radix",hint:"lat-editor__hint",hintInvalid:"lat-editor__hint--invalid"}),c=Object.freeze(["preset","radix","prefix","uppercase","pad","group","groupSeparator","bitWidth","signed","nullDisplay"]),i=new Map;function n(f){const u=f||"";let o=i.get(u);if(o)return o;try{o=new Intl.NumberFormat(f||void 0,{maximumFractionDigits:0})}catch{o={format:g=>String(g)}}return i.set(u,o),o}function t(f,u){const o=u||{},g={};if(f){for(const h of c)f[h]!==void 0&&(g[h]=f[h]);const d=y(f.bitWidth??null,f.signed!==!1);typeof f.min=="number"&&f.min>d.min&&(g.min=f.min),typeof f.max=="number"&&f.max<d.max&&(g.max=f.max)}for(const d of c)o[d]!==void 0&&(g[d]=o[d]);return typeof o.min=="number"&&(g.min=o.min),typeof o.max=="number"&&(g.max=o.max),S(g)}class r extends L{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=D(this.options),this.parse=v(this.options);const o=F(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:this.options.radix===2?"numeric":"text",autocomplete:"off",autocapitalize:"off",spellcheck:"false",placeholder:this.props.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-valuemin":this.options.min,"aria-valuemax":this.options.max}});o.value=this.format(this.params.value),this.params.key&&this.#t(this.params.key)&&(o.value=this.params.key),this.input=o;const g=F(this.doc,"span",{class:l.hint,attrs:{"aria-live":"polite"}});this.hint=g,this.#e.push(W(o,"input",()=>this.refresh())),this.#e.push(W(o,"keydown",h=>this.#n(h)));const d=F(this.doc,"div",{class:l.root,children:[o,g]});return this.refresh(),d}focusTarget(){return this.input}attached(){super.attached();const u=this.input;u&&!this.params.key&&this.props.selectOnFocus!==!1&&G(u.select)&&u.select()}#t(u){return u.length===1&&/[0-9a-fA-FxXbBoO#+\-.]/.test(u)}#n(u){const o=typeof this.props.step=="number"&&this.props.step!==0?this.props.step:1;u.key==="ArrowUp"?(G(u.preventDefault)&&u.preventDefault(),this.nudge(o)):u.key==="ArrowDown"&&(G(u.preventDefault)&&u.preventDefault(),this.nudge(-o))}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}clamp(u){const{min:o,max:g}=this.options;return u<o?o:u>g?g:u}evaluate(){const u=this.input?String(this.input.value):"";if(u.trim()==="")return{value:null,message:null};const o=this.parse(u);return o.ok?{value:this.mode()==="clamp"?this.clamp(o.value):o.value,message:null}:this.mode()==="clamp"&&typeof o.value=="number"&&(o.reason==="range"||o.reason==="negative")?{value:this.clamp(o.value),message:null}:{value:NaN,message:this.messageFor(o.reason)}}messageFor(u){const o=this.options;return u==="negative"?`This column holds an unsigned ${o.bitWidth}-bit pattern; enter ${this.format(0)} or more`:u==="range"?`Must be between ${this.format(o.min)} and ${this.format(o.max)}`:`Enter a ${o.name} value, e.g. ${this.format(o.radix===2?5:26)}`}refresh(){const{value:u,message:o}=this.evaluate();if(this.input&&this.input.classList&&(o?this.input.classList.add(B.invalid):this.input.classList.remove(B.invalid),this.input.setAttribute("aria-invalid",o?"true":"false"),o&&this.hint?(this.hint.id||(this.hint.id=H("lat-err")),this.input.setAttribute("aria-errormessage",this.hint.id)):this.input.removeAttribute("aria-errormessage")),!!this.hint){if(o){this.hint.textContent=o,this.hint.classList&&this.hint.classList.add(l.hintInvalid);return}this.hint.classList&&this.hint.classList.remove(l.hintInvalid),this.hint.textContent=u===null?"":`= ${n(this.params.locale).format(u)}`}}nudge(u){if(!this.input)return;const o=this.parse(this.input.value);let g;typeof o.value=="number"?g=o.value:typeof this.params.value=="number"?g=this.params.value:g=0,this.input.value=this.format(this.clamp(g+u)),this.refresh()}readValue(){return this.evaluate().value}checkValue(u){return u===null?!0:typeof u!="number"||Number.isNaN(u)?this.evaluate().message||this.messageFor("digits"):!this.options.signed&&u<0?this.messageFor("negative"):this.mode()==="reject"&&(u<this.options.min||u>this.options.max)?this.messageFor("range"):!0}toClipboard(){const u=this.readValue();return u===null||Number.isNaN(u)?this.input?String(this.input.value):"":this.format(u)}fromClipboard(u){const o=u==null?"":String(u);if(o.trim()==="")return{ok:!0,value:null};const g=this.parse(o);let d;if(g.ok)d=g.value;else if(this.mode()==="clamp"&&typeof g.value=="number"&&(g.reason==="range"||g.reason==="negative"))d=this.clamp(g.value);else return{ok:!1,message:this.messageFor(g.reason)};const h=this.checkValue(d);return h!==!0?{ok:!1,message:h}:{ok:!0,value:d}}destroy(){for(const u of this.#e)u();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const s=r}),xe("packages/dom/src/editors/segmented.js",function(e,K){"use strict";Object.defineProperty(e,"SEGMENTED_MAX",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const X=K("packages/dom/src/editors/common.js"),L=X.BaseEditor,B=X.CLS,F=X.el,W=X.on,Q=X.keyOf,G=X.normaliseLookup,H=X.documentFor,U=X.lookupFor,v=K("packages/dom/src/editors/select.js").SelectEditor,y=K("packages/core/src/internal/util.js").isFunction,c=K("packages/dom/src/cell/icons.js").createIcon,i=6;class n extends L{static popup=!1;options=[];selected=null;segments=[];focused=0;#e=null;#t=[];init(f){const u=f||{},o=t(u),g=U(u,o,{colId:u.column&&(u.column.id||u.column.field)}),d=Number(o.max??i),h=g.options().length;if(Number.isFinite(d)&&h>d){const a=new v;a.init(u),this.#e=a,this.params=u,this.doc=H(u),this.props=o,this.lookup=g,this.popup=a.popup;return}super.init(u),(!this.lookup||!this.lookup.options().length)&&(this.lookup=g)}usesFallback(){return this.#e!==null}build(){const f=this.doc;this.options=this.lookup?this.lookup.options():[],this.selected=this.params.value??null;const u=F(f,"div",{class:`${B.editor}__segmented`,attrs:{role:"radiogroup","aria-label":this.params.column&&this.params.column.title||null,"data-size":this.props.size?String(this.props.size):null}});for(let o=0;o<this.options.length;o++)u.appendChild(this.buildSegment(this.options[o],o));return this.props.allowClear===!0&&u.appendChild(this.buildClear()),this.#t.push(W(u,"keydown",o=>this.onKeyDown(o))),this.focused=Math.max(0,this.indexOf(this.selected)),this.paint(),u}buildSegment(f,u){const o=this.doc,g=F(o,"button",{class:`${B.editor}__segment`,attrs:{type:"button",role:"radio",tabindex:"-1","aria-checked":"false","data-index":u,"data-variant":f.variant??null,"aria-disabled":f.disabled===!0?"true":null}});return f.icon&&g.appendChild(c(o,f.icon,{className:B.icon})),g.appendChild(F(o,"span",{class:`${B.editor}__segment-label`,text:f.label})),this.#t.push(W(g,"mousedown",d=>{d&&y(d.preventDefault)&&d.preventDefault(),f.disabled!==!0&&(this.focused=u,this.select(u,{commit:!0}))})),this.segments.push(g),g}buildClear(){const f=F(this.doc,"button",{class:`${B.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clear")}});return this.#t.push(W(f,"mousedown",u=>{u&&y(u.preventDefault)&&u.preventDefault(),this.clearSelection()})),f}indexOf(f){if(f==null)return-1;const u=Q(f);for(let o=0;o<this.options.length;o++)if(Q(this.options[o].id)===u)return o;return-1}paint(){for(let f=0;f<this.segments.length;f++){const u=f===this.indexOf(this.selected),o=this.segments[f];o.setAttribute("aria-checked",u?"true":"false"),o.setAttribute("tabindex",f===this.focused?"0":"-1"),o.classList.toggle(`${B.editor}__segment--active`,u),o.classList.toggle(`${B.editor}__segment--disabled`,this.options[f].disabled===!0)}}select(f,u){const o=this.options[f];!o||o.disabled===!0||(this.selected=o.id,this.paint(),u&&u.commit&&this.commit())}clearSelection(){this.selected=null,this.paint()}moveFocus(f){const u=this.segments.length;if(!u)return;let o=this.focused;for(let g=0;g<u;g++)if(o=(o+f+u)%u,this.options[o].disabled!==!0){this.focusAt(o);return}}focusAt(f){if(f<0||f>=this.segments.length)return;this.focused=f,this.paint();const u=this.segments[f];u&&y(u.focus)&&u.focus()}edgeIndex(f){const u=this.options.length;for(let o=0;o<u;o++){const g=f===1?o:u-1-o;if(this.options[g].disabled!==!0)return g}return-1}onKeyDown(f){const u=()=>{y(f.preventDefault)&&f.preventDefault()};switch(f.key){case"ArrowRight":case"ArrowDown":u(),this.moveFocus(1);break;case"ArrowLeft":case"ArrowUp":u(),this.moveFocus(-1);break;case"Home":u(),this.focusAt(this.edgeIndex(1));break;case"End":u(),this.focusAt(this.edgeIndex(-1));break;case"Enter":u(),this.select(this.focused,{commit:!0});break;case" ":case"Spacebar":u(),this.select(this.focused);break;case"Escape":u(),this.cancel();break;case"Tab":this.select(this.focused),this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(u(),this.clearSelection());break;default:break}}readValue(){return this.selected??null}checkValue(f){return f==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.lookup||!this.lookup.options().length||this.lookup.option(f)||this.lookup.allowCustom||this.props.allowCustom===!0?!0:`"${String(f)}" is not a valid option`}element(){return this.#e?this.#e.element():super.element()}value(){return this.#e?this.#e.value():super.value()}focusTarget(){if(!this.segments.length)return super.focusTarget();const f=this.indexOf(this.selected);return this.segments[f>=0?f:Math.max(0,this.edgeIndex(1))]||null}attached(){if(this.#e){this.#e.attached();return}if(super.attached(),!this.lookup)return;const f=this.lookup.ready();!f||!y(f.then)||f.then(()=>{if(!super.element()||this.options.length)return;const u=super.element();this.options=this.lookup.options();for(let o=0;o<this.options.length;o++)u.appendChild(this.buildSegment(this.options[o],o));this.focused=Math.max(0,this.indexOf(this.selected)),this.paint()})}cancelBeforeStart(){return this.#e?this.#e.cancelBeforeStart():super.cancelBeforeStart()}cancelOnClose(){return this.#e?this.#e.cancelOnClose():super.cancelOnClose()}commit(){return this.#e?this.#e.commit():super.commit()}cancel(){this.#e?this.#e.cancel():super.cancel()}validate(f){return this.#e?this.#e.validate(f):super.validate(f)}message(){return this.#e?this.#e.message():super.message()}toClipboard(){return this.#e?this.#e.toClipboard():super.toClipboard()}fromClipboard(f){return this.#e?this.#e.fromClipboard(f):super.fromClipboard(f)}destroy(){for(const f of this.#t)f();this.#t.length=0,this.segments.length=0,this.options=[],this.#e&&(this.#e.destroy(),this.#e=null),super.destroy()}}function t(s){return{...s.column&&s.column.edit&&s.column.edit.props||{},...s.props||{}}}const r=n}),xe("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 X=K("packages/dom/src/editors/common.js"),L=X.BaseEditor,B=X.CLS,F=X.el,W=X.on,G=K("packages/dom/src/cell/icons.js").createIcon,H=K("packages/dom/src/cell/renderers/rating.js"),U=H.ratingFills,D=H.fillState,v=H.ratingText,S=H.clampRating,y=H.DEFAULT_RATING_ICON,l=H.DEFAULT_RATING_MAX,i=K("packages/core/src/internal/util.js").isFunction;class n extends L{static popup=!1;rating=null;preview=null;items=[];fills=[];slider=null;readout=null;#e=[];max(){const f=Math.floor(Number(this.props.max??l));return Number.isFinite(f)&&f>0?f:l}step(){return this.props.allowHalf===!0?.5:1}build(){const f=this.doc,u=this.max();this.rating=t(this.params.value,u,this.props.allowHalf===!0);const o=F(f,"div",{class:`${B.editor}__rating`}),g=F(f,"div",{class:`${B.editor}__rating-slider`,attrs:{role:"slider",tabindex:"0","aria-valuemin":"0","aria-valuemax":String(u),"aria-label":this.params.column&&this.params.column.title||"Rating"}});for(let h=0;h<u;h++)g.appendChild(this.buildItem(h));o.appendChild(g),this.slider=g;const d=F(f,"span",{class:`${B.editor}__rating-value`});return o.appendChild(d),this.readout=d,this.props.allowClear===!0&&o.appendChild(this.buildClear()),this.#e.push(W(g,"keydown",h=>this.onKeyDown(h))),this.props.hoverPreview!==!1&&this.#e.push(W(g,"mouseleave",()=>{this.preview=null,this.paint()})),this.params.key&&/^[0-9]$/.test(this.params.key)&&(this.rating=Math.min(Number(this.params.key),u)),this.paint(),o}buildItem(f){const u=this.doc,o=String(this.props.icon??y),g=F(u,"span",{class:`${B.editor}__rating-fill`,attrs:{"aria-hidden":"true"},children:[G(u,o,{className:B.icon})]}),d=F(u,"span",{class:`${B.editor}__rating-item`,attrs:{"data-index":f,"data-icon":o,"aria-hidden":"true"},children:[G(u,o,{className:B.icon}),g]});return this.fills.push(g),this.#e.push(W(d,"mousedown",h=>{h&&i(h.preventDefault)&&h.preventDefault(),this.setRating(this.ratingAt(f,h),{commit:!0})})),this.props.hoverPreview!==!1&&this.#e.push(W(d,"mousemove",h=>{const a=this.ratingAt(f,h);a!==this.preview&&(this.preview=a,this.paint())})),this.items.push(d),d}buildClear(){const f=F(this.doc,"button",{class:`${B.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearRating")}});return this.#e.push(W(f,"mousedown",u=>{u&&i(u.preventDefault)&&u.preventDefault(),this.setRating(null)})),f}ratingAt(f,u){if(this.props.allowHalf!==!0)return f+1;const o=this.items[f],g=o&&Number(o.offsetWidth),d=u&&Number(u.offsetX);return!Number.isFinite(g)||g<=0||!Number.isFinite(d)?f+1:d*2<g?f+.5:f+1}focusTarget(){return this.slider}setRating(f,u){this.rating=f===null?null:S(f,this.max(),this.props.allowHalf===!0,!1),this.preview=null,this.paint(),u&&u.commit&&this.commit()}nudge(f){const u=this.rating===null?0:this.rating;this.setRating(u+f)}paint(){const f=this.max(),u=this.props.allowHalf===!0,o=this.preview===null?this.rating:this.preview,g=U(o===null?0:o,f,{allowHalf:u});for(let a=0;a<this.items.length;a++){const p=D(g[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",`${(g[a]*100).toFixed(2)}%`)}const d=o===null?String(this.props.emptyLabel??this.t("cell.rating.empty")):this.t("cell.rating.of",{rating:v(o),max:f}),h=this.slider;h&&(h.setAttribute("aria-valuenow",o===null?"0":String(o)),h.setAttribute("aria-valuetext",d),h.setAttribute("data-preview",this.preview===null?"false":"true")),this.readout&&(this.readout.textContent=d)}onKeyDown(f){const u=()=>{i(f.preventDefault)&&f.preventDefault()},o=this.step();if(/^[0-9]$/.test(f.key)){u(),this.setRating(Math.min(Number(f.key),this.max()));return}switch(f.key){case"ArrowRight":case"ArrowUp":u(),this.nudge(o);break;case"ArrowLeft":case"ArrowDown":u(),this.nudge(-o);break;case"Home":u(),this.setRating(0);break;case"End":u(),this.setRating(this.max());break;case"Enter":u(),this.commit();break;case"Escape":u(),this.cancel();break;case"Tab":this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(u(),this.setRating(null));break;default:break}}readValue(){return this.rating}checkValue(f){if(f==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a rating";if(typeof f!="number"||!Number.isFinite(f))return"Enter a rating";const u=this.max();return f<0?"Must be 0 or more":f>u?`Must be ${u} or less`:this.props.allowHalf!==!0&&!Number.isInteger(f)?"Choose a whole rating":!0}toClipboard(){return this.rating===null?"":v(this.rating)}fromClipboard(f){const u=String(f??"").trim();if(u==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a rating"};const o=Number(u);if(!Number.isFinite(o))return{ok:!1,message:`"${u}" is not a rating`};const g=this.checkValue(o);return g!==!0?{ok:!1,message:g}:{ok:!0,value:o}}destroy(){for(const f of this.#e)f();this.#e.length=0,this.items.length=0,this.slider=null,this.readout=null,super.destroy()}}function t(s,f,u){if(s==null||s==="")return null;const o=Number(s);return Number.isFinite(o)?S(o,f,u,!1):null}const r=n}),xe("packages/dom/src/editors/slider.js",function(e,K){"use strict";Object.defineProperty(e,"SLIDER_MIN",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"SLIDER_MAX",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"proportion",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"decimalsOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"normaliseMarks",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const X=K("packages/dom/src/editors/common.js"),L=X.BaseEditor,B=X.CLS,F=X.el,W=X.on,Q=K("packages/dom/src/editors/number.js"),G=Q.parseNumberText,H=Q.presentNumber,D=K("packages/core/src/internal/util.js").isFunction,v=0,S=100;class y extends L{static popup=!1;amount=null;range=null;field=null;readout=null;root=null;marks=[];#e=[];min(){const r=Number(this.props.min??v);return Number.isFinite(r)?r:v}max(){const r=Number(this.props.max??S);return Number.isFinite(r)?r:S}step(){const r=Number(this.props.step??1);return Number.isFinite(r)&&r>0?r:1}build(){const r=this.doc,s=this.min(),f=this.max(),u=this.step(),o=i(this.props.marks);this.marks=o,this.amount=this.params.value==null||this.params.value===""?null:this.snap(Number(this.params.value));const g=F(r,"div",{class:`${B.editor}__slider`});this.root=g;const d=F(r,"input",{class:`${B.editor}__slider-input`,attrs:{type:"range",min:String(s),max:String(f),step:String(u),"aria-label":this.params.column&&this.params.column.title||null,"aria-valuetext":null,list:o.length?`${this.id}-marks`:null}});if(this.range=d,g.appendChild(d),o.length){const a=F(r,"datalist",{attrs:{id:`${this.id}-marks`}}),p=F(r,"div",{class:`${B.editor}__slider-marks`});for(const w of o){a.appendChild(F(r,"option",{attrs:{value:String(w.value),label:w.label}}));const k=F(r,"span",{class:`${B.editor}__slider-mark`,text:w.label,attrs:{"data-value":String(w.value)}});k.style&&D(k.style.setProperty)&&k.style.setProperty("--lat-slider-mark",`${(l(w.value,s,f)*100).toFixed(2)}%`),p.appendChild(k)}g.appendChild(a),g.appendChild(p)}const h=F(r,"input",{class:`${B.editor}__slider-number`,attrs:{type:"text",inputmode:"decimal","aria-label":this.t("editor.value")}});if(this.field=h,g.appendChild(h),this.props.showValue!==!1){const a=F(r,"span",{class:`${B.editor}__slider-value`});g.appendChild(a),this.readout=a}return this.#e.push(W(d,"input",()=>this.setAmount(Number(d.value),"range"))),this.#e.push(W(d,"change",()=>this.setAmount(Number(d.value),"range"))),this.#e.push(W(d,"keydown",a=>this.onKeyDown(a))),this.#e.push(W(h,"input",()=>this.onFieldInput())),this.#e.push(W(h,"change",()=>this.paint())),this.#e.push(W(h,"keydown",a=>this.onKeyDown(a))),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(h.value=this.params.key,this.onFieldInput()),this.paint(),g}focusTarget(){return this.field}attached(){super.attached();const r=this.field;r&&!this.params.key&&this.props.selectOnFocus!==!1&&D(r.select)&&r.select()}snap(r){if(!Number.isFinite(r))return this.min();const s=this.min(),f=this.max(),u=this.step(),o=Math.min(Math.max(r,s),f),g=s+Math.round((o-s)/u)*u,d=c(u),h=d>0?Number(g.toFixed(d)):Math.round(g);return Math.min(Math.max(h,s),f)}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=G(r,this.params.locale);if(s===null||Number.isNaN(s)){this.paint("field");return}this.setAmount(s,"field")}paint(r){const s=this.min(),f=this.max(),u=this.amount,o=u===null?s:u;this.range&&r!=="range"&&(this.range.value=String(o)),this.field&&r!=="field"&&(this.field.value=u===null?"":H(u,this.props));const g=this.root;g&&g.style&&D(g.style.setProperty)&&g.style.setProperty("--lat-slider-pos",`${(l(o,s,f)*100).toFixed(2)}%`),g&&g.setAttribute&&g.setAttribute("data-empty",u===null?"true":"false");const d=this.labelFor(u);this.range&&this.range.setAttribute&&this.range.setAttribute("aria-valuetext",d),this.readout&&(this.readout.textContent=d)}labelFor(r){if(r===null)return String(this.props.emptyLabel??"");const s=this.marks.find(u=>u.value===r),f=H(r,this.props);return s&&s.label!==f?`${f} (${s.label})`:f}onKeyDown(r){if(r.key==="Escape"){D(r.preventDefault)&&r.preventDefault(),this.cancel();return}if(r.key==="Enter"){D(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=G(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 f=G(s,this.params.locale);if(f===null||Number.isNaN(f))return{ok:!1,message:"Enter a number"};const u=this.snap(f),o=this.checkValue(u);return o!==!0?{ok:!1,message:o}:{ok:!0,value:u}}destroy(){for(const 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 f=s-r;return!Number.isFinite(f)||f===0?0:Math.min(1,Math.max(0,(Number(t)-r)/f))}function c(t){if(!Number.isFinite(t))return 0;const r=String(t),s=r.indexOf("e");if(s>=0){const u=r.slice(0,s),o=u.indexOf("."),g=o<0?0:u.length-o-1;return Math.min(15,Math.max(0,g-Number(r.slice(s+1))))}const f=r.indexOf(".");return f<0?0:Math.min(15,r.length-f-1)}function i(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 f=Number(s);Number.isFinite(f)&&r.push({value:f,label:String(f)})}return r}if(typeof t=="object")for(const[s,f]of Object.entries(t)){const u=Number(s);Number.isFinite(u)&&r.push({value:u,label:String(f)})}return r}const n=y}),xe("packages/dom/src/editors/colour.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_SWATCHES",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"TOKEN_FALLBACK",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"normaliseSwatch",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolveSwatchColour",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"toSwatches",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const X=K("packages/dom/src/editors/common.js"),L=X.BaseEditor,B=X.CLS,F=X.el,W=X.on,Q=K("packages/dom/src/cell/renderers/colour.js"),G=Q.normaliseColour,H=Q.parseColour,D=K("packages/core/src/internal/util.js").isFunction,v=Object.freeze(["neutral","info","success","warning","danger","accent"]),S=Object.freeze({neutral:"#5b6670",info:"#1a6bc7",success:"#1b7f3b",warning:"#a96a0b",danger:"#c22b2b",accent:"#5a46d6"});function y(r){if(r==null)return null;if(typeof r=="object"){const u=r,o=y(u.token??u.value??u.colour??u.color);return o?{...o,label:u.label==null?o.label:String(u.label)}:null}const s=String(r).trim();if(s==="")return null;const f=G(s);return f?{token:null,hex:f,label:f}:Object.hasOwn(S,s)?{token:s,hex:S[s],label:s}:null}function l(r,s){const f=r&&r.ownerDocument,u=f&&f.defaultView;if(!u||!D(u.getComputedStyle))return null;try{const o=u.getComputedStyle(r);return!o||!D(o.getPropertyValue)?null:G(String(o.getPropertyValue(`--lattice-variant-${s}-solid`)).trim())}catch{return null}}class c extends L{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=i(this.props.swatches);const f=F(s,"div",{class:`${B.editor}__colour`,attrs:{"aria-label":this.params.column&&this.params.column.title||null}});if(this.preview=F(s,"span",{class:`${B.editor}__colour-preview`,attrs:{"aria-hidden":"true"}}),f.appendChild(this.preview),this.swatches.length){const o=F(s,"div",{class:`${B.editor}__colour-swatches`,attrs:{role:"radiogroup","aria-label":this.t("editor.colours")}});for(let g=0;g<this.swatches.length;g++)o.appendChild(this.buildSwatch(this.swatches[g],g));f.appendChild(o)}this.native=F(s,"input",{class:`${B.editor}__colour-native`,attrs:{type:"color","aria-label":this.t("editor.customColour")}}),f.appendChild(this.native),this.hex=F(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")}}),f.appendChild(this.hex),this.props.allowClear===!0&&f.appendChild(this.buildClear()),this.#e.push(W(this.native,"input",()=>this.setColour(this.native?this.native.value:null))),this.#e.push(W(this.native,"change",()=>this.setColour(this.native?this.native.value:null))),this.#e.push(W(this.hex,"input",()=>this.paint())),this.#e.push(W(this.hex,"change",()=>this.paint())),this.#e.push(W(this.hex,"keydown",o=>this.onKeyDown(o))),this.#e.push(W(f,"keydown",o=>this.onKeyDown(o)));const u=G(this.params.value,{alpha:this.alpha()});return this.hex.value=u===null?this.params.value==null?"":String(this.params.value):u,this.params.key&&/^[#0-9a-fA-F]$/.test(this.params.key)&&(this.hex.value=this.params.key),this.paint(),f}buildSwatch(s,f){const u=F(this.doc,"button",{class:`${B.editor}__colour-swatch`,attrs:{type:"button",role:"radio","aria-checked":"false","aria-label":s.label,"data-index":f,"data-variant":s.token}});return s.token||n(u,s.hex),this.#e.push(W(u,"mousedown",o=>{o&&D(o.preventDefault)&&o.preventDefault(),this.setColour(this.swatches[f].hex)})),this.buttons.push(u),u}buildClear(){const s=F(this.doc,"button",{class:`${B.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearColour")}});return this.#e.push(W(s,"mousedown",f=>{f&&D(f.preventDefault)&&f.preventDefault(),this.setColour(null)})),s}focusTarget(){return this.hex}attached(){super.attached();for(let s=0;s<this.swatches.length;s++){const f=this.swatches[s];if(!f.token)continue;const u=l(this.buttons[s]||this.element(),f.token);u&&(f.hex=u)}this.paint()}setColour(s){const f=s===null?null:G(s,{alpha:this.alpha()});this.hex&&(this.hex.value=f===null?"":f),this.paint()}current(){const s=this.hex?String(this.hex.value).trim():"";return s===""?null:G(s,{alpha:this.alpha()})}paint(){const s=this.current(),f=s===null?null:s.slice(0,7);n(this.preview,f),this.preview&&this.preview.setAttribute&&this.preview.setAttribute("data-empty",s===null?"true":"false"),this.native&&(this.native.value=f===null?"#000000":f);for(let u=0;u<this.buttons.length;u++){const o=s!==null&&this.swatches[u].hex.toLowerCase()===s.toLowerCase();this.buttons[u].setAttribute("aria-checked",o?"true":"false"),this.buttons[u].classList.toggle(`${B.editor}__colour-swatch--selected`,o),this.swatches[u].token||n(this.buttons[u],this.swatches[u].hex)}}onKeyDown(s){if(s.key==="Escape"){D(s.preventDefault)&&s.preventDefault(),this.cancel();return}if(s.key==="Enter"){D(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 f=G(s,{alpha:this.alpha()});return f===null?s:f}checkValue(s){if(s==null||s==="")return this.props.allowClear===!0||this.params.value==null?!0:"Choose a colour";const f=H(s);return f?!this.alpha()&&f.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 f=String(s??"").trim();if(f==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a colour"};const u=G(f,{alpha:this.alpha()});if(u===null)return{ok:!1,message:`"${f}" is not a colour`};const o=this.checkValue(u);return o!==!0?{ok:!1,message:o}:{ok:!0,value:u}}destroy(){for(const 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 i(r){const s=Array.isArray(r)&&r.length?r:r===!1?[]:v,f=[];for(const u of s){const o=y(u);o&&f.push(o)}return f}function n(r,s){const f=r&&r.style;if(f){if(s===null){D(f.removeProperty)&&f.removeProperty("--lat-swatch");return}D(f.setProperty)&&f.setProperty("--lat-swatch",s)}}const t=c}),xe("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 L=K("packages/dom/src/editors/select.js").SelectEditorBase,F=K("packages/dom/src/cell/icons.js").createIcon,W=K("packages/dom/src/editors/common.js"),Q=W.CLS,G=W.el,H=W.on,U=W.clear,D=W.keyOf,v=W.rawOptions,S=W.lookupKey,y=K("packages/core/src/internal/util.js"),l=y.isFunction,c=y.isObject,i="\0";class n extends L{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 f=s.parent;f;f=f.parent)this.expanded.add(f.key)}rebuild(){const s=v(this.params,this.props),f=this.props.keys||{},u=f.value||S(this.params,"valueKey")||"id",o=f.label||S(this.params,"labelKey")||"label";this.roots=[],this.nodes=new Map;for(const g of s){if(!c(g)){this.addNode(null,String(g??""),g,null);continue}Array.isArray(g.path)&&g.path.length?this.addByPath(g,u,o):this.addByChildren(g,null,u,o)}if(this.props.defaultExpanded===!0)for(const g of this.nodes.keys())this.expanded.add(g)}addNode(s,f,u,o){const g=s?`${s.key}${i}${f}`:f;let d=this.nodes.get(g);return d?d.id===void 0&&u!==void 0&&(d.id=u):(d={id:u,label:f,key:g,parent:s,children:[],depth:s?s.depth+1:0,disabled:!1},this.nodes.set(g,d),(s?s.children:this.roots).push(d)),o&&(o.disabled===!0&&(d.disabled=!0),o.icon!==void 0&&(d.icon=o.icon),o.variant!==void 0&&(d.variant=o.variant)),d}addByPath(s,f,u){const o=s.path;let g=null;for(let d=0;d<o.length;d++){const h=d===o.length-1,a=String(o[d]),p=h&&s[u]!=null?String(s[u]):a,w=this.addNode(g,a,h?s[f]:void 0,h?s:null);h&&(w.label=p),g=w}}addByChildren(s,f,u,o){const g=s[u],d=s[o]!=null?String(s[o]):String(g??""),h=this.addNode(f,d,g,s),a=Array.isArray(s.children)?s.children:[];for(const p of a)c(p)?this.addByChildren(p,h,u,o):this.addNode(h,String(p??""),p,null)}nodeById(s){if(s==null)return;const f=D(s);for(const u of this.nodes.values())if(u.id!==void 0&&D(u.id)===f)return u}filterOptions(s){const f=String(s||"").trim().toLowerCase(),u=f!=="";this.matched=u?this.computeMatches(f):new Set;const o=[],g=d=>{for(const h of d)u&&!this.matched.has(h.key)||(o.push(h),h.children.length&&(u||this.expanded.has(h.key))&&g(h.children))};return g(this.roots),o}computeMatches(s){const f=new Set,u=o=>{let g=o.label.toLowerCase().includes(s);for(const d of o.children)u(d)&&(g=!0);return g&&f.add(o.key),g};for(const o of this.roots)u(o);return f}repaint(s){if(this.refreshOptions(),!s||!this.list)return;const f=this.visible.findIndex(u=>u.key===s);f>=0&&this.list.setActive(f)}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,f){this.isBranch(s)&&(f?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&&D(s.id)===D(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 f=this.nodeById(s);return f&&this.isSelectable(f)?!0:f?`"${f.label}" is a group, not a value`:this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(s)}" is not a valid option`}renderOption(s,f,u){U(f),f.setAttribute("role","treeitem"),f.setAttribute("aria-level",String(s.depth+1)),f.setAttribute("data-depth",String(s.depth));const o=G(this.doc,"span",{class:"lat-tree__indent"});for(let w=0;w<s.depth;w++)o.appendChild(G(this.doc,"span",{class:"lat-tree__guide"}));f.appendChild(o);const g=this.isBranch(s),d=g&&(this.expanded.has(s.key)||this.query.trim()!==""),h=g?d?"chevronDown":"chevronRight":"blank",a=G(this.doc,"span",{class:g?"lat-tree__twisty":"lat-tree__twisty lat-tree__twisty--leaf",children:[F(this.doc,h,{className:Q.icon})],attrs:{"data-icon":g?h:null,"aria-hidden":"true"}});g&&H(a,"mousedown",w=>{l(w.preventDefault)&&w.preventDefault(),l(w.stopPropagation)&&w.stopPropagation(),this.setExpanded(s,!this.expanded.has(s.key))}),f.appendChild(a),s.icon&&f.appendChild(F(this.doc,s.icon,{className:Q.icon})),f.appendChild(G(this.doc,"span",{class:`${Q.option}__label`,text:s.label})),s.variant?f.setAttribute("data-variant",s.variant):f.removeAttribute("data-variant"),g?f.setAttribute("aria-expanded",d?"true":"false"):f.removeAttribute("aria-expanded");const p=this.isSelected(s);f.classList.toggle(Q.optionSelected,p),f.classList.toggle(Q.optionDisabled,!this.isSelectable(s)),f.classList.toggle("lat-tree__row--branch",g),f.setAttribute("aria-selected",p?"true":"false"),this.isSelectable(s)?f.removeAttribute("aria-disabled"):f.setAttribute("aria-disabled","true")}paintDisplay(){const s=this.display;if(!s)return;if(U(s),this.selected==null){s.removeAttribute("data-variant");return}const f=this.nodeById(this.selected);if(!f){s.appendChild(G(this.doc,"span",{text:String(this.selected)}));return}f.icon&&s.appendChild(F(this.doc,f.icon,{className:Q.icon})),s.appendChild(G(this.doc,"span",{class:"lat-tree__path",text:this.pathLabel(f)})),f.variant?s.setAttribute("data-variant",f.variant):s.removeAttribute("data-variant")}pathLabel(s){const f=[];for(let u=s;u;u=u.parent)f.unshift(u.label);return f.join(String(this.props.pathSeparator??" / "))}onKeyDown(s){const f=this.list,u=f&&f.active>=0?this.visible[f.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)&&f&&f.setActive(Math.min(this.visible.length-1,f.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(),f&&this.visible.length&&f.setActive(0);return;case"End":l(s.preventDefault)&&s.preventDefault(),f&&this.visible.length&&f.setActive(this.visible.length-1);return;default:super.onKeyDown(s)}}focusNode(s){if(!this.list)return;const f=this.visible.findIndex(u=>u.key===s);f>=0&&this.list.setActive(f)}acceptHighlight(s){const f=this.list,u=f&&f.active>=0?this.visible[f.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 f=this.list;if(!f)return;let u=f.active;for(let o=0;o<this.visible.length;o++){if(u+=s,u<0||u>=this.visible.length)return;if(!this.visible[u].disabled){f.setActive(u);return}}}}const t=n}),xe("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 f}}),Object.defineProperty(e,"initialsOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const L=K("packages/dom/src/editors/select.js").SelectEditorBase,B=K("packages/dom/src/editors/common.js"),F=B.CLS,W=B.el,Q=B.on,G=B.clear,H=B.keyOf,U=B.debounce,D=B.rawOptions,v=B.optionSource,S=B.lookupSearch,y=B.lookupKey,l=K("packages/core/src/internal/util.js"),c=l.isFunction,i=l.isObject,n=l.getPath,r=K("packages/dom/src/cell/icons.js").createIcon;class s extends L{static popup=!0;all=[];selected=null;#e=null;#t=!1;#n=null;build(){const h=super.build();if(h.classList.add("lat-objectpicker"),c(this.props.search)&&!(this.lookup&&this.lookup.search)){const a=Number(this.props.searchDebounce)||200;this.#n=U(p=>this.runRemoteSearch(String(p)),a)}return h}onQuery(h){super.onQuery(h),this.#n&&this.#n(h)}initSelection(){const h=D(this.params,this.props).map(a=>this.toOption(a));(h.length||!this.all.length)&&(this.all=h),this.selected=this.params.value??null}toOption(h){if(!i(h)){const b=h==null?"":String(h);return{id:h,label:b,secondary:"",avatar:"",initials:u(b),disabled:!1,raw:{}}}const a=this.props.valueKey||y(this.params,"valueKey")||"id",p=this.props.labelKey||y(this.params,"labelKey")||"label",w=f(h,this.props.template??p,""),k=f(h,this.props.secondary,""),m=f(h,this.props.avatar,"");return{id:h[a],label:w||String(h[a]??""),secondary:k,avatar:m,initials:u(w||String(h[a]??"")),disabled:h.disabled===!0,icon:h.icon,variant:h.variant,raw:h}}attached(){if(super.attached(),this.#t||this.all.length)return;const h=v(this.params,this.props);c(h)&&(this.#t=!0,Promise.resolve(h()).then(a=>{!this.element()||!Array.isArray(a)||(this.all=a.map(p=>this.toOption(p)),this.refreshOptions(),this.paintDisplay())}))}filterOptions(h){const a=String(h||"").trim().toLowerCase();if(a==="")return this.all;const p=o(this.props.searchFields);return this.all.filter(w=>{if(!p)return w.label.toLowerCase().includes(a)||w.secondary.toLowerCase().includes(a);for(const k of p){const m=c(k)?k(w.raw):n(w.raw,k);if(m!=null&&String(m).toLowerCase().includes(a))return!0}return!1})}async runRemoteSearch(h){const a=S(this.params,this.props);if(!a)return;this.#e&&this.#e.abort();const p=new AbortController;this.#e=p;try{const w=await a(h,p.signal);if(p.signal.aborted||this.#e!==p)return;this.refreshOptions(Array.isArray(w)?w.map(k=>this.toOption(k)):[])}catch(w){if(!p.signal.aborted)throw w}finally{this.#e===p&&(this.#e=null)}}choose(h){!h||h.disabled||(this.selected=h.id,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay(),this.commit())}isSelected(h){return this.selected!=null&&h!=null&&H(h.id)===H(this.selected)}clearSelection(){this.selected=null,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay()}readValue(){return this.selected??null}optionById(h){if(h==null)return;const a=H(h);return this.all.find(p=>H(p.id)===a)}checkValue(h){return h==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.all.length||this.optionById(h)||this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(h)}" is not a valid option`}renderOption(h,a,p){G(a),a.appendChild(this.buildAvatar(h));const w=W(this.doc,"span",{class:"lat-object__text"});w.appendChild(W(this.doc,"span",{class:"lat-object__primary",text:h.label})),h.secondary&&w.appendChild(W(this.doc,"span",{class:"lat-object__secondary",text:h.secondary})),a.appendChild(w),h.icon&&a.appendChild(r(this.doc,h.icon,{className:F.icon})),h.variant?a.setAttribute("data-variant",h.variant):a.removeAttribute("data-variant");const k=this.isSelected(h);a.classList.add("lat-object__row"),a.classList.toggle(F.optionSelected,k),a.classList.toggle(F.optionDisabled,h.disabled===!0),a.setAttribute("aria-selected",k?"true":"false"),h.disabled?a.setAttribute("aria-disabled","true"):a.removeAttribute("aria-disabled")}buildAvatar(h){const a=W(this.doc,"span",{class:"lat-avatar",attrs:{"aria-hidden":"true"}});if(!h.avatar)return a.appendChild(W(this.doc,"span",{class:"lat-avatar__initials",text:h.initials})),a.setAttribute("data-fallback","initials"),a;const p=W(this.doc,"img",{class:"lat-avatar__image",attrs:{src:h.avatar,alt:"",loading:"lazy",decoding:"async"}});return Q(p,"error",()=>{p.parentNode===a&&(a.removeChild(p),a.appendChild(W(this.doc,"span",{class:"lat-avatar__initials",text:h.initials})),a.setAttribute("data-fallback","initials"))}),a.appendChild(p),a}paintDisplay(){const h=this.display;if(!h)return;if(G(h),this.selected==null){h.removeAttribute("data-variant");return}const a=this.optionById(this.selected);if(!a){h.appendChild(W(this.doc,"span",{text:this.lookup?this.lookup.label(this.selected):String(this.selected)}));return}h.appendChild(this.buildAvatar(a)),h.appendChild(W(this.doc,"span",{class:"lat-object__primary",text:a.label})),a.variant?h.setAttribute("data-variant",a.variant):h.removeAttribute("data-variant")}destroy(){this.#e&&(this.#e.abort(),this.#e=null),this.#n&&(this.#n.cancel(),this.#n=null),this.all=[],super.destroy()}}function f(d,h,a){if(h==null)return a;const p=c(h)?h(d):n(d,String(h));return p==null?a:String(p)}function u(d){const h=String(d||"").trim().split(/\s+/).filter(w=>w!=="");if(!h.length)return"";const a=[...h[0]][0]||"";if(h.length===1)return a.toUpperCase();const p=[...h[h.length-1]][0]||"";return(a+p).toUpperCase()}function o(d){if(d==null)return null;const a=(Array.isArray(d)?d:[d]).filter(p=>typeof p=="string"||c(p));return a.length?a:null}const g=s}),xe("packages/dom/src/editors/iconpicker.js",function(e,K){"use strict";Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolveNames",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const X=K("packages/dom/src/editors/common.js"),L=X.BaseEditor,B=X.CLS,F=X.VirtualList,W=X.el,Q=X.on,G=X.clear,H=K("packages/dom/src/cell/icons.js"),U=H.createIcon,D=H.iconNames,S=K("packages/core/src/internal/util.js").isFunction;class y extends L{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=W(this.doc,"div",{class:["lat-iconpicker",`${B.editor}__select`],attrs:{role:"combobox","aria-expanded":"true"}});return this.display=W(this.doc,"div",{class:`${B.editor}__display`}),this.input=W(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 F({document:this.doc,itemHeight:Number(n.rowHeight)||34,height:Number(n.listHeight)||204,renderItem:(r,s,f)=>this.renderRow(r,s,f)}),this.list.element().setAttribute("role","grid"),this.list.element().setAttribute("aria-label",this.t("panel.icons")),t.appendChild(this.display),t.appendChild(this.input),n.allowClear===!0&&t.appendChild(this.buildClearButton()),t.appendChild(this.list.element()),this.off.push(Q(this.input,"input",()=>this.onQuery(this.input?this.input.value:""))),this.off.push(Q(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=W(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(Q(n,"mousedown",t=>{S(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=[],G(t);for(let f=0;f<this.columns;f++){const u=W(this.doc,"span",{class:"lat-iconpicker__cell",attrs:{role:"gridcell",tabindex:"-1"}});Q(u,"mousedown",o=>{S(o.preventDefault)&&o.preventDefault();const g=u.getAttribute("data-icon");g&&this.choose(g)}),t.appendChild(u),s.push(u)}t.__latIconCells=s}for(let f=0;f<s.length;f++){const u=s[f],o=n[f];if(o===void 0){u.setAttribute("aria-hidden","true"),u.removeAttribute("data-icon"),u.removeAttribute("title"),u.removeAttribute("aria-label"),u.classList.add("lat-iconpicker__cell--empty"),u.classList.remove("lat-iconpicker__cell--active"),u.classList.remove("lat-iconpicker__cell--selected"),u.__latIconName!==void 0&&(G(u),u.__latIconName=void 0);continue}const g=r*this.columns+f;u.removeAttribute("aria-hidden"),u.classList.remove("lat-iconpicker__cell--empty"),u.setAttribute("data-icon",o),u.setAttribute("title",o),u.setAttribute("aria-label",o),u.__latIconName!==o&&(G(u),u.appendChild(U(this.doc,o,{className:B.icon})),u.__latIconName=o);const d=this.selected===o;u.classList.toggle("lat-iconpicker__cell--active",g===this.cursor),u.classList.toggle("lat-iconpicker__cell--selected",d),u.setAttribute("aria-selected",d?"true":"false")}}paintDisplay(){const n=this.display;if(n){if(G(n),this.selected==null){n.appendChild(W(this.doc,"span",{class:"lat-iconpicker__none",text:this.t("editor.noIcon")}));return}n.appendChild(U(this.doc,this.selected,{className:B.icon})),n.appendChild(W(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=()=>{S(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(i){const n=D();if(Array.isArray(i)&&i.length){const t=new Set(n);return i.map(r=>String(r)).filter(r=>t.has(r))}return n.filter(t=>t!=="blank")}const c=y}),xe("packages/dom/src/editors/temperature.js",function(e,K){"use strict";Object.defineProperty(e,"presentTemperature",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const X=K("packages/dom/src/editors/common.js"),L=X.BaseEditor,B=X.CLS,F=X.el,W=X.on,G=K("packages/core/src/internal/util.js").isFunction,H=K("packages/core/src/columns/types/temperature.js"),U=H.formatTemperature,D=H.parseTemperature,v=H.findScale;function S(c,i){return U(c,{...i,decimals:void 0,minDecimals:0,maxDecimals:20})}class y extends L{input=null;hint=null;opts=null;#e=[];buildOptions(){const i=this.params.column&&this.params.column.dataType||null,n=i&&i.temperatureConfig||{};return{scale:this.props.scale||n.scale||"C",locale:this.params.locale}}build(){const i=this.props;this.opts=this.buildOptions();const n=v(this.opts.scale),t=n?n.scale.symbol:"",r=`${this.id}-scale`,s=F(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:i.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":t?r:null}});s.value=S(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(s.value=this.params.key),this.input=s;const f=typeof i.step=="number"?i.step:0;return f>0&&this.#e.push(W(s,"keydown",u=>{u.key==="ArrowUp"?(G(u.preventDefault)&&u.preventDefault(),this.nudge(f)):u.key==="ArrowDown"&&(G(u.preventDefault)&&u.preventDefault(),this.nudge(-f))})),this.hint=F(this.doc,"span",{class:`${B.editor}__suffix`,text:t,attrs:{id:r,"aria-hidden":"true"}}),F(this.doc,"div",{class:`${B.editor}__unit`,children:[s,this.hint]})}focusTarget(){return this.input}attached(){super.attached();const i=this.input;i&&!this.params.key&&this.props.selectOnFocus!==!1&&G(i.select)&&i.select()}nudge(i){const n=D(this.input?this.input.value:"",this.opts);let t=(n??0)+i;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=S(t,this.opts))}readValue(){const i=this.input?String(this.input.value).trim():"";if(i==="")return null;const n=D(i,this.opts);return n===null?Number.NaN:n}checkValue(i){if(i===null)return!0;if(typeof i!="number"||Number.isNaN(i))return"Enter a temperature";const{min:n,max:t}=this.props;return typeof n=="number"&&i<n?`Must be ${n} or more`:typeof t=="number"&&i>t?`Must be ${t} or less`:!0}destroy(){for(const i of this.#e)i();this.#e=[],this.input=null,this.hint=null,super.destroy()}}const l=y}),xe("packages/dom/src/editors/currency.js",function(e,K){"use strict";Object.defineProperty(e,"presentAmount",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"CurrencyEditor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const X=K("packages/dom/src/editors/common.js"),L=X.BaseEditor,B=X.CLS,F=X.el,W=X.on,G=K("packages/core/src/internal/util.js").isFunction,H=K("packages/core/src/columns/types/currency.js"),U=H.parseMoney,D=H.toMoney,v=H.normaliseCode,S=["USD","EUR","GBP","JPY","CHF","CAD","AUD","CNY"];function y(i){const n=D(i);return n?String(n.amount):""}class l extends L{input=null;picker=null;opts=null;#e=[];buildOptions(){const n=this.params.column&&this.params.column.dataType||null,t=n&&n.currencyConfig||{},r=D(this.params.value),s=v(this.props.code)||r&&r.code||v(t.code)||"USD";let f=this.props.codes||t.codes||S;return f=f.map(u=>v(u)).filter(Boolean),f.includes(s)||(f=[s,...f]),{code:s,codes:f,locale:this.params.locale}}build(){const n=this.props;this.opts=this.buildOptions();const t=F(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=y(this.params.value),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(t.value=this.params.key),this.input=t;const r=F(this.doc,"select",{class:`${B.editor}__suffix`,attrs:{"aria-label":this.t("editor.currency")}});for(const s of this.opts.codes){const f=F(this.doc,"option",{text:s,attrs:{value:s}});s===this.opts.code&&(f.selected=!0),r.appendChild(f)}return this.picker=r,F(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&&G(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=U(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 c=l}),xe("packages/dom/src/editors/index.js",function(e,K){"use strict";Object.defineProperty(e,"TextEditor",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"TextareaEditor",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"NumberEditor",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"DateEditor",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"CheckboxEditor",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"SelectEditor",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"MultiSelectEditor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"TimeEditor",{enumerable:!0,get:function(){return i}}),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 g}}),Object.defineProperty(e,"CodeEditor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"CurrencyEditor",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(e,"editorByType",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return se}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return le}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return fe}});const L=K("packages/dom/src/editors/text.js").TextEditor,F=K("packages/dom/src/editors/textarea.js").TextareaEditor,Q=K("packages/dom/src/editors/number.js").NumberEditor,H=K("packages/dom/src/editors/date.js").DateEditor,D=K("packages/dom/src/editors/checkbox.js").CheckboxEditor,S=K("packages/dom/src/editors/select.js").SelectEditor,l=K("packages/dom/src/editors/multiselect.js").MultiSelectEditor,i=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,g=K("packages/dom/src/editors/password.js").PasswordEditor,h=K("packages/dom/src/editors/code.js").CodeEditor,p=K("packages/dom/src/editors/unit.js").UnitEditor,k=K("packages/dom/src/editors/radix.js").RadixEditor,b=K("packages/dom/src/editors/segmented.js").SegmentedEditor,M=K("packages/dom/src/editors/rating.js").RatingEditor,x=K("packages/dom/src/editors/slider.js").SliderEditor,A=K("packages/dom/src/editors/colour.js").ColourEditor,$=K("packages/dom/src/editors/treeselect.js").TreeSelectEditor,T=K("packages/dom/src/editors/objectpicker.js").ObjectPickerEditor,O=K("packages/dom/src/editors/iconpicker.js").IconPickerEditor,q=K("packages/dom/src/editors/temperature.js").TemperatureEditor,_=K("packages/dom/src/editors/currency.js").CurrencyEditor,J=K("packages/core/src/internal/util.js"),ee=J.isCtor,te=J.isFunction,ne=J.warnOnce,ie=K("packages/dom/src/editors/common.js");for(const be of Object.keys(ie))be!=="default"&&Object.defineProperty(e,be,{enumerable:!0,get:function(){return ie[be]}});const ae=Object.freeze({text:L,textarea:F,number:Q,date:H,checkbox:D,select:S,multiSelect:l,temperature:q,currency:_,time:i,datetime:t,duration:s,ipaddress:u,password:g,code:h,unit:p,radix:k,slider:x,rating:M,segmented:b,treeSelect:$,objectPicker:T,iconPicker:O,colour:A}),re=Object.freeze({text:"text",number:"number",boolean:"checkbox",date:"date",dateString:"date",lookup:"select",object:""});function se(be,Le){const we=be&&be.edit&&be.edit.editor,Re=Le&&Le.editors||{},ge=!!(be&&be.lookup&&be.lookup.multiple);if(ee(we)||te(we))return we;if(typeof we=="string"){if(ge&&we==="select")return l;const Ee=Re[we]||ae[we];if(Ee)return Ee;ne(`editor:missing:${we}`,`unknown editor "${we}"; falling back to the data type default`)}const he=be&&be.type||"text";if(he==="lookup"||be&&be.lookup)return ge?l:S;const Oe=re[he];return Oe&&(Re[Oe]||ae[Oe])||null}function le(be,Le){const we=se(be.column||{},Le);if(!we)return null;const Re=new we;return Re.init(be),te(Re.cancelBeforeStart)&&Re.cancelBeforeStart()===!0?(te(Re.destroy)&&Re.destroy(),null):Re}const fe=ae}),xe("packages/dom/src/ui/statusbar.js",function(e,K){"use strict";Object.defineProperty(e,"aggregate",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"StatusPanel",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"RowCountPanel",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"SelectedCountPanel",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"AggregationPanel",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ProgressPanel",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return i}}),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 f}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const X=K("packages/dom/src/editors/common.js"),L=X.CLS,B=X.documentFor,F=X.el,W=X.clear,G=K("packages/core/src/i18n/index.js").defaultMessages,U=K("packages/core/src/internal/util.js").isFunction;function D(d){let h=0,a=0,p=0,w=null,k=null;for(const m of d||[]){if(m==null||m==="")continue;h++;const b=typeof m=="number"?m:Number(m);Number.isFinite(b)&&(a++,p+=b,(w===null||b<w)&&(w=b),(k===null||b>k)&&(k=b))}return{count:h,numericCount:a,sum:a?p:null,min:w,max:k,avg:a?p/a:null}}class v{root=null;valueNode=null;init(h){this.ctx=h,this.doc=h.document,this.root=F(this.doc,"div",{class:`${L.statusBar}__panel`,attrs:{"data-align":h.align||"end"}}),h.label&&this.root.appendChild(F(this.doc,"span",{class:`${L.statusBar}__label`,text:h.label})),this.valueNode=F(this.doc,"span",{class:`${L.statusBar}__value`,text:""}),this.root.appendChild(this.valueNode)}t(h,a){const p=this.ctx&&this.ctx.messages;return(p&&U(p.t)?p:G).t(h,a)}element(){return this.root}refresh(){const h=this.read();this.valueNode&&this.valueNode.textContent!==h&&(this.valueNode.textContent=h)}read(){return""}destroy(){this.root=null,this.valueNode=null}}class S extends v{read(){const h=this.ctx.host||{},a=U(h.totalRowCount)?h.totalRowCount():0;if(a==null)return this.t("status.counting");const p=U(h.rowCount)?h.rowCount():a,w=this.ctx.noun,k=m=>w===void 0?this.t("count.rows",{count:m}):`${f(m,this.ctx.locale)}${w?` ${w}`:""}`;return p===a?this.t("status.total",{rows:k(a)}):this.t("status.shownOfTotal",{shown:f(p,this.ctx.locale),total:k(a)})}}class y extends v{read(){const h=this.ctx.host||{},a=U(h.selectedAcrossSource)?h.selectedAcrossSource():null;if(a)return typeof a.count=="number"?this.t("status.selectedAcrossSource",{count:a.count}):this.t("status.selectedAcrossSourceCounting");const p=U(h.selectedCount)?h.selectedCount():0;return p?this.t("status.selected",{count:p}):""}}class l extends v{read(){const h=this.ctx.host||{},a=U(h.rangeValues)?h.rangeValues():[],p=D(a);if(!p.count)return"";const w=this.ctx.stats||["count","sum","min","max","avg"],k=[];for(const m of w){if(m==="count"){k.push(this.t("status.count",{count:p.count}));continue}const b=p[m];b!==null&&k.push(`${this.t(`status.stat.${m}`)} ${o(b,this.ctx.locale)}`)}return k.join(" ")}}class c extends v{read(){const h=this.ctx.host||{},a=U(h.progress)?h.progress():null;if(!a)return"";const{loaded:p,estimated:w,done:k}=a;if(k)return"";if(!w)return this.t("status.loading",{count:p||0});const m=Math.min(100,Math.round((p||0)/w*100));return this.t("status.loadingOf",{loaded:p||0,total:w,percent:m})}}class i extends v{read(){const h=this.ctx.host||{},a=U(h.updateStats)?h.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 v{read(){const h=this.ctx.host||{},a=U(h.hiddenUnresolved)?h.hiddenUnresolved():0;return a?this.t("status.hiddenComments",{comments:this.t("count.unresolvedComments",{count:a})}):""}}const t=Object.freeze({rowCount:S,selectedCount:y,aggregation:l,progress:c,updates:i,comments:n});class r{panels=[];root=null;init(h){const a=h||{};this.doc=B(a),this.host=a.host||{},this.messages=a.messages||null,this.root=F(this.doc,"div",{class:L.statusBar,attrs:{role:"status","aria-live":"polite"}});const p=a.registry||{},w=Array.isArray(a.panels)&&a.panels.length?a.panels:["rowCount","selectedCount","aggregation","comments","updates","progress"];for(const k of w){const m=typeof k=="string"?k:k.name,b=typeof k=="function"?k:p[m]||t[m];if(!b)continue;const C=new b;C.init({document:this.doc,host:this.host,locale:a.locale,messages:this.messages,...typeof k=="object"?k.props||{}:{}}),this.panels.push({name:String(m||"panel"),panel:C}),this.root.appendChild(C.element())}this.refresh()}element(){return this.root}addPanel(h,a,p){const w=new a;return w.init({document:this.doc,host:this.host,messages:this.messages,...p||{}}),this.panels.push({name:h,panel:w}),this.root&&this.root.appendChild(w.element()),w.refresh(),w}removePanel(h){const a=this.panels.findIndex(k=>k.name===h);if(a<0)return!1;const[p]=this.panels.splice(a,1),w=p.panel.element();return w&&w.parentNode&&w.parentNode.removeChild(w),U(p.panel.destroy)&&p.panel.destroy(),!0}refresh(){for(const h of this.panels)h.panel.refresh()}destroy(){for(const h of this.panels)U(h.panel.destroy)&&h.panel.destroy();this.panels=[],this.root&&W(this.root),this.root=null}}const s=new Map;function f(d,h){const a=h||"";let p=s.get(a);return p||(p=new Intl.NumberFormat(h||void 0,{maximumFractionDigits:0}),s.set(a,p)),p.format(Number(d)||0)}const u=new Map;function o(d,h){const a=h||"";let p=u.get(a);return p||(p=new Intl.NumberFormat(h||void 0,{maximumFractionDigits:3}),u.set(a,p)),p.format(Number(d)||0)}const g=r}),xe("packages/dom/src/ui/contextmenu.js",function(e,K){"use strict";Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const X=K("packages/dom/src/editors/common.js"),L=X.CLS,B=X.documentFor,F=X.el,W=X.on,Q=X.clear,H=K("packages/core/src/internal/util.js").isFunction,D=K("packages/dom/src/renderer/direction.js").isRtlElement,S=K("packages/dom/src/cell/icons.js").renderIconInto;function y(t,r){const s=[];for(const f of t||[]){const u=H(f)?f(r):f;if(u==null||u===!1)continue;if(u==="separator"){s.push({separator:!0});continue}if(typeof u=="string"){s.push({name:u});continue}const o=u,g=o.subMenu||o.children;g?s.push({...o,subMenu:y(g,r)}):s.push(o)}return s.filter((f,u,o)=>f.separator?u===0||u===o.length-1?!1:!o[u-1].separator:!0)}class l{root=null;itemNodes=[];items=[];focused=-1;child=null;off=[];open=!1;anchor=null;constructor(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,f=H(s.getBoundingClientRect)?s.getBoundingClientRect():{left:0,top:0},u=H(this.root.getBoundingClientRect)?this.root.getBoundingClientRect():{width:0,height:0},o=this.doc.defaultView||{innerWidth:0,innerHeight:0},g=o.innerWidth||0,d=o.innerHeight||0;let h=r.x||0,a=r.y||0;const p=D(s);if(r.anchor&&H(r.anchor.getBoundingClientRect)){const m=r.anchor.getBoundingClientRect();r.placement==="below"?(h=p?m.right-u.width:m.left,a=m.bottom):(h=p?m.left-u.width:m.right,a=m.top)}else p&&(h-=u.width);const w={left:Math.max(0,f.left||0),top:Math.max(0,f.top||0),right:Math.min(g||1/0,(f.left||0)+(f.width||1/0)),bottom:Math.min(d||1/0,(f.top||0)+(f.height||1/0))};h+u.width>w.right&&(h-=u.width),h<w.left&&(h=w.left),a+u.height>w.bottom&&(a-=u.height),a<w.top&&(a=w.top);const k=w.bottom-a;u.height>k&&(this.root.style.maxHeight=`${Math.max(0,Math.floor(k))}px`,this.root.style.overflowY="auto"),this.root.style.left=`${Math.round(h-f.left+(s.scrollLeft||0))}px`,this.root.style.top=`${Math.round(a-f.top+(s.scrollTop||0))}px`}show(r){return this.hide(),r.ctx&&(this.ctx={...this.ctx||{},...r.ctx}),this.items=y(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=F(this.doc,"div",{class:L.menu,attrs:{role:"menu",tabindex:"-1"},style:{position:"absolute"}}),this.itemNodes=[],this.items.forEach((s,f)=>{if(s.separator){this.root.appendChild(F(this.doc,"div",{class:L.menuSeparator,attrs:{role:"separator"}}));return}const u=F(this.doc,"div",{class:[L.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":f}});if(s.icon!=null&&s.icon!==""){const g=F(this.doc,"span",{class:L.icon});S(g,s.icon,`menu:${s.name||f}`),u.appendChild(g)}u.appendChild(F(this.doc,"span",{class:`${L.menuItem}__label`,text:s.name||""})),s.shortcut&&u.appendChild(F(this.doc,"span",{class:`${L.menuItem}__shortcut`,text:s.shortcut})),s.subMenu&&u.appendChild(F(this.doc,"span",{class:`${L.menuItem}__arrow`,text:"›"}));const o=this.itemNodes.length;this.off.push(W(u,"click",()=>this.invoke(o))),this.off.push(W(u,"mouseenter",()=>{this.focus(o),s.subMenu?this.openSubMenu(o):this.closeChild()})),this.itemNodes.push(u),this.root.appendChild(u)}),this.host.appendChild(this.root),this.place(r),this.open=!0,this.off.push(W(this.root,"keydown",s=>this.onKeyDown(s))),H(this.doc.addEventListener)&&this.off.push(W(this.doc,"mousedown",this.outside=s=>{this.root&&!i(this.root,s.target)&&!(this.child&&this.child.root&&i(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(`${L.menuItem}--focused`),this.focused=r;const f=this.itemNodes[r];f.classList.add(`${L.menuItem}--focused`),H(f.focus)&&f.focus(),H(f.scrollIntoView)&&f.scrollIntoView({block:"nearest",inline:"nearest"})}move(r){const s=this.itemNodes.length;if(!s)return;let f=this.focused;for(let u=0;u<s;u++)if(f=(f+r+s)%s,!this.itemAt(f).disabled){this.focus(f);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":c(r),this.move(1);break;case"ArrowUp":c(r),this.move(-1);break;case"Home":c(r),this.focus(this.firstEnabled());break;case"End":c(r),this.focus(this.itemNodes.length-1);break;case"ArrowRight":c(r),this.openSubMenu(this.focused);break;case"ArrowLeft":c(r),this.parent&&(this.hide(),H(this.parent.root?.focus)&&this.parent.root.focus());break;case"Enter":case" ":c(r),this.invoke(this.focused);break;case"Escape":c(r),this.hideRoot();break;default:r.key&&r.key.length===1&&this.jumpTo(r.key);break}}jumpTo(r){const s=r.toLowerCase(),f=this.itemNodes.length;for(let u=1;u<=f;u++){const o=(this.focused+u+f)%f,g=this.itemAt(o);if(!g.disabled&&(g.name||"").toLowerCase().startsWith(s)){this.focus(o);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 c(t){H(t.preventDefault)&&t.preventDefault(),H(t.stopPropagation)&&t.stopPropagation()}function i(t,r){let s=r;for(;s;){if(s===t)return!0;s=s.parentNode}return!1}const n=l}),xe("packages/dom/src/viewpicker.js",function(e,K){"use strict";Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const X=K("packages/dom/src/editors/common.js"),L=X.documentFor,B=X.el,F=X.on,W=X.clear,G=K("packages/core/src/i18n/index.js").defaultMessages,U=K("packages/core/src/internal/util.js").isFunction,v=K("packages/dom/src/cell/icons.js").createIcon,S=Object.freeze({root:"lat-views",head:"lat-views__head",title:"lat-views__title",count:"lat-views__count",list:"lat-views__list",empty:"lat-views__empty",item:"lat-views__item",itemActive:"lat-views__item--active",itemEditing:"lat-views__item--editing",apply:"lat-views__apply",name:"lat-views__name",description:"lat-views__description",badges:"lat-views__badges",badge:"lat-views__badge",badgeDefault:"lat-views__badge--default",badgeShared:"lat-views__badge--shared",badgePrivate:"lat-views__badge--private",diff:"lat-views__diff",diffClean:"lat-views__diff--clean",actions:"lat-views__actions",action:"lat-views__action",actionIcon:"lat-views__action-icon",actionDanger:"lat-views__action--danger",confirm:"lat-views__confirm",foot:"lat-views__foot",input:"lat-views__input",save:"lat-views__save"});class y{root=null;off=[];host={};props={};editing=null;confirming=null;draft="";t(n,t){return(this.messages&&typeof this.messages.t=="function"?this.messages:G).t(n,t)}init(n){this.messages=n&&n.messages||n&&n.grid&&n.grid.messages||G;const t=n||{};this.doc=L(t),this.host=t.host||{},this.props=t.props||{},this.root=B(this.doc,"div",{class:S.root,attrs:{role:"group","aria-label":String(this.props.title||"Saved views")}}),this.refresh()}element(){return this.root}refresh(){const n=this.root;if(!n)return;for(const u of this.off)u();this.off.length=0,W(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:S.empty,text:String(this.props.emptyText||this.t("views.empty"))}));const f=this.buildFoot();f&&n.appendChild(f)}buildList(n){const t=B(this.doc,"div",{class:S.list,attrs:{role:"list"}});for(const r of n)t.appendChild(this.buildItem(r));return t}views(){const n=U(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 U(this.host.activeId)?this.host.activeId():null}buildHead(n,t){return B(this.doc,"div",{class:S.head,children:[B(this.doc,"span",{class:S.title,text:String(n)}),B(this.doc,"span",{class:S.count,text:String(t)})]})}buildItem(n){const t=String(n.id),r=this.activeId()===t,s=U(this.host.canEdit)?this.host.canEdit(n)!==!1:!0,f=B(this.doc,"div",{class:[S.item,r?S.itemActive:"",this.editing===t?S.itemEditing:""],attrs:{role:"listitem","data-view":t,"data-shared":n.shared?"true":"false"}});if(this.editing===t)return f.appendChild(this.buildRenameRow(n)),f;const u=B(this.doc,"button",{class:S.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:S.name,text:String(n.name||"")}),n.isDefault?this.buildBadges(n):null].filter(Boolean)});U(this.host.apply)?this.off.push(F(u,"click",()=>this.applyView(t))):u.setAttribute("disabled",""),n.description&&u.appendChild(B(this.doc,"span",{class:S.description,text:String(n.description)}));const o=this.buildDiff(t,r);return o&&u.appendChild(o),f.appendChild(u),n.builtin||f.appendChild(this.confirming===t?this.buildConfirm(n):this.buildActions(n,s)),f}buildBadges(n){const t=B(this.doc,"span",{class:S.badges});return n.isDefault&&t.appendChild(B(this.doc,"span",{class:[S.badge,S.badgeDefault],text:this.t("views.default"),attrs:{title:"Applied when the grid loads"}})),t}buildDiff(n,t){if(this.props.showDiff!==!0||!U(this.host.diff))return null;const r=this.diffOf(n);if(!r)return null;if(!r.changed)return B(this.doc,"span",{class:[S.diff,S.diffClean],text:this.t(t?"views.applied":"views.matchesGrid")});const s=l(r);return s.length?B(this.doc,"span",{class:S.diff,text:s.join(" · ")}):null}diffOf(n){if(!U(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:S.actions});if(t&&U(this.host.rename)&&s.appendChild(this.buildAction("Rename",`Rename ${n.name}`,()=>{this.editing=r,this.confirming=null,this.refresh(),this.focusInput()},"pencil")),n.isDefault&&U(this.host.clearDefault)?s.appendChild(this.buildAction("Unset default",`Stop applying ${n.name} at load`,()=>{this.host.clearDefault(r),this.refresh()},"pin")):!n.isDefault&&U(this.host.setDefault)&&s.appendChild(this.buildAction("Make default",`Apply ${n.name} when the grid loads`,()=>{this.host.setDefault(r),this.refresh()},"pin")),U(this.host.export)&&s.appendChild(this.buildAction("Share",`Export ${n.name}`,()=>this.host.export(r),"share")),t&&U(this.host.remove)){const f=this.buildAction("Delete",`Delete ${n.name}`,()=>{this.confirming=r,this.refresh()},"trash");f.classList.add(S.actionDanger),s.appendChild(f)}return s}buildConfirm(n){const t=String(n.id),r=B(this.doc,"span",{class:S.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(S.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:S.confirm}),s=B(this.doc,"input",{class:S.input,attrs:{type:"text","aria-label":`New name for ${n.name}`}});s.value=String(n.name||""),this.input=s;const f=()=>{const o=String(s.value||"").trim();this.editing=null,o&&o!==n.name&&this.host.rename(t,o),this.refresh()},u=()=>{this.editing=null,this.refresh()};return this.off.push(F(s,"keydown",o=>{o.key==="Enter"?f():o.key==="Escape"&&u()})),r.appendChild(s),r.appendChild(this.buildAction("Save","Save the new name",f)),r.appendChild(this.buildAction("Cancel","Leave the name alone",u)),r}buildFoot(){if(this.props.allowSave===!1||!U(this.host.saveAs))return null;const n=B(this.doc,"div",{class:S.foot}),t=B(this.doc,"input",{class:S.input,attrs:{type:"text",placeholder:this.t("views.namePlaceholder"),"aria-label":this.t("views.nameLabel")}});t.value=this.draft,this.editing===null&&(this.input=t);const r=()=>{const f=String(t.value||"").trim();if(!f){U(t.focus)&&t.focus();return}this.draft="",this.host.saveAs(f),this.refresh()};this.off.push(F(t,"input",()=>{this.draft=String(t.value||"")})),this.off.push(F(t,"keydown",f=>{f.key==="Enter"&&r()}));const s=B(this.doc,"button",{class:S.save,text:this.t("views.save"),attrs:{type:"button"}});return this.off.push(F(s,"click",r)),n.appendChild(t),n.appendChild(s),n}buildAction(n,t,r,s){const f=B(this.doc,"button",{class:S.action,text:s?null:n,attrs:{type:"button",title:t,"aria-label":t,"data-action":n}});return s&&f.appendChild(v(this.doc,s,{className:S.actionIcon})),this.off.push(F(f,"click",r)),f}applyView(n){this.confirming=null,this.host.apply(n),this.refresh()}focusInput(){const n=this.input;n&&U(n.focus)&&n.focus(),n&&U(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(i,n=3){if(!i||!i.changed)return[];const t=i.counts||{},r=[],s=(f,u,o)=>{f&&r.push((f===1?u:o).replace("%",String(f)))};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"),i.filters&&i.filters.changed){const f=t.filterColumns||0;r.push(f?`changes ${f} filter${f===1?"":"s"}`:"changes the filter")}return i.quick&&i.quick.changed&&r.push("changes the search"),i.sort&&i.sort.changed&&r.push("changes the sort"),i.group&&i.group.changed&&r.push("changes the grouping"),i.pivot&&i.pivot.changed&&r.push("changes the pivot"),s(t.columnsTotalled,"changes % total","changes % totals"),i.pagination&&i.pagination.changed&&r.push("changes the page size"),r.length<=n?r:[...r.slice(0,n),`and ${r.length-n} more`]}const c=y}),xe("packages/dom/src/ui/panelbase.js",function(e,K){"use strict";Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return Q}});const X=K("packages/dom/src/editors/common.js"),L=X.CLS,B=X.el,W=K("packages/core/src/i18n/index.js").defaultMessages;class Q{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:`${L.panel}__body`}),this.refresh()}t(H,U){const D=this.host||{};if(typeof D.t=="function")return D.t(H,U);const v=this.ctx||{};if(v.messages&&typeof v.messages.t=="function")return v.messages.t(H,U);const S=v.grid;return(S&&S.messages?S.messages:W).t(H,U)}element(){return this.root}refresh(){}destroy(){for(const H of this.off)H();this.off.length=0,this.root=null}}}),xe("packages/dom/src/formattingpanel.js",function(e,K){"use strict";Object.defineProperty(e,"describeRule",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"FormattingPanel",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createFormattingPanel",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return p}});const X=K("packages/dom/src/editors/common.js"),L=X.CLS,B=X.documentFor,F=X.el,W=X.on,Q=X.clear,H=K("packages/core/src/internal/util.js").isFunction,D=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,v=K("packages/core/src/formatting/rules.js"),S=v.compileRules,y=v.summariseColumn,l=v.needsDistribution,c=v.DISTRIBUTION_LABELS,i="*",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:c.topPercent,values:1},{op:"bottomPercent",label:c.bottomPercent,values:1},{op:"topN",label:c.topN,values:1},{op:"bottomN",label:c.bottomN,values:1},{op:"aboveMean",label:c.aboveMean,values:0},{op:"belowMean",label:c.belowMean,values:0},{op:"aboveMedian",label:c.aboveMedian,values:0},{op:"belowMedian",label:c.belowMedian,values:0},{op:"zAbove",label:c.zAbove,values:1},{op:"zBelow",label:c.zBelow,values:1},{op:"outlier",label:c.outlier,values:0}]),s=Object.freeze([...t,...r]),f=Object.freeze([{name:"Red",background:"#fbeceb",color:"#b03030"},{name:"Amber",background:"#fdf3e0",color:"#9a6400"},{name:"Green",background:"#e8f5ee",color:"#1a7f4b"},{name:"Blue",background:"#e7f0fb",color:"#1a6bc7"},{name:"Grey",background:"#f1f3f5",color:"#5b6570"}]),u=Object.freeze([{name:"White → Blue",colours:["#f8f9fa","#1a6bc7"]},{name:"White → Green",colours:["#f8f9fa","#1a7f4b"]},{name:"Red → Green",colours:["#d64545","#f6e58d","#1a7f4b"]},{name:"Blue → White → Red",colours:["#1a6bc7","#f8f9fa","#d64545"]}]),o=Object.freeze([{from:"minmax",label:"across the full range"},{from:"quantile",label:"across the middle 90%"},{from:"stddev",label:"within 2 deviations of the mean"}]);function g(w){const k=s.find(m=>m.op===w);return k?k.values:1}function d(w){if(!w)return"";if(w.scale){const{min:C,max:M,from:P}=w.scale;if(Number.isFinite(C)&&Number.isFinite(M))return`Colour scale, ${C} to ${M}`;const x=o.find(E=>E.from===P);return x?`Colour scale ${x.label}`:"Colour scale"}const k=w.when||{},m=s.find(C=>C.op===k.op),b=m?m.label:k.op;return!m||m.values===0?`Value ${b}`:m.values===2?`Value ${b} ${k.value} and ${k.value2}`:`Value ${b} ${k.value}`}class h extends D{scope=i;mode="condition";refresh(){const k=this.root;if(k){for(const m of this.off)m();this.off.length=0,Q(k),k.appendChild(this.#o()),k.appendChild(this.#i()),k.appendChild(this.#l())}}#e(){const k=H(this.host.formattableColumns)?this.host.formattableColumns():[];return[{id:i,title:"All columns"},...k]}#t(){return H(this.host.formattingRules)?this.host.formattingRules(this.scope):[]}#n(k){if(!H(this.host.columnSamples))return[];const m=this.host.columnSamples(k);return Array.isArray(m)?m:[...m||[]]}#r(k,m,b){const C=l(k)?y(m):null;return S(k,C)({value:b})}#o(){const k=F(this.doc,"div",{class:`${L.panel}__row`});k.appendChild(F(this.doc,"label",{class:`${L.panel}__label`,text:this.t("formatting.format"),attrs:{for:"lat-fmt-scope"}}));const m=F(this.doc,"select",{class:`${L.panel}__select`,attrs:{id:"lat-fmt-scope"}});for(const b of this.#e()){const C=F(this.doc,"option",{text:b.title,attrs:{value:b.id}});b.id===this.scope&&C.setAttribute("selected","selected"),m.appendChild(C)}return m.value=this.scope,this.off.push(W(m,"change",()=>{this.scope=m.value||i,this.refresh()})),k.appendChild(m),k}#i(){const k=F(this.doc,"ul",{class:`${L.panel}__list`}),m=this.#t();if(!m.length)return k.appendChild(F(this.doc,"li",{class:`${L.panel}__empty`,text:this.t("formatting.noRules")})),k;m.forEach((M,P)=>{const x=F(this.doc,"li",{class:`${L.panel}__item`,attrs:{"data-rule":M.id}}),E=F(this.doc,"input",{attrs:{type:"checkbox","aria-label":`Enable ${d(M)}`}});E.checked=M.enabled!==!1,this.off.push(W(E,"change",()=>{this.#c("updateRule",this.scope,M.id,{enabled:E.checked})})),x.appendChild(E);const A=F(this.doc,"span",{class:`${L.panel}__swatch`}),j=M.style||{};if(j.background&&A.style&&A.style.setProperty)A.style.setProperty("background",String(j.background));else if(M.scale&&M.scale.colours&&A.style&&A.style.setProperty){const R=M.scale.colours;A.style.setProperty("background",`linear-gradient(90deg, ${R[0]}, ${R[R.length-1]})`)}x.appendChild(A),x.appendChild(F(this.doc,"span",{class:`${L.panel}__text`,text:d(M)}));const $=F(this.doc,"button",{class:`${L.panel}__icon`,text:"↑",attrs:{type:"button","aria-label":this.t("formatting.moveEarlier"),...P===0?{disabled:"disabled"}:{}}});this.off.push(W($,"click",()=>this.#c("moveRule",this.scope,M.id,P-1))),x.appendChild($);const z=F(this.doc,"button",{class:`${L.panel}__icon`,text:"↓",attrs:{type:"button","aria-label":this.t("formatting.moveLater"),...P===m.length-1?{disabled:"disabled"}:{}}});this.off.push(W(z,"click",()=>this.#c("moveRule",this.scope,M.id,P+1))),x.appendChild(z);const T=F(this.doc,"button",{class:`${L.panel}__icon`,text:"×",attrs:{type:"button","aria-label":`Remove ${d(M)}`}});this.off.push(W(T,"click",()=>this.#c("removeRule",this.scope,M.id))),x.appendChild(T),k.appendChild(x)});const b=this.#s(m);b&&k.appendChild(b);const C=F(this.doc,"button",{class:`${L.panel}__link`,text:this.t("formatting.clearAll"),attrs:{type:"button"}});return this.off.push(W(C,"click",()=>this.#c("clearRules",this.scope))),k.appendChild(C),k}#s(k){const m=this.#n(this.scope);if(!m.length)return null;const b=k.filter(M=>M.enabled!==!1);if(!b.length)return null;const C=F(this.doc,"div",{class:`${L.panel}__preview`,attrs:{"aria-label":this.t("formatting.preview")}});for(const M of m.slice(0,n)){const P=this.#r(b,m,M),x=F(this.doc,"span",{class:`${L.panel}__previewcell`,text:String(M)});P&&x.style&&x.style.setProperty&&(P.background&&x.style.setProperty("background",String(P.background)),P.color&&x.style.setProperty("color",String(P.color))),C.appendChild(x)}return C}#l(){const k=F(this.doc,"div",{class:`${L.panel}__form`}),m=F(this.doc,"select",{class:`${L.panel}__select`,attrs:{"aria-label":this.t("formatting.ruleKind")}});return m.appendChild(F(this.doc,"option",{text:this.t("formatting.aCondition"),attrs:{value:"condition"}})),m.appendChild(F(this.doc,"option",{text:this.t("formatting.aColourScale"),attrs:{value:"scale"}})),m.value=this.mode,this.off.push(W(m,"change",()=>{this.mode=m.value==="scale"?"scale":"condition",this.refresh()})),k.appendChild(m),this.mode==="scale"?k.appendChild(this.#u()):k.appendChild(this.#a()),k}#a(){const k=F(this.doc,"div",{class:`${L.panel}__form`}),m=F(this.doc,"select",{class:`${L.panel}__select`,attrs:{"aria-label":this.t("formatting.condition")}}),b=F(this.doc,"optgroup",{attrs:{label:this.t("formatting.compare")}});for(const T of t)b.appendChild(F(this.doc,"option",{text:T.label,attrs:{value:T.op}}));m.appendChild(b);const C=F(this.doc,"optgroup",{attrs:{label:this.t("formatting.distribution")}});for(const T of r)C.appendChild(F(this.doc,"option",{text:T.label,attrs:{value:T.op}}));m.appendChild(C),m.value="gt",k.appendChild(m);const M=F(this.doc,"input",{class:`${L.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.value")}}),P=F(this.doc,"input",{class:`${L.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.secondValue")}});k.appendChild(M),k.appendChild(P);const x=()=>{const T=g(m.value);M.style.setProperty("display",T>=1?"":"none"),P.style.setProperty("display",T>=2?"":"none"),$()};this.off.push(W(m,"change",x));const E=F(this.doc,"select",{class:`${L.panel}__select`,attrs:{"aria-label":this.t("menu.colour")}});for(const T of f)E.appendChild(F(this.doc,"option",{text:T.name,attrs:{value:T.name}}));E.value=f[0].name,k.appendChild(E);const A=F(this.doc,"div",{class:`${L.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});k.appendChild(A);const j=()=>{const T=f.find(I=>I.name===E.value)||f[0],R=g(m.value),O={op:m.value};return R>=1&&(O.value=M.value),R>=2&&(O.value2=P.value),{when:O,style:{background:T.background,color:T.color}}},$=()=>{Q(A);const T=this.#n(this.scope);if(T.length)for(const R of T.slice(0,n)){const O=this.#r([j()],T,R),I=F(this.doc,"span",{class:`${L.panel}__previewcell`,text:String(R)});O&&I.style&&I.style.setProperty&&(O.background&&I.style.setProperty("background",String(O.background)),O.color&&I.style.setProperty("color",String(O.color))),A.appendChild(I)}};this.off.push(W(M,"input",$)),this.off.push(W(P,"input",$)),this.off.push(W(E,"change",$)),x();const z=F(this.doc,"button",{class:`${L.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(W(z,"click",()=>{this.#c("addRule",this.scope,j()),M.value="",P.value=""})),k.appendChild(z),k}#u(){const k=F(this.doc,"div",{class:`${L.panel}__form`}),m=F(this.doc,"select",{class:`${L.panel}__select`,attrs:{"aria-label":this.t("formatting.colourScale")}});for(const E of u)m.appendChild(F(this.doc,"option",{text:E.name,attrs:{value:E.name}}));m.value=u[0].name,k.appendChild(m);const b=F(this.doc,"select",{class:`${L.panel}__select`,attrs:{"aria-label":this.t("formatting.scaleBounds")}});for(const E of o)b.appendChild(F(this.doc,"option",{text:E.label,attrs:{value:E.from}}));b.value=o[0].from,k.appendChild(b);const C=F(this.doc,"div",{class:`${L.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});k.appendChild(C);const M=()=>{const E=u.find(A=>A.name===m.value)||u[0];return{scale:{from:b.value,colours:[...E.colours]}}},P=()=>{Q(C);const E=this.#n(this.scope);if(E.length)for(const A of E.slice(0,n)){const j=this.#r([M()],E,A),$=F(this.doc,"span",{class:`${L.panel}__previewcell`,text:String(A)});j&&j.background&&$.style&&$.style.setProperty&&$.style.setProperty("background",String(j.background)),C.appendChild($)}};this.off.push(W(m,"change",P)),this.off.push(W(b,"change",P)),P();const x=F(this.doc,"button",{class:`${L.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(W(x,"click",()=>{this.#c("addRule",this.scope,M())})),k.appendChild(x),k}#c(k,...m){H(this.host[k])&&this.host[k](...m),this.refresh()}}function a(w={}){const k=new h;return k.init({document:B(w),host:w.host||{}}),k}const p=h}),xe("packages/dom/src/statisticspanel.js",function(e,K){"use strict";Object.defineProperty(e,"StatisticsPanel",{enumerable:!0,get:function(){return l}});const X=K("packages/dom/src/editors/common.js"),L=X.CLS,B=X.el,F=X.on,W=X.clear,G=K("packages/core/src/internal/util.js").isFunction,U=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,D=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"}]),v=Object.freeze([{key:"present",label:"stats.present",kind:"count"},{key:"missing",label:"stats.missing",kind:"count"},{key:"distinct",label:"stats.distinct",kind:"count"}]),S=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 y(c){if(c==null||!Number.isFinite(c))return"—";if(Number.isInteger(c))return String(c);const i=Math.abs(c);return i!==0&&(i<.001||i>=1e7)?c.toExponential(2):String(Number(c.toPrecision(4)))}class l extends U{column=null;#e(){return G(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const i=this.root;if(!i)return;for(const s of this.off)s();this.off.length=0,W(i);const n=this.#e();if(!n.length){i.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("stats.noColumns")}));return}n.some(s=>s.id===this.column)||(this.column=n[0].id),i.appendChild(this.#t(n));const t=G(this.host.columnProfile)?this.host.columnProfile(this.column):null;if(!t||!t.present){i.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("stats.noValues")}));return}if(i.appendChild(B(this.doc,"p",{class:`${L.panel}__count`,text:this.t("stats.filtered",{count:t.rows})})),Array.isArray(t.topValues)){i.appendChild(this.#o(t,v)),i.appendChild(this.#i(t.topValues));return}i.appendChild(this.#o(t));for(const s of S){const f=this.#n(s);f&&i.appendChild(f)}const r=this.#r();r&&i.appendChild(r),t.histogram&&t.histogram.length>1&&i.appendChild(this.#s(t.histogram))}#t(i){const n=B(this.doc,"select",{class:`${L.panel}__select`,attrs:{"aria-label":this.t("stats.choose")}});for(const t of i){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(F(n,"change",()=>{this.column=n.value,this.refresh()})),B(this.doc,"label",{class:`${L.panel}__field`,children:[B(this.doc,"span",{class:`${L.panel}__label`,text:this.t("stats.column")}),n]})}#n(i){const n=this.host.reduceColumn;if(!G(n)||!this.column)return null;const t=[];for(const f of i.kernels){const u=n(this.column,f);u==null||Number.isNaN(u)||t.push([f,u])}if(!t.length)return null;const r=this.doc.createElement("div");r.appendChild(B(this.doc,"h4",{class:`${L.panel}__subtitle`,text:this.t(i.label)}));const s=B(this.doc,"dl",{class:`${L.panel}__stats`});for(const[f,u]of t)s.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-name`,text:this.t(`total.${f}`)})),s.appendChild(B(this.doc,"dd",{class:`${L.panel}__stat-value`,text:typeof u=="number"?y(u):String(u)}));return r.appendChild(s),r}#r(){const i=this.host.columnCapability;if(!G(i)||!this.column)return null;const n=i(this.column);if(!n)return null;const t=this.doc.createElement("div");t.appendChild(B(this.doc,"h4",{class:`${L.panel}__subtitle`,text:this.t("stats.section.capability")}));const r=B(this.doc,"dl",{class:`${L.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[f,u,o]of s){if(u==null)continue;r.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-name`,text:this.t(f)}));const g=[B(this.doc,"span",{text:y(u)})];o&&Number.isFinite(o.lower)&&g.push(B(this.doc,"span",{class:`${L.panel}__stat-interval`,text:`${y(o.lower)} – ${y(o.upper)}`,attrs:{title:`${Math.round(o.confidence*100)}%`}})),r.appendChild(B(this.doc,"dd",{class:`${L.panel}__stat-value`,children:g}))}return t.appendChild(r),t}#o(i,n=D){const t=B(this.doc,"dl",{class:`${L.panel}__stats`});for(const r of n){const s=i[r.key];t.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-name`,text:this.t(r.label)})),t.appendChild(B(this.doc,"dd",{class:`${L.panel}__stat-value`,text:r.kind==="count"?String(s??0):y(s)}))}return t}#i(i){const n=this.doc.createElement("div");n.appendChild(B(this.doc,"h4",{class:`${L.panel}__subtitle`,text:this.t("stats.topValues")}));const t=B(this.doc,"dl",{class:`${L.panel}__stats`});for(const r of i)t.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-name`,text:String(r.value)})),t.appendChild(B(this.doc,"dd",{class:`${L.panel}__stat-value`,children:[B(this.doc,"span",{text:String(r.count)}),B(this.doc,"span",{class:`${L.panel}__stat-interval`,text:`${Math.round(r.share*100)}%`})]}));return n.appendChild(t),n}#s(i){const n=i.reduce((r,s)=>Math.max(r,s.count),0)||1,t=B(this.doc,"div",{class:`${L.panel}__histogram`});t.appendChild(B(this.doc,"h4",{class:`${L.panel}__subtitle`,text:this.t("stats.distribution")}));for(const r of i){const s=B(this.doc,"div",{class:`${L.panel}__bar`,style:{width:`${r.count?Math.max(2,r.count/n*100):0}%`}});t.appendChild(B(this.doc,"div",{class:`${L.panel}__bin`,attrs:{title:this.t("stats.bin",{count:r.count,from:y(r.from),to:y(r.to)})},children:[s]}))}return t}}}),xe("packages/dom/src/regressionpanel.js",function(e,K){"use strict";Object.defineProperty(e,"RegressionPanel",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const X=K("packages/dom/src/editors/common.js"),L=X.CLS,B=X.el,F=X.clear,Q=K("packages/core/src/internal/util.js").isFunction,H=K("packages/dom/src/ui/panelbase.js").ToolPanelBase;function U(S,y=4){const l=Number(S);return Number.isFinite(l)?l.toFixed(y):l===1/0?"∞":"—"}class D extends H{#e(){const y=this.props||{};if(Array.isArray(y.predictors)&&y.predictors.length&&y.response)return y;const l=this.ctx&&this.ctx.grid,c=l&&Q(l.get)?l.get("regression"):null;return c&&Array.isArray(c.predictors)&&c.response?c:null}refresh(){const y=this.root;if(!y)return;F(y);const l=this.#e();if(!l){y.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("regression.noModel")}));return}const c=Q(this.host.regressionModel)?this.host.regressionModel(l):null;if(!c){y.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("regression.cannotFit")}));return}y.appendChild(B(this.doc,"p",{class:`${L.panel}__count`,text:this.t("regression.observations",{count:c.n})})),y.appendChild(this.#t(c)),y.appendChild(this.#n(c));const i=this.#r(c,l);i&&y.appendChild(i),y.appendChild(this.#o(c))}#t(y){const l=B(this.doc,"dl",{class:`${L.panel}__stats`}),c=(i,n)=>{l.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-label`,text:i})),l.appendChild(B(this.doc,"dd",{class:`${L.panel}__stat-value`,text:n}))};return c(this.t("regression.r2"),U(y.r2,4)),c(this.t("regression.adjR2"),U(y.adjR2,4)),l}#n(y){const l=B(this.doc,"div",{class:`${L.panel}__section`});l.appendChild(B(this.doc,"h4",{class:`${L.panel}__heading`,text:this.t("regression.coefficients")}));const c=B(this.doc,"table",{class:`${L.panel}__coef-table`}),i=B(this.doc,"tr");for(const n of["regression.term","regression.estimate","regression.stdError","regression.t","regression.p"])i.appendChild(B(this.doc,"th",{text:this.t(n)}));c.appendChild(i);for(const n of y.coefficients){const t=B(this.doc,"tr");t.appendChild(B(this.doc,"td",{text:n.name})),t.appendChild(B(this.doc,"td",{text:`${U(n.estimate)} ± ${U(n.stdError)}`})),t.appendChild(B(this.doc,"td",{text:U(n.stdError)})),t.appendChild(B(this.doc,"td",{text:U(n.t,3)})),t.appendChild(B(this.doc,"td",{text:U(n.p,4)})),c.appendChild(t)}return l.appendChild(c),l}#r(y,l){if(!Array.isArray(y.vif)||y.vif.length<2)return null;const c=B(this.doc,"div",{class:`${L.panel}__section`});c.appendChild(B(this.doc,"h4",{class:`${L.panel}__heading`,text:this.t("regression.vif")}));const i=B(this.doc,"dl",{class:`${L.panel}__stats`});return y.vif.forEach((n,t)=>{i.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-label`,text:l.predictors[t]})),i.appendChild(B(this.doc,"dd",{class:`${L.panel}__stat-value`,text:U(n,3)}))}),c.appendChild(i),c}#o(y){const l=y.heteroscedasticity,c=B(this.doc,"div",{class:`${L.panel}__section`});return c.appendChild(B(this.doc,"h4",{class:`${L.panel}__heading`,text:this.t("regression.heteroscedasticity")})),l?(c.appendChild(B(this.doc,"p",{class:`${L.panel}__flag`,attrs:{"data-heteroscedastic":l.heteroscedastic?"true":"false"},text:this.t(l.heteroscedastic?"regression.heteroscedastic":"regression.homoscedastic",{statistic:U(l.statistic,3),p:U(l.p,4)})})),c):(c.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("regression.cannotFit")})),c)}}const v=D}),xe("packages/dom/src/comparepanel.js",function(e,K){"use strict";Object.defineProperty(e,"ComparePanel",{enumerable:!0,get:function(){return S}});const X=K("packages/dom/src/editors/common.js"),L=X.CLS,B=X.el,F=X.on,W=X.clear,G=K("packages/core/src/internal/util.js").isFunction,U=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,D=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 v(y){if(y==null||!Number.isFinite(y))return"—";if(Number.isInteger(y))return String(y);const l=Math.abs(y);return l!==0&&(l<.001||l>=1e7)?y.toExponential(2):String(Number(y.toPrecision(4)))}class S extends U{first=null;second=null;#e(){return G(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,W(l);const c=this.#e();if(c.length<2){l.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("compare.needTwo")}));return}c.some(t=>t.id===this.first)||(this.first=c[0].id),(!c.some(t=>t.id===this.second)||this.second===this.first)&&(this.second=(c.find(t=>t.id!==this.first)||c[0]).id),l.appendChild(this.#t("compare.first",c,this.first,t=>{this.first=t,this.second===t&&(this.second=(c.find(r=>r.id!==t)||c[0]).id),this.refresh()})),l.appendChild(this.#t("compare.second",c,this.second,t=>{this.second=t,this.first===t&&(this.first=(c.find(r=>r.id!==t)||c[0]).id),this.refresh()}));const i=G(this.host.compareColumns)?this.host.compareColumns(this.first,this.second):null;if(!i||!i.n){l.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("compare.noPairs")}));return}l.appendChild(B(this.doc,"p",{class:`${L.panel}__count`,text:this.t("compare.pairs",{count:i.n})}));const n=B(this.doc,"dl",{class:`${L.panel}__stats`});for(const t of D){const r=i[t.key];r!=null&&(n.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-name`,text:this.t(t.label)})),n.appendChild(B(this.doc,"dd",{class:`${L.panel}__stat-value`,text:v(r)})))}l.appendChild(n)}#t(l,c,i,n){const t=B(this.doc,"select",{class:`${L.panel}__select`,attrs:{"aria-label":this.t(l)}});for(const r of c)t.appendChild(B(this.doc,"option",{text:r.title,attrs:{value:r.id,selected:r.id===i?!0:null}}));return t.value=i,this.off.push(F(t,"change",()=>n(t.value))),B(this.doc,"label",{class:`${L.panel}__field`,children:[B(this.doc,"span",{class:`${L.panel}__label`,text:this.t(l)}),t]})}}}),xe("packages/dom/src/insightspanel.js",function(e,K){"use strict";Object.defineProperty(e,"InsightsPanel",{enumerable:!0,get:function(){return S}});const X=K("packages/dom/src/editors/common.js"),L=X.CLS,B=X.el,F=X.on,W=X.clear,G=K("packages/core/src/internal/util.js").isFunction,U=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,D=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 v(y){if(y==null||!Number.isFinite(y))return"—";if(Number.isInteger(y))return String(y);const l=Math.abs(y);return l!==0&&(l<.001||l>=1e7)?y.toExponential(2):String(Number(y.toPrecision(4)))}class S extends U{column=null;by=null;#e(){return G(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,W(l);const c=this.#e();if(!c.length){l.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("insights.empty")}));return}const i=this.#t();i&&l.appendChild(i);const n=this.#n();n&&l.appendChild(n),l.appendChild(this.#o(c));const t=this.#s();t&&l.appendChild(t);const r=this.#u();r&&l.appendChild(r)}#t(){if(!G(this.host.subsetVsPopulation))return null;const l=this.host.subsetVsPopulation();if(!l)return null;const c=this.#c("insights.subset");return l.filtered?(c.appendChild(B(this.doc,"p",{class:`${L.panel}__count`,text:this.t("stats.filtered",{count:l.subsetN})})),c.appendChild(this.#r(l.ranked)),c):(c.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("insights.noFilter")})),c)}#n(){const l=this.props&&this.props.other;if(!l||!G(this.host.datasetVsDataset))return null;let c;try{c=this.host.datasetVsDataset(l)}catch{return null}if(!c||!c.ranked)return null;const i=this.#c("insights.dataset");return i.appendChild(this.#r(c.ranked)),i}#r(l){const c=B(this.doc,"dl",{class:`${L.panel}__stats`});for(const i of l||[]){const n=B(this.doc,"dt",{class:`${L.panel}__stat-name`});n.appendChild(B(this.doc,"span",{text:String(i.name??i.column)})),n.appendChild(B(this.doc,"span",{class:`${L.panel}__stat-interval`,text:String(i.measure||"")}));const t=B(this.doc,"dd",{class:`${L.panel}__stat-value`});t.appendChild(B(this.doc,"span",{text:v(i.magnitude)})),i.reliable===!1&&t.appendChild(B(this.doc,"span",{class:`${L.panel}__stat-interval`,text:this.t("insights.smallSample")})),c.appendChild(n),c.appendChild(t)}return c}#o(l){const c=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),c.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()})),c.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 i=G(this.host.compareGroups)?this.host.compareGroups(this.column,{by:this.by}):null;return i?(c.appendChild(this.#i(i)),c):(c.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("insights.needGroups")})),c)}#i(l){const c=B(this.doc,"dl",{class:`${L.panel}__stats`});Array.isArray(l.groups)&&l.groups.length===2&&this.#a(c,"insights.groups",`${l.groups[0]} · ${l.groups[1]}`),this.#a(c,"insights.test",String(l.method||l.test||""));const i=l.effectSize||{};this.#a(c,"insights.effect",`${i.name||""} ${v(i.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=`${v(n.lower)} – ${v(n.upper)}${s}`}const r=this.#a(c,"insights.interval",t);return n&&n.method&&r.appendChild(B(this.doc,"span",{class:`${L.panel}__stat-interval`,text:String(n.method)})),Number.isFinite(l.pValue)&&this.#a(c,"insights.pValue",v(l.pValue)),c}#s(){if(!G(this.host.anomalies))return null;let l;try{l=this.host.anomalies()}catch{return null}if(!l)return null;const c=this.#c("insights.anomalies");c.appendChild(B(this.doc,"p",{class:`${L.panel}__count`,text:this.t("insights.anomalyCount",{count:l.flagged||0,n:l.n||0})}));const i=B(this.doc,"dl",{class:`${L.panel}__stats`});this.#a(i,"insights.anomalyMethod",String(l.method||""));const n=this.#l(l);n!==null&&this.#a(i,"insights.anomalyThreshold",v(n)),c.appendChild(i);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 c.appendChild(this.#r(t)),c}#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 c=Array.isArray(l.columns)?l.columns[0]:null;return c&&Number.isFinite(c.threshold)?c.threshold:null}#a(l,c,i){l.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-name`,text:this.t(c)}));const n=B(this.doc,"dd",{class:`${L.panel}__stat-value`});return n.appendChild(B(this.doc,"span",{text:i})),l.appendChild(n),n}#u(){if(!G(this.host.columnCapability)||!this.column)return null;const l=this.host.columnCapability(this.column);if(!l)return null;const c=this.#c("stats.section.capability"),i=B(this.doc,"dl",{class:`${L.panel}__stats`});for(const n of D){const t=l[n.field];if(t==null)continue;i.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-name`,text:this.t(n.key)}));const r=[B(this.doc,"span",{text:v(t)})],s=n.interval?l[n.interval]:null;s&&Number.isFinite(s.lower)&&r.push(B(this.doc,"span",{class:`${L.panel}__stat-interval`,text:`${v(s.lower)} – ${v(s.upper)}`,attrs:{title:`${Math.round(s.confidence*100)}%`}})),i.appendChild(B(this.doc,"dd",{class:`${L.panel}__stat-value`,children:r}))}return c.appendChild(i),c}#c(l){const c=this.doc.createElement("div");return c.appendChild(B(this.doc,"h4",{class:`${L.panel}__subtitle`,text:this.t(l)})),c}#d(l,c,i,n){const t=B(this.doc,"select",{class:`${L.panel}__select`,attrs:{"aria-label":this.t(l)}});for(const r of c)t.appendChild(B(this.doc,"option",{text:r.title,attrs:{value:r.id,selected:r.id===i?!0:null}}));return t.value=i,this.off.push(F(t,"change",()=>n(t.value))),B(this.doc,"label",{class:`${L.panel}__field`,children:[B(this.doc,"span",{class:`${L.panel}__label`,text:this.t(l)}),t]})}}}),xe("packages/dom/src/ui/toolpanel.js",function(e,K){"use strict";Object.defineProperty(e,"ColumnsPanel",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"FiltersPanel",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"QuickFilterPanel",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"toolPanelTitles",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"toolPanelIcons",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return $}});const X=K("packages/dom/src/editors/common.js"),L=X.CLS,B=X.cssEscape,F=X.documentFor,W=X.el,Q=X.on,G=X.clear,U=K("packages/core/src/i18n/index.js").defaultMessages,D=K("packages/core/src/internal/util.js"),v=D.isFunction,S=D.nextFrame,y=K("packages/dom/src/cell/icons.js"),l=y.createIcon,c=y.updateIcon,i=y.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,g=K("packages/dom/src/regressionpanel.js").RegressionPanel,h=K("packages/dom/src/comparepanel.js").ComparePanel,p=K("packages/dom/src/insightspanel.js").InsightsPanel,k=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,b=K("packages/core/src/compute/total.js").TOTAL_LABELS;class C extends k{dragging=null;refresh(){const R=this.root;if(!R)return;for(const _ of this.off)_();this.off.length=0,G(R);const O=W(this.doc,"input",{class:`${L.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.searchColumns"),"aria-label":this.t("panel.searchColumns")}});this.off.push(Q(O,"input",()=>{this.query=O.value,this.paintList()})),R.appendChild(O),R.appendChild(this.buildZone("group","Row groups")),R.appendChild(this.buildZone("values","Grouped row calculation")),R.appendChild(this.buildZone("pivot","Pivot"));const I=W(this.doc,"div",{class:`${L.panel}__heading`});I.appendChild(W(this.doc,"span",{text:this.t("panel.columns")}));const q=W(this.doc,"button",{class:`${L.panel}__link`,text:this.t("panel.showAll"),attrs:{type:"button"}}),Z=W(this.doc,"button",{class:`${L.panel}__link`,text:this.t("panel.hideAll"),attrs:{type:"button"}});this.off.push(Q(q,"click",()=>{const _=this.columns().filter(J=>!(J.layout&&J.layout.lockVisible)).map(J=>J.id);v(this.host.showColumns)&&this.host.showColumns(_),this.refresh()})),this.off.push(Q(Z,"click",()=>{const _=this.columns().filter(J=>!(J.layout&&J.layout.lockVisible)).map(J=>J.id);v(this.host.hideColumns)&&this.host.hideColumns(_),this.refresh()})),I.appendChild(q),I.appendChild(Z),R.appendChild(I),this.list=W(this.doc,"div",{class:`${L.panel}__columns`,attrs:{role:"group","aria-label":this.t("panel.columns")}}),R.appendChild(this.list),this.paintList()}columns(){const R=this.host;return v(R.columns)?R.columns()||[]:R.columns&&v(R.columns.all)?R.columns.all():[]}paintList(){const R=this.list;if(!R)return;G(R);const O=String(this.query||"").trim().toLowerCase();for(const I of this.columns()){const q=String(I.title||I.id||"");if(O&&!q.toLowerCase().includes(O))continue;const Z=W(this.doc,"div",{class:`${L.panel}__column`,attrs:{"data-col":I.id,draggable:"true",title:this.t("panel.columnDragHint",{column:q})}});Z.appendChild(W(this.doc,"span",{class:`${L.panel}__grip`,attrs:{"aria-hidden":"true"}}));const _=W(this.doc,"input",{attrs:{type:"checkbox","aria-label":q}});_.checked=!(I.layout&&I.layout.hidden),I.layout&&I.layout.lockVisible&&_.setAttribute("disabled",""),this.off.push(Q(_,"change",()=>this.setVisible(I.id,_.checked))),Z.appendChild(_),Z.appendChild(W(this.doc,"span",{text:q})),Z.setAttribute("tabindex","0"),Z.setAttribute("role","listitem"),this.off.push(Q(Z,"keydown",J=>this.onRowKey(J,I))),this.off.push(Q(Z,"dragstart",()=>{this.dragging=I.id})),this.off.push(Q(Z,"dragend",()=>{this.dragging=null,this.clearDropMark()})),this.off.push(Q(Z,"dragover",J=>{if(!this.dragging||this.dragging===I.id)return;v(J.preventDefault)&&J.preventDefault();const ee=z(J,Z);Z.setAttribute("data-drop",ee?"before":"after")})),this.off.push(Q(Z,"dragleave",()=>Z.removeAttribute("data-drop"))),this.off.push(Q(Z,"drop",J=>{v(J.preventDefault)&&J.preventDefault();const ee=this.dragging;this.dragging=null,this.clearDropMark(),!(!ee||ee===I.id)&&this.moveColumn(ee,I.id,z(J,Z))})),R.appendChild(Z)}}onRowKey(R,O){const I=R&&R.key,q=C.zoneKeys[String(I).toLowerCase()];if(q&&!R.ctrlKey&&!R.metaKey&&!R.altKey){v(R.preventDefault)&&R.preventDefault(),this.toggleZone(q,O);return}if(I!=="ArrowUp"&&I!=="ArrowDown")return;const Z=I==="ArrowUp",_=this.columns().map(ae=>ae.id),J=_.indexOf(O.id);if(J<0)return;if(v(R.preventDefault)&&R.preventDefault(),!R.shiftKey){const ae=this.list&&this.list.querySelectorAll?[...this.list.querySelectorAll("[data-col]")]:[],re=ae.findIndex(le=>le.getAttribute("data-col")===O.id),se=ae[re+(Z?-1:1)];se&&v(se.focus)&&se.focus();return}const ee=O.layout&&(O.layout.movable===!1||O.layout.lockPosition),te=String(O.title||O.id||"");if(ee){this.announce(this.t("a11y.panel.cannotMove",{column:te}),{repeat:!0});return}const ne=_[J+(Z?-1:1)];if(!ne){this.announce(this.t(Z?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:te}),{repeat:!0});return}this.moveColumn(O.id,ne,Z),this.announce(this.t("a11y.panel.moved",{column:te,at:Z?J:J+2,of:_.length}),{repeat:!0});const ie=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${B(O.id)}"]`):null;ie&&v(ie.focus)&&ie.focus()}toggleZone(R,O){const I=this.titleOf(O.id),q=this.t(C.zoneLabel[R]||"panel.zone.group");if(this.zoneColumns(R).includes(O.id)){this.dropFromZone(R,O.id),this.announce(this.t("a11y.panel.removedFrom",{column:I,list:q}),{repeat:!0}),this.restoreFocus(O.id);return}if(this.addToZone(R,O.id)){this.announce(this.t("a11y.panel.addedTo",{column:I,list:q}),{repeat:!0}),this.restoreFocus(O.id);return}this.announce(this.t("a11y.panel.cannotAddTo",{column:I,list:q}),{repeat:!0})}restoreFocus(R){const O=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${B(R)}"]`):null;O&&v(O.focus)&&O.focus()}announce(R,O){const I=this.host||{};v(I.announce)&&I.announce(R,O)}clearDropMark(){if(!(!this.list||!this.list.querySelectorAll))for(const R of this.list.querySelectorAll("[data-drop]"))R.removeAttribute("data-drop")}moveColumn(R,O,I){const q=this.host||{};v(q.moveColumn)&&(q.moveColumn(R,O,I),this.refresh())}buildZone(R,O){const I=W(this.doc,"div",{class:`${L.panel}__zone`,attrs:{"data-zone":R,role:"group","aria-label":O}});I.appendChild(W(this.doc,"div",{class:`${L.panel}__zoneTitle`,text:O}));const q=this.zoneColumns(R);let Z=C.zoneAbout[R]||"";R==="values"&&q.length&&!this.zoneColumns("group").length&&(Z+=" Add a row group to see them."),Z&&I.appendChild(W(this.doc,"div",{class:`${L.panel}__zoneAbout`,text:Z}));const _=W(this.doc,"div",{class:`${L.panel}__zoneBody`});q.length||_.appendChild(W(this.doc,"span",{class:`${L.panel}__zoneHint`,text:this.t(C.zoneHint[R]||"panel.zoneHint.any")})),R==="values"&&_.classList.add(`${L.panel}__zoneBody--rows`);for(const J of q){const ee=W(this.doc,"span",{class:[L.chip,R==="values"?`${L.chip}--row`:""]});if(ee.appendChild(W(this.doc,"span",{class:`${L.chip}__label`,text:this.titleOf(J)})),R==="values"&&v(this.host.setValueAggregation)){const ne=v(this.host.valueAggregation)?this.host.valueAggregation(J):"sum",ie=W(this.doc,"select",{class:`${L.chip}__fn`,attrs:{"aria-label":`Calculation for ${this.titleOf(J)}`}});for(const ae of C.aggregations)ie.appendChild(W(this.doc,"option",{text:this.t(`total.${ae.name}`),attrs:{value:ae.name,selected:ae.name===ne?"":null}}));ie.value=ne,this.off.push(Q(ie,"change",()=>{this.host.setValueAggregation(J,ie.value),this.refresh()})),ee.appendChild(ie)}const te=W(this.doc,"button",{class:L.chipRemove,text:"×",attrs:{type:"button","aria-label":`Remove ${this.titleOf(J)}`}});this.off.push(Q(te,"click",()=>this.dropFromZone(R,J))),ee.appendChild(te),_.appendChild(ee)}return this.off.push(Q(I,"dragover",J=>{v(J.preventDefault)&&J.preventDefault(),I.setAttribute("data-over","true")})),this.off.push(Q(I,"dragleave",()=>I.removeAttribute("data-over"))),this.off.push(Q(I,"drop",J=>{v(J.preventDefault)&&J.preventDefault(),I.removeAttribute("data-over"),this.dragging&&this.addToZone(R,this.dragging)})),I.appendChild(_),I}static aggregations=Object.freeze(Object.keys(b).map(R=>({name:R})));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(R){const O=C.zoneApi[R],I=this.host;return O&&v(I[O.read])?I[O.read]()||[]:[]}titleOf(R){const O=this.columns().find(I=>I.id===R);return String(O&&(O.title||O.id)||R)}addToZone(R,O){const I=C.zoneApi[R],q=this.columns().find(_=>_.id===O);if(!I||!q||q[I.permission]===!1||!v(this.host[I.write]))return!1;const Z=this.zoneColumns(R);return Z.includes(O)?!1:(this.host[I.write]([...Z,O]),this.refresh(),!0)}dropFromZone(R,O){const I=C.zoneApi[R];return!I||!v(this.host[I.write])?!1:(this.host[I.write](this.zoneColumns(R).filter(q=>q!==O)),this.refresh(),!0)}setVisible(R,O){const I=this.host;O&&v(I.showColumns)?I.showColumns([R]):!O&&v(I.hideColumns)&&I.hideColumns([R])}}class M extends k{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 R=this.root;if(!R)return;for(const ee of this.off)ee();this.off.length=0,G(R);const O=this.host,I=(v(O.columns)?O.columns():[]).filter(ee=>!(ee.filter&&ee.filter.enabled===!1));if(!v(O.filterFor))return;const q=I.filter(ee=>this.isFiltered(ee.id));R.appendChild(this.buildSearch()),R.appendChild(this.buildSummary(q.length,I.length));const Z=this.query.trim().toLowerCase(),_=Z?I.filter(ee=>String(ee.title||ee.id).toLowerCase().includes(Z)):I;if(!_.length){R.appendChild(W(this.doc,"p",{class:`${L.panel}__empty`,text:Z?this.t("panel.filterEmptyNoMatch",{query:this.query.trim()}):this.t("panel.filterEmptyNone")}));return}const J=W(this.doc,"div",{class:`${L.panel}__filters`});for(const ee of _)J.appendChild(this.buildSection(ee));R.appendChild(J)}isFiltered(R){const O=this.host;return v(O.isFiltered)?O.isFiltered(R)===!0:!1}buildSearch(){const R=W(this.doc,"input",{class:`${L.panel}__search`,attrs:{type:"text",placeholder:this.t("panel.searchColumnsPlaceholder"),"aria-label":this.t("panel.searchColumnsToFilter")}});return R.value=this.query,this.off.push(Q(R,"input",()=>{this.query=R.value||"",this.refresh();const O=this.root&&this.root.querySelector?this.root.querySelector(`.${L.panel}__search`):null;O&&v(O.focus)&&O.focus()})),R}buildSummary(R,O){const I=W(this.doc,"div",{class:`${L.panel}__filterSummary`});if(I.appendChild(W(this.doc,"span",{class:`${L.panel}__filterCount`,text:R?this.t("panel.filterSummaryActive",{active:R,total:O}):this.t("panel.filterSummaryNone",{total:O}),attrs:{"data-active":R?"true":"false"}})),!R)return I;const q=W(this.doc,"button",{class:`${L.panel}__clearAll`,text:this.t("panel.clearAll"),attrs:{type:"button"}});return this.off.push(Q(q,"click",()=>{v(this.host.clearAllFilters)&&this.host.clearAllFilters(),this.refresh()})),I.appendChild(q),I}buildSection(R){const O=R.id,I=String(R.title||O),q=this.isFiltered(O),Z=this.open.has(O),_=W(this.doc,"section",{class:`${L.panel}__filter`,attrs:{"data-col":O,"data-filtered":q?"true":null}}),J=W(this.doc,"button",{class:`${L.panel}__filterTitle`,attrs:{type:"button","aria-expanded":Z?"true":"false",title:this.t(q?"panel.filteredBy":"panel.filterBy",{column:I})},children:[l(this.doc,Z?"chevronDown":"chevronRight",{className:`${L.panel}__twisty`}),W(this.doc,"span",{class:`${L.panel}__filterName`,text:I})]});q&&J.appendChild(W(this.doc,"span",{class:`${L.panel}__filterDot`,attrs:{"aria-label":this.t("panel.columnFiltered"),title:this.t("panel.columnFiltered")}}));const ee=W(this.doc,"div",{class:`${L.panel}__filterBody`,style:{display:Z?"":"none"}}),te=()=>{if(ee.firstChild)return;const ne=this.host.filterFor(O);ne&&v(ne.element)&&ee.appendChild(ne.element())};if(this.off.push(Q(J,"click",()=>{const ne=this.open.has(O);ne?this.open.delete(O):this.open.add(O),J.setAttribute("aria-expanded",ne?"false":"true"),ee.style.display=ne?"none":"";const ie=J.firstElementChild;ie&&c(ie,ne?"chevronRight":"chevronDown"),ne||te()})),_.appendChild(J),q){const ne=W(this.doc,"button",{class:`${L.panel}__filterClear`,attrs:{type:"button","aria-label":this.t("panel.clearFilterOn",{column:I}),title:this.t("panel.clearFilter")},children:[l(this.doc,"close",{className:L.icon})]});this.off.push(Q(ne,"click",ie=>{v(ie.stopPropagation)&&ie.stopPropagation(),v(this.host.clearFilter)&&this.host.clearFilter(O),this.refresh()})),_.appendChild(ne)}return _.appendChild(ee),Z&&te(),_}}class P extends k{refresh(){const R=this.root;if(!R)return;if(this.box){const Z=v(this.host.quickFilter)?this.host.quickFilter():"";this.doc&&this.doc.activeElement!==this.box&&this.box.value!==Z&&(this.box.value=Z),this.paintCount();return}for(const Z of this.off)Z();this.off.length=0,G(R);const O=v(this.host.quickFilter)?this.host.quickFilter():"",I=W(this.doc,"input",{class:`${L.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.filterAllColumns"),"aria-label":this.t("panel.quickFilter")}});I.value=O||"",this.off.push(Q(I,"input",()=>{v(this.host.setQuickFilter)&&this.host.setQuickFilter(I.value),this.paintCount()})),R.appendChild(I),this.box=I;const q=W(this.doc,"button",{class:`${L.panel}__link`,text:this.t("panel.clear"),attrs:{type:"button"}});this.off.push(Q(q,"click",()=>{I.value="",v(this.host.setQuickFilter)&&this.host.setQuickFilter(""),this.paintCount(),v(I.focus)&&I.focus()})),R.appendChild(q),this.count=W(this.doc,"p",{class:`${L.panel}__count`}),R.appendChild(this.count),this.paintCount()}destroy(){this.box=null,this.count=null,super.destroy()}focus(){S(()=>{this.box&&v(this.box.focus)&&this.box.focus()})}paintCount(){if(!this.count)return;const R=v(this.host.rowCount)?this.host.rowCount():null,O=v(this.host.totalRowCount)?this.host.totalRowCount():null;if(R===null||O===null){this.count.textContent="";return}this.count.textContent=R===O?this.t("count.rows",{count:O}):this.t("panel.rowsOf",{shown:R,total:O})}}const x=Object.freeze({columns:C,filters:M,views:t,quick:P,formatting:s,statistics:u,regression:g,compare:h,insights:p}),E=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"}),A=Object.freeze({columns:"columns",filters:"filter",views:"views",quick:"search",formatting:"palette",statistics:"chart",regression:"chart",compare:"link",insights:"chart"});class j{panels=[];actions=[];root=null;openPanel=null;off=[];t(R,O){return(this.messages&&typeof this.messages.t=="function"?this.messages:U).t(R,O)}init(R){const O=R||{};this.doc=F(O),this.host=O.host||{},this.messages=O.messages||O.grid&&O.grid.messages||U,this.icons=O.icons===void 0?O.side==="left":!!O.icons,this.side=O.side==="left"?"left":"right",this.root=W(this.doc,"div",{class:[L.panel,`${L.panel}--${this.side}`,this.icons?`${L.panel}--icons`:null]}),this.tabs=W(this.doc,"div",{class:`${L.panel}__tabs`,attrs:{role:"tablist"}}),this.body=W(this.doc,"div",{class:`${L.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=W(this.doc,"div",{class:`${L.panel}__actions`,attrs:{role:"group","aria-label":this.t("panel.gridActions")}}),this.tabs.appendChild(this.actionGroup);for(const Z of Array.isArray(O.actions)?O.actions:[])this.registerAction(Z);const I=O.registry||{},q=Array.isArray(O.panels)&&O.panels.length?O.panels:["columns","filters"];for(const Z of q){const _=typeof Z=="string"?Z:Z.name,J=typeof Z=="function"?Z:I[_]||x[_];J&&this.registerPanel(String(_),J,typeof Z=="object"?Z:{})}O.openPanel&&this.show(O.openPanel)}registerPanel(R,O,I){const q=new O;q.init({document:this.doc,host:this.host,props:I&&I.props||{}});const Z=I&&I.title||R,_=I&&I.icon||R,J=W(this.doc,"button",{class:`${L.panel}__tab`,text:this.icons?null:Z,attrs:{type:"button",role:"tab","aria-selected":"false","data-panel":R,title:this.icons?Z:null,"aria-label":this.icons?Z:null}});return this.icons&&J.appendChild(l(this.doc,_,{className:`${L.panel}__icon`})),this.off.push(Q(J,"click",()=>this.toggle(R))),this.tabs.appendChild(J),this.panels.push({name:R,title:Z,panel:q}),q}registerAction(R){if(!R||!R.name)return null;if(R.separator)return this.actionGroup.appendChild(W(this.doc,"div",{class:`${L.panel}__divider`,attrs:{"aria-hidden":"true"}})),null;const O=W(this.doc,"button",{class:`${L.panel}__action`,text:this.icons?null:v(R.title)?String(R.title()):R.title,attrs:{type:"button","data-action":R.name,title:v(R.title)?null:R.title,"aria-label":v(R.title)?null:R.title}});if(this.icons){const Z=(v(R.icon)?R.icon():R.icon)||(i(R.name)?R.name:"blank");O.appendChild(l(this.doc,Z,{className:`${L.panel}__icon`})),O.setAttribute("data-icon",Z)}const I=Q(O,"click",()=>{v(R.enabled)&&!R.enabled()||(v(R.run)&&R.run(),this.paintActions())});return this.off.push(I),this.actionGroup.appendChild(O),this.actions.push({...R,button:O,offClick:I}),this.paintActions(),O}removeAction(R){const O=this.actions.findIndex(q=>q.name===R);if(O<0)return!1;const I=this.actions[O];return v(I.offClick)&&I.offClick(),I.button&&I.button.parentNode&&I.button.parentNode.removeChild(I.button),this.actions.splice(O,1),!0}paintActions(){for(const R of this.actions){if(!R.button)continue;const O=v(R.enabled)?!!R.enabled():!0;if(R.button.disabled=!O,R.button.setAttribute("aria-disabled",O?"false":"true"),v(R.active)&&R.button.setAttribute("aria-pressed",R.active()?"true":"false"),v(R.title)){const I=String(R.title());R.button.setAttribute("title",I),R.button.setAttribute("aria-label",I),!this.icons&&R.button.textContent!==I&&(R.button.textContent=I)}if(this.icons&&v(R.icon)){const I=String(R.icon());R.button.getAttribute("data-icon")!==I&&(G(R.button),R.button.appendChild(l(this.doc,I,{className:`${L.panel}__icon`})),R.button.setAttribute("data-icon",I))}}}show(R){const O=this.panels.find(I=>I.name===R);return O?(G(this.body),v(O.panel.refresh)&&O.panel.refresh(),this.body.appendChild(O.panel.element()),this.openPanel=R,this.paintTabs(),v(O.panel.focus)&&O.panel.focus(),!0):!1}hide(){G(this.body),this.openPanel=null,this.paintTabs()}toggle(R){this.openPanel===R?this.hide():this.show(R)}paintTabs(){if(!(!this.tabs||!this.tabs.childNodes))for(let R=0;R<this.tabs.childNodes.length;R++){const O=this.tabs.childNodes[R];O&&O.setAttribute&&O.setAttribute("aria-selected",O.getAttribute("data-panel")===this.openPanel?"true":"false")}}element(){return this.root}refresh(){const R=this.panels.find(O=>O.name===this.openPanel);R&&v(R.panel.refresh)&&!this.#e(R.panel)&&R.panel.refresh(),this.paintActions()}#e(R){const O=this.doc&&this.doc.activeElement;if(!O||O===this.doc.body)return!1;const I=v(R.element)?R.element():null;return!!(I&&v(I.contains)&&I.contains(O))}destroy(){for(const R of this.off)R();this.off.length=0;for(const R of this.panels)v(R.panel.destroy)&&R.panel.destroy();this.panels=[],this.root=null}}const $=j;function z(T,R){if(!R.getBoundingClientRect||typeof T.clientY!="number")return!0;const O=R.getBoundingClientRect();return T.clientY<O.top+O.height/2}}),xe("packages/dom/src/ui/groupbyzone.js",function(e,K){"use strict";Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return S}});const L=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,B=K("packages/dom/src/editors/common.js"),F=B.CLS,W=B.el,Q=B.on,G=B.clear,H=B.cssEscape,D=K("packages/core/src/internal/util.js").isFunction,v="text/x-lattice-col";class S extends L{dragging=null;#e=[];init(l){this.ctx=l,this.doc=l.document,this.host=l.host||{},this.props=l.props||{},this.root=W(this.doc,"div",{class:F.groupZone,attrs:{role:"group","aria-label":this.t("groupZone.label")}}),this.refresh()}columns(){const l=this.host;return D(l.columns)?l.columns()||[]:l.columns&&D(l.columns.all)?l.columns.all():[]}groups(){return D(this.host.groupBy)?this.host.groupBy()||[]:[]}setGroups(l){D(this.host.setGroupBy)&&this.host.setGroupBy(l)}titleOf(l){const c=this.columns().find(i=>i.id===l);return String(c&&(c.title||c.id)||l)}canGroup(l){const c=this.columns().find(i=>i.id===l);return!!c&&c.allowGroup!==!1&&!c.generated}announce(l,c){D(this.host.announce)&&this.host.announce(l,c)}refresh(){const l=this.root;if(!l)return;for(const n of this.off)n();this.off.length=0,G(l),l.appendChild(W(this.doc,"span",{class:F.groupZoneTitle,text:this.t("groupZone.title"),attrs:{"aria-hidden":"true"}}));const c=this.groups(),i=W(this.doc,"div",{class:F.groupZoneChips,attrs:{role:"listbox","aria-orientation":"horizontal","aria-label":this.t("groupZone.label")}});c.length||i.appendChild(W(this.doc,"span",{class:F.groupZoneHint,text:this.t("groupZone.hint")})),c.forEach((n,t)=>i.appendChild(this.#t(n,t,c.length))),l.appendChild(i),this.chips=i,l.appendChild(this.#i(c)),this.off.push(Q(l,"dragover",n=>{this.dragging==null&&!this.#l(n)||(D(n.preventDefault)&&n.preventDefault(),l.setAttribute("data-over","true"))})),this.off.push(Q(l,"dragleave",()=>l.removeAttribute("data-over"))),this.off.push(Q(l,"drop",n=>{D(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,c,i){const n=this.titleOf(l),t=W(this.doc,"div",{class:[F.chip,F.groupZoneChip],attrs:{role:"option","aria-selected":"true",tabindex:"0",draggable:"true","data-col":l,"aria-label":this.t("groupZone.chip",{column:n,at:c+1,of:i})}});t.appendChild(W(this.doc,"span",{class:F.groupZoneChipText,text:n}));const r=W(this.doc,"button",{class:F.chipRemove,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("groupZone.remove",{column:n})}});return this.off.push(Q(r,"click",()=>this.#r(l))),t.appendChild(r),this.off.push(Q(t,"dragstart",s=>{this.dragging=l,s.dataTransfer&&D(s.dataTransfer.setData)&&s.dataTransfer.setData(v,l)})),this.off.push(Q(t,"dragend",()=>{this.dragging=null})),this.off.push(Q(t,"dragover",s=>{const f=this.#l(s)||this.dragging;f==null||f===l||D(s.preventDefault)&&s.preventDefault()})),this.off.push(Q(t,"drop",s=>{const f=this.#l(s)||this.dragging;f!=null&&(D(s.preventDefault)&&s.preventDefault(),D(s.stopPropagation)&&s.stopPropagation(),this.#o(f,c))})),this.off.push(Q(t,"keydown",s=>this.#n(s,l,c))),t}#n(l,c,i){const n=l&&l.key,t=this.groups();if(n==="Delete"||n==="Backspace"){D(l.preventDefault)&&l.preventDefault(),this.#r(c,t,i);return}const r=n==="ArrowLeft"||n==="ArrowUp",s=n==="ArrowRight"||n==="ArrowDown",f=n==="Home",u=n==="End";if(!r&&!s&&!f&&!u)return;if(D(l.preventDefault)&&l.preventDefault(),l.shiftKey&&(r||s)){const d=i+(r?-1:1);if(d<0||d>=t.length){this.announce(this.t(r?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:this.titleOf(c)}),{repeat:!0});return}const h=t.slice();h.splice(i,1),h.splice(d,0,c),this.setGroups(h),this.announce(this.t("a11y.panel.moved",{column:this.titleOf(c),at:d+1,of:h.length}),{repeat:!0}),this.#a(c);return}let o=i+(r?-1:s?1:0);f&&(o=0),u&&(o=t.length-1);const g=t[o];g&&this.#a(g)}#r(l,c=this.groups(),i=c.indexOf(l)){const n=this.titleOf(l);this.setGroups(c.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(i,t.length-1)]):this.#u()}#o(l,c){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 i=this.groups(),n=i.indexOf(l),t=i.slice();n>=0&&(t.splice(n,1),n<c&&(c-=1)),t.splice(Math.max(0,Math.min(c,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 c=new Set(l),i=W(this.doc,"label",{class:F.groupZoneAdd}),n=W(this.doc,"select",{class:F.groupZoneAddSelect,attrs:{"aria-label":this.t("groupZone.add")}});n.appendChild(W(this.doc,"option",{text:this.t("groupZone.add"),attrs:{value:""}}));for(const t of this.columns())c.has(t.id)||!this.canGroup(t.id)||n.appendChild(W(this.doc,"option",{text:this.titleOf(t.id),attrs:{value:t.id}}));return this.off.push(Q(n,"change",()=>{const t=n.value;t&&this.#o(t,this.groups().length)})),this.adderSelect=n,i.appendChild(n),i}#s(){for(const c of this.#e)c();this.#e.length=0;const l=this.props&&this.props.header;if(!(!l||!D(l.querySelectorAll)))for(const c of l.querySelectorAll("[data-col]")){const i=D(c.getAttribute)?c.getAttribute("data-col"):null;!i||!this.canGroup(i)||(D(c.setAttribute)&&c.setAttribute("draggable","true"),this.#e.push(Q(c,"dragstart",n=>{this.dragging=i,n.dataTransfer&&D(n.dataTransfer.setData)&&n.dataTransfer.setData(v,i)})),this.#e.push(Q(c,"dragend",()=>{this.dragging=null})))}}#l(l){const c=l&&l.dataTransfer;if(c&&D(c.getData)){const i=c.getData(v);if(i)return i}return null}#a(l){const c=this.chips&&D(this.chips.querySelector)?this.chips.querySelector(`[data-col="${H(l)}"]`):null;c&&D(c.focus)&&c.focus()}#u(){this.adderSelect&&D(this.adderSelect.focus)&&this.adderSelect.focus()}destroy(){for(const l of this.#e)l();this.#e.length=0,super.destroy()}}}),xe("packages/dom/src/ui/tooltip.js",function(e,K){"use strict";Object.defineProperty(e,"TextTooltip",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const X=K("packages/dom/src/editors/common.js"),L=X.CLS,B=X.documentFor,F=X.el,W=X.on,Q=X.clear,H=K("packages/core/src/internal/util.js").isFunction;class U{root=null;init(y){this.doc=y.document,this.root=F(this.doc,"div",{class:`${L.tooltip}__text`}),this.update(y.content)}update(y){if(!this.root)return;const l=y==null?"":String(y);this.root.textContent!==l&&(this.root.textContent=l)}element(){return this.root}destroy(){this.root=null}}class D{root=null;component=null;timer=null;target=null;off=[];constructor(y){const l=y||{};this.doc=B(l),this.host=l.host||this.doc.body,this.delay=l.delay??400,this.hideDelay=l.hideDelay??0,this.components={text:U,...l.components||{}}}show(y){this.cancelTimer();const l=y.delay??this.delay;if(!l){this.showNow(y);return}this.timer=setTimeout(()=>{this.timer=null,this.showNow(y)},l)}showNow(y){const l=y.component||"text",c=typeof l=="function"?l:this.components[l]||U;return this.root||(this.root=F(this.doc,"div",{class:L.tooltip,attrs:{role:"tooltip"},style:{position:"absolute"}}),this.host.appendChild(this.root)),!this.component||this.componentCtor!==c?(this.component&&H(this.component.destroy)&&this.component.destroy(),Q(this.root),this.component=new c,this.componentCtor=c,this.component.init({document:this.doc,content:y.content,...y.props||{}}),this.root.appendChild(this.component.element())):H(this.component.update)&&this.component.update(y.content),this.target=y.target||null,this.position(),this.root.setAttribute("data-open","true"),this.root}position(){if(!this.root||!this.target||!H(this.target.getBoundingClientRect))return;const y=this.target.getBoundingClientRect(),l=this.doc.defaultView||{};this.root.style.left=`${y.left+(l.scrollX||0)}px`,this.root.style.top=`${y.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(y,l,c){const i=()=>this.show({target:y,content:l(),...c||{}}),n=()=>this.hide(),t=[W(y,"mouseenter",i),W(y,"mouseleave",n),W(y,"focus",i),W(y,"blur",n)],r=()=>{for(const s of t)s()};return this.off.push(r),r}destroy(){this.hide();for(const y of this.off)y();this.off.length=0,this.component&&H(this.component.destroy)&&this.component.destroy(),this.component=null,this.root=null}}const v=D}),xe("packages/dom/src/ui/pagination.js",function(e,K){"use strict";Object.defineProperty(e,"pageModel",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const X=K("packages/dom/src/editors/common.js"),L=X.CLS,B=X.documentFor,F=X.el,W=X.on,Q=X.clear,H=K("packages/core/src/i18n/index.js").defaultMessages,D=K("packages/core/src/internal/util.js").isFunction;function v(l){const c=Math.max(1,Number(l.pageSize)||100),i=l.total==null?null:Math.max(0,Number(l.total)),n=i==null?null:Math.max(1,Math.ceil(i/c)),t=Math.max(0,n==null?Number(l.page)||0:Math.min(Number(l.page)||0,n-1)),r=i===0?0:t*c+1,s=i==null?(t+1)*c:Math.min(i,(t+1)*c);return{page:t,pageSize:c,pageCount:n,from:r,to:s,first:t===0,last:n==null?l.hasMore!==!0:t>=n-1,total:i}}class S{root=null;page=0;pageSize=100;total=null;counting=!1;hasMore=!1;off=[];init(c){const i=c||{};this.doc=B(i),this.host=i.host||{},this.pageSize=Number(i.pageSize)||100;const n=Array.isArray(i.pageSizes)&&i.pageSizes.length?[...i.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(i.page)||0,this.total=i.total===void 0?null:i.total,this.locale=i.locale,this.messages=i.messages||null,this.onChange=i.onChange||null,this.root=F(this.doc,"nav",{class:L.pagination,attrs:{"aria-label":this.t("pagination.label")}}),this.paint()}t(c,i){const n=this.messages;return(n&&typeof n.t=="function"?n:H).t(c,i)}element(){return this.root}model(){return v({total:this.total,pageSize:this.pageSize,page:this.page,hasMore:this.hasMore})}setState(c){c.total!==void 0&&(this.total=c.total),c.counting!==void 0&&(this.counting=c.counting===!0),c.hasMore!==void 0&&(this.hasMore=c.hasMore===!0),c.page!==void 0&&(this.page=Number(c.page)||0),this.paint()}goTo(c){const i=this.page;this.page=c;const n=this.model();return this.page=n.page,this.paint(),this.page!==i&&D(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 c=this.model();return c.pageCount==null?this.page:this.goTo(c.pageCount-1)}setPageSize(c){const i=this.page*this.pageSize;this.pageSize=Math.max(1,Number(c)||1),this.page=Math.floor(i/this.pageSize),this.paint(),D(this.onChange)&&this.onChange({page:this.page,pageSize:this.pageSize})}paint(){const c=this.root;if(!c)return;for(const o of this.off)o();this.off.length=0,Q(c);const i=this.model(),n=F(this.doc,"select",{class:`${L.pagination}__size`,attrs:{"aria-label":this.t("pagination.pageSize")}});for(const o of this.pageSizes)n.appendChild(F(this.doc,"option",{text:String(o),attrs:{value:o}}));n.value=String(this.pageSize),this.off.push(W(n,"change",()=>this.setPageSize(Number(n.value)))),c.appendChild(n);const t=i.total==null?this.t(this.counting?"pagination.counting":"pagination.range",{from:i.from,to:i.to}):this.t("pagination.summary",{from:i.from,to:i.to,total:i.total});c.appendChild(F(this.doc,"span",{class:`${L.pagination}__summary`,text:t}));const r=(o,g,d,h)=>{const a=F(this.doc,"button",{class:`${L.pagination}__button`,text:o,attrs:{type:"button","aria-label":h,disabled:d?"":null}});return d||this.off.push(W(a,"click",g)),a};c.appendChild(r("«",()=>this.goTo(0),i.first,this.t("pagination.first"))),c.appendChild(r("‹",()=>this.previous(),i.first,this.t("pagination.previous")));const s=F(this.doc,"span",{class:`${L.pagination}__page`});s.appendChild(F(this.doc,"span",{text:`${this.t("pagination.page")} `}));const f=F(this.doc,"input",{class:`${L.pagination}__field`,attrs:{type:"text",inputmode:"numeric","aria-label":i.pageCount==null?this.t("pagination.jump"):this.t("pagination.jumpBounded",{pages:i.pageCount}),size:String(Math.max(2,String(i.pageCount??i.page+1).length))}});f.value=String(i.page+1);const u=()=>{const o=parseInt(String(f.value).trim(),10);if(!Number.isFinite(o)){f.value=String(this.model().page+1);return}this.goTo(o-1)};this.off.push(W(f,"keydown",o=>{o.key==="Enter"?(u(),o.preventDefault?.()):o.key==="Escape"?(f.value=String(this.model().page+1),f.blur?.()):o.stopPropagation?.()})),this.off.push(W(f,"blur",()=>u())),this.off.push(W(f,"focus",()=>f.select?.())),s.appendChild(f),i.pageCount!=null&&s.appendChild(F(this.doc,"span",{text:` ${this.t("pagination.ofPages",{pages:i.pageCount})}`})),c.appendChild(s),c.appendChild(r("›",()=>this.next(),i.last,this.t("pagination.next"))),c.appendChild(r("»",()=>this.last(),i.last||i.pageCount==null,this.t("pagination.last")))}destroy(){for(const c of this.off)c();this.off.length=0,this.root=null}}const y=S}),xe("packages/dom/src/ui/overlay.js",function(e,K){"use strict";Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const X=K("packages/dom/src/editors/common.js"),L=X.CLS,B=X.documentFor,F=X.el,W=X.clear,G=K("packages/core/src/internal/util.js").isFunction,U=K("packages/core/src/i18n/index.js").defaultMessages;function D(i,n){const t=i&&i.grid&&i.grid.messages;return(t&&G(t.t)?t:U).t(n)}class v{root=null;init(n){this.doc=n.document,this.root=F(this.doc,"div",{class:`${L.overlay}__loading`,attrs:{role:"status","aria-live":"polite"},children:[F(this.doc,"span",{class:`${L.overlay}__spinner`,attrs:{"aria-hidden":"true"}}),F(this.doc,"span",{class:`${L.overlay}__message`,text:n.message||D(n,"overlay.loading")})]})}element(){return this.root}destroy(){this.root=null}}class S{root=null;init(n){this.doc=n.document,this.root=F(this.doc,"div",{class:`${L.overlay}__empty`,attrs:{role:"status"},children:[F(this.doc,"span",{class:`${L.overlay}__message`,text:n.message||D(n,"overlay.noRows")})]})}element(){return this.root}destroy(){this.root=null}}const y=Object.freeze({loading:v,empty:S});class l{root=null;slot=null;component=null;current=null;init(n){const t=n||{};this.doc=B(t),this.components={...y,...t.components||{}},this.root=F(this.doc,"div",{class:L.overlay,attrs:{"data-open":"false"}}),this.slot=F(this.doc,"div",{class:`${L.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&&G(this.component.destroy)&&this.component.destroy(),this.component=null,this.current=null,this.slot&&W(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 c=l}),xe("packages/dom/src/ui/index.js",function(e,K){"use strict";const X=K("packages/dom/src/ui/statusbar.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return X.StatusBar}}),Object.defineProperty(e,"StatusPanel",{enumerable:!0,get:function(){return X.StatusPanel}}),Object.defineProperty(e,"RowCountPanel",{enumerable:!0,get:function(){return X.RowCountPanel}}),Object.defineProperty(e,"SelectedCountPanel",{enumerable:!0,get:function(){return X.SelectedCountPanel}}),Object.defineProperty(e,"AggregationPanel",{enumerable:!0,get:function(){return X.AggregationPanel}}),Object.defineProperty(e,"ProgressPanel",{enumerable:!0,get:function(){return X.ProgressPanel}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return X.UpdatesPanel}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return X.CommentsPanel}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return X.statusPanels}}),Object.defineProperty(e,"aggregate",{enumerable:!0,get:function(){return X.aggregate}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return X.formatCount}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return X.formatNumber}});const L=K("packages/dom/src/ui/contextmenu.js");Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return L.ContextMenu}}),Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return L.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 F=K("packages/dom/src/ui/groupbyzone.js");Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return F.GroupByZone}});const W=K("packages/dom/src/ui/tooltip.js");Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return W.TooltipManager}}),Object.defineProperty(e,"TextTooltip",{enumerable:!0,get:function(){return W.TextTooltip}});const Q=K("packages/dom/src/ui/pagination.js");Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return Q.Pagination}}),Object.defineProperty(e,"pageModel",{enumerable:!0,get:function(){return Q.pageModel}});const G=K("packages/dom/src/ui/overlay.js");Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return G.OverlayLayer}}),Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return G.LoadingOverlay}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return G.EmptyOverlay}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return G.overlays}})}),xe("packages/dom/src/ui/celltooltip.js",function(e,K){"use strict";Object.defineProperty(e,"CellTooltips",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const X=K("packages/dom/src/editors/common.js"),L=X.documentFor,B=X.el,F=X.on,W=X.clear,Q=K("packages/core/src/internal/util.js"),G=Q.isFunction,H=Q.warnOnce,D=K("packages/dom/src/cell/sanitise.js").sanitiseHtml,S=K("packages/dom/src/detailhost.js").insideDetail,l=K("packages/dom/src/renderer/renderer.js").displayIndexOf,c=K("packages/dom/src/renderer/viewport.js"),i=c.CLASS,n=c.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"},f=400,u=140,o=6;let g=0;class d{#e;#t;#n;#r;#o=null;#i=null;#s;#l=!1;#a=null;#u=null;#c=null;#d=null;#f=null;#h=[];#p=!1;constructor(p){const w=p||{};this.#e=w.grid,this.#t=w.host,this.#n=w.viewport,this.#r=L(w),g+=1,this.#s=`lat-cell-tooltip-${g}`}mount(){const p=this.#n&&this.#n.root;if(!p||!G(p.addEventListener))return;const w=this.#e.on("cell:mouseover",b=>this.#w(b));G(w)&&this.#h.push(w);const k=this.#e.on("cell:mouseout",()=>this.#j());G(k)&&this.#h.push(k),this.#h.push(F(p,"focusin",b=>this.#k(b))),this.#h.push(F(p,"focusout",()=>this.#j())),this.#h.push(F(this.#r,"keydown",b=>this.#b(b),!0));const m=this.#r.defaultView;m&&G(m.addEventListener)&&this.#h.push(F(m,"scroll",()=>this.hide(),!0))}#m(){const p=G(this.#e.get)?this.#e.get("tooltip"):null,w=p&&typeof p=="object"?p:{},k=Number.isFinite(w.delay)&&w.delay>=0?Number(w.delay):f,m=w.maxWidth;return{delay:k,hideDelay:u,maxWidth:typeof m=="number"&&Number.isFinite(m)?`${m}px`:typeof m=="string"&&m?m:null}}#g(p){const w=p&&p.cell?p.cell.tooltip:null;return!w||typeof w!="object"||Array.isArray(w)||!G(w.render)&&!G(w.mount)?null:w}#y(p){if(!p||!G(p.closest))return null;const w=p.closest(`.${i.row}`);if(!w)return null;const k=l(w);if(k<0)return null;const m=this.#t.rowAt(k);if(!m)return null;const b=p.getAttribute("data-col");if(!b)return null;const C=this.#t.columns.get(b);return C?{row:m,key:m.key,index:k,colId:b,column:C,value:this.#t.cellValue?this.#t.cellValue(m,C):void 0,text:this.#t.cellText?this.#t.cellText(m,C):"",cell:p,grid:this.#e}:null}#w(p){const w=p&&p.target;if(!this.#g(p&&p.column)){this.#j();return}this.#O(w)}#k(p){const w=p&&p.target;if(!w||!G(w.closest)||S(w,this.#n.root))return;const k=w.closest(`.${i.cell}`);if(!k||k!==w){this.#j();return}const m=k.getAttribute("data-col"),b=m?this.#t.columns.get(m):null;if(!this.#g(b)){this.#j();return}this.#O(k)}#b(p){!p||p.key!=="Escape"||p.defaultPrevented||this.#l&&(G(p.preventDefault)&&p.preventDefault(),this.hide())}#O(p){if(this.#p||!p||(this.#x(),this.#l&&this.#a===p))return;this.#L();const{delay:w}=this.#m();if(!w){this.#A(p);return}this.#d=setTimeout(()=>{this.#d=null,this.#A(p)},w)}#j(){if(this.#L(),!this.#l||this.#f!==null)return;const{hideDelay:p}=this.#m();this.#f=setTimeout(()=>{this.#f=null,this.hide()},p)}#P(){if(this.#o)return this.#o;const p=this.#r,w=B(p,"div",{class:[n,s.tooltip],attrs:{id:this.#s,role:"tooltip","data-open":"false"}});this.#i=B(p,"div",{class:s.body}),w.appendChild(this.#i),this.#h.push(F(w,"mouseenter",()=>this.#x())),this.#h.push(F(w,"mouseleave",()=>this.#j()));const k=p.body;return k&&G(k.appendChild)&&k.appendChild(w),this.#o=w,w}#S(p,w){const k=this.#i;if(W(k),p==null||p==="")return!1;if(typeof p=="string")return k.textContent=p,!0;if(typeof p=="object"){if(typeof p.nodeType=="number")return k.appendChild(p),!0;const m=p;if(typeof m.html=="string")return k.innerHTML=D(m.html),!0;if(m.title!==void 0||m.rows!==void 0||m.note!==void 0)return this.#M(m),!0}return H(`tooltip-content:${w}`,`Column '${w}' 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}#M(p){const w=this.#r,k=this.#i,m=C=>C==null?"":String(C);p.title!==void 0&&p.title!==null&&p.title!==""&&k.appendChild(B(w,"div",{class:s.title,text:m(p.title)}));const b=Array.isArray(p.rows)?p.rows:[];if(b.length){const C=B(w,"div",{class:s.rows});for(const M of b){if(!M||typeof M!="object")continue;const P=B(w,"div",{class:s.row});P.appendChild(B(w,"span",{class:s.label,text:m(M.label)})),P.appendChild(B(w,"span",{class:s.value,text:m(M.value)})),C.appendChild(P)}k.appendChild(C)}p.note!==void 0&&p.note!==null&&p.note!==""&&k.appendChild(B(w,"div",{class:s.note,text:m(p.note)}))}#A(p){if(this.#p)return;const w=this.#y(p);if(!w){this.hide();return}const k=this.#g(w.column);if(!k){this.hide();return}this.hide();const m=this.#P();r(m,this.#n&&this.#n.root);let b;if(G(k.render))try{b=k.render(w)}catch(P){H(`tooltip-render:${w.colId}`,`Column '${w.colId}' cell.tooltip render threw; no tooltip was shown.`,P);return}const C=this.#S(b,w.colId);if(G(k.mount))try{k.mount(this.#i,w),this.#u=k}catch(P){H(`tooltip-mount:${w.colId}`,`Column '${w.colId}' cell.tooltip mount threw; the tooltip was closed.`,P),this.hide();return}else if(!C)return;const{maxWidth:M}=this.#m();M&&(m.style.maxWidth=M),this.#a=p,this.#l=!0,m.setAttribute("data-open","true"),this.#E(p),this.#R(p)}#E(p){if(!G(p.setAttribute))return;const w=G(p.getAttribute)?p.getAttribute("aria-describedby"):null;this.#c={cell:p,previous:w},p.setAttribute("aria-describedby",w?`${w} ${this.#s}`:this.#s)}#R(p){const w=this.#o;if(!w||!G(p.getBoundingClientRect))return;const k=this.#r.defaultView;if(!k)return;const m=p.getBoundingClientRect(),b=G(w.getBoundingClientRect)?w.getBoundingClientRect():{width:0,height:0},C=k.innerWidth||0,M=k.innerHeight||0,P=b.width||0,x=b.height||0;let E=m.bottom+o;const A=m.top-o-x;E+x>M-o&&A>=o&&(E=A),M&&(E=Math.max(o,Math.min(E,Math.max(o,M-x-o))));let j=m.left;C&&(j=Math.min(j,Math.max(o,C-P-o))),j=Math.max(o,j),w.style.left=`${Math.round(j)}px`,w.style.top=`${Math.round(E)}px`}hide(){if(this.#L(),this.#x(),!this.#l)return;if(this.#l=!1,this.#u&&G(this.#u.unmount))try{this.#u.unmount(this.#i)}catch(w){H("tooltip-unmount","A cell.tooltip unmount threw while the tooltip was closing.",w)}this.#u=null,this.#i&&W(this.#i),this.#o&&this.#o.setAttribute("data-open","false");const p=this.#c;p&&G(p.cell.setAttribute)&&(p.previous?p.cell.setAttribute("aria-describedby",p.previous):G(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.#f!==null&&(clearTimeout(this.#f),this.#f=null)}destroy(){this.hide(),this.#p=!0;for(const p of this.#h)p();this.#h.length=0,this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}const h=d}),xe("packages/dom/src/platform.js",function(e,K){"use strict";Object.defineProperty(e,"macLike",{enumerable:!0,get:function(){return X}});function X(){const L=globalThis.navigator,B=String(L&&(L.userAgentData?.platform||L.platform)||"");return/mac|iphone|ipad/i.test(B)}}),xe("packages/dom/src/columnmenu.js",function(e,K){"use strict";Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"aggregateMenuItem",{enumerable:!0,get:function(){return i}}),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 f}}),Object.defineProperty(e,"columnAcceptsEdits",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"rangeChartConfig",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"chartableRange",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return h}}),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 w}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,W=K("packages/dom/src/platform.js").macLike,G=K("packages/core/src/i18n/index.js").defaultMessages,U=K("packages/dom/src/ui/contextmenu.js").ContextMenu,D=K("packages/core/src/compute/total.js"),v=D.aggregatesFor,S=D.totalLabel,y=10,l=150;function c(k,m){const b=(ee,te)=>(k&&k.messages?k.messages:G).t(ee,te),C=k.columns.get(m);if(!C)return[];const M=k.sort.get(),P=M.find(ee=>ee.col===m),x=C.layout&&C.layout.pin,E=k.state.get().group||[],A=E.includes(m);if(C.generated&&Array.isArray(C.groupedIds))return r(k,C,E);const j=!C.sort||C.sort.enabled!==!1,$=!C.filter||C.filter.enabled!==!1,z=[];j&&z.push({name:b("menu.sortAscending"),icon:"↑",disabled:P&&P.dir==="asc",action:()=>k.sort.set([{col:m,dir:"asc"}])},{name:b("menu.sortDescending"),icon:"↓",disabled:P&&P.dir==="desc",action:()=>k.sort.set([{col:m,dir:"desc"}])},{name:b("menu.clearSort"),disabled:!P,action:()=>k.sort.set(M.filter(ee=>ee.col!==m))},{separator:!0}),$&&z.push({name:b("menu.filterEllipsis"),action:()=>k.emit("column:filter:open",{colId:m})},{separator:!0}),z.push({name:b("menu.columnStatistics"),action:()=>k.emit("column:profile:open",{colId:m})},{separator:!0}),z.push({name:b("menu.pinColumn"),children:[{name:b("menu.pinStart"),disabled:x==="start",action:()=>k.columns.pin(m,"start")},{name:b("menu.pinEnd"),disabled:x==="end",action:()=>k.columns.pin(m,"end")},{name:b("menu.unpin"),disabled:!x,action:()=>k.columns.pin(m,null)}]});const T=!(C.layout&&(C.layout.movable===!1||C.layout.lockPosition)),R=!(C.layout&&C.layout.resizable===!1),O=ee=>{const te=k.columns.get(ee);return Number(te&&te.layout&&te.layout.width)||l},I=k.columns.visible().filter(ee=>!ee.generated).map(ee=>ee.id),q=I.indexOf(m);if(z.push({name:b("menu.sizeToFit"),action:()=>k.columns.autoSize(m)},{name:b("menu.sizeAllToFit"),action:()=>k.columns.fit()},{name:b("menu.width"),disabled:!R,children:[{name:b("menu.narrower"),disabled:!R,action:()=>k.columns.resize(m,Math.max(1,O(m)-y))},{name:b("menu.wider"),disabled:!R,action:()=>k.columns.resize(m,O(m)+y)},{name:b("menu.autosize"),disabled:!R,action:()=>k.columns.autoSize(m)}]},{separator:!0},{name:b("menu.moveColumn"),disabled:!T,children:[{name:b("menu.moveLeft"),disabled:!T||q<=0,action:()=>k.columns.move(m,Math.max(0,q-1))},{name:b("menu.moveRight"),disabled:!T||q<0||q>=I.length-1,action:()=>k.columns.move(m,Math.min(I.length-1,q+1))},{name:b("menu.moveToStart"),disabled:!T||q<=0,action:()=>k.columns.move(m,0)},{name:b("menu.moveToEnd"),disabled:!T||q<0||q>=I.length-1,action:()=>k.columns.move(m,I.length-1)}]},{separator:!0}),C.allowGroup!==!1&&z.push({name:b(A?"menu.ungroup":"menu.groupBy"),action:()=>k.columns.group(A?E.filter(ee=>ee!==m):[...E,m])}),E.length&&z.push({name:b("menu.expandAll"),action:()=>k.rows.expandAll()},{name:b("menu.collapseAll"),action:()=>k.rows.collapseAll()}),L(k.columns.groupColumns)){const ee=C.groupPath||[],te=ee.length?ee[ee.length-1]:null,ne=[{name:b("columngroup.group"),disabled:I.length<2||q<0,action:()=>{const ie=I[q+1]??I[q-1];if(!ie)return;const ae=(k.columns.get(ie)||{}).groupPath||[],re=ae.length?ae[ae.length-1]:null;re?k.columns.groupColumns([m],{groupId:re}):k.columns.groupColumns([m,ie],{title:b("columngroup.newGroup")})}}];te&&ne.push({name:b("columngroup.dissolve"),action:()=>k.columns.dissolveGroup(te)}),z.push({separator:!0},...ne)}const Z=k.state&&L(k.state.get)?k.state.get().pivot:null,_=Z&&Z.columns||[],J=_.includes(m);if(C.allowPivot!==!1&&z.push({name:b(J?"menu.unpivot":"menu.pivotBy"),action:()=>k.columns.pivot(J?_.filter(ee=>ee!==m):[..._,m])}),C.allowTotal!==!1)if(L(k.get)&&k.get("aggregateChooser")===!0)z.push(i(k,C,b));else{const te=!!C.total;z.push({name:b(te?"menu.stopTotalling":"menu.totalColumn"),action:()=>k.columns.setTotal(m,te?null:"sum")})}return z.push({name:b("menu.hideColumn"),disabled:C.layout&&C.layout.lockVisible===!0,action:()=>k.columns.hide(m)}),z}function i(k,m,b){const C=m.id,M=typeof m.total=="string"?m.total:null,P=[{name:b("menu.aggregateNone"),checked:!m.total,action:()=>k.columns.setTotal(C,null)},{separator:!0},...v(m).map(x=>({name:S(x),checked:M===x,action:()=>k.columns.setTotal(C,x)})),{separator:!0},n(k,m,b,"group",b("menu.aggregateGroup")),n(k,m,b,"grand",b("menu.aggregateGrand"))];return{name:b("menu.aggregate"),children:P}}function n(k,m,b,C,M){const P=m.id,x=C==="grand"?m.grandTotal:m.groupTotal,E=typeof x=="string"?x:null,A=[{name:b("menu.aggregateSame"),checked:x==null,action:()=>k.columns.setTotal(P,null,{scope:C})},{separator:!0},...v(m).map(j=>({name:S(j),checked:E===j,action:()=>k.columns.setTotal(P,j,{scope:C})}))];return{name:M,children:A}}function t(k,m){const b=(E,A)=>(k&&k.messages?k.messages:G).t(E,A),C=k.columns.get(m);if(!C)return[];const M=k.redaction,P=!!(M&&M.has(m)),x=[];return M&&(x.push({name:b(P?"menu.stopRedacting":"menu.redactColumn"),action:()=>M.toggle(m)}),(M.list().length>1||M.active&&!P)&&x.push({name:b("menu.stopRedactingAll"),action:()=>M.clear()}),x.push({separator:!0})),x.push({name:b("menu.hideColumn"),disabled:C.layout&&C.layout.lockVisible===!0,action:()=>k.columns.hide(m)}),x}function r(k,m,b){const C=(A,j)=>(k&&k.messages?k.messages:G).t(A,j),M=b[0],P=k.sort.get(),x=M?P.find(A=>A.col===M):null,E=[];M&&E.push({name:C("menu.sortGroupsAscending"),icon:"↑",disabled:x&&x.dir==="asc",action:()=>k.sort.set([{col:M,dir:"asc"}])},{name:C("menu.sortGroupsDescending"),icon:"↓",disabled:x&&x.dir==="desc",action:()=>k.sort.set([{col:M,dir:"desc"}])},{separator:!0},{name:C("menu.filterGroups"),action:()=>k.emit("column:filter:open",{colId:m.id})},{separator:!0}),E.push({name:C("menu.expandAll"),action:()=>k.rows.expandAll()},{name:C("menu.collapseAll"),action:()=>k.rows.collapseAll()},{separator:!0});for(const A of b){const j=k.columns.get(A);E.push({name:`Remove "${j&&j.title||A}" from grouping`,action:()=>k.columns.group(b.filter($=>$!==A))})}return E.push({name:C("menu.clearGrouping"),disabled:!b.length,action:()=>k.columns.group([])}),E}function s(){const k=globalThis.navigator&&globalThis.navigator.clipboard;return!!(k&&typeof k.readText=="function")}function f(k){return L(k.get)&&k.get("edit")===!1?!1:(k.columns&&L(k.columns.visible)?k.columns.visible():[]).some(b=>{const C=b&&b.edit;return C?C.enabled===void 0||L(C.enabled)?!0:C.enabled!==!1:!1})}function u(k,m){if(L(k.get)&&k.get("edit")===!1)return!1;const b=m&&m.edit;return b?b.enabled===void 0||L(b.enabled)?!0:b.enabled!==!1:!1}const o=new Set(["number","currency","percent","integer"]);function g(k){const m=L(k.get)?k.get("rangeChart"):void 0;return m?L(m)?{enabled:!0,handler:m}:m&&typeof m=="object"&&L(m.onChart)?{enabled:!0,handler:m.onChart}:{enabled:!0,handler:null}:{enabled:!1,handler:null}}function d(k){const m=k.selection&&L(k.selection.ranges)?k.selection.ranges():[];if(!Array.isArray(m)||!m.length)return null;const b=m[m.length-1],C=L(k.columns.visible)?k.columns.visible():[],M=new Set(C.filter(P=>P&&o.has(P.type)).map(P=>P.id));return(b.columns||[]).some(P=>M.has(P))?b:null}function h(k,m){const b=(_,J)=>(k&&k.messages?k.messages:G).t(_,J),{colId:C,row:M}=m,P=k.selection.keys().length,x=k.selection.cells().length,E=(k.state&&L(k.state.get)?k.state.get().group:null)||[],A=k.ranges||null,j=W()?"Cmd":"Ctrl",$=()=>x||P||0,z=_=>k.columns&&L(k.columns.get)?k.columns.get(_):null,T=L(k.selection.cells)?k.selection.cells():[],R=[...new Set(T.map(_=>_&&_.colId).filter(Boolean))];!R.length&&C&&R.push(C);const O=R.length?R.some(_=>u(k,z(_))):f(k),I=C?u(k,z(C)):!1,q=g(k),Z=q.enabled?d(k):null;return[{name:x>1?`Copy ${x} cells`:b("menu.copy"),shortcut:`${j}+C`,disabled:!$(),action:()=>A&&x?A.copy():k.export.clipboard({rows:P?"selected":"range"})},{name:b("menu.copyWithHeaders"),disabled:!$(),action:()=>k.export.clipboard({headers:!0,rows:P?"selected":"range"})},...C==null?[]:[{name:b("menu.paste"),shortcut:`${j}+V`,disabled:!A||!O||!s(),action:()=>A&&A.paste()},{separator:!0},{name:b("menu.clearCells",{count:x||1}),shortcut:"Delete",disabled:!A||!O||!x,action:()=>A&&A.clear()},{name:b("menu.fillDown"),shortcut:`${j}+D`,disabled:!A||!O||x<2,action:()=>A&&A.fillDown()}],...Z&&q.handler?[{name:"Chart selection",action:()=>q.handler(k,Z)}]:[],{separator:!0},{name:"Export visible rows to CSV",action:()=>k.export.csv({rows:"visible",download:!0})},{name:`Export ${P} selected row${P===1?"":"s"} to CSV`,disabled:!P,action:()=>k.export.csv({rows:"selected",download:!0})},{name:"Export visible rows to Excel",action:()=>k.export.excel({rows:"visible",download:!0})},{name:`Export ${P} selected row${P===1?"":"s"} to Excel`,disabled:!P,action:()=>k.export.excel({rows:"selected",download:!0})},{name:"Copy visible rows",action:()=>k.export.clipboard({rows:"visible",headers:!0})},{name:"Print",action:()=>k.export.print()},...k.importer&&L(k.importer.openFile)?[{name:b("menu.importCsv"),action:()=>k.importer.openFile()}]:[],{separator:!0},...E.length?[{name:b("menu.expandAll"),action:()=>k.rows.expandAll()},{name:b("menu.collapseAll"),action:()=>k.rows.collapseAll()}]:[],{name:"Clear selection",disabled:!P,action:()=>k.selection.clear()},...L(k.get)&&k.get("rowDelete")===!0?[{name:b("menu.deleteRow",{count:P||1}),disabled:!P&&!M,action:()=>k.edit.deleteRows(P?void 0:M?M.key:void 0)}]:[],...C==null?[]:[{name:"Edit cell",disabled:!M||!C||!I,action:()=>M&&C&&k.edit.start(M.key,C)}]]}function a(k,m,b,C){if(k==null)return{items:m,spoke:!1,suppress:!1};if(k===!1)return{items:m,spoke:!0,suppress:!0};if(k===!0)return{items:m,spoke:!0,suppress:!1};if(Array.isArray(k))return{items:[...m,...k],spoke:!0,suppress:!1};if(L(k)){const M=k(b,m);return{items:Array.isArray(M)?M:m,spoke:!0,suppress:!1}}return B(`menu-layer:${C}`,`${C} must be a boolean, an array of items or a (params, defaults) => items function; got ${typeof k}. Ignoring it.`),{items:m,spoke:!1,suppress:!1}}function p(k,m,b){let C=Array.isArray(k)?k:[],M=!1;for(const P of m){if(!P)continue;const x=a(P.layer,C,b,P.where);C=x.items,x.spoke&&(M=x.suppress)}return M?null:C}class w{#e=!0;#t=!0;#n;#r;#o=[];#i=null;#s=null;constructor(m){this.#n=m.grid,this.#e=m.cellMenu!==!1,this.#t=m.headerMenu!==!1,this.#i=L(m.items)?m.items:null,this.#s=L(m.headerItems)?m.headerItems:null,this.#r=new U({document:m.document,host:m.host,ctx:{grid:m.grid}})}mount(){this.#t&&this.#o.push(this.#n.on("column:menu:open",m=>{const b=String(m.colId),C=this.#c(b,c(this.#n,b));C.length&&this.#r.show({items:C,ctx:this.#u(b),anchor:m.element,placement:"below",returnFocus:m.element})})),this.#t&&this.#o.push(this.#n.on("header:contextmenu",m=>{const b=String(m.colId),C=this.#c(b,t(this.#n,b));C.length&&this.#r.show({items:C,ctx:this.#u(b),x:m.x,y:m.y,returnFocus:m.element})})),this.#o.push(this.#n.on("cell:contextmenu",m=>{const b=m.event;this.#e&&b&&L(b.preventDefault)&&b.preventDefault();const C=this.#l(m),M=h(this.#n,C),P=p(M,[{layer:this.#e===!1?!1:this.#i,where:"contextMenu"},{layer:this.#a(C.column),where:`column '${C.colId}' contextMenu`}],C);!P||!P.length||(!this.#e&&b&&L(b.preventDefault)&&b.preventDefault(),this.#r.show({items:P,ctx:C,x:b?b.clientX:void 0,y:b?b.clientY:void 0}))}))}#l(m){const b=this.#n.columns,C=m.column||(m.colId!=null&&b&&L(b.get)?b.get(m.colId):void 0),M=m.row,P=this.#n.rows,x=m.key!==void 0?m.key:M?M.key:void 0;return{key:x,colId:m.colId,value:m.value!==void 0||x===void 0||m.colId==null?m.value:P&&L(P.value)?P.value(x,m.colId):void 0,row:M,data:M?M.data:void 0,column:C,index:m.index!==void 0?m.index:m.rowIndex,grid:this.#n}}#a(m){if(!(!m||m.contextMenu===void 0||m.contextMenu===null))return m.contextMenu}#u(m){return{colId:m,column:this.#n.columns.get(m),grid:this.#n}}#c(m,b){return this.#s?p(b,[{layer:this.#s,where:"columnMenu"}],this.#u(m))||[]:b}destroy(){for(const m of this.#o)m();this.#o=[],this.#r.destroy()}}}),xe("packages/dom/src/shortcutshelp.js",function(e,K){"use strict";Object.defineProperty(e,"HELP_CLASS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"ShortcutsHelp",{enumerable:!0,get:function(){return S}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,W=K("packages/dom/src/renderer/keyboard.js"),Q=W.groupedShortcuts,G=W.SHORTCUT_IDS,U=K("packages/dom/src/platform.js").macLike,D="lat-shortcuts",v='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class S{#e;#t;#n=null;#r=null;#o=[];constructor(l){this.#e=l.grid,this.#t=l.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#i(l,c){const i=this.#e;return(i&&i.messages?i.messages:F).t(l,c)}#s(l){const c=G[l.combo];if(!c)return l.meaning;const i=`shortcut.${c}`,n=this.#i(i);return n===i?l.meaning:n}mount(){const l=this.#t.viewport?.root;if(!l||!L(l.addEventListener))return;const c=i=>{if(this.open||i.key!=="?")return;const n=i.target,t=n&&n.tagName;t==="INPUT"||t==="TEXTAREA"||n&&n.isContentEditable||(i.preventDefault(),i.stopPropagation(),this.show())};l.addEventListener("keydown",c,!0),this.#o.push(()=>l.removeEventListener("keydown",c,!0))}show(){const l=this.#l();if(!l)return;const c=l.ownerDocument;this.#r=c&&c.activeElement,l.style.display="",L(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(l.focus)&&l.focus(),this.#e.emit?.("shortcuts:closed",{})}#l(){if(this.#n)return this.#n;const l=this.#t.viewport?.overlays,c=l?.ownerDocument;if(!l||!c?.createElement)return null;const i=c.createElement("div");i.className=D,i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("tabindex","-1");const n=`${D}-title`;i.setAttribute("aria-labelledby",n);const t=c.createElement("div");t.className=`${D}__head`;const r=c.createElement("h2");r.className=`${D}__title`,r.id=n,r.textContent=this.#i("shortcuts.title");const s=c.createElement("button");s.className=`${D}__close`,s.type="button",s.setAttribute("aria-label",this.#i("shortcuts.close")),s.textContent="×",t.appendChild(r),t.appendChild(s),i.appendChild(t);const f=c.createElement("div");f.className=`${D}__body`;for(const o of Q())o.items.length&&f.appendChild(this.#a(c,o));i.appendChild(f);const u=c.createElement("p");return u.className=`${D}__hint`,u.textContent=this.#i("shortcuts.hint"),i.appendChild(u),l.appendChild(i),this.#n=i,this.#u(i,s),i}#a(l,c){const i=l.createElement("section");i.className=`${D}__group`;const n=l.createElement("h3");n.className=`${D}__group-title`,n.textContent=this.#i(c.messageKey),i.appendChild(n);const t=l.createElement("dl");t.className=`${D}__list`;const r=U();for(const s of c.items){const f=l.createElement("dt");f.className=`${D}__keys`,s.alternatives.forEach((o,g)=>{if(g>0){const d=l.createElement("span");d.className=`${D}__or`,d.textContent=this.#i("shortcuts.or"),f.appendChild(d)}o.forEach((d,h)=>{h>0&&f.appendChild(l.createTextNode("+"));const a=l.createElement("kbd");a.textContent=r&&d==="Ctrl"?this.#i("shortcuts.key.cmd"):d,f.appendChild(a)})});const u=l.createElement("dd");u.className=`${D}__meaning`,u.textContent=this.#s(s),t.appendChild(f),t.appendChild(u)}return i.appendChild(t),i}#u(l,c){const i=t=>{if(t.stopPropagation(),t.key==="Escape"){t.preventDefault(),this.hide();return}if(t.key!=="Tab")return;const r=[...l.querySelectorAll(v)];if(!r.length){t.preventDefault();return}const s=r[0],f=r[r.length-1],u=l.ownerDocument.activeElement;t.shiftKey&&(u===s||u===l)?(t.preventDefault(),f.focus()):!t.shiftKey&&u===f&&(t.preventDefault(),s.focus())},n=t=>{t.preventDefault?.(),this.hide()};l.addEventListener("keydown",i),c.addEventListener("click",n),this.#o.push(()=>{l.removeEventListener("keydown",i),c.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}}}),xe("packages/dom/src/rowreorder.js",function(e,K){"use strict";Object.defineProperty(e,"HANDLE_CLASS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"MARKER_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DRAGGING_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"MANUAL_CLASS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"resolveRowTransfer",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"resolveRowReorder",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"RowReorder",{enumerable:!0,get:function(){return i}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,Q=K("packages/dom/src/renderer/renderer.js").displayIndexOf,G="lat-rowdrag",H="lat-rowdrag-marker",U="lat-rowdrag-lifted",D="lat-manual-order",v=Object.freeze({sorted:"a11y.reorder.sorted",filtered:"a11y.reorder.filtered",grouped:"a11y.reorder.grouped","group-derived":"a11y.reorder.groupDerived","group-not-editable":"a11y.reorder.groupReadOnly",invalid:"a11y.reorder.invalid",vetoed:"a11y.reorder.vetoed"}),S=4,y=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 c(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 i{#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=c(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:F).t(t,r)}#c(t,r){const s=this.#t&&this.#t.announce;L(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 f of s){if(f.querySelector(`.${G}`))continue;const u=f.parentNode;if(u&&L(u.getAttribute)&&u.getAttribute("data-pinned"))continue;const o=this.#n.createElement("span");o.className=G,o.setAttribute("data-role","row-drag"),o.setAttribute("aria-hidden","true"),o.setAttribute("title",this.#u("a11y.reorder.grab")),o.textContent="⠿",f.insertBefore(o,f.firstChild||null)}this.#h(r,t)}#f(){const t=this.#e.rowOrder;return!!(t&&L(t.manual)&&t.manual())}#h(t,r){const s=this.#f();if(L(t.setAttribute)&&(s?t.setAttribute("data-row-order","manual"):t.removeAttribute("data-row-order")),!this.#r||!this.#r.manualOrder)return;const f=t.querySelector(`.lat-header-cell[data-col="${r}"]`);if(!f)return;let u=f.querySelector(`.${D}`);u||(u=this.#n.createElement("button"),u.className=D,u.setAttribute("type","button"),u.setAttribute("data-role","manual-order"),u.setAttribute("tabindex","-1"),u.textContent=this.#u("rowOrder.button"),u.addEventListener("click",g=>{g.stopPropagation?.(),this.toggleManual()}),u.addEventListener("pointerdown",g=>g.stopPropagation?.()),f.insertBefore(u,f.firstChild||null)),u.setAttribute("aria-pressed",s?"true":"false");const o=this.#u(s?"rowOrder.exit":"rowOrder.enter");u.setAttribute("title",o),u.setAttribute("aria-label",o)}toggleManual(){const t=this.#e.rowOrder;if(!t)return;const r=this.#f()?t.exit():t.enter({origin:"user"}),s=f=>{f&&f.reason&&this.#c(this.#u(v[f.reason]||"a11y.reorder.refused"),{repeat:!0}),this.paint()};r&&L(r.then)?r.then(s):s(r)}mount(){if(!this.active)return;y.add(this);const t=this.#t.viewport?.root;if(!t||!L(t.addEventListener))return;const r=g=>this.#p(g),s=g=>this.#m(g),f=()=>this.#g(),u=g=>this.#M(g);if(t.addEventListener("pointerdown",r),t.addEventListener("keydown",u),L(this.#e.on)){let g=this.#f();this.#a.push(this.#e.on("state:changed",d=>{!d||!Array.isArray(d.sections)||!d.sections.includes("rowOrder")||this.#f()!==g&&(g=this.#f(),this.#c(this.#u(g?"a11y.rowOrder.entered":"a11y.rowOrder.exited"),{repeat:!0}))}))}const o=this.#n.defaultView||this.#n;o.addEventListener?.("pointermove",s),o.addEventListener?.("pointerup",f),this.#a.push(()=>{t.removeEventListener("pointerdown",r),t.removeEventListener("keydown",u),o.removeEventListener?.("pointermove",s),o.removeEventListener?.("pointerup",f)})}#p(t){const r=t.target;if(!r||!L(r.closest)||!r.closest('[data-role="row-drag"]'))return;const s=r.closest(".lat-row"),f=s?Q(s):-1;if(f<0)return;const u=this.#e.rows.get(f);if(!u||u.group)return;const o=this.#L();if(o&&!(this.#o&&this.#o.send)){this.#c(this.#u(o),{repeat:!0});return}t.preventDefault?.(),this.#i={key:u.key,from:f,at:f,x:t.clientX,y:t.clientY,armed:!1,hit:null,over:null,frame:null,pending:null}}#m(t){const r=this.#i;if(!r)return;if(!r.armed){if(Math.abs(t.clientX-r.x)+Math.abs(t.clientY-r.y)<S)return;r.armed=!0,this.#I(r),r.over=this,this.#e.emit("rowDrag:started",this.#y(r,this,r.from,r.key),"user")}this.#l&&this.#z(t.clientX,t.clientY);const s=this.#S(t.clientX,t.clientY);if(r.target=s,s!==this){this.#H(),s&&s.accepts(this)?(s.showDropTarget(t.clientX,t.clientY),r.hit=s.hitAt(t.clientX,t.clientY)):r.hit=null,this.#k(r,s),this.#b(r,s,r.hit?r.hit.at:null,r.hit?r.hit.overKey:null);return}const f=this.#x(t.clientX,t.clientY);if(this.#k(r,s),f<0){this.#b(r,this,null,null);return}r.at=f,this.#N(f);const u=this.#e.rows.get(f);this.#b(r,this,f,u?u.key:null)}#g(){const t=this.#i;this.#i=null,this.#H(),this.#$();for(const f of y)f.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.#P(t,r);return}if(t.at===t.from)return;const s=this.#L();if(s){this.#c(this.#u(s),{repeat:!0});return}this.#E(t.key,t.at)}#y(t,r,s,f){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:f}}#w(t){const r=t.target||null;if(r&&r!==this){if(!r.accepts(this))return{...this.#y(t,r,null,null),dropped:!1};const s=t.hit||{at:r.grid.rows.count(),overKey:null};return{...this.#y(t,r,s.at,s.overKey),dropped:!0}}if(r===this){const s=this.#e.rows.get(t.at);return{...this.#y(t,this,t.at,s?s.key:null),dropped:t.at!==t.from&&this.#L()===null}}return{...this.#y(t,null,null,null),dropped:!1}}#k(t,r){if(t.over===r)return;const s=t.over;t.over=r,s&&(this.#O(t),this.#e.emit("rowDrag:left",this.#y(t,s,null,null),"user"))}#b(t,r,s,f){t.pending={over:r,at:s,overKey:f},t.frame===null&&(t.frame=this.#j(()=>{t.frame=null;const u=t.pending;t.pending=null,!(!u||this.#i!==t)&&this.#e.emit("rowDrag:moved",this.#y(t,u.over,u.at,u.overKey),"user")}))}#O(t){t.pending=null,t.frame!==null&&(t.frame(),t.frame=null)}#j(t){const r=this.#n.defaultView||globalThis;if(L(r.requestAnimationFrame)){const f=r.requestAnimationFrame(t);return()=>{L(r.cancelAnimationFrame)&&r.cancelAnimationFrame(f)}}const s=setTimeout(t,16);return()=>clearTimeout(s)}#P(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 f=this.#o.mode,u=t.key,o=t.hit||{at:r.grid.rows.count(),overKey:null};let g=null;const d=r.receive(s.data,o.at,{overKey:o.overKey,source:this.#e,revalidate:()=>!!this.#e.rows.byKey(u),onCancel:a=>{g=a}}),h=a=>{if(a!==!0){const p=a===!1?"a11y.transfer.refused":g==="stale"?"a11y.transfer.stale":"a11y.transfer.declined";this.#c(this.#u(p),{repeat:!0});return}f==="move"?(this.#e.rows.apply({remove:[u]}),this.#e.emit("row:sent",{key:u,data:s.data,mode:f})):this.#e.emit("row:copied",{key:u,data:s.data,mode:f}),this.#c(this.#u(f==="copy"?"a11y.transfer.copied":"a11y.transfer.moved"),{repeat:!0})};d&&L(d.then)?d.then(h):h(d)}receive(t,r,s={}){const f=this.#e,u=t&&typeof t=="object"?{...t}:t,o=s.overKey??null,g=s.source||null,d=L(s.onCancel)?s.onCancel:null,h=()=>{const m=f.rows.totalCount(),b=f.rows.apply({add:[u],at:Math.max(0,r||0)}),C=f.rows.totalCount()>m;return C&&f.emit("row:received",{data:u,at:r,overKey:o,rejected:b?.rejected||[]}),C},a=()=>{if(o!==null){const m=f.rows.get(r);if(!m||m.key!==o)return!1}else r=f.rows.count();return!L(s.revalidate)||s.revalidate()},p=L(f.rendererHost)?f.rendererHost():null;if(!p||!L(p.gateBefore))return h();const w=d?f.on("rowReceive:cancelled",m=>d(m.reason)):null,k=p.gateBefore("beforeRowReceive","rowReceive:cancelled",{data:u,at:r,overKey:o,source:g,origin:"user"},h,a);return w&&(k&&L(k.then)?k.then(w,w):w()),k}hitAt(t,r){const s=this.#x(t,r);if(s<0)return{at:this.#e.rows.count(),overKey:null};const f=this.#e.rows.get(s);return{at:s,overKey:f?f.key:null}}showDropTarget(t,r){const s=this.root;s&&L(s.setAttribute)&&s.setAttribute("data-drop-target","")}hideDropTarget(){const t=this.root;t&&L(t.removeAttribute)&&t.removeAttribute("data-drop-target")}#S(t,r){const s=this.#n.elementFromPoint?this.#n.elementFromPoint(t,r):null,f=s&&L(s.closest)?s.closest(".lattice"):null;if(!f)return null;for(const u of y)if(u.root===f)return u;return null}#M(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,f=s&&L(s.closest)?s.closest(".lat-row"):null,u=f?Q(f):-1;if(u<0)return;t.preventDefault?.(),t.stopPropagation?.();const o=this.#L();if(o){this.#c(this.#u(o),{repeat:!0});return}const g=this.#e.rows.get(u);!g||g.group||this.#E(g.key,this.#A(u,r))}#A(t,r){const s=this.#e;if(r>0||!L(s.rows.groupHeadings))return t+r;const f=new Set(s.rows.groupHeadings(t).map(o=>o.key));let u=t+r;for(;u>=0;){const o=s.rows.get(u);if(!o||!f.has(o.key))break;u+=r}return u<0?t:u}#E(t,r){const s=this.#e.rows.count(),f=Math.max(0,Math.min(s-1,r)),u=this.#e.rows.move(t,f,{origin:"user"});u&&L(u.then)?u.then(o=>this.#R(o,s)):this.#R(u,s)}#R(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,f=s?this.#u("a11y.reorder.vetoedBecause",{reason:s}):this.#u(v[t.reason]||"a11y.reorder.refused");this.#c(f,{repeat:!0});return}if(Array.isArray(t.regrouped)&&t.regrouped.length){const s=t.regrouped.map(f=>String(f.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.#f()&&!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,f=s&&L(s.closest)?s.closest(".lat-row"):null;return!f||L(f.getAttribute)&&f.getAttribute("data-pinned")?-1:Q(f)}#I(t){const r=this.root,s=r&&L(r.querySelector)?r.querySelector(`.lat-row[data-index="${t.from}"]`):null;s&&L(s.classList?.add)&&s.classList.add(U);const f=this.#n.body;if(!f||!L(f.appendChild))return;const u=this.#d(),o=u&&L(this.#e.rows?.text)&&this.#e.rows.text(t.key,u)||this.#u("a11y.reorder.grab"),g=r&&this.#n.defaultView?.getComputedStyle?this.#n.defaultView.getComputedStyle(r):null,d=(a,p)=>g&&g.getPropertyValue(a).trim()||p,h=this.#n.createElement("div");h.textContent=String(o),h.setAttribute("aria-hidden","true"),h.setAttribute("data-role","row-drag-ghost"),h.style.cssText=["position:fixed","z-index:2147483647","pointer-events:none","top:0","left:0","white-space:nowrap",`padding:${d("--lattice-space","4px")} calc(${d("--lattice-space","4px")} * 2)`,`border-radius:${d("--lattice-radius-sm",d("--lattice-radius","4px"))}`,`border:${d("--lattice-border-width","1px")} solid ${d("--lattice-border-strong","#0003")}`,`background:${d("--lattice-background","#fff")}`,`color:${d("--lattice-foreground","#000")}`,`box-shadow:${d("--lattice-shadow-overlay","0 4px 12px rgba(0,0,0,.25)")}`,`font:${d("--lattice-font-size","13px")} ${d("--lattice-font-family","system-ui, sans-serif")}`].join(";"),f.appendChild(h),this.#l=h}#z(t,r){this.#l&&(this.#l.style.transform=`translate(${Math.round(t)+14}px, ${Math.round(r)+16}px)`)}#$(){this.#l&&(this.#l.parentNode&&this.#l.parentNode.removeChild(this.#l),this.#l=null);const t=this.root,r=t&&L(t.querySelectorAll)?t.querySelectorAll(`.${U}`):[];for(const s of r)s.classList.remove(U)}#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,f=s.querySelector(`.lat-row[data-index="${t}"]`)||s.querySelectorAll(".lat-row")[0];if(!f||!L(f.getBoundingClientRect))return;const u=f.getBoundingClientRect(),o=s.getBoundingClientRect(),g=this.#i&&t>this.#i.from;this.#s.style.display="",this.#s.style.top=`${Math.round((g?u.bottom:u.top)-o.top)}px`}#H(){this.#s&&(this.#s.style.display="none")}destroy(){y.delete(this);for(const t of this.#a)t();this.#a=[],this.#i&&this.#O(this.#i),this.#i=null,this.#$(),this.#s&&this.#s.parentNode&&this.#s.parentNode.removeChild(this.#s),this.#s=null}}}),xe("packages/dom/src/alignedgrids.js",function(e,K){"use strict";Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return Q}});const L=K("packages/core/src/internal/util.js").isFunction,B=["column:resized","column:moved","column:visible","column:pinned"];function F(G){return(G||[]).map(H=>({id:H.id,width:H.width,flex:H.flex,hidden:H.hidden,pin:H.pin===void 0?null:H.pin}))}class W{#e=new Set;#t=new Map;#n=!1;add(H){if(!H||this.#e.has(H))return;this.#e.add(H);const U=[];for(const v of B)U.push(H.on(v,()=>this.#r(H)));U.push(H.on("scroll",v=>this.#i(H,v))),U.push(H.on("destroy",()=>this.remove(H))),this.#t.set(H,U);const[D]=this.#e;D!==H&&this.#o(H,F(D.columns.state()))}remove(H){const U=this.#t.get(H);if(U)for(const D of U)D();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 U=F(H.columns.state());this.#n=!0;try{for(const D of this.#e)D!==H&&this.#o(D,U)}finally{this.#n=!1}}#o(H,U){if(!H.columns||!L(H.columns.apply))return;const D=new Map((H.columns.state()||[]).map(S=>[S.id,S])),v=[];for(const S of U){const y=D.get(S.id);y&&(v.push({...y,...S}),D.delete(S.id))}for(const S of D.values())v.push(S);H.columns.apply(v)}#i(H,U){if(this.#n)return;const D=U&&typeof U.left=="number"?U.left:null;if(D!==null){this.#n=!0;try{for(const v of this.#e)v!==H&&v.scroll?.to?.({left:D})}finally{this.#n=!1}}}}function Q(G){const H=new W;for(const U of G||[])H.add(U);return H}}),xe("packages/dom/src/columntagbar.js",function(e,K){"use strict";Object.defineProperty(e,"BAR_CLASS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"resolveTagFilter",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"ColumnTagBar",{enumerable:!0,get:function(){return G}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,W="lat-tagbar";function Q(U){if(!U)return null;const D=U===!0?{}:typeof U=="object"?U:null;return D?{multiple:D.multiple===!0,label:typeof D.label=="string"?D.label:null}:null}class G{#e;#t;#n;#r=null;#o=null;#i=null;#s="\0";#l=[];constructor(D){this.#e=D.grid,this.#t=D.renderer,this.#n=D.document,this.#r=Q(D.grid.get("columnTagFilter"))}get active(){return this.#r!==null}#a(D,v){const S=this.#e;return(S&&S.messages?S.messages:F).t(D,v)}mount(){if(!this.active)return;const D=this.#t.viewport,v=D?.root;if(!v||!L(v.insertBefore))return;const S=this.#n.createElement("div");S.className=W,S.setAttribute("role","toolbar"),S.setAttribute("aria-label",this.#a("tags.label"));const y=this.#n.createElement("label");y.className=`${W}__label`,y.textContent=this.#r.label||this.#a("tags.label");const l=this.#n.createElement("select");l.className=`${W}__select`,this.#r.multiple&&l.setAttribute("multiple","");const c=`${W}-select-${Math.abs(H(String(v.className)))}`;l.id=c,y.setAttribute("for",c),S.appendChild(y),S.appendChild(l),v.insertBefore(S,D.header||v.firstChild),this.#o=S,this.#i=l;const i=()=>{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",i),this.#l.push(()=>l.removeEventListener("change",i));const n=this.#e.on("model:changed",()=>this.refresh());this.#l.push(n),this.refresh()}#u(D){const v=this.#t&&this.#t.announce;if(!L(v))return;const S=D.length?D.join(", "):this.#a("tags.all");v.call(this.#t,this.#a("tags.showing",{tag:S}))}refresh(){if(!this.#i||!this.#o)return;const D=this.#e.columns.tags();if(this.#o.style.display=D.length?"":"none",!D.length)return;const v=D.join("\0");if(v===this.#s)return;this.#s=v;const S=this.#e.columns.activeTags();if(this.#i.replaceChildren&&this.#i.replaceChildren(),!this.#r.multiple){const y=this.#n.createElement("option");y.value="",y.textContent=this.#a("tags.all"),this.#i.appendChild(y)}for(const y of D){const l=this.#n.createElement("option");l.value=y,l.textContent=y,S.includes(y)&&(l.selected=!0),this.#i.appendChild(l)}this.#r.multiple||(this.#i.value=S.length?S[0]:"")}destroy(){for(const D of this.#l)D();this.#l=[],this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}function H(U){let D=0;for(let v=0;v<U.length;v++)D=D*31+U.charCodeAt(v)|0;return D}}),xe("packages/dom/src/anomalychip.js",function(e,K){"use strict";Object.defineProperty(e,"CHIP_CLASS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"resolveAnomalySummary",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"AnomalyChip",{enumerable:!0,get:function(){return U}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,W="lat-anomaly-chip";function Q(D){if(!D)return null;const v=D===!0?{}:typeof D=="object"?D:null;return v?{column:typeof v.column=="string"?v.column:null,label:typeof v.label=="string"?v.label:null}:null}function G(D){return D?typeof D=="string"?{kind:D}:typeof D=="object"?D:null:null}function H(D,v){return D?Array.isArray(D.conditions)?D.conditions.some(S=>H(S,v)):D.col===v&&D.op==="eq"&&D.value===!0:!1}class U{#e;#t;#n;#r=null;#o=null;#i=null;#s=[];#l=!1;#a=!1;#u=null;#c=0;#d=null;constructor(v){this.#e=v.grid,this.#t=v.renderer,this.#n=v.document,this.#r=Q(v.grid.get("anomalySummary"))}get active(){return this.#r!==null}#f(v,S){const y=this.#e;return(y&&y.messages?y.messages:F).t(v,S)}#h(){const v=this.#r&&this.#r.column;let S=null;for(const y of this.#e.columns.all()){const l=G(y.shadow);if(!l||l.kind!=="anomalyFlag")continue;const c=l.of||y.field||y.id;if(v){if(y.id===v||c===v)return this.#d=y.id,y}else S||(S=y,this.#d=y.id)}return v?null:S}#p(){if(!this.#d||!L(this.#e.rows&&this.#e.rows.forEach))return 0;let v=0;try{this.#e.rows.forEach(S=>{!S||S.group||S.key==null||this.#e.rows.value(S.key,this.#d)===!0&&v++})}catch{return 0}return v}mount(){if(!this.active)return;const v=this.#t.viewport,S=v&&v.root;if(!S||!L(S.insertBefore))return;const y=this.#n.createElement("div");y.className=W,y.setAttribute("role","status");const l=this.#n.createElement("button");l.className=`${W}__button`,l.setAttribute("type","button"),l.setAttribute("aria-pressed","false"),y.appendChild(l),S.insertBefore(y,v.header||S.firstChild),this.#o=y,this.#i=l;const c=()=>this.toggle();l.addEventListener("click",c),this.#s.push(()=>l.removeEventListener("click",c));for(const i of["filter:changed","rows:changed","model:changed"])this.#s.push(this.#e.on(i,()=>{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 v={col:this.#d,op:"eq",value:!0},S=this.#u?{op:"and",conditions:[this.#u,v]}:v;this.#l=!0,this.#a=!0;try{this.#e.filters.set(S)}finally{this.#a=!1}this.refresh()}#g(){this.#l=!1,this.#a=!0;try{this.#e.filters.set(this.#u||null)}finally{this.#a=!1}this.#u=null,this.refresh()}refresh(){if(!this.#o||!this.#i)return;if(!this.#h()){this.#o.style.display="none";return}if(this.#l&&!H(this.#e.filters.get(),this.#d)&&(this.#l=!1,this.#u=null),this.#l){this.#y(this.#c,!0);return}const S=this.#p();if(this.#c=S,!S){this.#o.style.display="none";return}this.#y(S,!1)}#y(v,S){if(!this.#o||!this.#i)return;this.#o.style.display="",this.#o.setAttribute("data-active",S?"true":"false"),this.#i.setAttribute("aria-pressed",S?"true":"false");const y=this.#r&&this.#r.label,l=S?this.#f("anomaly.chipActive",{count:v}):y||this.#f("anomaly.chip",{count:v});this.#i.textContent=l}destroy(){for(const v of this.#s)v();this.#s=[],this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}}),xe("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 i}}),Object.defineProperty(e,"RowForm",{enumerable:!0,get:function(){return s}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,W=K("packages/core/src/i18n/index.js").defaultMessages,G=K("packages/core/src/model/rowkey.js").createRowKey,U=K("packages/dom/src/editors/index.js").createEditor,v=K("packages/dom/src/renderer/renderer.js").displayIndexOf,y=K("packages/dom/src/themeof.js").themeOf,l="lat-rowform",c='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';function i(f){if(!f)return null;const u=f===!0?{}:typeof f=="object"?f:null;if(!u)return null;const o=L(u.load)?u.load:null,g=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:o,create:L(u.create)?u.create:null,fields:g,title:u.title??null,width:typeof u.width=="string"?u.width:null,trigger:u.trigger===!1?"none":"dblclick"}}function n(f,u){const o=L(f)?f():f;return o?typeof o=="string"?u&&L(u.querySelector)?u.querySelector(o):null:o&&L(o.appendChild)?o:null:null}const t=2e3;function r(f){return f===!1||f===0?0:typeof f!="number"||!Number.isFinite(f)||f<=0?t:f}class s{#e;#t;#n;#r;#o=null;#i=null;#s=null;#l=null;#a=null;#u=!1;#c=null;#d=[];#f=null;#h=0;#p=null;#m=!1;#g=[];constructor(u){this.#e=u.grid,this.#t=u.renderer,this.#n=u.document,this.#r=u.registry||null,this.#o=i(u.grid.get("rowForm"))}get active(){return this.#o!==null}get open(){return!!this.#i&&this.#i.style.display!=="none"}#y(u,o){const g=this.#e;return(g&&g.messages?g.messages:W).t(u,o)}mount(){if(!this.active)return;const u=this.#t.viewport?.root;if(!u||!L(u.addEventListener)||this.#o.trigger==="none")return;const o=g=>{const d=g.target;if(!d||!L(d.closest)||d.closest(".lat-editor-host, .lat-editor--popup"))return;const h=d.closest(".lat-row"),a=h?v(h):-1;if(a<0)return;const p=this.#e.rows.get(a);!p||p.group||p.detail||(g.preventDefault?.(),g.stopPropagation?.(),this.openRow(p.key))};u.addEventListener("dblclick",o,!0),this.#g.push(()=>u.removeEventListener("dblclick",o,!0))}openRow(u){const o=this.#e.rows.byKey(u);if(!o)return!1;const g=this.#P();if(!g)return!1;this.#a=o,this.#u=!1,this.#j(),this.#f=this.#n.activeElement,g.style.display="",this.#N(g),this.#M(o);const d=this.#o.load;if(!d)this.#z(o.data);else{this.#L();const h=++this.#h;this.#A(h,a=>{this.#x(new Error(`Loading the record timed out after ${a}ms`),u,"form.loadTimeout")}),Promise.resolve().then(()=>d({row:o,data:o.data,key:u,grid:this.#e})).then(a=>{h!==this.#h||!this.open||(this.#R(),this.#z(a||o.data))}).catch(a=>{h!==this.#h||!this.open||(this.#R(),this.#x(a,u))})}return L(g.focus)&&g.focus(),this.#e.emit("form:opened",{key:u,row:o}),!0}openNew(u){const o=this.#P();if(!o)return!1;this.#h+=1,this.#R(),this.#a=null,this.#u=!0,this.#j(),this.open||(this.#f=this.#n.activeElement),o.style.display="",this.#N(o);const g=o.querySelector(`.${l}__title`);return g&&(g.textContent=this.#y("form.newTitle")),this.#z(u&&typeof u=="object"?{...u}:{}),L(o.focus)&&o.focus(),this.#e.emit("form:opened",{key:null,row:null,created:!0}),!0}close(){if(!this.#i)return;this.#h+=1,this.#R(),this.#he(),this.#i.style.display="none";const u=this.#a?this.#a.key:null;this.#a=null,this.#u=!1,this.#j();const o=this.#f;this.#f=null,o&&L(o.focus)&&o.focus(),this.#e.emit("form:closed",{key:u})}save(){if(!this.#a&&!this.#u||!this.#d.length||this.#u&&this.#l&&this.#l.disabled)return!1;const u=this.#a?this.#a.key:null,o={},g={},d=[],h=[];for(const a of this.#d){const p=L(a.editor.commit)?a.editor.commit():{ok:!0,value:void 0};if(!p.ok)return this.#W(a,p.message),!1;if(o[a.field]=p.value,a.readOnly){h.push(a.field);continue}const w=a.initial;Object.is(w,p.value)||(g[a.field]=p.value,a.colId?d.push({key:u,colId:a.colId,value:p.value}):h.push(a.field))}return this.#u?this.#w(o):(d.length&&this.#e.edit.setCells(d,"cell",{origin:"form"}),this.#e.emit("form:saved",{key:u,values:o,changed:g,unmapped:h}),this.close(),!0)}#w(u){const o=this.#d.filter(h=>!h.colId).map(h=>h.field),g=this.#o.create;if(!g)return this.#k(u)?(this.#b(u,u,o),!0):(B("rowform:create:missing-key","rowForm could not add the new row: it carries no row key. Return the stored row, key included, from rowForm.create, or give the key a field or a default."),!1);this.#j(),this.#E(!1);const d=++this.#h;return this.#A(d,h=>{this.#O(new Error(`Adding the record timed out after ${h}ms`),u,!0)}),Promise.resolve().then(()=>g(u)).then(h=>{if(!(d!==this.#h||!this.open)){if(this.#R(),!this.#k(h)){B("rowform:create:missing-key","rowForm could not add the new row: it carries no row key. Return the stored row, key included, from rowForm.create, or give the key a field or a default."),this.#O(new Error("rowForm.create answered with a row that carries no row key"),u,!1);return}this.#b(h,u,o)}}).catch(h=>{d!==this.#h||!this.open||(this.#R(),this.#O(h,u,!1))}),!0}#k(u){if(!u||typeof u!="object")return!1;const o=G(this.#e.get("rowKey"),{warn:!1});return!o||o.stable===!1?!1:L(o.keyEmpty)?!o.keyEmpty(u):!0}#b(u,o,g){const d=this.#e,h=d.rows.apply({add:[u]}),a=h&&Array.isArray(h.added)?h.added[0]:null;if(!a){this.#O(new Error("The new row could not be added"),o,!1);return}const p=a.key;d.emit("form:saved",{key:p,values:o,changed:o,unmapped:g,created:!0}),this.close();const w=d.get("selection");(typeof w=="string"?w!=="none":w&&typeof w=="object"&&w.mode!=="none")&&d.selection&&L(d.selection.set)&&d.selection.set([p]),d.scroll&&L(d.scroll.toRow)&&d.scroll.toRow(p)}#O(u,o,g){this.#E(!0),this.#j();const d=this.#n.createElement("div");d.className=`${l}__failure`;const h=this.#n.createElement("p");h.className=`${l}__note ${l}__note--error`,h.setAttribute("role","alert"),h.textContent=this.#y("form.createFailed");const a=this.#n.createElement("button");a.className=`${l}__retry`,a.type="button",a.textContent=this.#y("form.retry"),a.addEventListener("click",()=>this.save()),d.appendChild(h),d.appendChild(a),L(this.#s.insertBefore)?this.#s.insertBefore(d,this.#s.firstChild):this.#s.appendChild(d),this.#c=d,this.#e.emit("form:error",{key:null,error:u,timedOut:g,created:!0})}#j(){const u=this.#c;this.#c=null,u&&u.parentNode&&u.parentNode.removeChild(u)}#P(){if(this.#i)return this.#i;const u=this.#t.viewport?.overlays,o=this.#n||u?.ownerDocument;if(!o?.createElement)return null;const g=n(this.#o.container,o),d=g||u;if(!d)return null;this.#o.container&&!g&&B("rowform:container","rowForm.container could not be resolved; the form opens over the grid instead."),this.#m=!!g;const h=o.createElement("div"),a=this.#m?"lattice ":"";h.className=`${a}${l} ${l}--${this.#m?"inline":this.#o.mode}`,h.setAttribute("role",this.#m?"region":"dialog"),this.#m||h.setAttribute("aria-modal","true"),h.setAttribute("tabindex","-1"),this.#o.width&&h.style.setProperty("--lattice-rowform-width",this.#o.width);const p=`${l}-title`;h.setAttribute("aria-labelledby",p);const w=o.createElement("div");w.className=`${l}__head`;const k=o.createElement("h2");k.className=`${l}__title`,k.id=p,w.appendChild(k);const m=o.createElement("div");m.className=`${l}__body`;const b=o.createElement("div");b.className=`${l}__foot`;const C=o.createElement("button");C.className=`${l}__cancel`,C.type="button",C.textContent=this.#y("form.cancel");const M=o.createElement("button");return M.className=`${l}__save`,M.type="button",M.textContent=this.#y("form.save"),b.appendChild(C),b.appendChild(M),h.appendChild(w),h.appendChild(m),h.appendChild(b),d.appendChild(h),this.#i=h,this.#s=m,this.#l=M,this.#S(h,M,C),h}#S(u,o,g){const d=p=>{if(p.stopPropagation(),p.key==="Escape"){p.preventDefault(),this.close();return}if(p.key!=="Tab"||this.#m)return;const w=[...u.querySelectorAll(c)];if(!w.length){p.preventDefault();return}const k=w[0],m=w[w.length-1],b=u.ownerDocument.activeElement;p.shiftKey&&(b===k||b===u)?(p.preventDefault(),m.focus()):!p.shiftKey&&b===m&&(p.preventDefault(),k.focus())},h=p=>{p.preventDefault?.(),this.save()},a=p=>{p.preventDefault?.(),this.close()};u.addEventListener("keydown",d),o.addEventListener("click",h),g.addEventListener("click",a),this.#g.push(()=>{u.removeEventListener("keydown",d),o.removeEventListener("click",h),g.removeEventListener("click",a)})}#M(u){const o=this.#i.querySelector(`.${l}__title`);if(!o)return;const g=this.#o.title;L(g)?o.textContent=String(g({row:u,data:u.data})??""):typeof g=="string"?o.textContent=g:o.textContent=this.#y("form.title")}#A(u,o){this.#R();const g=this.#o.timeout;if(!g)return;const d=this.#n.defaultView||globalThis;L(d.setTimeout)&&(this.#p=d.setTimeout(()=>{this.#p=null,!(u!==this.#h||!this.open)&&(this.#h+=1,o(g))},g))}#E(u){this.#l&&(this.#l.disabled=!u,u?this.#l.removeAttribute("aria-disabled"):this.#l.setAttribute("aria-disabled","true"))}#R(){if(this.#p===null)return;const u=this.#n.defaultView||globalThis;L(u.clearTimeout)&&u.clearTimeout(this.#p),this.#p=null}#L(){this.#he(),this.#E(!1),this.#s.replaceChildren&&this.#s.replaceChildren();const u=this.#n.createElement("p");u.className=`${l}__note`,u.setAttribute("role","status"),u.textContent=this.#y("form.loading"),this.#s.appendChild(u)}#x(u,o,g="form.loadFailed"){this.#he(),this.#E(!1),this.#s.replaceChildren&&this.#s.replaceChildren();const d=this.#n.createElement("p");d.className=`${l}__note ${l}__note--error`,d.setAttribute("role","alert"),d.textContent=this.#y(g);const h=this.#n.createElement("button");h.className=`${l}__retry`,h.type="button",h.textContent=this.#y("form.retry"),h.addEventListener("click",()=>this.openRow(o)),this.#s.appendChild(d),this.#s.appendChild(h),this.#e.emit("form:error",{key:o,error:u,timedOut:g==="form.loadTimeout"})}#I(){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}))}#z(u){this.#he(),this.#E(!0),this.#s.replaceChildren&&this.#s.replaceChildren();const o=u&&typeof u=="object"?u:{};for(const g of this.#I()){const d=g.field;if(!d)continue;const h=g.colId?this.#e.columns.get(g.colId):this.#ue(d),a=Object.hasOwn(o,d)?o[d]:null,p=this.#n.createElement("div");p.className=`${l}__field`;const w=this.#n.createElement("label");w.className=`${l}__label`,w.textContent=String(g.label??(h&&h.title)??d);const k=this.#n.createElement("div");k.className=`${l}__control`,p.appendChild(w),p.appendChild(k),this.#s.appendChild(p);const m={field:d,colId:h?h.id:null,editor:null,initial:a,opener:null,wrap:p,readOnly:!1},C=!!(h&&(h.computed||h.generated))?null:U({grid:this.#e,column:this.#le(g,h,d),colId:h?h.id:d,row:this.#a,data:o,value:a,text:a==null?"":String(a),locale:this.#e.get("locale"),props:g.props||h&&h.edit&&h.edit.props,lookup:g.lookup||h&&h.lookup,document:this.#n,cell:k,overlay:this.#H(),stop:()=>this.#ie(m)},this.#r);if(!C){m.readOnly=!0,m.colId=null,m.editor={commit:()=>({ok:!0,value:m.initial})},this.#$(k,h,a),this.#d.push(m);continue}m.editor=C;try{L(C.value)&&(m.initial=C.value())}catch{}if(this.#d.push(m),C.popup===!0)this.#B(k,m);else{const M=L(C.element)?C.element():null;M&&k.appendChild(M)}}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,o,g){const d=this.#n.createElement("div");d.className=`${l}__static`,d.setAttribute("aria-readonly","true");let h="";try{const a=o&&o.dataType&&o.dataType.format;L(a)&&(h=a({value:g,column:o,row:this.#a,data:this.#a?this.#a.data:null,locale:this.#e.get("locale")}))}catch{h=""}(h===""||h==null)&&(h=g==null?"":String(g)),d.textContent=h,u.appendChild(d)}#N(u){if(!this.#m)return;const o=this.#t.viewport?.root;if(!(!o||!L(o.getAttribute)))for(const g of["data-theme","data-density","dir"]){const d=g==="data-theme"?y(o):o.getAttribute(g);d?u.setAttribute(g,d):L(u.removeAttribute)&&u.removeAttribute(g)}}#H(){return this.#m?this.#n.body||this.#t.viewport.overlays:this.#t.viewport.overlays}#B(u,o){const g=this.#n.createElement("button");g.className=`${l}__opener`,g.type="button",o.opener=g,this.#re(o);const d=()=>{L(o.editor.attached)&&o.editor.attached()};g.addEventListener("click",d),this.#g.push(()=>g.removeEventListener("click",d)),u.appendChild(g)}#W(u,o){const g=u.wrap;g&&L(g.scrollIntoView)&&g.scrollIntoView({block:"nearest"});const d=u.opener||(L(u.editor.focusTarget)?u.editor.focusTarget():null);d&&L(d.focus)&&d.focus();const h=this.#t&&this.#t.announce;L(h)&&o&&h.call(this.#t,String(o))}#ie(u){if(!u.opener||!u.editor)return;const o=L(u.editor.popupHandle)?u.editor.popupHandle():null;o&&L(o.hide)&&o.hide(),this.#re(u),L(u.opener.focus)&&u.opener.focus()}#re(u){if(!u.opener)return;let o="";try{const d=u.colId?this.#e.columns.get(u.colId):null,h=d&&d.dataType&&d.dataType.format;L(h)&&(o=h({value:L(u.editor.value)?u.editor.value():null,column:d,row:this.#a,data:this.#a?this.#a.data:null,locale:this.#e.get("locale")})),(o===""||o==null)&&L(u.editor.toClipboard)&&(o=u.editor.toClipboard())}catch{o=""}const g=o===""||o==null;u.opener.textContent=g?this.#y("form.choose"):String(o),u.opener.classList.toggle(`${l}__opener--empty`,g)}#le(u,o,g){const d=u.editor||u.type||u.lookup||u.props,h={...o&&o.edit?o.edit:{},enabled:!0};return u.editor&&(h.editor=u.editor),u.props&&(h.props=u.props),o&&!d?{...o,edit:h}:{...o||{id:g,field:g},type:u.type||o&&o.type||"text",lookup:u.lookup||o&&o.lookup||void 0,edit:h}}#ue(u){for(const o of this.#e.columns.all())if(!o.generated&&o.field===u)return o;return null}#he(){for(const u of this.#d)L(u.editor.destroy)&&u.editor.destroy();this.#d=[]}destroy(){this.#h+=1,this.#R(),this.#he();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}}}),xe("packages/dom/src/toolpanelmount.js",function(e,K){"use strict";Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return E}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,F=K("packages/dom/src/ui/toolpanel.js"),W=F.ToolPanel,Q=F.toolPanels,G=F.toolPanelTitles,H=F.toolPanelIcons,U=K("packages/dom/src/filters/index.js"),D=U.createFilter,v=U.filterFor,y=K("packages/dom/src/filters/text.js").TextFilter,l=K("packages/dom/src/filters/engineset.js"),c=l.EngineSetFilter,i=l.VALUE_LIMIT,n=K("packages/dom/src/editors/common.js"),t=n.CLS,r=n.documentFor,s=n.scannableRows,f=n.el,u=K("packages/dom/src/filtermenu.js"),o=u.mergeColumnFilter,g=u.branchFor,d=u.valueSource,h=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(A,j,$){const z=f(A,"div",{class:`${t.panel}__filterRefusal`});return z.appendChild(f(A,"div",{class:`${t.filter}__note`,text:$,attrs:{role:"note","data-warning":"filter:values-unsupported"}})),z.appendChild(j.element()),{get:()=>j.get(),set:T=>j.set(T),active:()=>j.active(),...L(j.clear)?{clear:()=>j.clear()}:{},destroy:()=>j.destroy(),element:()=>z}}function w(A){const{grid:j,container:$}=A||{};if(!j)throw new Error("[lattice] mountPanel needs a grid");if(!$||!$.appendChild)throw new Error("[lattice] mountPanel needs a container element");const z=L(A.panel)?A.panel:Q[String(A.panel)];if(!z)throw new Error(`[lattice] unknown panel "${A.panel}"; known panels are ${Object.keys(Q).join(", ")}`);const T=$.ownerDocument||r($),R=x(j,T,A.announce),O=new z;O.init({document:T,host:R,grid:j,props:A.props||{}});const I=O.element();$.appendChild(I);const q=[];for(const Z of a)L(j.on)&&q.push(j.on(Z,()=>O.refresh()));return{element:I,refresh(){O.refresh()},destroy(){for(const Z of q)Z();q.length=0,L(O.destroy)&&O.destroy(),I&&I.parentNode&&I.parentNode.removeChild(I)}}}const k=260,m=30,b=`${t.panel}-dock`;function C(A,j,$){if(!A||!L(A.set))return;const z=g($.filters.get(),j)||null,T=L(A.get)&&(!L(A.active)||A.active())&&A.get()||null;JSON.stringify(T)!==JSON.stringify(z)&&(z?A.set(z):L(A.clear)?A.clear():A.set(null))}function M(A,j){if(A==="insights"){const T=j&&L(j.get)?j.get("insights"):null;return{other:(T&&typeof T=="object"?T:{}).compareWith||null}}if(A!=="views")return{};const $=j&&L(j.get)?j.get("views"):null,z=$&&typeof $=="object"?$:{};return{allowSave:z.allowSave!==!1,showDiff:z.showDiff===!0,builtinTitle:z.builtinTitle,savedTitle:z.savedTitle}}function P(A){const j=A.pagination&&L(A.pagination.get)?A.pagination.get():null;return j&&Number.isFinite(j.total)?j.total:A.rows.count()}function x(A,j,$){const z=new Map;return{announce(T,R){L($)&&$(T,R)},t(T,R){return A.messages.t(T,R)},grid:A,document:j,columns:()=>A.columns.all(),showColumns:T=>A.columns.show(T),hideColumns:T=>A.columns.hide(T),groupBy:()=>A.state.get().group||[],setGroupBy:T=>A.columns.group(T),pivotBy:()=>(A.state.get().pivot||{}).columns||[],setPivotBy:T=>A.columns.pivot(T),valueColumns:()=>A.columns.all().filter(T=>T.total).map(T=>T.id),setValueColumns:T=>A.columns.totals(T),valueAggregation(T){const R=A.columns.get(T);return!R||!R.total?"sum":typeof R.total=="string"?R.total:"custom"},setValueAggregation(T,R){A.columns.setTotal(T,R)},quickFilter:()=>A.state.get().quick||"",setQuickFilter:T=>A.filters.quick(T),rowCount:()=>P(A),totalRowCount:()=>L(A.rows.totalCount)?A.rows.totalCount():A.rows.count(),formattableColumns:()=>A.columns.visible().filter(T=>!T.generated).map(T=>({id:T.id,title:String(T.title??T.id)})),formattingRules:T=>A.formatting.list(T),columnSamples:T=>{let R=T;if(!R||R==="*"){const q=A.columns.visible().find(Z=>!Z.generated);R=q?q.id:null}if(!R)return[];const O=[],I=new Set;for(const q of s(A)){const Z=A.rows.value(q.key,R);if(Z==null||Z==="")continue;const _=typeof Z=="object"?O.length:Z;if(!I.has(_)&&(I.add(_),O.push(Z),O.length>=24))break}return O},profilableColumns:()=>A.columns.visible().filter(T=>!T.generated).map(T=>({id:T.id,title:String(T.title??T.id)})),columnProfile:T=>A.statistics.profile(T),reduceColumn:(T,R)=>A.statistics.reduce(T,R),columnCapability:T=>A.statistics.capability(T),regressionModel:T=>L(A.statistics.regressionModel)?A.statistics.regressionModel(T):null,insightsColumns:()=>A.columns.visible().filter(T=>!T.generated).map(T=>({id:T.id,title:String(T.title??T.id),type:T.type})),subsetVsPopulation:()=>A.statistics.subsetVsPopulation(),datasetVsDataset:T=>A.statistics.datasetVsDataset(T),compareGroups:(T,R)=>A.statistics.compareGroups(T,R),anomalies:T=>A.statistics.anomalies(T||{}),compareColumns:(T,R)=>{if(!T||!R||T===R)return null;const O=A.statistics.regression(T,R);return{n:O?O.n:0,pearson:A.statistics.correlation(T,R),spearman:A.statistics.spearman(T,R),kendall:A.statistics.kendall(T,R),covariance:A.statistics.covariance(T,R),slope:O?O.slope:null,intercept:O?O.intercept:null,r2:O?O.r2:null,stdError:O?O.stdError:null,weighted:A.statistics.weightedAverage(T,R)}},addRule:(T,R)=>A.formatting.add(T,R),removeRule:(T,R)=>A.formatting.remove(T,R),updateRule:(T,R,O)=>A.formatting.update(T,R,O),moveRule:(T,R,O)=>A.formatting.move(T,R,O),clearRules:T=>A.formatting.clear(T),views:()=>A.views.list(),activeId:()=>A.views.activeId,apply:T=>{A.views.apply(T)},saveAs:T=>A.views.save(T),rename:(T,R)=>A.views.rename(T,R),setDefault:T=>A.views.setDefault(T),clearDefault:()=>A.views.setDefault(null),remove:T=>A.views.remove(T),export:T=>A.views.export(T),diff:T=>A.views.diff(T),moveColumn(T,R,O){const I=A.columns.all().map(J=>J.id),q=I.indexOf(T),Z=I.indexOf(R);if(q<0||Z<0)return;let _=O?Z:Z+1;q<_&&(_-=1),_!==q&&A.columns.move(T,_)},isFiltered(T){return g(A.filters.get(),T)!==null},clearFilter(T){A.filters.set(o(A.filters.get(),T,null));const R=z.get(T);R&&L(R.clear)?R.clear():R&&L(R.set)&&R.set(null)},clearAllFilters(){A.filters.set(null);for(const T of z.values())L(T.clear)?T.clear():L(T.set)&&T.set(null)},filterFor(T){if(z.has(T))return C(z.get(T),T,A),z.get(T);const R=A.columns.get(T);if(!R)return null;const O=R.filter&&R.filter.props&&R.filter.props.values,I=d(A),q=I?A.config().context??null:null,Z=I?te=>I.columnValues(T,{...te||{},context:q}):null,_={grid:A,column:R,colId:T,type:R.type,locale:A.get("locale"),props:{...R.filter&&R.filter.props,values:O||(R.lookup?void 0:I?()=>Z({limit:i}).then(te=>te&&te.supported?te.values.map(ne=>ne.value):[]):()=>A.columns.distinct(T)),...I?{valueList:!1}:{}},lookup:R.lookup,document:j,value:te=>A.rows.value(te.row&&te.row.key,T),rows:I?()=>[]:R.lookup?void 0:()=>s(A),changed:()=>{const ne=(L(J.active)?J.active():!0)&&L(J.get)?J.get():null;A.filters.set(o(A.filters.get(),T,ne||null))},fetchValues:Z};let J=null;const ee=I&&!O&&!R.lookup?v(R):null;if(ee&&h(ee)){const te=I.columnValuesRefusal(T);if(te){const ne=new y;ne.init({..._,props:{..._.props,valueList:!1}}),J=p(j,ne,A.messages.t("filter.valuesUnsupported",{column:R.title||T})),B(`filter:values-unsupported:${T}`,`the filter on column "${T}" cannot list its values: ${te}. It offers the text condition editor instead.`)}else J=new c,J.init(_)}else J=D(_);return J&&(C(J,T,A),z.set(T,J)),J},destroyFilters(){for(const T of z.values())L(T.destroy)&&T.destroy();z.clear()}}}class E{#e;#t;#n;#r;#o;#i=null;#s=[];#l="right";#a=null;#u=!1;#c=!1;constructor(j){this.#e=j.grid,this.#t=j.document,this.#n=j.root,this.#o=x(j.grid,j.document,j.announce);const z=(j.panels||["columns","filters"]).map(T=>Q[T]?{name:T,title:G[T]?j.grid.messages.t(G[T]):T,icon:H[T]||T,Ctor:Q[T],props:M(T,j.grid)}:(B(`toolpanel:${T}`,`unknown tool panel "${T}"`),null)).filter(Boolean);this.#l=j.side==="left"?"left":"right",this.#r=new W,this.#r.init({document:j.document,host:this.#o,grid:j.grid,panels:z,actions:j.actions,icons:j.icons,side:this.#l,openPanel:j.openPanel})}mount(){const j=this.#t.createElement("div");j.className=`${b} ${b}--${this.#l}`,j.appendChild(this.#r.element()),this.#n.appendChild(j),this.#i=j;const $=this.#r.show.bind(this.#r),z=this.#r.hide.bind(this.#r);this.#r.show=T=>{const R=$(T);return this.#h(),R},this.#r.hide=()=>{z(),this.#h()};for(const T of[...a,"rows:paused","rows:resumed","rows:queued","annotation:changed"])this.#s.push(this.#e.on(T,()=>this.#r.refresh()));this.#s.push(this.#e.on("presentation:started",T=>{this.#u=!0;const R=T&&T.options&&Array.isArray(T.options.chrome)?T.options.chrome:[];this.#c=R.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",T=>{const R=T&&T.colId,O=this.#r.panels.find(I=>I.name==="statistics");O&&R!=null&&(O.panel.column=String(R)),this.open("statistics")})),this.#h()}open(j){this.#r.show(j),this.#h()}close(){this.#r.hide(),this.#h()}toggle(j){this.#r.toggle(j),this.#h()}addAction(j){if(!(!j||!j.name)&&!this.#r.actions.some($=>$.name===j.name)){if(this.#r.registerAction(j),this.#a&&!j.annotation){const $=this.#r.actions.find(z=>z.name===j.name);$&&this.#f($.button)}else!this.#a&&j.annotation&&this.#u&&!this.#c&&this.#d();this.#h()}}removeAction(j){this.#r.removeAction(j)&&this.#h()}presentOnly(){return this.#a?!0:this.#r.actions.some(j=>j.annotation&&j.button)?(this.#d(),!0):!1}#d(){const j=this.#r;this.#a={hidden:[],reopen:j.openPanel||null},this.#a.reopen&&j.hide(),this.#f(j.body);for(const $ of[...j.tabs?.children||[]])$!==j.actionGroup&&this.#f($);for(const $ of[...j.actionGroup?.children||[]]){const z=j.actions.find(T=>T.button===$);(!z||!z.annotation)&&this.#f($)}this.#i&&this.#i.style&&(this.#i.style.display=""),this.#h()}presentRestore(){const j=this.#a;if(!j)return!1;this.#a=null;for(const $ of j.hidden)$.el&&$.el.style&&($.el.style.display=$.display);return j.reopen&&this.#r.show(j.reopen),this.#h(),!0}#f(j){if(!j||!j.style||!this.#a)return;const $=j.style.display||"";$!=="none"&&(j.style.display="none",this.#a.hidden.push({el:j,display:$}))}#h(){if(!this.#i)return;const j=!!this.#r.openPanel;this.#i.setAttribute("data-open",j?"true":"false"),this.#i.style.width=j?`${k}px`:"";const $=`${j?k:this.#p()}px`;this.#n.style.paddingLeft=this.#l==="left"?$:"",this.#n.style.paddingRight=this.#l==="left"?"":$,this.#n.style.setProperty("--lattice-dock-left",this.#l==="left"?$:"0px"),this.#n.style.setProperty("--lattice-dock-right",this.#l==="left"?"0px":$)}#p(){const j=this.#r&&L(this.#r.element)?this.#r.element().querySelector?.(`.${t.panel}__tabs`):null,$=j&&(j.offsetWidth||j.getBoundingClientRect?.().width)||0;return $>0?Math.ceil($):m}destroy(){for(const j of this.#s)j();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=""}}}),xe("packages/dom/src/celledit.js",function(e,K){"use strict";Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return y}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,W=K("packages/dom/src/editors/index.js").createEditor,Q=K("packages/dom/src/editors/common.js"),G=Q.CLS,H=Q.markInvalid,U=Q.isEditable,v=K("packages/dom/src/detailhost.js").insideDetail,S=`${G.editor}-host`;class y{#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",g=>this.open(g))),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",f=g=>{if(v(g.target,t))return;const d=l(g.target,k=>k.getAttribute&&k.getAttribute("data-col"));if(!d)return;const h=l(d,k=>k.getAttribute&&k.getAttribute("data-key"));if(!h)return;const a=this.#e.rows.byKey(h.getAttribute("data-key"));if(!a||a.group)return;const p=d.getAttribute("data-col"),w=this.#e.columns.get(p);!w||!w.edit||!w.edit.enabled||this.#e.edit.start(a.key,p)},u=s==="key"?null:s==="single"?"click":"dblclick";u&&(t.addEventListener(u,f),this.#u.push(()=>t.removeEventListener(u,f)));const o=g=>{!this.#i||!this.#l||this.#p(g.target)||this.commit()};this.#t.addEventListener("mousedown",o,!0),this.#u.push(()=>this.#t.removeEventListener("mousedown",o,!0))}get target(){return this.#l}open(t){this.close();const r=t.key||t.row&&t.row.key,s=t.colId;if(!r||!s)return;const f=this.#e.columns.get(s),u=this.#e.rows.byKey(r);if(!f||!u||!U({column:f,edit:f.edit,row:u,value:this.#e.rows.value(r,s),grid:this.#e}))return;const o=this.#w(r,s);if(this.#c=o,!o){B("celledit.offscreen","cannot edit a row that is not rendered; scroll to it first.");return}const g=this.#e.permissions,d=!!(g&&L(g.isSecret)&&g.isSecret(s)),h=W({grid:this.#e,column:f,colId:s,row:u,data:u.data,value:d?null:this.#e.rows.value(r,s),text:d?"":this.#e.rows.text(r,s),locale:this.#e.get("locale"),props:f.edit&&f.edit.props,lookup:f.lookup,document:this.#t,cell:o,overlay:this.#n.viewport.overlays,onCommit:w=>this.#h({value:w,key:r,colId:s}),onCancel:()=>{this.#d=!0,this.#e.edit.stop(!0)},stop:w=>{this.#d||this.#e.edit.stop(w)}},this.#r);if(!h){B(`celledit.noeditor:${s}`,`column "${s}" has no editor.`);return}this.#i=h,this.#s=o,this.#l={key:r,colId:s},this.#d=!1,this.#a=this.#y(o);const a=h.element();h.popup?(this.#n.viewport.overlays.appendChild(a),c(a,o,this.#n.viewport.root)):o.replaceChildren(a),o.classList.add(S),L(h.attached)&&h.attached(),i(a);const p=w=>this.#f(w);a.addEventListener("keydown",p),this.#u.push(()=>a.removeEventListener("keydown",p))}#f(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)}#h(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(L(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(L(this.#i.value)){const s=this.#i.value();if(L(this.#i.validate)){const f=this.#i.validate(s);if(f!==!0){if(H(this.#c,f),L(this.#i.focusTarget)){const u=this.#i.focusTarget();u&&L(u.focus)&&u.focus()}return!1}H(this.#c,null)}this.#h({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=L(this.#i.element)?this.#i.element():null;if(r&&L(r.contains)&&r.contains(t))return!0;const s=this.#c;return!!(s&&L(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(f=>f.id===this.#l.colId);for(let f=s+t;f>=0&&f<r.length;f+=t){const u=r[f];if(u.edit&&u.edit.enabled)return{key:this.#l.key,colId:u.id}}return null}#y(t){const r=l(t,f=>f.getAttribute&&f.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 f of s.querySelectorAll(`[data-col="${r}"]`)){const u=l(f,o=>o.getAttribute&&o.getAttribute("data-key"));if(u&&u.getAttribute("data-key")===t)return f}return null}close(){this.#c&&H(this.#c,null);const t=this.#k();if(this.#i&&L(this.#i.destroy)&&this.#i.destroy(),this.#s){if(this.#s.classList.remove(S),this.#o&&L(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.#b(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}#k(){const t=this.#t.activeElement;if(!t||t===this.#t.body)return!1;const r=this.#i&&L(this.#i.element)?this.#i.element():null,s=f=>!!f&&L(f.contains)&&f.contains(t);return s(r)||s(this.#s)}#b(t){const s=L(t.hasAttribute)&&t.hasAttribute("tabindex")?t:this.#n.viewport.root;s&&L(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 c(n,t,r){if(!L(t.getBoundingClientRect))return;const s=t.getBoundingClientRect(),f=r.getBoundingClientRect();n.style.position="absolute",n.style.top=`${Math.round(s.top-f.top)}px`,n.style.minWidth=`${Math.round(s.width)}px`,n.style.left=`${Math.round(s.left-f.left)}px`;const u=n.offsetWidth||Math.round(s.width),o=Math.round(s.left-f.left)+u-Math.round(f.width);o>0&&(n.style.left=`${Math.max(0,Math.round(s.left-f.left)-o)}px`)}function i(n){const t=n.querySelector&&n.querySelector("input, select, textarea, [tabindex]")||n;L(t.focus)&&t.focus(),L(t.select)&&t.select()}}),xe("packages/dom/src/editbar.js",function(e,K){"use strict";Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return U}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,W=K("packages/dom/src/editors/index.js").createEditor,H=`${K("packages/dom/src/editors/common.js").CLS.editor}-bar`;class U{#e;#t;#n;#r=null;#o=null;#i=null;#s=null;#l=null;#a=null;#u=!1;#c=null;#d=[];constructor(v){this.#e=v.grid,this.#t=v.document,this.#n=v.root}mount(){const v=this.#t,S=v.createElement("div");S.className=H;const y=v.createElement("span");y.className=`${H}__ref`,y.textContent="";const l=v.createElement("div");l.className=`${H}__slot`;const c=v.createElement("span");c.className=`${H}__readonly`,S.appendChild(y),S.appendChild(l),this.#n.insertBefore(S,this.#n.firstChild),this.#r=S,this.#o=y,this.#i=l,this.#l=c;for(const i of["cell:clicked","cell:edit:start","selection:changed","model:changed","rows:changed"])this.#d.push(this.#e.on(i,n=>this.#h(n)))}bind(v,S){const y=this.#e.columns.get(S),l=v?this.#e.rows.byKey(v):null;this.#a=l&&y&&!l.group?{key:v,colId:S}:null,this.refresh()}refresh(){if(!this.#i||this.#u)return;if(this.#f(),!this.#a){this.#o.textContent="";return}const{key:v,colId:S}=this.#a,y=this.#e.columns.get(S);if(!y)return;if(this.#o.textContent=y.title||S,!!!(y.edit&&y.edit.enabled)){this.#l.textContent=this.#e.rows.text(v,S),this.#i.appendChild(this.#l);return}const c=this.#e.rows.byKey(v);if(!c)return;const i=W({grid:this.#e,column:y,colId:S,row:c,data:c.data,value:this.#e.rows.value(v,S),text:this.#e.rows.text(v,S),locale:this.#e.get("locale"),props:y.edit&&y.edit.props,lookup:y.lookup,document:this.#t,cell:this.#i,overlay:this.#n,stop:f=>f?this.cancel():this.commit(!0)});if(!i){B(`editbar.noeditor:${S}`,`column "${S}" has no editor.`),this.#l.textContent=this.#e.rows.text(v,S),this.#i.appendChild(this.#l);return}this.#s=i;const n=i.element();i.popup?(this.#l.textContent=this.#e.rows.text(v,S),this.#i.appendChild(this.#l)):this.#i.appendChild(n),L(i.attached)&&i.attached();const t=f=>this.#p(f),r=()=>{this.#u=!0},s=[n,this.#i];for(const f of s)f.addEventListener("keydown",t),f.addEventListener("input",r),f.addEventListener("change",r);this.#c=()=>{for(const f of s)f.removeEventListener("keydown",t),f.removeEventListener("input",r),f.removeEventListener("change",r)}}#f(){this.#c&&(this.#c(),this.#c=null),this.#s&&L(this.#s.destroy)&&this.#s.destroy(),this.#s=null,this.#i&&this.#i.replaceChildren&&this.#i.replaceChildren()}cancel(){this.#u=!1,this.refresh()}#h(v){if(v&&v.colId&&(v.key||v.row&&v.row.key)){this.bind(v.key||v.row.key,v.colId);return}this.refresh()}#p(v){if(v.key==="Enter"){v.preventDefault(),this.commit();return}v.key==="Escape"&&(v.preventDefault(),this.cancel())}commit(v){if(!this.#a||!this.#u&&!v)return!1;const{key:S,colId:y}=this.#a;if(!this.#s||!L(this.#s.value))return!1;const l=this.#s.value();return this.#u=!1,this.#e.edit.start(S,y),this.#e.edit.stop(!1,{value:l,key:S,colId:y}),this.refresh(),!0}destroy(){this.#f();for(const v of this.#d)v();this.#d=[],this.#r&&L(this.#r.remove)&&this.#r.remove(),this.#r=null,this.#i=null,this.#o=null,this.#a=null}}}),xe("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 D}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,W=K("packages/dom/src/editors/common.js"),Q=W.el,G=W.clear,H="lat-pastepreview",U='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class D{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=null;#a=null;#u=[];constructor(S){this.#e=S.grid,this.#t=S.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#c(S,y){const l=this.#e;return(l&&l.messages?l.messages:F).t(S,y)}#d(S){const y=`paste.preview.reason.${S}`,l=this.#c(y);return l===y?S:l}#f(S){return S==null||S===""?"":String(S)}#h(S,y){const l=this.#e.columns&&L(this.#e.columns.get)?this.#e.columns.get(y):null;return`${l&&(l.title||l.headerName)||y} · ${S}`}show(S,y){const l=this.#w();if(!l)return!1;this.#l=y&&y.onConfirm,this.#a=y&&y.onCancel||null;const c=S&&S.changes||[],i=S&&S.rejected||[],n=c.filter(r=>r.changed);this.#p(n,i);const t=l.ownerDocument;return this.#s=t&&t.activeElement,l.style.display="",L(l.focus)&&l.focus(),this.#b(this.#c("a11y.paste.previewOpened",{count:n.length,changes:n.length,rejected:i.length}),{repeat:!0}),!0}#p(S,y){const l=this.#r.ownerDocument;G(this.#r);const c=Q(l,"p",{class:`${H}__summary`,attrs:{role:"status"},text:this.#c("paste.preview.summary",{count:S.length,changes:S.length,rejected:y.length})});if(this.#r.appendChild(c),!S.length&&!y.length){this.#r.appendChild(Q(l,"p",{class:`${H}__empty`,text:this.#c("paste.preview.empty")})),this.#o.disabled=!S.length;return}this.#o.disabled=!S.length,S.length&&(this.#r.appendChild(Q(l,"h3",{class:`${H}__heading`,text:this.#c("paste.preview.changesHeading",{count:S.length})})),this.#r.appendChild(this.#m(l,S))),y.length&&(this.#r.appendChild(Q(l,"h3",{class:`${H}__heading ${H}__heading--rejected`,text:this.#c("paste.preview.rejectedHeading",{count:y.length})})),this.#r.appendChild(this.#g(l,y)))}#m(S,y){const l=Q(S,"tr",{children:[Q(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),Q(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colOld")}),Q(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colNew")})]}),c=y.map(i=>Q(S,"tr",{children:[Q(S,"th",{attrs:{scope:"row"},text:this.#h(i.key,i.colId)}),Q(S,"td",{class:`${H}__old`,text:this.#f(i.oldValue)}),Q(S,"td",{class:`${H}__new`,text:this.#f(i.newValue)})]}));return Q(S,"table",{class:`${H}__table`,children:[Q(S,"thead",{children:[l]}),Q(S,"tbody",{children:c})]})}#g(S,y){const l=Q(S,"tr",{children:[Q(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),Q(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colReason")})]}),c=y.map(i=>Q(S,"tr",{children:[Q(S,"th",{attrs:{scope:"row"},text:this.#h(i.key,i.colId)}),Q(S,"td",{class:`${H}__reason`,text:this.#d(i.reason)})]}));return Q(S,"table",{class:`${H}__table ${H}__table--rejected`,children:[Q(S,"thead",{children:[l]}),Q(S,"tbody",{children:c})]})}confirm(){const S=this.#l;this.#y(),L(S)&&S()}cancel(){const S=this.#a;this.#y(),this.#b(this.#c("a11y.paste.cancelled"),{repeat:!0}),L(S)&&S()}#y(){if(!this.#n)return;this.#n.style.display="none",this.#l=null,this.#a=null;const S=this.#s;this.#s=null,S&&L(S.focus)&&S.focus()}#w(){if(this.#n)return this.#n;const S=this.#t.viewport&&this.#t.viewport.overlays,y=S&&S.ownerDocument;if(!S||!y||!L(y.createElement))return null;const l=`${H}-title`,c=Q(y,"h2",{class:`${H}__title`,attrs:{id:l},text:this.#c("paste.preview.title")}),i=Q(y,"div",{class:`${H}__body`}),n=Q(y,"button",{class:`${H}__confirm`,attrs:{type:"button"},text:this.#c("paste.preview.confirm")}),t=Q(y,"button",{class:`${H}__cancel`,attrs:{type:"button"},text:this.#c("paste.preview.cancel")}),r=Q(y,"div",{class:`${H}__foot`,children:[t,n]}),s=Q(y,"div",{class:H,attrs:{role:"dialog","aria-modal":"true",tabindex:"-1","aria-labelledby":l},children:[Q(y,"div",{class:`${H}__head`,children:[c]}),i,r]});return S.appendChild(s),this.#n=s,this.#r=i,this.#o=n,this.#i=t,this.#k(s,n,t),s}#k(S,y,l){const c=t=>{if(t.stopPropagation(),t.key==="Escape"){t.preventDefault(),this.cancel();return}if(t.key!=="Tab")return;const r=[...S.querySelectorAll(U)].filter(o=>!o.disabled);if(!r.length){t.preventDefault();return}const s=r[0],f=r[r.length-1],u=S.ownerDocument.activeElement;t.shiftKey&&(u===s||u===S)?(t.preventDefault(),f.focus()):!t.shiftKey&&u===f&&(t.preventDefault(),s.focus())},i=t=>{t&&L(t.preventDefault)&&t.preventDefault(),this.confirm()},n=t=>{t&&L(t.preventDefault)&&t.preventDefault(),this.cancel()};S.addEventListener("keydown",c),y.addEventListener("click",i),l.addEventListener("click",n),this.#u.push(()=>{S.removeEventListener("keydown",c),y.removeEventListener("click",i),l.removeEventListener("click",n)})}#b(S,y){const l=this.#t&&this.#t.announce;L(l)&&l.call(this.#t,S,y)}destroy(){for(const S of this.#u)S();this.#u=[],this.#n&&this.#n.parentNode&&this.#n.parentNode.removeChild(this.#n),this.#n=null,this.#r=null,this.#o=null,this.#i=null,this.#s=null,this.#l=null,this.#a=null}}}),xe("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 f}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,W=K("packages/core/src/model/selection.js"),Q=W.extendSeries,G=W.resolveSelectionConfig,H=K("packages/dom/src/renderer/textentry.js"),U=H.isTextEntry,D=H.isFindBarControl,S=K("packages/dom/src/pastepreview.js").PastePreview,y=K("packages/dom/src/columnmenu.js"),l=y.chartableRange,c=y.rangeChartConfig,i="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(o){this.#e=o.grid,this.#t=o.renderer,this.#n=o.document,this.#a=o.preview||null}mount(){const o=this.#t.viewport.root,g=p=>this.#c(p),d=p=>this.#d(p),h=()=>this.#f(),a=p=>this.#h(p);o.addEventListener("pointerdown",g),this.#n.addEventListener("pointermove",d),this.#n.addEventListener("pointerup",h),o.addEventListener("keydown",a),this.#o.push(()=>{o.removeEventListener("pointerdown",g),this.#n.removeEventListener("pointermove",d),this.#n.removeEventListener("pointerup",h),o.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(o){if(o.button!==0)return;const g=o.target;if(!g||!L(g.closest))return;if(this.#r=!1,g.closest('[data-role="fill-handle"]')){if(this.#E())return;this.#i={mode:"fill",fromX:o.clientX,fromY:o.clientY,armed:!0};return}if(g.closest('[data-role="row-drag"]'))return;const d=this.#N(g);if(!d)return;if(o.shiftKey&&this.#e.selection.corner()){const a=this.#A(d);this.#e.selection.extendRange(a.rowIndex,a.colId),this.#i={mode:"select",fromX:o.clientX,fromY:o.clientY,armed:!0};return}const h=this.#M(d);this.#u=h,this.#e.selection.startRange(h.rowIndex,h.colId,{additive:o.ctrlKey||o.metaKey}),this.#i={mode:"select",fromX:o.clientX,fromY:o.clientY,armed:!1}}#d(o){const g=this.#i;if(!g)return;if(!g.armed){if(Math.abs(o.clientX-g.fromX)+Math.abs(o.clientY-g.fromY)<r)return;g.armed=!0}const d=this.#H(o.clientX,o.clientY);if(!d)return;if(g.mode==="fill"){this.#l=d,this.paint();return}const h=this.#A(d);this.#e.selection.extendRange(h.rowIndex,h.colId)}#f(){const o=this.#i;if(this.#i=null,!!o){if(o.mode==="fill"&&this.#l){const g=this.#l;this.#l=null,this.fillTo(g.rowIndex)}this.#l=null,this.paint()}}#h(o){if(this.#x()||D(o.target)||U(o.target))return;const g=o.ctrlKey||o.metaKey,d=o.key;if(g&&(d==="c"||d==="C")){this.copy(),o.preventDefault();return}if(g&&(d==="v"||d==="V")){this.paste(),o.preventDefault();return}if(g&&(d==="d"||d==="D")){this.fillDown(),o.preventDefault();return}if(d==="Delete"||d==="Backspace"){if(!this.#e.selection.cells().length&&this.#e.selection.keys().length&&this.#e.get("rowDelete")===!0){this.#e.edit.deleteRows(),o.preventDefault();return}this.clear(),o.preventDefault();return}if(o.altKey&&d==="F1"){this.chartSelection()&&o.preventDefault();return}if(!o.shiftKey)return;const h={ArrowDown:[1,0],ArrowUp:[-1,0],ArrowRight:[0,1],ArrowLeft:[0,-1]}[d];if(!h)return;if(g){const P=this.#$();if(!P)return;if(!this.#r){const $=this.#M(P);this.#u=$,this.#e.selection.startRange($.rowIndex,$.colId,{additive:!0}),this.#r=!0}const x=this.#e.columns.visible().map($=>$.id),E=x.indexOf(P.colId),A=this.#e.selection.corner()||{row:P.rowIndex,colId:P.colId},j=this.#A({rowIndex:Math.min(this.#e.rows.count()-1,Math.max(0,A.row+h[0])),colId:x[Math.min(x.length-1,Math.max(0,(E<0?0:E)+h[1]))]});this.#e.selection.extendRange(j.rowIndex,j.colId),o.preventDefault();return}this.#r=!1;const a=this.#e.selection.corner(),p=this.#$(),w=a||p;if(!w)return;if(!a&&p){const P=this.#M(p);this.#u=P,this.#e.selection.startRange(P.rowIndex,P.colId)}const k=this.#e.columns.visible().map(P=>P.id),m=k.indexOf(w.colId??w.colId),b=k[Math.min(k.length-1,Math.max(0,m+h[1]))],C=Math.min(this.#e.rows.count()-1,Math.max(0,(a?a.row:p.rowIndex)+h[0])),M=this.#A({rowIndex:C,colId:b});this.#e.selection.extendRange(M.rowIndex,M.colId),o.preventDefault()}async copy(){const o=this.#e.export.rangeText();if(!o)return this.#e.selection.ranges().length>1&&this.#e.emit("clipboard:copy",{text:"",ok:!1,rows:"range",reason:"discontiguous"},"user"),!1;const g=globalThis.navigator&&globalThis.navigator.clipboard;if(!g||!L(g.writeText))return!1;try{return await g.writeText(o),this.#e.emit("clipboard:copy",{text:o,ok:!0,rows:"range"},"user"),!0}catch{return this.#e.emit("clipboard:copy",{text:o,ok:!1,rows:"range"},"user"),!1}}async paste(){const o=globalThis.navigator&&globalThis.navigator.clipboard;if(!o||!L(o.readText))return 0;let g="";try{g=await o.readText()}catch{return 0}return this.pasteText(g)}pasteText(o){if(!o)return 0;const g=this.#e.selection.cells(),d=g.length?g[0]:this.#k();if(!d)return 0;const h=g.length>1?{rows:new Set(g.map(a=>a.key)).size,columns:new Set(g.map(a=>a.colId)).size}:void 0;if(this.#p()){const a=this.#e.edit.previewPaste(d,o,h);if(a.changes.length+a.rejected.length>1)return this.#m().show(a,{onConfirm:()=>this.#g(d,o,h)}),0}return this.#g(d,o,h)}#p(){const o=this.#e.edit;return!!(o&&o.pastePreview&&L(o.previewPaste))}#m(){return this.#a||(this.#a=new S({grid:this.#e,renderer:this.#t})),this.#a}#g(o,g,d){const h=this.#e.edit.pasteInto(o,g,d);return this.#w(h?this.#y("a11y.range.written",{count:h}):this.#y("a11y.range.refused"),{repeat:!0}),h}#y(o,g){const d=this.#e;return(d&&d.messages?d.messages:F).t(o,g)}#w(o,g){const d=this.#t&&this.#t.announce;L(d)&&d.call(this.#t,o,g)}#k(){const o=this.#$();if(!o)return null;const g=this.#e.rows.get(o.rowIndex);return g?{key:g.key,colId:o.colId}:null}clear(){const o=this.#e.selection.cells();return o.length?this.#e.edit.setCells(o.map(g=>({...g,value:null}))):0}fillDown(){if(this.#e.selection.ranges().length>1)return 0;const o=this.#e.selection.cells();if(o.length<2)return 0;const g=[...new Set(o.map(a=>a.key))];if(g.length<2)return 0;const d=g[0],h=[];for(const{key:a,colId:p}of o)a!==d&&h.push({key:a,colId:p,value:this.#e.rows.value(d,p)});return this.#e.edit.setCells(h)}chartSelection(){const o=c(this.#e);if(!o.handler)return!1;const g=l(this.#e);return g?(o.handler(this.#e,g),!0):!1}fillTo(o){if(this.#e.selection.ranges().length>1)return 0;const g=this.#e.selection.cells();if(!g.length)return 0;const d=[...new Set(g.map(b=>b.key))],h=[...new Set(g.map(b=>b.colId))],a=this.#z(d[d.length-1]);if(a<0||o<=a)return 0;const p=[];for(let b=a+1;b<=o;b++){const C=this.#e.rows.get(b);if(!C)break;p.push(C)}if(!p.length)return 0;const w=[];for(const b of h){const C=d.map(P=>this.#e.rows.value(P,b)),M=this.#b(C,p,b);for(let P=0;P<p.length;P++)w.push({key:p[P].key,colId:b,value:M[P]})}const k=this.#e.edit.setCells(w),m=this.#e.selection.corner();return m&&this.#e.selection.extendRange(o,m.colId),k}#b(o,g,d){const h=this.#e.get("selection"),a=h&&typeof h=="object"?h.fill:void 0;if(L(a)){const p=this.#e.columns.get(d),w=g.map(m=>({row:m,column:p})),k=a({source:o,target:w,direction:"down"});if(Array.isArray(k)&&k.length===g.length)return k}return Q(o,g.length)}paint(){const o=this.#t.viewport.root;if(!o||!o.querySelectorAll)return;const g=this.#e.selection,d=g.ranges().length>0,h=this.#l;for(const a of o.querySelectorAll("[data-col]")){const p=a.getAttribute("data-col"),w=a.parentNode,k=a.getAttribute?a.getAttribute("data-index"):null,m=k!==null&&k!==""?k:w&&w.getAttribute?w.getAttribute("data-index"):null;if(m===null||m==="")continue;const b=Number(m);if(!Number.isFinite(b)||b<0)continue;const C=d&&g.inRange(b,p),M=!!h&&this.#O(b,p,h);a.classList.toggle(i,C||M);const P=C||M?this.#j(b,p,g):null;a.classList.toggle(n,!!P&&P.any);for(const[x,E]of Object.entries(t))a.classList.toggle(E,!!P&&P[x])}this.#P()}#O(o,g,d){const h=this.#e.selection.cells();if(!h.length||!new Set(h.map(w=>w.colId)).has(g))return!1;const p=this.#z([...new Set(h.map(w=>w.key))].pop());return o>p&&o<=d.rowIndex}#j(o,g,d){const h=this.#e.columns.visible().map(m=>m.id),a=h.indexOf(g),p=a>0?h[a-1]:null,w=a>=0&&a<h.length-1?h[a+1]:null,k={top:!d.inRange(o-1,g),bottom:!d.inRange(o+1,g),left:!p||!d.inRange(o,p),right:!w||!d.inRange(o,w)};return k.any=k.top||k.bottom||k.left||k.right,k}#P(){const o=this.#e.selection.corner(),g=this.#t.viewport.overlays;if(!g)return;if(!o||this.#L()===!1||this.#e.selection.ranges().length>1||this.#E()){this.#s&&(this.#s.style.display="none");return}const d=this.#B(o.row,o.colId);if(!d||!L(d.getBoundingClientRect)){this.#s&&(this.#s.style.display="none");return}this.#s||(this.#s=this.#n.createElement("div"),this.#s.className="lat-fill-handle",this.#s.setAttribute("data-role","fill-handle"),this.#s.setAttribute("title",this.#y("a11y.fillHandle")),g.appendChild(this.#s));const h=d.getBoundingClientRect(),a=this.#t.viewport.root.getBoundingClientRect();this.#s.style.display="";const w=this.#t.viewport.rtl===!0?h.left:h.right;this.#s.style.left=`${Math.round(w-a.left)-4}px`,this.#s.style.top=`${Math.round(h.bottom-a.top)-4}px`}#S(o){const g=this.#t;return!o||typeof g.spanAt!="function"?null:g.spanAt(o.rowIndex,o.colId)}#M(o){const g=this.#S(o);return g?{rowIndex:g.row,colId:g.columnId}:o}#A(o){const g=this.#S(o);if(!g)return o;const d=this.#u,h=!!d&&d.rowIndex>=g.row+g.rows,a=this.#R(),p=d?a.indexOf(d.colId):-1,w=p>=0&&p>=g.col+g.cols;return{rowIndex:h?g.row:g.row+g.rows-1,colId:w?g.columnId:g.endColumnId}}#E(){const o=this.#e.selection.corner();if(!o)return!1;const g=this.#S({rowIndex:o.row,colId:o.colId});return!!g&&(g.rows>1||g.cols>1)}#R(){const o=this.#e.columns;return o&&L(o.visible)?o.visible().map(g=>g.id):[]}#L(){return G(this.#e.get("selection")).fillHandle}#x(){const o=this.#t.viewport.root;return!!(o&&o.querySelector&&o.querySelector(".lat-editor-host, .lat-editor--popup"))}#I(){const o=this.#e.selection.cells();return o.length?o[0]:null}#z(o){for(let g=0;g<this.#e.rows.count();g++){const d=this.#e.rows.get(g);if(d&&d.key===o)return g}return-1}#$(){const o=this.#t.viewport.root,g=o&&o.querySelector?o.querySelector('[data-col][tabindex="0"]'):null;return g?this.#N(g):null}#N(o){if(!o||!L(o.closest))return null;const g=o.closest("[data-col]");if(!g||!g.classList.contains("lat-cell"))return null;const d=g.closest("[data-index]");if(!d)return null;const h=Number(d.getAttribute("data-index"));return!Number.isFinite(h)||h<0?null:{rowIndex:h,colId:g.getAttribute("data-col")}}#H(o,g){const d=this.#n.elementFromPoint?this.#n.elementFromPoint(o,g):null;return d?this.#N(d):null}#B(o,g){const d=this.#t.viewport.root;if(!d||!d.querySelectorAll)return null;for(const h of d.querySelectorAll(`[data-col="${g}"]`)){const a=h.closest?h.closest("[data-index]"):null;if(a&&Number(a.getAttribute("data-index"))===o)return h}return null}destroy(){for(const o of this.#o)o();this.#o=[],this.#s&&L(this.#s.remove)&&this.#s.remove(),this.#s=null,this.#i=null,this.#l=null,this.#a&&L(this.#a.destroy)&&this.#a.destroy(),this.#a=null}}const f=s}),xe("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 L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,W=K("packages/core/src/import/index.js"),Q=W.parseDelimited,G=W.inferColumns,H=W.mapRecords,U=W.readXlsx,D=W.looksLikeXlsx,v=K("packages/dom/src/editors/common.js"),S=v.el,y=v.clear,l=v.on,i=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 o=u.settings&&typeof u.settings=="object"?u.settings:{};this.#r={file:o.file!==!1,drop:o.drop!==!1,paste:o.paste!==!1,mode:o.mode==="replace"?"replace":"append"},this.#u()}#u(){const u=this.#t&&this.#t.viewport?this.#t.viewport.root:null;u&&(this.#r.drop&&(this.#o.push(l(u,"dragover",o=>{o.dataTransfer&&[...o.dataTransfer.types||[]].includes("Files")&&(o.preventDefault(),u.classList.add("lat-import--dropzone"))})),this.#o.push(l(u,"dragleave",()=>u.classList.remove("lat-import--dropzone"))),this.#o.push(l(u,"drop",o=>{u.classList.remove("lat-import--dropzone");const g=o.dataTransfer&&o.dataTransfer.files&&o.dataTransfer.files[0];g&&(o.preventDefault(),this.#c(g))}))),this.#r.paste&&this.#o.push(l(u,"paste",o=>{if(i(o.target)||this.#e.edit.isEditing?.()||this.#e.selection&&this.#e.selection.cells().length)return;const g=o.clipboardData&&o.clipboardData.getData("text/plain");!g||!g.includes(`
|
|
57
57
|
`)||(o.preventDefault(),this.fromText(g))})))}openFile(){const u=S(this.#n,"input",{attrs:{type:"file",accept:r}});u.style.display="none",this.#o.push(l(u,"change",()=>{const o=u.files&&u.files[0];o&&this.#c(o),u.parentNode&&u.parentNode.removeChild(u)})),this.#n.body.appendChild(u),u.click()}#c(u){if(L(u.arrayBuffer)){u.arrayBuffer().then(g=>{const d=new Uint8Array(g);if(D(d)){this.fromXlsx(d,u.name);return}this.fromText(new TextDecoder().decode(d),u.name)});return}if(L(u.text)){u.text().then(g=>this.fromText(g,u.name));return}const o=new this.#n.defaultView.FileReader;o.onload=()=>this.fromText(String(o.result||""),u.name),o.readAsText(u)}async fromXlsx(u,o){const{header:g,rows:d}=await U(u);if(!g.length)return;const h=G(g,d,{columns:this.#e.columns.all()}),a=d.filter(p=>p.length!==g.length).length;this.#l={rows:d,columns:h,delimiter:null,name:o,warnings:a?[`${a} row(s) do not have ${g.length} columns`]:[]},this.#d()}fromText(u,o){const{header:g,rows:d,delimiter:h}=Q(u);if(!g.length)return;const a=G(g,d,{columns:this.#e.columns.all()}),p=d.filter(w=>w.length!==g.length).length;this.#l={rows:d,columns:a,delimiter:h,name:o,warnings:p?[`${p} row(s) do not have ${g.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&&L(u.focus)&&u.focus(),this.#f(this.#h("import.opened",{count:this.#l.rows.length}),{repeat:!0})}#f(u,o){const g=this.#t&&this.#t.announce;L(g)&&g.call(this.#t,u,o)}#h(u,o){return(this.#e&&this.#e.messages?this.#e.messages:F).t(u,o)}#p(){const u=this.#n,o=S(u,"div",{class:n,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#h("import.title"),hidden:!0}}),g=S(u,"div",{class:`${n}__panel`});g.appendChild(S(u,"h2",{class:`${n}__title`,text:this.#h("import.title")})),this.#s=S(u,"div",{class:`${n}__body`}),g.appendChild(this.#s);const d=S(u,"div",{class:`${n}__footer`}),h=S(u,"button",{class:`${n}__cancel`,text:this.#h("import.cancel"),attrs:{type:"button"}}),a=S(u,"button",{class:`${n}__confirm`,text:this.#h("import.confirm"),attrs:{type:"button"}});this.#o.push(l(h,"click",()=>this.close())),this.#o.push(l(a,"click",()=>this.#g())),d.appendChild(h),d.appendChild(a),g.appendChild(d),o.appendChild(g),this.#o.push(l(o,"keydown",w=>{if(w.key==="Escape"){w.preventDefault(),this.close();return}if(w.key!=="Tab")return;const k=[...o.querySelectorAll(t)].filter(C=>!C.hidden);if(!k.length)return;const m=k[0],b=k[k.length-1];w.shiftKey&&this.#n.activeElement===m?(w.preventDefault(),b.focus()):!w.shiftKey&&this.#n.activeElement===b&&(w.preventDefault(),m.focus())})),(this.#t.viewport&&this.#t.viewport.overlays||this.#n.body).appendChild(o),this.#i=o}#m(){const u=this.#n,o=y(this.#s),{rows:g,columns:d,name:h,warnings:a}=this.#l;o.appendChild(S(u,"p",{class:`${n}__summary`,text:this.#h("import.summary",{count:g.length,name:h||this.#h("import.clipboard")})}));for(const C of a)o.appendChild(S(u,"p",{class:`${n}__warning`,text:C}));const p=this.#e.columns.all().map(C=>C.field||C.id).filter(Boolean),w=S(u,"table",{class:`${n}__map`}),k=S(u,"tr",{});for(const C of["import.colSource","import.colField","import.colType"])k.appendChild(S(u,"th",{text:this.#h(C)}));w.appendChild(k),d.forEach((C,M)=>{const P=S(u,"tr",{});P.appendChild(S(u,"td",{text:C.source}));const x=S(u,"select",{attrs:{"data-col":String(M),"aria-label":this.#h("import.mapLabel",{source:C.source})}});x.appendChild(S(u,"option",{text:this.#h("import.skip"),attrs:{value:""}}));for(const A of p)x.appendChild(S(u,"option",{text:A,attrs:{value:A,selected:A===C.field?!0:null}}));C.field&&!p.includes(C.field)&&x.appendChild(S(u,"option",{text:C.field,attrs:{value:C.field,selected:!0}}));const E=S(u,"td",{});E.appendChild(x),P.appendChild(E),P.appendChild(S(u,"td",{class:`${n}__type`,text:C.type})),w.appendChild(P)}),o.appendChild(w);const m=S(u,"div",{class:`${n}__mode`}),b=S(u,"select",{attrs:{"aria-label":this.#h("import.modeLabel"),"data-mode":"mode"}});b.appendChild(S(u,"option",{text:this.#h("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),b.appendChild(S(u,"option",{text:this.#h("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),m.appendChild(S(u,"label",{text:this.#h("import.modeLabel")})),m.appendChild(b),o.appendChild(m)}#g(){const{rows:u,columns:o}=this.#l;for(const p of this.#i.querySelectorAll("select[data-col]")){const w=Number(p.getAttribute("data-col"));o[w]&&p.value!==void 0&&p.value!==null&&(o[w].field=p.value)}const g=this.#i.querySelector("select[data-mode]"),d=g?g.value:void 0,h=d==="replace"||d==="append"?d:this.#r.mode,a=H(u,o);this.#e.import.apply(a,{mode:h}),this.close(),this.#f(this.#h("import.done",{count:a.length}),{repeat:!0})}close(){this.#i&&(this.#i.hidden=!0),this.#l=null,this.#a&&L(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}}}),xe("packages/dom/src/historybar.js",function(e,K){"use strict";Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,W=K("packages/dom/src/editors/common.js"),Q=W.el,G=W.on,H=W.clear,U=W.documentFor,D="lat-history";class v{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(l,c){return(this.messages&&typeof this.messages.t=="function"?this.messages:F).t(l,c)}init(l){this.messages=l&&l.messages||l&&l.grid&&l.grid.messages||F;const c=l||{};if(this.doc=U(c),this.host=c.host||{},this.props=c.props||{},this.root=Q(this.doc,"div",{class:["lattice-tokens",D],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 i=Q(this.doc,"button",{class:`${D}__toggle`,text:"▾",attrs:{type:"button","aria-haspopup":"menu","aria-expanded":"false","aria-label":this.t("history.show")}});this.off.push(G(i,"click",()=>this.toggle())),this.root.appendChild(i),this.toggleButton=i,this.menu=Q(this.doc,"div",{class:`${D}__menu`,attrs:{role:"menu"}}),this.menu.style.display="none",this.root.appendChild(this.menu)}this.refresh()}#e(l,c,i){const n=Q(this.doc,"button",{class:`${D}__${l}`,attrs:{type:"button"},children:[Q(this.doc,"span",{class:`${D}__glyph`,text:i,attrs:{"aria-hidden":"true"}}),Q(this.doc,"span",{class:`${D}__label`,text:c})]});return this.off.push(G(n,"click",()=>{const t=this.host[l];L(t)&&t(),this.refresh()})),n}element(){return this.root}refresh(){if(!this.root)return;const l=this.host,c=L(l.canUndo)?l.canUndo():!1,i=L(l.canRedo)?l.canRedo():!1,n=L(l.peek)?l.peek("undo"):null,t=L(l.peek)?l.peek("redo"):null;this.#t(this.undoButton,"undo",c,n),this.#t(this.redoButton,"redo",i,t),this.open&&this.#n()}#t(l,c,i,n){if(!l)return;l.disabled=!i;const t=c==="undo",r=this.t(t?"history.undo":"history.redo"),s=l.querySelector(`.${D}__label`);s&&(s.textContent=r);const f=n&&n.label?this.t("history.described",{action:r,label:n.label}):r;l.setAttribute("title",i?f:this.t(t?"history.nothingToUndo":"history.nothingToRedo")),l.setAttribute("aria-label",i?f:this.t(t?"history.undoDisabled":"history.redoDisabled"))}toggle(){this.menu&&(this.open=!this.open,this.menu.style.display=this.open?"":"none",this.toggleButton&&this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open&&this.#n())}#n(){const l=this.menu;if(!l)return;H(l);const c=L(this.host.list)?this.host.list():[];if(!c.length){l.appendChild(Q(this.doc,"p",{class:`${D}__empty`,text:this.t("history.empty")}));return}c.forEach((i,n)=>{const t=Q(this.doc,"button",{class:`${D}__item`,attrs:{type:"button",role:"menuitem","data-type":i.type,"data-undone":i.undone?"true":null},children:[Q(this.doc,"span",{class:`${D}__kind`,text:i.type}),Q(this.doc,"span",{class:`${D}__text`,text:i.label||i.type})]});this.off.push(G(t,"click",()=>{const r=n+1;for(let s=0;s<r;s++)L(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&&L(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const S=v}),xe("packages/dom/src/diffpaint.js",function(e,K){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"diffConfigured",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,W=K("packages/core/src/i18n/index.js").defaultMessages,Q={changed:"lat-row--changed",added:"lat-row--added",removed:"lat-row--removed"},G="lat-cell--changed",H="lat-cell--added-column";class U{#e;#t;#n=[];constructor(y){this.#e=y.grid,this.#t=y.renderer}mount(){for(const y of["render:done","diff:changed","rows:changed","model:changed","cell:changed","scroll"])this.#n.push(this.#e.on(y,()=>this.paint()));this.paint()}paint(){const y=this.#t.viewport.root;if(!y||!y.querySelectorAll)return;const l=this.#e.diff,c=l&&l.enabled;for(const i of y.querySelectorAll("[data-key]")){const n=i.getAttribute("data-key"),t=c?l.statusOf(n):"unchanged";for(const s of Object.values(Q))i.classList.remove(s);c&&Q[t]&&i.classList.add(Q[t]),i.setAttribute("data-diff",c?t:"");const r=c&&t==="changed";for(const s of i.querySelectorAll("[data-col]")){const f=s.getAttribute("data-col");if(s.classList.remove(G,H),s.removeAttribute("data-before"),!r)continue;const u=l.cellStatus(n,f);if(u==="changed"){s.classList.add(G);const o=this.#r(l,n,f);o===null?s.removeAttribute("title"):(s.setAttribute("data-before",o),s.setAttribute("title",this.#o("diff.before",{value:o})))}else u==="added-column"&&s.classList.add(H)}}}#r(y,l,c){const i=this.#e,n=i&&i.columns,t=n&&L(n.get)?n.get(c):null,r=i&&i.permissions;if(t&&r&&L(r.isSecret)&&r.isSecret(t))return null;const s=y.before(l,c);if(s==null)return this.#o("diff.empty");if(!t||!L(t.formatValue))return String(s);const f=L(y.beforeRow)?y.beforeRow(l):void 0,o={...(i.rows&&L(i.rows.byKey)?i.rows.byKey(l):null)||{},data:f===void 0?{}:f};try{const g=t.formatValue(s,o,o.data);return g==null?"":String(g)}catch(g){return B(`diff-before-format:${c}`,`the formatter for column "${c}" threw while formatting a previous value, so the diff hover shows the raw one.`,g),String(s)}}#o(y,l){const c=this.#e;return(c&&c.messages?c.messages:W).t(y,l)}destroy(){for(const l of this.#n)l();this.#n=[];const y=this.#t.viewport.root;if(!(!y||!y.querySelectorAll)){for(const l of y.querySelectorAll("[data-key]")){for(const c of Object.values(Q))l.classList.remove(c);l.removeAttribute("data-diff")}for(const l of y.querySelectorAll("[data-col]"))l.classList.remove(G,H),l.removeAttribute("data-before")}}}function D(S){return!!(S&&S.diff&&(L(S.diff)||typeof S.diff=="object"))}const v=U}),xe("packages/dom/src/highlightpaint.js",function(e,K){"use strict";Object.defineProperty(e,"HighlightPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Q}});const L=K("packages/core/src/internal/util.js").isFunction,B="lat-cell--highlight",F="--lattice-cell-highlight";class W{#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()};L(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(H):L(this.#i.setTimeout)?this.#i.setTimeout(H,0):H()}paint(){const H=this.#t.viewport?.root;if(!H||!H.querySelectorAll)return;const U=this.#l();if(U){U.sweep();for(const D of H.querySelectorAll("[data-key]")){const v=D.getAttribute("data-key");for(const S of D.querySelectorAll("[data-col]")){const y=U.active?U.colourFor(v,S.getAttribute("data-col")):null;y?(S.classList.add(B),S.style.setProperty(F,y)):S.classList.contains(B)&&(S.classList.remove(B),S.style.removeProperty(F))}}this.#s(U)}}#s(H){this.#r!==null&&L(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const U=H.nextExpiry;if(!Number.isFinite(U)||!L(this.#i.setTimeout))return;const D=Math.max(0,U-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},D)}#l(){const H=this.#e.highlight;return H&&L(H.model)?H.model():null}destroy(){this.#r!==null&&L(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const U of this.#n)U();this.#n=[];const H=this.#t.viewport?.root;if(!(!H||!H.querySelectorAll))for(const U of H.querySelectorAll(`.${B}`))U.classList.remove(B),U.style.removeProperty(F)}}const Q=W}),xe("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 F}}),Object.defineProperty(e,"FindPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Q}});const L=K("packages/core/src/internal/util.js").isFunction,B="lat-cell--find",F="lat-cell--find-current";class W{#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()};L(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(H):L(this.#i.setTimeout)?this.#i.setTimeout(H,0):H()}paint(){const H=this.#t.viewport?.root;if(!H||!H.querySelectorAll)return;const U=this.#e.find;if(!U||!L(U.stateFor))return;const D=L(U.model)?U.model():null,v=!!D&&D.active;if(!v&&!this.#o)return;let S=!1;for(const y of H.querySelectorAll("[data-key]")){const l=y.getAttribute("data-key");for(const c of y.querySelectorAll("[data-col]")){const i=v?U.stateFor(l,c.getAttribute("data-col")):null;i?(S=!0,c.classList.add(B),c.classList.toggle(F,i==="current")):c.classList.contains(B)&&c.classList.remove(B,F)}}this.#o=S}destroy(){for(const U of this.#n)U();this.#n=[];const H=this.#t.viewport?.root;if(!(!H||!H.querySelectorAll)){for(const U of H.querySelectorAll(`.${B}`))U.classList.remove(B,F);this.#o=!1}}}const Q=W}),xe("packages/dom/src/findbar.js",function(e,K){"use strict";Object.defineProperty(e,"FIND_CLASS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"FindBar",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const X=K("packages/dom/src/editors/common.js"),L=X.el,B=X.on,W=K("packages/dom/src/renderer/textentry.js").isTextEntry,G=K("packages/core/src/i18n/index.js").defaultMessages,U=K("packages/core/src/internal/util.js").isFunction,D="lat-find",v=12,S=120;class y{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#f=null;#h=!1;#p=!1;#m=null;#g=[];#y=null;#w=null;#k=!1;constructor(i){this.#e=i.grid,this.#t=i.renderer,this.#n=i.document||i.renderer.viewport?.document,this.#r=this.#n&&this.#n.defaultView||(typeof globalThis>"u"?{}:globalThis),this.#o=i.settings&&typeof i.settings=="object"?i.settings:{}}get open(){return!!this.#i&&this.#i.style.display!=="none"}get element(){return this.#i}t(i,n){const t=this.#e;return(t&&t.messages&&U(t.messages.t)?t.messages:G).t(i,n)}mount(){const i=this.#O();if(!i)return;i.attachUi({open:t=>this.show(t),close:()=>this.hide(),focus:()=>{this.#s&&this.#s.focus()}}),i.attachDriver({run:()=>this.#E()});const n=this.#t.viewport?.root;if(n&&U(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(),U(this.#s.select)&&this.#s.select();return}W(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.#P())),this.#g.push(this.#e.on("column:visible",()=>this.#P()))}show(i){const n=this.#j();if(!n)return;const t=n.style.display!=="none";n.style.display="",t||this.#b(),this.#O().setOpen(!0),i!=null&&(this.#s.value=String(i),this.#M()),this.#s.focus(),U(this.#s.select)&&this.#s.select(),this.#L()}hide(){this.#z();const i=this.#O();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#b()),i&&(i.clear(),i.setOpen(!1));const n=this.#t.viewport?.root;if(!n||!(this.#i&&this.#n&&this.#n.activeElement&&U(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const s=(U(n.querySelector)?n.querySelector('[tabindex="0"]'):null)||n;U(s.focus)&&s.focus()}search(){this.#M()}destroy(){this.#k=!0,this.#z();for(const n of this.#g)n();this.#g=[];const i=this.#O();i&&(i.attachUi(null),i.attachDriver(null)),this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null}#b(){const i=this.#t;i&&U(i.invalidate)&&i.invalidate("size")}#O(){const i=this.#e&&this.#e.find;return i&&U(i.model)?i.model():null}#j(){if(this.#i)return this.#i;const i=this.#t.viewport,n=i?.root,t=this.#n;if(!n||!t||!U(n.insertBefore))return null;const r=L(t,"div",{class:D,attrs:{role:"search","aria-label":this.t("find.label")}});this.#s=L(t,"input",{class:`${D}__input`,attrs:{type:"text","aria-label":this.t("find.label"),placeholder:this.t("find.placeholder"),autocomplete:"off",spellcheck:"false"}}),this.#l=L(t,"span",{class:`${D}__count`,attrs:{"aria-hidden":"true"}}),this.#a=L(t,"span",{class:`${D}__scope`,attrs:{"aria-hidden":"true"}}),this.#a.style.display="none",this.#u=L(t,"span",{class:`${D}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const s=L(t,"button",{class:`${D}__nav ${D}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),f=L(t,"button",{class:`${D}__nav ${D}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=L(t,"button",{class:`${D}__toggle ${D}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=L(t,"button",{class:`${D}__toggle ${D}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#f=L(t,"select",{class:`${D}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const u=L(t,"button",{class:`${D}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),o=L(t,"div",{class:`${D}__options`,children:[this.#c,this.#d,this.#f]});for(const d of[this.#s,this.#l,this.#a,this.#u,s,f,u,o])r.appendChild(d);this.#g.push(B(this.#s,"input",()=>this.#S())),this.#g.push(B(s,"click",()=>this.#e.find.prev())),this.#g.push(B(f,"click",()=>this.#e.find.next())),this.#g.push(B(this.#c,"click",()=>{this.#h=!this.#h,this.#c.setAttribute("aria-pressed",String(this.#h)),this.#M()})),this.#g.push(B(this.#d,"click",()=>{this.#p=!this.#p,this.#d.setAttribute("aria-pressed",String(this.#p)),this.#M()})),this.#g.push(B(this.#f,"change",()=>{const d=this.#f.value;this.#m=d?String(d):null,this.#M()})),this.#g.push(B(u,"click",()=>this.hide()));const g=d=>{if(d.key==="Escape"){d.preventDefault(),d.stopPropagation(),this.hide();return}d.key==="Enter"&&d.target===this.#s&&(d.preventDefault(),d.stopPropagation(),this.#y!==null&&(this.#x(),this.#M()),d.shiftKey?this.#e.find.prev():this.#e.find.next())};return r.addEventListener("keydown",g),this.#g.push(()=>r.removeEventListener("keydown",g)),r.style.display="none",n.insertBefore(r,i.header||n.firstChild),this.#i=r,this.#P(),r}#P(){const i=this.#f;if(!i)return;const n=this.#n;for(;i.firstChild;)i.removeChild(i.firstChild);i.appendChild(L(n,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const t=this.#e.columns,r=t&&U(t.visible)?t.visible():[];let s=!1;for(const f of r){if(!f||f.id===void 0)continue;const u=String(f.id);i.appendChild(L(n,"option",{text:f.title||u,attrs:{value:u}})),u===this.#m&&(s=!0)}s||(this.#m=null),i.value=this.#m||""}#S(){const i=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):S;if(this.#x(),i===0||!U(this.#r.setTimeout)){this.#M();return}this.#y=this.#r.setTimeout(()=>{this.#y=null,this.#M()},i)}#M(){const i=this.#O();if(!i||this.#k)return;const n=this.#s?this.#s.value:"";if(!n){this.#I(),i.clear();return}i.begin(n,{caseSensitive:this.#h,wholeCell:this.#p,columns:this.#m?[this.#m]:null,from:this.#A()}),this.#E()}#A(){const i=this.#t&&this.#t.window,n=i&&Number.isFinite(i.first)?i.first:0;return Math.max(0,n)}#E(){if(this.#w!==null||this.#k)return;const i=()=>{this.#w=null,this.#R()};U(this.#r.requestAnimationFrame)?this.#w=this.#r.requestAnimationFrame(i):U(this.#r.setTimeout)?this.#w=this.#r.setTimeout(i,0):i()}#R(){const i=this.#O();!i||this.#k||!i.active||(i.stale&&i.rescan({from:this.#A()}),!i.complete&&(i.step(v)||this.#E()))}#L(){if(!this.#i||this.#k)return;const i=this.#e.find.count(),n=this.#O().active;let t="",r="idle";n&&(i.total===0?(t=i.complete?this.t("find.none"):this.t("find.searching"),r=i.complete?"none":"searching"):(t=this.t(i.complete?"find.count":"find.countPartial",{current:i.current,total:i.total}),r=i.complete?"matches":"searching")),this.#l.textContent=t,this.#i.setAttribute("data-state",r);const s=n&&i.windowed;this.#a.textContent=s?this.t("find.loadedRows"):"",this.#a.style.display=s?"":"none",n?i.complete&&(this.#u.textContent=i.total===0?this.t(s?"a11y.find.noneLoaded":"a11y.find.none"):this.t(s?"a11y.find.countLoaded":"a11y.find.count",{current:i.current,count:i.total})):this.#u.textContent=""}#x(){this.#y!==null&&U(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#y),this.#y=null}#I(){this.#w!==null&&(U(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#w):U(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#w),this.#w=null)}#z(){this.#x(),this.#I()}}const l=y}),xe("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 F}});const X="lat-cell--redacted",L="lat-cell";class B{#e;#t;#n=[];constructor(Q){this.#e=Q.grid,this.#t=Q.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.paint()}paint(){const Q=this.#t.viewport?.root;if(!Q||!Q.querySelectorAll)return;const G=this.#e.redaction;if(!G)return;const H=G.active;for(const U of Q.querySelectorAll(`.${L}[data-col]`))H&&G.has(U.getAttribute("data-col"))?U.classList.add(X):U.classList.contains(X)&&U.classList.remove(X)}destroy(){for(const Q of this.#n)Q();this.#n=[]}}const F=B}),xe("packages/dom/src/validationpaint.js",function(e,K){"use strict";Object.defineProperty(e,"ValidationPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Q}});const L=K("packages/dom/src/editors/common.js").markInvalid,B="lat-cell";function F(G,H){let U=G;for(;U;){if(H(U))return U;U=U.parentNode}return null}class W{#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 U=F(H,D=>D.getAttribute&&D.getAttribute("data-key")!==null);return U?U.getAttribute("data-key"):null}paint(){const H=this.#e.validation;if(!H||!H.active)return;const U=this.#t.viewport?.root;if(!(!U||!U.querySelectorAll))for(const D of U.querySelectorAll(`.${B}[data-col]`)){const v=D.getAttribute("data-col"),S=this.#r(D),y=S?H.errorFor(S,v):null;L(D,y?y.message:null)}}destroy(){for(const H of this.#n)H();this.#n=[]}}const Q=W}),xe("packages/dom/src/presentation.js",function(e,K){"use strict";Object.defineProperty(e,"CHROME",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"PresentationController",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/dom/src/renderer/textentry.js").isTextEntry,Q=K("packages/dom/src/renderer/viewport.js").CLASS,G="lat-presenting",H="lat-presenting--changing",U="lat-presenting__progress",D="lat-cell--dimmed",v=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class S{#e;#t;#n;#r=[];#o=null;#i=null;#s=null;constructor(c){this.#e=c.grid,this.#t=c.renderer,this.#n=c.maximiser||null}mount(){this.#r.push(this.#e.on("presentation:started",()=>this.#d())),this.#r.push(this.#e.on("presentation:changed",()=>this.#h())),this.#r.push(this.#e.on("presentation:scale",()=>this.#h())),this.#r.push(this.#e.on("presentation:ended",()=>this.#f())),this.#r.push(this.#e.on("presentation:view",i=>this.#a(i))),this.#r.push(this.#e.on("presentation:spotlight",()=>this.#p())),this.#r.push(this.#e.on("render:done",()=>this.#p())),this.#n&&L(this.#n.watch)&&this.#r.push(this.#n.watch(i=>{i||!this.#o||this.#o.maximised||this.#e.presentation?.active&&this.#e.presentation.stop()}));const c=this.#t.viewport?.root;if(c&&L(c.addEventListener)){const i=n=>this.#l(n);c.addEventListener("keydown",i),this.#r.push(()=>c.removeEventListener("keydown",i))}}#l(c){const i=this.#e.presentation;if(!i?.active)return;const n=c.ctrlKey||c.metaKey,t=c.key;if(t==="Escape"&&!this.#n){c.defaultPrevented||(i.stop(),c.preventDefault?.());return}if(n){t==="="||t==="+"?(i.nudge(1),c.preventDefault?.()):t==="-"||t==="_"?(i.nudge(-1),c.preventDefault?.()):t==="0"&&(i.setScale(1.5),c.preventDefault?.());return}if(!i.views.length||F(c.target))return;t==="ArrowRight"||t==="ArrowDown"||t==="PageDown"||t===" "?(i.step(1),c.preventDefault?.()):t==="ArrowLeft"||t==="ArrowUp"||t==="PageUp"?(i.step(-1),c.preventDefault?.()):t==="Home"?(i.goTo(0),c.preventDefault?.()):t==="End"?(i.goTo(i.views.length-1),c.preventDefault?.()):(t==="r"||t==="R")&&(i.reset(),c.preventDefault?.())}#a(c){!c||!c.viewId||(this.#u(),this.#e.views?.apply?.(c.viewId),this.#c(c))}#u(){const c=this.#t.viewport?.root;c?.classList&&(c.classList.remove(H),c.offsetWidth,c.classList.add(H))}#c(c){const i=this.#t.viewport?.overlays;if(!i||!this.#e.presentation.views.length)return;const n=i.ownerDocument;if(!n?.createElement)return;if(!this.#i){const s=n.createElement("div");s.className=U,s.setAttribute("role","status"),s.setAttribute("aria-live","polite"),i.appendChild(s),this.#i=s}const t=this.#e.views?.get?.(c.viewId),r=t&&t.name?t.name:"";this.#i.textContent=r?`${r} · ${(c.index||0)+1} / ${c.count||0}`:`${(c.index||0)+1} / ${c.count||0}`}#d(){if(this.#o){this.#h();return}const c=!!(this.#n&&this.#n.active());this.#n&&!c&&this.#n.enter();const i=new Set(this.#e.presentation?.options?.chrome||[]),n=[];for(const r of v){if(i.has(r)||r==="toolPanel"&&this.#k())continue;const s=this.#b(r);s&&s.style&&s.style.display!=="none"&&(s.style.display="none",n.push(s))}const t=this.#y();t&&t.style&&t.style.display!=="none"&&this.#w(t)&&(t.style.display="none",n.push(t)),this.#o={maximised:c,hidden:n},this.#t.viewport?.root?.classList?.add(G),this.#h(),this.#m()}#f(){const c=this.#o;this.#o=null;const i=this.#t.viewport?.root;if(i?.classList?.remove(G),i?.style?.removeProperty("--lattice-presentation-scale"),this.#g(),this.#i&&(this.#i.remove?.(),this.#i=null),i?.classList?.remove(H),this.#p(),c){const n=this.#e.toolPanel;n&&L(n.presentRestore)&&n.presentRestore();for(const t of c.hidden)t.style.display="";this.#n&&!c.maximised&&this.#n.active()&&this.#n.exit()}this.#t.invalidate?.("theme")}#h(){const c=this.#t.viewport?.root;!c||!c.style||(c.style.setProperty("--lattice-presentation-scale",String(this.#e.presentation.scale)),this.#t.invalidate?.("theme"))}#p(){const c=this.#t.viewport?.root;if(!c?.querySelectorAll)return;const i=this.#e.presentation?.active?this.#e.presentation.spotlight:null,n=i&&i.keys.length?new Set(i.keys):null,t=i&&i.colIds.length?new Set(i.colIds):null;for(const r of c.querySelectorAll("[data-key]")){const s=!n||n.has(r.getAttribute("data-key"));for(const f of r.querySelectorAll("[data-col]"))!i||s&&(!t||t.has(f.getAttribute("data-col")))?f.classList.remove(D):f.classList.add(D)}}#m(){this.#g();const c=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(c)||c<=0||!this.#e.presentation.views.length)return;const i=this.#t.viewport?.root?.ownerDocument?.defaultView;i?.setInterval&&(this.#s=i.setInterval(()=>{const n=this.#e.presentation;n.active&&n.goTo(n.index>=n.views.length-1?0:n.index+1)},Math.max(1e3,c)))}#g(){if(this.#s===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#s),this.#s=null}#y(){const c=this.#e.element;return!c||!L(c.querySelector)?null:c.querySelector(`.${Q.statusBar}`)}#w(c){const i=c.children||[];for(const n of i)if(!n.style||n.style.display!=="none")return!1;return!0}#k(){const c=this.#e.toolPanel;return!!(c&&L(c.presentOnly)&&c.presentOnly())}#b(c){const i=this.#e.element;if(!i||!L(i.querySelector))return null;const n={toolPanel:".lat-panel-dock",statusBar:".lat-statusbar",editBar:".lat-editor-bar",historyBar:".lat-history",pagination:".lat-pagination"}[c];return n?i.querySelector(n):null}destroy(){this.#o&&this.#f();for(const c of this.#r)c();this.#r=[]}}const y=S}),xe("packages/dom/src/capture.js",function(e,K){"use strict";Object.defineProperty(e,"isSafeImageSource",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"captureElement",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return H}});const L=K("packages/core/src/internal/util.js").isFunction,B=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function F(U,D,v){const S=v.getComputedStyle(U),y=D.style;if(y)for(let l=0;l<S.length;l++){const c=S[l];B.has(c)||y.setProperty(c,S.getPropertyValue(c),S.getPropertyPriority(c))}}function W(U,D,v){if(F(U,D,v),U.tagName==="CANVAS"&&L(U.toDataURL))try{const l=U.toDataURL("image/png"),c=D.style;c&&(c.setProperty("background-image",`url(${l})`),c.setProperty("background-size","100% 100%"),c.setProperty("background-repeat","no-repeat"))}catch{}const S=U.children||[],y=D.children||[];for(let l=0;l<S.length&&l<y.length;l++)W(S[l],y[l],v)}function Q(U,D){if(!U||U.startsWith("data:")||U.startsWith("blob:"))return!0;try{return new URL(U,D).origin===D}catch{return!0}}async function G(U,D={}){const v=U.ownerDocument,S=v?.defaultView;if(!S||typeof S.getComputedStyle!="function")throw new Error("capture needs a browser document");const y=U.getBoundingClientRect(),l=Math.max(1,Math.ceil(y.width)),c=Math.max(1,Math.ceil(y.height)),i=Math.max(.1,Number(D.scale)||2),n=S.location?.origin||"";for(const g of U.querySelectorAll("img")){const d=g.getAttribute("src")||"";if(!Q(d,n))throw new Error(`capture refused: the image at ${d} 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=U.cloneNode(!0);W(U,t,S),t.style.width=`${l}px`,t.style.height=`${c}px`,t.style.margin="0";const r=new S.XMLSerializer().serializeToString(t),s=`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${c}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${r}</div></foreignObject></svg>`,f=new S.Image;await new Promise((g,d)=>{f.onload=()=>g(void 0),f.onerror=()=>d(new Error("capture failed to rasterise the grid; a host element inside it may not serialise as XML")),f.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(s)}`});const u=v.createElement("canvas");u.width=Math.round(l*i),u.height=Math.round(c*i);const o=u.getContext("2d");if(!o)throw new Error("capture could not get a 2d context");return o.fillStyle=D.background||S.getComputedStyle(U).backgroundColor||"#ffffff",o.fillRect(0,0,u.width,u.height),o.drawImage(f,0,0,u.width,u.height),new Promise((g,d)=>{u.toBlob(h=>h?g({blob:h,width:u.width,height:u.height}):d(new Error("capture produced no image")),D.type||"image/png",D.quality)})}const H=G}),xe("packages/dom/src/annotate.js",function(e,K){"use strict";Object.defineProperty(e,"TOOLS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"MARK_TYPES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.uid,F=X.warnOnce,Q=K("packages/dom/src/renderer/direction.js").signedX,G=Object.freeze(["pen","arrow","rect","highlight","erase"]),H=Object.freeze(["freehand","arrow","rect","highlight","text"]),U=Object.freeze({freehand:"pen",pen:"pen",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),D=Object.freeze({pen:"freehand",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),v=14,S="system-ui, -apple-system, sans-serif";function y(h,a){if(!h||typeof h!="object")return null;const p=U[h.type];if(!p)return null;const w=typeof h.id=="string"&&h.id?h.id:B("mark"),k=Array.isArray(h.points)?h.points:[],m=[];for(const C of k){const M=Number(C&&C.x),P=Number(C&&C.y);Number.isFinite(M)&&Number.isFinite(P)&&m.push({x:M,y:P})}const b=typeof h.colour=="string"&&h.colour?h.colour:a;if(p==="text"){const C=typeof h.text=="string"?h.text:"";if(!m.length||!C)return null;const M={id:w,tool:p,colour:b,points:[m[0]],text:C,region:l(h.region)},P=Number(h.fontSize);return Number.isFinite(P)&&P>0&&(M.fontSize=P),typeof h.background=="string"&&h.background&&(M.background=h.background),M}return m.length<2?null:{id:w,tool:p,colour:b,points:m,region:l(h.region)}}function l(h){return h==="start"||h==="end"?h:"centre"}function c(h){const a={id:h.id,type:D[h.tool]||h.tool,colour:h.colour,points:h.points.map(p=>({x:p.x,y:p.y}))};return(h.region==="start"||h.region==="end")&&(a.region=h.region),h.tool==="text"&&(a.text=h.text,h.fontSize!==void 0&&(a.fontSize=h.fontSize),h.background!==void 0&&(a.background=h.background)),a}const i="lat-annotate",n=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(h){return h==="arrow"||h==="rect"}function r(h,a){return{id:h,count:a,valueOf(){return this.count}}}const s=10;function f(h,a,p){const w=p.x-a.x,k=p.y-a.y,m=w*w+k*k;let b=m?((h.x-a.x)*w+(h.y-a.y)*k)/m:0;b=Math.max(0,Math.min(1,b));const C=a.x+b*w,M=a.y+b*k;return Math.hypot(h.x-C,h.y-M)}function u(h){const a=h.points;if(!a.length)return null;if(h.tool==="text"){const b=h.fontSize||v,C=(h.text||"").length*b*.6;return{x1:a[0].x,y1:a[0].y,x2:a[0].x+C,y2:a[0].y+b*1.2}}let p=1/0,w=1/0,k=-1/0,m=-1/0;for(const b of a)p=Math.min(p,b.x),w=Math.min(w,b.y),k=Math.max(k,b.x),m=Math.max(m,b.y);return{x1:p,y1:w,x2:k,y2:m}}function o(h,a){const p=u(h);if(!p)return 1/0;if(h.tool==="text"||h.tool==="rect"){if(a.x>=p.x1&&a.x<=p.x2&&a.y>=p.y1&&a.y<=p.y2)return 0;if(h.tool==="text")return 1/0}const w=h.points;if(h.tool==="rect"){const m=[{x:p.x1,y:p.y1},{x:p.x2,y:p.y1},{x:p.x2,y:p.y2},{x:p.x1,y:p.y2}];let b=1/0;for(let C=0;C<4;C++)b=Math.min(b,f(a,m[C],m[(C+1)%4]));return b}if(w.length===1)return Math.hypot(a.x-w[0].x,a.y-w[0].y);let k=1/0;for(let m=0;m<w.length-1;m++)k=Math.min(k,f(a,w[m],w[m+1]));return k}class g{#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=y(a,this.#i);return p?(p.durable=!0,this.#s.push(p),this.#M(),this.redraw(),this.#R(),r(p.id,this.#s.length)):(F("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(c)}remove(a){const p=this.#s.findIndex(w=>w.id===a);return p<0?(F("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.#R(),!0)}replaceAll(a){const p=Array.isArray(a)?a:[];this.#s=p.map(w=>y(w,this.#i)).filter(Boolean);for(const w of this.#s)w.durable=!0;this.#s.length&&this.#M(),this.redraw(),this.#R()}#d(){const a=this.#t.viewport?.root;if(!a||!L(a.addEventListener))return;const p=w=>{if(!(!this.#o||!w)){if(w.key==="Escape"){this.use(null),w.preventDefault?.();return}if(this.#o==="erase"){if(w.key==="Tab"){this.#f(w);return}(w.key==="Delete"||w.key==="Backspace")&&this.#h(w)}}};a.addEventListener("keydown",p,!0),this.#a.push(()=>a.removeEventListener("keydown",p,!0))}#f(a){if(!this.#s.length){this.#x("a11y.annotate.noMarks");return}a.preventDefault?.();const p=this.#c?this.#s.findIndex(m=>m.id===this.#c):-1,w=a.shiftKey?-1:1,k=p<0?w>0?0:this.#s.length-1:(p+w+this.#s.length)%this.#s.length;this.#c=this.#s[k].id,this.redraw(),this.#x("a11y.annotate.focusedMark",{at:k+1,of:this.#s.length})}#h(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||!L(a.matchMedia))return;let p=null;const w=()=>{const k=a.devicePixelRatio||1;let m;try{m=a.matchMedia(`(resolution: ${k}dppx)`)}catch{return}p=m;const b=()=>{this.redraw(),w()};L(m.addEventListener)?m.addEventListener("change",b,{once:!0}):L(m.addListener)&&m.addListener(b)};w(),this.#a.push(()=>{p=null})}use(a,p={}){const w=!!p.colour&&a===this.#o;p.colour&&(this.#i=String(p.colour));const k=a&&G.includes(a)?a:null;this.#o=k&&k===this.#o&&!w?null:k,this.#o!=="erase"&&(this.#c=null);const m=this.#o?this.#M():this.#n;return m&&(m.style.pointerEvents=this.#o?"auto":"none",m.style.cursor=this.#o?"crosshair":""),this.#R(),this.#o}undo(){const a=this.#s.pop();return a&&this.#c===a.id&&(this.#c=null),this.redraw(),this.#R(),this.#s.length}clear(){this.#s.length&&(this.#s=[],this.#c=null,this.redraw(),this.#R())}#m(){const a=this.#s.filter(p=>p.durable);a.length!==this.#s.length&&(this.#s=a,this.redraw(),this.#R())}redraw(){!this.#n&&this.#s.length&&this.#M();const a=this.#n,p=this.#r;if(!a||!p)return;this.#A();const{left:w,top:k}=this.#S();p.clearRect(0,0,a.width,a.height);const m=this.#l?[...this.#s,this.#l]:this.#s;for(const b of["centre","start","end"]){const C=m.filter(M=>l(M.region)===b);if(C.length){p.save(),this.#g(p,b),p.translate((b==="centre"?-w:0)||0,-k||0);for(const M of C)this.#b(p,M),M.id===this.#c&&this.#j(p,M);p.restore()}}}#g(a,p="centre"){const w=this.#n,k=this.#t.viewport?.bodyViewport;if(!L(w?.getBoundingClientRect)||!L(k?.getBoundingClientRect))return;const m=w.getBoundingClientRect(),b=k.getBoundingClientRect();if(!b.width||!b.height)return;const C=this.#y(p,b);C&&(a.beginPath(),a.rect(C.left-m.left,b.top-m.top,C.width,b.height),a.clip())}#y(a,p){const w=P=>{if(!L(P?.getBoundingClientRect))return null;const x=P.getBoundingClientRect();return x&&x.width>0?{left:x.left,width:x.width}:null},k=w(this.#t.viewport?.bodyStart),m=w(this.#t.viewport?.bodyEnd);if(a==="start")return k;if(a==="end")return m;let b=p.left,C=p.left+p.width;const M=p.left+p.width/2;for(const P of[k,m]){if(!P)continue;const x=P.left+P.width;P.left+P.width/2<M?b=Math.max(b,x):C=Math.min(C,P.left)}return C>b?{left:b,width:C-b}:null}#w(a){for(const[p,w]of[["start",this.#t.viewport?.bodyStart],["end",this.#t.viewport?.bodyEnd]]){if(!L(w?.getBoundingClientRect))continue;const k=w.getBoundingClientRect();if(k&&k.width>0&&a>=k.left&&a<k.left+k.width)return p}return"centre"}#k(a){const p=this.#t.viewport?.bodyViewport;if(!L(p?.getBoundingClientRect))return!0;const w=p.getBoundingClientRect();return!w.width||!w.height?!0:a.clientX>=w.left&&a.clientX<=w.right&&a.clientY>=w.top&&a.clientY<=w.bottom}#b(a,p){const w=p.points;if(!w.length)return;const k=this.#e.presentation?.scale||1;a.lineWidth=(n[p.tool]||3)*k,a.strokeStyle=p.colour,a.fillStyle=p.colour,a.lineCap="round",a.lineJoin="round",a.globalAlpha=p.tool==="highlight"?.32:1;const m=w[0],b=w[w.length-1];if(p.tool==="text"){const C=(p.fontSize||v)*k;a.font=`${C}px ${S}`,a.textBaseline="top";const M=p.text||"";if(p.background){let P=M.length*C*.6;if(typeof a.measureText=="function"){const x=a.measureText(M);x&&Number.isFinite(x.width)&&(P=x.width)}a.fillStyle=p.background,a.fillRect(m.x-C*.15,m.y-C*.1,P+C*.3,C*1.2)}a.fillStyle=p.colour,a.fillText(M,m.x,m.y),a.globalAlpha=1;return}if(p.tool==="rect")a.strokeRect(m.x,m.y,b.x-m.x,b.y-m.y);else if(p.tool==="arrow")a.beginPath(),a.moveTo(m.x,m.y),a.lineTo(b.x,b.y),a.stroke(),this.#O(a,m,b,a.lineWidth);else{a.beginPath(),a.moveTo(m.x,m.y);for(let C=1;C<w.length;C++)a.lineTo(w[C].x,w[C].y);a.stroke()}a.globalAlpha=1}#O(a,p,w,k){const m=Math.atan2(w.y-p.y,w.x-p.x),b=Math.max(8,k*3);a.beginPath(),a.moveTo(w.x,w.y),a.lineTo(w.x-b*Math.cos(m-Math.PI/7),w.y-b*Math.sin(m-Math.PI/7)),a.lineTo(w.x-b*Math.cos(m+Math.PI/7),w.y-b*Math.sin(m+Math.PI/7)),a.closePath(),a.fill()}#j(a,p){const w=u(p);if(!w||!L(a.strokeRect))return;const k=6;a.save(),a.setLineDash?.([4,3]),a.strokeStyle="#1a73e8",a.lineWidth=2,a.globalAlpha=1,a.strokeRect(w.x1-k,w.y1-k,w.x2-w.x1+k*2,w.y2-w.y1+k*2),a.restore()}#P(a,p){const w=this.#e.presentation?.scale||1,k=s*w;for(let m=this.#s.length-1;m>=0;m--){const b=this.#s[m];if(l(b.region)===p&&o(b,a)<=k)return b}return null}#S(){const a=L(this.#t.scrollPosition)?this.#t.scrollPosition():null,p=this.#t.viewport?.rtl===!0;return{left:Q(a?.left||0,p),top:a?.top||0}}#M(){if(this.#n)return this.#n;const a=this.#t.viewport?.overlays,p=a?.ownerDocument;if(!a||!p?.createElement)return null;const w=p.createElement("canvas");return w.className=i,w.style.position="absolute",w.style.inset="0",w.style.pointerEvents="none",a.appendChild(w),this.#n=w,this.#r=w.getContext?w.getContext("2d"):null,this.#A(),this.#E(w),w}#A(){const a=this.#n,p=this.#t.viewport?.root;if(!a||!p?.getBoundingClientRect)return;const w=p.getBoundingClientRect(),m=a.ownerDocument?.defaultView?.devicePixelRatio||1,b=Math.max(1,Math.round(w.width*m)),C=Math.max(1,Math.round(w.height*m));a.width===b&&a.height===C||(a.width=b,a.height=C,a.style&&(a.style.width=`${Math.max(1,w.width)}px`,a.style.height=`${Math.max(1,w.height)}px`),this.#r?.setTransform(m,0,0,m,0,0))}#E(a){const p=(C,M="centre")=>{const P=a.getBoundingClientRect(),{left:x,top:E}=this.#S();return{x:C.clientX-P.left+(M==="centre"?x:0),y:C.clientY-P.top+E}},w=C=>{if(!this.#o||!this.#k(C))return;const M=this.#w(C.clientX);if(this.#o==="erase"){const P=this.#P(p(C,M),M);P&&(this.remove(P.id),this.#x("a11y.annotate.erased")),C.preventDefault?.();return}this.#l={id:B("mark"),tool:this.#o,colour:this.#i,points:[p(C,M)],region:M},a.setPointerCapture?.(C.pointerId),C.preventDefault?.()},k=C=>{if(!this.#l)return;const M=p(C,this.#l.region);t(this.#l.tool)&&this.#l.points.length>1&&this.#l.points.pop(),this.#l.points.push(M),this.redraw()},m=C=>{this.#l&&(this.#l.points.length>1&&this.#s.push(this.#l),this.#l=null,a.releasePointerCapture?.(C.pointerId),this.redraw(),this.#R())},b=C=>{if(!this.#o)return;const M=this.#t.viewport?.bodyViewport;if(!M)return;let P=!1;C.deltaY&&typeof M.scrollTop=="number"&&(M.scrollTop+=C.deltaY,P=!0),C.deltaX&&typeof M.scrollLeft=="number"&&(M.scrollLeft+=C.deltaX,P=!0),P&&C.preventDefault?.()};a.addEventListener("pointerdown",w),a.addEventListener("pointermove",k),a.addEventListener("pointerup",m),a.addEventListener("pointercancel",m),a.addEventListener("wheel",b,{passive:!1}),this.#a.push(()=>{a.removeEventListener("pointerdown",w),a.removeEventListener("pointermove",k),a.removeEventListener("pointerup",m),a.removeEventListener("pointercancel",m),a.removeEventListener("wheel",b)})}#R(){this.#e.emit?.("annotation:changed",{tool:this.#o,count:this.#s.length},"user")}#L(a,p){const w=this.#e.messages;return w&&L(w.t)?w.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 d=g}),xe("packages/dom/src/timelinebar.js",function(e,K){"use strict";Object.defineProperty(e,"agoLabel",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"clockLabel",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"TimelineBar",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,W="lat-timeline";function Q(D){if(!Number.isFinite(D)||D<1e3)return"now";const v=Math.round(D/1e3);if(v<60)return`${v}s ago`;const S=Math.round(v/60);return S<60?`${S}m ago`:`${Math.round(S/60)}h ago`}function G(D,v){return Number.isFinite(D)?new Date(D).toLocaleTimeString(v||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(v){this.#e=v.grid,this.#t=v.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 v=this.#e.timeline,S=v.depth,y=v.position;this.#r.max=String(Math.max(1,S)),this.#r.value=String(Math.max(0,S-y)),this.#r.disabled=S===0;const l=v.at(),c=v.live;this.#o&&(this.#o.textContent=c?this.#l("timeline.live"):Q(Date.now()-(l||Date.now())),this.#o.setAttribute("data-live",c?"true":"false")),this.#i&&(this.#i.textContent=S===0?this.#l("timeline.recording"):G(l,this.#e.get("locale"))),this.#n.setAttribute("data-live",c?"true":"false")}#l(v,S){const y=this.#e;return(y&&y.messages?y.messages:F).t(v,S)}#a(){if(this.#n)return;const v=this.#t.viewport?.overlays,S=v?.ownerDocument;if(!v||!S?.createElement)return;const y=S.createElement("div");y.className=W;const l=S.createElement("span");l.className=`${W}__ago`,l.setAttribute("role","status"),l.setAttribute("aria-live","polite");const c=S.createElement("input");c.className=`${W}__range`,c.type="range",c.min="0",c.step="1",c.setAttribute("aria-label",this.#l("timeline.scrub"));const i=S.createElement("span");i.className=`${W}__clock`;const n=S.createElement("button");n.className=`${W}__live`,n.type="button",n.textContent=this.#l("timeline.goLive"),n.setAttribute("aria-label",this.#l("timeline.returnToPresent")),y.appendChild(l),y.appendChild(c),y.appendChild(i),y.appendChild(n),v.appendChild(y),this.#n=y,this.#r=c,this.#o=l,this.#i=i;const t=()=>{const f=this.#e.timeline.depth;this.#e.timeline.seek(f-Number(c.value))};c.addEventListener("input",t);const r=()=>this.#e.timeline.toLive();n.addEventListener("click",r);const s=f=>f.stopPropagation();c.addEventListener("keydown",s),this.#s.push(()=>{c.removeEventListener("input",t),n.removeEventListener("click",r),c.removeEventListener("keydown",s)})}#u(){this.#n&&(L(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null,this.#i=null)}destroy(){for(const v of this.#s)v();this.#s=[],this.#u()}}const U=H}),xe("packages/dom/src/commentpaint.js",function(e,K){"use strict";Object.defineProperty(e,"CommentPainter",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,Q=K("packages/dom/src/renderer/direction.js").isRtlElement,G="lat-comment-mark",H="lat-cell--commented",U="lat-cell--commented-open";class D{#e;#t;#n=[];#r=[];constructor(y){this.#e=y.grid,this.#t=y.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 y=this.#e.comments;if(!y||!y.enabled)return;const l=this.#t.viewport?.root;if(!l||!l.querySelectorAll)return;const c=[];for(const i of l.querySelectorAll("[data-key]")){const n=i.getAttribute("data-key");if(n){c.push(n);for(const t of i.querySelectorAll("[data-col]")){const r=t.getAttribute("data-col"),s=y.at(n,r),f=!!(s&&s.count);t.classList.toggle(H,f),t.classList.toggle(U,f&&s.unresolved>0),this.#i(t,s,r)}}}(c.length!==this.#r.length||c.some((i,n)=>i!==this.#r[n]))&&(this.#r=c,y.request(c))}#o(y,l){const c=this.#e;return(c&&c.messages?c.messages:F).t(y,l)}#i(y,l,c){if(!l||!l.count){y.hasAttribute("aria-description")&&y.removeAttribute("aria-description");return}const i=l.count,n=l.unresolved,t=this.#o("count.comments",{count:i});y.setAttribute("aria-description",n>0?this.#o("comments.someUnresolved",{comments:t,unresolved:n}):this.#o("comments.allResolved",{comments:t}))}#s(){const y=this.#t.viewport?.root;if(!y||!L(y.addEventListener))return;const l=i=>{const n=this.#e.comments;if(!n||!n.enabled)return;const t=i.target&&L(i.target.closest)?i.target.closest("[data-col]"):null;if(!t||!t.classList.contains(H)||!this.#l(t,i))return;const r=t.closest("[data-key]"),s=r&&r.getAttribute("data-key");s&&(i.stopPropagation(),i.preventDefault(),n.open(s,t.getAttribute("data-col")))},c=i=>{const n=this.#e.comments;if(!n||!n.enabled||!i.altKey||i.key!=="m"&&i.key!=="M")return;const t=this.#t.viewport?.root?.querySelector?.("[data-col].lat-cell--focus")||(typeof document<"u"&&document.activeElement&&L(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&&(i.preventDefault(),i.stopPropagation(),n.open(s,t.getAttribute("data-col")))};y.addEventListener("click",l,!0),y.addEventListener("keydown",c,!0),this.#n.push(()=>{y.removeEventListener("click",l,!0),y.removeEventListener("keydown",c,!0)})}#l(y,l){if(!L(y.getBoundingClientRect))return!1;const c=y.getBoundingClientRect(),i=Math.max(14,Math.min(24,c.height*.6));return(Q(y)?l.clientX<=c.left+i:l.clientX>=c.right-i)&&l.clientY<=c.top+i}destroy(){for(const y of this.#n)y();this.#n=[]}}const v=D}),xe("packages/dom/src/presencepaint.js",function(e,K){"use strict";Object.defineProperty(e,"PresencePainter",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,Q=K("packages/dom/src/editors/common.js").cssEscape,H=K("packages/core/src/model/presence.js").CURSOR_LABEL_MS,U="lat-presence";class D{#e;#t;#n=null;#r=null;#o=new Set;#i=[];#s=null;constructor(y){this.#e=y.grid,this.#t=y.renderer}mount(){const y=this.#e.presence;if(!(!y||!y.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,c=>this.#l(l,c)));this.#a(),this.paint()}}#l(y,l){if(this.#f(),y==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const i=l&&l.peer;i&&(this.#r.textContent=this.#h(y==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:i.name}))}#a(){const y=this.#t.viewport?.overlays,l=y?.ownerDocument;if(!y||!l?.createElement)return;const c=this.#e.get("presence")||{},i=l.createElement("span");if(i.className=`${U}__live`,i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),y.appendChild(i),this.#r=i,c.roster===!1)return;const n=l.createElement("div");n.className=U,c.roster&&c.roster.side==="start"&&n.setAttribute("data-side","start"),n.style.pointerEvents="auto",y.appendChild(n),this.#n=n}paint(){const y=this.#e.presence,l=this.#t.viewport?.root;if(!y||!y.enabled||!l?.querySelectorAll)return;this.#d(l);const c=y.peers(),i=[...c].sort((n,t)=>n.at-t.at);for(const n of i)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 i)n.cursor&&this.#c(l,n.cursor.rowId,n.cursor.colId,n,"cursor");for(const n of i)n.editing&&this.#c(l,n.editing.rowId,n.editing.colId,n,"edit");this.#f(),this.#u(c)}#u(y){if(this.#s!==null)return;const l=y.filter(n=>n.cursorFresh);if(!l.length)return;const i=Math.max(...l.map(n=>n.cursorAt||0))+H-Date.now();this.#s=setTimeout(()=>{this.#s=null,this.paint()},Math.max(50,i))}#c(y,l,c,i,n){const t=y.querySelector(`[data-key="${Q(l)}"]`),r=t&&t.querySelector(`[data-col="${Q(c)}"]`);r&&(r.setAttribute("data-presence",n),r.style.setProperty("--lat-peer",i.colour),r.setAttribute("data-peer-name",i.name),r.setAttribute("data-peer-initial",i.initials||(i.name||"?").slice(0,1).toUpperCase()),i.idle?r.setAttribute("data-peer-idle","true"):r.removeAttribute("data-peer-idle"),n==="cursor"&&i.cursorFresh&&r.setAttribute("data-peer-fresh","true"),this.#o.add(`${l}${c}`))}#d(y){if(this.#o.size){for(const l of y.querySelectorAll("[data-presence]"))l.removeAttribute("data-presence"),l.removeAttribute("data-peer-name"),l.removeAttribute("data-peer-initial"),l.removeAttribute("data-peer-fresh"),l.removeAttribute("data-peer-idle"),l.style.removeProperty("--lat-peer");this.#o.clear()}}#f(){if(!this.#n)return;const y=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 i of l){const n=y.createElement("button");n.className=`${U}__peer`,n.type="button",n.style.setProperty("--lat-peer",i.colour),n.toggleAttribute("data-idle",!!i.idle),n.toggleAttribute("data-hidden",!!i.hidden);let t="presence.peer";i.hidden?t="presence.peerHidden":i.idle&&(t="presence.peerIdle"),n.setAttribute("aria-label",this.#h(t,{name:i.name}));const r=y.createElement("span");r.className=`${U}__dot`,r.setAttribute("aria-hidden","true"),r.textContent=i.initials||(i.name||"?").slice(0,1).toUpperCase(),n.appendChild(r);const s=y.createElement("span");s.className=`${U}__name`,s.textContent=i.name,n.appendChild(s),n.addEventListener("click",()=>this.#e.presence.jumpTo(i.id)),this.#n.appendChild(n)}const c=l.filter(i=>i.hidden).length;if(c){const i=y.createElement("span");i.className=`${U}__hidden`,i.textContent=this.#h("presence.hidden",{count:c}),this.#n.appendChild(i)}}announceRefusal(y){if(!this.#r)return;const l=y&&y.name?y.name:this.#h("presence.someoneElse");this.#r.textContent=this.#h("a11y.presence.refused",{name:l})}#h(y,l){const c=this.#e;return(c&&c.messages?c.messages:F).t(y,l)}destroy(){for(const l of this.#i)l();this.#i=[],this.#s!==null&&clearTimeout(this.#s),this.#s=null;const y=this.#t.viewport?.root;y?.querySelectorAll&&this.#d(y),this.#n&&L(this.#n.remove)&&this.#n.remove(),this.#r&&L(this.#r.remove)&&this.#r.remove(),this.#n=null,this.#r=null}}const v=D}),xe("packages/dom/src/commentpanel.js",function(e,K){"use strict";Object.defineProperty(e,"relativeTime",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"renderBody",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"CommentPanel",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,Q=K("packages/dom/src/editors/common.js").cssEscape,H=K("packages/core/src/model/comments.js").parseCellKey,U="lat-comments",D=/^(https?:|mailto:)/i,v='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function S(i,n){if(!Number.isFinite(i))return"";const t=Math.max(0,Math.round((n-i)/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 y(i,n,t,r){n.textContent="";const s=String(t??"");if(!r){n.textContent=s;return}const f=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let u=0,o=f.exec(s);for(;o;){o.index>u&&n.appendChild(i.createTextNode(s.slice(u,o.index)));const g=o[0];if(g.startsWith("*")){const d=i.createElement("em");d.textContent=g.slice(1,-1),n.appendChild(d)}else if(g.startsWith("`")){const d=i.createElement("code");d.textContent=g.slice(1,-1),n.appendChild(d)}else{const d=g.indexOf("]("),h=g.slice(1,d),a=g.slice(d+2,-1);if(D.test(a)){const p=i.createElement("a");p.href=a,p.textContent=h,p.rel="noopener noreferrer",p.target="_blank",n.appendChild(p)}else n.appendChild(i.createTextNode(h))}u=o.index+g.length,o=f.exec(s)}u<s.length&&n.appendChild(i.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.#b()})),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.#f(n.rowId,n.field),this.#n||this.#p(t),this.#n.setAttribute("data-open","true"),this.#w(),this.#b(),this.#o&&L(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&&L(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=`${U}__note`,r.setAttribute("role","status"),r.textContent=n,this.#r.appendChild(r)}#f(n,t){const r=this.#t.viewport?.root;if(!r||!r.querySelector)return null;const s=r.querySelector(`[data-key="${Q(n)}"]`);return s?s.querySelector(`[data-col="${t}"]`):null}#h(n,t){const r=this.#e;return(r&&r.messages?r.messages:F).t(n,t)}#p(n){const t=n.createElement("div");t.className=U,t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label",this.#h("comments.panel"));const r=n.createElement("header");r.className=`${U}__head`;const s=n.createElement("div");s.className=`${U}__title`,r.appendChild(s);const f=n.createElement("button");f.className=`${U}__resolve`,f.type="button",r.appendChild(f);const u=n.createElement("button");u.className=`${U}__close`,u.type="button",u.setAttribute("aria-label",this.#h("comments.close")),u.textContent="×",r.appendChild(u);const o=n.createElement("div");o.className=`${U}__list`,o.setAttribute("role","log"),o.setAttribute("aria-live","polite");const g=n.createElement("form");g.className=`${U}__composer`;const d=n.createElement("textarea");d.className=`${U}__input`,d.rows=2,d.setAttribute("aria-label",this.#h("comments.write"));const h=n.createElement("button");h.className=`${U}__send`,h.type="submit",h.textContent=this.#h("comments.post"),g.appendChild(d),g.appendChild(h),t.appendChild(r),t.appendChild(o),t.appendChild(g),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(t),this.#n=t,this.#r=o,this.#o=d,this.#m=s,this.#g=f;const a=m=>{m.preventDefault();const b=String(d.value||"").trim();b&&(d.value="",this.#e.comments.add(b))},p=()=>this.#e.comments.close(),w=()=>{this.#y()>0?this.#e.comments.resolve():this.#e.comments.unresolve()},k=m=>{if(m.stopPropagation(),m.key==="Escape"){m.preventDefault(),this.#e.comments.close();return}if(m.key!=="Tab")return;const b=[...t.querySelectorAll(v)].filter(x=>x.offsetParent!==null||x===d);if(!b.length)return;const C=b[0],M=b[b.length-1],P=t.ownerDocument.activeElement;m.shiftKey&&P===C?(m.preventDefault(),M.focus()):!m.shiftKey&&P===M&&(m.preventDefault(),C.focus())};g.addEventListener("submit",a),u.addEventListener("click",p),f.addEventListener("click",w),t.addEventListener("keydown",k),this.#l.push(()=>{g.removeEventListener("submit",a),u.removeEventListener("click",p),f.removeEventListener("click",w),t.removeEventListener("keydown",k)})}#m=null;#g=null;#y(){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(),f=n.openKey,{rowId:u,field:o}=H(f),g=this.#e.columns.get(o),d=this.#e.rows.byKey(u),h=L(r.rowLabel)&&d?r.rowLabel(d):u;if(this.#m.textContent=this.#h("comments.cellTitle",{column:g&&(g.title??g.id)||o,row:h}),this.#g.textContent=this.#y()>0?this.#h("comments.resolve"):this.#h("comments.reopen"),this.#r.textContent="",n.loading){this.#d(this.#h("comments.loading"));return}const a=n.thread||[];if(!a.length){this.#d(this.#h("comments.empty"));return}const p=d&&g?g.getValue(d.data,d):void 0;for(const w of a)this.#r.appendChild(this.#k(t,w,s,p,r))}#k(n,t,r,s,f){const u=n.createElement("article");u.className=`${U}__item`,t.pending&&u.setAttribute("data-pending","true"),t.resolved&&u.setAttribute("data-resolved","true");const o=n.createElement("div");o.className=`${U}__meta`;const g=n.createElement("span");g.className=`${U}__author`,g.textContent=t.author&&(t.author.name||t.author.initials)||this.#h("comments.unknownAuthor"),o.appendChild(g);const d=n.createElement("time");d.className=`${U}__time`;const h=S(t.at,r);d.textContent=t.edited?this.#h("comments.edited",{time:h}):h,o.appendChild(d),u.appendChild(o);const a=n.createElement("div");if(a.className=`${U}__body`,y(n,a,t.body,!!f.markdown),u.appendChild(a),t.value!==void 0&&!Object.is(t.value,s)){const k=n.createElement("p");k.className=`${U}__moved`,k.textContent=this.#h("comments.valueMoved",{was:String(t.value),now:String(s)}),u.appendChild(k)}const p=t.can||{},w=k=>p[k]!==!1;if(w("edit")||w("delete")){const k=n.createElement("div");if(k.className=`${U}__actions`,w("delete")){const m=n.createElement("button");m.type="button",m.className=`${U}__action`,m.textContent=this.#h("comments.delete"),m.addEventListener("click",()=>this.#e.comments.remove(t.id)),k.appendChild(m)}u.appendChild(k)}return u}#b(){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),f=this.#f(r,s)||this.#i,u=this.#t.viewport?.root;if(!f||!u||!L(f.getBoundingClientRect))return;const o=f.getBoundingClientRect(),g=u.getBoundingClientRect(),d=this.#n.getBoundingClientRect();let h=o.bottom-g.top+4;h+d.height>g.height&&o.top-g.top>d.height&&(h=o.top-g.top-d.height-4);let a=o.left-g.left;a+d.width>g.width&&(a=Math.max(0,g.width-d.width-4)),this.#n.style.top=`${Math.max(0,h)}px`,this.#n.style.left=`${Math.max(0,a)}px`;const p=o.bottom<g.top||o.top>g.bottom;this.#n.toggleAttribute("data-offscreen",p)}destroy(){for(const n of this.#l)n();this.#l=[],this.#n&&L(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const c=l}),xe("packages/dom/src/watermark.js",function(e,K){"use strict";Object.defineProperty(e,"WATERMARK_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"Watermark",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,W=K("packages/dom/src/editors/common.js"),Q=W.el,G=W.on,H="lat-watermark",U="https://www.latticegrid.dev",D=["br","bl","tl","tr"],v=4e3;class S{#e;#t;#n;#r=null;#o=[];#i;#s=0;#l=null;constructor(c){this.#e=c.grid,this.#t=c.document,this.#n=c.element,this.#i=c.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),L(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const c=this.#e.licence&&this.#e.licence.ready;c&&L(c.then)&&c.then(()=>this.refresh(),()=>this.refresh())}refresh(){const c=this.#d();c&&!this.#r?(this.#f(),this.#u()):!c&&this.#r&&(this.#h(),this.#c())}#a(){const c=this.#i;if(!c||!L(c.matchMedia))return!1;try{return!!c.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),L(this.#i.setTimeout)&&(this.#a()||(this.#l=this.#i.setTimeout(()=>{if(this.#l=null,!this.#d()){this.#h();return}this.#s=(this.#s+1)%D.length,this.#h(),this.#f(),this.#u()},v)))}#c(){this.#l!==null&&L(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#l),this.#l=null}#d(){const c=this.#e.licence;return!!(c&&L(c.watermark)&&c.watermark())}#f(){const c=Q(this.#t,"a",{class:`${H}__link`,text:(this.grid&&this.grid.messages?this.grid.messages:F).t("licence.watermark"),attrs:{href:U,target:"_blank",rel:"noopener noreferrer"}});this.#r=Q(this.#t,"div",{class:`${H} ${H}--${D[this.#s]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[c]}),this.#o.push(G(this.#r,"pointerdown",i=>{L(i.stopPropagation)&&i.stopPropagation()})),this.#n&&L(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#h(){this.#r&&L(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c();for(const c of this.#o)c();this.#o=[],this.#h()}}const y=S}),xe("packages/dom/src/maximise.js",function(e,K){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const X=K("packages/core/src/internal/util.js"),L=X.warnOnce,B=X.isFunction,F=K("packages/dom/src/editors/common.js"),W=F.el,Q=F.on,H=K("packages/dom/src/themeof.js").themeOf,U="lat-maximised",D={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"},v="lat-maximised-host",S="lat-maximise-placeholder";class y{#e;#t;#n;#r;#o;#i=null;#s=null;#l=new Set;#a=null;#u=!1;#c=null;constructor(i){this.#e=i.element,this.#t=i.document,this.#n=B(i.onChange)?i.onChange:null,this.#r=B(i.captureScroll)?i.captureScroll:null,this.#o=B(i.restoreScroll)?i.restoreScroll:null}active(){return this.#i!==null}enter(){if(this.active())return!0;const i=this.#e.parentNode;if(!i||!this.#t.body)return L("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=W(this.#t,"div",{class:S}),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(i):null;s&&(this.#e.setAttribute("data-theme",s),this.#u=!0),i.insertBefore(this.#i,this.#e),this.#d(()=>this.#t.body.appendChild(this.#e)),this.#a={};for(const[f,u]of Object.entries(D))this.#a[f]=this.#e.style[f]||"",this.#e.style[f]=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(U),this.#t.body.classList&&this.#t.body.classList.add(v),r&&this.#o&&this.#o(r),this.#s=Q(this.#t,"keydown",f=>this.#f(f)),this.#h(),!0}exit(){if(!this.active())return!1;const i=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(U),this.#t.body&&this.#t.body.classList&&this.#t.body.classList.remove(v),i&&this.#o&&this.#o(i),this.#s&&this.#s(),this.#s=null,this.#h(),!0}toggle(){return this.active()?!this.exit():this.enter()}#d(i){const n=this.#t.activeElement,t=n&&n!==this.#t.body&&B(this.#e.contains)&&this.#e.contains(n)?n:null;i(),t&&B(t.focus)&&t.focus()}#f(i){!i||i.key!=="Escape"||i.defaultPrevented||this.exit()}#h(){this.#n&&this.#n();for(const i of this.#l)i(this.active())}watch(i){return B(i)?(this.#l.add(i),()=>this.#l.delete(i)):()=>{}}destroy(){this.exit()}}const l=y}),xe("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 X=K("packages/dom/src/editors/common.js"),L=X.documentFor,B=X.el,F=X.on,W=X.clear,G=K("packages/core/src/i18n/index.js").defaultMessages,U=K("packages/core/src/internal/util.js").isFunction,D=K("packages/core/src/ai/schema.js"),v=D.describeGrid,S=D.promptText,y=K("packages/core/src/ai/intent.js"),l=y.applyPlan,c=y.buildPrompt,i=y.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;#f=null;#h=null;#p=null;#m=null;#g=null;#y="idle";#w=0;#k=!1;#b=[];t(u,o){return(this.messages&&typeof this.messages.t=="function"?this.messages:G).t(u,o)}init(u={}){this.messages=u&&u.messages||u&&u.grid&&u.grid.messages||G,this.#e=L(u),this.#t=u.grid||null,this.#n=U(u.ask)?u.ask:null,this.#r=u.schemaOptions||{},this.#o=u.context,this.#i={onPlan:U(u.onPlan)?u.onPlan:null,onApply:U(u.onApply)?u.onApply:null,onError:U(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.#k||!this.#s||this.#y!=="busy"&&this.#M()}destroy(){this.#k=!0,this.#w++;for(const u of this.#b)u();this.#b.length=0,this.#g=null,this.#s=null,this.#l=null,this.#a=null,this.#u=null,this.#c=null,this.#d=null,this.#f=null,this.#h=null,this.#p=null,this.#m=null}plan(){return this.#g}async ask(u){if(this.#k||this.#y==="busy")return null;const o=String(u??(this.#l&&this.#l.value)??"").trim();if(!o)return null;if(!this.#n)return this.#E("No model is wired up. Supply `ai.ask` to use the prompt bar."),null;const g=++this.#w;this.#j("busy"),this.#A("Thinking…");let d;try{const h=v(this.#t,this.#r),a=S(h);if(d=await this.#n({prompt:o,schema:h,schemaText:a,message:c(o,a),context:this.#o}),this.#k||g!==this.#w)return null;const p=i(d,h);return this.#P(p),p}catch(h){return this.#k||g!==this.#w||(this.#i.onError&&this.#i.onError(h),this.#E(h instanceof Error?h.message:String(h))),null}}apply(){const u=this.#g;if(this.#k||!u||!u.ok)return null;const o=this.#t?.ai,g=U(o?.apply)?o.apply(u):l(u,this.#t);return this.#i.onApply&&this.#i.onApply(g,u),this.#M(),this.#l&&(this.#l.value=""),g.failed.length?this.#E(`Applied ${g.applied.length}; ${g.failed.map(d=>`${d.type} failed: ${d.reason}`).join("; ")}`):this.#A(`Applied: ${u.describe()}`),g}discard(){this.#k||(this.#M(),this.#A("Discarded."))}#O(u){const o=this.#e,g=B(o,"div",{class:`${n}__row`});this.#l=B(o,"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.#b.push(F(this.#l,"keydown",h=>{const a=h&&h.key;a==="Enter"?(U(h.preventDefault)&&h.preventDefault(),this.ask()):a==="Escape"&&this.#g&&(U(h.preventDefault)&&h.preventDefault(),this.discard())})),g.appendChild(this.#l),this.#a=B(o,"button",{class:`${n}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#b.push(F(this.#a,"click",()=>{this.ask()})),g.appendChild(this.#a),this.#s.appendChild(g),this.#u=B(o,"div",{class:`${n}__preview`,attrs:{hidden:!0}}),this.#c=B(o,"p",{class:`${n}__summary`}),this.#d=B(o,"ul",{class:`${n}__notes`});const d=B(o,"div",{class:`${n}__buttons`});this.#f=B(o,"button",{class:`${n}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#h=B(o,"button",{class:`${n}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#b.push(F(this.#f,"click",()=>{this.apply()})),this.#b.push(F(this.#h,"click",()=>{this.discard()})),d.appendChild(this.#f),d.appendChild(this.#h),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(d),this.#s.appendChild(this.#u),this.#p=B(o,"p",{class:`${n}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#m=B(o,"p",{class:`${n}__error`,attrs:{role:"alert",hidden:!0}}),this.#s.appendChild(this.#p),this.#s.appendChild(this.#m)}#j(u){if(this.#y=u,!this.#s)return;this.#s.setAttribute("data-state",u);const o=u==="busy";r(this.#l,o),r(this.#a,o),this.#a&&(this.#a.textContent=this.t(o?"prompt.asking":"prompt.ask")),s(this.#u,u!=="preview"),s(this.#m,u!=="error")}#P(u){const o=u;if(this.#i.onPlan&&this.#i.onPlan(u),!o.ok){this.#g=null;const g=o.rejected.length?o.rejected.map(d=>d.reason).join("; "):"nothing to do";this.#E(`I could not turn that into a change: ${g}`);return}this.#g=u,this.#A(""),this.#c&&(this.#c.textContent=o.describe()),this.#S(o.rejected),this.#j("preview")}#S(u){const o=this.#d;if(o){W(o),s(o,!u.length);for(const g of u.slice(0,6))o.appendChild(B(this.#e,"li",{class:`${n}__note`,text:g.reason}));u.length>6&&o.appendChild(B(this.#e,"li",{class:`${n}__note`,text:this.t("prompt.moreNotes",{count:u.length-6})}))}}#M(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&W(this.#d),this.#j("idle")}#A(u){this.#p&&(this.#p.textContent=u)}#E(u){this.#g=null,this.#A(""),this.#m&&(this.#m.textContent=u),this.#j("error")}}function r(f,u){f&&(f.disabled=u,u?f.setAttribute("disabled",""):f.removeAttribute("disabled"))}function s(f,u){f&&(f.hidden=u,u?f.setAttribute("hidden",""):f.removeAttribute("hidden"))}}),xe("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 X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.isObject,F=X.warnOnce,Q=K("packages/core/src/source/derive.js").reduceValues,H=K("packages/core/src/source/memory.js").isPipelineSettle,D=K("packages/core/src/i18n/index.js").defaultMessages,S=K("packages/dom/src/cell/icons.js").renderIconInto,y={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",c=new Set(["sum","min","max","avg","first","last","mode","median","p25","p75","p90","p95","p99","stddev","stddevP","mad","range","iqr","trimmedMean","winsorizedMean","geomean","harmean"]),i=Object.freeze({direction:"flat",change:null,percent:null});function n(a,p){if(!Number.isFinite(a)||!Number.isFinite(p))return i;const w=a-p,k=w>0?"up":w<0?"down":"flat",m=p===0?null:w/Math.abs(p)*100;return{direction:k,change:w,percent:m}}function t(a,p){return a==="flat"||p==="neither"?"flat":a===p?"good":"bad"}function r(a,p,w=null){if(L(p)){const P=p(a,w);return P==="good"||P==="warn"||P==="bad"?P:null}if(!B(p))return null;const k=typeof a=="number"&&Number.isFinite(a)?a:null;if(k===null)return null;const m=Number.isFinite(Number(p.good))?Number(p.good):null,b=Number.isFinite(Number(p.warn))?Number(p.warn):null,C=String(p.direction||"up")==="down",M=P=>C?k<=P:k>=P;return m!==null&&M(m)?"good":b!==null&&M(b)?"warn":m===null&&b===null?null:"bad"}function s(a){return!(L(a.value)||a.value!==void 0&&!B(a.value))}function f(a){return!a||!a.rows||!L(a.rows.totalCount)?!0:a.rows.totalCount()>0}function u(a){const p=B(a)?a:{},w=p.grid||null,k=d(p.container,w);if(!k)return F("stat.container","createStat needs a `container`: an element or a selector."),h();const m=k.ownerDocument||(typeof document>"u"?null:document);if(!m)return F("stat.document","createStat needs a document; it draws DOM."),h();const b=m.createElement("div");b.className=["lattice",y.root,p.class].filter(Boolean).join(" "),b.setAttribute("role","group");const C=m.createElement("div");C.className=y.title;const M=m.createElement("div");M.className=y.value;const P=m.createElement("div");P.className=y.interval;const x=m.createElement("div");x.className=y.delta;const E=m.createElement("div");E.className=y.footer;const A=m.createElement("div");if(A.className=y.note,A.hidden=!0,p.icon!=null&&p.icon!==""){const ee=m.createElement("span");ee.className=y.icon,ee.setAttribute("aria-hidden","true"),S(ee,p.icon,`stat:${p.title||"stat"}`),b.appendChild(ee);const te=m.createElement("div");te.className=y.body,te.appendChild(C),te.appendChild(M),te.appendChild(A),te.appendChild(P),te.appendChild(x),te.appendChild(E),b.appendChild(te)}else b.appendChild(C),b.appendChild(M),b.appendChild(A),b.appendChild(P),b.appendChild(x),b.appendChild(E);k.appendChild(b);let $=null;const z=[];let T=!1;function R(){if(L(p.value))return p.value(w);if(p.value!==void 0&&!B(p.value))return p.value;const ee=B(p.value)?p.value:p,te=ee.of,ne=ee.fn||"sum",ie=ee.show;return w?ne==="count"?I().length:te?ie?q(String(te),String(ne),String(ie)):O()==="filtered"&&w.statistics&&L(w.statistics.reduce)?w.statistics.reduce(String(te),String(ne)):Q(I().map(ae=>g(ae,String(te))),String(ne)):null:null}function O(){return String(p.scope||"filtered")}function I(){if(!w||!w.rows)return[];const ee=O();if(ee==="all"){const ne=[];return L(w.rows.forEachAll)&&w.rows.forEachAll(ie=>{ie.group||ne.push(o(ie))}),ne}if(ee==="selected")return(w.selection&&L(w.selection.rows)?w.selection.rows():[]).filter(Boolean).map(o);const te=[];return L(w.rows.forEach)&&w.rows.forEach(ne=>{ne.group||te.push(o(ne))}),te}function q(ee,te,ne){if(te!=="min"&&te!=="max")return F(`stat.show.${te}`,`\`show\` needs \`fn: 'min'\` or \`fn: 'max'\`: "${te}" reduces to a value that no single row holds, so there is no row to report from.`),null;let ie=null,ae=null;for(const re of I()){const se=Number(g(re,ee));Number.isFinite(se)&&(ie===null||(te==="max"?se>ie:se<ie))&&(ie=se,ae=re)}return ae===null?null:g(ae,ne)}function Z(ee){if(L(p.format))return String(p.format(ee,w));if(ee==null)return p.empty??"—";const te=B(p.value)?p.value:p,ne=te.show||te.of;if((te.show?!0:c.has(String(te.fn||"sum")))&&w&&ne&&L(w.columns?.get)){const ae=w.columns.get(String(ne));if(ae&&L(ae.formatValue))return ae.formatValue(ee)}return typeof ee=="number"?Number.isInteger(ee)?String(ee):ee.toFixed(p.decimals??2):String(ee)}function _(ee){return ee?(w&&w.messages||D).t(`stat.tone.${ee}`):""}function J(){if(T)return;const ee=R(),te=s(p)&&!!w&&!f(w),ne=te?null:ee,ie=L(p.baseline)?p.baseline(w):p.baseline;$=ne,C.textContent=p.title??"",C.hidden=!p.title,M.textContent=Z(ne),A.hidden=!te,te&&(A.textContent=w.messages.t("stat.noData"));const ae=te||ie===void 0||ie===null?i:n(typeof ne=="number"?ne:null,Number(ie)),re=t(ae.direction,p.goodWhen||"up");if(x.hidden=ae.change===null,ae.change!==null){const be=ae.direction==="up"?"↑":ae.direction==="down"?"↓":"→",Le=ae.percent===null?Z(Math.abs(ae.change)):`${Math.abs(ae.percent).toFixed(1)}%`;x.textContent=`${be} ${Le}`,x.setAttribute("data-tone",re),x.setAttribute("data-direction",ae.direction)}const se=L(p.interval)?p.interval(ne,w):null,le=!!se&&Number.isFinite(se.lower)&&Number.isFinite(se.upper);P.hidden=!le,le&&(P.textContent=`${Z(se.lower)} – ${Z(se.upper)}`,Number.isFinite(se.confidence)&&P.setAttribute("title",`${Math.round(se.confidence*100)}%`));const fe=te?l:p.bands?r(ne,p.bands,w):null;fe?b.setAttribute("data-tone",fe):b.removeAttribute("data-tone"),E.textContent=L(p.footer)?String(p.footer(ne,w)):p.footer??"",E.hidden=!E.textContent,b.setAttribute("aria-label",[p.title,M.textContent,te?A.textContent:"",le?P.textContent:"",ae.change===null?"":x.textContent,ae.change===null?"":_(re),E.textContent].filter(Boolean).join(", "))}if(w&&L(w.on)&&p.live!==!1)for(const ee of["rows:changed","filter:changed","selection:changed","model:changed"]){const te=ne=>{ee==="model:changed"&&!H(ne)||J()};w.on(ee,te),z.push(()=>L(w.off)&&w.off(ee,te))}return J(),{element:()=>b,value:()=>$,refresh:J,destroy(){T=!0;for(const ee of z)try{ee()}catch{}z.length=0,b.remove()}}}function o(a){return B(a)&&"data"in a?a.data:a}function g(a,p){if(!B(a))return;if(!p.includes("."))return a[p];let w=a;for(const k of p.split(".")){if(!B(w))return;w=w[k]}return w}function d(a,p){if(a&&typeof a=="object")return a;if(typeof a!="string")return null;const w=p&&p.element&&p.element.ownerDocument||(typeof document>"u"?null:document);return w?w.querySelector(a):null}function h(){return{element:()=>null,value:()=>null,refresh(){},destroy(){}}}}),xe("packages/dom/src/kpistrip.js",function(e,K){"use strict";Object.defineProperty(e,"KpiStrip",{enumerable:!0,get:function(){return Q}});const L=K("packages/core/src/internal/util.js").isObject,F=K("packages/dom/src/stat.js").createStat,W={band:"lat-kpi-strip"};class Q{#e;#t;#n;#r=null;#o=[];constructor({grid:H,document:U,kpis:D}){this.#e=H,this.#t=U,this.#n=Array.isArray(D)?D.filter(L):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const U=this.#t.createElement("div");U.className=`lattice ${W.band}`,U.setAttribute("role","group"),U.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=U;for(const D of this.#n){const v=F({...D,grid:this.#e,container:U});this.#o.push(v)}}destroy(){for(const H of this.#o)try{H.destroy()}catch{}this.#o.length=0,this.#r&&(this.#r.remove(),this.#r=null)}}}),xe("packages/dom/src/createGrid.js",function(e,K){"use strict";Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return jt}});const L=K("packages/core/src/index.js").createHeadlessGrid,F=K("packages/core/src/defaults.js").applyDefaults,Q=K("packages/core/src/export/download.js").downloadBlob,G=K("packages/core/src/internal/util.js"),H=G.fail,U=G.isFunction,D=G.warnOnce,S=K("packages/dom/src/localviews.js").createLocalViewStorage,l=K("packages/dom/src/renderer/index.js").DomRenderer,i=K("packages/dom/src/cell/index.js").createCellLayer,n=K("packages/dom/src/cell/icons.js"),t=n.icon,r=n.iconNames,f=K("packages/dom/src/editors/index.js").editors,o=K("packages/dom/src/filters/index.js").filters,g=K("packages/dom/src/ui/index.js"),d=g.StatusBar,h=g.TooltipManager,a=g.Pagination,p=g.GroupByZone,k=K("packages/dom/src/ui/celltooltip.js").CellTooltips,b=K("packages/dom/src/filtermenu.js").FilterMenu,M=K("packages/dom/src/columnmenu.js").ColumnMenu,x=K("packages/dom/src/shortcutshelp.js").ShortcutsHelp,A=K("packages/dom/src/rowreorder.js").RowReorder,$=K("packages/dom/src/alignedgrids.js").AlignedGrids,T=K("packages/dom/src/columntagbar.js").ColumnTagBar,O=K("packages/dom/src/anomalychip.js").AnomalyChip,q=K("packages/dom/src/rowform.js").RowForm,Z=K("packages/dom/src/toolpanelmount.js"),_=Z.ToolPanelDock,J=Z.panelHost,te=K("packages/dom/src/celledit.js").CellEditController,ie=K("packages/dom/src/editbar.js").EditBar,re=K("packages/dom/src/rangeselect.js").RangeController,le=K("packages/core/src/model/selection.js").resolveSelectionConfig,be=K("packages/dom/src/importer.js").ImportController,we=K("packages/dom/src/historybar.js").HistoryBar,ge=K("packages/dom/src/diffpaint.js").DiffPainter,Oe=K("packages/dom/src/detailhost.js").DetailHost,Ie=K("packages/dom/src/highlightpaint.js").HighlightPainter,Ye=K("packages/dom/src/findpaint.js").FindPainter,Te=K("packages/dom/src/findbar.js").FindBar,Ke=K("packages/dom/src/redactpaint.js").RedactionPainter,it=K("packages/dom/src/validationpaint.js").ValidationPainter,yt=K("packages/dom/src/presentation.js").PresentationController,At=K("packages/dom/src/capture.js").captureElement,Tt=K("packages/dom/src/annotate.js").AnnotationLayer,Bt=K("packages/dom/src/timelinebar.js").TimelineBar,Ge=K("packages/dom/src/commentpaint.js").CommentPainter,pe=K("packages/dom/src/presencepaint.js").PresencePainter,Ue=K("packages/dom/src/commentpanel.js").CommentPanel,nt=K("packages/dom/src/watermark.js").Watermark,ke=K("packages/dom/src/maximise.js").Maximiser,Ae=K("packages/dom/src/promptbar.js").PromptBar,me=K("packages/dom/src/kpistrip.js").KpiStrip;function Me(He,lt,rt){const vt=lt==="redo"?"toolbar.redo":"toolbar.undo";return!rt||!rt.label?He(vt):He(lt==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:rt.label})}const Pe=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],Ne=2e3;function De(He,lt,rt,vt){const Nt=lt.annotate===!0?qe(He,vt):[];if(lt.actions===!1)return[];if(lt.actions===void 0&<.side!=="left")return Nt;const $t=Array.isArray(lt.actions)?lt.actions:Pe,gt=(Ut,Jt)=>He.messages.t(Ut,Jt),Rt={undo:{name:"undo",title:()=>Me(gt,"undo",He.history.peek("undo")),icon:"undo",run:()=>He.history.undo(),enabled:()=>He.history.canUndo()},redo:{name:"redo",title:()=>Me(gt,"redo",He.history.peek("redo")),icon:"redo",run:()=>He.history.redo(),enabled:()=>He.history.canRedo()},export:{name:"export",title:()=>gt("toolbar.exportCsv"),icon:"download",run:()=>He.export.csv({download:!0,fileName:lt.exportName})},excel:{name:"excel",title:()=>gt("toolbar.exportExcel"),icon:"spreadsheet",run:()=>He.export.excel({download:!0,fileName:lt.exportName})},clipboard:{name:"clipboard",title:()=>gt("toolbar.clipboard"),icon:"copy",run:()=>He.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>gt("toolbar.print"),icon:"print",run:()=>He.export.print()},pause:{name:"pause",title:()=>{if(!He.updates.paused)return gt("toolbar.pause");const Ut=He.updates.stats().pending;return Ut?gt("toolbar.applyHeld",{count:Ut}):gt("toolbar.resume")},icon:()=>He.updates.paused?"play":"pause",run:()=>He.updates.paused?He.updates.resume():He.updates.pause()},restore:{name:"restore",title:()=>gt("toolbar.restoreView"),icon:"restore",run:()=>He.state.reset(),enabled:()=>He.state.modified()},maximise:{name:"maximise",title:()=>gt(rt&&rt.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>rt&&rt.active()?"minimise":"maximise",run:()=>rt.toggle()}};return rt||delete Rt.maximise,$t.map(Ut=>Ut==="-"?{name:"-",separator:!0}:typeof Ut=="string"?Rt[Ut]:!Ut||typeof Ut!="object"||!Ut.name?null:{...Ut,run:U(Ut.run)?()=>Ut.run({grid:He,keys:He.selection&&U(He.selection.keys)?He.selection.keys():[],cells:He.selection&&U(He.selection.cells)?He.selection.cells():[]}):void 0}).filter(Boolean).concat(Nt)}function qe(He,lt){const rt={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight",erase:"eraser"},vt=($t,gt)=>He.messages.t($t,gt),Nt=["pen","arrow","rect","highlight","erase"].map($t=>({name:$t,title:()=>vt(`toolbar.annotate.${$t}`),icon:rt[$t],run:()=>He.annotate?.use($t),active:()=>He.annotate?.tool===$t,annotation:!0}));return Nt.push(ot(He,vt,lt)),Nt}function ot(He,lt,rt){return{name:"clearAll",title:()=>lt("toolbar.annotate.clearAll"),icon:"trash",enabled:()=>(He.annotate?.count||0)>0,annotation:!0,run:()=>ut(He,lt,rt)}}function ut(He,lt,rt){const vt=He.toolPanel;if(!vt)return;const Nt=gt=>rt?.announce?.(lt(gt),{repeat:!0});vt.removeAction("clearAll");const $t=()=>{vt.removeAction("clearAllConfirm"),vt.removeAction("clearAllKeep"),vt.addAction(ot(He,lt,rt))};vt.addAction({name:"clearAllConfirm",title:()=>lt("toolbar.annotate.clearAllConfirm"),icon:"trash",annotation:!0,run:()=>{He.annotate?.clear(),$t(),Nt("a11y.annotate.cleared")}}),vt.addAction({name:"clearAllKeep",title:()=>lt("toolbar.annotate.clearAllKeep"),icon:"close",annotation:!0,run:()=>$t()}),Nt("a11y.annotate.confirmClear")}const dt=["pen","arrow","rect","highlight","erase","clearAll"];function st(He){let lt=null;return{rowCount:()=>{if(U(He.rows.matchCount))return He.rows.matchCount();const rt=He.pagination&&U(He.pagination.get)?He.pagination.get():null;return rt&&Number.isFinite(rt.total)?rt.total:He.rows.count()},totalRowCount:()=>U(He.rows.totalCount)?He.rows.totalCount():He.rows.count(),selectedAcrossSource:()=>{lt||(lt=U(He.rendererHost)?He.rendererHost():{});const rt=U(lt.selectionSummary)?lt.selectionSummary():null;return rt&&rt.predicate?{count:rt.count}:null},selectedCount:()=>{const rt=He.selection&&He.selection.keys?He.selection.keys():null;return rt?rt.length:0},rangeValues:()=>{const rt=He.selection;return!rt||!U(rt.cells)?[]:rt.cells().map(({key:vt,colId:Nt})=>He.rows.value(vt,Nt))},hiddenUnresolved:()=>U(He.comments&&He.comments.hiddenUnresolved)?He.comments.hiddenUnresolved():0,progress:()=>U(He.source&&He.source.progress)?He.source.progress():null,updateStats:()=>He.updates?He.updates.stats():null}}function wt(He,lt){for(const[rt,vt]of Object.entries(f||{}))He.register("editor",rt,vt);for(const[rt,vt]of Object.entries(o||{}))He.register("filter",rt,vt);for(const[rt,vt]of Object.entries(lt.components||{}))He.register("component",rt,vt);for(const[rt,vt]of Object.entries(lt.pipes||{}))He.register("pipe",rt,vt);for(const[rt,vt]of Object.entries(lt.totalFns||{}))He.register("totalFn",rt,vt)}function ct(He,lt,rt,vt,Nt,$t){const gt=[],Rt=lt.viewport;let Ut=null;if(rt.maximise!==!1&&(Ut=new ke({element:$t,document:vt,onChange:()=>lt.invalidate("all"),captureScroll:()=>lt.scrollState(),restoreScroll:at=>lt.restoreScroll(at)}),He.maximise=Ut,gt.push(()=>Ut.destroy())),rt.statusBar){const at=typeof rt.statusBar=="object"?rt.statusBar:{},bt=new d;bt.init({document:vt,host:st(He),panels:at.panels,registry:at.registry,locale:He.get("locale"),messages:He.messages}),Rt.statusBar.appendChild(bt.element());const Mt=()=>{const tn=Rt.statusBar.offsetHeight||Rt.statusBar.getBoundingClientRect?.().height||0;Rt.root.style.setProperty("--lattice-status-height",`${Math.ceil(tn)}px`)},Gt=()=>{bt.refresh(),Mt()},Wt=["rows:changed","model:changed","selection:changed","range:changed","rows:queued","rows:paused","rows:resumed","comment:added","comment:edited","comment:deleted","comment:indexLoaded"].map(tn=>He.on(tn,Gt));Gt(),Mt(),gt.push(()=>{for(const tn of Wt)tn();Rt.root.style.removeProperty("--lattice-status-height"),bt.destroy?.()})}const Jt=le(rt.selection);if(Jt.ranges){const at=new re({grid:He,renderer:lt,document:vt});at.mount(),He.ranges=at,gt.push(()=>at.destroy())}if(rt.import){const at=new be({grid:He,renderer:lt,document:vt,settings:typeof rt.import=="object"?rt.import:{}});He.importer=at,gt.push(()=>at.destroy())}if(rt.historyBar){const at=typeof rt.historyBar=="object"?rt.historyBar.element:null,bt=new we;bt.init({document:vt,host:{undo:()=>He.history.undo(),redo:()=>He.history.redo(),canUndo:()=>He.history.canUndo(),canRedo:()=>He.history.canRedo(),peek:Gt=>He.history.peek(Gt),list:()=>He.history.list()},props:typeof rt.historyBar=="object"?rt.historyBar:{}}),(at||Rt.root).appendChild(bt.element());const Mt=[He.on("history:changed",()=>bt.refresh())];He.historyBar=bt,gt.push(()=>{for(const Gt of Mt)Gt();bt.destroy()})}if(rt.diff){const at=new ge({grid:He,renderer:lt});at.mount(),He.diffPainter=at,gt.push(()=>at.destroy())}if(rt.ai&&U(rt.ai.ask)){const at=new Ae;at.init({document:vt,grid:He,ask:rt.ai.ask,schemaOptions:rt.ai.schemaOptions,context:rt.ai.context,placeholder:rt.ai.placeholder});const bt=rt.ai.element||Rt.root;bt===Rt.root?bt.insertBefore(at.element(),bt.firstChild):bt.appendChild(at.element()),He.promptBar=at,gt.push(()=>at.destroy())}if(rt.groupPanel){const at=typeof rt.groupPanel=="object"?rt.groupPanel:{},bt=new p;bt.init({document:vt,grid:He,host:J(He,vt,(Mt,Gt)=>lt.announce?.(Mt,Gt)),props:{header:Rt.header,hint:at.hint}}),Rt.root.insertBefore(bt.element(),Rt.header),He.groupPanel=bt;for(const Mt of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])U(He.on)&>.push(He.on(Mt,()=>bt.refresh()));gt.push(()=>bt.destroy())}if(rt.kpis){const at=new me({grid:He,document:vt,kpis:rt.kpis});at.active&&(at.mount(),Rt.root.insertBefore(at.element(),Rt.header),He.kpiStrip=at,gt.push(()=>at.destroy()))}if(rt.toolPanel){const at=typeof rt.toolPanel=="object"?rt.toolPanel:{},bt=new _({grid:He,document:vt,root:Rt.root,panels:at.panels,openPanel:at.openPanel,side:at.side,icons:at.icons,actions:De(He,at,Ut,lt),announce:(Mt,Gt)=>lt.announce?.(Mt,Gt)});bt.mount(),He.toolPanel=bt,gt.push(()=>bt.destroy()),at.annotate===void 0&&(gt.push(He.on("presentation:started",()=>{for(const Mt of qe(He,lt))bt.addAction(Mt)})),gt.push(He.on("presentation:ended",()=>{for(const Mt of dt)bt.removeAction(Mt)})))}if(!!rt.pagination&&(()=>{const at=typeof rt.pagination=="object"?rt.pagination:{};return He.pagination.set({pageSize:Number(at.pageSize)||100}),He.pagination.get().pageSize>0})()){const at=typeof rt.pagination=="object"?rt.pagination:{},bt=new a;bt.init({document:vt,pageSize:at.pageSize,pageSizes:at.pageSizes,page:at.page,total:at.total,locale:He.get("locale"),messages:He.messages,onChange:({page:Wt,pageSize:tn})=>He.pagination.set({page:Wt,pageSize:tn})});const Mt=()=>{const Wt=He.pagination.get();bt.total=Wt.total,bt.counting=Wt.counting===!0,bt.hasMore=Wt.total==null&&Wt.pageCount>Wt.page+1,bt.page=Wt.page,bt.paint()};He.pagination.set({pageSize:bt.pageSize}),Mt();const Gt=["rows:changed","filter:changed","model:changed"].map(Wt=>He.on(Wt,Mt));Rt.statusBar.appendChild(bt.element()),gt.push(()=>{for(const Wt of Gt)Wt();bt.destroy?.()})}if(rt.edit!==!1)if(rt.editBar){const at=new ie({grid:He,document:vt,root:Rt.root});at.mount(),He.editBar=at,gt.push(()=>at.destroy())}else{const at=new te({grid:He,document:vt,renderer:lt,registry:Nt,cellLayer:lt.cellLayer});at.mount(),gt.push(()=>at.destroy())}const dn=new b({grid:He,document:vt,layer:Rt.overlays,registry:Nt});dn.mount(),gt.push(()=>dn.destroy());const qt=new M({grid:He,document:vt,host:Rt.root,cellMenu:rt.contextMenu!==!1,headerMenu:rt.columnMenu!==!1,items:U(rt.contextMenu)?rt.contextMenu:void 0,headerItems:U(rt.columnMenu)?rt.columnMenu:void 0});if(qt.mount(),gt.push(()=>qt.destroy()),Array.isArray(rt.alignedGrids)&&rt.alignedGrids.length){const at=new $;at.add(He);for(const bt of rt.alignedGrids)bt&&bt!==He&&at.add(bt);gt.push(()=>at.destroy())}const _t=new q({grid:He,renderer:lt,document:vt,registry:Nt});_t.active&&(_t.mount(),gt.push(()=>_t.destroy())),Object.defineProperty(He,"form",{configurable:!0,value:Object.freeze({open(at){return _t.active?_t.openRow(at):!1},openNew(at){return _t.active?_t.openNew(at):(D("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}})}),gt.push(()=>{delete He.form}),Object.defineProperty(He,"icons",{configurable:!0,value:Object.freeze({get(at){const bt=t(at);return bt?{viewBox:bt.viewBox,paths:bt.paths.slice(),paint:bt.paint==="stroke"?"stroke":"fill"}:null},names(){return r()}})}),gt.push(()=>{delete He.icons});const Pt=new T({grid:He,renderer:lt,document:vt});Pt.active&&(Pt.mount(),gt.push(()=>Pt.destroy()));const Ft=new O({grid:He,renderer:lt,document:vt});Ft.active&&(Ft.mount(),gt.push(()=>Ft.destroy()));const zt=new A({grid:He,renderer:lt,document:vt});if(zt.active){zt.mount(),zt.paint();const at=He.on("render:done",()=>zt.paint());gt.push(()=>{at(),zt.destroy()})}if(rt.shortcuts!==!1){const at=new x({grid:He,renderer:lt});at.mount(),gt.push(()=>at.destroy())}const Kt=new Ie({grid:He,renderer:lt,window:vt.defaultView||void 0});Kt.mount(),gt.push(()=>Kt.destroy());const Xt=new Ye({grid:He,renderer:lt,window:vt.defaultView||void 0});if(Xt.mount(),gt.push(()=>Xt.destroy()),rt.find!==!1){const at=new Te({grid:He,renderer:lt,document:vt,settings:rt.find});at.mount(),gt.push(()=>at.destroy())}const Yt=new Ke({grid:He,renderer:lt});Yt.mount(),gt.push(()=>Yt.destroy());const Qt=new it({grid:He,renderer:lt});Qt.mount(),gt.push(()=>Qt.destroy());const rn=new yt({grid:He,renderer:lt,maximiser:Ut});rn.mount(),gt.push(()=>rn.destroy());const en=new Bt({grid:He,renderer:lt});en.mount(),gt.push(()=>en.destroy()),rt.environment||He.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[at,bt]of[["filter:changed","filter"],["sort:changed","sort"],["rows:changed","data"],["column:resized","resize"],["column:moved","columns"],["column:visible","columns"]])gt.push(He.on(at,()=>{cn=bt}));gt.push(He.on("render:done",at=>{He.diagnostics.render(cn||at.cause,at.phases),cn=null}));const ln=vt.defaultView;if(ln&&U(ln.requestAnimationFrame)){let at=ln.requestAnimationFrame(function bt(Mt){He.diagnostics.frame(Mt),at=ln.requestAnimationFrame(bt)});gt.push(()=>{U(ln.cancelAnimationFrame)&&ln.cancelAnimationFrame(at)})}const yn=new pe({grid:He,renderer:lt});if(yn.mount(),gt.push(()=>yn.destroy()),gt.push(He.on("presence:lockRefused",at=>yn.announceRefusal(at.peer))),He.presence&&He.presence.enabled){for(const Mt of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])gt.push(He.on(Mt,()=>He.presence.publish()));let at="";gt.push(He.on("render:done",()=>{const Mt=lt.focusState&<.focusState(),Gt=Mt?`${Mt.rowKey}${Mt.colId}`:"";Gt!==at&&(at=Gt,He.presence.publish())}));const bt=$t.ownerDocument;if(bt&&U(bt.addEventListener)){const Mt=()=>He.presence.setPaused(bt.visibilityState==="hidden");bt.addEventListener("visibilitychange",Mt),Mt(),gt.push(()=>bt.removeEventListener("visibilitychange",Mt))}}const bn=new Ge({grid:He,renderer:lt});bn.mount(),gt.push(()=>bn.destroy());const wn=new Ue({grid:He,renderer:lt});wn.mount(),gt.push(()=>wn.destroy()),gt.push(He.on("facet:computed",()=>lt.refreshHeader?.())),Jt&&Jt.headerCheckbox===!0&>.push(He.on("selection:changed",()=>lt.refreshHeader?.())),gt.push(He.on("facet:expanded",()=>lt.invalidate("columns"))),gt.push(He.on("model:changed",()=>lt.invalidate("rows")));const Zt=(at,bt)=>lt.announce?.(at,bt),mn=He.messages,Vt=(at,bt)=>mn.t(at,bt),gn=at=>Vt("count.rows",{count:at});gt.push(He.on("sort:changed",()=>{const at=He.sort.get();if(!at.length){Zt(Vt("a11y.sort.cleared"));return}const bt=at.map(Mt=>{const Gt=He.columns.get(Mt.col);return Vt("a11y.sort.column",{column:Gt&&Gt.title||Mt.col,direction:Vt(Mt.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});Zt(Vt("a11y.sort.by",{columns:mn.list(bt)}))})),gt.push(He.on("filter:changed",()=>{const at=He.rows.matchCount?He.rows.matchCount():He.rows.count(),bt=He.rows.totalCount?He.rows.totalCount():at;Zt(at===bt?Vt("a11y.filter.cleared",{rows:gn(bt)}):Vt("a11y.filter.applied",{shown:gn(at),total:gn(bt)}))})),gt.push(He.on("selection:changed",()=>{const at=He.selection.keys().length;Zt(at===0?Vt("a11y.selection.cleared"):Vt("a11y.selection.count",{count:at}))})),gt.push(He.on("group:toggled",at=>{const bt=He.rows.byKey?He.rows.byKey(at.key):null,Mt=(bt&&(bt.groupLabel??bt.groupValue))??at.key;Zt(Vt(at.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:Mt,rows:gn(He.rows.count())}))})),gt.push(He.on("column:grouped",at=>{const bt=Array.isArray(at.columns)?at.columns:[];if(!bt.length){Zt(Vt("a11y.group.cleared"));return}const Mt=bt.map(Gt=>{const Wt=He.columns.get(Gt);return Wt&&Wt.title||Gt});Zt(Vt("a11y.group.by",{columns:mn.list(Mt)}))})),gt.push(He.on("page:changed",at=>{const bt=Number(at.size)||0,Mt=Number(at.total)||0,Gt=bt>0?Math.max(1,Math.ceil(Mt/bt)):1;Zt(Vt("a11y.page.position",{page:(Number(at.page)||0)+1,pages:Gt}))}));let on={added:0,removed:0},sn=null;const Cn=()=>{sn=null;const at=[];on.added&&at.push(Vt("count.rowsAdded",{count:on.added})),on.removed&&at.push(Vt("count.rowsRemoved",{count:on.removed})),on={added:0,removed:0},at.length&&Zt(mn.list(at))};gt.push(He.on("rows:changed",at=>{if(!at||typeof at.added!="number")return;const bt=Number(at.added)||0,Mt=Number(at.removed)||0;!bt&&!Mt||(on.added+=bt,on.removed+=Mt,sn||(sn=setTimeout(Cn,Ne)))})),gt.push(()=>{sn&&clearTimeout(sn)}),gt.push(He.on("rows:paused",()=>{sn&&(clearTimeout(sn),sn=null),on={added:0,removed:0},Zt(Vt("a11y.updates.paused"),{repeat:!0})})),gt.push(He.on("rows:resumed",()=>Zt(Vt("a11y.updates.resumed"),{repeat:!0})));let fn={count:0,first:null},hn=null;const Kn=()=>{hn=null;const{count:at,first:bt}=fn;if(fn={count:0,first:null},!at||!bt)return;const Mt=He.columns.get(bt.colId),Gt=Mt&&Mt.title||bt.colId,Wt=bt.reason?Vt("a11y.edit.reason",{reason:bt.reason}):"";if(at===1){const tn=bt.restored===void 0||bt.restored===null||bt.restored===""?Vt("value.empty"):String(bt.restored);Zt(Vt("a11y.edit.refusedOne",{column:Gt,value:tn,reason:Wt}),{repeat:!0});return}Zt(Vt("a11y.edit.refusedMany",{count:at,reason:Wt}),{repeat:!0})};gt.push(He.on("cell:reverted",at=>{!at||!at.applied||(fn.count+=1,fn.first||(fn.first=at),hn||(hn=setTimeout(Kn,150)))})),gt.push(()=>{hn&&clearTimeout(hn)}),gt.push(He.on("history:applied",at=>{const bt=!!(at&&at.direction==="redo"),Mt=at&&at.step&&at.step.label;Zt(Mt?Vt(bt?"a11y.history.redo":"a11y.history.undo",{label:Mt}):Vt(bt?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const vn=new Tt({grid:He,renderer:lt,seed:rt.state&&Array.isArray(rt.state.annotations)?rt.state.annotations:null});vn.mount(),gt.push(()=>vn.destroy()),He.annotate=vn,He.capture=async(at={})=>{const{blob:bt,width:Mt,height:Gt}=await At(lt.viewport.root,at);return(at.download===!0||at.download!==!1&&at.fileName)&&Q(bt,at.fileName||`${He.get("exportName")||"grid"}.png`),He.emit("presentation:captured",{width:Mt,height:Gt,bytes:bt.size,mimeType:bt.type,fileName:at.fileName||null},"api"),bt};const kn=new nt({grid:He,document:vt,element:Rt.overlays,window:vt.defaultView||void 0});kn.mount(),gt.push(()=>kn.destroy());const En=new h({grid:He,document:vt,element:Rt.overlays});En.mount?.(),gt.push(()=>En.destroy?.());const Tn=new k({grid:He,host:He.rendererHost(),viewport:Rt,document:vt});return Tn.mount(),gt.push(()=>Tn.destroy()),gt}function pt(He){const lt=[],rt=vt=>{if(vt&&(vt.__lattice&<.push(vt),vt.children))for(const Nt of vt.children)rt(Nt)};return rt(He),lt}function jt(He,lt={}){(!He||typeof He!="object"||!("appendChild"in He))&&H("createGrid needs a host element as its first argument."),lt=F(lt);const rt=He.ownerDocument||(typeof document<"u"?document:null);rt||H("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const vt=rt.documentElement&&rt.documentElement.lang,Nt=!lt.licence&&U(rt.querySelector)?rt.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,$t={...lt};if(!lt.locale&&vt&&($t.locale=vt),Nt&&($t.licence=Nt),lt.views&<.views.local)if(lt.views.storage)D("views:local:ignored","[lattice] views.local is ignored because views.storage was also supplied; the explicit adapter wins.");else{const qt=lt.views.local===!0?{}:lt.views.local;$t.views={...lt.views,storage:S(qt)}}const gt=L($t),Rt=gt.rendererHost();Rt.document=rt,wt(Rt.registry,lt),Rt.cellLayer=i(Rt),Rt.detailHost=new Oe({grid:gt,document:He.ownerDocument||globalThis.document,createGrid:(qt,_t)=>jt(qt,_t)});const Ut=new l(He,Rt),Jt=gt.on("detail:toggled",()=>{Rt.detailHost.syncTarget(),Rt.detailHost.prune()}),pn=gt.on("config:changed",qt=>{qt&&qt.key==="detail"&&Rt.detailHost.reconfigure()});gt.on("destroy",()=>{Jt(),pn(),Rt.detailHost.destroy()}),Rt.detailHost.syncTarget(),gt.attachRenderer(Ut),Ut.mount();const an=ct(gt,Ut,lt,rt,Rt.registry,He),dn=gt.destroy.bind(gt);return gt.destroy=()=>{for(const qt of an)try{qt()}catch{}He.__lattice===gt&&(He.__lattice=null),dn()},He.__lattice=gt,gt}}),xe("packages/dom/src/hydrate.js",function(e,K){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return i}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,W=K("packages/core/src/columns/datatypes.js").BUILTIN_TYPES,G=K("packages/core/src/columns/types/index.js").EXTENDED_TYPES,U=K("packages/dom/src/createGrid.js").createGrid,D=new Set([...Object.keys(W),...Object.keys(G)]);function v(n,t){for(const r of n.children)if(r.tagName===t.toUpperCase())return r;return null}function S(n,t){const r=[];for(const s of n.children)s.tagName===t.toUpperCase()&&r.push(s);return r}function y(n,t){const r=L(n.getAttribute)?n.getAttribute("data-field"):null;return r||String(n.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${t}`}function l(n){const t=n.trim();if(t==="")return null;if(t==="true"||t==="false")return t==="true";const r=Number(t);return Number.isFinite(r)&&t!==""?r:t}function c(n){const t=v(n,"thead"),r=v(t||n,"tr"),f=(r?S(r,"th").length?S(r,"th"):S(r,"td"):[]).map((d,h)=>{const a=y(d,h),p={id:a,field:a,title:String(d.textContent||"").trim()||a},w=L(d.getAttribute)?d.getAttribute("data-type"):null;w&&(D.has(w)?p.type=w:B(`hydrate.unknownType:${w}`,`data-type "${w}" on column "${a}" is not a built-in type name, so it was ignored; the column falls back to sampled shape typing.`));const k=L(d.getAttribute)?d.getAttribute("data-format"):null;return k&&(p.format=k),p}),u=v(n,"tbody"),g=(u?S(u,"tr"):S(n,"tr").filter(d=>d!==r)).map((d,h)=>{const a=S(d,"td"),w={__row:(L(d.getAttribute)?d.getAttribute("data-id"):null)||`row${h}`};return f.forEach((k,m)=>{w[k.field]=a[m]?l(String(a[m].textContent||"")):null}),w});return{columns:f,rows:g}}function i(n,t={}){const{columns:r,rows:s}=c(n),f=n.ownerDocument.createElement("div");return n.parentNode.insertBefore(f,n),n.parentNode.removeChild(n),U(f,{rowKey:"__row",columns:r,rows:s,...t,columns:t.columns!==void 0?t.columns:r,rows:t.rows!==void 0?t.rows:s})}}),xe("packages/dom/src/autoinit.js",function(e,K){"use strict";Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return D}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/dom/src/createGrid.js").createGrid,Q=K("packages/dom/src/hydrate.js").hydrateTable;function G(v,S){const y=[];return L(v.hasAttribute)&&v.hasAttribute(S)&&y.push(v),L(v.querySelectorAll)&&y.push(...v.querySelectorAll(`[${S}]`)),y}function H(v){const S=v.parentNode;if(!S||!S.children)return null;const y=[...S.children],l=y.indexOf(v),c=[y[l+1],y[l-1]];for(const i of c)if(i&&i.tagName==="SCRIPT"&&L(i.getAttribute)&&i.hasAttribute("data-lattice-config"))return i;return null}function U(v){const S=H(v);if(!S)return{};try{return JSON.parse(S.textContent||"{}")}catch(y){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",y),{}}}function D(v){const S=v||(typeof document<"u"?document:null);if(!S)return[];const y=[];for(const l of G(S,"data-lattice-grid")){if(l.__lattice)continue;const c=U(l);y.push(l.tagName==="TABLE"?Q(l,c):F(l,c))}return y}}),xe("packages/dom/src/index.js",function(e,K){"use strict";Object.defineProperty(e,"LatticeGrid",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return x}});const X=K("packages/dom/src/createGrid.js"),L=X.createGrid,B=K("packages/dom/src/hydrate.js"),F=B.hydrateTable,W=K("packages/dom/src/autoinit.js"),Q=W.autoInit,G=K("packages/dom/src/localviews.js"),H=G.createLocalViewStorage,U=K("packages/core/src/index.js"),D=U.createHeadlessGrid,v=U.registerModules,S=U.setLicence,y=U.version,l=U.getVersion,c=U.serialiseState,i=U.restoreState,n=U.defaults;Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return X.createGrid}}),Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return X.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 W.autoInit}}),Object.defineProperty(e,"createLocalViewStorage",{enumerable:!0,get:function(){return G.createLocalViewStorage}}),Object.defineProperty(e,"DEFAULT_VIEWS_KEY",{enumerable:!0,get:function(){return G.DEFAULT_VIEWS_KEY}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return U.createHeadlessGrid}}),Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return U.defaults}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return U.version}}),Object.defineProperty(e,"getVersion",{enumerable:!0,get:function(){return U.getVersion}}),Object.defineProperty(e,"Grid",{enumerable:!0,get:function(){return U.Grid}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return U.EventBus}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return U.Registry}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return U.sharedRegistry}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return U.registerModules}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return U.parseLicence}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return U.verifyLicence}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return U.licenceInfo}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return U.watermark}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return U.setLicence}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return U.licenceState}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return U.isLocalHost}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return U.matchesDomain}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return U.LicenceHolder}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return U.ColumnModel}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return U.buildGraph}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return U.Lookup}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return U.ValuePipeline}}),Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return U.compileFormat}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return U.compileMask}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return U.specToOoxml}}),Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return U.EXTENDED_TYPES}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return U.createRadixType}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return U.RADIX_PRESETS}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return U.parseRadix}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return U.formatRadix}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return U.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return U.registerUnitSystem}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return U.defineUnit}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return U.UNIT_SYSTEMS}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return U.parseUnit}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return U.formatUnit}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return U.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return U.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return U.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return U.convertMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return U.rateFunction}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return U.MISSING_RATE}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return U.Messages}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return U.createMessages}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return U.auditCatalogue}}),Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return U.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return U.MESSAGE_KEYS}}),Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return U.DEFAULT_LOCALE}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return U.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return U.resolveLocale}}),Object.defineProperty(e,"LOCALES",{enumerable:!0,get:function(){return U.LOCALES}}),Object.defineProperty(e,"resolveCatalogue",{enumerable:!0,get:function(){return U.resolveCatalogue}}),Object.defineProperty(e,"EN_US",{enumerable:!0,get:function(){return U.EN_US}}),Object.defineProperty(e,"FR_FR",{enumerable:!0,get:function(){return U.FR_FR}}),Object.defineProperty(e,"FR_CA",{enumerable:!0,get:function(){return U.FR_CA}}),Object.defineProperty(e,"IT_IT",{enumerable:!0,get:function(){return U.IT_IT}}),Object.defineProperty(e,"ES_ES",{enumerable:!0,get:function(){return U.ES_ES}}),Object.defineProperty(e,"PT_BR",{enumerable:!0,get:function(){return U.PT_BR}}),Object.defineProperty(e,"DE_DE",{enumerable:!0,get:function(){return U.DE_DE}}),Object.defineProperty(e,"NL_NL",{enumerable:!0,get:function(){return U.NL_NL}}),Object.defineProperty(e,"SV_SE",{enumerable:!0,get:function(){return U.SV_SE}}),Object.defineProperty(e,"DA_DK",{enumerable:!0,get:function(){return U.DA_DK}}),Object.defineProperty(e,"NB_NO",{enumerable:!0,get:function(){return U.NB_NO}}),Object.defineProperty(e,"FI_FI",{enumerable:!0,get:function(){return U.FI_FI}}),Object.defineProperty(e,"PL_PL",{enumerable:!0,get:function(){return U.PL_PL}}),Object.defineProperty(e,"CS_CZ",{enumerable:!0,get:function(){return U.CS_CZ}}),Object.defineProperty(e,"HU_HU",{enumerable:!0,get:function(){return U.HU_HU}}),Object.defineProperty(e,"RO_RO",{enumerable:!0,get:function(){return U.RO_RO}}),Object.defineProperty(e,"UK_UA",{enumerable:!0,get:function(){return U.UK_UA}}),Object.defineProperty(e,"EL_GR",{enumerable:!0,get:function(){return U.EL_GR}}),Object.defineProperty(e,"JA_JP",{enumerable:!0,get:function(){return U.JA_JP}}),Object.defineProperty(e,"AR",{enumerable:!0,get:function(){return U.AR}}),Object.defineProperty(e,"AR_SA",{enumerable:!0,get:function(){return U.AR_SA}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return U.ColumnStore}}),Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return U.Bitset}}),Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return U.Dictionary}}),Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return U.MultiValue}}),Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return U.MaskPool}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return U.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return U.sortMulti}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return U.evaluateFilters}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return U.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return U.testValue}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return U.groupByColumns}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return U.total}}),Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return U.TOTAL_FNS}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return U.pivot}}),Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return U.Window}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return U.openWindow}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return U.WINDOW_KINDS}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return U.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return U.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return U.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return U.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return U.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return U.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return U.anomalyCondition}}),Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return U.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return U.forecast}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return U.evaluateFormula}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return U.parseFormula}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return U.referencesOf}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return U.looksLikeFormula}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return U.FormulaError}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return U.FUNCTIONS}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return U.compileRules}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return U.ingest}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return U.ingestSync}}),Object.defineProperty(e,"createSource",{enumerable:!0,get:function(){return U.createSource}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return U.createMemorySource}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return U.createPagedSource}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return U.createRemoteSource}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return U.createStreamSource}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return U.createUrlSource}}),Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return U.PROTOCOL}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return U.createPushdownSource}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return U.planQuery}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return U.splitFilters}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return U.applyResidual}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return U.capabilitiesOf}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return U.resolveMutate}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return U.NO_CAPABILITIES}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return U.odataAdapter}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return U.filtersToOData}}),Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return U.conditionToOData}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return U.restAdapter}}),Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return U.DEFAULT_PARAMS}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return U.dfqlAdapter}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return U.duckdbAdapter}}),Object.defineProperty(e,"filtersToSql",{enumerable:!0,get:function(){return U.filtersToSql}}),Object.defineProperty(e,"graphqlAdapter",{enumerable:!0,get:function(){return U.graphqlAdapter}}),Object.defineProperty(e,"splunkAdapter",{enumerable:!0,get:function(){return U.splunkAdapter}}),Object.defineProperty(e,"clickhouseAdapter",{enumerable:!0,get:function(){return U.clickhouseAdapter}}),Object.defineProperty(e,"elasticsearchAdapter",{enumerable:!0,get:function(){return U.elasticsearchAdapter}}),Object.defineProperty(e,"RowModel",{enumerable:!0,get:function(){return U.RowModel}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return U.createRowKey}}),Object.defineProperty(e,"SelectionModel",{enumerable:!0,get:function(){return U.SelectionModel}}),Object.defineProperty(e,"RangeModel",{enumerable:!0,get:function(){return U.RangeModel}}),Object.defineProperty(e,"EditModel",{enumerable:!0,get:function(){return U.EditModel}}),Object.defineProperty(e,"ChangeModel",{enumerable:!0,get:function(){return U.ChangeModel}}),Object.defineProperty(e,"StateModel",{enumerable:!0,get:function(){return U.StateModel}}),Object.defineProperty(e,"STATE_VERSION",{enumerable:!0,get:function(){return U.STATE_VERSION}}),Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return U.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return U.restoreState}}),Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return U.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 f=K("packages/dom/src/columnmenu.js");Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return f.ColumnMenu}}),Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return f.columnMenuItems}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return f.cellMenuItems}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return f.autoGroupMenuItems}});const u=K("packages/dom/src/alignedgrids.js");Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return u.AlignedGrids}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return u.alignGrids}}),Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return u.layoutState}});const o=K("packages/dom/src/toolpanelmount.js");Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return o.ToolPanelDock}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return o.panelHost}}),Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return o.mountPanel}});const g=K("packages/dom/src/celledit.js");Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return g.CellEditController}});const d=K("packages/dom/src/editbar.js");Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return d.EditBar}});const h=K("packages/dom/src/historybar.js");Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return h.HistoryBar}}),Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return h.HISTORY_CLS}});const 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 w=K("packages/dom/src/promptbar.js");Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return w.PromptBar}}),Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return w.PROMPT_CLASS}});const k=K("packages/dom/src/cell/index.js");Object.defineProperty(e,"createCellLayer",{enumerable:!0,get:function(){return k.createCellLayer}}),Object.defineProperty(e,"compileTemplate",{enumerable:!0,get:function(){return k.compileTemplate}}),Object.defineProperty(e,"compileVariant",{enumerable:!0,get:function(){return k.compileVariant}}),Object.defineProperty(e,"checkVariant",{enumerable:!0,get:function(){return k.checkVariant}}),Object.defineProperty(e,"VariantRegistry",{enumerable:!0,get:function(){return k.VariantRegistry}}),Object.defineProperty(e,"BUILTIN_RENDERERS",{enumerable:!0,get:function(){return k.BUILTIN_RENDERERS}}),Object.defineProperty(e,"BUILTIN_VARIANTS",{enumerable:!0,get:function(){return k.BUILTIN_VARIANTS}}),Object.defineProperty(e,"BUILTIN_PIPES",{enumerable:!0,get:function(){return k.BUILTIN_PIPES}}),Object.defineProperty(e,"sanitiseHtml",{enumerable:!0,get:function(){return k.sanitiseHtml}});const m=K("packages/dom/src/editors/index.js");Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return m.editors}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return m.createEditor}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return m.editorFor}}),Object.defineProperty(e,"BaseEditor",{enumerable:!0,get:function(){return m.BaseEditor}});const b=K("packages/dom/src/filters/index.js");Object.defineProperty(e,"filters",{enumerable:!0,get:function(){return b.filters}}),Object.defineProperty(e,"createFilter",{enumerable:!0,get:function(){return b.createFilter}}),Object.defineProperty(e,"filterFor",{enumerable:!0,get:function(){return b.filterFor}}),Object.defineProperty(e,"parseExpression",{enumerable:!0,get:function(){return b.parseExpression}}),Object.defineProperty(e,"ConditionFilter",{enumerable:!0,get:function(){return b.ConditionFilter}});const C=K("packages/dom/src/ui/index.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return C.StatusBar}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return C.ContextMenu}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return C.ToolPanel}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return C.TooltipManager}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return C.Pagination}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return C.OverlayLayer}});const M=K("packages/core/src/registry/licence.js");Object.defineProperty(e,"setLicense",{enumerable:!0,get:function(){return M.setLicence}}),Object.defineProperty(e,"licenseInfo",{enumerable:!0,get:function(){return M.licenceInfo}}),Object.defineProperty(e,"licenseState",{enumerable:!0,get:function(){return M.licenceState}});const P=Object.freeze({createGrid:L,createHeadlessGrid:D,defaults:n,registerModules:v,setLicence:S,version:y,autoInit:Q,hydrateTable:F,serialiseState:c,restoreState:i,createLocalViewStorage:H}),x=P}),xe("packages/modules/shared/adapter.js",function(e,K){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"handlerName",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"dashedName",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"CONFIG_KEY_ALIASES",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"aliasConfigKey",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"isHandlerProp",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"partition",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createGridController",{enumerable:!0,get:function(){return D}});const X=Object.freeze(["ready","destroy","render:first","render:done","config:changed","licence:changed","model:changed","rows:changed","rows:queued","rows:deferred","rows:paused","rows:resumed","row:received","row:sent","row:copied","row:moved","source:error","source:total","stream:chunk","stream:end","stream:evicted","rowDrag:started","rowDrag:moved","rowDrag:left","rowDrag:ended","cell:changed","cell:pending","cell:confirmed","cell:reverted","cell:conflict","cell:clicked","cell:dblclicked","cell:contextmenu","cell:mouseover","cell:mouseout","cell:mousedown","cell:mouseup","cell:edit:start","cell:edit:end","row:edit:start","row:edit:end","row:clicked","row:dblclicked","row:pending","row:confirmed","row:reverted","row:conflict","form:opened","form:closed","form:saved","form:error","sort:changed","filter:changed","group:toggled","facet:computed","facet:filtered","facet:expanded","facet:failed","column:moved","column:resized","column:visible","column:pinned","column:grouped","column:pivoted","column:filter:open","column:profile:open","column:menu:open","columns:changed","columns:tagged","columngroup:changed","header:contextmenu","pivot:drill","selection:changed","range:changed","clipboard:copy","page:changed","scroll","scroll:end","size:changed","detail:toggled","detail:cell:edit:start","detail:cell:edit:end","detail:row:edit:start","detail:row:edit:end","detail:cell:changed","toolpanel:focus","highlight:changed","find:changed","tree:loading","tree:loaded","tree:loadFailed","tree:loadAborted","state:changed","state:reset","history:changed","history:applied","views:changed","view:applied","view:saved","view:removed","view:renamed","view:default","formatting:changed","redaction:changed","permissions:changed","presentation:changed","presentation:started","presentation:ended","presentation:view","presentation:scale","presentation:spotlight","presentation:captured","comment:added","comment:edited","comment:deleted","comment:failed","comment:resolved","comment:unresolved","comment:threadOpened","comment:threadClosed","comment:indexLoaded","presence:published","presence:joined","presence:updated","presence:left","presence:failed","presence:lockRefused","diff:changed","diff:swapped","timeline:attached","timeline:detached","timeline:seek","timeline:seeking","annotation:changed","validation:failed","validation:cleared","export:progress","export:request","export:done","shortcuts:opened","shortcuts:closed","print:before","print:after","beforeEdit","beforeSort","beforeFilter","beforeColumnMove","beforeColumnResize","beforeColumnHide","beforeSelect","beforeRowAdd","beforeDelete","beforeRowMove","beforeGroup","beforeRowReceive","edit:cancelled","sort:cancelled","filter:cancelled","columnMove:cancelled","columnResize:cancelled","columnHide:cancelled","selection:cancelled","rowAdd:cancelled","delete:cancelled","rowMove:cancelled","group:cancelled","rowReceive:cancelled"]),L=Object.freeze({sort:(v,S)=>v.sort.set(S||[]),filters:(v,S)=>v.filters.set(S||null),quickFilter:(v,S)=>{if(S&&typeof S=="object"){v.filters.quick(S.text||"",{mode:S.mode});return}v.filters.quick(typeof S=="string"?S:"")},selectedKeys:(v,S)=>v.selection.set(Array.isArray(S)?S:[])});function B(v){return`on${String(v).split(":").map(y=>y.charAt(0).toUpperCase()+y.slice(1)).join("")}`}function F(v){return String(v).replace(/:/g,"-")}const W=Object.freeze({"row-key":"rowKey","row-height":"rowHeight","header-height":"headerHeight","auto-height":"autoHeight"});function Q(v){return Object.hasOwn(W,v)?W[v]:v}const G=Object.freeze(Object.fromEntries(X.map(v=>[B(v),v])));function H(v){return Object.hasOwn(G,v)}function U(v){const S={},y={},l={};for(const[c,i]of Object.entries(v||{})){if(H(c)){l[c]=i;continue}if(Object.hasOwn(L,c)){y[c]=i;continue}S[c]=i}return{config:S,imperative:y,handlers:l}}function D(v){const S=v.createGrid;if(typeof S!="function")throw new TypeError("createGridController needs createGrid; pass it in from the grid package.");const y=U(v.props||{}),l=S(v.element,{...y.config});let c=y.handlers,i=y.config,n={};const t=f=>{if(!f||typeof f.type!="string")return;const u=c[B(f.type)];typeof u=="function"&&u(f)},r=l.on("*",t);for(const[f,u]of Object.entries(y.imperative))u!==void 0&&(L[f](l,u),n[f]=u);let s=!1;return{grid:l,update(f){if(s)return;const u=U(f||{});c=u.handlers;const o={};for(const[g,d]of Object.entries(u.config))Object.is(i[g],d)||(o[g]=d);for(const g of Object.keys(i))Object.hasOwn(u.config,g)||(o[g]=void 0);Object.keys(o).length&&l.setAll(o),i=u.config;for(const[g,d]of Object.entries(L)){const h=u.imperative[g];Object.is(n[g],h)||h===void 0&&!Object.hasOwn(n,g)||(d(l,h),n[g]=h)}},destroy(){s||(s=!0,r(),l.destroy())}}}}),xe("packages/modules/react/viewers.js",function(e,K){"use strict";Object.defineProperty(e,"VIEWER_EVENTS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"VIEWER_APPLY",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"VIEWER_BULK_UPDATE",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"viewerHandlerName",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"partitionViewerProps",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createViewerController",{enumerable:!0,get:function(){return U}});const L=K("packages/core/src/internal/util.js").warnOnce,B=Object.freeze({kpi:Object.freeze(["tile:click","tile:dblclick","tile:contextmenu","node:toggle","change","tile:status"]),kanban:Object.freeze(["card:click","card:dblclick","card:contextmenu","card:move","card:reverted","card:confirmed","selection:changed","column:collapse","card:add","drag:start","drag:end","swimlane:collapse","swimlane:reorder","column:reorder","filter:changed","sprint:changed","epic:changed","card:expand","card:drill","card:edit","card:sla","beforeMove","beforeAdd","beforeEdit","beforeLaneReorder","beforeColumnReorder","beforeColumnChange","move:cancelled","add:cancelled","edit:cancelled","laneReorder:cancelled","columnReorder:cancelled","columnChange:cancelled"]),tabs:Object.freeze(["beforeTabChange","tab:changed","tabChange:cancelled"]),chart:Object.freeze(["click","hover","leave","draw","legend"]),gantt:Object.freeze(["schedule","error"]),layout:Object.freeze(["layout:changed","window:moved","window:resized","window:closed","beforeWindowClose","windowClose:cancelled"]),router:Object.freeze(["metrics"])}),F=Object.freeze({kpi:Object.freeze({rows:(D,v)=>D.setRows(Array.isArray(v)?v:[])}),kanban:Object.freeze({rows:(D,v)=>D.setRows(Array.isArray(v)?v:[]),quickFilter:(D,v)=>D.setQuickFilter(typeof v=="string"?v:""),sprint:(D,v)=>D.setSprint(v),epic:(D,v)=>D.setEpic(v),loading:(D,v)=>D.setLoading(!!v),error:(D,v)=>D.setError(v??null)}),gantt:Object.freeze({tasks:(D,v)=>D.setTasks(Array.isArray(v)?v:[]),dependencies:(D,v)=>D.setDependencies(Array.isArray(v)?v:[])}),tabs:Object.freeze({active:(D,v)=>{typeof v=="string"&&D.activate(v)}}),chart:Object.freeze({}),layout:Object.freeze({})}),W=Object.freeze({chart:"update"});function Q(D){return`on${String(D).split(":").map(S=>S.charAt(0).toUpperCase()+S.slice(1)).join("")}`}const G=Object.freeze(Object.fromEntries(Object.entries(B).map(([D,v])=>[D,Object.freeze(Object.fromEntries(v.map(S=>[Q(S),S])))])));function H(D,v){const S=G[D]||{},y=F[D]||{},l={},c={},i={};for(const[n,t]of Object.entries(v||{})){if(Object.hasOwn(S,n)){i[n]=t;continue}if(Object.hasOwn(y,n)){c[n]=t,l[n]=t;continue}l[n]=t}return{config:l,live:c,handlers:i}}function U(D){const v=String(D.viewer),S=D.mount,y=D.name||v;if(typeof S!="function")throw new TypeError(`createViewerController needs a mount factory for "${v}"; pass the module's own factory in, e.g. { createKPI } from lattice-grid/modules/kpi.`);const l=H(v,D.props||{}),c=S(D.element,{...l.config});if(!c||typeof c!="object")throw new TypeError(`the ${y} factory returned no instance; nothing can be driven.`);let i=l.handlers,n=l.config;const t={...l.live},r=[];if(typeof c.on=="function")for(const o of B[v]||[]){const g=Q(o),d=c.on(o,h=>{const a=i[g];typeof a=="function"&&a(h)});typeof d=="function"&&r.push(d)}const s=W[v],f=F[v]||{};let u=!1;return{instance:c,update(o){if(u)return;const g=H(v,o||{});i=g.handlers;const d={};for(const[a,p]of Object.entries(g.config))Object.is(n[a],p)||(d[a]=p);if(n=g.config,!Object.keys(d).length)return;const h=[];for(const a of Object.keys(d)){const p=f[a];if(p){p(c,d[a]),t[a]=d[a];continue}s&&typeof c[s]=="function"||h.push(a)}if(s&&typeof c[s]=="function"){const a={};for(const p of Object.keys(d))f[p]||(a[p]=d[p]);Object.keys(a).length&&c[s](a)}h.length&&L(`react.viewer.${v}.mountOnly.${h.join(".")}`,`${y}: ${h.map(a=>`\`${a}\``).join(", ")} changed, but ${y} takes ${h.length===1?"it":"them"} only when the viewer is created. Nothing was applied and the viewer was NOT rebuilt — rebuilding it silently would throw away scroll position, selection and expansion. Give the component a \`key\` that changes when this must take effect, so the rebuild is yours and visible, or drive the instance through the ref.`)},destroy(){if(!u){u=!0;for(const o of r)try{o()}catch{}r.length=0,typeof c.destroy=="function"&&c.destroy()}}}}}),xe("packages/modules/webcomponent/controller.js",function(e,K){"use strict";Object.defineProperty(e,"EVENT_PREFIX",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"ELEMENT_STYLE_ID",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"ATTRIBUTE_CONFIG",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"observedAttributeNames",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"domEventName",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"coerceAttribute",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"injectElementStyle",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"GridElementController",{enumerable:!0,get:function(){return v}});const X="lattice-",L="lattice-grid-element-styles",B=Object.freeze({theme:"theme",density:"density",locale:"locale","row-key":"rowKey","row-height":"rowHeight","header-height":"headerHeight","auto-height":"autoHeight","filter-row":"filterRow",selection:"selection",rows:"rows",columns:"columns"}),F=new Set(["rowHeight","headerHeight"]),W=new Set(["autoHeight","filterRow"]),Q=new Set(["rows","columns"]);function G(){return Object.keys(B)}function H(S){return X+String(S).replace(/:/g,"-")}function U(S,y){if(W.has(S))return y!==null&&y!=="false";if(y!==null){if(F.has(S)){const l=Number(y);return Number.isFinite(l)?l:void 0}if(Q.has(S))try{return JSON.parse(y)}catch{return}return y}}function D(S){if(!S||!S.createElement||S.getElementById&&S.getElementById(L))return;const y=S.createElement("style");y.setAttribute("id",L),y.appendChild(S.createTextNode(`lattice-grid{display:block}
|
|
58
58
|
`));const l=S.head||S.documentElement||null;l&&l.appendChild(y)}class v{#e;#t;#n=null;#r={};#o=null;#i=!1;#s=!1;constructor(y,l){this.#e=y,this.#t=l.createGrid}get grid(){return!this.#n&&this.#s&&this.settleCreate(),this.#n}get teardownPending(){return this.#i}config(){return{...this.#r}}configure(y){if(!(!y||typeof y!="object"))for(const[l,c]of Object.entries(y))this.#l(l,c)}attributeChanged(y,l){const c=B[y];if(!c)return;const i=U(c,l);i===void 0&&!W.has(c)||this.#l(c,i)}connect(){this.#i=!1,this.#s=!0,!this.#n&&queueMicrotask(()=>this.settleCreate())}settleCreate(){if(!this.#s||this.#n)return;D(this.#e.ownerDocument||null);const y=this.#t(this.#e,{...this.#r});this.#n=y,this.#a(y)}disconnect(){this.#s=!1,this.#n&&(this.#i=!0,queueMicrotask(()=>this.settleTeardown()))}settleTeardown(){this.#i&&(this.#i=!1,this.destroy())}destroy(){this.#o&&(this.#o(),this.#o=null);const y=this.#n;this.#n=null,y&&typeof y.destroy=="function"&&y.destroy()}#l(y,l){this.#r[y]=l,this.#n&&typeof this.#n.set=="function"&&this.#n.set(y,l)}#a(y){!y||typeof y.on!="function"||(this.#o=y.on("*",l=>{const c=this.#e;if(!c||typeof c.dispatchEvent!="function")return;const i={...l};delete i.grid,c.dispatchEvent(this.#u(H(l.type),i))}))}#u(y,l){const c=globalThis.CustomEvent;return typeof c=="function"?new c(y,{detail:l,bubbles:!0,composed:!0}):{type:y,detail:l,bubbles:!0,composed:!0}}}}),xe("packages/modules/webcomponent/styles.js",function(e,K){"use strict";Object.defineProperty(e,"constructableStyleSheets",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"isLatticeStyleNode",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"sheetText",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"latticeStyleNodes",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"latticeStyleSheets",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"adoptLatticeStyles",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"adoptIntoHostRoot",{enumerable:!0,get:function(){return y}});const X=Symbol.for("lattice.webcomponent.styleMirror"),L=/--lattice-|\.lat-/,B=new WeakMap,F=new WeakMap;function W(){const l=globalThis.CSSStyleSheet;if(typeof l!="function")return!1;try{return typeof new l().replaceSync=="function"}catch{return!1}}function Q(l){if(!l||typeof l.getAttribute!="function")return!1;const c=String(l.tagName||"").toLowerCase();if(c!=="style"&&c!=="link"||c==="link"&&!String(l.getAttribute("rel")||"").toLowerCase().split(/\s+/).includes("stylesheet"))return!1;const i=String(l.getAttribute("id")||"");if(i.startsWith("lattice")||i.startsWith("lat-")||l.hasAttribute&&l.hasAttribute("data-lattice"))return!0;if(c==="link"){const n=String(l.getAttribute("href")||"");return/lattice/i.test(n)?!0:L.test(G(l))}return L.test(String(l.textContent||""))}function G(l){if(String(l&&l.tagName||"").toLowerCase()==="style")return String(l.textContent||"");try{const i=l&&l.sheet;if(!i||!i.cssRules)return"";let n="";for(const t of i.cssRules)n+=`${t.cssText}
|
|
59
|
-
`;return n}catch{return""}}function H(l,c){const i=B.get(l);if(i)return i.sheet;const n=G(l);if(!n)return null;const t=c.CSSStyleSheet,r=new t;try{r.replaceSync(n)}catch{return null}r[X]=!0;let s=null;const f=c.MutationObserver;return typeof f=="function"&&String(l.tagName).toLowerCase()==="style"&&(s=new f(()=>{try{r.replaceSync(String(l.textContent||""))}catch{}}),s.observe(l,{childList:!0,characterData:!0,subtree:!0})),B.set(l,{sheet:r,stop:()=>s&&s.disconnect()}),r}function U(l){return l?l.nodeType===9?l:l.ownerDocument||globalThis.document||null:globalThis.document||null}function D(l){const c=l||globalThis.document;return!c||typeof c.querySelectorAll!="function"?[]:[...c.querySelectorAll("style,link[rel]")].filter(Q)}function v(l={}){if(!W())return[];const c=l.document||globalThis.document,i=c&&c.defaultView||globalThis,n=[];for(const t of D(c)){const r=H(t,i);r&&!n.includes(r)&&n.push(r)}return n}function S(l,c={}){const i=()=>{};if(!l||typeof l!="object")return i;const n=c.document||U(l);if(!n)return i;const t=n.defaultView||globalThis;let r=F.get(l);r||(r=new Map,F.set(l,r));const s=[],f=W(),u=a=>{if(r.has(a))return;const p=f?H(a,t):null;if(p){r.set(a,p);const k=l.adoptedStyleSheets||[];k.includes(p)||(l.adoptedStyleSheets=[...k,p]);return}if(String(a.tagName).toLowerCase()!=="link"||typeof l.appendChild!="function")return;const w=n.createElement("link");w.setAttribute("rel","stylesheet"),w.setAttribute("href",a.getAttribute("href")||""),w.setAttribute("data-lattice","adopted"),l.appendChild(w),s.push(w),r.set(a,w)};for(const a of D(n))u(a);let o=null;const g=t.MutationObserver,d=n.head||n.documentElement;typeof g=="function"&&d&&(o=new g(a=>{for(const p of a)for(const w of p.addedNodes||[])Q(w)&&u(w)}),o.observe(d,{childList:!0}));let h=!1;return()=>{if(h)return;h=!0,o&&o.disconnect();const a=l.adoptedStyleSheets||[],p=new Set([...r.values()]);l.adoptedStyleSheets=a.filter(w=>!p.has(w));for(const w of s)w.parentNode&&w.parentNode.removeChild(w);r.clear()}}function y(l){if(!l||typeof l.getRootNode!="function"||typeof l.getAttribute=="function"&&String(l.getAttribute("lattice-styles")||"")==="off")return null;const c=l.getRootNode();return!c||c.nodeType!==11||!c.host?null:S(c)}}),xe("packages/modules/webcomponent/elements.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_GRID_NAME",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"DEFAULT_TAG_PREFIX",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ELEMENT_TAGS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"VIEWER_ALIASES",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"VIEWER_BINDING",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"coerceElementAttribute",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"attributeConfig",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createElementScope",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"scopeFor",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"applyPredicates",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"upgradeProperty",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"installProperty",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"harvestProperties",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"createLatticeKPIElement",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"createLatticeChartElement",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"createLatticeKanbanElement",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"createLatticeGanttElement",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"createLatticeLayoutElement",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"createLatticeTabsElement",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"createLatticeRouterElement",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"createLatticeElements",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(e,"defineLatticeElements",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"gridElementClass",{enumerable:!0,get:function(){return ne}});const L=K("packages/core/src/internal/util.js").warnOnce,F=K("packages/modules/shared/adapter.js").aliasConfigKey,W=K("packages/modules/react/viewers.js"),Q=W.VIEWER_EVENTS,G=W.viewerHandlerName,H=W.createViewerController,U=K("packages/modules/webcomponent/controller.js"),D=U.GridElementController,v=U.observedAttributeNames,S=U.domEventName,y=U.ATTRIBUTE_CONFIG,c=K("packages/modules/webcomponent/styles.js").adoptIntoHostRoot,i="default",n="lattice-",t=Object.freeze({grid:"grid",kpi:"kpi",chart:"chart",kanban:"kanban",gantt:"gantt",layout:"layout",tabs:"tabs",router:"router"}),r=Object.freeze({chart:ie=>{if("data"in ie){const ae=ie.data;delete ie.data,ae!=null&&ie.rows===void 0&&(ie.rows=ae)}if("stacked"in ie){const ae=ie.stacked;delete ie.stacked,ae!=null&&ie.stack===void 0&&(ie.stack=ae)}if("horizontal"in ie){const ae=ie.horizontal;delete ie.horizontal,ae&&ie.type==="bar"&&(ie.type="horizontalBar")}},kanban:ie=>{if(!("titleProperty"in ie))return;const ae=ie.titleProperty;if(delete ie.titleProperty,typeof ae!="string"||!ae)return;const re=ie.card&&typeof ie.card=="object"?ie.card:null;re&&re.title!==void 0||(ie.card={title:ae,...re||{}})},gantt:ie=>{if(!("scale"in ie))return;const ae=ie.scale;if(delete ie.scale,ae==null||ae==="")return;const re=ie.render&&typeof ie.render=="object"?{...ie.render}:{};re.zoom===void 0&&(re.zoom=ae),ie.render=re}}),s=Object.freeze({kpi:Object.freeze({label:"lattice-kpi",requires:Object.freeze([]),fromContext:"grid",properties:Object.freeze(["tiles","rows","columns"]),scalars:Object.freeze(["rowKey","locale"])}),chart:Object.freeze({label:"lattice-chart",requires:Object.freeze(["grid"]),fromContext:"grid",properties:Object.freeze(["shapes","series","data"]),scalars:Object.freeze(["type","x","y","value","label","lon","lat","labels","stacked","horizontal","scheme","subtitle","footnote","tooltip","legend"])}),kanban:Object.freeze({label:"lattice-kanban",requires:Object.freeze([]),fromContext:"grid",properties:Object.freeze(["rows","columns","card"]),scalars:Object.freeze(["rowKey","columnProperty","titleProperty","pointsProperty","orderProperty","swimlaneProperty","sprintProperty","epicProperty","swimlanes","virtualize"])}),gantt:Object.freeze({label:"lattice-gantt",requires:Object.freeze([]),fromContext:null,properties:Object.freeze(["tasks","dependencies","resources","calendar","columns"]),scalars:Object.freeze(["rowKey","scale","projectStart","autoSchedule"])}),layout:Object.freeze({label:"lattice-layout",requires:Object.freeze([]),fromContext:null,properties:Object.freeze(["windows"]),scalars:Object.freeze(["columns","rows","compact","columnWidth","rowHeight","gap","overflowX","overflowY"])}),tabs:Object.freeze({label:"lattice-tabs",requires:Object.freeze([]),fromContext:null,properties:Object.freeze(["tabs"]),scalars:Object.freeze(["lazy"])})}),f=new Set(["grid-name","lattice-styles","name","route","route-options","id","class","style","slot"]),u=new Set(["role","tabindex","hidden","part","exportparts","lang","dir","title-id","is"]),o=Symbol.for("lattice.webcomponent.routerScope"),g=new WeakMap;function d(ie){if(ie==null)return;if(ie===""||ie==="true")return!0;if(ie==="false")return!1;const ae=String(ie).trim();if(ae.startsWith("[")||ae.startsWith("{"))try{return JSON.parse(ae)}catch{return ie}return ae!==""&&Number.isFinite(Number(ae))?Number(ae):ie}function h(ie,ae){const re={},se=ie&&typeof ie.getAttributeNames=="function"?ie.getAttributeNames():[];for(const le of se){if(f.has(le)||u.has(le)||ae&&ae.has(le)||le.startsWith("data-")||le.startsWith("aria-"))continue;const fe=d(ie.getAttribute(le));fe!==void 0&&(re[a(le)]=fe)}return re}function a(ie){const ae=F(ie);return ae!==ie||!ie.includes("-")?ae:ie.replace(/-([a-z0-9])/g,(re,se)=>se.toUpperCase())}function p(ie){return ie&&typeof ie.getAttributeNames=="function"?ie.getAttributeNames():[]}function w(ie){const ae=[];for(const re of p(ie))f.has(re)||u.has(re)||re.startsWith("data-")||re.startsWith("aria-")||ae.push(a(re));return ae}function k(){const ie=new Map,ae=new Set;return{publish(re,se){const le=re||i;se?ie.set(le,se):ie.delete(le);for(const fe of[...ae])fe()},get(re){return ie.get(re||i)||null},names(){return[...ie.keys()]},subscribe(re){return ae.add(re),()=>{ae.delete(re)}}}}function m(ie={}){const ae=typeof ie.createDataRouter=="function"?ie.createDataRouter:null;let re=null,se=!1;return{grids:k(),get router(){return re},attach(fe,be,Le){se||!ae||(re||(re=ae(ie.config||{})),re.attach(fe,be,Le||{}))},detach(fe){if(!(se||!re))try{re.detach(fe)}catch{}},destroy(){se=!0;const fe=re;re=null,fe&&fe.destroy()}}}function b(ie){let ae=ie&&ie.parentNode||null;for(;ae;){if(ae[o])return ae[o];ae=ae.parentNode||ae.host||null}const se=(ie&&typeof ie.getRootNode=="function"?ie.getRootNode():ie&&ie.ownerDocument||null)||globalThis.document||globalThis;let le=g.get(se);return le||(le=m(),g.set(se,le)),le}function C(ie,ae,re){const se=ae&&typeof ae=="object"?ae:{},le=re&&typeof re=="object"?re:{};for(const[fe,be]of Object.entries(se))Object.is(le[fe],be)||ie.filters.where(fe,typeof be=="function"?be:null);for(const fe of Object.keys(le))Object.hasOwn(se,fe)||ie.filters.where(fe,null)}function M(ie,ae){if(!Object.hasOwn(ie,ae))return;const re=ie[ae];delete ie[ae],ie[ae]=re}const P=new Set(["instance","config","grid","gridName","router"]);function x(ie,ae){let re=Object.getPrototypeOf(ie);for(;re;){const se=Object.getOwnPropertyDescriptor(re,ae);if(se)return typeof se.get=="function";re=Object.getPrototypeOf(re)}return!1}function E(ie,ae){if(!ae||P.has(ae)||ae.startsWith("__"))return;const re=Object.getOwnPropertyDescriptor(ie,ae);if(re&&typeof re.get=="function")return;if(x(ie,ae)){re&&M(ie,ae);return}const se=re?re.value:void 0;re&&delete ie[ae],Object.defineProperty(ie,ae,{get(){return this.__props[ae]},set(le){this.__write(ae,le)},configurable:!0,enumerable:!0}),re&&(ie[ae]=se)}function A(ie){let ae=!1;for(const re of Object.getOwnPropertyNames(ie)){if(re.startsWith("__")||P.has(re))continue;const se=Object.getOwnPropertyDescriptor(ie,re);!se||typeof se.get=="function"||!se.enumerable||(E(ie,re),ae=!0)}return ae}function j(ie,ae,re){if(!ie||typeof ie.dispatchEvent!="function")return;const se=globalThis.CustomEvent,le={detail:re,bubbles:!0,composed:!0};ie.dispatchEvent(typeof se=="function"?new se(ae,le):{type:ae,...le})}function $(ie){const ae=ie.viewer,re=s[ae],se=ie.label||re.label,le=ie.mount,fe=Q[ae]||[];class be extends ie.Base{__props={};__controller=null;__builtAgainst=null;__connected=!1;__teardownPending=!1;__release=[];__queued=!1;__wired=!1;__scope=null;__ownAttributes=new Set;constructor(){super();for(const we of["config","grid","gridName",...re.properties,...re.scalars])M(this,we);A(this)}get instance(){return this.__controller?this.__controller.instance:null}get grid(){return this.__props.grid}set grid(we){this.__write("grid",we)}get gridName(){const we=this.__props.gridName;if(typeof we=="string")return we;const Re=typeof this.getAttribute=="function"?this.getAttribute("grid-name"):null;return Re===null?void 0:Re}set gridName(we){this.__write("gridName",we)}get config(){return{...this.__props}}set config(we){if(!(!we||typeof we!="object")){for(const[Re,ge]of Object.entries(we))this.__props[Re]=ge;this.__schedule()}}connectedCallback(){if(this.__teardownPending=!1,!this.__connected){if(this.__connected=!0,!this.__wired){this.__wired=!0;const we=c(this);we&&this.__release.push(we);const Re=b(this);this.__scope=Re,re.fromContext&&this.__release.push(Re.grids.subscribe(()=>this.__settle()));const ge=globalThis.MutationObserver;if(typeof ge=="function"){const he=new ge(()=>this.__settle());he.observe(this,{attributes:!0}),this.__release.push(()=>he.disconnect())}}A(this);for(const we of w(this))E(this,we);this.__schedule()}}disconnectedCallback(){this.__connected&&(this.__connected=!1,this.__teardownPending=!0,queueMicrotask(()=>this.__settleTeardown()))}__settleTeardown(){if(this.__teardownPending){this.__teardownPending=!1,this.__wired=!1,this.__scope=null;for(const we of this.__release.splice(0))try{we()}catch{}this.__tearDown()}}__write(we,Re){this.__props[we]=Re,this.__schedule()}__schedule(){this.__queued||(this.__queued=!0,queueMicrotask(()=>{this.__queued=!1,this.__settle()}))}__boundGrid(){if(!re.fromContext)return null;if(this.__props.grid!==void 0)return this.__props.grid||null;const we=this.__scope;return we?we.grids.get(this.gridName):null}__resolve(){const we={...h(this,this.__ownAttributes),...this.__props};if(delete we.gridName,re.fromContext){const ge=this.__boundGrid();ge?we[re.fromContext]=ge:delete we[re.fromContext]}const Re=r[ae];Re&&Re(we);for(const ge of fe)we[G(ge)]=he=>j(this,S(ge),he);return we}__settle(){if(!this.__connected)return;A(this);const we=this.__resolve(),Re=re.fromContext&&we[re.fromContext]||null;if(this.__controller&&!Object.is(this.__builtAgainst,Re)&&this.__tearDown(),!this.__controller){for(const he of re.requires)if(we[he]===void 0||we[he]===null)return;if(re.fromContext&&!Re&&we.rows===void 0)return;const ge=new Set(p(this));this.__controller=H({viewer:ae,mount:le,element:this,props:we,name:se});for(const he of p(this))ge.has(he)||this.__ownAttributes.add(he);this.__builtAgainst=Re,j(this,"ready",{instance:this.__controller.instance});return}this.__controller.update(we)}__tearDown(){const we=this.__controller;this.__controller=null,this.__builtAgainst=null,we&&(j(this,"destroyed",{instance:we.instance}),we.destroy())}}for(const Le of[...re.properties,...re.scalars])Le in ie.Base.prototype||Object.defineProperty(be.prototype,Le,{get(){return this.__props[Le]},set(we){this.__write(Le,we)},configurable:!0,enumerable:!0});return be}function z(ie,ae,re){if(typeof ie!="function")throw new TypeError(`${ae} needs ${re}: ${ae}({ ${re} }).`)}function T(){const ie=globalThis.HTMLElement;return typeof ie=="function"?ie:null}function R(ie){z(ie&&ie.createKPI,"createLatticeKPIElement","createKPI");const ae=T();return ae?$({viewer:"kpi",Base:ae,mount:(re,se)=>ie.createKPI(re,se)}):null}function O(ie){z(ie&&ie.createChart,"createLatticeChartElement","createChart");const ae=T();return ae?$({viewer:"chart",Base:ae,mount:(re,se)=>ie.createChart({...se,container:re})}):null}function I(ie){z(ie&&ie.createKanban,"createLatticeKanbanElement","createKanban");const ae=T();return ae?$({viewer:"kanban",Base:ae,mount:(re,se)=>ie.createKanban(re,se)}):null}function q(ie){z(ie&&ie.createGantt,"createLatticeGanttElement","createGantt");const ae=T();return ae?$({viewer:"gantt",Base:ae,mount:(re,se)=>ie.createGantt({...se,element:re})}):null}function Z(ie){z(ie&&ie.createLayout,"createLatticeLayoutElement","createLayout");const ae=T();return ae?$({viewer:"layout",Base:ae,mount:(re,se)=>ie.createLayout(re,se)}):null}function _(ie){z(ie&&ie.createTabs,"createLatticeTabsElement","createTabs");const ae=T();return ae?$({viewer:"tabs",Base:ae,mount:(se,le)=>{const fe=new Map,be=typeof se.querySelectorAll=="function"?[...se.querySelectorAll("template[data-tab]")]:[];for(const Re of be)Re.parentNode===se&&fe.set(Re.getAttribute("data-tab"),Re);const we=(Array.isArray(le.tabs)&&le.tabs.length?le.tabs:[...fe.keys()].map(Re=>({id:Re,label:fe.get(Re).getAttribute("data-label")||Re}))).map(Re=>{const ge=Re,he=fe.get(ge.id);return he?{...ge,view:Oe=>{const Ee=he.content.cloneNode(!0),Ie=[...Ee.childNodes];return Oe.appendChild(Ee),{destroy(){for(const ze of Ie)ze.parentNode&&ze.parentNode.removeChild(ze)}}}}:ge});return ie.createTabs(se,{...le,tabs:we,createGrid:ie.createGrid||(()=>{throw new Error('[lattice] <lattice-tabs>: a tab has neither a <template data-tab="…"> nor a createGrid to build it with. Give the tab a template, or pass createGrid into createLatticeTabsElement.')})})}}):null}function J(ie){z(ie&&ie.createDataRouter,"createLatticeRouterElement","createDataRouter");const ae=T();if(!ae)return null;class re extends ae{__scope=null;__config={};constructor(){super(),M(this,"config")}get config(){return{...this.__config}}set config(le){!le||typeof le!="object"||(this.__config={...this.__config,...le},this.__scope&&this.__scope.router&&L("webcomponent.router.mountOnly.config","[lattice] <lattice-router>: `config` changed after the router was built. Nothing was applied and the router was NOT rebuilt — rebuilding it would detach every grid and drop every row it holds. Replace the <lattice-router> element itself when a genuinely different router is wanted."))}get router(){return this.__scope?this.__scope.router:null}get instance(){return this.router}connectedCallback(){if(this.__scope)return;const le=h(this);this.__scope=m({createDataRouter:ie.createDataRouter,config:{...le,...this.__config}}),this[o]=this.__scope}disconnectedCallback(){const le=this.__scope;if(this.__scope=null,this[o]=null,!le)return;const fe=le.router;le.destroy(),fe&&j(this,"destroyed",{instance:fe})}}return re}function ee(ie={}){const ae={},re=(se,le,fe)=>{if(typeof le!="function")return;const be=fe();be&&(ae[se]=be)};return re("LatticeGridElement",ie.createGrid,()=>ne(ie.createGrid)),re("LatticeKPIElement",ie.createKPI,()=>R({createKPI:ie.createKPI})),re("LatticeChartElement",ie.createChart,()=>O({createChart:ie.createChart})),re("LatticeKanbanElement",ie.createKanban,()=>I({createKanban:ie.createKanban})),re("LatticeGanttElement",ie.createGantt,()=>q({createGantt:ie.createGantt})),re("LatticeLayoutElement",ie.createLayout,()=>Z({createLayout:ie.createLayout})),re("LatticeTabsElement",ie.createTabs,()=>_({createTabs:ie.createTabs,createGrid:ie.createGrid})),re("LatticeRouterElement",ie.createDataRouter,()=>J({createDataRouter:ie.createDataRouter})),ae}function te(ie={}){const ae=globalThis.customElements,re={};if(!ae||typeof ae.define!="function")return re;const se=typeof ie.prefix=="string"?ie.prefix:n,le=ee(ie),fe={LatticeGridElement:t.grid,LatticeKPIElement:t.kpi,LatticeChartElement:t.chart,LatticeKanbanElement:t.kanban,LatticeGanttElement:t.gantt,LatticeLayoutElement:t.layout,LatticeTabsElement:t.tabs,LatticeRouterElement:t.router};for(const[be,Le]of Object.entries(le)){const we=se+fe[be],Re=ae.get?ae.get(we):void 0;if(Re){re[we]=Re;continue}ae.define(we,Le),re[we]=Le}return re}function ne(ie){const ae=T();if(!ae)return null;class re extends ae{static get observedAttributes(){return v()}__connected=!1;__teardownPending=!1;__published=!1;__publishedAs=i;__scope=null;__predicates=void 0;__rowUpdates=void 0;__release=[];constructor(){super(),this.__controller=new D(this,{createGrid:ie});for(const le of["rows","columns","config","predicates","rowUpdates",...Object.values(y)])M(this,le)}get grid(){return this.__controller.grid}get instance(){return this.__controller.grid}get rows(){return this.__controller.config().rows}set rows(le){this.__controller.configure({rows:le})}get columns(){return this.__controller.config().columns}set columns(le){this.__controller.configure({columns:le})}get config(){return this.__controller.config()}set config(le){this.__controller.configure(le)}get predicates(){return this.__predicates}set predicates(le){const fe=this.__published?this.__controller.grid:null;fe&&C(fe,le,this.__predicates),this.__predicates=le}get rowUpdates(){return this.__rowUpdates}set rowUpdates(le){if(Object.is(le,this.__rowUpdates))return;this.__rowUpdates=le;const fe=this.__published?this.__controller.grid:null;fe&&le&&fe.rows.apply(le)}connectedCallback(){if(this.__teardownPending=!1,!this.__connected){if(this.__connected=!0,!this.__scope){const le=c(this);le&&this.__release.push(le),this.__scope=b(this)}this.__controller.connect(),queueMicrotask(()=>this.__publish())}}disconnectedCallback(){this.__connected&&(this.__connected=!1,this.__teardownPending=!0,queueMicrotask(()=>this.__settleTeardown()),this.__controller.disconnect())}attributeChangedCallback(le,fe,be){this.__controller.attributeChanged(le,be)}__publish(){if(!this.__connected||this.__published)return;const le=this.__controller.grid;if(!le)return;this.__published=!0,this.__predicates&&C(le,this.__predicates,{});const fe=typeof this.getAttribute=="function"?this.getAttribute("name"):null;this.__publishedAs=fe||i;const be=this.__scope;be&&be.grids.publish(this.__publishedAs,le);const Le=typeof this.getAttribute=="function"?this.getAttribute("route"):null;if(be&&Le!==null){const we=this.getAttribute("route-options");be.attach(le,d(Le),we===null?{}:d(we))}this.__rowUpdates&&le.rows.apply(this.__rowUpdates),j(this,"grid-ready",{grid:le})}__settleTeardown(){if(!this.__teardownPending)return;this.__teardownPending=!1;const le=this.__controller.grid,fe=this.__scope;this.__scope=null,this.__published=!1;for(const be of this.__release.splice(0))try{be()}catch{}le&&fe&&(j(this,"grid-destroyed",{grid:le}),fe.detach(le),fe.grids.publish(this.__publishedAs,null)),this.__controller.settleTeardown()}}for(const se of Object.values(y))Object.getOwnPropertyDescriptor(re.prototype,se)||se in ae.prototype||Object.defineProperty(re.prototype,se,{get(){return this.__controller.config()[se]},set(le){this.__controller.configure({[se]:le})},configurable:!0,enumerable:!0});return re}}),xe("packages/modules/webcomponent/index.js",function(e,K){"use strict";Object.defineProperty(e,"TAG_NAME",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createLatticeGridElement",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"defineLatticeGrid",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const X=K("packages/dom/src/index.js"),L=X.createGrid,B=K("packages/modules/webcomponent/elements.js"),F=B.gridElementClass,W=K("packages/modules/webcomponent/controller.js");Object.defineProperty(e,"GridElementController",{enumerable:!0,get:function(){return W.GridElementController}}),Object.defineProperty(e,"observedAttributeNames",{enumerable:!0,get:function(){return W.observedAttributeNames}}),Object.defineProperty(e,"domEventName",{enumerable:!0,get:function(){return W.domEventName}}),Object.defineProperty(e,"ATTRIBUTE_CONFIG",{enumerable:!0,get:function(){return W.ATTRIBUTE_CONFIG}}),Object.defineProperty(e,"EVENT_PREFIX",{enumerable:!0,get:function(){return W.EVENT_PREFIX}}),Object.defineProperty(e,"createLatticeElements",{enumerable:!0,get:function(){return B.createLatticeElements}}),Object.defineProperty(e,"defineLatticeElements",{enumerable:!0,get:function(){return B.defineLatticeElements}}),Object.defineProperty(e,"ELEMENT_TAGS",{enumerable:!0,get:function(){return B.ELEMENT_TAGS}}),Object.defineProperty(e,"createLatticeKPIElement",{enumerable:!0,get:function(){return B.createLatticeKPIElement}}),Object.defineProperty(e,"createLatticeChartElement",{enumerable:!0,get:function(){return B.createLatticeChartElement}}),Object.defineProperty(e,"createLatticeKanbanElement",{enumerable:!0,get:function(){return B.createLatticeKanbanElement}}),Object.defineProperty(e,"createLatticeGanttElement",{enumerable:!0,get:function(){return B.createLatticeGanttElement}}),Object.defineProperty(e,"createLatticeLayoutElement",{enumerable:!0,get:function(){return B.createLatticeLayoutElement}}),Object.defineProperty(e,"createLatticeTabsElement",{enumerable:!0,get:function(){return B.createLatticeTabsElement}}),Object.defineProperty(e,"createLatticeRouterElement",{enumerable:!0,get:function(){return B.createLatticeRouterElement}});const Q=K("packages/modules/webcomponent/styles.js");Object.defineProperty(e,"adoptLatticeStyles",{enumerable:!0,get:function(){return Q.adoptLatticeStyles}}),Object.defineProperty(e,"latticeStyleSheets",{enumerable:!0,get:function(){return Q.latticeStyleSheets}});const G=K("packages/modules/react/viewers.js");Object.defineProperty(e,"VIEWER_EVENTS",{enumerable:!0,get:function(){return G.VIEWER_EVENTS}}),Object.defineProperty(e,"VIEWER_APPLY",{enumerable:!0,get:function(){return G.VIEWER_APPLY}}),Object.defineProperty(e,"viewerHandlerName",{enumerable:!0,get:function(){return G.viewerHandlerName}}),Object.defineProperty(e,"createViewerController",{enumerable:!0,get:function(){return G.createViewerController}});const H=K("packages/modules/shared/adapter.js");Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return H.EVENT_NAMES}}),Object.defineProperty(e,"dashedName",{enumerable:!0,get:function(){return H.dashedName}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return X.createCurrencyType}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return X.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return X.registerUnitSystem}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return X.createStat}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return X.createHeadlessGrid}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return X.duckdbAdapter}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return X.createPushdownSource}});const U="lattice-grid";function D(y=L){return F(y)}function v(y={}){const l=globalThis.customElements,c=y.tagName||U;if(!l||typeof l.define!="function")return null;const i=l.get?l.get(c):void 0;if(i)return i;const n=D(y.createGrid||L);return n?(l.define(c,n),n):null}v();const S=v});try{Gn("packages/worker/src/inline.js").setWorkerSource('(function(yt){"use strict";var nt=Object.create(null),rt=Object.create(null);function Se(o,me){nt[o]=me}function it(o){var me=rt[o];if(me)return me;var fe=Object.create(null);rt[o]=fe;var he=nt[o];if(!he)throw new Error("[lattice] missing module: "+o);return he(fe,it),fe}Se("packages/core/src/internal/util.js",function(o,me){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return a}}),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 h}}),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 M}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return oe}});const fe="1.80.0";async function he(){return fe}const Q="1.80.0",z=new Set,ne=2e3;function _(w){if(z.add(w),z.size>ne){const v=z.values().next().value;v!==void 0&&z.delete(v)}}const T=[],K=500;function ie(w,v,Z){T.push({key:w,level:v,message:Z.map(x=>typeof x=="string"?x:J(x)).join(" "),at:Date.now()}),T.length>K&&T.shift()}function J(w){if(w instanceof Error)return w.message;try{return JSON.stringify(w)}catch{return String(w)}}function le(){return T.map(w=>({...w}))}function ue(w){if(w.length===0||typeof w[0]!="string")return w;const v=w[0].replace(/^\\[lattice\\]\\s*/,"");return v===w[0]?w:[v,...w.slice(1)]}function W(w,...v){if(z.has(w))return;_(w);const Z=ue(v);ie(w,"warn",Z),console.warn("[lattice]",...Z)}function L(w,...v){if(z.has(w))return;_(w);const Z=ue(v);ie(w,"info",Z),console.info("[lattice]",...Z)}function Y(){z.clear(),T.length=0}function ee(w,v){const Z=new Error(`[lattice] ${w}`);throw v!==void 0&&(Z.cause=v),Z}function C(w,v){w||ee(v)}const A=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function i(w){return w!==null&&typeof w=="object"&&!Array.isArray(w)}function s(w){return typeof w=="function"}function u(w){return w==null}function f(w){return w==null||w===""}function l(w){return typeof w!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(w))?!0:!!(w.prototype&&Object.getOwnPropertyNames(w.prototype).length>1)}const t=new Map;function a(w){let v=t.get(w);if(v)return v;if(!w.includes("."))v=Z=>Z?.[w];else{const Z=w.split("."),x=Z.length;v=de=>{let we=de;for(let ge=0;ge<x;ge++){if(we==null)return;we=we[Z[ge]]}return we}}return t.set(w,v),v}const m=new Map;function e(w){let v=m.get(w);if(v)return v;if(!w.includes("."))v=(Z,x)=>{Z!=null&&(Z[w]=x)};else{const Z=w.split("."),x=Z.length-1;v=(de,we)=>{let ge=de;for(let pe=0;pe<x;pe++){if(ge==null)return;const Te=Z[pe];ge[Te]==null&&(ge[Te]={}),ge=ge[Te]}ge!=null&&(ge[Z[x]]=we)}}return m.set(w,v),v}function d(w,v){return a(v)(w)}function h(w,v,Z){e(v)(w,Z)}function r(w){return w?(w.includes(".")?w.slice(w.lastIndexOf(".")+1):w).replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/\\s+/g," ").trim().replace(/^./,Z=>Z.toUpperCase()):""}const n={"&":"&","<":"<",">":">",\'"\':""","\'":"'"};function c(w){const v=w==null?"":String(w);return/[&<>"\']/.test(v)?v.replace(/[&<>"\']/g,Z=>n[Z]):v}function g(w){return String(w).replace(/\\w\\S*/g,v=>v[0].toUpperCase()+v.slice(1).toLowerCase())}function M(w,v,Z){if(w!==void 0)return w===!0?{enabled:!0,...Z}:w===!1?{enabled:!1}:i(w)?w:{[v]:w,enabled:!0}}function N(w){return w==null?[]:Array.isArray(w)?w:[w]}const G=Object.freeze(new Set(["__proto__","constructor","prototype"]));function F(w,v){if(!i(w))return i(v)?{...v}:v;if(!i(v))return v===void 0?w:v;const Z={...w};for(const x of Object.keys(v)){if(G.has(x))continue;const de=v[x];de!==void 0&&(Z[x]=i(de)&&i(Z[x])?F(Z[x],de):de)}return Z}function R(w,v){if(!i(w)||!i(v)||w===v)return v;const Z=Object.create(Object.getPrototypeOf(w));return Object.assign(Z,w,v),Z}class X{#t;#e=new Map;#n;constructor(v=256,Z=null){this.#t=v,this.#n=Z}get size(){return this.#e.size}get max(){return this.#t}set max(v){this.#t=v,this.#r()}has(v){return this.#e.has(v)}get(v){const Z=this.#e;if(!Z.has(v))return;const x=Z.get(v);return Z.delete(v),Z.set(v,x),x}peek(v){return this.#e.get(v)}set(v,Z){const x=this.#e;return x.has(v)&&x.delete(v),x.set(v,Z),this.#r(),Z}delete(v){const Z=this.#e.get(v);return this.#e.delete(v)&&this.#n&&this.#n(Z,v),Z}clear(){if(this.#n)for(const[v,Z]of this.#e)this.#n(Z,v);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const v=this.#e;for(;v.size>this.#t;){const Z=v.keys().next().value,x=v.get(Z);v.delete(Z),this.#n&&this.#n(x,Z)}}}const E=new Map;function S(w,v){const Z=`${w||""}|${v?JSON.stringify(v):""}`;let x=E.get(Z);return x||(x=new Intl.Collator(w||void 0,{numeric:!0,sensitivity:"variant",...v}),E.set(Z,x)),x}function U(w,v){if(w===v)return 0;if(w==null)return 1;if(v==null)return-1;if(typeof w=="number"&&typeof v=="number")return Number.isNaN(w)?Number.isNaN(v)?0:1:Number.isNaN(v)||w<v?-1:w>v?1:0;const Z=String(w),x=String(v);return Z<x?-1:Z>x?1:0}function H(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const $=typeof requestAnimationFrame=="function";function re(w){return $?requestAnimationFrame(w):setTimeout(()=>w(H()),16)}function te(w){w!=null&&($?cancelAnimationFrame(w):clearTimeout(w))}function ae(w){let v=null,Z=null;const x=()=>{v=null;const we=Z;Z=null,w(...we||[])},de=(...we)=>{Z=we,v===null&&(v=re(x))};return de.cancel=()=>{te(v),v=null,Z=null},de.flush=()=>{v!==null&&(te(v),x())},de}function p(w,v){let Z=null,x=null;const de=()=>{if(Z=null,x===null)return;const pe=x;x=null,w(...pe),we()},we=()=>{Z=setTimeout(de,v),typeof Z?.unref=="function"&&Z.unref()},ge=(...pe)=>{Z===null?(w(...pe),we()):(x=pe,clearTimeout(Z),we())};return ge.flush=()=>{if(Z!==null&&clearTimeout(Z),Z=null,x===null)return;const pe=x;x=null,w(...pe)},ge.cancel=()=>{Z!==null&&clearTimeout(Z),Z=null,x=null},ge.pending=()=>Z!==null||x!==null,ge}function B(w,v=50){return typeof requestIdleCallback=="function"?requestIdleCallback(w,{timeout:v}):setTimeout(()=>w({timeRemaining:()=>0,didTimeout:!0}),1)}let q=0;function oe(w="l"){return`${w}${(++q).toString(36)}`}}),Se("packages/worker/src/transport.js",function(o,me){"use strict";Object.defineProperty(o,"PROTOCOL",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"OPS",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"ERRORS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"packHandle",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"packHandles",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"TransportedDictionary",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,Q=fe.isFunction,z=1,ne=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"}),_=Object.freeze({READY:"ready",CANCEL:"cancel",PING:"ping"}),T=Object.freeze({NO_COMPUTE:"E_NO_COMPUTE",NO_KERNEL:"E_NO_KERNEL",ABORTED:"E_ABORTED",KERNEL:"E_KERNEL",PROTOCOL:"E_PROTOCOL"});function K(s){if(s==null)return null;const u=s.presence;return{id:s.id,kind:s.kind,nullable:!!s.nullable,values:s.values??null,presence:u?u.words??u:null,presenceBits:u?u.size??(u.words??u).length*8:0,dict:s.dict?ie(s.dict):null,offsets:s.offsets??null,version:s.version??0}}function ie(s){return Array.isArray(s)?s:Q(s.values)?s.values():[]}function J(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=K(s[f]);return u}class le{#t;#e;constructor(u,f){this.#t=u,this.#e=f}get words(){return this.#t}get size(){return this.#e}get(u){return(this.#t[u>>>3]&1<<(u&7))!==0}count(){const u=this.#t;let f=0;for(let l=0;l<u.length;l++){let t=u[l];for(;t;)t&=t-1,f++}return f}}class ue{#t;#e=null;#n=0;#r=new Map;constructor(u){this.#t=u||[]}get size(){return this.#t.length}get version(){return this.#n}codeOf(u){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 f=this.#e.get(u);if(f!==void 0)return f;const l=this.#t.length;return this.#t.push(u),this.#e.set(u,l),this.#n++,l}valueOf(u){return this.#t[u]}values(){return this.#t}ranks(u){const f=u||"",l=this.#r.get(f);if(l&&l.version===this.#n)return l.ranks;const t=this.#t.length,a=new Uint32Array(t);for(let r=0;r<t;r++)a[r]=r;const m=he(u).compare,e=this.#t,d=Array.from(a).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))}),h=new Uint32Array(t);for(let r=0;r<d.length;r++)h[d[r]]=r;return this.#r.set(f,{version:this.#n,ranks:h}),h}}function W(s){if(s==null)return null;const u=s.presence?new le(s.presence,s.presenceBits||s.presence.length*8):null,f=s.dict?new ue(s.dict):null,l=s.values,t=s.offsets??null,a=s.kind,m=e=>{if(u&&!u.get(e))return null;switch(a){case"dictionary":return f?f.valueOf(l[e]):l[e];case"bitset":return(l[e>>>3]&1<<(e&7))!==0;case"multi":{if(!t)return null;const d=t[e],h=t[e+1],r=new Array(h-d);for(let n=d;n<h;n++)r[n-d]=f?f.valueOf(l[n]):l[n];return r}default:return l[e]}};return{id:s.id,kind:a,nullable:s.nullable,values:l,presence:u,dict:f,offsets:t,get:m,version:s.version}}function L(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=W(s[f]);return u}function Y(){const s=[],u=[];return{mask(f){for(let l=0;l<s.length;l++)if(s[l].length>=f){const t=s.splice(l,1)[0].subarray(0,f);return t.fill(0),t}return new Uint8Array(f)},indices(f){for(let l=0;l<u.length;l++)if(u[l].length>=f)return u.splice(l,1)[0].subarray(0,f);return new Uint32Array(f)},release(f){f&&(f instanceof Uint8Array?s.push(f):f instanceof Uint32Array&&u.push(f))},clear(){s.length=0,u.length=0}}}function ee(s){if(!ArrayBuffer.isView(s))return!1;const u=s.buffer;return u?typeof SharedArrayBuffer>"u"||!(u instanceof SharedArrayBuffer):!1}function C(s,u=[]){const f=l=>{if(!ee(l))return;const t=l.buffer;u.includes(t)||u.push(t)};if(s==null)return u;if(ArrayBuffer.isView(s))return f(s),u;if(Array.isArray(s)){for(const l of s)f(l);return u}if(typeof s=="object")for(const l of Object.keys(s)){const t=s[l];if(Array.isArray(t))for(const a of t)f(a);else f(t)}return u}function A(s,u=0){if(s==null)return!0;const f=typeof s;if(f==="function"||f==="symbol")return!1;if(f!=="object"||u>4||ArrayBuffer.isView(s)||s instanceof ArrayBuffer||s instanceof Date)return!0;if(Array.isArray(s)){for(const l of s)if(!A(l,u+1))return!1;return!0}for(const l of Object.keys(s))if(!A(s[l],u+1))return!1;return!0}function i(s,u=new Set){if(!s||typeof s!="object")return u;const f=s;typeof f.col=="string"&&u.add(f.col);const l=f.conditions;if(Array.isArray(l))for(const t of l)i(t,u);return u}}),Se("packages/core/src/store/bitset.js",function(o,me){"use strict";Object.defineProperty(o,"Bitset",{enumerable:!0,get:function(){return he}});const fe=8;class he{static#t=new Uint8Array(256);static{for(let z=1;z<256;z++)he.#t[z]=he.#t[z>>1]+(z&1)}#e;#n;constructor(z=0){const ne=Math.max(0,z|0);this.#n=ne,this.#e=new Uint8Array(Math.ceil(ne/fe))}get size(){return this.#n}get words(){return this.#e}get bytes(){return this.#e?this.#e.byteLength:0}get(z){return z<0||z>=this.#n?0:this.#e[z>>3]>>(z&7)&1}set(z){return z>=0&&z<this.#n&&(this.#e[z>>3]|=1<<(z&7)),this}clear(z){return z>=0&&z<this.#n&&(this.#e[z>>3]&=~(1<<(z&7))),this}assign(z,ne){return ne?this.set(z):this.clear(z)}fill(z=!1){return this.#e.fill(z?255:0),z&&this.#r(),this}grow(z){const ne=Math.max(0,z|0);if(ne<=this.#n)return this;const _=Math.ceil(ne/fe);if(_>this.#e.length){const T=new Uint8Array(_);T.set(this.#e),this.#e=T}return this.#n=ne,this}count(){const z=this.#e,ne=he.#t;let _=0;for(let T=0;T<z.length;T++)_+=ne[z[T]];return _}and(z){const ne=z instanceof he?z.words:z,_=this.#e,T=Math.min(_.length,ne.length);for(let K=0;K<T;K++)_[K]&=ne[K];for(let K=T;K<_.length;K++)_[K]=0;return this}or(z){const ne=z instanceof he?z.words:z,_=this.#e,T=Math.min(_.length,ne.length);for(let K=0;K<T;K++)_[K]|=ne[K];return this}not(){const z=this.#e;for(let ne=0;ne<z.length;ne++)z[ne]=~z[ne]&255;return this.#r(),this}clone(){const z=new he(this.#n);return z.words.set(this.#e.subarray(0,z.words.length)),z}release(){this.#e=new Uint8Array(0),this.#n=0}#r(){const z=this.#n&7;if(z===0)return;const ne=this.#n>>3;ne<this.#e.length&&(this.#e[ne]&=(1<<z)-1)}static from(z){const ne=Array.isArray(z)?z:Array.from(z),_=new he(ne.length);for(let T=0;T<ne.length;T++)ne[T]&&_.set(T);return _}}}),Se("packages/core/src/store/dictionary.js",function(o,me){"use strict";Object.defineProperty(o,"Dictionary",{enumerable:!0,get:function(){return z}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,Q=fe.defaultCompare;class z{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(_=[]){this.#t=[];for(let T=0;T<_.length;T++){const K=_[T];this.#e.has(K)||(this.#e.set(K,this.#t.length),this.#t.push(K))}}get size(){return this.#t.length}get version(){return this.#n}get bytes(){let _=this.#t.length*8;for(let T=0;T<this.#t.length;T++){const K=this.#t[T];typeof K=="string"&&(_+=K.length*2),_+=16}return _}codeOf(_){const T=this.#e.get(_);if(T!==void 0)return T;const K=this.#t.length;return this.#t.push(_),this.#e.set(_,K),this.#n++,K}lookup(_){const T=this.#e.get(_);return T===void 0?-1:T}has(_){return this.#e.has(_)}valueOf(_){return this.#t[_]}values(){return this.#t}ranks(_){const T=_||"";if(this.#r&&this.#i===this.#n&&this.#s===T)return this.#r;const K=this.#t.length,ie=new Array(K);for(let W=0;W<K;W++)ie[W]=W;const J=he(_).compare,le=this.#t;ie.sort((W,L)=>this.#h(le[W],le[L],J));const ue=new Uint32Array(K);for(let W=0;W<K;W++)ue[ie[W]]=W;return this.#r=ue,this.#i=this.#n,this.#s=T,ue}#h(_,T,K){return typeof _=="string"&&typeof T=="string"?K(_,T):Q(_,T)}}}),Se("packages/core/src/store/multivalue.js",function(o,me){"use strict";Object.defineProperty(o,"MultiValue",{enumerable:!0,get:function(){return fe}});class fe{#t;#e;#n=0;#r=0;constructor(Q={}){const z=Math.max(1,Q.rows??16),ne=Math.max(1,Q.values??z);this.#t=new Int32Array(ne),this.#e=new Uint32Array(z+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(Q){return Q<0||Q>=this.#n?0:this.#e[Q+1]-this.#e[Q]}at(Q){return Q<0||Q>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[Q],this.#e[Q+1])}has(Q,z){if(Q<0||Q>=this.#n)return!1;const ne=this.#t,_=this.#e[Q+1];for(let T=this.#e[Q];T<_;T++)if(ne[T]===z)return!0;return!1}hasAny(Q,z){for(let ne=0;ne<z.length;ne++)if(this.has(Q,z[ne]))return!0;return!1}hasAll(Q,z){for(let ne=0;ne<z.length;ne++)if(!this.has(Q,z[ne]))return!1;return!0}hasNone(Q,z){return!this.hasAny(Q,z)}push(Q){const z=this.#n,ne=Q.length;this.#i(z+1),this.#s(this.#r+ne);const _=this.#r;for(let T=0;T<ne;T++)this.#t[_+T]=Q[T]|0;return this.#r+=ne,this.#n=z+1,this.#e[z]=_,this.#e[z+1]=this.#r,z}write(Q,z){if(Q===this.#n){this.push(z);return}if(Q<0||Q>this.#n)return;const ne=this.#e[Q],_=this.#e[Q+1],T=z.length;if(_-ne===T){for(let K=0;K<T;K++)this.#t[ne+K]=z[K]|0;return}this.#h(Q,z)}compact(Q,z,ne){const _=this.#t,T=this.#e,K=this.#n,ie=new Int32Array(Math.max(1,this.#r)),J=new Uint32Array(z+1);let le=0;for(let ue=0;ue<K;ue++){if(Q[ue]===ne)continue;const W=T[ue],L=T[ue+1];J[Q[ue]]=le;for(let Y=W;Y<L;Y++)ie[le++]=_[Y];J[Q[ue]+1]=le}this.#t=ie,this.#e=J,this.#n=z,this.#r=le}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(Q){if(Q+1<=this.#e.length)return;let z=this.#e.length-1;for(;z<Q;)z=z*2||16;const ne=new Uint32Array(z+1);ne.set(this.#e),this.#e=ne}#s(Q){if(Q<=this.#t.length)return;let z=this.#t.length;for(;z<Q;)z=z*2||16;const ne=new Int32Array(z);ne.set(this.#t),this.#t=ne}#h(Q,z){const ne=this.#t,_=this.#e,T=this.#n,K=z.length-(_[Q+1]-_[Q]),ie=new Int32Array(Math.max(1,this.#r+K)),J=new Uint32Array(_.length);let le=0;for(let ue=0;ue<T;ue++){if(J[ue]=le,ue===Q)for(let W=0;W<z.length;W++)ie[le++]=z[W]|0;else for(let W=_[ue];W<_[ue+1];W++)ie[le++]=ne[W];J[ue+1]=le}this.#t=ie,this.#e=J,this.#r=le}}}),Se("packages/core/src/compute/handle.js",function(o,me){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return A}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,Q=fe.defaultCompare,z=fe.warnOnce;function ne(i){const s=new Uint32Array(i);for(let u=0;u<i;u++)s[u]=u;return s}function _(i,s){if(s&&typeof s.count=="number")return s.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const u=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):u?i.kind==="bitset"?typeof u.size=="number"?u.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(z(`count:${i.id}`,`column "${i.id}" is bitset-backed with no declared row count; assuming ${u.length*8}`),u.length*8):u.length:i.presence&&typeof i.presence.size=="number"?i.presence.size:0}const T=new WeakMap;function K(i){const s=i.constructor;if(!s)return"unknown";const u=T.get(s);if(u)return u;let f="unknown";try{let l=null;typeof s.from=="function"?l=s.from([!1,!0]):(l=new s(8),l.set(1));const t=l&&l.words;t&&t.length&&(t[0]===2?f="lsb":t[0]===64&&(f="msb"))}catch{f="unknown"}return T.set(s,f),f}function ie(i){if(!i)return()=>0;const s=i instanceof Uint8Array?i:i.words;if(s instanceof Uint8Array){const u=i instanceof Uint8Array?"lsb":K(i);if(u==="lsb")return f=>s[f>>>3]>>>(f&7)&1;if(u==="msb")return f=>s[f>>>3]>>>7-(f&7)&1}return typeof i.get=="function"?u=>i.get(u)?1:0:()=>0}function J(i){return!i||!i.presence?null:ie(i.presence)}function le(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function ue(i,s){return i?typeof i.valueOf=="function"?i.valueOf(s):typeof i.values=="function"?i.values()[s]:null:null}function W(i,s){const u=i.offsets,f=i.values;if(!u||!f)return[];const l=u[s],t=u[s+1];if(!(t>l))return[];const a=i.dict,m=new Array(t-l);for(let e=l;e<t;e++)m[e-l]=a?ue(a,f[e]):f[e];return m}function L(i){if(!i)return()=>{};const s=i.values,u=J(i),f=i.kind;if(f==="dictionary"){const l=i.dict;return u?t=>u(t)?ue(l,s[t]):null:t=>ue(l,s[t])}if(f==="bitset"){const l=ie(s);return u?t=>u(t)?l(t)===1:null:t=>l(t)===1}if(f==="multi")return u?l=>u(l)?W(i,l):null:l=>W(i,l);if(!s&&typeof i.get=="function"){const l=i.get.bind(i);return t=>{const a=l(t);return a===void 0?null:a}}return u?l=>{if(!u(l))return null;const t=s[l];return t===void 0?null:t}:l=>{const t=s[l];return t===void 0?null:t}}function Y(i,s){if(i<s)return-1;if(i>s)return 1;if(i===s){const l=Object.is(i,-0),t=Object.is(s,-0);return l===t?0:l?-1:1}const u=Number.isNaN(i),f=Number.isNaN(s);return u&&f?0:u?1:-1}function ee(i){const s=he(i);return(u,f)=>{if(u===f)return 0;const l=typeof u,t=typeof f;if(l==="string"&&t==="string")return s.compare(u,f);if(l==="number"&&t==="number")return Y(u,f);if(l==="boolean"&&t==="boolean")return u===f?0:u?1:-1;if(u instanceof Date||f instanceof Date){const a=u instanceof Date?u.getTime():Number(u),m=f instanceof Date?f.getTime():Number(f);return Y(a,m)}return Q(u,f)}}function C(i,s){if(i&&typeof i.ranks=="function")return i.ranks(s);const u=i&&typeof i.values=="function"?i.values():[],f=u.length,l=ee(s),t=new Array(f);for(let m=0;m<f;m++)t[m]=m;t.sort((m,e)=>l(u[m],u[e])||m-e);const a=new Uint32Array(f);for(let m=0;m<f;m++)a[t[m]]=m;return a}function A(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Se("packages/core/src/compute/sort.js",function(o,me){"use strict";Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return a}}),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 F}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return R}});const fe=me("packages/core/src/compute/handle.js"),he=fe.bitReader,Q=fe.dictRanks,z=fe.dictSize,ne=fe.identity,_=fe.isMissing,T=fe.presenceReader,K=fe.rowCount,ie=fe.valueComparator,J=fe.valueReader,le=new Uint32Array(0),ue=new ArrayBuffer(8),W=new Float64Array(ue),L=new Uint32Array(ue),Y=(W[0]=-1,(L[1]&2147483648)!==0?1:0),ee=Y===1?0:1;function C(E,S){W[0]=E;let U=L[Y],H=L[ee];(U&2147483648)!==0?(U=~U>>>0,H=~H>>>0):U=(U^2147483648)>>>0,S[0]=H,S[1]=U}function A(E,S,U,H){if(H<2)return E;const $=new Uint32Array(256*8);for(let w=0;w<H;w++){const v=S[w],Z=U[w];$[v&255]++,$[256+(v>>>8&255)]++,$[512+(v>>>16&255)]++,$[768+(v>>>24&255)]++,$[1024+(Z&255)]++,$[1280+(Z>>>8&255)]++,$[1536+(Z>>>16&255)]++,$[1792+(Z>>>24&255)]++}let re=E,te=S,ae=U,p=new Uint32Array(H),B=new Uint32Array(H),q=new Uint32Array(H);const oe=new Uint32Array(256);for(let w=0;w<8;w++){const v=w<<8,Z=(w&3)<<3,x=w>=4;let de=!1;for(let pe=0;pe<256;pe++)if($[v+pe]===H){de=!0;break}if(de)continue;let we=0;for(let pe=0;pe<256;pe++)oe[pe]=we,we+=$[v+pe];for(let pe=0;pe<H;pe++){const Te=te[pe],Le=ae[pe],Be=(x?Le:Te)>>>Z&255,ze=oe[Be]++;p[ze]=re[pe],B[ze]=Te,q[ze]=Le}let ge=re;re=p,p=ge,ge=te,te=B,B=ge,ge=ae,ae=q,q=ge}return re}function i(E,S,U){if(U<2)return E;const H=new Uint32Array(256*4);for(let B=0;B<U;B++){const q=S[B];H[q&255]++,H[256+(q>>>8&255)]++,H[512+(q>>>16&255)]++,H[768+(q>>>24&255)]++}let $=E,re=S,te=new Uint32Array(U),ae=new Uint32Array(U);const p=new Uint32Array(256);for(let B=0;B<4;B++){const q=B<<8,oe=B<<3;let w=!1;for(let x=0;x<256;x++)if(H[q+x]===U){w=!0;break}if(w)continue;let v=0;for(let x=0;x<256;x++)p[x]=v,v+=H[q+x];for(let x=0;x<U;x++){const de=re[x],we=p[de>>>oe&255]++;te[we]=$[x],ae[we]=de}let Z=$;$=te,te=Z,Z=re,re=ae,ae=Z}return $}function s(E,S,U,H){const $=new Uint32Array(H+1);for(let ae=0;ae<U;ae++)$[S[ae]]++;let re=0;for(let ae=0;ae<=H;ae++){const p=$[ae];$[ae]=re,re+=p}const te=new Uint32Array(U);for(let ae=0;ae<U;ae++)te[$[S[ae]]++]=E[ae];return te}function u(E,S,U,H){return U<2?E:H<=65536||H<=U*2?s(E,S,U,H):i(E,S,U)}function f(E,S){return E.length===S&&E.byteOffset===0?E:Uint32Array.prototype.slice.call(E,0,S)}function l(E,S,U=!1){const H=S||ne(E.length),$=H.length;if($<2)return Uint32Array.from(H);const re=new Uint32Array($),te=new Uint32Array($),ae=new Uint32Array($),p=new Uint32Array($),B=new Uint32Array(2);let q=0,oe=0;for(let Z=0;Z<$;Z++){const x=H[Z],de=E[x];if(Number.isNaN(de)){p[oe++]=x;continue}C(de,B),U?(te[q]=~B[0]>>>0,ae[q]=~B[1]>>>0):(te[q]=B[0],ae[q]=B[1]),re[q++]=x}const w=A(re.subarray(0,q),te.subarray(0,q),ae.subarray(0,q),q);if(oe===0)return f(w,q);const v=new Uint32Array($);return v.set(w.subarray(0,q),0),v.set(p.subarray(0,oe),q),v}function t(E,S,U=!1){const H=S||ne(E.length),$=H.length;if($<2)return Uint32Array.from(H);const re=Uint32Array.from(H),te=new Uint32Array($);for(let ae=0;ae<$;ae++){const p=(E[re[ae]]^2147483648)>>>0;te[ae]=U?~p>>>0:p}return f(i(re,te,$),$)}function a(E,S,U={}){const H=S||ne(K(E,U)),$=H.length;if($<2)return Uint32Array.from(H);const re=Q(E.dict,U.locale),te=E.values,ae=T(E),p=Math.max(z(E.dict),re.length),B=p,q=Uint32Array.from(H),oe=new Uint32Array($),w=!!U.descending;for(let v=0;v<$;v++){const Z=q[v];let x=ae&&ae(Z)===0?B:re[te[Z]];x===void 0&&(x=B),oe[v]=w?B-x:x}return f(u(q,oe,$,p+1),$)}function m(E,S,U){const H=S.length;let $=Uint32Array.from(S);if(H<2)return $;let re=new Uint32Array(H);for(let te=1;te<H;te<<=1){for(let p=0;p<H;p+=te<<1){const B=Math.min(p+te,H),q=Math.min(p+(te<<1),H);let oe=p,w=B,v=p;for(;oe<B&&w<q;)re[v++]=U(E[$[oe]],E[$[w]])<=0?$[oe++]:$[w++];for(;oe<B;)re[v++]=$[oe++];for(;w<q;)re[v++]=$[w++]}const ae=$;$=re,re=ae}return $}function e(E,S,U){const H=he(E.values),$=S.length,re=new Uint32Array($),te=U?1:0;let ae=0;for(let p=0;p<$;p++)H(S[p])===te&&(re[ae++]=S[p]);for(let p=0;p<$;p++)H(S[p])!==te&&(re[ae++]=S[p]);return re}function d(E,S){const U=E.values,H=E.kind;if((H==="object"||H===void 0)&&(Array.isArray(U)||ArrayBuffer.isView(U))&&!E.presence)return U;const re=J(E),te=new Array(K(E)||0);for(let ae=0;ae<S.length;ae++){const p=S[ae];te[p]=re(p)}return te}function h(E,S){for(let U=0;U<S.length;U++)if(typeof E[S[U]]!="string")return!1;return!0}function r(E,S,U,H,$){const re=E.length,te=Uint32Array.from(E);if(re<2||H<1)return te;const ae=new Uint32Array(re),p=H-1;for(let B=0;B<re;B++){const q=U[S[B]];ae[B]=$?p-q:q}return f(u(te,ae,re,H),re)}function n(E,S,U){const H=ie(U),$=new Array(S);for(let te=0;te<S;te++)$[te]=te;$.sort((te,ae)=>H(E[te],E[ae])||te-ae);const re=new Uint32Array(S);for(let te=0;te<S;te++)re[$[te]]=te;return re}function c(E,S,U){const H=S.length,$=new Map,re=[],te=new Uint32Array(H);for(let B=0;B<H;B++){const q=E[S[B]];let oe=$.get(q);oe===void 0&&(oe=re.length,$.set(q,oe),re.push(q)),te[B]=oe}const ae=re.length,p=n(re,ae,U.locale);return r(S,te,p,ae,!!U.descending)}function g(E,S,U){const H=d(E,S);if(S.length>=2&&h(H,S)){const te=E.stringRank;return te&&te.version===E.version&&te.usable(S,H,U.locale)?te.sort(S,U):c(H,S,U)}const $=ie(U.locale),re=U.descending?(te,ae)=>$(ae,te):$;return m(H,S,re)}function M(E,S,U){const H=d(E,S),$=U.compare,te=!!U.descending?(ae,p)=>-$(ae,p,void 0,void 0,!0):(ae,p)=>$(ae,p,void 0,void 0,!1);return m(H,S,te)}function N(E,S){const U=S.length,H=T(E),$=E.values,re=E.kind==="float64"&&!!$,te=E.kind==="object"||E.kind==="multi"||E.kind===void 0;if(!H&&!re&&!te)return{present:S,absent:le};const ae=new Uint32Array(U),p=new Uint32Array(U);let B=0,q=0;if(H&&re)for(let oe=0;oe<U;oe++){const w=S[oe];H(w)===1&&!Number.isNaN($[w])?ae[B++]=w:p[q++]=w}else if(re&&!H)for(let oe=0;oe<U;oe++){const w=S[oe];Number.isNaN($[w])?p[q++]=w:ae[B++]=w}else if(H&&!te)for(let oe=0;oe<U;oe++){const w=S[oe];H(w)===1?ae[B++]=w:p[q++]=w}else{const oe=J(E);for(let w=0;w<U;w++){const v=S[w];_(oe(v))?p[q++]=v:ae[B++]=v}}return q===0?{present:S,absent:le}:{present:ae.subarray(0,B),absent:p.subarray(0,q)}}function G(E,S,U){if(S.length===0)return E;const H=new Uint32Array(E.length+S.length);return U?(H.set(S,0),H.set(E,S.length)):(H.set(E,0),H.set(S,E.length)),H}function F(E,S,U={}){const H=S||ne(K(E,U));if(!E||H.length<2)return Uint32Array.from(H);const{present:$,absent:re}=N(E,H);if($.length===0)return Uint32Array.from(H);const te=!!U.descending;let ae;if(typeof U.compare=="function")ae=M(E,$,U);else switch(E.kind){case"float64":ae=l(E.values,$,te);break;case"int32":ae=t(E.values,$,te);break;case"dictionary":ae=a(E,$,U);break;case"bitset":ae=e(E,$,te);break;default:ae=g(E,$,U);break}return G(ae,re,!!U.nullsFirst)}function R(E,S,U,H={}){const $=S||[],re=$.length&&($[0].handle||X(E,$[0].col))||E&&E[0];let te=U||ne(K(re,H));for(let ae=$.length-1;ae>=0;ae--){const p=$[ae],B=p.handle||X(E,p.col)||E&&E[ae];B&&(te=F(B,te,{descending:p.descending!==void 0?!!p.descending:p.dir==="desc",nullsFirst:!!p.nullsFirst,locale:p.locale!==void 0?p.locale:H.locale,compare:p.compare}))}return te instanceof Uint32Array?te:Uint32Array.from(te)}function X(E,S){if(!(!E||S===void 0)){for(let U=0;U<E.length;U++)if(E[U]&&E[U].id===S)return E[U]}}}),Se("packages/core/src/store/stringrank.js",function(o,me){"use strict";Object.defineProperty(o,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"StringRankIndex",{enumerable:!0,get:function(){return ne}});const fe=me("packages/core/src/compute/sort.js"),he=fe.collateStringRanks,Q=fe.rankSortStrings,z=1e5;class ne{#t=[];#e=new Map;#n;#r=0;#i=0;#s=-1;#h;#u=!1;#o=null;#c=-1;#l="\\0";constructor(T=z){this.#h=T>0?T:z,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(T){this.#s=T}get generation(){return this.#i}get size(){return this.#t.length}get capped(){return this.#u}get length(){return this.#r}get bytes(){let T=this.#n.byteLength;const K=this.#t;for(let ie=0;ie<K.length;ie++)T+=K[ie].length*2+24;return T}#a(T,K){const ie=this.#e.get(T);if(ie!==void 0)return ie;if(this.#u)return-1;if(K&&this.#t.length>=this.#h)return this.#u=!0,-1;const J=this.#t.length;return this.#t.push(T),this.#e.set(T,J),this.#i++,J}build(T,K){const ie=K|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(ie);for(let J=0;J<ie;J++){const le=T[J],ue=typeof le=="string"?this.#a(le,!1):-1;this.#n[J]=ue<0?0:ue}this.#r=ie}append(T,K,ie){const J=(K|0)+(ie|0);if(J>this.#n.length){const le=new Uint32Array(J);le.set(this.#n.subarray(0,this.#r)),this.#n=le}for(let le=K|0;le<J;le++){const ue=T[le],W=typeof ue=="string"?this.#a(ue,!0):-1;this.#n[le]=W<0?0:W}this.#r=Math.max(this.#r,J)}ranks(T){const K=T||"";if(this.#o&&this.#c===this.#i&&this.#l===K)return this.#o;const ie=he(this.#t,this.#t.length,T);return this.#o=ie,this.#c=this.#i,this.#l=K,ie}usable(T,K,ie){if(this.#u||this.#t.length===0)return!1;const J=this.#n,le=this.#t,ue=this.#r;for(let W=0;W<T.length;W++){const L=T[W];if(L>=ue||le[J[L]]!==K[L])return!1}return!0}sort(T,K){const ie=this.ranks(K.locale),J=this.#t.length,le=T.length,ue=new Uint32Array(le),W=this.#n;for(let L=0;L<le;L++)ue[L]=W[T[L]];return Q(T,ue,ie,J,!!K.descending)}}}),Se("packages/core/src/store/columnstore.js",function(o,me){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return W}}),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 a}});const fe=me("packages/core/src/internal/util.js"),he=fe.warnOnce,Q=fe.isFunction,z=fe.pathGetter,_=me("packages/core/src/store/bitset.js").Bitset,K=me("packages/core/src/store/dictionary.js").Dictionary,J=me("packages/core/src/store/multivalue.js").MultiValue,ue=me("packages/core/src/store/stringrank.js").StringRankIndex,W=4294967295,L=1024,Y=5e3,ee=.2,C=new Set(["float64","int32","bitset","dictionary","object","multi"]);function A(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 s(m){const e=i(m);return Number.isFinite(e)?e|0:0}function u(m){return A(m)?[]:Array.isArray(m)?m:[m]}function f(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),h=new Array(d.length);for(let r=0;r<d.length;r++)h[r]=m.dict.valueOf(d[r]);return h}default:return m.buf[e]}}function l(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],h=m.offsets[e+1],r=m.table||[],n=new Array(h-d);for(let c=d;c<h;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 h=C.has(e.kind)?e.kind:"object";e.kind&&!C.has(e.kind)&&he(`store.kind.${e.id}`,`column "${e.id}" declares unknown storage kind "${e.kind}"; falling back to object`),this.#n=h,this.#e=h,this.#r=e.nullable!==!1,this.#h=e.dictionary??null,this.#s=d,this.#i=Q(e.read)?e.read:z(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 h=new ue(this.#S());return h.build(e,d),h.version=this.#f,this.#d=h,this.#k=this.#f,h.capped?null:h}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),h=new Array(d.length);for(let r=0;r<d.length;r++)h[r]=this.#a.valueOf(d[r]);return h}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,h){if(this.#g||h<=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 M=this.#o;for(let N=0;N<h;N++){const G=r(e[N]);if(typeof G=="number"){n&&c.set(d+N),M[d+N]=G;continue}const F=G==null;n?c.assign(d+N,!F):F&&(g=!0),M[d+N]=F?NaN:i(G)}break}case"int32":{const M=this.#o;for(let N=0;N<h;N++){const G=r(e[N]),F=G==null;n?c.assign(d+N,!F):F&&(g=!0),M[d+N]=F?0:s(G)}break}case"bitset":{const M=this.#c;for(let N=0;N<h;N++){const G=r(e[N]),F=G==null;n?c.assign(d+N,!F):F&&(g=!0),M.assign(d+N,!F&&!!G)}break}case"dictionary":{const M=this.#o,N=this.#a;for(let G=0;G<h;G++){const F=r(e[G]),R=F==null;n?c.assign(d+G,!R):R&&(g=!0),M[d+G]=R?0:N.codeOf(F)}break}case"multi":{const M=this.#l,N=this.#a;for(let G=0;G<h;G++){const F=r(e[G]),R=F==null;n?c.assign(d+G,!R):R&&(g=!0);const X=u(F),E=new Array(X.length);for(let S=0;S<X.length;S++)E[S]=N.codeOf(X[S]);M.write(d+G,E)}break}default:{const M=this.#o;for(let N=0;N<h;N++){const G=r(e[N]),F=G==null;n?c.assign(d+N,!F):F&&(g=!0),M[d+N]=F?null:G}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,h),this.#d.version=this.#f+1,this.#k=this.#f+1),this.#f++}appendPacked(e,d,h){if(this.#g||h<=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<h;g++)r.assign(d+g,(n[g>>3]&1<<(g&7))!==0);else for(let g=0;g<h;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 M=0;M<h;M++)this.#c.assign(d+M,(g[M>>3]&1<<(M&7))!==0);this.#f++;return}if(c&&this.#e==="dictionary"){const g=e.table||[],M=new Uint32Array(g.length);for(let R=0;R<g.length;R++)M[R]=this.#a.codeOf(g[R]);const N=e.values,G=this.#o,F=r;for(let R=0;R<h;R++){if(F&&(n&&(n[R>>3]&1<<(R&7))===0)){G[d+R]=0;continue}G[d+R]=M[N[R]]??0}this.#f++;return}if(c&&this.#e==="multi"){const g=e.table||[],M=new Uint32Array(g.length);for(let F=0;F<g.length;F++)M[F]=this.#a.codeOf(g[F]);const N=e.values,G=e.offsets;for(let F=0;F<h;F++){const R=G[F],X=G[F+1],E=new Array(X-R);for(let S=R;S<X;S++)E[S-R]=M[N[S]]??0;this.#l.write(d+F,E)}this.#f++;return}for(let g=0;g<h;g++){const M=n?(n[g>>3]&1<<(g&7))===0:e.kind==="object"?e.values[g]===null:!1;this.#A(d+g,M?null:l(e,g))}this.#f++}touch(){this.#f++}columnarise(e,d){if(this.#u||this.#g)return;const h=new Array(d);for(let r=0;r<d;r++)h[r]=this.#M(r);this.#e=this.#n,this.#u=!0,this.#P(e);for(let r=0;r<d;r++)this.#A(r,h[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||!C.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},h=this.#s.physical(),r=this.#m;this.#e=e,this.#P(this.#p);for(let n=0;n<h;n++){const c=r!==null&&r.get(n)===0;c&&e!=="multi"||this.#A(n,c?null:f(d,n))}return this.#j(),this.#f++,!0}compact(e,d,h){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]!==W&&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]!==W&&(r[e[n]]=r[n]);if(this.#e==="object")for(let n=h;n<d;n++)r[n]=void 0;break}case"bitset":{const r=this.#c;for(let n=0;n<d;n++)e[n]!==W&&r.assign(e[n],r.get(n)===1);for(let n=h;n<d;n++)r.clear(n);break}case"multi":this.#l.compact(e,h,W);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<d;n++)e[n]!==W&&r.assign(e[n],r.get(n)===1);for(let n=h;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 _(d);break;case"dictionary":this.#o=new Uint32Array(d),this.#a=this.#a??new K(this.#h??[]);break;case"multi":this.#l=new J({rows:d,values:d}),this.#a=this.#a??new K(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 _(d)),this.#p=d}#A(e,d){const h=A(d);switch(this.#r?this.#m.assign(e,!h):h&&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]=h?NaN:i(d);break;case"int32":this.#o[e]=h?0:s(d);break;case"bitset":this.#c.assign(e,!h&&!!d);break;case"dictionary":this.#o[e]=h?0:this.#a.codeOf(d);break;case"multi":{const r=u(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]=h?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),h=this.#r?new _(e):null;for(let r=0;r<e;r++){const n=this.#M(r);d[r]=n,h&&!A(n)&&h.set(r)}return this.#O={version:this.#f,values:d,presence:h},this.#O}}class a{#t;#e=new Map;#n=[];#r=[];#i=0;#s=0;#h=0;#u=0;#o=new _(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??L),this.#l=d.retainSource!==!1,this.#a=this.#l?d.columnarBelow??Y:0,this.#w=d.compactRatio??ee;const h={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,h);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 h=e.length|0;if(h===0)return{from:d,to:d};if(this.#l)for(let n=0;n<h;n++)this.#r[d+n]=e[n];if(this.#i=d+h,this.#h+=h,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,h);return{from:d,to:this.#i}}appendPacked(e,d){const h=this.#i;if(this.#b||!e)return{from:h,to:h};const r=e.count|0;if(r===0)return{from:h,to:h};if(this.#l&&d)for(let c=0;c<r;c++)this.#r[h+c]=d[c];this.#i=h+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,h,r):c.grow(this.#s)}return{from:h,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 h=this.#e.get(e);return h?h.get(d):void 0}set(e,d,h){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,h)}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,h=new Uint32Array(d);let r=0;for(let n=0;n<d;n++)h[n]=this.#o.get(n)===1?W:r++;for(const n of this.#n)n.compact(h,d,r);if(this.#l){const n=this.#r;for(let c=0;c<d;c++)h[c]!==W&&(n[h[c]]=n[c]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new _(Math.max(this.#s,r)),h}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 h=0;h<this.#i;h++)e[h]=h;return e}let d=0;for(let h=0;h<this.#i;h++)this.#o.get(h)===0&&(e[d++]=h);return e}convert(e,d){const h=this.#e.get(e);return h?h.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 h of this.#n)h.grow(d);this.#o.grow(d),this.#s=d}#m(e){const d={};for(const h of this.#n)d[h.id]=h.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)}}}),Se("packages/core/src/store/ingest.js",function(o,me){"use strict";Object.defineProperty(o,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"inferKind",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return C}});const fe=me("packages/core/src/internal/util.js"),he=fe.now,Q=fe.nextFrame,z=fe.infoOnce,ne=fe.warnOnce,_=fe.isFunction,T=fe.pathGetter,ie=me("packages/core/src/store/columnstore.js").ColumnStore,J=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function le(A,i={}){if(i.multi)return"multi";if(A.length===0)return"object";let s=0,u=0,f=0,l=0,t=0;for(let m=0;m<A.length;m++){const e=A[m];typeof e=="number"?s++:typeof e=="boolean"?u++:typeof e=="string"?f++:e instanceof Date?l++:Array.isArray(e)&&t++}const a=A.length;return s===a?"float64":u===a?"bitset":l===a?"float64":f===a?"text":t===a?"multi":"object"}function ue(A,i,s){return i<=0||A<s*i?"dictionary":"object"}function W(A,i,s){const u=new Map,f=new Map;for(const c of A){if(c.computed)continue;const g=_(c.read)?c.read:T(c.field||c.id);f.set(c.id,g),u.set(c.id,g)}const l=i?.order??[],t=i?.fns??{},a=i?.deps??{},m=i?.wrapDeps??null,e=l.filter(c=>_(t[c])),d=e.some(c=>a[c]==="*");let h=new WeakMap;const r=c=>{const g={};if(d)for(const[M,N]of f)g[M]=N(c);for(const M of e){const N=a[M];let G;if(N==="*")G=g;else{G={};const F=N||[];for(let R=0;R<F.length;R++){const X=F[R];G[X]=X in g?g[X]:f.get(X)?.(c)}}g[M]=t[M](m?m(G,M):G,{data:c,row:null,column:null,grid:null,context:s})}return g},n=c=>{if(c===null||typeof c!="object"&&typeof c!="function")return r(c);let g=h.get(c);return g===void 0&&(g=r(c),h.set(c,g)),g};for(const c of e)u.set(c,g=>n(g)[c]);return{readers:u,reset(){h=new WeakMap}}}class L{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(i,s){this.spec=i,this.read=s,this.kind="object",this.inferred=!1,this.nullable=i.nullable!==!1}}class Y{#t;#e=[];#n=null;#r;#i=0;#s;#h=!1;#u=!1;#o=0;#c;constructor(i,s={},u={}){this.#t=Array.isArray(i)?i:Array.from(i||[]),this.#s={...J,...u};const f=s.columns??[];this.#r=W(f,s.computed??null,s.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(f,s.computed??null),this.#n=new ie(this.#e.map(l=>({id:l.spec.id,kind:l.kind,nullable:l.nullable,read:l.read,dictionary:l.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:s,chunkRows:u}=this.#s,f=this.#t.length;do{const l=Math.min(this.#i+u,f);this.#n.append(this.#t.slice(this.#i,l)),this.#a(this.#i,l),this.#i=l,this.#r.reset(),this.#w(!1)}while(this.#i<f&&he()-i<s);return this.#o+=he()-i,this.#s.onProgress?.({loaded:this.#i,total:f}),this.#i>=f?(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,s){const u=this.#t,f=Math.min(this.#s.sampleSize,u.length),l=this.#s.dictionaryRatio,t=s?.pure instanceof Set?s.pure:new Set(s?.pure??s?.order??[]);for(const a of i){if(!a||!a.id)continue;if(a.computed&&(a.pure===!1||s&&!t.has(a.id))){ne(`ingest.impure.${a.id}`,`column "${a.id}" is an impure computed column and is not materialised into the store`);continue}const m=this.#r.readers.get(a.id)??(_(a.read)?a.read:T(a.field||a.id)),e=new L(a,m);if(a.kind)e.kind=a.kind,e.reason="declared by the caller";else if(a.dictionary)e.kind=a.multi?"multi":"dictionary",e.reason="value table supplied (lookup column)";else{const d=[];for(let r=0;r<f&&d.length<this.#s.sampleSize;r++){const n=m(u[r]);n!=null&&d.push(n)}e.inferred=!0;const h=le(d,{multi:a.multi});if(h==="text"){const r=new Set(d).size;e.kind=ue(r,d.length,l),e.candidate=this.#c,e.reason=`sampled ${r} distinct in ${d.length}`}else e.kind=h,e.reason=`inferred from ${d.length} sampled values`,h==="object"&&d.length&&z(`ingest.mixed.${a.id}`,`column "${a.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,s){const u=this.#t;for(const f of this.#e){if(!f.candidate||!f.distinct)continue;const l=f.distinct;for(let t=i;t<s;t++){const a=f.read(u[t]);a!=null&&l.add(a)}}}#d(i){if(i.distinct)return i.distinct.size;const s=this.#n.column(i.spec.id);return s?.dict?s.dict.size:0}#w(i){const s=this.#s.dictionaryRatio,u=this.#t.length;for(const f of this.#e){if(!f.candidate)continue;const l=this.#d(f);if(f.kind==="dictionary"&&l>=s*u){const t=this.#n.column(f.spec.id);f.distinct=new Set(t?.dict?t.dict.values():[]),this.#n.convert(f.spec.id,"object"),f.kind="object",f.change="demoted",f.reason=`${l} distinct values is at or above ${s*100}% of ${u} rows`;continue}if(f.kind==="object"&&l>=s*u){f.candidate=!1,f.distinct=null,f.reason=`${l} distinct values is at or above ${s*100}% of ${u} rows`;continue}i&&f.kind==="object"&&l<s*u&&(this.#n.convert(f.spec.id,"dictionary"),f.kind="dictionary",f.change=f.change==="demoted"?null:"promoted",f.reason=`${l} distinct values is below ${s*100}% of ${u} rows`,f.distinct=null),i&&(f.candidate=!1)}}}async function ee(A,i={},s={}){const u=new Y(A,i,s),f=s.scheduler?.frame??Q;for(;u.slice();)await new Promise(l=>{f(l)});return u.result()}function C(A,i={},s={}){const u=new Y(A,i,{...s,chunkMs:1/0});for(;u.slice(););return u.result()}}),Se("packages/core/src/store/columnpack.js",function(o,me){"use strict";Object.defineProperty(o,"isPortableSchema",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"packChunk",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"packedTransfers",{enumerable:!0,get:function(){return Y}});const he=me("packages/core/src/internal/util.js").pathGetter,Q=me("packages/core/src/store/ingest.js"),z=Q.inferKind,ne=Q.decideText,_=Q.INGEST_DEFAULTS,K=me("packages/core/src/store/columnstore.js").toFloat,ie=new Set(["float64","int32","bitset","dictionary","object","multi"]);function J(ee){if(!Array.isArray(ee)||ee.length===0)return!1;for(const C of ee)if(!C||typeof C.id!="string"||typeof C.field!="string"||C.field===""||C.kind&&!ie.has(C.kind))return!1;return!0}function le(ee){const C=K(ee);return Number.isFinite(C)?C|0:0}function ue(ee){return ee==null?[]:Array.isArray(ee)?ee:[ee]}function W(ee,C,A,i){if(ee.kind)return ee.kind;const s=[];for(let l=0;l<C.length&&s.length<_.sampleSize;l++){const t=C[l];t!=null&&s.push(t)}const u=z(s,{multi:ee.multi});if(u!=="text")return u;const f=new Set(s).size;return ne(f,s.length,i)}function L(ee,C,A={}){const i=C.length|0,s=A.dictionaryRatio??_.dictionaryRatio,u=[];for(const f of ee){const l=he(f.field||f.id),t=f.nullable!==!1,a=new Array(i);for(let r=0;r<i;r++){const n=l(C[r]);a[r]=n===void 0?null:n}const m=W(f,a,i,s),e=t?new Uint8Array(i+7>>3):null,d=r=>{e&&(e[r>>3]|=1<<(r&7))};let h;switch(m){case"float64":{const r=new Float64Array(i);for(let n=0;n<i;n++){const c=a[n],g=c===null;g||d(n),r[n]=g?NaN:K(c)}h={id:f.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=a[n],g=c===null;g||d(n),r[n]=g?0:le(c)}h={id:f.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=a[n],g=c===null;g||d(n),!g&&c&&(r[n>>3]|=1<<(n&7))}h={id:f.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 M=a[g];if(M===null){r[g]=0;continue}d(g);let N=c.get(M);N===void 0&&(N=n.length,n.push(M),c.set(M,N)),r[g]=N}h={id:f.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 M=0;M<i;M++){const N=a[M];c[M]=g.length,N===null||d(M);const F=ue(N);for(let R=0;R<F.length;R++){const X=F[R];let E=n.get(X);E===void 0&&(E=r.length,r.push(X),n.set(X,E)),g.push(E)}}c[i]=g.length,h={id:f.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=a[n];c!==null&&d(n),r[n]=c}h={id:f.id,kind:"object",nullable:t,values:r,presence:e,offsets:null,table:null};break}}u.push(h)}return{count:i,columns:u}}function Y(ee){const C=[];if(!ee||!Array.isArray(ee.columns))return C;const A=i=>{ArrayBuffer.isView(i)&&i.buffer&&!C.includes(i.buffer)&&C.push(i.buffer)};for(const i of ee.columns)A(i.values),A(i.presence),A(i.offsets);return C}}),Se("packages/core/src/compute/sortspec.js",function(o,me){"use strict";Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return ne}});function fe(_){return{locale:_===void 0?void 0:String(_),numeric:!0,sensitivity:"variant"}}function he(_){return!!_&&typeof _.compare!="function"}function Q(_){if(!_)return!0;for(let T=0;T<_.length;T++)if(!he(_[T]))return!1;return!0}function z(_,T){const K=_.col!==void 0?_.col:_.handle&&_.handle.id,ie=_.locale!==void 0?_.locale:T;return{col:K,descending:_.descending!==void 0?!!_.descending:_.dir==="desc",nullsFirst:!!_.nullsFirst,collation:fe(ie)}}function ne(_,T){const K=_||[],ie=new Array(K.length);for(let J=0;J<K.length;J++)ie[J]=z(K[J],T);return ie}}),Se("packages/core/src/format/date.js",function(o,me){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return C}});const fe=me("packages/core/src/internal/util.js"),he=fe.isNil,Q=fe.warnOnce,z=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function ne(A){const i=[];let s=0,u="";const f=()=>{u&&(i.push({token:null,text:u}),u="")};for(;s<A.length;){const l=A[s];if(l==="\'"){if(A[s+1]==="\'"){u+="\'",s+=2;continue}const a=A.indexOf("\'",s+1);if(a===-1){u+=A.slice(s+1),s=A.length;continue}u+=A.slice(s+1,a),s=a+1;continue}const t=z.find(a=>A.startsWith(a,s));if(t){f(),i.push({token:t,text:t}),s+=t.length;continue}/[A-Za-z]/.test(l)&&Q(`date.pattern.token:${l}`,`the date pattern "${A}" contains \'${l}\', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${z.join(" ")}.`),u+=l,s+=1}return f(),i}const _=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function T(A){if(he(A)||A==="")return null;if(A instanceof Date)return Number.isNaN(A.getTime())?null:A;if(typeof A=="number")return Number.isNaN(A)?null:new Date(A);if(typeof A=="string"){const i=_.exec(A.trim());if(i){const[,u,f,l,t="0",a="0",m="0"]=i;return new Date(+u,+f-1,+l,+t,+a,+m)}const s=new Date(A);return Number.isNaN(s.getTime())?null:s}return null}function K(A,i){return String(A).padStart(i,"0")}function ie(A){if(!A)return u=>({year:u.getFullYear(),month:u.getMonth()+1,day:u.getDate(),hour:u.getHours(),minute:u.getMinutes(),second:u.getSeconds(),ms:u.getMilliseconds(),weekday:u.getDay()});const i=new Intl.DateTimeFormat("en-US",{timeZone:A,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 u=>{const f={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:u.getMilliseconds(),weekday:0};for(const l of i.formatToParts(u))switch(l.type){case"year":f.year=Number(l.value);break;case"month":f.month=Number(l.value);break;case"day":f.day=Number(l.value);break;case"hour":f.hour=Number(l.value)%24;break;case"minute":f.minute=Number(l.value);break;case"second":f.second=Number(l.value);break;case"weekday":f.weekday=s[l.value]??0;break;default:break}return f}}function J(A,i,s){const u=ne(A),f=ie(s),l=new Set(u.filter(d=>d.token).map(d=>d.token)),t=l.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:s}):null,a=l.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:s}):null,m=l.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:s}):null,e=l.has("EEEE")?new Intl.DateTimeFormat(i,{weekday:"long",timeZone:s}):null;return d=>{const h=f(d);let r="";for(const n of u){if(!n.token){r+=n.text;continue}switch(n.token){case"yyyy":r+=K(h.year,4);break;case"yy":r+=K(h.year%100,2);break;case"MMMM":r+=a.format(d);break;case"MMM":r+=t.format(d);break;case"MM":r+=K(h.month,2);break;case"M":r+=String(h.month);break;case"dd":r+=K(h.day,2);break;case"d":r+=String(h.day);break;case"EEEE":r+=e.format(d);break;case"EEE":r+=m.format(d);break;case"HH":r+=K(h.hour,2);break;case"H":r+=String(h.hour);break;case"hh":r+=K(h.hour%12===0?12:h.hour%12,2);break;case"h":r+=String(h.hour%12===0?12:h.hour%12);break;case"mm":r+=K(h.minute,2);break;case"m":r+=String(h.minute);break;case"ss":r+=K(h.second,2);break;case"s":r+=String(h.second);break;case"SSS":r+=K(h.ms,3);break;case"a":r+=h.hour<12?"AM":"PM";break;default:r+=n.text;break}}return r}}const le=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function ue(A,i){const s=A||{},u=s.locale||i||void 0,f=s.nullDisplay??"",l=s.timeZone;let t;if(s.pattern)t=J(s.pattern,u,l);else if(s.dateStyle||s.timeStyle){const h={timeZone:l};s.dateStyle&&(h.dateStyle=s.dateStyle),s.timeStyle&&(h.timeStyle=s.timeStyle);const r=new Intl.DateTimeFormat(u,h);t=n=>r.format(n)}else{const h=new Intl.DateTimeFormat(u,{dateStyle:"medium",timeZone:l});t=r=>h.format(r)}const a=s.relative?new Intl.RelativeTimeFormat(u,{numeric:"auto"}):null,e=(typeof s.relative=="object"&&s.relative?s.relative.threshold??7:7)*24*36e5,d=(h,r)=>{const n=T(h);if(!n)return f;if(a){const c=r&&typeof r.now=="number"?r.now:Date.now(),g=n.getTime()-c;if(Math.abs(g)<e){for(const[M,N]of le)if(Math.abs(g)>=N||M==="second")return a.format(Math.round(g/N),M)}}return t(n)};return d.spec=s,d}function W(A){if(he(A)||A==="")return null;if(typeof A=="string"){const u=/^(\\d{4}-\\d{2}-\\d{2})/.exec(A.trim());if(u)return u[1];const f=T(A);return f?W(f):null}const i=T(A);if(!i)return null;const s=u=>String(u).padStart(2,"0");return`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}`}function L(A,i){if(he(A)||A==="")return null;if(typeof A=="string"){const u=A.trim();if(Y.test(u)){const t=T(u);return t?ee(t,i):null}const f=/^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(u);if(f){const[,t,a,m,e]=f;return`${t}T${a}:${m}${e&&e!=="00"?`:${e}`:""}`}if(/^\\d{4}-\\d{2}-\\d{2}$/.test(u))return`${u}T00:00`;const l=T(u);return l?L(l):null}const s=T(A);return s?ee(s,i):null}const Y=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function ee(A,i){const s=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(A).reduce((e,d)=>(d.type!=="literal"&&(e[d.type]=d.value),e),{}),a=t.hour==="24"?"00":t.hour,m=Number(t.second);return`${t.year}-${t.month}-${t.day}T${a}:${t.minute}`+(m?`:${t.second}`:"")}catch{}const u=`${A.getFullYear()}-${s(A.getMonth()+1)}-${s(A.getDate())}`,f=A.getSeconds(),l=`${s(A.getHours())}:${s(A.getMinutes())}${f?`:${s(f)}`:""}`;return`${u}T${l}`}function C(A,i){const s=he(A)||A===""?null:String(A),u=he(i)||i===""?null:String(i);return s===null?u===null?0:1:u===null||s<u?-1:s>u?1:0}}),Se("packages/core/src/compute/filter.js",function(o,me){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"itemwisePredicate",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"declareOperators",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"declaredOperator",{enumerable:!0,get:function(){return ae}});const fe=me("packages/core/src/internal/util.js"),he=fe.isBlank,Q=fe.toArray,z=fe.warnOnce,_=me("packages/core/src/format/date.js").toIsoDate,T=me("packages/core/src/compute/handle.js"),K=T.bitReader,ie=T.dictSize,J=T.dictValue,le=T.presenceReader,ue=T.valueComparator,W=T.valueReader,L=/^\\d{4}-\\d{2}-\\d{2}$/,Y="\\0null\\0";function ee(p,B){const q=p&&p.pool;if(q){const oe=q.mask||q.acquireMask||q.acquire||q.take;if(typeof oe=="function"){const w=oe.call(q,B);if(w&&w.length>=B)return w}}return new Uint8Array(B)}function C(p,B){const q=p&&p.pool;if(!q||!B)return;const oe=q.release||q.releaseMask||q.free||q.recycle;typeof oe=="function"&&oe.call(q,B)}function A(p,B,q){return p.fill(q,0,B),p}function i(p){return p==null||typeof p=="number"&&Number.isNaN(p)}function s(p,B){if(p==null)return p;if(B==="number")return typeof p=="number"?p:Number(p);if(B==="date"||B==="dateString"){const q=_(p);return q===null?u(p):q}return B==="boolean"?typeof p=="boolean"?p:p==="true"||p===1?!0:p==="false"||p===0?!1:!!p:p}function u(p){return p instanceof Date?p.getTime():typeof p=="number"?p:Date.parse(String(p))}function f(p){return typeof p=="number"?p:p instanceof Date?p.getTime():p==null||p===""?NaN:Number(p)}function l(p,B){const q=typeof p=="string"?p:String(p);return B?q:q.toLowerCase()}function t(p,B){return p==null?Y:typeof p=="string"?B?p:p.toLowerCase():p instanceof Date?p.getTime():p}function a(p,B,q){const oe=new Set;for(const w of Q(p)){const v=s(w,q);oe.add(t(v,B)),typeof v=="string"&&v!==""&&Number.isFinite(Number(v))?oe.add(Number(v)):typeof v=="number"&&Number.isFinite(v)&&oe.add(t(String(v),B))}return oe}function m(p,B,q){if(p==null||B===null||B===void 0)return p==null&&B==null;const oe=typeof p,w=typeof B;return oe==="string"&&w==="string"?q?p===B:p.toLowerCase()===B.toLowerCase():p instanceof Date||B instanceof Date?u(p)===u(B):oe==="number"&&w==="number"?p===B||Number.isNaN(p)&&Number.isNaN(B):oe==="number"&&w==="string"?p===Number(B):oe==="string"&&w==="number"?Number(p)===B:oe==="boolean"||w==="boolean"?p===B:Array.isArray(p)&&Array.isArray(B)?p.length===B.length&&p.every((v,Z)=>m(v,B[Z],q)):p===B}function e(p,B){try{if(p instanceof RegExp){const q=p.flags.replace(/[gy]/g,"");return new RegExp(p.source,B||q.includes("i")?q:`${q}i`)}return new RegExp(String(p),B?"":"i")}catch(q){return z(`regex:${String(p)}`,`filter operator "matches" received an invalid pattern: ${String(p)}`,q),null}}function d(p,B){const q=h(p,B),oe=p&&p.type;return oe!=="date"&&oe!=="dateString"?q:w=>q(typeof w=="string"&&L.test(w)?w:_(w)??w)}function h(p,B){const q=p&&p.op,oe=!!(p&&p.caseSensitive),w=p&&p.type,v=ue(B),Z=x=>de=>!x(de);switch(q){case"eq":{const x=s(p.value,w);return de=>m(de,x,oe)}case"ne":{const x=s(p.value,w);return de=>!m(de,x,oe)}case"lt":case"lte":case"gt":case"gte":{const x=s(p.value,w);if(i(x))return()=>!1;const de=q==="lt"?-1:q==="lte"?0:q==="gt"?1:2;return we=>{if(i(we))return!1;const ge=v(we,x);return de===-1?ge<0:de===0?ge<=0:de===1?ge>0:ge>=0}}case"between":case"notBetween":{const x=Q(p.value),de=s(x[0],w),we=s(x[1],w),ge=p.bounds||"[]",pe=ge.charAt(0)!=="(",Te=ge.charAt(1)!==")";if(i(de)||i(we))return q==="between"?()=>!1:()=>!0;const Le=Be=>{if(i(Be))return!1;const ze=v(Be,de),Ke=v(Be,we);return(pe?ze>=0:ze>0)&&(Te?Ke<=0:Ke<0)};return q==="between"?Le:Z(Le)}case"in":case"notIn":{const x=a(p.value,oe,w),de=we=>x.has(t(we,oe));return q==="in"?de:Z(de)}case"contains":case"notContains":{const x=l(s(p.value,w),oe),de=we=>we==null?!1:l(we,oe).includes(x);return q==="contains"?de:Z(de)}case"startsWith":{const x=l(s(p.value,w),oe);return de=>de==null?!1:l(de,oe).startsWith(x)}case"endsWith":{const x=l(s(p.value,w),oe);return de=>de==null?!1:l(de,oe).endsWith(x)}case"matches":{const x=e(p.value,oe);return x?de=>de==null?!1:x.test(String(de)):()=>!1}case"blank":return x=>he(x)||Array.isArray(x)&&x.length===0;case"notBlank":return x=>!(he(x)||Array.isArray(x)&&x.length===0);case"containsAny":case"containsNone":{const x=a(p.value,oe,w),de=we=>{const ge=we==null?[]:Q(we);for(let pe=0;pe<ge.length;pe++)if(x.has(t(ge[pe],oe)))return!0;return!1};return q==="containsAny"?de:Z(de)}case"containsAll":{const x=Q(p.value).map(de=>t(s(de,w),oe));return de=>{const we=de==null?[]:Q(de);if(x.length===0)return!0;const ge=new Set(we.map(pe=>t(pe,oe)));for(let pe=0;pe<x.length;pe++)if(!ge.has(x[pe]))return!1;return!0}}default:{const x=ae(q);return x?x.compile(p.value):(z(`op:${String(q)}`,`unknown filter operator "${String(q)}"; the condition is refused rather than matching every row`),()=>!1)}}}function r(p,B,q){return d(B,q)(p)}const n=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),c=new Set(["containsAny","containsAll","containsNone"]);function g(p,B,q){const oe=p&&p.op,w=n[oe]||oe,v=d({...p,op:w,type:B.type},q),Z=B.items,x=de=>{const we=Z(de);if(!we)return!1;for(let ge=0;ge<we.length;ge++)if(v(we[ge]))return!0;return!1};return n[oe]?de=>!x(de):x}function M(p,B,q,oe){const w=le(p);if(w){const x=B?1:0;for(let de=0;de<oe;de++)q[de]=w(de)===x?1:0;return q}const v=p.kind;if(v==="float64"||v==="int32"||v==="bitset")return A(q,oe,B?1:0);const Z=W(p);for(let x=0;x<oe;x++){const de=Z(x),we=he(de)||Array.isArray(de)&&de.length===0;q[x]=we===B?0:1}return q}function N(p,B,q,oe){const w=p.dict,v=ie(w),Z=new Uint8Array(v);for(let ge=0;ge<v;ge++)Z[ge]=B(J(w,ge))?1:0;const x=p.values,de=le(p);if(!de){for(let ge=0;ge<oe;ge++)q[ge]=Z[x[ge]];return q}const we=B(null)?1:0;for(let ge=0;ge<oe;ge++)q[ge]=de(ge)===1?Z[x[ge]]:we;return q}function G(p,B,q,oe){const w=K(p.values),v=B(!0)?1:0,Z=B(!1)?1:0,x=le(p);if(!x){for(let we=0;we<oe;we++)q[we]=w(we)===1?v:Z;return q}const de=B(null)?1:0;for(let we=0;we<oe;we++)q[we]=x(we)===0?de:w(we)===1?v:Z;return q}function F(p,B,q,oe,w){const v=p.values,Z=B.type,x=B.op;let de=!0;switch(x){case"eq":case"ne":{const ge=f(s(B.value,Z)),pe=typeof B.value=="number"&&Number.isNaN(B.value),Te=x==="ne"?1:0;if(pe)for(let Le=0;Le<w;Le++)oe[Le]=(Number.isNaN(v[Le])?1:0)^Te;else for(let Le=0;Le<w;Le++)oe[Le]=(v[Le]===ge?1:0)^Te;break}case"lt":{const ge=f(s(B.value,Z));for(let pe=0;pe<w;pe++)oe[pe]=v[pe]<ge?1:0;break}case"lte":{const ge=f(s(B.value,Z));for(let pe=0;pe<w;pe++)oe[pe]=v[pe]<=ge?1:0;break}case"gt":{const ge=f(s(B.value,Z));for(let pe=0;pe<w;pe++)oe[pe]=v[pe]>ge?1:0;break}case"gte":{const ge=f(s(B.value,Z));for(let pe=0;pe<w;pe++)oe[pe]=v[pe]>=ge?1:0;break}case"between":case"notBetween":{const ge=Q(B.value),pe=f(s(ge[0],Z)),Te=f(s(ge[1],Z)),Le=B.bounds||"[]",Be=Le.charAt(0)!=="(",ze=Le.charAt(1)!==")",Ke=x==="notBetween"?1:0;if(Be&&ze)for(let Ee=0;Ee<w;Ee++)oe[Ee]=(v[Ee]>=pe&v[Ee]<=Te?1:0)^Ke;else if(Be)for(let Ee=0;Ee<w;Ee++)oe[Ee]=(v[Ee]>=pe&v[Ee]<Te?1:0)^Ke;else if(ze)for(let Ee=0;Ee<w;Ee++)oe[Ee]=(v[Ee]>pe&v[Ee]<=Te?1:0)^Ke;else for(let Ee=0;Ee<w;Ee++)oe[Ee]=(v[Ee]>pe&v[Ee]<Te?1:0)^Ke;break}case"in":case"notIn":{const ge=new Set;for(const Te of Q(B.value)){const Le=f(s(Te,Z));Number.isNaN(Le)||ge.add(Le)}const pe=x==="notIn"?1:0;for(let Te=0;Te<w;Te++)oe[Te]=(ge.has(v[Te])?1:0)^pe;break}default:de=!1;break}if(!de)return!1;const we=le(p);if(we){const ge=q(null)?1:0;for(let pe=0;pe<w;pe++)we(pe)===0&&(oe[pe]=ge)}return!0}function R(p,B,q,oe){const w=W(p);for(let v=0;v<oe;v++)q[v]=B(w(v))?1:0;return q}function X(p,B,q){const oe=B.count|0,w=q||ee(B,oe);if(!p)return A(w,oe,1);const v=typeof B.handle=="function"?B.handle(p.col):void 0,Z=typeof B.custom=="function"?B.custom:null;if(!v){if(Z){for(let ge=0;ge<oe;ge++)w[ge]=Z(p,ge)?1:0;return w}return z(`filter:col:${String(p.col)}`,`filter references unknown column "${String(p.col)}"; the condition is refused rather than matching every row`),A(w,oe,0)}const x=p.op;if(x==="blank"||x==="notBlank")return M(v,x==="notBlank",w,oe);const de=typeof B.itemwise=="function"?B.itemwise(p.col):null;if(de&&!ae(x)&&!c.has(x))return R(v,g(p,de,B.locale),w,oe);const we=d(p,B.locale);switch(v.kind){case"dictionary":return N(v,we,w,oe);case"bitset":return G(v,we,w,oe);case"float64":case"int32":return F(v,p,we,w,oe)?w:R(v,we,w,oe);default:return R(v,we,w,oe)}}function E(p,B,q){if(!p)return A(ee(B,q),q,1);if(Array.isArray(p.conditions)){const oe=p.conditions.filter(Z=>Z!=null),w=p.op==="or"?"or":p.op==="not"?"not":"and";if(oe.length===0)return A(ee(B,q),q,1);const v=E(oe[0],B,q);for(let Z=1;Z<oe.length;Z++){const x=E(oe[Z],B,q);if(w==="or")for(let de=0;de<q;de++)v[de]|=x[de];else for(let de=0;de<q;de++)v[de]&=x[de];C(B,x)}if(w==="not")for(let Z=0;Z<q;Z++)v[Z]^=1;return v}return X(p,B,ee(B,q))}function S(p,B){return E(p,B,B.count|0)}function U(p,B){if(!p||!B)return p||null;const q=p;if(Array.isArray(q.conditions)){if((q.op==="or"?"or":q.op==="not"?"not":"and")!=="and")return H(q,B)?null:p;const w=[];for(const v of q.conditions){const Z=U(v,B);Z&&w.push(Z)}return w.length?{...q,op:"and",conditions:w}:null}return q.col===B?null:p}function H(p,B){if(!p||typeof p!="object")return!1;const q=p;if(q.col===B)return!0;if(Array.isArray(q.conditions)){for(const oe of q.conditions)if(H(oe,B))return!0}return!1}function $(p,B,q){if(q&&q.length>=B){let Z=0;for(let x=0;x<B;x++)p[x]&&(q[Z++]=x);return q.subarray(0,Z)}let oe=0;for(let Z=0;Z<B;Z++)oe+=p[Z]?1:0;const w=new Uint32Array(oe);let v=0;for(let Z=0;Z<B;Z++)p[Z]&&(w[v++]=Z);return w}const re=new Map;function te(p){if(!(!p||typeof p!="object"))for(const[B,q]of Object.entries(p))q&&typeof q.compile=="function"&&re.set(B,q)}function ae(p){return typeof p=="string"?re.get(p):void 0}}),Se("packages/core/src/compute/group.js",function(o,me){"use strict";Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return ue}});const fe=me("packages/core/src/compute/handle.js"),he=fe.dictSize,Q=fe.identity,z=fe.presenceReader,ne=fe.rowCount,_=fe.valueReader,T="",K="\\0",ie=1<<20;function J(W,L,Y,ee){const C=W.length,A=W.map(t=>_(t)),i=Array.isArray(ee)&&ee.some(Boolean),s=i?A.map((t,a)=>ee[a]?m=>ee[a](t(m)):t):A;if(!i&&C>0&&W.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=W.map(m=>he(m.dict)+1);let a=1;for(let m=0;m<C;m++)a*=t[m];if(a<=Number.MAX_SAFE_INTEGER){const m=W.map(r=>r.values),e=W.map(r=>z(r)),d=r=>{let n=0;for(let c=0;c<C;c++){const g=e[c],M=g&&g(r)===0?t[c]-1:m[c][r];n=n*t[c]+M}return n},h=new Float64Array(Y);for(let r=0;r<Y;r++)h[r]=d(L[r]);return{packed:h,strings:null,product:a,readers:s,keyOf:d}}}const f=t=>{let a="";for(let m=0;m<C;m++){const e=s[m](t);a+=(m===0?"":T)+(e==null?K:String(e))}return a},l=new Array(Y);for(let t=0;t<Y;t++)l[t]=f(L[t]);return{packed:null,strings:l,product:1/0,readers:s,keyOf:f}}function le(W,L,Y,ee){const C=new Uint32Array(ee+1);for(let u=0;u<Y;u++)C[L[u]+1]++;for(let u=0;u<ee;u++)C[u+1]+=C[u];const A=new Uint32Array(Y),i=C.slice(0,ee);for(let u=0;u<Y;u++)A[i[L[u]]++]=W[u];const s=new Array(ee);for(let u=0;u<ee;u++)s[u]=A.subarray(C[u],C[u+1]);return s}function ue(W,L,Y={}){const ee=W||[],C=L||Q(ne(ee[0],Y)),A=C.length;if(ee.length===0||A===0)return{keys:[],buckets:[]};const{packed:i,strings:s,product:u,readers:f}=J(ee,C,A,Y.project),l=new Uint32Array(A);let t=0,a=null;if(i&&u<=Math.max(1024,Math.min(ie,A*4))){const h=u,r=new Int32Array(h).fill(-1);for(let n=0;n<A;n++)r[i[n]]=0;for(let n=0;n<h;n++)r[n]===0&&(r[n]=t++);for(let n=0;n<A;n++)l[n]=r[i[n]];a=new Float64Array(t);for(let n=0;n<h;n++)r[n]>=0&&(a[r[n]]=n)}else if(i){const h=new Map;for(let r=0;r<A;r++){const n=i[r];let c=h.get(n);c===void 0&&(c=t++,h.set(n,c)),l[r]=c}a=new Float64Array(t);for(const[r,n]of h)a[n]=r}else{const h=new Map;for(let r=0;r<A;r++){const n=s[r];let c=h.get(n);c===void 0&&(c=t++,h.set(n,c)),l[r]=c}}const m=le(C,l,A,t),e=new Array(t);for(let h=0;h<t;h++){const r=m[h][0],n=new Array(f.length);for(let c=0;c<f.length;c++)n[c]=f[c](r);e[h]=n}const d={keys:e,buckets:m};return a&&(d.packed=a),d}}),Se("packages/core/src/compute/facet.js",function(o,me){"use strict";Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return f}}),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 h}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return r}});const fe=me("packages/core/src/compute/handle.js"),he=fe.presenceReader,Q=fe.valueReader,z=fe.dictSize,ne=fe.dictValue,_=Object.freeze(["equal","quantile","log"]),T=Object.freeze(["hour","day","week","month","quarter","year"]),K=20,ie=50,J=1e4;function le(n,c){if(!n)return"none";const g=c;if(g&&(g.multi===!0||typeof g.items=="function"))return"category";const M=c&&c.base;if(M==="date"||M==="datetime"||M==="time"||M==="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 M==="number"?"numeric":M==="boolean"?"boolean":M==="text"?"category":"none"}}function ue(n){const c=n.values,g=n.kind;if((g==="float64"||g==="int32")&&c)return N=>c[N];const M=Q(n);return N=>W(M(N))}function W(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 L(n,c,g,M=ie){if(!n)return{cardinality:0,exact:!0};if(n.dict)return{cardinality:z(n.dict),exact:!0};if(n.kind==="bitset")return{cardinality:2,exact:!0};const N=Q(n),G=c?c.length:g,F=new Set;for(let R=0;R<G;R++){const X=N(c?c[R]:R);if(X!=null&&(F.add(X),F.size>M))return{cardinality:F.size,exact:!1}}return{cardinality:F.size,exact:!0}}const Y=36e5,ee=864e5;function C(n,c=K){const g=Number.isFinite(n)&&n>0?n:0,M=Math.max(1,c)*2;return g/Y<=M?"hour":g/ee<=M?"day":g/(7*ee)<=M?"week":g/(30*ee)<=M?"month":g/(91*ee)<=M?"quarter":"year"}function A(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 M=(g.getDay()+6)%7;return g.setDate(g.getDate()-M),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 s(n,c,g){const M=ue(n),N=he(n),G=c?c.length:g;let F=1/0,R=-1/0,X=0,E=0;for(let S=0;S<G;S++){const U=c?c[S]:S;if(N&&!N(U)){X++;continue}const H=M(U);if(!Number.isFinite(H)){X++;continue}H<F&&(F=H),H>R&&(R=H),E++}return{min:F,max:R,nulls:X,finite:E}}function u(n,c,g,M){const N=ue(n),G=he(n),F=c?c.length:g,R=F>M?F/M:1,X=[];for(let S=0;S<F;S+=R){const U=c?c[Math.floor(S)]:Math.floor(S);if(G&&!G(U))continue;const H=N(U);Number.isFinite(H)&&X.push(H)}const E=Float64Array.from(X);return E.sort(),E}function f(n,c,g,M={}){const N=M.kind||le(n,M.type);return N==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:N==="boolean"?l(n,c,g):N==="category"?t(n,c,g,M):a(n,c,g,N,M)}function l(n,c,g){const M=he(n);let N=0;if(M){const F=c?c.length:g;for(let R=0;R<F;R++)M(c?c[R]:R)||N++}const G=[{value:!1,label:"false"},{value:!0,label:"true"}];return N>0&&G.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:G}}function t(n,c,g,M){const N=M.cardinalityLimit??ie,{cardinality:G}=L(n,c,g,N);if(G>N&&(M.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:G};const F=Q(n),R=c?c.length:g,X=new Map;let E=0;for(let re=0;re<R;re++){const te=F(c?c[re]:re);if(te==null||te===""){E++;continue}if(Array.isArray(te)){if(!te.length){E++;continue}for(const ae of te)X.set(ae,(X.get(ae)||0)+1);continue}X.set(te,(X.get(te)||0)+1)}let S=[...X.entries()];M.order==="alpha"?S.sort((re,te)=>String(re[0]).localeCompare(String(te[0]))):S.sort((re,te)=>te[1]-re[1]);let U=0,H=0;if(S.length>N){H=S.length-N;for(let re=N;re<S.length;re++)U+=S[re][1];S=S.slice(0,N)}const $=S.map(([re])=>({value:re,label:String(re)}));return U>0&&$.push({remainder:!0,label:`Other (${H} values)`}),E>0&&$.push({null:!0,label:"Empty"}),{kind:"category",buckets:$,cardinality:G}}function a(n,c,g,M,N){const{min:G,max:F,nulls:R,finite:X}=s(n,c,g);if(!X)return{kind:M,buckets:R?[{null:!0,label:"Empty"}]:[],empty:!0};const E=Math.max(1,Math.floor(N.buckets||K));let S=[];if(M==="date"){const H=T.includes(N.granularity)?N.granularity:C(F-G,E);let $=A(G,H);for(;$<=F&&S.length<4096;){const re=i($,H);if(!(re>$))break;S.push({from:$,to:re}),$=re}return{kind:M,buckets:m(S,R),granularity:H}}const U=_.includes(N.strategy)?N.strategy:"equal";if(U==="quantile"){const H=u(n,c,g,J);if(H.length){const $=[H[0]];for(let re=1;re<E;re++){const te=H[Math.min(H.length-1,Math.floor(re/E*H.length))];te>$[$.length-1]&&$.push(te)}$.push(F);for(let re=0;re<$.length-1;re++)S.push({from:$[re],to:$[re+1]})}}else if(U==="log"&&G>0){const H=Math.log10(G),re=(Math.log10(F)-H)/E||1;for(let te=0;te<E;te++)S.push({from:10**(H+te*re),to:10**(H+(te+1)*re)})}if(!S.length){const H=(F-G)/E||1;for(let $=0;$<E;$++)S.push({from:G+$*H,to:G+($+1)*H})}return S[S.length-1].to=F,{kind:M,buckets:m(S,R),strategy:U,min:G,max:F}}function m(n,c){return c>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,c,g,M,N){const G=M&&M.buckets||[],F=N&&N.length>=G.length?N.subarray(0,G.length):new Uint32Array(G.length);if(F.fill(0),!n||!G.length)return F;const R=G.length-1,X=!!G[R]&&G[R].null===!0,E=c?c.length:g;if(M.kind==="boolean"){const re=Q(n);for(let te=0;te<E;te++){const ae=re(c?c[te]:te);if(ae==null){X&&F[R]++;continue}F[ae?1:0]++}return F}if(M.kind==="category"){const re=new Map;for(let p=0;p<G.length;p++)!G[p].null&&!G[p].remainder&&re.set(G[p].value,p);const te=G.findIndex(p=>p.remainder),ae=Q(n);for(let p=0;p<E;p++){const B=ae(c?c[p]:p);if(B==null||B===""){X&&F[R]++;continue}if(Array.isArray(B)){if(!B.length){X&&F[R]++;continue}for(const oe of B){const w=re.get(oe);w!==void 0?F[w]++:te>=0&&F[te]++}continue}const q=re.get(B);q!==void 0?F[q]++:te>=0&&F[te]++}return F}const S=X?G.length-1:G.length,U=new Float64Array(S+1);for(let re=0;re<S;re++)U[re]=G[re].from;U[S]=S?G[S-1].to:0;const H=ue(n),$=he(n);for(let re=0;re<E;re++){const te=c?c[re]:re;if($&&!$(te)){X&&F[R]++;continue}const ae=H(te);if(!Number.isFinite(ae)){X&&F[R]++;continue}const p=d(U,S,ae);p>=0&&F[p]++}return F}function d(n,c,g){if(!c||g<n[0])return-1;if(g>=n[c])return g===n[c]?c-1:-1;let M=0,N=c-1;for(;M<N;){const G=M+N+1>>>1;g>=n[G]?M=G:N=G-1}return M}function h(n,c,g,M={}){const N=M.bounds||f(n,M.boundsIndices??c,g,M);return{bounds:N,counts:e(n,c,g,N)}}const r=h}),Se("packages/core/src/compute/special.js",function(o,me){"use strict";Object.defineProperty(o,"logGamma",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"incompleteBeta",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return ee}});const fe=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),he=3e-12,Q=1e-300;function z(C){if(C<.5)return Math.log(Math.PI/Math.sin(Math.PI*C))-z(1-C);const A=C-1;let i=.9999999999998099;const s=A+7.5;for(let u=0;u<fe.length;u++)i+=fe[u]/(A+u+1);return .5*Math.log(2*Math.PI)+(A+.5)*Math.log(s)-s+Math.log(i)}function ne(C,A,i){const s=C+A,u=C+1,f=C-1;let l=1,t=1-s*i/u;Math.abs(t)<Q&&(t=Q),t=1/t;let a=t;for(let m=1;m<=300;m++){const e=2*m;let d=m*(A-m)*i/((f+e)*(C+e));t=1+d*t,Math.abs(t)<Q&&(t=Q),l=1+d/l,Math.abs(l)<Q&&(l=Q),t=1/t,a*=t*l,d=-(C+m)*(s+m)*i/((C+e)*(u+e)),t=1+d*t,Math.abs(t)<Q&&(t=Q),l=1+d/l,Math.abs(l)<Q&&(l=Q),t=1/t;const h=t*l;if(a*=h,Math.abs(h-1)<he)break}return a}function _(C,A,i){if(!(C>0)||!(A>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const s=Math.exp(z(C+A)-z(C)-z(A)+C*Math.log(i)+A*Math.log(1-i));return i<(C+1)/(C+A+2)?s*ne(C,A,i)/C:1-s*ne(A,C,1-i)/A}function T(C){if(!(C>0)||!(C<1))return C===0?-1/0:C===1?1/0:Number.NaN;const A=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],i=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],s=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],u=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],f=.02425;let l,t,a;C<f?(l=Math.sqrt(-2*Math.log(C)),a=(((((s[0]*l+s[1])*l+s[2])*l+s[3])*l+s[4])*l+s[5])/((((u[0]*l+u[1])*l+u[2])*l+u[3])*l+1)):C<=1-f?(l=C-.5,t=l*l,a=(((((A[0]*t+A[1])*t+A[2])*t+A[3])*t+A[4])*t+A[5])*l/(((((i[0]*t+i[1])*t+i[2])*t+i[3])*t+i[4])*t+1)):(l=Math.sqrt(-2*Math.log(1-C)),a=-(((((s[0]*l+s[1])*l+s[2])*l+s[3])*l+s[4])*l+s[5])/((((u[0]*l+u[1])*l+u[2])*l+u[3])*l+1));const e=(.5*K(-a/Math.SQRT2)-C)*Math.sqrt(2*Math.PI)*Math.exp(a*a/2);return a-e/(1+a*e/2)}function K(C){const A=Math.abs(C),i=2/(2+A),s=4*i-2,u=[-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 f=0,l=0,t;for(let m=u.length-1;m>0;m--)t=l,l=s*l-f+u[m],f=t;const a=i*Math.exp(-A*A+.5*(u[0]+s*l)-f);return C>=0?a:2-a}function ie(C){return .5*K(-C/Math.SQRT2)}function J(C,A){if(!(A>0)||!Number.isFinite(C))return Number.NaN;const i=.5*_(A/2,.5,A/(A+C*C));return C>0?1-i:i}function le(C,A){if(!(C>0)||!(C<1)||!(A>0))return Number.NaN;if(A>1e7)return T(C);let i=-1e4,s=1e4,u=T(C);const f=z(A/2)+z(.5)-z((A+1)/2);for(let l=0;l<60;l++){const t=J(u,A);t<C?i=u:s=u;const a=Math.exp(-((A+1)/2)*Math.log(1+u*u/A)-f)/Math.sqrt(A),m=a>0?(t-C)/a:0;if(Math.abs(m)<1e-12)break;const e=u-m;if(u=e>i&&e<s&&Number.isFinite(e)?e:(i+s)/2,s-i<1e-12)break}return u}function ue(C,A){let i=C,s=1/C,u=s;for(let f=0;f<300&&(i+=1,u*=A/i,s+=u,!(Math.abs(u)<Math.abs(s)*he));f++);return s*Math.exp(-A+C*Math.log(A)-z(C))}function W(C,A){let i=A+1-C,s=1/Q,u=1/i,f=u;for(let l=1;l<=300;l++){const t=-l*(l-C);i+=2,u=t*u+i,Math.abs(u)<Q&&(u=Q),s=i+t/s,Math.abs(s)<Q&&(s=Q),u=1/u;const a=u*s;if(f*=a,Math.abs(a-1)<he)break}return Math.exp(-A+C*Math.log(A)-z(C))*f}function L(C,A){return!(C>0)||!(A>=0)||!Number.isFinite(A)?Number.NaN:A===0?0:A<C+1?ue(C,A):1-W(C,A)}function Y(C,A){return A>0?L(A/2,C/2):Number.NaN}function ee(C,A){const i=Y(C,A);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Se("packages/core/src/compute/linalg.js",function(o,me){"use strict";Object.defineProperty(o,"cholesky",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"choleskySolve",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"choleskyInverse",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return _}});function fe(T){const K=T.length,ie=Array.from({length:K},()=>new Array(K).fill(0));for(let J=0;J<K;J++)for(let le=0;le<=J;le++){let ue=T[J][le];for(let W=0;W<le;W++)ue-=ie[J][W]*ie[le][W];if(J===le){if(!(ue>0))return null;ie[J][le]=Math.sqrt(ue)}else ie[J][le]=ue/ie[le][le]}return ie}function he(T,K){const ie=T.length,J=new Array(ie).fill(0);for(let ue=0;ue<ie;ue++){let W=K[ue];for(let L=0;L<ue;L++)W-=T[ue][L]*J[L];J[ue]=W/T[ue][ue]}const le=new Array(ie).fill(0);for(let ue=ie-1;ue>=0;ue--){let W=J[ue];for(let L=ue+1;L<ie;L++)W-=T[L][ue]*le[L];le[ue]=W/T[ue][ue]}return le}function Q(T){const K=T.length,ie=Array.from({length:K},()=>new Array(K).fill(0));for(let J=0;J<K;J++){const le=new Array(K).fill(0);le[J]=1;const ue=he(T,le);for(let W=0;W<K;W++)ie[W][J]=ue[W]}return ie}function z(T,K,ie){const J=T.length,le=J?T[0].length:0,ue=Array.from({length:le},()=>new Array(le).fill(0)),W=new Array(le).fill(0);for(let L=0;L<J;L++){const Y=ie?ie[L]:1,ee=T[L];for(let C=0;C<le;C++){const A=Y*ee[C];W[C]+=A*K[L];for(let i=C;i<le;i++)ue[C][i]+=A*ee[i]}}for(let L=0;L<le;L++)for(let Y=0;Y<L;Y++)ue[L][Y]=ue[Y][L];return{xtwx:ue,xtwy:W}}function ne(T,K){return T.map(ie=>ie.reduce((J,le,ue)=>J+le*K[ue],0))}function _(T,K){let ie=0;for(let J=0;J<T.length;J++){let le=0;for(let ue=0;ue<T.length;ue++)le+=K[J][ue]*T[ue];ie+=T[J]*le}return ie}}),Se("packages/core/src/compute/sketch.js",function(o,me){"use strict";Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return ue}});class fe{#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(L){if(!Number.isFinite(L))return;this.#t++;const Y=L-this.#e;this.#e+=Y/this.#t,this.#n+=Y*(L-this.#e)}merge(L){if(L.#t===0)return;if(this.#t===0){this.#t=L.#t,this.#e=L.#e,this.#n=L.#n;return}const Y=this.#t+L.#t,ee=L.#e-this.#e;this.#e+=ee*(L.#t/Y),this.#n+=L.#n+ee*ee*(this.#t*L.#t/Y),this.#t=Y}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 L=this.variance();return L===null?null:Math.sqrt(L)}stddevP(){const L=this.varianceP();return L===null?null:Math.sqrt(L)}}class he{#t=[];#e=0;#n;#r;constructor(L,Y=Math.random){if(!(L>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(L),this.#r=Y}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(L){if(!Number.isFinite(L))return;if(this.#e++,this.#t.length<this.#n){this.#t.push(L);return}const Y=Math.floor(this.#r()*this.#e);Y<this.#n&&(this.#t[Y]=L)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let L=0;for(const Y of this.#t)L+=Y;return L/this.#t.length}quantile(L){const Y=this.#t.length;if(!Y)return null;const ee=this.#t.slice().sort((s,u)=>s-u);if(Y===1)return ee[0];const C=(Y-1)*Math.min(1,Math.max(0,L)),A=Math.floor(C),i=Math.ceil(C);return A===i?ee[A]:ee[A]+(C-A)*(ee[i]-ee[A])}}function Q(W){return W^=W>>>16,W=Math.imul(W,2246822507),W^=W>>>13,W=Math.imul(W,3266489909),W^=W>>>15,W>>>0}function z(W){if(typeof W=="number"){const ee=new DataView(new ArrayBuffer(8));return ee.setFloat64(0,W===0?0:W),Q(ee.getUint32(0)^ee.getUint32(4))}const L=typeof W=="string"?W:String(W);let Y=2166136261;for(let ee=0;ee<L.length;ee++)Y^=L.charCodeAt(ee),Y=Math.imul(Y,16777619);return Q(Y)}class ne{#t;#e;#n;constructor(L=14){const Y=Math.floor(L);if(Y<4||Y>16)throw new RangeError("HLL precision must be 4..16");this.#t=Y,this.#e=1<<Y,this.#n=new Uint8Array(this.#e)}static errorBoundFor(L=14){const Y=1<<Math.floor(L),ee=1.04/Math.sqrt(Y);return Object.freeze({kind:"probabilistic",metric:"relative",value:ee,statement:`distinct count within ~${(ee*100).toFixed(2)}% relative standard error (m=${Y} buckets)`})}errorBound(){return ne.errorBoundFor(this.#t)}add(L){const Y=z(L),ee=Y&this.#e-1,C=Y>>>this.#t|1<<32-this.#t;let A=1,i=C;for(;(i&1)===0;)A++,i>>>=1;A>this.#n[ee]&&(this.#n[ee]=A)}count(){const L=this.#e,Y=32-this.#t,ee=new Float64Array(Y+2);for(let i=0;i<L;i++)ee[this.#n[i]]++;let C=L*K(1-ee[Y+1]/L);for(let i=Y;i>=1;i--)C=.5*(C+ee[i]);C+=L*T(ee[0]/L);const A=_*L*L/C;return Math.round(A)}}const _=.5/Math.log(2);function T(W){if(W===1)return 1/0;let L=1,Y=W,ee;do W*=W,ee=Y,Y+=W*L,L+=L;while(Y!==ee);return Y}function K(W){if(W===0||W===1)return 0;let L=1,Y=1-W,ee;do W=Math.sqrt(W),ee=Y,L*=.5,Y-=(1-W)**2*L;while(Y!==ee);return Y/3}class ie{#t=new Map;#e;#n=0;constructor(L){if(!(L>0))throw new RangeError("Space-Saving capacity must be positive");this.#e=Math.floor(L)}errorBoundFor(L){const Y=L/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:Y,statement:`each count overestimates the truth by at most N/m = ${Y.toFixed(2)} (N=${L}, m=${this.#e})`})}get seen(){return this.#n}add(L){this.#n++;const Y=this.#t.get(L);if(Y){Y.count++;return}if(this.#t.size<this.#e){this.#t.set(L,{count:1,error:0});return}let ee,C=1/0;for(const[A,i]of this.#t)i.count<C&&(C=i.count,ee=A);this.#t.delete(ee),this.#t.set(L,{count:C+1,error:C})}top(L=this.#e){return[...this.#t.entries()].map(([ee,C])=>({item:ee,count:C.count,error:C.error})).sort((ee,C)=>C.count-ee.count).slice(0,Math.max(0,Math.floor(L)))}}class J{#t;#e=[[]];#n=0;#r;#i;constructor(L=200,Y=Math.random){this.#t=Math.max(8,Math.floor(L)),this.#r=Y,this.#i=2/3}static errorBoundFor(L=200){const Y=1/Math.max(8,Math.floor(L));return Object.freeze({kind:"probabilistic",metric:"rank",value:Y,statement:`queried quantile\'s true rank within ~${(Y*100).toFixed(2)}% of N of the requested rank (k=${L})`})}errorBound(){return J.errorBoundFor(this.#t)}get count(){return this.#n}#s(L){const ee=this.#e.length-1-L,C=Math.ceil(this.#t*this.#i**ee);return Math.max(2,C)}add(L){Number.isFinite(L)&&(this.#n++,this.#e[0].push(L),this.#e[0].length>=this.#s(0)&&this.#h(0))}#h(L){const Y=this.#e[L];Y.sort((A,i)=>A-i),L+1>=this.#e.length&&this.#e.push([]);const ee=this.#e[L+1],C=this.#r()<.5?0:1;for(let A=C;A<Y.length;A+=2)ee.push(Y[A]);this.#e[L]=[];for(let A=0;A<this.#e.length;A++)if(this.#e[A].length>=this.#s(A)){this.#h(A);return}}#u(){const L=[];for(let Y=0;Y<this.#e.length;Y++){const ee=1<<Y;for(const C of this.#e[Y])L.push({v:C,w:ee})}return L}quantile(L){const Y=this.#u();if(!Y.length)return null;Y.sort((i,s)=>i.v-s.v);let ee=0;for(const i of Y)ee+=i.w;const C=Math.min(1,Math.max(0,L))*ee;let A=0;for(const i of Y)if(A+=i.w,A>=C)return i.v;return Y[Y.length-1].v}rank(L){let Y=0;for(let ee=0;ee<this.#e.length;ee++){const C=1<<ee;for(const A of this.#e[ee])A<=L&&(Y+=C)}return Y}}const le=Object.freeze({distinct:ne.errorBoundFor(14),median:J.errorBoundFor(200),p25:J.errorBoundFor(200),p75:J.errorBoundFor(200),p90:J.errorBoundFor(200),p95:J.errorBoundFor(200),p99:J.errorBoundFor(200),iqr:J.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"})}),ue={Welford:fe,Reservoir:he,HyperLogLog:ne,SpaceSaving:ie,KLL:J,hash32:z,SKETCH_BOUNDS:le}}),Se("packages/core/src/compute/statistics.js",function(o,me){"use strict";Object.defineProperty(o,"KENDALL_LIMIT",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"numbers",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"frequencies",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"herfindahl",{enumerable:!0,get:function(){return a}}),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 h}}),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 M}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"weightedAverage",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"extremeRow",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"correlation",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"fitLinearModel",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(o,"autocorrelations",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(o,"spearman",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(o,"kendall",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(o,"seriesStats",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(o,"D2_N2",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(o,"D4_N2",{enumerable:!0,get:function(){return st}}),Object.defineProperty(o,"movingRanges",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(o,"withinSigma",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(o,"capability",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(o,"controlLimits",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(o,"westernElectricViolations",{enumerable:!0,get:function(){return ut}}),Object.defineProperty(o,"nelsonViolations",{enumerable:!0,get:function(){return ct}}),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 Ge}}),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 lt}}),Object.defineProperty(o,"normalTotalVariation",{enumerable:!0,get:function(){return at}}),Object.defineProperty(o,"frequencyMap",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(o,"categoricalDistance",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(o,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return et}}),Object.defineProperty(o,"compareColumn",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(o,"isNumericColumn",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(o,"populationRead",{enumerable:!0,get:function(){return Rt}});const fe=me("packages/core/src/compute/handle.js"),he=fe.presenceReader,Q=fe.valueReader,z=me("packages/core/src/compute/special.js"),ne=z.studentTQuantile,_=z.studentT,T=z.normalQuantile,K=z.normalCdf,ie=z.chiSquareUpperTail,J=me("packages/core/src/compute/linalg.js"),le=J.cholesky,ue=J.choleskySolve,W=J.choleskyInverse,L=J.normalEquations,Y=J.quadForm,C=me("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,A=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"}),s=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:C.distinct}),median:Object.freeze({sketch:"KLL",bound:C.median}),p25:Object.freeze({sketch:"KLL",bound:C.p25}),p75:Object.freeze({sketch:"KLL",bound:C.p75}),p90:Object.freeze({sketch:"KLL",bound:C.p90}),p95:Object.freeze({sketch:"KLL",bound:C.p95}),p99:Object.freeze({sketch:"KLL",bound:C.p99}),iqr:Object.freeze({sketch:"KLL",bound:C.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:C.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:C.topK})});function u(b){const j=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(s,b)?s[b]:null;return{stat:b,exact:j,approximate:y}}function f(b,j){const y=j.length,O=new Float64Array(y);let k=0;if(b&&(b.kind==="float64"||b.kind==="int32")){const I=b.values,D=he(b);for(let se=0;se<y;se++){const ce=j[se];if(D&&D(ce)!==1)continue;const Oe=I[ce];Number.isNaN(Oe)||(O[k++]=Oe)}return O.subarray(0,k)}const V=Q(b);for(let I=0;I<y;I++){const D=V(j[I]);if(D==null||D==="")continue;const se=typeof D=="number"?D:Number(D);Number.isFinite(se)&&(O[k++]=se)}return O.subarray(0,k)}function l(b,j){const y=new Map,O=Q(b);let k=0;for(let V=0;V<j.length;V++){const I=O(j[V]);if(I==null||I===""||typeof I=="number"&&Number.isNaN(I))continue;const D=typeof I=="object"?String(I):I;y.set(D,(y.get(D)||0)+1),k++}const P=[...y.values()].sort((V,I)=>I-V);return{counts:P,total:k,distinct:P.length}}function t(b){return b.total>0?b.counts.map(j=>j/b.total):[]}function a(b,j){const y=l(b,j);if(!y.total)return null;let O=0;for(const k of t(y))O+=k*k;return O}function m(b,j){const y=l(b,j);if(!y.total)return null;let O=0;for(const k of t(y))k>0&&(O-=k*Math.log2(k));return O}function e(b,j){const y=l(b,j);if(!y.total||y.distinct<2)return y.total?1:null;let O=0;for(const k of t(y))k>0&&(O-=k*Math.log2(k));return O/Math.log2(y.distinct)}function d(b,j,y=3){const O=l(b,j);if(!O.total)return null;const k=Math.max(1,Math.floor(y));let P=0;for(let V=0;V<Math.min(k,O.counts.length);V++)P+=O.counts[V];return P/O.total}function h(b,j){const y=f(b,j),O=y.length;if(!O)return null;const k=y.slice().sort();if(k[0]<0)return null;let P=0,V=0;for(let I=0;I<O;I++)P+=k[I],V+=(I+1)*k[I];return P===0?0:2*V/(O*P)-(O+1)/O}function r(b){let j=0,y=0,O=0;for(let k=0;k<b.length;k++){const P=b[k];j++;const V=P-y;y+=V/j,O+=V*(P-y)}return{n:j,mean:y,m2:O}}function n(b,j){const y=b.length;if(!y)return NaN;if(y===1)return b[0];const O=(y-1)*Math.min(1,Math.max(0,j)),k=Math.floor(O),P=Math.ceil(O);return k===P?b[k]:b[k]+(O-k)*(b[P]-b[k])}function c(b,j){if(!b.length)return NaN;const y=b.slice().sort();return n(y,j)}function g(b,j){const y=Q(b);let O=0,k=0,P=0;for(let V=0;V<j.length;V++){const I=y(j[V]);if(I==null||I==="")continue;const D=String(I).toUpperCase();D==="PASS"?O++:D==="FAIL"?k++:D==="WARN"&&P++}return{pass:O+P,fail:k,warn:P,judged:O+P+k}}const M=Object.freeze({hhi:(b,j)=>a(b,j),entropy:(b,j)=>m(b,j),evenness:(b,j)=>e(b,j),top3Share:(b,j)=>d(b,j,3),top10Share:(b,j)=>d(b,j,10),gini:(b,j)=>h(b,j),trimmedMean:(b,j)=>X(f(b,j),.1),winsorizedMean:(b,j)=>E(f(b,j),.1),robustOutliers:(b,j)=>S(f(b,j),3.5),jarqueBera:(b,j)=>U(f(b,j)),variance:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>1?O/(y-1):null},varianceP:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>0?O/y:null},stddev:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>1?Math.sqrt(O/(y-1)):null},stddevP:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>0?Math.sqrt(O/y):null},median:(b,j)=>{const y=f(b,j);return y.length?c(y,.5):null},p25:(b,j)=>{const y=f(b,j);return y.length?c(y,.25):null},p75:(b,j)=>{const y=f(b,j);return y.length?c(y,.75):null},p90:(b,j)=>{const y=f(b,j);return y.length?c(y,.9):null},p95:(b,j)=>{const y=f(b,j);return y.length?c(y,.95):null},p99:(b,j)=>{const y=f(b,j);return y.length?c(y,.99):null},iqr:(b,j)=>{const y=f(b,j);if(!y.length)return null;const O=y.slice().sort();return n(O,.75)-n(O,.25)},mad:(b,j)=>{const y=f(b,j);if(!y.length)return null;const O=c(y,.5),k=new Float64Array(y.length);for(let P=0;P<y.length;P++)k[P]=Math.abs(y[P]-O);return c(k,.5)},range:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=1/0,k=-1/0;for(let P=0;P<y.length;P++)y[P]<O&&(O=y[P]),y[P]>k&&(k=y[P]);return k-O},distinct:(b,j)=>{const y=Q(b),O=new Set;for(let k=0;k<j.length;k++){const P=y(j[k]);P==null||P===""||O.add(P instanceof Date?P.getTime():P)}return O.size},mode:(b,j)=>{const y=Q(b),O=new Map;for(let V=0;V<j.length;V++){const I=y(j[V]);if(I==null||I==="")continue;const D=I instanceof Date?I.getTime():I;O.set(D,(O.get(D)||0)+1)}let k=null,P=1;for(const[V,I]of O)I>P&&(P=I,k=V);return k},skewness:(b,j)=>{const y=f(b,j),{n:O,mean:k,m2:P}=r(y);if(O<3||P<=0)return null;const V=Math.sqrt(P/(O-1));let I=0;for(let D=0;D<y.length;D++)I+=((y[D]-k)/V)**3;return O/((O-1)*(O-2))*I},kurtosis:(b,j)=>{const y=f(b,j),{n:O,mean:k,m2:P}=r(y);if(O<4||P<=0)return null;const V=Math.sqrt(P/(O-1));let I=0;for(let ce=0;ce<y.length;ce++)I+=((y[ce]-k)/V)**4;const D=O*(O+1)/((O-1)*(O-2)*(O-3)),se=3*(O-1)**2/((O-2)*(O-3));return D*I-se},geomean:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=0;for(let k=0;k<y.length;k++){if(y[k]<=0)return null;O+=Math.log(y[k])}return Math.exp(O/y.length)},harmean:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=0;for(let k=0;k<y.length;k++){if(y[k]===0)return null;O+=1/y[k]}return y.length/O},sumSquares:(b,j)=>{const y=f(b,j);let O=0;for(let k=0;k<y.length;k++)O+=y[k]*y[k];return O},passRate:(b,j)=>{const{pass:y,judged:O}=g(b,j);return O?y/O:null},failureCount:(b,j)=>g(b,j).fail}),N=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 G(b,j,y){const O=Q(b),k=Q(j);let P=0,V=0;for(let I=0;I<y.length;I++){const D=y[I],se=Number(O(D)),ce=Number(k(D));!Number.isFinite(se)||!Number.isFinite(ce)||(P+=se*ce,V+=ce)}return V===0?null:P/V}function F(b,j,y){const O=Q(b);let k=null,P=y?-1/0:1/0;for(let V=0;V<j.length;V++){const I=j[V],D=Number(O(I));Number.isFinite(D)&&(y?D>P:D<P)&&(P=D,k=I)}return k}function R(b,j,y){const O=Q(b),k=Q(j);let P=0,V=0,I=0,D=0,se=0,ce=0;for(let be=0;be<y.length;be++){const Ae=y[be],Pe=Number(O(Ae)),ye=Number(k(Ae));!Number.isFinite(Pe)||!Number.isFinite(ye)||(P++,V+=Pe,I+=ye,D+=Pe*Pe,se+=ye*ye,ce+=Pe*ye)}if(P<2)return null;const Oe=P*ce-V*I,ke=Math.sqrt((P*D-V*V)*(P*se-I*I));if(ke===0)return null;const je=Oe/ke;return Math.max(-1,Math.min(1,je))}function X(b,j=.1){const y=b.length;if(!y)return null;const O=Array.from(b).sort((I,D)=>I-D),k=Math.floor(y*Math.min(.49,Math.max(0,j))),P=O.slice(k,y-k);if(!P.length)return n(O,.5);let V=0;for(const I of P)V+=I;return V/P.length}function E(b,j=.1){const y=b.length;if(!y)return null;const O=Array.from(b).sort((D,se)=>D-se),k=Math.floor(y*Math.min(.49,Math.max(0,j))),P=O[k],V=O[y-1-k];let I=0;for(const D of O)I+=Math.min(V,Math.max(P,D));return I/y}function S(b,j=3.5){if(!b.length)return null;const O=Array.from(b).sort((D,se)=>D-se),k=n(O,.5),P=O.map(D=>Math.abs(D-k)).sort((D,se)=>D-se),V=n(P,.5);if(V===0)return null;let I=0;for(const D of O)Math.abs(.6745*(D-k)/V)>j&&I++;return I}function U(b){const j=b.length;if(j<8)return null;let y=0;for(const D of b)y+=D;y/=j;let O=0,k=0,P=0;for(const D of b){const se=D-y;O+=se*se,k+=se*se*se,P+=se*se*se*se}if(O/=j,k/=j,P/=j,O===0)return null;const V=k/O**1.5,I=P/(O*O)-3;return j/6*(V*V+I*I/4)}function H(b,j,y){const O=[];let k=0;for(let D=0;D<b.length;D++){const se=Number(b[D]),ce=Number(j[D]);!Number.isFinite(se)||!Number.isFinite(ce)||ce<=0||(O.push([se,ce]),k+=ce)}if(!O.length||k<=0)return null;if(O.sort((D,se)=>D[0]-se[0]),O.length===1)return O[0][0];const P=[];let V=0;for(const[,D]of O)P.push((V+D/2)/k),V+=D;const I=Math.max(0,Math.min(1,y));if(I<=P[0])return O[0][0];if(I>=P[P.length-1])return O[O.length-1][0];for(let D=1;D<P.length;D++){if(I>P[D])continue;const se=P[D]-P[D-1],ce=se>0?(I-P[D-1])/se:0;return O[D-1][0]+(O[D][0]-O[D-1][0])*ce}return O[O.length-1][0]}function $(b,j,y){const O=Q(b),k=Q(j),P=new Float64Array(y.length),V=new Float64Array(y.length);let I=0;for(let D=0;D<y.length;D++){const se=y[D],ce=Number(O(se)),Oe=Number(k(se));!Number.isFinite(ce)||!Number.isFinite(Oe)||(P[I]=ce,V[I]=Oe,I++)}return{xs:P.subarray(0,I),ys:V.subarray(0,I),n:I}}function re(b,j,y,O=!1){const{xs:k,ys:P,n:V}=$(b,j,y);if(V<2)return null;let I=0,D=0;for(let ce=0;ce<V;ce++)I+=k[ce],D+=P[ce];I/=V,D/=V;let se=0;for(let ce=0;ce<V;ce++)se+=(k[ce]-I)*(P[ce]-D);return se/(O?V:V-1)}function te(b,j,y){const{xs:O,ys:k,n:P}=$(b,j,y);if(P<2)return null;let V=0,I=0;for(let Pe=0;Pe<P;Pe++)V+=O[Pe],I+=k[Pe];V/=P,I/=P;let D=0,se=0,ce=0;for(let Pe=0;Pe<P;Pe++){const ye=O[Pe]-V,ve=k[Pe]-I;D+=ye*ye,se+=ye*ve,ce+=ve*ve}if(D===0)return null;const Oe=se/D,ke=I-Oe*V,je=ce===0?1:Math.max(0,Math.min(1,se*se/(D*ce))),be=Math.max(0,ce-Oe*se),Ae=P>2?Math.sqrt(be/(P-2)/D):0;return{slope:Oe,intercept:ke,r2:je,stdError:Ae,n:P}}const ae=new Set(["ols","wls","robust"]),p=new Set(["quantile"]),B=new Set(["ridge","lasso","elasticnet","mixed","gls"]),q=1.345;function oe(b,j,y){const{xtwx:O,xtwy:k}=L(b,j,y),P=le(O);if(!P)return null;const V=ue(P,k),I=W(P),D=w(b,V),se=j.map((ce,Oe)=>ce-D[Oe]);return{beta:V,cov:I,fitted:D,residuals:se}}function w(b,j){return b.map(y=>y.reduce((O,k,P)=>O+k*j[P],0))}function v(b,j){const y=b.length,O=b.map(se=>se[j]),k=b.map(se=>[1,...se.filter((ce,Oe)=>Oe!==j)]),P=oe(k,O,null);if(!P)return 1;const V=O.reduce((se,ce)=>se+ce,0)/y;let I=0,D=0;for(let se=0;se<y;se++)I+=P.residuals[se]**2,D+=(O[se]-V)**2;return D===0?1:Math.max(0,Math.min(1,1-I/D))}function Z(b){const j=[...b].sort((k,P)=>k-P),y=x(j),O=b.map(k=>Math.abs(k-y)).sort((k,P)=>k-P);return x(O)/.6745}function x(b){const j=b.length;if(!j)return 0;const y=Math.floor(j/2);return j%2?b[y]:(b[y-1]+b[y])/2}function de(b,j,y={}){const O=y.method||"ols";if(B.has(O))throw new Error(`[lattice] regression method "${O}" is out of scope; use ols, wls or robust.`);if(p.has(O))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!ae.has(O))throw new Error(`[lattice] unknown regression method "${O}"; use ols, wls or robust.`);const k=Array.isArray(j)?j.length:0,P=k&&Array.isArray(b[0])?b[0].length:0,V=P+1;if(!(k>V))return null;for(let Me=0;Me<k;Me++){if(!Number.isFinite(j[Me])||!Array.isArray(b[Me])||b[Me].length!==P)return null;for(let Ne=0;Ne<P;Ne++)if(!Number.isFinite(b[Me][Ne]))return null}let I=null;if(O==="wls"){if(I=y.weights,!Array.isArray(I)||I.length!==k)return null;for(let Me=0;Me<k;Me++)if(!(I[Me]>0)||!Number.isFinite(I[Me]))return null}const D=b.map(Me=>[1,...Me]);let se,ce=null;if(O==="robust"){if(se=oe(D,j,null),!se)return null;for(let Me=0;Me<50;Me++){const Ne=Z(se.residuals);if(!(Ne>0))break;const Re=se.residuals.map($e=>{const We=Math.abs($e/Ne);return We<=q?1:q/We}),Ce=oe(D,j,Re);if(!Ce)return null;const Ve=Ce.beta.reduce(($e,We,Je)=>Math.max($e,Math.abs(We-se.beta[Je])),0);if(se=Ce,ce=Re,Ve<1e-10)break}}else if(se=oe(D,j,I),!se)return null;const Oe=O==="robust"?ce:I,{beta:ke,cov:je,fitted:be,residuals:Ae}=se;let Pe=0,ye=0,ve=0;for(let Me=0;Me<k;Me++){const Ne=Oe?Oe[Me]:1;Pe+=Ne*Ae[Me]**2,ye+=Ne,ve+=Ne*j[Me]}const Fe=ve/ye;let Ie=0;for(let Me=0;Me<k;Me++){const Ne=Oe?Oe[Me]:1;Ie+=Ne*(j[Me]-Fe)**2}const De=k-V,qe=Pe/De,Ue=Ie===0?1:Math.max(0,Math.min(1,1-Pe/Ie)),tt=1-(1-Ue)*(k-1)/De,Xe=Array.isArray(y.names)&&y.names.length===P?y.names:b[0].map((Me,Ne)=>`x${Ne+1}`),He=Qe(y.confidence),Ze=De>0?ne(1-(1-He)/2,De):1/0,Lt=ke.map((Me,Ne)=>{const Re=Math.sqrt(Math.max(0,qe*je[Ne][Ne])),Ce=Re>0?Me/Re:Me===0?0:1/0,Ve=Number.isFinite(Ce)?2*(1-_(Math.abs(Ce),De)):0,$e=Number.isFinite(Ze)?Ze*Re:null;return{name:Ne===0?"(intercept)":Xe[Ne-1],estimate:Me,stdError:Re,t:Ce,p:Math.max(0,Math.min(1,Ve)),lower:$e===null?null:Me-$e,upper:$e===null?null:Me+$e}}),dt=new Array(k),mt=new Array(k);for(let Me=0;Me<k;Me++){const Ne=Oe?Oe[Me]:1,Re=Math.max(0,Math.min(1,Ne*Y(D[Me],je)));dt[Me]=Re;const Ce=(1-Re)**2;mt[Me]=Ce>0&&qe>0?Ae[Me]**2/(V*qe)*(Re/Ce):null}const Ft=b[0].map((Me,Ne)=>{if(P<2)return 1;const Re=v(b,Ne);return Re>=1?1/0:1/(1-Re)});let gt=null;{const Me=Ae.map(Re=>Re*Re),Ne=oe(D,Me,null);if(Ne){const Re=Me.reduce((Ye,Ct)=>Ye+Ct,0)/k;let Ce=0,Ve=0;for(let Ye=0;Ye<k;Ye++)Ce+=Ne.residuals[Ye]**2,Ve+=(Me[Ye]-Re)**2;const $e=Ve===0?0:Math.max(0,Math.min(1,1-Ce/Ve)),We=k*$e,Je=ie(We,P);gt={statistic:We,df:P,p:Je,heteroscedastic:Je<.05}}}let bt=null;if(P===1){const Me=b.map((Ne,Re)=>Re).sort((Ne,Re)=>b[Ne][0]-b[Re][0]);bt={confidence:He,points:Me.map(Ne=>{const Re=D[Ne],Ce=Math.sqrt(Math.max(0,qe*Y(Re,je)));return{x:b[Ne][0],yhat:be[Ne],lower:be[Ne]-Ze*Ce,upper:be[Ne]+Ze*Ce}})}}return{method:O,coefficients:Lt,r2:Ue,adjR2:tt,n:k,df:De,sigma2:qe,fitted:be,residuals:Ae,leverage:dt,cooksD:mt,vif:Ft,heteroscedasticity:gt,band:bt,weights:Oe?[...Oe]:null}}function we(b){const j=b.length,y=Array.from({length:j},(P,V)=>V).sort((P,V)=>b[P]-b[V]),O=new Float64Array(j);let k=0;for(;k<j;){let P=k;for(;P+1<j&&b[y[P+1]]===b[y[k]];)P++;const V=(k+P)/2+1;for(let I=k;I<=P;I++)O[y[I]]=V;k=P+1}return O}const ge=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function pe(b){const j=[.01,.05,.1],y=[ge["1%"],ge["5%"],ge["10%"]];if(b<=y[0]){const P=(Math.log(j[1])-Math.log(j[0]))/(y[1]-y[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(j[0])+P*(b-y[0]))))}if(b>=y[2]){const P=(Math.log(j[2])-Math.log(j[1]))/(y[2]-y[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(j[2])+P*(b-y[2]))))}const O=b<y[1]?0:1,k=(b-y[O])/(y[O+1]-y[O]);return Math.exp(Math.log(j[O])+k*(Math.log(j[O+1])-Math.log(j[O])))}function Te(b,j,y,O){const k=y-O,P=O+3,V=new Array(k),I=new Array(k);let D=!0,se=O;for(let be=0;be<k;be++){const Ae=O+be,Pe=new Float64Array(P);Pe[0]=1,Pe[1]=be+1,Pe[2]=b[Ae];for(let ye=1;ye<=O;ye++)Pe[2+ye]=j[Ae-ye];for(let ye=1;ye<P;ye++)Number.isFinite(Pe[ye])||(se=Math.min(se,ye-3));V[be]=Pe,I[be]=j[Ae],Number.isFinite(I[be])||(D=!1)}if(!D)return 0;const{xtwx:ce,xtwy:Oe}=L(V,I,null);let ke=0,je=1/0;for(let be=0;be<=se;be++){const Ae=be+3;if(!(k>Ae))continue;const Pe=new Array(Ae);for(let Ue=0;Ue<Ae;Ue++)Pe[Ue]=ce[Ue].slice(0,Ae);const ye=le(Pe);if(!ye)continue;const ve=ue(ye,Oe.slice(0,Ae));let Fe=0;for(let Ue=0;Ue<k;Ue++){const tt=V[Ue];let Xe=0;for(let He=0;He<Ae;He++)Xe+=tt[He]*ve[He];Fe+=(I[Ue]-Xe)**2}const De=Fe/(k-Ae)*(k-Ae);if(!(De>0))continue;const qe=k*Math.log(De/k)+2*Ae;qe<je&&(je=qe,ke=be)}return ke}function Le(b,j={}){const y=[];for(let je=0;je<b.length;je++){const be=Number(b[je]);Number.isFinite(be)&&y.push(be)}const O=y.length,k=O-1;if(O<8||k<6)return null;const P=new Array(k);for(let je=0;je<k;je++)P[je]=y[je+1]-y[je];let V=Number.isFinite(j.maxlag)?Math.floor(j.maxlag):Math.ceil(12*(O/100)**.25);V=Math.max(0,Math.min(V,Math.floor((k-5)/2)));const I=(je,be)=>{const Ae=[],Pe=[];for(let ye=be;ye<k;ye++){const ve=[ye-be+1,y[ye]];for(let Fe=1;Fe<=je;Fe++)ve.push(P[ye-Fe]);Ae.push(ve),Pe.push(P[ye])}return de(Ae,Pe,{method:"ols"})},D=Te(y,P,k,V),se=I(D,D);if(!se||!se.coefficients[2])return null;const ce=se.coefficients[2].t,Oe=pe(ce),ke=ce<ge["5%"];return{statistic:ce,usedLag:D,nobs:k-D,criticalValues:{...ge},pValue:Oe,pApproximate:!0,stationary:ke,verdict:ke?"stationary":"non-stationary",regression:"ct"}}function Be(b,j={}){const y=[];for(let ke=0;ke<b.length;ke++){const je=Number(b[ke]);Number.isFinite(je)&&y.push(je)}const O=y.length;if(O<3)return null;let k=Number.isFinite(j.maxlag)?Math.floor(j.maxlag):Math.min(10,O-1);k=Math.max(1,Math.min(k,O-1));let P=0;for(const ke of y)P+=ke;P/=O;const V=y.map(ke=>ke-P);let I=0;for(const ke of V)I+=ke*ke;I/=O;const D=new Array(k+1).fill(0);D[0]=1;for(let ke=1;ke<=k;ke++){let je=0;for(let be=ke;be<O;be++)je+=V[be]*V[be-ke];D[ke]=I>0?je/O/I:0}const se=new Array(k+1).fill(0);se[0]=1;let ce=[];for(let ke=1;ke<=k;ke++){let je=D[ke];for(let ye=1;ye<ke;ye++)je-=ce[ye-1]*D[ke-ye];let be=1;for(let ye=1;ye<ke;ye++)be-=ce[ye-1]*D[ye];const Ae=be!==0?je/be:0,Pe=new Array(ke);for(let ye=1;ye<ke;ye++)Pe[ye-1]=ce[ye-1]-Ae*ce[ke-1-ye];Pe[ke-1]=Ae,se[ke]=Ae,ce=Pe}const Oe=1.96/Math.sqrt(O);return{acf:D,pacf:se,bounds:{upper:Oe,lower:-Oe},n:O,nlags:k,approximate:!0}}function ze(b,j,y){const{xs:O,ys:k,n:P}=$(b,j,y);if(P<2)return null;const V=we(O),I=we(k);let D=0,se=0;for(let je=0;je<P;je++)D+=V[je],se+=I[je];D/=P,se/=P;let ce=0,Oe=0,ke=0;for(let je=0;je<P;je++){const be=V[je]-D,Ae=I[je]-se;ce+=be*Ae,Oe+=be*be,ke+=Ae*Ae}return Oe===0||ke===0?null:Math.max(-1,Math.min(1,ce/Math.sqrt(Oe*ke)))}function Ke(b,j,y){const{xs:O,ys:k,n:P}=$(b,j,y);if(P<2||P>A)return null;let V=0,I=0,D=0,se=0;for(let ke=0;ke<P;ke++)for(let je=ke+1;je<P;je++){const be=Math.sign(O[ke]-O[je]),Ae=Math.sign(k[ke]-k[je]),Pe=be*Ae;Pe>0?V++:Pe<0?I++:be===0&&Ae===0||(be===0?D++:se++)}const ce=V+I+se,Oe=V+I+D;return ce===0||Oe===0?null:(V-I)/Math.sqrt(ce*Oe)}function Ee(b,j={}){const y=b.length;if(y<2)return null;const O=b[0],k=b[y-1],P=[];for(let ye=1;ye<y;ye++){const ve=b[ye-1];ve!==0&&P.push((b[ye]-ve)/Math.abs(ve))}let V=null;if(P.length>1){let ye=0;for(const Fe of P)ye+=Fe;ye/=P.length;let ve=0;for(const Fe of P)ve+=(Fe-ye)**2;V=Math.sqrt(ve/(P.length-1))}const I=Number(j.periodsPerYear)>0?Number(j.periodsPerYear):null;let D=b[0],se=0,ce=0,Oe=0,ke=0;for(let ye=1;ye<y;ye++){if(b[ye]>D){D=b[ye],se=ye;continue}if(D<=0)continue;const ve=(D-b[ye])/D;ve>ce&&(ce=ve,Oe=se,ke=ye)}let je=null;if(y>2){let ye=0;for(let Ie=0;Ie<y;Ie++)ye+=b[Ie];ye/=y;let ve=0,Fe=0;for(let Ie=0;Ie<y;Ie++){const De=b[Ie]-ye;Fe+=De*De,Ie>0&&(ve+=De*(b[Ie-1]-ye))}je=Fe>0?ve/Fe:null}let be=0,Ae=0;for(const ye of P)ye>0?be++:ye<0&&Ae++;let Pe=null;if(O>0&&k>0){const ye=(k/O)**(1/(y-1))-1;Pe=I?(1+ye)**I-1:ye}return{n:y,first:O,last:k,change:k-O,changePercent:O===0?null:(k-O)/Math.abs(O)*100,volatility:V,annualisedVolatility:V!==null&&I?V*Math.sqrt(I):null,growth:Pe,maxDrawdown:ce,maxDrawdownFrom:Oe,maxDrawdownTo:ke,autocorrelation:je,upDays:be,downDays:Ae}}const ot=1.128,st=3.267;function wt(b){const j=b.length;if(j<2)return null;const y=[];for(let k=1;k<j;k++)y.push(Math.abs(b[k]-b[k-1]));const O=y.reduce((k,P)=>k+P,0)/y.length;return{ranges:y,centre:O,upper:st*O,lower:0}}function xe(b){const j=b.length;if(j<2)return null;let y=0;for(let k=1;k<j;k++)y+=Math.abs(b[k]-b[k-1]);const O=y/(j-1);return{sigma:O/ot,meanRange:O}}function Ot(b,j){const y=b.length;if(y<2||!j)return null;const O=Number.isFinite(Number(j.lower))?Number(j.lower):null,k=Number.isFinite(Number(j.upper))?Number(j.upper):null;if(O===null&&k===null)return null;let P=0;for(let be=0;be<y;be++)P+=b[be];P/=y;let V=0;for(let be=0;be<y;be++)V+=(b[be]-P)**2;const I=Math.sqrt(V/(y-1)),D=xe(b),se=D?D.sigma:null,ce=be=>{if(!be||be<=0)return{index:null,k:null};const Pe=O!==null&&k!==null?(k-O)/(6*be):null,ye=k!==null?(k-P)/(3*be):1/0,ve=O!==null?(P-O)/(3*be):1/0;return{index:Pe,k:Math.min(ye,ve)}},Oe=ce(se),ke=ce(I);let je=0;for(let be=0;be<y;be++){if(O!==null&&b[be]<O){je++;continue}k!==null&&b[be]>k&&je++}return{n:y,mean:P,lower:O,upper:k,target:Number.isFinite(Number(j.target))?Number(j.target):null,sigmaWithin:se,sigmaOverall:I,cp:Oe.index,cpk:Oe.k,pp:ke.index,ppk:ke.k,outOfSpec:je,defectRate:y?je/y:null}}function kt(b){const j=b.length;if(j<2)return null;const y=xe(b);if(!y||!(y.sigma>0))return null;let O=0;for(let k=0;k<j;k++)O+=b[k];return O/=j,{centre:O,sigma:y.sigma,upper:O+3*y.sigma,lower:O-3*y.sigma}}function ut(b,j){if(!j||!(j.sigma>0))return[];const y=b.length,{centre:O,sigma:k}=j,P=I=>(b[I]-O)/k,V=[];for(let I=0;I<y;I++){if(Math.abs(P(I))>3&&V.push({index:I,rule:1,description:"beyond three sigma"}),I>=2)for(const D of[1,-1]){let se=0;for(let ce=I-2;ce<=I;ce++)P(ce)*D>2&&se++;if(se>=2){V.push({index:I,rule:2,description:"two of three past two sigma"});break}}if(I>=4)for(const D of[1,-1]){let se=0;for(let ce=I-4;ce<=I;ce++)P(ce)*D>1&&se++;if(se>=4){V.push({index:I,rule:3,description:"four of five past one sigma"});break}}if(I>=7)for(const D of[1,-1]){let se=!0;for(let ce=I-7;ce<=I;ce++)if(P(ce)*D<=0){se=!1;break}if(se){V.push({index:I,rule:4,description:"eight in a row on one side"});break}}}return V}function ct(b,j){if(!j||!(j.sigma>0))return[];const y=b.length,{centre:O,sigma:k}=j,P=D=>(b[D]-O)/k,V=(D,se,ce,Oe)=>{for(const ke of[1,-1]){let je=0;for(let be=D;be<=se;be++)P(be)*ke>ce&&je++;if(je>=Oe)return!0}return!1},I=[];for(let D=0;D<y;D++){if(Math.abs(P(D))>3&&I.push({index:D,rule:1,description:"beyond three sigma"}),D>=8)for(const se of[1,-1]){let ce=!0;for(let Oe=D-8;Oe<=D;Oe++)if(P(Oe)*se<=0){ce=!1;break}if(ce){I.push({index:D,rule:2,description:"nine in a row on one side"});break}}if(D>=5)for(const se of[1,-1]){let ce=!0;for(let Oe=D-4;Oe<=D;Oe++)if((b[Oe]-b[Oe-1])*se<=0){ce=!1;break}if(ce){I.push({index:D,rule:3,description:se>0?"six rising":"six falling"});break}}if(D>=13){let se=!0;for(let ce=D-12;ce<=D;ce++){const Oe=b[ce]-b[ce-1],ke=b[ce+1<=D?ce+1:ce]-b[ce];if(ce+1>D)break;if(Oe===0||ke===0||Oe>0==ke>0){se=!1;break}}se&&I.push({index:D,rule:4,description:"fourteen alternating"})}if(D>=2&&V(D-2,D,2,2)&&I.push({index:D,rule:5,description:"two of three past two sigma"}),D>=4&&V(D-4,D,1,4)&&I.push({index:D,rule:6,description:"four of five past one sigma"}),D>=14){let se=!0;for(let ce=D-14;ce<=D;ce++)if(Math.abs(P(ce))>=1){se=!1;break}se&&I.push({index:D,rule:7,description:"fifteen within one sigma"})}if(D>=7){let se=!0;for(let ce=D-7;ce<=D;ce++)if(Math.abs(P(ce))<=1){se=!1;break}se&&I.push({index:D,rule:8,description:"eight beyond one sigma"})}}return I}const jt=Object.freeze(["westernElectric","nelson"]);function At(b,j,y="westernElectric"){return String(y)==="nelson"?ct(b,j):ut(b,j)}function Mt(b,j,y){let O=0;for(let k=0;k<b.length;k++)(b[k]<j||b[k]>y)&&O++;return O}function Pt(b,j,y,O=20){const k=b.length;if(!k)return[];const P=b[0],V=b[k-1];if(V===P)return[{from:P,to:V,count:k}];const I=y-j,D=1.5*I;let se=I>0?Math.max(P,j-D):P,ce=I>0?Math.min(V,y+D):V;ce>se||(se=P,ce=V);const Oe=I>0?2*I/Math.cbrt(k):(ce-se)/(Math.ceil(Math.log2(k))+1),ke=Oe>0?Math.min(O,Math.max(1,Math.ceil((ce-se)/Oe))):1,je=(ce-se)/ke,be=[];for(let Ae=0;Ae<ke;Ae++)be.push({from:se+Ae*je,to:se+(Ae+1)*je,count:0});for(let Ae=0;Ae<k;Ae++){const Pe=Math.min(ke-1,Math.max(0,Math.floor((b[Ae]-se)/je)));be[Pe].count++}return be[0].from=P,be[ke-1].to=V,be}const Ge=.95;function Qe(b){const j=Number(b);return Number.isFinite(j)&&j>0&&j<1?j:Ge}function Nt(b,j=Ge){const y=b.length;if(y<2)return null;let O=0;for(let ce=0;ce<y;ce++)O+=b[ce];const k=O/y;let P=0;for(let ce=0;ce<y;ce++){const Oe=b[ce]-k;P+=Oe*Oe}const V=Math.sqrt(P/(y-1)),I=Qe(j),se=ne(1-(1-I)/2,y-1)*V/Math.sqrt(y);return{mean:k,lower:k-se,upper:k+se,margin:se,n:y,confidence:I}}function St(b,j,y=Ge){const O=Number(b),k=Number(j);if(!(k>0)||!(O>=0)||O>k)return null;const P=Qe(y),V=T(1-(1-P)/2),I=O/k,D=V*V,se=1+D/k,ce=(I+D/(2*k))/se,Oe=V/se*Math.sqrt(I*(1-I)/k+D/(4*k*k));return{proportion:I,lower:Math.max(0,ce-Oe),upper:Math.min(1,ce+Oe),n:k,confidence:P}}function vt(b,j=Ge){if(!b||!(b.n>2)||!Number.isFinite(b.stdError))return null;const y=Qe(j),k=ne(1-(1-y)/2,b.n-2)*b.stdError;return{slope:b.slope,lower:b.slope-k,upper:b.slope+k,margin:k,confidence:y}}function Tt(b,j,y=Ge){const O=Number(b),k=Number(j);if(!Number.isFinite(O)||!(k>1))return null;const P=Qe(y),I=T(1-(1-P)/2)*Math.sqrt(1/(9*k)+O*O/(2*(k-1)));return{index:O,lower:O-I,upper:O+I,margin:I,n:k,confidence:P}}function lt(b,j){return!b||!(b.sd>0)||!Number.isFinite(j)||!Number.isFinite(b.mean)?null:(j-b.mean)/b.sd}function at(b){return Number.isFinite(b)?Math.min(1,Math.max(0,2*K(Math.abs(b)/2)-1)):0}function _e(b,j){const y=new Map,O=Q(b);let k=0;for(let P=0;P<j.length;P++){const V=O(j[P]);if(V==null||V===""||typeof V=="number"&&Number.isNaN(V))continue;const I=V instanceof Date?V.getTime():typeof V=="object"?String(V):V;y.set(I,(y.get(I)||0)+1),k++}return{map:y,total:k}}function ft(b,j,y,O){if(!(j>0)||!(O>0))return null;let k=0;const P=new Set(b.keys());for(const V of y.keys())P.add(V);for(const V of P){const I=(b.get(V)||0)/j,D=(y.get(V)||0)/O;k+=Math.abs(I-D)}return k/2}const et=10;function Et(b,j,y){if(y&&y.numeric){const I=f(b,j),{n:D,mean:se}=r(I),ce=D>0?lt({mean:y.mean,sd:y.sd},se):null;return{measure:"standardizedMeanDifference",magnitude:ce,distance:ce===null?0:at(ce),direction:ce===null?0:Math.sign(ce),subsetN:D,populationN:y.n||0,reliable:D>=et}}const{map:k,total:P}=_e(b,j),V=ft(k,P,y.map,y.total);return{measure:"categoricalTotalVariation",magnitude:V,distance:V===null?0:V,direction:0,subsetN:P,populationN:y.total||0,reliable:P>=et}}function ht(b,j){if(b&&(b.kind==="float64"||b.kind==="int32"))return!0;const y=Q(b);let O=0,k=0;for(let P=0;P<j.length&&O<200;P++){const V=y(j[P]);if(V==null||V==="")continue;if(V instanceof Date)return!1;O++;const I=typeof V=="number"?V:Number(V);Number.isFinite(I)&&k++}return O===0?!1:k/O>=.9}function Rt(b,j){if(ht(b,j)){const k=f(b,j),{n:P,mean:V,m2:I}=r(k);return{numeric:!0,mean:V,sd:P>0?Math.sqrt(I/P):0,n:P}}const{map:y,total:O}=_e(b,j);return{numeric:!1,map:y,total:O}}}),Se("packages/core/src/compute/total.js",function(o,me){"use strict";Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return l}}),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 h}});const fe=me("packages/core/src/internal/util.js"),he=fe.isFunction,Q=fe.warnOnce,z=me("packages/core/src/compute/handle.js"),ne=z.presenceReader,_=z.valueComparator,T=z.valueReader,K=me("packages/core/src/compute/statistics.js"),ie=K.STAT_FNS,J=K.STAT_LABELS;function le(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function ue(r,n){const c=n.length;let g=0;if(le(r)){const N=r.values,G=ne(r);if(!G){for(let F=0;F<c;F++){const R=N[n[F]];Number.isNaN(R)||(g+=R)}return g}for(let F=0;F<c;F++){const R=n[F];if(G(R)===1){const X=N[R];Number.isNaN(X)||(g+=X)}}return g}const M=T(r);for(let N=0;N<c;N++){const G=u(M(n[N]));G!==null&&(g+=G)}return g}ue.kernel=!0;function W(r,n){const c=n.length;let g=0;if(le(r)){const N=r.values,G=ne(r);if(!G){for(let F=0;F<c;F++)Number.isNaN(N[n[F]])||g++;return g}for(let F=0;F<c;F++){const R=n[F];G(R)===1&&!Number.isNaN(N[R])&&g++}return g}const M=T(r);for(let N=0;N<c;N++){const G=M(n[N]);G!=null&&!(typeof G=="number"&&Number.isNaN(G))&&g++}return g}W.kernel=!0;function L(r,n){return n.length}L.kernel=!0;function Y(r,n){const c=W(r,n);return c===0?null:ue(r,n)/c}Y.kernel=!0;function ee(r,n,c,g){const M=n.length;if(le(r)){const R=r.values,X=ne(r);let E=null;if(!X){for(let S=0;S<M;S++){const U=R[n[S]];Number.isNaN(U)||(E===null||(c<0?U<E:U>E))&&(E=U)}return E}for(let S=0;S<M;S++){const U=n[S];if(X(U)===0)continue;const H=R[U];Number.isNaN(H)||(E===null||(c<0?H<E:H>E))&&(E=H)}return E}const N=T(r),G=_(g);let F=null;for(let R=0;R<M;R++){const X=N(n[R]);X==null||typeof X=="number"&&Number.isNaN(X)||(F===null||(c<0?G(X,F)<0:G(X,F)>0))&&(F=X)}return F}function C(r,n,c){return ee(r,n,-1,c&&c.locale)}C.kernel=!0;function A(r,n,c){return ee(r,n,1,c&&c.locale)}A.kernel=!0;function i(r,n){return n.length===0?null:T(r)(n[0])}i.kernel=!0;function s(r,n){return n.length===0?null:T(r)(n[n.length-1])}s.kernel=!0;function u(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 f={sum:ue,min:C,max:A,avg:Y,count:L,first:i,last:s,countValues:W,...ie},l=Object.freeze({...J,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"?l[r]||r:"Total":""}const a=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=a.filter(g=>g in f);for(const g of Object.keys(f))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=T(r),g=[];for(let M=0;M<n.length;M++){const N=c(n[M]);N!=null&&g.push(N)}return g}function h(r,n,c,g){const M=n||[];if(typeof c=="string"){const N=f[c];return N?N(r,M,g):(Q(`total:${c}`,`unknown total function "${c}"; register it in config.totalFns`),null)}return he(c)?c.kernel===!0?c(r,M,g):c(d(r,M),g||{}):null}}),Se("packages/core/src/compute/pivot.js",function(o,me){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return A}});const he=me("packages/core/src/internal/util.js").warnOnce,z=me("packages/core/src/compute/handle.js").valueComparator,_=me("packages/core/src/compute/group.js").packKeys,K=me("packages/core/src/compute/total.js").total,ie="|",J="/",le=2e3;function ue(u,f,l){return`${u}${ie}${f}${ie}${l}`}function W(u,f){let l="";for(let t=0;t<u.length;t++){const a=u[t];l+=(t===0?"":f)+(a==null?"":String(a))}return l}function L(u,f,l={}){const t=l.separator||J,a=f.length,{keyOf:m,readers:e}=_(u,f,0),d=new Map,h=[],r=[];for(let F=0;F<a;F++){const R=f[F],X=m(R);if(d.has(X))continue;d.set(X,h.length),r.push(X);const E=new Array(e.length);for(let S=0;S<e.length;S++)E[S]=e[S](R);h.push(E)}const n=z(l.locale),c=h.map((F,R)=>R);c.sort((F,R)=>{const X=h[F],E=h[R];for(let S=0;S<X.length;S++){const U=Y(X[S],E[S],n);if(U!==0)return U}return F-R});const g=new Array(c.length),M=new Array(c.length),N=new Map;for(let F=0;F<c.length;F++){const R=c[F];g[F]=h[R],M[F]=W(h[R],t),N.set(r[R],F)}return{keys:g,paths:M,idOf:F=>{const R=N.get(m(F));return R===void 0?-1:R}}}function Y(u,f,l){const t=u==null,a=f==null;return t||a?t&&a?0:t?1:-1:l(u,f)}function ee(u){const f=u.values||u.totals||[];if(f.length&&typeof f[0]=="object"&&f[0]!==null)return f.filter(m=>m&&m.handle);const l=typeof u.handle=="function"?u.handle:null;if(!l)return f.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 u.totalOf=="function"?u.totalOf:null,a=[];for(const m of f){const e=l(m);e&&a.push({colId:m,handle:e,fn:t?t(m):"sum"})}return a}function C(u,f,l){if(Array.isArray(u)){const t=l||{};return{...t,pivotHandles:u,order:f||null,groups:t.groups||null}}return u||{}}function A(u,f,l){const t=C(u,f,l),a=t.separator||J,m=ee(t),e=t.maxColumns===void 0?le:t.maxColumns,d=t.groups&&t.groups.buckets?t.groups:null,h=d?d.buckets:[t.order||new Uint32Array(0)],r=t.groupPaths||(d?d.keys.map(X=>W(X,a)):[""]),n=s(h),{keys:c,paths:g,idOf:M}=L(t.pivotHandles||[],n,t),N=g.length*Math.max(1,m.length),G=i(g,m,a);if(e&&N>e){const X=new Map;return{keys:c,paths:g,fields:G,groupPaths:r,columns:N,values:X,cells:X,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${N} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:N,maxColumns:e}}}const F=new Map,R=g.length;for(let X=0;X<h.length;X++){const E=h[X],S=r[X]===void 0?"":r[X],U=E.length;if(U===0)continue;const H=new Int32Array(U),$=new Uint32Array(R+1);for(let ae=0;ae<U;ae++){const p=M(E[ae]);H[ae]=p,p>=0&&$[p+1]++}for(let ae=0;ae<R;ae++)$[ae+1]+=$[ae];const re=new Uint32Array(U),te=$.slice(0,R);for(let ae=0;ae<U;ae++){const p=H[ae];p>=0&&(re[te[p]++]=E[ae])}for(let ae=0;ae<R;ae++){const p=$[ae],B=$[ae+1];if(B===p)continue;const q=re.subarray(p,B);for(let oe=0;oe<m.length;oe++){const w=m[oe],v=K(w.handle,q,w.fn,t.totalContext||{locale:t.locale});F.set(ue(S,g[ae],w.colId),v)}}}return{keys:c,paths:g,fields:G,groupPaths:r,columns:N,values:F,cells:F,error:null}}function i(u,f,l){if(f.length===0)return u.slice();const t=[];for(const a of u)for(const m of f)t.push(`${a}${l}${m.colId}`);return t}function s(u){if(u.length===1)return u[0]||new Uint32Array(0);let f=0;for(const a of u)f+=a?a.length:0;const l=new Uint32Array(f);let t=0;for(const a of u)!a||a.length===0||(l.set(a,t),t+=a.length);return l}}),Se("packages/core/src/compute/pivotmatrix.js",function(o,me){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return A}});const he=me("packages/core/src/compute/handle.js").valueComparator,z=me("packages/core/src/compute/total.js").total,_=me("packages/core/src/compute/group.js").packKeys,T=me("packages/core/src/compute/pivot.js"),K=T.joinPath,ie=T.DEFAULT_PATH_SEPARATOR,J=T.DEFAULT_MAX_COLUMNS,le="";function ue(i,s,u={}){const f=u.separator||ie,l=i||[],t=s instanceof Uint32Array?s:Uint32Array.from(s||[]),a=t.length;if(l.length===0)return{tuples:[[]],paths:[le],buckets:[t]};const{keyOf:m,readers:e}=_(l,t,0),d=new Map,h=[],r=[],n=[];for(let F=0;F<a;F++){const R=t[F],X=m(R);let E=d.get(X);if(E===void 0){E=h.length,d.set(X,E),r.push(X);const S=new Array(e.length);for(let U=0;U<e.length;U++)S[U]=e[U](R);h.push(S),n.push([])}n[E].push(R)}const c=he(u.locale),g=h.map((F,R)=>R);g.sort((F,R)=>{const X=h[F],E=h[R];for(let S=0;S<X.length;S++){const U=W(X[S],E[S],c);if(U!==0)return U}return F-R});const M=new Array(g.length),N=new Array(g.length),G=new Array(g.length);for(let F=0;F<g.length;F++){const R=g[F];M[F]=h[R],N[F]=K(h[R],f),G[F]=Uint32Array.from(n[R])}return{tuples:M,paths:N,buckets:G}}function W(i,s,u){const f=i==null,l=s==null;return f||l?f&&l?0:f?1:-1:u(i,s)}function L(i,s,u){const f=[];for(let l=0;l<i.length;l++)u.has(i[l])&&f.push(i[l]);return Uint32Array.from(f)}function Y(i,s,u,f){return{value:s.length?z(i,s,u,f):null,leaves:s,count:s.length}}function ee(i){const s=i&&i.opts||{},u=s.separator||ie,f=s.totalContext||{locale:s.locale},l=(i.measures||[]).filter(N=>N&&N.handle),t=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),a=ue(i.rowHandles||[],t,{...s,separator:u}),m=ue(i.columnHandles||[],t,{...s,separator:u}),e=s.maxColumns===void 0?J:s.maxColumns,d=m.paths.length*Math.max(1,l.length),h=new Map;if(e&&d>e)return{rowAxis:a,columnAxis:m,measures:l.map(N=>({colId:N.colId,fn:N.fn})),body:h,rowMargin:h,columnMargin:h,grand:h,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,M=m.buckets.map(N=>new Set(N));for(let N=0;N<m.paths.length;N++){const G=m.buckets[N],F=m.paths[N];for(const R of l)c.set(A(F,R.colId),Y(R.handle,G,R.fn,f))}for(let N=0;N<a.paths.length;N++){const G=a.buckets[N],F=a.paths[N];for(const R of l)n.set(A(F,R.colId),Y(R.handle,G,R.fn,f));for(let R=0;R<m.paths.length;R++){const X=L(G,m.buckets[R],M[R]);if(X.length===0)continue;const E=m.paths[R];for(const S of l)r.set(C(F,E,S.colId),Y(S.handle,X,S.fn,f))}}for(const N of l)g.set(N.colId,Y(N.handle,t,N.fn,f));return{rowAxis:a,columnAxis:m,measures:l.map(N=>({colId:N.colId,fn:N.fn})),body:r,rowMargin:n,columnMargin:c,grand:g,columns:d,error:null}}function C(i,s,u){return`${i}\\0${s}\\0${u}`}function A(i,s){return`${i}\\0${s}`}}),Se("packages/core/src/compute/reference.js",function(o,me){"use strict";Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ee}});const he=me("packages/core/src/internal/util.js").getPath,Q=me("packages/core/src/compute/handle.js"),z=Q.isMissing,ne=Q.valueComparator,T=me("packages/core/src/compute/filter.js").testValue,K="",ie="\\0";function J(i,s){const u=s.includes(".")?he(i,s):i?.[s];return u===void 0?null:u}function le(i,s,u={}){const f=s||[];let l=i.map((t,a)=>a);if(f.length===0)return l;for(let t=f.length-1;t>=0;t--)l=ue(i,l,f[t],u);return l}function ue(i,s,u,f){const l=u.locale!==void 0?u.locale:f.locale,t=ne(l),a=u.descending!==void 0?!!u.descending:u.dir==="desc",m=[],e=[];for(const r of s){const n=J(i[r],u.col);z(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 h=(r,n)=>{const c=J(i[r],u.col),g=J(i[n],u.col);let M;return typeof u.compare=="function"?(M=u.compare(c,g,i[r],i[n],a),a&&(M=-M)):M=a?t(g,c):t(c,g),M!==0?M:d.get(r)-d.get(n)};return m.sort(h),u.nullsFirst?e.concat(m):m.concat(e)}function W(i,s,u={}){const f=[];for(let l=0;l<i.length;l++)L(i[l],s,u,l)&&f.push(l);return f}function L(i,s,u,f){if(!s)return!0;if(Array.isArray(s.conditions)){const l=s.conditions.filter(a=>a!=null);if(l.length===0)return!0;if(s.op==="or")return l.some(a=>L(i,a,u,f));const t=l.every(a=>L(i,a,u,f));return s.op==="not"?!t:t}return s.col===void 0&&typeof u.custom=="function"?!!u.custom(s,i,f):T(J(i,s.col),s,u.locale)}function Y(i,s,u,f){const l=u||i.map((e,d)=>d),t=new Map,a=[],m=[];for(const e of l){const d=s.map((n,c)=>{const g=J(i[e],n);return f&&f[c]?f[c](g):g}),h=d.map(n=>n==null?ie:String(n)).join(K);let r=t.get(h);r===void 0&&(r=a.length,t.set(h,r),a.push(d),m.push([])),m[r].push(e)}return{keys:a,buckets:m}}function ee(i,s,u={}){const f=ne(u.locale),l=i.filter(a=>!z(a)),t=l.map(C).filter(a=>a!==null);switch(s){case"count":return i.length;case"countValues":return l.length;case"sum":return t.reduce((a,m)=>a+m,0);case"avg":return l.length===0?null:t.reduce((a,m)=>a+m,0)/l.length;case"min":return l.length===0?null:l.reduce((a,m)=>f(m,a)<0?m:a);case"max":return l.length===0?null:l.reduce((a,m)=>f(m,a)>0?m:a);case"first":return i.length===0?null:A(i[0]);case"last":return i.length===0?null:A(i[i.length-1]);default:return null}}function C(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 s=Number(i);return Number.isNaN(s)?null:s}function A(i){return i===void 0?null:i}}),Se("packages/core/src/compute/windowed.js",function(o,me){"use strict";Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return _}});const he=me("packages/core/src/compute/sketch.js").Welford;class Q{#t;#e;#n=[];#r;#i;constructor(K,ie=0,J=Date.now){if(K!=="count"&&K!=="time"&&K!=="session")throw new RangeError(`unknown window kind: ${K}`);if((K==="count"||K==="time")&&!(ie>0))throw new RangeError(`a ${K} window needs a positive span`);this.#t=K,this.#e=Math.floor(ie),this.#r=J,this.#i=J()}get size(){return this.#n.length}push(K,ie=this.#r()){Number.isFinite(K)&&(this.#n.push({t:ie,v:K}),this.#s(ie))}#s(K){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const ie=K-this.#e;for(;this.#n.length&&this.#n[0].t<ie;)this.#n.shift()}}spec(){const K=this.#t==="session"?this.#r()-this.#i:this.#e;return{kind:this.#t,span:K,size:this.#n.length}}values(){return this.#n.map(K=>K.v)}aggregate(){const K=this.spec();if(!this.#n.length)return{over:K,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const ie=new he;let J=0,le=1/0,ue=-1/0;for(const{v:W}of this.#n)J+=W,W<le&&(le=W),W>ue&&(ue=W),ie.add(W);return{over:K,count:this.#n.length,sum:J,mean:ie.mean(),min:le,max:ue,variance:ie.variance(),stddev:ie.stddev()}}reduce(K){const ie=this.aggregate(),J={sum:ie.sum,avg:ie.mean,mean:ie.mean,min:ie.min,max:ie.max,count:ie.count,variance:ie.variance,stddev:ie.stddev};if(!(K in J))throw new RangeError(`unknown windowed aggregate: ${K}`);return{value:J[K],over:ie.over}}}const z=Object.freeze(["count","time","session"]);function ne(T,K=Date.now){const ie=T.kind==="time"&&T.minutes!=null?T.minutes*6e4:T.span??0;return new Q(T.kind,ie,K)}const _={Window:Q,WINDOW_KINDS:z,openWindow:ne}}),Se("packages/core/src/compute/anomaly.js",function(o,me){"use strict";Object.defineProperty(o,"MAD_SCALE",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return f}});const he=me("packages/core/src/compute/statistics.js").quantileSorted,z=me("packages/core/src/compute/special.js").logGamma,ne=.6745,_=3.5,T=1.5,K=.975,ie=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function J(l){if(!l.length)return null;const a=Array.from(l,Number).sort((h,r)=>h-r),m=he(a,.5),e=a.map(h=>Math.abs(h-m)).sort((h,r)=>h-r),d=he(e,.5);return{median:m,mad:d}}function le(l,t={}){const a=Number.isFinite(t.threshold)?t.threshold:_,m=l.length,e=new Array(m).fill(null),d=new Array(m).fill(!1),h=[];for(let c=0;c<m;c++){const g=Number(l[c]);Number.isFinite(g)&&h.push(g)}if(!h.length)return{median:null,mad:null,threshold:a,scores:e,flags:d,flagged:0};const r=J(h);if(r.mad===0)return{median:r.median,mad:0,threshold:a,scores:e,flags:d,flagged:0};let n=0;for(let c=0;c<m;c++){const g=Number(l[c]);if(!Number.isFinite(g))continue;const M=ne*(g-r.median)/r.mad;e[c]=M,Math.abs(M)>a&&(d[c]=!0,n++)}return{median:r.median,mad:r.mad,threshold:a,scores:e,flags:d,flagged:n}}function ue(l,t={}){const a=Number.isFinite(t.k)?t.k:T,m=[];for(let n=0;n<l.length;n++){const c=Number(l[n]);Number.isFinite(c)&&m.push(c)}if(!m.length)return null;const e=m.sort((n,c)=>n-c),d=he(e,.25),h=he(e,.75),r=h-d;return{q1:d,q3:h,iqr:r,lower:d-a*r,upper:h+a*r,k:a}}function W(l,t){if(t<=0)return 0;const a=z(l);if(t<l+1){let c=l,g=1/l,M=g;for(let N=0;N<1e3&&(c+=1,M*=t/c,g+=M,!(Math.abs(M)<Math.abs(g)*1e-15));N++);return g*Math.exp(-t+l*Math.log(t)-a)}const m=1e-300;let e=t+1-l,d=1/m,h=1/e,r=h;for(let c=1;c<1e3;c++){const g=-c*(c-l);e+=2,h=g*h+e,Math.abs(h)<m&&(h=m),d=e+g/d,Math.abs(d)<m&&(d=m),h=1/h;const M=h*d;if(r*=M,Math.abs(M-1)<1e-15)break}return 1-Math.exp(-t+l*Math.log(t)-a)*r}function L(l,t){return l<=0?0:W(t/2,l/2)}function Y(l,t=K){if(!(t>0)||!(t<1))return NaN;let a=0,m=Math.max(1,l);for(;L(m,l)<t;)m*=2;for(let e=0;e<200;e++){const d=(a+m)/2;if(L(d,l)<t?a=d:m=d,m-a<1e-10)break}return(a+m)/2}function ee(l){const t=l.length,a=l.map((m,e)=>{const d=m.slice();for(let h=0;h<t;h++)d.push(e===h?1:0);return d});for(let m=0;m<t;m++){let e=m;for(let h=m+1;h<t;h++)Math.abs(a[h][m])>Math.abs(a[e][m])&&(e=h);if(Math.abs(a[e][m])<1e-12)return null;if(e!==m){const h=a[e];a[e]=a[m],a[m]=h}const d=a[m][m];for(let h=0;h<2*t;h++)a[m][h]/=d;for(let h=0;h<t;h++){if(h===m)continue;const r=a[h][m];if(r!==0)for(let n=0;n<2*t;n++)a[h][n]-=r*a[m][n]}}return a.map(m=>m.slice(t))}function C(l,t){const a=l.length,m=new Array(t).fill(0);for(const h of l)for(let r=0;r<t;r++)m[r]+=h[r];for(let h=0;h<t;h++)m[h]/=a;const e=Array.from({length:t},()=>new Array(t).fill(0));for(const h of l)for(let r=0;r<t;r++){const n=h[r]-m[r];for(let c=r;c<t;c++)e[r][c]+=n*(h[c]-m[c])}const d=a>1?a-1:1;for(let h=0;h<t;h++)for(let r=h;r<t;r++)e[h][r]/=d,e[r][h]=e[h][r];return{mean:m,cov:e}}function A(l,t={}){const a=Number.isFinite(t.p)?t.p:K,m=Number.isFinite(t.ridge)?t.ridge:1e-6,e=l.length;if(!e)return null;const d=l[0].length;if(!d)return null;const h=new Array(e).fill(null),r=new Array(e).fill(null),n=new Array(e).fill(!1),c=[],g=[];for(let S=0;S<e;S++){const U=l[S];let H=U.length===d;const $=new Array(d);for(let re=0;H&&re<d;re++){const te=Number(U[re]);Number.isFinite(te)?$[re]=te:H=!1}H&&(c.push(S),g.push($))}const M=d,N=Y(M,a);if(g.length<=d)return{center:[],df:M,cutoff:N,singular:!0,used:g.length,distances:h,squared:r,flags:n,flagged:0};const{mean:G,cov:F}=C(g,d);let R=ee(F),X=!1;if(!R){X=!0;let S=0;for(let $=0;$<d;$++)S+=F[$][$];const U=S/d*m||m,H=F.map(($,re)=>$.map((te,ae)=>re===ae?te+U:te));if(R=ee(H),!R)return{center:G,df:M,cutoff:N,singular:!0,used:g.length,distances:h,squared:r,flags:n,flagged:0}}let E=0;for(let S=0;S<g.length;S++){const U=g[S],H=new Array(d);for(let te=0;te<d;te++)H[te]=U[te]-G[te];let $=0;for(let te=0;te<d;te++){let ae=0;for(let p=0;p<d;p++)ae+=R[te][p]*H[p];$+=H[te]*ae}$<0&&($=0);const re=c[S];r[re]=$,h[re]=Math.sqrt($),$>N&&(n[re]=!0,E++)}return{center:G,df:M,cutoff:N,singular:X,used:g.length,distances:h,squared:r,flags:n,flagged:E}}const i=20,s=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function u(l,t={}){const a=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:_,d=Number.isFinite(t.k)?t.k:T,h=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):m,r=l.length,n=new Array(r).fill(null),c=new Array(r).fill(!1);let g=0;for(let M=0;M<r;M++){const N=Number(l[M]);if(!Number.isFinite(N))continue;const G=Math.max(0,M-m+1),F=[];for(let R=G;R<=M;R++){const X=Number(l[R]);Number.isFinite(X)&&F.push(X)}if(!(F.length<h))if(a==="rollingIqr"){const R=ue(F,{k:d});if(!R)continue;(N<R.lower||N>R.upper)&&(c[M]=!0,g++)}else{const R=J(F);if(!R||R.mad===0)continue;const X=ne*(N-R.median)/R.mad;n[M]=X,Math.abs(X)>e&&(c[M]=!0,g++)}}return{method:a,windowLen:m,minPeriods:h,threshold:e,k:d,scores:n,flags:c,flagged:g}}function f(l={}){const t=l||{},a=t.field;if(typeof a!="string"||!a)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const m=t.method||"modifiedZScore";if(!(ie.includes(m)||s.includes(m))||m==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method \'${m}\'`);const d=typeof t.orderBy=="string"?t.orderBy:null,h=t.latest===!0,r=s.includes(m),n=c=>Number(c==null?NaN:c[a]);return c=>{const g=Array.isArray(c)?c.slice():[...c];d&&g.sort((R,X)=>{const E=R?.[d],S=X?.[d];return E===S?0:E==null?-1:S==null?1:E<S?-1:1});const M=g.map(n);let N,G;if(r)({flags:N,scores:G}=u(M,{method:m,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(m==="iqr"){const R=ue(M,{k:t.k});N=M.map(X=>R?Number.isFinite(X)&&(X<R.lower||X>R.upper):!1),G=M.map(()=>null)}else({flags:N,scores:G}=le(M,{threshold:t.threshold}));if(h){const R=N.length-1;return R<0||!N[R]?!1:{method:m,field:a,flagged:[{row:g[R],score:G[R]}]}}const F=[];for(let R=0;R<N.length;R++)N[R]&&F.push({row:g[R],score:G[R]});return F.length?{method:m,field:a,flagged:F}:!1}}}),Se("packages/core/src/compute/forecast.js",function(o,me){"use strict";Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return l}});const fe=me("packages/core/src/compute/special.js"),he=fe.normalQuantile,Q=fe.studentTQuantile,ne=me("packages/core/src/internal/util.js").warnOnce,_=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),T=1e-4,K=1-1e-4;function ie(t){const a=[];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,h=Number.isFinite(e.value)?e.value:null;a.push({at:d,value:h})}else a.push({at:m,value:Number.isFinite(e)?Number(e):null})}return a}function J(t){const a=t.filter(r=>r.value!==null),m=a[0],e=a[a.length-1],d=e.at-m.at,h=a.length>1&&d>0?d/(a.length-1):1;return{lastAt:e.at,step:h}}function le(t){return Math.min(K,Math.max(T,t))}function ue(t,a=T,m=K,e=80){const d=(Math.sqrt(5)-1)/2;let h=a,r=m,n=r-d*(r-h),c=h+d*(r-h),g=t(n),M=t(c);for(let N=0;N<e;N++)g<M?(r=c,c=n,M=g,n=r-d*(r-h),g=t(n)):(h=n,n=c,g=M,c=h+d*(r-h),M=t(c));return(h+r)/2}function W(t,a){let m=null,e=0,d=0;for(let h=0;h<t.length;h++){const r=t[h];if(r!==null){if(m===null){m=r;continue}e+=(r-m)**2,d+=1,m=a*r+(1-a)*m}}return{level:m,sse:e,m:d}}function L(t,a,m){let e=null,d=null,h=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;h+=(c-g)**2,r+=1;const M=e;e=a*c+(1-a)*(M+d),d=m*(e-M)+(1-m)*d}return{level:e,trend:d,sse:h,m:r}}function Y(t,a,m,e,d){const h=t.length;if(h<2*a)return null;const r=X=>{let E=0,S=0;for(let U=X;U<X+a&&U<h;U++)t[U]!==null&&(E+=t[U],S+=1);return S?E/S:null},n=r(0),c=r(a);if(n===null||c===null)return null;let g=n,M=(c-n)/a;const N=new Array(a).fill(0);for(let X=0;X<a;X++)N[X]=t[X]===null?0:t[X]-g;const G=N.reduce((X,E)=>X+E,0)/a;for(let X=0;X<a;X++)N[X]-=G;let F=0,R=0;for(let X=a;X<h;X++){const E=X%a,S=N[E],U=t[X];if(U===null){g+=M;continue}const H=g+M+S;F+=(U-H)**2,R+=1;const $=g;g=m*(U-S)+(1-m)*(g+M),M=e*(g-$)+(1-e)*M,N[E]=d*(U-g)+(1-d)*S}return{level:g,trend:M,season:N,phase:(h-1)%a,sse:F,count:R}}function ee(t,a,m){let e=1;for(const h of a)e+=h*h;const d=Math.sqrt(t*e);return{se:d,margin:m*d}}function C(t,a={}){if(!t||typeof t.length!="number"||t.length===0)return null;const m=_.includes(a.method)?a.method:"linear",e=Math.max(1,Math.floor(Number(a.horizon)||1)),d=Number.isFinite(a.confidence)&&a.confidence>0&&a.confidence<1?a.confidence:.95,h=1-(1-d)/2,r=ie(t),n=r.map(F=>F.value),c=n.filter(F=>F!==null),g=c.length,{lastAt:M,step:N}=g?J(r):{lastAt:0,step:1},G=F=>M+F*N;return m==="linear"?A(r,g,e,d,h,G):m==="movingAverage"?i(c,g,e,d,h,a,G):m==="ses"?s(n,g,e,d,h,a,G):m==="holt"?u(n,g,e,d,h,a,G):f(n,g,e,d,h,a,G)}function A(t,a,m,e,d,h){if(a<2)return null;let r=0,n=0;for(const U of t)U.value!==null&&(r+=U.at,n+=U.value);r/=a,n/=a;let c=0,g=0,M=0;for(const U of t){if(U.value===null)continue;const H=U.at-r,$=U.value-n;c+=H*H,g+=H*$,M+=$*$}if(c===0)return null;const N=g/c,G=n-N*r,F=M===0?1:Math.max(0,Math.min(1,g*g/(c*M))),R=Math.max(0,M-N*g),X=a>2?Math.sqrt(R/(a-2)):null,E=a>2?Q(d,a-2):null,S=[];for(let U=1;U<=m;U++){const H=h(U),$=G+N*H;let re=null,te=null,ae=null,p=null,B=null;if(X!==null){const q=1/a+(H-r)**2/c,oe=X*Math.sqrt(1+q),w=X*Math.sqrt(q);B=oe,re=$-E*oe,te=$+E*oe,ae=$-E*w,p=$+E*w}S.push({step:U,at:H,mean:$,lower:re,upper:te,lowerMean:ae,upperMean:p,se:B})}return{method:"linear",horizon:m,confidence:e,n:a,sigma:X,r2:F,params:{slope:N,intercept:G},points:S}}function i(t,a,m,e,d,h,r){if(a<1)return null;const n=Math.max(1,Math.min(a,Math.floor(Number(h.windowLen)||a))),c=t.slice(a-n);let g=0;for(const X of c)g+=X;const M=g/n;let N=null,G=null;if(n>1){let X=0;for(const S of c)X+=(S-M)**2;N=Math.sqrt(X/(n-1))*Math.sqrt(1+1/n),G=Q(d,n-1)}const F=N===null?null:G*N,R=[];for(let X=1;X<=m;X++)R.push({step:X,at:r(X),mean:M,lower:F===null?null:M-F,upper:F===null?null:M+F,se:N});return{method:"movingAverage",horizon:m,confidence:e,n:a,sigma:N===null?null:N,params:{windowLen:n},points:R}}function s(t,a,m,e,d,h,r){if(a<1)return null;let n=Number.isFinite(h.alpha)?le(h.alpha):null;n===null&&(n=ue(G=>W(t,G).sse));const c=W(t,n),g=he(d),M=c.m>0?c.sse/c.m:null,N=[];for(let G=1;G<=m;G++){const F=c.level;let R=null,X=null,E=null;if(M!==null){const S=[];for(let H=1;H<G;H++)S.push(n);const U=ee(M,S,g);E=U.se,R=F-U.margin,X=F+U.margin}N.push({step:G,at:r(G),mean:F,lower:R,upper:X,se:E})}return{method:"ses",horizon:m,confidence:e,n:a,sigma:M===null?null:Math.sqrt(M),params:{alpha:n},points:N}}function u(t,a,m,e,d,h,r){if(a<2)return null;let n=Number.isFinite(h.alpha)?le(h.alpha):null,c=Number.isFinite(h.beta)?le(h.beta):null;if(n===null||c===null){let R=n===null?.5:n,X=c===null?.5:c;for(let E=0;E<6;E++)n===null&&(R=ue(S=>L(t,S,X).sse)),c===null&&(X=ue(S=>L(t,R,S).sse));n=n===null?R:n,c=c===null?X:c}const g=L(t,n,c),M=he(d),N=g.m>0?g.sse/g.m:null,G=n*c,F=[];for(let R=1;R<=m;R++){const X=g.level+R*g.trend;let E=null,S=null,U=null;if(N!==null){const H=[];for(let re=1;re<R;re++)H.push(n+re*G);const $=ee(N,H,M);U=$.se,E=X-$.margin,S=X+$.margin}F.push({step:R,at:r(R),mean:X,lower:E,upper:S,se:U})}return{method:"holt",horizon:m,confidence:e,n:a,sigma:N===null?null:Math.sqrt(N),params:{alpha:n,beta:c},points:F}}function f(t,a,m,e,d,h,r){const n=Math.floor(Number(h.period));if(!(n>=2))return ne("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(a<2*n)return null;let c=Number.isFinite(h.alpha)?le(h.alpha):null,g=Number.isFinite(h.beta)?le(h.beta):null,M=Number.isFinite(h.gamma)?le(h.gamma):null;const N=(U,H,$)=>{const re=Y(t,n,U,H,$);return re?re.sse:1/0};if(c===null||g===null||M===null){let U=c===null?.5:c,H=g===null?.5:g,$=M===null?.5:M;for(let re=0;re<8;re++)c===null&&(U=ue(te=>N(te,H,$))),g===null&&(H=ue(te=>N(U,te,$))),M===null&&($=ue(te=>N(U,H,te)));c=c===null?U:c,g=g===null?H:g,M=M===null?$:M}const G=Y(t,n,c,g,M);if(!G)return null;const F=he(d),R=G.count>0?G.sse/G.count:null,X=c*g,E=M*(1-c),S=[];for(let U=1;U<=m;U++){const H=G.season[(G.phase+U)%n],$=G.level+U*G.trend+H;let re=null,te=null,ae=null;if(R!==null){const p=[];for(let q=1;q<U;q++)p.push(c+q*X+(q%n===0?E:0));const B=ee(R,p,F);ae=B.se,re=$-B.margin,te=$+B.margin}S.push({step:U,at:r(U),mean:$,lower:re,upper:te,se:ae})}return{method:"holtWinters",horizon:m,confidence:e,n:a,sigma:R===null?null:Math.sqrt(R),params:{alpha:c,beta:g,gamma:M,period:n},points:S}}const l={FORECAST_METHODS:_,forecast:C}}),Se("packages/core/src/compute/index.js",function(o,me){"use strict";const fe=me("packages/core/src/compute/sort.js");Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return fe.sortColumn}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return fe.sortMulti}}),Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return fe.radixSortFloat64}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return fe.radixSortInt32}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return fe.rankSortDictionary}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return fe.mergeSortComparator}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return fe.collateStringRanks}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return fe.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 Q=me("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return Q.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return Q.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return Q.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return Q.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return Q.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return Q.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return Q.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return Q.mentionsColumn}});const z=me("packages/core/src/compute/group.js");Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return z.groupByColumns}}),Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return z.packKeys}});const ne=me("packages/core/src/compute/facet.js");Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return ne.facet}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return ne.computeBounds}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return ne.countInto}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return ne.bucketOf}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return ne.facetKind}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return ne.cardinalityOf}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return ne.pickGranularity}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return ne.floorTo}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return ne.advance}}),Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return ne.STRATEGIES}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return ne.GRANULARITIES}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return ne.DEFAULT_BUCKETS}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return ne.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return ne.QUANTILE_SAMPLE}});const _=me("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return _.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return _.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return _.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return _.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return _.collectValues}});const T=me("packages/core/src/compute/pivot.js");Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return T.pivot}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return T.resolvePivotKeys}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return T.pivotKey}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return T.joinPath}}),Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return T.KEY_DELIMITER}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return T.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return T.DEFAULT_MAX_COLUMNS}});const K=me("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return K.pivotMatrix}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return K.resolveAxis}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return K.cellKey}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return K.marginKey}}),Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return K.GRAND_PATH}});const ie=me("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return ie.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return ie.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return ie.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ie.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return ie.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return ie.referenceValue}});const J=me("packages/core/src/compute/handle.js");Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return J.identity}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return J.rowCount}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return J.presenceReader}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return J.bitReader}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return J.valueReader}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return J.valueComparator}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return J.numericTotalOrder}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return J.dictRanks}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return J.dictSize}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return J.dictValue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return J.multiValue}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return J.isMissing}});const le=me("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return le.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return le.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return le.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return le.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return le.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return le.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return le.SKETCH_BOUNDS}});const ue=me("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return ue.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return ue.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return ue.openWindow}});const W=me("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return W.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return W.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return W.maintenanceOf}});const L=me("packages/core/src/compute/anomaly.js");Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return L.ANOMALY_METHODS}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return L.modifiedZScores}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return L.iqrFences}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return L.mahalanobis}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return L.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return L.rollingAnomalies}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return L.anomalyCondition}});const Y=me("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Y.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return Y.forecast}})}),Se("packages/worker/src/kernel.js",function(o,me){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"setCompute",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"dispatch",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"handleMessage",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"installKernel",{enumerable:!0,get:function(){return u}});const fe=me("packages/worker/src/transport.js"),he=fe.PROTOCOL,Q=fe.OPS,z=fe.CONTROL,ne=fe.ERRORS,_=fe.unpackHandle,T=fe.unpackHandles,K=fe.createMaskPool,ie=fe.collectTransfers,J=me("packages/core/src/store/columnpack.js"),le=J.packChunk,ue=J.packedTransfers;let W=null,L=null,Y=null;async function ee(f){if(W)return W;if(!L){const l=f||(()=>Promise.resolve(me("packages/core/src/compute/index.js")));L=Promise.resolve().then(l).then(t=>(W=t,t)).catch(t=>(Y=t,W=null,null))}return L}function C(f){W=f,L=f?Promise.resolve(f):null,Y=f?null:Y}function A(f,l,t){const a=new Map;for(const m of f)m&&a.set(m.id,m);return{handle(m){return a.get(m)},count:l,pool:K(),locale:t}}function i(f,l){const{op:t,args:a}=f;if(t===Q.COLUMNIZE)return le(a.schema||[],a.rows||[],a.opts||{});const m=l[t];if(typeof m!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=ne.NO_KERNEL,e}switch(t){case Q.COLLATE_STRING_RANKS:return m(a.table||[],(a.table||[]).length,a.locale);case Q.SORT_COLUMN:return m(_(a.handle),a.order??null,a.opts||{});case Q.SORT_MULTI:{const e=T(a.handles||[]),d=(a.entries||[]).map(h=>({...h,handle:e[h.index]}));return m(e,d,a.order??null)}case Q.EVALUATE_FILTERS:return m(a.filters,A(T(a.handles||[]),a.count,a.locale));case Q.COMPACT:return m(a.mask,a.count,void 0);case Q.GROUP_BY_COLUMNS:return m(T(a.handles||[]),a.order??null,a.opts||{});case Q.TOTAL:return m(_(a.handle),a.indices??null,a.fn);case Q.PIVOT:return m(T(a.handles||[]),a.order??null,a.opts||{});case Q.FACET:return m(_(a.handle),a.indices??null,a.count,a.opts||{});default:{const e=new Error(`[lattice] unknown worker op \'${t}\'`);throw e.code=ne.PROTOCOL,e}}}async function s(f,l={}){if(!f||f.lattice!==he)return null;const{id:t,op:a}=f;if(a===z.CANCEL)return l.cancelled?.add(f.target),null;if(a===z.PING)return{reply:{lattice:he,id:t,ok:!0,result:"pong"},transfer:[]};if(a===Q.COLUMNIZE){if(l.cancelled?.has(t))return l.cancelled.delete(t),null;try{const e=le(f.args.schema||[],f.args.rows||[],f.args.opts||{});return l.cancelled?.has(t)?(l.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:ne.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:ue(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||ne.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}const m=await ee(l.loader);if(!m)return{reply:{lattice:he,id:t,ok:!1,error:{code:ne.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${Y?Y.message:"module not found"}`}},transfer:[]};if(l.cancelled?.has(t))return l.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:ne.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(f,m);return l.cancelled?.has(t)?(l.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:ne.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:ie(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||ne.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}function u(f,l={}){const t=new Set,a=async m=>{const e=await s(m.data,{loader:l.loader,cancelled:t});e&&f.postMessage(e.reply,e.transfer)};return f.addEventListener("message",a),ee(l.loader).then(m=>{f.postMessage({lattice:he,id:0,op:z.READY,compute:!!m})}),()=>f.removeEventListener("message",a)}});var pt=it("packages/worker/src/kernel.js");yt.__latticeKernel=pt})(typeof globalThis<"u"?globalThis:this);\n\n__latticeKernel.installKernel(self);\n',{type:"classic"})}catch{}const It=Gn("packages/modules/webcomponent/index.js"),Qi=It.GridElementController,Ji=It.observedAttributeNames,eo=It.domEventName,to=It.ATTRIBUTE_CONFIG,no=It.EVENT_PREFIX,ro=It.createLatticeElements,io=It.defineLatticeElements,oo=It.ELEMENT_TAGS,so=It.createLatticeKPIElement,ao=It.createLatticeChartElement,lo=It.createLatticeKanbanElement,uo=It.createLatticeGanttElement,co=It.createLatticeLayoutElement,fo=It.createLatticeTabsElement,ho=It.createLatticeRouterElement,po=It.adoptLatticeStyles,mo=It.latticeStyleSheets,go=It.VIEWER_EVENTS,yo=It.VIEWER_APPLY,bo=It.viewerHandlerName,wo=It.createViewerController,vo=It.EVENT_NAMES,ko=It.dashedName,So=It.createCurrencyType,Oo=It.createUnitType,jo=It.registerUnitSystem,Ao=It.createStat,Po=It.createHeadlessGrid,Co=It.duckdbAdapter,Eo=It.createPushdownSource,To=It.TAG_NAME,Mo=It.createLatticeGridElement,No=It.defineLatticeGrid;var Ro=It.default;export{to as ATTRIBUTE_CONFIG,oo as ELEMENT_TAGS,vo as EVENT_NAMES,no as EVENT_PREFIX,Qi as GridElementController,To as TAG_NAME,yo as VIEWER_APPLY,go as VIEWER_EVENTS,po as adoptLatticeStyles,So as createCurrencyType,Po as createHeadlessGrid,ao as createLatticeChartElement,ro as createLatticeElements,uo as createLatticeGanttElement,Mo as createLatticeGridElement,so as createLatticeKPIElement,lo as createLatticeKanbanElement,co as createLatticeLayoutElement,ho as createLatticeRouterElement,fo as createLatticeTabsElement,Eo as createPushdownSource,Ao as createStat,Oo as createUnitType,wo as createViewerController,ko as dashedName,Ro as default,io as defineLatticeElements,No as defineLatticeGrid,eo as domEventName,Co as duckdbAdapter,mo as latticeStyleSheets,Ji as observedAttributeNames,jo as registerUnitSystem,bo as viewerHandlerName};
|
|
59
|
+
`;return n}catch{return""}}function H(l,c){const i=B.get(l);if(i)return i.sheet;const n=G(l);if(!n)return null;const t=c.CSSStyleSheet,r=new t;try{r.replaceSync(n)}catch{return null}r[X]=!0;let s=null;const f=c.MutationObserver;return typeof f=="function"&&String(l.tagName).toLowerCase()==="style"&&(s=new f(()=>{try{r.replaceSync(String(l.textContent||""))}catch{}}),s.observe(l,{childList:!0,characterData:!0,subtree:!0})),B.set(l,{sheet:r,stop:()=>s&&s.disconnect()}),r}function U(l){return l?l.nodeType===9?l:l.ownerDocument||globalThis.document||null:globalThis.document||null}function D(l){const c=l||globalThis.document;return!c||typeof c.querySelectorAll!="function"?[]:[...c.querySelectorAll("style,link[rel]")].filter(Q)}function v(l={}){if(!W())return[];const c=l.document||globalThis.document,i=c&&c.defaultView||globalThis,n=[];for(const t of D(c)){const r=H(t,i);r&&!n.includes(r)&&n.push(r)}return n}function S(l,c={}){const i=()=>{};if(!l||typeof l!="object")return i;const n=c.document||U(l);if(!n)return i;const t=n.defaultView||globalThis;let r=F.get(l);r||(r=new Map,F.set(l,r));const s=[],f=W(),u=a=>{if(r.has(a))return;const p=f?H(a,t):null;if(p){r.set(a,p);const k=l.adoptedStyleSheets||[];k.includes(p)||(l.adoptedStyleSheets=[...k,p]);return}if(String(a.tagName).toLowerCase()!=="link"||typeof l.appendChild!="function")return;const w=n.createElement("link");w.setAttribute("rel","stylesheet"),w.setAttribute("href",a.getAttribute("href")||""),w.setAttribute("data-lattice","adopted"),l.appendChild(w),s.push(w),r.set(a,w)};for(const a of D(n))u(a);let o=null;const g=t.MutationObserver,d=n.head||n.documentElement;typeof g=="function"&&d&&(o=new g(a=>{for(const p of a)for(const w of p.addedNodes||[])Q(w)&&u(w)}),o.observe(d,{childList:!0}));let h=!1;return()=>{if(h)return;h=!0,o&&o.disconnect();const a=l.adoptedStyleSheets||[],p=new Set([...r.values()]);l.adoptedStyleSheets=a.filter(w=>!p.has(w));for(const w of s)w.parentNode&&w.parentNode.removeChild(w);r.clear()}}function y(l){if(!l||typeof l.getRootNode!="function"||typeof l.getAttribute=="function"&&String(l.getAttribute("lattice-styles")||"")==="off")return null;const c=l.getRootNode();return!c||c.nodeType!==11||!c.host?null:S(c)}}),xe("packages/modules/webcomponent/elements.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_GRID_NAME",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"DEFAULT_TAG_PREFIX",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ELEMENT_TAGS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"VIEWER_ALIASES",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"VIEWER_BINDING",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"coerceElementAttribute",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"attributeConfig",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createElementScope",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"scopeFor",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"applyPredicates",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"upgradeProperty",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"installProperty",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"harvestProperties",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"createLatticeKPIElement",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"createLatticeChartElement",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"createLatticeKanbanElement",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"createLatticeGanttElement",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"createLatticeLayoutElement",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"createLatticeTabsElement",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"createLatticeRouterElement",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"createLatticeElements",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(e,"defineLatticeElements",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"gridElementClass",{enumerable:!0,get:function(){return ne}});const L=K("packages/core/src/internal/util.js").warnOnce,F=K("packages/modules/shared/adapter.js").aliasConfigKey,W=K("packages/modules/react/viewers.js"),Q=W.VIEWER_EVENTS,G=W.viewerHandlerName,H=W.createViewerController,U=K("packages/modules/webcomponent/controller.js"),D=U.GridElementController,v=U.observedAttributeNames,S=U.domEventName,y=U.ATTRIBUTE_CONFIG,c=K("packages/modules/webcomponent/styles.js").adoptIntoHostRoot,i="default",n="lattice-",t=Object.freeze({grid:"grid",kpi:"kpi",chart:"chart",kanban:"kanban",gantt:"gantt",layout:"layout",tabs:"tabs",router:"router"}),r=Object.freeze({chart:ie=>{if("data"in ie){const ae=ie.data;delete ie.data,ae!=null&&ie.rows===void 0&&(ie.rows=ae)}if("stacked"in ie){const ae=ie.stacked;delete ie.stacked,ae!=null&&ie.stack===void 0&&(ie.stack=ae)}if("horizontal"in ie){const ae=ie.horizontal;delete ie.horizontal,ae&&ie.type==="bar"&&(ie.type="horizontalBar")}},kanban:ie=>{if(!("titleProperty"in ie))return;const ae=ie.titleProperty;if(delete ie.titleProperty,typeof ae!="string"||!ae)return;const re=ie.card&&typeof ie.card=="object"?ie.card:null;re&&re.title!==void 0||(ie.card={title:ae,...re||{}})},gantt:ie=>{if(!("scale"in ie))return;const ae=ie.scale;if(delete ie.scale,ae==null||ae==="")return;const re=ie.render&&typeof ie.render=="object"?{...ie.render}:{};re.zoom===void 0&&(re.zoom=ae),ie.render=re}}),s=Object.freeze({kpi:Object.freeze({label:"lattice-kpi",requires:Object.freeze([]),fromContext:"grid",properties:Object.freeze(["tiles","rows","columns"]),scalars:Object.freeze(["rowKey","locale"])}),chart:Object.freeze({label:"lattice-chart",requires:Object.freeze(["grid"]),fromContext:"grid",properties:Object.freeze(["shapes","series","data"]),scalars:Object.freeze(["type","x","y","value","label","lon","lat","labels","stacked","horizontal","scheme","subtitle","footnote","tooltip","legend"])}),kanban:Object.freeze({label:"lattice-kanban",requires:Object.freeze([]),fromContext:"grid",properties:Object.freeze(["rows","columns","card"]),scalars:Object.freeze(["rowKey","columnProperty","titleProperty","pointsProperty","orderProperty","swimlaneProperty","sprintProperty","epicProperty","swimlanes","virtualize"])}),gantt:Object.freeze({label:"lattice-gantt",requires:Object.freeze([]),fromContext:null,properties:Object.freeze(["tasks","dependencies","resources","calendar","columns"]),scalars:Object.freeze(["rowKey","scale","projectStart","autoSchedule"])}),layout:Object.freeze({label:"lattice-layout",requires:Object.freeze([]),fromContext:null,properties:Object.freeze(["windows"]),scalars:Object.freeze(["columns","rows","compact","columnWidth","rowHeight","gap","overflowX","overflowY"])}),tabs:Object.freeze({label:"lattice-tabs",requires:Object.freeze([]),fromContext:null,properties:Object.freeze(["tabs"]),scalars:Object.freeze(["lazy"])})}),f=new Set(["grid-name","lattice-styles","name","route","route-options","id","class","style","slot"]),u=new Set(["role","tabindex","hidden","part","exportparts","lang","dir","title-id","is"]),o=Symbol.for("lattice.webcomponent.routerScope"),g=new WeakMap;function d(ie){if(ie==null)return;if(ie===""||ie==="true")return!0;if(ie==="false")return!1;const ae=String(ie).trim();if(ae.startsWith("[")||ae.startsWith("{"))try{return JSON.parse(ae)}catch{return ie}return ae!==""&&Number.isFinite(Number(ae))?Number(ae):ie}function h(ie,ae){const re={},se=ie&&typeof ie.getAttributeNames=="function"?ie.getAttributeNames():[];for(const le of se){if(f.has(le)||u.has(le)||ae&&ae.has(le)||le.startsWith("data-")||le.startsWith("aria-"))continue;const fe=d(ie.getAttribute(le));fe!==void 0&&(re[a(le)]=fe)}return re}function a(ie){const ae=F(ie);return ae!==ie||!ie.includes("-")?ae:ie.replace(/-([a-z0-9])/g,(re,se)=>se.toUpperCase())}function p(ie){return ie&&typeof ie.getAttributeNames=="function"?ie.getAttributeNames():[]}function w(ie){const ae=[];for(const re of p(ie))f.has(re)||u.has(re)||re.startsWith("data-")||re.startsWith("aria-")||ae.push(a(re));return ae}function k(){const ie=new Map,ae=new Set;return{publish(re,se){const le=re||i;se?ie.set(le,se):ie.delete(le);for(const fe of[...ae])fe()},get(re){return ie.get(re||i)||null},names(){return[...ie.keys()]},subscribe(re){return ae.add(re),()=>{ae.delete(re)}}}}function m(ie={}){const ae=typeof ie.createDataRouter=="function"?ie.createDataRouter:null;let re=null,se=!1;return{grids:k(),get router(){return re},attach(fe,be,Le){se||!ae||(re||(re=ae(ie.config||{})),re.attach(fe,be,Le||{}))},detach(fe){if(!(se||!re))try{re.detach(fe)}catch{}},destroy(){se=!0;const fe=re;re=null,fe&&fe.destroy()}}}function b(ie){let ae=ie&&ie.parentNode||null;for(;ae;){if(ae[o])return ae[o];ae=ae.parentNode||ae.host||null}const se=(ie&&typeof ie.getRootNode=="function"?ie.getRootNode():ie&&ie.ownerDocument||null)||globalThis.document||globalThis;let le=g.get(se);return le||(le=m(),g.set(se,le)),le}function C(ie,ae,re){const se=ae&&typeof ae=="object"?ae:{},le=re&&typeof re=="object"?re:{};for(const[fe,be]of Object.entries(se))Object.is(le[fe],be)||ie.filters.where(fe,typeof be=="function"?be:null);for(const fe of Object.keys(le))Object.hasOwn(se,fe)||ie.filters.where(fe,null)}function M(ie,ae){if(!Object.hasOwn(ie,ae))return;const re=ie[ae];delete ie[ae],ie[ae]=re}const P=new Set(["instance","config","grid","gridName","router"]);function x(ie,ae){let re=Object.getPrototypeOf(ie);for(;re;){const se=Object.getOwnPropertyDescriptor(re,ae);if(se)return typeof se.get=="function";re=Object.getPrototypeOf(re)}return!1}function E(ie,ae){if(!ae||P.has(ae)||ae.startsWith("__"))return;const re=Object.getOwnPropertyDescriptor(ie,ae);if(re&&typeof re.get=="function")return;if(x(ie,ae)){re&&M(ie,ae);return}const se=re?re.value:void 0;re&&delete ie[ae],Object.defineProperty(ie,ae,{get(){return this.__props[ae]},set(le){this.__write(ae,le)},configurable:!0,enumerable:!0}),re&&(ie[ae]=se)}function A(ie){let ae=!1;for(const re of Object.getOwnPropertyNames(ie)){if(re.startsWith("__")||P.has(re))continue;const se=Object.getOwnPropertyDescriptor(ie,re);!se||typeof se.get=="function"||!se.enumerable||(E(ie,re),ae=!0)}return ae}function j(ie,ae,re){if(!ie||typeof ie.dispatchEvent!="function")return;const se=globalThis.CustomEvent,le={detail:re,bubbles:!0,composed:!0};ie.dispatchEvent(typeof se=="function"?new se(ae,le):{type:ae,...le})}function $(ie){const ae=ie.viewer,re=s[ae],se=ie.label||re.label,le=ie.mount,fe=Q[ae]||[];class be extends ie.Base{__props={};__controller=null;__builtAgainst=null;__connected=!1;__teardownPending=!1;__release=[];__queued=!1;__wired=!1;__scope=null;__ownAttributes=new Set;constructor(){super();for(const we of["config","grid","gridName",...re.properties,...re.scalars])M(this,we);A(this)}get instance(){return this.__controller?this.__controller.instance:null}get grid(){return this.__props.grid}set grid(we){this.__write("grid",we)}get gridName(){const we=this.__props.gridName;if(typeof we=="string")return we;const Re=typeof this.getAttribute=="function"?this.getAttribute("grid-name"):null;return Re===null?void 0:Re}set gridName(we){this.__write("gridName",we)}get config(){return{...this.__props}}set config(we){if(!(!we||typeof we!="object")){for(const[Re,ge]of Object.entries(we))this.__props[Re]=ge;this.__schedule()}}connectedCallback(){if(this.__teardownPending=!1,!this.__connected){if(this.__connected=!0,!this.__wired){this.__wired=!0;const we=c(this);we&&this.__release.push(we);const Re=b(this);this.__scope=Re,re.fromContext&&this.__release.push(Re.grids.subscribe(()=>this.__settle()));const ge=globalThis.MutationObserver;if(typeof ge=="function"){const he=new ge(()=>this.__settle());he.observe(this,{attributes:!0}),this.__release.push(()=>he.disconnect())}}A(this);for(const we of w(this))E(this,we);this.__schedule()}}disconnectedCallback(){this.__connected&&(this.__connected=!1,this.__teardownPending=!0,queueMicrotask(()=>this.__settleTeardown()))}__settleTeardown(){if(this.__teardownPending){this.__teardownPending=!1,this.__wired=!1,this.__scope=null;for(const we of this.__release.splice(0))try{we()}catch{}this.__tearDown()}}__write(we,Re){this.__props[we]=Re,this.__schedule()}__schedule(){this.__queued||(this.__queued=!0,queueMicrotask(()=>{this.__queued=!1,this.__settle()}))}__boundGrid(){if(!re.fromContext)return null;if(this.__props.grid!==void 0)return this.__props.grid||null;const we=this.__scope;return we?we.grids.get(this.gridName):null}__resolve(){const we={...h(this,this.__ownAttributes),...this.__props};if(delete we.gridName,re.fromContext){const ge=this.__boundGrid();ge?we[re.fromContext]=ge:delete we[re.fromContext]}const Re=r[ae];Re&&Re(we);for(const ge of fe)we[G(ge)]=he=>j(this,S(ge),he);return we}__settle(){if(!this.__connected)return;A(this);const we=this.__resolve(),Re=re.fromContext&&we[re.fromContext]||null;if(this.__controller&&!Object.is(this.__builtAgainst,Re)&&this.__tearDown(),!this.__controller){for(const he of re.requires)if(we[he]===void 0||we[he]===null)return;if(re.fromContext&&!Re&&we.rows===void 0)return;const ge=new Set(p(this));this.__controller=H({viewer:ae,mount:le,element:this,props:we,name:se});for(const he of p(this))ge.has(he)||this.__ownAttributes.add(he);this.__builtAgainst=Re,j(this,"ready",{instance:this.__controller.instance});return}this.__controller.update(we)}__tearDown(){const we=this.__controller;this.__controller=null,this.__builtAgainst=null,we&&(j(this,"destroyed",{instance:we.instance}),we.destroy())}}for(const Le of[...re.properties,...re.scalars])Le in ie.Base.prototype||Object.defineProperty(be.prototype,Le,{get(){return this.__props[Le]},set(we){this.__write(Le,we)},configurable:!0,enumerable:!0});return be}function z(ie,ae,re){if(typeof ie!="function")throw new TypeError(`${ae} needs ${re}: ${ae}({ ${re} }).`)}function T(){const ie=globalThis.HTMLElement;return typeof ie=="function"?ie:null}function R(ie){z(ie&&ie.createKPI,"createLatticeKPIElement","createKPI");const ae=T();return ae?$({viewer:"kpi",Base:ae,mount:(re,se)=>ie.createKPI(re,se)}):null}function O(ie){z(ie&&ie.createChart,"createLatticeChartElement","createChart");const ae=T();return ae?$({viewer:"chart",Base:ae,mount:(re,se)=>ie.createChart({...se,container:re})}):null}function I(ie){z(ie&&ie.createKanban,"createLatticeKanbanElement","createKanban");const ae=T();return ae?$({viewer:"kanban",Base:ae,mount:(re,se)=>ie.createKanban(re,se)}):null}function q(ie){z(ie&&ie.createGantt,"createLatticeGanttElement","createGantt");const ae=T();return ae?$({viewer:"gantt",Base:ae,mount:(re,se)=>ie.createGantt({...se,element:re})}):null}function Z(ie){z(ie&&ie.createLayout,"createLatticeLayoutElement","createLayout");const ae=T();return ae?$({viewer:"layout",Base:ae,mount:(re,se)=>ie.createLayout(re,se)}):null}function _(ie){z(ie&&ie.createTabs,"createLatticeTabsElement","createTabs");const ae=T();return ae?$({viewer:"tabs",Base:ae,mount:(se,le)=>{const fe=new Map,be=typeof se.querySelectorAll=="function"?[...se.querySelectorAll("template[data-tab]")]:[];for(const Re of be)Re.parentNode===se&&fe.set(Re.getAttribute("data-tab"),Re);const we=(Array.isArray(le.tabs)&&le.tabs.length?le.tabs:[...fe.keys()].map(Re=>({id:Re,label:fe.get(Re).getAttribute("data-label")||Re}))).map(Re=>{const ge=Re,he=fe.get(ge.id);return he?{...ge,view:Oe=>{const Ee=he.content.cloneNode(!0),Ie=[...Ee.childNodes];return Oe.appendChild(Ee),{destroy(){for(const ze of Ie)ze.parentNode&&ze.parentNode.removeChild(ze)}}}}:ge});return ie.createTabs(se,{...le,tabs:we,createGrid:ie.createGrid||(()=>{throw new Error('[lattice] <lattice-tabs>: a tab has neither a <template data-tab="…"> nor a createGrid to build it with. Give the tab a template, or pass createGrid into createLatticeTabsElement.')})})}}):null}function J(ie){z(ie&&ie.createDataRouter,"createLatticeRouterElement","createDataRouter");const ae=T();if(!ae)return null;class re extends ae{__scope=null;__config={};constructor(){super(),M(this,"config")}get config(){return{...this.__config}}set config(le){!le||typeof le!="object"||(this.__config={...this.__config,...le},this.__scope&&this.__scope.router&&L("webcomponent.router.mountOnly.config","[lattice] <lattice-router>: `config` changed after the router was built. Nothing was applied and the router was NOT rebuilt — rebuilding it would detach every grid and drop every row it holds. Replace the <lattice-router> element itself when a genuinely different router is wanted."))}get router(){return this.__scope?this.__scope.router:null}get instance(){return this.router}connectedCallback(){if(this.__scope)return;const le=h(this);this.__scope=m({createDataRouter:ie.createDataRouter,config:{...le,...this.__config}}),this[o]=this.__scope}disconnectedCallback(){const le=this.__scope;if(this.__scope=null,this[o]=null,!le)return;const fe=le.router;le.destroy(),fe&&j(this,"destroyed",{instance:fe})}}return re}function ee(ie={}){const ae={},re=(se,le,fe)=>{if(typeof le!="function")return;const be=fe();be&&(ae[se]=be)};return re("LatticeGridElement",ie.createGrid,()=>ne(ie.createGrid)),re("LatticeKPIElement",ie.createKPI,()=>R({createKPI:ie.createKPI})),re("LatticeChartElement",ie.createChart,()=>O({createChart:ie.createChart})),re("LatticeKanbanElement",ie.createKanban,()=>I({createKanban:ie.createKanban})),re("LatticeGanttElement",ie.createGantt,()=>q({createGantt:ie.createGantt})),re("LatticeLayoutElement",ie.createLayout,()=>Z({createLayout:ie.createLayout})),re("LatticeTabsElement",ie.createTabs,()=>_({createTabs:ie.createTabs,createGrid:ie.createGrid})),re("LatticeRouterElement",ie.createDataRouter,()=>J({createDataRouter:ie.createDataRouter})),ae}function te(ie={}){const ae=globalThis.customElements,re={};if(!ae||typeof ae.define!="function")return re;const se=typeof ie.prefix=="string"?ie.prefix:n,le=ee(ie),fe={LatticeGridElement:t.grid,LatticeKPIElement:t.kpi,LatticeChartElement:t.chart,LatticeKanbanElement:t.kanban,LatticeGanttElement:t.gantt,LatticeLayoutElement:t.layout,LatticeTabsElement:t.tabs,LatticeRouterElement:t.router};for(const[be,Le]of Object.entries(le)){const we=se+fe[be],Re=ae.get?ae.get(we):void 0;if(Re){re[we]=Re;continue}ae.define(we,Le),re[we]=Le}return re}function ne(ie){const ae=T();if(!ae)return null;class re extends ae{static get observedAttributes(){return v()}__connected=!1;__teardownPending=!1;__published=!1;__publishedAs=i;__scope=null;__predicates=void 0;__rowUpdates=void 0;__release=[];constructor(){super(),this.__controller=new D(this,{createGrid:ie});for(const le of["rows","columns","config","predicates","rowUpdates",...Object.values(y)])M(this,le)}get grid(){return this.__controller.grid}get instance(){return this.__controller.grid}get rows(){return this.__controller.config().rows}set rows(le){this.__controller.configure({rows:le})}get columns(){return this.__controller.config().columns}set columns(le){this.__controller.configure({columns:le})}get config(){return this.__controller.config()}set config(le){this.__controller.configure(le)}get predicates(){return this.__predicates}set predicates(le){const fe=this.__published?this.__controller.grid:null;fe&&C(fe,le,this.__predicates),this.__predicates=le}get rowUpdates(){return this.__rowUpdates}set rowUpdates(le){if(Object.is(le,this.__rowUpdates))return;this.__rowUpdates=le;const fe=this.__published?this.__controller.grid:null;fe&&le&&fe.rows.apply(le)}connectedCallback(){if(this.__teardownPending=!1,!this.__connected){if(this.__connected=!0,!this.__scope){const le=c(this);le&&this.__release.push(le),this.__scope=b(this)}this.__controller.connect(),queueMicrotask(()=>this.__publish())}}disconnectedCallback(){this.__connected&&(this.__connected=!1,this.__teardownPending=!0,queueMicrotask(()=>this.__settleTeardown()),this.__controller.disconnect())}attributeChangedCallback(le,fe,be){this.__controller.attributeChanged(le,be)}__publish(){if(!this.__connected||this.__published)return;const le=this.__controller.grid;if(!le)return;this.__published=!0,this.__predicates&&C(le,this.__predicates,{});const fe=typeof this.getAttribute=="function"?this.getAttribute("name"):null;this.__publishedAs=fe||i;const be=this.__scope;be&&be.grids.publish(this.__publishedAs,le);const Le=typeof this.getAttribute=="function"?this.getAttribute("route"):null;if(be&&Le!==null){const we=this.getAttribute("route-options");be.attach(le,d(Le),we===null?{}:d(we))}this.__rowUpdates&&le.rows.apply(this.__rowUpdates),j(this,"grid-ready",{grid:le})}__settleTeardown(){if(!this.__teardownPending)return;this.__teardownPending=!1;const le=this.__controller.grid,fe=this.__scope;this.__scope=null,this.__published=!1;for(const be of this.__release.splice(0))try{be()}catch{}le&&fe&&(j(this,"grid-destroyed",{grid:le}),fe.detach(le),fe.grids.publish(this.__publishedAs,null)),this.__controller.settleTeardown()}}for(const se of Object.values(y))Object.getOwnPropertyDescriptor(re.prototype,se)||se in ae.prototype||Object.defineProperty(re.prototype,se,{get(){return this.__controller.config()[se]},set(le){this.__controller.configure({[se]:le})},configurable:!0,enumerable:!0});return re}}),xe("packages/modules/webcomponent/index.js",function(e,K){"use strict";Object.defineProperty(e,"TAG_NAME",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createLatticeGridElement",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"defineLatticeGrid",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const X=K("packages/dom/src/index.js"),L=X.createGrid,B=K("packages/modules/webcomponent/elements.js"),F=B.gridElementClass,W=K("packages/modules/webcomponent/controller.js");Object.defineProperty(e,"GridElementController",{enumerable:!0,get:function(){return W.GridElementController}}),Object.defineProperty(e,"observedAttributeNames",{enumerable:!0,get:function(){return W.observedAttributeNames}}),Object.defineProperty(e,"domEventName",{enumerable:!0,get:function(){return W.domEventName}}),Object.defineProperty(e,"ATTRIBUTE_CONFIG",{enumerable:!0,get:function(){return W.ATTRIBUTE_CONFIG}}),Object.defineProperty(e,"EVENT_PREFIX",{enumerable:!0,get:function(){return W.EVENT_PREFIX}}),Object.defineProperty(e,"createLatticeElements",{enumerable:!0,get:function(){return B.createLatticeElements}}),Object.defineProperty(e,"defineLatticeElements",{enumerable:!0,get:function(){return B.defineLatticeElements}}),Object.defineProperty(e,"ELEMENT_TAGS",{enumerable:!0,get:function(){return B.ELEMENT_TAGS}}),Object.defineProperty(e,"createLatticeKPIElement",{enumerable:!0,get:function(){return B.createLatticeKPIElement}}),Object.defineProperty(e,"createLatticeChartElement",{enumerable:!0,get:function(){return B.createLatticeChartElement}}),Object.defineProperty(e,"createLatticeKanbanElement",{enumerable:!0,get:function(){return B.createLatticeKanbanElement}}),Object.defineProperty(e,"createLatticeGanttElement",{enumerable:!0,get:function(){return B.createLatticeGanttElement}}),Object.defineProperty(e,"createLatticeLayoutElement",{enumerable:!0,get:function(){return B.createLatticeLayoutElement}}),Object.defineProperty(e,"createLatticeTabsElement",{enumerable:!0,get:function(){return B.createLatticeTabsElement}}),Object.defineProperty(e,"createLatticeRouterElement",{enumerable:!0,get:function(){return B.createLatticeRouterElement}});const Q=K("packages/modules/webcomponent/styles.js");Object.defineProperty(e,"adoptLatticeStyles",{enumerable:!0,get:function(){return Q.adoptLatticeStyles}}),Object.defineProperty(e,"latticeStyleSheets",{enumerable:!0,get:function(){return Q.latticeStyleSheets}});const G=K("packages/modules/react/viewers.js");Object.defineProperty(e,"VIEWER_EVENTS",{enumerable:!0,get:function(){return G.VIEWER_EVENTS}}),Object.defineProperty(e,"VIEWER_APPLY",{enumerable:!0,get:function(){return G.VIEWER_APPLY}}),Object.defineProperty(e,"viewerHandlerName",{enumerable:!0,get:function(){return G.viewerHandlerName}}),Object.defineProperty(e,"createViewerController",{enumerable:!0,get:function(){return G.createViewerController}});const H=K("packages/modules/shared/adapter.js");Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return H.EVENT_NAMES}}),Object.defineProperty(e,"dashedName",{enumerable:!0,get:function(){return H.dashedName}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return X.createCurrencyType}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return X.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return X.registerUnitSystem}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return X.createStat}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return X.createHeadlessGrid}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return X.duckdbAdapter}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return X.createPushdownSource}});const U="lattice-grid";function D(y=L){return F(y)}function v(y={}){const l=globalThis.customElements,c=y.tagName||U;if(!l||typeof l.define!="function")return null;const i=l.get?l.get(c):void 0;if(i)return i;const n=D(y.createGrid||L);return n?(l.define(c,n),n):null}v();const S=v});try{Gn("packages/worker/src/inline.js").setWorkerSource('(function(yt){"use strict";var nt=Object.create(null),rt=Object.create(null);function Se(o,me){nt[o]=me}function it(o){var me=rt[o];if(me)return me;var fe=Object.create(null);rt[o]=fe;var he=nt[o];if(!he)throw new Error("[lattice] missing module: "+o);return he(fe,it),fe}Se("packages/core/src/internal/util.js",function(o,me){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return a}}),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 h}}),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 M}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return oe}});const fe="1.81.0";async function he(){return fe}const Q="1.81.0",z=new Set,ne=2e3;function _(w){if(z.add(w),z.size>ne){const v=z.values().next().value;v!==void 0&&z.delete(v)}}const T=[],K=500;function ie(w,v,Z){T.push({key:w,level:v,message:Z.map(x=>typeof x=="string"?x:J(x)).join(" "),at:Date.now()}),T.length>K&&T.shift()}function J(w){if(w instanceof Error)return w.message;try{return JSON.stringify(w)}catch{return String(w)}}function le(){return T.map(w=>({...w}))}function ue(w){if(w.length===0||typeof w[0]!="string")return w;const v=w[0].replace(/^\\[lattice\\]\\s*/,"");return v===w[0]?w:[v,...w.slice(1)]}function W(w,...v){if(z.has(w))return;_(w);const Z=ue(v);ie(w,"warn",Z),console.warn("[lattice]",...Z)}function L(w,...v){if(z.has(w))return;_(w);const Z=ue(v);ie(w,"info",Z),console.info("[lattice]",...Z)}function Y(){z.clear(),T.length=0}function ee(w,v){const Z=new Error(`[lattice] ${w}`);throw v!==void 0&&(Z.cause=v),Z}function C(w,v){w||ee(v)}const A=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function i(w){return w!==null&&typeof w=="object"&&!Array.isArray(w)}function s(w){return typeof w=="function"}function u(w){return w==null}function f(w){return w==null||w===""}function l(w){return typeof w!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(w))?!0:!!(w.prototype&&Object.getOwnPropertyNames(w.prototype).length>1)}const t=new Map;function a(w){let v=t.get(w);if(v)return v;if(!w.includes("."))v=Z=>Z?.[w];else{const Z=w.split("."),x=Z.length;v=de=>{let we=de;for(let ge=0;ge<x;ge++){if(we==null)return;we=we[Z[ge]]}return we}}return t.set(w,v),v}const m=new Map;function e(w){let v=m.get(w);if(v)return v;if(!w.includes("."))v=(Z,x)=>{Z!=null&&(Z[w]=x)};else{const Z=w.split("."),x=Z.length-1;v=(de,we)=>{let ge=de;for(let pe=0;pe<x;pe++){if(ge==null)return;const Te=Z[pe];ge[Te]==null&&(ge[Te]={}),ge=ge[Te]}ge!=null&&(ge[Z[x]]=we)}}return m.set(w,v),v}function d(w,v){return a(v)(w)}function h(w,v,Z){e(v)(w,Z)}function r(w){return w?(w.includes(".")?w.slice(w.lastIndexOf(".")+1):w).replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/\\s+/g," ").trim().replace(/^./,Z=>Z.toUpperCase()):""}const n={"&":"&","<":"<",">":">",\'"\':""","\'":"'"};function c(w){const v=w==null?"":String(w);return/[&<>"\']/.test(v)?v.replace(/[&<>"\']/g,Z=>n[Z]):v}function g(w){return String(w).replace(/\\w\\S*/g,v=>v[0].toUpperCase()+v.slice(1).toLowerCase())}function M(w,v,Z){if(w!==void 0)return w===!0?{enabled:!0,...Z}:w===!1?{enabled:!1}:i(w)?w:{[v]:w,enabled:!0}}function N(w){return w==null?[]:Array.isArray(w)?w:[w]}const G=Object.freeze(new Set(["__proto__","constructor","prototype"]));function F(w,v){if(!i(w))return i(v)?{...v}:v;if(!i(v))return v===void 0?w:v;const Z={...w};for(const x of Object.keys(v)){if(G.has(x))continue;const de=v[x];de!==void 0&&(Z[x]=i(de)&&i(Z[x])?F(Z[x],de):de)}return Z}function R(w,v){if(!i(w)||!i(v)||w===v)return v;const Z=Object.create(Object.getPrototypeOf(w));return Object.assign(Z,w,v),Z}class X{#t;#e=new Map;#n;constructor(v=256,Z=null){this.#t=v,this.#n=Z}get size(){return this.#e.size}get max(){return this.#t}set max(v){this.#t=v,this.#r()}has(v){return this.#e.has(v)}get(v){const Z=this.#e;if(!Z.has(v))return;const x=Z.get(v);return Z.delete(v),Z.set(v,x),x}peek(v){return this.#e.get(v)}set(v,Z){const x=this.#e;return x.has(v)&&x.delete(v),x.set(v,Z),this.#r(),Z}delete(v){const Z=this.#e.get(v);return this.#e.delete(v)&&this.#n&&this.#n(Z,v),Z}clear(){if(this.#n)for(const[v,Z]of this.#e)this.#n(Z,v);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const v=this.#e;for(;v.size>this.#t;){const Z=v.keys().next().value,x=v.get(Z);v.delete(Z),this.#n&&this.#n(x,Z)}}}const E=new Map;function S(w,v){const Z=`${w||""}|${v?JSON.stringify(v):""}`;let x=E.get(Z);return x||(x=new Intl.Collator(w||void 0,{numeric:!0,sensitivity:"variant",...v}),E.set(Z,x)),x}function U(w,v){if(w===v)return 0;if(w==null)return 1;if(v==null)return-1;if(typeof w=="number"&&typeof v=="number")return Number.isNaN(w)?Number.isNaN(v)?0:1:Number.isNaN(v)||w<v?-1:w>v?1:0;const Z=String(w),x=String(v);return Z<x?-1:Z>x?1:0}function H(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const $=typeof requestAnimationFrame=="function";function re(w){return $?requestAnimationFrame(w):setTimeout(()=>w(H()),16)}function te(w){w!=null&&($?cancelAnimationFrame(w):clearTimeout(w))}function ae(w){let v=null,Z=null;const x=()=>{v=null;const we=Z;Z=null,w(...we||[])},de=(...we)=>{Z=we,v===null&&(v=re(x))};return de.cancel=()=>{te(v),v=null,Z=null},de.flush=()=>{v!==null&&(te(v),x())},de}function p(w,v){let Z=null,x=null;const de=()=>{if(Z=null,x===null)return;const pe=x;x=null,w(...pe),we()},we=()=>{Z=setTimeout(de,v),typeof Z?.unref=="function"&&Z.unref()},ge=(...pe)=>{Z===null?(w(...pe),we()):(x=pe,clearTimeout(Z),we())};return ge.flush=()=>{if(Z!==null&&clearTimeout(Z),Z=null,x===null)return;const pe=x;x=null,w(...pe)},ge.cancel=()=>{Z!==null&&clearTimeout(Z),Z=null,x=null},ge.pending=()=>Z!==null||x!==null,ge}function B(w,v=50){return typeof requestIdleCallback=="function"?requestIdleCallback(w,{timeout:v}):setTimeout(()=>w({timeRemaining:()=>0,didTimeout:!0}),1)}let q=0;function oe(w="l"){return`${w}${(++q).toString(36)}`}}),Se("packages/worker/src/transport.js",function(o,me){"use strict";Object.defineProperty(o,"PROTOCOL",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"OPS",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"ERRORS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"packHandle",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"packHandles",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"TransportedDictionary",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,Q=fe.isFunction,z=1,ne=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"}),_=Object.freeze({READY:"ready",CANCEL:"cancel",PING:"ping"}),T=Object.freeze({NO_COMPUTE:"E_NO_COMPUTE",NO_KERNEL:"E_NO_KERNEL",ABORTED:"E_ABORTED",KERNEL:"E_KERNEL",PROTOCOL:"E_PROTOCOL"});function K(s){if(s==null)return null;const u=s.presence;return{id:s.id,kind:s.kind,nullable:!!s.nullable,values:s.values??null,presence:u?u.words??u:null,presenceBits:u?u.size??(u.words??u).length*8:0,dict:s.dict?ie(s.dict):null,offsets:s.offsets??null,version:s.version??0}}function ie(s){return Array.isArray(s)?s:Q(s.values)?s.values():[]}function J(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=K(s[f]);return u}class le{#t;#e;constructor(u,f){this.#t=u,this.#e=f}get words(){return this.#t}get size(){return this.#e}get(u){return(this.#t[u>>>3]&1<<(u&7))!==0}count(){const u=this.#t;let f=0;for(let l=0;l<u.length;l++){let t=u[l];for(;t;)t&=t-1,f++}return f}}class ue{#t;#e=null;#n=0;#r=new Map;constructor(u){this.#t=u||[]}get size(){return this.#t.length}get version(){return this.#n}codeOf(u){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 f=this.#e.get(u);if(f!==void 0)return f;const l=this.#t.length;return this.#t.push(u),this.#e.set(u,l),this.#n++,l}valueOf(u){return this.#t[u]}values(){return this.#t}ranks(u){const f=u||"",l=this.#r.get(f);if(l&&l.version===this.#n)return l.ranks;const t=this.#t.length,a=new Uint32Array(t);for(let r=0;r<t;r++)a[r]=r;const m=he(u).compare,e=this.#t,d=Array.from(a).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))}),h=new Uint32Array(t);for(let r=0;r<d.length;r++)h[d[r]]=r;return this.#r.set(f,{version:this.#n,ranks:h}),h}}function W(s){if(s==null)return null;const u=s.presence?new le(s.presence,s.presenceBits||s.presence.length*8):null,f=s.dict?new ue(s.dict):null,l=s.values,t=s.offsets??null,a=s.kind,m=e=>{if(u&&!u.get(e))return null;switch(a){case"dictionary":return f?f.valueOf(l[e]):l[e];case"bitset":return(l[e>>>3]&1<<(e&7))!==0;case"multi":{if(!t)return null;const d=t[e],h=t[e+1],r=new Array(h-d);for(let n=d;n<h;n++)r[n-d]=f?f.valueOf(l[n]):l[n];return r}default:return l[e]}};return{id:s.id,kind:a,nullable:s.nullable,values:l,presence:u,dict:f,offsets:t,get:m,version:s.version}}function L(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=W(s[f]);return u}function Y(){const s=[],u=[];return{mask(f){for(let l=0;l<s.length;l++)if(s[l].length>=f){const t=s.splice(l,1)[0].subarray(0,f);return t.fill(0),t}return new Uint8Array(f)},indices(f){for(let l=0;l<u.length;l++)if(u[l].length>=f)return u.splice(l,1)[0].subarray(0,f);return new Uint32Array(f)},release(f){f&&(f instanceof Uint8Array?s.push(f):f instanceof Uint32Array&&u.push(f))},clear(){s.length=0,u.length=0}}}function ee(s){if(!ArrayBuffer.isView(s))return!1;const u=s.buffer;return u?typeof SharedArrayBuffer>"u"||!(u instanceof SharedArrayBuffer):!1}function C(s,u=[]){const f=l=>{if(!ee(l))return;const t=l.buffer;u.includes(t)||u.push(t)};if(s==null)return u;if(ArrayBuffer.isView(s))return f(s),u;if(Array.isArray(s)){for(const l of s)f(l);return u}if(typeof s=="object")for(const l of Object.keys(s)){const t=s[l];if(Array.isArray(t))for(const a of t)f(a);else f(t)}return u}function A(s,u=0){if(s==null)return!0;const f=typeof s;if(f==="function"||f==="symbol")return!1;if(f!=="object"||u>4||ArrayBuffer.isView(s)||s instanceof ArrayBuffer||s instanceof Date)return!0;if(Array.isArray(s)){for(const l of s)if(!A(l,u+1))return!1;return!0}for(const l of Object.keys(s))if(!A(s[l],u+1))return!1;return!0}function i(s,u=new Set){if(!s||typeof s!="object")return u;const f=s;typeof f.col=="string"&&u.add(f.col);const l=f.conditions;if(Array.isArray(l))for(const t of l)i(t,u);return u}}),Se("packages/core/src/store/bitset.js",function(o,me){"use strict";Object.defineProperty(o,"Bitset",{enumerable:!0,get:function(){return he}});const fe=8;class he{static#t=new Uint8Array(256);static{for(let z=1;z<256;z++)he.#t[z]=he.#t[z>>1]+(z&1)}#e;#n;constructor(z=0){const ne=Math.max(0,z|0);this.#n=ne,this.#e=new Uint8Array(Math.ceil(ne/fe))}get size(){return this.#n}get words(){return this.#e}get bytes(){return this.#e?this.#e.byteLength:0}get(z){return z<0||z>=this.#n?0:this.#e[z>>3]>>(z&7)&1}set(z){return z>=0&&z<this.#n&&(this.#e[z>>3]|=1<<(z&7)),this}clear(z){return z>=0&&z<this.#n&&(this.#e[z>>3]&=~(1<<(z&7))),this}assign(z,ne){return ne?this.set(z):this.clear(z)}fill(z=!1){return this.#e.fill(z?255:0),z&&this.#r(),this}grow(z){const ne=Math.max(0,z|0);if(ne<=this.#n)return this;const _=Math.ceil(ne/fe);if(_>this.#e.length){const T=new Uint8Array(_);T.set(this.#e),this.#e=T}return this.#n=ne,this}count(){const z=this.#e,ne=he.#t;let _=0;for(let T=0;T<z.length;T++)_+=ne[z[T]];return _}and(z){const ne=z instanceof he?z.words:z,_=this.#e,T=Math.min(_.length,ne.length);for(let K=0;K<T;K++)_[K]&=ne[K];for(let K=T;K<_.length;K++)_[K]=0;return this}or(z){const ne=z instanceof he?z.words:z,_=this.#e,T=Math.min(_.length,ne.length);for(let K=0;K<T;K++)_[K]|=ne[K];return this}not(){const z=this.#e;for(let ne=0;ne<z.length;ne++)z[ne]=~z[ne]&255;return this.#r(),this}clone(){const z=new he(this.#n);return z.words.set(this.#e.subarray(0,z.words.length)),z}release(){this.#e=new Uint8Array(0),this.#n=0}#r(){const z=this.#n&7;if(z===0)return;const ne=this.#n>>3;ne<this.#e.length&&(this.#e[ne]&=(1<<z)-1)}static from(z){const ne=Array.isArray(z)?z:Array.from(z),_=new he(ne.length);for(let T=0;T<ne.length;T++)ne[T]&&_.set(T);return _}}}),Se("packages/core/src/store/dictionary.js",function(o,me){"use strict";Object.defineProperty(o,"Dictionary",{enumerable:!0,get:function(){return z}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,Q=fe.defaultCompare;class z{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(_=[]){this.#t=[];for(let T=0;T<_.length;T++){const K=_[T];this.#e.has(K)||(this.#e.set(K,this.#t.length),this.#t.push(K))}}get size(){return this.#t.length}get version(){return this.#n}get bytes(){let _=this.#t.length*8;for(let T=0;T<this.#t.length;T++){const K=this.#t[T];typeof K=="string"&&(_+=K.length*2),_+=16}return _}codeOf(_){const T=this.#e.get(_);if(T!==void 0)return T;const K=this.#t.length;return this.#t.push(_),this.#e.set(_,K),this.#n++,K}lookup(_){const T=this.#e.get(_);return T===void 0?-1:T}has(_){return this.#e.has(_)}valueOf(_){return this.#t[_]}values(){return this.#t}ranks(_){const T=_||"";if(this.#r&&this.#i===this.#n&&this.#s===T)return this.#r;const K=this.#t.length,ie=new Array(K);for(let W=0;W<K;W++)ie[W]=W;const J=he(_).compare,le=this.#t;ie.sort((W,L)=>this.#h(le[W],le[L],J));const ue=new Uint32Array(K);for(let W=0;W<K;W++)ue[ie[W]]=W;return this.#r=ue,this.#i=this.#n,this.#s=T,ue}#h(_,T,K){return typeof _=="string"&&typeof T=="string"?K(_,T):Q(_,T)}}}),Se("packages/core/src/store/multivalue.js",function(o,me){"use strict";Object.defineProperty(o,"MultiValue",{enumerable:!0,get:function(){return fe}});class fe{#t;#e;#n=0;#r=0;constructor(Q={}){const z=Math.max(1,Q.rows??16),ne=Math.max(1,Q.values??z);this.#t=new Int32Array(ne),this.#e=new Uint32Array(z+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(Q){return Q<0||Q>=this.#n?0:this.#e[Q+1]-this.#e[Q]}at(Q){return Q<0||Q>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[Q],this.#e[Q+1])}has(Q,z){if(Q<0||Q>=this.#n)return!1;const ne=this.#t,_=this.#e[Q+1];for(let T=this.#e[Q];T<_;T++)if(ne[T]===z)return!0;return!1}hasAny(Q,z){for(let ne=0;ne<z.length;ne++)if(this.has(Q,z[ne]))return!0;return!1}hasAll(Q,z){for(let ne=0;ne<z.length;ne++)if(!this.has(Q,z[ne]))return!1;return!0}hasNone(Q,z){return!this.hasAny(Q,z)}push(Q){const z=this.#n,ne=Q.length;this.#i(z+1),this.#s(this.#r+ne);const _=this.#r;for(let T=0;T<ne;T++)this.#t[_+T]=Q[T]|0;return this.#r+=ne,this.#n=z+1,this.#e[z]=_,this.#e[z+1]=this.#r,z}write(Q,z){if(Q===this.#n){this.push(z);return}if(Q<0||Q>this.#n)return;const ne=this.#e[Q],_=this.#e[Q+1],T=z.length;if(_-ne===T){for(let K=0;K<T;K++)this.#t[ne+K]=z[K]|0;return}this.#h(Q,z)}compact(Q,z,ne){const _=this.#t,T=this.#e,K=this.#n,ie=new Int32Array(Math.max(1,this.#r)),J=new Uint32Array(z+1);let le=0;for(let ue=0;ue<K;ue++){if(Q[ue]===ne)continue;const W=T[ue],L=T[ue+1];J[Q[ue]]=le;for(let Y=W;Y<L;Y++)ie[le++]=_[Y];J[Q[ue]+1]=le}this.#t=ie,this.#e=J,this.#n=z,this.#r=le}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(Q){if(Q+1<=this.#e.length)return;let z=this.#e.length-1;for(;z<Q;)z=z*2||16;const ne=new Uint32Array(z+1);ne.set(this.#e),this.#e=ne}#s(Q){if(Q<=this.#t.length)return;let z=this.#t.length;for(;z<Q;)z=z*2||16;const ne=new Int32Array(z);ne.set(this.#t),this.#t=ne}#h(Q,z){const ne=this.#t,_=this.#e,T=this.#n,K=z.length-(_[Q+1]-_[Q]),ie=new Int32Array(Math.max(1,this.#r+K)),J=new Uint32Array(_.length);let le=0;for(let ue=0;ue<T;ue++){if(J[ue]=le,ue===Q)for(let W=0;W<z.length;W++)ie[le++]=z[W]|0;else for(let W=_[ue];W<_[ue+1];W++)ie[le++]=ne[W];J[ue+1]=le}this.#t=ie,this.#e=J,this.#r=le}}}),Se("packages/core/src/compute/handle.js",function(o,me){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return A}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,Q=fe.defaultCompare,z=fe.warnOnce;function ne(i){const s=new Uint32Array(i);for(let u=0;u<i;u++)s[u]=u;return s}function _(i,s){if(s&&typeof s.count=="number")return s.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const u=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):u?i.kind==="bitset"?typeof u.size=="number"?u.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(z(`count:${i.id}`,`column "${i.id}" is bitset-backed with no declared row count; assuming ${u.length*8}`),u.length*8):u.length:i.presence&&typeof i.presence.size=="number"?i.presence.size:0}const T=new WeakMap;function K(i){const s=i.constructor;if(!s)return"unknown";const u=T.get(s);if(u)return u;let f="unknown";try{let l=null;typeof s.from=="function"?l=s.from([!1,!0]):(l=new s(8),l.set(1));const t=l&&l.words;t&&t.length&&(t[0]===2?f="lsb":t[0]===64&&(f="msb"))}catch{f="unknown"}return T.set(s,f),f}function ie(i){if(!i)return()=>0;const s=i instanceof Uint8Array?i:i.words;if(s instanceof Uint8Array){const u=i instanceof Uint8Array?"lsb":K(i);if(u==="lsb")return f=>s[f>>>3]>>>(f&7)&1;if(u==="msb")return f=>s[f>>>3]>>>7-(f&7)&1}return typeof i.get=="function"?u=>i.get(u)?1:0:()=>0}function J(i){return!i||!i.presence?null:ie(i.presence)}function le(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function ue(i,s){return i?typeof i.valueOf=="function"?i.valueOf(s):typeof i.values=="function"?i.values()[s]:null:null}function W(i,s){const u=i.offsets,f=i.values;if(!u||!f)return[];const l=u[s],t=u[s+1];if(!(t>l))return[];const a=i.dict,m=new Array(t-l);for(let e=l;e<t;e++)m[e-l]=a?ue(a,f[e]):f[e];return m}function L(i){if(!i)return()=>{};const s=i.values,u=J(i),f=i.kind;if(f==="dictionary"){const l=i.dict;return u?t=>u(t)?ue(l,s[t]):null:t=>ue(l,s[t])}if(f==="bitset"){const l=ie(s);return u?t=>u(t)?l(t)===1:null:t=>l(t)===1}if(f==="multi")return u?l=>u(l)?W(i,l):null:l=>W(i,l);if(!s&&typeof i.get=="function"){const l=i.get.bind(i);return t=>{const a=l(t);return a===void 0?null:a}}return u?l=>{if(!u(l))return null;const t=s[l];return t===void 0?null:t}:l=>{const t=s[l];return t===void 0?null:t}}function Y(i,s){if(i<s)return-1;if(i>s)return 1;if(i===s){const l=Object.is(i,-0),t=Object.is(s,-0);return l===t?0:l?-1:1}const u=Number.isNaN(i),f=Number.isNaN(s);return u&&f?0:u?1:-1}function ee(i){const s=he(i);return(u,f)=>{if(u===f)return 0;const l=typeof u,t=typeof f;if(l==="string"&&t==="string")return s.compare(u,f);if(l==="number"&&t==="number")return Y(u,f);if(l==="boolean"&&t==="boolean")return u===f?0:u?1:-1;if(u instanceof Date||f instanceof Date){const a=u instanceof Date?u.getTime():Number(u),m=f instanceof Date?f.getTime():Number(f);return Y(a,m)}return Q(u,f)}}function C(i,s){if(i&&typeof i.ranks=="function")return i.ranks(s);const u=i&&typeof i.values=="function"?i.values():[],f=u.length,l=ee(s),t=new Array(f);for(let m=0;m<f;m++)t[m]=m;t.sort((m,e)=>l(u[m],u[e])||m-e);const a=new Uint32Array(f);for(let m=0;m<f;m++)a[t[m]]=m;return a}function A(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Se("packages/core/src/compute/sort.js",function(o,me){"use strict";Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return a}}),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 F}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return R}});const fe=me("packages/core/src/compute/handle.js"),he=fe.bitReader,Q=fe.dictRanks,z=fe.dictSize,ne=fe.identity,_=fe.isMissing,T=fe.presenceReader,K=fe.rowCount,ie=fe.valueComparator,J=fe.valueReader,le=new Uint32Array(0),ue=new ArrayBuffer(8),W=new Float64Array(ue),L=new Uint32Array(ue),Y=(W[0]=-1,(L[1]&2147483648)!==0?1:0),ee=Y===1?0:1;function C(E,S){W[0]=E;let U=L[Y],H=L[ee];(U&2147483648)!==0?(U=~U>>>0,H=~H>>>0):U=(U^2147483648)>>>0,S[0]=H,S[1]=U}function A(E,S,U,H){if(H<2)return E;const $=new Uint32Array(256*8);for(let w=0;w<H;w++){const v=S[w],Z=U[w];$[v&255]++,$[256+(v>>>8&255)]++,$[512+(v>>>16&255)]++,$[768+(v>>>24&255)]++,$[1024+(Z&255)]++,$[1280+(Z>>>8&255)]++,$[1536+(Z>>>16&255)]++,$[1792+(Z>>>24&255)]++}let re=E,te=S,ae=U,p=new Uint32Array(H),B=new Uint32Array(H),q=new Uint32Array(H);const oe=new Uint32Array(256);for(let w=0;w<8;w++){const v=w<<8,Z=(w&3)<<3,x=w>=4;let de=!1;for(let pe=0;pe<256;pe++)if($[v+pe]===H){de=!0;break}if(de)continue;let we=0;for(let pe=0;pe<256;pe++)oe[pe]=we,we+=$[v+pe];for(let pe=0;pe<H;pe++){const Te=te[pe],Le=ae[pe],Be=(x?Le:Te)>>>Z&255,ze=oe[Be]++;p[ze]=re[pe],B[ze]=Te,q[ze]=Le}let ge=re;re=p,p=ge,ge=te,te=B,B=ge,ge=ae,ae=q,q=ge}return re}function i(E,S,U){if(U<2)return E;const H=new Uint32Array(256*4);for(let B=0;B<U;B++){const q=S[B];H[q&255]++,H[256+(q>>>8&255)]++,H[512+(q>>>16&255)]++,H[768+(q>>>24&255)]++}let $=E,re=S,te=new Uint32Array(U),ae=new Uint32Array(U);const p=new Uint32Array(256);for(let B=0;B<4;B++){const q=B<<8,oe=B<<3;let w=!1;for(let x=0;x<256;x++)if(H[q+x]===U){w=!0;break}if(w)continue;let v=0;for(let x=0;x<256;x++)p[x]=v,v+=H[q+x];for(let x=0;x<U;x++){const de=re[x],we=p[de>>>oe&255]++;te[we]=$[x],ae[we]=de}let Z=$;$=te,te=Z,Z=re,re=ae,ae=Z}return $}function s(E,S,U,H){const $=new Uint32Array(H+1);for(let ae=0;ae<U;ae++)$[S[ae]]++;let re=0;for(let ae=0;ae<=H;ae++){const p=$[ae];$[ae]=re,re+=p}const te=new Uint32Array(U);for(let ae=0;ae<U;ae++)te[$[S[ae]]++]=E[ae];return te}function u(E,S,U,H){return U<2?E:H<=65536||H<=U*2?s(E,S,U,H):i(E,S,U)}function f(E,S){return E.length===S&&E.byteOffset===0?E:Uint32Array.prototype.slice.call(E,0,S)}function l(E,S,U=!1){const H=S||ne(E.length),$=H.length;if($<2)return Uint32Array.from(H);const re=new Uint32Array($),te=new Uint32Array($),ae=new Uint32Array($),p=new Uint32Array($),B=new Uint32Array(2);let q=0,oe=0;for(let Z=0;Z<$;Z++){const x=H[Z],de=E[x];if(Number.isNaN(de)){p[oe++]=x;continue}C(de,B),U?(te[q]=~B[0]>>>0,ae[q]=~B[1]>>>0):(te[q]=B[0],ae[q]=B[1]),re[q++]=x}const w=A(re.subarray(0,q),te.subarray(0,q),ae.subarray(0,q),q);if(oe===0)return f(w,q);const v=new Uint32Array($);return v.set(w.subarray(0,q),0),v.set(p.subarray(0,oe),q),v}function t(E,S,U=!1){const H=S||ne(E.length),$=H.length;if($<2)return Uint32Array.from(H);const re=Uint32Array.from(H),te=new Uint32Array($);for(let ae=0;ae<$;ae++){const p=(E[re[ae]]^2147483648)>>>0;te[ae]=U?~p>>>0:p}return f(i(re,te,$),$)}function a(E,S,U={}){const H=S||ne(K(E,U)),$=H.length;if($<2)return Uint32Array.from(H);const re=Q(E.dict,U.locale),te=E.values,ae=T(E),p=Math.max(z(E.dict),re.length),B=p,q=Uint32Array.from(H),oe=new Uint32Array($),w=!!U.descending;for(let v=0;v<$;v++){const Z=q[v];let x=ae&&ae(Z)===0?B:re[te[Z]];x===void 0&&(x=B),oe[v]=w?B-x:x}return f(u(q,oe,$,p+1),$)}function m(E,S,U){const H=S.length;let $=Uint32Array.from(S);if(H<2)return $;let re=new Uint32Array(H);for(let te=1;te<H;te<<=1){for(let p=0;p<H;p+=te<<1){const B=Math.min(p+te,H),q=Math.min(p+(te<<1),H);let oe=p,w=B,v=p;for(;oe<B&&w<q;)re[v++]=U(E[$[oe]],E[$[w]])<=0?$[oe++]:$[w++];for(;oe<B;)re[v++]=$[oe++];for(;w<q;)re[v++]=$[w++]}const ae=$;$=re,re=ae}return $}function e(E,S,U){const H=he(E.values),$=S.length,re=new Uint32Array($),te=U?1:0;let ae=0;for(let p=0;p<$;p++)H(S[p])===te&&(re[ae++]=S[p]);for(let p=0;p<$;p++)H(S[p])!==te&&(re[ae++]=S[p]);return re}function d(E,S){const U=E.values,H=E.kind;if((H==="object"||H===void 0)&&(Array.isArray(U)||ArrayBuffer.isView(U))&&!E.presence)return U;const re=J(E),te=new Array(K(E)||0);for(let ae=0;ae<S.length;ae++){const p=S[ae];te[p]=re(p)}return te}function h(E,S){for(let U=0;U<S.length;U++)if(typeof E[S[U]]!="string")return!1;return!0}function r(E,S,U,H,$){const re=E.length,te=Uint32Array.from(E);if(re<2||H<1)return te;const ae=new Uint32Array(re),p=H-1;for(let B=0;B<re;B++){const q=U[S[B]];ae[B]=$?p-q:q}return f(u(te,ae,re,H),re)}function n(E,S,U){const H=ie(U),$=new Array(S);for(let te=0;te<S;te++)$[te]=te;$.sort((te,ae)=>H(E[te],E[ae])||te-ae);const re=new Uint32Array(S);for(let te=0;te<S;te++)re[$[te]]=te;return re}function c(E,S,U){const H=S.length,$=new Map,re=[],te=new Uint32Array(H);for(let B=0;B<H;B++){const q=E[S[B]];let oe=$.get(q);oe===void 0&&(oe=re.length,$.set(q,oe),re.push(q)),te[B]=oe}const ae=re.length,p=n(re,ae,U.locale);return r(S,te,p,ae,!!U.descending)}function g(E,S,U){const H=d(E,S);if(S.length>=2&&h(H,S)){const te=E.stringRank;return te&&te.version===E.version&&te.usable(S,H,U.locale)?te.sort(S,U):c(H,S,U)}const $=ie(U.locale),re=U.descending?(te,ae)=>$(ae,te):$;return m(H,S,re)}function M(E,S,U){const H=d(E,S),$=U.compare,te=!!U.descending?(ae,p)=>-$(ae,p,void 0,void 0,!0):(ae,p)=>$(ae,p,void 0,void 0,!1);return m(H,S,te)}function N(E,S){const U=S.length,H=T(E),$=E.values,re=E.kind==="float64"&&!!$,te=E.kind==="object"||E.kind==="multi"||E.kind===void 0;if(!H&&!re&&!te)return{present:S,absent:le};const ae=new Uint32Array(U),p=new Uint32Array(U);let B=0,q=0;if(H&&re)for(let oe=0;oe<U;oe++){const w=S[oe];H(w)===1&&!Number.isNaN($[w])?ae[B++]=w:p[q++]=w}else if(re&&!H)for(let oe=0;oe<U;oe++){const w=S[oe];Number.isNaN($[w])?p[q++]=w:ae[B++]=w}else if(H&&!te)for(let oe=0;oe<U;oe++){const w=S[oe];H(w)===1?ae[B++]=w:p[q++]=w}else{const oe=J(E);for(let w=0;w<U;w++){const v=S[w];_(oe(v))?p[q++]=v:ae[B++]=v}}return q===0?{present:S,absent:le}:{present:ae.subarray(0,B),absent:p.subarray(0,q)}}function G(E,S,U){if(S.length===0)return E;const H=new Uint32Array(E.length+S.length);return U?(H.set(S,0),H.set(E,S.length)):(H.set(E,0),H.set(S,E.length)),H}function F(E,S,U={}){const H=S||ne(K(E,U));if(!E||H.length<2)return Uint32Array.from(H);const{present:$,absent:re}=N(E,H);if($.length===0)return Uint32Array.from(H);const te=!!U.descending;let ae;if(typeof U.compare=="function")ae=M(E,$,U);else switch(E.kind){case"float64":ae=l(E.values,$,te);break;case"int32":ae=t(E.values,$,te);break;case"dictionary":ae=a(E,$,U);break;case"bitset":ae=e(E,$,te);break;default:ae=g(E,$,U);break}return G(ae,re,!!U.nullsFirst)}function R(E,S,U,H={}){const $=S||[],re=$.length&&($[0].handle||X(E,$[0].col))||E&&E[0];let te=U||ne(K(re,H));for(let ae=$.length-1;ae>=0;ae--){const p=$[ae],B=p.handle||X(E,p.col)||E&&E[ae];B&&(te=F(B,te,{descending:p.descending!==void 0?!!p.descending:p.dir==="desc",nullsFirst:!!p.nullsFirst,locale:p.locale!==void 0?p.locale:H.locale,compare:p.compare}))}return te instanceof Uint32Array?te:Uint32Array.from(te)}function X(E,S){if(!(!E||S===void 0)){for(let U=0;U<E.length;U++)if(E[U]&&E[U].id===S)return E[U]}}}),Se("packages/core/src/store/stringrank.js",function(o,me){"use strict";Object.defineProperty(o,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"StringRankIndex",{enumerable:!0,get:function(){return ne}});const fe=me("packages/core/src/compute/sort.js"),he=fe.collateStringRanks,Q=fe.rankSortStrings,z=1e5;class ne{#t=[];#e=new Map;#n;#r=0;#i=0;#s=-1;#h;#u=!1;#o=null;#c=-1;#l="\\0";constructor(T=z){this.#h=T>0?T:z,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(T){this.#s=T}get generation(){return this.#i}get size(){return this.#t.length}get capped(){return this.#u}get length(){return this.#r}get bytes(){let T=this.#n.byteLength;const K=this.#t;for(let ie=0;ie<K.length;ie++)T+=K[ie].length*2+24;return T}#a(T,K){const ie=this.#e.get(T);if(ie!==void 0)return ie;if(this.#u)return-1;if(K&&this.#t.length>=this.#h)return this.#u=!0,-1;const J=this.#t.length;return this.#t.push(T),this.#e.set(T,J),this.#i++,J}build(T,K){const ie=K|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(ie);for(let J=0;J<ie;J++){const le=T[J],ue=typeof le=="string"?this.#a(le,!1):-1;this.#n[J]=ue<0?0:ue}this.#r=ie}append(T,K,ie){const J=(K|0)+(ie|0);if(J>this.#n.length){const le=new Uint32Array(J);le.set(this.#n.subarray(0,this.#r)),this.#n=le}for(let le=K|0;le<J;le++){const ue=T[le],W=typeof ue=="string"?this.#a(ue,!0):-1;this.#n[le]=W<0?0:W}this.#r=Math.max(this.#r,J)}ranks(T){const K=T||"";if(this.#o&&this.#c===this.#i&&this.#l===K)return this.#o;const ie=he(this.#t,this.#t.length,T);return this.#o=ie,this.#c=this.#i,this.#l=K,ie}usable(T,K,ie){if(this.#u||this.#t.length===0)return!1;const J=this.#n,le=this.#t,ue=this.#r;for(let W=0;W<T.length;W++){const L=T[W];if(L>=ue||le[J[L]]!==K[L])return!1}return!0}sort(T,K){const ie=this.ranks(K.locale),J=this.#t.length,le=T.length,ue=new Uint32Array(le),W=this.#n;for(let L=0;L<le;L++)ue[L]=W[T[L]];return Q(T,ue,ie,J,!!K.descending)}}}),Se("packages/core/src/store/columnstore.js",function(o,me){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return W}}),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 a}});const fe=me("packages/core/src/internal/util.js"),he=fe.warnOnce,Q=fe.isFunction,z=fe.pathGetter,_=me("packages/core/src/store/bitset.js").Bitset,K=me("packages/core/src/store/dictionary.js").Dictionary,J=me("packages/core/src/store/multivalue.js").MultiValue,ue=me("packages/core/src/store/stringrank.js").StringRankIndex,W=4294967295,L=1024,Y=5e3,ee=.2,C=new Set(["float64","int32","bitset","dictionary","object","multi"]);function A(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 s(m){const e=i(m);return Number.isFinite(e)?e|0:0}function u(m){return A(m)?[]:Array.isArray(m)?m:[m]}function f(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),h=new Array(d.length);for(let r=0;r<d.length;r++)h[r]=m.dict.valueOf(d[r]);return h}default:return m.buf[e]}}function l(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],h=m.offsets[e+1],r=m.table||[],n=new Array(h-d);for(let c=d;c<h;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 h=C.has(e.kind)?e.kind:"object";e.kind&&!C.has(e.kind)&&he(`store.kind.${e.id}`,`column "${e.id}" declares unknown storage kind "${e.kind}"; falling back to object`),this.#n=h,this.#e=h,this.#r=e.nullable!==!1,this.#h=e.dictionary??null,this.#s=d,this.#i=Q(e.read)?e.read:z(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 h=new ue(this.#S());return h.build(e,d),h.version=this.#f,this.#d=h,this.#k=this.#f,h.capped?null:h}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),h=new Array(d.length);for(let r=0;r<d.length;r++)h[r]=this.#a.valueOf(d[r]);return h}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,h){if(this.#g||h<=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 M=this.#o;for(let N=0;N<h;N++){const G=r(e[N]);if(typeof G=="number"){n&&c.set(d+N),M[d+N]=G;continue}const F=G==null;n?c.assign(d+N,!F):F&&(g=!0),M[d+N]=F?NaN:i(G)}break}case"int32":{const M=this.#o;for(let N=0;N<h;N++){const G=r(e[N]),F=G==null;n?c.assign(d+N,!F):F&&(g=!0),M[d+N]=F?0:s(G)}break}case"bitset":{const M=this.#c;for(let N=0;N<h;N++){const G=r(e[N]),F=G==null;n?c.assign(d+N,!F):F&&(g=!0),M.assign(d+N,!F&&!!G)}break}case"dictionary":{const M=this.#o,N=this.#a;for(let G=0;G<h;G++){const F=r(e[G]),R=F==null;n?c.assign(d+G,!R):R&&(g=!0),M[d+G]=R?0:N.codeOf(F)}break}case"multi":{const M=this.#l,N=this.#a;for(let G=0;G<h;G++){const F=r(e[G]),R=F==null;n?c.assign(d+G,!R):R&&(g=!0);const X=u(F),E=new Array(X.length);for(let S=0;S<X.length;S++)E[S]=N.codeOf(X[S]);M.write(d+G,E)}break}default:{const M=this.#o;for(let N=0;N<h;N++){const G=r(e[N]),F=G==null;n?c.assign(d+N,!F):F&&(g=!0),M[d+N]=F?null:G}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,h),this.#d.version=this.#f+1,this.#k=this.#f+1),this.#f++}appendPacked(e,d,h){if(this.#g||h<=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<h;g++)r.assign(d+g,(n[g>>3]&1<<(g&7))!==0);else for(let g=0;g<h;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 M=0;M<h;M++)this.#c.assign(d+M,(g[M>>3]&1<<(M&7))!==0);this.#f++;return}if(c&&this.#e==="dictionary"){const g=e.table||[],M=new Uint32Array(g.length);for(let R=0;R<g.length;R++)M[R]=this.#a.codeOf(g[R]);const N=e.values,G=this.#o,F=r;for(let R=0;R<h;R++){if(F&&(n&&(n[R>>3]&1<<(R&7))===0)){G[d+R]=0;continue}G[d+R]=M[N[R]]??0}this.#f++;return}if(c&&this.#e==="multi"){const g=e.table||[],M=new Uint32Array(g.length);for(let F=0;F<g.length;F++)M[F]=this.#a.codeOf(g[F]);const N=e.values,G=e.offsets;for(let F=0;F<h;F++){const R=G[F],X=G[F+1],E=new Array(X-R);for(let S=R;S<X;S++)E[S-R]=M[N[S]]??0;this.#l.write(d+F,E)}this.#f++;return}for(let g=0;g<h;g++){const M=n?(n[g>>3]&1<<(g&7))===0:e.kind==="object"?e.values[g]===null:!1;this.#A(d+g,M?null:l(e,g))}this.#f++}touch(){this.#f++}columnarise(e,d){if(this.#u||this.#g)return;const h=new Array(d);for(let r=0;r<d;r++)h[r]=this.#M(r);this.#e=this.#n,this.#u=!0,this.#P(e);for(let r=0;r<d;r++)this.#A(r,h[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||!C.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},h=this.#s.physical(),r=this.#m;this.#e=e,this.#P(this.#p);for(let n=0;n<h;n++){const c=r!==null&&r.get(n)===0;c&&e!=="multi"||this.#A(n,c?null:f(d,n))}return this.#j(),this.#f++,!0}compact(e,d,h){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]!==W&&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]!==W&&(r[e[n]]=r[n]);if(this.#e==="object")for(let n=h;n<d;n++)r[n]=void 0;break}case"bitset":{const r=this.#c;for(let n=0;n<d;n++)e[n]!==W&&r.assign(e[n],r.get(n)===1);for(let n=h;n<d;n++)r.clear(n);break}case"multi":this.#l.compact(e,h,W);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<d;n++)e[n]!==W&&r.assign(e[n],r.get(n)===1);for(let n=h;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 _(d);break;case"dictionary":this.#o=new Uint32Array(d),this.#a=this.#a??new K(this.#h??[]);break;case"multi":this.#l=new J({rows:d,values:d}),this.#a=this.#a??new K(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 _(d)),this.#p=d}#A(e,d){const h=A(d);switch(this.#r?this.#m.assign(e,!h):h&&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]=h?NaN:i(d);break;case"int32":this.#o[e]=h?0:s(d);break;case"bitset":this.#c.assign(e,!h&&!!d);break;case"dictionary":this.#o[e]=h?0:this.#a.codeOf(d);break;case"multi":{const r=u(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]=h?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),h=this.#r?new _(e):null;for(let r=0;r<e;r++){const n=this.#M(r);d[r]=n,h&&!A(n)&&h.set(r)}return this.#O={version:this.#f,values:d,presence:h},this.#O}}class a{#t;#e=new Map;#n=[];#r=[];#i=0;#s=0;#h=0;#u=0;#o=new _(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??L),this.#l=d.retainSource!==!1,this.#a=this.#l?d.columnarBelow??Y:0,this.#w=d.compactRatio??ee;const h={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,h);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 h=e.length|0;if(h===0)return{from:d,to:d};if(this.#l)for(let n=0;n<h;n++)this.#r[d+n]=e[n];if(this.#i=d+h,this.#h+=h,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,h);return{from:d,to:this.#i}}appendPacked(e,d){const h=this.#i;if(this.#b||!e)return{from:h,to:h};const r=e.count|0;if(r===0)return{from:h,to:h};if(this.#l&&d)for(let c=0;c<r;c++)this.#r[h+c]=d[c];this.#i=h+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,h,r):c.grow(this.#s)}return{from:h,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 h=this.#e.get(e);return h?h.get(d):void 0}set(e,d,h){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,h)}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,h=new Uint32Array(d);let r=0;for(let n=0;n<d;n++)h[n]=this.#o.get(n)===1?W:r++;for(const n of this.#n)n.compact(h,d,r);if(this.#l){const n=this.#r;for(let c=0;c<d;c++)h[c]!==W&&(n[h[c]]=n[c]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new _(Math.max(this.#s,r)),h}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 h=0;h<this.#i;h++)e[h]=h;return e}let d=0;for(let h=0;h<this.#i;h++)this.#o.get(h)===0&&(e[d++]=h);return e}convert(e,d){const h=this.#e.get(e);return h?h.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 h of this.#n)h.grow(d);this.#o.grow(d),this.#s=d}#m(e){const d={};for(const h of this.#n)d[h.id]=h.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)}}}),Se("packages/core/src/store/ingest.js",function(o,me){"use strict";Object.defineProperty(o,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"inferKind",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return C}});const fe=me("packages/core/src/internal/util.js"),he=fe.now,Q=fe.nextFrame,z=fe.infoOnce,ne=fe.warnOnce,_=fe.isFunction,T=fe.pathGetter,ie=me("packages/core/src/store/columnstore.js").ColumnStore,J=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function le(A,i={}){if(i.multi)return"multi";if(A.length===0)return"object";let s=0,u=0,f=0,l=0,t=0;for(let m=0;m<A.length;m++){const e=A[m];typeof e=="number"?s++:typeof e=="boolean"?u++:typeof e=="string"?f++:e instanceof Date?l++:Array.isArray(e)&&t++}const a=A.length;return s===a?"float64":u===a?"bitset":l===a?"float64":f===a?"text":t===a?"multi":"object"}function ue(A,i,s){return i<=0||A<s*i?"dictionary":"object"}function W(A,i,s){const u=new Map,f=new Map;for(const c of A){if(c.computed)continue;const g=_(c.read)?c.read:T(c.field||c.id);f.set(c.id,g),u.set(c.id,g)}const l=i?.order??[],t=i?.fns??{},a=i?.deps??{},m=i?.wrapDeps??null,e=l.filter(c=>_(t[c])),d=e.some(c=>a[c]==="*");let h=new WeakMap;const r=c=>{const g={};if(d)for(const[M,N]of f)g[M]=N(c);for(const M of e){const N=a[M];let G;if(N==="*")G=g;else{G={};const F=N||[];for(let R=0;R<F.length;R++){const X=F[R];G[X]=X in g?g[X]:f.get(X)?.(c)}}g[M]=t[M](m?m(G,M):G,{data:c,row:null,column:null,grid:null,context:s})}return g},n=c=>{if(c===null||typeof c!="object"&&typeof c!="function")return r(c);let g=h.get(c);return g===void 0&&(g=r(c),h.set(c,g)),g};for(const c of e)u.set(c,g=>n(g)[c]);return{readers:u,reset(){h=new WeakMap}}}class L{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(i,s){this.spec=i,this.read=s,this.kind="object",this.inferred=!1,this.nullable=i.nullable!==!1}}class Y{#t;#e=[];#n=null;#r;#i=0;#s;#h=!1;#u=!1;#o=0;#c;constructor(i,s={},u={}){this.#t=Array.isArray(i)?i:Array.from(i||[]),this.#s={...J,...u};const f=s.columns??[];this.#r=W(f,s.computed??null,s.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(f,s.computed??null),this.#n=new ie(this.#e.map(l=>({id:l.spec.id,kind:l.kind,nullable:l.nullable,read:l.read,dictionary:l.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:s,chunkRows:u}=this.#s,f=this.#t.length;do{const l=Math.min(this.#i+u,f);this.#n.append(this.#t.slice(this.#i,l)),this.#a(this.#i,l),this.#i=l,this.#r.reset(),this.#w(!1)}while(this.#i<f&&he()-i<s);return this.#o+=he()-i,this.#s.onProgress?.({loaded:this.#i,total:f}),this.#i>=f?(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,s){const u=this.#t,f=Math.min(this.#s.sampleSize,u.length),l=this.#s.dictionaryRatio,t=s?.pure instanceof Set?s.pure:new Set(s?.pure??s?.order??[]);for(const a of i){if(!a||!a.id)continue;if(a.computed&&(a.pure===!1||s&&!t.has(a.id))){ne(`ingest.impure.${a.id}`,`column "${a.id}" is an impure computed column and is not materialised into the store`);continue}const m=this.#r.readers.get(a.id)??(_(a.read)?a.read:T(a.field||a.id)),e=new L(a,m);if(a.kind)e.kind=a.kind,e.reason="declared by the caller";else if(a.dictionary)e.kind=a.multi?"multi":"dictionary",e.reason="value table supplied (lookup column)";else{const d=[];for(let r=0;r<f&&d.length<this.#s.sampleSize;r++){const n=m(u[r]);n!=null&&d.push(n)}e.inferred=!0;const h=le(d,{multi:a.multi});if(h==="text"){const r=new Set(d).size;e.kind=ue(r,d.length,l),e.candidate=this.#c,e.reason=`sampled ${r} distinct in ${d.length}`}else e.kind=h,e.reason=`inferred from ${d.length} sampled values`,h==="object"&&d.length&&z(`ingest.mixed.${a.id}`,`column "${a.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,s){const u=this.#t;for(const f of this.#e){if(!f.candidate||!f.distinct)continue;const l=f.distinct;for(let t=i;t<s;t++){const a=f.read(u[t]);a!=null&&l.add(a)}}}#d(i){if(i.distinct)return i.distinct.size;const s=this.#n.column(i.spec.id);return s?.dict?s.dict.size:0}#w(i){const s=this.#s.dictionaryRatio,u=this.#t.length;for(const f of this.#e){if(!f.candidate)continue;const l=this.#d(f);if(f.kind==="dictionary"&&l>=s*u){const t=this.#n.column(f.spec.id);f.distinct=new Set(t?.dict?t.dict.values():[]),this.#n.convert(f.spec.id,"object"),f.kind="object",f.change="demoted",f.reason=`${l} distinct values is at or above ${s*100}% of ${u} rows`;continue}if(f.kind==="object"&&l>=s*u){f.candidate=!1,f.distinct=null,f.reason=`${l} distinct values is at or above ${s*100}% of ${u} rows`;continue}i&&f.kind==="object"&&l<s*u&&(this.#n.convert(f.spec.id,"dictionary"),f.kind="dictionary",f.change=f.change==="demoted"?null:"promoted",f.reason=`${l} distinct values is below ${s*100}% of ${u} rows`,f.distinct=null),i&&(f.candidate=!1)}}}async function ee(A,i={},s={}){const u=new Y(A,i,s),f=s.scheduler?.frame??Q;for(;u.slice();)await new Promise(l=>{f(l)});return u.result()}function C(A,i={},s={}){const u=new Y(A,i,{...s,chunkMs:1/0});for(;u.slice(););return u.result()}}),Se("packages/core/src/store/columnpack.js",function(o,me){"use strict";Object.defineProperty(o,"isPortableSchema",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"packChunk",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"packedTransfers",{enumerable:!0,get:function(){return Y}});const he=me("packages/core/src/internal/util.js").pathGetter,Q=me("packages/core/src/store/ingest.js"),z=Q.inferKind,ne=Q.decideText,_=Q.INGEST_DEFAULTS,K=me("packages/core/src/store/columnstore.js").toFloat,ie=new Set(["float64","int32","bitset","dictionary","object","multi"]);function J(ee){if(!Array.isArray(ee)||ee.length===0)return!1;for(const C of ee)if(!C||typeof C.id!="string"||typeof C.field!="string"||C.field===""||C.kind&&!ie.has(C.kind))return!1;return!0}function le(ee){const C=K(ee);return Number.isFinite(C)?C|0:0}function ue(ee){return ee==null?[]:Array.isArray(ee)?ee:[ee]}function W(ee,C,A,i){if(ee.kind)return ee.kind;const s=[];for(let l=0;l<C.length&&s.length<_.sampleSize;l++){const t=C[l];t!=null&&s.push(t)}const u=z(s,{multi:ee.multi});if(u!=="text")return u;const f=new Set(s).size;return ne(f,s.length,i)}function L(ee,C,A={}){const i=C.length|0,s=A.dictionaryRatio??_.dictionaryRatio,u=[];for(const f of ee){const l=he(f.field||f.id),t=f.nullable!==!1,a=new Array(i);for(let r=0;r<i;r++){const n=l(C[r]);a[r]=n===void 0?null:n}const m=W(f,a,i,s),e=t?new Uint8Array(i+7>>3):null,d=r=>{e&&(e[r>>3]|=1<<(r&7))};let h;switch(m){case"float64":{const r=new Float64Array(i);for(let n=0;n<i;n++){const c=a[n],g=c===null;g||d(n),r[n]=g?NaN:K(c)}h={id:f.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=a[n],g=c===null;g||d(n),r[n]=g?0:le(c)}h={id:f.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=a[n],g=c===null;g||d(n),!g&&c&&(r[n>>3]|=1<<(n&7))}h={id:f.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 M=a[g];if(M===null){r[g]=0;continue}d(g);let N=c.get(M);N===void 0&&(N=n.length,n.push(M),c.set(M,N)),r[g]=N}h={id:f.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 M=0;M<i;M++){const N=a[M];c[M]=g.length,N===null||d(M);const F=ue(N);for(let R=0;R<F.length;R++){const X=F[R];let E=n.get(X);E===void 0&&(E=r.length,r.push(X),n.set(X,E)),g.push(E)}}c[i]=g.length,h={id:f.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=a[n];c!==null&&d(n),r[n]=c}h={id:f.id,kind:"object",nullable:t,values:r,presence:e,offsets:null,table:null};break}}u.push(h)}return{count:i,columns:u}}function Y(ee){const C=[];if(!ee||!Array.isArray(ee.columns))return C;const A=i=>{ArrayBuffer.isView(i)&&i.buffer&&!C.includes(i.buffer)&&C.push(i.buffer)};for(const i of ee.columns)A(i.values),A(i.presence),A(i.offsets);return C}}),Se("packages/core/src/compute/sortspec.js",function(o,me){"use strict";Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return ne}});function fe(_){return{locale:_===void 0?void 0:String(_),numeric:!0,sensitivity:"variant"}}function he(_){return!!_&&typeof _.compare!="function"}function Q(_){if(!_)return!0;for(let T=0;T<_.length;T++)if(!he(_[T]))return!1;return!0}function z(_,T){const K=_.col!==void 0?_.col:_.handle&&_.handle.id,ie=_.locale!==void 0?_.locale:T;return{col:K,descending:_.descending!==void 0?!!_.descending:_.dir==="desc",nullsFirst:!!_.nullsFirst,collation:fe(ie)}}function ne(_,T){const K=_||[],ie=new Array(K.length);for(let J=0;J<K.length;J++)ie[J]=z(K[J],T);return ie}}),Se("packages/core/src/format/date.js",function(o,me){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return C}});const fe=me("packages/core/src/internal/util.js"),he=fe.isNil,Q=fe.warnOnce,z=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function ne(A){const i=[];let s=0,u="";const f=()=>{u&&(i.push({token:null,text:u}),u="")};for(;s<A.length;){const l=A[s];if(l==="\'"){if(A[s+1]==="\'"){u+="\'",s+=2;continue}const a=A.indexOf("\'",s+1);if(a===-1){u+=A.slice(s+1),s=A.length;continue}u+=A.slice(s+1,a),s=a+1;continue}const t=z.find(a=>A.startsWith(a,s));if(t){f(),i.push({token:t,text:t}),s+=t.length;continue}/[A-Za-z]/.test(l)&&Q(`date.pattern.token:${l}`,`the date pattern "${A}" contains \'${l}\', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${z.join(" ")}.`),u+=l,s+=1}return f(),i}const _=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function T(A){if(he(A)||A==="")return null;if(A instanceof Date)return Number.isNaN(A.getTime())?null:A;if(typeof A=="number")return Number.isNaN(A)?null:new Date(A);if(typeof A=="string"){const i=_.exec(A.trim());if(i){const[,u,f,l,t="0",a="0",m="0"]=i;return new Date(+u,+f-1,+l,+t,+a,+m)}const s=new Date(A);return Number.isNaN(s.getTime())?null:s}return null}function K(A,i){return String(A).padStart(i,"0")}function ie(A){if(!A)return u=>({year:u.getFullYear(),month:u.getMonth()+1,day:u.getDate(),hour:u.getHours(),minute:u.getMinutes(),second:u.getSeconds(),ms:u.getMilliseconds(),weekday:u.getDay()});const i=new Intl.DateTimeFormat("en-US",{timeZone:A,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 u=>{const f={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:u.getMilliseconds(),weekday:0};for(const l of i.formatToParts(u))switch(l.type){case"year":f.year=Number(l.value);break;case"month":f.month=Number(l.value);break;case"day":f.day=Number(l.value);break;case"hour":f.hour=Number(l.value)%24;break;case"minute":f.minute=Number(l.value);break;case"second":f.second=Number(l.value);break;case"weekday":f.weekday=s[l.value]??0;break;default:break}return f}}function J(A,i,s){const u=ne(A),f=ie(s),l=new Set(u.filter(d=>d.token).map(d=>d.token)),t=l.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:s}):null,a=l.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:s}):null,m=l.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:s}):null,e=l.has("EEEE")?new Intl.DateTimeFormat(i,{weekday:"long",timeZone:s}):null;return d=>{const h=f(d);let r="";for(const n of u){if(!n.token){r+=n.text;continue}switch(n.token){case"yyyy":r+=K(h.year,4);break;case"yy":r+=K(h.year%100,2);break;case"MMMM":r+=a.format(d);break;case"MMM":r+=t.format(d);break;case"MM":r+=K(h.month,2);break;case"M":r+=String(h.month);break;case"dd":r+=K(h.day,2);break;case"d":r+=String(h.day);break;case"EEEE":r+=e.format(d);break;case"EEE":r+=m.format(d);break;case"HH":r+=K(h.hour,2);break;case"H":r+=String(h.hour);break;case"hh":r+=K(h.hour%12===0?12:h.hour%12,2);break;case"h":r+=String(h.hour%12===0?12:h.hour%12);break;case"mm":r+=K(h.minute,2);break;case"m":r+=String(h.minute);break;case"ss":r+=K(h.second,2);break;case"s":r+=String(h.second);break;case"SSS":r+=K(h.ms,3);break;case"a":r+=h.hour<12?"AM":"PM";break;default:r+=n.text;break}}return r}}const le=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function ue(A,i){const s=A||{},u=s.locale||i||void 0,f=s.nullDisplay??"",l=s.timeZone;let t;if(s.pattern)t=J(s.pattern,u,l);else if(s.dateStyle||s.timeStyle){const h={timeZone:l};s.dateStyle&&(h.dateStyle=s.dateStyle),s.timeStyle&&(h.timeStyle=s.timeStyle);const r=new Intl.DateTimeFormat(u,h);t=n=>r.format(n)}else{const h=new Intl.DateTimeFormat(u,{dateStyle:"medium",timeZone:l});t=r=>h.format(r)}const a=s.relative?new Intl.RelativeTimeFormat(u,{numeric:"auto"}):null,e=(typeof s.relative=="object"&&s.relative?s.relative.threshold??7:7)*24*36e5,d=(h,r)=>{const n=T(h);if(!n)return f;if(a){const c=r&&typeof r.now=="number"?r.now:Date.now(),g=n.getTime()-c;if(Math.abs(g)<e){for(const[M,N]of le)if(Math.abs(g)>=N||M==="second")return a.format(Math.round(g/N),M)}}return t(n)};return d.spec=s,d}function W(A){if(he(A)||A==="")return null;if(typeof A=="string"){const u=/^(\\d{4}-\\d{2}-\\d{2})/.exec(A.trim());if(u)return u[1];const f=T(A);return f?W(f):null}const i=T(A);if(!i)return null;const s=u=>String(u).padStart(2,"0");return`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}`}function L(A,i){if(he(A)||A==="")return null;if(typeof A=="string"){const u=A.trim();if(Y.test(u)){const t=T(u);return t?ee(t,i):null}const f=/^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(u);if(f){const[,t,a,m,e]=f;return`${t}T${a}:${m}${e&&e!=="00"?`:${e}`:""}`}if(/^\\d{4}-\\d{2}-\\d{2}$/.test(u))return`${u}T00:00`;const l=T(u);return l?L(l):null}const s=T(A);return s?ee(s,i):null}const Y=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function ee(A,i){const s=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(A).reduce((e,d)=>(d.type!=="literal"&&(e[d.type]=d.value),e),{}),a=t.hour==="24"?"00":t.hour,m=Number(t.second);return`${t.year}-${t.month}-${t.day}T${a}:${t.minute}`+(m?`:${t.second}`:"")}catch{}const u=`${A.getFullYear()}-${s(A.getMonth()+1)}-${s(A.getDate())}`,f=A.getSeconds(),l=`${s(A.getHours())}:${s(A.getMinutes())}${f?`:${s(f)}`:""}`;return`${u}T${l}`}function C(A,i){const s=he(A)||A===""?null:String(A),u=he(i)||i===""?null:String(i);return s===null?u===null?0:1:u===null||s<u?-1:s>u?1:0}}),Se("packages/core/src/compute/filter.js",function(o,me){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"itemwisePredicate",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"declareOperators",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"declaredOperator",{enumerable:!0,get:function(){return ae}});const fe=me("packages/core/src/internal/util.js"),he=fe.isBlank,Q=fe.toArray,z=fe.warnOnce,_=me("packages/core/src/format/date.js").toIsoDate,T=me("packages/core/src/compute/handle.js"),K=T.bitReader,ie=T.dictSize,J=T.dictValue,le=T.presenceReader,ue=T.valueComparator,W=T.valueReader,L=/^\\d{4}-\\d{2}-\\d{2}$/,Y="\\0null\\0";function ee(p,B){const q=p&&p.pool;if(q){const oe=q.mask||q.acquireMask||q.acquire||q.take;if(typeof oe=="function"){const w=oe.call(q,B);if(w&&w.length>=B)return w}}return new Uint8Array(B)}function C(p,B){const q=p&&p.pool;if(!q||!B)return;const oe=q.release||q.releaseMask||q.free||q.recycle;typeof oe=="function"&&oe.call(q,B)}function A(p,B,q){return p.fill(q,0,B),p}function i(p){return p==null||typeof p=="number"&&Number.isNaN(p)}function s(p,B){if(p==null)return p;if(B==="number")return typeof p=="number"?p:Number(p);if(B==="date"||B==="dateString"){const q=_(p);return q===null?u(p):q}return B==="boolean"?typeof p=="boolean"?p:p==="true"||p===1?!0:p==="false"||p===0?!1:!!p:p}function u(p){return p instanceof Date?p.getTime():typeof p=="number"?p:Date.parse(String(p))}function f(p){return typeof p=="number"?p:p instanceof Date?p.getTime():p==null||p===""?NaN:Number(p)}function l(p,B){const q=typeof p=="string"?p:String(p);return B?q:q.toLowerCase()}function t(p,B){return p==null?Y:typeof p=="string"?B?p:p.toLowerCase():p instanceof Date?p.getTime():p}function a(p,B,q){const oe=new Set;for(const w of Q(p)){const v=s(w,q);oe.add(t(v,B)),typeof v=="string"&&v!==""&&Number.isFinite(Number(v))?oe.add(Number(v)):typeof v=="number"&&Number.isFinite(v)&&oe.add(t(String(v),B))}return oe}function m(p,B,q){if(p==null||B===null||B===void 0)return p==null&&B==null;const oe=typeof p,w=typeof B;return oe==="string"&&w==="string"?q?p===B:p.toLowerCase()===B.toLowerCase():p instanceof Date||B instanceof Date?u(p)===u(B):oe==="number"&&w==="number"?p===B||Number.isNaN(p)&&Number.isNaN(B):oe==="number"&&w==="string"?p===Number(B):oe==="string"&&w==="number"?Number(p)===B:oe==="boolean"||w==="boolean"?p===B:Array.isArray(p)&&Array.isArray(B)?p.length===B.length&&p.every((v,Z)=>m(v,B[Z],q)):p===B}function e(p,B){try{if(p instanceof RegExp){const q=p.flags.replace(/[gy]/g,"");return new RegExp(p.source,B||q.includes("i")?q:`${q}i`)}return new RegExp(String(p),B?"":"i")}catch(q){return z(`regex:${String(p)}`,`filter operator "matches" received an invalid pattern: ${String(p)}`,q),null}}function d(p,B){const q=h(p,B),oe=p&&p.type;return oe!=="date"&&oe!=="dateString"?q:w=>q(typeof w=="string"&&L.test(w)?w:_(w)??w)}function h(p,B){const q=p&&p.op,oe=!!(p&&p.caseSensitive),w=p&&p.type,v=ue(B),Z=x=>de=>!x(de);switch(q){case"eq":{const x=s(p.value,w);return de=>m(de,x,oe)}case"ne":{const x=s(p.value,w);return de=>!m(de,x,oe)}case"lt":case"lte":case"gt":case"gte":{const x=s(p.value,w);if(i(x))return()=>!1;const de=q==="lt"?-1:q==="lte"?0:q==="gt"?1:2;return we=>{if(i(we))return!1;const ge=v(we,x);return de===-1?ge<0:de===0?ge<=0:de===1?ge>0:ge>=0}}case"between":case"notBetween":{const x=Q(p.value),de=s(x[0],w),we=s(x[1],w),ge=p.bounds||"[]",pe=ge.charAt(0)!=="(",Te=ge.charAt(1)!==")";if(i(de)||i(we))return q==="between"?()=>!1:()=>!0;const Le=Be=>{if(i(Be))return!1;const ze=v(Be,de),Ke=v(Be,we);return(pe?ze>=0:ze>0)&&(Te?Ke<=0:Ke<0)};return q==="between"?Le:Z(Le)}case"in":case"notIn":{const x=a(p.value,oe,w),de=we=>x.has(t(we,oe));return q==="in"?de:Z(de)}case"contains":case"notContains":{const x=l(s(p.value,w),oe),de=we=>we==null?!1:l(we,oe).includes(x);return q==="contains"?de:Z(de)}case"startsWith":{const x=l(s(p.value,w),oe);return de=>de==null?!1:l(de,oe).startsWith(x)}case"endsWith":{const x=l(s(p.value,w),oe);return de=>de==null?!1:l(de,oe).endsWith(x)}case"matches":{const x=e(p.value,oe);return x?de=>de==null?!1:x.test(String(de)):()=>!1}case"blank":return x=>he(x)||Array.isArray(x)&&x.length===0;case"notBlank":return x=>!(he(x)||Array.isArray(x)&&x.length===0);case"containsAny":case"containsNone":{const x=a(p.value,oe,w),de=we=>{const ge=we==null?[]:Q(we);for(let pe=0;pe<ge.length;pe++)if(x.has(t(ge[pe],oe)))return!0;return!1};return q==="containsAny"?de:Z(de)}case"containsAll":{const x=Q(p.value).map(de=>t(s(de,w),oe));return de=>{const we=de==null?[]:Q(de);if(x.length===0)return!0;const ge=new Set(we.map(pe=>t(pe,oe)));for(let pe=0;pe<x.length;pe++)if(!ge.has(x[pe]))return!1;return!0}}default:{const x=ae(q);return x?x.compile(p.value):(z(`op:${String(q)}`,`unknown filter operator "${String(q)}"; the condition is refused rather than matching every row`),()=>!1)}}}function r(p,B,q){return d(B,q)(p)}const n=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),c=new Set(["containsAny","containsAll","containsNone"]);function g(p,B,q){const oe=p&&p.op,w=n[oe]||oe,v=d({...p,op:w,type:B.type},q),Z=B.items,x=de=>{const we=Z(de);if(!we)return!1;for(let ge=0;ge<we.length;ge++)if(v(we[ge]))return!0;return!1};return n[oe]?de=>!x(de):x}function M(p,B,q,oe){const w=le(p);if(w){const x=B?1:0;for(let de=0;de<oe;de++)q[de]=w(de)===x?1:0;return q}const v=p.kind;if(v==="float64"||v==="int32"||v==="bitset")return A(q,oe,B?1:0);const Z=W(p);for(let x=0;x<oe;x++){const de=Z(x),we=he(de)||Array.isArray(de)&&de.length===0;q[x]=we===B?0:1}return q}function N(p,B,q,oe){const w=p.dict,v=ie(w),Z=new Uint8Array(v);for(let ge=0;ge<v;ge++)Z[ge]=B(J(w,ge))?1:0;const x=p.values,de=le(p);if(!de){for(let ge=0;ge<oe;ge++)q[ge]=Z[x[ge]];return q}const we=B(null)?1:0;for(let ge=0;ge<oe;ge++)q[ge]=de(ge)===1?Z[x[ge]]:we;return q}function G(p,B,q,oe){const w=K(p.values),v=B(!0)?1:0,Z=B(!1)?1:0,x=le(p);if(!x){for(let we=0;we<oe;we++)q[we]=w(we)===1?v:Z;return q}const de=B(null)?1:0;for(let we=0;we<oe;we++)q[we]=x(we)===0?de:w(we)===1?v:Z;return q}function F(p,B,q,oe,w){const v=p.values,Z=B.type,x=B.op;let de=!0;switch(x){case"eq":case"ne":{const ge=f(s(B.value,Z)),pe=typeof B.value=="number"&&Number.isNaN(B.value),Te=x==="ne"?1:0;if(pe)for(let Le=0;Le<w;Le++)oe[Le]=(Number.isNaN(v[Le])?1:0)^Te;else for(let Le=0;Le<w;Le++)oe[Le]=(v[Le]===ge?1:0)^Te;break}case"lt":{const ge=f(s(B.value,Z));for(let pe=0;pe<w;pe++)oe[pe]=v[pe]<ge?1:0;break}case"lte":{const ge=f(s(B.value,Z));for(let pe=0;pe<w;pe++)oe[pe]=v[pe]<=ge?1:0;break}case"gt":{const ge=f(s(B.value,Z));for(let pe=0;pe<w;pe++)oe[pe]=v[pe]>ge?1:0;break}case"gte":{const ge=f(s(B.value,Z));for(let pe=0;pe<w;pe++)oe[pe]=v[pe]>=ge?1:0;break}case"between":case"notBetween":{const ge=Q(B.value),pe=f(s(ge[0],Z)),Te=f(s(ge[1],Z)),Le=B.bounds||"[]",Be=Le.charAt(0)!=="(",ze=Le.charAt(1)!==")",Ke=x==="notBetween"?1:0;if(Be&&ze)for(let Ee=0;Ee<w;Ee++)oe[Ee]=(v[Ee]>=pe&v[Ee]<=Te?1:0)^Ke;else if(Be)for(let Ee=0;Ee<w;Ee++)oe[Ee]=(v[Ee]>=pe&v[Ee]<Te?1:0)^Ke;else if(ze)for(let Ee=0;Ee<w;Ee++)oe[Ee]=(v[Ee]>pe&v[Ee]<=Te?1:0)^Ke;else for(let Ee=0;Ee<w;Ee++)oe[Ee]=(v[Ee]>pe&v[Ee]<Te?1:0)^Ke;break}case"in":case"notIn":{const ge=new Set;for(const Te of Q(B.value)){const Le=f(s(Te,Z));Number.isNaN(Le)||ge.add(Le)}const pe=x==="notIn"?1:0;for(let Te=0;Te<w;Te++)oe[Te]=(ge.has(v[Te])?1:0)^pe;break}default:de=!1;break}if(!de)return!1;const we=le(p);if(we){const ge=q(null)?1:0;for(let pe=0;pe<w;pe++)we(pe)===0&&(oe[pe]=ge)}return!0}function R(p,B,q,oe){const w=W(p);for(let v=0;v<oe;v++)q[v]=B(w(v))?1:0;return q}function X(p,B,q){const oe=B.count|0,w=q||ee(B,oe);if(!p)return A(w,oe,1);const v=typeof B.handle=="function"?B.handle(p.col):void 0,Z=typeof B.custom=="function"?B.custom:null;if(!v){if(Z){for(let ge=0;ge<oe;ge++)w[ge]=Z(p,ge)?1:0;return w}return z(`filter:col:${String(p.col)}`,`filter references unknown column "${String(p.col)}"; the condition is refused rather than matching every row`),A(w,oe,0)}const x=p.op;if(x==="blank"||x==="notBlank")return M(v,x==="notBlank",w,oe);const de=typeof B.itemwise=="function"?B.itemwise(p.col):null;if(de&&!ae(x)&&!c.has(x))return R(v,g(p,de,B.locale),w,oe);const we=d(p,B.locale);switch(v.kind){case"dictionary":return N(v,we,w,oe);case"bitset":return G(v,we,w,oe);case"float64":case"int32":return F(v,p,we,w,oe)?w:R(v,we,w,oe);default:return R(v,we,w,oe)}}function E(p,B,q){if(!p)return A(ee(B,q),q,1);if(Array.isArray(p.conditions)){const oe=p.conditions.filter(Z=>Z!=null),w=p.op==="or"?"or":p.op==="not"?"not":"and";if(oe.length===0)return A(ee(B,q),q,1);const v=E(oe[0],B,q);for(let Z=1;Z<oe.length;Z++){const x=E(oe[Z],B,q);if(w==="or")for(let de=0;de<q;de++)v[de]|=x[de];else for(let de=0;de<q;de++)v[de]&=x[de];C(B,x)}if(w==="not")for(let Z=0;Z<q;Z++)v[Z]^=1;return v}return X(p,B,ee(B,q))}function S(p,B){return E(p,B,B.count|0)}function U(p,B){if(!p||!B)return p||null;const q=p;if(Array.isArray(q.conditions)){if((q.op==="or"?"or":q.op==="not"?"not":"and")!=="and")return H(q,B)?null:p;const w=[];for(const v of q.conditions){const Z=U(v,B);Z&&w.push(Z)}return w.length?{...q,op:"and",conditions:w}:null}return q.col===B?null:p}function H(p,B){if(!p||typeof p!="object")return!1;const q=p;if(q.col===B)return!0;if(Array.isArray(q.conditions)){for(const oe of q.conditions)if(H(oe,B))return!0}return!1}function $(p,B,q){if(q&&q.length>=B){let Z=0;for(let x=0;x<B;x++)p[x]&&(q[Z++]=x);return q.subarray(0,Z)}let oe=0;for(let Z=0;Z<B;Z++)oe+=p[Z]?1:0;const w=new Uint32Array(oe);let v=0;for(let Z=0;Z<B;Z++)p[Z]&&(w[v++]=Z);return w}const re=new Map;function te(p){if(!(!p||typeof p!="object"))for(const[B,q]of Object.entries(p))q&&typeof q.compile=="function"&&re.set(B,q)}function ae(p){return typeof p=="string"?re.get(p):void 0}}),Se("packages/core/src/compute/group.js",function(o,me){"use strict";Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return ue}});const fe=me("packages/core/src/compute/handle.js"),he=fe.dictSize,Q=fe.identity,z=fe.presenceReader,ne=fe.rowCount,_=fe.valueReader,T="",K="\\0",ie=1<<20;function J(W,L,Y,ee){const C=W.length,A=W.map(t=>_(t)),i=Array.isArray(ee)&&ee.some(Boolean),s=i?A.map((t,a)=>ee[a]?m=>ee[a](t(m)):t):A;if(!i&&C>0&&W.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=W.map(m=>he(m.dict)+1);let a=1;for(let m=0;m<C;m++)a*=t[m];if(a<=Number.MAX_SAFE_INTEGER){const m=W.map(r=>r.values),e=W.map(r=>z(r)),d=r=>{let n=0;for(let c=0;c<C;c++){const g=e[c],M=g&&g(r)===0?t[c]-1:m[c][r];n=n*t[c]+M}return n},h=new Float64Array(Y);for(let r=0;r<Y;r++)h[r]=d(L[r]);return{packed:h,strings:null,product:a,readers:s,keyOf:d}}}const f=t=>{let a="";for(let m=0;m<C;m++){const e=s[m](t);a+=(m===0?"":T)+(e==null?K:String(e))}return a},l=new Array(Y);for(let t=0;t<Y;t++)l[t]=f(L[t]);return{packed:null,strings:l,product:1/0,readers:s,keyOf:f}}function le(W,L,Y,ee){const C=new Uint32Array(ee+1);for(let u=0;u<Y;u++)C[L[u]+1]++;for(let u=0;u<ee;u++)C[u+1]+=C[u];const A=new Uint32Array(Y),i=C.slice(0,ee);for(let u=0;u<Y;u++)A[i[L[u]]++]=W[u];const s=new Array(ee);for(let u=0;u<ee;u++)s[u]=A.subarray(C[u],C[u+1]);return s}function ue(W,L,Y={}){const ee=W||[],C=L||Q(ne(ee[0],Y)),A=C.length;if(ee.length===0||A===0)return{keys:[],buckets:[]};const{packed:i,strings:s,product:u,readers:f}=J(ee,C,A,Y.project),l=new Uint32Array(A);let t=0,a=null;if(i&&u<=Math.max(1024,Math.min(ie,A*4))){const h=u,r=new Int32Array(h).fill(-1);for(let n=0;n<A;n++)r[i[n]]=0;for(let n=0;n<h;n++)r[n]===0&&(r[n]=t++);for(let n=0;n<A;n++)l[n]=r[i[n]];a=new Float64Array(t);for(let n=0;n<h;n++)r[n]>=0&&(a[r[n]]=n)}else if(i){const h=new Map;for(let r=0;r<A;r++){const n=i[r];let c=h.get(n);c===void 0&&(c=t++,h.set(n,c)),l[r]=c}a=new Float64Array(t);for(const[r,n]of h)a[n]=r}else{const h=new Map;for(let r=0;r<A;r++){const n=s[r];let c=h.get(n);c===void 0&&(c=t++,h.set(n,c)),l[r]=c}}const m=le(C,l,A,t),e=new Array(t);for(let h=0;h<t;h++){const r=m[h][0],n=new Array(f.length);for(let c=0;c<f.length;c++)n[c]=f[c](r);e[h]=n}const d={keys:e,buckets:m};return a&&(d.packed=a),d}}),Se("packages/core/src/compute/facet.js",function(o,me){"use strict";Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return f}}),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 h}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return r}});const fe=me("packages/core/src/compute/handle.js"),he=fe.presenceReader,Q=fe.valueReader,z=fe.dictSize,ne=fe.dictValue,_=Object.freeze(["equal","quantile","log"]),T=Object.freeze(["hour","day","week","month","quarter","year"]),K=20,ie=50,J=1e4;function le(n,c){if(!n)return"none";const g=c;if(g&&(g.multi===!0||typeof g.items=="function"))return"category";const M=c&&c.base;if(M==="date"||M==="datetime"||M==="time"||M==="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 M==="number"?"numeric":M==="boolean"?"boolean":M==="text"?"category":"none"}}function ue(n){const c=n.values,g=n.kind;if((g==="float64"||g==="int32")&&c)return N=>c[N];const M=Q(n);return N=>W(M(N))}function W(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 L(n,c,g,M=ie){if(!n)return{cardinality:0,exact:!0};if(n.dict)return{cardinality:z(n.dict),exact:!0};if(n.kind==="bitset")return{cardinality:2,exact:!0};const N=Q(n),G=c?c.length:g,F=new Set;for(let R=0;R<G;R++){const X=N(c?c[R]:R);if(X!=null&&(F.add(X),F.size>M))return{cardinality:F.size,exact:!1}}return{cardinality:F.size,exact:!0}}const Y=36e5,ee=864e5;function C(n,c=K){const g=Number.isFinite(n)&&n>0?n:0,M=Math.max(1,c)*2;return g/Y<=M?"hour":g/ee<=M?"day":g/(7*ee)<=M?"week":g/(30*ee)<=M?"month":g/(91*ee)<=M?"quarter":"year"}function A(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 M=(g.getDay()+6)%7;return g.setDate(g.getDate()-M),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 s(n,c,g){const M=ue(n),N=he(n),G=c?c.length:g;let F=1/0,R=-1/0,X=0,E=0;for(let S=0;S<G;S++){const U=c?c[S]:S;if(N&&!N(U)){X++;continue}const H=M(U);if(!Number.isFinite(H)){X++;continue}H<F&&(F=H),H>R&&(R=H),E++}return{min:F,max:R,nulls:X,finite:E}}function u(n,c,g,M){const N=ue(n),G=he(n),F=c?c.length:g,R=F>M?F/M:1,X=[];for(let S=0;S<F;S+=R){const U=c?c[Math.floor(S)]:Math.floor(S);if(G&&!G(U))continue;const H=N(U);Number.isFinite(H)&&X.push(H)}const E=Float64Array.from(X);return E.sort(),E}function f(n,c,g,M={}){const N=M.kind||le(n,M.type);return N==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:N==="boolean"?l(n,c,g):N==="category"?t(n,c,g,M):a(n,c,g,N,M)}function l(n,c,g){const M=he(n);let N=0;if(M){const F=c?c.length:g;for(let R=0;R<F;R++)M(c?c[R]:R)||N++}const G=[{value:!1,label:"false"},{value:!0,label:"true"}];return N>0&&G.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:G}}function t(n,c,g,M){const N=M.cardinalityLimit??ie,{cardinality:G}=L(n,c,g,N);if(G>N&&(M.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:G};const F=Q(n),R=c?c.length:g,X=new Map;let E=0;for(let re=0;re<R;re++){const te=F(c?c[re]:re);if(te==null||te===""){E++;continue}if(Array.isArray(te)){if(!te.length){E++;continue}for(const ae of te)X.set(ae,(X.get(ae)||0)+1);continue}X.set(te,(X.get(te)||0)+1)}let S=[...X.entries()];M.order==="alpha"?S.sort((re,te)=>String(re[0]).localeCompare(String(te[0]))):S.sort((re,te)=>te[1]-re[1]);let U=0,H=0;if(S.length>N){H=S.length-N;for(let re=N;re<S.length;re++)U+=S[re][1];S=S.slice(0,N)}const $=S.map(([re])=>({value:re,label:String(re)}));return U>0&&$.push({remainder:!0,label:`Other (${H} values)`}),E>0&&$.push({null:!0,label:"Empty"}),{kind:"category",buckets:$,cardinality:G}}function a(n,c,g,M,N){const{min:G,max:F,nulls:R,finite:X}=s(n,c,g);if(!X)return{kind:M,buckets:R?[{null:!0,label:"Empty"}]:[],empty:!0};const E=Math.max(1,Math.floor(N.buckets||K));let S=[];if(M==="date"){const H=T.includes(N.granularity)?N.granularity:C(F-G,E);let $=A(G,H);for(;$<=F&&S.length<4096;){const re=i($,H);if(!(re>$))break;S.push({from:$,to:re}),$=re}return{kind:M,buckets:m(S,R),granularity:H}}const U=_.includes(N.strategy)?N.strategy:"equal";if(U==="quantile"){const H=u(n,c,g,J);if(H.length){const $=[H[0]];for(let re=1;re<E;re++){const te=H[Math.min(H.length-1,Math.floor(re/E*H.length))];te>$[$.length-1]&&$.push(te)}$.push(F);for(let re=0;re<$.length-1;re++)S.push({from:$[re],to:$[re+1]})}}else if(U==="log"&&G>0){const H=Math.log10(G),re=(Math.log10(F)-H)/E||1;for(let te=0;te<E;te++)S.push({from:10**(H+te*re),to:10**(H+(te+1)*re)})}if(!S.length){const H=(F-G)/E||1;for(let $=0;$<E;$++)S.push({from:G+$*H,to:G+($+1)*H})}return S[S.length-1].to=F,{kind:M,buckets:m(S,R),strategy:U,min:G,max:F}}function m(n,c){return c>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,c,g,M,N){const G=M&&M.buckets||[],F=N&&N.length>=G.length?N.subarray(0,G.length):new Uint32Array(G.length);if(F.fill(0),!n||!G.length)return F;const R=G.length-1,X=!!G[R]&&G[R].null===!0,E=c?c.length:g;if(M.kind==="boolean"){const re=Q(n);for(let te=0;te<E;te++){const ae=re(c?c[te]:te);if(ae==null){X&&F[R]++;continue}F[ae?1:0]++}return F}if(M.kind==="category"){const re=new Map;for(let p=0;p<G.length;p++)!G[p].null&&!G[p].remainder&&re.set(G[p].value,p);const te=G.findIndex(p=>p.remainder),ae=Q(n);for(let p=0;p<E;p++){const B=ae(c?c[p]:p);if(B==null||B===""){X&&F[R]++;continue}if(Array.isArray(B)){if(!B.length){X&&F[R]++;continue}for(const oe of B){const w=re.get(oe);w!==void 0?F[w]++:te>=0&&F[te]++}continue}const q=re.get(B);q!==void 0?F[q]++:te>=0&&F[te]++}return F}const S=X?G.length-1:G.length,U=new Float64Array(S+1);for(let re=0;re<S;re++)U[re]=G[re].from;U[S]=S?G[S-1].to:0;const H=ue(n),$=he(n);for(let re=0;re<E;re++){const te=c?c[re]:re;if($&&!$(te)){X&&F[R]++;continue}const ae=H(te);if(!Number.isFinite(ae)){X&&F[R]++;continue}const p=d(U,S,ae);p>=0&&F[p]++}return F}function d(n,c,g){if(!c||g<n[0])return-1;if(g>=n[c])return g===n[c]?c-1:-1;let M=0,N=c-1;for(;M<N;){const G=M+N+1>>>1;g>=n[G]?M=G:N=G-1}return M}function h(n,c,g,M={}){const N=M.bounds||f(n,M.boundsIndices??c,g,M);return{bounds:N,counts:e(n,c,g,N)}}const r=h}),Se("packages/core/src/compute/special.js",function(o,me){"use strict";Object.defineProperty(o,"logGamma",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"incompleteBeta",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return ee}});const fe=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),he=3e-12,Q=1e-300;function z(C){if(C<.5)return Math.log(Math.PI/Math.sin(Math.PI*C))-z(1-C);const A=C-1;let i=.9999999999998099;const s=A+7.5;for(let u=0;u<fe.length;u++)i+=fe[u]/(A+u+1);return .5*Math.log(2*Math.PI)+(A+.5)*Math.log(s)-s+Math.log(i)}function ne(C,A,i){const s=C+A,u=C+1,f=C-1;let l=1,t=1-s*i/u;Math.abs(t)<Q&&(t=Q),t=1/t;let a=t;for(let m=1;m<=300;m++){const e=2*m;let d=m*(A-m)*i/((f+e)*(C+e));t=1+d*t,Math.abs(t)<Q&&(t=Q),l=1+d/l,Math.abs(l)<Q&&(l=Q),t=1/t,a*=t*l,d=-(C+m)*(s+m)*i/((C+e)*(u+e)),t=1+d*t,Math.abs(t)<Q&&(t=Q),l=1+d/l,Math.abs(l)<Q&&(l=Q),t=1/t;const h=t*l;if(a*=h,Math.abs(h-1)<he)break}return a}function _(C,A,i){if(!(C>0)||!(A>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const s=Math.exp(z(C+A)-z(C)-z(A)+C*Math.log(i)+A*Math.log(1-i));return i<(C+1)/(C+A+2)?s*ne(C,A,i)/C:1-s*ne(A,C,1-i)/A}function T(C){if(!(C>0)||!(C<1))return C===0?-1/0:C===1?1/0:Number.NaN;const A=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],i=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],s=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],u=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],f=.02425;let l,t,a;C<f?(l=Math.sqrt(-2*Math.log(C)),a=(((((s[0]*l+s[1])*l+s[2])*l+s[3])*l+s[4])*l+s[5])/((((u[0]*l+u[1])*l+u[2])*l+u[3])*l+1)):C<=1-f?(l=C-.5,t=l*l,a=(((((A[0]*t+A[1])*t+A[2])*t+A[3])*t+A[4])*t+A[5])*l/(((((i[0]*t+i[1])*t+i[2])*t+i[3])*t+i[4])*t+1)):(l=Math.sqrt(-2*Math.log(1-C)),a=-(((((s[0]*l+s[1])*l+s[2])*l+s[3])*l+s[4])*l+s[5])/((((u[0]*l+u[1])*l+u[2])*l+u[3])*l+1));const e=(.5*K(-a/Math.SQRT2)-C)*Math.sqrt(2*Math.PI)*Math.exp(a*a/2);return a-e/(1+a*e/2)}function K(C){const A=Math.abs(C),i=2/(2+A),s=4*i-2,u=[-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 f=0,l=0,t;for(let m=u.length-1;m>0;m--)t=l,l=s*l-f+u[m],f=t;const a=i*Math.exp(-A*A+.5*(u[0]+s*l)-f);return C>=0?a:2-a}function ie(C){return .5*K(-C/Math.SQRT2)}function J(C,A){if(!(A>0)||!Number.isFinite(C))return Number.NaN;const i=.5*_(A/2,.5,A/(A+C*C));return C>0?1-i:i}function le(C,A){if(!(C>0)||!(C<1)||!(A>0))return Number.NaN;if(A>1e7)return T(C);let i=-1e4,s=1e4,u=T(C);const f=z(A/2)+z(.5)-z((A+1)/2);for(let l=0;l<60;l++){const t=J(u,A);t<C?i=u:s=u;const a=Math.exp(-((A+1)/2)*Math.log(1+u*u/A)-f)/Math.sqrt(A),m=a>0?(t-C)/a:0;if(Math.abs(m)<1e-12)break;const e=u-m;if(u=e>i&&e<s&&Number.isFinite(e)?e:(i+s)/2,s-i<1e-12)break}return u}function ue(C,A){let i=C,s=1/C,u=s;for(let f=0;f<300&&(i+=1,u*=A/i,s+=u,!(Math.abs(u)<Math.abs(s)*he));f++);return s*Math.exp(-A+C*Math.log(A)-z(C))}function W(C,A){let i=A+1-C,s=1/Q,u=1/i,f=u;for(let l=1;l<=300;l++){const t=-l*(l-C);i+=2,u=t*u+i,Math.abs(u)<Q&&(u=Q),s=i+t/s,Math.abs(s)<Q&&(s=Q),u=1/u;const a=u*s;if(f*=a,Math.abs(a-1)<he)break}return Math.exp(-A+C*Math.log(A)-z(C))*f}function L(C,A){return!(C>0)||!(A>=0)||!Number.isFinite(A)?Number.NaN:A===0?0:A<C+1?ue(C,A):1-W(C,A)}function Y(C,A){return A>0?L(A/2,C/2):Number.NaN}function ee(C,A){const i=Y(C,A);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Se("packages/core/src/compute/linalg.js",function(o,me){"use strict";Object.defineProperty(o,"cholesky",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"choleskySolve",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"choleskyInverse",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return _}});function fe(T){const K=T.length,ie=Array.from({length:K},()=>new Array(K).fill(0));for(let J=0;J<K;J++)for(let le=0;le<=J;le++){let ue=T[J][le];for(let W=0;W<le;W++)ue-=ie[J][W]*ie[le][W];if(J===le){if(!(ue>0))return null;ie[J][le]=Math.sqrt(ue)}else ie[J][le]=ue/ie[le][le]}return ie}function he(T,K){const ie=T.length,J=new Array(ie).fill(0);for(let ue=0;ue<ie;ue++){let W=K[ue];for(let L=0;L<ue;L++)W-=T[ue][L]*J[L];J[ue]=W/T[ue][ue]}const le=new Array(ie).fill(0);for(let ue=ie-1;ue>=0;ue--){let W=J[ue];for(let L=ue+1;L<ie;L++)W-=T[L][ue]*le[L];le[ue]=W/T[ue][ue]}return le}function Q(T){const K=T.length,ie=Array.from({length:K},()=>new Array(K).fill(0));for(let J=0;J<K;J++){const le=new Array(K).fill(0);le[J]=1;const ue=he(T,le);for(let W=0;W<K;W++)ie[W][J]=ue[W]}return ie}function z(T,K,ie){const J=T.length,le=J?T[0].length:0,ue=Array.from({length:le},()=>new Array(le).fill(0)),W=new Array(le).fill(0);for(let L=0;L<J;L++){const Y=ie?ie[L]:1,ee=T[L];for(let C=0;C<le;C++){const A=Y*ee[C];W[C]+=A*K[L];for(let i=C;i<le;i++)ue[C][i]+=A*ee[i]}}for(let L=0;L<le;L++)for(let Y=0;Y<L;Y++)ue[L][Y]=ue[Y][L];return{xtwx:ue,xtwy:W}}function ne(T,K){return T.map(ie=>ie.reduce((J,le,ue)=>J+le*K[ue],0))}function _(T,K){let ie=0;for(let J=0;J<T.length;J++){let le=0;for(let ue=0;ue<T.length;ue++)le+=K[J][ue]*T[ue];ie+=T[J]*le}return ie}}),Se("packages/core/src/compute/sketch.js",function(o,me){"use strict";Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return ue}});class fe{#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(L){if(!Number.isFinite(L))return;this.#t++;const Y=L-this.#e;this.#e+=Y/this.#t,this.#n+=Y*(L-this.#e)}merge(L){if(L.#t===0)return;if(this.#t===0){this.#t=L.#t,this.#e=L.#e,this.#n=L.#n;return}const Y=this.#t+L.#t,ee=L.#e-this.#e;this.#e+=ee*(L.#t/Y),this.#n+=L.#n+ee*ee*(this.#t*L.#t/Y),this.#t=Y}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 L=this.variance();return L===null?null:Math.sqrt(L)}stddevP(){const L=this.varianceP();return L===null?null:Math.sqrt(L)}}class he{#t=[];#e=0;#n;#r;constructor(L,Y=Math.random){if(!(L>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(L),this.#r=Y}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(L){if(!Number.isFinite(L))return;if(this.#e++,this.#t.length<this.#n){this.#t.push(L);return}const Y=Math.floor(this.#r()*this.#e);Y<this.#n&&(this.#t[Y]=L)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let L=0;for(const Y of this.#t)L+=Y;return L/this.#t.length}quantile(L){const Y=this.#t.length;if(!Y)return null;const ee=this.#t.slice().sort((s,u)=>s-u);if(Y===1)return ee[0];const C=(Y-1)*Math.min(1,Math.max(0,L)),A=Math.floor(C),i=Math.ceil(C);return A===i?ee[A]:ee[A]+(C-A)*(ee[i]-ee[A])}}function Q(W){return W^=W>>>16,W=Math.imul(W,2246822507),W^=W>>>13,W=Math.imul(W,3266489909),W^=W>>>15,W>>>0}function z(W){if(typeof W=="number"){const ee=new DataView(new ArrayBuffer(8));return ee.setFloat64(0,W===0?0:W),Q(ee.getUint32(0)^ee.getUint32(4))}const L=typeof W=="string"?W:String(W);let Y=2166136261;for(let ee=0;ee<L.length;ee++)Y^=L.charCodeAt(ee),Y=Math.imul(Y,16777619);return Q(Y)}class ne{#t;#e;#n;constructor(L=14){const Y=Math.floor(L);if(Y<4||Y>16)throw new RangeError("HLL precision must be 4..16");this.#t=Y,this.#e=1<<Y,this.#n=new Uint8Array(this.#e)}static errorBoundFor(L=14){const Y=1<<Math.floor(L),ee=1.04/Math.sqrt(Y);return Object.freeze({kind:"probabilistic",metric:"relative",value:ee,statement:`distinct count within ~${(ee*100).toFixed(2)}% relative standard error (m=${Y} buckets)`})}errorBound(){return ne.errorBoundFor(this.#t)}add(L){const Y=z(L),ee=Y&this.#e-1,C=Y>>>this.#t|1<<32-this.#t;let A=1,i=C;for(;(i&1)===0;)A++,i>>>=1;A>this.#n[ee]&&(this.#n[ee]=A)}count(){const L=this.#e,Y=32-this.#t,ee=new Float64Array(Y+2);for(let i=0;i<L;i++)ee[this.#n[i]]++;let C=L*K(1-ee[Y+1]/L);for(let i=Y;i>=1;i--)C=.5*(C+ee[i]);C+=L*T(ee[0]/L);const A=_*L*L/C;return Math.round(A)}}const _=.5/Math.log(2);function T(W){if(W===1)return 1/0;let L=1,Y=W,ee;do W*=W,ee=Y,Y+=W*L,L+=L;while(Y!==ee);return Y}function K(W){if(W===0||W===1)return 0;let L=1,Y=1-W,ee;do W=Math.sqrt(W),ee=Y,L*=.5,Y-=(1-W)**2*L;while(Y!==ee);return Y/3}class ie{#t=new Map;#e;#n=0;constructor(L){if(!(L>0))throw new RangeError("Space-Saving capacity must be positive");this.#e=Math.floor(L)}errorBoundFor(L){const Y=L/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:Y,statement:`each count overestimates the truth by at most N/m = ${Y.toFixed(2)} (N=${L}, m=${this.#e})`})}get seen(){return this.#n}add(L){this.#n++;const Y=this.#t.get(L);if(Y){Y.count++;return}if(this.#t.size<this.#e){this.#t.set(L,{count:1,error:0});return}let ee,C=1/0;for(const[A,i]of this.#t)i.count<C&&(C=i.count,ee=A);this.#t.delete(ee),this.#t.set(L,{count:C+1,error:C})}top(L=this.#e){return[...this.#t.entries()].map(([ee,C])=>({item:ee,count:C.count,error:C.error})).sort((ee,C)=>C.count-ee.count).slice(0,Math.max(0,Math.floor(L)))}}class J{#t;#e=[[]];#n=0;#r;#i;constructor(L=200,Y=Math.random){this.#t=Math.max(8,Math.floor(L)),this.#r=Y,this.#i=2/3}static errorBoundFor(L=200){const Y=1/Math.max(8,Math.floor(L));return Object.freeze({kind:"probabilistic",metric:"rank",value:Y,statement:`queried quantile\'s true rank within ~${(Y*100).toFixed(2)}% of N of the requested rank (k=${L})`})}errorBound(){return J.errorBoundFor(this.#t)}get count(){return this.#n}#s(L){const ee=this.#e.length-1-L,C=Math.ceil(this.#t*this.#i**ee);return Math.max(2,C)}add(L){Number.isFinite(L)&&(this.#n++,this.#e[0].push(L),this.#e[0].length>=this.#s(0)&&this.#h(0))}#h(L){const Y=this.#e[L];Y.sort((A,i)=>A-i),L+1>=this.#e.length&&this.#e.push([]);const ee=this.#e[L+1],C=this.#r()<.5?0:1;for(let A=C;A<Y.length;A+=2)ee.push(Y[A]);this.#e[L]=[];for(let A=0;A<this.#e.length;A++)if(this.#e[A].length>=this.#s(A)){this.#h(A);return}}#u(){const L=[];for(let Y=0;Y<this.#e.length;Y++){const ee=1<<Y;for(const C of this.#e[Y])L.push({v:C,w:ee})}return L}quantile(L){const Y=this.#u();if(!Y.length)return null;Y.sort((i,s)=>i.v-s.v);let ee=0;for(const i of Y)ee+=i.w;const C=Math.min(1,Math.max(0,L))*ee;let A=0;for(const i of Y)if(A+=i.w,A>=C)return i.v;return Y[Y.length-1].v}rank(L){let Y=0;for(let ee=0;ee<this.#e.length;ee++){const C=1<<ee;for(const A of this.#e[ee])A<=L&&(Y+=C)}return Y}}const le=Object.freeze({distinct:ne.errorBoundFor(14),median:J.errorBoundFor(200),p25:J.errorBoundFor(200),p75:J.errorBoundFor(200),p90:J.errorBoundFor(200),p95:J.errorBoundFor(200),p99:J.errorBoundFor(200),iqr:J.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"})}),ue={Welford:fe,Reservoir:he,HyperLogLog:ne,SpaceSaving:ie,KLL:J,hash32:z,SKETCH_BOUNDS:le}}),Se("packages/core/src/compute/statistics.js",function(o,me){"use strict";Object.defineProperty(o,"KENDALL_LIMIT",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"numbers",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"frequencies",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"herfindahl",{enumerable:!0,get:function(){return a}}),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 h}}),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 M}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"weightedAverage",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"extremeRow",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"correlation",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"fitLinearModel",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(o,"autocorrelations",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(o,"spearman",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(o,"kendall",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(o,"seriesStats",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(o,"D2_N2",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(o,"D4_N2",{enumerable:!0,get:function(){return st}}),Object.defineProperty(o,"movingRanges",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(o,"withinSigma",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(o,"capability",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(o,"controlLimits",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(o,"westernElectricViolations",{enumerable:!0,get:function(){return ut}}),Object.defineProperty(o,"nelsonViolations",{enumerable:!0,get:function(){return ct}}),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 Ge}}),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 lt}}),Object.defineProperty(o,"normalTotalVariation",{enumerable:!0,get:function(){return at}}),Object.defineProperty(o,"frequencyMap",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(o,"categoricalDistance",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(o,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return et}}),Object.defineProperty(o,"compareColumn",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(o,"isNumericColumn",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(o,"populationRead",{enumerable:!0,get:function(){return Rt}});const fe=me("packages/core/src/compute/handle.js"),he=fe.presenceReader,Q=fe.valueReader,z=me("packages/core/src/compute/special.js"),ne=z.studentTQuantile,_=z.studentT,T=z.normalQuantile,K=z.normalCdf,ie=z.chiSquareUpperTail,J=me("packages/core/src/compute/linalg.js"),le=J.cholesky,ue=J.choleskySolve,W=J.choleskyInverse,L=J.normalEquations,Y=J.quadForm,C=me("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,A=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"}),s=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:C.distinct}),median:Object.freeze({sketch:"KLL",bound:C.median}),p25:Object.freeze({sketch:"KLL",bound:C.p25}),p75:Object.freeze({sketch:"KLL",bound:C.p75}),p90:Object.freeze({sketch:"KLL",bound:C.p90}),p95:Object.freeze({sketch:"KLL",bound:C.p95}),p99:Object.freeze({sketch:"KLL",bound:C.p99}),iqr:Object.freeze({sketch:"KLL",bound:C.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:C.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:C.topK})});function u(b){const j=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(s,b)?s[b]:null;return{stat:b,exact:j,approximate:y}}function f(b,j){const y=j.length,O=new Float64Array(y);let k=0;if(b&&(b.kind==="float64"||b.kind==="int32")){const I=b.values,D=he(b);for(let se=0;se<y;se++){const ce=j[se];if(D&&D(ce)!==1)continue;const Oe=I[ce];Number.isNaN(Oe)||(O[k++]=Oe)}return O.subarray(0,k)}const V=Q(b);for(let I=0;I<y;I++){const D=V(j[I]);if(D==null||D==="")continue;const se=typeof D=="number"?D:Number(D);Number.isFinite(se)&&(O[k++]=se)}return O.subarray(0,k)}function l(b,j){const y=new Map,O=Q(b);let k=0;for(let V=0;V<j.length;V++){const I=O(j[V]);if(I==null||I===""||typeof I=="number"&&Number.isNaN(I))continue;const D=typeof I=="object"?String(I):I;y.set(D,(y.get(D)||0)+1),k++}const P=[...y.values()].sort((V,I)=>I-V);return{counts:P,total:k,distinct:P.length}}function t(b){return b.total>0?b.counts.map(j=>j/b.total):[]}function a(b,j){const y=l(b,j);if(!y.total)return null;let O=0;for(const k of t(y))O+=k*k;return O}function m(b,j){const y=l(b,j);if(!y.total)return null;let O=0;for(const k of t(y))k>0&&(O-=k*Math.log2(k));return O}function e(b,j){const y=l(b,j);if(!y.total||y.distinct<2)return y.total?1:null;let O=0;for(const k of t(y))k>0&&(O-=k*Math.log2(k));return O/Math.log2(y.distinct)}function d(b,j,y=3){const O=l(b,j);if(!O.total)return null;const k=Math.max(1,Math.floor(y));let P=0;for(let V=0;V<Math.min(k,O.counts.length);V++)P+=O.counts[V];return P/O.total}function h(b,j){const y=f(b,j),O=y.length;if(!O)return null;const k=y.slice().sort();if(k[0]<0)return null;let P=0,V=0;for(let I=0;I<O;I++)P+=k[I],V+=(I+1)*k[I];return P===0?0:2*V/(O*P)-(O+1)/O}function r(b){let j=0,y=0,O=0;for(let k=0;k<b.length;k++){const P=b[k];j++;const V=P-y;y+=V/j,O+=V*(P-y)}return{n:j,mean:y,m2:O}}function n(b,j){const y=b.length;if(!y)return NaN;if(y===1)return b[0];const O=(y-1)*Math.min(1,Math.max(0,j)),k=Math.floor(O),P=Math.ceil(O);return k===P?b[k]:b[k]+(O-k)*(b[P]-b[k])}function c(b,j){if(!b.length)return NaN;const y=b.slice().sort();return n(y,j)}function g(b,j){const y=Q(b);let O=0,k=0,P=0;for(let V=0;V<j.length;V++){const I=y(j[V]);if(I==null||I==="")continue;const D=String(I).toUpperCase();D==="PASS"?O++:D==="FAIL"?k++:D==="WARN"&&P++}return{pass:O+P,fail:k,warn:P,judged:O+P+k}}const M=Object.freeze({hhi:(b,j)=>a(b,j),entropy:(b,j)=>m(b,j),evenness:(b,j)=>e(b,j),top3Share:(b,j)=>d(b,j,3),top10Share:(b,j)=>d(b,j,10),gini:(b,j)=>h(b,j),trimmedMean:(b,j)=>X(f(b,j),.1),winsorizedMean:(b,j)=>E(f(b,j),.1),robustOutliers:(b,j)=>S(f(b,j),3.5),jarqueBera:(b,j)=>U(f(b,j)),variance:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>1?O/(y-1):null},varianceP:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>0?O/y:null},stddev:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>1?Math.sqrt(O/(y-1)):null},stddevP:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>0?Math.sqrt(O/y):null},median:(b,j)=>{const y=f(b,j);return y.length?c(y,.5):null},p25:(b,j)=>{const y=f(b,j);return y.length?c(y,.25):null},p75:(b,j)=>{const y=f(b,j);return y.length?c(y,.75):null},p90:(b,j)=>{const y=f(b,j);return y.length?c(y,.9):null},p95:(b,j)=>{const y=f(b,j);return y.length?c(y,.95):null},p99:(b,j)=>{const y=f(b,j);return y.length?c(y,.99):null},iqr:(b,j)=>{const y=f(b,j);if(!y.length)return null;const O=y.slice().sort();return n(O,.75)-n(O,.25)},mad:(b,j)=>{const y=f(b,j);if(!y.length)return null;const O=c(y,.5),k=new Float64Array(y.length);for(let P=0;P<y.length;P++)k[P]=Math.abs(y[P]-O);return c(k,.5)},range:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=1/0,k=-1/0;for(let P=0;P<y.length;P++)y[P]<O&&(O=y[P]),y[P]>k&&(k=y[P]);return k-O},distinct:(b,j)=>{const y=Q(b),O=new Set;for(let k=0;k<j.length;k++){const P=y(j[k]);P==null||P===""||O.add(P instanceof Date?P.getTime():P)}return O.size},mode:(b,j)=>{const y=Q(b),O=new Map;for(let V=0;V<j.length;V++){const I=y(j[V]);if(I==null||I==="")continue;const D=I instanceof Date?I.getTime():I;O.set(D,(O.get(D)||0)+1)}let k=null,P=1;for(const[V,I]of O)I>P&&(P=I,k=V);return k},skewness:(b,j)=>{const y=f(b,j),{n:O,mean:k,m2:P}=r(y);if(O<3||P<=0)return null;const V=Math.sqrt(P/(O-1));let I=0;for(let D=0;D<y.length;D++)I+=((y[D]-k)/V)**3;return O/((O-1)*(O-2))*I},kurtosis:(b,j)=>{const y=f(b,j),{n:O,mean:k,m2:P}=r(y);if(O<4||P<=0)return null;const V=Math.sqrt(P/(O-1));let I=0;for(let ce=0;ce<y.length;ce++)I+=((y[ce]-k)/V)**4;const D=O*(O+1)/((O-1)*(O-2)*(O-3)),se=3*(O-1)**2/((O-2)*(O-3));return D*I-se},geomean:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=0;for(let k=0;k<y.length;k++){if(y[k]<=0)return null;O+=Math.log(y[k])}return Math.exp(O/y.length)},harmean:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=0;for(let k=0;k<y.length;k++){if(y[k]===0)return null;O+=1/y[k]}return y.length/O},sumSquares:(b,j)=>{const y=f(b,j);let O=0;for(let k=0;k<y.length;k++)O+=y[k]*y[k];return O},passRate:(b,j)=>{const{pass:y,judged:O}=g(b,j);return O?y/O:null},failureCount:(b,j)=>g(b,j).fail}),N=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 G(b,j,y){const O=Q(b),k=Q(j);let P=0,V=0;for(let I=0;I<y.length;I++){const D=y[I],se=Number(O(D)),ce=Number(k(D));!Number.isFinite(se)||!Number.isFinite(ce)||(P+=se*ce,V+=ce)}return V===0?null:P/V}function F(b,j,y){const O=Q(b);let k=null,P=y?-1/0:1/0;for(let V=0;V<j.length;V++){const I=j[V],D=Number(O(I));Number.isFinite(D)&&(y?D>P:D<P)&&(P=D,k=I)}return k}function R(b,j,y){const O=Q(b),k=Q(j);let P=0,V=0,I=0,D=0,se=0,ce=0;for(let be=0;be<y.length;be++){const Ae=y[be],Pe=Number(O(Ae)),ye=Number(k(Ae));!Number.isFinite(Pe)||!Number.isFinite(ye)||(P++,V+=Pe,I+=ye,D+=Pe*Pe,se+=ye*ye,ce+=Pe*ye)}if(P<2)return null;const Oe=P*ce-V*I,ke=Math.sqrt((P*D-V*V)*(P*se-I*I));if(ke===0)return null;const je=Oe/ke;return Math.max(-1,Math.min(1,je))}function X(b,j=.1){const y=b.length;if(!y)return null;const O=Array.from(b).sort((I,D)=>I-D),k=Math.floor(y*Math.min(.49,Math.max(0,j))),P=O.slice(k,y-k);if(!P.length)return n(O,.5);let V=0;for(const I of P)V+=I;return V/P.length}function E(b,j=.1){const y=b.length;if(!y)return null;const O=Array.from(b).sort((D,se)=>D-se),k=Math.floor(y*Math.min(.49,Math.max(0,j))),P=O[k],V=O[y-1-k];let I=0;for(const D of O)I+=Math.min(V,Math.max(P,D));return I/y}function S(b,j=3.5){if(!b.length)return null;const O=Array.from(b).sort((D,se)=>D-se),k=n(O,.5),P=O.map(D=>Math.abs(D-k)).sort((D,se)=>D-se),V=n(P,.5);if(V===0)return null;let I=0;for(const D of O)Math.abs(.6745*(D-k)/V)>j&&I++;return I}function U(b){const j=b.length;if(j<8)return null;let y=0;for(const D of b)y+=D;y/=j;let O=0,k=0,P=0;for(const D of b){const se=D-y;O+=se*se,k+=se*se*se,P+=se*se*se*se}if(O/=j,k/=j,P/=j,O===0)return null;const V=k/O**1.5,I=P/(O*O)-3;return j/6*(V*V+I*I/4)}function H(b,j,y){const O=[];let k=0;for(let D=0;D<b.length;D++){const se=Number(b[D]),ce=Number(j[D]);!Number.isFinite(se)||!Number.isFinite(ce)||ce<=0||(O.push([se,ce]),k+=ce)}if(!O.length||k<=0)return null;if(O.sort((D,se)=>D[0]-se[0]),O.length===1)return O[0][0];const P=[];let V=0;for(const[,D]of O)P.push((V+D/2)/k),V+=D;const I=Math.max(0,Math.min(1,y));if(I<=P[0])return O[0][0];if(I>=P[P.length-1])return O[O.length-1][0];for(let D=1;D<P.length;D++){if(I>P[D])continue;const se=P[D]-P[D-1],ce=se>0?(I-P[D-1])/se:0;return O[D-1][0]+(O[D][0]-O[D-1][0])*ce}return O[O.length-1][0]}function $(b,j,y){const O=Q(b),k=Q(j),P=new Float64Array(y.length),V=new Float64Array(y.length);let I=0;for(let D=0;D<y.length;D++){const se=y[D],ce=Number(O(se)),Oe=Number(k(se));!Number.isFinite(ce)||!Number.isFinite(Oe)||(P[I]=ce,V[I]=Oe,I++)}return{xs:P.subarray(0,I),ys:V.subarray(0,I),n:I}}function re(b,j,y,O=!1){const{xs:k,ys:P,n:V}=$(b,j,y);if(V<2)return null;let I=0,D=0;for(let ce=0;ce<V;ce++)I+=k[ce],D+=P[ce];I/=V,D/=V;let se=0;for(let ce=0;ce<V;ce++)se+=(k[ce]-I)*(P[ce]-D);return se/(O?V:V-1)}function te(b,j,y){const{xs:O,ys:k,n:P}=$(b,j,y);if(P<2)return null;let V=0,I=0;for(let Pe=0;Pe<P;Pe++)V+=O[Pe],I+=k[Pe];V/=P,I/=P;let D=0,se=0,ce=0;for(let Pe=0;Pe<P;Pe++){const ye=O[Pe]-V,ve=k[Pe]-I;D+=ye*ye,se+=ye*ve,ce+=ve*ve}if(D===0)return null;const Oe=se/D,ke=I-Oe*V,je=ce===0?1:Math.max(0,Math.min(1,se*se/(D*ce))),be=Math.max(0,ce-Oe*se),Ae=P>2?Math.sqrt(be/(P-2)/D):0;return{slope:Oe,intercept:ke,r2:je,stdError:Ae,n:P}}const ae=new Set(["ols","wls","robust"]),p=new Set(["quantile"]),B=new Set(["ridge","lasso","elasticnet","mixed","gls"]),q=1.345;function oe(b,j,y){const{xtwx:O,xtwy:k}=L(b,j,y),P=le(O);if(!P)return null;const V=ue(P,k),I=W(P),D=w(b,V),se=j.map((ce,Oe)=>ce-D[Oe]);return{beta:V,cov:I,fitted:D,residuals:se}}function w(b,j){return b.map(y=>y.reduce((O,k,P)=>O+k*j[P],0))}function v(b,j){const y=b.length,O=b.map(se=>se[j]),k=b.map(se=>[1,...se.filter((ce,Oe)=>Oe!==j)]),P=oe(k,O,null);if(!P)return 1;const V=O.reduce((se,ce)=>se+ce,0)/y;let I=0,D=0;for(let se=0;se<y;se++)I+=P.residuals[se]**2,D+=(O[se]-V)**2;return D===0?1:Math.max(0,Math.min(1,1-I/D))}function Z(b){const j=[...b].sort((k,P)=>k-P),y=x(j),O=b.map(k=>Math.abs(k-y)).sort((k,P)=>k-P);return x(O)/.6745}function x(b){const j=b.length;if(!j)return 0;const y=Math.floor(j/2);return j%2?b[y]:(b[y-1]+b[y])/2}function de(b,j,y={}){const O=y.method||"ols";if(B.has(O))throw new Error(`[lattice] regression method "${O}" is out of scope; use ols, wls or robust.`);if(p.has(O))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!ae.has(O))throw new Error(`[lattice] unknown regression method "${O}"; use ols, wls or robust.`);const k=Array.isArray(j)?j.length:0,P=k&&Array.isArray(b[0])?b[0].length:0,V=P+1;if(!(k>V))return null;for(let Me=0;Me<k;Me++){if(!Number.isFinite(j[Me])||!Array.isArray(b[Me])||b[Me].length!==P)return null;for(let Ne=0;Ne<P;Ne++)if(!Number.isFinite(b[Me][Ne]))return null}let I=null;if(O==="wls"){if(I=y.weights,!Array.isArray(I)||I.length!==k)return null;for(let Me=0;Me<k;Me++)if(!(I[Me]>0)||!Number.isFinite(I[Me]))return null}const D=b.map(Me=>[1,...Me]);let se,ce=null;if(O==="robust"){if(se=oe(D,j,null),!se)return null;for(let Me=0;Me<50;Me++){const Ne=Z(se.residuals);if(!(Ne>0))break;const Re=se.residuals.map($e=>{const We=Math.abs($e/Ne);return We<=q?1:q/We}),Ce=oe(D,j,Re);if(!Ce)return null;const Ve=Ce.beta.reduce(($e,We,Je)=>Math.max($e,Math.abs(We-se.beta[Je])),0);if(se=Ce,ce=Re,Ve<1e-10)break}}else if(se=oe(D,j,I),!se)return null;const Oe=O==="robust"?ce:I,{beta:ke,cov:je,fitted:be,residuals:Ae}=se;let Pe=0,ye=0,ve=0;for(let Me=0;Me<k;Me++){const Ne=Oe?Oe[Me]:1;Pe+=Ne*Ae[Me]**2,ye+=Ne,ve+=Ne*j[Me]}const Fe=ve/ye;let Ie=0;for(let Me=0;Me<k;Me++){const Ne=Oe?Oe[Me]:1;Ie+=Ne*(j[Me]-Fe)**2}const De=k-V,qe=Pe/De,Ue=Ie===0?1:Math.max(0,Math.min(1,1-Pe/Ie)),tt=1-(1-Ue)*(k-1)/De,Xe=Array.isArray(y.names)&&y.names.length===P?y.names:b[0].map((Me,Ne)=>`x${Ne+1}`),He=Qe(y.confidence),Ze=De>0?ne(1-(1-He)/2,De):1/0,Lt=ke.map((Me,Ne)=>{const Re=Math.sqrt(Math.max(0,qe*je[Ne][Ne])),Ce=Re>0?Me/Re:Me===0?0:1/0,Ve=Number.isFinite(Ce)?2*(1-_(Math.abs(Ce),De)):0,$e=Number.isFinite(Ze)?Ze*Re:null;return{name:Ne===0?"(intercept)":Xe[Ne-1],estimate:Me,stdError:Re,t:Ce,p:Math.max(0,Math.min(1,Ve)),lower:$e===null?null:Me-$e,upper:$e===null?null:Me+$e}}),dt=new Array(k),mt=new Array(k);for(let Me=0;Me<k;Me++){const Ne=Oe?Oe[Me]:1,Re=Math.max(0,Math.min(1,Ne*Y(D[Me],je)));dt[Me]=Re;const Ce=(1-Re)**2;mt[Me]=Ce>0&&qe>0?Ae[Me]**2/(V*qe)*(Re/Ce):null}const Ft=b[0].map((Me,Ne)=>{if(P<2)return 1;const Re=v(b,Ne);return Re>=1?1/0:1/(1-Re)});let gt=null;{const Me=Ae.map(Re=>Re*Re),Ne=oe(D,Me,null);if(Ne){const Re=Me.reduce((Ye,Ct)=>Ye+Ct,0)/k;let Ce=0,Ve=0;for(let Ye=0;Ye<k;Ye++)Ce+=Ne.residuals[Ye]**2,Ve+=(Me[Ye]-Re)**2;const $e=Ve===0?0:Math.max(0,Math.min(1,1-Ce/Ve)),We=k*$e,Je=ie(We,P);gt={statistic:We,df:P,p:Je,heteroscedastic:Je<.05}}}let bt=null;if(P===1){const Me=b.map((Ne,Re)=>Re).sort((Ne,Re)=>b[Ne][0]-b[Re][0]);bt={confidence:He,points:Me.map(Ne=>{const Re=D[Ne],Ce=Math.sqrt(Math.max(0,qe*Y(Re,je)));return{x:b[Ne][0],yhat:be[Ne],lower:be[Ne]-Ze*Ce,upper:be[Ne]+Ze*Ce}})}}return{method:O,coefficients:Lt,r2:Ue,adjR2:tt,n:k,df:De,sigma2:qe,fitted:be,residuals:Ae,leverage:dt,cooksD:mt,vif:Ft,heteroscedasticity:gt,band:bt,weights:Oe?[...Oe]:null}}function we(b){const j=b.length,y=Array.from({length:j},(P,V)=>V).sort((P,V)=>b[P]-b[V]),O=new Float64Array(j);let k=0;for(;k<j;){let P=k;for(;P+1<j&&b[y[P+1]]===b[y[k]];)P++;const V=(k+P)/2+1;for(let I=k;I<=P;I++)O[y[I]]=V;k=P+1}return O}const ge=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function pe(b){const j=[.01,.05,.1],y=[ge["1%"],ge["5%"],ge["10%"]];if(b<=y[0]){const P=(Math.log(j[1])-Math.log(j[0]))/(y[1]-y[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(j[0])+P*(b-y[0]))))}if(b>=y[2]){const P=(Math.log(j[2])-Math.log(j[1]))/(y[2]-y[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(j[2])+P*(b-y[2]))))}const O=b<y[1]?0:1,k=(b-y[O])/(y[O+1]-y[O]);return Math.exp(Math.log(j[O])+k*(Math.log(j[O+1])-Math.log(j[O])))}function Te(b,j,y,O){const k=y-O,P=O+3,V=new Array(k),I=new Array(k);let D=!0,se=O;for(let be=0;be<k;be++){const Ae=O+be,Pe=new Float64Array(P);Pe[0]=1,Pe[1]=be+1,Pe[2]=b[Ae];for(let ye=1;ye<=O;ye++)Pe[2+ye]=j[Ae-ye];for(let ye=1;ye<P;ye++)Number.isFinite(Pe[ye])||(se=Math.min(se,ye-3));V[be]=Pe,I[be]=j[Ae],Number.isFinite(I[be])||(D=!1)}if(!D)return 0;const{xtwx:ce,xtwy:Oe}=L(V,I,null);let ke=0,je=1/0;for(let be=0;be<=se;be++){const Ae=be+3;if(!(k>Ae))continue;const Pe=new Array(Ae);for(let Ue=0;Ue<Ae;Ue++)Pe[Ue]=ce[Ue].slice(0,Ae);const ye=le(Pe);if(!ye)continue;const ve=ue(ye,Oe.slice(0,Ae));let Fe=0;for(let Ue=0;Ue<k;Ue++){const tt=V[Ue];let Xe=0;for(let He=0;He<Ae;He++)Xe+=tt[He]*ve[He];Fe+=(I[Ue]-Xe)**2}const De=Fe/(k-Ae)*(k-Ae);if(!(De>0))continue;const qe=k*Math.log(De/k)+2*Ae;qe<je&&(je=qe,ke=be)}return ke}function Le(b,j={}){const y=[];for(let je=0;je<b.length;je++){const be=Number(b[je]);Number.isFinite(be)&&y.push(be)}const O=y.length,k=O-1;if(O<8||k<6)return null;const P=new Array(k);for(let je=0;je<k;je++)P[je]=y[je+1]-y[je];let V=Number.isFinite(j.maxlag)?Math.floor(j.maxlag):Math.ceil(12*(O/100)**.25);V=Math.max(0,Math.min(V,Math.floor((k-5)/2)));const I=(je,be)=>{const Ae=[],Pe=[];for(let ye=be;ye<k;ye++){const ve=[ye-be+1,y[ye]];for(let Fe=1;Fe<=je;Fe++)ve.push(P[ye-Fe]);Ae.push(ve),Pe.push(P[ye])}return de(Ae,Pe,{method:"ols"})},D=Te(y,P,k,V),se=I(D,D);if(!se||!se.coefficients[2])return null;const ce=se.coefficients[2].t,Oe=pe(ce),ke=ce<ge["5%"];return{statistic:ce,usedLag:D,nobs:k-D,criticalValues:{...ge},pValue:Oe,pApproximate:!0,stationary:ke,verdict:ke?"stationary":"non-stationary",regression:"ct"}}function Be(b,j={}){const y=[];for(let ke=0;ke<b.length;ke++){const je=Number(b[ke]);Number.isFinite(je)&&y.push(je)}const O=y.length;if(O<3)return null;let k=Number.isFinite(j.maxlag)?Math.floor(j.maxlag):Math.min(10,O-1);k=Math.max(1,Math.min(k,O-1));let P=0;for(const ke of y)P+=ke;P/=O;const V=y.map(ke=>ke-P);let I=0;for(const ke of V)I+=ke*ke;I/=O;const D=new Array(k+1).fill(0);D[0]=1;for(let ke=1;ke<=k;ke++){let je=0;for(let be=ke;be<O;be++)je+=V[be]*V[be-ke];D[ke]=I>0?je/O/I:0}const se=new Array(k+1).fill(0);se[0]=1;let ce=[];for(let ke=1;ke<=k;ke++){let je=D[ke];for(let ye=1;ye<ke;ye++)je-=ce[ye-1]*D[ke-ye];let be=1;for(let ye=1;ye<ke;ye++)be-=ce[ye-1]*D[ye];const Ae=be!==0?je/be:0,Pe=new Array(ke);for(let ye=1;ye<ke;ye++)Pe[ye-1]=ce[ye-1]-Ae*ce[ke-1-ye];Pe[ke-1]=Ae,se[ke]=Ae,ce=Pe}const Oe=1.96/Math.sqrt(O);return{acf:D,pacf:se,bounds:{upper:Oe,lower:-Oe},n:O,nlags:k,approximate:!0}}function ze(b,j,y){const{xs:O,ys:k,n:P}=$(b,j,y);if(P<2)return null;const V=we(O),I=we(k);let D=0,se=0;for(let je=0;je<P;je++)D+=V[je],se+=I[je];D/=P,se/=P;let ce=0,Oe=0,ke=0;for(let je=0;je<P;je++){const be=V[je]-D,Ae=I[je]-se;ce+=be*Ae,Oe+=be*be,ke+=Ae*Ae}return Oe===0||ke===0?null:Math.max(-1,Math.min(1,ce/Math.sqrt(Oe*ke)))}function Ke(b,j,y){const{xs:O,ys:k,n:P}=$(b,j,y);if(P<2||P>A)return null;let V=0,I=0,D=0,se=0;for(let ke=0;ke<P;ke++)for(let je=ke+1;je<P;je++){const be=Math.sign(O[ke]-O[je]),Ae=Math.sign(k[ke]-k[je]),Pe=be*Ae;Pe>0?V++:Pe<0?I++:be===0&&Ae===0||(be===0?D++:se++)}const ce=V+I+se,Oe=V+I+D;return ce===0||Oe===0?null:(V-I)/Math.sqrt(ce*Oe)}function Ee(b,j={}){const y=b.length;if(y<2)return null;const O=b[0],k=b[y-1],P=[];for(let ye=1;ye<y;ye++){const ve=b[ye-1];ve!==0&&P.push((b[ye]-ve)/Math.abs(ve))}let V=null;if(P.length>1){let ye=0;for(const Fe of P)ye+=Fe;ye/=P.length;let ve=0;for(const Fe of P)ve+=(Fe-ye)**2;V=Math.sqrt(ve/(P.length-1))}const I=Number(j.periodsPerYear)>0?Number(j.periodsPerYear):null;let D=b[0],se=0,ce=0,Oe=0,ke=0;for(let ye=1;ye<y;ye++){if(b[ye]>D){D=b[ye],se=ye;continue}if(D<=0)continue;const ve=(D-b[ye])/D;ve>ce&&(ce=ve,Oe=se,ke=ye)}let je=null;if(y>2){let ye=0;for(let Ie=0;Ie<y;Ie++)ye+=b[Ie];ye/=y;let ve=0,Fe=0;for(let Ie=0;Ie<y;Ie++){const De=b[Ie]-ye;Fe+=De*De,Ie>0&&(ve+=De*(b[Ie-1]-ye))}je=Fe>0?ve/Fe:null}let be=0,Ae=0;for(const ye of P)ye>0?be++:ye<0&&Ae++;let Pe=null;if(O>0&&k>0){const ye=(k/O)**(1/(y-1))-1;Pe=I?(1+ye)**I-1:ye}return{n:y,first:O,last:k,change:k-O,changePercent:O===0?null:(k-O)/Math.abs(O)*100,volatility:V,annualisedVolatility:V!==null&&I?V*Math.sqrt(I):null,growth:Pe,maxDrawdown:ce,maxDrawdownFrom:Oe,maxDrawdownTo:ke,autocorrelation:je,upDays:be,downDays:Ae}}const ot=1.128,st=3.267;function wt(b){const j=b.length;if(j<2)return null;const y=[];for(let k=1;k<j;k++)y.push(Math.abs(b[k]-b[k-1]));const O=y.reduce((k,P)=>k+P,0)/y.length;return{ranges:y,centre:O,upper:st*O,lower:0}}function xe(b){const j=b.length;if(j<2)return null;let y=0;for(let k=1;k<j;k++)y+=Math.abs(b[k]-b[k-1]);const O=y/(j-1);return{sigma:O/ot,meanRange:O}}function Ot(b,j){const y=b.length;if(y<2||!j)return null;const O=Number.isFinite(Number(j.lower))?Number(j.lower):null,k=Number.isFinite(Number(j.upper))?Number(j.upper):null;if(O===null&&k===null)return null;let P=0;for(let be=0;be<y;be++)P+=b[be];P/=y;let V=0;for(let be=0;be<y;be++)V+=(b[be]-P)**2;const I=Math.sqrt(V/(y-1)),D=xe(b),se=D?D.sigma:null,ce=be=>{if(!be||be<=0)return{index:null,k:null};const Pe=O!==null&&k!==null?(k-O)/(6*be):null,ye=k!==null?(k-P)/(3*be):1/0,ve=O!==null?(P-O)/(3*be):1/0;return{index:Pe,k:Math.min(ye,ve)}},Oe=ce(se),ke=ce(I);let je=0;for(let be=0;be<y;be++){if(O!==null&&b[be]<O){je++;continue}k!==null&&b[be]>k&&je++}return{n:y,mean:P,lower:O,upper:k,target:Number.isFinite(Number(j.target))?Number(j.target):null,sigmaWithin:se,sigmaOverall:I,cp:Oe.index,cpk:Oe.k,pp:ke.index,ppk:ke.k,outOfSpec:je,defectRate:y?je/y:null}}function kt(b){const j=b.length;if(j<2)return null;const y=xe(b);if(!y||!(y.sigma>0))return null;let O=0;for(let k=0;k<j;k++)O+=b[k];return O/=j,{centre:O,sigma:y.sigma,upper:O+3*y.sigma,lower:O-3*y.sigma}}function ut(b,j){if(!j||!(j.sigma>0))return[];const y=b.length,{centre:O,sigma:k}=j,P=I=>(b[I]-O)/k,V=[];for(let I=0;I<y;I++){if(Math.abs(P(I))>3&&V.push({index:I,rule:1,description:"beyond three sigma"}),I>=2)for(const D of[1,-1]){let se=0;for(let ce=I-2;ce<=I;ce++)P(ce)*D>2&&se++;if(se>=2){V.push({index:I,rule:2,description:"two of three past two sigma"});break}}if(I>=4)for(const D of[1,-1]){let se=0;for(let ce=I-4;ce<=I;ce++)P(ce)*D>1&&se++;if(se>=4){V.push({index:I,rule:3,description:"four of five past one sigma"});break}}if(I>=7)for(const D of[1,-1]){let se=!0;for(let ce=I-7;ce<=I;ce++)if(P(ce)*D<=0){se=!1;break}if(se){V.push({index:I,rule:4,description:"eight in a row on one side"});break}}}return V}function ct(b,j){if(!j||!(j.sigma>0))return[];const y=b.length,{centre:O,sigma:k}=j,P=D=>(b[D]-O)/k,V=(D,se,ce,Oe)=>{for(const ke of[1,-1]){let je=0;for(let be=D;be<=se;be++)P(be)*ke>ce&&je++;if(je>=Oe)return!0}return!1},I=[];for(let D=0;D<y;D++){if(Math.abs(P(D))>3&&I.push({index:D,rule:1,description:"beyond three sigma"}),D>=8)for(const se of[1,-1]){let ce=!0;for(let Oe=D-8;Oe<=D;Oe++)if(P(Oe)*se<=0){ce=!1;break}if(ce){I.push({index:D,rule:2,description:"nine in a row on one side"});break}}if(D>=5)for(const se of[1,-1]){let ce=!0;for(let Oe=D-4;Oe<=D;Oe++)if((b[Oe]-b[Oe-1])*se<=0){ce=!1;break}if(ce){I.push({index:D,rule:3,description:se>0?"six rising":"six falling"});break}}if(D>=13){let se=!0;for(let ce=D-12;ce<=D;ce++){const Oe=b[ce]-b[ce-1],ke=b[ce+1<=D?ce+1:ce]-b[ce];if(ce+1>D)break;if(Oe===0||ke===0||Oe>0==ke>0){se=!1;break}}se&&I.push({index:D,rule:4,description:"fourteen alternating"})}if(D>=2&&V(D-2,D,2,2)&&I.push({index:D,rule:5,description:"two of three past two sigma"}),D>=4&&V(D-4,D,1,4)&&I.push({index:D,rule:6,description:"four of five past one sigma"}),D>=14){let se=!0;for(let ce=D-14;ce<=D;ce++)if(Math.abs(P(ce))>=1){se=!1;break}se&&I.push({index:D,rule:7,description:"fifteen within one sigma"})}if(D>=7){let se=!0;for(let ce=D-7;ce<=D;ce++)if(Math.abs(P(ce))<=1){se=!1;break}se&&I.push({index:D,rule:8,description:"eight beyond one sigma"})}}return I}const jt=Object.freeze(["westernElectric","nelson"]);function At(b,j,y="westernElectric"){return String(y)==="nelson"?ct(b,j):ut(b,j)}function Mt(b,j,y){let O=0;for(let k=0;k<b.length;k++)(b[k]<j||b[k]>y)&&O++;return O}function Pt(b,j,y,O=20){const k=b.length;if(!k)return[];const P=b[0],V=b[k-1];if(V===P)return[{from:P,to:V,count:k}];const I=y-j,D=1.5*I;let se=I>0?Math.max(P,j-D):P,ce=I>0?Math.min(V,y+D):V;ce>se||(se=P,ce=V);const Oe=I>0?2*I/Math.cbrt(k):(ce-se)/(Math.ceil(Math.log2(k))+1),ke=Oe>0?Math.min(O,Math.max(1,Math.ceil((ce-se)/Oe))):1,je=(ce-se)/ke,be=[];for(let Ae=0;Ae<ke;Ae++)be.push({from:se+Ae*je,to:se+(Ae+1)*je,count:0});for(let Ae=0;Ae<k;Ae++){const Pe=Math.min(ke-1,Math.max(0,Math.floor((b[Ae]-se)/je)));be[Pe].count++}return be[0].from=P,be[ke-1].to=V,be}const Ge=.95;function Qe(b){const j=Number(b);return Number.isFinite(j)&&j>0&&j<1?j:Ge}function Nt(b,j=Ge){const y=b.length;if(y<2)return null;let O=0;for(let ce=0;ce<y;ce++)O+=b[ce];const k=O/y;let P=0;for(let ce=0;ce<y;ce++){const Oe=b[ce]-k;P+=Oe*Oe}const V=Math.sqrt(P/(y-1)),I=Qe(j),se=ne(1-(1-I)/2,y-1)*V/Math.sqrt(y);return{mean:k,lower:k-se,upper:k+se,margin:se,n:y,confidence:I}}function St(b,j,y=Ge){const O=Number(b),k=Number(j);if(!(k>0)||!(O>=0)||O>k)return null;const P=Qe(y),V=T(1-(1-P)/2),I=O/k,D=V*V,se=1+D/k,ce=(I+D/(2*k))/se,Oe=V/se*Math.sqrt(I*(1-I)/k+D/(4*k*k));return{proportion:I,lower:Math.max(0,ce-Oe),upper:Math.min(1,ce+Oe),n:k,confidence:P}}function vt(b,j=Ge){if(!b||!(b.n>2)||!Number.isFinite(b.stdError))return null;const y=Qe(j),k=ne(1-(1-y)/2,b.n-2)*b.stdError;return{slope:b.slope,lower:b.slope-k,upper:b.slope+k,margin:k,confidence:y}}function Tt(b,j,y=Ge){const O=Number(b),k=Number(j);if(!Number.isFinite(O)||!(k>1))return null;const P=Qe(y),I=T(1-(1-P)/2)*Math.sqrt(1/(9*k)+O*O/(2*(k-1)));return{index:O,lower:O-I,upper:O+I,margin:I,n:k,confidence:P}}function lt(b,j){return!b||!(b.sd>0)||!Number.isFinite(j)||!Number.isFinite(b.mean)?null:(j-b.mean)/b.sd}function at(b){return Number.isFinite(b)?Math.min(1,Math.max(0,2*K(Math.abs(b)/2)-1)):0}function _e(b,j){const y=new Map,O=Q(b);let k=0;for(let P=0;P<j.length;P++){const V=O(j[P]);if(V==null||V===""||typeof V=="number"&&Number.isNaN(V))continue;const I=V instanceof Date?V.getTime():typeof V=="object"?String(V):V;y.set(I,(y.get(I)||0)+1),k++}return{map:y,total:k}}function ft(b,j,y,O){if(!(j>0)||!(O>0))return null;let k=0;const P=new Set(b.keys());for(const V of y.keys())P.add(V);for(const V of P){const I=(b.get(V)||0)/j,D=(y.get(V)||0)/O;k+=Math.abs(I-D)}return k/2}const et=10;function Et(b,j,y){if(y&&y.numeric){const I=f(b,j),{n:D,mean:se}=r(I),ce=D>0?lt({mean:y.mean,sd:y.sd},se):null;return{measure:"standardizedMeanDifference",magnitude:ce,distance:ce===null?0:at(ce),direction:ce===null?0:Math.sign(ce),subsetN:D,populationN:y.n||0,reliable:D>=et}}const{map:k,total:P}=_e(b,j),V=ft(k,P,y.map,y.total);return{measure:"categoricalTotalVariation",magnitude:V,distance:V===null?0:V,direction:0,subsetN:P,populationN:y.total||0,reliable:P>=et}}function ht(b,j){if(b&&(b.kind==="float64"||b.kind==="int32"))return!0;const y=Q(b);let O=0,k=0;for(let P=0;P<j.length&&O<200;P++){const V=y(j[P]);if(V==null||V==="")continue;if(V instanceof Date)return!1;O++;const I=typeof V=="number"?V:Number(V);Number.isFinite(I)&&k++}return O===0?!1:k/O>=.9}function Rt(b,j){if(ht(b,j)){const k=f(b,j),{n:P,mean:V,m2:I}=r(k);return{numeric:!0,mean:V,sd:P>0?Math.sqrt(I/P):0,n:P}}const{map:y,total:O}=_e(b,j);return{numeric:!1,map:y,total:O}}}),Se("packages/core/src/compute/total.js",function(o,me){"use strict";Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return l}}),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 h}});const fe=me("packages/core/src/internal/util.js"),he=fe.isFunction,Q=fe.warnOnce,z=me("packages/core/src/compute/handle.js"),ne=z.presenceReader,_=z.valueComparator,T=z.valueReader,K=me("packages/core/src/compute/statistics.js"),ie=K.STAT_FNS,J=K.STAT_LABELS;function le(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function ue(r,n){const c=n.length;let g=0;if(le(r)){const N=r.values,G=ne(r);if(!G){for(let F=0;F<c;F++){const R=N[n[F]];Number.isNaN(R)||(g+=R)}return g}for(let F=0;F<c;F++){const R=n[F];if(G(R)===1){const X=N[R];Number.isNaN(X)||(g+=X)}}return g}const M=T(r);for(let N=0;N<c;N++){const G=u(M(n[N]));G!==null&&(g+=G)}return g}ue.kernel=!0;function W(r,n){const c=n.length;let g=0;if(le(r)){const N=r.values,G=ne(r);if(!G){for(let F=0;F<c;F++)Number.isNaN(N[n[F]])||g++;return g}for(let F=0;F<c;F++){const R=n[F];G(R)===1&&!Number.isNaN(N[R])&&g++}return g}const M=T(r);for(let N=0;N<c;N++){const G=M(n[N]);G!=null&&!(typeof G=="number"&&Number.isNaN(G))&&g++}return g}W.kernel=!0;function L(r,n){return n.length}L.kernel=!0;function Y(r,n){const c=W(r,n);return c===0?null:ue(r,n)/c}Y.kernel=!0;function ee(r,n,c,g){const M=n.length;if(le(r)){const R=r.values,X=ne(r);let E=null;if(!X){for(let S=0;S<M;S++){const U=R[n[S]];Number.isNaN(U)||(E===null||(c<0?U<E:U>E))&&(E=U)}return E}for(let S=0;S<M;S++){const U=n[S];if(X(U)===0)continue;const H=R[U];Number.isNaN(H)||(E===null||(c<0?H<E:H>E))&&(E=H)}return E}const N=T(r),G=_(g);let F=null;for(let R=0;R<M;R++){const X=N(n[R]);X==null||typeof X=="number"&&Number.isNaN(X)||(F===null||(c<0?G(X,F)<0:G(X,F)>0))&&(F=X)}return F}function C(r,n,c){return ee(r,n,-1,c&&c.locale)}C.kernel=!0;function A(r,n,c){return ee(r,n,1,c&&c.locale)}A.kernel=!0;function i(r,n){return n.length===0?null:T(r)(n[0])}i.kernel=!0;function s(r,n){return n.length===0?null:T(r)(n[n.length-1])}s.kernel=!0;function u(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 f={sum:ue,min:C,max:A,avg:Y,count:L,first:i,last:s,countValues:W,...ie},l=Object.freeze({...J,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"?l[r]||r:"Total":""}const a=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=a.filter(g=>g in f);for(const g of Object.keys(f))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=T(r),g=[];for(let M=0;M<n.length;M++){const N=c(n[M]);N!=null&&g.push(N)}return g}function h(r,n,c,g){const M=n||[];if(typeof c=="string"){const N=f[c];return N?N(r,M,g):(Q(`total:${c}`,`unknown total function "${c}"; register it in config.totalFns`),null)}return he(c)?c.kernel===!0?c(r,M,g):c(d(r,M),g||{}):null}}),Se("packages/core/src/compute/pivot.js",function(o,me){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return A}});const he=me("packages/core/src/internal/util.js").warnOnce,z=me("packages/core/src/compute/handle.js").valueComparator,_=me("packages/core/src/compute/group.js").packKeys,K=me("packages/core/src/compute/total.js").total,ie="|",J="/",le=2e3;function ue(u,f,l){return`${u}${ie}${f}${ie}${l}`}function W(u,f){let l="";for(let t=0;t<u.length;t++){const a=u[t];l+=(t===0?"":f)+(a==null?"":String(a))}return l}function L(u,f,l={}){const t=l.separator||J,a=f.length,{keyOf:m,readers:e}=_(u,f,0),d=new Map,h=[],r=[];for(let F=0;F<a;F++){const R=f[F],X=m(R);if(d.has(X))continue;d.set(X,h.length),r.push(X);const E=new Array(e.length);for(let S=0;S<e.length;S++)E[S]=e[S](R);h.push(E)}const n=z(l.locale),c=h.map((F,R)=>R);c.sort((F,R)=>{const X=h[F],E=h[R];for(let S=0;S<X.length;S++){const U=Y(X[S],E[S],n);if(U!==0)return U}return F-R});const g=new Array(c.length),M=new Array(c.length),N=new Map;for(let F=0;F<c.length;F++){const R=c[F];g[F]=h[R],M[F]=W(h[R],t),N.set(r[R],F)}return{keys:g,paths:M,idOf:F=>{const R=N.get(m(F));return R===void 0?-1:R}}}function Y(u,f,l){const t=u==null,a=f==null;return t||a?t&&a?0:t?1:-1:l(u,f)}function ee(u){const f=u.values||u.totals||[];if(f.length&&typeof f[0]=="object"&&f[0]!==null)return f.filter(m=>m&&m.handle);const l=typeof u.handle=="function"?u.handle:null;if(!l)return f.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 u.totalOf=="function"?u.totalOf:null,a=[];for(const m of f){const e=l(m);e&&a.push({colId:m,handle:e,fn:t?t(m):"sum"})}return a}function C(u,f,l){if(Array.isArray(u)){const t=l||{};return{...t,pivotHandles:u,order:f||null,groups:t.groups||null}}return u||{}}function A(u,f,l){const t=C(u,f,l),a=t.separator||J,m=ee(t),e=t.maxColumns===void 0?le:t.maxColumns,d=t.groups&&t.groups.buckets?t.groups:null,h=d?d.buckets:[t.order||new Uint32Array(0)],r=t.groupPaths||(d?d.keys.map(X=>W(X,a)):[""]),n=s(h),{keys:c,paths:g,idOf:M}=L(t.pivotHandles||[],n,t),N=g.length*Math.max(1,m.length),G=i(g,m,a);if(e&&N>e){const X=new Map;return{keys:c,paths:g,fields:G,groupPaths:r,columns:N,values:X,cells:X,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${N} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:N,maxColumns:e}}}const F=new Map,R=g.length;for(let X=0;X<h.length;X++){const E=h[X],S=r[X]===void 0?"":r[X],U=E.length;if(U===0)continue;const H=new Int32Array(U),$=new Uint32Array(R+1);for(let ae=0;ae<U;ae++){const p=M(E[ae]);H[ae]=p,p>=0&&$[p+1]++}for(let ae=0;ae<R;ae++)$[ae+1]+=$[ae];const re=new Uint32Array(U),te=$.slice(0,R);for(let ae=0;ae<U;ae++){const p=H[ae];p>=0&&(re[te[p]++]=E[ae])}for(let ae=0;ae<R;ae++){const p=$[ae],B=$[ae+1];if(B===p)continue;const q=re.subarray(p,B);for(let oe=0;oe<m.length;oe++){const w=m[oe],v=K(w.handle,q,w.fn,t.totalContext||{locale:t.locale});F.set(ue(S,g[ae],w.colId),v)}}}return{keys:c,paths:g,fields:G,groupPaths:r,columns:N,values:F,cells:F,error:null}}function i(u,f,l){if(f.length===0)return u.slice();const t=[];for(const a of u)for(const m of f)t.push(`${a}${l}${m.colId}`);return t}function s(u){if(u.length===1)return u[0]||new Uint32Array(0);let f=0;for(const a of u)f+=a?a.length:0;const l=new Uint32Array(f);let t=0;for(const a of u)!a||a.length===0||(l.set(a,t),t+=a.length);return l}}),Se("packages/core/src/compute/pivotmatrix.js",function(o,me){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return A}});const he=me("packages/core/src/compute/handle.js").valueComparator,z=me("packages/core/src/compute/total.js").total,_=me("packages/core/src/compute/group.js").packKeys,T=me("packages/core/src/compute/pivot.js"),K=T.joinPath,ie=T.DEFAULT_PATH_SEPARATOR,J=T.DEFAULT_MAX_COLUMNS,le="";function ue(i,s,u={}){const f=u.separator||ie,l=i||[],t=s instanceof Uint32Array?s:Uint32Array.from(s||[]),a=t.length;if(l.length===0)return{tuples:[[]],paths:[le],buckets:[t]};const{keyOf:m,readers:e}=_(l,t,0),d=new Map,h=[],r=[],n=[];for(let F=0;F<a;F++){const R=t[F],X=m(R);let E=d.get(X);if(E===void 0){E=h.length,d.set(X,E),r.push(X);const S=new Array(e.length);for(let U=0;U<e.length;U++)S[U]=e[U](R);h.push(S),n.push([])}n[E].push(R)}const c=he(u.locale),g=h.map((F,R)=>R);g.sort((F,R)=>{const X=h[F],E=h[R];for(let S=0;S<X.length;S++){const U=W(X[S],E[S],c);if(U!==0)return U}return F-R});const M=new Array(g.length),N=new Array(g.length),G=new Array(g.length);for(let F=0;F<g.length;F++){const R=g[F];M[F]=h[R],N[F]=K(h[R],f),G[F]=Uint32Array.from(n[R])}return{tuples:M,paths:N,buckets:G}}function W(i,s,u){const f=i==null,l=s==null;return f||l?f&&l?0:f?1:-1:u(i,s)}function L(i,s,u){const f=[];for(let l=0;l<i.length;l++)u.has(i[l])&&f.push(i[l]);return Uint32Array.from(f)}function Y(i,s,u,f){return{value:s.length?z(i,s,u,f):null,leaves:s,count:s.length}}function ee(i){const s=i&&i.opts||{},u=s.separator||ie,f=s.totalContext||{locale:s.locale},l=(i.measures||[]).filter(N=>N&&N.handle),t=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),a=ue(i.rowHandles||[],t,{...s,separator:u}),m=ue(i.columnHandles||[],t,{...s,separator:u}),e=s.maxColumns===void 0?J:s.maxColumns,d=m.paths.length*Math.max(1,l.length),h=new Map;if(e&&d>e)return{rowAxis:a,columnAxis:m,measures:l.map(N=>({colId:N.colId,fn:N.fn})),body:h,rowMargin:h,columnMargin:h,grand:h,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,M=m.buckets.map(N=>new Set(N));for(let N=0;N<m.paths.length;N++){const G=m.buckets[N],F=m.paths[N];for(const R of l)c.set(A(F,R.colId),Y(R.handle,G,R.fn,f))}for(let N=0;N<a.paths.length;N++){const G=a.buckets[N],F=a.paths[N];for(const R of l)n.set(A(F,R.colId),Y(R.handle,G,R.fn,f));for(let R=0;R<m.paths.length;R++){const X=L(G,m.buckets[R],M[R]);if(X.length===0)continue;const E=m.paths[R];for(const S of l)r.set(C(F,E,S.colId),Y(S.handle,X,S.fn,f))}}for(const N of l)g.set(N.colId,Y(N.handle,t,N.fn,f));return{rowAxis:a,columnAxis:m,measures:l.map(N=>({colId:N.colId,fn:N.fn})),body:r,rowMargin:n,columnMargin:c,grand:g,columns:d,error:null}}function C(i,s,u){return`${i}\\0${s}\\0${u}`}function A(i,s){return`${i}\\0${s}`}}),Se("packages/core/src/compute/reference.js",function(o,me){"use strict";Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ee}});const he=me("packages/core/src/internal/util.js").getPath,Q=me("packages/core/src/compute/handle.js"),z=Q.isMissing,ne=Q.valueComparator,T=me("packages/core/src/compute/filter.js").testValue,K="",ie="\\0";function J(i,s){const u=s.includes(".")?he(i,s):i?.[s];return u===void 0?null:u}function le(i,s,u={}){const f=s||[];let l=i.map((t,a)=>a);if(f.length===0)return l;for(let t=f.length-1;t>=0;t--)l=ue(i,l,f[t],u);return l}function ue(i,s,u,f){const l=u.locale!==void 0?u.locale:f.locale,t=ne(l),a=u.descending!==void 0?!!u.descending:u.dir==="desc",m=[],e=[];for(const r of s){const n=J(i[r],u.col);z(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 h=(r,n)=>{const c=J(i[r],u.col),g=J(i[n],u.col);let M;return typeof u.compare=="function"?(M=u.compare(c,g,i[r],i[n],a),a&&(M=-M)):M=a?t(g,c):t(c,g),M!==0?M:d.get(r)-d.get(n)};return m.sort(h),u.nullsFirst?e.concat(m):m.concat(e)}function W(i,s,u={}){const f=[];for(let l=0;l<i.length;l++)L(i[l],s,u,l)&&f.push(l);return f}function L(i,s,u,f){if(!s)return!0;if(Array.isArray(s.conditions)){const l=s.conditions.filter(a=>a!=null);if(l.length===0)return!0;if(s.op==="or")return l.some(a=>L(i,a,u,f));const t=l.every(a=>L(i,a,u,f));return s.op==="not"?!t:t}return s.col===void 0&&typeof u.custom=="function"?!!u.custom(s,i,f):T(J(i,s.col),s,u.locale)}function Y(i,s,u,f){const l=u||i.map((e,d)=>d),t=new Map,a=[],m=[];for(const e of l){const d=s.map((n,c)=>{const g=J(i[e],n);return f&&f[c]?f[c](g):g}),h=d.map(n=>n==null?ie:String(n)).join(K);let r=t.get(h);r===void 0&&(r=a.length,t.set(h,r),a.push(d),m.push([])),m[r].push(e)}return{keys:a,buckets:m}}function ee(i,s,u={}){const f=ne(u.locale),l=i.filter(a=>!z(a)),t=l.map(C).filter(a=>a!==null);switch(s){case"count":return i.length;case"countValues":return l.length;case"sum":return t.reduce((a,m)=>a+m,0);case"avg":return l.length===0?null:t.reduce((a,m)=>a+m,0)/l.length;case"min":return l.length===0?null:l.reduce((a,m)=>f(m,a)<0?m:a);case"max":return l.length===0?null:l.reduce((a,m)=>f(m,a)>0?m:a);case"first":return i.length===0?null:A(i[0]);case"last":return i.length===0?null:A(i[i.length-1]);default:return null}}function C(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 s=Number(i);return Number.isNaN(s)?null:s}function A(i){return i===void 0?null:i}}),Se("packages/core/src/compute/windowed.js",function(o,me){"use strict";Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return _}});const he=me("packages/core/src/compute/sketch.js").Welford;class Q{#t;#e;#n=[];#r;#i;constructor(K,ie=0,J=Date.now){if(K!=="count"&&K!=="time"&&K!=="session")throw new RangeError(`unknown window kind: ${K}`);if((K==="count"||K==="time")&&!(ie>0))throw new RangeError(`a ${K} window needs a positive span`);this.#t=K,this.#e=Math.floor(ie),this.#r=J,this.#i=J()}get size(){return this.#n.length}push(K,ie=this.#r()){Number.isFinite(K)&&(this.#n.push({t:ie,v:K}),this.#s(ie))}#s(K){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const ie=K-this.#e;for(;this.#n.length&&this.#n[0].t<ie;)this.#n.shift()}}spec(){const K=this.#t==="session"?this.#r()-this.#i:this.#e;return{kind:this.#t,span:K,size:this.#n.length}}values(){return this.#n.map(K=>K.v)}aggregate(){const K=this.spec();if(!this.#n.length)return{over:K,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const ie=new he;let J=0,le=1/0,ue=-1/0;for(const{v:W}of this.#n)J+=W,W<le&&(le=W),W>ue&&(ue=W),ie.add(W);return{over:K,count:this.#n.length,sum:J,mean:ie.mean(),min:le,max:ue,variance:ie.variance(),stddev:ie.stddev()}}reduce(K){const ie=this.aggregate(),J={sum:ie.sum,avg:ie.mean,mean:ie.mean,min:ie.min,max:ie.max,count:ie.count,variance:ie.variance,stddev:ie.stddev};if(!(K in J))throw new RangeError(`unknown windowed aggregate: ${K}`);return{value:J[K],over:ie.over}}}const z=Object.freeze(["count","time","session"]);function ne(T,K=Date.now){const ie=T.kind==="time"&&T.minutes!=null?T.minutes*6e4:T.span??0;return new Q(T.kind,ie,K)}const _={Window:Q,WINDOW_KINDS:z,openWindow:ne}}),Se("packages/core/src/compute/anomaly.js",function(o,me){"use strict";Object.defineProperty(o,"MAD_SCALE",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return f}});const he=me("packages/core/src/compute/statistics.js").quantileSorted,z=me("packages/core/src/compute/special.js").logGamma,ne=.6745,_=3.5,T=1.5,K=.975,ie=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function J(l){if(!l.length)return null;const a=Array.from(l,Number).sort((h,r)=>h-r),m=he(a,.5),e=a.map(h=>Math.abs(h-m)).sort((h,r)=>h-r),d=he(e,.5);return{median:m,mad:d}}function le(l,t={}){const a=Number.isFinite(t.threshold)?t.threshold:_,m=l.length,e=new Array(m).fill(null),d=new Array(m).fill(!1),h=[];for(let c=0;c<m;c++){const g=Number(l[c]);Number.isFinite(g)&&h.push(g)}if(!h.length)return{median:null,mad:null,threshold:a,scores:e,flags:d,flagged:0};const r=J(h);if(r.mad===0)return{median:r.median,mad:0,threshold:a,scores:e,flags:d,flagged:0};let n=0;for(let c=0;c<m;c++){const g=Number(l[c]);if(!Number.isFinite(g))continue;const M=ne*(g-r.median)/r.mad;e[c]=M,Math.abs(M)>a&&(d[c]=!0,n++)}return{median:r.median,mad:r.mad,threshold:a,scores:e,flags:d,flagged:n}}function ue(l,t={}){const a=Number.isFinite(t.k)?t.k:T,m=[];for(let n=0;n<l.length;n++){const c=Number(l[n]);Number.isFinite(c)&&m.push(c)}if(!m.length)return null;const e=m.sort((n,c)=>n-c),d=he(e,.25),h=he(e,.75),r=h-d;return{q1:d,q3:h,iqr:r,lower:d-a*r,upper:h+a*r,k:a}}function W(l,t){if(t<=0)return 0;const a=z(l);if(t<l+1){let c=l,g=1/l,M=g;for(let N=0;N<1e3&&(c+=1,M*=t/c,g+=M,!(Math.abs(M)<Math.abs(g)*1e-15));N++);return g*Math.exp(-t+l*Math.log(t)-a)}const m=1e-300;let e=t+1-l,d=1/m,h=1/e,r=h;for(let c=1;c<1e3;c++){const g=-c*(c-l);e+=2,h=g*h+e,Math.abs(h)<m&&(h=m),d=e+g/d,Math.abs(d)<m&&(d=m),h=1/h;const M=h*d;if(r*=M,Math.abs(M-1)<1e-15)break}return 1-Math.exp(-t+l*Math.log(t)-a)*r}function L(l,t){return l<=0?0:W(t/2,l/2)}function Y(l,t=K){if(!(t>0)||!(t<1))return NaN;let a=0,m=Math.max(1,l);for(;L(m,l)<t;)m*=2;for(let e=0;e<200;e++){const d=(a+m)/2;if(L(d,l)<t?a=d:m=d,m-a<1e-10)break}return(a+m)/2}function ee(l){const t=l.length,a=l.map((m,e)=>{const d=m.slice();for(let h=0;h<t;h++)d.push(e===h?1:0);return d});for(let m=0;m<t;m++){let e=m;for(let h=m+1;h<t;h++)Math.abs(a[h][m])>Math.abs(a[e][m])&&(e=h);if(Math.abs(a[e][m])<1e-12)return null;if(e!==m){const h=a[e];a[e]=a[m],a[m]=h}const d=a[m][m];for(let h=0;h<2*t;h++)a[m][h]/=d;for(let h=0;h<t;h++){if(h===m)continue;const r=a[h][m];if(r!==0)for(let n=0;n<2*t;n++)a[h][n]-=r*a[m][n]}}return a.map(m=>m.slice(t))}function C(l,t){const a=l.length,m=new Array(t).fill(0);for(const h of l)for(let r=0;r<t;r++)m[r]+=h[r];for(let h=0;h<t;h++)m[h]/=a;const e=Array.from({length:t},()=>new Array(t).fill(0));for(const h of l)for(let r=0;r<t;r++){const n=h[r]-m[r];for(let c=r;c<t;c++)e[r][c]+=n*(h[c]-m[c])}const d=a>1?a-1:1;for(let h=0;h<t;h++)for(let r=h;r<t;r++)e[h][r]/=d,e[r][h]=e[h][r];return{mean:m,cov:e}}function A(l,t={}){const a=Number.isFinite(t.p)?t.p:K,m=Number.isFinite(t.ridge)?t.ridge:1e-6,e=l.length;if(!e)return null;const d=l[0].length;if(!d)return null;const h=new Array(e).fill(null),r=new Array(e).fill(null),n=new Array(e).fill(!1),c=[],g=[];for(let S=0;S<e;S++){const U=l[S];let H=U.length===d;const $=new Array(d);for(let re=0;H&&re<d;re++){const te=Number(U[re]);Number.isFinite(te)?$[re]=te:H=!1}H&&(c.push(S),g.push($))}const M=d,N=Y(M,a);if(g.length<=d)return{center:[],df:M,cutoff:N,singular:!0,used:g.length,distances:h,squared:r,flags:n,flagged:0};const{mean:G,cov:F}=C(g,d);let R=ee(F),X=!1;if(!R){X=!0;let S=0;for(let $=0;$<d;$++)S+=F[$][$];const U=S/d*m||m,H=F.map(($,re)=>$.map((te,ae)=>re===ae?te+U:te));if(R=ee(H),!R)return{center:G,df:M,cutoff:N,singular:!0,used:g.length,distances:h,squared:r,flags:n,flagged:0}}let E=0;for(let S=0;S<g.length;S++){const U=g[S],H=new Array(d);for(let te=0;te<d;te++)H[te]=U[te]-G[te];let $=0;for(let te=0;te<d;te++){let ae=0;for(let p=0;p<d;p++)ae+=R[te][p]*H[p];$+=H[te]*ae}$<0&&($=0);const re=c[S];r[re]=$,h[re]=Math.sqrt($),$>N&&(n[re]=!0,E++)}return{center:G,df:M,cutoff:N,singular:X,used:g.length,distances:h,squared:r,flags:n,flagged:E}}const i=20,s=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function u(l,t={}){const a=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:_,d=Number.isFinite(t.k)?t.k:T,h=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):m,r=l.length,n=new Array(r).fill(null),c=new Array(r).fill(!1);let g=0;for(let M=0;M<r;M++){const N=Number(l[M]);if(!Number.isFinite(N))continue;const G=Math.max(0,M-m+1),F=[];for(let R=G;R<=M;R++){const X=Number(l[R]);Number.isFinite(X)&&F.push(X)}if(!(F.length<h))if(a==="rollingIqr"){const R=ue(F,{k:d});if(!R)continue;(N<R.lower||N>R.upper)&&(c[M]=!0,g++)}else{const R=J(F);if(!R||R.mad===0)continue;const X=ne*(N-R.median)/R.mad;n[M]=X,Math.abs(X)>e&&(c[M]=!0,g++)}}return{method:a,windowLen:m,minPeriods:h,threshold:e,k:d,scores:n,flags:c,flagged:g}}function f(l={}){const t=l||{},a=t.field;if(typeof a!="string"||!a)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const m=t.method||"modifiedZScore";if(!(ie.includes(m)||s.includes(m))||m==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method \'${m}\'`);const d=typeof t.orderBy=="string"?t.orderBy:null,h=t.latest===!0,r=s.includes(m),n=c=>Number(c==null?NaN:c[a]);return c=>{const g=Array.isArray(c)?c.slice():[...c];d&&g.sort((R,X)=>{const E=R?.[d],S=X?.[d];return E===S?0:E==null?-1:S==null?1:E<S?-1:1});const M=g.map(n);let N,G;if(r)({flags:N,scores:G}=u(M,{method:m,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(m==="iqr"){const R=ue(M,{k:t.k});N=M.map(X=>R?Number.isFinite(X)&&(X<R.lower||X>R.upper):!1),G=M.map(()=>null)}else({flags:N,scores:G}=le(M,{threshold:t.threshold}));if(h){const R=N.length-1;return R<0||!N[R]?!1:{method:m,field:a,flagged:[{row:g[R],score:G[R]}]}}const F=[];for(let R=0;R<N.length;R++)N[R]&&F.push({row:g[R],score:G[R]});return F.length?{method:m,field:a,flagged:F}:!1}}}),Se("packages/core/src/compute/forecast.js",function(o,me){"use strict";Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return l}});const fe=me("packages/core/src/compute/special.js"),he=fe.normalQuantile,Q=fe.studentTQuantile,ne=me("packages/core/src/internal/util.js").warnOnce,_=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),T=1e-4,K=1-1e-4;function ie(t){const a=[];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,h=Number.isFinite(e.value)?e.value:null;a.push({at:d,value:h})}else a.push({at:m,value:Number.isFinite(e)?Number(e):null})}return a}function J(t){const a=t.filter(r=>r.value!==null),m=a[0],e=a[a.length-1],d=e.at-m.at,h=a.length>1&&d>0?d/(a.length-1):1;return{lastAt:e.at,step:h}}function le(t){return Math.min(K,Math.max(T,t))}function ue(t,a=T,m=K,e=80){const d=(Math.sqrt(5)-1)/2;let h=a,r=m,n=r-d*(r-h),c=h+d*(r-h),g=t(n),M=t(c);for(let N=0;N<e;N++)g<M?(r=c,c=n,M=g,n=r-d*(r-h),g=t(n)):(h=n,n=c,g=M,c=h+d*(r-h),M=t(c));return(h+r)/2}function W(t,a){let m=null,e=0,d=0;for(let h=0;h<t.length;h++){const r=t[h];if(r!==null){if(m===null){m=r;continue}e+=(r-m)**2,d+=1,m=a*r+(1-a)*m}}return{level:m,sse:e,m:d}}function L(t,a,m){let e=null,d=null,h=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;h+=(c-g)**2,r+=1;const M=e;e=a*c+(1-a)*(M+d),d=m*(e-M)+(1-m)*d}return{level:e,trend:d,sse:h,m:r}}function Y(t,a,m,e,d){const h=t.length;if(h<2*a)return null;const r=X=>{let E=0,S=0;for(let U=X;U<X+a&&U<h;U++)t[U]!==null&&(E+=t[U],S+=1);return S?E/S:null},n=r(0),c=r(a);if(n===null||c===null)return null;let g=n,M=(c-n)/a;const N=new Array(a).fill(0);for(let X=0;X<a;X++)N[X]=t[X]===null?0:t[X]-g;const G=N.reduce((X,E)=>X+E,0)/a;for(let X=0;X<a;X++)N[X]-=G;let F=0,R=0;for(let X=a;X<h;X++){const E=X%a,S=N[E],U=t[X];if(U===null){g+=M;continue}const H=g+M+S;F+=(U-H)**2,R+=1;const $=g;g=m*(U-S)+(1-m)*(g+M),M=e*(g-$)+(1-e)*M,N[E]=d*(U-g)+(1-d)*S}return{level:g,trend:M,season:N,phase:(h-1)%a,sse:F,count:R}}function ee(t,a,m){let e=1;for(const h of a)e+=h*h;const d=Math.sqrt(t*e);return{se:d,margin:m*d}}function C(t,a={}){if(!t||typeof t.length!="number"||t.length===0)return null;const m=_.includes(a.method)?a.method:"linear",e=Math.max(1,Math.floor(Number(a.horizon)||1)),d=Number.isFinite(a.confidence)&&a.confidence>0&&a.confidence<1?a.confidence:.95,h=1-(1-d)/2,r=ie(t),n=r.map(F=>F.value),c=n.filter(F=>F!==null),g=c.length,{lastAt:M,step:N}=g?J(r):{lastAt:0,step:1},G=F=>M+F*N;return m==="linear"?A(r,g,e,d,h,G):m==="movingAverage"?i(c,g,e,d,h,a,G):m==="ses"?s(n,g,e,d,h,a,G):m==="holt"?u(n,g,e,d,h,a,G):f(n,g,e,d,h,a,G)}function A(t,a,m,e,d,h){if(a<2)return null;let r=0,n=0;for(const U of t)U.value!==null&&(r+=U.at,n+=U.value);r/=a,n/=a;let c=0,g=0,M=0;for(const U of t){if(U.value===null)continue;const H=U.at-r,$=U.value-n;c+=H*H,g+=H*$,M+=$*$}if(c===0)return null;const N=g/c,G=n-N*r,F=M===0?1:Math.max(0,Math.min(1,g*g/(c*M))),R=Math.max(0,M-N*g),X=a>2?Math.sqrt(R/(a-2)):null,E=a>2?Q(d,a-2):null,S=[];for(let U=1;U<=m;U++){const H=h(U),$=G+N*H;let re=null,te=null,ae=null,p=null,B=null;if(X!==null){const q=1/a+(H-r)**2/c,oe=X*Math.sqrt(1+q),w=X*Math.sqrt(q);B=oe,re=$-E*oe,te=$+E*oe,ae=$-E*w,p=$+E*w}S.push({step:U,at:H,mean:$,lower:re,upper:te,lowerMean:ae,upperMean:p,se:B})}return{method:"linear",horizon:m,confidence:e,n:a,sigma:X,r2:F,params:{slope:N,intercept:G},points:S}}function i(t,a,m,e,d,h,r){if(a<1)return null;const n=Math.max(1,Math.min(a,Math.floor(Number(h.windowLen)||a))),c=t.slice(a-n);let g=0;for(const X of c)g+=X;const M=g/n;let N=null,G=null;if(n>1){let X=0;for(const S of c)X+=(S-M)**2;N=Math.sqrt(X/(n-1))*Math.sqrt(1+1/n),G=Q(d,n-1)}const F=N===null?null:G*N,R=[];for(let X=1;X<=m;X++)R.push({step:X,at:r(X),mean:M,lower:F===null?null:M-F,upper:F===null?null:M+F,se:N});return{method:"movingAverage",horizon:m,confidence:e,n:a,sigma:N===null?null:N,params:{windowLen:n},points:R}}function s(t,a,m,e,d,h,r){if(a<1)return null;let n=Number.isFinite(h.alpha)?le(h.alpha):null;n===null&&(n=ue(G=>W(t,G).sse));const c=W(t,n),g=he(d),M=c.m>0?c.sse/c.m:null,N=[];for(let G=1;G<=m;G++){const F=c.level;let R=null,X=null,E=null;if(M!==null){const S=[];for(let H=1;H<G;H++)S.push(n);const U=ee(M,S,g);E=U.se,R=F-U.margin,X=F+U.margin}N.push({step:G,at:r(G),mean:F,lower:R,upper:X,se:E})}return{method:"ses",horizon:m,confidence:e,n:a,sigma:M===null?null:Math.sqrt(M),params:{alpha:n},points:N}}function u(t,a,m,e,d,h,r){if(a<2)return null;let n=Number.isFinite(h.alpha)?le(h.alpha):null,c=Number.isFinite(h.beta)?le(h.beta):null;if(n===null||c===null){let R=n===null?.5:n,X=c===null?.5:c;for(let E=0;E<6;E++)n===null&&(R=ue(S=>L(t,S,X).sse)),c===null&&(X=ue(S=>L(t,R,S).sse));n=n===null?R:n,c=c===null?X:c}const g=L(t,n,c),M=he(d),N=g.m>0?g.sse/g.m:null,G=n*c,F=[];for(let R=1;R<=m;R++){const X=g.level+R*g.trend;let E=null,S=null,U=null;if(N!==null){const H=[];for(let re=1;re<R;re++)H.push(n+re*G);const $=ee(N,H,M);U=$.se,E=X-$.margin,S=X+$.margin}F.push({step:R,at:r(R),mean:X,lower:E,upper:S,se:U})}return{method:"holt",horizon:m,confidence:e,n:a,sigma:N===null?null:Math.sqrt(N),params:{alpha:n,beta:c},points:F}}function f(t,a,m,e,d,h,r){const n=Math.floor(Number(h.period));if(!(n>=2))return ne("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(a<2*n)return null;let c=Number.isFinite(h.alpha)?le(h.alpha):null,g=Number.isFinite(h.beta)?le(h.beta):null,M=Number.isFinite(h.gamma)?le(h.gamma):null;const N=(U,H,$)=>{const re=Y(t,n,U,H,$);return re?re.sse:1/0};if(c===null||g===null||M===null){let U=c===null?.5:c,H=g===null?.5:g,$=M===null?.5:M;for(let re=0;re<8;re++)c===null&&(U=ue(te=>N(te,H,$))),g===null&&(H=ue(te=>N(U,te,$))),M===null&&($=ue(te=>N(U,H,te)));c=c===null?U:c,g=g===null?H:g,M=M===null?$:M}const G=Y(t,n,c,g,M);if(!G)return null;const F=he(d),R=G.count>0?G.sse/G.count:null,X=c*g,E=M*(1-c),S=[];for(let U=1;U<=m;U++){const H=G.season[(G.phase+U)%n],$=G.level+U*G.trend+H;let re=null,te=null,ae=null;if(R!==null){const p=[];for(let q=1;q<U;q++)p.push(c+q*X+(q%n===0?E:0));const B=ee(R,p,F);ae=B.se,re=$-B.margin,te=$+B.margin}S.push({step:U,at:r(U),mean:$,lower:re,upper:te,se:ae})}return{method:"holtWinters",horizon:m,confidence:e,n:a,sigma:R===null?null:Math.sqrt(R),params:{alpha:c,beta:g,gamma:M,period:n},points:S}}const l={FORECAST_METHODS:_,forecast:C}}),Se("packages/core/src/compute/index.js",function(o,me){"use strict";const fe=me("packages/core/src/compute/sort.js");Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return fe.sortColumn}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return fe.sortMulti}}),Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return fe.radixSortFloat64}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return fe.radixSortInt32}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return fe.rankSortDictionary}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return fe.mergeSortComparator}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return fe.collateStringRanks}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return fe.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 Q=me("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return Q.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return Q.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return Q.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return Q.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return Q.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return Q.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return Q.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return Q.mentionsColumn}});const z=me("packages/core/src/compute/group.js");Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return z.groupByColumns}}),Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return z.packKeys}});const ne=me("packages/core/src/compute/facet.js");Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return ne.facet}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return ne.computeBounds}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return ne.countInto}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return ne.bucketOf}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return ne.facetKind}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return ne.cardinalityOf}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return ne.pickGranularity}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return ne.floorTo}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return ne.advance}}),Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return ne.STRATEGIES}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return ne.GRANULARITIES}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return ne.DEFAULT_BUCKETS}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return ne.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return ne.QUANTILE_SAMPLE}});const _=me("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return _.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return _.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return _.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return _.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return _.collectValues}});const T=me("packages/core/src/compute/pivot.js");Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return T.pivot}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return T.resolvePivotKeys}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return T.pivotKey}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return T.joinPath}}),Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return T.KEY_DELIMITER}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return T.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return T.DEFAULT_MAX_COLUMNS}});const K=me("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return K.pivotMatrix}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return K.resolveAxis}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return K.cellKey}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return K.marginKey}}),Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return K.GRAND_PATH}});const ie=me("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return ie.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return ie.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return ie.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ie.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return ie.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return ie.referenceValue}});const J=me("packages/core/src/compute/handle.js");Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return J.identity}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return J.rowCount}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return J.presenceReader}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return J.bitReader}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return J.valueReader}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return J.valueComparator}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return J.numericTotalOrder}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return J.dictRanks}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return J.dictSize}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return J.dictValue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return J.multiValue}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return J.isMissing}});const le=me("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return le.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return le.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return le.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return le.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return le.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return le.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return le.SKETCH_BOUNDS}});const ue=me("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return ue.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return ue.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return ue.openWindow}});const W=me("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return W.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return W.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return W.maintenanceOf}});const L=me("packages/core/src/compute/anomaly.js");Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return L.ANOMALY_METHODS}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return L.modifiedZScores}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return L.iqrFences}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return L.mahalanobis}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return L.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return L.rollingAnomalies}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return L.anomalyCondition}});const Y=me("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Y.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return Y.forecast}})}),Se("packages/worker/src/kernel.js",function(o,me){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"setCompute",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"dispatch",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"handleMessage",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"installKernel",{enumerable:!0,get:function(){return u}});const fe=me("packages/worker/src/transport.js"),he=fe.PROTOCOL,Q=fe.OPS,z=fe.CONTROL,ne=fe.ERRORS,_=fe.unpackHandle,T=fe.unpackHandles,K=fe.createMaskPool,ie=fe.collectTransfers,J=me("packages/core/src/store/columnpack.js"),le=J.packChunk,ue=J.packedTransfers;let W=null,L=null,Y=null;async function ee(f){if(W)return W;if(!L){const l=f||(()=>Promise.resolve(me("packages/core/src/compute/index.js")));L=Promise.resolve().then(l).then(t=>(W=t,t)).catch(t=>(Y=t,W=null,null))}return L}function C(f){W=f,L=f?Promise.resolve(f):null,Y=f?null:Y}function A(f,l,t){const a=new Map;for(const m of f)m&&a.set(m.id,m);return{handle(m){return a.get(m)},count:l,pool:K(),locale:t}}function i(f,l){const{op:t,args:a}=f;if(t===Q.COLUMNIZE)return le(a.schema||[],a.rows||[],a.opts||{});const m=l[t];if(typeof m!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=ne.NO_KERNEL,e}switch(t){case Q.COLLATE_STRING_RANKS:return m(a.table||[],(a.table||[]).length,a.locale);case Q.SORT_COLUMN:return m(_(a.handle),a.order??null,a.opts||{});case Q.SORT_MULTI:{const e=T(a.handles||[]),d=(a.entries||[]).map(h=>({...h,handle:e[h.index]}));return m(e,d,a.order??null)}case Q.EVALUATE_FILTERS:return m(a.filters,A(T(a.handles||[]),a.count,a.locale));case Q.COMPACT:return m(a.mask,a.count,void 0);case Q.GROUP_BY_COLUMNS:return m(T(a.handles||[]),a.order??null,a.opts||{});case Q.TOTAL:return m(_(a.handle),a.indices??null,a.fn);case Q.PIVOT:return m(T(a.handles||[]),a.order??null,a.opts||{});case Q.FACET:return m(_(a.handle),a.indices??null,a.count,a.opts||{});default:{const e=new Error(`[lattice] unknown worker op \'${t}\'`);throw e.code=ne.PROTOCOL,e}}}async function s(f,l={}){if(!f||f.lattice!==he)return null;const{id:t,op:a}=f;if(a===z.CANCEL)return l.cancelled?.add(f.target),null;if(a===z.PING)return{reply:{lattice:he,id:t,ok:!0,result:"pong"},transfer:[]};if(a===Q.COLUMNIZE){if(l.cancelled?.has(t))return l.cancelled.delete(t),null;try{const e=le(f.args.schema||[],f.args.rows||[],f.args.opts||{});return l.cancelled?.has(t)?(l.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:ne.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:ue(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||ne.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}const m=await ee(l.loader);if(!m)return{reply:{lattice:he,id:t,ok:!1,error:{code:ne.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${Y?Y.message:"module not found"}`}},transfer:[]};if(l.cancelled?.has(t))return l.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:ne.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(f,m);return l.cancelled?.has(t)?(l.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:ne.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:ie(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||ne.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}function u(f,l={}){const t=new Set,a=async m=>{const e=await s(m.data,{loader:l.loader,cancelled:t});e&&f.postMessage(e.reply,e.transfer)};return f.addEventListener("message",a),ee(l.loader).then(m=>{f.postMessage({lattice:he,id:0,op:z.READY,compute:!!m})}),()=>f.removeEventListener("message",a)}});var pt=it("packages/worker/src/kernel.js");yt.__latticeKernel=pt})(typeof globalThis<"u"?globalThis:this);\n\n__latticeKernel.installKernel(self);\n',{type:"classic"})}catch{}const It=Gn("packages/modules/webcomponent/index.js"),Qi=It.GridElementController,Ji=It.observedAttributeNames,eo=It.domEventName,to=It.ATTRIBUTE_CONFIG,no=It.EVENT_PREFIX,ro=It.createLatticeElements,io=It.defineLatticeElements,oo=It.ELEMENT_TAGS,so=It.createLatticeKPIElement,ao=It.createLatticeChartElement,lo=It.createLatticeKanbanElement,uo=It.createLatticeGanttElement,co=It.createLatticeLayoutElement,fo=It.createLatticeTabsElement,ho=It.createLatticeRouterElement,po=It.adoptLatticeStyles,mo=It.latticeStyleSheets,go=It.VIEWER_EVENTS,yo=It.VIEWER_APPLY,bo=It.viewerHandlerName,wo=It.createViewerController,vo=It.EVENT_NAMES,ko=It.dashedName,So=It.createCurrencyType,Oo=It.createUnitType,jo=It.registerUnitSystem,Ao=It.createStat,Po=It.createHeadlessGrid,Co=It.duckdbAdapter,Eo=It.createPushdownSource,To=It.TAG_NAME,Mo=It.createLatticeGridElement,No=It.defineLatticeGrid;var Ro=It.default;export{to as ATTRIBUTE_CONFIG,oo as ELEMENT_TAGS,vo as EVENT_NAMES,no as EVENT_PREFIX,Qi as GridElementController,To as TAG_NAME,yo as VIEWER_APPLY,go as VIEWER_EVENTS,po as adoptLatticeStyles,So as createCurrencyType,Po as createHeadlessGrid,ao as createLatticeChartElement,ro as createLatticeElements,uo as createLatticeGanttElement,Mo as createLatticeGridElement,so as createLatticeKPIElement,lo as createLatticeKanbanElement,co as createLatticeLayoutElement,ho as createLatticeRouterElement,fo as createLatticeTabsElement,Eo as createPushdownSource,Ao as createStat,Oo as createUnitType,wo as createViewerController,ko as dashedName,Ro as default,io as defineLatticeElements,No as defineLatticeGrid,eo as domEventName,Co as duckdbAdapter,mo as latticeStyleSheets,Ji as observedAttributeNames,jo as registerUnitSystem,bo as viewerHandlerName};
|
|
60
60
|
|
|
61
61
|
//# sourceMappingURL=webcomponent.esm.min.js.map
|