@toclocoinc/lattice-grid 1.74.0 → 1.75.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 +12 -0
- package/README.md +1 -1
- package/angular/package.json +1 -1
- package/docs/API.html +44 -6
- package/docs/CHART-CODES.md +8 -0
- 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 +28 -2
- package/docs/api/data-router.html +1 -1
- package/docs/api/deckgl.html +2 -2
- package/docs/api/gantt.html +1 -1
- package/docs/api/geometry.html +1 -1
- package/docs/api/grid.html +2 -2
- package/docs/api/index.html +2 -2
- package/docs/api/kanban.html +1 -1
- package/docs/api/kpi.html +1 -1
- package/docs/api/layout.html +1 -1
- package/docs/api/list.html +1 -1
- package/docs/api/mock-socket.html +1 -1
- package/docs/api/tabs.html +1 -1
- package/docs/api/types.html +13 -1
- package/docs/api-detail.html +13 -4
- package/docs/warnings.json +36 -3
- package/lattice-grid.d.ts +37 -2
- package/lattice-grid.esm.min.js +3 -3
- package/lattice-grid.min.cjs +3 -3
- 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 +2 -2
- package/modules/chart-calendar.esm.min.js.map +1 -1
- package/modules/chart-calendar.min.cjs +2 -2
- package/modules/chart-calendar.min.js +2 -2
- package/modules/chart-calendar.min.js.map +1 -1
- package/modules/chart-choropleth.d.ts +1 -1
- package/modules/chart-choropleth.esm.min.js +2 -2
- package/modules/chart-choropleth.esm.min.js.map +1 -1
- package/modules/chart-choropleth.min.cjs +2 -2
- package/modules/chart-choropleth.min.js +2 -2
- package/modules/chart-choropleth.min.js.map +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 +2 -2
- package/modules/chart-hexbin.esm.min.js.map +1 -1
- package/modules/chart-hexbin.min.cjs +2 -2
- package/modules/chart-hexbin.min.js +2 -2
- package/modules/chart-hexbin.min.js.map +1 -1
- package/modules/chart-hexmap.d.ts +1 -1
- package/modules/chart-hexmap.esm.min.js +2 -2
- package/modules/chart-hexmap.esm.min.js.map +1 -1
- package/modules/chart-hexmap.min.cjs +2 -2
- package/modules/chart-hexmap.min.js +2 -2
- package/modules/chart-hexmap.min.js.map +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 +185 -178
- package/modules/charts.esm.min.js.map +2 -2
- package/modules/charts.min.cjs +185 -178
- package/modules/charts.min.js +185 -178
- package/modules/charts.min.js.map +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 +9 -3
- package/modules/deckgl.esm.min.js +18 -11
- package/modules/deckgl.esm.min.js.map +2 -2
- package/modules/deckgl.min.cjs +18 -11
- package/modules/deckgl.min.js +18 -11
- package/modules/deckgl.min.js.map +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/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/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.75.0, webcomponent module
|
|
3
3
|
* Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
|
|
4
4
|
* https://latticegrid.dev
|
|
5
5
|
*/
|
|
6
|
-
var rr=Object.create(null),ir=Object.create(null);function Ae(e,G){rr[e]=G}function Un(e){var G=ir[e];if(G)return G;var q=Object.create(null);ir[e]=q;var M=rr[e];if(!M)throw new Error("[lattice] missing module: "+e);return M(q,Un),q}Ae("packages/core/src/internal/util.js",function(e,G){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return u}}),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 i}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return te}});const q="1.74.0";async function M(){return q}const $="1.74.0",N=new Set,W=2e3;function Z(ee){if(N.add(ee),N.size>W){const oe=N.values().next().value;oe!==void 0&&N.delete(oe)}}const V=[],U=500;function x(ee,oe,re){V.push({key:ee,level:oe,message:re.map(le=>typeof le=="string"?le:I(le)).join(" "),at:Date.now()}),V.length>U&&V.shift()}function I(ee){if(ee instanceof Error)return ee.message;try{return JSON.stringify(ee)}catch{return String(ee)}}function v(){return V.map(ee=>({...ee}))}function k(ee,...oe){N.has(ee)||(Z(ee),x(ee,"warn",oe),console.warn("[lattice]",...oe))}function y(ee,...oe){N.has(ee)||(Z(ee),x(ee,"info",oe),console.info("[lattice]",...oe))}function l(){N.clear(),V.length=0}function u(ee,oe){const re=new Error(`[lattice] ${ee}`);throw oe!==void 0&&(re.cause=oe),re}function n(ee,oe){ee||u(oe)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function i(ee){return ee!==null&&typeof ee=="object"&&!Array.isArray(ee)}function s(ee){return typeof ee=="function"}function r(ee){return ee==null}function o(ee){return ee==null||ee===""}function c(ee){return typeof ee!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(ee))?!0:!!(ee.prototype&&Object.getOwnPropertyNames(ee.prototype).length>1)}const a=new Map;function g(ee){let oe=a.get(ee);if(oe)return oe;if(!ee.includes("."))oe=re=>re?.[ee];else{const re=ee.split("."),le=re.length;oe=ne=>{let se=ne;for(let ae=0;ae<le;ae++){if(se==null)return;se=se[re[ae]]}return se}}return a.set(ee,oe),oe}const h=new Map;function b(ee){let oe=h.get(ee);if(oe)return oe;if(!ee.includes("."))oe=(re,le)=>{re!=null&&(re[ee]=le)};else{const re=ee.split("."),le=re.length-1;oe=(ne,se)=>{let ae=ne;for(let de=0;de<le;de++){if(ae==null)return;const me=re[de];ae[me]==null&&(ae[me]={}),ae=ae[me]}ae!=null&&(ae[re[le]]=se)}}return h.set(ee,oe),oe}function p(ee,oe){return g(oe)(ee)}function f(ee,oe,re){b(oe)(ee,re)}function w(ee){return ee?(ee.includes(".")?ee.slice(ee.lastIndexOf(".")+1):ee).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(/^./,re=>re.toUpperCase()):""}const S={"&":"&","<":"<",">":">",'"':""","'":"'"};function m(ee){const oe=ee==null?"":String(ee);return/[&<>"']/.test(oe)?oe.replace(/[&<>"']/g,re=>S[re]):oe}function d(ee){return String(ee).replace(/\w\S*/g,oe=>oe[0].toUpperCase()+oe.slice(1).toLowerCase())}function j(ee,oe,re){if(ee!==void 0)return ee===!0?{enabled:!0,...re}:ee===!1?{enabled:!1}:i(ee)?ee:{[oe]:ee,enabled:!0}}function E(ee){return ee==null?[]:Array.isArray(ee)?ee:[ee]}const O=Object.freeze(new Set(["__proto__","constructor","prototype"]));function T(ee,oe){if(!i(ee))return i(oe)?{...oe}:oe;if(!i(oe))return oe===void 0?ee:oe;const re={...ee};for(const le of Object.keys(oe)){if(O.has(le))continue;const ne=oe[le];ne!==void 0&&(re[le]=i(ne)&&i(re[le])?T(re[le],ne):ne)}return re}function A(ee,oe){if(!i(ee)||!i(oe)||ee===oe)return oe;const re=Object.create(Object.getPrototypeOf(ee));return Object.assign(re,ee,oe),re}class P{#e;#t=new Map;#n;constructor(oe=256,re=null){this.#e=oe,this.#n=re}get size(){return this.#t.size}get max(){return this.#e}set max(oe){this.#e=oe,this.#r()}has(oe){return this.#t.has(oe)}get(oe){const re=this.#t;if(!re.has(oe))return;const le=re.get(oe);return re.delete(oe),re.set(oe,le),le}peek(oe){return this.#t.get(oe)}set(oe,re){const le=this.#t;return le.has(oe)&&le.delete(oe),le.set(oe,re),this.#r(),re}delete(oe){const re=this.#t.get(oe);return this.#t.delete(oe)&&this.#n&&this.#n(re,oe),re}clear(){if(this.#n)for(const[oe,re]of this.#t)this.#n(re,oe);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const oe=this.#t;for(;oe.size>this.#e;){const re=oe.keys().next().value,le=oe.get(re);oe.delete(re),this.#n&&this.#n(le,re)}}}const L=new Map;function z(ee,oe){const re=`${ee||""}|${oe?JSON.stringify(oe):""}`;let le=L.get(re);return le||(le=new Intl.Collator(ee||void 0,{numeric:!0,sensitivity:"variant",...oe}),L.set(re,le)),le}function H(ee,oe){if(ee===oe)return 0;if(ee==null)return 1;if(oe==null)return-1;if(typeof ee=="number"&&typeof oe=="number")return Number.isNaN(ee)?Number.isNaN(oe)?0:1:Number.isNaN(oe)||ee<oe?-1:ee>oe?1:0;const re=String(ee),le=String(oe);return re<le?-1:re>le?1:0}function D(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const F=typeof requestAnimationFrame=="function";function C(ee){return F?requestAnimationFrame(ee):setTimeout(()=>ee(D()),16)}function B(ee){ee!=null&&(F?cancelAnimationFrame(ee):clearTimeout(ee))}function _(ee){let oe=null,re=null;const le=()=>{oe=null;const se=re;re=null,ee(...se||[])},ne=(...se)=>{re=se,oe===null&&(oe=C(le))};return ne.cancel=()=>{B(oe),oe=null,re=null},ne.flush=()=>{oe!==null&&(B(oe),le())},ne}function Q(ee,oe){let re=null,le=null;const ne=()=>{if(re=null,le===null)return;const de=le;le=null,ee(...de),se()},se=()=>{re=setTimeout(ne,oe),typeof re?.unref=="function"&&re.unref()},ae=(...de)=>{re===null?(ee(...de),se()):(le=de,clearTimeout(re),se())};return ae.flush=()=>{if(re!==null&&clearTimeout(re),re=null,le===null)return;const de=le;le=null,ee(...de)},ae.cancel=()=>{re!==null&&clearTimeout(re),re=null,le=null},ae.pending=()=>re!==null||le!==null,ae}function Y(ee,oe=50){return typeof requestIdleCallback=="function"?requestIdleCallback(ee,{timeout:oe}):setTimeout(()=>ee({timeRemaining:()=>0,didTimeout:!0}),1)}let J=0;function te(ee="l"){return`${ee}${(++J).toString(36)}`}}),Ae("packages/core/src/formatting/rules.js",function(e,G){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return j}});const q=G("packages/core/src/internal/util.js"),M=q.isFunction,$=q.warnOnce,N=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"]),Z=Object.freeze({topPercent:"In the top %",bottomPercent:"In the bottom %",topN:"In the top N",bottomN:"In the bottom N",aboveMean:"Above average",belowMean:"Below average",aboveMedian:"Above the median",belowMedian:"Below the median",zAbove:"Standard deviations above the mean",zBelow:"Standard deviations below the mean",outlier:"An outlier"});function V(E,O){const T=Number(E),A=Number(O);if(E!==null&&E!==""&&O!==null&&O!==""&&Number.isFinite(T)&&Number.isFinite(A))return T<A?-1:T>A?1:0;const L=String(E??"").toLowerCase(),z=String(O??"").toLowerCase();return L<z?-1:L>z?1:0}function U(E){return E==null||E===""}function x(E,O){if(!O||typeof O!="object")return!1;const{op:T}=O,A=O.value,P=O.value2;switch(T){case"blank":return U(E);case"notBlank":return!U(E);case"true":return E===!0;case"false":return E===!1;default:break}if(U(E))return!1;switch(T){case"eq":return V(E,A)===0;case"ne":return V(E,A)!==0;case"gt":return V(E,A)>0;case"gte":return V(E,A)>=0;case"lt":return V(E,A)<0;case"lte":return V(E,A)<=0;case"between":return V(E,A)>=0&&V(E,P)<=0;case"outside":return V(E,A)<0||V(E,P)>0;case"contains":return String(E).toLowerCase().includes(String(A??"").toLowerCase());case"notContains":return!String(E).toLowerCase().includes(String(A??"").toLowerCase());case"startsWith":return String(E).toLowerCase().startsWith(String(A??"").toLowerCase());case"endsWith":return String(E).toLowerCase().endsWith(String(A??"").toLowerCase());default:return!1}}function I(E,O,T){const A=_=>{const Q=String(_).replace("#",""),Y=Q.length===3?Q.split("").map(J=>J+J).join(""):Q;return[0,2,4].map(J=>parseInt(Y.slice(J,J+2),16)||0)},[P,L,z]=A(E),[H,D,F]=A(O),C=Math.max(0,Math.min(1,T)),B=(_,Q)=>Math.round(_+(Q-_)*C);return`#${[B(P,H),B(L,D),B(z,F)].map(_=>_.toString(16).padStart(2,"0")).join("")}`}function v(E){const O=[];for(const H of E||[]){if(H==null||H==="")continue;const D=H instanceof Date?H.getTime():Number(H);Number.isFinite(D)&&O.push(D)}if(!O.length)return null;O.sort((H,D)=>H-D);let T=0,A=0,P=0;for(const H of O){T++;const D=H-A;A+=D/T,P+=D*(H-A)}const L=k(O,.25),z=k(O,.75);return{n:O.length,min:O[0],max:O[O.length-1],mean:A,stddev:O.length>1?Math.sqrt(P/(O.length-1)):0,median:k(O,.5),q1:L,q3:z,iqr:z-L,sorted:O}}function k(E,O){if(!E.length)return 0;const T=(E.length-1)*Math.max(0,Math.min(1,O)),A=Math.floor(T),P=Math.ceil(T);return A===P?E[A]:E[A]+(T-A)*(E[P]-E[A])}function y(E){for(const O of Array.isArray(E)?E:[])if(!(!O||typeof O!="object")&&(O.when&&W.includes(O.when.op)||O.scale&&O.scale.from||O.dataBar&&!(Number.isFinite(Number(O.dataBar.min))&&Number.isFinite(Number(O.dataBar.max)))||O.iconSet&&!Array.isArray(O.iconSet.thresholds)))return!0;return!1}function l(E,O){const T=Number(E.value),A=P=>k(O.sorted,P);switch(E.op){case"topPercent":{const P=u(T,10);return{op:"gte",value:A(1-P)}}case"bottomPercent":{const P=u(T,10);return{op:"lte",value:A(P)}}case"topN":{const P=Math.max(1,Math.floor(T)||1),L=Math.max(0,O.sorted.length-P);return{op:"gte",value:O.sorted[L]}}case"bottomN":{const P=Math.max(1,Math.floor(T)||1),L=Math.min(O.sorted.length-1,P-1);return{op:"lte",value:O.sorted[L]}}case"aboveMean":return{op:"gt",value:O.mean};case"belowMean":return{op:"lt",value:O.mean};case"aboveMedian":return{op:"gt",value:O.median};case"belowMedian":return{op:"lt",value:O.median};case"zAbove":return O.stddev?{op:"gte",value:O.mean+(Number.isFinite(T)?T:2)*O.stddev}:null;case"zBelow":return O.stddev?{op:"lte",value:O.mean-(Number.isFinite(T)?T:2)*O.stddev}:null;case"outlier":{const P=(Number.isFinite(T)&&T>0?T:1.5)*O.iqr;return O.iqr?{op:"outside",value:O.q1-P,value2:O.q3+P}:null}default:return null}}function u(E,O){const T=Number.isFinite(E)?E:O,A=T>1?T/100:T;return Math.max(0,Math.min(1,A))}function n(E,O){if(E.from==="minmax")return{...E,min:O.min,max:O.max};if(E.from==="quantile")return{...E,min:k(O.sorted,u(Number(E.low),5)),max:k(O.sorted,u(Number(E.high),95))};if(E.from==="stddev"){const T=Number.isFinite(Number(E.deviations))?Number(E.deviations):2;return{...E,min:O.mean-T*O.stddev,max:O.mean+T*O.stddev}}return E}function t(E,O){const T=Array.isArray(E)?E:[];return!O||!O.n?T.map(A=>A&&y([A])?{...A,enabled:!1}:A):T.map(A=>{if(!A||typeof A!="object")return A;if(A.scale&&A.scale.from)return{...A,scale:n(A.scale,O)};if(A.dataBar)return{...A,dataBar:i(A.dataBar,O)};if(A.iconSet)return{...A,iconSet:s(A.iconSet,O)};if(!A.when||!W.includes(A.when.op))return A;const P=l(A.when,O);return P?{...A,when:P}:{...A,enabled:!1}})}function i(E,O){const T=Number.isFinite(Number(E.min))?Number(E.min):void 0,A=Number.isFinite(Number(E.max))?Number(E.max):void 0;if(T!==void 0&&A!==void 0)return{...E,min:T,max:A};if(E.from==="quantile")return{...E,min:T??k(O.sorted,u(Number(E.low),5)),max:A??k(O.sorted,u(Number(E.high),95))};if(E.from==="stddev"){const P=Number.isFinite(Number(E.deviations))?Number(E.deviations):2;return{...E,min:T??O.mean-P*O.stddev,max:A??O.mean+P*O.stddev}}return{...E,min:T??O.min,max:A??O.max}}function s(E,O){if(Array.isArray(E.thresholds))return E;const T=r(E),A=[];for(let P=1;P<T;P++)A.push(k(O.sorted,P/T));return{...E,thresholds:A}}function r(E){if(Array.isArray(E.icons)&&E.icons.length>=2)return E.icons.length;if(Number.isFinite(Number(E.count))&&Number(E.count)>=2)return Math.floor(Number(E.count));const O=p[E.set];return O?O.length:3}function o(E){return`url("data:image/svg+xml,${encodeURIComponent(E)}")`}function c(E){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${E}"/></svg>`}function a(E,O){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${O==="up"?"8,2 14,13 2,13":O==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${E}"/></svg>`}function g(E,O){const T="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 A=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${O*16} 16">`;for(let P=0;P<O;P++){const L=P<E?"#f5a623":"#d0d0d0";A+=`<path transform="translate(${P*16},0)" d="${T}" fill="${L}"/>`}return`${A}</svg>`}const h=Object.freeze([a("#c0392b","down"),a("#e0a800","right"),a("#2e7d32","up")]),b=Object.freeze([c("#d13438"),c("#f5a623"),c("#2e9e44")]),p=Object.freeze({arrows:h,trafficLights:b,ratings:Object.freeze([1,2,3,4,5].map(E=>g(E,5)))}),f=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function w(E){if(Array.isArray(E.icons)&&E.icons.length>=2)return E.icons.map(A=>/^\s*(url\(|data:|<)/.test(String(A))&&String(A).trim().startsWith("<")?o(String(A)):String(A));const O=E.set||"arrows";if(O==="ratings"){const A=r(E),P=[];for(let L=1;L<=A;L++)P.push(o(g(L,A)));return P}const T=p[O];return T?T.map(o):($(`iconSet:${O}`,`unknown icon set '${O}'; falling back to arrows.`),h.map(o))}function S(E){const O=Number(E.min),A=Number(E.max)-O,P=E.colour||E.color||"#5b9bd5",L=E.negativeColour||E.negativeColor||"#d13438",z=E.direction==="rtl"?"left":"right",H=F=>Math.max(0,Math.min(1,(F-O)/A))*100,D=A?Math.max(0,Math.min(100,(0-O)/A*100)):0;return F=>{if(U(F))return null;const C=Number(F);if(!Number.isFinite(C)||!A)return null;const B=H(C),_=Math.min(B,D),Q=Math.max(B,D),Y=C>=0?P:L;return{backgroundImage:`linear-gradient(to ${z}, transparent ${_}%, ${Y} ${_}%, ${Y} ${Q}%, transparent ${Q}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function m(E){const O=w(E),T=E.reverse?[...O].reverse():O,A=(Array.isArray(E.thresholds)?E.thresholds:[]).map(Number).filter(Number.isFinite),P=Number.isFinite(Number(E.size))?Number(E.size):16,L=E.set==="ratings"?P*r(E):P;return z=>{if(U(z))return null;const H=Number(z);if(!Number.isFinite(H))return null;let D=0;for(const C of A)H>=C&&D++;const F=T[Math.min(D,T.length-1)];return F?{backgroundImage:F,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${L}px ${P}px`,paddingLeft:`${L+4}px`}:null}}function d(E){const O=Array.isArray(E.colours)&&E.colours.length>=2?E.colours:["#f8f9fa","#1a6bc7"],T=Number(E.min),A=Number(E.max),P=A-T,L=O.length-1,z=[];for(let D=0;D<=L;D++)z.push(L?D/L:0);const H=Number(E.mid);if(E.mid!==void 0&&E.mid!==null)if(O.length%2===0)$("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${O.length} were given, so "mid" was ignored.`);else if(Number.isFinite(H)&&P&&H>Math.min(T,A)&&H<Math.max(T,A)){const D=L/2,F=Math.max(0,Math.min(1,(H-T)/P));for(let C=0;C<=L;C++)z[C]=C<=D?D?C/D*F:F:F+(C-D)/(L-D)*(1-F)}else Number.isFinite(H)&&$("formatting.scale.mid.range",`a scale's "mid" (${H}) is outside its min..max range, so it was ignored.`);return D=>{const F=Number(D);if(!Number.isFinite(F)||!P)return null;const C=Math.max(0,Math.min(1,(F-T)/P));let B=0;for(;B<L-1&&C>z[B+1];)B++;const _=z[B+1]-z[B],Q=_>0?(C-z[B])/_:0;return{background:I(O[B],O[B+1],Math.max(0,Math.min(1,Q)))}}}function j(E,O=null){const T=y(E)?t(E,O):E,A=(Array.isArray(T)?T:[]).filter(L=>L&&typeof L=="object");if(!A.length)return()=>null;const P=A.map(L=>L.scale?{scale:d(L.scale),enabled:L.enabled!==!1}:L.dataBar?{scale:S(L.dataBar),enabled:L.enabled!==!1}:L.iconSet?{scale:m(L.iconSet),enabled:L.enabled!==!1}:{when:L.when,style:L.style,stop:L.stopIfTrue!==!1,enabled:L.enabled!==!1});return L=>{const z=L?L.value:void 0;let H=null;for(const D of P){if(!D.enabled)continue;if(D.scale){const C=D.scale(z);C&&(H={...H||{},...C});continue}if(!x(z,D.when))continue;const F=M(D.style)?D.style(L):D.style;if(F&&(H={...H||{},...F}),D.stop)break}return H}}}),Ae("packages/core/src/formula/parse.js",function(e,G){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return i}});const q="num",M="str",$="ref",N="name",W="op",Z="end",V=["<=",">=","<>","!="],U="+-*/^%(),<>=";class x extends Error{constructor(r,o){super(r),this.name="FormulaError",this.at=o}}function I(s){const r=[];let o=0;for(;o<s.length;){const c=s[o];if(c===" "||c===" "||c===`
|
|
6
|
+
var rr=Object.create(null),ir=Object.create(null);function Ae(e,G){rr[e]=G}function Un(e){var G=ir[e];if(G)return G;var q=Object.create(null);ir[e]=q;var M=rr[e];if(!M)throw new Error("[lattice] missing module: "+e);return M(q,Un),q}Ae("packages/core/src/internal/util.js",function(e,G){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return u}}),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 i}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return te}});const q="1.75.0";async function M(){return q}const $="1.75.0",N=new Set,W=2e3;function Z(ee){if(N.add(ee),N.size>W){const oe=N.values().next().value;oe!==void 0&&N.delete(oe)}}const V=[],U=500;function x(ee,oe,re){V.push({key:ee,level:oe,message:re.map(le=>typeof le=="string"?le:I(le)).join(" "),at:Date.now()}),V.length>U&&V.shift()}function I(ee){if(ee instanceof Error)return ee.message;try{return JSON.stringify(ee)}catch{return String(ee)}}function v(){return V.map(ee=>({...ee}))}function k(ee,...oe){N.has(ee)||(Z(ee),x(ee,"warn",oe),console.warn("[lattice]",...oe))}function y(ee,...oe){N.has(ee)||(Z(ee),x(ee,"info",oe),console.info("[lattice]",...oe))}function l(){N.clear(),V.length=0}function u(ee,oe){const re=new Error(`[lattice] ${ee}`);throw oe!==void 0&&(re.cause=oe),re}function n(ee,oe){ee||u(oe)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function i(ee){return ee!==null&&typeof ee=="object"&&!Array.isArray(ee)}function s(ee){return typeof ee=="function"}function r(ee){return ee==null}function o(ee){return ee==null||ee===""}function c(ee){return typeof ee!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(ee))?!0:!!(ee.prototype&&Object.getOwnPropertyNames(ee.prototype).length>1)}const a=new Map;function g(ee){let oe=a.get(ee);if(oe)return oe;if(!ee.includes("."))oe=re=>re?.[ee];else{const re=ee.split("."),le=re.length;oe=ne=>{let se=ne;for(let ae=0;ae<le;ae++){if(se==null)return;se=se[re[ae]]}return se}}return a.set(ee,oe),oe}const h=new Map;function b(ee){let oe=h.get(ee);if(oe)return oe;if(!ee.includes("."))oe=(re,le)=>{re!=null&&(re[ee]=le)};else{const re=ee.split("."),le=re.length-1;oe=(ne,se)=>{let ae=ne;for(let de=0;de<le;de++){if(ae==null)return;const me=re[de];ae[me]==null&&(ae[me]={}),ae=ae[me]}ae!=null&&(ae[re[le]]=se)}}return h.set(ee,oe),oe}function p(ee,oe){return g(oe)(ee)}function f(ee,oe,re){b(oe)(ee,re)}function w(ee){return ee?(ee.includes(".")?ee.slice(ee.lastIndexOf(".")+1):ee).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(/^./,re=>re.toUpperCase()):""}const S={"&":"&","<":"<",">":">",'"':""","'":"'"};function m(ee){const oe=ee==null?"":String(ee);return/[&<>"']/.test(oe)?oe.replace(/[&<>"']/g,re=>S[re]):oe}function d(ee){return String(ee).replace(/\w\S*/g,oe=>oe[0].toUpperCase()+oe.slice(1).toLowerCase())}function j(ee,oe,re){if(ee!==void 0)return ee===!0?{enabled:!0,...re}:ee===!1?{enabled:!1}:i(ee)?ee:{[oe]:ee,enabled:!0}}function E(ee){return ee==null?[]:Array.isArray(ee)?ee:[ee]}const O=Object.freeze(new Set(["__proto__","constructor","prototype"]));function T(ee,oe){if(!i(ee))return i(oe)?{...oe}:oe;if(!i(oe))return oe===void 0?ee:oe;const re={...ee};for(const le of Object.keys(oe)){if(O.has(le))continue;const ne=oe[le];ne!==void 0&&(re[le]=i(ne)&&i(re[le])?T(re[le],ne):ne)}return re}function A(ee,oe){if(!i(ee)||!i(oe)||ee===oe)return oe;const re=Object.create(Object.getPrototypeOf(ee));return Object.assign(re,ee,oe),re}class P{#e;#t=new Map;#n;constructor(oe=256,re=null){this.#e=oe,this.#n=re}get size(){return this.#t.size}get max(){return this.#e}set max(oe){this.#e=oe,this.#r()}has(oe){return this.#t.has(oe)}get(oe){const re=this.#t;if(!re.has(oe))return;const le=re.get(oe);return re.delete(oe),re.set(oe,le),le}peek(oe){return this.#t.get(oe)}set(oe,re){const le=this.#t;return le.has(oe)&&le.delete(oe),le.set(oe,re),this.#r(),re}delete(oe){const re=this.#t.get(oe);return this.#t.delete(oe)&&this.#n&&this.#n(re,oe),re}clear(){if(this.#n)for(const[oe,re]of this.#t)this.#n(re,oe);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const oe=this.#t;for(;oe.size>this.#e;){const re=oe.keys().next().value,le=oe.get(re);oe.delete(re),this.#n&&this.#n(le,re)}}}const L=new Map;function z(ee,oe){const re=`${ee||""}|${oe?JSON.stringify(oe):""}`;let le=L.get(re);return le||(le=new Intl.Collator(ee||void 0,{numeric:!0,sensitivity:"variant",...oe}),L.set(re,le)),le}function H(ee,oe){if(ee===oe)return 0;if(ee==null)return 1;if(oe==null)return-1;if(typeof ee=="number"&&typeof oe=="number")return Number.isNaN(ee)?Number.isNaN(oe)?0:1:Number.isNaN(oe)||ee<oe?-1:ee>oe?1:0;const re=String(ee),le=String(oe);return re<le?-1:re>le?1:0}function D(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const F=typeof requestAnimationFrame=="function";function C(ee){return F?requestAnimationFrame(ee):setTimeout(()=>ee(D()),16)}function B(ee){ee!=null&&(F?cancelAnimationFrame(ee):clearTimeout(ee))}function _(ee){let oe=null,re=null;const le=()=>{oe=null;const se=re;re=null,ee(...se||[])},ne=(...se)=>{re=se,oe===null&&(oe=C(le))};return ne.cancel=()=>{B(oe),oe=null,re=null},ne.flush=()=>{oe!==null&&(B(oe),le())},ne}function Q(ee,oe){let re=null,le=null;const ne=()=>{if(re=null,le===null)return;const de=le;le=null,ee(...de),se()},se=()=>{re=setTimeout(ne,oe),typeof re?.unref=="function"&&re.unref()},ae=(...de)=>{re===null?(ee(...de),se()):(le=de,clearTimeout(re),se())};return ae.flush=()=>{if(re!==null&&clearTimeout(re),re=null,le===null)return;const de=le;le=null,ee(...de)},ae.cancel=()=>{re!==null&&clearTimeout(re),re=null,le=null},ae.pending=()=>re!==null||le!==null,ae}function Y(ee,oe=50){return typeof requestIdleCallback=="function"?requestIdleCallback(ee,{timeout:oe}):setTimeout(()=>ee({timeRemaining:()=>0,didTimeout:!0}),1)}let J=0;function te(ee="l"){return`${ee}${(++J).toString(36)}`}}),Ae("packages/core/src/formatting/rules.js",function(e,G){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return j}});const q=G("packages/core/src/internal/util.js"),M=q.isFunction,$=q.warnOnce,N=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"]),Z=Object.freeze({topPercent:"In the top %",bottomPercent:"In the bottom %",topN:"In the top N",bottomN:"In the bottom N",aboveMean:"Above average",belowMean:"Below average",aboveMedian:"Above the median",belowMedian:"Below the median",zAbove:"Standard deviations above the mean",zBelow:"Standard deviations below the mean",outlier:"An outlier"});function V(E,O){const T=Number(E),A=Number(O);if(E!==null&&E!==""&&O!==null&&O!==""&&Number.isFinite(T)&&Number.isFinite(A))return T<A?-1:T>A?1:0;const L=String(E??"").toLowerCase(),z=String(O??"").toLowerCase();return L<z?-1:L>z?1:0}function U(E){return E==null||E===""}function x(E,O){if(!O||typeof O!="object")return!1;const{op:T}=O,A=O.value,P=O.value2;switch(T){case"blank":return U(E);case"notBlank":return!U(E);case"true":return E===!0;case"false":return E===!1;default:break}if(U(E))return!1;switch(T){case"eq":return V(E,A)===0;case"ne":return V(E,A)!==0;case"gt":return V(E,A)>0;case"gte":return V(E,A)>=0;case"lt":return V(E,A)<0;case"lte":return V(E,A)<=0;case"between":return V(E,A)>=0&&V(E,P)<=0;case"outside":return V(E,A)<0||V(E,P)>0;case"contains":return String(E).toLowerCase().includes(String(A??"").toLowerCase());case"notContains":return!String(E).toLowerCase().includes(String(A??"").toLowerCase());case"startsWith":return String(E).toLowerCase().startsWith(String(A??"").toLowerCase());case"endsWith":return String(E).toLowerCase().endsWith(String(A??"").toLowerCase());default:return!1}}function I(E,O,T){const A=_=>{const Q=String(_).replace("#",""),Y=Q.length===3?Q.split("").map(J=>J+J).join(""):Q;return[0,2,4].map(J=>parseInt(Y.slice(J,J+2),16)||0)},[P,L,z]=A(E),[H,D,F]=A(O),C=Math.max(0,Math.min(1,T)),B=(_,Q)=>Math.round(_+(Q-_)*C);return`#${[B(P,H),B(L,D),B(z,F)].map(_=>_.toString(16).padStart(2,"0")).join("")}`}function v(E){const O=[];for(const H of E||[]){if(H==null||H==="")continue;const D=H instanceof Date?H.getTime():Number(H);Number.isFinite(D)&&O.push(D)}if(!O.length)return null;O.sort((H,D)=>H-D);let T=0,A=0,P=0;for(const H of O){T++;const D=H-A;A+=D/T,P+=D*(H-A)}const L=k(O,.25),z=k(O,.75);return{n:O.length,min:O[0],max:O[O.length-1],mean:A,stddev:O.length>1?Math.sqrt(P/(O.length-1)):0,median:k(O,.5),q1:L,q3:z,iqr:z-L,sorted:O}}function k(E,O){if(!E.length)return 0;const T=(E.length-1)*Math.max(0,Math.min(1,O)),A=Math.floor(T),P=Math.ceil(T);return A===P?E[A]:E[A]+(T-A)*(E[P]-E[A])}function y(E){for(const O of Array.isArray(E)?E:[])if(!(!O||typeof O!="object")&&(O.when&&W.includes(O.when.op)||O.scale&&O.scale.from||O.dataBar&&!(Number.isFinite(Number(O.dataBar.min))&&Number.isFinite(Number(O.dataBar.max)))||O.iconSet&&!Array.isArray(O.iconSet.thresholds)))return!0;return!1}function l(E,O){const T=Number(E.value),A=P=>k(O.sorted,P);switch(E.op){case"topPercent":{const P=u(T,10);return{op:"gte",value:A(1-P)}}case"bottomPercent":{const P=u(T,10);return{op:"lte",value:A(P)}}case"topN":{const P=Math.max(1,Math.floor(T)||1),L=Math.max(0,O.sorted.length-P);return{op:"gte",value:O.sorted[L]}}case"bottomN":{const P=Math.max(1,Math.floor(T)||1),L=Math.min(O.sorted.length-1,P-1);return{op:"lte",value:O.sorted[L]}}case"aboveMean":return{op:"gt",value:O.mean};case"belowMean":return{op:"lt",value:O.mean};case"aboveMedian":return{op:"gt",value:O.median};case"belowMedian":return{op:"lt",value:O.median};case"zAbove":return O.stddev?{op:"gte",value:O.mean+(Number.isFinite(T)?T:2)*O.stddev}:null;case"zBelow":return O.stddev?{op:"lte",value:O.mean-(Number.isFinite(T)?T:2)*O.stddev}:null;case"outlier":{const P=(Number.isFinite(T)&&T>0?T:1.5)*O.iqr;return O.iqr?{op:"outside",value:O.q1-P,value2:O.q3+P}:null}default:return null}}function u(E,O){const T=Number.isFinite(E)?E:O,A=T>1?T/100:T;return Math.max(0,Math.min(1,A))}function n(E,O){if(E.from==="minmax")return{...E,min:O.min,max:O.max};if(E.from==="quantile")return{...E,min:k(O.sorted,u(Number(E.low),5)),max:k(O.sorted,u(Number(E.high),95))};if(E.from==="stddev"){const T=Number.isFinite(Number(E.deviations))?Number(E.deviations):2;return{...E,min:O.mean-T*O.stddev,max:O.mean+T*O.stddev}}return E}function t(E,O){const T=Array.isArray(E)?E:[];return!O||!O.n?T.map(A=>A&&y([A])?{...A,enabled:!1}:A):T.map(A=>{if(!A||typeof A!="object")return A;if(A.scale&&A.scale.from)return{...A,scale:n(A.scale,O)};if(A.dataBar)return{...A,dataBar:i(A.dataBar,O)};if(A.iconSet)return{...A,iconSet:s(A.iconSet,O)};if(!A.when||!W.includes(A.when.op))return A;const P=l(A.when,O);return P?{...A,when:P}:{...A,enabled:!1}})}function i(E,O){const T=Number.isFinite(Number(E.min))?Number(E.min):void 0,A=Number.isFinite(Number(E.max))?Number(E.max):void 0;if(T!==void 0&&A!==void 0)return{...E,min:T,max:A};if(E.from==="quantile")return{...E,min:T??k(O.sorted,u(Number(E.low),5)),max:A??k(O.sorted,u(Number(E.high),95))};if(E.from==="stddev"){const P=Number.isFinite(Number(E.deviations))?Number(E.deviations):2;return{...E,min:T??O.mean-P*O.stddev,max:A??O.mean+P*O.stddev}}return{...E,min:T??O.min,max:A??O.max}}function s(E,O){if(Array.isArray(E.thresholds))return E;const T=r(E),A=[];for(let P=1;P<T;P++)A.push(k(O.sorted,P/T));return{...E,thresholds:A}}function r(E){if(Array.isArray(E.icons)&&E.icons.length>=2)return E.icons.length;if(Number.isFinite(Number(E.count))&&Number(E.count)>=2)return Math.floor(Number(E.count));const O=p[E.set];return O?O.length:3}function o(E){return`url("data:image/svg+xml,${encodeURIComponent(E)}")`}function c(E){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${E}"/></svg>`}function a(E,O){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${O==="up"?"8,2 14,13 2,13":O==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${E}"/></svg>`}function g(E,O){const T="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 A=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${O*16} 16">`;for(let P=0;P<O;P++){const L=P<E?"#f5a623":"#d0d0d0";A+=`<path transform="translate(${P*16},0)" d="${T}" fill="${L}"/>`}return`${A}</svg>`}const h=Object.freeze([a("#c0392b","down"),a("#e0a800","right"),a("#2e7d32","up")]),b=Object.freeze([c("#d13438"),c("#f5a623"),c("#2e9e44")]),p=Object.freeze({arrows:h,trafficLights:b,ratings:Object.freeze([1,2,3,4,5].map(E=>g(E,5)))}),f=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function w(E){if(Array.isArray(E.icons)&&E.icons.length>=2)return E.icons.map(A=>/^\s*(url\(|data:|<)/.test(String(A))&&String(A).trim().startsWith("<")?o(String(A)):String(A));const O=E.set||"arrows";if(O==="ratings"){const A=r(E),P=[];for(let L=1;L<=A;L++)P.push(o(g(L,A)));return P}const T=p[O];return T?T.map(o):($(`iconSet:${O}`,`unknown icon set '${O}'; falling back to arrows.`),h.map(o))}function S(E){const O=Number(E.min),A=Number(E.max)-O,P=E.colour||E.color||"#5b9bd5",L=E.negativeColour||E.negativeColor||"#d13438",z=E.direction==="rtl"?"left":"right",H=F=>Math.max(0,Math.min(1,(F-O)/A))*100,D=A?Math.max(0,Math.min(100,(0-O)/A*100)):0;return F=>{if(U(F))return null;const C=Number(F);if(!Number.isFinite(C)||!A)return null;const B=H(C),_=Math.min(B,D),Q=Math.max(B,D),Y=C>=0?P:L;return{backgroundImage:`linear-gradient(to ${z}, transparent ${_}%, ${Y} ${_}%, ${Y} ${Q}%, transparent ${Q}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function m(E){const O=w(E),T=E.reverse?[...O].reverse():O,A=(Array.isArray(E.thresholds)?E.thresholds:[]).map(Number).filter(Number.isFinite),P=Number.isFinite(Number(E.size))?Number(E.size):16,L=E.set==="ratings"?P*r(E):P;return z=>{if(U(z))return null;const H=Number(z);if(!Number.isFinite(H))return null;let D=0;for(const C of A)H>=C&&D++;const F=T[Math.min(D,T.length-1)];return F?{backgroundImage:F,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${L}px ${P}px`,paddingLeft:`${L+4}px`}:null}}function d(E){const O=Array.isArray(E.colours)&&E.colours.length>=2?E.colours:["#f8f9fa","#1a6bc7"],T=Number(E.min),A=Number(E.max),P=A-T,L=O.length-1,z=[];for(let D=0;D<=L;D++)z.push(L?D/L:0);const H=Number(E.mid);if(E.mid!==void 0&&E.mid!==null)if(O.length%2===0)$("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${O.length} were given, so "mid" was ignored.`);else if(Number.isFinite(H)&&P&&H>Math.min(T,A)&&H<Math.max(T,A)){const D=L/2,F=Math.max(0,Math.min(1,(H-T)/P));for(let C=0;C<=L;C++)z[C]=C<=D?D?C/D*F:F:F+(C-D)/(L-D)*(1-F)}else Number.isFinite(H)&&$("formatting.scale.mid.range",`a scale's "mid" (${H}) is outside its min..max range, so it was ignored.`);return D=>{const F=Number(D);if(!Number.isFinite(F)||!P)return null;const C=Math.max(0,Math.min(1,(F-T)/P));let B=0;for(;B<L-1&&C>z[B+1];)B++;const _=z[B+1]-z[B],Q=_>0?(C-z[B])/_:0;return{background:I(O[B],O[B+1],Math.max(0,Math.min(1,Q)))}}}function j(E,O=null){const T=y(E)?t(E,O):E,A=(Array.isArray(T)?T:[]).filter(L=>L&&typeof L=="object");if(!A.length)return()=>null;const P=A.map(L=>L.scale?{scale:d(L.scale),enabled:L.enabled!==!1}:L.dataBar?{scale:S(L.dataBar),enabled:L.enabled!==!1}:L.iconSet?{scale:m(L.iconSet),enabled:L.enabled!==!1}:{when:L.when,style:L.style,stop:L.stopIfTrue!==!1,enabled:L.enabled!==!1});return L=>{const z=L?L.value:void 0;let H=null;for(const D of P){if(!D.enabled)continue;if(D.scale){const C=D.scale(z);C&&(H={...H||{},...C});continue}if(!x(z,D.when))continue;const F=M(D.style)?D.style(L):D.style;if(F&&(H={...H||{},...F}),D.stop)break}return H}}}),Ae("packages/core/src/formula/parse.js",function(e,G){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return i}});const q="num",M="str",$="ref",N="name",W="op",Z="end",V=["<=",">=","<>","!="],U="+-*/^%(),<>=";class x extends Error{constructor(r,o){super(r),this.name="FormulaError",this.at=o}}function I(s){const r=[];let o=0;for(;o<s.length;){const c=s[o];if(c===" "||c===" "||c===`
|
|
7
7
|
`||c==="\r"){o++;continue}if(c>="0"&&c<="9"){o=k(s,o,r);continue}if(c==="."&&s[o+1]>="0"&&s[o+1]<="9"){o=k(s,o,r);continue}if(c==='"'||c==="'"){o=y(s,o,r);continue}if(c==="["){const g=s.indexOf("]",o+1);if(g<0)throw new x("a [column reference] was opened and never closed",o);r.push({kind:$,value:s.slice(o+1,g).trim(),at:o}),o=g+1;continue}if(v(c)){o=l(s,o,r);continue}const a=s.slice(o,o+2);if(V.includes(a)){r.push({kind:W,value:a==="!="?"<>":a,at:o}),o+=2;continue}if(U.includes(c)){r.push({kind:W,value:c,at:o}),o++;continue}throw new x(`unexpected character ${JSON.stringify(c)}`,o)}return r.push({kind:Z,value:null,at:s.length}),r}function v(s){return/[A-Za-z_À-]/.test(s)}function k(s,r,o){let c=r,a=!1;for(;c<s.length;){const g=s[c];if(g>="0"&&g<="9"){c++;continue}if(g==="."&&!a){a=!0,c++;continue}if((g==="e"||g==="E")&&/[0-9+-]/.test(s[c+1]||"")){for(c+=2;c<s.length&&s[c]>="0"&&s[c]<="9";)c++;break}break}return o.push({kind:q,value:Number(s.slice(r,c)),at:r}),c}function y(s,r,o){const c=s[r];let a=r+1,g="";for(;a<s.length;){if(s[a]===c){if(s[a+1]===c){g+=c,a+=2;continue}return o.push({kind:M,value:g,at:r}),a+1}g+=s[a],a++}throw new x("a string was opened and never closed",r)}function l(s,r,o){let c=r;for(;c<s.length&&/[A-Za-z0-9_.À-]/.test(s[c]);)c++;const a=s.slice(r,c);let g=c;for(;g<s.length&&s[g]===" ";)g++;return o.push({kind:s[g]==="("?N:$,value:a,at:r}),c}const u={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function n(s){const r=String(s??"").replace(/^\s*=/,"");if(!r.trim())throw new x("the formula is empty");const o=I(r);let c=0;const a=()=>o[c],g=()=>o[c++],h=d=>{const j=a();if(j.kind!==W||j.value!==d)throw new x(`expected ${JSON.stringify(d)}`,j.at);c++},b=d=>{let j=p();for(;;){const E=a();if(E.kind!==W)break;const O=u[E.value];if(!O||O<d)break;c++;const T=b(E.value==="^"?O:O+1);j={kind:"bin",op:E.value,left:j,right:T}}return j},p=()=>{const d=a();return d.kind===W&&(d.value==="-"||d.value==="+")?(c++,{kind:"unary",op:d.value,arg:p()}):f()},f=()=>{let d=w();for(;a().kind===W&&a().value==="%";)c++,d={kind:"unary",op:"%",arg:d};return d},w=()=>{const d=g();if(d.kind===q)return{kind:"num",value:d.value};if(d.kind===M)return{kind:"str",value:d.value};if(d.kind===$)return{kind:"ref",name:d.value};if(d.kind===N){h("(");const j=[];if(!(a().kind===W&&a().value===")"))for(;;){if(j.push(b(1)),a().kind===W&&a().value===","){c++;continue}break}return h(")"),{kind:"call",name:String(d.value).toUpperCase(),args:j}}if(d.kind===W&&d.value==="("){const j=b(1);return h(")"),j}throw d.kind===Z?new x("the formula ends unexpectedly",d.at):new x(`unexpected ${JSON.stringify(d.value)}`,d.at)},S=b(1),m=a();if(m.kind!==Z)throw new x(`unexpected ${JSON.stringify(m.value)}: is an operator missing?`,m.at);return S}function t(s){const r=new Set,o=c=>{if(!(!c||typeof c!="object")){if(c.kind==="ref"){r.add(String(c.name));return}if(c.kind==="bin"){o(c.left),o(c.right);return}if(c.kind==="unary"){o(c.arg);return}if(c.kind==="call")for(const a of c.args)o(a)}};return o(s),[...r]}function i(s){return typeof s=="string"&&/^\s*=/.test(s)&&s.trim()!=="="}}),Ae("packages/core/src/formula/evaluate.js",function(e,G){"use strict";Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return k}});const M=G("packages/core/src/formula/parse.js").FormulaError;function $(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 M(`${JSON.stringify(y)} is not a number`);return l}function N(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 Z(y){const l=[];for(const u of y){if(Array.isArray(u)){for(const n of u)n!=null&&n!==""&&l.push($(n));continue}u==null||u===""||l.push($(u))}return l}function V(y,l){const u=10**l,n=y*u;return Math.sign(n)*Math.round(Math.abs(n)+Number.EPSILON*Math.abs(n))/u}function U(y,l){if(!y.length)return 0;const u=y.slice().sort((s,r)=>s-r),n=(u.length-1)*Math.min(1,Math.max(0,l)),t=Math.floor(n),i=Math.ceil(n);return t===i?u[t]:u[t]+(n-t)*(u[i]-u[t])}function x(y,l){let u=0,n=0,t=0;for(const s of y){u++;const r=s-n;n+=r/u,t+=r*(s-n)}const i=l?u-1:u;return i>0?Math.sqrt(t/i):0}const I={SUM:y=>Z(y).reduce((l,u)=>l+u,0),AVERAGE:y=>{const l=Z(y);return l.length?l.reduce((u,n)=>u+n,0)/l.length:0},MIN:y=>{const l=Z(y);return l.length?Math.min(...l):0},MAX:y=>{const l=Z(y);return l.length?Math.max(...l):0},COUNT:y=>Z(y).length,PRODUCT:y=>Z(y).reduce((l,u)=>l*u,1),ROUND:y=>V($(y[0]),y.length>1?$(y[1]):0),ROUNDDOWN:y=>{const l=10**(y.length>1?$(y[1]):0),u=$(y[0])*l;return(u<0?Math.ceil(u):Math.floor(u))/l},ROUNDUP:y=>{const l=10**(y.length>1?$(y[1]):0),u=$(y[0])*l;return(u<0?Math.floor(u):Math.ceil(u))/l},ABS:y=>Math.abs($(y[0])),FLOOR:y=>Math.floor($(y[0])),CEILING:y=>Math.ceil($(y[0])),SQRT:y=>Math.sqrt($(y[0])),POWER:y=>$(y[0])**$(y[1]),MOD:y=>{const l=$(y[1]);if(l===0)throw new M("MOD by zero");return($(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(N).join(""),LEN:y=>N(y[0]).length,UPPER:y=>N(y[0]).toUpperCase(),LOWER:y=>N(y[0]).toLowerCase(),TRIM:y=>N(y[0]).trim(),LEFT:y=>N(y[0]).slice(0,y.length>1?$(y[1]):1),RIGHT:y=>{const l=y.length>1?$(y[1]):1;return l<=0?"":N(y[0]).slice(-l)},MEDIAN:y=>U(Z(y),.5),PERCENTILE:y=>{const l=$(y[y.length-1]);return U(Z(y.slice(0,-1)),l>1?l/100:l)},QUARTILE1:y=>U(Z(y),.25),QUARTILE3:y=>U(Z(y),.75),STDEV:y=>x(Z(y),!0),STDEVP:y=>x(Z(y),!1),VAR:y=>{const l=x(Z(y),!0);return l*l},VARP:y=>{const l=x(Z(y),!1);return l*l},COUNTDISTINCT:y=>{const l=new Set;for(const u of y){const n=Array.isArray(u)?u:[u];for(const t of n)t!=null&&t!==""&&l.add(t)}return l.size},IQR:y=>{const l=Z(y);return U(l,.75)-U(l,.25)}};I.AVG=I.AVERAGE,I.CEIL=I.CEILING,I.POW=I.POWER,I.STDEVS=I.STDEV,I.PERCENTILEINC=I.PERCENTILE;function v(y,l){const u=Number(y),n=Number(l);if(y!==null&&y!==""&&l!==null&&l!==""&&Number.isFinite(u)&&Number.isFinite(n))return u<n?-1:u>n?1:0;const i=N(y).toLowerCase(),s=N(l).toLowerCase();return i<s?-1:i>s?1:0}function k(y,l={}){const u=typeof l.lookup=="function"?l.lookup:null,n=l.functions?{...I,...l.functions}:I,t=i=>{switch(i.kind){case"num":return i.value;case"str":return i.value;case"ref":{if(!u)throw new M(`there is no column called ${JSON.stringify(i.name)} here`);const s=u(String(i.name));if(s===void 0)throw new M(`there is no column called ${JSON.stringify(i.name)}`);return s}case"unary":{if(i.op==="%")return $(t(i.arg))/100;const s=$(t(i.arg));return i.op==="-"?-s:s}case"bin":{const s=i.op;if(s==="=")return v(t(i.left),t(i.right))===0;if(s==="<>")return v(t(i.left),t(i.right))!==0;if(s==="<")return v(t(i.left),t(i.right))<0;if(s==="<=")return v(t(i.left),t(i.right))<=0;if(s===">")return v(t(i.left),t(i.right))>0;if(s===">=")return v(t(i.left),t(i.right))>=0;const r=$(t(i.left)),o=$(t(i.right));if(s==="+")return r+o;if(s==="-")return r-o;if(s==="*")return r*o;if(s==="^")return r**o;if(s==="/"){if(o===0)throw new M("division by zero");return r/o}throw new M(`unknown operator ${JSON.stringify(s)}`)}case"call":{const s=n[i.name];if(typeof s!="function")throw new M(`there is no function called ${i.name}`);return s(i.args.map(t),l)}default:throw new M("the formula could not be read")}};return t(y)}}),Ae("packages/core/src/formula/index.js",function(e,G){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"rowLookup",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return v}});const q=G("packages/core/src/formula/parse.js"),M=q.parseFormula,$=q.referencesOf,N=q.looksLikeFormula,W=q.FormulaError,Z=q.tokenise,V=G("packages/core/src/formula/evaluate.js"),U=V.evaluateAst,x=V.FUNCTIONS;function I(k){const{grid:y,row:l,data:u}=k||{},n=o=>String(o).toLowerCase().replace(/[\s_-]/g,""),t=y&&y.columns&&typeof y.columns.all=="function"?y.columns.all():[],i=y&&y.permissions,s=i&&typeof i.isReadable=="function"?o=>i.isReadable(o):()=>!0,r=new Set;for(const o of t)s(o)||(r.add(n(o.id)),o.field&&r.add(n(o.field)),o.title&&r.add(n(o.title)));return o=>{const c=n(o);if(r.has(c))throw new W(`"${o}" cannot be read`);for(const a of t)if(n(a.id)===c||a.field&&n(a.field)===c||a.title&&n(a.title)===c)return l&&y.rows&&typeof y.rows.value=="function"?y.rows.value(l.key,a.id):u?u[a.field||a.id]:void 0;if(u&&typeof u=="object"){for(const a of Object.keys(u))if(n(a)===c){if(!s(a))throw new W(`"${o}" cannot be read`);return u[a]}}}}function v(k,y={}){try{const l=M(k);return{ok:!0,value:U(l,{lookup:I(y),functions:y.formulaFunctions}),references:$(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}}}}),Ae("packages/core/src/defaults.js",function(e,G){"use strict";Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"applyDefaults",{enumerable:!0,get:function(){return U}});const q=G("packages/core/src/internal/util.js"),M=q.isObject,$=q.merge,N=q.warnOnce;let W=null;function Z(x){if(Array.isArray(x))return x.map(Z);if(!M(x)||Object.getPrototypeOf(x)!==Object.prototype&&Object.getPrototypeOf(x)!==null)return x;const I={};for(const[v,k]of Object.entries(x))I[v]=Z(k);return I}function V(x){return x===void 0?Z(W??{}):x===null?(W=null,{}):M(x)?(W=Z(x),Z(W)):(N("defaults:type",`defaults() expects a configuration object, or null to clear it, but got ${Array.isArray(x)?"an array":typeof x}. The call was ignored and the defaults are unchanged.`),Z(W??{}))}function U(x){return W===null?x:$(Z(W),x)}}),Ae("packages/core/src/events/names.js",function(e,G){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"isKnownEvent",{enumerable:!0,get:function(){return $}});const q=Object.freeze(["ready","destroy","render:first","render:done","config:changed","licence:changed","model:changed","rows:changed","rows:queued","rows:deferred","rows:paused","rows:resumed","row:received","row:sent","row:copied","row:moved","source:error","source:total","stream:chunk","stream:end","stream:evicted","rowDrag:started","rowDrag:moved","rowDrag:left","rowDrag:ended","cell:changed","cell:pending","cell:confirmed","cell:reverted","cell:conflict","cell:clicked","cell:dblclicked","cell:contextmenu","cell:mouseover","cell:mouseout","cell:mousedown","cell:mouseup","cell:edit:start","cell:edit:end","row:edit:start","row:edit:end","row:clicked","row:dblclicked","row:pending","row:confirmed","row:reverted","row:conflict","form:opened","form:closed","form:saved","form:error","sort:changed","filter:changed","group:toggled","facet:computed","facet:filtered","facet:expanded","facet:failed","column:moved","column:resized","column:visible","column:pinned","column:grouped","column:pivoted","column:filter:open","column:profile:open","column:menu:open","columns:changed","columns:tagged","columngroup:changed","header:contextmenu","pivot:drill","selection:changed","range:changed","clipboard:copy","page:changed","scroll","scroll:end","size:changed","detail:toggled","detail:cell:edit:start","detail:cell:edit:end","detail:row:edit:start","detail:row:edit:end","detail:cell:changed","toolpanel:focus","highlight:changed","find:changed","tree:loading","tree:loaded","tree:loadFailed","tree:loadAborted","state:changed","state:reset","history:changed","history:applied","views:changed","view:applied","view:saved","view:removed","view:renamed","view:default","validation:failed","validation:cleared","formatting:changed","redaction:changed","permissions:changed","presentation:changed","presentation:started","presentation:ended","presentation:view","presentation:scale","presentation:spotlight","presentation:captured","comment:added","comment:edited","comment:deleted","comment:failed","comment:resolved","comment:unresolved","comment:threadOpened","comment:threadClosed","comment:indexLoaded","presence:published","presence:joined","presence:updated","presence:left","presence:failed","presence:lockRefused","diff:changed","diff:swapped","timeline:attached","timeline:detached","timeline:seek","timeline:seeking","annotation:changed","export:progress","export:request","export:done","shortcuts:opened","shortcuts:closed","print:before","print:after","beforeEdit","beforeSort","beforeFilter","beforeColumnMove","beforeColumnResize","beforeColumnHide","beforeSelect","beforeRowAdd","beforeDelete","beforeRowMove","beforeGroup","beforeRowReceive","edit:cancelled","sort:cancelled","filter:cancelled","columnMove:cancelled","columnResize:cancelled","columnHide:cancelled","selection:cancelled","rowAdd:cancelled","delete:cancelled","rowMove:cancelled","group:cancelled","rowReceive:cancelled"]),M=new Set(q);function $(N){return N==="*"||M.has(N)}}),Ae("packages/core/src/events/bus.js",function(e,G){"use strict";Object.defineProperty(e,"WILDCARD",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return l}});const q=G("packages/core/src/internal/util.js"),M=q.warnOnce,$=q.uid,N=q.DEV,Z=G("packages/core/src/events/names.js").isKnownEvent,V="*";function U(u,n){!N||Z(n)||M(`bus.unknown:${n}`,`${u}('${n}') 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 x=new Set(["api","user","init","ai"]),I=new WeakMap;function v(u){let n=I.get(u);return n||(n=$("h"),I.set(u,n)),n}function k(){return typeof performance=="object"&&performance?performance.now():Date.now()}function y(u){if(!u||typeof u!="object")return{};const n={};for(const[t,i]of Object.entries(u))t!=="grid"&&(i==null?n[t]=String(i):Array.isArray(i)?n[t]=`[${i.length}]`:typeof i=="object"?n[t]=i.key?`row ${i.key}`:"{…}":typeof i=="function"?n[t]="[function]":n[t]=String(i).slice(0,60));return n}class l{#e=new Map;#t=!1;#n=[];#r=200;#o=new Map;#i=null;#s=!1;#l=0;constructor(n=null){this.#i=n}attach(n){this.#i=n}get grid(){return this.#i}get destroyed(){return this.#s}on(n,t){if(typeof t!="function")return M(`bus.handler:${n}`,`on('${n}') needs a function; ignored.`),()=>{};U("on",n);let i=this.#e.get(n);return i||(i=[],this.#e.set(n,i)),i.push(t),()=>this.off(n,t)}once(n,t){if(typeof t!="function")return M(`bus.handler:${n}`,`once('${n}') needs a function; ignored.`),()=>{};U("once",n);const i=s=>{this.off(n,t),t(s)};return this.#o.set(t,i),this.on(n,i)}off(n,t){if(t===void 0){this.#e.delete(n);return}const i=this.#e.get(n);if(!i)return;const s=this.#o.get(t),r=s&&i.includes(s)?s:t,o=i.indexOf(r);o>=0&&i.splice(o,1),s&&r===s&&this.#o.delete(t),i.length===0&&this.#e.delete(n)}count(n){const t=this.#e.get(n),i=n===V?null:this.#e.get(V);return(t?t.length:0)+(i?i.length:0)}#a(n,t,i,s,r){this.#n.push({type:n,origin:t,listeners:(s?s.length:0)+(r?r.length:0),payload:y(i),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(n,t){this.#t=!!n,Number.isFinite(t)&&t>0&&(this.#r=Math.floor(t)),n||(this.#n=[])}eventLog(){return this.#n.map(n=>({...n}))}clearEventLog(){this.#n=[]}counts(){const n={};for(const[t,i]of this.#e)n[t]=i.length;return n}emit(n,t,i){const s=i??(t&&t.origin),r=x.has(s)?s:"api",o={...t||null,type:n,origin:r,grid:this.#i};if(this.#s)return o;const c=this.#e.get(n),a=n===V?void 0:this.#e.get(V);if(this.#t&&this.#a(n,r,t,c,a),!c&&!a)return o;const g=this.#t?k():0;this.#l++;try{c&&this.#u(c.slice(),o,n),a&&this.#u(a.slice(),o,V)}finally{this.#l--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=k()-g)}return o}emitBefore(n,t,i){const s=i??(t&&t.origin),r=x.has(s)?s:"user";let o=!1,c=null;const a=w=>{o=!0,w!=null&&c===null&&(c=String(w))},g={...t||null,type:n,origin:r,grid:this.#i,get defaultPrevented(){return o},get reason(){return c},preventDefault(w){a(w)}};if(this.#s)return!0;const h=this.#e.get(n);this.#t&&this.#a(n,r,t,h,void 0);const b=h?h.slice():[];if(b.length===0)return!0;const p=()=>(o&&c===null&&(c="prevented"),o&&t&&typeof t=="object"&&(t.reason=c),!o),f=[];for(const w of b)try{const S=w(g);S&&typeof S.then=="function"?f.push(S):S===!1&&a("prevented")}catch(S){a("error"),M(`bus.beforeThrow:${n}:${v(w)}`,`a '${n}' before-handler threw; the action was cancelled.`,S)}return f.length===0?p():Promise.allSettled(f).then(w=>{for(const S of w)S.status==="rejected"?(a("error"),M(`bus.beforeReject:${n}`,`a '${n}' before-handler rejected; the action was cancelled.`,S.reason)):S.value===!1&&a("prevented");return p()})}#u(n,t,i){for(let s=0;s<n.length;s++)try{n[s](t)}catch(r){M(`bus.throw:${i}:${v(n[s])}`,`a '${i}' handler threw; other handlers were unaffected.`,r)}}clear(){this.#e.clear(),this.#o.clear()}destroy(){this.clear(),this.#s=!0,this.#i=null}}}),Ae("packages/core/src/registry/licence.js",function(e,G){"use strict";Object.defineProperty(e,"PRODUCT",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"LICENCE_VERSION",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"PUBLIC_KEY",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"fromBase64Url",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"toBase64Url",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"asciiBytes",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"hasEd25519",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"currentHost",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return j}});const M=G("packages/core/src/internal/util.js").warnOnce,$="lattice-grid",N=1,W="LG1",Z=64,V="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",U="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",x=(()=>{const E=new Int16Array(128).fill(-1);for(let O=0;O<U.length;O++)E[U.charCodeAt(O)]=O;return E[43]=62,E[47]=63,E})();function I(E){if(typeof E!="string")return null;let O="";for(let H=0;H<E.length;H++){const D=E.charCodeAt(H);if(D!==61){if(D>127||x[D]<0)return null;O+=E[H]}}const T=O.length;if(T%4===1)return null;const A=new Uint8Array(Math.floor(T*3/4));let P=0,L=0,z=0;for(let H=0;H<T;H++)P=P<<6|x[O.charCodeAt(H)],L+=6,L>=8&&(L-=8,A[z++]=P>>L&255);return z===A.length?A:A.subarray(0,z)}function v(E){let O="",T=0;for(;T+2<E.length;T+=3){const P=E[T]<<16|E[T+1]<<8|E[T+2];O+=U[P>>18&63]+U[P>>12&63]+U[P>>6&63]+U[P&63]}const A=E.length-T;if(A===1){const P=E[T]<<16;O+=U[P>>18&63]+U[P>>12&63]}else if(A===2){const P=E[T]<<16|E[T+1]<<8;O+=U[P>>18&63]+U[P>>12&63]+U[P>>6&63]}return O}function k(E){const O=new Uint8Array(E.length);for(let T=0;T<E.length;T++)O[T]=E.charCodeAt(T)&127;return O}function y(E){if(typeof TextDecoder=="function")return new TextDecoder().decode(E);let O="";for(let T=0;T<E.length;T++)O+=String.fromCharCode(E[T]);return O}function l(E){const O={ok:!1,reason:"malformed",product:null,issuedTo:null,expires:null,features:[],deployments:[],version:0,message:null,signature:null,raw:typeof E=="string"?E:""};if(typeof E!="string"||E.length===0)return{...O,reason:"missing"};const T=E.trim(),A=T.split(".");if(A.length!==3)return O;const[P,L,z]=A;if(P!==W)return{...O,reason:"prefix"};const H=I(L),D=I(z);if(!H||!D)return O;let F;try{F=JSON.parse(y(H))}catch{return O}return F===null||typeof F!="object"?O:{ok:!0,reason:null,product:typeof F.p=="string"?F.p:null,issuedTo:typeof F.t=="string"?F.t:null,expires:typeof F.e=="string"?F.e:null,features:Array.isArray(F.f)?F.f.slice():[],deployments:Array.isArray(F.d)?F.d.slice():[],version:typeof F.v=="number"?F.v:0,message:k(L),signature:D,raw:T}}function u(E,O){if(!E)return!1;const T=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(E)?`${E}T23:59:59.999Z`:E);return Number.isNaN(T)?!0:O>T}let n=null,t=null,i=null;function s(){const E=globalThis.crypto;return E&&E.subtle?E.subtle:null}async function r(E){if(n&&t===E)return n;const O=s();if(!O)return null;const T=I(E);if(!T)return null;try{const A=await O.importKey("raw",T,{name:"Ed25519"},!1,["verify"]);return n=A,t=E,A}catch{return null}}async function o(){return i!==null||(i=await r(V)!==null),i}async function c(E,O={}){const T=O.warn!==!1,A=O.product||$,P=O.publicKey||V,L=O.now??Date.now(),z=l(E);if(!z.ok){const _=z.reason==="missing"?"missing":"malformed";return T&&M(`licence.${_}`,_==="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:_}}const H={product:z.product||void 0,issuedTo:z.issuedTo||void 0,expires:z.expires||void 0};if(z.product!==A)return T&&M("licence.product",`licence key is for '${z.product}', not '${A}'. The grid will render with a watermark.`),{valid:!1,...H,reason:"product"};if(u(z.expires,L))return T&&M("licence.expired",`licence expired on ${z.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...H,reason:"expired"};const D=O.host??g(),F=z.deployments||[];if(F.length&&D&&!a(D)&&!h(D,F))return T&&M("licence.domain",`licence key is not valid for ${D}; it covers ${F.join(", ")}. The grid will render with a watermark.`),{valid:!1,...H,reason:"domain"};const C=await r(P);if(!C){const _=!!z.signature&&z.signature.length===Z;return T&&M("licence.algorithm","this host does not provide crypto.subtle Ed25519, so the licence signature could not be verified. A structural check was used instead."),_?{valid:!0,...H,reason:"unverified"}:{valid:!1,...H,reason:"signature"}}let B=!1;try{B=await s().verify({name:"Ed25519"},C,z.signature,z.message)}catch{B=!1}return B?{valid:!0,...H}:(T&&M("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...H,reason:"signature"})}function a(E){const O=String(E??g()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!O||O==="localhost"||O.endsWith(".localhost")||O==="::1"||O==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(O)}function g(){const E=globalThis.location;return E&&typeof E.hostname=="string"?E.hostname:null}function h(E,O){const T=b(E);return!T||!Array.isArray(O)?!1:O.some(A=>{const P=b(A);if(!P)return!1;if(P==="*")return!0;if(P.startsWith("*.")){const L=P.slice(2);return T===L||T.endsWith(`.${L}`)}return T===P})}function b(E){return String(E??"").trim().toLowerCase().replace(/\.$/,"")}class p{#e="";#t={valid:!1,reason:"missing"};#n=null;#r=null;#o;#i=new Set;constructor(O={}){this.#o=O}set(O){this.#e=typeof O=="string"?O.trim():"";const T=l(this.#e);return this.#t=T.ok?{valid:!u(T.expires,Date.now())&&T.product===(this.#o.product||$),product:T.product||void 0,issuedTo:T.issuedTo||void 0,expires:T.expires||void 0,reason:"pending"}:{valid:!1,reason:T.reason||"malformed"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const O=this.#e;return this.#n=c(O,this.#o).then(T=>{if(this.#e===O){this.#t=T;for(const A of this.#i)A(T)}return T}),this.#n}onSettled(O){return this.#i.add(O),()=>this.#i.delete(O)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!a(this.#r)}setHost(O){this.#r=O}state(){return this.#t.valid?"licensed":a(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing"},this.#n=null,this.#i.clear()}}const f=new p;function w(E){return f.set(E)}function S(){return f.info()}function m(){return f.watermark()}function d(){return f.state()}function j(){return f}}),Ae("packages/core/src/registry/registry.js",function(e,G){"use strict";Object.defineProperty(e,"KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"REGIONS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return i}});const q=G("packages/core/src/internal/util.js"),M=q.warnOnce,$=q.isFunction,N=q.DEV,W=G("packages/core/src/registry/licence.js"),Z=W.LicenceHolder,V=W.sharedLicence,U=["renderer","editor","filter","dataType","totalFn","pipe","component"],x=["all","header","body","totals","panels"];class I{#e=new Map;#t=new Map;#n=new Set;#r=new Set;#o;#i=null;#s=null;#l=new Set;#a=new Map;constructor(r={}){for(const o of U)this.#t.set(o,new Map);this.#o=r.holder||V(),this.#s=r.grid??null,this.#i=this.#o.onSettled(()=>{this.#d({reason:"licence",name:"licence",capabilities:this.capabilities(),regions:["all"]})}),r.licence&&this.setLicence(r.licence)}registerModules(r,o={}){o.licence&&this.setLicence(o.licence),o.grid!==void 0&&(this.#s=o.grid);const c=Array.isArray(r)?r:[r],a=[];for(const g of c){if(!g||typeof g!="object"||typeof g.name!="string"||!g.name){M("registry.module.shape","registerModules received something that is not a module; ignored.");continue}if(this.#e.has(g.name)){N&&this.#c(this.#e.get(g.name),g);continue}if(!$(g.install)){M(`registry.module.install:${g.name}`,`module '${g.name}' has no install() and was ignored.`);continue}const h={registry:this,grid:this.#s};try{g.install(h)}catch(b){M(`registry.module.throw:${g.name}`,`module '${g.name}' threw during install; it was not registered.`,b);continue}this.#e.set(g.name,g);for(const b of v(g))this.#n.add(b);a.push(g.name),this.#d({reason:"module",name:g.name,capabilities:this.capabilities(),regions:l(g)})}return a}unregisterModule(r){const o=this.#e.get(r);if(!o)return!1;if($(o.uninstall))try{o.uninstall({registry:this,grid:this.#s})}catch(c){M(`registry.module.uninstall:${r}`,`module '${r}' threw during uninstall.`,c)}return this.#e.delete(r),this.#u(),this.#d({reason:"unmodule",name:r,capabilities:this.capabilities(),regions:l(o)}),!0}modules(){return[...this.#e.values()]}has(r){return this.#e.has(r)}#u(){this.#n.clear();for(const r of this.#e.values())for(const o of v(r))this.#n.add(o)}#c(r,o){!r||r===o||k(r,o)||M(`registry.module.reconfigure:${o.name}`,`module '${o.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(r){return this.#n.has(r)}onChange(r){return $(r)?(this.#r.add(r),this.#a.set(r,this.#s),()=>{this.#r.delete(r),this.#a.delete(r)}):()=>{}}#d(r){for(const o of[...this.#r])try{o(r)}catch(c){M("registry.onChange.throw","a registry change handler threw.",c)}}register(r,o,c){const a=this.#t.get(r);if(!a){M(`registry.kind:${r}`,`unknown registry kind '${r}'; expected one of ${U.join(", ")}.`);return}if(!o||typeof o!="string"){M(`registry.name:${r}`,`register('${r}', ...) needs a name.`);return}a.has(o)&&a.get(o)!==c&&M(`registry.replace:${r}:${o}`,`'${o}' was already registered as a ${r} and has been replaced.`),a.set(o,c),this.#d({reason:"register",name:o,kind:r,capabilities:this.capabilities(),regions:u(r)})}registerAll(r,o){if(o)for(const c of Object.keys(o))this.register(r,c,o[c])}get(r,o){const c=this.#t.get(r);return c?c.get(o):void 0}names(r){const o=this.#t.get(r);return o?[...o.keys()]:[]}#h(r,o){const c=this.#t.get(r).get(o);return c!==void 0?c:this.#t.get("component").get(o)}renderer(r){return this.#h("renderer",r)}editor(r){return this.#h("editor",r)}filter(r){return this.#h("filter",r)}dataType(r){return this.get("dataType",r)}totalFn(r){return this.get("totalFn",r)}pipe(r){return this.get("pipe",r)}setLicence(r){return this.#o.set(r)}licence(){return this.#o.info()}licenceVerified(){return this.#o.verify()}watermark(){return this.#o.watermark()}attach(r){r!=null&&(this.#l.add(r),this.#s=r)}detach(r){if(r!=null){this.#l.delete(r);for(const[o,c]of[...this.#a])c===r&&(this.#r.delete(o),this.#a.delete(o));if(this.#s===r){const o=this.#l.size?[...this.#l][this.#l.size-1]:null;this.#s=o}this.#l.size===0&&this.#i&&(this.#i(),this.#i=null)}}destroy(r){if(r!=null){this.detach(r);return}for(const o of[...this.#e.keys()])this.unregisterModule(o);this.#r.clear(),this.#a.clear(),this.#l.clear(),this.#i&&this.#i(),this.#i=null,this.#s=null}}function v(s){const r=s.capabilities,o=Array.isArray(r)?r.filter(c=>typeof c=="string"):[];return[s.name,...o]}function k(s,r){return s.install!==r.install||s.uninstall!==r.uninstall||(s.version||"")!==(r.version||"")?!1:y(v(s),v(r))&&y(l(s),l(r))}function y(s,r){const o=new Set(s),c=new Set(r);if(o.size!==c.size)return!1;for(const a of o)if(!c.has(a))return!1;return!0}function l(s){const r=s.regions;return!Array.isArray(r)||r.length===0?["all"]:r.filter(o=>x.includes(o))}function u(s){switch(s){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const n=new I;function t(){return n}function i(s,r={}){return n.registerModules(s,r)}}),Ae("packages/core/src/format/number.js",function(e,G){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return $}});const M=G("packages/core/src/internal/util.js").isNil;function $(N,W){const Z=N||{},V=Z.locale||W||void 0,U=Z.style||"decimal",x=typeof Z.scale=="number"?Z.scale:1,I=Z.nullDisplay??"",v=Z.zeroDisplay,k=Z.prefix||"",y=Z.suffix||"",l=Z.negative||"minus",u=Z.signed===!0,n={style:U,notation:Z.notation||"standard"};U==="currency"&&(n.currency=Z.currency||"USD",Z.currencyDisplay&&(n.currencyDisplay=Z.currencyDisplay)),typeof Z.decimals=="number"?(n.minimumFractionDigits=Z.decimals,n.maximumFractionDigits=Z.decimals):(typeof Z.minDecimals=="number"&&(n.minimumFractionDigits=Z.minDecimals),typeof Z.maxDecimals=="number"&&(n.maximumFractionDigits=Z.maxDecimals),n.minimumFractionDigits>(n.maximumFractionDigits??20)&&(n.maximumFractionDigits=n.minimumFractionDigits)),Z.thousandsSeparator===!1&&(n.useGrouping=!1),n.notation==="compact"&&(n.compactDisplay=Z.compactDisplay||"short");const t=new Intl.NumberFormat(V,n),i=typeof Z.thousandsSeparator=="string"?Z.thousandsSeparator:null,s=typeof Z.decimalSeparator=="string"?Z.decimalSeparator:null;let r=",",o=".";if(i||s)for(const p of t.formatToParts(12345.6))p.type==="group"?r=p.value:p.type==="decimal"&&(o=p.value);const c=p=>{let f=p;return i&&(f=f.split(r).join("")),s&&(f=f.split(o).join("")),i&&(f=f.split("").join(i)),s&&(f=f.split("").join(s)),f},a=!!(i||s),g=k!==""&&U==="currency",h=p=>{let f;if(g){const w=t.formatToParts(p);let S=!1;f="";for(const m of w)f+=m.value,!S&&m.type==="currency"&&(f+=k,S=!0);S||(f=k+f)}else f=k+t.format(p);return a&&(f=c(f)),f+y},b=p=>{if(M(p)||p==="")return I;const f=typeof p=="number"?p:Number(p);if(Number.isNaN(f))return I;const w=x===1?f:f*x;return w===0&&v!==void 0?v:w<0?l==="parentheses"?`(${h(-w)})`:l==="suffix"?`${h(-w)}-`:h(w):u&&w>0?`+${h(w)}`:h(w)};return b.negativeClass=Z.negativeClass||null,b.spec=Z,b}}),Ae("packages/core/src/format/date.js",function(e,G){"use strict";Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return k}}),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 t}});const q=G("packages/core/src/internal/util.js"),M=q.isNil,$=q.warnOnce,N=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function W(i){const s=[];let r=0,o="";const c=()=>{o&&(s.push({token:null,text:o}),o="")};for(;r<i.length;){const a=i[r];if(a==="'"){if(i[r+1]==="'"){o+="'",r+=2;continue}const h=i.indexOf("'",r+1);if(h===-1){o+=i.slice(r+1),r=i.length;continue}o+=i.slice(r+1,h),r=h+1;continue}const g=N.find(h=>i.startsWith(h,r));if(g){c(),s.push({token:g,text:g}),r+=g.length;continue}/[A-Za-z]/.test(a)&&$(`date.pattern.token:${a}`,`the date pattern "${i}" contains '${a}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${N.join(" ")}.`),o+=a,r+=1}return c(),s}const Z=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function V(i){if(M(i)||i==="")return null;if(i instanceof Date)return Number.isNaN(i.getTime())?null:i;if(typeof i=="number")return Number.isNaN(i)?null:new Date(i);if(typeof i=="string"){const s=Z.exec(i.trim());if(s){const[,o,c,a,g="0",h="0",b="0"]=s;return new Date(+o,+c-1,+a,+g,+h,+b)}const r=new Date(i);return Number.isNaN(r.getTime())?null:r}return null}function U(i,s){return String(i).padStart(s,"0")}function x(i){if(!i)return o=>({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate(),hour:o.getHours(),minute:o.getMinutes(),second:o.getSeconds(),ms:o.getMilliseconds(),weekday:o.getDay()});const s=new Intl.DateTimeFormat("en-US",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),r={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return o=>{const c={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:o.getMilliseconds(),weekday:0};for(const a of s.formatToParts(o))switch(a.type){case"year":c.year=Number(a.value);break;case"month":c.month=Number(a.value);break;case"day":c.day=Number(a.value);break;case"hour":c.hour=Number(a.value)%24;break;case"minute":c.minute=Number(a.value);break;case"second":c.second=Number(a.value);break;case"weekday":c.weekday=r[a.value]??0;break;default:break}return c}}function I(i,s,r){const o=W(i),c=x(r),a=new Set(o.filter(f=>f.token).map(f=>f.token)),g=a.has("MMM")?new Intl.DateTimeFormat(s,{month:"short",timeZone:r}):null,h=a.has("MMMM")?new Intl.DateTimeFormat(s,{month:"long",timeZone:r}):null,b=a.has("EEE")?new Intl.DateTimeFormat(s,{weekday:"short",timeZone:r}):null,p=a.has("EEEE")?new Intl.DateTimeFormat(s,{weekday:"long",timeZone:r}):null;return f=>{const w=c(f);let S="";for(const m of o){if(!m.token){S+=m.text;continue}switch(m.token){case"yyyy":S+=U(w.year,4);break;case"yy":S+=U(w.year%100,2);break;case"MMMM":S+=h.format(f);break;case"MMM":S+=g.format(f);break;case"MM":S+=U(w.month,2);break;case"M":S+=String(w.month);break;case"dd":S+=U(w.day,2);break;case"d":S+=String(w.day);break;case"EEEE":S+=p.format(f);break;case"EEE":S+=b.format(f);break;case"HH":S+=U(w.hour,2);break;case"H":S+=String(w.hour);break;case"hh":S+=U(w.hour%12===0?12:w.hour%12,2);break;case"h":S+=String(w.hour%12===0?12:w.hour%12);break;case"mm":S+=U(w.minute,2);break;case"m":S+=String(w.minute);break;case"ss":S+=U(w.second,2);break;case"s":S+=String(w.second);break;case"SSS":S+=U(w.ms,3);break;case"a":S+=w.hour<12?"AM":"PM";break;default:S+=m.text;break}}return S}}const v=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function k(i,s){const r=i||{},o=r.locale||s||void 0,c=r.nullDisplay??"",a=r.timeZone;let g;if(r.pattern)g=I(r.pattern,o,a);else if(r.dateStyle||r.timeStyle){const w={timeZone:a};r.dateStyle&&(w.dateStyle=r.dateStyle),r.timeStyle&&(w.timeStyle=r.timeStyle);const S=new Intl.DateTimeFormat(o,w);g=m=>S.format(m)}else{const w=new Intl.DateTimeFormat(o,{dateStyle:"medium",timeZone:a});g=S=>w.format(S)}const h=r.relative?new Intl.RelativeTimeFormat(o,{numeric:"auto"}):null,p=(typeof r.relative=="object"&&r.relative?r.relative.threshold??7:7)*24*36e5,f=(w,S)=>{const m=V(w);if(!m)return c;if(h){const d=S&&typeof S.now=="number"?S.now:Date.now(),j=m.getTime()-d;if(Math.abs(j)<p){for(const[E,O]of v)if(Math.abs(j)>=O||E==="second")return h.format(Math.round(j/O),E)}}return g(m)};return f.spec=r,f}function y(i){if(M(i)||i==="")return null;if(typeof i=="string"){const o=/^(\d{4}-\d{2}-\d{2})/.exec(i.trim());if(o)return o[1];const c=V(i);return c?y(c):null}const s=V(i);if(!s)return null;const r=o=>String(o).padStart(2,"0");return`${s.getFullYear()}-${r(s.getMonth()+1)}-${r(s.getDate())}`}function l(i,s){if(M(i)||i==="")return null;if(typeof i=="string"){const o=i.trim();if(u.test(o)){const g=V(o);return g?n(g,s):null}const c=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(o);if(c){const[,g,h,b,p]=c;return`${g}T${h}:${b}${p&&p!=="00"?`:${p}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(o))return`${o}T00:00`;const a=V(o);return a?l(a):null}const r=V(i);return r?n(r,s):null}const u=/(?:Z|[+-]\d{2}:?\d{2})$/i;function n(i,s){const r=g=>String(g).padStart(2,"0");if(s)try{const g=new Intl.DateTimeFormat("en-CA",{timeZone:s,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(i).reduce((p,f)=>(f.type!=="literal"&&(p[f.type]=f.value),p),{}),h=g.hour==="24"?"00":g.hour,b=Number(g.second);return`${g.year}-${g.month}-${g.day}T${h}:${g.minute}`+(b?`:${g.second}`:"")}catch{}const o=`${i.getFullYear()}-${r(i.getMonth()+1)}-${r(i.getDate())}`,c=i.getSeconds(),a=`${r(i.getHours())}:${r(i.getMinutes())}${c?`:${r(c)}`:""}`;return`${o}T${a}`}function t(i,s){const r=M(i)||i===""?null:String(i),o=M(s)||s===""?null:String(s);return r===null?o===null?0:1:o===null||r<o?-1:r>o?1:0}}),Ae("packages/core/src/format/boolean.js",function(e,G){"use strict";Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return Z}});const M=G("packages/core/src/internal/util.js").isNil,$={true:"☑",false:"☐",null:""},N={true:"◉",false:"◯",null:""};function W(V){if(M(V)||V==="")return null;if(typeof V=="boolean")return V;if(typeof V=="number")return V!==0;const U=String(V).trim().toLowerCase();return U==="true"||U==="yes"||U==="y"||U==="1"?!0:U==="false"||U==="no"||U==="n"||U==="0"?!1:null}function Z(V,U){const x=V||{},I=x.display||"text",v=x.trueLabel??"Yes",k=x.falseLabel??"No",y=x.nullLabel??"";let l=v,u=k;const n=y;I==="checkbox"?(l=$.true,u=$.false):I==="switch"?(l=N.true,u=N.false):I==="icon"&&(l=x.trueIcon??v,u=x.falseIcon??k);const t=i=>{const s=W(i);return s===null?n:s?l:u};return t.display=I,t.labels={true:v,false:k,null:y},t.locale=U,t.spec=x,t}}),Ae("packages/core/src/format/text.js",function(e,G){"use strict";Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return N}});const q=G("packages/core/src/internal/util.js"),M=q.isNil,$=q.titleCase;function N(W,Z){const V=W||{},U=V.locale||Z||void 0,x=V.nullDisplay??"",I=V.emptyDisplay??"",v=V.transform||"none",k=typeof V.truncate=="number"?{chars:V.truncate}:V.truncate||null,y=k?k.chars:0,l=k?k.ellipsis??"…":"",u=t=>{switch(v){case"upper":return U?t.toLocaleUpperCase(U):t.toUpperCase();case"lower":return U?t.toLocaleLowerCase(U):t.toLowerCase();case"title":return $(t);default:return t}},n=t=>{if(M(t))return x;let i=typeof t=="string"?t:String(t);return i===""?I:(v!=="none"&&(i=u(i)),y>0&&i.length>y&&(i=i.slice(0,y)+l),i)};return n.spec=V,n}}),Ae("packages/core/src/format/mask.js",function(e,G){"use strict";Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return Z}});const q=new Set(["0","#","?",",","."]),M="\0";function $(U){const x=[];let I="",v=!1;for(let k=0;k<U.length;k++){const y=U[k];if(y==="\\"){I+=y+(U[k+1]??""),k+=1;continue}if(y==='"'){v=!v,I+=y;continue}if(y===";"&&!v){x.push(I),I="";continue}I+=y}return x.push(I),x}function N(U){let x="",I="",v="",k=1,y=!1,l=!1;const u=g=>{l?I+=g:x+=g};for(let g=0;g<U.length;g++){const h=U[g];if(h==="\\"){u(U[g+1]??""),g+=1;continue}if(h==='"'){const b=U.indexOf('"',g+1);u(b===-1?U.slice(g+1):U.slice(g+1,b)),g=b===-1?U.length:b;continue}if(h==="%"){k*=100,u("%");continue}if(h==="@"){y=!0,u("\0");continue}if(q.has(h)){v+=h,l=!0;continue}u(h)}let n=-1;for(let g=v.length-1;g>=0;g--){const h=v[g];if(h==="0"||h==="#"||h==="?"){n=g;break}}let t=!1,i="";for(let g=0;g<v.length;g++){const h=v[g];if(h===","){g>n?k/=1e3:t=!0;continue}i+=h}const s=i.indexOf("."),r=s===-1?i:i.slice(0,s),o=s===-1?"":i.slice(s+1);let c=0;for(const g of r)g==="0"&&(c+=1);let a=0;for(const g of o)g==="0"&&(a+=1);return{prefix:x,suffix:I,minInt:c,minDec:a,maxDec:o.length,grouping:t,scale:k,hasNumber:n!==-1,isText:y}}function W(U,x){const I=new Intl.NumberFormat(x,{minimumIntegerDigits:Math.max(U.minInt,1),minimumFractionDigits:U.minDec,maximumFractionDigits:Math.max(U.maxDec,U.minDec),useGrouping:U.grouping}),{prefix:v,suffix:k,scale:y,hasNumber:l}=U;return u=>{if(!l)return v+k;const n=y===1?u:u*y;return v+I.format(n)+k}}function Z(U,x){const v=$(String(U)).map(N),k=v.map(i=>W(i,x)),y=0,l=v.length>1?1:-1,u=v.length>2?2:-1,n=v.length>3?3:-1,t=i=>{if(i==null||i==="")return"";if(typeof i!="number"||Number.isNaN(i)){const s=Number(i);if(Number.isNaN(s))return n===-1?String(i):(v[n].prefix+v[n].suffix).split("\0").join(String(i));i=s}return i===0&&u!==-1?k[u](0):i<0&&l!==-1?k[l](-i):k[y](i)};return t.spec={mask:U},{format:t,ooxml:V(String(U))}}function V(U){return U.trim()}}),Ae("packages/core/src/format/shorthand.js",function(e,G){"use strict";Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return V}});const q=["currency","number","percent","date","boolean","text","relative"],M=/[#0?@;"\\]/,$=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function N(U){return typeof U!="string"||U===""||Z(U)?!1:M.test(U)}function W(U){return typeof U!="string"||U===""||Z(U)?!1:$.test(U)}function Z(U){const x=U.indexOf(":"),I=x===-1?U:U.slice(0,x);return q.includes(I)?I:null}function V(U){const x=Z(U);if(!x)return null;const I=U.indexOf(":"),v=I===-1?"":U.slice(I+1),k=v===""?[]:v.split(":");switch(x){case"currency":{const y={type:"number",style:"currency",currency:k[0]||"USD"};return k[1]!==void 0&&k[1]!==""&&(y.decimals=Number(k[1])),y}case"number":{const y={type:"number",style:"decimal"};return k[0]!==void 0&&k[0]!==""&&(y.decimals=Number(k[0])),y}case"percent":{const y={type:"number",style:"percent"};return k[0]!==void 0&&k[0]!==""&&(y.decimals=Number(k[0])),y}case"date":return{type:"date",pattern: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 k[0]&&(y.transform=k[0]),k[1]!==void 0&&k[1]!==""&&(y.truncate=Number(k[1])),y}default:return null}}}),Ae("packages/core/src/format/index.js",function(e,G){"use strict";Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return f}});const q=G("packages/core/src/internal/util.js"),M=q.isFunction,$=q.isObject,N=q.warnOnce,W=G("packages/core/src/format/number.js"),Z=W.compileNumber,V=G("packages/core/src/format/date.js"),U=V.compileDate,x=V.scanPattern,I=G("packages/core/src/format/boolean.js"),v=I.compileBoolean,k=G("packages/core/src/format/text.js"),y=k.compileText,l=G("packages/core/src/format/mask.js"),u=l.compileMask,n=G("packages/core/src/format/shorthand.js"),t=n.parseShorthand,i=n.looksLikeMask,s=n.looksLikeDatePattern;Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return W.compileNumber}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return V.compileDate}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return V.compilePattern}}),Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return V.scanPattern}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return V.toDate}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return I.compileBoolean}}),Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return I.toTriState}}),Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return k.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 n.parseShorthand}}),Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return n.looksLikeMask}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return n.looksLikeDatePattern}});const r=new Set(["decimal","currency","percent","unit"]),o=new Set(["type","locale"]),c={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"])};function a(d,j,E){const O=c[j],T=E?`"${E}"`:"with no id";for(const A of d){if(o.has(A)||O.has(A))continue;const P=Object.keys(c).find(L=>L!==j&&c[L].has(A));P?N(`format:inapplicable:${E||""}:${A}`,`column ${T} has format key "${A}", which applies to a ${P} column, not the ${j} column it was applied to; it is ignored.`):N(`format:unknown:${E||""}:${A}`,`column ${T} has an unrecognised format key "${A}" for its ${j} format; it is ignored.`)}}function g(d){if(d.type==="number"||d.type==="date"||d.type==="boolean"||d.type==="text")return!0;const j=r.has(String(d.style));return!!(d.pattern||d.dateStyle||d.timeStyle||d.relative||d.timeZone||d.trueLabel||d.falseLabel||d.display||d.trueIcon||d.falseIcon||d.transform||d.truncate||d.emptyDisplay||j||d.currency||d.decimals!==void 0||d.minDecimals!==void 0||d.maxDecimals!==void 0||d.notation||d.negative||d.scale!==void 0||d.prefix||d.suffix||d.zeroDisplay!==void 0)}function h(d,j){if(d.type==="number"||d.type==="date"||d.type==="boolean"||d.type==="text")return d.type;if(d.pattern||d.dateStyle||d.timeStyle||d.relative||d.timeZone)return"date";if(d.trueLabel||d.falseLabel||d.display||d.trueIcon||d.falseIcon)return"boolean";if(d.transform||d.truncate||d.emptyDisplay)return"text";if(d.style||d.currency||d.decimals!==void 0||d.minDecimals!==void 0||d.maxDecimals!==void 0||d.notation||d.negative||d.scale!==void 0||d.prefix||d.suffix||d.zeroDisplay!==void 0)return"number";const E=j&&j.base;return E==="number"?"number":E==="date"||E==="dateString"?"date":E==="boolean"?"boolean":"text"}function b(d,j=null,E=void 0,O=void 0,T=void 0){if(d==null||d==="")return null;const A=$(d)?Object.keys(d):null;if(typeof d=="function"){const z=(H,D)=>String(d({...D||{},value:H,locale:E})??"");return z.ooxml=j&&j.excel||"General",z}if(typeof d=="string"){if(i(d)){const{format:H,ooxml:D}=u(d,E);return H.ooxml=D,H}const z=t(d)||(s(d)?{type:"date",pattern:d}:null);return z?b(z,j,E,O,T):(N(`format:${d}`,`unrecognised format string "${d}"; the value will be stringified`),null)}if(!$(d))return N("format:shape","format must be a spec object or a string; ignoring",d),null;if(j&&M(j.format)&&!g(d)||j&&M(j.format)&&Array.isArray(j.formatPatterns)&&d.type===void 0)return null;const P=h(d,j);P==="date"&&O&&d.timeZone===void 0&&(d={...d,timeZone:O}),a(A||Object.keys(d),P,T);let L;switch(P){case"number":L=Z(d,E);break;case"date":L=U(d,E);break;case"boolean":L=v(d,E);break;default:L=y(d,E);break}return L.ooxml=f(d,P,E,j),L.kind=P,L}const p={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 f(d,j,E=void 0,O=null){if(j==="date"){if(d.pattern){let z="";for(const H of x(d.pattern))z+=H.token?p[H.token]??H.text:H.text;return z}return O&&O.excel||"yyyy-mm-dd"}if(j==="boolean")return"General";if(j==="text")return"@";if(d.notation==="compact"||d.notation==="scientific")return"General";const T=typeof d.decimals=="number"?d.decimals:typeof d.minDecimals=="number"?d.minDecimals:d.style==="currency"?2:0;let P=`${d.thousandsSeparator===!1?"":"#,#"}#0${T>0?`.${"0".repeat(T)}`:""}`,L="";return d.style==="currency"&&(L+=w(m(d.currency||"USD",E))),d.prefix&&(L+=w(d.prefix)),P=L+P,d.style==="percent"&&(P=`${P}%`),d.suffix&&(P+=w(d.suffix)),d.negative==="parentheses"?`${P};(${P})`:d.negative==="suffix"?`${P};${P}-`:P}function w(d){return`"${String(d).split('"').join("")}"`}const S=new Map;function m(d,j){const E=`${d}|${j||""}`;let O=S.get(E);if(O!==void 0)return O;O=d;try{const A=new Intl.NumberFormat(j,{style:"currency",currency:d}).formatToParts(0).find(P=>P.type==="currency");A&&(O=A.value)}catch{}return S.set(E,O),O}}),Ae("packages/core/src/columns/types/temporal.js",function(e,G){"use strict";Object.defineProperty(e,"MS_SECOND",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"MS_MINUTE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"MS_HOUR",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"MS_DAY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"MS_WEEK",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toTimeMs",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"zonedParts",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"zoneOffsetAt",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"instantFromParts",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"toEpochMs",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"toDurationMs",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(e,"zoneAbbrev",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"resolveZoneName",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return be}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(e,"timestampGroupProjector",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(e,"TEMPORAL_INFERENCE_ORDER",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return tt}});const q=G("packages/core/src/internal/util.js"),M=q.isNil,$=q.isFunction,N=G("packages/core/src/format/date.js"),W=N.toDate,Z=N.compilePattern,V=N.compileDate,U=N.toIsoDateTime,x=N.compareIso,I=864e5,v=Object.freeze({}),k=1e3,y=60*k,l=60*y,u=24*l,n=7*u,t=new WeakMap;function i(Ce,Ge){const He=Ce&&Ce.locale||"",Ye=Ce&&Ce.column;if(!Ye)return He?{locale:He}:v;const ot=t.get(Ye);if(ot&&ot.locale===He)return ot.bag;const ft=Ye.typeOptions||Ye[Ge]||(s(Ye.format)?Ye.format:null),yt={...ft||v,locale:ft&&ft.locale||He||void 0};return t.set(Ye,{locale:He,bag:yt}),yt}function s(Ce){return Ce!==null&&typeof Ce=="object"&&!Array.isArray(Ce)&&!(Ce instanceof Date)}function r(Ce,Ge){const He=Ce===null||Number.isNaN(Ce)?null:Ce,Ye=Ge===null||Number.isNaN(Ge)?null:Ge;return He===null?Ye===null?0:1:Ye===null||He<Ye?-1:He>Ye?1:0}const o=/^(\d{1,2})(?:\s*[:.h]\s*(\d{1,2})(?:\s*[:.]\s*(\d{1,2})(?:[.,](\d{1,3}))?)?)?\s*(a\.?m\.?|p\.?m\.?|a|p)?$/i,c=/^(\d{3,6})$/;function a(Ce,Ge,He,Ye){return!(Ce>=0&&Ce<=23)||!(Ge>=0&&Ge<=59)||!(He>=0&&He<=59)||!(Ye>=0&&Ye<=999)?null:Ce*l+Ge*y+He*k+Ye}function g(Ce){if(M(Ce))return null;const Ge=String(Ce).trim();if(Ge==="")return null;const He=c.exec(Ge);if(He){const Dt=He[1];if(Dt.length===5)return null;const xt=Dt.length===3?1:2;return a(Number(Dt.slice(0,xt)),Number(Dt.slice(xt,xt+2)),Number(Dt.slice(xt+2,xt+4)||0),0)}const Ye=o.exec(Ge);if(!Ye)return null;let ot=Number(Ye[1]);const ft=Number(Ye[2]||0),yt=Number(Ye[3]||0),jt=Ye[4]?Number(Ye[4].padEnd(3,"0")):0,Et=Ye[5]?Ye[5][0].toLowerCase():null;if(Et){if(ot<1||ot>12)return null;ot=ot%12,Et==="p"&&(ot+=12)}return a(ot,ft,yt,jt)}function h(Ce){return M(Ce)||Ce===""?null:typeof Ce=="number"?Number.isFinite(Ce)?(Ce%u+u)%u:null:Ce instanceof Date?Number.isNaN(Ce.getTime())?null:Ce.getHours()*l+Ce.getMinutes()*y+Ce.getSeconds()*k+Ce.getMilliseconds():g(Ce)}const b=new Map;function p(Ce){const Ge=Ce.pattern||"",He=Ce.timeStyle||(Ce.seconds?"medium":"short"),Ye=`${Ce.locale||""}|${Ge}|${He}`;let ot=b.get(Ye);if(ot)return ot;if(Ge)ot=Z(Ge,Ce.locale||void 0,"UTC");else{const ft=new Intl.DateTimeFormat(Ce.locale||void 0,{timeStyle:He,timeZone:"UTC"});ot=yt=>ft.format(yt)}return b.set(Ye,ot),ot}function f(Ce,Ge){const He=Ge||v;if(Ce==null||typeof Ce!="number"||!Number.isFinite(Ce))return He.nullDisplay??"";const Ye=(Ce%u+u)%u;return p(He)(new Date(Ye))}function w(Ce){return Ce instanceof Date?!Number.isNaN(Ce.getTime()):typeof Ce=="number"?Number.isFinite(Ce)&&Ce>=0&&Ce<u:typeof Ce!="string"||!Ce.includes(":")?!1:g(Ce)!==null}function S(Ce){const Ge=h(Ce);return Ge==null?"":f(Ge,{pattern:Ge%k===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const m=new Map;function d(Ce){const Ge=Ce||"";let He=m.get(Ge);return He||(He=new Intl.DateTimeFormat("en-GB",{timeZone:Ce||void 0,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),m.set(Ge,He)),He}function j(Ce,Ge){const He={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const Ye of d(Ge).formatToParts(new Date(Ce)))Ye.type==="year"?He.year=Number(Ye.value):Ye.type==="month"?He.month=Number(Ye.value):Ye.type==="day"?He.day=Number(Ye.value):Ye.type==="hour"?He.hour=Number(Ye.value)%24:Ye.type==="minute"?He.minute=Number(Ye.value):Ye.type==="second"&&(He.second=Number(Ye.value));return He}function E(Ce,Ge){const He=j(Ce,Ge);return Date.UTC(He.year,He.month-1,He.day,He.hour,He.minute,He.second,0)-Math.floor(Ce/1e3)*1e3}function O(Ce,Ge){const He=Ce.hour||0,Ye=Ce.minute||0,ot=Ce.second||0,ft=Ce.ms||0;if(!Ge)return new Date(Ce.year,Ce.month-1,Ce.day,He,Ye,ot,ft).getTime();const yt=Date.UTC(Ce.year,Ce.month-1,Ce.day,He,Ye,ot,ft);let jt=yt-E(yt,Ge);return jt=yt-E(jt,Ge),jt}const T=/(?:Z|[+-]\d{2}:?\d{2})$/i,A=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function P(Ce,Ge){if(M(Ce))return null;const He=String(Ce).trim();if(He==="")return null;const Ye=Ge&&Ge.timeZone||void 0;if(!T.test(He)){const ot=A.exec(He);if(ot){const ft=(ot[4]||"").trim(),yt=ft===""?0:g(ft);if(yt===null)return null;const jt=O({year:Number(ot[1]),month:Number(ot[2]),day:Number(ot[3]),hour:Math.floor(yt/l),minute:Math.floor(yt/y)%60,second:Math.floor(yt/k)%60,ms:yt%k},Ye);return Number.isNaN(jt)?null:new Date(jt)}}return W(He)}function L(Ce){if(typeof Ce=="number")return Number.isFinite(Ce)?Ce:null;const Ge=W(Ce);return Ge?Ge.getTime():null}const z=new Map;function H(Ce){const Ge=[Ce.locale||"",Ce.pattern||"",Ce.dateStyle||"",Ce.timeStyle||"",Ce.timeZone||"",Ce.seconds?"1":""].join("|");let He=z.get(Ge);if(He)return He;const Ye=Ce.pattern?{type:"date",pattern:Ce.pattern,timeZone:Ce.timeZone}:{type:"date",dateStyle:Ce.dateStyle||"medium",timeStyle:Ce.timeStyle||(Ce.seconds?"medium":"short"),timeZone:Ce.timeZone};return He=V(Ye,Ce.locale||void 0),z.set(Ge,He),He}function D(Ce,Ge){const He=Ge||v,Ye=L(Ce);return Ye==null?He.nullDisplay??"":H(He)(Ye)}function F(Ce){return Ce instanceof Date?!Number.isNaN(Ce.getTime()):typeof Ce!="string"||!A.test(Ce.trim())?!1:P(Ce)!==null}const C=Object.freeze([{key:"w",ms:n,intl:"week",long:["week","weeks"],names:["w","wk","wks","week","weeks"]},{key:"d",ms:u,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:k,intl:"second",long:["second","seconds"],names:["s","sec","secs","second","seconds"]},{key:"ms",ms:1,intl:"millisecond",long:["millisecond","milliseconds"],names:["ms","msec","msecs","milli","millis","millisecond","milliseconds"]}]),B=new Map;for(const Ce of C)for(const Ge of Ce.names)B.set(Ge,Ce);const _=Object.freeze(C.filter(Ce=>Ce.key!=="w")),Q=/^(\d+(?:\.\d+)?)\s*([a-z]+)\s*(?:,\s*)?/,Y=/^\d+(?:\.\d+)?$/,J=/^(\d+):([0-5]?\d)(?::([0-5]?\d))?(?:\.(\d{1,3}))?$/;function te(Ce){const Ge=Ce&&Ce.defaultUnit?B.get(String(Ce.defaultUnit).toLowerCase()):null;return Ge?Ge.ms:y}function ee(Ce){return(Ce&&Ce.defaultUnit?B.get(String(Ce.defaultUnit).toLowerCase()):null)||B.get("m")}function oe(Ce,Ge){if(M(Ce))return null;let He=String(Ce).trim().toLowerCase();if(He==="")return null;let Ye=1;if(He[0]==="-"?(Ye=-1,He=He.slice(1).trim()):He[0]==="+"&&(He=He.slice(1).trim()),He==="")return null;const ot=J.exec(He);if(ot){const Et=ot[3]!==void 0,Dt=Number(ot[1])*l+Number(ot[2])*y+(Et?Number(ot[3])*k:0)+(ot[4]?Number(ot[4].padEnd(3,"0")):0);return Ye*Dt}if(Y.test(He))return Math.round(Ye*Number(He)*te(Ge||v));let ft=He,yt=0,jt=0;for(;ft!=="";){const Et=Q.exec(ft);if(!Et)return null;const Dt=B.get(Et[2]);if(!Dt)return null;yt+=Number(Et[1])*Dt.ms,ft=ft.slice(Et[0].length),jt++}return jt===0?null:Math.round(Ye*yt)}function re(Ce){return M(Ce)||Ce===""?null:typeof Ce=="number"?Number.isFinite(Ce)?Ce:null:oe(Ce)}const le=new Map;function ne(Ce,Ge,He){const Ye=`${He||""}|${Ge.intl}`;let ot=le.get(Ye);if(ot===void 0){try{ot=new Intl.NumberFormat(He||void 0,{style:"unit",unit:Ge.intl,unitDisplay:"long"})}catch{ot=null}le.set(Ye,ot)}return ot?ot.format(Ce):`${Ce} ${Ce===1?Ge.long[0]:Ge.long[1]}`}function se(Ce,Ge){return String(Ce).padStart(Ge,"0")}function ae(Ce,Ge){const He=Ge||v;if(Ce==null||typeof Ce!="number"||!Number.isFinite(Ce))return He.nullDisplay??"";const Ye=He.style||"short",ot=Ce<0;let ft=Math.round(Math.abs(Ce));const yt=ot?"-":"";if(ft===0&&He.zeroDisplay!=null)return He.zeroDisplay;if(Ye==="clock"){const xt=Math.floor(ft/l),Gt=Math.floor(ft/y)%60,Yt=Math.floor(ft/k)%60;return`${yt}${se(xt,2)}:${se(Gt,2)}:${se(Yt,2)}`}if(ft===0){const xt=ee(He);return Ye==="long"?ne(0,xt,He.locale):`0${xt.key}`}const jt=He.weeks===!0?C:_,Et=typeof He.maxUnits=="number"&&He.maxUnits>0?He.maxUnits:He.maxUnits===void 0?2:1/0,Dt=[];for(const xt of jt){if(Dt.length>=Et)break;const Gt=Math.floor(ft/xt.ms);Gt!==0&&(ft-=Gt*xt.ms,Dt.push(Ye==="long"?ne(Gt,xt,He.locale):`${Gt}${xt.key}`))}return yt+Dt.join(" ")}function de(Ce){if(typeof Ce!="string")return!1;const Ge=Ce.trim();return Ge===""||J.test(Ge)||!/[a-z]/i.test(Ge)?!1:oe(Ge)!==null}const me=Date.UTC(1899,11,30),Pe=new Map;function Ie(Ce,Ge){const He=Ce||"";let Ye=Pe.get(He);Ye||(Ye=new Intl.DateTimeFormat("en-GB",{timeZone:Ce||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),Pe.set(He,Ye));const ot=typeof Ge=="number"?Ge:Date.now();for(const ft of Ye.formatToParts(new Date(ot)))if(ft.type==="timeZoneName")return ft.value;return""}function ke(Ce){if(Ce)return Ce;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function be(Ce,Ge){const He=ke(Ce),Ye=Ie(Ce,Ge);return Ye?`${He} (${Ye})`:He}function ge(Ce,Ge){if(Ce&&Ce.timeZone)return Ce.timeZone;const He=Ge&&Ge.grid;return(He&&$(He.get)?He.get("timeZone"):void 0)||void 0}function Ee(Ce,Ge){const He=Ge||v,Ye=L(Ce);if(Ye==null)return He.nullDisplay??"";const ot=H(He)(Ye);if(!He.showOrigin)return ot;const ft=He.originZone;return ft?ft===(He.timeZone||ke(He.timeZone))?ot:`${ot} (${be(ft,Ye)})`:`${ot} (no origin recorded)`}function xe(Ce,Ge,He,Ye){if(Ge==="instant"||!Ge)return Ce;const ot=j(Ce,He);if(Ge==="month")return O({year:ot.year,month:ot.month,day:1},He);if(Ge==="week"){const ft=Ye>=1&&Ye<=7?Ye:1,jt=((new Date(Date.UTC(ot.year,ot.month-1,ot.day)).getUTCDay()+6)%7+1-ft+7)%7,Et=new Date(Date.UTC(ot.year,ot.month-1,ot.day-jt));return O({year:Et.getUTCFullYear(),month:Et.getUTCMonth()+1,day:Et.getUTCDate()},He)}return O({year:ot.year,month:ot.month,day:ot.day},He)}function ze(Ce,Ge){const He=Ce&&Ce.group,Ye=He&&He.granularity||"day";if(Ye==="instant")return null;const ot=He&&He.weekStart;return ft=>typeof ft=="number"?xe(ft,Ye,Ge,ot):ft}const _e={time:{base:"number",storage:"float64",matches:w,format:Ce=>f(h(Ce.value),i(Ce,"time")),parse:Ce=>g(Ce.text),compare:(Ce,Ge)=>r(h(Ce),h(Ge)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:Ce=>{const Ge=h(Ce);return Ge===null?null:Ge/I},toStorage:Ce=>h(Ce),toClipboard:S,fromClipboard:g},datetime:{base:"dateString",storage:"dictionary",matches:F,format:Ce=>D(Ce.value,i(Ce,"datetime")),parse:Ce=>U(P(Ce.text,i(Ce,"datetime"))??Ce.text),compare:x,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(Ce,Ge)=>U(Ce,Ge&&Ge.timeZone),toClipboard:Ce=>M(Ce)?"":String(Ce),fromClipboard:Ce=>U(Ce)},duration:{base:"number",storage:"float64",matches:de,format:Ce=>ae(re(Ce.value),i(Ce,"duration")),parse:Ce=>oe(Ce.text,i(Ce,"duration")),compare:(Ce,Ge)=>r(re(Ce),re(Ge)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:Ce=>{const Ge=re(Ce);return Ge===null?null:Ge/I},toStorage:Ce=>re(Ce),toClipboard:Ce=>ae(re(Ce),{style:"short",maxUnits:-1}),fromClipboard:Ce=>oe(Ce)},timestamp:{base:"number",storage:"float64",format:Ce=>{const Ge=i(Ce,"timestamp");return Ee(Ce.value,{...Ge,timeZone:ge(Ge,Ce)})},parse:Ce=>{const Ge=i(Ce,"timestamp"),He=P(Ce.text,{timeZone:ge(Ge,Ce)});return He?He.getTime():null},compare:(Ce,Ge)=>r(L(Ce),L(Ge)),groupProjector:(Ce,Ge)=>ze(Ce,Ge),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(Ce,Ge)=>{const He=L(Ce);if(He==null)return null;const Ye=j(He,Ge&&Ge.timeZone||void 0);return(Date.UTC(Ye.year,Ye.month-1,Ye.day,Ye.hour,Ye.minute,Ye.second)-me)/I},toStorage:Ce=>L(Ce),toClipboard:Ce=>{const Ge=L(Ce);return Ge==null?"":new Date(Ge).toISOString()},fromClipboard:Ce=>L(Ce)}},Xe=["datetime","time","duration"],tt=_e}),Ae("packages/core/src/columns/types/network.js",function(e,G){"use strict";Object.defineProperty(e,"toUint32",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"isIpv4",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"compareIpv4",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"packCidr",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"cidrParts",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isCidr",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"compareCidr",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"netmask",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"addressCount",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"ipv6Groups",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"isIpv6",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return P}});const q=G("packages/core/src/internal/util.js"),M=q.isNil,$=q.Lru,N=4294967295,W=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function Z(L){if(M(L))return null;if(typeof L=="string")return V(L);const z=Number(L);return Number.isFinite(z)?z<0?z<-2147483648?null:z>>>0:z>N?null:Math.trunc(z)>>>0:null}function V(L){if(M(L))return null;const z=String(L).trim();if(z==="")return null;const H=W.exec(z);if(!H)return null;let D=0;for(let F=1;F<=4;F++){const C=H[F];if(C.length>1&&C.charCodeAt(0)===48)return null;const B=Number(C);if(B>255)return null;D=D*256+B}return D}function U(L){const z=Z(L);return z===null?"":`${z>>>24&255}.${z>>>16&255}.${z>>>8&255}.${z&255}`}function x(L){return typeof L=="string"&&V(L)!==null}function I(L,z){const H=Z(L),D=Z(z);return H===null?D===null?0:1:D===null||H<D?-1:H>D?1:0}const v=64,k=N*v+32,y=/^(?:0|[1-9]\d?)$/;function l(L,z){return L*v+z}function u(L){if(M(L))return null;if(typeof L=="string"){const D=n(L);return D===null?null:u(D)}if(typeof L=="object"){const D=Z(L.address),F=Number(L.prefix);return D===null||!Number.isInteger(F)||F<0||F>32?null:{address:D,prefix:F}}const z=Number(L);if(!Number.isInteger(z)||z<0||z>k)return null;const H=z%v;return H>32?null:{address:(z-H)/v,prefix:H}}function n(L){if(M(L))return null;const z=String(L).trim();if(z==="")return null;const H=z.indexOf("/");if(H<0)return null;const D=V(z.slice(0,H));if(D===null)return null;const F=z.slice(H+1).trim();if(!y.test(F))return null;const C=Number(F);return C>32?null:l(D,C)}function t(L){const z=u(L);return z?`${U(z.address)}/${z.prefix}`:""}function i(L){return typeof L=="string"&&n(L)!==null}function s(L,z){const H=u(L),D=u(z);return H?D?H.address!==D.address?H.address<D.address?-1:1:H.prefix-D.prefix:-1:D?1:0}function r(L){return L===0?0:4294967295<<32-L>>>0}function o(L){const z=u(L);return z?(z.address&r(z.prefix))>>>0:null}function c(L){const z=u(L);return z?(z.address&r(z.prefix)|~r(z.prefix)>>>0)>>>0:null}function a(L){const z=u(L);return z?2**(32-z.prefix):null}function g(L){const z=u(L);return z?z.prefix===32?1:z.prefix===31?2:2**(32-z.prefix)-2:null}function h(L,z){const H=u(L);if(!H)return!1;const D=Z(z);if(D===null)return!1;const F=r(H.prefix);return(D&F)>>>0===(H.address&F)>>>0}function b(L,z){const H=o(L),D=o(z);return H===null||D===null?!1:H<=c(z)&&D<=c(L)}const p=/^[0-9a-fA-F]{1,4}$/,f=new $(512);function w(L){if(M(L))return null;let z=String(L).trim();if(z==="")return null;const H=z.indexOf("%");if(H>=0&&(z=z.slice(0,H)),z==="")return null;if(z.indexOf(".")>=0){const Q=z.lastIndexOf(":");if(Q<0)return null;const Y=V(z.slice(Q+1));if(Y===null)return null;z=`${z.slice(0,Q+1)}${(Y>>>16&65535).toString(16)}:${(Y&65535).toString(16)}`}const D=z.split("::");if(D.length>2)return null;const F=S(D[0]);if(F===null)return null;if(D.length===1)return F.length===8?F:null;const C=S(D[1]);if(C===null)return null;const B=8-F.length-C.length;if(B<1)return null;const _=F.slice();for(let Q=0;Q<B;Q++)_.push(0);for(const Q of C)_.push(Q);return _}function S(L){if(L==="")return[];const z=[];for(const H of L.split(":")){if(!p.test(H))return null;z.push(parseInt(H,16))}return z}function m(L){if(typeof L!="string")return w(L);if(f.has(L))return f.get(L);const z=w(L);return f.set(L,z),z}function d(L){if(L[0]===0&&L[1]===0&&L[2]===0&&L[3]===0&&L[4]===0&&L[5]===65535)return`::ffff:${U((L[6]<<16|L[7])>>>0)}`;let z=-1,H=0,D=-1,F=0;for(let _=0;_<8;_++)L[_]===0?(D<0?(D=_,F=1):F++,F>H&&(H=F,z=D)):(D=-1,F=0);if(H<2)return L.map(_=>_.toString(16)).join(":");const C=L.slice(0,z).map(_=>_.toString(16)).join(":"),B=L.slice(z+H).map(_=>_.toString(16)).join(":");return`${C}::${B}`}function j(L){const z=w(L);return z===null?null:d(z)}function E(L){return j(L)??""}function O(L){return typeof L=="string"&&L.indexOf(":")>=0&&w(L)!==null}function T(L,z){const H=m(L),D=m(z);if(!H)return D?1:0;if(!D)return-1;for(let F=0;F<8;F++)if(H[F]!==D[F])return H[F]<D[F]?-1:1;return 0}const A=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:x,parse:L=>V(L.text),compare:I,format:L=>U(L.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:L=>Z(L),toClipboard:L=>U(L),fromClipboard:L=>V(L)},cidr:{base:"number",storage:"float64",matches:i,parse:L=>n(L.text),compare:s,format:L=>t(L.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:L=>{const z=u(L);return z===null?null:l(z.address,z.prefix)},toClipboard:L=>t(L),fromClipboard:L=>n(L)},ipv6:{base:"text",storage:"dictionary",matches:O,parse:L=>j(L.text),compare:T,format:L=>E(L.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",toStorage:L=>j(L),toClipboard:L=>E(L),fromClipboard:L=>j(L)}}),P=A}),Ae("packages/core/src/i18n/catalogue.js",function(e,G){"use strict";Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return M}});const q=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.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.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","overlay.noRows":"No rows to show","overlay.noResults":"No rows match the current filters","overlay.loading":"Loading…","overlay.error":"Something went wrong","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.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.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…","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.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"}),M=Object.freeze(Object.keys(q))}),Ae("packages/core/src/i18n/format.js",function(e,G){"use strict";Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"formatMessage",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"lookup",{enumerable:!0,get:function(){return k}});const M=G("packages/core/src/internal/util.js").isFunction,$=/\{(\w+)\}/g,N=new Map,W=new Map;function Z(y){const l=y||"";if(N.has(l))return N.get(l);let u=null;try{u=new Intl.PluralRules(y||void 0)}catch{u=null}return N.set(l,u),u}function V(y,l,u="conjunction"){const n=Array.isArray(y)?y.filter(s=>s!=null&&s!==""):[];if(n.length===0)return"";if(n.length===1)return String(n[0]);const t=`${l||""}|${u}`;let i=W.get(t);if(i===void 0){try{i=new Intl.ListFormat(l||void 0,{style:"long",type:u})}catch{i=null}W.set(t,i)}return i?i.format(n.map(String)):n.map(String).join(", ")}function U(y,l){return y==null?"":typeof y=="number"?Number.isFinite(y)?y.toLocaleString(l||void 0,{maximumFractionDigits:20}):"":String(y)}function x(y,l,u){if(typeof y=="string")return y;if(!y||typeof y!="object")return"";const n=l&&typeof l.count=="number"?l.count:null;if(n===null)return y.other??"";const t=Z(u),i=t?t.select(n):n===1?"one":"other";return y[i]??y.other??""}function I(y,l={},u){const n=x(y,l,u);return n?n.replace($,(t,i)=>Object.prototype.hasOwnProperty.call(l,i)?U(l[i],u):t):""}function v(y,l,u="en-GB"){return typeof y=="string"&&y?y:typeof l=="string"&&l?l:u}function k(y,l){const u=y?y[l]:void 0;return u==null||M(u)?l:u}}),Ae("packages/core/src/i18n/index.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return k}}),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 u}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return n}});const q=G("packages/core/src/i18n/catalogue.js"),M=q.EN_GB,$=q.MESSAGE_KEYS,N=G("packages/core/src/i18n/format.js"),W=N.formatMessage,Z=N.formatList,V=N.lookup,U=N.resolveLocale,x=G("packages/core/src/internal/util.js"),I=x.isFunction,v=x.warnOnce;Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return q.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return q.MESSAGE_KEYS}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return N.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return N.resolveLocale}});const k="en-GB";class y{#e=k;#t=M;constructor(i={}){this.configure(i)}configure(i={}){this.#e=U(i.locale,i.declared,k);const s=i.messages;if(!s||typeof s!="object"){this.#t=M;return}const r=Object.keys(s).filter(o=>!(o in M));r.length&&v(`i18n:unknown:${r[0]}`,`message keys not in the catalogue and so ignored: ${r.slice(0,5).join(", ")}${r.length>5?`, and ${r.length-5} more`:""}`),this.#t={...M,...s}}get locale(){return this.#e}t(i,s){return W(V(this.#t,i),s||{},this.#e)}list(i,s){return Z(i,this.#e,s)}number(i,s){const r=Number(i);return Number.isFinite(r)?r.toLocaleString(this.#e,s||{maximumFractionDigits:20}):""}}const l=new y;function u(t){return t instanceof y?t:new y(t||{})}function n(t){const i=t&&typeof t=="object"?t:{},s=$.filter(o=>{const c=i[o];return c==null||c===""||I(c)}),r=Object.keys(i).filter(o=>!(o in M));return{missing:s,unknown:r}}}),Ae("packages/core/src/columns/types/structured.js",function(e,G){"use strict";Object.defineProperty(e,"MASK_DEFAULTS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return I}}),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 u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const q=G("packages/core/src/internal/util.js"),M=q.isNil,$=q.isObject,W=G("packages/core/src/i18n/index.js").defaultMessages,Z=Object.freeze({char:"•",length:8,fixedLength:!0,lastVisible:0,emptyDisplay:""});function V(t,i){const s=i||{},r=s.emptyDisplay??Z.emptyDisplay;if(M(t)||t==="")return r;const c=[...typeof s.char=="string"&&s.char!==""?s.char:Z.char][0]||Z.char,a=s.fixedLength??Z.fixedLength,g=Number.isFinite(s.length)&&Number(s.length)>0?Math.floor(Number(s.length)):Z.length,h=typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?String(t):null;let b=0;if(h!==null){const p=Number.isFinite(s.lastVisible)?Math.floor(Number(s.lastVisible)):Z.lastVisible,f=[...h];if(b=p>0&&p<f.length?p:0,b>0){const w=f.slice(f.length-b).join(""),S=Math.max(1,(a?g:f.length)-b);return c.repeat(S)+w}return c.repeat(a?g:Math.max(1,f.length))}return c.repeat(g)}const U=48;function x(t){try{const i=JSON.stringify(t);return i===void 0?null:i}catch{return null}}function I(t,i){if(M(t))return"";const s=Number.isFinite(i&&i.inlineLimit)?Number(i.inlineLimit):U;if(typeof t=="string")return t.length>s?`${t.slice(0,s-1)}…`:t;if(typeof t!="object")return String(t);const r=x(t);if(r!==null&&r.length<=s)return r;if(Array.isArray(t)){const c=t.length;return`[${W.t("count.items",{count:c})}]`}const o=Object.keys(t).length;return`{${W.t("count.keys",{count:o})}}`}function v(t,i){if(t==null)return"null";const s=typeof t;if(s==="number"||s==="boolean"||s==="bigint")return String(t);if(s==="string")return JSON.stringify(t);if(s!=="object")return JSON.stringify(String(t));const r=i||new WeakSet;return r.has(t)?'"[circular]"':(r.add(t),t instanceof Date?JSON.stringify(t.toISOString()):Array.isArray(t)?`[${t.map(a=>v(a,r)).join(",")}]`:`{${Object.keys(t).sort().map(a=>`${JSON.stringify(a)}:${v(t[a],r)}`).join(",")}}`)}function k(t,i){if(M(t))return M(i)?0:1;if(M(i))return-1;const s=v(t),r=v(i);return s<r?-1:s>r?1:0}function y(t){if(M(t))return null;const i=String(t);if(i.trim()==="")return null;try{return JSON.parse(i)}catch{return i}}function l(t){const i=t&&t.cell&&t.cell.props;return $(i)?i:{}}const u=Object.freeze({json:{base:"object",storage:"object",format:t=>I(t&&t.value,l(t&&t.column)),parse:t=>y(t&&t.text),compare:k,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:t=>{if(M(t))return"";if(typeof t=="string")return t;try{const i=JSON.stringify(t,null,2);return i===void 0?String(t):i}catch{return String(t)}},fromClipboard:t=>y(t)},secret:{base:"text",storage:"object",format:t=>V(t&&t.value,l(t&&t.column)),parse:t=>{const i=t&&t.text;return M(i)||String(i)===""?null:String(i)},compare:(t,i)=>{const s=M(t)||t==="",r=M(i)||i==="";return s===r?0:s?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:t=>V(t),fromClipboard:t=>M(t)||String(t)===""?null:String(t)}}),n=u}),Ae("packages/core/src/columns/types/unit.js",function(e,G){"use strict";Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return D}});const q=G("packages/core/src/internal/util.js"),M=q.isNil,$=q.warnOnce;function N(F,C,B,_){return Object.freeze({symbol:F,factor:C,aliases:Object.freeze(B||[]),binary:!!(_&&_.binary),prefix:_&&_.prefix||null,auto:!(_&&_.auto===!1)})}function W(F,C,B,_){return N(F,C,B,_)}const Z=Object.freeze({data:Object.freeze([N("B",1,["byte","bytes"]),N("kB",1e3,["kilobyte","kilobytes"],{prefix:"k"}),N("KiB",1024,["kibibyte","kibibytes"],{binary:!0,prefix:"k"}),N("MB",1e6,["megabyte","megabytes"],{prefix:"m"}),N("MiB",1024**2,["mebibyte","mebibytes"],{binary:!0,prefix:"m"}),N("GB",1e9,["gigabyte","gigabytes"],{prefix:"g"}),N("GiB",1024**3,["gibibyte","gibibytes"],{binary:!0,prefix:"g"}),N("TB",1e12,["terabyte","terabytes"],{prefix:"t"}),N("TiB",1024**4,["tebibyte","tebibytes"],{binary:!0,prefix:"t"}),N("PB",1e15,["petabyte","petabytes"],{prefix:"p"})]),bitrate:Object.freeze([N("bps",1,["bit","bits","bit/s","b/s"]),N("kbps",1e3,["kbit","kbits","kbit/s","kb/s","kilobit","kilobits"],{prefix:"k"}),N("Mbps",1e6,["mbit","mbits","mbit/s","mb/s","megabit","megabits"],{prefix:"m"}),N("Gbps",1e9,["gbit","gbits","gbit/s","gb/s","gigabit","gigabits"],{prefix:"g"}),N("Tbps",1e12,["tbit","tbits","tbit/s","tb/s","terabit","terabits"],{prefix:"t"})]),length:Object.freeze([N("nm",1e-9,["nanometre","nanometres","nanometer","nanometers"]),N("µm",1e-6,["um","micrometre","micrometres","micrometer","micrometers","micron","microns"]),N("mm",.001,["millimetre","millimetres","millimeter","millimeters"]),N("cm",.01,["centimetre","centimetres","centimeter","centimeters"]),N("in",.0254,["inch","inches"],{auto:!1}),N("ft",.3048,["foot","feet"],{auto:!1}),N("yd",.9144,["yard","yards"],{auto:!1}),N("m",1,["metre","metres","meter","meters"]),N("km",1e3,["kilometre","kilometres","kilometer","kilometers"]),N("mi",1609.344,["mile","miles"],{auto:!1}),N("nmi",1852,["nauticalmile","nauticalmiles"],{auto:!1})]),mass:Object.freeze([N("mg",.001,["milligram","milligrams"]),N("g",1,["gram","grams"]),N("oz",28.349523125,["ounce","ounces"],{auto:!1}),N("lb",453.59237,["pound","pounds","lbs"],{auto:!1}),N("kg",1e3,["kilogram","kilograms"]),N("st",6350.29318,["stone"],{auto:!1}),N("t",1e6,["tonne","tonnes","ton"],{auto:!1}),N("ton (US)",907184.74,["ton","shortton"],{auto:!1}),N("ton (UK)",10160469088e-4,["ton","longton"],{auto:!1})]),duration:Object.freeze([N("ns",1e-9,["nsec","nsecs","nanosecond","nanoseconds"]),N("µs",1e-6,["us","usec","usecs","microsecond","microseconds"]),N("ms",.001,["msec","msecs","millisecond","milliseconds"]),N("s",1,["sec","secs","second","seconds"]),N("m",60,["min","mins","minute","minutes"]),N("h",3600,["hr","hrs","hour","hours"]),N("d",86400,["day","days"])]),speed:Object.freeze([N("mm/s",.001,["millimetre/s","millimeter/s"]),N("ft/s",.3048,["fps","foot/s","feet/s"],{auto:!1}),N("km/h",1/3.6,["kph","kmh","kilometre/h","kilometer/h"],{auto:!1}),N("mph",.44704,["mile/h","miles/h"],{auto:!1}),N("kn",1852/3600,["knot","knots"],{auto:!1}),N("m/s",1,["metre/s","meter/s","mps"]),N("km/s",1e3,["kilometre/s","kilometer/s"])]),acceleration:Object.freeze([N("mm/s²",.001,["mm/s2"]),N("ft/s²",.3048,["ft/s2"],{auto:!1}),N("m/s²",1,["m/s2","metre/s2","meter/s2"]),N("g",9.80665,["gee","gravity"],{auto:!1})]),area:Object.freeze([N("mm²",1e-6,["mm2"]),N("cm²",1e-4,["cm2"]),N("in²",64516e-8,["in2","sqin"],{auto:!1}),N("ft²",.09290304,["ft2","sqft"],{auto:!1}),N("yd²",.83612736,["yd2","sqyd"],{auto:!1}),N("m²",1,["m2","sqm"]),N("ha",1e4,["hectare","hectares"],{auto:!1}),N("ac",4046.8564224,["acre","acres"],{auto:!1}),N("km²",1e6,["km2","sqkm"])]),volume:Object.freeze([N("µL",1e-6,["ul","microlitre","microliter"]),N("mL",.001,["millilitre","milliliter"]),N("fl oz (US)",.0295735295625,["fl oz","usfloz"],{auto:!1}),N("fl oz (imp)",.0284130625,["fl oz","impfloz"],{auto:!1}),N("L",1,["litre","litres","liter","liters"]),N("gal (US)",3.785411784,["gal","usgal","usgallon"],{auto:!1}),N("gal (imp)",4.54609,["gal","impgal","impgallon"],{auto:!1}),N("m³",1e3,["m3","cubicmetre","cubicmeter","kl"],{auto:!1}),N("bbl",158.987294928,["barrel","barrels"],{auto:!1})]),energy:Object.freeze([N("eV",1602176634e-28,["electronvolt","electronvolts"],{auto:!1}),N("J",1,["joule","joules"]),N("cal",4.184,["calorie","calories"],{auto:!1}),N("kJ",1e3,["kilojoule","kilojoules"]),N("BTU",1055.05585262,["btu"],{auto:!1}),N("kcal",4184,["kilocalorie","kilocalories","Cal"],{auto:!1}),N("MJ",1e6,["megajoule","megajoules"]),N("kWh",36e5,["kilowatthour","kilowatthours"],{auto:!1}),N("GJ",1e9,["gigajoule","gigajoules"]),N("MWh",36e8,["megawatthour","megawatthours"],{auto:!1})]),power:Object.freeze([N("mW",.001,["milliwatt","milliwatts"]),N("W",1,["watt","watts"]),N("BTU/h",1055.05585262/3600,["btuh","btu/h"],{auto:!1}),N("kW",1e3,["kilowatt","kilowatts"]),N("hp",745.6998715822702,["horsepower"],{auto:!1}),N("MW",1e6,["megawatt","megawatts"]),N("GW",1e9,["gigawatt","gigawatts"])]),force:Object.freeze([N("mN",.001,["millinewton","millinewtons"]),N("N",1,["newton","newtons"]),N("lbf",4.4482216152605,["poundforce"],{auto:!1}),N("kgf",9.80665,["kilogramforce"],{auto:!1}),N("kN",1e3,["kilonewton","kilonewtons"]),N("MN",1e6,["meganewton","meganewtons"])]),pressure:Object.freeze([N("Pa",1,["pascal","pascals"]),N("mbar",100,["millibar"],{auto:!1}),N("inH₂O",249.0889,["inh2o"],{auto:!1}),N("mmHg",133.322387415,["torr"],{auto:!1}),N("kPa",1e3,["kilopascal","kilopascals"]),N("inHg",3386.388640341,["inhg"],{auto:!1}),N("psi",6894.757293168361,["lbf/in2"],{auto:!1}),N("bar",1e5,[],{auto:!1}),N("atm",101325,["atmosphere","atmospheres"],{auto:!1}),N("MPa",1e6,["megapascal","megapascals"]),N("GPa",1e9,["gigapascal","gigapascals"])]),torque:Object.freeze([N("N·m",1,["nm","n.m","newtonmetre","newtonmeter"]),N("lbf·ft",1.3558179483314003,["lbfft","lbf.ft","ftlb","ft-lb"],{auto:!1}),N("kN·m",1e3,["knm","kn.m"],{auto:!1}),N("MN·m",1e6,["mnm","mn.m"],{auto:!1})]),density:Object.freeze([N("kg/m³",1,["kg/m3"]),N("lb/ft³",16.01846337396014,["lb/ft3","pcf"],{auto:!1}),N("g/cm³",1e3,["g/cm3","g/ml","kg/l"],{auto:!1}),N("t/m³",1e3,["t/m3"],{auto:!1})]),flow:Object.freeze([N("L/min",1/6e4,["lpm","l/min"],{auto:!1}),N("m³/h",1/3600,["m3/h","cmh"],{auto:!1}),N("gpm (US)",.003785411784/60,["gpm","usgpm"],{auto:!1}),N("gpm (imp)",.00454609/60,["gpm","impgpm"],{auto:!1}),N("cfm",.0004719474432,["ft3/min"],{auto:!1}),N("L/s",.001,["lps","l/s"],{auto:!1}),N("m³/s",1,["m3/s","cms"])]),angle:Object.freeze([N("″",Math.PI/648e3,["arcsec","arcsecond","arcseconds"],{auto:!1}),N("′",Math.PI/10800,["arcmin","arcminute","arcminutes"],{auto:!1}),N("mrad",.001,["milliradian","milliradians"],{auto:!1}),N("mil",Math.PI/3200,["nato-mil"],{auto:!1}),N("°",Math.PI/180,["deg","degree","degrees"],{auto:!1}),N("gon",Math.PI/200,["grad","gradian","gradians"],{auto:!1}),N("rad",1,["radian","radians"]),N("turn",2*Math.PI,["rev","revolution","revolutions"],{auto:!1})]),angularVelocity:Object.freeze([N("°/s",Math.PI/180,["degps","deg/s","degrees/s"],{auto:!1}),N("rad/s",1,["radps","radians/s"]),N("rpm",2*Math.PI/60,["rev/min","r/min","revolutions/min"],{auto:!1}),N("rps",2*Math.PI,["rev/s","r/s","revolutions/s"],{auto:!1})]),fraction:Object.freeze([N("ppt",1e-12,["partspertrillion"],{auto:!1}),N("ppb",1e-9,["partsperbillion"]),N("ppm",1e-6,["partspermillion"]),N("bp",1e-4,["bps-finance","basispoint","basispoints","bips"],{auto:!1}),N("‰",.001,["permille","permil"],{auto:!1}),N("%",.01,["pct","percent"]),N("×",1,["x","ratio","times"])]),molarity:Object.freeze([N("pM",1e-12,["picomolar","picomolarity"]),N("nM",1e-9,["nanomolar","nanomolarity"]),N("µM",1e-6,["um-molar","micromolar","micromolarity"]),N("mM",.001,["millimolar","millimolarity"]),N("M",1,["molar","mol/l","mol/L","molarity"]),N("mol/m³",.001,["mol/m3"],{auto:!1})]),massFlow:Object.freeze([N("mg/s",1e-6,["milligrams/s"]),N("g/s",.001,["grams/s"]),N("kg/h",1/3600,["kilograms/h","kgph"],{auto:!1}),N("kg/s",1,["kilograms/s","kgps"]),N("t/h",1e3/3600,["tonnes/h","tph"],{auto:!1}),N("lb/h",.45359237/3600,["pounds/h","pph"],{auto:!1}),N("t/s",1e3,["tonnes/s"],{auto:!1})]),viscosity:Object.freeze([N("µPa·s",1e-6,["upas","micropascalsecond"]),N("cP",.001,["centipoise"],{auto:!1}),N("mPa·s",.001,["mpas","millipascalsecond"]),N("P",.1,["poise"],{auto:!1}),N("Pa·s",1,["pas","pascalsecond"])]),kinematicViscosity:Object.freeze([N("cSt",1e-6,["centistokes","centistoke"]),N("mm²/s",1e-6,["mm2/s"],{auto:!1}),N("St",1e-4,["stokes","stoke"],{auto:!1}),N("m²/s",1,["m2/s"])]),thermalConductivity:Object.freeze([N("mW/(m·K)",.001,["mw/mk"]),N("W/(m·K)",1,["w/mk","wmk"]),N("kW/(m·K)",1e3,["kw/mk"],{auto:!1}),N("BTU/(hr·ft·°F)",1.730734666,["btu/hrftf"],{auto:!1})]),specificHeat:Object.freeze([N("J/(kg·K)",1,["j/kgk","jkgk"]),N("kJ/(kg·K)",1e3,["kj/kgk"]),N("cal/(g·°C)",4184,["cal/gc"],{auto:!1})]),doseRate:Object.freeze([N("nSv/h",1e-9,["nsvh"]),N("µSv/h",1e-6,["usv/h","usvh"]),N("mSv/h",.001,["msvh"]),N("Sv/h",1,["svh"]),N("mSv/a",.001/8766,["msv/year","msvpa"],{auto:!1})])}),V=Symbol("ambiguous"),U=new Map,x=new Map;function I(F,C){const B=String(F||"").trim();if(!B)throw new Error("[lattice] a unit system needs a name");if(Z[B]||x.has(B))throw new Error(`[lattice] unit system "${B}" already exists`);const _=[...C||[]];if(!_.length)throw new Error(`[lattice] unit system "${B}" has no units`);if(!_.some(Y=>Y.factor===1))throw new Error(`[lattice] unit system "${B}" has no base unit (none with factor 1)`);const Q=new Set;for(const Y of _){if(Q.has(Y.symbol))throw new Error(`[lattice] unit system "${B}" declares "${Y.symbol}" twice`);Q.add(Y.symbol)}return x.set(B,Object.freeze(_)),U.delete(B),B}function v(){return[...Object.keys(Z),...x.keys()]}function k(F){const C=y(F);return C?C.units:[]}function y(F){const C=String(F||""),B=U.get(C);if(B!==void 0)return B;const _=Z[C]||x.get(C);if(!_)return U.set(C,null),null;const Q=Object.freeze([..._].sort((oe,re)=>oe.factor-re.factor)),Y=new Map,J=new Map,te=(oe,re)=>{const le=Y.get(oe);le===void 0?Y.set(oe,re):le!==re&&Y.set(oe,V)};for(const oe of Q){te(oe.symbol.toLowerCase(),oe);for(const re of oe.aliases)te(re.toLowerCase(),oe);if(oe.prefix){const re=J.get(oe.prefix)||[];re.push(oe),J.set(oe.prefix,re)}}const ee={units:Q,byToken:Y,byPrefix:J,decimal:Q.filter(oe=>!oe.binary&&oe.auto),binary:Q.some(oe=>oe.binary)?Q.filter(oe=>(oe.binary||oe.factor===1)&&oe.auto):null};return U.set(C,ee),ee}function l(F,C){return C&&F.binary||F.decimal}function u(F,C){const B=y(F);if(!B||M(C))return null;const _=B.units.find(Y=>Y.symbol===String(C));if(_)return _;const Q=B.byToken.get(String(C).trim().toLowerCase());return Q&&Q!==V?Q:null}const n=new WeakMap;function t(F){const C=F||{};if(typeof C=="object"&&C!==null){const Y=n.get(C);if(Y!==void 0)return Y}const B=C.system||"data",_=y(B);let Q=null;if(!_)$(`unit:system:${B}`,`unknown unit system "${B}"; known systems are ${v().join(", ")}`);else{let Y=C.unit?u(B,C.unit):null;Y||(C.unit&&$(`unit:unit:${B}:${C.unit}`,`unknown unit "${C.unit}" in system "${B}"; falling back to ${_.units[0].symbol}`),Y=_.units.find(J=>J.factor===1)||_.units[0]),Q={index:_,base:Y,binary:C.binary===!0}}return typeof C=="object"&&C!==null&&n.set(C,Q),Q}const i=new WeakMap;function s(F,C){if(!F||!C||!Array.isArray(F.compound)||F.compound.length===0)return null;const B=i.get(F);if(B!==void 0)return B;const _=new Set,Q=[];for(const J of F.compound){const te=u(F.system||"data",J);if(!te){$(`unit:compound:${F.system}:${J}`,`unknown compound unit "${J}" in system "${F.system||"data"}"; ignoring it`);continue}_.has(te.symbol)||(_.add(te.symbol),Q.push(te))}Q.sort((J,te)=>te.factor-J.factor);const Y=Q.length>=2?Q:null;return i.set(F,Y),Y}function r(F,C,B){return C===B||C.factor===B.factor?F:F*C.factor/B.factor}const o=new Map;function c(F){const C=F||"",B=o.get(C);if(B)return B;const _={group:",",decimal:"."};try{for(const Q of new Intl.NumberFormat(F||void 0).formatToParts(12345.6))Q.type==="group"?_.group=Q.value:Q.type==="decimal"&&(_.decimal=Q.value)}catch{}return o.set(C,_),_}const a=/[\s ]/g,g=/^[+-]?[\d '’ .,]*(?:[eE][+-]?\d+)?/,h=/^[^\d+\-(.,\s]+\s*/,b=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function p(F,C){const{group:B,decimal:_}=c(C);let Q=String(F).replace(a,"");if(Q==="")return null;const Y=_?Q.indexOf(_):-1;if(B&&B!==_){if(Y>=0&&Q.indexOf(B,Y+_.length)>=0)return null;Q=Q.split(B).join("")}if(_&&_!=="."&&(Q=Q.split(_).join(".")),!b.test(Q))return null;const J=Number(Q);return Number.isFinite(J)?J:null}function f(F,C,B){const _=String(F).trim().replace(/\.$/,"");if(_==="")return null;const Q=C.units.find(re=>re.symbol===_);if(Q)return Q;const Y=_.toLowerCase(),J=C.byToken.get(Y);if(J===V)return null;if(J)return J;const te=C.byPrefix.get(Y);if(!te||!te.length)return null;const ee=l(C,B),oe=te.filter(re=>ee.includes(re));return oe.length===1?oe[0]:null}function w(F,C,B,_){let Q=F,Y=0,J=!1,te=!1;for(;Q!=="";){const ee=g.exec(Q)[0];if(ee==="")return null;const oe=p(ee,_&&_.locale);if(oe===null)return null;Q=Q.slice(ee.length).trim();const re=Q.search(/[+-]?[\d]/),le=(re>=0?Q.slice(0,re):Q).trim();if(Q=re>=0?Q.slice(re).trim():"",le===""){if(J)return null;te=!0,Y+=r(oe,B[0],C.base)}else{const ne=f(le,C.index,C.binary);if(!ne)return null;Y+=r(oe,ne,C.base)}if(J=!0,te&&Q!=="")return null}return J?Y:null}function S(F,C){if(M(F))return null;if(typeof F=="number")return Number.isFinite(F)?F:null;const B=t(C);if(!B)return null;let _=String(F).trim();if(_==="")return null;let Q=!1;_.startsWith("(")&&_.endsWith(")")&&(Q=!0,_=_.slice(1,-1).trim());const Y=s(C,B);if(Y){_.startsWith("-")&&(Q=!0,_=_.slice(1).trim());const se=w(_,B,Y,C);return se===null?null:Q?-se:se}let J=null;const te=h.exec(_);if(te&&te[0]){const se=f(te[0].trim(),B.index,B.binary);se&&(J=se,_=_.slice(te[0].length).trim())}const ee=g.exec(_)[0],oe=p(ee,C&&C.locale);if(oe===null)return null;const re=_.slice(ee.length).trim();if(J&&re!=="")return null;const le=J||(re===""?B.base:f(re,B.index,B.binary));if(!le)return null;const ne=r(oe,le,B.base);return Q?-ne:ne}const m=new Map;function d(F,C,B,_){const Q=`${F||""}|${C}|${B}|${_?1:0}`;let Y=m.get(Q);return Y||(Y=new Intl.NumberFormat(F||void 0,{minimumFractionDigits:C,maximumFractionDigits:B,useGrouping:_}),m.set(Q,Y)),Y}function j(F,C){if(!Number.isFinite(F)||F===0)return Math.max(0,C-1);const B=Math.floor(Math.log10(Math.abs(F)));return Math.min(20,Math.max(0,C-1-B))}function E(F,C){if(!Number.isFinite(F)||F===0)return F;const B=Math.ceil(Math.log10(Math.abs(F))),_=10**(C-B);return Math.round(F*_)/_}function O(F,C,B){if(!B||B===C.base.symbol)return C.base;if(B!=="auto")return T(C,B);if(F===0||!Number.isFinite(F))return C.base;const _=Math.abs(F)*C.base.factor,Q=l(C.index,C.binary);let Y=Q[0];for(const ee of Q)_>=ee.factor&&(Y=ee);if(_>=Y.factor)return Y;let J=Y;for(const ee of C.index.units)ee.binary!==C.binary&&ee.factor!==1||ee.factor<=_&&ee.factor>(J===Y?0:J.factor)&&(J=ee);if(J!==Y)return J;let te=Y;for(const ee of C.index.units)ee.binary!==C.binary&&ee.factor!==1||ee.factor<te.factor&&(te=ee);return te.factor<C.base.factor?te:C.base}function T(F,C){const B=F.index.units.find(Q=>Q.symbol===C);if(B)return B;const _=F.index.byToken.get(String(C).toLowerCase());return _&&_!==V?_:($(`unit:display:${C}`,`unknown display unit "${C}"; rendering in ${F.base.symbol}`),F.base)}function A(F,C,B,_){const Q=F<0;let Y=Math.abs(F)*C.base.factor;const J=typeof _.decimals=="number"?_.decimals:_.minDecimals??0,te=typeof _.decimals=="number"?_.decimals:_.maxDecimals??Math.max(J,2),ee=_.space??" ",oe=[];for(let le=0;le<B.length;le++){const ne=B[le],se=le===B.length-1;let ae=se?Y/ne.factor:Math.floor(Y/ne.factor);if(Y-=ae*ne.factor,se){const me=10**te;ae=Math.round(ae*me)/me+0}const de=se?d(_.locale,J,te,_.group!==!1):d(_.locale,0,0,_.group!==!1);oe.push(`${de.format(ae)}${ee}${ne.symbol}`)}const re=oe.join(" ");return Q?`-${re}`:re}function P(F,C){const B=C||{},_=B.nullDisplay??"";if(M(F)||F==="")return _;const Q=typeof F=="number"?F:Number(F);if(!Number.isFinite(Q))return _;const Y=t(B);if(!Y)return String(Q);const J=s(B,Y);if(J)return A(Q,Y,J,B);const te=typeof B.significantFigures=="number"&&B.significantFigures>0?B.significantFigures:0,ee=te?E(Q,te):Q,oe=O(ee,Y,B.display),re=r(ee,Y.base,oe);let le=typeof B.decimals=="number"?B.decimals:B.minDecimals??0,ne=typeof B.decimals=="number"?B.decimals:B.maxDecimals??Math.max(le,2);te&&(le=j(re,te),ne=le);const se=d(B.locale,le,ne,B.group!==!1).format(re),ae=B.space??" ";return B.placement==="prefix"?`${oe.symbol}${B.space??""}${se}`:`${se}${ae}${oe.symbol}`}function L(F,C){const B=M(F)||Number.isNaN(F)?null:Number(F),_=M(C)||Number.isNaN(C)?null:Number(C);return B===null||Number.isNaN(B)?_===null||Number.isNaN(_)?0:1:_===null||Number.isNaN(_)||B<_?-1:B>_?1:0}function z(F){const C=typeof F.decimals=="number"&&F.decimals>0?`.${"0".repeat(F.decimals)}`:"";return`${typeof F.decimals=="number"?`#,##0${C}`:"#,##0.##"}" ${F.symbol}"`}function H(F){const C={system:"data",...F||{}},B=t(C),_=B?B.base.symbol:String(C.unit||""),Q=Object.freeze({...C,unit:_}),Y=Object.freeze({...Q,display:_,decimals:void 0,minDecimals:0,maxDecimals:20,group:!1}),J=new Map([[Q.locale||"",Q]]),te=ee=>{const oe=ee||"";let re=J.get(oe);return re||(re=Object.freeze({...Q,locale:ee||void 0}),J.set(oe,re)),re};return{base:"number",extends:"number",storage:"float64",unitConfig:Q,format:ee=>P(ee.value,ee.locale?te(ee.locale):Q),parse:ee=>S(ee.text,ee.locale?te(ee.locale):Q),compare:L,defaults:{filter:"number",editor:"unit",align:"end",total:C.total||"sum"},...C.totals?{totals:C.totals}:{},excel:C.excel||z({decimals:C.decimals,symbol:_}),toStorage:ee=>typeof ee=="number"?Number.isFinite(ee)?ee:null:typeof ee=="string"?S(ee,Q):M(ee)?null:S(String(ee),Q),toClipboard:ee=>P(ee,Y),fromClipboard:ee=>S(ee,Q)}}const D=H}),Ae("packages/core/src/columns/types/engineering.js",function(e,G){"use strict";Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return W}});const M=G("packages/core/src/internal/util.js").isNil,N=G("packages/core/src/columns/types/unit.js").createUnitType;function W(U){const x=2*Math.PI/U;return I=>{let v=0,k=0,y=0;for(const u of I||[]){if(M(u))continue;const n=Number(u);Number.isFinite(n)&&(v+=Math.cos(n*x),k+=Math.sin(n*x),y+=1)}return!y||Math.hypot(v,k)/y<1e-12?null:(Math.atan2(k,v)/x%U+U)%U}}function Z(U){return{supported:["sum","avg","min","max","count","countValues"],implement:{avg:W(U)}}}const V=Object.freeze({metres:N({system:"length",unit:"m",display:"auto",maxDecimals:3}),millimetres:N({system:"length",unit:"mm",maxDecimals:2}),kilometres:N({system:"length",unit:"km",maxDecimals:3}),grams:N({system:"mass",unit:"g",display:"auto",maxDecimals:3}),kilograms:N({system:"mass",unit:"kg",maxDecimals:3}),tonnes:N({system:"mass",unit:"t",maxDecimals:3}),seconds:N({system:"duration",unit:"s",display:"auto",maxDecimals:3}),milliseconds:N({system:"duration",unit:"ms",maxDecimals:3}),hours:N({system:"duration",unit:"h",maxDecimals:2}),speed:N({system:"speed",unit:"m/s",display:"auto",maxDecimals:2}),kph:N({system:"speed",unit:"km/h",maxDecimals:1}),mph:N({system:"speed",unit:"mph",maxDecimals:1}),knots:N({system:"speed",unit:"kn",maxDecimals:1}),acceleration:N({system:"acceleration",unit:"m/s²",maxDecimals:3}),area:N({system:"area",unit:"m²",display:"auto",maxDecimals:2}),hectares:N({system:"area",unit:"ha",maxDecimals:4}),volume:N({system:"volume",unit:"L",display:"auto",maxDecimals:3}),cubicMetres:N({system:"volume",unit:"m³",maxDecimals:3}),energy:N({system:"energy",unit:"J",display:"auto",maxDecimals:3}),kilowattHours:N({system:"energy",unit:"kWh",maxDecimals:2}),power:N({system:"power",unit:"W",display:"auto",maxDecimals:2}),kilowatts:N({system:"power",unit:"kW",maxDecimals:2}),force:N({system:"force",unit:"N",display:"auto",maxDecimals:2}),pressure:N({system:"pressure",unit:"Pa",display:"auto",maxDecimals:2}),bar:N({system:"pressure",unit:"bar",maxDecimals:3}),psi:N({system:"pressure",unit:"psi",maxDecimals:1}),torque:N({system:"torque",unit:"N·m",maxDecimals:2}),density:N({system:"density",unit:"kg/m³",maxDecimals:2}),flow:N({system:"flow",unit:"m³/s",maxDecimals:4}),litresPerMinute:N({system:"flow",unit:"L/min",maxDecimals:1}),radians:N({system:"angle",unit:"rad",maxDecimals:4,totals:Z(2*Math.PI)}),degrees:N({system:"angle",unit:"°",maxDecimals:2,totals:Z(360)}),rpm:N({system:"angularVelocity",unit:"rpm",maxDecimals:0}),angularVelocity:N({system:"angularVelocity",unit:"rad/s",maxDecimals:3}),ppm:N({system:"fraction",unit:"ppm",maxDecimals:2}),ppb:N({system:"fraction",unit:"ppb",maxDecimals:2}),basisPoints:N({system:"fraction",unit:"bp",maxDecimals:1}),molarity:N({system:"molarity",unit:"M",display:"auto",maxDecimals:3}),massFlow:N({system:"massFlow",unit:"kg/s",maxDecimals:3}),tonnesPerHour:N({system:"massFlow",unit:"t/h",maxDecimals:2}),viscosity:N({system:"viscosity",unit:"Pa·s",display:"auto",maxDecimals:3}),kinematicViscosity:N({system:"kinematicViscosity",unit:"cSt",maxDecimals:2}),thermalConductivity:N({system:"thermalConductivity",unit:"W/(m·K)",maxDecimals:3}),specificHeat:N({system:"specificHeat",unit:"J/(kg·K)",maxDecimals:1}),doseRate:N({system:"doseRate",unit:"µSv/h",display:"auto",maxDecimals:2})})}),Ae("packages/core/src/columns/types/si.js",function(e,G){"use strict";Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const q=G("packages/core/src/columns/types/unit.js"),M=q.defineUnit,$=q.registerUnitSystem,N=q.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})]),Z=Object.freeze(["p","n","µ","m","","k","M","G"]);function V(k){const y=String(k.base),l=new Set([...k.prefixes||Z,""]),u=[];for(const n of W){if(!l.has(n.symbol))continue;const t=`${n.symbol}${y}`,i=[];if(k.name){i.push(`${n.name}${k.name}`,`${n.name}${k.name}s`);const s=n.name.slice(-1);if(s&&k.name.startsWith(s)){const r=`${n.name.slice(0,-1)}${k.name}`;i.push(r,`${r}s`)}}n.symbol==="µ"&&i.push(`u${y}`),n.factor===1&&k.aliases&&i.push(...k.aliases),u.push(M(t,n.factor,i))}for(const n of k.extra||[])u.push(n);return u}function U(k,y){const l=V(y);return $(k,l)}function x(k,y,l){return U(k,y),N({system:k,unit:y.base,display:"auto",maxDecimals:3,...l||{}})}const I=Object.freeze({voltage:x("voltage",{base:"V",name:"volt"}),current:x("current",{base:"A",name:"amp",aliases:["ampere","amperes"]}),resistance:x("resistance",{base:"Ω",name:"ohm",aliases:["ohm","ohms","R"],prefixes:["m","","k","M","G"]}),capacitance:x("capacitance",{base:"F",name:"farad",prefixes:["f","p","n","µ","m",""]}),inductance:x("inductance",{base:"H",name:"henry",prefixes:["p","n","µ","m",""]}),charge:x("charge",{base:"C",name:"coulomb",prefixes:["p","n","µ","m",""],extra:[M("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),M("Ah",3600,["amphour","amphours"],{auto:!1})]}),conductance:x("conductance",{base:"S",name:"siemens",prefixes:["n","µ","m","","k"]}),fluxDensity:x("fluxDensity",{base:"T",name:"tesla",prefixes:["n","µ","m",""],extra:[M("G",1e-4,["gauss"],{auto:!1})]}),luminousFlux:x("luminousFlux",{base:"lm",name:"lumen",prefixes:["m","","k"]}),illuminance:x("illuminance",{base:"lx",name:"lux",prefixes:["m","","k"]}),luminousIntensity:x("luminousIntensity",{base:"cd",name:"candela",prefixes:["m","","k"]}),substance:x("substance",{base:"mol",name:"mole",prefixes:["n","µ","m","","k"]}),absorbedDose:x("absorbedDose",{base:"Gy",name:"gray",prefixes:["µ","m",""]}),equivalentDose:x("equivalentDose",{base:"Sv",name:"sievert",prefixes:["n","µ","m",""]}),radioactivity:x("radioactivity",{base:"Bq",name:"becquerel",prefixes:["","k","M","G","T"],extra:[M("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:x("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),v=x}),Ae("packages/core/src/columns/types/temperature.js",function(e,G){"use strict";Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const M=G("packages/core/src/internal/util.js").isNil,$=Object.freeze({C:Object.freeze({symbol:"°C",aliases:["c","°c","celsius","centigrade"],toKelvin:u=>u+273.15,fromKelvin:u=>u-273.15}),F:Object.freeze({symbol:"°F",aliases:["f","°f","fahrenheit"],toKelvin:u=>(u+459.67)*(5/9),fromKelvin:u=>u*(9/5)-459.67}),K:Object.freeze({symbol:"K",aliases:["k","kelvin"],toKelvin:u=>u,fromKelvin:u=>u}),R:Object.freeze({symbol:"°R",aliases:["r","°r","rankine"],toKelvin:u=>u*(5/9),fromKelvin:u=>u*(9/5)})});function N(u){if(M(u))return null;const n=String(u).trim();if(n==="")return null;for(const[i,s]of Object.entries($))if(n===i||n===s.symbol)return{key:i,scale:s};const t=n.toLowerCase();for(const[i,s]of Object.entries($))if(s.aliases.includes(t))return{key:i,scale:s};return null}function W(u,n,t){const i=N(n),s=N(t);return!i||!s||!Number.isFinite(Number(u))?null:i.key===s.key?Number(u):s.scale.fromKelvin(i.scale.toKelvin(Number(u)))}const Z=new Map;function V(u,n,t){const i=`${u||""}|${n}|${t}`;let s=Z.get(i);return s||(s=new Intl.NumberFormat(u||void 0,{minimumFractionDigits:n,maximumFractionDigits:t}),Z.set(i,s)),s}function U(u,n){const t=n||{},i=t.nullDisplay??"";if(M(u)||u==="")return i;const s=Number(u);if(!Number.isFinite(s))return i;const r=N(t.scale||"C");if(!r)return String(s);const o=N(t.display||t.scale||"C")||r,c=o.key===r.key?s:o.scale.fromKelvin(r.scale.toKelvin(s)),a=typeof t.decimals=="number"?t.decimals:null,g=a??t.minDecimals??0,h=a??t.maxDecimals??1;return`${V(t.locale,g,h).format(c)}${t.space??" "}${o.scale.symbol}`}const x=/^[+-]?[\d\s., ]*\d/;function I(u,n){const t=String(u).trim();if(t==="")return null;const i=new Intl.NumberFormat(n||void 0).formatToParts(1.1).find(c=>c.type==="decimal")?.value||".",s=i===","?".":",",r=t.split(s).join("").split(/[\s ]/).join("").replace(i,"."),o=Number(r);return Number.isFinite(o)?o:null}function v(u,n){if(M(u))return null;const t=n||{},i=N(t.scale||"C");if(!i)return null;if(typeof u=="number")return Number.isFinite(u)?u:null;let s=String(u).trim();if(s==="")return null;let r=!1;s.startsWith("(")&&s.endsWith(")")&&(r=!0,s=s.slice(1,-1).trim());const o=x.exec(s);if(!o)return null;const c=I(o[0],t.locale);if(c===null)return null;const a=s.slice(o[0].length).trim();if(a==="")return r?-c:c;const g=N(a);if(!g)return null;const h=g.key===i.key?c:i.scale.fromKelvin(g.scale.toKelvin(c));return r?-h:h}function k(u){const n=Object.freeze({scale:"C",...u||{}}),i=(N(n.scale)||N("C")).scale.symbol,s=Object.freeze({...n,display:n.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),r=new Map([[n.locale||"",n]]),o=c=>{const a=c||"";let g=r.get(a);return g||(g=Object.freeze({...n,locale:c||void 0}),r.set(a,g)),g};return{base:"number",extends:"number",storage:"float64",temperatureConfig:n,format:c=>U(c.value,c.locale?o(c.locale):n),parse:c=>v(c.text,c.locale?o(c.locale):n),defaults:{filter:"number",editor:"temperature",align:"end",total:"avg"},totals:{supported:["avg","min","max","count","countValues"]},excel:n.excel||`#,##0${typeof n.decimals=="number"&&n.decimals>0?`.${"0".repeat(n.decimals)}`:".#"}" ${i}"`,toStorage:c=>typeof c=="number"?Number.isFinite(c)?c:null:typeof c=="string"?v(c,n):M(c)?null:v(String(c),n),toClipboard:c=>U(c,s),fromClipboard:c=>v(c,n)}}const y=Object.freeze({celsius:k({scale:"C"}),fahrenheit:k({scale:"F"}),kelvin:k({scale:"K"})}),l=k}),Ae("packages/core/src/columns/types/radix.js",function(e,G){"use strict";Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"digitsForWidth",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"radixRange",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"radixName",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"normaliseRadixOptions",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"compileRadixFormat",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"compileRadixParse",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"parseRadixResult",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return A}});const q=G("packages/core/src/internal/util.js"),M=q.isNil,$=q.warnOnce,N=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}),Z=Object.freeze({2:"0b",8:"0o",16:"0x"}),V=Object.freeze({2:4,8:3,16:2}),U=Object.freeze({2:/^[01]+$/,8:/^[0-7]+$/,16:/^[0-9a-f]+$/i}),x=Object.freeze({2:"binary",8:"octal",16:"hexadecimal"}),I=Object.freeze([[/^0x/i,16],[/^0b/i,2],[/^0o/i,8],[/^#/,16]]),v=/[\s\u00a0\u202f_,']/g,k=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,y=Object.freeze([8,16,32,53]),l=new WeakSet,u=new WeakMap,n=new Map,t=new WeakMap,i=new WeakMap,s=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 r(P){if(P==null)return 16;const L=typeof P=="string"?P.toLowerCase():P,z=N[L];return z||($(`radix:base:${String(P)}`,`unsupported radix ${String(P)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function o(P,L){return Math.ceil(P/W[L])}function c(P,L){if(!P)return L?{min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}:{min:0,max:Number.MAX_SAFE_INTEGER};if(!L)return{min:0,max:2**P-1};const z=2**(P-1);return{min:-z,max:z-1}}function a(P){return x[P]||"hexadecimal"}function g(P){if(typeof P=="string"){const L=s[P];return L||$(`radix:preset:${P}`,`unknown radix preset "${P}"; known presets are ${Object.keys(s).join(", ")}`),{...L||{}}}if(P&&typeof P.preset=="string"){const L=s[P.preset];return L||$(`radix:preset:${P.preset}`,`unknown radix preset "${P.preset}"; known presets are ${Object.keys(s).join(", ")}`),{...L||{},...P}}return P||{}}function h(P){const L=g(P),z=r(L.radix),H=W[z];let D=null;if(L.bitWidth!==void 0&&L.bitWidth!==null&&L.bitWidth!==!1){const ee=Number(L.bitWidth);y.includes(ee)?D=ee:$(`radix:width:${String(L.bitWidth)}`,`unsupported bitWidth ${String(L.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let F=L.signed!==!1;!F&&D===null&&($("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),D=32);const C=L.prefix===void 0||L.prefix===!0?Z[z]:L.prefix===!1?"":String(L.prefix);let B=0;L.pad===!0?B=D?o(D,z):0:typeof L.pad=="number"&&L.pad>0&&(B=Math.floor(L.pad));let _=0;L.group===!0?_=V[z]:typeof L.group=="number"&&L.group>0&&(_=Math.floor(L.group));const Q=c(D,F),Y=typeof L.min=="number"?Math.max(Q.min,L.min):Q.min,J=typeof L.max=="number"?Math.min(Q.max,L.max):Q.max,te=Object.freeze({radix:z,bits:H,prefix:C,uppercase:L.uppercase!==!1,pad:B,group:_,groupSeparator:typeof L.groupSeparator=="string"?L.groupSeparator:" ",bitWidth:D,signed:F,min:Y,max:J<Y?Y:J,nullDisplay:typeof L.nullDisplay=="string"?L.nullDisplay:"",name:a(z)});return l.add(te),te}function b(P){if(P&&l.has(P))return P;if(typeof P=="string"){let L=n.get(P);return L||(L=h(P),n.set(P,L)),L}if(P&&typeof P=="object"){let L=u.get(P);return L||(L=h(P),u.set(P,L)),L}return b("hex")}function p(P){return P<0?-Math.round(-P):Math.round(P)}function f(P,L,z){if(L<=0||P.length<=L)return P;const H=P.length%L||L,D=[P.slice(0,H)];for(let F=H;F<P.length;F+=L)D.push(P.slice(F,F+L));return D.join(z)}function w(P){const L=b(P),{radix:z,prefix:H,uppercase:D,pad:F,group:C,groupSeparator:B,signed:_,bitWidth:Q,nullDisplay:Y}=L,J=Q?2**Q:0,te=ee=>{if(M(ee)||ee==="")return Y;const oe=typeof ee=="number"?ee:Number(ee);if(!Number.isFinite(oe))return Y;const re=p(oe);let le="",ne=re;re<0&&(_?(le="-",ne=-re):ne=(re%J+J)%J);let se=ne.toString(z);return se=D?se.toUpperCase():se.toLowerCase(),F>0&&se.length<F&&(se=se.padStart(F,"0")),C>0&&(se=f(se,C,B)),le+H+se};return te.options=L,te}function S(P,L){const z=b(L);let H=t.get(z);return H||(H=w(z),t.set(z,H)),H(P)}function m(P){const L=b(P),{radix:z,groupSeparator:H,signed:D,min:F,max:C}=L,B=U[z],_=Q=>{if(M(Q))return{ok:!0,value:null,reason:"blank"};let Y=String(Q);if(H&&H!==""&&(Y=Y.split(H).join("")),Y=Y.replace(v,""),Y==="")return{ok:!0,value:null,reason:"blank"};let J=!1;if((Y[0]==="-"||Y[0]==="+")&&(J=Y[0]==="-",Y=Y.slice(1)),Y==="")return{ok:!1,value:null,reason:"digits"};let te=null;for(const[oe,re]of I){const le=oe.exec(Y);if(!le)continue;const ne=Y.slice(le[0].length);if(ne==="")break;if(!U[re].test(ne))return{ok:!1,value:null,reason:"digits"};te=parseInt(ne,re);break}if(te===null)if(B.test(Y))te=parseInt(Y,z);else if(k.test(Y))te=Number(Y);else return{ok:!1,value:null,reason:"digits"};if(!Number.isFinite(te))return{ok:!1,value:null,reason:"digits"};const ee=p(J?-te:te);return!D&&ee<0?{ok:!1,value:ee,reason:"negative"}:ee<F||ee>C?{ok:!1,value:ee,reason:"range"}:{ok:!0,value:ee,reason:"ok"}};return _.options=L,_}function d(P,L){const z=b(L);let H=i.get(z);return H||(H=m(z),i.set(z,H)),H(P)}function j(P,L){const z=d(P,L);return z.ok?z.value:null}function E(P,L){const z=M(P)||Number.isNaN(P)?null:Number(P),H=M(L)||Number.isNaN(L)?null:Number(L);return z===null?H===null?0:1:H===null||z<H?-1:z>H?1:0}function O(P){const L=P.min>=-2147483648&&P.max<=2147483647;return P.bitWidth&&L?"int32":"float64"}function T(P){const L=h(P),z=w(L),H=m(L);return{base:"number",extends:"number",storage:O(L),matches:null,format:D=>z(D.value),parse:D=>{const F=H(D.text);return F.ok?F.value:null},compare:E,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:D=>z(D),fromClipboard:D=>{const F=H(D);return F.ok?F.value:null},radix:L,formatValue:z,parseText:H}}const A=T}),Ae("packages/core/src/columns/types/aggregable.js",function(e,G){"use strict";Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"weightedMean",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"logarithmicSum",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"logarithmicMean",{enumerable:!0,get:function(){return W}});const M=G("packages/core/src/internal/util.js").isNil;function $(I){const v=[];for(const k of I||[]){if(M(k))continue;const y=Number(k);Number.isFinite(y)&&v.push(y)}return v}function N(I){return v=>{const k=$(v);if(!k.length)return null;let y=0;for(const l of k)y+=10**(l/I);return I*Math.log10(y)}}function W(I){return v=>{const k=$(v);if(!k.length)return null;let y=0;for(const l of k)y+=10**(l/I);return I*Math.log10(y/k.length)}}function Z(I,v){const k=v&&v.column,l=(k&&k.typeOptions||{}).weight,u=v&&v.valueAt;if(!l||typeof u!="function")return null;let n=0,t=0;for(let i=0;i<I.length;i++){if(M(I[i]))continue;const s=Number(I[i]);if(!Number.isFinite(s))continue;const r=u(l,i);if(M(r))continue;const o=Number(r);!Number.isFinite(o)||o<=0||(n+=s*o,t+=o)}return t===0?null:n/t}function V(I={}){const v=I.factor===20?20:10,k=typeof I.suffix=="string"?I.suffix:"",y=Number.isInteger(I.decimals)?I.decimals:1;return{base:"number",storage:"float64",name:I.name||"logarithmic",format:l=>{const u=l&&l.value;return M(u)||!Number.isFinite(Number(u))?"":`${Number(u).toFixed(y)}${k}`},parse:l=>{const u=String((l&&l.text)??"").replace(k,"").trim();if(!u)return null;const n=Number(u);return Number.isFinite(n)?n:null},defaults:{align:"end",filter:"number"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:{sum:N(v),avg:W(v)}}}}function U(I={}){const v=Number.isInteger(I.decimals)?I.decimals:1,k=I.percent===!0;return{base:"number",storage:"float64",name:I.name||"ratio",format:y=>{const l=y&&y.value;return M(l)||!Number.isFinite(Number(l))?"":k?`${Number(l).toFixed(v)}%`:Number(l).toFixed(v)},parse:y=>{const l=String((y&&y.text)??"").replace("%","").trim();if(!l)return null;const u=Number(l);return Number.isFinite(u)?u:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:Z}}}}const x=Object.freeze({decibel:V({name:"decibel",factor:10,suffix:" dB"}),decibelAmplitude:V({name:"decibelAmplitude",factor:20,suffix:" dB"}),ratio:U({name:"ratio"}),percentRate:U({name:"percentRate",percent:!0})})}),Ae("packages/core/src/columns/types/currency.js",function(e,G){"use strict";Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"moneyToText",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const M=G("packages/core/src/internal/util.js").isNil,$="⚠ no rate";function N(c){if(M(c))return null;const a=String(c).trim().toUpperCase();return a===""?null:a}function W(c){if(M(c))return null;if(typeof c=="object"&&!Array.isArray(c)){const a=Number(c.amount),g=N(c.code);return!g||!Number.isFinite(a)?null:{amount:a,code:g}}if(Array.isArray(c)&&c.length===2){const a=Number(c[0]),g=N(c[1]);return!g||!Number.isFinite(a)?null:{amount:a,code:g}}return null}const Z=Object.freeze({$:"USD","€":"EUR","£":"GBP","¥":"JPY","₹":"INR","₩":"KRW","₽":"RUB","₺":"TRY","₴":"UAH","₪":"ILS"}),V=Object.freeze({USD:"$",EUR:"€",GBP:"£",JPY:"¥",INR:"₹",KRW:"₩",RUB:"₽",TRY:"₺",UAH:"₴",ILS:"₪"}),U=/[+-]?[\d\s., ]*\d/;function x(c,a){const g=String(c).trim();if(g==="")return null;const h=new Intl.NumberFormat(a||void 0).formatToParts(1.1).find(w=>w.type==="decimal")?.value||".",b=h===","?".":",",p=g.split(b).join("").split(/[\s ]/).join("").replace(h,"."),f=Number(p);return Number.isFinite(f)?f:null}function I(c,a){const g=a||{},h=N(g.code);if(M(c))return null;const b=W(c);if(b)return b;if(typeof c=="number")return Number.isFinite(c)&&h?{amount:c,code:h}:null;let p=String(c).trim();if(p==="")return null;let f=!1;p.startsWith("(")&&p.endsWith(")")&&(f=!0,p=p.slice(1,-1).trim());let w=null;for(const[O,T]of Object.entries(Z)){if(p.startsWith(O)){w=T,p=p.slice(O.length).trim();break}if(p.endsWith(O)){w=T,p=p.slice(0,-O.length).trim();break}}const S=U.exec(p);if(!S)return null;const m=x(S[0],g.locale);if(m===null)return null;const d=(p.slice(0,S.index)+" "+p.slice(S.index+S[0].length)).trim();!w&&d!==""&&(w=N(d));const j=w||h;return j?{amount:f?-m:m,code:j}:null}function v(c,a){if(typeof c=="function")return(g,h)=>{if(g===h)return 1;const b=c(g,h);return typeof b=="number"&&Number.isFinite(b)&&b>0?b:null};if(c&&typeof c=="object"){const g=c;return(h,b)=>{if(h===b)return 1;const p=Number(g[h]),f=Number(g[b]);return!Number.isFinite(p)||!Number.isFinite(f)||p<=0||f<=0?null:f/p}}return(g,h)=>g===h?1:null}function k(c,a,g){if(!c)return null;if(c.code===a)return c.amount;const h=g(c.code,a);return h===null?null:c.amount*h}const y=new Map;function l(c,a,g){const h=`${c||""}|${a}|${g??""}`;let b=y.get(h);if(!b){const p={style:"currency",currency:a};typeof g=="number"&&(p.minimumFractionDigits=g,p.maximumFractionDigits=g);try{b={fmt:new Intl.NumberFormat(c||void 0,p),currency:!0}}catch{b={fmt:new Intl.NumberFormat(c||void 0,typeof g=="number"?{minimumFractionDigits:g,maximumFractionDigits:g}:{}),currency:!1}}y.set(h,b)}return b}function u(c,a){const g=a||{},h=g.nullDisplay??"",b=W(c);if(!b)return h;const p=N(g.display)||b.code;let f=b.amount,w=b.code;if(p!==b.code){const d=g.rateFn||v(g.rates,g.rateBase),j=k(b,p,d);if(j===null)return`${g.missingRate??$} ${b.code}→${p}`;f=j,w=p}const{fmt:S,currency:m}=l(g.locale,w,g.decimals);return m?S.format(f):`${S.format(f)} ${w}`}function n(c){const a=W(c);return a?`${a.amount} ${a.code}`:""}function t(c){const a=c||{},g=N(a.display),h=a.rateFn||v(a.rates,a.rateBase);return(b,p)=>{const f=W(b),w=W(p);if(!f&&!w)return 0;if(!f)return 1;if(!w)return-1;if(g){const S=k(f,g,h),m=k(w,g,h);if(S!==null&&m!==null)return S===m?0:S<m?-1:1}return f.code===w.code?f.amount===w.amount?0:f.amount<w.amount?-1:1:f.code<w.code?-1:1}}function i(c){const a=c||{},g=(b,p)=>{const f=[];for(const j of b||[]){const E=W(j);E&&f.push(E)}if(!f.length)return null;if(new Set(f.map(j=>j.code)).size===1){const j=f[0].code;return{amount:p(f.map(E=>E.amount)),code:j}}const S=N(a.display);if(!S)return`${a.missingRate??$}: mixed currencies, no display currency set`;const m=a.rateFn||v(a.rates,a.rateBase),d=[];for(const j of f){const E=k(j,S,m);if(E===null)return`${a.missingRate??$}: ${j.code}→${S}`;d.push(E)}return{amount:p(d),code:S}},h=b=>b.reduce((p,f)=>p+f,0);return{sum:b=>g(b,h),avg:b=>g(b,p=>h(p)/p.length),min:b=>g(b,p=>Math.min(...p)),max:b=>g(b,p=>Math.max(...p))}}function s(c){const a=Object.freeze({code:"USD",...c||{}}),g=v(a.rates,a.rateBase),h=Object.freeze({...a,rateFn:g}),b=i(h),p=t(h),f=new Map([[a.locale||"",h]]),w=d=>{const j=d||"";let E=f.get(j);return E||(E=Object.freeze({...h,locale:d||void 0}),f.set(j,E)),E},S=V[N(a.display||a.code)]||"",m=typeof a.decimals=="number"&&a.decimals>0?`.${"0".repeat(a.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:h,format:d=>u(d.value,d.locale?w(d.locale):h),parse:d=>I(d.text,d.locale?w(d.locale):h),compare:p,defaults:{filter:"number",editor:"currency",align:"end",total:"sum"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:b},excel:a.excel||(S?`"${S}"#,##0${m}`:`#,##0${m}`),toStorage:d=>{const j=W(d);return j||(typeof d=="string"||typeof d=="number"?I(d,h):null)},toClipboard:d=>n(d),fromClipboard:d=>I(d,h)}}const r=Object.freeze({currency:s({code:"USD"}),usd:s({code:"USD"}),eur:s({code:"EUR"}),gbp:s({code:"GBP"}),jpy:s({code:"JPY",decimals:0})}),o=s}),Ae("packages/core/src/columns/types/index.js",function(e,G){"use strict";Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return O}});const q=G("packages/core/src/columns/types/temporal.js"),M=q.TEMPORAL_TYPES,$=G("packages/core/src/columns/types/network.js"),N=$.NETWORK_TYPES,W=G("packages/core/src/columns/types/structured.js"),Z=W.STRUCTURED_TYPES,V=G("packages/core/src/columns/types/unit.js"),U=V.createUnitType,x=V.UNIT_SYSTEMS,I=V.parseUnit,v=V.formatUnit,k=V.registerUnitSystem,y=V.unitSystemNames,l=V.unitsOf,u=V.defineUnit,n=G("packages/core/src/columns/types/engineering.js"),t=n.ENGINEERING_TYPES,i=G("packages/core/src/columns/types/si.js"),s=i.SI_TYPES,r=i.createSiType,o=i.createSiSystem,c=i.siUnits,a=i.SI_PREFIXES,g=G("packages/core/src/columns/types/temperature.js"),h=g.TEMPERATURE_TYPES,b=g.createTemperatureType,p=g.convertTemperature,f=g.formatTemperature,w=g.parseTemperature,S=g.TEMPERATURE_SCALES,m=G("packages/core/src/columns/types/radix.js"),d=m.createRadixType,j=m.RADIX_PRESETS,E=m.parseRadix,O=m.formatRadix,T=G("packages/core/src/columns/types/aggregable.js"),A=T.AGGREGABLE_TYPES,P=G("packages/core/src/columns/types/currency.js"),L=P.CURRENCY_TYPES,z=P.createCurrencyType,H=P.parseMoney,D=P.formatMoney,F=P.convertMoney,C=P.toMoney,B=P.rateFunction,_=P.moneyComparator,Q=P.normaliseCode,Y=P.MISSING_RATE;Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return V.findUnit}}),Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return n.ENGINEERING_TYPES}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return n.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 P.CURRENCY_TYPES}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return P.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return P.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return P.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return P.convertMoney}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return P.toMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return P.rateFunction}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return P.moneyComparator}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return P.normaliseCode}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return P.MISSING_RATE}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return q.TEMPORAL_TYPES}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return $.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 T.AGGREGABLE_TYPES}}),Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return T.createLogarithmicType}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return T.createRatioType}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return q.parseTime}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return q.formatTime}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return q.parseDateTime}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return q.formatDateTime}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return q.parseDuration}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return q.formatDuration}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return $.parseIpv4}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return $.formatIpv4}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return $.parseCidr}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return $.formatCidr}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return $.parseIpv6}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return $.formatIpv6}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return $.networkAddress}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return $.broadcastAddress}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return $.hostCount}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return $.containsAddress}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return $.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({...M,...N,...Z,...A,hex:d(j.hex),hex8:d(j.hex8),hex16:d(j.hex16),hex32:d(j.hex32),binary:d(j.binary),binary8:d(j.binary8),octal:d(j.octal),bytes:U({system:"data",unit:"B",display:"auto"}),megabytes:U({system:"data",unit:"MB"}),gigabytes:U({system:"data",unit:"GB"}),bitrate:U({system:"bitrate",unit:"Mbps"}),gigabits:U({system:"bitrate",unit:"Gbps"}),...t,...s,...h,...L});{const te=new Set;for(const ee of[M,N,Z,A,t,s,h,L])for(const oe of Object.keys(ee)){if(te.has(oe))throw new Error(`[lattice] data type "${oe}" is declared twice`);te.add(oe)}}}),Ae("packages/core/src/compute/handle.js",function(e,G){"use strict";Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return k}}),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 u}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return i}});const q=G("packages/core/src/internal/util.js"),M=q.collator,$=q.defaultCompare,N=q.warnOnce;function W(s){const r=new Uint32Array(s);for(let o=0;o<s;o++)r[o]=o;return r}function Z(s,r){if(r&&typeof r.count=="number")return r.count;if(!s)return 0;if(typeof s.count=="number")return s.count;if(typeof s.length=="number")return s.length;const o=s.values;return s.kind==="multi"&&s.offsets?Math.max(0,s.offsets.length-1):o?s.kind==="bitset"?typeof o.size=="number"?o.size:s.presence&&typeof s.presence.size=="number"?s.presence.size:(N(`count:${s.id}`,`column "${s.id}" is bitset-backed with no declared row count; assuming ${o.length*8}`),o.length*8):o.length:s.presence&&typeof s.presence.size=="number"?s.presence.size:0}const V=new WeakMap;function U(s){const r=s.constructor;if(!r)return"unknown";const o=V.get(r);if(o)return o;let c="unknown";try{let a=null;typeof r.from=="function"?a=r.from([!1,!0]):(a=new r(8),a.set(1));const g=a&&a.words;g&&g.length&&(g[0]===2?c="lsb":g[0]===64&&(c="msb"))}catch{c="unknown"}return V.set(r,c),c}function x(s){if(!s)return()=>0;const r=s instanceof Uint8Array?s:s.words;if(r instanceof Uint8Array){const o=s instanceof Uint8Array?"lsb":U(s);if(o==="lsb")return c=>r[c>>>3]>>>(c&7)&1;if(o==="msb")return c=>r[c>>>3]>>>7-(c&7)&1}return typeof s.get=="function"?o=>s.get(o)?1:0:()=>0}function I(s){return!s||!s.presence?null:x(s.presence)}function v(s){return s?typeof s.size=="number"?s.size:typeof s.values=="function"?s.values().length:0:0}function k(s,r){return s?typeof s.valueOf=="function"?s.valueOf(r):typeof s.values=="function"?s.values()[r]:null:null}function y(s,r){const o=s.offsets,c=s.values;if(!o||!c)return[];const a=o[r],g=o[r+1];if(!(g>a))return[];const h=s.dict,b=new Array(g-a);for(let p=a;p<g;p++)b[p-a]=h?k(h,c[p]):c[p];return b}function l(s){if(!s)return()=>{};const r=s.values,o=I(s),c=s.kind;if(c==="dictionary"){const a=s.dict;return o?g=>o(g)?k(a,r[g]):null:g=>k(a,r[g])}if(c==="bitset"){const a=x(r);return o?g=>o(g)?a(g)===1:null:g=>a(g)===1}if(c==="multi")return o?a=>o(a)?y(s,a):null:a=>y(s,a);if(!r&&typeof s.get=="function"){const a=s.get.bind(s);return g=>{const h=a(g);return h===void 0?null:h}}return o?a=>{if(!o(a))return null;const g=r[a];return g===void 0?null:g}:a=>{const g=r[a];return g===void 0?null:g}}function u(s,r){if(s<r)return-1;if(s>r)return 1;if(s===r){const a=Object.is(s,-0),g=Object.is(r,-0);return a===g?0:a?-1:1}const o=Number.isNaN(s),c=Number.isNaN(r);return o&&c?0:o?1:-1}function n(s){const r=M(s);return(o,c)=>{if(o===c)return 0;const a=typeof o,g=typeof c;if(a==="string"&&g==="string")return r.compare(o,c);if(a==="number"&&g==="number")return u(o,c);if(a==="boolean"&&g==="boolean")return o===c?0:o?1:-1;if(o instanceof Date||c instanceof Date){const h=o instanceof Date?o.getTime():Number(o),b=c instanceof Date?c.getTime():Number(c);return u(h,b)}return $(o,c)}}function t(s,r){if(s&&typeof s.ranks=="function")return s.ranks(r);const o=s&&typeof s.values=="function"?s.values():[],c=o.length,a=n(r),g=new Array(c);for(let b=0;b<c;b++)g[b]=b;g.sort((b,p)=>a(o[b],o[p])||b-p);const h=new Uint32Array(c);for(let b=0;b<c;b++)h[g[b]]=b;return h}function i(s){return s==null||typeof s=="number"&&Number.isNaN(s)}}),Ae("packages/core/src/compute/filter.js",function(e,G){"use strict";Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"itemwisePredicate",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"declareOperators",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"declaredOperator",{enumerable:!0,get:function(){return Q}});const q=G("packages/core/src/internal/util.js"),M=q.isBlank,$=q.toArray,N=q.warnOnce,Z=G("packages/core/src/format/date.js").toIsoDate,V=G("packages/core/src/compute/handle.js"),U=V.bitReader,x=V.dictSize,I=V.dictValue,v=V.presenceReader,k=V.valueComparator,y=V.valueReader,l=/^\d{4}-\d{2}-\d{2}$/,u="\0null\0";function n(Y,J){const te=Y&&Y.pool;if(te){const ee=te.mask||te.acquireMask||te.acquire||te.take;if(typeof ee=="function"){const oe=ee.call(te,J);if(oe&&oe.length>=J)return oe}}return new Uint8Array(J)}function t(Y,J){const te=Y&&Y.pool;if(!te||!J)return;const ee=te.release||te.releaseMask||te.free||te.recycle;typeof ee=="function"&&ee.call(te,J)}function i(Y,J,te){return Y.fill(te,0,J),Y}function s(Y){return Y==null||typeof Y=="number"&&Number.isNaN(Y)}function r(Y,J){if(Y==null)return Y;if(J==="number")return typeof Y=="number"?Y:Number(Y);if(J==="date"||J==="dateString"){const te=Z(Y);return te===null?o(Y):te}return J==="boolean"?typeof Y=="boolean"?Y:Y==="true"||Y===1?!0:Y==="false"||Y===0?!1:!!Y:Y}function o(Y){return Y instanceof Date?Y.getTime():typeof Y=="number"?Y:Date.parse(String(Y))}function c(Y){return typeof Y=="number"?Y:Y instanceof Date?Y.getTime():Y==null||Y===""?NaN:Number(Y)}function a(Y,J){const te=typeof Y=="string"?Y:String(Y);return J?te:te.toLowerCase()}function g(Y,J){return Y==null?u:typeof Y=="string"?J?Y:Y.toLowerCase():Y instanceof Date?Y.getTime():Y}function h(Y,J,te){const ee=new Set;for(const oe of $(Y)){const re=r(oe,te);ee.add(g(re,J)),typeof re=="string"&&re!==""&&Number.isFinite(Number(re))?ee.add(Number(re)):typeof re=="number"&&Number.isFinite(re)&&ee.add(g(String(re),J))}return ee}function b(Y,J,te){if(Y==null||J===null||J===void 0)return Y==null&&J==null;const ee=typeof Y,oe=typeof J;return ee==="string"&&oe==="string"?te?Y===J:Y.toLowerCase()===J.toLowerCase():Y instanceof Date||J instanceof Date?o(Y)===o(J):ee==="number"&&oe==="number"?Y===J||Number.isNaN(Y)&&Number.isNaN(J):ee==="number"&&oe==="string"?Y===Number(J):ee==="string"&&oe==="number"?Number(Y)===J:ee==="boolean"||oe==="boolean"?Y===J:Array.isArray(Y)&&Array.isArray(J)?Y.length===J.length&&Y.every((re,le)=>b(re,J[le],te)):Y===J}function p(Y,J){try{if(Y instanceof RegExp){const te=Y.flags.replace(/[gy]/g,"");return new RegExp(Y.source,J||te.includes("i")?te:`${te}i`)}return new RegExp(String(Y),J?"":"i")}catch(te){return N(`regex:${String(Y)}`,`filter operator "matches" received an invalid pattern: ${String(Y)}`,te),null}}function f(Y,J){const te=w(Y,J),ee=Y&&Y.type;return ee!=="date"&&ee!=="dateString"?te:oe=>te(typeof oe=="string"&&l.test(oe)?oe:Z(oe)??oe)}function w(Y,J){const te=Y&&Y.op,ee=!!(Y&&Y.caseSensitive),oe=Y&&Y.type,re=k(J),le=ne=>se=>!ne(se);switch(te){case"eq":{const ne=r(Y.value,oe);return se=>b(se,ne,ee)}case"ne":{const ne=r(Y.value,oe);return se=>!b(se,ne,ee)}case"lt":case"lte":case"gt":case"gte":{const ne=r(Y.value,oe);if(s(ne))return()=>!1;const se=te==="lt"?-1:te==="lte"?0:te==="gt"?1:2;return ae=>{if(s(ae))return!1;const de=re(ae,ne);return se===-1?de<0:se===0?de<=0:se===1?de>0:de>=0}}case"between":case"notBetween":{const ne=$(Y.value),se=r(ne[0],oe),ae=r(ne[1],oe),de=Y.bounds||"[]",me=de.charAt(0)!=="(",Pe=de.charAt(1)!==")";if(s(se)||s(ae))return te==="between"?()=>!1:()=>!0;const Ie=ke=>{if(s(ke))return!1;const be=re(ke,se),ge=re(ke,ae);return(me?be>=0:be>0)&&(Pe?ge<=0:ge<0)};return te==="between"?Ie:le(Ie)}case"in":case"notIn":{const ne=h(Y.value,ee,oe),se=ae=>ne.has(g(ae,ee));return te==="in"?se:le(se)}case"contains":case"notContains":{const ne=a(r(Y.value,oe),ee),se=ae=>ae==null?!1:a(ae,ee).includes(ne);return te==="contains"?se:le(se)}case"startsWith":{const ne=a(r(Y.value,oe),ee);return se=>se==null?!1:a(se,ee).startsWith(ne)}case"endsWith":{const ne=a(r(Y.value,oe),ee);return se=>se==null?!1:a(se,ee).endsWith(ne)}case"matches":{const ne=p(Y.value,ee);return ne?se=>se==null?!1:ne.test(String(se)):()=>!1}case"blank":return ne=>M(ne)||Array.isArray(ne)&&ne.length===0;case"notBlank":return ne=>!(M(ne)||Array.isArray(ne)&&ne.length===0);case"containsAny":case"containsNone":{const ne=h(Y.value,ee,oe),se=ae=>{const de=ae==null?[]:$(ae);for(let me=0;me<de.length;me++)if(ne.has(g(de[me],ee)))return!0;return!1};return te==="containsAny"?se:le(se)}case"containsAll":{const ne=$(Y.value).map(se=>g(r(se,oe),ee));return se=>{const ae=se==null?[]:$(se);if(ne.length===0)return!0;const de=new Set(ae.map(me=>g(me,ee)));for(let me=0;me<ne.length;me++)if(!de.has(ne[me]))return!1;return!0}}default:{const ne=Q(te);return ne?ne.compile(Y.value):(N(`op:${String(te)}`,`unknown filter operator "${String(te)}"; the condition is refused rather than matching every row`),()=>!1)}}}function S(Y,J,te){return f(J,te)(Y)}const m=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),d=new Set(["containsAny","containsAll","containsNone"]);function j(Y,J,te){const ee=Y&&Y.op,oe=m[ee]||ee,re=f({...Y,op:oe,type:J.type},te),le=J.items,ne=se=>{const ae=le(se);if(!ae)return!1;for(let de=0;de<ae.length;de++)if(re(ae[de]))return!0;return!1};return m[ee]?se=>!ne(se):ne}function E(Y,J,te,ee){const oe=v(Y);if(oe){const ne=J?1:0;for(let se=0;se<ee;se++)te[se]=oe(se)===ne?1:0;return te}const re=Y.kind;if(re==="float64"||re==="int32"||re==="bitset")return i(te,ee,J?1:0);const le=y(Y);for(let ne=0;ne<ee;ne++){const se=le(ne),ae=M(se)||Array.isArray(se)&&se.length===0;te[ne]=ae===J?0:1}return te}function O(Y,J,te,ee){const oe=Y.dict,re=x(oe),le=new Uint8Array(re);for(let de=0;de<re;de++)le[de]=J(I(oe,de))?1:0;const ne=Y.values,se=v(Y);if(!se){for(let de=0;de<ee;de++)te[de]=le[ne[de]];return te}const ae=J(null)?1:0;for(let de=0;de<ee;de++)te[de]=se(de)===1?le[ne[de]]:ae;return te}function T(Y,J,te,ee){const oe=U(Y.values),re=J(!0)?1:0,le=J(!1)?1:0,ne=v(Y);if(!ne){for(let ae=0;ae<ee;ae++)te[ae]=oe(ae)===1?re:le;return te}const se=J(null)?1:0;for(let ae=0;ae<ee;ae++)te[ae]=ne(ae)===0?se:oe(ae)===1?re:le;return te}function A(Y,J,te,ee,oe){const re=Y.values,le=J.type,ne=J.op;let se=!0;switch(ne){case"eq":case"ne":{const de=c(r(J.value,le)),me=typeof J.value=="number"&&Number.isNaN(J.value),Pe=ne==="ne"?1:0;if(me)for(let Ie=0;Ie<oe;Ie++)ee[Ie]=(Number.isNaN(re[Ie])?1:0)^Pe;else for(let Ie=0;Ie<oe;Ie++)ee[Ie]=(re[Ie]===de?1:0)^Pe;break}case"lt":{const de=c(r(J.value,le));for(let me=0;me<oe;me++)ee[me]=re[me]<de?1:0;break}case"lte":{const de=c(r(J.value,le));for(let me=0;me<oe;me++)ee[me]=re[me]<=de?1:0;break}case"gt":{const de=c(r(J.value,le));for(let me=0;me<oe;me++)ee[me]=re[me]>de?1:0;break}case"gte":{const de=c(r(J.value,le));for(let me=0;me<oe;me++)ee[me]=re[me]>=de?1:0;break}case"between":case"notBetween":{const de=$(J.value),me=c(r(de[0],le)),Pe=c(r(de[1],le)),Ie=J.bounds||"[]",ke=Ie.charAt(0)!=="(",be=Ie.charAt(1)!==")",ge=ne==="notBetween"?1:0;if(ke&&be)for(let Ee=0;Ee<oe;Ee++)ee[Ee]=(re[Ee]>=me&re[Ee]<=Pe?1:0)^ge;else if(ke)for(let Ee=0;Ee<oe;Ee++)ee[Ee]=(re[Ee]>=me&re[Ee]<Pe?1:0)^ge;else if(be)for(let Ee=0;Ee<oe;Ee++)ee[Ee]=(re[Ee]>me&re[Ee]<=Pe?1:0)^ge;else for(let Ee=0;Ee<oe;Ee++)ee[Ee]=(re[Ee]>me&re[Ee]<Pe?1:0)^ge;break}case"in":case"notIn":{const de=new Set;for(const Pe of $(J.value)){const Ie=c(r(Pe,le));Number.isNaN(Ie)||de.add(Ie)}const me=ne==="notIn"?1:0;for(let Pe=0;Pe<oe;Pe++)ee[Pe]=(de.has(re[Pe])?1:0)^me;break}default:se=!1;break}if(!se)return!1;const ae=v(Y);if(ae){const de=te(null)?1:0;for(let me=0;me<oe;me++)ae(me)===0&&(ee[me]=de)}return!0}function P(Y,J,te,ee){const oe=y(Y);for(let re=0;re<ee;re++)te[re]=J(oe(re))?1:0;return te}function L(Y,J,te){const ee=J.count|0,oe=te||n(J,ee);if(!Y)return i(oe,ee,1);const re=typeof J.handle=="function"?J.handle(Y.col):void 0,le=typeof J.custom=="function"?J.custom:null;if(!re){if(le){for(let de=0;de<ee;de++)oe[de]=le(Y,de)?1:0;return oe}return N(`filter:col:${String(Y.col)}`,`filter references unknown column "${String(Y.col)}"; the condition is refused rather than matching every row`),i(oe,ee,0)}const ne=Y.op;if(ne==="blank"||ne==="notBlank")return E(re,ne==="notBlank",oe,ee);const se=typeof J.itemwise=="function"?J.itemwise(Y.col):null;if(se&&!Q(ne)&&!d.has(ne))return P(re,j(Y,se,J.locale),oe,ee);const ae=f(Y,J.locale);switch(re.kind){case"dictionary":return O(re,ae,oe,ee);case"bitset":return T(re,ae,oe,ee);case"float64":case"int32":return A(re,Y,ae,oe,ee)?oe:P(re,ae,oe,ee);default:return P(re,ae,oe,ee)}}function z(Y,J,te){if(!Y)return i(n(J,te),te,1);if(Array.isArray(Y.conditions)){const ee=Y.conditions.filter(le=>le!=null),oe=Y.op==="or"?"or":Y.op==="not"?"not":"and";if(ee.length===0)return i(n(J,te),te,1);const re=z(ee[0],J,te);for(let le=1;le<ee.length;le++){const ne=z(ee[le],J,te);if(oe==="or")for(let se=0;se<te;se++)re[se]|=ne[se];else for(let se=0;se<te;se++)re[se]&=ne[se];t(J,ne)}if(oe==="not")for(let le=0;le<te;le++)re[le]^=1;return re}return L(Y,J,n(J,te))}function H(Y,J){return z(Y,J,J.count|0)}function D(Y,J){if(!Y||!J)return Y||null;const te=Y;if(Array.isArray(te.conditions)){if((te.op==="or"?"or":te.op==="not"?"not":"and")!=="and")return F(te,J)?null:Y;const oe=[];for(const re of te.conditions){const le=D(re,J);le&&oe.push(le)}return oe.length?{...te,op:"and",conditions:oe}:null}return te.col===J?null:Y}function F(Y,J){if(!Y||typeof Y!="object")return!1;const te=Y;if(te.col===J)return!0;if(Array.isArray(te.conditions)){for(const ee of te.conditions)if(F(ee,J))return!0}return!1}function C(Y,J,te){if(te&&te.length>=J){let le=0;for(let ne=0;ne<J;ne++)Y[ne]&&(te[le++]=ne);return te.subarray(0,le)}let ee=0;for(let le=0;le<J;le++)ee+=Y[le]?1:0;const oe=new Uint32Array(ee);let re=0;for(let le=0;le<J;le++)Y[le]&&(oe[re++]=le);return oe}const B=new Map;function _(Y){if(!(!Y||typeof Y!="object"))for(const[J,te]of Object.entries(Y))te&&typeof te.compile=="function"&&B.set(J,te)}function Q(Y){return typeof Y=="string"?B.get(Y):void 0}}),Ae("packages/core/src/columns/datatypes.js",function(e,G){"use strict";Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"parseNumberText",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"BUILTIN_TYPES",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"INFERENCE_ORDER",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"createTypeRegistry",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"comparatorFor",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"storageKind",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"typeLabel",{enumerable:!0,get:function(){return L}});const q=G("packages/core/src/internal/util.js"),M=q.collator,$=q.defaultCompare,N=q.isNil,W=q.isObject,Z=q.isFunction,V=q.fail,U=q.titleCase,x=G("packages/core/src/format/date.js"),I=x.toDate,v=x.toIsoDate,k=x.compareIso,l=G("packages/core/src/format/boolean.js").toTriState,n=G("packages/core/src/columns/types/index.js").EXTENDED_TYPES,t=G("packages/core/src/formula/index.js"),i=t.evaluateFormula,s=t.looksLikeFormula,o=G("packages/core/src/compute/filter.js").declareOperators,c=/^\d{4}-\d{2}-\d{2}$/;function a(z){return z.getHours()===0&&z.getMinutes()===0&&z.getSeconds()===0&&z.getMilliseconds()===0}const g=new Map;function h(z){const H=z||"",D=g.get(H);if(D)return D;const F={group:",",decimal:"."};try{for(const C of new Intl.NumberFormat(z||void 0).formatToParts(12345.6))C.type==="group"?F.group=C.value:C.type==="decimal"&&(F.decimal=C.value)}catch{}return g.set(H,F),F}const b=/\d\s*[*/^]\s*[\d.(]/;function p(z,H){if(N(z))return null;let D=String(z).trim();if(D===""||D.startsWith("=")||b.test(D))return null;let F=1;D.startsWith("(")&&D.endsWith(")")&&(F=-1,D=D.slice(1,-1));const C=D.endsWith("%"),{group:B,decimal:_}=h(H);if(D=D.replace(/[\s\u00a0\u202f\u2009']/g,""),B&&B!=="."&&B!==","&&(D=D.split(B).join("")),D=D.replace(/[^0-9eE+\-.,]/g,""),_===","?D=D.split(".").join("").replace(",","."):D=D.split(",").join(""),D===""||D==="-"||D==="+")return null;const Q=Number(D);return Number.isNaN(Q)?null:F*(C?Q/100:Q)}function f(z,H){const D=N(z)||Number.isNaN(z)?null:Number(z),F=N(H)||Number.isNaN(H)?null:Number(H);return D===null?F===null?0:1:F===null||D<F?-1:D>F?1:0}function w(z,H){const D=l(z),F=l(H);return D===null?F===null?0:1:F===null?-1:D===F?0:D?1:-1}function S(z,H){const D=I(z),F=I(H);if(!D)return F?1:0;if(!F)return-1;const C=D.getTime(),B=F.getTime();return C<B?-1:C>B?1:0}const m=new Map;function d(z){const H=I(z.value);if(!H)return"";const D=z.locale||"";let F=m.get(D);return F||(F=new Intl.DateTimeFormat(z.locale||void 0,{dateStyle:"medium"}),m.set(D,F)),F.format(H)}const j={boolean:{base:"boolean",storage:"bitset",matches:z=>typeof z=="boolean",parse:z=>l(z.text),compare:w,format:z=>l(z.value)===null?"":l(z.value)?"Yes":"No",defaults:{filter:"set",editor:"checkbox",align:"center"},excel:"General",toClipboard:z=>l(z)===null?"":String(l(z)),fromClipboard:z=>l(z)},number:{base:"number",storage:"float64",matches:z=>typeof z=="number"&&!Number.isNaN(z),parse:z=>{if(s(z.text)){const H=i(z.text,z);if(!H.ok)return null;const D=Number(H.value);return Number.isFinite(D)?D:null}return p(z.text,z.locale)},compare:f,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:z=>N(z)?"":String(z),fromClipboard:(z,H)=>p(z,H&&H.locale)},date:{base:"dateString",storage:"dictionary",matches:z=>typeof z=="string"&&c.test(z)&&!Number.isNaN(Date.parse(z))||z instanceof Date&&!Number.isNaN(z.getTime())&&a(z),parse:z=>v(z.text),compare:k,format:d,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:z=>v(z),toClipboard:z=>N(z)?"":String(z),fromClipboard:z=>v(z)},dateString:{base:"dateString",storage:"dictionary",matches:z=>typeof z=="string"&&c.test(z)&&!Number.isNaN(Date.parse(z)),parse:z=>v(z.text),compare:k,format:d,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:z=>v(z),toClipboard:z=>N(z)?"":String(z),fromClipboard:z=>v(z)},text:{base:"text",storage:"dictionary",matches:z=>typeof z=="string",parse:z=>z.text===""?null:String(z.text),compare:(z,H)=>N(z)?N(H)?0:1:N(H)?-1:M().compare(String(z),String(H)),defaults:{filter:"text",editor:"text",align:"start"},excel:"@",toClipboard:z=>N(z)?"":String(z),fromClipboard:z=>z},image:{base:"text",storage:"dictionary",parse:z=>z.text===""||z.text==null?null:String(z.text).trim(),compare:(z,H)=>N(z)?N(H)?0:1:N(H)?-1:M().compare(String(z),String(H)),defaults:{filter:"text",editor:"text",align:"center",render:"image"},excel:"@",toClipboard:z=>N(z)?"":String(z),fromClipboard:z=>z},lookup:{base:"text",storage:"dictionary",parse:z=>{if(z.text===""||z.text==null)return null;const H=z.column&&z.column.lookup,D=H&&Z(H.options)?H.options():null;if(!D)return z.text;const F=String(z.text),C=D.find(Q=>String(Q.id)===F);if(C)return C.id;const B=F.trim().toLowerCase(),_=D.find(Q=>String(Q.label).toLowerCase()===B);return _?_.id:z.text},compare:$,defaults:{filter:"set",editor:"select",align:"start"},excel:"@",multiStorage:"multi",toClipboard:z=>N(z)?"":String(z),fromClipboard:z=>z},object:{base:"object",storage:"object",matches:z=>z!==null&&typeof z=="object"&&!(z instanceof Date),parse:z=>{try{return z.text===""?null:JSON.parse(z.text)}catch{return z.text}},compare:(z,H)=>$(z,H),format:z=>{const H=z.value;if(N(H))return"";if(typeof H=="string")return H;try{return JSON.stringify(H)}catch{return String(H)}},defaults:{filter:"none",editor:"none",align:"start"},excel:"@",toClipboard:z=>N(z)?"":typeof z=="string"?z:JSON.stringify(z),fromClipboard:z=>z}},E=["boolean","number","date","dateString","datetime","text","object"];function O(z,H,D,F){const C=D.get(z);if(C)return C;F.includes(z)&&V(`circular data type extends chain: ${[...F,z].join(" → ")}`);const B=H[z];B||V(`unknown data type "${z}"`);let _=null;B.extends&&(_=O(B.extends,H,D,[...F,z]));const Q={..._||{},...B,name:z,defaults:{..._&&_.defaults||{},...B.defaults||{}}};return Q.base||(Q.base=_&&_.base||"text"),Q.storage||(Q.storage=_&&_.storage||"object"),D.set(z,Q),Q}function T(z,H){const D={...j,...n};if(H&&typeof H.dataType=="function"&&typeof H.names=="function")for(const C of H.names("dataType")){const B=H.dataType(C);B&&(D[C]=B)}if(W(z))for(const[C,B]of Object.entries(z))D[C]=B;const F=new Map;for(const C of E)O(C,D,F,[]);O("lookup",D,F,[]);for(const C of Object.keys(D))O(C,D,F,[]);for(const C of F.values())o(C.operators);return F}function A(z,H){if(z.base==="text"&&(!z.compare||z.compare===j.text.compare)){const D=M(H);return(F,C)=>N(F)?N(C)?0:1:N(C)?-1:D.compare(String(F),String(C))}return z.compare||$}function P(z,H){return H?z.multiStorage||"multi":z.storage||"object"}function L(z){return U(String(z).replace(/([a-z])([A-Z])/g,"$1 $2"))}}),Ae("packages/core/src/columns/infer.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_SAMPLE",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"inferFromValues",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"inferColumnType",{enumerable:!0,get:function(){return Z}});const q=G("packages/core/src/internal/util.js"),M=q.infoOnce,$=q.isNil,N=100;function W(V,U,x={}){const I=x.sampleSize??N,v=[];for(let k=0;k<V.length&&v.length<I;k++){const y=V[k];$(y)||typeof y=="number"&&Number.isNaN(y)||v.push(y)}if(v.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[k,y]of U){if(typeof y.matches!="function")continue;let l=!0;for(let u=0;u<v.length;u++)if(!y.matches(v[u])){l=!1;break}if(l)return{type:k,unanimous:!0,sampled:v.length}}return x.quiet||M(`infer:${x.colId||"?"}`,`column "${x.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 Z(V,U,x,I,v={}){const k=v.sampleSize??N,y=[];for(let l=0;l<U.length&&y.length<k;l++){const u=x(U[l]);$(u)||typeof u=="number"&&Number.isNaN(u)||y.push(u)}return W(y,I,{...v,colId:V}).type}}),Ae("packages/core/src/columns/graph.js",function(e,G){"use strict";Object.defineProperty(e,"WHOLE_ROW",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"declarationOf",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"affectedBy",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return I}});const q=G("packages/core/src/internal/util.js"),M=q.DEV,$=q.fail,N=q.isFunction,W=q.warnOnce,Z="*";function V(v){const k=v.value||{};if(!N(k.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const l=k.pure!==!1;return k.deps===Z?{computed:!0,wholeRow:!0,deps:[],pure:l}:Array.isArray(k.deps)?{computed:!0,wholeRow:!1,deps:k.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 U(v){const k=new Map;for(const g of v)k.set(g.id,g);const y=new Map,l=new Map,u=new Set,n=new Set,t=new Set,i=new Set;for(const g of v){const h=V(g);if(!h.computed){y.set(g.id,[]);continue}n.add(g.id),(h.pure?t:i).add(g.id),h.wholeRow&&u.add(g.id);const b=[],p=[];for(const f of h.deps)(k.has(f)?b:p).push(f);y.set(g.id,b),p.length&&l.set(g.id,p)}for(const g of t)for(const h of y.get(g))i.has(h)&&$(`pure computed column "${g}" depends on impure column "${h}". Mark it \`value.pure: false\` or make the dependency pure.`);const s=[],r=new Map,o=[],c=g=>{const h=r.get(g);if(h!=="done"){if(h==="open"){const b=o.indexOf(g);$(`circular column dependency: ${[...o.slice(b),g].join(" → ")}`)}r.set(g,"open"),o.push(g);for(const b of y.get(g)||[])k.has(b)&&c(b);o.pop(),r.set(g,"done"),s.push(g)}};for(const g of v)c(g.id);const a=new Map;for(const g of v)a.set(g.id,[]);for(const g of v)for(const h of y.get(g.id)||[]){const b=a.get(h);b&&!b.includes(g.id)&&b.push(g.id)}if(u.size)for(const g of v){if(n.has(g.id))continue;const h=a.get(g.id);for(const b of u)h.includes(b)||h.push(b)}return{order:s,dependents:a,pure:t,impure:i,computed:n,deps:y,wholeRow:u,external:l,index:k}}function x(v,k){const y=Array.isArray(k)?k:[k],l=new Set,u=[...y];for(;u.length;){const n=u.shift();for(const t of v.dependents.get(n)||[])l.has(t)||(l.add(t),u.push(t))}for(const n of y)l.delete(n);return v.order.filter(n=>l.has(n))}function I(v,k,y){if(!M)return v;const l=k instanceof Set?k:new Set(k);return new Proxy(v,{get(u,n){return typeof n=="string"&&!l.has(n)&&!Object.hasOwn(u,n)&&W(`undeclared:${y}:${n}`,`computed column "${y}" read undeclared dependency "${n}". Add it to \`value.deps\` or the value will go stale.`),u[n]}})}}),Ae("packages/core/src/columns/lookup.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_SEPARATOR",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"normaliseOption",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"flattenOptions",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return y}});const q=G("packages/core/src/internal/util.js"),M=q.collator,$=q.defaultCompare,N=q.isFunction,W=q.isNil,Z=q.warnOnce,V=", ",U="";function x(l,u,n,t){if(l===null||typeof l!="object")return{id:l,label:l==null?"":String(l)};const i=l[u],s=l[n],r={id:i,label:s==null?String(i??""):String(s)};l.disabled&&(r.disabled=!0),l.variant&&(r.variant=l.variant),l.icon&&(r.icon=l.icon);const o=t?l[t]:l.group;return o!==void 0&&(r.group=o),r}function I(l,u,n=0,t=[],i=[]){for(const s of l||[]){const r=s&&typeof s=="object"?s[u]:null;if(i.push({raw:s,depth:n,path:t}),Array.isArray(r)&&r.length){const o=String(s&&typeof s=="object"?s.label??s.name??s.id??"":s);I(r,u,n+1,[...t,o],i)}}return i}class v{#e;#t;#n;#r;#o=[];#i=new Map;#s=new Map;#l=0;#a="idle";#u=null;#c;constructor(u,n={}){this.#e=u||{},this.#t=n.colId||"?",this.#n=n.locale,this.#r=n.onChange||null,this.#c=M(this.#n),Array.isArray(this.#e.options)?this.#d(this.#e.options):this.#e.options===void 0&&(this.#a="ready")}get colId(){return this.#t}get version(){return this.#l}get state(){return this.#a}get ready(){return this.#a==="ready"}get multiple(){return this.#e.multiple===!0}get separator(){return this.#e.separator??V}get allowCustom(){return this.#e.allowCustom===!0}get sortBy(){return this.#e.sortBy||"label"}get spec(){return this.#e}options(){return this.#o}setLocale(u){this.#n=u,this.#c=M(u)}#d(u){const n=this.#e,t=n.valueKey||"id",i=n.labelKey||"label",s=n.childrenKey||"children";this.#o=I(u,s).map(r=>{const o=x(r.raw,t,i,n.groupKey);return r.depth&&(o.depth=r.depth,o.path=r.path),o}),this.#i=new Map,this.#s=new Map,this.#o.forEach((r,o)=>{this.#i.set(r.id,r),this.#s.set(r.id,o)}),this.#a="ready",this.#l+=1}load(){if(this.#u)return this.#u;const u=this.#e.options;if(Array.isArray(u)||u===void 0)return this.#u=Promise.resolve(this.#o),this.#u;if(!N(u))return Z(`lookup:options:${this.#t}`,`column "${this.#t}" has an invalid \`lookup.options\`; expected an array or a function`),this.#a="ready",this.#u=Promise.resolve([]),this.#u;this.#a="loading";let n;try{n=u()}catch(t){return this.#a="error",Z(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,t),this.#u=Promise.resolve([]),this.#u}return!n||!N(n.then)?(this.#d(n),this.#u=Promise.resolve(this.#o),this.#r&&this.#r(this),this.#u):(this.#u=n.then(t=>(this.#d(t),this.#r&&this.#r(this),this.#o),t=>(this.#a="error",Z(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,t),[])),this.#u)}refresh(){return this.#u=null,Array.isArray(this.#e.options)?(this.#d(this.#e.options),this.#r&&this.#r(this),Promise.resolve(this.#o)):this.load()}search(u,n){const t=this.#e;if(!N(t.search)){const r=String(u||"").toLowerCase();return Promise.resolve(r===""?this.#o:this.#o.filter(o=>o.label.toLowerCase().includes(r)))}const i=t.valueKey||"id",s=t.labelKey||"label";return Promise.resolve(t.search(u,n)).then(r=>(r||[]).map(o=>x(o,i,s,t.groupKey)))}option(u){return this.#i.get(u)}has(u){return this.#i.has(u)}label(u){if(W(u)||u==="")return"";const n=this.#i.get(u);if(n)return n.label;if(this.#a==="loading"||this.#a==="idle")return"";this.allowCustom||Z(`lookup:unknown:${this.#t}`,`column "${this.#t}" holds value ${JSON.stringify(u)} which is not in its lookup options. Showing the raw value; set \`lookup.unknownLabel\` or \`lookup.allowCustom\` to change that.`);const t=this.#e.unknownLabel;return N(t)?String(t(u)??""):typeof t=="string"?t:String(u)}text(u){if(this.multiple){const n=k(u);return n.length===0?"":n.map(t=>this.label(t)).join(this.separator)}return this.label(u)}dictionary(){return this.#o.map(u=>u.id)}sorted(){const u=this.sortBy;if(u==="optionOrder"||u==="count")return this.#o.slice();if(u==="value")return this.#o.slice().sort((t,i)=>$(t.id,i.id));const n=this.#c;return this.#o.slice().sort((t,i)=>n.compare(t.label,i.label))}comparator(){const u=this.sortBy,n=this.multiple,t=this.#c,i=this.#s;if(n&&u==="count")return(r,o)=>k(r).length-k(o).length;const s=n?r=>k(r)[0]:r=>r;return u==="value"?(r,o)=>$(s(r),s(o)):u==="optionOrder"?(r,o)=>{const c=i.has(s(r))?i.get(s(r)):Number.MAX_SAFE_INTEGER,a=i.has(s(o))?i.get(s(o)):Number.MAX_SAFE_INTEGER;return c-a}:(r,o)=>{const c=s(r),a=s(o);return W(c)?W(a)?0:1:W(a)?-1:t.compare(this.label(c),this.label(a))}}groupKey(u){return this.multiple?k(u).map(t=>String(t)).sort().join(U):W(u)?"":String(u)}countValues(u){return this.multiple?k(u).length:W(u)?0:1}contains(u,n,t){const i=this.multiple?k(u):W(u)?[]:[u],s=Array.isArray(n)?n:[n];switch(t){case"containsAll":return s.every(r=>i.includes(r));case"containsNone":return!s.some(r=>i.includes(r));default:return s.some(r=>i.includes(r))}}exportText(u,n="label"){return n==="value"?this.multiple?k(u).join(this.separator):W(u)?"":String(u):this.text(u)}exportColumns(){const u=this.multiple;return this.#o.map(n=>({id:n.id,label:n.label,has:t=>u?k(t).includes(n.id):t===n.id}))}}function k(l){return Array.isArray(l)?l:W(l)||l===""?[]:[l]}function y(l,u={}){const n=l.lookup;if(!n)return null;const t=new v(n,{colId:l.id,locale:u.locale,onChange:u.onChange});return!Array.isArray(n.options)&&n.options!==void 0&&t.load(),t}}),Ae("packages/core/src/columns/value.js",function(e,G){"use strict";Object.defineProperty(e,"compileDisplay",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"warnImpureUse",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return y}});const q=G("packages/core/src/internal/util.js"),M=q.getPath,$=q.isFunction,N=q.isNil,W=q.Lru,Z=q.warnOnce,U=G("packages/core/src/columns/graph.js").depsProxy,x="\0";function I(t,i={}){const s=i.locale,r=i.grid??null,o=i.context,c=t.value&&t.value.format,a=t.formatter||null,g=t.dataType&&t.dataType.format,h=t.lookup||null,b=(p,f,w)=>({value:p,data:w,row:f,column:t,colId:t.id,grid:r,context:o,locale:s});if($(c))return(p,f,w)=>{const S=c(b(p,f,w));return S==null?"":String(S)};if(a){if(h){const p=a.kind==="text";return(f,w,S)=>a(p?h.text(f):f,b(f,w,S))}return(p,f,w)=>a(p,b(p,f,w))}return $(g)?(p,f,w)=>{const S=g(b(p,f,w));return S==null?"":String(S)}:h?p=>h.text(p):p=>N(p)?"":typeof p=="string"?p:String(p)}function v(t,i){!t||!t.value||t.value.pure!==!1||Z(`impure:${i}:${t.id}`,`column "${t.id}" is an impure computed column (\`value.pure: false\`) and is being used to ${i}. The result is not stable across passes.`)}class k{#e;#t;#n;#r;#o;#i;#s=new W(4096);constructor(i){this.#e=i.columns instanceof Map?i.columns:new Map((i.columns||[]).map(s=>[s.id,s])),this.#t=i.graph,this.#n=i.grid??null,this.#r=i.context,this.#i=i.stored||null,this.#o=i.rowKey||y}get graph(){return this.#t}setGraph(i){this.#t=i,this.#s.clear()}beginPass(){this.#s.clear()}endPass(){this.#s.clear()}invalidate(i){if(this.#s.size===0)return;const s=i&&i.rows?new Set([...i.rows].map(String)):null,r=i&&i.columns?[...i.columns]:null;if(!s&&!r){this.#s.clear();return}const o=r?this.#l(r):null;for(const c of[...this.#s.keys()]){const a=String(c).split(x);a.length===3&&(s&&!s.has(a[0])||o&&!o.has(a[2])||this.#s.delete(c))}}#l(i){const s=new Set,r=this.#t,o=[...i];for(;o.length;){const c=o.pop();if(!s.has(c)){s.add(c);for(const a of r?r.dependents.get(c)||[]:[])o.push(a)}}return s}value(i,s,r){const o=typeof i=="string"?this.#e.get(i):i;if(!o)return;if(!o.computed)return this.#u(o,s,r);if(o.value.pure!==!1&&this.#i&&r&&r.physical!=null&&this.#i.has(o.id))return this.#i.get(o.id,r.physical);if(o.volatile)return this.compute(o,s,r);if(o.value.pure===!1)return this.compute(o,s,r);const c=`${this.#a(s,r)}${x}${o.id}`;if(this.#s.has(c))return this.#s.get(c);const a=this.compute(o,s,r);return this.#s.set(c,a),a}#a(i,s){return`${this.#o(i,s)}${x}${l(i)}`}#u(i,s,r){if(this.#i&&r&&r.physical!=null&&this.#i.has(i.id))return this.#i.get(i.id,r.physical);if(i.field)return i.read?i.read(s):M(s,i.field)}compute(i,s,r){const o=this.#t,c=o&&o.wholeRow.has(i.id);let a;if(c)a=s??{};else{a={};const h=o&&o.deps.get(i.id)||[];for(const p of h)a[p]=this.value(p,s,r);const b=o&&o.external.get(i.id)||[];for(const p of b)a[p]=M(s,p);a=U(a,[...h,...b],i.id)}const g={data:s,row:r,column:i,grid:this.#n,context:this.#r};return i.value.compute(a,g)}values(i,s){const r={},o=this.#t?this.#t.order:[...this.#e.keys()];for(const c of o)r[c]=this.value(c,i,s);return r}text(i,s,r){const o=typeof i=="string"?this.#e.get(i):i;return o?o.formatValue(this.value(o,s,r),r,s):""}key(i,s,r){const o=typeof i=="string"?this.#e.get(i):i;if(!o)return"";const c=this.value(o,s,r);return $(o.value.key)?String(o.value.key(this.#c(o,c,s,r))):o.lookup?o.lookup.groupKey(c):N(c)?"":String(c)}quickFilterText(i,s,r){const o=typeof i=="string"?this.#e.get(i):i;if(!o)return"";if($(o.value.quickFilterText)){const c=this.value(o,s,r);return String(o.value.quickFilterText(this.#c(o,c,s,r))??"")}return this.text(o,s,r)}#c(i,s,r,o){return{value:s,data:r,row:o,column:i,colId:i.id,grid:this.#n,context:this.#r}}parse(i,s,r,o){const c=typeof i=="string"?this.#e.get(i):i;if(!c)return s;const a={text:s,value:this.value(c,r,o),data:r,row:o,column:c,grid:this.#n,context:this.#r,locale:this.#n&&$(this.#n.get)?this.#n.get("locale"):void 0,formulaFunctions:this.#n&&$(this.#n.get)?this.#n.get("formulaFunctions"):void 0};return $(c.value.parse)?c.value.parse(a):c.dataType&&$(c.dataType.parse)?c.dataType.parse(a):s}validate(i,s,r,o,c){const a=typeof i=="string"?this.#e.get(i):i;if(!a||!$(a.edit.validate))return!0;const g=a.edit.validate({value:s,oldValue:r,data:o,row:c,column:a,grid:this.#n,context:this.#r});return g===!0||g===void 0?!0:String(g)}apply(i,s,r,o){const c=typeof i=="string"?this.#e.get(i):i;if(!c)return!1;const a=this.value(c,r,o);if($(c.value.apply)){const g=c.value.apply({value:s,oldValue:a,data:r,row:o,column:c,grid:this.#n,context:this.#r});return this.#d(c,r,o),g!==!1}return c.field?a===s?!1:(c.write(r,s),this.#d(c,r,o),!0):(Z(`apply:${c.id}`,`column "${c.id}" has no \`field\` and no \`value.apply\`, so an edit cannot be written back.`),!1)}commit(i,s,r,o){const c=typeof i=="string"?this.#e.get(i):i;if(!c)return{ok:!1,value:void 0,oldValue:void 0,changed:!1,error:"unknown column"};const a=this.value(c,r,o),g=this.parse(c,s,r,o),h=this.validate(c,g,a,r,o);if(h!==!0)return{ok:!1,value:g,oldValue:a,changed:!1,error:h};const b=this.apply(c,g,r,o);return{ok:!0,value:g,oldValue:a,changed:b}}#d(i,s,r){if(this.#s.size===0)return;const o=this.#a(s,r);this.#s.delete(`${o}${x}${i.id}`);for(const c of this.#t?this.#t.dependents.get(i.id)||[]:[])this.#s.delete(`${o}${x}${c}`)}}function y(t,i){return i&&i.key!=null?String(i.key):l(t)}function l(t){if(t&&typeof t=="object"){let i=u.get(t);return i===void 0&&(i=`#${n++}`,u.set(t,i)),i}return String(t)}const u=new WeakMap;let n=0}),Ae("packages/core/src/model/shadow.js",function(e,G){"use strict";Object.defineProperty(e,"MAX_TRACKED",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"DEFAULT_DEPTH",{enumerable:!0,get:function(){return N}}),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 Z}}),Object.defineProperty(e,"historyTickFor",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"SHADOW_KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"ROLLING_KINDS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"FIT_SHADOW_KINDS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"DEFAULT_ANOMALY_THRESHOLD",{enumerable:!0,get:function(){return k}}),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 u}}),Object.defineProperty(e,"specStatusOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ShadowTracker",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"shadowsIn",{enumerable:!0,get:function(){return a}});const M=G("packages/core/src/internal/util.js").warnOnce,$=2e5,N=20,W=1e3,Z=50;function V(g){return Math.min(W,Math.max(Z,Math.floor(g)))}const U=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"]),x=Object.freeze(["rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta"]),I=Object.freeze(["fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),v=.6745,k=3.5,y=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),l=Object.freeze(["rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag"]),u=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 n(g,h){if(!h)return null;const b=Number.isFinite(Number(h.lower))?Number(h.lower):null,p=Number.isFinite(Number(h.upper))?Number(h.upper):null;if(b===null&&p===null||!Number.isFinite(g))return null;if(b!==null&&g<b||p!==null&&g>p)return y.FAIL;const f=Number.isFinite(Number(h.warnLower))?Number(h.warnLower):null,w=Number.isFinite(Number(h.warnUpper))?Number(h.warnUpper):null;return f!==null&&g<f||w!==null&&g>w?y.WARN:y.PASS}function t(g,h,b){if(!h||typeof h!="object")return null;if(h.kind!=="time")return h.kind!==void 0&&M(`shadow.history.window.kind:${g}`,`a 'history' shadow's 'window' only accepts {kind: 'time', span}; '${h.kind}' is not honoured (a plain count is already what 'depth' means, and a session has no span to divide into buckets), so it reported the original, unwindowed history.`),null;const p=h.minutes!=null?Number(h.minutes)*6e4:Number(h.span);if(!(p>0))return M(`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 f=Math.max(2,Math.floor(b)||N);return{span:p,bucketMs:Math.max(1,Math.floor(p/f))}}class i{#e;#t=new Map;#n=new Map;#r=new Map;#o=new Map;#i=new Map;#s=new Map;#l=0;#a;#u;#c;#d;#h=new Map;#f=null;#m=null;#p=null;constructor(h){this.#e=h.colId,this.#a=Math.max(2,h.depth||N),this.#u=Math.max(1,h.max||$),this.#c=h.now||(()=>Date.now()),this.#d=t(this.#e,h.historyWindow,this.#a),this.#d&&(this.#f=Math.floor(this.#c()/this.#d.bucketMs))}get colId(){return this.#e}get forgotten(){return this.#l}get size(){return this.#n.size}get historyWindow(){return this.#d}observe(h,b){const p=c(b);if(p===null)return;if(!this.#n.has(h)){this.#m=null,this.#p=null,this.#g(),this.#t.set(h,p),this.#n.set(h,p),this.#r.set(h,0),this.#o.set(h,this.#c()),this.#i.set(h,[p]),this.#d&&this.#h.set(h,[p]),this.#s.set(h,0);return}const f=this.#n.get(h);if(f===p)return;this.#m=null,this.#p=null,this.#n.set(h,p),this.#r.set(h,(this.#r.get(h)||0)+1),this.#o.set(h,this.#c());const w=this.#i.get(h)||[];w.push(p),w.length>this.#a&&w.splice(0,w.length-this.#a),this.#i.set(h,w);const S=Math.sign(p-f),m=this.#s.get(h)||0;this.#s.set(h,Math.sign(m)===S?m+S:S)}#g(){if(this.#n.size<this.#u)return;const h=this.#n.keys().next().value;h!==void 0&&(this.#t.delete(h),this.#n.delete(h),this.#r.delete(h),this.#o.delete(h),this.#i.delete(h),this.#h.delete(h),this.#s.delete(h),this.#l++)}rebase(){for(const[h,b]of this.#n)this.#t.set(h,b);this.#m=null,this.#p=null}reset(){this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#o.clear(),this.#i.clear(),this.#h.clear(),this.#s.clear(),this.#l=0,this.#m=null,this.#p=null,this.#d&&(this.#f=Math.floor(this.#c()/this.#d.bucketMs))}retain(h){const b=h instanceof Set?h:new Set(h);let p=0;for(const f of[...this.#n.keys()])b.has(f)||(this.#t.delete(f),this.#n.delete(f),this.#r.delete(f),this.#o.delete(f),this.#i.delete(f),this.#h.delete(f),this.#s.delete(f),p++);return p&&(this.#m=null,this.#p=null),p}advanceHistoryWindow(h=this.#c()){const b=this.#d;if(!b)return 0;const p=Math.floor(h/b.bucketMs),f=p-this.#f;if(!(f>0))return 0;const w=Math.min(f,this.#a);for(const[S,m]of this.#h){const d=this.#n.get(S);for(let j=0;j<w;j++)m.push(d);m.length>this.#a&&m.splice(0,m.length-this.#a)}return this.#f=p,f}read(h,b,p,f){switch(h){case"updates":return this.#r.has(b)?this.#r.get(b):0;case"updatedAt":{const w=this.#o.get(b);return w===void 0?null:new Date(w)}case"sinceUpdate":{const w=this.#o.get(b);return w===void 0?null:this.#c()-w}case"firstValue":return this.#t.has(b)?this.#t.get(b):null;case"delta":return this.#n.has(b)?this.#n.get(b)-this.#t.get(b):null;case"deltaPercent":{if(!this.#n.has(b))return null;const w=this.#t.get(b);return w?(this.#n.get(b)-w)/Math.abs(w)*100:null}case"rate":{const w=this.#i.get(b),S=this.#o.get(b);if(!w||w.length<2||S===void 0)return null;const m=this.#c()-S,d=w[w.length-1]-w[w.length-2];return m>0?d/m*1e3:d}case"history":return this.#d?this.#h.has(b)?[...this.#h.get(b)]:null:this.#i.has(b)?[...this.#i.get(b)]:null;case"streak":return this.#s.has(b)?this.#s.get(b):0;case"specStatus":return this.#n.has(b)?n(this.#n.get(b),f):null;default:return l.includes(h)?this.#v(h,b,p,f):null}}#w(h){if(h){if(this.#p&&this.#p.only===h)return this.#p.view;const b=this.#b(h);return this.#p={only:h,view:b},b}return this.#m?this.#m:(this.#m=this.#b(null),this.#m)}#b(h){const b=[];for(const[T,A]of this.#n)h&&!h.has(T)||b.push(A);const p=b.sort((T,A)=>T-A);let f=0,w=0,S=0,m=0;for(const T of p){m+=T,f++;const A=T-w;w+=A/f,S+=A*(T-w)}const d=[];for(const[T,A]of this.#t)h&&!h.has(T)||d.push(A);const j=f?s(p):0,E=p.map(T=>Math.abs(T-j)).sort((T,A)=>T-A),O=f?s(E):0;return{sorted:p,baseline:d.sort((T,A)=>T-A),sum:m,mean:f?w:0,sd:f>1?Math.sqrt(S/(f-1)):0,median:j,mad:O}}#v(h,b,p,f){if(!this.#n.has(b)||p&&!p.has(b))return null;const w=this.#n.get(b),S=this.#w(p),m=S.sorted.length;if(!m)return null;switch(h){case"rank":return m-o(S.sorted,w)+1;case"rankAsc":return r(S.sorted,w)+1;case"rankChange":{if(!this.#t.has(b)||!S.baseline.length)return null;const d=S.baseline.length-o(S.baseline,this.#t.get(b))+1,j=m-o(S.sorted,w)+1;return d-j}case"percentile":return o(S.sorted,w)/m*100;case"quartile":{const d=o(S.sorted,w)/m;return Math.min(4,Math.max(1,Math.ceil(d*4)))}case"zScore":return S.sd?(w-S.mean)/S.sd:null;case"anomalyScore":return S.mad?v*(w-S.median)/S.mad:null;case"anomalyFlag":{if(!S.mad)return null;const d=f&&Number.isFinite(Number(f.threshold))?Number(f.threshold):k;return Math.abs(v*(w-S.median)/S.mad)>d}case"shareOfTotal":return S.sum?w/S.sum*100:null;default:return null}}}function s(g){const h=g.length;if(!h)return 0;const b=(h-1)*.5,p=Math.floor(b),f=Math.ceil(b);return p===f?g[p]:g[p]+(b-p)*(g[f]-g[p])}function r(g,h){let b=0,p=g.length;for(;b<p;){const f=b+p>>1;g[f]<h?b=f+1:p=f}return b}function o(g,h){let b=0,p=g.length;for(;b<p;){const f=b+p>>1;g[f]<=h?b=f+1:p=f}return b}function c(g){if(g==null||g==="")return null;if(g instanceof Date){const b=g.getTime();return Number.isFinite(b)?b:null}const h=typeof g=="number"?g:Number(g);return Number.isFinite(h)?h:null}function a(g){const h=[];for(const b of g||[]){const p=b.shadow;if(!p)continue;const f=typeof p=="string"?{kind:p}:p,w=f.kind;U.includes(w)&&(x.includes(w)||I.includes(w)||h.push({colId:b.id||b.field,of:f.of||b.field||b.id,kind:w,depth:f.depth,historyWindow:w==="history"?f.window:void 0}))}return h}}),Ae("packages/core/src/columns/model.js",function(e,G){"use strict";Object.defineProperty(e,"BUILTIN_DEFAULTS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"normaliseAlign",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"normaliseVAlign",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"expandColumn",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"flattenTree",{enumerable:!0,get:function(){return oe}});const q=G("packages/core/src/internal/util.js"),M=q.expand,$=q.fail,N=q.getPath,W=q.humanise,Z=q.isFunction,V=q.isObject,U=q.merge,x=q.pathGetter,I=q.pathSetter,v=q.toArray,k=q.uid,y=q.warnOnce,u=G("packages/core/src/format/index.js").compileFormat,n=G("packages/core/src/columns/datatypes.js"),t=n.comparatorFor,i=n.createTypeRegistry,s=n.storageKind,r=G("packages/core/src/columns/infer.js"),o=r.inferColumnType,c=r.DEFAULT_SAMPLE,a=G("packages/core/src/columns/graph.js"),g=a.buildGraph,h=a.affectedBy,p=G("packages/core/src/columns/lookup.js").createLookup,f=G("packages/core/src/columns/value.js"),w=f.compileDisplay,S=f.ValuePipeline,m=f.warnImpureUse,j=G("packages/core/src/model/shadow.js").FIT_SHADOW_KINDS,E=Object.freeze({geometry:"geometry",list:"list"}),O={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},T={centre:"center"},A=new Set(["start","center","end","left","right"]);function P(le){if(typeof le!="string")return;const ne=le.toLowerCase();return T[ne]?T[ne]:A.has(ne)?ne:void 0}function L(le){if(typeof le!="string")return;const ne=le.toLowerCase();return ne==="center"||ne==="centre"?"middle":ne==="top"||ne==="middle"||ne==="bottom"?ne:void 0}const z=["cell","layout","header"];function H(le){if(!V(le))return{};const ne={...le},se=(ae,de)=>{if(le[ae]===void 0)return;const me=M(le[ae],de);me&&z.includes(ae)&&!V(le[ae])&&delete me.enabled,ne[ae]=me};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"),ne}function D(le,ne){const se={...le||{}},ae=V(ne)&&V(ne.layout)&&ne.layout.width!==void 0;return se.fit==="content"&&!ae&&delete se.width,se}const F=new Set(["allowGroup","allowPivot","allowTotal","cell","colSpan","contextMenu","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"]),C=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function B(le,ne,se,ae){const de=se==="columnGroup"?"column group":"column";for(const me of Object.keys(le))ne.has(me)||y(`${se}.unknown:${me}`,`'${me}' is not a configuration key this grid recognises, so it had no effect on ${de} "${ae}". Check the spelling against the reference.`)}function _(le,ne){const se=ne&&Z(le.defaultsFor)?le.defaultsFor(ne):null,ae={...le.defaults||{},...V(se)?se:{}},de={};return ae.align&&(de.align=ae.align,de.cell={align:ae.align},de.header={align:ae.align}),ae.filter&&(de.filter=ae.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:ae.filter}),ae.editor&&(de.edit=ae.editor==="none"?{editor:null}:{editor:ae.editor}),ae.total&&(de.total=ae.total),ae.render&&(de.cell={...de.cell||{},render:ae.render}),le.export&&(de.export={...le.export}),de}function Q(le){if(typeof le=="string")return le.trim()?[le.trim()]:[];if(!Array.isArray(le))return[];const ne=[];for(const se of le){if(typeof se!="string")continue;const ae=se.trim();ae&&!ne.includes(ae)&&ne.push(ae)}return ne}class Y{#e=new Map;#t=[];#n=[];#r;#o;#i;#s;#l;#a;#u(ne,se,ae){const de=this.#c(ne,se,ae);if(typeof de!="string"||!this.#d)return de??null;const me=se&&se.totals&&se.totals.implement;if(me&&Z(me[de])){const Ie=me[de];return Ie.totalName=de,Ie}const Pe=this.#d.totalFn?.(de);return Z(Pe)?Pe:de}#c(ne,se,ae){if(typeof ne!="string")return ne;const de=se&&se.totals&&se.totals.supported;if(!Array.isArray(de)||de.includes(ne))return ne;const me=de.length?de.join(", "):"none";return $(`column "${ae}" is typed ${se.name||"a type"}, for which the total "${ne}" is not meaningful. Supported: ${me}. Aggregating it anyway would produce a confident wrong number.`),ne}#d;#h;#f;#m;#p;#g;#w=!1;#b;#v;constructor(ne={}){this.#o=H(ne.columnDefaults||{}),this.#i=ne.columnPresets||{},this.#l=ne.locale,this.#s=ne.timeZone,this.#a=L(ne.verticalAlign),this.#d=ne.registry||null,this.#h=ne.grid||null,this.#f=ne.context,this.#b=ne.sampleSize??c,this.#v=ne.onChange||null,this.#g=Z(ne.rowKey)?ne.rowKey:void 0,this.#r=i(ne.dataTypes,this.#d);const{leaves:se,groups:ae}=oe(ne.columns||[]);this.#n=ae;for(const de of se){const me=this.#y(de.def,null);if(me.groupPath=de.path,this.#e.has(me.id)){y(`columns.duplicate:${me.id}`,`two columns resolve to the id '${me.id}', so the second is ignored. An id defaults to the column's field, so declare an explicit \`id\` when two columns read the same field.`);continue}de.column=me,this.#e.set(me.id,me),this.#t.push(me.id)}this.#O(ne.stored||null)}#y(ne,se){B(ne,F,"column",ne.id||ne.field||"(unnamed)");const ae=H(ne),de=v(ne.preset),me=de.map(tt=>{const Ce=this.#i[tt];return Ce?H(Ce):(y(`preset:${tt}`,`unknown column preset "${tt}"; ignoring`),{})}),Pe=this.#j(ae,me,se),Ie=this.#r.get(Pe)||this.#r.get("text");if(!this.#r.has(Pe)&&ne.type){const tt=E[Pe];y(`type:${Pe}`,`unknown data type "${Pe}"; falling back to "text"`+(tt?`. It is registered by importing '@toclocoinc/lattice-grid/modules/${tt}'.`:""))}const ke=Z(Ie.items)?this.#A(ae,me,ne.id||ne.field||"(unnamed)"):null;let be=O;be=U(be,this.#o),ne.type!==!1&&(be=U(be,_(Ie,ke)));for(const tt of me)be=U(be,tt);be=U(be,ae);const ge=be.edit;ge&&ge.editor&&ge.enabled!==!0&&!Z(ge.enabled)&&(ne.edit||{}).editor&&y(`column.editor-not-enabled:${ne.id||ne.field}`,`column '${ne.id||ne.field}' names the editor '${ge.editor}' but does not enable editing, so it stays read-only. Add \`enabled: true\`, or use \`edit: true\` and set \`editor\` alongside it.`);const Ee=ne.id||ne.field||k("col");if(ne.shadow&&!Z(be.value&&be.value.compute)){const tt=typeof ne.shadow=="string"?{kind:ne.shadow}:ne.shadow,Ce=tt.of||ne.field||Ee,Ge=j.includes(tt.kind),He=Ge?tt.model||tt:null,Ye=Ge&&He?[...Array.isArray(He.predictors)?He.predictors:[],He.response].filter(Boolean):null;be.value={...be.value||{},deps:Ye&&Ye.length?Ye:tt.orderBy&&tt.orderBy!==Ce?[Ce,tt.orderBy]:[Ce],pure:!1,compute:(ot,ft)=>{const yt=ft.grid&&ft.grid.statistics;if(!yt)return null;const jt=ft.row&&ft.row.key||yt.keyOf(ft.data);if(!jt)return null;if(Ge){if(!Z(yt.fitShadow))return null;const Et=tt.model?{...tt.model,threshold:tt.threshold}:tt;return yt.fitShadow(tt.kind,jt,Et)}return yt.shadow(Ce,tt.kind,jt,tt.scope,tt)}}}if(ne.running&&!Z(be.value&&be.value.compute)){const tt=typeof ne.running=="string"?{kind:ne.running}:ne.running,Ce=tt.of||ne.field||Ee;be.value={...be.value||{},deps:[Ce],pure:!1,compute:(Ge,He)=>{const Ye=He.grid&&He.grid.statistics;if(!Ye||!Z(Ye.running))return null;const ot=He.row&&He.row.key||Ye.keyOf(He.data);return ot?Ye.running(Ce,tt.kind||"total",ot):null}},ne.sort===void 0&&(be.sort={...be.sort||{},enabled:!1})}const xe=ne.field??(Z(be.value&&be.value.compute)?null:ne.id??null),ze=Z(be.value&&be.value.compute),_e={id:Ee,field:xe,shadow:ne.shadow||null,running:ne.running||null,spec:ne.spec||null,validation:ne.validation||null,volatile:!!(ne.shadow||ne.running),title:be.title??W(xe||Ee),type:Ie.name,dataType:Ie,itemType:ke,nullable:be.nullable!==!1,align:P(ae.cell&&ae.cell.align||ae.align||be.cell&&be.cell.align||be.align||Ie.defaults&&Ie.defaults.align)||"start",verticalAlign:L(ae.cell&&ae.cell.verticalAlign||ae.verticalAlign||be.cell&&be.cell.verticalAlign||be.verticalAlign)||this.#a,rowSpan:Z(be.rowSpan)?be.rowSpan:null,colSpan:Z(be.colSpan)?be.colSpan:null,value:{pure:!0,...be.value||{}},cell:{...be.cell||{}},edit:{...be.edit||{}},sort:{...be.sort||{}},filter:{...be.filter||{}},group:{enabled:!1,index:-1,explode:!1,...be.group||{}},pivot:{enabled:!1,index:-1,...be.pivot||{}},total:this.#u(be.total,Ie,ne.id||ne.field||"(unnamed)"),groupTotal:be.groupTotal===void 0?null:this.#u(be.groupTotal,Ie,ne.id||ne.field||"(unnamed)"),grandTotal:be.grandTotal===void 0?null:this.#u(be.grandTotal,Ie,ne.id||ne.field||"(unnamed)"),tags:Q(be.tags),typeOptions:be.typeOptions??null,...V(be[Pe])?{[Pe]:be[Pe]}:{},layout:D(be.layout,ae),header:{...be.header||{}},contextMenu:be.contextMenu===void 0?null:be.contextMenu,facet:{...be.facet||{}},export:{...be.export||{}},allowGroup:be.allowGroup!==!1,allowPivot:be.allowPivot!==!1,allowTotal:be.allowTotal!==!1,quickFilter:be.quickFilter!==!1,def:ne,format:be.format,presets:de,inferred:se!=null&&!ne.type,computed:ze,read:xe?x(xe):null,write:xe?I(xe):null};_e.cell.align=P(ae.cell&&ae.cell.align)||_e.align,_e.header.align=P(ae.header&&ae.header.align)||_e.align;const Xe=be.lookup||null;return _e.lookup=Xe?p({id:Ee,lookup:Xe},{locale:this.#l,onChange:()=>{this.#v&&this.#v("lookup",{colId:Ee})}}):null,_e.group.explode&&_e.lookup&&_e.lookup.multiple&&y(`explode:${Ee}`,`column "${Ee}" has \`group.explode\`, so rows appear under each of their values and totals double-count. Group footers should be annotated accordingly.`),this.#S(_e),_e}#S(ne){ne.formatter=u(ne.format,ne.dataType,this.#l,this.#s,ne.id),ne.formatValue=w(ne,{locale:this.#l,grid:this.#h,context:this.#f}),ne.itemCompare=ne.itemType?t(ne.itemType,this.#l):null,ne.compare=Z(ne.value.compare)?ne.value.compare:ne.lookup?ne.lookup.comparator():Z(ne.dataType.compareFor)?ne.dataType.compareFor(ne):t(ne.dataType,this.#l),ne.excel=ne.formatter&&ne.formatter.ooxml||ne.dataType&&ne.dataType.excel||"General",ne.storeKind=s(ne.dataType,!!(ne.lookup&&ne.lookup.multiple))}#A(ne,se,ae){let de=V(ne.typeOptions)?ne.typeOptions:null;for(let ke=se.length-1;!de&&ke>=0;ke--)V(se[ke].typeOptions)&&(de=se[ke].typeOptions);!de&&V(this.#o.typeOptions)&&(de=this.#o.typeOptions);const me=de&&de.of!==void 0?de.of:"text",Pe=typeof me=="string"?this.#r.get(me):void 0;return Pe&&!Z(Pe.items)&&Pe.storage!=="object"?Pe:(y(`type:of:${String(me)}`,`column "${ae}" names "${String(me)}" as its item type (typeOptions.of), which is not ${Pe?"a scalar data type":"a known data type"}; its items are read as text.`),this.#r.get("text"))}#j(ne,se,ae){if(ne.type===!1)return"text";if(ne.type)return ne.type;for(let de=se.length-1;de>=0;de--)if(se[de].type)return se[de].type;if(this.#o.type)return this.#o.type;if(ne.shadow){const de=typeof ne.shadow=="string"?ne.shadow:ne.shadow.kind;if(de==="fitInfluence")return"boolean";if(de==="fitPredicted"||de==="fitResidual"||de==="fitStdResidual"||de==="fitLeverage"||de==="fitCooksD"||de==="tsTrend"||de==="tsSeasonal"||de==="tsResidual"||de==="tsCoverage"||de==="tsSmoothed"||de==="tsSmoothingAlpha"||de==="tsSmoothingBeta")return"number"}return ae||(ne.lookup?"lookup":"text")}#O(ne){const se=this.all();this.#m=g(se),this.#p?this.#p.setGraph(this.#m):this.#p=new S({columns:this.#e,graph:this.#m,grid:this.#h,context:this.#f,stored:ne||null,rowKey:this.#g});const ae=this.#p;for(const de of se)de.getValue=(me,Pe)=>ae.value(de,me,Pe)}all(){return this.#t.map(ne=>this.#e.get(ne))}visible(){return this.all().filter(ne=>!ne.layout.hidden)}get(ne){return this.#e.get(ne)}groups(){const ne=se=>{const ae=[];for(const de of se)Array.isArray(de.columns)?ae.push({...de,columns:ne(de.columns)}):de.column&&ae.push(de.column);return ae};return ne(this.#n)}graph(){return this.#m}pipeline(){return this.#p}types(){return this.#r}affectedBy(ne){return h(this.#m,ne)}value(ne,se,ae){return this.#p.value(ne,se,ae)}text(ne,se,ae){return this.#p.text(ne,se,ae)}checkImpure(ne,se){m(this.#e.get(ne),se)}setLocale(ne){this.#l=ne;for(const se of this.all())se.lookup&&se.lookup.setLocale(ne),this.#S(se);this.#v&&this.#v("locale",{locale:ne})}infer(ne){const se={};if(this.#w||!Array.isArray(ne)||ne.length===0)return se;this.#w=!0;let ae=!1;for(const de of this.all()){const me=de.def;if(me.type!==void 0||!de.field||de.computed||de.lookup||this.#E(de))continue;const Pe=de.read||(be=>N(be,de.field)),Ie=o(de.id,ne,Pe,this.#r,{sampleSize:this.#b});if(Ie===de.type)continue;se[de.id]=Ie;const ke=this.#y(me,Ie);ke.groupPath=de.groupPath,ke.layout={...ke.layout,...J(de.layout)},this.#e.set(de.id,ke),re(this.#n,de.id,ke),ae=!0}return ae&&this.#O(null),se}redecorate(ne,se,ae={}){const de=this.#e.get(ne);if(!de){y(`redecorate:${ne}`,`columns.decorate('${ne}', …): no column with id '${ne}'.`);return}const me=de.def||{},Pe={...V(me.cell)?me.cell:{}};Pe.decoration=se??void 0,ae&&"variant"in ae&&(Pe.variant=ae.variant);const Ie={...me,cell:Pe},ke=this.#y(Ie,de.type);return ke.groupPath=de.groupPath,ke.layout={...ke.layout,...J(de.layout)},this.#e.set(ne,ke),re(this.#n,ne,ke),this.#O(null),this.#v&&this.#v("decorate",{colId:ne}),ke}#E(ne){for(const se of ne.presets){const ae=this.#i[se];if(ae&&ae.type)return!0}return!!this.#o.type}#C(ne){return!ne.computed&&Z(ne.dataType&&ne.dataType.toStorage)}storeReader(ne){if(ne.computed)return se=>this.#p.value(ne,se,null);if(this.#C(ne)){const se=ne.dataType.toStorage,ae={timeZone:ne.timeZone||this.#s,colId:ne.id,itemType:ne.itemType||null};return de=>se(ne.read(de),ae)}return ne.read}storeValue(ne,se){if(!(!ne||ne.computed)&&Z(ne.read))return this.storeReader(ne)(se)}storeSchema(){const ne=[];for(const se of this.all()){if(se.computed&&se.value.pure===!1||!se.computed&&!se.field)continue;const ae=this.storeReader(se);let de=null;!se.computed&&!this.#C(se)&&typeof se.field=="string"&&!se.lookup&&(de=se.field);const me={id:se.id,kind:se.storeKind,nullable:se.nullable,read:ae};de!==null&&(me.field=de),se.lookup&&(me.dictionary=se.lookup.dictionary()),ne.push(me)}return ne}state(){return this.all().map(ne=>({id:ne.id,width:ne.layout.width,flex:ne.layout.flex||void 0,hidden:!!ne.layout.hidden,pin:ne.layout.pin??null,sort:ne.sort.direction??null,sortIndex:ne.sort.direction?ne.sort.order??0:null,groupIndex:ne.group.enabled?ne.group.index??0:null,pivotIndex:ne.pivot.enabled?ne.pivot.index??0:null,total:typeof ne.total=="string"?ne.total:null,groupTotal:typeof ne.groupTotal=="string"?ne.groupTotal:void 0,grandTotal:typeof ne.grandTotal=="string"?ne.grandTotal:void 0,decoration:ne.cell&&ne.cell.decoration!=null?te(ne.cell.decoration):void 0,variant:ne.cell&&ne.cell.variant!=null?te(ne.cell.variant):void 0}))}applyState(ne){const se={applied:[],skipped:[]},ae=Array.isArray(ne)?ne:ne&&ne.columns||[],de=!Array.isArray(ne)&&ne&&ne.columnOrder||null;for(const Pe of ae){if(!Pe||!Pe.id){se.skipped.push({key:"?",reason:"no id"});continue}let Ie=this.#e.get(Pe.id);if(!Ie){se.skipped.push({key:Pe.id,reason:"unknown column"});continue}if(Object.hasOwn(Pe,"decoration")||Object.hasOwn(Pe,"variant")){const ke=Ie.cell?Ie.cell.decoration:void 0,be=Pe.decoration??null,ge=Object.hasOwn(Pe,"variant"),Ee=ge&&!ee(Ie.cell?Ie.cell.variant:void 0,Pe.variant);(!ee(ke,be)||Ee)&&(this.redecorate(Pe.id,be,ge?{variant:Pe.variant??void 0}:{}),Ie=this.#e.get(Pe.id)||Ie)}Pe.width!=null&&(Ie.layout.width=Pe.width),Pe.flex!=null&&(Ie.layout.flex=Pe.flex),Pe.hidden!=null&&(Ie.layout.hidden=!!Pe.hidden),Pe.pin!==void 0&&(Ie.layout.pin=Pe.pin),Pe.sort!==void 0&&(Ie.sort.direction=Pe.sort),Pe.sortIndex!=null&&(Ie.sort.order=Pe.sortIndex),Pe.groupIndex!=null&&(Ie.group.enabled=!0,Ie.group.index=Pe.groupIndex),Pe.pivotIndex!=null&&(Ie.pivot.enabled=!0,Ie.pivot.index=Pe.pivotIndex),Pe.total!==void 0&&(Ie.total=Pe.total),Pe.groupTotal!==void 0&&(Ie.groupTotal=Pe.groupTotal),Pe.grandTotal!==void 0&&(Ie.grandTotal=Pe.grandTotal),se.applied.push(Pe.id)}const me=de||ae.map(Pe=>Pe&&Pe.id).filter(Boolean);if(me.length){const Pe=me.filter(ke=>this.#e.has(ke)),Ie=this.#t.filter(ke=>!Pe.includes(ke));this.#t=[...Pe,...Ie]}return this.#v&&this.#v("state",se),se}move(ne,se){const ae=this.#t.indexOf(ne);if(ae===-1)return;const de=this.#e.get(ne);if(de.layout.movable===!1||de.layout.lockPosition){y(`move:${ne}`,`column "${ne}" is not movable; the move was ignored`);return}const me=this.#T(ne,se);if(me){y(`move.married:${me}`,`band "${me}" declares marryChildren, so its columns stay together; the move was ignored`);return}this.#t.splice(ae,1),this.#t.splice(Math.max(0,Math.min(se,this.#t.length)),0,ne),this.#x(),this.#v&&this.#v("move",{id:ne,to:se})}#T(ne,se){if(!this.#n||!this.#n.length)return null;const ae=this.#t.filter(Ie=>Ie!==ne),de=Math.max(0,Math.min(se,ae.length)),me=(Ie,ke)=>{if(Array.isArray(Ie.columns)){for(const ge of Ie.columns)me(ge,ke);return ke}const be=Ie.column?Ie.column.id:Ie.id;return be&&ke.push(be),ke},Pe=Ie=>{for(const ke of Ie){if(!Array.isArray(ke.columns))continue;if(ke.marryChildren===!0){const ge=me(ke,[]),Ee=ge.includes(ne),xe=ge.map(ze=>ae.indexOf(ze)).filter(ze=>ze>=0);if(xe.length){const ze=Math.min(...xe),_e=Math.max(...xe);if(Ee?de<ze||de>_e+1:de>ze&&de<=_e)return ke.id}}const be=Pe(ke.columns);if(be)return be}return null};return Pe(this.#n)}#x(){const ne=new Map(this.#t.map((de,me)=>[de,me])),se=de=>{if(!Array.isArray(de.columns)){const Pe=de.column?de.column.id:de.id;return ne.has(Pe)?ne.get(Pe):1/0}let me=1/0;for(const Pe of de.columns)me=Math.min(me,se(Pe));return me},ae=de=>{de.sort((me,Pe)=>se(me)-se(Pe));for(const me of de)Array.isArray(me.columns)&&ae(me.columns)};ae(this.#n)}#N(ne){const se=ae=>{for(let de=0;de<ae.length;de++){const me=ae[de];if(Array.isArray(me.columns)){const Pe=se(me.columns);if(Pe)return Pe}else if(me.column&&me.column.id===ne)return ae.splice(de,1)[0]}return null};return se(this.#n)}#D(ne){const se=[];for(let ae=ne.length-1;ae>=0;ae--){const de=ne[ae];Array.isArray(de.columns)&&(se.push(...this.#D(de.columns)),de.columns.length===0&&(se.push(de.id),ne.splice(ae,1)))}return se}#M(){const ne=(se,ae)=>{for(const de of se)Array.isArray(de.columns)?ne(de.columns,[...ae,de.id]):de.column&&(de.column.groupPath=ae)};ne(this.#n,[])}#I(ne){const se=new Set(ne),ae=this.#t.filter(Ie=>se.has(Ie));if(!ae.length)return;const de=Math.min(...ae.map(Ie=>this.#t.indexOf(Ie))),me=this.#t.slice(0,de).filter(Ie=>!se.has(Ie)),Pe=this.#t.slice(de).filter(Ie=>!se.has(Ie));this.#t=[...me,...ae,...Pe]}#W(ne){const se=[],ae=de=>{if(Array.isArray(de.columns))for(const me of de.columns)ae(me);else de.column&&se.push(de.column.id)};return ae(ne),se}#R(ne){const se=ae=>{for(const de of ae){if(!Array.isArray(de.columns))continue;if(de.id===ne)return{node:de,parent:ae};const me=se(de.columns);if(me)return me}return null};return se(this.#n)}groupColumns(ne,se={}){const ae=v(ne).filter(ke=>this.#e.has(ke));if(!ae.length)return y("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const ke of ae)if(this.#e.get(ke).layout.lockPosition)return y(`columns.group.locked:${ke}`,`column "${ke}" is position-locked and cannot be grouped.`),null;const de=se.groupId?this.#R(se.groupId):null;if(se.groupId&&!de)return y(`columns.group.unknown:${se.groupId}`,`no band "${se.groupId}" to add to; nothing was grouped.`),null;let me=null;if(!de&&se.id!=null&&(me=String(se.id),this.#R(me)||this.#e.has(me)))return y(`columns.group.idtaken:${me}`,`band id "${me}" is already in use; nothing was grouped.`),null;const Pe=ae.map(ke=>this.#N(ke)).filter(Boolean);if(!Pe.length)return null;let Ie;if(de)de.node.columns.push(...Pe),Ie=de.node.id;else{const ke={id:me||k("grp"),title:se.title||"",collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Pe},be=Number.isInteger(se.at)?Math.max(0,Math.min(se.at,this.#n.length)):this.#n.length;this.#n.splice(be,0,ke),Ie=ke.id}return this.#D(this.#n),this.#I(ae),this.#M(),this.#x(),this.#v&&this.#v("columngroup",{action:"formed",groupId:Ie,ids:ae}),Ie}ungroupColumn(ne){const se=this.#e.get(ne);if(!se){y(`columns.ungroup.unknown:${ne}`,`no column "${ne}" to ungroup.`);return}const ae=se.groupPath||[];if(!ae.length)return;const de=ae[ae.length-1],me=this.#R(de);if(!me)return;const Pe=this.#N(ne);if(!Pe)return;const Ie=me.parent.indexOf(me.node);me.parent.splice(Ie+1,0,Pe);const ke=this.#D(this.#n),be=this.#W(me.node);if(be.length){this.#I(be);const ge=Math.max(...be.map(xe=>this.#t.indexOf(xe))),Ee=this.#t.filter(xe=>xe!==ne);Ee.splice(ge+1,0,ne),this.#t=Ee}this.#M(),this.#x(),this.#v&&this.#v("columngroup",{action:"removed",id:ne,dissolved:ke})}renameGroup(ne,se){const ae=this.#R(ne);if(!ae){y(`columns.group.rename:${ne}`,`no band "${ne}" to rename.`);return}ae.node.title=String(se??""),this.#v&&this.#v("columngroup",{action:"renamed",groupId:ne,title:ae.node.title})}dissolveGroup(ne){const se=this.#R(ne);if(!se){y(`columns.group.dissolve:${ne}`,`no band "${ne}" to dissolve.`);return}const ae=se.parent.indexOf(se.node);se.parent.splice(ae,1,...se.node.columns),this.#M(),this.#x(),this.#v&&this.#v("columngroup",{action:"dissolved",groupId:ne})}moveGroup(ne,se){const ae=this.#R(ne);if(!ae){y(`columns.group.move:${ne}`,`no band "${ne}" to move.`);return}const de=ae.parent,me=de.indexOf(ae.node);me!==-1&&(de.splice(me,1),de.splice(Math.max(0,Math.min(se,de.length)),0,ae.node),this.#q(),this.#M(),this.#v&&this.#v("columngroup",{action:"moved",groupId:ne,to:se}))}#q(){const ne=[],se=de=>{for(const me of de)Array.isArray(me.columns)?se(me.columns):me.column&&ne.push(me.column.id)};se(this.#n);const ae=new Set(ne);this.#t=[...ne,...this.#t.filter(de=>!ae.has(de))]}groupTree(){const ne=ae=>ae.map(de=>Array.isArray(de.columns)?{id:de.id,title:de.title||"",collapsible:!!de.collapsible,openByDefault:de.openByDefault!==!1,columns:ne(de.columns)}:de.column?de.column.id:null).filter(de=>de!==null),se=ne(this.#n);return se.some(ae=>ae&&typeof ae=="object")?se:[]}applyGroupTree(ne){if(!Array.isArray(ne))return;const se=new Set,ae=me=>{const Pe=[];for(const Ie of me)if(Ie&&typeof Ie=="object"&&Array.isArray(Ie.columns)){const ke=ae(Ie.columns);if(!ke.length)continue;Pe.push({id:Ie.id||k("grp"),title:Ie.title||"",collapsible:Ie.collapsible===!0,openByDefault:Ie.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:ke})}else if(typeof Ie=="string"){const ke=this.#e.get(Ie);ke&&!se.has(Ie)&&(se.add(Ie),Pe.push({column:ke,path:[]}))}return Pe},de=ae(ne);for(const me of this.#t){if(se.has(me))continue;const Pe=this.#e.get(me);Pe&&de.push({column:Pe,path:[]})}this.#n=de,this.#M(),this.#x(),this.#v&&this.#v("columngroup",{action:"applied"})}show(ne){this.#B(ne,!1)}hide(ne){this.#B(ne,!0)}#B(ne,se){const ae=[];for(const de of v(ne)){const me=this.#e.get(de);if(me){if(se&&me.layout.lockVisible){y(`lockVisible:${de}`,`column "${de}" is \`layout.lockVisible\` and cannot be hidden`);continue}me.layout.hidden!==se&&(me.layout.hidden=se,ae.push(de))}}ae.length&&this.#v&&this.#v("visible",{ids:ae,hidden:se})}pin(ne,se){const ae=this.#e.get(ne);ae&&(ae.layout.pin=se??null,this.#v&&this.#v("pin",{id:ne,side:ae.layout.pin}))}resize(ne,se){const ae=this.#e.get(ne);if(!ae)return;if(ae.layout.resizable===!1){y(`resize:${ne}`,`column "${ne}" is not resizable; the resize was ignored`);return}const de=ae.layout.min??0,me=ae.layout.max;let Pe=Math.max(de,se);me!=null&&(Pe=Math.min(me,Pe)),ae.layout.width=Pe,ae.layout.flex=0,this.#v&&this.#v("resize",{id:ne,width:Pe})}}function J(le){const ne={};return le.width!=null&&(ne.width=le.width),le.hidden!=null&&(ne.hidden=le.hidden),le.pin!==void 0&&(ne.pin=le.pin),ne}function te(le){if(le===null||typeof le!="object")return le;try{return structuredClone(le)}catch{}try{return JSON.parse(JSON.stringify(le))}catch{return le}}function ee(le,ne){const se=le??null,ae=ne??null;if(se===ae)return!0;if(se===null||ae===null)return!1;if(typeof se!="object"||typeof ae!="object")return se===ae;try{return JSON.stringify(se)===JSON.stringify(ae)}catch{return!1}}function oe(le){const ne=[],se=(de,me)=>{const Pe=[];for(const Ie of de){if(!V(Ie)){$("a column definition must be an object");continue}if(Array.isArray(Ie.columns)){B(Ie,C,"columnGroup",Ie.title||Ie.id||"(unnamed)");const ke={id:Ie.id||k("grp"),title:Ie.title||"",collapsible:Ie.collapsible===!0,openByDefault:Ie.openByDefault!==!1,showWhen:Ie.showWhen||"always",marryChildren:Ie.marryChildren===!0,header:Ie.header||{},def:Ie,columns:[]};ke.columns=se(Ie.columns,[...me,ke.id]),Pe.push(ke)}else{const ke={def:Ie,path:me};ne.push(ke),Pe.push(ke)}}return Pe},ae=se(le,[]);return{leaves:ne,groups:ae}}function re(le,ne,se){for(const ae of le){if(ae.columns){if(re(ae.columns,ne,se))return!0;continue}if(ae.column&&ae.column.id===ne)return ae.column=se,!0}return!1}}),Ae("packages/core/src/columns/autogroup.js",function(e,G){"use strict";Object.defineProperty(e,"AUTO_GROUP_ID",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"createAutoGroupColumn",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"warnOnAbsurdGrouping",{enumerable:!0,get:function(){return V}});const M=G("packages/core/src/internal/util.js").warnOnce,$="__lattice_group",N=240,W=.5;function Z(U){const{columns:x,groupBy:I}=U,v=I.map(l=>x.get(l)).filter(Boolean),k=v.length?v.map(l=>l.title||l.id).join(" > "):"Group",y=U.config&&U.config.autoGroupColumnWidth||N;return{id:$,field:null,title:k,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:I.slice(),group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:y,min:120,pin:U.config&&U.config.autoGroupColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(l,u){return u&&u.group?u.groupValue:null},formatValue(l,u){if(!u||!u.group)return"";if(u.grandTotal)return U.config&&U.config.grandTotalLabel||"Total";const n=v[Math.min(u.level||0,v.length-1)];return n&&typeof n.formatValue=="function"?n.formatValue(l,u):l==null?"":String(l)}}}function V(U,x,I){!U.length||I<100||x<I*W||M(`grouping.cardinality:${U.join(",")}`,`grouping by ${U.join(", ")} produced ${x} groups for ${I} 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.`)}}),Ae("packages/core/src/columns/selectcolumn.js",function(e,G){"use strict";Object.defineProperty(e,"SELECT_COLUMN_ID",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"createSelectionColumn",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return N}});const q="__lattice_select",M=44;function $(W){const Z=W.selection||{},V=W.config&&W.config.selectionColumnWidth||M;return{id:q,field:null,title:"",type:"boolean",dataType:{base:"boolean"},nullable:!1,align:"center",generated:!0,control:!0,value:{pure:!0},cell:{render:"checkbox",props:{mode:"selection"},align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:V,min:V,max:V,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:Z.headerCheckbox===!0,def:{},getValue(U,x){return x?x.selected:!1},formatValue(){return""}}}const N=$}),Ae("packages/core/src/columns/rownumbercolumn.js",function(e,G){"use strict";Object.defineProperty(e,"ROW_NUMBER_COLUMN_ID",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"createRowNumberColumn",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return x}});const M=G("packages/core/src/internal/util.js").isFunction,$="__lattice_rownumber",N=40,W=9,Z=22;function V(I){const v=String(Math.max(1,Math.trunc(Math.abs(I))||1)).length;return Math.max(N,v*W+Z)}function U(I){const v=I.rowNumbers,k=v&&typeof v=="object"?v:{},y=Number.isFinite(k.start)?k.start:1,l=Number.isFinite(k.width)?k.width:V((I.maxNumber||0)+y),u=M(I.rank)?I.rank:()=>null;return{id:$,field:null,title:typeof k.title=="string"?k.title:"",type:"number",dataType:{base:"number"},nullable:!0,align:"end",generated:!0,control:!0,value:{pure:!0},cell:{align:"end"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:l,min:l,max:l,pin:"start",hidden:!1,resizable:k.width==null,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(n,t){const i=u(t);return i==null?null:i-1+y},formatValue(n){return n==null?"":String(n)}}}const x=U}),Ae("packages/core/src/model/detail.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_DETAIL_HEIGHT",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"DEFAULT_CACHE_LIMIT",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"resolveDetail",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"DetailModel",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const q=G("packages/core/src/internal/util.js"),M=q.isFunction,$=q.warnOnce,N=240,W=10;function Z(x){if(!x)return null;const I=x===!0?{}:x;return I.enabled===!1?null:!M(I.rows)&&!I.render?($("detail.rows","detail is enabled but neither `rows` nor `render` was supplied; expanding a master would show an empty region, so it stays off."),null):{render:I.render||null,config:I.config||null,rows:M(I.rows)?I.rows:null,height:I.height??N,cacheLimit:Number.isFinite(I.cacheLimit)?Math.max(0,I.cacheLimit):W,isMaster:M(I.isMaster)?I.isMaster:null,target:I.target||null,onCreate:M(I.onCreate)?I.onCreate:null,path:typeof I.path=="string"?I.path:null}}class V{#e;#t=new Set;#n;#r=0;constructor(I){this.#e=I.config,this.#n=M(I.onChange)?I.onChange:()=>{}}get config(){return this.#e}get inline(){return!this.#e.target}isMaster(I){if(!I||I.group||I.detail)return!1;const v=this.#e.isMaster;return v?!!v(I.data,I):!0}isOpen(I){return this.#t.has(I)}keys(){return[...this.#t]}activeKey(){for(const I of this.#t)return I;return null}heightOf(I){const v=this.#e.height;return M(v)?Number(v(I))||N:v==="auto"?N:Number(v)||N}open(I){return this.#t.has(I)?!1:(this.inline||this.#t.clear(),this.#t.add(I),this.#o(),!0)}close(I){return this.#t.delete(I)?(this.#o(),!0):!1}toggle(I){return this.#t.has(I)?(this.close(I),!1):(this.open(I),!0)}closeAll(){this.#t.size&&(this.#t.clear(),this.#o())}prune(I){if(!this.#t.size||!M(I))return;let v=!1;for(const k of[...this.#t])I(k)||(this.#t.delete(k),v=!0);v&&this.#o()}signature(){return`${this.#r}`}set(I){this.#t.clear();const v=Array.isArray(I)?I:[];for(const k of this.inline?v:v.slice(0,1))this.#t.add(k);this.#o()}#o(){this.#r++,this.#n()}}const U=V}),Ae("packages/core/src/compute/special.js",function(e,G){"use strict";Object.defineProperty(e,"logGamma",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"incompleteBeta",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"normalQuantile",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"normalCdf",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"studentT",{enumerable:!0,get:function(){return I}}),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 u}}),Object.defineProperty(e,"chiSquareUpperTail",{enumerable:!0,get:function(){return n}});const q=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),M=3e-12,$=1e-300;function N(t){if(t<.5)return Math.log(Math.PI/Math.sin(Math.PI*t))-N(1-t);const i=t-1;let s=.9999999999998099;const r=i+7.5;for(let o=0;o<q.length;o++)s+=q[o]/(i+o+1);return .5*Math.log(2*Math.PI)+(i+.5)*Math.log(r)-r+Math.log(s)}function W(t,i,s){const r=t+i,o=t+1,c=t-1;let a=1,g=1-r*s/o;Math.abs(g)<$&&(g=$),g=1/g;let h=g;for(let b=1;b<=300;b++){const p=2*b;let f=b*(i-b)*s/((c+p)*(t+p));g=1+f*g,Math.abs(g)<$&&(g=$),a=1+f/a,Math.abs(a)<$&&(a=$),g=1/g,h*=g*a,f=-(t+b)*(r+b)*s/((t+p)*(o+p)),g=1+f*g,Math.abs(g)<$&&(g=$),a=1+f/a,Math.abs(a)<$&&(a=$),g=1/g;const w=g*a;if(h*=w,Math.abs(w-1)<M)break}return h}function Z(t,i,s){if(!(t>0)||!(i>0)||!Number.isFinite(s))return Number.NaN;if(s<=0)return 0;if(s>=1)return 1;const r=Math.exp(N(t+i)-N(t)-N(i)+t*Math.log(s)+i*Math.log(1-s));return s<(t+1)/(t+i+2)?r*W(t,i,s)/t:1-r*W(i,t,1-s)/i}function V(t){if(!(t>0)||!(t<1))return t===0?-1/0:t===1?1/0:Number.NaN;const i=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],s=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],r=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],o=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],c=.02425;let a,g,h;t<c?(a=Math.sqrt(-2*Math.log(t)),h=(((((r[0]*a+r[1])*a+r[2])*a+r[3])*a+r[4])*a+r[5])/((((o[0]*a+o[1])*a+o[2])*a+o[3])*a+1)):t<=1-c?(a=t-.5,g=a*a,h=(((((i[0]*g+i[1])*g+i[2])*g+i[3])*g+i[4])*g+i[5])*a/(((((s[0]*g+s[1])*g+s[2])*g+s[3])*g+s[4])*g+1)):(a=Math.sqrt(-2*Math.log(1-t)),h=-(((((r[0]*a+r[1])*a+r[2])*a+r[3])*a+r[4])*a+r[5])/((((o[0]*a+o[1])*a+o[2])*a+o[3])*a+1));const p=(.5*U(-h/Math.SQRT2)-t)*Math.sqrt(2*Math.PI)*Math.exp(h*h/2);return h-p/(1+h*p/2)}function U(t){const i=Math.abs(t),s=2/(2+i),r=4*s-2,o=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let c=0,a=0,g;for(let b=o.length-1;b>0;b--)g=a,a=r*a-c+o[b],c=g;const h=s*Math.exp(-i*i+.5*(o[0]+r*a)-c);return t>=0?h:2-h}function x(t){return .5*U(-t/Math.SQRT2)}function I(t,i){if(!(i>0)||!Number.isFinite(t))return Number.NaN;const s=.5*Z(i/2,.5,i/(i+t*t));return t>0?1-s:s}function v(t,i){if(!(t>0)||!(t<1)||!(i>0))return Number.NaN;if(i>1e7)return V(t);let s=-1e4,r=1e4,o=V(t);const c=N(i/2)+N(.5)-N((i+1)/2);for(let a=0;a<60;a++){const g=I(o,i);g<t?s=o:r=o;const h=Math.exp(-((i+1)/2)*Math.log(1+o*o/i)-c)/Math.sqrt(i),b=h>0?(g-t)/h:0;if(Math.abs(b)<1e-12)break;const p=o-b;if(o=p>s&&p<r&&Number.isFinite(p)?p:(s+r)/2,r-s<1e-12)break}return o}function k(t,i){let s=t,r=1/t,o=r;for(let c=0;c<300&&(s+=1,o*=i/s,r+=o,!(Math.abs(o)<Math.abs(r)*M));c++);return r*Math.exp(-i+t*Math.log(i)-N(t))}function y(t,i){let s=i+1-t,r=1/$,o=1/s,c=o;for(let a=1;a<=300;a++){const g=-a*(a-t);s+=2,o=g*o+s,Math.abs(o)<$&&(o=$),r=s+g/r,Math.abs(r)<$&&(r=$),o=1/o;const h=o*r;if(c*=h,Math.abs(h-1)<M)break}return Math.exp(-i+t*Math.log(i)-N(t))*c}function l(t,i){return!(t>0)||!(i>=0)||!Number.isFinite(i)?Number.NaN:i===0?0:i<t+1?k(t,i):1-y(t,i)}function u(t,i){return i>0?l(i/2,t/2):Number.NaN}function n(t,i){const s=u(t,i);return Number.isNaN(s)?Number.NaN:Math.min(1,Math.max(0,1-s))}}),Ae("packages/core/src/compute/linalg.js",function(e,G){"use strict";Object.defineProperty(e,"cholesky",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"choleskySolve",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"choleskyInverse",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"normalEquations",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"matVec",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"quadForm",{enumerable:!0,get:function(){return Z}});function q(V){const U=V.length,x=Array.from({length:U},()=>new Array(U).fill(0));for(let I=0;I<U;I++)for(let v=0;v<=I;v++){let k=V[I][v];for(let y=0;y<v;y++)k-=x[I][y]*x[v][y];if(I===v){if(!(k>0))return null;x[I][v]=Math.sqrt(k)}else x[I][v]=k/x[v][v]}return x}function M(V,U){const x=V.length,I=new Array(x).fill(0);for(let k=0;k<x;k++){let y=U[k];for(let l=0;l<k;l++)y-=V[k][l]*I[l];I[k]=y/V[k][k]}const v=new Array(x).fill(0);for(let k=x-1;k>=0;k--){let y=I[k];for(let l=k+1;l<x;l++)y-=V[l][k]*v[l];v[k]=y/V[k][k]}return v}function $(V){const U=V.length,x=Array.from({length:U},()=>new Array(U).fill(0));for(let I=0;I<U;I++){const v=new Array(U).fill(0);v[I]=1;const k=M(V,v);for(let y=0;y<U;y++)x[y][I]=k[y]}return x}function N(V,U,x){const I=V.length,v=I?V[0].length:0,k=Array.from({length:v},()=>new Array(v).fill(0)),y=new Array(v).fill(0);for(let l=0;l<I;l++){const u=x?x[l]:1,n=V[l];for(let t=0;t<v;t++){const i=u*n[t];y[t]+=i*U[l];for(let s=t;s<v;s++)k[t][s]+=i*n[s]}}for(let l=0;l<v;l++)for(let u=0;u<l;u++)k[l][u]=k[u][l];return{xtwx:k,xtwy:y}}function W(V,U){return V.map(x=>x.reduce((I,v,k)=>I+v*U[k],0))}function Z(V,U){let x=0;for(let I=0;I<V.length;I++){let v=0;for(let k=0;k<V.length;k++)v+=U[I][k]*V[k];x+=V[I]*v}return x}}),Ae("packages/core/src/compute/sketch.js",function(e,G){"use strict";Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});class q{#e=0;#t=0;#n=0;static get errorBound(){return Object.freeze({kind:"exact",metric:"none",value:0,statement:"mean and variance match a full recompute to float rounding"})}get count(){return this.#e}add(l){if(!Number.isFinite(l))return;this.#e++;const u=l-this.#t;this.#t+=u/this.#e,this.#n+=u*(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 u=this.#e+l.#e,n=l.#t-this.#t;this.#t+=n*(l.#e/u),this.#n+=l.#n+n*n*(this.#e*l.#e/u),this.#e=u}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 M{#e=[];#t=0;#n;#r;constructor(l,u=Math.random){if(!(l>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(l),this.#r=u}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 u=Math.floor(this.#r()*this.#t);u<this.#n&&(this.#e[u]=l)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let l=0;for(const u of this.#e)l+=u;return l/this.#e.length}quantile(l){const u=this.#e.length;if(!u)return null;const n=this.#e.slice().sort((r,o)=>r-o);if(u===1)return n[0];const t=(u-1)*Math.min(1,Math.max(0,l)),i=Math.floor(t),s=Math.ceil(t);return i===s?n[i]:n[i]+(t-i)*(n[s]-n[i])}}function $(y){return y^=y>>>16,y=Math.imul(y,2246822507),y^=y>>>13,y=Math.imul(y,3266489909),y^=y>>>15,y>>>0}function N(y){if(typeof y=="number"){const n=new DataView(new ArrayBuffer(8));return n.setFloat64(0,y===0?0:y),$(n.getUint32(0)^n.getUint32(4))}const l=typeof y=="string"?y:String(y);let u=2166136261;for(let n=0;n<l.length;n++)u^=l.charCodeAt(n),u=Math.imul(u,16777619);return $(u)}class W{#e;#t;#n;constructor(l=14){const u=Math.floor(l);if(u<4||u>16)throw new RangeError("HLL precision must be 4..16");this.#e=u,this.#t=1<<u,this.#n=new Uint8Array(this.#t)}static errorBoundFor(l=14){const u=1<<Math.floor(l),n=1.04/Math.sqrt(u);return Object.freeze({kind:"probabilistic",metric:"relative",value:n,statement:`distinct count within ~${(n*100).toFixed(2)}% relative standard error (m=${u} buckets)`})}errorBound(){return W.errorBoundFor(this.#e)}add(l){const u=N(l),n=u&this.#t-1,t=u>>>this.#e|1<<32-this.#e;let i=1,s=t;for(;(s&1)===0;)i++,s>>>=1;i>this.#n[n]&&(this.#n[n]=i)}count(){const l=this.#t,u=32-this.#e,n=new Float64Array(u+2);for(let s=0;s<l;s++)n[this.#n[s]]++;let t=l*U(1-n[u+1]/l);for(let s=u;s>=1;s--)t=.5*(t+n[s]);t+=l*V(n[0]/l);const i=Z*l*l/t;return Math.round(i)}}const Z=.5/Math.log(2);function V(y){if(y===1)return 1/0;let l=1,u=y,n;do y*=y,n=u,u+=y*l,l+=l;while(u!==n);return u}function U(y){if(y===0||y===1)return 0;let l=1,u=1-y,n;do y=Math.sqrt(y),n=u,l*=.5,u-=(1-y)**2*l;while(u!==n);return u/3}class x{#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 u=l/this.#t;return Object.freeze({kind:"deterministic",metric:"absolute",value:u,statement:`each count overestimates the truth by at most N/m = ${u.toFixed(2)} (N=${l}, m=${this.#t})`})}get seen(){return this.#n}add(l){this.#n++;const u=this.#e.get(l);if(u){u.count++;return}if(this.#e.size<this.#t){this.#e.set(l,{count:1,error:0});return}let n,t=1/0;for(const[i,s]of this.#e)s.count<t&&(t=s.count,n=i);this.#e.delete(n),this.#e.set(l,{count:t+1,error:t})}top(l=this.#t){return[...this.#e.entries()].map(([n,t])=>({item:n,count:t.count,error:t.error})).sort((n,t)=>t.count-n.count).slice(0,Math.max(0,Math.floor(l)))}}class I{#e;#t=[[]];#n=0;#r;#o;constructor(l=200,u=Math.random){this.#e=Math.max(8,Math.floor(l)),this.#r=u,this.#o=2/3}static errorBoundFor(l=200){const u=1/Math.max(8,Math.floor(l));return Object.freeze({kind:"probabilistic",metric:"rank",value:u,statement:`queried quantile's true rank within ~${(u*100).toFixed(2)}% of N of the requested rank (k=${l})`})}errorBound(){return I.errorBoundFor(this.#e)}get count(){return this.#n}#i(l){const n=this.#t.length-1-l,t=Math.ceil(this.#e*this.#o**n);return Math.max(2,t)}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 u=this.#t[l];u.sort((i,s)=>i-s),l+1>=this.#t.length&&this.#t.push([]);const n=this.#t[l+1],t=this.#r()<.5?0:1;for(let i=t;i<u.length;i+=2)n.push(u[i]);this.#t[l]=[];for(let i=0;i<this.#t.length;i++)if(this.#t[i].length>=this.#i(i)){this.#s(i);return}}#l(){const l=[];for(let u=0;u<this.#t.length;u++){const n=1<<u;for(const t of this.#t[u])l.push({v:t,w:n})}return l}quantile(l){const u=this.#l();if(!u.length)return null;u.sort((s,r)=>s.v-r.v);let n=0;for(const s of u)n+=s.w;const t=Math.min(1,Math.max(0,l))*n;let i=0;for(const s of u)if(i+=s.w,i>=t)return s.v;return u[u.length-1].v}rank(l){let u=0;for(let n=0;n<this.#t.length;n++){const t=1<<n;for(const i of this.#t[n])i<=l&&(u+=t)}return u}}const v=Object.freeze({distinct:W.errorBoundFor(14),median:I.errorBoundFor(200),p25:I.errorBoundFor(200),p75:I.errorBoundFor(200),p90:I.errorBoundFor(200),p95:I.errorBoundFor(200),p99:I.errorBoundFor(200),iqr:I.errorBoundFor(200),topK:Object.freeze({kind:"deterministic",metric:"absolute",value:0,statement:"each count overestimates the truth by at most N/m; top-K exact when the K-th item exceeds N/m"})}),k={Welford:q,Reservoir:M,HyperLogLog:W,SpaceSaving:x,KLL:I,hash32:N,SKETCH_BOUNDS:v}}),Ae("packages/core/src/compute/statistics.js",function(e,G){"use strict";Object.defineProperty(e,"KENDALL_LIMIT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"numbers",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"frequencies",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"entropy",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"evenness",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"topShare",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"gini",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"moments",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"quantileSorted",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"quantile",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"STAT_FNS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"STAT_LABELS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"extremeRow",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"correlation",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"trimmedMean",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"winsorizedMean",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"modifiedZOutliers",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"jarqueBera",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"covariance",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"regression",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"fitLinearModel",{enumerable:!0,get:function(){return se}}),Object.defineProperty(e,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return de}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return be}}),Object.defineProperty(e,"kendall",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"seriesStats",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"D2_N2",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(e,"D4_N2",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(e,"movingRanges",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(e,"withinSigma",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return tt}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return He}}),Object.defineProperty(e,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(e,"controlViolations",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(e,"countOutside",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(e,"histogram",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(e,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(e,"meanInterval",{enumerable:!0,get:function(){return Dt}}),Object.defineProperty(e,"proportionInterval",{enumerable:!0,get:function(){return xt}}),Object.defineProperty(e,"slopeInterval",{enumerable:!0,get:function(){return Gt}}),Object.defineProperty(e,"capabilityInterval",{enumerable:!0,get:function(){return Yt}}),Object.defineProperty(e,"standardizedMeanDifference",{enumerable:!0,get:function(){return bt}}),Object.defineProperty(e,"normalTotalVariation",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"frequencyMap",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return De}}),Object.defineProperty(e,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(e,"compareColumn",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(e,"isNumericColumn",{enumerable:!0,get:function(){return lt}}),Object.defineProperty(e,"populationRead",{enumerable:!0,get:function(){return pt}});const q=G("packages/core/src/compute/handle.js"),M=q.presenceReader,$=q.valueReader,N=G("packages/core/src/compute/special.js"),W=N.studentTQuantile,Z=N.studentT,V=N.normalQuantile,U=N.normalCdf,x=N.chiSquareUpperTail,I=G("packages/core/src/compute/linalg.js"),v=I.cholesky,k=I.choleskySolve,y=I.choleskyInverse,l=I.normalEquations,u=I.quadForm,t=G("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,i=5e3,s=Object.freeze({variance:"rescan",varianceP:"rescan",stddev:"rescan",stddevP:"rescan",sumSquares:"rescan",weightedAvg:"rescan",median:"rescan",p25:"rescan",p75:"rescan",p90:"rescan",p95:"rescan",p99:"rescan",iqr:"rescan",mode:"rescan",distinct:"rescan",range:"rescan",skewness:"rescan",kurtosis:"rescan",geomean:"rescan",harmean:"rescan",mad:"rescan",argmin:"rescan",argmax:"rescan",hhi:"rescan",entropy:"rescan",evenness:"rescan",top3Share:"rescan",top10Share:"rescan",gini:"rescan",trimmedMean:"rescan",winsorizedMean:"rescan",robustOutliers:"rescan",jarqueBera:"rescan",passRate:"rescan",failureCount:"rescan"}),r=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:t.distinct}),median:Object.freeze({sketch:"KLL",bound:t.median}),p25:Object.freeze({sketch:"KLL",bound:t.p25}),p75:Object.freeze({sketch:"KLL",bound:t.p75}),p90:Object.freeze({sketch:"KLL",bound:t.p90}),p95:Object.freeze({sketch:"KLL",bound:t.p95}),p99:Object.freeze({sketch:"KLL",bound:t.p99}),iqr:Object.freeze({sketch:"KLL",bound:t.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:t.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:t.topK})});function o(pe){const je=pe==="sum"||pe==="avg"||pe==="countValues"||pe==="min"||pe==="max"?"maintained":Object.prototype.hasOwnProperty.call(s,pe)?s[pe]:null,ve=Object.prototype.hasOwnProperty.call(r,pe)?r[pe]:null;return{stat:pe,exact:je,approximate:ve}}function c(pe,je){const ve=je.length,Ne=new Float64Array(ve);let he=0;if(pe&&(pe.kind==="float64"||pe.kind==="int32")){const Te=pe.values,Re=M(pe);for(let Be=0;Be<ve;Be++){const We=je[Be];if(Re&&Re(We)!==1)continue;const dt=Te[We];Number.isNaN(dt)||(Ne[he++]=dt)}return Ne.subarray(0,he)}const Me=$(pe);for(let Te=0;Te<ve;Te++){const Re=Me(je[Te]);if(Re==null||Re==="")continue;const Be=typeof Re=="number"?Re:Number(Re);Number.isFinite(Be)&&(Ne[he++]=Be)}return Ne.subarray(0,he)}function a(pe,je){const ve=new Map,Ne=$(pe);let he=0;for(let Me=0;Me<je.length;Me++){const Te=Ne(je[Me]);if(Te==null||Te===""||typeof Te=="number"&&Number.isNaN(Te))continue;const Re=typeof Te=="object"?String(Te):Te;ve.set(Re,(ve.get(Re)||0)+1),he++}const Se=[...ve.values()].sort((Me,Te)=>Te-Me);return{counts:Se,total:he,distinct:Se.length}}function g(pe){return pe.total>0?pe.counts.map(je=>je/pe.total):[]}function h(pe,je){const ve=a(pe,je);if(!ve.total)return null;let Ne=0;for(const he of g(ve))Ne+=he*he;return Ne}function b(pe,je){const ve=a(pe,je);if(!ve.total)return null;let Ne=0;for(const he of g(ve))he>0&&(Ne-=he*Math.log2(he));return Ne}function p(pe,je){const ve=a(pe,je);if(!ve.total||ve.distinct<2)return ve.total?1:null;let Ne=0;for(const he of g(ve))he>0&&(Ne-=he*Math.log2(he));return Ne/Math.log2(ve.distinct)}function f(pe,je,ve=3){const Ne=a(pe,je);if(!Ne.total)return null;const he=Math.max(1,Math.floor(ve));let Se=0;for(let Me=0;Me<Math.min(he,Ne.counts.length);Me++)Se+=Ne.counts[Me];return Se/Ne.total}function w(pe,je){const ve=c(pe,je),Ne=ve.length;if(!Ne)return null;const he=ve.slice().sort();if(he[0]<0)return null;let Se=0,Me=0;for(let Te=0;Te<Ne;Te++)Se+=he[Te],Me+=(Te+1)*he[Te];return Se===0?0:2*Me/(Ne*Se)-(Ne+1)/Ne}function S(pe){let je=0,ve=0,Ne=0;for(let he=0;he<pe.length;he++){const Se=pe[he];je++;const Me=Se-ve;ve+=Me/je,Ne+=Me*(Se-ve)}return{n:je,mean:ve,m2:Ne}}function m(pe,je){const ve=pe.length;if(!ve)return NaN;if(ve===1)return pe[0];const Ne=(ve-1)*Math.min(1,Math.max(0,je)),he=Math.floor(Ne),Se=Math.ceil(Ne);return he===Se?pe[he]:pe[he]+(Ne-he)*(pe[Se]-pe[he])}function d(pe,je){if(!pe.length)return NaN;const ve=pe.slice().sort();return m(ve,je)}function j(pe,je){const ve=$(pe);let Ne=0,he=0,Se=0;for(let Me=0;Me<je.length;Me++){const Te=ve(je[Me]);if(Te==null||Te==="")continue;const Re=String(Te).toUpperCase();Re==="PASS"?Ne++:Re==="FAIL"?he++:Re==="WARN"&&Se++}return{pass:Ne+Se,fail:he,warn:Se,judged:Ne+Se+he}}const E=Object.freeze({hhi:(pe,je)=>h(pe,je),entropy:(pe,je)=>b(pe,je),evenness:(pe,je)=>p(pe,je),top3Share:(pe,je)=>f(pe,je,3),top10Share:(pe,je)=>f(pe,je,10),gini:(pe,je)=>w(pe,je),trimmedMean:(pe,je)=>L(c(pe,je),.1),winsorizedMean:(pe,je)=>z(c(pe,je),.1),robustOutliers:(pe,je)=>H(c(pe,je),3.5),jarqueBera:(pe,je)=>D(c(pe,je)),variance:(pe,je)=>{const{n:ve,m2:Ne}=S(c(pe,je));return ve>1?Ne/(ve-1):null},varianceP:(pe,je)=>{const{n:ve,m2:Ne}=S(c(pe,je));return ve>0?Ne/ve:null},stddev:(pe,je)=>{const{n:ve,m2:Ne}=S(c(pe,je));return ve>1?Math.sqrt(Ne/(ve-1)):null},stddevP:(pe,je)=>{const{n:ve,m2:Ne}=S(c(pe,je));return ve>0?Math.sqrt(Ne/ve):null},median:(pe,je)=>{const ve=c(pe,je);return ve.length?d(ve,.5):null},p25:(pe,je)=>{const ve=c(pe,je);return ve.length?d(ve,.25):null},p75:(pe,je)=>{const ve=c(pe,je);return ve.length?d(ve,.75):null},p90:(pe,je)=>{const ve=c(pe,je);return ve.length?d(ve,.9):null},p95:(pe,je)=>{const ve=c(pe,je);return ve.length?d(ve,.95):null},p99:(pe,je)=>{const ve=c(pe,je);return ve.length?d(ve,.99):null},iqr:(pe,je)=>{const ve=c(pe,je);if(!ve.length)return null;const Ne=ve.slice().sort();return m(Ne,.75)-m(Ne,.25)},mad:(pe,je)=>{const ve=c(pe,je);if(!ve.length)return null;const Ne=d(ve,.5),he=new Float64Array(ve.length);for(let Se=0;Se<ve.length;Se++)he[Se]=Math.abs(ve[Se]-Ne);return d(he,.5)},range:(pe,je)=>{const ve=c(pe,je);if(!ve.length)return null;let Ne=1/0,he=-1/0;for(let Se=0;Se<ve.length;Se++)ve[Se]<Ne&&(Ne=ve[Se]),ve[Se]>he&&(he=ve[Se]);return he-Ne},distinct:(pe,je)=>{const ve=$(pe),Ne=new Set;for(let he=0;he<je.length;he++){const Se=ve(je[he]);Se==null||Se===""||Ne.add(Se instanceof Date?Se.getTime():Se)}return Ne.size},mode:(pe,je)=>{const ve=$(pe),Ne=new Map;for(let Me=0;Me<je.length;Me++){const Te=ve(je[Me]);if(Te==null||Te==="")continue;const Re=Te instanceof Date?Te.getTime():Te;Ne.set(Re,(Ne.get(Re)||0)+1)}let he=null,Se=1;for(const[Me,Te]of Ne)Te>Se&&(Se=Te,he=Me);return he},skewness:(pe,je)=>{const ve=c(pe,je),{n:Ne,mean:he,m2:Se}=S(ve);if(Ne<3||Se<=0)return null;const Me=Math.sqrt(Se/(Ne-1));let Te=0;for(let Re=0;Re<ve.length;Re++)Te+=((ve[Re]-he)/Me)**3;return Ne/((Ne-1)*(Ne-2))*Te},kurtosis:(pe,je)=>{const ve=c(pe,je),{n:Ne,mean:he,m2:Se}=S(ve);if(Ne<4||Se<=0)return null;const Me=Math.sqrt(Se/(Ne-1));let Te=0;for(let We=0;We<ve.length;We++)Te+=((ve[We]-he)/Me)**4;const Re=Ne*(Ne+1)/((Ne-1)*(Ne-2)*(Ne-3)),Be=3*(Ne-1)**2/((Ne-2)*(Ne-3));return Re*Te-Be},geomean:(pe,je)=>{const ve=c(pe,je);if(!ve.length)return null;let Ne=0;for(let he=0;he<ve.length;he++){if(ve[he]<=0)return null;Ne+=Math.log(ve[he])}return Math.exp(Ne/ve.length)},harmean:(pe,je)=>{const ve=c(pe,je);if(!ve.length)return null;let Ne=0;for(let he=0;he<ve.length;he++){if(ve[he]===0)return null;Ne+=1/ve[he]}return ve.length/Ne},sumSquares:(pe,je)=>{const ve=c(pe,je);let Ne=0;for(let he=0;he<ve.length;he++)Ne+=ve[he]*ve[he];return Ne},passRate:(pe,je)=>{const{pass:ve,judged:Ne}=j(pe,je);return Ne?ve/Ne:null},failureCount:(pe,je)=>j(pe,je).fail}),O=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 T(pe,je,ve){const Ne=$(pe),he=$(je);let Se=0,Me=0;for(let Te=0;Te<ve.length;Te++){const Re=ve[Te],Be=Number(Ne(Re)),We=Number(he(Re));!Number.isFinite(Be)||!Number.isFinite(We)||(Se+=Be*We,Me+=We)}return Me===0?null:Se/Me}function A(pe,je,ve){const Ne=$(pe);let he=null,Se=ve?-1/0:1/0;for(let Me=0;Me<je.length;Me++){const Te=je[Me],Re=Number(Ne(Te));Number.isFinite(Re)&&(ve?Re>Se:Re<Se)&&(Se=Re,he=Te)}return he}function P(pe,je,ve){const Ne=$(pe),he=$(je);let Se=0,Me=0,Te=0,Re=0,Be=0,We=0;for(let ut=0;ut<ve.length;ut++){const wt=ve[ut],kt=Number(Ne(wt)),Le=Number(he(wt));!Number.isFinite(kt)||!Number.isFinite(Le)||(Se++,Me+=kt,Te+=Le,Re+=kt*kt,Be+=Le*Le,We+=kt*Le)}if(Se<2)return null;const dt=Se*We-Me*Te,st=Math.sqrt((Se*Re-Me*Me)*(Se*Be-Te*Te));if(st===0)return null;const ht=dt/st;return Math.max(-1,Math.min(1,ht))}function L(pe,je=.1){const ve=pe.length;if(!ve)return null;const Ne=Array.from(pe).sort((Te,Re)=>Te-Re),he=Math.floor(ve*Math.min(.49,Math.max(0,je))),Se=Ne.slice(he,ve-he);if(!Se.length)return m(Ne,.5);let Me=0;for(const Te of Se)Me+=Te;return Me/Se.length}function z(pe,je=.1){const ve=pe.length;if(!ve)return null;const Ne=Array.from(pe).sort((Re,Be)=>Re-Be),he=Math.floor(ve*Math.min(.49,Math.max(0,je))),Se=Ne[he],Me=Ne[ve-1-he];let Te=0;for(const Re of Ne)Te+=Math.min(Me,Math.max(Se,Re));return Te/ve}function H(pe,je=3.5){if(!pe.length)return null;const Ne=Array.from(pe).sort((Re,Be)=>Re-Be),he=m(Ne,.5),Se=Ne.map(Re=>Math.abs(Re-he)).sort((Re,Be)=>Re-Be),Me=m(Se,.5);if(Me===0)return null;let Te=0;for(const Re of Ne)Math.abs(.6745*(Re-he)/Me)>je&&Te++;return Te}function D(pe){const je=pe.length;if(je<8)return null;let ve=0;for(const Re of pe)ve+=Re;ve/=je;let Ne=0,he=0,Se=0;for(const Re of pe){const Be=Re-ve;Ne+=Be*Be,he+=Be*Be*Be,Se+=Be*Be*Be*Be}if(Ne/=je,he/=je,Se/=je,Ne===0)return null;const Me=he/Ne**1.5,Te=Se/(Ne*Ne)-3;return je/6*(Me*Me+Te*Te/4)}function F(pe,je,ve){const Ne=[];let he=0;for(let Re=0;Re<pe.length;Re++){const Be=Number(pe[Re]),We=Number(je[Re]);!Number.isFinite(Be)||!Number.isFinite(We)||We<=0||(Ne.push([Be,We]),he+=We)}if(!Ne.length||he<=0)return null;if(Ne.sort((Re,Be)=>Re[0]-Be[0]),Ne.length===1)return Ne[0][0];const Se=[];let Me=0;for(const[,Re]of Ne)Se.push((Me+Re/2)/he),Me+=Re;const Te=Math.max(0,Math.min(1,ve));if(Te<=Se[0])return Ne[0][0];if(Te>=Se[Se.length-1])return Ne[Ne.length-1][0];for(let Re=1;Re<Se.length;Re++){if(Te>Se[Re])continue;const Be=Se[Re]-Se[Re-1],We=Be>0?(Te-Se[Re-1])/Be:0;return Ne[Re-1][0]+(Ne[Re][0]-Ne[Re-1][0])*We}return Ne[Ne.length-1][0]}function C(pe,je,ve){const Ne=$(pe),he=$(je),Se=new Float64Array(ve.length),Me=new Float64Array(ve.length);let Te=0;for(let Re=0;Re<ve.length;Re++){const Be=ve[Re],We=Number(Ne(Be)),dt=Number(he(Be));!Number.isFinite(We)||!Number.isFinite(dt)||(Se[Te]=We,Me[Te]=dt,Te++)}return{xs:Se.subarray(0,Te),ys:Me.subarray(0,Te),n:Te}}function B(pe,je,ve,Ne=!1){const{xs:he,ys:Se,n:Me}=C(pe,je,ve);if(Me<2)return null;let Te=0,Re=0;for(let We=0;We<Me;We++)Te+=he[We],Re+=Se[We];Te/=Me,Re/=Me;let Be=0;for(let We=0;We<Me;We++)Be+=(he[We]-Te)*(Se[We]-Re);return Be/(Ne?Me:Me-1)}function _(pe,je,ve){const{xs:Ne,ys:he,n:Se}=C(pe,je,ve);if(Se<2)return null;let Me=0,Te=0;for(let kt=0;kt<Se;kt++)Me+=Ne[kt],Te+=he[kt];Me/=Se,Te/=Se;let Re=0,Be=0,We=0;for(let kt=0;kt<Se;kt++){const Le=Ne[kt]-Me,nt=he[kt]-Te;Re+=Le*Le,Be+=Le*nt,We+=nt*nt}if(Re===0)return null;const dt=Be/Re,st=Te-dt*Me,ht=We===0?1:Math.max(0,Math.min(1,Be*Be/(Re*We))),ut=Math.max(0,We-dt*Be),wt=Se>2?Math.sqrt(ut/(Se-2)/Re):0;return{slope:dt,intercept:st,r2:ht,stdError:wt,n:Se}}const Q=new Set(["ols","wls","robust"]),Y=new Set(["quantile"]),J=new Set(["ridge","lasso","elasticnet","mixed","gls"]),te=1.345;function ee(pe,je,ve){const{xtwx:Ne,xtwy:he}=l(pe,je,ve),Se=v(Ne);if(!Se)return null;const Me=k(Se,he),Te=y(Se),Re=oe(pe,Me),Be=je.map((We,dt)=>We-Re[dt]);return{beta:Me,cov:Te,fitted:Re,residuals:Be}}function oe(pe,je){return pe.map(ve=>ve.reduce((Ne,he,Se)=>Ne+he*je[Se],0))}function re(pe,je){const ve=pe.length,Ne=pe.map(Be=>Be[je]),he=pe.map(Be=>[1,...Be.filter((We,dt)=>dt!==je)]),Se=ee(he,Ne,null);if(!Se)return 1;const Me=Ne.reduce((Be,We)=>Be+We,0)/ve;let Te=0,Re=0;for(let Be=0;Be<ve;Be++)Te+=Se.residuals[Be]**2,Re+=(Ne[Be]-Me)**2;return Re===0?1:Math.max(0,Math.min(1,1-Te/Re))}function le(pe){const je=[...pe].sort((he,Se)=>he-Se),ve=ne(je),Ne=pe.map(he=>Math.abs(he-ve)).sort((he,Se)=>he-Se);return ne(Ne)/.6745}function ne(pe){const je=pe.length;if(!je)return 0;const ve=Math.floor(je/2);return je%2?pe[ve]:(pe[ve-1]+pe[ve])/2}function se(pe,je,ve={}){const Ne=ve.method||"ols";if(J.has(Ne))throw new Error(`[lattice] regression method "${Ne}" is out of scope; use ols, wls or robust.`);if(Y.has(Ne))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!Q.has(Ne))throw new Error(`[lattice] unknown regression method "${Ne}"; use ols, wls or robust.`);const he=Array.isArray(je)?je.length:0,Se=he&&Array.isArray(pe[0])?pe[0].length:0,Me=Se+1;if(!(he>Me))return null;for(let Ot=0;Ot<he;Ot++){if(!Number.isFinite(je[Ot])||!Array.isArray(pe[Ot])||pe[Ot].length!==Se)return null;for(let Nt=0;Nt<Se;Nt++)if(!Number.isFinite(pe[Ot][Nt]))return null}let Te=null;if(Ne==="wls"){if(Te=ve.weights,!Array.isArray(Te)||Te.length!==he)return null;for(let Ot=0;Ot<he;Ot++)if(!(Te[Ot]>0)||!Number.isFinite(Te[Ot]))return null}const Re=pe.map(Ot=>[1,...Ot]);let Be,We=null;if(Ne==="robust"){if(Be=ee(Re,je,null),!Be)return null;for(let Ot=0;Ot<50;Ot++){const Nt=le(Be.residuals);if(!(Nt>0))break;const Ft=Be.residuals.map(_t=>{const Zt=Math.abs(_t/Nt);return Zt<=te?1:te/Zt}),Ut=ee(Re,je,Ft);if(!Ut)return null;const Qt=Ut.beta.reduce((_t,Zt,en)=>Math.max(_t,Math.abs(Zt-Be.beta[en])),0);if(Be=Ut,We=Ft,Qt<1e-10)break}}else if(Be=ee(Re,je,Te),!Be)return null;const dt=Ne==="robust"?We:Te,{beta:st,cov:ht,fitted:ut,residuals:wt}=Be;let kt=0,Le=0,nt=0;for(let Ot=0;Ot<he;Ot++){const Nt=dt?dt[Ot]:1;kt+=Nt*wt[Ot]**2,Le+=Nt,nt+=Nt*je[Ot]}const Je=nt/Le;let rt=0;for(let Ot=0;Ot<he;Ot++){const Nt=dt?dt[Ot]:1;rt+=Nt*(je[Ot]-Je)**2}const Ct=he-Me,Mt=kt/Ct,ct=rt===0?1:Math.max(0,Math.min(1,1-kt/rt)),St=1-(1-ct)*(he-1)/Ct,Vt=Array.isArray(ve.names)&&ve.names.length===Se?ve.names:pe[0].map((Ot,Nt)=>`x${Nt+1}`),Wt=Et(ve.confidence),sn=Ct>0?W(1-(1-Wt)/2,Ct):1/0,an=st.map((Ot,Nt)=>{const Ft=Math.sqrt(Math.max(0,Mt*ht[Nt][Nt])),Ut=Ft>0?Ot/Ft:Ot===0?0:1/0,Qt=Number.isFinite(Ut)?2*(1-Z(Math.abs(Ut),Ct)):0,_t=Number.isFinite(sn)?sn*Ft:null;return{name:Nt===0?"(intercept)":Vt[Nt-1],estimate:Ot,stdError:Ft,t:Ut,p:Math.max(0,Math.min(1,Qt)),lower:_t===null?null:Ot-_t,upper:_t===null?null:Ot+_t}}),ln=new Array(he),zt=new Array(he);for(let Ot=0;Ot<he;Ot++){const Nt=dt?dt[Ot]:1,Ft=Math.max(0,Math.min(1,Nt*u(Re[Ot],ht)));ln[Ot]=Ft;const Ut=(1-Ft)**2;zt[Ot]=Ut>0&&Mt>0?wt[Ot]**2/(Me*Mt)*(Ft/Ut):null}const un=pe[0].map((Ot,Nt)=>{if(Se<2)return 1;const Ft=re(pe,Nt);return Ft>=1?1/0:1/(1-Ft)});let cn=null;{const Ot=wt.map(Ft=>Ft*Ft),Nt=ee(Re,Ot,null);if(Nt){const Ft=Ot.reduce((Xt,dn)=>Xt+dn,0)/he;let Ut=0,Qt=0;for(let Xt=0;Xt<he;Xt++)Ut+=Nt.residuals[Xt]**2,Qt+=(Ot[Xt]-Ft)**2;const _t=Qt===0?0:Math.max(0,Math.min(1,1-Ut/Qt)),Zt=he*_t,en=x(Zt,Se);cn={statistic:Zt,df:Se,p:en,heteroscedastic:en<.05}}}let rn=null;if(Se===1){const Ot=pe.map((Nt,Ft)=>Ft).sort((Nt,Ft)=>pe[Nt][0]-pe[Ft][0]);rn={confidence:Wt,points:Ot.map(Nt=>{const Ft=Re[Nt],Ut=Math.sqrt(Math.max(0,Mt*u(Ft,ht)));return{x:pe[Nt][0],yhat:ut[Nt],lower:ut[Nt]-sn*Ut,upper:ut[Nt]+sn*Ut}})}}return{method:Ne,coefficients:an,r2:ct,adjR2:St,n:he,df:Ct,sigma2:Mt,fitted:ut,residuals:wt,leverage:ln,cooksD:zt,vif:un,heteroscedasticity:cn,band:rn,weights:dt?[...dt]:null}}function ae(pe){const je=pe.length,ve=Array.from({length:je},(Se,Me)=>Me).sort((Se,Me)=>pe[Se]-pe[Me]),Ne=new Float64Array(je);let he=0;for(;he<je;){let Se=he;for(;Se+1<je&&pe[ve[Se+1]]===pe[ve[he]];)Se++;const Me=(he+Se)/2+1;for(let Te=he;Te<=Se;Te++)Ne[ve[Te]]=Me;he=Se+1}return Ne}const de=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function me(pe){const je=[.01,.05,.1],ve=[de["1%"],de["5%"],de["10%"]];if(pe<=ve[0]){const Se=(Math.log(je[1])-Math.log(je[0]))/(ve[1]-ve[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(je[0])+Se*(pe-ve[0]))))}if(pe>=ve[2]){const Se=(Math.log(je[2])-Math.log(je[1]))/(ve[2]-ve[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(je[2])+Se*(pe-ve[2]))))}const Ne=pe<ve[1]?0:1,he=(pe-ve[Ne])/(ve[Ne+1]-ve[Ne]);return Math.exp(Math.log(je[Ne])+he*(Math.log(je[Ne+1])-Math.log(je[Ne])))}function Pe(pe,je,ve,Ne){const he=ve-Ne,Se=Ne+3,Me=new Array(he),Te=new Array(he);let Re=!0,Be=Ne;for(let ut=0;ut<he;ut++){const wt=Ne+ut,kt=new Float64Array(Se);kt[0]=1,kt[1]=ut+1,kt[2]=pe[wt];for(let Le=1;Le<=Ne;Le++)kt[2+Le]=je[wt-Le];for(let Le=1;Le<Se;Le++)Number.isFinite(kt[Le])||(Be=Math.min(Be,Le-3));Me[ut]=kt,Te[ut]=je[wt],Number.isFinite(Te[ut])||(Re=!1)}if(!Re)return 0;const{xtwx:We,xtwy:dt}=l(Me,Te,null);let st=0,ht=1/0;for(let ut=0;ut<=Be;ut++){const wt=ut+3;if(!(he>wt))continue;const kt=new Array(wt);for(let ct=0;ct<wt;ct++)kt[ct]=We[ct].slice(0,wt);const Le=v(kt);if(!Le)continue;const nt=k(Le,dt.slice(0,wt));let Je=0;for(let ct=0;ct<he;ct++){const St=Me[ct];let Vt=0;for(let Wt=0;Wt<wt;Wt++)Vt+=St[Wt]*nt[Wt];Je+=(Te[ct]-Vt)**2}const Ct=Je/(he-wt)*(he-wt);if(!(Ct>0))continue;const Mt=he*Math.log(Ct/he)+2*wt;Mt<ht&&(ht=Mt,st=ut)}return st}function Ie(pe,je={}){const ve=[];for(let ht=0;ht<pe.length;ht++){const ut=Number(pe[ht]);Number.isFinite(ut)&&ve.push(ut)}const Ne=ve.length,he=Ne-1;if(Ne<8||he<6)return null;const Se=new Array(he);for(let ht=0;ht<he;ht++)Se[ht]=ve[ht+1]-ve[ht];let Me=Number.isFinite(je.maxlag)?Math.floor(je.maxlag):Math.ceil(12*(Ne/100)**.25);Me=Math.max(0,Math.min(Me,Math.floor((he-5)/2)));const Te=(ht,ut)=>{const wt=[],kt=[];for(let Le=ut;Le<he;Le++){const nt=[Le-ut+1,ve[Le]];for(let Je=1;Je<=ht;Je++)nt.push(Se[Le-Je]);wt.push(nt),kt.push(Se[Le])}return se(wt,kt,{method:"ols"})},Re=Pe(ve,Se,he,Me),Be=Te(Re,Re);if(!Be||!Be.coefficients[2])return null;const We=Be.coefficients[2].t,dt=me(We),st=We<de["5%"];return{statistic:We,usedLag:Re,nobs:he-Re,criticalValues:{...de},pValue:dt,pApproximate:!0,stationary:st,verdict:st?"stationary":"non-stationary",regression:"ct"}}function ke(pe,je={}){const ve=[];for(let st=0;st<pe.length;st++){const ht=Number(pe[st]);Number.isFinite(ht)&&ve.push(ht)}const Ne=ve.length;if(Ne<3)return null;let he=Number.isFinite(je.maxlag)?Math.floor(je.maxlag):Math.min(10,Ne-1);he=Math.max(1,Math.min(he,Ne-1));let Se=0;for(const st of ve)Se+=st;Se/=Ne;const Me=ve.map(st=>st-Se);let Te=0;for(const st of Me)Te+=st*st;Te/=Ne;const Re=new Array(he+1).fill(0);Re[0]=1;for(let st=1;st<=he;st++){let ht=0;for(let ut=st;ut<Ne;ut++)ht+=Me[ut]*Me[ut-st];Re[st]=Te>0?ht/Ne/Te:0}const Be=new Array(he+1).fill(0);Be[0]=1;let We=[];for(let st=1;st<=he;st++){let ht=Re[st];for(let Le=1;Le<st;Le++)ht-=We[Le-1]*Re[st-Le];let ut=1;for(let Le=1;Le<st;Le++)ut-=We[Le-1]*Re[Le];const wt=ut!==0?ht/ut:0,kt=new Array(st);for(let Le=1;Le<st;Le++)kt[Le-1]=We[Le-1]-wt*We[st-1-Le];kt[st-1]=wt,Be[st]=wt,We=kt}const dt=1.96/Math.sqrt(Ne);return{acf:Re,pacf:Be,bounds:{upper:dt,lower:-dt},n:Ne,nlags:he,approximate:!0}}function be(pe,je,ve){const{xs:Ne,ys:he,n:Se}=C(pe,je,ve);if(Se<2)return null;const Me=ae(Ne),Te=ae(he);let Re=0,Be=0;for(let ht=0;ht<Se;ht++)Re+=Me[ht],Be+=Te[ht];Re/=Se,Be/=Se;let We=0,dt=0,st=0;for(let ht=0;ht<Se;ht++){const ut=Me[ht]-Re,wt=Te[ht]-Be;We+=ut*wt,dt+=ut*ut,st+=wt*wt}return dt===0||st===0?null:Math.max(-1,Math.min(1,We/Math.sqrt(dt*st)))}function ge(pe,je,ve){const{xs:Ne,ys:he,n:Se}=C(pe,je,ve);if(Se<2||Se>i)return null;let Me=0,Te=0,Re=0,Be=0;for(let st=0;st<Se;st++)for(let ht=st+1;ht<Se;ht++){const ut=Math.sign(Ne[st]-Ne[ht]),wt=Math.sign(he[st]-he[ht]),kt=ut*wt;kt>0?Me++:kt<0?Te++:ut===0&&wt===0||(ut===0?Re++:Be++)}const We=Me+Te+Be,dt=Me+Te+Re;return We===0||dt===0?null:(Me-Te)/Math.sqrt(We*dt)}function Ee(pe,je={}){const ve=pe.length;if(ve<2)return null;const Ne=pe[0],he=pe[ve-1],Se=[];for(let Le=1;Le<ve;Le++){const nt=pe[Le-1];nt!==0&&Se.push((pe[Le]-nt)/Math.abs(nt))}let Me=null;if(Se.length>1){let Le=0;for(const Je of Se)Le+=Je;Le/=Se.length;let nt=0;for(const Je of Se)nt+=(Je-Le)**2;Me=Math.sqrt(nt/(Se.length-1))}const Te=Number(je.periodsPerYear)>0?Number(je.periodsPerYear):null;let Re=pe[0],Be=0,We=0,dt=0,st=0;for(let Le=1;Le<ve;Le++){if(pe[Le]>Re){Re=pe[Le],Be=Le;continue}if(Re<=0)continue;const nt=(Re-pe[Le])/Re;nt>We&&(We=nt,dt=Be,st=Le)}let ht=null;if(ve>2){let Le=0;for(let rt=0;rt<ve;rt++)Le+=pe[rt];Le/=ve;let nt=0,Je=0;for(let rt=0;rt<ve;rt++){const Ct=pe[rt]-Le;Je+=Ct*Ct,rt>0&&(nt+=Ct*(pe[rt-1]-Le))}ht=Je>0?nt/Je:null}let ut=0,wt=0;for(const Le of Se)Le>0?ut++:Le<0&&wt++;let kt=null;if(Ne>0&&he>0){const Le=(he/Ne)**(1/(ve-1))-1;kt=Te?(1+Le)**Te-1:Le}return{n:ve,first:Ne,last:he,change:he-Ne,changePercent:Ne===0?null:(he-Ne)/Math.abs(Ne)*100,volatility:Me,annualisedVolatility:Me!==null&&Te?Me*Math.sqrt(Te):null,growth:kt,maxDrawdown:We,maxDrawdownFrom:dt,maxDrawdownTo:st,autocorrelation:ht,upDays:ut,downDays:wt}}const xe=1.128,ze=3.267;function _e(pe){const je=pe.length;if(je<2)return null;const ve=[];for(let he=1;he<je;he++)ve.push(Math.abs(pe[he]-pe[he-1]));const Ne=ve.reduce((he,Se)=>he+Se,0)/ve.length;return{ranges:ve,centre:Ne,upper:ze*Ne,lower:0}}function Xe(pe){const je=pe.length;if(je<2)return null;let ve=0;for(let he=1;he<je;he++)ve+=Math.abs(pe[he]-pe[he-1]);const Ne=ve/(je-1);return{sigma:Ne/xe,meanRange:Ne}}function tt(pe,je){const ve=pe.length;if(ve<2||!je)return null;const Ne=Number.isFinite(Number(je.lower))?Number(je.lower):null,he=Number.isFinite(Number(je.upper))?Number(je.upper):null;if(Ne===null&&he===null)return null;let Se=0;for(let ut=0;ut<ve;ut++)Se+=pe[ut];Se/=ve;let Me=0;for(let ut=0;ut<ve;ut++)Me+=(pe[ut]-Se)**2;const Te=Math.sqrt(Me/(ve-1)),Re=Xe(pe),Be=Re?Re.sigma:null,We=ut=>{if(!ut||ut<=0)return{index:null,k:null};const kt=Ne!==null&&he!==null?(he-Ne)/(6*ut):null,Le=he!==null?(he-Se)/(3*ut):1/0,nt=Ne!==null?(Se-Ne)/(3*ut):1/0;return{index:kt,k:Math.min(Le,nt)}},dt=We(Be),st=We(Te);let ht=0;for(let ut=0;ut<ve;ut++){if(Ne!==null&&pe[ut]<Ne){ht++;continue}he!==null&&pe[ut]>he&&ht++}return{n:ve,mean:Se,lower:Ne,upper:he,target:Number.isFinite(Number(je.target))?Number(je.target):null,sigmaWithin:Be,sigmaOverall:Te,cp:dt.index,cpk:dt.k,pp:st.index,ppk:st.k,outOfSpec:ht,defectRate:ve?ht/ve:null}}function Ce(pe){const je=pe.length;if(je<2)return null;const ve=Xe(pe);if(!ve||!(ve.sigma>0))return null;let Ne=0;for(let he=0;he<je;he++)Ne+=pe[he];return Ne/=je,{centre:Ne,sigma:ve.sigma,upper:Ne+3*ve.sigma,lower:Ne-3*ve.sigma}}function Ge(pe,je){if(!je||!(je.sigma>0))return[];const ve=pe.length,{centre:Ne,sigma:he}=je,Se=Te=>(pe[Te]-Ne)/he,Me=[];for(let Te=0;Te<ve;Te++){if(Math.abs(Se(Te))>3&&Me.push({index:Te,rule:1,description:"beyond three sigma"}),Te>=2)for(const Re of[1,-1]){let Be=0;for(let We=Te-2;We<=Te;We++)Se(We)*Re>2&&Be++;if(Be>=2){Me.push({index:Te,rule:2,description:"two of three past two sigma"});break}}if(Te>=4)for(const Re of[1,-1]){let Be=0;for(let We=Te-4;We<=Te;We++)Se(We)*Re>1&&Be++;if(Be>=4){Me.push({index:Te,rule:3,description:"four of five past one sigma"});break}}if(Te>=7)for(const Re of[1,-1]){let Be=!0;for(let We=Te-7;We<=Te;We++)if(Se(We)*Re<=0){Be=!1;break}if(Be){Me.push({index:Te,rule:4,description:"eight in a row on one side"});break}}}return Me}function He(pe,je){if(!je||!(je.sigma>0))return[];const ve=pe.length,{centre:Ne,sigma:he}=je,Se=Re=>(pe[Re]-Ne)/he,Me=(Re,Be,We,dt)=>{for(const st of[1,-1]){let ht=0;for(let ut=Re;ut<=Be;ut++)Se(ut)*st>We&&ht++;if(ht>=dt)return!0}return!1},Te=[];for(let Re=0;Re<ve;Re++){if(Math.abs(Se(Re))>3&&Te.push({index:Re,rule:1,description:"beyond three sigma"}),Re>=8)for(const Be of[1,-1]){let We=!0;for(let dt=Re-8;dt<=Re;dt++)if(Se(dt)*Be<=0){We=!1;break}if(We){Te.push({index:Re,rule:2,description:"nine in a row on one side"});break}}if(Re>=5)for(const Be of[1,-1]){let We=!0;for(let dt=Re-4;dt<=Re;dt++)if((pe[dt]-pe[dt-1])*Be<=0){We=!1;break}if(We){Te.push({index:Re,rule:3,description:Be>0?"six rising":"six falling"});break}}if(Re>=13){let Be=!0;for(let We=Re-12;We<=Re;We++){const dt=pe[We]-pe[We-1],st=pe[We+1<=Re?We+1:We]-pe[We];if(We+1>Re)break;if(dt===0||st===0||dt>0==st>0){Be=!1;break}}Be&&Te.push({index:Re,rule:4,description:"fourteen alternating"})}if(Re>=2&&Me(Re-2,Re,2,2)&&Te.push({index:Re,rule:5,description:"two of three past two sigma"}),Re>=4&&Me(Re-4,Re,1,4)&&Te.push({index:Re,rule:6,description:"four of five past one sigma"}),Re>=14){let Be=!0;for(let We=Re-14;We<=Re;We++)if(Math.abs(Se(We))>=1){Be=!1;break}Be&&Te.push({index:Re,rule:7,description:"fifteen within one sigma"})}if(Re>=7){let Be=!0;for(let We=Re-7;We<=Re;We++)if(Math.abs(Se(We))<=1){Be=!1;break}Be&&Te.push({index:Re,rule:8,description:"eight beyond one sigma"})}}return Te}const Ye=Object.freeze(["westernElectric","nelson"]);function ot(pe,je,ve="westernElectric"){return String(ve)==="nelson"?He(pe,je):Ge(pe,je)}function ft(pe,je,ve){let Ne=0;for(let he=0;he<pe.length;he++)(pe[he]<je||pe[he]>ve)&&Ne++;return Ne}function yt(pe,je,ve,Ne=20){const he=pe.length;if(!he)return[];const Se=pe[0],Me=pe[he-1];if(Me===Se)return[{from:Se,to:Me,count:he}];const Te=ve-je,Re=1.5*Te;let Be=Te>0?Math.max(Se,je-Re):Se,We=Te>0?Math.min(Me,ve+Re):Me;We>Be||(Be=Se,We=Me);const dt=Te>0?2*Te/Math.cbrt(he):(We-Be)/(Math.ceil(Math.log2(he))+1),st=dt>0?Math.min(Ne,Math.max(1,Math.ceil((We-Be)/dt))):1,ht=(We-Be)/st,ut=[];for(let wt=0;wt<st;wt++)ut.push({from:Be+wt*ht,to:Be+(wt+1)*ht,count:0});for(let wt=0;wt<he;wt++){const kt=Math.min(st-1,Math.max(0,Math.floor((pe[wt]-Be)/ht)));ut[kt].count++}return ut[0].from=Se,ut[st-1].to=Me,ut}const jt=.95;function Et(pe){const je=Number(pe);return Number.isFinite(je)&&je>0&&je<1?je:jt}function Dt(pe,je=jt){const ve=pe.length;if(ve<2)return null;let Ne=0;for(let We=0;We<ve;We++)Ne+=pe[We];const he=Ne/ve;let Se=0;for(let We=0;We<ve;We++){const dt=pe[We]-he;Se+=dt*dt}const Me=Math.sqrt(Se/(ve-1)),Te=Et(je),Be=W(1-(1-Te)/2,ve-1)*Me/Math.sqrt(ve);return{mean:he,lower:he-Be,upper:he+Be,margin:Be,n:ve,confidence:Te}}function xt(pe,je,ve=jt){const Ne=Number(pe),he=Number(je);if(!(he>0)||!(Ne>=0)||Ne>he)return null;const Se=Et(ve),Me=V(1-(1-Se)/2),Te=Ne/he,Re=Me*Me,Be=1+Re/he,We=(Te+Re/(2*he))/Be,dt=Me/Be*Math.sqrt(Te*(1-Te)/he+Re/(4*he*he));return{proportion:Te,lower:Math.max(0,We-dt),upper:Math.min(1,We+dt),n:he,confidence:Se}}function Gt(pe,je=jt){if(!pe||!(pe.n>2)||!Number.isFinite(pe.stdError))return null;const ve=Et(je),he=W(1-(1-ve)/2,pe.n-2)*pe.stdError;return{slope:pe.slope,lower:pe.slope-he,upper:pe.slope+he,margin:he,confidence:ve}}function Yt(pe,je,ve=jt){const Ne=Number(pe),he=Number(je);if(!Number.isFinite(Ne)||!(he>1))return null;const Se=Et(ve),Te=V(1-(1-Se)/2)*Math.sqrt(1/(9*he)+Ne*Ne/(2*(he-1)));return{index:Ne,lower:Ne-Te,upper:Ne+Te,margin:Te,n:he,confidence:Se}}function bt(pe,je){return!pe||!(pe.sd>0)||!Number.isFinite(je)||!Number.isFinite(pe.mean)?null:(je-pe.mean)/pe.sd}function fe(pe){return Number.isFinite(pe)?Math.min(1,Math.max(0,2*U(Math.abs(pe)/2)-1)):0}function we(pe,je){const ve=new Map,Ne=$(pe);let he=0;for(let Se=0;Se<je.length;Se++){const Me=Ne(je[Se]);if(Me==null||Me===""||typeof Me=="number"&&Number.isNaN(Me))continue;const Te=Me instanceof Date?Me.getTime():typeof Me=="object"?String(Me):Me;ve.set(Te,(ve.get(Te)||0)+1),he++}return{map:ve,total:he}}function De(pe,je,ve,Ne){if(!(je>0)||!(Ne>0))return null;let he=0;const Se=new Set(pe.keys());for(const Me of ve.keys())Se.add(Me);for(const Me of Se){const Te=(pe.get(Me)||0)/je,Re=(ve.get(Me)||0)/Ne;he+=Math.abs(Te-Re)}return he/2}const Ke=10;function qe(pe,je,ve){if(ve&&ve.numeric){const Te=c(pe,je),{n:Re,mean:Be}=S(Te),We=Re>0?bt({mean:ve.mean,sd:ve.sd},Be):null;return{measure:"standardizedMeanDifference",magnitude:We,distance:We===null?0:fe(We),direction:We===null?0:Math.sign(We),subsetN:Re,populationN:ve.n||0,reliable:Re>=Ke}}const{map:he,total:Se}=we(pe,je),Me=De(he,Se,ve.map,ve.total);return{measure:"categoricalTotalVariation",magnitude:Me,distance:Me===null?0:Me,direction:0,subsetN:Se,populationN:ve.total||0,reliable:Se>=Ke}}function lt(pe,je){if(pe&&(pe.kind==="float64"||pe.kind==="int32"))return!0;const ve=$(pe);let Ne=0,he=0;for(let Se=0;Se<je.length&&Ne<200;Se++){const Me=ve(je[Se]);if(Me==null||Me==="")continue;if(Me instanceof Date)return!1;Ne++;const Te=typeof Me=="number"?Me:Number(Me);Number.isFinite(Te)&&he++}return Ne===0?!1:he/Ne>=.9}function pt(pe,je){if(lt(pe,je)){const he=c(pe,je),{n:Se,mean:Me,m2:Te}=S(he);return{numeric:!0,mean:Me,sd:Se>0?Math.sqrt(Te/Se):0,n:Se}}const{map:ve,total:Ne}=we(pe,je);return{numeric:!1,map:ve,total:Ne}}}),Ae("packages/core/src/compute/total.js",function(e,G){"use strict";Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"aggregatesFor",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"aggregateAllowed",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return w}});const q=G("packages/core/src/internal/util.js"),M=q.isFunction,$=q.warnOnce,N=G("packages/core/src/compute/handle.js"),W=N.presenceReader,Z=N.valueComparator,V=N.valueReader,U=G("packages/core/src/compute/statistics.js"),x=U.STAT_FNS,I=U.STAT_LABELS;function v(S){return!!S&&(S.kind==="float64"||S.kind==="int32")}function k(S,m){const d=m.length;let j=0;if(v(S)){const O=S.values,T=W(S);if(!T){for(let A=0;A<d;A++){const P=O[m[A]];Number.isNaN(P)||(j+=P)}return j}for(let A=0;A<d;A++){const P=m[A];if(T(P)===1){const L=O[P];Number.isNaN(L)||(j+=L)}}return j}const E=V(S);for(let O=0;O<d;O++){const T=o(E(m[O]));T!==null&&(j+=T)}return j}k.kernel=!0;function y(S,m){const d=m.length;let j=0;if(v(S)){const O=S.values,T=W(S);if(!T){for(let A=0;A<d;A++)Number.isNaN(O[m[A]])||j++;return j}for(let A=0;A<d;A++){const P=m[A];T(P)===1&&!Number.isNaN(O[P])&&j++}return j}const E=V(S);for(let O=0;O<d;O++){const T=E(m[O]);T!=null&&!(typeof T=="number"&&Number.isNaN(T))&&j++}return j}y.kernel=!0;function l(S,m){return m.length}l.kernel=!0;function u(S,m){const d=y(S,m);return d===0?null:k(S,m)/d}u.kernel=!0;function n(S,m,d,j){const E=m.length;if(v(S)){const P=S.values,L=W(S);let z=null;if(!L){for(let H=0;H<E;H++){const D=P[m[H]];Number.isNaN(D)||(z===null||(d<0?D<z:D>z))&&(z=D)}return z}for(let H=0;H<E;H++){const D=m[H];if(L(D)===0)continue;const F=P[D];Number.isNaN(F)||(z===null||(d<0?F<z:F>z))&&(z=F)}return z}const O=V(S),T=Z(j);let A=null;for(let P=0;P<E;P++){const L=O(m[P]);L==null||typeof L=="number"&&Number.isNaN(L)||(A===null||(d<0?T(L,A)<0:T(L,A)>0))&&(A=L)}return A}function t(S,m,d){return n(S,m,-1,d&&d.locale)}t.kernel=!0;function i(S,m,d){return n(S,m,1,d&&d.locale)}i.kernel=!0;function s(S,m){return m.length===0?null:V(S)(m[0])}s.kernel=!0;function r(S,m){return m.length===0?null:V(S)(m[m.length-1])}r.kernel=!0;function o(S){if(typeof S=="number")return Number.isNaN(S)?null:S;if(S==null||S===""||typeof S=="boolean")return null;if(S instanceof Date)return S.getTime();const m=Number(S);return Number.isNaN(m)?null:m}const c={sum:k,min:t,max:i,avg:u,count:l,first:s,last:r,countValues:y,...x},a=Object.freeze({...I,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function g(S){return S?typeof S=="string"?a[S]||S:"Total":""}const h=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function b(S){const m=S&&S.dataType&&S.dataType.totals&&S.dataType.totals.supported;if(Array.isArray(m))return m.slice();const d=h.filter(j=>j in c);for(const j of Object.keys(c))d.includes(j)||d.push(j);return d}function p(S,m){return typeof m!="string"?!0:b(S).includes(m)}function f(S,m){const d=V(S),j=[];for(let E=0;E<m.length;E++){const O=d(m[E]);O!=null&&j.push(O)}return j}function w(S,m,d,j){const E=m||[];if(typeof d=="string"){const O=c[d];return O?O(S,E,j):($(`total:${d}`,`unknown total function "${d}"; register it in config.totalFns`),null)}return M(d)?d.kernel===!0?d(S,E,j):d(f(S,E),j||{}):null}}),Ae("packages/core/src/compute/windowed.js",function(e,G){"use strict";Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const M=G("packages/core/src/compute/sketch.js").Welford;class ${#e;#t;#n=[];#r;#o;constructor(U,x=0,I=Date.now){if(U!=="count"&&U!=="time"&&U!=="session")throw new RangeError(`unknown window kind: ${U}`);if((U==="count"||U==="time")&&!(x>0))throw new RangeError(`a ${U} window needs a positive span`);this.#e=U,this.#t=Math.floor(x),this.#r=I,this.#o=I()}get size(){return this.#n.length}push(U,x=this.#r()){Number.isFinite(U)&&(this.#n.push({t:x,v:U}),this.#i(x))}#i(U){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const x=U-this.#t;for(;this.#n.length&&this.#n[0].t<x;)this.#n.shift()}}spec(){const U=this.#e==="session"?this.#r()-this.#o:this.#t;return{kind:this.#e,span:U,size:this.#n.length}}values(){return this.#n.map(U=>U.v)}aggregate(){const U=this.spec();if(!this.#n.length)return{over:U,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const x=new M;let I=0,v=1/0,k=-1/0;for(const{v:y}of this.#n)I+=y,y<v&&(v=y),y>k&&(k=y),x.add(y);return{over:U,count:this.#n.length,sum:I,mean:x.mean(),min:v,max:k,variance:x.variance(),stddev:x.stddev()}}reduce(U){const x=this.aggregate(),I={sum:x.sum,avg:x.mean,mean:x.mean,min:x.min,max:x.max,count:x.count,variance:x.variance,stddev:x.stddev};if(!(U in I))throw new RangeError(`unknown windowed aggregate: ${U}`);return{value:I[U],over:x.over}}}const N=Object.freeze(["count","time","session"]);function W(V,U=Date.now){const x=V.kind==="time"&&V.minutes!=null?V.minutes*6e4:V.span??0;return new $(V.kind,x,U)}const Z={Window:$,WINDOW_KINDS:N,openWindow:W}}),Ae("packages/core/src/compute/rolling.js",function(e,G){"use strict";Object.defineProperty(e,"ROLLING_WINDOW_FIELDS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"rollingWindow",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"cumulativeToDate",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"periodOverPeriod",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"QUANTILE_SPAN_CAP",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"rollingQuantile",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"seasonalDecompose",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"exponentialSmoothing",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const M=G("packages/core/src/compute/windowed.js").openWindow,N=G("packages/core/src/compute/sketch.js").KLL,W=Object.freeze({rollingSum:"sum",rollingAvg:"avg",rollingMin:"min",rollingMax:"max"});function Z(a,g,h,b){if(a.kind==="count"){const p=Math.max(1,Math.floor(a.span||0));return{coverage:Math.min(1,g/p),partial:g<p}}if(a.kind==="time"){const p=a.minutes!=null?a.minutes*6e4:a.span||0;if(!(p>0))return{coverage:1,partial:!1};const f=h-b;return{coverage:Math.min(1,f/p),partial:f<p}}return{coverage:null,partial:!1}}function V(a,g){const h=M(g),b=new Map,p=a.length?a[0].at:0;for(let f=0;f<a.length;f++){const{key:w,at:S,value:m}=a[f];Number.isFinite(m)&&h.push(m,S);const d=h.aggregate(),j=Z(g,d.count,S,p);w!=null&&b.set(String(w),{sum:d.sum,avg:d.mean,min:d.min,max:d.max,count:d.count,coverage:j.coverage,partial:j.partial})}return b}function U(a){const g=new Map;let h=0;for(const{key:b,value:p}of a)Number.isFinite(p)&&(h+=p),b!=null&&g.set(String(b),h);return g}function x(a,g=1){const h=new Map,b=Math.max(1,Math.floor(g));for(let p=0;p<a.length;p++){const{key:f,value:w}=a[p];if(f==null)continue;const S=p>=b?a[p-b].value:null,m=Number.isFinite(w)?w:null,d=Number.isFinite(S)?S:null;h.set(String(f),m!==null&&d!==null?m-d:null)}return h}const I=4096;function v(a){let g=a>>>0;return()=>{g+=1831565813;let h=g;return h=Math.imul(h^h>>>15,h|1),h^=h+Math.imul(h^h>>>7,h|61),((h^h>>>14)>>>0)/4294967296}}function k(a,g){const h=a.length;if(h===1)return a[0];const b=(h-1)*g,p=Math.floor(b),f=Math.ceil(b);return p===f?a[p]:a[p]+(b-p)*(a[f]-a[p])}function y(a,g,h={}){const b=Math.min(1,Math.max(0,h.q==null?.5:h.q)),p=Math.max(1,Math.floor(h.cap==null?I:h.cap)),f=v(h.seed==null?2654435769:h.seed),w=new Map,S=a.length?a[0].at:0;if(g.kind==="session"){const d=new N(200,f);let j=0;for(const{key:E,value:O}of a)Number.isFinite(O)&&(d.add(O),j++),E!=null&&w.set(String(E),{value:j?d.quantile(b):null,approx:j>0,count:j,coverage:null,partial:!1});return w}const m=M(g);for(const{key:d,at:j,value:E}of a){Number.isFinite(E)&&m.push(E,j);const O=m.values(),T=O.length;let A=null,P=!1;if(T)if(T<=p)A=k([...O].sort((z,H)=>z-H),b);else{const z=new N(200,f);for(const H of O)z.add(H);A=z.quantile(b),P=!0}const L=Z(g,T,j,S);d!=null&&w.set(String(d),{value:A,approx:P,count:T,coverage:L.coverage,partial:L.partial})}return w}function l(a,g){const h=a.length,b=new Array(h).fill(null),p=Math.floor(g/2),f=g%2===0;for(let w=0;w<h;w++){if(w-p<0||w+p>=h)continue;let S=0,m=!0;if(f)for(let d=-p;d<=p;d++){const j=a[w+d];if(!Number.isFinite(j)){m=!1;break}S+=d===-p||d===p?j*.5:j}else for(let d=-p;d<=p;d++){const j=a[w+d];if(!Number.isFinite(j)){m=!1;break}S+=j}m&&(b[w]=S/g)}return b}function u(a,g){const h=new Map,b=Math.floor(Number(g&&g.period));if(!(b>=2))return h;const p=g&&g.model==="multiplicative",f=a.length,w=a.map(P=>Number.isFinite(P.value)?P.value:null),S=l(w,b),m=new Array(f).fill(null);for(let P=0;P<f;P++){const L=S[P],z=w[P];L===null||z===null||(p?L!==0&&(m[P]=z/L):m[P]=z-L)}const d=new Array(b).fill(0),j=new Array(b).fill(0);for(let P=0;P<f;P++){if(m[P]===null)continue;const L=P%b;d[L]+=m[P],j[L]+=1}const E=p?1:0,O=d.map((P,L)=>j[L]?P/j[L]:E),T=O.reduce((P,L)=>P+L,0)/b,A=p?O.map(P=>T!==0?P/T:1):O.map(P=>P-T);for(let P=0;P<f;P++){const{key:L}=a[P];if(L==null)continue;const z=S[P],H=A[P%b],D=w[P];let F=null;z!==null&&D!==null&&(F=p?z*H!==0?D/(z*H):null:D-z-H),h.set(String(L),{trend:z,seasonal:D===null?null:H,residual:F,coverage:z===null?0:1,partial:z===null})}return h}function n(a,g,h,b=80){const p=(Math.sqrt(5)-1)/2;let f=g,w=h,S=w-p*(w-f),m=f+p*(w-f),d=a(S),j=a(m);for(let E=0;E<b;E++)d<j?(w=m,m=S,j=d,S=w-p*(w-f),d=a(S)):(f=S,S=m,d=j,m=f+p*(w-f),j=a(m));return(f+w)/2}const t=1e-4,i=1-1e-4;function s(a,g){const h=a.length,b=new Array(h).fill(null),p=new Array(h).fill(null);let f=null,w=0;for(let S=0;S<h;S++){const m=a[S];if(!Number.isFinite(m)){f!==null&&(p[S]=f,b[S]=f);continue}if(f===null){f=m,p[S]=m,b[S]=m;continue}p[S]=f,w+=(m-f)**2,f=g*m+(1-g)*f,b[S]=f}return{smoothed:b,fitted:p,sse:w}}function r(a,g,h){const b=a.length,p=new Array(b).fill(null),f=new Array(b).fill(null);let w=null,S=null,m=0;for(let d=0;d<b;d++){const j=a[d];if(!Number.isFinite(j)){w!==null&&(w+=S,p[d]=w);continue}if(w===null){w=j,p[d]=j;continue}if(S===null){S=j-w;const T=w+S;f[d]=T,m+=(j-T)**2;const A=w;w=g*j+(1-g)*(A+S),S=h*(w-A)+(1-h)*S,p[d]=w;continue}const E=w+S;f[d]=E,m+=(j-E)**2;const O=w;w=g*j+(1-g)*(O+S),S=h*(w-O)+(1-h)*S,p[d]=w}return{smoothed:p,fitted:f,sse:m}}function o(a,g={}){const h=new Map,b=g.method==="holt",p=a.map(E=>Number.isFinite(E.value)?E.value:null),f=p.filter(E=>E!==null).length,w=E=>Math.min(i,Math.max(t,E)),S=()=>{for(const{key:E}of a)E!=null&&h.set(String(E),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return h};if(f<(b?2:1))return S();let m=Number.isFinite(g.alpha)?w(g.alpha):null,d=b&&Number.isFinite(g.beta)?w(g.beta):null;if(b){if(m===null||d===null){let E=m===null?.5:m,O=d===null?.5:d;for(let T=0;T<6;T++)m===null&&(E=n(A=>r(p,A,O).sse,t,i)),d===null&&(O=n(A=>r(p,E,A).sse,t,i));m=m===null?E:m,d=d===null?O:d}}else m===null&&(m=n(E=>s(p,E).sse,t,i));const j=b?r(p,m,d):s(p,m);for(let E=0;E<a.length;E++){const{key:O}=a[E];O!=null&&h.set(String(O),{smoothed:j.smoothed[E],fitted:j.fitted[E],alpha:m,beta:b?d:null,sse:j.sse})}return h}const c={ROLLING_WINDOW_FIELDS:W,QUANTILE_SPAN_CAP:I,rollingWindow:V,rollingQuantile:y,cumulativeToDate:U,periodOverPeriod:x,seasonalDecompose:u,exponentialSmoothing:o}}),Ae("packages/core/src/compute/compare.js",function(e,G){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"pooledStandardMeanDifference",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"numericSummary",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"bothNumeric",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"compareColumnAcross",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"compareDatasets",{enumerable:!0,get:function(){return l}});const q=G("packages/core/src/compute/statistics.js"),M=q.numbers,$=q.moments,N=q.frequencyMap,W=q.categoricalDistance,Z=q.normalTotalVariation,V=q.isNumericColumn,U=q.SUBSET_RELIABILITY_FLOOR,x=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function I(u,n){if(!u||!n||!(u.n>0)||!(n.n>0)||!Number.isFinite(u.mean)||!Number.isFinite(n.mean))return null;const t=(u.n*u.sd*u.sd+n.n*n.sd*n.sd)/(u.n+n.n);return t>0?(u.mean-n.mean)/Math.sqrt(t):null}function v(u,n){const t=M(u,n),{n:i,mean:s,m2:r}=$(t),o=i>0?Math.sqrt(r/i):0;return{mean:s,sd:o,n:i}}function k(u,n,t,i){return V(u,n)&&V(t,i)}function y(u,n,t,i){if(k(u,n,t,i)){const c=v(u,n),a=v(t,i),g=I(c,a);return{measure:x.numeric,magnitude:g,distance:g===null?0:Z(g),direction:g===null?0:Math.sign(g),nA:c.n,nB:a.n,reliable:c.n>=U&&a.n>=U}}const s=N(u,n),r=N(t,i),o=W(s.map,s.total,r.map,r.total);return{measure:x.categorical,magnitude:o,distance:o===null?0:o,direction:0,nA:s.total,nB:r.total,reliable:s.total>=U&&r.total>=U}}function l(u,n,t={}){const i=new Set(u.columns),s=new Set(n.columns),r=u.columns.filter(h=>s.has(h)),o=Array.isArray(t.columns)&&t.columns.length?r.filter(h=>t.columns.includes(h)):r,c=u.indices(),a=n.indices(),g=[];for(const h of o){const b=u.handle(h),p=n.handle(h);if(!b||!p)continue;const f=y(b,c,p,a);g.push({column:h,name:u.name&&u.name(h)||n.name&&n.name(h)||h,measure:f.measure,magnitude:f.magnitude,distance:f.distance,direction:f.direction,nA:f.nA,nB:f.nB,reliable:f.reliable})}return g.sort((h,b)=>b.distance-h.distance||Math.abs(b.magnitude||0)-Math.abs(h.magnitude||0)),{ranked:g,nA:c.length,nB:a.length,unmatched:{onlyA:u.columns.filter(h=>!s.has(h)),onlyB:n.columns.filter(h=>!i.has(h))},measures:x}}}),Ae("packages/core/src/compute/anomaly.js",function(e,G){"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 Z}}),Object.defineProperty(e,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"robustSpread",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return c}});const M=G("packages/core/src/compute/statistics.js").quantileSorted,N=G("packages/core/src/compute/special.js").logGamma,W=.6745,Z=3.5,V=1.5,U=.975,x=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function I(a){if(!a.length)return null;const h=Array.from(a,Number).sort((w,S)=>w-S),b=M(h,.5),p=h.map(w=>Math.abs(w-b)).sort((w,S)=>w-S),f=M(p,.5);return{median:b,mad:f}}function v(a,g={}){const h=Number.isFinite(g.threshold)?g.threshold:Z,b=a.length,p=new Array(b).fill(null),f=new Array(b).fill(!1),w=[];for(let d=0;d<b;d++){const j=Number(a[d]);Number.isFinite(j)&&w.push(j)}if(!w.length)return{median:null,mad:null,threshold:h,scores:p,flags:f,flagged:0};const S=I(w);if(S.mad===0)return{median:S.median,mad:0,threshold:h,scores:p,flags:f,flagged:0};let m=0;for(let d=0;d<b;d++){const j=Number(a[d]);if(!Number.isFinite(j))continue;const E=W*(j-S.median)/S.mad;p[d]=E,Math.abs(E)>h&&(f[d]=!0,m++)}return{median:S.median,mad:S.mad,threshold:h,scores:p,flags:f,flagged:m}}function k(a,g={}){const h=Number.isFinite(g.k)?g.k:V,b=[];for(let m=0;m<a.length;m++){const d=Number(a[m]);Number.isFinite(d)&&b.push(d)}if(!b.length)return null;const p=b.sort((m,d)=>m-d),f=M(p,.25),w=M(p,.75),S=w-f;return{q1:f,q3:w,iqr:S,lower:f-h*S,upper:w+h*S,k:h}}function y(a,g){if(g<=0)return 0;const h=N(a);if(g<a+1){let d=a,j=1/a,E=j;for(let O=0;O<1e3&&(d+=1,E*=g/d,j+=E,!(Math.abs(E)<Math.abs(j)*1e-15));O++);return j*Math.exp(-g+a*Math.log(g)-h)}const b=1e-300;let p=g+1-a,f=1/b,w=1/p,S=w;for(let d=1;d<1e3;d++){const j=-d*(d-a);p+=2,w=j*w+p,Math.abs(w)<b&&(w=b),f=p+j/f,Math.abs(f)<b&&(f=b),w=1/w;const E=w*f;if(S*=E,Math.abs(E-1)<1e-15)break}return 1-Math.exp(-g+a*Math.log(g)-h)*S}function l(a,g){return a<=0?0:y(g/2,a/2)}function u(a,g=U){if(!(g>0)||!(g<1))return NaN;let h=0,b=Math.max(1,a);for(;l(b,a)<g;)b*=2;for(let p=0;p<200;p++){const f=(h+b)/2;if(l(f,a)<g?h=f:b=f,b-h<1e-10)break}return(h+b)/2}function n(a){const g=a.length,h=a.map((b,p)=>{const f=b.slice();for(let w=0;w<g;w++)f.push(p===w?1:0);return f});for(let b=0;b<g;b++){let p=b;for(let w=b+1;w<g;w++)Math.abs(h[w][b])>Math.abs(h[p][b])&&(p=w);if(Math.abs(h[p][b])<1e-12)return null;if(p!==b){const w=h[p];h[p]=h[b],h[b]=w}const f=h[b][b];for(let w=0;w<2*g;w++)h[b][w]/=f;for(let w=0;w<g;w++){if(w===b)continue;const S=h[w][b];if(S!==0)for(let m=0;m<2*g;m++)h[w][m]-=S*h[b][m]}}return h.map(b=>b.slice(g))}function t(a,g){const h=a.length,b=new Array(g).fill(0);for(const w of a)for(let S=0;S<g;S++)b[S]+=w[S];for(let w=0;w<g;w++)b[w]/=h;const p=Array.from({length:g},()=>new Array(g).fill(0));for(const w of a)for(let S=0;S<g;S++){const m=w[S]-b[S];for(let d=S;d<g;d++)p[S][d]+=m*(w[d]-b[d])}const f=h>1?h-1:1;for(let w=0;w<g;w++)for(let S=w;S<g;S++)p[w][S]/=f,p[S][w]=p[w][S];return{mean:b,cov:p}}function i(a,g={}){const h=Number.isFinite(g.p)?g.p:U,b=Number.isFinite(g.ridge)?g.ridge:1e-6,p=a.length;if(!p)return null;const f=a[0].length;if(!f)return null;const w=new Array(p).fill(null),S=new Array(p).fill(null),m=new Array(p).fill(!1),d=[],j=[];for(let H=0;H<p;H++){const D=a[H];let F=D.length===f;const C=new Array(f);for(let B=0;F&&B<f;B++){const _=Number(D[B]);Number.isFinite(_)?C[B]=_:F=!1}F&&(d.push(H),j.push(C))}const E=f,O=u(E,h);if(j.length<=f)return{center:[],df:E,cutoff:O,singular:!0,used:j.length,distances:w,squared:S,flags:m,flagged:0};const{mean:T,cov:A}=t(j,f);let P=n(A),L=!1;if(!P){L=!0;let H=0;for(let C=0;C<f;C++)H+=A[C][C];const D=H/f*b||b,F=A.map((C,B)=>C.map((_,Q)=>B===Q?_+D:_));if(P=n(F),!P)return{center:T,df:E,cutoff:O,singular:!0,used:j.length,distances:w,squared:S,flags:m,flagged:0}}let z=0;for(let H=0;H<j.length;H++){const D=j[H],F=new Array(f);for(let _=0;_<f;_++)F[_]=D[_]-T[_];let C=0;for(let _=0;_<f;_++){let Q=0;for(let Y=0;Y<f;Y++)Q+=P[_][Y]*F[Y];C+=F[_]*Q}C<0&&(C=0);const B=d[H];S[B]=C,w[B]=Math.sqrt(C),C>O&&(m[B]=!0,z++)}return{center:T,df:E,cutoff:O,singular:L,used:j.length,distances:w,squared:S,flags:m,flagged:z}}const s=20,r=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function o(a,g={}){const h=g.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",b=Number.isFinite(g.windowLen)&&g.windowLen>=1?Math.floor(g.windowLen):s,p=Number.isFinite(g.threshold)?g.threshold:Z,f=Number.isFinite(g.k)?g.k:V,w=Number.isFinite(g.minPeriods)&&g.minPeriods>=1?Math.floor(g.minPeriods):b,S=a.length,m=new Array(S).fill(null),d=new Array(S).fill(!1);let j=0;for(let E=0;E<S;E++){const O=Number(a[E]);if(!Number.isFinite(O))continue;const T=Math.max(0,E-b+1),A=[];for(let P=T;P<=E;P++){const L=Number(a[P]);Number.isFinite(L)&&A.push(L)}if(!(A.length<w))if(h==="rollingIqr"){const P=k(A,{k:f});if(!P)continue;(O<P.lower||O>P.upper)&&(d[E]=!0,j++)}else{const P=I(A);if(!P||P.mad===0)continue;const L=W*(O-P.median)/P.mad;m[E]=L,Math.abs(L)>p&&(d[E]=!0,j++)}}return{method:h,windowLen:b,minPeriods:w,threshold:p,k:f,scores:m,flags:d,flagged:j}}function c(a={}){const g=a||{},h=g.field;if(typeof h!="string"||!h)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const b=g.method||"modifiedZScore";if(!(x.includes(b)||r.includes(b))||b==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${b}'`);const f=typeof g.orderBy=="string"?g.orderBy:null,w=g.latest===!0,S=r.includes(b),m=d=>Number(d==null?NaN:d[h]);return d=>{const j=Array.isArray(d)?d.slice():[...d];f&&j.sort((P,L)=>{const z=P?.[f],H=L?.[f];return z===H?0:z==null?-1:H==null?1:z<H?-1:1});const E=j.map(m);let O,T;if(S)({flags:O,scores:T}=o(E,{method:b,windowLen:g.windowLen,threshold:g.threshold,k:g.k,minPeriods:g.minPeriods}));else if(b==="iqr"){const P=k(E,{k:g.k});O=E.map(L=>P?Number.isFinite(L)&&(L<P.lower||L>P.upper):!1),T=E.map(()=>null)}else({flags:O,scores:T}=v(E,{threshold:g.threshold}));if(w){const P=O.length-1;return P<0||!O[P]?!1:{method:b,field:h,flagged:[{row:j[P],score:T[P]}]}}const A=[];for(let P=0;P<O.length;P++)O[P]&&A.push({row:j[P],score:T[P]});return A.length?{method:b,field:h,flagged:A}:!1}}}),Ae("packages/core/src/compute/forecast.js",function(e,G){"use strict";Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const q=G("packages/core/src/compute/special.js"),M=q.normalQuantile,$=q.studentTQuantile,W=G("packages/core/src/internal/util.js").warnOnce,Z=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),V=1e-4,U=1-1e-4;function x(g){const h=[];for(let b=0;b<g.length;b++){const p=g[b];if(p!==null&&typeof p=="object"){const f=Number.isFinite(p.at)?p.at:b,w=Number.isFinite(p.value)?p.value:null;h.push({at:f,value:w})}else h.push({at:b,value:Number.isFinite(p)?Number(p):null})}return h}function I(g){const h=g.filter(S=>S.value!==null),b=h[0],p=h[h.length-1],f=p.at-b.at,w=h.length>1&&f>0?f/(h.length-1):1;return{lastAt:p.at,step:w}}function v(g){return Math.min(U,Math.max(V,g))}function k(g,h=V,b=U,p=80){const f=(Math.sqrt(5)-1)/2;let w=h,S=b,m=S-f*(S-w),d=w+f*(S-w),j=g(m),E=g(d);for(let O=0;O<p;O++)j<E?(S=d,d=m,E=j,m=S-f*(S-w),j=g(m)):(w=m,m=d,j=E,d=w+f*(S-w),E=g(d));return(w+S)/2}function y(g,h){let b=null,p=0,f=0;for(let w=0;w<g.length;w++){const S=g[w];if(S!==null){if(b===null){b=S;continue}p+=(S-b)**2,f+=1,b=h*S+(1-h)*b}}return{level:b,sse:p,m:f}}function l(g,h,b){let p=null,f=null,w=0,S=0;for(let m=0;m<g.length;m++){const d=g[m];if(d===null){p!==null&&f!==null&&(p+=f);continue}if(p===null){p=d;continue}f===null&&(f=d-p);const j=p+f;w+=(d-j)**2,S+=1;const E=p;p=h*d+(1-h)*(E+f),f=b*(p-E)+(1-b)*f}return{level:p,trend:f,sse:w,m:S}}function u(g,h,b,p,f){const w=g.length;if(w<2*h)return null;const S=L=>{let z=0,H=0;for(let D=L;D<L+h&&D<w;D++)g[D]!==null&&(z+=g[D],H+=1);return H?z/H:null},m=S(0),d=S(h);if(m===null||d===null)return null;let j=m,E=(d-m)/h;const O=new Array(h).fill(0);for(let L=0;L<h;L++)O[L]=g[L]===null?0:g[L]-j;const T=O.reduce((L,z)=>L+z,0)/h;for(let L=0;L<h;L++)O[L]-=T;let A=0,P=0;for(let L=h;L<w;L++){const z=L%h,H=O[z],D=g[L];if(D===null){j+=E;continue}const F=j+E+H;A+=(D-F)**2,P+=1;const C=j;j=b*(D-H)+(1-b)*(j+E),E=p*(j-C)+(1-p)*E,O[z]=f*(D-j)+(1-f)*H}return{level:j,trend:E,season:O,phase:(w-1)%h,sse:A,count:P}}function n(g,h,b){let p=1;for(const w of h)p+=w*w;const f=Math.sqrt(g*p);return{se:f,margin:b*f}}function t(g,h={}){if(!g||typeof g.length!="number"||g.length===0)return null;const b=Z.includes(h.method)?h.method:"linear",p=Math.max(1,Math.floor(Number(h.horizon)||1)),f=Number.isFinite(h.confidence)&&h.confidence>0&&h.confidence<1?h.confidence:.95,w=1-(1-f)/2,S=x(g),m=S.map(A=>A.value),d=m.filter(A=>A!==null),j=d.length,{lastAt:E,step:O}=j?I(S):{lastAt:0,step:1},T=A=>E+A*O;return b==="linear"?i(S,j,p,f,w,T):b==="movingAverage"?s(d,j,p,f,w,h,T):b==="ses"?r(m,j,p,f,w,h,T):b==="holt"?o(m,j,p,f,w,h,T):c(m,j,p,f,w,h,T)}function i(g,h,b,p,f,w){if(h<2)return null;let S=0,m=0;for(const D of g)D.value!==null&&(S+=D.at,m+=D.value);S/=h,m/=h;let d=0,j=0,E=0;for(const D of g){if(D.value===null)continue;const F=D.at-S,C=D.value-m;d+=F*F,j+=F*C,E+=C*C}if(d===0)return null;const O=j/d,T=m-O*S,A=E===0?1:Math.max(0,Math.min(1,j*j/(d*E))),P=Math.max(0,E-O*j),L=h>2?Math.sqrt(P/(h-2)):null,z=h>2?$(f,h-2):null,H=[];for(let D=1;D<=b;D++){const F=w(D),C=T+O*F;let B=null,_=null,Q=null,Y=null,J=null;if(L!==null){const te=1/h+(F-S)**2/d,ee=L*Math.sqrt(1+te),oe=L*Math.sqrt(te);J=ee,B=C-z*ee,_=C+z*ee,Q=C-z*oe,Y=C+z*oe}H.push({step:D,at:F,mean:C,lower:B,upper:_,lowerMean:Q,upperMean:Y,se:J})}return{method:"linear",horizon:b,confidence:p,n:h,sigma:L,r2:A,params:{slope:O,intercept:T},points:H}}function s(g,h,b,p,f,w,S){if(h<1)return null;const m=Math.max(1,Math.min(h,Math.floor(Number(w.windowLen)||h))),d=g.slice(h-m);let j=0;for(const L of d)j+=L;const E=j/m;let O=null,T=null;if(m>1){let L=0;for(const H of d)L+=(H-E)**2;O=Math.sqrt(L/(m-1))*Math.sqrt(1+1/m),T=$(f,m-1)}const A=O===null?null:T*O,P=[];for(let L=1;L<=b;L++)P.push({step:L,at:S(L),mean:E,lower:A===null?null:E-A,upper:A===null?null:E+A,se:O});return{method:"movingAverage",horizon:b,confidence:p,n:h,sigma:O===null?null:O,params:{windowLen:m},points:P}}function r(g,h,b,p,f,w,S){if(h<1)return null;let m=Number.isFinite(w.alpha)?v(w.alpha):null;m===null&&(m=k(T=>y(g,T).sse));const d=y(g,m),j=M(f),E=d.m>0?d.sse/d.m:null,O=[];for(let T=1;T<=b;T++){const A=d.level;let P=null,L=null,z=null;if(E!==null){const H=[];for(let F=1;F<T;F++)H.push(m);const D=n(E,H,j);z=D.se,P=A-D.margin,L=A+D.margin}O.push({step:T,at:S(T),mean:A,lower:P,upper:L,se:z})}return{method:"ses",horizon:b,confidence:p,n:h,sigma:E===null?null:Math.sqrt(E),params:{alpha:m},points:O}}function o(g,h,b,p,f,w,S){if(h<2)return null;let m=Number.isFinite(w.alpha)?v(w.alpha):null,d=Number.isFinite(w.beta)?v(w.beta):null;if(m===null||d===null){let P=m===null?.5:m,L=d===null?.5:d;for(let z=0;z<6;z++)m===null&&(P=k(H=>l(g,H,L).sse)),d===null&&(L=k(H=>l(g,P,H).sse));m=m===null?P:m,d=d===null?L:d}const j=l(g,m,d),E=M(f),O=j.m>0?j.sse/j.m:null,T=m*d,A=[];for(let P=1;P<=b;P++){const L=j.level+P*j.trend;let z=null,H=null,D=null;if(O!==null){const F=[];for(let B=1;B<P;B++)F.push(m+B*T);const C=n(O,F,E);D=C.se,z=L-C.margin,H=L+C.margin}A.push({step:P,at:S(P),mean:L,lower:z,upper:H,se:D})}return{method:"holt",horizon:b,confidence:p,n:h,sigma:O===null?null:Math.sqrt(O),params:{alpha:m,beta:d},points:A}}function c(g,h,b,p,f,w,S){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(h<2*m)return null;let d=Number.isFinite(w.alpha)?v(w.alpha):null,j=Number.isFinite(w.beta)?v(w.beta):null,E=Number.isFinite(w.gamma)?v(w.gamma):null;const O=(D,F,C)=>{const B=u(g,m,D,F,C);return B?B.sse:1/0};if(d===null||j===null||E===null){let D=d===null?.5:d,F=j===null?.5:j,C=E===null?.5:E;for(let B=0;B<8;B++)d===null&&(D=k(_=>O(_,F,C))),j===null&&(F=k(_=>O(D,_,C))),E===null&&(C=k(_=>O(D,F,_)));d=d===null?D:d,j=j===null?F:j,E=E===null?C:E}const T=u(g,m,d,j,E);if(!T)return null;const A=M(f),P=T.count>0?T.sse/T.count:null,L=d*j,z=E*(1-d),H=[];for(let D=1;D<=b;D++){const F=T.season[(T.phase+D)%m],C=T.level+D*T.trend+F;let B=null,_=null,Q=null;if(P!==null){const Y=[];for(let te=1;te<D;te++)Y.push(d+te*L+(te%m===0?z:0));const J=n(P,Y,A);Q=J.se,B=C-J.margin,_=C+J.margin}H.push({step:D,at:S(D),mean:C,lower:B,upper:_,se:Q})}return{method:"holtWinters",horizon:b,confidence:p,n:h,sigma:P===null?null:Math.sqrt(P),params:{alpha:d,beta:j,gamma:E,period:m},points:H}}const a={FORECAST_METHODS:Z,forecast:t}}),Ae("packages/core/src/compute/hypothesis.js",function(e,G){"use strict";Object.defineProperty(e,"GROUP_TESTS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NORMALITY_ALPHA",{enumerable:!0,get:function(){return a}}),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 d}}),Object.defineProperty(e,"chiSquareTest",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"compareGroups",{enumerable:!0,get:function(){return A}});const M=G("packages/core/src/internal/util.js").warnOnce,N=G("packages/core/src/compute/handle.js").valueReader,W=G("packages/core/src/compute/statistics.js"),Z=W.numbers,V=W.moments,U=W.frequencyMap,x=W.categoricalDistance,I=W.isNumericColumn,v=W.jarqueBera,k=W.proportionInterval,y=W.SUBSET_RELIABILITY_FLOOR,u=G("packages/core/src/compute/compare.js").pooledStandardMeanDifference,n=G("packages/core/src/compute/special.js"),t=n.studentT,i=n.studentTQuantile,s=n.normalCdf,r=n.normalQuantile,o=n.chiSquareUpperTail,c=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),a=.05,g=2e6;function h(P){const L=Number(P);return Number.isFinite(L)&&L>0&&L<1?L:.95}function b(P){const{n:L,mean:z,m2:H}=V(P);return{mean:z,sd:L>0?Math.sqrt(H/L):0,n:L}}function p(P,L){const z=P.length;if(z<2)return 0;let H=0;for(let D=0;D<z;D++){const F=P[D]-L;H+=F*F}return H/(z-1)}function f(P,L){return{name:"pooledStandardMeanDifference",value:u(b(P),b(L))}}function w(P,L,z){const H=P.length,D=L.length;if(H<2||D<2)return null;const F=h(z),{mean:C}=V(P),{mean:B}=V(L),_=p(P,C),Q=p(L,B),Y=_/H+Q/D;if(!(Y>0))return null;const J=Math.sqrt(Y),te=(C-B)/J,ee=_/H*(_/H)/(H-1),oe=Q/D*(Q/D)/(D-1),re=Y*Y/(ee+oe),le=Math.min(1,Math.max(0,2*(1-t(Math.abs(te),re)))),ne=C-B,se=i(1-(1-F)/2,re)*J;return{test:c.WELCH,statistic:te,statisticName:"t",df:re,pValue:le,interval:{estimate:ne,lower:ne-se,upper:ne+se,confidence:F,method:"welch-t (difference of means)"},effectSize:f(P,L),nA:H,nB:D,reliable:H>=y&&D>=y,method:"Welch's t-test (unequal variances; Welch–Satterthwaite df)"}}function S(P){const L=P.length;if(L===0)return Number.NaN;const z=L>>1;return L%2?P[z]:(P[z-1]+P[z])/2}function m(P,L,z){const H=P.length,D=L.length,F=H*D;if(F===0||F>g)return null;const C=new Float64Array(F);let B=0;for(let ee=0;ee<H;ee++)for(let oe=0;oe<D;oe++)C[B++]=P[ee]-L[oe];C.sort();const _=S(C),Q=Math.sqrt(H*D*(H+D+1)/12),Y=r(1-(1-z)/2);let J=Math.round(F/2-Y*Q);J>=0||(J=0);const te=Math.floor((F-1)/2);return J>te&&(J=te),{estimate:_,lower:C[J],upper:C[F-1-J],confidence:z,method:"hodges-lehmann (normal approximation)"}}function d(P,L,z){const H=P.length,D=L.length;if(H<1||D<1)return null;const F=h(z),C=H+D,B=new Array(C);for(let le=0;le<H;le++)B[le]={v:P[le],g:0};for(let le=0;le<D;le++)B[H+le]={v:L[le],g:1};B.sort((le,ne)=>le.v-ne.v);let _=0,Q=0,Y=0;for(;Y<C;){let le=Y;for(;le<C&&B[le].v===B[Y].v;)le++;const ne=le-Y,se=(Y+1+le)/2;for(let ae=Y;ae<le;ae++)B[ae].g===0&&(_+=se);Q+=ne*ne*ne-ne,Y=le}const J=_-H*(H+1)/2,te=H*D/2,ee=H*D/12*(C+1-Q/(C*(C-1)));let oe=1;if(ee>0){const le=Math.max(0,Math.abs(J-te)-.5);oe=Math.min(1,2*s(-le/Math.sqrt(ee)))}const re=m(P,L,F);return{test:c.MANN_WHITNEY,statistic:J,statisticName:"U",df:null,pValue:oe,interval:re,effectSize:f(P,L),nA:H,nB:D,reliable:H>=y&&D>=y,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function j(P,L,z,H,D){const F=k(P,L,D),C=k(z,H,D);if(!F||!C)return null;const B=F.proportion-C.proportion,_=B-Math.sqrt((F.proportion-F.lower)**2+(C.upper-C.proportion)**2),Q=B+Math.sqrt((F.upper-F.proportion)**2+(C.proportion-C.lower)**2);return{lower:_,upper:Q}}function E(P,L,z,H,D,F={}){if(!(L>0)||!(H>0))return null;const C=new Set([...P.keys(),...z.keys()]),B=C.size;if(B<2)return null;const _=L+H;let Q=0;for(const oe of C){const re=P.get(oe)||0,le=z.get(oe)||0,ne=re+le,se=L*ne/_,ae=H*ne/_;se>0&&(Q+=(re-se)*(re-se)/se),ae>0&&(Q+=(le-ae)*(le-ae)/ae)}const Y=B-1,J=o(Q,Y);let te=null;F.category!==void 0&&C.has(F.category)?te=F.category:B===2&&([te]=[...C]);let ee=null;if(te!==null){const oe=j(P.get(te)||0,L,z.get(te)||0,H,h(D));oe&&(ee={estimate:(P.get(te)||0)/L-(z.get(te)||0)/H,lower:oe.lower,upper:oe.upper,confidence:h(D),method:"newcombe (difference in this category's share)",category:te})}return{test:c.CHI_SQUARE,statistic:Q,statisticName:"chiSquare",df:Y,pValue:J,interval:ee,effectSize:{name:"categoricalTotalVariation",value:x(P,L,z,H)},nA:L,nB:H,reliable:L>=y&&H>=y,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function O(P){return P==null||P===""||typeof P=="number"&&Number.isNaN(P)?null:P instanceof Date?P.getTime():typeof P=="object"?String(P):P}function T(P,L,z){if(z===c.WELCH||z===c.MANN_WHITNEY)return{test:z,chosenBy:"override",reason:`caller override: ${z}`};const H=v(P),D=v(L),F=H===null?null:Math.exp(-H/2),C=D===null?null:Math.exp(-D/2);return F!==null&&F<a||C!==null&&C<a?{test:c.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${a})`}:{test:c.WELCH,chosenBy:"auto",reason:F!==null||C!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function A(P,L,z,H={}){if(!P||!L)return null;const D=h(H.confidence),F=N(L);let C;if(Array.isArray(H.groups)&&H.groups.length===2)C=[O(H.groups[0]),O(H.groups[1])];else{const{map:le}=U(L,z),ne=[...le.entries()].sort((se,ae)=>ae[1]-se[1]).slice(0,2).map(se=>se[0]);if(ne.length<2)return M("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;C=ne}const[B,_]=C;if(B===null||_===null||B===_)return M("compareGroups:distinct","[lattice] compareGroups: the two groups must be two distinct, present values."),null;const Q=[],Y=[];for(let le=0;le<z.length;le++){const ne=O(F(z[le]));ne===B?Q.push(z[le]):ne===_&&Y.push(z[le])}if(Q.length===0||Y.length===0)return M("compareGroups:empty","[lattice] compareGroups: one of the two groups has no rows in the current set."),null;const J=H.test&&H.test!=="auto"?String(H.test):null,te=I(P,Q.concat(Y));let ee,oe,re;if(J===c.CHI_SQUARE||!J&&!te){oe=J?"override":"auto",re=J?"caller override: chiSquare":"column family: categorical";const le=U(P,Q),ne=U(P,Y);ee=E(le.map,le.total,ne.map,ne.total,D,{category:H.category})}else{if((J===c.WELCH||J===c.MANN_WHITNEY)&&!te)return M("compareGroups:numeric-override",`[lattice] compareGroups: ${J} needs a numeric column, but the column is not numeric.`),null;const le=Z(P,Q),ne=Z(P,Y),se=T(le,ne,J);oe=se.chosenBy,re=se.reason,ee=se.test===c.MANN_WHITNEY?d(le,ne,D):w(le,ne,D)}return ee?{...ee,chosenBy:oe,reason:re,groups:[B,_]}:(M("compareGroups:degenerate","[lattice] compareGroups: the chosen test had too little to work with (too few values, or no variation)."),null)}}),Ae("packages/core/src/columns/detailcolumn.js",function(e,G){"use strict";Object.defineProperty(e,"DETAIL_COLUMN_ID",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"createDetailColumn",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return N}});const q="__lattice_detail",M=36;function $(W){const Z=W.config&&W.config.detailColumnWidth||M;return{id:q,field:null,title:"",type:"text",dataType:{base:"text"},nullable:!0,align:"center",generated:!0,control:!0,detailExpander:!0,value:{pure:!0},cell:{render:"detailExpander",align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:Z,min:Z,max:Z,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(V,U){return!!(U&&U.expanded)},formatValue(){return""}}}const N=$}),Ae("packages/core/src/columns/treecolumn.js",function(e,G){"use strict";Object.defineProperty(e,"TREE_COLUMN_ID",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"createTreeColumn",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const M=G("packages/core/src/internal/util.js").isFunction,$="__lattice_tree",N=260;function W(V){const U=V.tree||{},x=V.config&&V.config.treeColumnWidth||N,I=()=>(V.columns&&M(V.columns.visible)?V.columns.visible():[]).find(l=>!l.generated)||null,v=(y,l)=>{if(l&&l.group)return l.groupValue;if(M(U.label))return U.label(y,l);if(typeof U.label=="string")return y==null?null:y[U.label];const u=I();return u&&M(u.getValue)?u.getValue(y,l):null},k=()=>{if(U.title)return U.title;const y=typeof U.label=="string"?V.columns&&M(V.columns.get)?V.columns.get(U.label):null:I();return y&&(y.title||y.id)||"Hierarchy"};return{id:$,get title(){return k()},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:x,min:140,pin:V.config&&V.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 V.config&&V.config.grandTotalLabel||"Total";if(y==null)return"";if(!U.label){const u=I();if(u&&M(u.formatValue))return u.formatValue(y,l)}return String(y)}}}const Z=W}),Ae("packages/core/src/columns/pivotcolumns.js",function(e,G){"use strict";Object.defineProperty(e,"PIVOT_PREFIX",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"createPivotColumns",{enumerable:!0,get:function(){return W}});const M=G("packages/core/src/internal/util.js").warnOnce,$="__lattice_pivot",N=500;function W(x){const{pivot:I,valueColumns:v,config:k}=x,y=I&&I.paths||[],l=x.separator||k&&k.pivot&&k.pivot.separator||" | ",u=k&&k.pivot&&k.pivot.maxColumns||N;if(!y.length||!v.length)return{tree:[],leaves:[],error:null};const n=Z(k),t=y.length*v.length+(n?v.length:0);if(t>u){const r=`pivot would generate ${t} columns, above the limit of ${u}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return M(`pivot.maxColumns:${t}`,r),{tree:[],leaves:[],error:r}}const i=[],s=[];for(const r of y){const o=[];for(const c of v){const a=U(r,c,l);o.push(a),s.push(a)}o.length===1?(o[0].title=String(r),i.push(o[0])):i.push({id:`${$}:group:${r}`,title:String(r),columns:o,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(n){const r=v.map(c=>V(c,k));s.push(...r);const o=k&&k.pivot&&k.pivot.totalsLabel||"Total";if(r.length===1)r[0].title=o,n==="before"?i.unshift(r[0]):i.push(r[0]);else{const c={id:`${$}:group:__totals`,title:o,columns:r,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};n==="before"?i.unshift(c):i.push(c)}}return{tree:i,leaves:s,error:null}}function Z(x){const I=x&&x.pivot&&x.pivot.groupTotals;return I==="before"||I==="after"?I:null}function V(x,I){return{id:`${$}:__total${I&&I.pivot&&I.pivot.separator||" | "}${x.id}`,field:null,title:x.title||x.id,type:x.type,dataType:x.dataType,nullable:!0,align:x.align,generated:!0,pivot:{enabled:!1,index:0,sourceId:x.id,total:!0},value:{pure:!0},cell:{align:x.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:x.total,lookup:null,layout:{width:x.layout&&x.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(v,k){const y=k&&k.totals;return y&&Object.hasOwn(y,x.id)?y[x.id]:null},formatValue(v,k){return v==null?"":x.formatValue?x.formatValue(v,k):String(v)}}}function U(x,I,v){return{id:`${$}:${x}${v}${I.id}`,field:null,title:I.title||I.id,type:I.type,dataType:I.dataType,nullable:!0,align:I.align,generated:!0,pivot:{enabled:!1,index:0,path:x,sourceId:I.id},value:{pure:!0},cell:{align:I.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:I.total,lookup:null,layout:{width:I.layout&&I.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(){return null},formatValue(k,y){return k==null?"":I.formatValue?I.formatValue(k,y):String(k)}}}}),Ae("packages/core/src/compute/group.js",function(e,G){"use strict";Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return k}});const q=G("packages/core/src/compute/handle.js"),M=q.dictSize,$=q.identity,N=q.presenceReader,W=q.rowCount,Z=q.valueReader,V="",U="\0",x=1<<20;function I(y,l,u,n){const t=y.length,i=y.map(g=>Z(g)),s=Array.isArray(n)&&n.some(Boolean),r=s?i.map((g,h)=>n[h]?b=>n[h](g(b)):g):i;if(!s&&t>0&&y.every(g=>g&&g.kind==="dictionary"&&g.dict)){const g=y.map(b=>M(b.dict)+1);let h=1;for(let b=0;b<t;b++)h*=g[b];if(h<=Number.MAX_SAFE_INTEGER){const b=y.map(S=>S.values),p=y.map(S=>N(S)),f=S=>{let m=0;for(let d=0;d<t;d++){const j=p[d],E=j&&j(S)===0?g[d]-1:b[d][S];m=m*g[d]+E}return m},w=new Float64Array(u);for(let S=0;S<u;S++)w[S]=f(l[S]);return{packed:w,strings:null,product:h,readers:r,keyOf:f}}}const c=g=>{let h="";for(let b=0;b<t;b++){const p=r[b](g);h+=(b===0?"":V)+(p==null?U:String(p))}return h},a=new Array(u);for(let g=0;g<u;g++)a[g]=c(l[g]);return{packed:null,strings:a,product:1/0,readers:r,keyOf:c}}function v(y,l,u,n){const t=new Uint32Array(n+1);for(let o=0;o<u;o++)t[l[o]+1]++;for(let o=0;o<n;o++)t[o+1]+=t[o];const i=new Uint32Array(u),s=t.slice(0,n);for(let o=0;o<u;o++)i[s[l[o]]++]=y[o];const r=new Array(n);for(let o=0;o<n;o++)r[o]=i.subarray(t[o],t[o+1]);return r}function k(y,l,u={}){const n=y||[],t=l||$(W(n[0],u)),i=t.length;if(n.length===0||i===0)return{keys:[],buckets:[]};const{packed:s,strings:r,product:o,readers:c}=I(n,t,i,u.project),a=new Uint32Array(i);let g=0,h=null;if(s&&o<=Math.max(1024,Math.min(x,i*4))){const w=o,S=new Int32Array(w).fill(-1);for(let m=0;m<i;m++)S[s[m]]=0;for(let m=0;m<w;m++)S[m]===0&&(S[m]=g++);for(let m=0;m<i;m++)a[m]=S[s[m]];h=new Float64Array(g);for(let m=0;m<w;m++)S[m]>=0&&(h[S[m]]=m)}else if(s){const w=new Map;for(let S=0;S<i;S++){const m=s[S];let d=w.get(m);d===void 0&&(d=g++,w.set(m,d)),a[S]=d}h=new Float64Array(g);for(const[S,m]of w)h[m]=S}else{const w=new Map;for(let S=0;S<i;S++){const m=r[S];let d=w.get(m);d===void 0&&(d=g++,w.set(m,d)),a[S]=d}}const b=v(t,a,i,g),p=new Array(g);for(let w=0;w<g;w++){const S=b[w][0],m=new Array(c.length);for(let d=0;d<c.length;d++)m[d]=c[d](S);p[w]=m}const f={keys:p,buckets:b};return h&&(f.packed=h),f}}),Ae("packages/core/src/compute/pivot.js",function(e,G){"use strict";Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return i}});const M=G("packages/core/src/internal/util.js").warnOnce,N=G("packages/core/src/compute/handle.js").valueComparator,Z=G("packages/core/src/compute/group.js").packKeys,U=G("packages/core/src/compute/total.js").total,x="|",I="/",v=2e3;function k(o,c,a){return`${o}${x}${c}${x}${a}`}function y(o,c){let a="";for(let g=0;g<o.length;g++){const h=o[g];a+=(g===0?"":c)+(h==null?"":String(h))}return a}function l(o,c,a={}){const g=a.separator||I,h=c.length,{keyOf:b,readers:p}=Z(o,c,0),f=new Map,w=[],S=[];for(let A=0;A<h;A++){const P=c[A],L=b(P);if(f.has(L))continue;f.set(L,w.length),S.push(L);const z=new Array(p.length);for(let H=0;H<p.length;H++)z[H]=p[H](P);w.push(z)}const m=N(a.locale),d=w.map((A,P)=>P);d.sort((A,P)=>{const L=w[A],z=w[P];for(let H=0;H<L.length;H++){const D=u(L[H],z[H],m);if(D!==0)return D}return A-P});const j=new Array(d.length),E=new Array(d.length),O=new Map;for(let A=0;A<d.length;A++){const P=d[A];j[A]=w[P],E[A]=y(w[P],g),O.set(S[P],A)}return{keys:j,paths:E,idOf:A=>{const P=O.get(b(A));return P===void 0?-1:P}}}function u(o,c,a){const g=o==null,h=c==null;return g||h?g&&h?0:g?1:-1:a(o,c)}function n(o){const c=o.values||o.totals||[];if(c.length&&typeof c[0]=="object"&&c[0]!==null)return c.filter(b=>b&&b.handle);const a=typeof o.handle=="function"?o.handle:null;if(!a)return c.length&&M("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 o.totalOf=="function"?o.totalOf:null,h=[];for(const b of c){const p=a(b);p&&h.push({colId:b,handle:p,fn:g?g(b):"sum"})}return h}function t(o,c,a){if(Array.isArray(o)){const g=a||{};return{...g,pivotHandles:o,order:c||null,groups:g.groups||null}}return o||{}}function i(o,c,a){const g=t(o,c,a),h=g.separator||I,b=n(g),p=g.maxColumns===void 0?v:g.maxColumns,f=g.groups&&g.groups.buckets?g.groups:null,w=f?f.buckets:[g.order||new Uint32Array(0)],S=g.groupPaths||(f?f.keys.map(L=>y(L,h)):[""]),m=r(w),{keys:d,paths:j,idOf:E}=l(g.pivotHandles||[],m,g),O=j.length*Math.max(1,b.length),T=s(j,b,h);if(p&&O>p){const L=new Map;return{keys:d,paths:j,fields:T,groupPaths:S,columns:O,values:L,cells:L,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${O} columns, above pivot.maxColumns of ${p}. Narrow the pivot columns or raise the limit.`,columns:O,maxColumns:p}}}const A=new Map,P=j.length;for(let L=0;L<w.length;L++){const z=w[L],H=S[L]===void 0?"":S[L],D=z.length;if(D===0)continue;const F=new Int32Array(D),C=new Uint32Array(P+1);for(let Q=0;Q<D;Q++){const Y=E(z[Q]);F[Q]=Y,Y>=0&&C[Y+1]++}for(let Q=0;Q<P;Q++)C[Q+1]+=C[Q];const B=new Uint32Array(D),_=C.slice(0,P);for(let Q=0;Q<D;Q++){const Y=F[Q];Y>=0&&(B[_[Y]++]=z[Q])}for(let Q=0;Q<P;Q++){const Y=C[Q],J=C[Q+1];if(J===Y)continue;const te=B.subarray(Y,J);for(let ee=0;ee<b.length;ee++){const oe=b[ee],re=U(oe.handle,te,oe.fn,g.totalContext||{locale:g.locale});A.set(k(H,j[Q],oe.colId),re)}}}return{keys:d,paths:j,fields:T,groupPaths:S,columns:O,values:A,cells:A,error:null}}function s(o,c,a){if(c.length===0)return o.slice();const g=[];for(const h of o)for(const b of c)g.push(`${h}${a}${b.colId}`);return g}function r(o){if(o.length===1)return o[0]||new Uint32Array(0);let c=0;for(const h of o)c+=h?h.length:0;const a=new Uint32Array(c);let g=0;for(const h of o)!h||h.length===0||(a.set(h,g),g+=h.length);return a}}),Ae("packages/core/src/store/bitset.js",function(e,G){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return M}});const q=8;class M{static#e=new Uint8Array(256);static{for(let N=1;N<256;N++)M.#e[N]=M.#e[N>>1]+(N&1)}#t;#n;constructor(N=0){const W=Math.max(0,N|0);this.#n=W,this.#t=new Uint8Array(Math.ceil(W/q))}get size(){return this.#n}get words(){return this.#t}get bytes(){return this.#t?this.#t.byteLength:0}get(N){return N<0||N>=this.#n?0:this.#t[N>>3]>>(N&7)&1}set(N){return N>=0&&N<this.#n&&(this.#t[N>>3]|=1<<(N&7)),this}clear(N){return N>=0&&N<this.#n&&(this.#t[N>>3]&=~(1<<(N&7))),this}assign(N,W){return W?this.set(N):this.clear(N)}fill(N=!1){return this.#t.fill(N?255:0),N&&this.#r(),this}grow(N){const W=Math.max(0,N|0);if(W<=this.#n)return this;const Z=Math.ceil(W/q);if(Z>this.#t.length){const V=new Uint8Array(Z);V.set(this.#t),this.#t=V}return this.#n=W,this}count(){const N=this.#t,W=M.#e;let Z=0;for(let V=0;V<N.length;V++)Z+=W[N[V]];return Z}and(N){const W=N instanceof M?N.words:N,Z=this.#t,V=Math.min(Z.length,W.length);for(let U=0;U<V;U++)Z[U]&=W[U];for(let U=V;U<Z.length;U++)Z[U]=0;return this}or(N){const W=N instanceof M?N.words:N,Z=this.#t,V=Math.min(Z.length,W.length);for(let U=0;U<V;U++)Z[U]|=W[U];return this}not(){const N=this.#t;for(let W=0;W<N.length;W++)N[W]=~N[W]&255;return this.#r(),this}clone(){const N=new M(this.#n);return N.words.set(this.#t.subarray(0,N.words.length)),N}release(){this.#t=new Uint8Array(0),this.#n=0}#r(){const N=this.#n&7;if(N===0)return;const W=this.#n>>3;W<this.#t.length&&(this.#t[W]&=(1<<N)-1)}static from(N){const W=Array.isArray(N)?N:Array.from(N),Z=new M(W.length);for(let V=0;V<W.length;V++)W[V]&&Z.set(V);return Z}}}),Ae("packages/core/src/store/dictionary.js",function(e,G){"use strict";Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return N}});const q=G("packages/core/src/internal/util.js"),M=q.collator,$=q.defaultCompare;class N{#e;#t=new Map;#n=0;#r=null;#o=-1;#i="\0";constructor(Z=[]){this.#e=[];for(let V=0;V<Z.length;V++){const U=Z[V];this.#t.has(U)||(this.#t.set(U,this.#e.length),this.#e.push(U))}}get size(){return this.#e.length}get version(){return this.#n}get bytes(){let Z=this.#e.length*8;for(let V=0;V<this.#e.length;V++){const U=this.#e[V];typeof U=="string"&&(Z+=U.length*2),Z+=16}return Z}codeOf(Z){const V=this.#t.get(Z);if(V!==void 0)return V;const U=this.#e.length;return this.#e.push(Z),this.#t.set(Z,U),this.#n++,U}lookup(Z){const V=this.#t.get(Z);return V===void 0?-1:V}has(Z){return this.#t.has(Z)}valueOf(Z){return this.#e[Z]}values(){return this.#e}ranks(Z){const V=Z||"";if(this.#r&&this.#o===this.#n&&this.#i===V)return this.#r;const U=this.#e.length,x=new Array(U);for(let y=0;y<U;y++)x[y]=y;const I=M(Z).compare,v=this.#e;x.sort((y,l)=>this.#s(v[y],v[l],I));const k=new Uint32Array(U);for(let y=0;y<U;y++)k[x[y]]=y;return this.#r=k,this.#o=this.#n,this.#i=V,k}#s(Z,V,U){return typeof Z=="string"&&typeof V=="string"?U(Z,V):$(Z,V)}}}),Ae("packages/core/src/store/multivalue.js",function(e,G){"use strict";Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return q}});class q{#e;#t;#n=0;#r=0;constructor($={}){const N=Math.max(1,$.rows??16),W=Math.max(1,$.values??N);this.#e=new Int32Array(W),this.#t=new Uint32Array(N+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($){return $<0||$>=this.#n?0:this.#t[$+1]-this.#t[$]}at($){return $<0||$>=this.#n?this.#e.subarray(0,0):this.#e.subarray(this.#t[$],this.#t[$+1])}has($,N){if($<0||$>=this.#n)return!1;const W=this.#e,Z=this.#t[$+1];for(let V=this.#t[$];V<Z;V++)if(W[V]===N)return!0;return!1}hasAny($,N){for(let W=0;W<N.length;W++)if(this.has($,N[W]))return!0;return!1}hasAll($,N){for(let W=0;W<N.length;W++)if(!this.has($,N[W]))return!1;return!0}hasNone($,N){return!this.hasAny($,N)}push($){const N=this.#n,W=$.length;this.#o(N+1),this.#i(this.#r+W);const Z=this.#r;for(let V=0;V<W;V++)this.#e[Z+V]=$[V]|0;return this.#r+=W,this.#n=N+1,this.#t[N]=Z,this.#t[N+1]=this.#r,N}write($,N){if($===this.#n){this.push(N);return}if($<0||$>this.#n)return;const W=this.#t[$],Z=this.#t[$+1],V=N.length;if(Z-W===V){for(let U=0;U<V;U++)this.#e[W+U]=N[U]|0;return}this.#s($,N)}compact($,N,W){const Z=this.#e,V=this.#t,U=this.#n,x=new Int32Array(Math.max(1,this.#r)),I=new Uint32Array(N+1);let v=0;for(let k=0;k<U;k++){if($[k]===W)continue;const y=V[k],l=V[k+1];I[$[k]]=v;for(let u=y;u<l;u++)x[v++]=Z[u];I[$[k]+1]=v}this.#e=x,this.#t=I,this.#n=N,this.#r=v}release(){this.#e=new Int32Array(0),this.#t=new Uint32Array(1),this.#n=0,this.#r=0}#o($){if($+1<=this.#t.length)return;let N=this.#t.length-1;for(;N<$;)N=N*2||16;const W=new Uint32Array(N+1);W.set(this.#t),this.#t=W}#i($){if($<=this.#e.length)return;let N=this.#e.length;for(;N<$;)N=N*2||16;const W=new Int32Array(N);W.set(this.#e),this.#e=W}#s($,N){const W=this.#e,Z=this.#t,V=this.#n,U=N.length-(Z[$+1]-Z[$]),x=new Int32Array(Math.max(1,this.#r+U)),I=new Uint32Array(Z.length);let v=0;for(let k=0;k<V;k++){if(I[k]=v,k===$)for(let y=0;y<N.length;y++)x[v++]=N[y]|0;else for(let y=Z[k];y<Z[k+1];y++)x[v++]=W[y];I[k+1]=v}this.#e=x,this.#t=I,this.#r=v}}}),Ae("packages/core/src/compute/sort.js",function(e,G){"use strict";Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return P}});const q=G("packages/core/src/compute/handle.js"),M=q.bitReader,$=q.dictRanks,N=q.dictSize,W=q.identity,Z=q.isMissing,V=q.presenceReader,U=q.rowCount,x=q.valueComparator,I=q.valueReader,v=new Uint32Array(0),k=new ArrayBuffer(8),y=new Float64Array(k),l=new Uint32Array(k),u=(y[0]=-1,(l[1]&2147483648)!==0?1:0),n=u===1?0:1;function t(z,H){y[0]=z;let D=l[u],F=l[n];(D&2147483648)!==0?(D=~D>>>0,F=~F>>>0):D=(D^2147483648)>>>0,H[0]=F,H[1]=D}function i(z,H,D,F){if(F<2)return z;const C=new Uint32Array(256*8);for(let oe=0;oe<F;oe++){const re=H[oe],le=D[oe];C[re&255]++,C[256+(re>>>8&255)]++,C[512+(re>>>16&255)]++,C[768+(re>>>24&255)]++,C[1024+(le&255)]++,C[1280+(le>>>8&255)]++,C[1536+(le>>>16&255)]++,C[1792+(le>>>24&255)]++}let B=z,_=H,Q=D,Y=new Uint32Array(F),J=new Uint32Array(F),te=new Uint32Array(F);const ee=new Uint32Array(256);for(let oe=0;oe<8;oe++){const re=oe<<8,le=(oe&3)<<3,ne=oe>=4;let se=!1;for(let me=0;me<256;me++)if(C[re+me]===F){se=!0;break}if(se)continue;let ae=0;for(let me=0;me<256;me++)ee[me]=ae,ae+=C[re+me];for(let me=0;me<F;me++){const Pe=_[me],Ie=Q[me],ke=(ne?Ie:Pe)>>>le&255,be=ee[ke]++;Y[be]=B[me],J[be]=Pe,te[be]=Ie}let de=B;B=Y,Y=de,de=_,_=J,J=de,de=Q,Q=te,te=de}return B}function s(z,H,D){if(D<2)return z;const F=new Uint32Array(256*4);for(let J=0;J<D;J++){const te=H[J];F[te&255]++,F[256+(te>>>8&255)]++,F[512+(te>>>16&255)]++,F[768+(te>>>24&255)]++}let C=z,B=H,_=new Uint32Array(D),Q=new Uint32Array(D);const Y=new Uint32Array(256);for(let J=0;J<4;J++){const te=J<<8,ee=J<<3;let oe=!1;for(let ne=0;ne<256;ne++)if(F[te+ne]===D){oe=!0;break}if(oe)continue;let re=0;for(let ne=0;ne<256;ne++)Y[ne]=re,re+=F[te+ne];for(let ne=0;ne<D;ne++){const se=B[ne],ae=Y[se>>>ee&255]++;_[ae]=C[ne],Q[ae]=se}let le=C;C=_,_=le,le=B,B=Q,Q=le}return C}function r(z,H,D,F){const C=new Uint32Array(F+1);for(let Q=0;Q<D;Q++)C[H[Q]]++;let B=0;for(let Q=0;Q<=F;Q++){const Y=C[Q];C[Q]=B,B+=Y}const _=new Uint32Array(D);for(let Q=0;Q<D;Q++)_[C[H[Q]]++]=z[Q];return _}function o(z,H,D,F){return D<2?z:F<=65536||F<=D*2?r(z,H,D,F):s(z,H,D)}function c(z,H){return z.length===H&&z.byteOffset===0?z:Uint32Array.prototype.slice.call(z,0,H)}function a(z,H,D=!1){const F=H||W(z.length),C=F.length;if(C<2)return Uint32Array.from(F);const B=new Uint32Array(C),_=new Uint32Array(C),Q=new Uint32Array(C),Y=new Uint32Array(C),J=new Uint32Array(2);let te=0,ee=0;for(let le=0;le<C;le++){const ne=F[le],se=z[ne];if(Number.isNaN(se)){Y[ee++]=ne;continue}t(se,J),D?(_[te]=~J[0]>>>0,Q[te]=~J[1]>>>0):(_[te]=J[0],Q[te]=J[1]),B[te++]=ne}const oe=i(B.subarray(0,te),_.subarray(0,te),Q.subarray(0,te),te);if(ee===0)return c(oe,te);const re=new Uint32Array(C);return re.set(oe.subarray(0,te),0),re.set(Y.subarray(0,ee),te),re}function g(z,H,D=!1){const F=H||W(z.length),C=F.length;if(C<2)return Uint32Array.from(F);const B=Uint32Array.from(F),_=new Uint32Array(C);for(let Q=0;Q<C;Q++){const Y=(z[B[Q]]^2147483648)>>>0;_[Q]=D?~Y>>>0:Y}return c(s(B,_,C),C)}function h(z,H,D={}){const F=H||W(U(z,D)),C=F.length;if(C<2)return Uint32Array.from(F);const B=$(z.dict,D.locale),_=z.values,Q=V(z),Y=Math.max(N(z.dict),B.length),J=Y,te=Uint32Array.from(F),ee=new Uint32Array(C),oe=!!D.descending;for(let re=0;re<C;re++){const le=te[re];let ne=Q&&Q(le)===0?J:B[_[le]];ne===void 0&&(ne=J),ee[re]=oe?J-ne:ne}return c(o(te,ee,C,Y+1),C)}function b(z,H,D){const F=H.length;let C=Uint32Array.from(H);if(F<2)return C;let B=new Uint32Array(F);for(let _=1;_<F;_<<=1){for(let Y=0;Y<F;Y+=_<<1){const J=Math.min(Y+_,F),te=Math.min(Y+(_<<1),F);let ee=Y,oe=J,re=Y;for(;ee<J&&oe<te;)B[re++]=D(z[C[ee]],z[C[oe]])<=0?C[ee++]:C[oe++];for(;ee<J;)B[re++]=C[ee++];for(;oe<te;)B[re++]=C[oe++]}const Q=C;C=B,B=Q}return C}function p(z,H,D){const F=M(z.values),C=H.length,B=new Uint32Array(C),_=D?1:0;let Q=0;for(let Y=0;Y<C;Y++)F(H[Y])===_&&(B[Q++]=H[Y]);for(let Y=0;Y<C;Y++)F(H[Y])!==_&&(B[Q++]=H[Y]);return B}function f(z,H){const D=z.values,F=z.kind;if((F==="object"||F===void 0)&&(Array.isArray(D)||ArrayBuffer.isView(D))&&!z.presence)return D;const B=I(z),_=new Array(U(z)||0);for(let Q=0;Q<H.length;Q++){const Y=H[Q];_[Y]=B(Y)}return _}function w(z,H){for(let D=0;D<H.length;D++)if(typeof z[H[D]]!="string")return!1;return!0}function S(z,H,D,F,C){const B=z.length,_=Uint32Array.from(z);if(B<2||F<1)return _;const Q=new Uint32Array(B),Y=F-1;for(let J=0;J<B;J++){const te=D[H[J]];Q[J]=C?Y-te:te}return c(o(_,Q,B,F),B)}function m(z,H,D){const F=x(D),C=new Array(H);for(let _=0;_<H;_++)C[_]=_;C.sort((_,Q)=>F(z[_],z[Q])||_-Q);const B=new Uint32Array(H);for(let _=0;_<H;_++)B[C[_]]=_;return B}function d(z,H,D){const F=H.length,C=new Map,B=[],_=new Uint32Array(F);for(let J=0;J<F;J++){const te=z[H[J]];let ee=C.get(te);ee===void 0&&(ee=B.length,C.set(te,ee),B.push(te)),_[J]=ee}const Q=B.length,Y=m(B,Q,D.locale);return S(H,_,Y,Q,!!D.descending)}function j(z,H,D){const F=f(z,H);if(H.length>=2&&w(F,H)){const _=z.stringRank;return _&&_.version===z.version&&_.usable(H,F,D.locale)?_.sort(H,D):d(F,H,D)}const C=x(D.locale),B=D.descending?(_,Q)=>C(Q,_):C;return b(F,H,B)}function E(z,H,D){const F=f(z,H),C=D.compare,_=!!D.descending?(Q,Y)=>-C(Q,Y,void 0,void 0,!0):(Q,Y)=>C(Q,Y,void 0,void 0,!1);return b(F,H,_)}function O(z,H){const D=H.length,F=V(z),C=z.values,B=z.kind==="float64"&&!!C,_=z.kind==="object"||z.kind==="multi"||z.kind===void 0;if(!F&&!B&&!_)return{present:H,absent:v};const Q=new Uint32Array(D),Y=new Uint32Array(D);let J=0,te=0;if(F&&B)for(let ee=0;ee<D;ee++){const oe=H[ee];F(oe)===1&&!Number.isNaN(C[oe])?Q[J++]=oe:Y[te++]=oe}else if(B&&!F)for(let ee=0;ee<D;ee++){const oe=H[ee];Number.isNaN(C[oe])?Y[te++]=oe:Q[J++]=oe}else if(F&&!_)for(let ee=0;ee<D;ee++){const oe=H[ee];F(oe)===1?Q[J++]=oe:Y[te++]=oe}else{const ee=I(z);for(let oe=0;oe<D;oe++){const re=H[oe];Z(ee(re))?Y[te++]=re:Q[J++]=re}}return te===0?{present:H,absent:v}:{present:Q.subarray(0,J),absent:Y.subarray(0,te)}}function T(z,H,D){if(H.length===0)return z;const F=new Uint32Array(z.length+H.length);return D?(F.set(H,0),F.set(z,H.length)):(F.set(z,0),F.set(H,z.length)),F}function A(z,H,D={}){const F=H||W(U(z,D));if(!z||F.length<2)return Uint32Array.from(F);const{present:C,absent:B}=O(z,F);if(C.length===0)return Uint32Array.from(F);const _=!!D.descending;let Q;if(typeof D.compare=="function")Q=E(z,C,D);else switch(z.kind){case"float64":Q=a(z.values,C,_);break;case"int32":Q=g(z.values,C,_);break;case"dictionary":Q=h(z,C,D);break;case"bitset":Q=p(z,C,_);break;default:Q=j(z,C,D);break}return T(Q,B,!!D.nullsFirst)}function P(z,H,D,F={}){const C=H||[],B=C.length&&(C[0].handle||L(z,C[0].col))||z&&z[0];let _=D||W(U(B,F));for(let Q=C.length-1;Q>=0;Q--){const Y=C[Q],J=Y.handle||L(z,Y.col)||z&&z[Q];J&&(_=A(J,_,{descending:Y.descending!==void 0?!!Y.descending:Y.dir==="desc",nullsFirst:!!Y.nullsFirst,locale:Y.locale!==void 0?Y.locale:F.locale,compare:Y.compare}))}return _ instanceof Uint32Array?_:Uint32Array.from(_)}function L(z,H){if(!(!z||H===void 0)){for(let D=0;D<z.length;D++)if(z[D]&&z[D].id===H)return z[D]}}}),Ae("packages/core/src/store/stringrank.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"StringRankIndex",{enumerable:!0,get:function(){return W}});const q=G("packages/core/src/compute/sort.js"),M=q.collateStringRanks,$=q.rankSortStrings,N=1e5;class W{#e=[];#t=new Map;#n;#r=0;#o=0;#i=-1;#s;#l=!1;#a=null;#u=-1;#c="\0";constructor(V=N){this.#s=V>0?V:N,this.#n=new Uint32Array(0)}get version(){return this.#i}set version(V){this.#i=V}get generation(){return this.#o}get size(){return this.#e.length}get capped(){return this.#l}get length(){return this.#r}get bytes(){let V=this.#n.byteLength;const U=this.#e;for(let x=0;x<U.length;x++)V+=U[x].length*2+24;return V}#d(V,U){const x=this.#t.get(V);if(x!==void 0)return x;if(this.#l)return-1;if(U&&this.#e.length>=this.#s)return this.#l=!0,-1;const I=this.#e.length;return this.#e.push(V),this.#t.set(V,I),this.#o++,I}build(V,U){const x=U|0;this.#e=[],this.#t=new Map,this.#o=0,this.#l=!1,this.#a=null,this.#u=-1,this.#n=new Uint32Array(x);for(let I=0;I<x;I++){const v=V[I],k=typeof v=="string"?this.#d(v,!1):-1;this.#n[I]=k<0?0:k}this.#r=x}append(V,U,x){const I=(U|0)+(x|0);if(I>this.#n.length){const v=new Uint32Array(I);v.set(this.#n.subarray(0,this.#r)),this.#n=v}for(let v=U|0;v<I;v++){const k=V[v],y=typeof k=="string"?this.#d(k,!0):-1;this.#n[v]=y<0?0:y}this.#r=Math.max(this.#r,I)}ranks(V){const U=V||"";if(this.#a&&this.#u===this.#o&&this.#c===U)return this.#a;const x=M(this.#e,this.#e.length,V);return this.#a=x,this.#u=this.#o,this.#c=U,x}usable(V,U,x){if(this.#l||this.#e.length===0)return!1;const I=this.#n,v=this.#e,k=this.#r;for(let y=0;y<V.length;y++){const l=V[y];if(l>=k||v[I[l]]!==U[l])return!1}return!0}sort(V,U){const x=this.ranks(U.locale),I=this.#e.length,v=V.length,k=new Uint32Array(v),y=this.#n;for(let l=0;l<v;l++)k[l]=y[V[l]];return $(V,k,x,I,!!U.descending)}}}),Ae("packages/core/src/store/columnstore.js",function(e,G){"use strict";Object.defineProperty(e,"REMOVED",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"toFloat",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ColumnHandle",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return h}});const q=G("packages/core/src/internal/util.js"),M=q.warnOnce,$=q.isFunction,N=q.pathGetter,Z=G("packages/core/src/store/bitset.js").Bitset,U=G("packages/core/src/store/dictionary.js").Dictionary,I=G("packages/core/src/store/multivalue.js").MultiValue,k=G("packages/core/src/store/stringrank.js").StringRankIndex,y=4294967295,l=1024,u=5e3,n=.2,t=new Set(["float64","int32","bitset","dictionary","object","multi"]);function i(b){return b==null}function s(b){if(typeof b=="number")return b;if(b instanceof Date)return b.getTime();if(typeof b=="boolean")return b?1:0;const p=Number(b);return Number.isNaN(p)&&typeof b=="string"?Date.parse(b):p}function r(b){const p=s(b);return Number.isFinite(p)?p|0:0}function o(b){return i(b)?[]:Array.isArray(b)?b:[b]}function c(b,p){switch(b.kind){case"float64":case"int32":return b.buf[p];case"bitset":return b.bits.get(p)===1;case"dictionary":return b.dict.valueOf(b.buf[p]);case"multi":{const f=b.mv.at(p),w=new Array(f.length);for(let S=0;S<f.length;S++)w[S]=b.dict.valueOf(f[S]);return w}default:return b.buf[p]}}function a(b,p){switch(b.kind){case"float64":case"int32":return b.values[p];case"bitset":return(b.values[p>>3]&1<<(p&7))!==0;case"dictionary":return(b.table||[])[b.values[p]];case"multi":{const f=b.offsets[p],w=b.offsets[p+1],S=b.table||[],m=new Array(w-f);for(let d=f;d<w;d++)m[d-f]=S[b.values[d]];return m}default:return b.values[p]}}class g{#e;#t;#n;#r;#o;#i;#s;#l=!1;#a=null;#u=null;#c=null;#d=null;#h=null;#f;#m;#p=-1;#g=null;#w=0;#b=0;#v=null;#y=null;#S=!1;constructor(p,f){this.#e=p.id;const w=t.has(p.kind)?p.kind:"object";p.kind&&!t.has(p.kind)&&M(`store.kind.${p.id}`,`column "${p.id}" declares unknown storage kind "${p.kind}"; falling back to object`),this.#n=w,this.#t=w,this.#r=p.nullable!==!1,this.#s=p.dictionary??null,this.#i=f,this.#o=$(p.read)?p.read:N(p.field||p.id),this.#f=p.stringRankIndex!=="off",this.#m=typeof p.stringRankMaxDistinct=="number"?p.stringRankMaxDistinct:0,this.#v=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.#S?null:this.#l?this.#t==="bitset"?this.#u.words:this.#t==="multi"?this.#c.values:this.#a:this.#T().values}get presence(){return this.#S||!this.#r?null:this.#l?this.#g:this.#T().presence}get dict(){return this.#S||!this.#l?null:this.#t==="dictionary"||this.#t==="multi"?this.#d:null}get stringRank(){if(this.#S||!this.#f||this.kind!=="object")return null;const p=this.values,f=this.#i.physical();if(!p||f===0)return null;if(this.#h===null){if(typeof p[0]!="string")return null;const w=new k(this.#A());return w.build(p,f),w.version=this.#b,this.#h=w,this.#p=this.#b,w.capped?null:w}return this.#h.length<f&&this.#h.append(p,this.#h.length,f-this.#h.length),this.#h.version=this.#b,this.#p=this.#b,this.#h.capped?null:this.#h}#A(){return this.#m}#j(){this.#h=null,this.#p=-1}get offsets(){return this.#S||!this.#l||this.#t!=="multi"?null:this.#c.offsets}get version(){return this.#b}get bytes(){let p=0;return this.#a&&(p+=this.#a.byteLength??this.#a.length*8),this.#u&&(p+=this.#u.bytes),this.#c&&(p+=this.#c.bytes),this.#g&&(p+=this.#g.bytes),this.#d&&(p+=this.#d.bytes),this.#v&&(p+=this.#v.size*24),p}get(p){if(!this.#S&&!(p<0||p>=this.#i.physical())){if(!this.#l)return this.#C(p);if(this.#r&&this.#g.get(p)===0)return null;switch(this.#t){case"float64":case"int32":return this.#a[p];case"bitset":return this.#u.get(p)===1;case"dictionary":return this.#d.valueOf(this.#a[p]);case"multi":{const f=this.#c.at(p),w=new Array(f.length);for(let S=0;S<f.length;S++)w[S]=this.#d.valueOf(f[S]);return w}default:return this.#a[p]}}}set(p,f){this.#S||(this.#l?this.#E(p,f):this.#v.set(p,f===void 0?null:f),this.#h&&this.#j(),this.#b++)}read(p){return this.#o(p)}appendColumn(p,f,w){if(this.#S||w<=0)return;if(!this.#l){this.#b++;return}const S=this.#o,m=this.#r,d=this.#g;let j=!1;switch(this.#t){case"float64":{const E=this.#a;for(let O=0;O<w;O++){const T=S(p[O]);if(typeof T=="number"){m&&d.set(f+O),E[f+O]=T;continue}const A=T==null;m?d.assign(f+O,!A):A&&(j=!0),E[f+O]=A?NaN:s(T)}break}case"int32":{const E=this.#a;for(let O=0;O<w;O++){const T=S(p[O]),A=T==null;m?d.assign(f+O,!A):A&&(j=!0),E[f+O]=A?0:r(T)}break}case"bitset":{const E=this.#u;for(let O=0;O<w;O++){const T=S(p[O]),A=T==null;m?d.assign(f+O,!A):A&&(j=!0),E.assign(f+O,!A&&!!T)}break}case"dictionary":{const E=this.#a,O=this.#d;for(let T=0;T<w;T++){const A=S(p[T]),P=A==null;m?d.assign(f+T,!P):P&&(j=!0),E[f+T]=P?0:O.codeOf(A)}break}case"multi":{const E=this.#c,O=this.#d;for(let T=0;T<w;T++){const A=S(p[T]),P=A==null;m?d.assign(f+T,!P):P&&(j=!0);const L=o(A),z=new Array(L.length);for(let H=0;H<L.length;H++)z[H]=O.codeOf(L[H]);E.write(f+T,z)}break}default:{const E=this.#a;for(let O=0;O<w;O++){const T=S(p[O]),A=T==null;m?d.assign(f+O,!A):A&&(j=!0),E[f+O]=A?null:T}break}}j&&M(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#h&&this.#t==="object"&&(this.#h.append(this.#a,f,w),this.#h.version=this.#b+1,this.#p=this.#b+1),this.#b++}appendPacked(p,f,w){if(this.#S||w<=0||!p)return;if(!this.#l){this.#b++;return}const S=this.#g,m=p.presence;if(S)if(m)for(let j=0;j<w;j++)S.assign(f+j,(m[j>>3]&1<<(j&7))!==0);else for(let j=0;j<w;j++)S.set(f+j);const d=p.kind===this.#t;if(d&&(this.#t==="float64"||this.#t==="int32")){this.#a.set(p.values,f),this.#b++;return}if(d&&this.#t==="bitset"){const j=p.values;for(let E=0;E<w;E++)this.#u.assign(f+E,(j[E>>3]&1<<(E&7))!==0);this.#b++;return}if(d&&this.#t==="dictionary"){const j=p.table||[],E=new Uint32Array(j.length);for(let P=0;P<j.length;P++)E[P]=this.#d.codeOf(j[P]);const O=p.values,T=this.#a,A=S;for(let P=0;P<w;P++){if(A&&(m&&(m[P>>3]&1<<(P&7))===0)){T[f+P]=0;continue}T[f+P]=E[O[P]]??0}this.#b++;return}if(d&&this.#t==="multi"){const j=p.table||[],E=new Uint32Array(j.length);for(let A=0;A<j.length;A++)E[A]=this.#d.codeOf(j[A]);const O=p.values,T=p.offsets;for(let A=0;A<w;A++){const P=T[A],L=T[A+1],z=new Array(L-P);for(let H=P;H<L;H++)z[H-P]=E[O[H]]??0;this.#c.write(f+A,z)}this.#b++;return}for(let j=0;j<w;j++){const E=m?(m[j>>3]&1<<(j&7))===0:p.kind==="object"?p.values[j]===null:!1;this.#E(f+j,E?null:a(p,j))}this.#b++}touch(){this.#b++}columnarise(p,f){if(this.#l||this.#S)return;const w=new Array(f);for(let S=0;S<f;S++)w[S]=this.#C(S);this.#t=this.#n,this.#l=!0,this.#O(p);for(let S=0;S<f;S++)this.#E(S,w[S]);this.#v.clear(),this.#y=null,this.#j(),this.#b++}grow(p){if(!(!this.#l||this.#S||p<=this.#w)){switch(this.#t){case"float64":case"int32":case"dictionary":{const f=new this.#a.constructor(p);f.set(this.#a),this.#a=f;break}case"bitset":this.#u.grow(p);break;case"multi":break;default:this.#a.length=p;break}this.#g&&this.#g.grow(p),this.#w=p,this.#b++}}convert(p){if(this.#S||!t.has(p)||(this.#n=p,!this.#l||p===this.#t))return!1;const f={kind:this.#t,buf:this.#a,bits:this.#u,mv:this.#c,dict:this.#d},w=this.#i.physical(),S=this.#g;this.#t=p,this.#O(this.#w);for(let m=0;m<w;m++){const d=S!==null&&S.get(m)===0;d&&p!=="multi"||this.#E(m,d?null:c(f,m))}return this.#j(),this.#b++,!0}compact(p,f,w){if(!this.#S){if(this.#j(),!this.#l){const S=this.#v;if(S.size){const m=new Map;for(const[d,j]of S)p[d]!==y&&m.set(p[d],j);this.#v=m}this.#y=null,this.#b++;return}switch(this.#t){case"float64":case"int32":case"dictionary":case"object":{const S=this.#a;for(let m=0;m<f;m++)p[m]!==y&&(S[p[m]]=S[m]);if(this.#t==="object")for(let m=w;m<f;m++)S[m]=void 0;break}case"bitset":{const S=this.#u;for(let m=0;m<f;m++)p[m]!==y&&S.assign(p[m],S.get(m)===1);for(let m=w;m<f;m++)S.clear(m);break}case"multi":this.#c.compact(p,w,y);break;default:break}if(this.#g){const S=this.#g;for(let m=0;m<f;m++)p[m]!==y&&S.assign(p[m],S.get(m)===1);for(let m=w;m<f;m++)S.clear(m)}this.#b++}}release(){this.#S||(this.#S=!0,this.#a=null,this.#u&&this.#u.release(),this.#u=null,this.#c&&this.#c.release(),this.#c=null,this.#g&&this.#g.release(),this.#g=null,this.#d=null,this.#h=null,this.#v=new Map,this.#y=null,this.#w=0,this.#b++)}#O(p){const f=Math.max(1,p);switch(this.#a=null,this.#u=null,this.#c=null,this.#t){case"float64":this.#a=new Float64Array(f);break;case"int32":this.#a=new Int32Array(f);break;case"bitset":this.#u=new Z(f);break;case"dictionary":this.#a=new Uint32Array(f),this.#d=this.#d??new U(this.#s??[]);break;case"multi":this.#c=new I({rows:f,values:f}),this.#d=this.#d??new U(this.#s??[]);break;default:this.#a=new Array(f);break}this.#t!=="dictionary"&&this.#t!=="multi"&&(this.#d=null),this.#r&&(this.#g?this.#g.grow(f):this.#g=new Z(f)),this.#w=f}#E(p,f){const w=i(f);switch(this.#r?this.#g.assign(p,!w):w&&M(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#t){case"float64":this.#a[p]=w?NaN:s(f);break;case"int32":this.#a[p]=w?0:r(f);break;case"bitset":this.#u.assign(p,!w&&!!f);break;case"dictionary":this.#a[p]=w?0:this.#d.codeOf(f);break;case"multi":{const S=o(f),m=new Array(S.length);for(let d=0;d<S.length;d++)m[d]=this.#d.codeOf(S[d]);this.#c.write(p,m);break}default:this.#a[p]=w?null:f;break}}#C(p){if(this.#v.has(p))return this.#v.get(p);const f=this.#o(this.#i.rowAt(p));return f===void 0?null:f}#T(){if(this.#y&&this.#y.version===this.#b)return this.#y;const p=this.#i.physical(),f=new Array(p),w=this.#r?new Z(p):null;for(let S=0;S<p;S++){const m=this.#C(S);f[S]=m,w&&!i(m)&&w.set(S)}return this.#y={version:this.#b,values:f,presence:w},this.#y}}class h{#e;#t=new Map;#n=[];#r=[];#o=0;#i=0;#s=0;#l=0;#a=new Z(0);#u=!1;#c=!0;#d;#h;#f;#m=!1;constructor(p,f={}){this.#e=Array.isArray(p)?p:[],this.#h=Math.max(1,f.initialCapacity??l),this.#c=f.retainSource!==!1,this.#d=this.#c?f.columnarBelow??u:0,this.#f=f.compactRatio??n;const w={rowAt:S=>this.#r[S],physical:()=>this.#o};for(const S of this.#e){if(!S||!S.id)continue;if(this.#t.has(S.id)){M(`store.dup.${S.id}`,`duplicate column id "${S.id}" in the store schema; ignoring the second`);continue}const m=new g(S,w);this.#t.set(S.id,m),this.#n.push(m)}this.#d<=0&&this.#w()}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.#m}get bytes(){let p=this.#a.bytes+this.#r.length*8;for(const f of this.#n)p+=f.bytes;return p}append(p){const f=this.#o;if(this.#m||!p)return{from:f,to:f};const w=p.length|0;if(w===0)return{from:f,to:f};if(this.#c)for(let m=0;m<w;m++)this.#r[f+m]=p[m];if(this.#o=f+w,this.#s+=w,this.#a.grow(this.#o),!this.#u){if(this.#o>=this.#d)this.#w();else for(const m of this.#n)m.touch();return{from:f,to:this.#o}}this.#p(this.#o);const S=this.#n;for(let m=0;m<S.length;m++)S[m].appendColumn(p,f,w);return{from:f,to:this.#o}}appendPacked(p,f){const w=this.#o;if(this.#m||!p)return{from:w,to:w};const S=p.count|0;if(S===0)return{from:w,to:w};if(this.#c&&f)for(let d=0;d<S;d++)this.#r[w+d]=f[d];this.#o=w+S,this.#s+=S,this.#a.grow(this.#o),this.#u||this.#w(),this.#p(this.#o);const m=new Map;for(const d of p.columns)m.set(d.id,d);for(const d of this.#n){const j=m.get(d.id);j?d.appendPacked(j,w,S):d.grow(this.#i)}return{from:w,to:this.#o}}source(p){if(this.#c)return this.#r[p];if(!(p<0||p>=this.#o))return this.#g(p)}setSource(p,f){this.#m||p<0||p>=this.#o||this.#c&&(this.#r[p]=f)}get(p,f){const w=this.#t.get(p);return w?w.get(f):void 0}set(p,f,w){if(this.#m||f<0||f>=this.#o)return;const S=this.#t.get(p);if(!S){M(`store.set.${p}`,`set() on unknown column "${p}"`);return}S.set(f,w)}remove(p){return this.#m||p<0||p>=this.#o||this.#a.get(p)===1?!1:(this.#a.set(p),this.#l++,this.#s--,!0)}live(p){return p<0||p>=this.#o?!1:this.#a.get(p)===0}compact(p={}){if(this.#m||this.#l===0||!p.force&&this.#l/this.#o<this.#f)return null;const f=this.#o,w=new Uint32Array(f);let S=0;for(let m=0;m<f;m++)w[m]=this.#a.get(m)===1?y:S++;for(const m of this.#n)m.compact(w,f,S);if(this.#c){const m=this.#r;for(let d=0;d<f;d++)w[d]!==y&&(m[w[d]]=m[d]);m.length=S}return this.#o=S,this.#s=S,this.#l=0,this.#a=new Z(Math.max(this.#i,S)),w}column(p){return this.#t.get(p)}columns(){return this.#n.slice()}liveIndices(){const p=new Uint32Array(this.#s);if(this.#l===0){for(let w=0;w<this.#o;w++)p[w]=w;return p}let f=0;for(let w=0;w<this.#o;w++)this.#a.get(w)===0&&(p[f++]=w);return p}convert(p,f){const w=this.#t.get(p);return w?w.convert(f):!1}destroy(){if(!this.#m){this.#m=!0;for(const p of this.#n)p.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}}#p(p){if(p<=this.#i)return;let f=this.#i||this.#h;for(;f<p;)f*=2;for(const w of this.#n)w.grow(f);this.#a.grow(f),this.#i=f}#g(p){const f={};for(const w of this.#n)f[w.id]=w.get(p);return f}#w(){if(this.#u)return;let p=this.#h;for(;p<this.#o;)p*=2;this.#u=!0,this.#i=p,this.#a.grow(p);for(const f of this.#n)f.columnarise(p,this.#o)}}}),Ae("packages/core/src/store/pool.js",function(e,G){"use strict";Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"sharedPool",{enumerable:!0,get:function(){return W}});const q=64,M=8;function $(V){let U=q;for(;U<V;)U*=2;return U}class N{#e=new Map;#t=new WeakSet;#n;#r=0;#o={acquired:0,reused:0,released:0};constructor(U={}){this.#n=U.limit??M}get bytes(){return this.#r}mask(U){const x=new Uint8Array(this.#i(U),0,U);return x.fill(0),x}indices(U){return new Uint32Array(this.#i(U*4),0,U)}release(U){if(!U||!U.buffer)return!1;const x=U.buffer;if(!this.#t.has(x))return!1;this.#t.delete(x),this.#o.released++;const I=x.byteLength;let v=this.#e.get(I);return v||this.#e.set(I,v=[]),v.length>=this.#n||(v.push(x),this.#r+=I),!0}releaseAll(U){for(const x of U)this.release(x)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#o,retained:this.#r}}#i(U){const x=$(U),I=this.#e.get(x);this.#o.acquired++;let v;return I&&I.length?(v=I.pop(),this.#r-=x,this.#o.reused++):v=new ArrayBuffer(x),this.#t.add(v),v}}function W(){return Z??=new N,Z}let Z=null}),Ae("packages/core/src/compute/sortspec.js",function(e,G){"use strict";Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return W}});function q(Z){return{locale:Z===void 0?void 0:String(Z),numeric:!0,sensitivity:"variant"}}function M(Z){return!!Z&&typeof Z.compare!="function"}function $(Z){if(!Z)return!0;for(let V=0;V<Z.length;V++)if(!M(Z[V]))return!1;return!0}function N(Z,V){const U=Z.col!==void 0?Z.col:Z.handle&&Z.handle.id,x=Z.locale!==void 0?Z.locale:V;return{col:U,descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,collation:q(x)}}function W(Z,V){const U=Z||[],x=new Array(U.length);for(let I=0;I<U.length;I++)x[I]=N(U[I],V);return x}}),Ae("packages/core/src/compute/facet.js",function(e,G){"use strict";Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"orderedReader",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"toNumeric",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const q=G("packages/core/src/compute/handle.js"),M=q.presenceReader,$=q.valueReader,N=q.dictSize,W=q.dictValue,Z=Object.freeze(["equal","quantile","log"]),V=Object.freeze(["hour","day","week","month","quarter","year"]),U=20,x=50,I=1e4;function v(m,d){if(!m)return"none";const j=d;if(j&&(j.multi===!0||typeof j.items=="function"))return"category";const E=d&&d.base;if(E==="date"||E==="datetime"||E==="time"||E==="dateString")return"date";switch(m.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return E==="number"?"numeric":E==="boolean"?"boolean":E==="text"?"category":"none"}}function k(m){const d=m.values,j=m.kind;if((j==="float64"||j==="int32")&&d)return O=>d[O];const E=$(m);return O=>y(E(O))}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 d=Number(m);if(Number.isFinite(d))return d;const j=Date.parse(m);return Number.isFinite(j)?j:NaN}return NaN}function l(m,d,j,E=x){if(!m)return{cardinality:0,exact:!0};if(m.dict)return{cardinality:N(m.dict),exact:!0};if(m.kind==="bitset")return{cardinality:2,exact:!0};const O=$(m),T=d?d.length:j,A=new Set;for(let P=0;P<T;P++){const L=O(d?d[P]:P);if(L!=null&&(A.add(L),A.size>E))return{cardinality:A.size,exact:!1}}return{cardinality:A.size,exact:!0}}const u=36e5,n=864e5;function t(m,d=U){const j=Number.isFinite(m)&&m>0?m:0,E=Math.max(1,d)*2;return j/u<=E?"hour":j/n<=E?"day":j/(7*n)<=E?"week":j/(30*n)<=E?"month":j/(91*n)<=E?"quarter":"year"}function i(m,d){if(!Number.isFinite(m))return NaN;const j=new Date(m);switch(d){case"hour":return j.setMinutes(0,0,0),j.getTime();case"day":return j.setHours(0,0,0,0),j.getTime();case"week":{j.setHours(0,0,0,0);const E=(j.getDay()+6)%7;return j.setDate(j.getDate()-E),j.getTime()}case"month":return j.setDate(1),j.setHours(0,0,0,0),j.getTime();case"quarter":return j.setMonth(Math.floor(j.getMonth()/3)*3,1),j.setHours(0,0,0,0),j.getTime();default:return j.setMonth(0,1),j.setHours(0,0,0,0),j.getTime()}}function s(m,d){const j=new Date(m);switch(d){case"hour":j.setHours(j.getHours()+1);break;case"day":j.setDate(j.getDate()+1);break;case"week":j.setDate(j.getDate()+7);break;case"month":j.setMonth(j.getMonth()+1);break;case"quarter":j.setMonth(j.getMonth()+3);break;default:j.setFullYear(j.getFullYear()+1);break}return j.getTime()}function r(m,d,j){const E=k(m),O=M(m),T=d?d.length:j;let A=1/0,P=-1/0,L=0,z=0;for(let H=0;H<T;H++){const D=d?d[H]:H;if(O&&!O(D)){L++;continue}const F=E(D);if(!Number.isFinite(F)){L++;continue}F<A&&(A=F),F>P&&(P=F),z++}return{min:A,max:P,nulls:L,finite:z}}function o(m,d,j,E){const O=k(m),T=M(m),A=d?d.length:j,P=A>E?A/E:1,L=[];for(let H=0;H<A;H+=P){const D=d?d[Math.floor(H)]:Math.floor(H);if(T&&!T(D))continue;const F=O(D);Number.isFinite(F)&&L.push(F)}const z=Float64Array.from(L);return z.sort(),z}function c(m,d,j,E={}){const O=E.kind||v(m,E.type);return O==="none"||!m?{kind:"none",buckets:[],suppressed:"type"}:O==="boolean"?a(m,d,j):O==="category"?g(m,d,j,E):h(m,d,j,O,E)}function a(m,d,j){const E=M(m);let O=0;if(E){const A=d?d.length:j;for(let P=0;P<A;P++)E(d?d[P]:P)||O++}const T=[{value:!1,label:"false"},{value:!0,label:"true"}];return O>0&&T.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:T}}function g(m,d,j,E){const O=E.cardinalityLimit??x,{cardinality:T}=l(m,d,j,O);if(T>O&&(E.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:T};const A=$(m),P=d?d.length:j,L=new Map;let z=0;for(let B=0;B<P;B++){const _=A(d?d[B]:B);if(_==null||_===""){z++;continue}if(Array.isArray(_)){if(!_.length){z++;continue}for(const Q of _)L.set(Q,(L.get(Q)||0)+1);continue}L.set(_,(L.get(_)||0)+1)}let H=[...L.entries()];E.order==="alpha"?H.sort((B,_)=>String(B[0]).localeCompare(String(_[0]))):H.sort((B,_)=>_[1]-B[1]);let D=0,F=0;if(H.length>O){F=H.length-O;for(let B=O;B<H.length;B++)D+=H[B][1];H=H.slice(0,O)}const C=H.map(([B])=>({value:B,label:String(B)}));return D>0&&C.push({remainder:!0,label:`Other (${F} values)`}),z>0&&C.push({null:!0,label:"Empty"}),{kind:"category",buckets:C,cardinality:T}}function h(m,d,j,E,O){const{min:T,max:A,nulls:P,finite:L}=r(m,d,j);if(!L)return{kind:E,buckets:P?[{null:!0,label:"Empty"}]:[],empty:!0};const z=Math.max(1,Math.floor(O.buckets||U));let H=[];if(E==="date"){const F=V.includes(O.granularity)?O.granularity:t(A-T,z);let C=i(T,F);for(;C<=A&&H.length<4096;){const B=s(C,F);if(!(B>C))break;H.push({from:C,to:B}),C=B}return{kind:E,buckets:b(H,P),granularity:F}}const D=Z.includes(O.strategy)?O.strategy:"equal";if(D==="quantile"){const F=o(m,d,j,I);if(F.length){const C=[F[0]];for(let B=1;B<z;B++){const _=F[Math.min(F.length-1,Math.floor(B/z*F.length))];_>C[C.length-1]&&C.push(_)}C.push(A);for(let B=0;B<C.length-1;B++)H.push({from:C[B],to:C[B+1]})}}else if(D==="log"&&T>0){const F=Math.log10(T),B=(Math.log10(A)-F)/z||1;for(let _=0;_<z;_++)H.push({from:10**(F+_*B),to:10**(F+(_+1)*B)})}if(!H.length){const F=(A-T)/z||1;for(let C=0;C<z;C++)H.push({from:T+C*F,to:T+(C+1)*F})}return H[H.length-1].to=A,{kind:E,buckets:b(H,P),strategy:D,min:T,max:A}}function b(m,d){return d>0?[...m,{null:!0,label:"Empty"}]:m}function p(m,d,j,E,O){const T=E&&E.buckets||[],A=O&&O.length>=T.length?O.subarray(0,T.length):new Uint32Array(T.length);if(A.fill(0),!m||!T.length)return A;const P=T.length-1,L=!!T[P]&&T[P].null===!0,z=d?d.length:j;if(E.kind==="boolean"){const B=$(m);for(let _=0;_<z;_++){const Q=B(d?d[_]:_);if(Q==null){L&&A[P]++;continue}A[Q?1:0]++}return A}if(E.kind==="category"){const B=new Map;for(let Y=0;Y<T.length;Y++)!T[Y].null&&!T[Y].remainder&&B.set(T[Y].value,Y);const _=T.findIndex(Y=>Y.remainder),Q=$(m);for(let Y=0;Y<z;Y++){const J=Q(d?d[Y]:Y);if(J==null||J===""){L&&A[P]++;continue}if(Array.isArray(J)){if(!J.length){L&&A[P]++;continue}for(const ee of J){const oe=B.get(ee);oe!==void 0?A[oe]++:_>=0&&A[_]++}continue}const te=B.get(J);te!==void 0?A[te]++:_>=0&&A[_]++}return A}const H=L?T.length-1:T.length,D=new Float64Array(H+1);for(let B=0;B<H;B++)D[B]=T[B].from;D[H]=H?T[H-1].to:0;const F=k(m),C=M(m);for(let B=0;B<z;B++){const _=d?d[B]:B;if(C&&!C(_)){L&&A[P]++;continue}const Q=F(_);if(!Number.isFinite(Q)){L&&A[P]++;continue}const Y=f(D,H,Q);Y>=0&&A[Y]++}return A}function f(m,d,j){if(!d||j<m[0])return-1;if(j>=m[d])return j===m[d]?d-1:-1;let E=0,O=d-1;for(;E<O;){const T=E+O+1>>>1;j>=m[T]?E=T:O=T-1}return E}function w(m,d,j,E={}){const O=E.bounds||c(m,E.boundsIndices??d,j,E);return{bounds:O,counts:p(m,d,j,O)}}const S=w}),Ae("packages/core/src/compute/pivotmatrix.js",function(e,G){"use strict";Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return i}});const M=G("packages/core/src/compute/handle.js").valueComparator,N=G("packages/core/src/compute/total.js").total,Z=G("packages/core/src/compute/group.js").packKeys,V=G("packages/core/src/compute/pivot.js"),U=V.joinPath,x=V.DEFAULT_PATH_SEPARATOR,I=V.DEFAULT_MAX_COLUMNS,v="";function k(s,r,o={}){const c=o.separator||x,a=s||[],g=r instanceof Uint32Array?r:Uint32Array.from(r||[]),h=g.length;if(a.length===0)return{tuples:[[]],paths:[v],buckets:[g]};const{keyOf:b,readers:p}=Z(a,g,0),f=new Map,w=[],S=[],m=[];for(let A=0;A<h;A++){const P=g[A],L=b(P);let z=f.get(L);if(z===void 0){z=w.length,f.set(L,z),S.push(L);const H=new Array(p.length);for(let D=0;D<p.length;D++)H[D]=p[D](P);w.push(H),m.push([])}m[z].push(P)}const d=M(o.locale),j=w.map((A,P)=>P);j.sort((A,P)=>{const L=w[A],z=w[P];for(let H=0;H<L.length;H++){const D=y(L[H],z[H],d);if(D!==0)return D}return A-P});const E=new Array(j.length),O=new Array(j.length),T=new Array(j.length);for(let A=0;A<j.length;A++){const P=j[A];E[A]=w[P],O[A]=U(w[P],c),T[A]=Uint32Array.from(m[P])}return{tuples:E,paths:O,buckets:T}}function y(s,r,o){const c=s==null,a=r==null;return c||a?c&&a?0:c?1:-1:o(s,r)}function l(s,r,o){const c=[];for(let a=0;a<s.length;a++)o.has(s[a])&&c.push(s[a]);return Uint32Array.from(c)}function u(s,r,o,c){return{value:r.length?N(s,r,o,c):null,leaves:r,count:r.length}}function n(s){const r=s&&s.opts||{},o=r.separator||x,c=r.totalContext||{locale:r.locale},a=(s.measures||[]).filter(O=>O&&O.handle),g=s.leaves instanceof Uint32Array?s.leaves:Uint32Array.from(s.leaves||[]),h=k(s.rowHandles||[],g,{...r,separator:o}),b=k(s.columnHandles||[],g,{...r,separator:o}),p=r.maxColumns===void 0?I:r.maxColumns,f=b.paths.length*Math.max(1,a.length),w=new Map;if(p&&f>p)return{rowAxis:h,columnAxis:b,measures:a.map(O=>({colId:O.colId,fn:O.fn})),body:w,rowMargin:w,columnMargin:w,grand:w,columns:f,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${f} columns, above pivot.maxColumns of ${p}. Narrow the pivot columns or raise the limit.`,columns:f,maxColumns:p}};const S=new Map,m=new Map,d=new Map,j=new Map,E=b.buckets.map(O=>new Set(O));for(let O=0;O<b.paths.length;O++){const T=b.buckets[O],A=b.paths[O];for(const P of a)d.set(i(A,P.colId),u(P.handle,T,P.fn,c))}for(let O=0;O<h.paths.length;O++){const T=h.buckets[O],A=h.paths[O];for(const P of a)m.set(i(A,P.colId),u(P.handle,T,P.fn,c));for(let P=0;P<b.paths.length;P++){const L=l(T,b.buckets[P],E[P]);if(L.length===0)continue;const z=b.paths[P];for(const H of a)S.set(t(A,z,H.colId),u(H.handle,L,H.fn,c))}}for(const O of a)j.set(O.colId,u(O.handle,g,O.fn,c));return{rowAxis:h,columnAxis:b,measures:a.map(O=>({colId:O.colId,fn:O.fn})),body:S,rowMargin:m,columnMargin:d,grand:j,columns:f,error:null}}function t(s,r,o){return`${s}\0${r}\0${o}`}function i(s,r){return`${s}\0${r}`}}),Ae("packages/core/src/compute/reference.js",function(e,G){"use strict";Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return I}}),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 u}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return n}});const M=G("packages/core/src/internal/util.js").getPath,$=G("packages/core/src/compute/handle.js"),N=$.isMissing,W=$.valueComparator,V=G("packages/core/src/compute/filter.js").testValue,U="",x="\0";function I(s,r){const o=r.includes(".")?M(s,r):s?.[r];return o===void 0?null:o}function v(s,r,o={}){const c=r||[];let a=s.map((g,h)=>h);if(c.length===0)return a;for(let g=c.length-1;g>=0;g--)a=k(s,a,c[g],o);return a}function k(s,r,o,c){const a=o.locale!==void 0?o.locale:c.locale,g=W(a),h=o.descending!==void 0?!!o.descending:o.dir==="desc",b=[],p=[];for(const S of r){const m=I(s[S],o.col);N(m)?p.push(S):b.push(S)}const f=new Map;for(let S=0;S<b.length;S++)f.set(b[S],S);const w=(S,m)=>{const d=I(s[S],o.col),j=I(s[m],o.col);let E;return typeof o.compare=="function"?(E=o.compare(d,j,s[S],s[m],h),h&&(E=-E)):E=h?g(j,d):g(d,j),E!==0?E:f.get(S)-f.get(m)};return b.sort(w),o.nullsFirst?p.concat(b):b.concat(p)}function y(s,r,o={}){const c=[];for(let a=0;a<s.length;a++)l(s[a],r,o,a)&&c.push(a);return c}function l(s,r,o,c){if(!r)return!0;if(Array.isArray(r.conditions)){const a=r.conditions.filter(h=>h!=null);if(a.length===0)return!0;if(r.op==="or")return a.some(h=>l(s,h,o,c));const g=a.every(h=>l(s,h,o,c));return r.op==="not"?!g:g}return r.col===void 0&&typeof o.custom=="function"?!!o.custom(r,s,c):V(I(s,r.col),r,o.locale)}function u(s,r,o,c){const a=o||s.map((p,f)=>f),g=new Map,h=[],b=[];for(const p of a){const f=r.map((m,d)=>{const j=I(s[p],m);return c&&c[d]?c[d](j):j}),w=f.map(m=>m==null?x:String(m)).join(U);let S=g.get(w);S===void 0&&(S=h.length,g.set(w,S),h.push(f),b.push([])),b[S].push(p)}return{keys:h,buckets:b}}function n(s,r,o={}){const c=W(o.locale),a=s.filter(h=>!N(h)),g=a.map(t).filter(h=>h!==null);switch(r){case"count":return s.length;case"countValues":return a.length;case"sum":return g.reduce((h,b)=>h+b,0);case"avg":return a.length===0?null:g.reduce((h,b)=>h+b,0)/a.length;case"min":return a.length===0?null:a.reduce((h,b)=>c(b,h)<0?b:h);case"max":return a.length===0?null:a.reduce((h,b)=>c(b,h)>0?b:h);case"first":return s.length===0?null:i(s[0]);case"last":return s.length===0?null:i(s[s.length-1]);default:return null}}function t(s){if(typeof s=="number")return Number.isNaN(s)?null:s;if(s==null||s===""||typeof s=="boolean")return null;if(s instanceof Date)return s.getTime();const r=Number(s);return Number.isNaN(r)?null:r}function i(s){return s===void 0?null:s}}),Ae("packages/core/src/compute/index.js",function(e,G){"use strict";const q=G("packages/core/src/compute/sort.js");Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return q.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return q.sortMulti}}),Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return q.radixSortFloat64}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return q.radixSortInt32}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return q.rankSortDictionary}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return q.mergeSortComparator}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return q.collateStringRanks}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return q.rankSortStrings}});const M=G("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return M.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return M.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return M.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return M.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return M.describeSort}});const $=G("packages/core/src/compute/filter.js");Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return $.evaluateFilters}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return $.evaluateCondition}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return $.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return $.testValue}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return $.compilePredicate}}),Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return $.releaseMask}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return $.pruneColumn}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return $.mentionsColumn}});const N=G("packages/core/src/compute/group.js");Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return N.groupByColumns}}),Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return N.packKeys}});const W=G("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 Z=G("packages/core/src/compute/total.js");Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return Z.TOTAL_FNS}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return Z.TOTAL_LABELS}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return Z.totalLabel}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return Z.total}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return Z.collectValues}});const V=G("packages/core/src/compute/pivot.js");Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return V.pivot}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return V.resolvePivotKeys}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return V.pivotKey}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return V.joinPath}}),Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return V.KEY_DELIMITER}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return V.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return V.DEFAULT_MAX_COLUMNS}});const U=G("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return U.pivotMatrix}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return U.resolveAxis}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return U.cellKey}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return U.marginKey}}),Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return U.GRAND_PATH}});const x=G("packages/core/src/compute/reference.js");Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return x.referenceSort}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return x.referenceFilter}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return x.referenceGroup}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return x.referenceTotal}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return x.referencePasses}}),Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return x.referenceValue}});const I=G("packages/core/src/compute/handle.js");Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return I.identity}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return I.rowCount}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return I.presenceReader}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return I.bitReader}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return I.valueReader}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return I.valueComparator}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return I.numericTotalOrder}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return I.dictRanks}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return I.dictSize}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return I.dictValue}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return I.multiValue}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return I.isMissing}});const v=G("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 k=G("packages/core/src/compute/windowed.js");Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return k.Window}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return k.WINDOW_KINDS}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return k.openWindow}});const y=G("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=G("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 u=G("packages/core/src/compute/forecast.js");Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return u.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return u.forecast}})}),Ae("packages/core/src/source/rows.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_ROW_HEIGHT",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"KEY_SEP",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"createRowFactory",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"RowFactory",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"pinnedRow",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"lazyRowView",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"groupPathElement",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"groupKey",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"groupPrefixKeys",{enumerable:!0,get:function(){return l}});const q=G("packages/core/src/internal/util.js"),M=q.warnOnce,$=q.isFunction,N=32,W="\0";function Z(u){return new V(u)}class V{#e;#t;constructor(n){this.#e=$(n&&n.rowKey)?n.rowKey:null;const t=n&&n.config?n.config.rowHeight:void 0;this.#t=typeof t=="number"||$(t)?t:N}get keyed(){return this.#e!==null}keyOf(n,t){if(this.#e){const i=this.#e(n);if(i!=null)return String(i)}else M("source.rowKey.missing","no config.rowKey; falling back to index identity.","Row changes, streaming dedupe, selection persistence and remote reload are disabled.");return`#${t}`}heightOf(n){return $(this.#t)?Number(this.#t(n))||N:this.#t}leaf(n,t,i=0,s=null){const r={key:this.keyOf(n,t),data:n,level:i,parent:s,group:!1,expanded:!1,leafCount:1,height:0,index:null,selected:!1,physical:t};return r.height=this.heightOf(r),r}group(n){const t={key:y(n.keyPath||n.path),data:null,level:n.level,parent:n.parent||null,children:[],group:!0,expanded:n.expanded!==!1,leafCount:n.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:n.column,groupValue:n.value,groupPath:n.path,hasChildren:n.hasChildren!==!1};return n.totals&&(t.totals=n.totals),t.height=this.heightOf(t),t}footer(n){const t={key:`${n.key}${W}footer`,data:null,level:n.level,parent:n,group:!0,footer:!0,expanded:!1,leafCount:n.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:n.groupColumn,groupValue:n.groupValue,groupPath:n.groupPath,hasChildren:!1,totals:n.totals};return t.height=this.heightOf(t),t}detail(n,t){return{key:`${n.key}${W}detail`,data:n.data,level:n.level+1,parent:n,group:!1,detail:!0,expanded:!1,leafCount:0,height:t,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:n.key}}grandTotal(n,t){const i={key:`${W}grandTotal`,data:null,level:0,parent:null,group:!0,grandTotal:!0,expanded:!1,leafCount:t,height:0,index:null,selected:!1,physical:null,groupPath:[],hasChildren:!1,totals:n};return i.height=this.heightOf(i),i}skeleton(n,t=0){const i={key:`${W}pending${W}${n}`,data:null,level:t,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:n,selected:!1,physical:null};return i.height=this.heightOf(i),i}}function U(u,n,t,i){return{key:`${W}pinned${W}${t}${W}${n}`,data:u,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:i,index:null,selected:!1,physical:null,hasChildren:!1,pinned:t}}function x(u,n){return new Proxy([],{get(t,i,s){if(i==="length")return u();if(typeof i=="string"){const r=Number(i);if(Number.isInteger(r)&&r>=0)return n(r)}return Reflect.get(t,i,s)},has(t,i){if(typeof i=="string"){const s=Number(i);if(Number.isInteger(s)&&s>=0)return s<u()}return Reflect.has(t,i)}})}function I(u){return u==null?"":String(u)}const v="";function k(u){if(u==null)return v;const n=String(u);return n.startsWith(v)?v+n:n}function y(u){const n=u||[];let t="g";for(let i=0;i<n.length;i++)t+=W+k(n[i]);return t}function l(u){const n=new Array(u.length),t=[];for(let i=0;i<u.length;i++)t.push(u[i]),n[i]=y(t);return n}}),Ae("packages/core/src/source/handles.js",function(e,G){"use strict";Object.defineProperty(e,"HandleProvider",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"createHandleProvider",{enumerable:!0,get:function(){return W}});const q=G("packages/core/src/internal/util.js"),M=q.isFunction,$=q.warnOnce;class N{#e;#t;#n;#r=new Map;#o=0;constructor(V,U,x){this.#e=V,this.#t=U,this.#n=M(x)?x:()=>!1}get store(){const V=this.#e.store;return V&&M(V.column)?V:null}invalidate(){this.#o++}handle(V){const U=this.store;if(U){const k=U.column(V);if(k)return k}const x=this.#r.get(V);if(x&&x.builtAt===this.#o)return x.handle;const I=this.#i(V);if(!I)return;if(U&&this.#n()){$(`source.dropped.${V}`,`column "${V}" 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(I);return this.#r.set(V,{handle:v,builtAt:this.#o}),v}#i(V){const U=this.#e.columns;return U&&M(U.get)?U.get(V):void 0}#s(V){const U=this.#t()||[],x=U.length,I=new Array(x),v=M(V.getValue)?y=>V.getValue(y):y=>y?.[V.field||V.id];for(let y=0;y<x;y++)I[y]=U[y]===void 0?void 0:v(U[y]);const k=this.#o;return{id:V.id,kind:"object",nullable:!1,values:I,presence:null,dict:null,offsets:null,get(y){return I[y]},version:k}}}function W(Z,V,U){return new N(Z,V,U)}}),Ae("packages/core/src/compute/incremental.js",function(e,G){"use strict";Object.defineProperty(e,"INCREMENTAL_FNS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"INCREMENTAL_KINDS",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"MAGNITUDE_LIMIT",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"isIncremental",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"RunningTotal",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return x}});const M=G("packages/core/src/store/columnstore.js").toFloat,$=Object.freeze(["sum","avg","countValues","min","max"]),N=Object.freeze(["float64"]),W=1e15;function Z(I,v){return typeof I!="string"||!$.includes(I)?!1:!!v&&N.includes(v.kind)}function V(I){if(I==null)return null;const v=M(I);return Number.isNaN(v)?null:v}class U{#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 k=0;k<v.length;k++){const y=V(v[k]);y!==null&&this.#u(y)}this.#s=!0}seedColumn(v,k,y){this.#a();for(let l=0;l<y.length;l++){const u=y[l];if(k&&k(u)===0)continue;const n=v[u];Number.isNaN(n)||this.#u(n)}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 k=this.#t+v;this.#n+=Math.abs(this.#t)>=Math.abs(v)?this.#t-k+v:v-k+this.#t,this.#t=k,this.#r++,v<this.#o&&(this.#o=v),v>this.#i&&(this.#i=v)}#c(v){const k=this.#t-v;this.#n+=Math.abs(this.#t)>=Math.abs(v)?this.#t-k-v:-v-k+this.#t,this.#t=k,this.#r--}update(v,k){if(!this.#s)return!1;const y=V(v),l=V(k);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 x=U}),Ae("packages/core/src/source/filterwire.js",function(e,G){"use strict";Object.defineProperty(e,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"warnWherePageRelative",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"warnWhereNotApplied",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"warnWhereOverThreshold",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"parseRelativeToken",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"resolveRelativeRange",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"relativeTokenOf",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"relativeTokenHelp",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isResolvableRelative",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"resolveRelativeCondition",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"isGroup",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"forEachCondition",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"mapConditions",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"normaliseFilterSet",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"buildFilterSet",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"wireFilters",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"querySignature",{enumerable:!0,get:function(){return d}});const M=G("packages/core/src/internal/util.js").warnOnce,$="source.remote.hostFilter",N="source.where.pageRelative";function W(O,T){!Array.isArray(O)||!O.length||M(N,`filters.where (${O.join(", ")}) runs over the rows the ${T} source fetched,`,"not the whole dataset: match counts and totals are page-relative.","Give the predicate a { condition } twin so the engine can narrow the fetch itself.")}function Z(O){const T=(O||{}).config;!T||!T.hostFilter||M($,"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 V="source.where.notApplied";function U(O,T){M(`${V}:${O}`,`filters.where("${O}") is registered but the ${T} source holds only its fetched window`,"and cannot run the predicate over it: the predicate is not applied there, and rows it would","exclude stay on screen.","Give it a { condition } twin so the engine can narrow the fetch itself — that is the","supported route for a paged or remote source.")}const x="source.where.overThreshold";function I(O,T,A,P){!Array.isArray(O)||!O.length||M(`${x}:${T}`,`filters.where (${O.join(", ")}) is not applied to the ${T} pushdown source:`,A===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${A.toLocaleString()} rows, at or past the whereRowLimit of ${P.toLocaleString()}.`,"Running the predicate needs every matching row fetched and held here, which is the whole","download a pushdown source exists to avoid, so it is refused and the rows the predicate","would exclude stay on screen.","Give the predicate a { condition } twin so the engine narrows the fetch itself — that is the","route that works at any size — or raise `whereRowLimit` on the source config if you want the","download.")}const v=new Map;function k(O){let T=v.get(O);return T||(T=new Intl.DateTimeFormat("en-US",{timeZone:O,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),v.set(O,T)),T}function y(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function l(O,T){const A=k(T).formatToParts(new Date(O)),P={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const L of A)L.type==="year"?P.y=+L.value:L.type==="month"?P.m=+L.value:L.type==="day"?P.d=+L.value:L.type==="hour"?P.h=+L.value%24:L.type==="minute"?P.mi=+L.value:L.type==="second"&&(P.s=+L.value);return P}function u(O,T){const A=l(O,T);return Date.UTC(A.y,A.m-1,A.d,A.h,A.mi,A.s)-Math.floor(O/1e3)*1e3}function n(O,T,A,P){const L=Date.UTC(O,T-1,A),z=L-u(L,P);return L-u(z,P)}function t(O,T,A){const P=new Date(Date.UTC(O.y,O.m-1,O.d+T));return n(P.getUTCFullYear(),P.getUTCMonth()+1,P.getUTCDate(),A)}const i=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function s(O,T){if(typeof O!="string")return null;const A=O.trim().toLowerCase().replace(/[\s_-]+/g,""),P=/^last(\d*|n)days?$/.exec(A);if(P){const L=P[1]==="n"?"":P[1],z=Number(L||T);return!Number.isFinite(z)||z<=0?null:{kind:"lastNDays",n:Math.floor(z)}}switch(A){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 r(O,T={}){const A=s(O,T.n);if(!A)return null;const P=T.tz||y(),L=T.now instanceof Date?T.now.getTime():typeof T.now=="number"?T.now:Date.now(),z=l(L,P),H=n(z.y,z.m,z.d,P),D=t(z,1,P);let F=H,C=D;switch(A.kind){case"today":break;case"yesterday":F=t(z,-1,P),C=H;break;case"lastNDays":C=T.includeToday?D:H,F=t(z,T.includeToday?-(A.n-1):-A.n,P);break;case"thisWeek":{const B=Number.isFinite(T.weekStartsOn)?Number(T.weekStartsOn):1,Q=(new Date(Date.UTC(z.y,z.m-1,z.d)).getUTCDay()-B+7)%7;F=t(z,-Q,P),C=t(z,-Q+7,P);break}case"thisMonth":F=n(z.y,z.m,1,P),C=n(z.m===12?z.y+1:z.y,z.m===12?1:z.m+1,1,P);break;case"thisQuarter":case"quarterToDate":{const B=Math.floor((z.m-1)/3)*3+1;F=n(z.y,B,1,P),C=A.kind==="quarterToDate"?D:B===10?n(z.y+1,1,1,P):n(z.y,B+3,1,P);break}case"thisYear":case"yearToDate":F=n(z.y,1,1,P),C=A.kind==="yearToDate"?D:n(z.y+1,1,1,P);break;default:return null}return{from:new Date(F).toISOString(),to:new Date(C).toISOString(),bounds:"[)",tz:P,relative:A.kind==="lastNDays"?`last${A.n}Days`:A.kind,n:A.n}}function o(O){if(!O||typeof O!="object")return null;const T=O.value;if(T&&typeof T=="object"&&!Array.isArray(T)&&"relative"in T)return{token:String(T.relative),n:typeof T.n=="number"?T.n:void 0};if(O.op==="relative"&&typeof O.value=="string")return{token:O.value,n:void 0};const A=O.meta;return A&&typeof A.relative=="string"&&O.value===void 0?{token:A.relative,n:typeof A.n=="number"?A.n:void 0}:null}function c(){return`Known tokens: ${i.filter(T=>T!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function a(O){const T=o(O);return T?s(T.token,T.n)!==null:!1}function g(O,T={}){const A=o(O);if(!A)return O;const P=r(A.token,{...T,n:A.n});return P?{...O,type:O.type||"date",op:"between",value:[P.from,P.to],bounds:O.bounds||P.bounds,meta:{...O.meta||{},relative:P.relative,tz:P.tz}}:(M(`source.relative.${A.token}`,`unknown relative date token "${A.token}"; sending the condition unresolved.`,c()),O)}function h(O){return!!O&&typeof O=="object"&&Array.isArray(O.conditions)}function b(O,T){if(O){if(h(O)){for(const A of O.conditions)b(A,T);return}T(O)}}function p(O,T){if(!O)return null;if(!h(O))return T(O);const A=O;let P=!1;const L=[];for(const z of A.conditions){const H=p(z,T);H!==z&&(P=!0),H&&L.push(H)}return!P&&L.length===A.conditions.length?O:L.length?{...A,conditions:L}:null}function f(O){if(!O)return null;if(!h(O))return O;const T=O,A=[];for(const P of T.conditions){const L=f(P);L&&A.push(L)}return A.length?{op:T.op,conditions:A}:null}function w(O){const T=f(O);return T?h(T)&&T.op==="and"?T:{op:"and",conditions:[T]}:null}function S(O){const T=(O||[]).filter(Boolean);return T.length?{op:"and",conditions:T}:null}function m(O,T={}){const A=p(O,P=>g(P,T));return w(A)}function d(O){const T=j(O.filters??null);return JSON.stringify([T,O.sort??null,O.quick??"",O.groupBy??null,O.pivotBy??null,E(O.context)])}function j(O){if(!O)return null;if(h(O)){const P=O;return{op:P.op,conditions:P.conditions.map(j)}}const T=O,A=T.meta&&typeof T.meta.relative=="string"?T.meta.relative:o(T)?.token;return{col:T.col,op:T.op,bounds:T.bounds??null,caseSensitive:T.caseSensitive??!1,value:A?`rel:${A}`:T.value??null}}function E(O){if(O==null)return null;try{return JSON.parse(JSON.stringify(O))}catch{return M("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),Ae("packages/core/src/source/tree.js",function(e,G){"use strict";Object.defineProperty(e,"SYNTHETIC",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"buildFromPath",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"buildFromParentKey",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"assignLevels",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"resolveTree",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"buildTree",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return y}});const q=G("packages/core/src/internal/util.js"),M=q.isFunction,$=q.warnOnce,N="",W="\0tree:";function Z(l,u){return{physical:l,key:u,level:0,children:[],value:void 0}}function V(l,u){const n=[],t=new Map;for(let i=0;i<l.length;i++){const s=l[i],r=u.pathOf(s),o=Array.isArray(r)?r.map(a=>String(a)):[];if(!o.length){const a=Z(s,u.keyOf(s));n.push(a);continue}let c=null;for(let a=0;a<o.length;a++){const g=o.slice(0,a+1).join(N),h=a===o.length-1;let b=t.get(g);b&&h&&b.physical===-1&&(b.physical=s,b.key=u.keyOf(s)),b||(b=Z(h?s:-1,h?u.keyOf(s):W+g),b.level=a,b.value=o[a],t.set(g,b),c?c.children.push(b):n.push(b)),c=b}}return{roots:n,nodes:t}}function U(l,u){const n=new Map,t=[];for(let o=0;o<l.length;o++){const c=l[o],a=u.keyOf(c),g=Z(c,a);n.set(a,g);const h=u.parentOf(c);h!=null&&h!==""&&t.push({node:g,parent:String(h)})}let i=null;const s=new Map;for(const{node:o,parent:c}of t){const a=n.get(c);if(a){s.set(o.key,a);continue}u.orphans&&u.orphans!=="root"&&(i||(i=Z(-1,`${W}orphans`),i.value=u.orphans),s.set(o.key,i))}const r=[];for(const o of n.values()){const c=s.get(o.key);c?c.children.push(o):r.push(o)}return i&&i.children.length&&r.push(i),{roots:x(r,n,u.orphans,i),nodes:n}}function x(l,u,n,t){const i=new Set,s=[...l];for(;s.length;){const g=s.pop();if(!i.has(g.key)){i.add(g.key);for(const h of g.children)s.push(h)}}const r=[];for(const g of u.values())i.has(g.key)||r.push(g);if(!r.length)return l;const o=!!n&&n!=="root";$("tree.cycle",`tree.parentKey produced ${r.length} row(s) inside a parent cycle; `+(o?`they are shown under "${n}".`:"they are shown at the root."));for(const g of r)g.children=g.children.filter(h=>i.has(h.key));if(!o)return[...l,...r];let c=t;const a=[...l];return c||(c=Z(-1,`${W}orphans`),c.value=n,a.push(c)),c.children.push(...r),a}function I(l){let u=0;const n=(t,i)=>{for(const s of t)s.level=i,i>u&&(u=i),s.children.length&&n(s.children,i+1)};return n(l,0),u}function v(l,u){if(!l||typeof l!="object")return null;const n=l.path,t=l.parentKey,i=M(l.hasChildren)?s=>!!l.hasChildren(u.dataAt(s)):null;if(M(n))return{mode:"path",pathOf:s=>n(u.dataAt(s)),keyOf:u.keyOf,declaresChildren:i};if(t!=null){const s=M(t)?t:r=>r?.[t];return{mode:"parentKey",parentOf:r=>s(u.dataAt(r)),keyOf:u.keyOf,orphans:l.orphans||"root",declaresChildren:i}}return $("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function k(l,u){const n=u.mode==="path"?V(l,u):U(l,u),t=I(n.roots);return{...n,depth:t}}function y(l,u){const n=new Map,t=i=>{for(let s=0;s<i.length;s++){const r=i[s];if(r.physical>=0){const o=u?u(r.physical):!1,c=o&&r.children.length===0;n.set(r.physical,{level:r.level,posinset:s+1,setsize:i.length,hasChildren:r.children.length>0||o,lazy:c})}r.children.length&&t(r.children)}};return t(l),n}}),Ae("packages/core/src/source/memory.js",function(e,G){"use strict";Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"quickMatcher",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"MemorySource",{enumerable:!0,get:function(){return D}});const q=G("packages/core/src/internal/util.js"),M=q.Lru,$=q.warnOnce,N=q.fail,W=q.isFunction,Z=q.defaultCompare,V=q.mergeRow,U=G("packages/core/src/source/rows.js"),x=U.createRowFactory,I=U.groupKey,v=U.groupPathElement,k=U.groupPrefixKeys,y=U.lazyRowView,u=G("packages/core/src/source/handles.js").createHandleProvider,n=G("packages/core/src/compute/incremental.js"),t=n.RunningTotal,i=n.isIncremental,r=G("packages/core/src/compute/handle.js").presenceReader,o=G("packages/core/src/source/filterwire.js"),c=o.querySignature,a=o.mapConditions,g=o.resolveRelativeCondition,h=G("packages/core/src/source/tree.js"),b=h.buildTree,p=h.resolveTree,f=h.indexTree,w=Object.freeze(["filter","sort","group","total","pivot","flatten"]),S=Object.freeze(["pipeline:sort","pipeline:sort:error"]);function m(F){const C=F&&typeof F=="object"?F.reason:null;return typeof C=="string"&&S.includes(C)}const d=Object.freeze([]);function j(F,C){if(!F)return null;const B=C==="grand"?F.grandTotal:F.groupTotal;return B??F.total}function E(F){return!!F&&!F.running}function O(F){if(F)return F.value&&W(F.value.compare)?F.value.compare:W(F.compare)?F.compare:void 0}function T(F){const C=F&&F.dataType;return!C||!W(C.items)?null:{items:C.items,type:F.itemType&&F.itemType.name||"text"}}function A(F){return!!F&&(typeof F=="object"||typeof F=="function")&&W(F.then)}const P=new Uint32Array(0),L=4096;function z(F,C){return new D(F,C)}function H(F,C){if(C==="regex")try{const B=new RegExp(F,"iu");return _=>B.test(_)}catch{return B=>B.includes(F)}if(C==="fuzzy"){const B=[...F].filter(_=>_!==" ");return B.length?_=>{let Q=0;for(let Y=0;Y<_.length&&Q<B.length;Y++)_[Y]===B[Q]&&Q++;return Q===B.length}:()=>!0}if(C==="words"){const B=F.split(/\s+/).filter(Boolean);return B.length?_=>B.every(Q=>_.includes(Q)):()=>!0}return B=>B.includes(F)}class D{mode="memory";#e;#t;#n;#r=!1;#o=null;#i;#s;#l=new Map;#a=!1;#u=0;#c=0;#d=new Map;#h=new Map;#f;#m=null;#p=D.#g();static#g(){return{slots:[],groupHeadings:d,unnumbered:d,pivot:null,inlineLeaves:null,matchCount:0,grand:null,grandLeaves:0,groupLeaves:null}}#w=new Map;#b=null;#v=new Map;#y=-1;#S=[];#A=new Map;#j=-1;#O=[];#E=null;#C=null;#T=null;#x=null;#N=null;#D=null;#M=null;#I=null;#W=Symbol("unset");#R=new Map;#q=null;get#B(){return this.#p.slots}set#B(C){this.#p.slots=C}get#H(){return this.#p.inlineLeaves}set#H(C){this.#p.inlineLeaves=C}get#ne(){return this.#p.groupHeadings}set#ne(C){this.#p.groupHeadings=C}get#ae(){return this.#p.unnumbered}set#ae(C){this.#p.unnumbered=C}get#le(){return this.#p.pivot}set#le(C){this.#p.pivot=C}constructor(C,B){this.#t=C||{mode:"memory"},this.#e=B||{};const _=this.#e.config||{};this.#n=this.#t.rows||_.rows||[],this.#i=x(this.#e),this.#s=u(this.#e,()=>this.#n,()=>this.#r),this.#f=new M(Number(_.rowCacheSize)||L);for(const Q of w)this.#l.set(Q,{key:null,result:null,id:0,computed:!1})}count(){this.#ee();const C=this.#de();return C?C.length:this.#B.length}#de(){const C=Number(this.#$("pageSize",0))||0;if(C<=0)return null;const B=this.#B.length,_=Math.max(1,Math.ceil(B/C)),Y=Math.min(Math.max(0,Number(this.#$("page",0))||0),_-1)*C;return{offset:Y,length:Math.max(0,Math.min(C,B-Y))}}pageInfo(){this.#ee();const C=Number(this.#$("pageSize",0))||0,B=this.#B.length;if(C<=0)return{page:0,pageSize:0,total:B,pageCount:1};const _=Math.max(1,Math.ceil(B/C));return{page:Math.min(Math.max(0,Number(this.#$("page",0))||0),_-1),pageSize:C,total:B,pageCount:_}}totalCount(){return this.#$e().length}matchCount(){return this.#ee(),this.#p.matchCount}at(C){this.#ee();const B=this.#de();if(B)return C<0||C>=B.length?void 0:this.#st(B.offset+C,C);if(!(C<0||C>=this.#B.length))return this.#st(C,C)}byKey(C){this.#ee(),this.#m||this.#G();const B=this.#m.get(C);if(B!==void 0)return this.#Ae(B);for(let _=0;_<this.#B.length;_++){const Q=this.#B[_];if(typeof Q!="number"&&Q&&Q.key===C)return this.#st(_)}}loaded(C){return C>=0&&C<this.count()}hint(C,B){}display(){return this.#ee(),this.#q||(this.#q=this.#wt()),this.#q}invalidateQuickText(){this.#R.clear(),this.invalidate("filter")}invalidate(C){const B=w.indexOf(C);B<0&&N(`unknown pipeline stage "${C}"; expected one of ${w.join(", ")}`);for(let _=B;_<w.length;_++){const Q=this.#l.get(w[_]);Q.key=null,Q.computed=!1}this.#q=null}apply(C){const B=[],_={added:[],updated:[],removed:[],rejected:B};if(!C)return _;let Q=!1;const Y=new Set;if(C.remove&&C.remove.length)for(const J of C.remove){const te=this.#_(J);if(te===void 0){B.push({operation:"remove",id:this.#z(J),reason:"unknown-id"});continue}_.removed.push(this.#i.keyOf(this.#r?this.#Ye(te):this.#n[te],te)),this.#r||(this.#n[te]=void 0),this.#f.delete(te),this.#R.delete(te),Q=!0}if(C.update&&C.update.length){const J=this.#v.size||this.#it()?this.#Xe():null,te=this.#A.size?this.#_e():null,ee=te&&te.length?this.#Xe():null;for(const oe of C.update){const re=this.#_(oe);if(re===void 0){B.push({operation:"update",id:this.#Z(oe),reason:"unknown-id"});continue}const le=this.#r?this.#o&&this.#o.has(re)?this.#o.get(re):this.#Ye(re):this.#n[re],ne=V(le,oe);for(const se of this.#me(le,ne))Y.add(se);if(this.#r||(this.#n[re]=ne),J&&this.#ke(J,re,le,ne),ee&&this.#yt(te,ee,re,le,ne),this.#m){const se=this.#i.keyOf(le,re),ae=this.#i.keyOf(ne,re);se!==ae&&(this.#m.delete(se),this.#m.set(ae,re))}this.#f.delete(re),this.#R.delete(re),_.updated.push(this.#Ae(re))}}if(C.add&&C.add.length&&this.#r){typeof C.at=="number"&&C.at<this.#Ze()&&(this.#f.clear(),this.#R.clear()),this.#m=null;for(const J of C.add){const te=this.#K(this.#Z(J));te!==void 0&&_.added.push(this.#Ae(te))}Q=!0}else if(C.add&&C.add.length){const J=typeof C.at=="number"?C.at:this.#n.length,te=this.#n.length;let ee=C.add===this.#n?C.add.slice():C.add;if(this.#i.keyed){const oe=[];for(const re of ee){const le=this.#Z(re);if(this.#_(le)!==void 0){B.push({operation:"add",id:le,reason:"duplicate-id"});continue}oe.push(re)}oe.length!==ee.length&&(ee=oe)}if(!ee.length)return _;if(J>=te)for(let oe=0;oe<ee.length;oe++)this.#n.push(ee[oe]);else this.#n.splice(J,0,...ee),this.#f.clear(),this.#R.clear();for(let oe=0;oe<ee.length;oe++)_.added.push(this.#Ae(J>=te?te+oe:J+oe));Q=!0}return this.#u++,Q&&(this.#m=null,this.#Je()),this.#s.invalidate(),this.#q=null,Q||this.#Me(Y)?(this.#c++,this.invalidate("filter")):this.invalidate("total"),this.#Ue("rows:changed",{companion:!0,added:_.added.length,updated:_.updated.length,removed:_.removed.length}),this.#o=null,_}groupHeadingsAt(C){this.#ee();const B=this.#ne;if(!B.length||!Number.isInteger(C)||C<0)return d;let _=0,Q=B.length-1,Y=-1;for(;_<=Q;){const te=_+Q>>1;B[te].at<=C?(Y=te,_=te+1):Q=te-1}if(Y<0)return d;const J=[];for(let te=B[Y].row;te;te=te.parent)J.push(te);return J.reverse(),J}unnumberedRowCount(C){this.#ee();const B=this.#ae;if(!B.length||!Number.isInteger(C)||C<0)return 0;let _=0,Q=B.length-1,Y=-1;for(;_<=Q;){const J=_+Q>>1;B[J].at<=C?(Y=J,_=J+1):Q=J-1}return Y+1}moveRow(C,B){if(this.#r)return $("source.moveRow.dropped","rows.move() is not supported under ingest.dropSourceRows: the source objects have been released and the store cannot reorder its columns in place. Enable retainSource (leave dropSourceRows off) to reorder rows."),!1;const _=this.#n;if(!Number.isInteger(C)||!Number.isInteger(B)||C<0||C>=_.length)return!1;const Q=Math.max(0,Math.min(_.length-1,B));if(Q===C)return!1;const[Y]=_.splice(C,1);return _.splice(Q,0,Y),this.#u++,this.#c++,this.#m=null,this.#f.clear(),this.#R.clear(),this.#Je(),this.#s.invalidate(),this.#q=null,this.invalidate("filter"),this.#Ue("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(C){this.#ie(),this.#u++,this.#c++,this.#m=null,this.#R.clear(),this.#f.clear(),this.#Je(),this.#s.invalidate(),this.invalidate("filter"),this.#Ue("model:changed",{reason:"reload"})}destroy(){this.#ie(),this.#f.clear(),this.#R.clear(),this.#m=null,this.#B=[],this.#H=null,this.#q=null,this.#Je();for(const C of w)this.#l.set(C,{key:null,result:null,id:0,computed:!1})}#ie(){for(const{controller:C}of this.#w.values())try{C.abort()}catch{}this.#w.clear()}setRows(C){this.#n=C||[],this.#r=!1,this.#u++,this.#c++,this.#m=null,this.#R.clear(),this.#f.clear(),this.#Je(),this.#s.invalidate(),this.invalidate("filter")}notePriorRows(C){this.#o=C||null}releaseSource(){this.#r=!0,this.#n=[],this.#m=null,this.#f.clear(),this.#R.clear(),this.#s.invalidate()}data(){if(!this.#r)return this.#n;const C=this.#e.store;if(!C||!W(C.source))return this.#n;const B=C.physical||0,_=new Array(B);for(let Q=0;Q<B;Q++)_[Q]=C.live&&!C.live(Q)?void 0:C.source(Q);return _}#oe(){const C=this.#$("detail",null);return!C||!W(C.isOpen)||C.inline===!1?null:C}#te(){const C=(this.#e.config||{}).tree;return this.#W!==C&&(this.#W=C,this.#I=p(C,{dataAt:B=>this.#Ye(B),keyOf:B=>this.#i.keyOf(this.#Ye(B),B)})),this.#I}#V(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#V())return null;this.#ee();const C=this.#p.grand;return C?this.#i.grandTotal(C,this.#he(this.#p.grandLeaves)):null}pivot(){return this.#ee(),this.#le}pivotMatrix(){this.#ee();const C=this.#p.groupLeaves,B=(this.#e.compute||{}).pivotMatrix;if(!W(B))return null;const _=this.#$("groupBy",[]),Q=this.#$("pivotBy",[]);if(!_.length&&!Q.length)return null;const Y=this.#Xe().map(te=>({colId:te.id,handle:this.#s.handle(te.id),fn:j(te,"group")})).filter(te=>te.handle&&te.fn),J=this.#e.config||{};return B({rowHandles:_.map(te=>this.#s.handle(te)).filter(Boolean),columnHandles:Q.map(te=>this.#s.handle(te)).filter(Boolean),measures:Y,leaves:C||new Uint32Array(0),opts:{locale:J.locale,separator:(J.pivot||{}).separator,maxColumns:(J.pivot||{}).maxColumns}})}keysForLeaves(C){const B=[];if(!C)return B;for(let _=0;_<C.length;_++){const Q=this.#Ae(C[_]);Q&&Q.key!=null&&B.push(String(Q.key))}return B}leavesOf(C){this.#ee();const B=this.#l.get("group"),_=B&&B.result;if(!_||!_.nodes)return[];const Q=_.nodes.get(C);if(!Q)return[];const Y=[],J=te=>{const ee=te.row&&te.row.children;if(ee&&ee.length){for(const oe of ee){const re=_.nodes.get(oe.key);re&&J(re)}return}if(te.leaves)for(let oe=0;oe<te.leaves.length;oe++)Y.push(this.#Ae(te.leaves[oe]))};return J(Q),Y}#z(C){return typeof C=="string"?C:this.#Z(C)}#Z(C){try{return this.#i.keyOf(C,-1)}catch{return"(unkeyed)"}}#_(C){if(typeof C=="string")return this.#K(C);if(this.#i.keyed){const _=this.#i.keyOf(C,-1),Q=this.#K(_);if(Q!==void 0)return Q}if(this.#r)return;const B=this.#n.indexOf(C);return B>=0?B:void 0}#K(C){return this.#m||this.#G(),this.#m.get(C)}#G(){this.#m=new Map;const C=this.#Ze(),B=this.#e.store,_=B&&W(B.live)?Q=>B.live(Q):null;for(let Q=0;Q<C;Q++){if(_&&!_(Q))continue;const Y=this.#Ye(Q);Y!==void 0&&this.#m.set(this.#i.keyOf(Y,Q),Q)}}#me(C,B){const _=[];for(const Q of this.#we())this.#Le(Q)&&this.#be(Q,C,B,new Set)&&_.push(Q);return _}#be(C,B,_,Q){if(Q.has(C))return!1;Q.add(C);const Y=this.#Le(C);if(!Y)return!1;const J=Y.value&&Y.value.deps;return Array.isArray(J)&&J.length?J.some(te=>this.#be(String(te),B,_,Q)):W(Y.getValue)?!Object.is(Y.getValue(B),Y.getValue(_)):!1}#we(){const C=new Set;for(const _ of this.#$("sort",[]))C.add(_.col);for(const _ of this.#$("groupBy",[]))C.add(_);const B=_=>{if(_){if(Array.isArray(_.conditions)){_.conditions.forEach(B);return}_.col&&C.add(_.col)}};return B(this.#$("filters",null)),[...C]}#Me(C){if(!C.size)return!1;if(this.#$("quick",""))return!0;for(const B of this.#we())if(C.has(B))return!0;return!1}#ee(){if(!this.#a){this.#a=!0;try{this.#fe()}finally{this.#a=!1}}}pipelineRunning(){return this.#a}#fe(){const C=this.#Y("filter",()=>this.#Ee(),()=>this.#ve()),B=this.#pe(C),_=this.#Y("group",()=>this.#je(),()=>this.#Ne(B)),Q=this.#Y("total",()=>this.#Ie(),()=>this.#Ke(_));this.#Y("pivot",()=>this.#De(),()=>this.#bt(_)),this.#Y("flatten",()=>this.#ze(),()=>this.#qe(_)),this.#se(_,Q)}#pe(C){const B=this.#l.get("sort"),_=this.#Te();if(B.computed&&B.key===_&&!this.#w.has("sort"))return B.result;const Q=this.#w.get("sort");return Q&&Q.key===_?B.result:B.result&&this.#U(C)?(this.#L(C,_),B.result):this.#Y("sort",()=>_,()=>this.#xe(C))}#ge(){if(this.#b===null){const C=this.#e.pipelineWorker,B=W(C)?C():null;this.#b=B||!1}return this.#b||null}#ue(){const C=this.#$("sort",[]);if(!Array.isArray(C)||!C.length)return null;const B=(this.#e.config||{}).locale,_=[],Q=[];for(const Y of C){const J=this.#Le(Y.col);if(J&&J.running)continue;if(J&&J.value&&W(J.value.compare))return null;const te=this.#s.handle(Y.col);if(!te)return null;_.push({col:Y.col,descending:Y.dir==="desc",nullsFirst:!!Y.nullsFirst,locale:B}),Q.push(te)}return _.length?{entries:_,handles:Q,locale:B}:null}#U(C){const B=this.#ge();if(!B)return!1;const _=Number(B.threshold);return Number.isFinite(_)&&C.length<_?!1:!!this.#ue()}#L(C,B){const _=this.#ge(),Q=_&&this.#ue();if(!Q){this.#Y("sort",()=>B,()=>this.#xe(C));return}const Y=new AbortController;this.#w.set("sort",{key:B,controller:Y});const J=Q.entries.length===1?_.sortColumn(Q.handles[0],C,{descending:Q.entries[0].descending,nullsFirst:Q.entries[0].nullsFirst,locale:Q.locale,signal:Y.signal,key:"sort"}):_.sortMulti(Q.handles,Q.entries.map((te,ee)=>({...te,handle:Q.handles[ee]})),C,{signal:Y.signal,key:"sort"});if(!A(J)){this.#w.delete("sort"),this.#Y("sort",()=>B,()=>J);return}J.then(te=>this.#Oe(B,te),te=>this.#re("sort",B,te))}#Oe(C,B){const _=this.#w.get("sort");if(!(!_||_.key!==C)){if(this.#Te()!==C){this.#w.delete("sort");return}this.#w.delete("sort"),this.#Y("sort",()=>C,()=>B),this.#q=null,this.#ee(),this.#Ue("model:changed",{reason:S[0]})}}#re(C,B,_){const Q=this.#w.get(C);if(!(!Q||Q.key!==B)&&(this.#w.delete(C),!(_&&_.name==="AbortError")&&C==="sort"&&this.#Te()===B)){const Y=this.#Y("filter",()=>this.#Ee(),()=>this.#ve());this.#Y("sort",()=>B,()=>this.#xe(Y)),this.#q=null,this.#ee(),$("source.pipeline.sort","off-thread sort failed; recomputed on the main thread.",_),this.#Ue("model:changed",{reason:S[1]})}}#se(C,B){const _=C&&C.leaves?C.leaves.length:this.#p.slots.length;this.#p.matchCount=_,this.#p.grand=B&&B.grand||null,this.#p.grandLeaves=C&&C.leaves?C.leaves.length:0,this.#p.groupLeaves=C&&C.leaves?C.leaves:null}#Y(C,B,_){const Q=this.#l.get(C),Y=B();return Q.computed&&Q.key===Y||(Q.result=_(),Q.key=Y,Q.computed=!0,Q.id++,C==="flatten"&&(this.#q=null)),Q.result}#k(C){return this.#l.get(C).id}#Ee(){const C=(this.#e.config||{}).hostFilter,B=C&&W(C.active)&&C.active()?1:0,_=this.#$("where",null),Q=_?_.version:0,Y=this.#ut("filter.sig",`${this.#Qe()}`,()=>c({filters:this.#$("filters",null),quick:this.#$("quick",""),quickMode:this.#$("quickMode","contains")}));return`${this.#c}|${Y}|${B}|${Q}`}#Te(){return`${this.#k("filter")}|${JSON.stringify(this.#$("sort",[]))}`}#je(){return`${this.#k("sort")}|${JSON.stringify(this.#$("groupBy",[]))}`}#Ie(){const C=this.#Se()?"f":"a",B=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#k("group")}|${JSON.stringify(this.#$("totals",[]))}|${C}${B}|${this.#u}`}#De(){return`${this.#k("group")}|${JSON.stringify(this.#$("pivotBy",[]))}`}#ze(){const B=this.#Ge()||!this.#V()?this.#k("total"):"x",_=`${this.#Qe()}`,Q=this.#ut("flatten.keys",_,()=>{const J=this.#$("expanded",null);return J?[...J].sort().join(""):"*"}),Y=this.#ut("flatten.detail",_,()=>{const J=this.#$("detail",null);return J&&W(J.signature)?J.signature():""});return`${B}|${this.#k("pivot")}|${Q}|${Y}`}#Ge(){const C=this.#$("groupBy",[]);return Array.isArray(C)&&C.length>0}stageState(){const C=[];for(const[B,_]of this.#l){const Q=_.result;C.push({stage:B,materialised:!!_.computed,bytes:Q&&typeof Q.byteLength=="number"?Q.byteLength:null,rows:Q&&typeof Q.length=="number"?Q.length:null,rebuilds:_.id})}return C}facetIndices(C){return this.#ve(C||null)}facetRows(C){const B=this.facetIndices(C),_=[];for(let Q=0;Q<B.length;Q++){const Y=this.#Ae(B[Q]);Y&&_.push(Y)}return _}invalidateRows(){this.#f.clear(),this.#R.clear(),this.#q=null}invalidateHandles(){this.#s.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#$e()}filteredIndices(){const C=this.#l.get("filter");if(C&&C.computed&&C.key===this.#Ee())return C.result||this.#$e();this.#ee();const B=this.#l.get("filter");return(B&&B.computed?B.result:null)||this.#$e()}unfilteredRows(){const C=this.#$e(),B=[];for(let _=0;_<C.length;_++){const Q=this.#Ae(C[_]);Q&&B.push(Q)}return B}#ve(C=null){const B=this.#$e(),_=this.#$("filters",null),Q=C?this.#tt("pruneColumn")(_,C):_,Y=this.#Tt(Q),J=String(this.#$("quick","")||"").trim().toLowerCase(),te=J?H(J,String(this.#$("quickMode","contains")||"contains")):null,ee=(this.#e.config||{}).hostFilter,oe=!!(ee&&W(ee.active)&&ee.active()),re=this.#$("where",null),le=!!(re&&re.active);if(!Y&&!J&&!oe&&!le)return B;let ne=null;Y&&(ne=this.#tt("evaluateFilters")(Y,{handle:me=>this.#s.handle(me),count:this.#Ze(),pool:this.#e.pool,locale:(this.#e.config||{}).locale,itemwise:me=>T(this.#Le(me))}));const se=new Uint32Array(B.length);let ae=0;for(let de=0;de<B.length;de++){const me=B[de];if(!(ne&&!ne[me])&&!(te&&!this.#Et(me,te))){if(oe||le){const Pe=this.#Ae(me);if(oe&&!ee.passes(Pe)||le&&!re.passes(Pe.data,Pe.key))continue}se[ae++]=me}}if(ne){const de=(this.#e.compute||{}).releaseMask;W(de)&&de({pool:this.#e.pool},ne)}return se.subarray(0,ae)}handleFor(C){return this.#s.handle(C)}#xe(C){const B=this.#$("sort",[]).filter(Y=>{const J=this.#Le(Y.col);return!J||!J.running?!0:($(`source.sort.running.${Y.col}`,`sort ignores "${Y.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(!B.length)return C;const _=(this.#e.config||{}).locale;if(B.length===1){const Y=B[0],J=this.#s.handle(Y.col);if(!J)return $(`source.sort.${Y.col}`,`sort ignores unknown column "${Y.col}".`),C;const te=this.#Le(Y.col);return this.#tt("sortColumn")(J,C,{descending:Y.dir==="desc",nullsFirst:Y.nullsFirst,locale:_,compare:O(te)})}const Q=[];for(const Y of B){const J=this.#s.handle(Y.col);if(!J){$(`source.sort.${Y.col}`,`sort ignores unknown column "${Y.col}".`);continue}Q.push({handle:J,descending:Y.dir==="desc",nullsFirst:Y.nullsFirst,locale:_,compare:O(this.#Le(Y.col))})}return Q.length?this.#tt("sortMulti")(Q.map(Y=>Y.handle),Q,C):C}#Ne(C){const B=this.#$("groupBy",[]),_=this.#te();if(_&&!B.length){const de=b(C,_);return this.#D=f(de.roots,_.declaresChildren),{roots:null,leaves:C,nodes:new Map,tree:de}}if(this.#D=null,_&&B.length&&$("tree.grouped","grouping is active on a grid configured with `tree`; the grouping wins and the hierarchy is not shown."),!B.length)return{roots:null,leaves:C,nodes:new Map};const Q=(this.#e.config||{}).timeZone,Y=[],J=[];let te=!1;for(const de of B){const me=this.#s.handle(de);if(!me){$(`source.group.${de}`,`grouping ignores unknown column "${de}".`);continue}Y.push(me);const Pe=this.#Le(de),Ie=Pe&&Pe.dataType;if(Ie&&W(Ie.groupProjector)){const ke=Pe.typeOptions&&Pe.typeOptions.timeZone||Pe.timeZone||Q||void 0,be=Ie.groupProjector(Pe,ke);J.push(be||null),be&&(te=!0)}else J.push(null)}if(!Y.length)return{roots:null,leaves:C,nodes:new Map};const{keys:ee,buckets:oe}=this.#tt("groupByColumns")(Y,C,{locale:(this.#e.config||{}).locale,project:te?J:void 0}),re=this.#$("pivotBy",[]).length>0,le=[],ne=new Map;for(let de=0;de<oe.length;de++){const me=ee[de];let Pe=null;const Ie=[];for(let ke=0;ke<me.length;ke++){Ie.push(v(me[ke]));const be=I(Ie),ge=ke===me.length-1;let Ee=ne.get(be);if(!Ee){const xe=this.#i.group({path:[...Ie],column:B[ke],value:me[ke],level:ke,parent:Pe,expanded:re&&ge?!1:this.#at(be,{key:be,column:B[ke],value:me[ke],level:ke,path:[...Ie]}),hasChildren:!(re&&ge)});Ee={row:xe,leaves:null},ne.set(be,Ee),Pe?Pe.children.push(xe):le.push(xe)}Ee.row.leafCount+=oe[de].length,ke===me.length-1&&(Ee.leaves=oe[de]),Pe=Ee.row}}const se=this.#$("sort",[])||[],ae=(de,me)=>{if(!de||de.length<2){if(de)for(const be of de)ae(be.children,me+1);return}const Pe=B[me],Ie=se.find(be=>be.col===Pe),ke=Ie&&Ie.dir==="desc"?-1:1;de.sort((be,ge)=>ke*Z(be.groupValue,ge.groupValue));for(const be of de)ae(be.children,me+1)};return ae(le,0),{roots:le,leaves:C,nodes:ne,keys:ee,buckets:oe}}#X(C,B){const _=new Map,Q=new Map,Y=J=>{const te=J.physical>=0?[J.physical]:[];for(const ee of J.children)te.push(...Y(ee));if(J.children.length){const ee=this.#Re(B,Uint32Array.from(te),null);J.physical>=0?_.set(J.physical,ee):Q.set(J.key,ee)}return te};for(const J of C.roots)Y(J);return{byPhysical:_,byKey:Q}}#Ke(C){const B=this.#Xe();if(!B.length)return this.#C=null,this.#T=null,{grand:null};const _={id:this.#k("group"),columns:B.map(se=>se.id).join("")},Q=this.#C&&this.#C.id===_.id&&this.#C.columns===_.columns,Y=this.#it()&&Q?this.#E:null,J=Y?B.filter(se=>Y.has(se.id)):B,te=Q?this.#T:null,ee=this.#Se()?null:this.#rt(),oe=this.#We(B),re=se=>{const ae=C.nodes.get(se.key);let de=ae&&ae.leaves?ae.leaves:null;if(se.children&&se.children.length){const Ie=se.children.map(re);let ke=0;for(const Ee of Ie)ke+=Ee.length;const be=new Uint32Array(ke);let ge=0;for(const Ee of Ie)be.set(Ee,ge),ge+=Ee.length;de=be}de=de||new Uint32Array(0);const me=ee?ee.get(se.key)||P:de,Pe=this.#ce(se,Y?J:B,me,oe);return se.totals=Y?{...se.totals,...Pe}:Pe,de};if(C.roots&&J.length)for(const se of C.roots)re(se);if(this.#M=C.tree?this.#X(C.tree,B):null,this.#C=_,this.#E=this.#it()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#S.length=0,this.#T=null,{grand:null};const ne=ee?this.#Ce():C.leaves;return this.#T=this.#nt(B,ne,Y,te),{grand:this.#T}}#nt(C,B,_,Q){const Y={},J=this.#k("group");J!==this.#y&&(this.#ot(),this.#y=J);const te=this.#S;this.#S=[];for(const ee of C){if(!E(ee))continue;const oe=this.#s.handle(ee.id);if(!oe)continue;const re=j(ee,"grand");if(!i(re,oe)){if(_&&!_.has(ee.id)&&Q&&ee.id in Q){Y[ee.id]=Q[ee.id];continue}Y[ee.id]=this.#Re([ee],B,null,"grand")[ee.id];continue}let le=this.#v.get(ee.id);if((!le||le.fn!==re)&&(le=new t(re),this.#v.set(ee.id,le)),le.valid){let ne=!0;for(const se of te)if(se.colId===ee.id&&!le.update(se.before,se.after)){ne=!1;break}if(ne){Y[ee.id]=le.value();continue}le.invalidate()}le.seedColumn(oe.values,r(oe),B),Y[ee.id]=le.valid?le.value():this.#Re([ee],B,null,"grand")[ee.id]}return Y}#We(C){const B=this.#k("group");B!==this.#j&&(this.#A.clear(),this.#j=B);const _=new Map;for(const Y of C){if(!E(Y))continue;const J=this.#s.handle(Y.id),te=j(Y,"group");i(te,J)&&_.set(Y.id,{fn:te})}if(!_.size)return this.#O.length=0,_;const Q=this.#O;this.#O=[];for(const Y of Q){const{beforeKeys:J,afterKeys:te,colDeltas:ee}=Y,oe=J.length?new Set(J):null,re=te.length?new Set(te):null;for(const{colId:le,before:ne,after:se}of ee)if(_.has(le)){for(const ae of J)re&&re.has(ae)||this.#Be(ae,le,ne,null);for(const ae of te)oe&&oe.has(ae)||this.#Be(ae,le,null,se);for(const ae of J)re&&!re.has(ae)||this.#Be(ae,le,ne,se)}}return _}#Be(C,B,_,Q){const Y=this.#A.get(C),J=Y&&Y.get(B);!J||!J.valid||J.update(_,Q)||J.invalidate()}#ce(C,B,_,Q){if(!Q||!Q.size)return this.#Re(B,_,C);const Y={};let J=null,te=this.#A.get(C.key);for(const ee of B){const oe=Q.get(ee.id);if(!oe){(J||(J=[])).push(ee);continue}const re=this.#s.handle(ee.id);if(!re)continue;te||(te=new Map,this.#A.set(C.key,te));let le=te.get(ee.id);if((!le||le.fn!==oe.fn)&&(le=new t(oe.fn),te.set(ee.id,le)),le.valid||le.seedColumn(re.values,r(re),_),le.valid){Y[ee.id]=le.value();continue}(J||(J=[])).push(ee)}return J&&Object.assign(Y,this.#Re(J,_,C)),Y}#ke(C,B,_,Q){const Y=!this.#Se()||this.#P(B);for(const J of C){const te=J.getValue;if(!W(te))continue;const ee=te(_),oe=te(Q);Object.is(ee,oe)||(this.#E&&this.#E.add(J.id),Y&&this.#v.has(J.id)&&this.#S.push({colId:J.id,before:ee,after:oe}))}}#_e(){const C=this.#$("groupBy",[]),B=[];for(const _ of C){const Q=this.#Le(_);Q&&B.push(Q)}return B}#mt(C,B){const _=new Array(C.length);for(let Q=0;Q<C.length;Q++){const Y=C[Q].getValue;_[Q]=v(W(Y)?Y(B):void 0)}return _}#yt(C,B,_,Q,Y){if(this.#Se()&&!this.#P(_))return;const J=k(this.#mt(C,Q)),te=k(this.#mt(C,Y)),ee=J.length!==te.length||J.some((re,le)=>re!==te[le]),oe=[];for(const re of B){const le=re.getValue;if(!W(le))continue;const ne=le(Q),se=le(Y);!ee&&Object.is(ne,se)||oe.push({colId:re.id,before:ne,after:se})}!oe.length&&!ee||this.#O.push({beforeKeys:J,afterKeys:te,colDeltas:oe})}#P(C){const B=this.#l.get("filter"),_=B&&B.computed?B.result:null;if(!_)return!0;let Q=0,Y=_.length-1;for(;Q<=Y;){const J=Q+Y>>1,te=_[J];if(te===C)return!0;te<C?Q=J+1:Y=J-1}return!1}#Se(){return(this.#e.config||{}).totalFilteredOnly!==!1}#he(C){return this.#Se()?C:this.#Ce().length}#Ce(){return(!this.#x||this.#x.version!==this.#c)&&(this.#x={version:this.#c,indices:this.#$e()}),this.#x.indices}#rt(){const C=this.#$("groupBy",[]),B=`${this.#c}|${JSON.stringify(C)}`;if(this.#N&&this.#N.key===B)return this.#N.map;const _=new Map,Q=[];for(const Y of C){const J=this.#s.handle(Y);J&&Q.push(J)}if(Q.length){const Y=this.#Ce(),{keys:J,buckets:te}=this.#tt("groupByColumns")(Q,Y,{locale:(this.#e.config||{}).locale}),ee=new Map;for(let oe=0;oe<te.length;oe++){const re=J[oe],le=[];for(let ne=0;ne<re.length;ne++){le.push(v(re[ne]));const se=I(le);let ae=ee.get(se);ae||(ae=[],ee.set(se,ae));for(let de=0;de<te[oe].length;de++)ae.push(te[oe][de])}}for(const[oe,re]of ee)_.set(oe,Uint32Array.from(re))}return this.#N={key:B,map:_},_}#it(){return!!(this.#e.config||{}).totalOnlyChangedColumns}#Je(){this.#ot(),this.#et(),this.#E=null,this.#C=null,this.#T=null}#ot(){this.#v.clear(),this.#S.length=0,this.#y=-1}#et(){this.#A.clear(),this.#O.length=0,this.#j=-1}#bt(C){const B=this.#$("pivotBy",[]);if(!B.length)return this.#le=null,null;const _=(this.#e.compute||{}).pivot;if(!W(_))return $("source.pivot.kernel","pivot requested but ctx.compute.pivot is not available; showing unpivoted rows."),this.#le=null,null;const Q=B.map(J=>this.#s.handle(J)).filter(Boolean),Y=this.#Xe();return this.#le=_(Q,C.leaves,{groups:C.keys&&C.buckets?{keys:C.keys,buckets:C.buckets}:null,totals:Y.map(J=>J.id),handle:J=>this.#s.handle(J),totalOf:J=>j(Y.find(te=>te.id===J),"group"),separator:((this.#e.config||{}).pivot||{}).separator,maxColumns:((this.#e.config||{}).pivot||{}).maxColumns})||null,this.#le}#qe(C){const B=this.#l.get("total").result,_=!!(this.#e.config||{}).groupFooter,Q=this.#oe();if(C.tree)return this.#Ct(C,B,Q);if(!C.roots&&!Q){if(B&&B.grand&&!this.#V()){const re=this.#i.grandTotal(B.grand,this.#he(C.leaves.length));if(this.#H===C.leaves&&Array.isArray(this.#B))this.#B[this.#B.length-1]=re;else{const le=Array.from(C.leaves);le.push(re),this.#B=le,this.#H=C.leaves}this.#ae=[{at:this.#B.length-1}]}else this.#H=null,this.#B=C.leaves,this.#ae=d;return this.#ne=d,this.#B}const Y=[],J=[],te=[],ee=re=>{if(Y.push(re),!Q)return;const le=this.#Ae(re);!le||!Q.isOpen(le.key)||(le.master=!0,le.expanded=!0,te.push({at:Y.length}),Y.push(this.#i.detail(le,Q.heightOf(le))))};if(!C.roots){for(let re=0;re<C.leaves.length;re++)ee(C.leaves[re]);return B&&B.grand&&!this.#V()&&(te.push({at:Y.length}),Y.push(this.#i.grandTotal(B.grand,this.#he(C.leaves.length)))),this.#H=null,this.#ne=d,this.#ae=te.length?te:d,this.#B=Y,Y}const oe=(re,le,ne)=>{if(re.expanded=re.hasChildren===!1?!1:this.#at(re.key,{key:re.key,column:re.groupColumn,value:re.groupValue,level:re.level,path:re.groupPath}),re.posinset=le+1,re.setsize=ne,J.push({at:Y.length,row:re}),te.push({at:Y.length}),Y.push(re),!!re.expanded){if(re.children&&re.children.length)for(let se=0;se<re.children.length;se++)oe(re.children[se],se,re.children.length);else{const se=C.nodes.get(re.key),ae=se&&se.leaves?se.leaves:null;if(ae)for(let de=0;de<ae.length;de++)ee(ae[de])}_&&re.totals&&(te.push({at:Y.length}),Y.push(this.#i.footer(re)))}};for(let re=0;re<C.roots.length;re++)oe(C.roots[re],re,C.roots.length);return B&&B.grand&&!this.#V()&&(te.push({at:Y.length}),Y.push(this.#i.grandTotal(B.grand,this.#he(C.leaves.length)))),this.#ne=J,this.#ae=te,this.#B=Y,Y}#$e(){const C=this.#e.store;if(C&&W(C.liveIndices))return C.liveIndices();const B=new Uint32Array(this.#n.length);let _=0;for(let Q=0;Q<this.#n.length;Q++)this.#n[Q]!==void 0&&(B[_++]=Q);return B.subarray(0,_)}#Ze(){const C=this.#e.store;return C&&typeof C.physical=="number"?C.physical:this.#n.length}#Ye(C){const B=this.#e.store;return B&&W(B.source)?B.source(C):this.#n[C]}#st(C,B=C){const _=this.#B[C];if(typeof _!="number")return _.index=B,_;const Q=this.#Ae(_);return Q.index=B,Q}#Ae(C){let B=this.#f.get(C);B||(B=this.#i.leaf(this.#Ye(C),C),this.#f.set(C,B));const _=this.#D?this.#D.get(C):null;if(_){B.level=_.level,B.posinset=_.posinset,B.setsize=_.setsize,B.hasChildren=_.hasChildren,B.expanded=_.hasChildren&&!_.lazy&&this.#at(B.key);const Q=this.#M?this.#M.byPhysical.get(C):void 0;Q?B.totals=Q:B.totals&&(B.totals=null)}else B.hasChildren&&(B.level=0,B.hasChildren=!1,B.expanded=!1,B.posinset=void 0,B.setsize=void 0);return B}#Ct(C,B,_){const Q=[],Y=[],J=ee=>{if(ee.leafCount!==void 0)return ee.leafCount;let oe=ee.physical>=0?1:0;for(const re of ee.children)oe+=J(re);return ee.leafCount=oe,oe},te=ee=>{const oe=this.#at(ee.key);if(ee.physical>=0){if(Q.push(ee.physical),_&&_.isOpen(this.#Ae(ee.physical).key)){const re=this.#Ae(ee.physical);Y.push({at:Q.length}),Q.push(this.#i.detail(re,_.heightOf(re)))}}else Q.push(this.#i.group({path:[ee.key],column:null,value:ee.value,level:ee.level,parent:null,expanded:oe,hasChildren:ee.children.length>0,leafCount:J(ee),totals:this.#M?this.#M.byKey.get(ee.key):void 0}));if(oe)for(const re of ee.children)te(re)};for(const ee of C.tree.roots)te(ee);return B&&B.grand&&!this.#V()&&(Y.push({at:Q.length}),Q.push(this.#i.grandTotal(B.grand,this.#he(C.leaves.length)))),this.#H=null,this.#ne=d,this.#ae=Y.length?Y:d,this.#B=Q,Q}#wt(){return y(()=>this.count(),C=>this.at(C))}#Et(C,B){let _=this.#R.get(C);if(_===void 0){const Q=this.#Ye(C),Y=this.#kt(),J=[],te=this.#e.columnHidden;for(const ee of Y){if(ee.quickFilter===!1||W(te)&&te(ee.id))continue;const oe=ee.value&&W(ee.value.quickFilterText)?ee.value.quickFilterText({value:void 0,data:Q,row:null,column:ee,colId:ee.id,grid:null,context:this.#$("context",null)}):null,re=oe??(W(ee.formatValue)?ee.formatValue(W(ee.getValue)?ee.getValue(Q):void 0):"");re!=null&&re!==""&&J.push(String(re))}_=J.join(" ").toLowerCase(),this.#R.set(C,_)}return B(_)}#Xe(){const C=this.#$("totals",[]),B=C&&C.length?new Set(C):null;return this.#kt().filter(_=>B?B.has(_.id):!!(_.total||_.groupTotal||_.grandTotal))}#Re(C,B,_,Q="group"){const Y={},J=(this.#e.compute||{}).total;for(const te of C){if(!E(te))continue;const ee=this.#s.handle(te.id);if(!ee)continue;const oe=j(te,Q);if(oe)if(W(oe)){const re=new Array(B.length);for(let le=0;le<B.length;le++)re[le]=ee.get(B[le]);Y[te.id]=oe(re,{row:_,column:te,grid:this.#e.grid||null,context:this.#$("context",null),valueAt:(le,ne)=>{const se=this.#s.handle(le);return se&&ne>=0&&ne<B.length?se.get(B[ne]):null}})}else W(J)&&(Y[te.id]=J(ee,B,oe))}return Y}#Tt(C){if(!C)return C;const B=this.#e.config||{},_={tz:B.timeZone,weekStartsOn:B.weekStartsOn};return a(C,Q=>{const Y=g(Q,_);if(Y&&Y.type)return Y;const J=this.#Le(Y&&Y.col),te=J&&(J.dataType?.base||J.type);return te?{...Y,type:te}:Y})}#at(C,B){const _=this.#$("expanded",null);return _?W(_.has)?_.has(C,B):Array.prototype.includes.call(_,C):!0}#$(C,B){if(C==="context"||!W(this.#e.stateVersion))return this.#lt(C,B);const _=this.#Mt(C),Q=this.#d.get(C);if(Q&&Q.version===_)return Q.value;const Y=this.#lt(C,B);return this.#d.set(C,{version:_,value:Y}),Y}#lt(C,B){const _=this.#e.state;if(_&&W(_[C])){const Q=_[C]();return Q??B}return B}#Qe(){const C=this.#e.stateVersion;return W(C)?C():0}#vt(){const C=this.#e.columnsVersion,B=this.#e.permissionsVersion;return`${W(C)?C():0}|${W(B)?B():0}`}#Mt(C){return C==="totals"?this.#vt():`${this.#Qe()}`}#ut(C,B,_){if(!W(this.#e.stateVersion))return _();const Q=this.#h.get(C);if(Q&&Q.version===B)return Q.key;const Y=_();return this.#h.set(C,{version:B,key:Y}),Y}#tt(C){const B=(this.#e.compute||{})[C];return W(B)||N(`ctx.compute.${C} is required by the memory source pipeline`),B}#kt(){const C=this.#e.columns;return C&&W(C.all)?C.all():[]}#Le(C){const B=this.#e.columns;return B&&W(B.get)?B.get(C):void 0}#Ue(C,B){const _=this.#e.emit;W(_)&&_(C,B)}}}),Ae("packages/core/src/source/abort.js",function(e,G){"use strict";Object.defineProperty(e,"SupersededError",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"RequestToken",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"AbortScope",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"createAbortScope",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"isAbortError",{enumerable:!0,get:function(){return W}});class q extends Error{constructor(V,U="superseded"){super(`[lattice] request ${V?`"${V}" `:""}${U}`),this.name="SupersededError",this.superseded=!0,this.key=V}}class M{#e;constructor(V,U,x,I){this.#e=V,this.key=U,this.controller=x,this.signal=x.signal,this.seq=I}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(V){this.signal.aborted||this.controller.abort(new q(this.key,V)),this.#e.settle(this)}}class ${#e=new Map;#t=0;begin(V="",U="superseded"){const x=this.#e.get(V);x&&!x.signal.aborted&&x.controller.abort(new q(V,U));const I=new M(this,V,new AbortController,++this.#t);return this.#e.set(V,I),I}tokenFor(V){return this.#e.get(V)}pending(V=""){const U=this.#e.get(V);return!!U&&!U.signal.aborted}get size(){return this.#e.size}settle(V){this.#e.get(V.key)===V&&this.#e.delete(V.key)}abort(V="",U="superseded"){const x=this.#e.get(V);x&&x.abort(U)}abortAll(V="superseded"){for(const U of[...this.#e.values()])U.abort(V);this.#e.clear()}}function N(){return new $}function W(Z){if(!Z||typeof Z!="object")return!1;const V=Z;return V.superseded===!0||V.name==="AbortError"||V.name==="SupersededError"}}),Ae("packages/core/src/source/blockcache.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_PAGE_SIZE",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"DEFAULT_MAX_CACHED_PAGES",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return N}});const q=100,M=32;class ${constructor(Z){this.id=Z,this.rows=null,this.state="pending",this.token=null,this.error=null}}class N{#e=new Map;#t;#n;#r=0;#o=-1;constructor(Z={}){this.#t=Math.max(1,Math.floor(Number(Z.pageSize)||q)),this.#n=Math.max(1,Math.floor(Number(Z.maxCachedPages)||M))}get pageSize(){return this.#t}get maxBlocks(){return this.#n}get size(){return this.#e.size}blockOf(Z){return Math.floor(Z/this.#t)}rangeOf(Z){return{start:Z*this.#t,end:(Z+1)*this.#t}}has(Z){return this.#e.has(Z)}pending(Z){const V=this.#e.get(Z);return!!V&&V.state==="pending"}loaded(Z){const V=this.#e.get(Z);return!!V&&V.state==="loaded"}begin(Z,V){let U=this.#e.get(Z);return U||(U=new $(Z)),U.state="pending",U.token=V,U.error=null,this.#i(Z,U),U}fill(Z,V){const U=this.#e.get(Z)||new $(Z);U.rows=V,U.state="loaded",U.token=null,this.#i(Z,U)}failed(Z,V){const U=this.#e.get(Z)||new $(Z);U.state="error",U.error=V,U.token=null,this.#i(Z,U)}delete(Z){return this.#e.delete(Z)}rowAt(Z){const V=this.blockOf(Z),U=this.#e.get(V);if(!(!U||U.state!=="loaded"||!U.rows))return this.#i(V,U),U.rows[Z-V*this.#t]}rowLoaded(Z){const V=this.blockOf(Z),U=this.#e.get(V);return!!U&&U.state==="loaded"&&!!U.rows&&Z-V*this.#t<U.rows.length}loadedExtent(){let Z=0;for(const V of this.#e.values()){if(V.state!=="loaded"||!V.rows)continue;const U=V.id*this.#t+V.rows.length;U>Z&&(Z=U)}return Z}fillOf(Z){const V=this.#e.get(Z);return V&&V.state==="loaded"&&V.rows?V.rows.length:null}protect(Z,V){this.#r=this.blockOf(Math.max(0,Z)),this.#o=this.blockOf(Math.max(0,V))}evict(){const Z=[];if(this.#e.size<=this.#n)return Z;for(const[V,U]of this.#e){if(this.#e.size-Z.length<=this.#n)break;V>=this.#r&&V<=this.#o||U.state!=="pending"&&Z.push(V)}for(const V of Z)this.#e.delete(V);return Z}ids(){return[...this.#e.keys()]}clear(){this.#e.clear()}#i(Z,V){this.#e.delete(Z),this.#e.set(Z,V)}}}),Ae("packages/core/src/source/paged.js",function(e,G){"use strict";Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"PagedSource",{enumerable:!0,get:function(){return o}});const q=G("packages/core/src/internal/util.js"),M=q.Lru,$=q.isFunction,N=q.warnOnce,W=q.settleDebounce,Z=G("packages/core/src/source/abort.js"),V=Z.createAbortScope,U=Z.isAbortError,x=G("packages/core/src/source/blockcache.js"),I=x.BlockCache,v=x.DEFAULT_PAGE_SIZE,k=x.DEFAULT_MAX_CACHED_PAGES,l=G("packages/core/src/source/rows.js").createRowFactory,u=G("packages/core/src/source/filterwire.js"),n=u.wireFilters,t=u.querySignature,i=u.warnHostFilterNotApplied,s=120;function r(c,a){return new o(c,a)}class o{mode="paged";#e;#t;#n;#r=V();#o;#i;#s=new Map;#l=null;#a=!1;#u=0;#c="";#d={start:0,end:0};#h;#f=!1;constructor(a,g){this.#e=a||{mode:"paged"},this.#t=g||{},this.#n=new I({pageSize:this.#e.pageSize||v,maxCachedPages:this.#e.maxCachedPages||k}),this.#o=l(this.#t),this.#i=new M(this.#n.pageSize*4),this.#h=W((h,b)=>this.#m(h,b),s),this.#c=this.#v(),$(this.#e.fetch)||N("source.paged.fetch",'source.mode "paged" requires a fetch function; the grid will stay empty.'),i(this.#t)}count(){if(this.#w(),this.#l!==null)return this.#l;const a=Math.max(this.#u,this.#n.loadedExtent());return this.#a?a:a+this.#n.pageSize}at(a){if(this.#w(),a<0||a>=this.count())return;const g=this.#i.get(a);if(g&&(g.data!==null||!this.#n.rowLoaded(a)))return g;const h=this.#n.rowAt(a);if(h===void 0){const p=this.#o.skeleton(a);return this.#i.set(a,p),p}const b=this.#o.leaf(h,a);return b.index=a,this.#i.set(a,b),this.#s.set(b.key,a),b}byKey(a){const g=this.#s.get(a);return g===void 0?void 0:this.at(g)}loaded(a){return this.#n.rowLoaded(a)}hint(a,g){if(this.#f)return;const h=this.#w(),b=Math.max(0,Math.floor(a)),p=Math.max(b,Math.floor(g));this.#d={start:b,end:p},this.#n.protect(b,p);for(const f of this.#n.evict())this.#g(f);this.#h(b,p),h&&this.#h.flush()}#m(a,g){if(this.#f)return;this.#n.protect(a,g);const h=this.#n.blockOf(a),b=this.#n.blockOf(g);for(let p=h;p<=b&&!(this.#l!==null&&p*this.#n.pageSize>=this.#l);p++)this.#n.has(p)||this.#p(p)}apply(a){const g={added:[],updated:[],removed:[]};if(!a)return g;if(a.update)for(const h of a.update){const b=this.#o.keyOf(h,-1),p=this.#s.get(b);if(p===void 0)continue;const f=this.#o.leaf(h,p);f.index=p,this.#i.set(p,f),g.updated.push(f)}return(a.add&&a.add.length||a.remove&&a.remove.length)&&this.reload(),g}reload(a){this.#b("reload"),this.#h.cancel(),this.hint(this.#d.start,this.#d.end)}destroy(){this.#f=!0,this.#h.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#p(a){if(!$(this.#e.fetch))return;const g=this.#r.begin(`block:${a}`);this.#n.begin(a,g);const{start:h,end:b}=this.#n.rangeOf(a),p=this.#c;try{const f=await this.#e.fetch({range:{start:h,end:b},sort:this.#S("sort",[]),filters:n(this.#S("filters",null),this.#y()),quick:this.#S("quick","")||void 0,context:this.#S("context",null),signal:g.signal});if(!g.current||p!==this.#c||this.#f)return;g.settle();const w=f&&f.rows||[];this.#n.fill(a,w);for(let m=0;m<w.length;m++)this.#i.delete(h+m);const S=f&&typeof f.total=="number"?f.total:f&&typeof f.count=="number"?f.count:null;S!==null?(this.#l=S,this.#a=!0):w.length<this.#n.pageSize?(this.#a=!0,this.#l=h+w.length):this.#u=Math.max(this.#u,h+w.length),this.#A("model:changed",{reason:"page",block:a,from:h,to:h+w.length}),this.#A("rows:changed",{companion:!0,reason:"page",block:a,from:h,to:h+w.length})}catch(f){if(g.settle(),U(f))return;this.#n.failed(a,f),this.#A("source:error",{error:f,block:a,range:{start:h,end:b}})}}#g(a){const{start:g,end:h}=this.#n.rangeOf(a);for(let b=g;b<h;b++){const p=this.#i.peek(b);p&&this.#s.delete(p.key),this.#i.delete(b)}}#w(){const a=this.#v();return a===this.#c?!1:(this.#c=a,this.#b("query"),!0)}#b(a){this.#r.abortAll(a),this.#n.clear(),this.#i.clear(),this.#s.clear(),this.#l=null,this.#a=!1,this.#u=0,this.#A("model:changed",{reason:a})}#v(){return t({filters:this.#S("filters",null),sort:this.#S("sort",[]),quick:this.#S("quick",""),context:this.#S("context",null)})}#y(){const a=this.#t.config||{};return{tz:a.timeZone,weekStartsOn:a.weekStartsOn}}#S(a,g){const h=this.#t.state;if(h&&$(h[a])){const b=h[a]();return b??g}return g}#A(a,g){const h=this.#t.emit;$(h)&&h(a,g)}}}),Ae("packages/core/src/source/remote.js",function(e,G){"use strict";Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return b}});const q=G("packages/core/src/internal/util.js"),M=q.Lru,$=q.isFunction,N=q.warnOnce,W=q.settleDebounce,Z=G("packages/core/src/source/abort.js"),V=Z.createAbortScope,U=Z.isAbortError,x=G("packages/core/src/source/blockcache.js"),I=x.BlockCache,v=x.DEFAULT_PAGE_SIZE,k=x.DEFAULT_MAX_CACHED_PAGES,y=G("packages/core/src/source/rows.js"),l=y.createRowFactory,u=y.groupKey,n=G("packages/core/src/source/filterwire.js"),t=n.wireFilters,i=n.querySignature,s=n.warnHostFilterNotApplied,o=G("packages/core/src/source/memory.js").MemorySource,c=1,a=120;function g(p,f){return new b(p,f)}class h{constructor(f,w,S,m){this.path=f,this.keyPath=m||f,this.values=[],this.level=w,this.key=u(this.keyPath),this.cache=new I(S),this.count=null,this.complete=!1,this.counting=!1,this.children=new Map,this.row=null}}class b{mode="remote";#e;#t;#n;#r;#o=new Map;#i=new Set;#s=V();#l;#a;#u=new Map;#c=[];#d="";#h;#f=!1;#m=null;#p=-1;constructor(f,w){this.#e=f||{mode:"remote"},this.#t=w||{},$(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#S(),this.unfilteredIndices=()=>this.#A(),this.handleFor=d=>this.#j(d),this.display=()=>this.#O(),this.grandTotalRow=()=>this.#C(),this.unfilteredRows=()=>this.#N(),this.facetIndices=d=>this.#E(d));const S=this.#e.counts;$(S)&&(this.matchCount=()=>this.#T("match"),this.totalCount=()=>this.#T("total"));const m=this.#e.grandTotals;$(m)&&(this.grandTotalRow=()=>this.#x()),this.#n={pageSize:this.#e.pageSize||v,maxCachedPages:this.#e.maxCachedPages||k},this.#l=l(this.#t),this.#a=new M(this.#n.pageSize*4),this.#h=W((d,j)=>this.#w(d,j),a),this.#r=new h([],0,this.#n),this.#o.set(this.#r.key,this.#r),this.#d=this.#ie(),$(this.#e.fetch)||N("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#Z()}count(){const f=this.#v();return f?f.count():(this.#le(),this.#R(this.#r))}at(f){const w=this.#v();if(w)return w.at(f);if(this.#le(),f<0||f>=this.count())return;const S=this.#B(this.#r,f);if(!S)return;const m=this.#H(S.node,S.local);return m&&(m.index=f),m||this.#l.skeleton(f,S.node.level)}byKey(f){const w=this.#v();if(w)return w.byKey(f);const S=this.#u.get(f);if(!S)return;const m=S.lastIndexOf(":"),d=this.#o.get(S.slice(0,m));return d&&this.#H(d,Number(S.slice(m+1)))||void 0}loaded(f){const w=this.#v();if(w)return w.loaded(f);if(f<0||f>=this.count())return!1;const S=this.#B(this.#r,f);return!!S&&S.node.cache.rowLoaded(S.local)}hint(f,w){if(this.#f)return;const S=this.#le(),m=Math.max(0,Math.floor(f)),d=Math.max(m,Math.floor(w));for(const[j,E]of this.#g(m,d)){j.cache.protect(E.min,E.max);for(const O of j.cache.evict())this.#ae(j,O)}this.#h(m,d),S&&this.#h.flush()}#g(f,w){const S=this.count(),m=new Map;for(let d=f;d<=w&&d<S;d++){const j=this.#B(this.#r,d);if(!j)continue;const E=m.get(j.node);E?(E.min=Math.min(E.min,j.local),E.max=Math.max(E.max,j.local)):m.set(j.node,{min:j.local,max:j.local})}return m.size||m.set(this.#r,{min:f,max:f}),m}#w(f,w){if(!this.#f)for(const[S,m]of this.#g(f,w)){S.cache.protect(m.min,m.max);const d=S.cache.blockOf(m.min),j=S.cache.blockOf(m.max);for(let E=d;E<=j&&!(S.count!==null&&E*S.cache.pageSize>=S.count);E++)S.cache.has(E)||this.#M(S,E)}}apply(f){const w={added:[],updated:[],removed:[]};if(!f)return w;if(f.update)for(const S of f.update){const m=this.#u.get(this.#l.keyOf(S,-1));if(!m)continue;this.#a.delete(m);const d=m.lastIndexOf(":"),j=this.#o.get(m.slice(0,d));if(!j)continue;const E=Number(m.slice(d+1)),O=j.cache.blockOf(E);if(!j.cache.loaded(O))continue;const{start:T}=j.cache.rangeOf(O),A=[];for(let L=T;L<T+j.cache.pageSize;L++){const z=j.cache.rowAt(L);if(z===void 0)break;A.push(L===E?S:z)}j.cache.fill(O,A);const P=this.#H(j,E);P&&w.updated.push(P)}return(f.add&&f.add.length||f.remove&&f.remove.length)&&this.reload({keepExpanded:!0}),w}reload(f){this.#s.abortAll("reload"),this.#h.cancel(),f&&f.keepExpanded===!1&&this.#i.clear(),this.#de(),this.#G("model:changed",{reason:"reload"})}destroy(){this.#f=!0,this.#h.cancel(),this.#s.abortAll("destroyed"),this.#de(),this.#o.clear(),this.#i.clear(),this.#m&&$(this.#m.destroy)&&this.#m.destroy(),this.#m=null}expand(f){this.#i.has(f)||(this.#i.add(f),this.#G("group:toggled",{key:f,expanded:!0}),this.#G("model:changed",{reason:"expand",key:f}))}collapse(f){this.#i.delete(f)&&(this.#G("group:toggled",{key:f,expanded:!1}),this.#G("model:changed",{reason:"collapse",key:f}))}expandedKeys(){return[...this.#i]}pivotFields(){return this.#c}invalidateHandles(){this.#m&&($(this.#m.invalidateHandles)&&this.#m.invalidateHandles(),$(this.#m.invalidate)&&this.#m.invalidate("filter"))}#b(){const f=this.#e.fullFrame;return $(f)?f():null}#v(){const f=this.#b();return f?(this.#m||(this.#m=new o({mode:"memory"},this.#y())),f.version!==this.#p&&(this.#m.setRows(f.rows),this.#p=f.version),this.#m):null}#y(){const f=this.#t,w=f.state||{};return{...f,state:{...w,page:()=>0,pageSize:()=>0}}}#S(){const f=this.#v();return f?f.filteredIndices():new Uint32Array(0)}#A(){const f=this.#v();return f?f.unfilteredIndices():new Uint32Array(0)}#j(f){const w=this.#v();return w?w.handleFor(f):void 0}#O(){const f=this.#v();return f?f.display():[]}#E(f){const w=this.#v();return w&&$(w.facetIndices)?w.facetIndices(f):new Uint32Array(0)}#C(){const f=this.#v();return f&&$(f.grandTotalRow)?f.grandTotalRow():null}#T(f){const w=this.#v();if(w){const j=f==="match"?w.matchCount:w.totalCount;if($(j))return j.call(w)}const S=this.#e.counts,m=$(S)?S():null,d=m?m[f]:null;return typeof d=="number"?d:this.count()}#x(){const f=this.#v();if(f&&$(f.grandTotalRow))return f.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const S=this.#e.grandTotals,m=$(S)?S():null;return!m||!m.totals?null:this.#l.grandTotal(m.totals,m.leafCount||0)}#N(){const f=this.#v();if(f&&$(f.unfilteredRows))return f.unfilteredRows();const w=[],S=this.count();for(let m=0;m<S;m++){const d=this.at(m);d&&w.push(d)}return w}#D(f,w,S){const{start:m,end:d}=f.cache.rangeOf(w),j=this.#K("groupBy",[]),E=this.#K("pivotBy",[]),O=this.#K("quick",""),T=this.#te(),A={protocol:c,range:{start:m,end:d},groupPath:f.path,groupValues:f.values,groupBy:j,totals:T,totalFns:this.#V(T),pivotBy:E,pivotMode:E.length>0,filters:t(this.#K("filters",null),this.#_()),sort:this.#K("sort",[]),context:this.#K("context",null),signal:S};O&&(A.quick=O);const P=this.#K("where",null);return P&&P.active&&(A.where=P),A}async#M(f,w){if(!$(this.#e.fetch))return;const S=this.#s.begin(`${f.key}:${w}`);f.cache.begin(w,S);const m=this.#d,{start:d}=f.cache.rangeOf(w);try{const j=await this.#e.fetch(this.#D(f,w,S.signal));if(!S.current||m!==this.#d||this.#f)return;S.settle();const E=j&&j.rows||[];f.cache.fill(w,E);for(let A=0;A<E.length;A++)this.#a.delete(`${f.key}:${d+A}`);const O=j&&typeof j.count=="number"?j.count:j&&typeof j.total=="number"?j.total:null,T=j&&$(j.pendingTotal?.then)?j.pendingTotal:null;O!==null?(f.count=O,f.complete=!0):E.length<f.cache.pageSize?(f.count=d+E.length,f.complete=!0):T&&(f.counting=!0),j&&Array.isArray(j.pivotFields)&&this.#W(j.pivotFields),this.#G("model:changed",{reason:"page",groupPath:f.path,block:w}),this.#G("rows:changed",{companion:!0,reason:"page",groupPath:f.path,block:w}),T&&this.#I(f,T,m)}catch(j){if(S.settle(),U(j))return;f.cache.failed(w,j),this.#G("source:error",{error:j,groupPath:f.path,block:w})}}async#I(f,w,S){let m;try{m=await w}catch(d){if(S!==this.#d||this.#f)return;f.counting=!1,U(d)||this.#G("source:error",{error:d,groupPath:f.path});return}S!==this.#d||this.#f||(f.counting=!1,typeof m=="number"&&(f.count=m,f.complete=!0,this.#G("source:total",{total:m,groupPath:f.path}),this.#G("model:changed",{reason:"total",count:m,groupPath:f.path})))}totalPending(){return this.#r.counting===!0}#W(f){f.length===this.#c.length&&f.every((w,S)=>w===this.#c[S])||(this.#c=f,this.#G("column:pivoted",{pivotFields:f,remote:!0}))}#R(f){let w=this.#q(f);for(const S of f.children.values())this.#oe(S.key)&&(w+=this.#R(S));return w}#q(f){if(f.count!==null)return f.count;const w=f.cache.loadedExtent();return f.complete?w:f.row&&f.row.leafCount>0?Math.max(w,f.row.leafCount):w+f.cache.pageSize}#B(f,w){let S=w,m=0;const d=[...f.children.entries()].filter(([,E])=>this.#oe(E.key)).sort((E,O)=>E[0]-O[0]);for(const[E,O]of d){const T=E-m+1;if(S<T)return{node:f,local:m+S};S-=T,m=E+1;const A=this.#R(O);if(S<A)return this.#B(O,S);S-=A}const j=this.#q(f);return m+S<j?{node:f,local:m+S}:null}#H(f,w){const S=`${f.key}:${w}`,m=this.#a.get(S);if(m)return m;const d=f.cache.rowAt(w);if(d===void 0)return null;const j=this.#K("groupBy",[]);let E;if(f.level<j.length){const O=j[f.level],T=this.#z(d,O),A=T==null,P=[...f.path,A?"":String(T)],L=[...f.keyPath,A?null:String(T)];E=this.#l.group({path:P,keyPath:L,column:O,value:T,level:f.level,parent:f.row,leafCount:Number(d.leafCount)||0,expanded:this.#oe(u(L))}),E.totals=this.#ne(d),E.data=d;let z=this.#o.get(E.key);z?z.row=E:(z=new h(P,f.level+1,this.#n,L),z.row=E,this.#o.set(z.key,z)),z.values=[...f.values,T],f.children.set(w,z)}else E=this.#l.leaf(d,w,f.level,f.row);return this.#a.set(S,E),this.#u.set(E.key,S),E}#ne(f){const w=f||{};if(w.totals&&typeof w.totals=="object")return w.totals;const S={};for(const m of this.#te())Object.hasOwn(w,m)&&(S[m]=w[m]);return S}#ae(f,w){const{start:S,end:m}=f.cache.rangeOf(w);for(let d=S;d<m;d++){const j=`${f.key}:${d}`,E=this.#a.peek(j);E&&this.#u.delete(E.key),this.#a.delete(j)}}#le(){const f=this.#ie();return f===this.#d?!1:(this.#d=f,this.#s.abortAll("query"),this.#de(),this.#G("model:changed",{reason:"query"}),!0)}#de(){for(const f of this.#o.values())f.cache.clear(),f.count=null,f.complete=!1,f.counting=!1,f.children.clear();this.#a.clear(),this.#u.clear()}#ie(){const f=this.#K("where",null);return`${i({filters:this.#K("filters",null),sort:this.#K("sort",[]),quick:this.#K("quick",""),groupBy:this.#K("groupBy",[]),pivotBy:this.#K("pivotBy",[]),context:this.#K("context",null)})}|${f?f.version:0}`}#oe(f){const w=this.#K("expanded",null);return w?$(w.has)?w.has(f):Array.prototype.includes.call(w,f):this.#i.has(f)}#te(){const f=this.#K("totals",[]);if(f&&f.length)return[...f];const w=this.#t.columns;return!w||!$(w.all)?[]:w.all().filter(S=>!!S.total).map(S=>S.id)}#V(f){const w=this.#t.columns,S={};if(!w||!$(w.get))return S;for(const m of f){const d=w.get(m);if(!d)continue;const j=d.groupTotal!=null?d.groupTotal:d.total;typeof j=="string"&&(S[m]=j)}return S}#z(f,w){const S=this.#t.columns,m=S&&$(S.get)?S.get(w):void 0;return m&&$(m.getValue)?m.getValue(f):f?.[w]}#Z(){s(this.#t)}#_(){const f=this.#t.config||{};return{tz:f.timeZone,weekStartsOn:f.weekStartsOn}}#K(f,w){const S=this.#t.state;if(S&&$(S[f])){const m=S[f]();return m??w}return w}#G(f,w){const S=this.#t.emit;$(S)&&S(f,w)}}}),Ae("packages/core/src/source/gapbuffer.js",function(e,G){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return M}});const q=64;class M{#e;#t=0;#n=0;constructor(N=q){this.#e=new Uint32Array(Math.max(1,N)),this.#n=this.#e.length}static from(N,W=q){const Z=new M(N.length+Math.max(1,W));return Z.#e.set(N,0),Z.#t=N.length,Z.#n=Z.#e.length,Z}get length(){return this.#t+(this.#e.length-this.#n)}get capacity(){return this.#e.length}at(N){return N<0||N>=this.length?0:N<this.#t?this.#e[N]:this.#e[N+(this.#n-this.#t)]}insert(N,W){const Z=N<0?0:N>this.length?this.length:N;this.#r(Z),this.#t===this.#n&&this.#o(),this.#e[this.#t++]=W}push(N){this.insert(this.length,N)}removeAt(N){return!Number.isInteger(N)||N<0||N>=this.length?!1:(this.#r(N),this.#n++,!0)}toArray(){const N=new Uint32Array(this.length);return N.set(this.#e.subarray(0,this.#t),0),N.set(this.#e.subarray(this.#n),this.#t),N}clear(){this.#t=0,this.#n=this.#e.length}#r(N){if(N!==this.#t)if(N<this.#t){const W=this.#t-N;this.#e.copyWithin(this.#n-W,N,this.#t),this.#t=N,this.#n-=W}else{const W=N-this.#t;this.#e.copyWithin(this.#t,this.#n,this.#n+W),this.#t=N,this.#n+=W}}#o(){const N=this.#e.length-this.#n,W=new Uint32Array(Math.max(this.#e.length*2,this.#e.length+q));W.set(this.#e.subarray(0,this.#t),0),W.set(this.#e.subarray(this.#n),W.length-N),this.#e=W,this.#n=W.length-N}}}),Ae("packages/core/src/store/ingest.js",function(e,G){"use strict";Object.defineProperty(e,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"inferKind",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"decideText",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"createReaders",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"Ingest",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return t}});const q=G("packages/core/src/internal/util.js"),M=q.now,$=q.nextFrame,N=q.infoOnce,W=q.warnOnce,Z=q.isFunction,V=q.pathGetter,x=G("packages/core/src/store/columnstore.js").ColumnStore,I=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function v(i,s={}){if(s.multi)return"multi";if(i.length===0)return"object";let r=0,o=0,c=0,a=0,g=0;for(let b=0;b<i.length;b++){const p=i[b];typeof p=="number"?r++:typeof p=="boolean"?o++:typeof p=="string"?c++:p instanceof Date?a++:Array.isArray(p)&&g++}const h=i.length;return r===h?"float64":o===h?"bitset":a===h?"float64":c===h?"text":g===h?"multi":"object"}function k(i,s,r){return s<=0||i<r*s?"dictionary":"object"}function y(i,s,r){const o=new Map,c=new Map;for(const d of i){if(d.computed)continue;const j=Z(d.read)?d.read:V(d.field||d.id);c.set(d.id,j),o.set(d.id,j)}const a=s?.order??[],g=s?.fns??{},h=s?.deps??{},b=s?.wrapDeps??null,p=a.filter(d=>Z(g[d])),f=p.some(d=>h[d]==="*");let w=new WeakMap;const S=d=>{const j={};if(f)for(const[E,O]of c)j[E]=O(d);for(const E of p){const O=h[E];let T;if(O==="*")T=j;else{T={};const A=O||[];for(let P=0;P<A.length;P++){const L=A[P];T[L]=L in j?j[L]:c.get(L)?.(d)}}j[E]=g[E](b?b(T,E):T,{data:d,row:null,column:null,grid:null,context:r})}return j},m=d=>{if(d===null||typeof d!="object"&&typeof d!="function")return S(d);let j=w.get(d);return j===void 0&&(j=S(d),w.set(d,j)),j};for(const d of p)o.set(d,j=>m(j)[d]);return{readers:o,reset(){w=new WeakMap}}}class l{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(s,r){this.spec=s,this.read=r,this.kind="object",this.inferred=!1,this.nullable=s.nullable!==!1}}class u{#e;#t=[];#n=null;#r;#o=0;#i;#s=!1;#l=!1;#a=0;#u;constructor(s,r={},o={}){this.#e=Array.isArray(s)?s:Array.from(s||[]),this.#i={...I,...o};const c=r.columns??[];this.#r=y(c,r.computed??null,r.context),this.#u=this.#e.length>=this.#i.columnarBelow,this.#c(c,r.computed??null),this.#n=new x(this.#t.map(a=>({id:a.spec.id,kind:a.kind,nullable:a.nullable,read:a.read,dictionary:a.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 s=M(),{chunkMs:r,chunkRows:o}=this.#i,c=this.#e.length;do{const a=Math.min(this.#o+o,c);this.#n.append(this.#e.slice(this.#o,a)),this.#d(this.#o,a),this.#o=a,this.#r.reset(),this.#f(!1)}while(this.#o<c&&M()-s<r);return this.#a+=M()-s,this.#i.onProgress?.({loaded:this.#o,total:c}),this.#o>=c?(this.#f(!0),this.#s=!0,!1):!0}cancel(){this.#l=!0}result(){return{store:this.#n,schema:this.#t.map(s=>({id:s.spec.id,kind:s.kind,nullable:s.nullable,read:s.read,dictionary:s.spec.dictionary})),decisions:this.#t.map(s=>({id:s.spec.id,kind:s.kind,nullable:s.nullable,inferred:s.inferred,distinct:s.candidate||s.change?this.#h(s):null,change:s.change,reason:s.reason})),count:this.#n.count,elapsed:this.#a,cancelled:this.#l}}#c(s,r){const o=this.#e,c=Math.min(this.#i.sampleSize,o.length),a=this.#i.dictionaryRatio,g=r?.pure instanceof Set?r.pure:new Set(r?.pure??r?.order??[]);for(const h of s){if(!h||!h.id)continue;if(h.computed&&(h.pure===!1||r&&!g.has(h.id))){W(`ingest.impure.${h.id}`,`column "${h.id}" is an impure computed column and is not materialised into the store`);continue}const b=this.#r.readers.get(h.id)??(Z(h.read)?h.read:V(h.field||h.id)),p=new l(h,b);if(h.kind)p.kind=h.kind,p.reason="declared by the caller";else if(h.dictionary)p.kind=h.multi?"multi":"dictionary",p.reason="value table supplied (lookup column)";else{const f=[];for(let S=0;S<c&&f.length<this.#i.sampleSize;S++){const m=b(o[S]);m!=null&&f.push(m)}p.inferred=!0;const w=v(f,{multi:h.multi});if(w==="text"){const S=new Set(f).size;p.kind=k(S,f.length,a),p.candidate=this.#u,p.reason=`sampled ${S} distinct in ${f.length}`}else p.kind=w,p.reason=`inferred from ${f.length} sampled values`,w==="object"&&f.length&&N(`ingest.mixed.${h.id}`,`column "${h.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);p.kind==="object"&&p.candidate&&(p.distinct=new Set(f))}this.#t.push(p)}}#d(s,r){const o=this.#e;for(const c of this.#t){if(!c.candidate||!c.distinct)continue;const a=c.distinct;for(let g=s;g<r;g++){const h=c.read(o[g]);h!=null&&a.add(h)}}}#h(s){if(s.distinct)return s.distinct.size;const r=this.#n.column(s.spec.id);return r?.dict?r.dict.size:0}#f(s){const r=this.#i.dictionaryRatio,o=this.#e.length;for(const c of this.#t){if(!c.candidate)continue;const a=this.#h(c);if(c.kind==="dictionary"&&a>=r*o){const g=this.#n.column(c.spec.id);c.distinct=new Set(g?.dict?g.dict.values():[]),this.#n.convert(c.spec.id,"object"),c.kind="object",c.change="demoted",c.reason=`${a} distinct values is at or above ${r*100}% of ${o} rows`;continue}if(c.kind==="object"&&a>=r*o){c.candidate=!1,c.distinct=null,c.reason=`${a} distinct values is at or above ${r*100}% of ${o} rows`;continue}s&&c.kind==="object"&&a<r*o&&(this.#n.convert(c.spec.id,"dictionary"),c.kind="dictionary",c.change=c.change==="demoted"?null:"promoted",c.reason=`${a} distinct values is below ${r*100}% of ${o} rows`,c.distinct=null),s&&(c.candidate=!1)}}}async function n(i,s={},r={}){const o=new u(i,s,r),c=r.scheduler?.frame??$;for(;o.slice();)await new Promise(a=>{c(a)});return o.result()}function t(i,s={},r={}){const o=new u(i,s,{...r,chunkMs:1/0});for(;o.slice(););return o.result()}}),Ae("packages/core/src/store/columnpack.js",function(e,G){"use strict";Object.defineProperty(e,"isPortableSchema",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"packChunk",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"packedTransfers",{enumerable:!0,get:function(){return u}});const M=G("packages/core/src/internal/util.js").pathGetter,$=G("packages/core/src/store/ingest.js"),N=$.inferKind,W=$.decideText,Z=$.INGEST_DEFAULTS,U=G("packages/core/src/store/columnstore.js").toFloat,x=new Set(["float64","int32","bitset","dictionary","object","multi"]);function I(n){if(!Array.isArray(n)||n.length===0)return!1;for(const t of n)if(!t||typeof t.id!="string"||typeof t.field!="string"||t.field===""||t.kind&&!x.has(t.kind))return!1;return!0}function v(n){const t=U(n);return Number.isFinite(t)?t|0:0}function k(n){return n==null?[]:Array.isArray(n)?n:[n]}function y(n,t,i,s){if(n.kind)return n.kind;const r=[];for(let a=0;a<t.length&&r.length<Z.sampleSize;a++){const g=t[a];g!=null&&r.push(g)}const o=N(r,{multi:n.multi});if(o!=="text")return o;const c=new Set(r).size;return W(c,r.length,s)}function l(n,t,i={}){const s=t.length|0,r=i.dictionaryRatio??Z.dictionaryRatio,o=[];for(const c of n){const a=M(c.field||c.id),g=c.nullable!==!1,h=new Array(s);for(let S=0;S<s;S++){const m=a(t[S]);h[S]=m===void 0?null:m}const b=y(c,h,s,r),p=g?new Uint8Array(s+7>>3):null,f=S=>{p&&(p[S>>3]|=1<<(S&7))};let w;switch(b){case"float64":{const S=new Float64Array(s);for(let m=0;m<s;m++){const d=h[m],j=d===null;j||f(m),S[m]=j?NaN:U(d)}w={id:c.id,kind:b,nullable:g,values:S,presence:p,offsets:null,table:null};break}case"int32":{const S=new Int32Array(s);for(let m=0;m<s;m++){const d=h[m],j=d===null;j||f(m),S[m]=j?0:v(d)}w={id:c.id,kind:b,nullable:g,values:S,presence:p,offsets:null,table:null};break}case"bitset":{const S=new Uint8Array(s+7>>3);for(let m=0;m<s;m++){const d=h[m],j=d===null;j||f(m),!j&&d&&(S[m>>3]|=1<<(m&7))}w={id:c.id,kind:b,nullable:g,values:S,presence:p,offsets:null,table:null};break}case"dictionary":{const S=new Uint32Array(s),m=[],d=new Map;for(let j=0;j<s;j++){const E=h[j];if(E===null){S[j]=0;continue}f(j);let O=d.get(E);O===void 0&&(O=m.length,m.push(E),d.set(E,O)),S[j]=O}w={id:c.id,kind:b,nullable:g,values:S,presence:p,offsets:null,table:m};break}case"multi":{const S=[],m=new Map,d=new Uint32Array(s+1),j=[];for(let E=0;E<s;E++){const O=h[E];d[E]=j.length,O===null||f(E);const A=k(O);for(let P=0;P<A.length;P++){const L=A[P];let z=m.get(L);z===void 0&&(z=S.length,S.push(L),m.set(L,z)),j.push(z)}}d[s]=j.length,w={id:c.id,kind:b,nullable:g,values:Int32Array.from(j),presence:p,offsets:d,table:S};break}default:{const S=new Array(s);for(let m=0;m<s;m++){const d=h[m];d!==null&&f(m),S[m]=d}w={id:c.id,kind:"object",nullable:g,values:S,presence:p,offsets:null,table:null};break}}o.push(w)}return{count:s,columns:o}}function u(n){const t=[];if(!n||!Array.isArray(n.columns))return t;const i=s=>{ArrayBuffer.isView(s)&&s.buffer&&!t.includes(s.buffer)&&t.push(s.buffer)};for(const s of n.columns)i(s.values),i(s.presence),i(s.offsets);return t}}),Ae("packages/core/src/source/stream.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_PROMOTE_BELOW",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"StreamSource",{enumerable:!0,get:function(){return O}});const q=G("packages/core/src/internal/util.js"),M=q.Lru,$=q.isFunction,N=q.now,W=q.nextFrame,Z=q.cancelFrame,V=q.whenIdle,U=q.defaultCompare,x=q.warnOnce,I=q.infoOnce,v=q.getPath,k=G("packages/core/src/source/abort.js"),y=k.createAbortScope,l=k.isAbortError,u=G("packages/core/src/source/rows.js"),n=u.createRowFactory,t=u.lazyRowView,s=G("packages/core/src/source/gapbuffer.js").GapBuffer,o=G("packages/core/src/source/memory.js").createMemorySource,a=G("packages/core/src/source/filterwire.js").querySignature,h=G("packages/core/src/store/columnpack.js").isPortableSchema,b=25e4,p=Symbol("lattice.stream.storeBacked"),f=8,w=.1,S=1e3,m=50;function d(T){return Math.min(S,Math.max(m,Math.floor(T/4)))}function j(T){if(T instanceof Date)return T.getTime();if(typeof T=="number")return Number.isFinite(T)?T:NaN;if(typeof T=="string"){const A=T.trim();if(!A)return NaN;const P=Date.parse(A);return Number.isNaN(P)?Number(A):P}return NaN}function E(T,A){return new O(T,A)}class O{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;#h=0;#f=0;#m=0;#p=0;#g=null;#w=null;#b=null;#v=!1;#y=!1;#S=!1;#A=!1;#j="";#O=0;#E=0;#C=0;#T=null;#x=1/0;#N=!1;#D=null;#M=null;#I=null;#W=null;#R=!1;#q=0;#B=0;#H=!1;constructor(A,P){this.#e=A||{mode:"stream"},this.#t=P||{},this.#s=n(this.#t),this.#l=new M(4096),this.#j=this.#Be();const L=(this.#t.config||{}).ingest;this.#R=!!L&&L.retainSource===!1,$(this.#e.open)||x("source.stream.open",'source.mode "stream" requires an open function; the grid will stay empty.'),this.#e.autoStart!==!1&&queueMicrotask(()=>this.start());const z=Number(this.#e.poll);Number.isFinite(z)&&z>0&&(this.#W=setInterval(()=>{this.#A||this.reload()},z),this.#W&&$(this.#W.unref)&&this.#W.unref()),this.#ae()}#ne(){const A=Number(this.#e.maxAge);return Number.isFinite(A)&&A>0?A:0}#ae(){const A=this.#ne();if(!A)return;const P=this.#e.ageBy;$(P)?this.#M=P:typeof P=="string"&&P?this.#M=L=>v(L,P):this.#M=null,this.#T=[],this.#D=setInterval(()=>{this.#A||this.#le()&&(this.#pe(),this.#je())},d(A)),this.#D&&$(this.#D.unref)&&this.#D.unref()}#le(){const A=this.#ne();return!A||!this.#T?!1:this.#N?!0:this.#x<Date.now()-A*(1+w)}#de(A,P){if(!this.#T)return;const L=this.#M?j(this.#M(P)):Date.now();this.#T[A]=L,Number.isNaN(L)||(L<this.#x&&(this.#x=L),L<Date.now()-this.#ne()&&(this.#N=!0))}#ie(){return this.#ce("groupBy",[]).length>0?!0:!!this.#ce("pivotMode",!1)&&this.#ce("pivotBy",[]).length>0}#oe(){if(this.#g||this.#A)return;const A=this.#ie();if(A&&!this.#w){this.#w=o({mode:"memory",rows:this.#n},this.#te()),this.#v=!1;return}!A&&this.#w&&(this.#w.destroy(),this.#w=null)}#te(){if(this.#b)return this.#b;const A=this,P={liveIndices:()=>A.#V(),live:L=>A.#n[L]!==void 0,source:L=>A.#ve(L),get physical(){return A.#n.length}};return this.#R&&(P.column=L=>{const z=A.#t.store;return z&&$(z.column)?z.column(L):void 0}),this.#b=Object.create(this.#t,{store:{value:P,enumerable:!0,configurable:!0}}),this.#b}#V(){const A=new Uint32Array(this.#n.length);let P=0;for(let L=0;L<this.#n.length;L++)this.#n[L]!==void 0&&(A[P++]=L);return A.subarray(0,P)}#z(){return this.#g?this.#g:this.#w?(this.#v&&(this.#v=!1,this.#w.setRows(this.#n)),this.#w):null}invalidate(A="filter"){if(this.#g){this.#g.invalidate(A);return}this.#oe(),this.#w&&this.#w.invalidate(A),(A==="filter"||A==="sort")&&this.#L()}count(){const A=this.#z();return A?A.count():this.#r?this.#r.length:this.#O}matchCount(){const A=this.#z();return A&&$(A.matchCount)?A.matchCount():this.#r?this.#r.length:this.#O}totalCount(){const A=this.#z();return A&&$(A.totalCount)?A.totalCount():this.#O}unfilteredRows(){const A=this.#z();if(A&&$(A.unfilteredRows))return A.unfilteredRows();const P=[];for(let L=0;L<this.#n.length;L++){if(!this.#n[L])continue;const z=this.#Ne(L);z&&P.push(z)}return P}at(A){const P=this.#z();if(P)return P.at(A);if(A<0||A>=this.count())return;const L=this.#r?this.#r.at(A):A,z=this.#Ne(L);return z.index=A,z}byKey(A){const P=this.#z();if(P)return P.byKey(A);const L=this.#a.get(A);return L===void 0?void 0:this.#Ne(L)}leavesOf(A){const P=this.#z();return P&&$(P.leavesOf)?P.leavesOf(A):[]}loaded(A){return A>=0&&A<this.count()}hint(A,P){if(this.#g){this.#g.hint(A,P);return}this.#Z(),this.#m=Math.max(0,Math.floor(A))}#Z(){this.#A||this.#Be()===this.#j||this.reload()}display(){const A=this.#z();return A?A.display():t(()=>this.count(),P=>this.at(P))}apply(A){if(this.#g)return this.#g.apply(A);const P={added:[],updated:[],removed:[]};if(!A)return P;if(A.update){let L=!1;for(const z of A.update){const H=this.#a.get(this.#s.keyOf(z,-1));if(H===void 0)continue;const D=this.#se(H);this.#R?this.#xe(H,z):this.#n[H]=z,this.#l.delete(H),this.#Y(H,D),this.#T&&(this.#de(H,z),L=!0),this.#v=!0,P.updated.push(this.#Ne(H))}L&&this.#pe()}if(A.add&&A.add.length){const L=this.#ee(A.add);for(const z of L)P.added.push(this.#Ne(z))}return A.remove&&A.remove.length&&x("source.stream.remove","removing rows from a live stream is not supported; reload instead."),this.#je(),P}reload(A){this.#u.abortAll("reload"),this.#We(),this.#w&&(this.#w.destroy(),this.#w=null),this.#v=!1,this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear(),this.#g=null,this.#O=0,this.#E=0,this.#C=0,this.#T&&(this.#T=[]),this.#x=1/0,this.#N=!1,this.#y=!1,this.#S=!1,this.#c={loaded:0,estimated:void 0},this.#j=this.#Be(),this.#ke("model:changed",{reason:"reload"}),this.start()}destroy(){this.#A=!0,this.#W!==null&&(clearInterval(this.#W),this.#W=null),this.#D!==null&&(clearInterval(this.#D),this.#D=null),this.#T=null,this.#u.abortAll("destroyed"),this.#We(),this.#d!==null&&(this.#Ge(this.#d),this.#d=null),this.#w&&(this.#w.destroy(),this.#w=null),this.#g&&this.#g.destroy(),this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear()}async start(){if(this.#S||this.#A||!$(this.#e.open))return;this.#S=!0;const A=this.#u.begin("stream");this.#L(),this.#oe();let P;try{P=this.#e.open({sort:this.#ce("sort",[]),filters:this.#ce("filters",null),quick:this.#ce("quick","")||void 0,context:this.#ce("context",null),signal:A.signal})}catch(z){this.#ke("source:error",{error:z});return}const L=$(P[Symbol.asyncIterator])?P[Symbol.asyncIterator]():P[Symbol.iterator]();this.#I=L;try{for(;;){const z=await L.next();if(!A.current||this.#A)return;if(z.done){this.#Te();return}if(await this.#_(z.value,A),!A.current||this.#A)return;if(z.value&&z.value.done){this.#Te();return}if(await this.#Ie(),!A.current||this.#A)return}}catch(z){if(l(z))return;this.#ke("source:error",{error:z})}finally{A.settle()}}progress(){return{loaded:this.#c.loaded,estimated:this.#c.estimated,done:this.#y,live:this.#O,evicted:this.#E}}promoted(){return this.#g!==null}memorySource(){return this.#g}invalidateHandles(){const A=this.#z();A&&($(A.invalidateHandles)&&A.invalidateHandles(),$(A.invalidate)&&A.invalidate("sort"))}renderCount(){return this.#h}ingestStats(){return{worker:this.#q,inline:this.#B,storeBacked:this.#R}}#_(A,P){if(!A)return;const L=A.rows;if(L&&L.length&&this.#G(L))return this.#be(A,P);const z=N();L&&L.length&&(this.#ee(L),this.#B++),this.#K(A),this.#f+=N()-z,this.#je()}#K(A){this.#c.loaded=A.progress&&typeof A.progress.loaded=="number"?A.progress.loaded:this.#n.length,A.progress&&typeof A.progress.estimated=="number"&&(this.#c.estimated=A.progress.estimated)}#G(A){if(this.#H||this.#g)return!1;const P=this.#we();if(!P)return!1;const L=this.#t.store;if(!L||!$(L.appendPacked))return!1;const z=this.#Me();return!z||!h(z)?(this.#H=!0,I("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):A.length<P.threshold?!1:!this.#me(A)}#me(A){if(!this.#s.keyed)return!1;const P=new Set;for(let L=0;L<A.length;L++){const z=this.#s.keyOf(A[L],this.#n.length+L);if(z!=null){if(P.has(z)||this.#a.has(z))return!0;P.add(z)}}return!1}async#be(A,P){const L=A.rows,z=this.#we(),H=this.#Me();let D;try{D=await z.columnize(H,L,{key:"ingest:stream",signal:P&&P.signal})}catch(Q){if(l(Q)||(x("source.stream.columnize","worker columnization failed; columnizing on the main thread",Q),this.#H=!0,P&&(!P.current||this.#A)))return;this.#ee(L),this.#B++,this.#K(A),this.#je();return}if(P&&(!P.current||this.#A))return;const F=this.#t.store,C=this.#R?void 0:L,{from:B}=F.appendPacked(D,C),_=D.count|0;for(let Q=0;Q<_;Q++){const Y=B+Q,J=L[Q],te=this.#s.keyed?this.#s.keyOf(J,Y):null;if(this.#n[Y]=this.#R?p:J,this.#O++,this.#de(Y,J),te!==null&&this.#a.set(te,Y),!this.#r||!this.#Oe(Y))continue;const ee=this.#k(Y);this.#r.insert(ee,Y),ee<=this.#m&&this.#p++}this.#v=!0,this.#pe(),this.#q++,this.#K(A),this.#je()}#we(){const A=this.#t.ingestWorker;return $(A)?A():null}#Me(){const A=this.#t.storeSchema;return $(A)?A():null}#ee(A){const P=[],L=this.#t.store,z=new Array(A.length),H=[],D=new Set;for(let C=0;C<A.length;C++){const B=this.#s.keyed?this.#s.keyOf(A[C],this.#n.length+H.length):null;z[C]=B,!(B!==null&&(this.#a.has(B)||D.has(B)))&&(B!==null&&D.add(B),H.push(A[C]))}let F=H.length&&L&&$(L.append)?L.append(H).from:this.#n.length;for(let C=0;C<A.length;C++){const B=A[C],_=z[C];if(_!==null&&this.#a.has(_)){const J=this.#a.get(_),te=this.#se(J);this.#R||(this.#n[J]=B,L&&$(L.setSource)&&L.setSource(J,B)),this.#xe(J,B),this.#l.delete(J),this.#de(J,B),this.#Y(J,te);continue}const Q=F++;if(this.#n[Q]=this.#R?p:B,this.#O++,this.#de(Q,B),_!==null&&this.#a.set(_,Q),P.push(Q),!this.#r||!this.#Oe(Q))continue;const Y=this.#k(Q);this.#r.insert(Y,Q),Y<=this.#m&&this.#p++}return this.#v=!0,this.#pe(),P}#fe(A){const P=this.#n[A];let L=!1;if(this.#r){const F=this.#U(A);F>=0&&F<=this.#m&&(L=!0)}else A<=this.#m&&(L=!0);const z=P===p?this.#ve(A):P,H=this.#s.keyed?this.#s.keyOf(z,A):null;H!==null&&this.#a.get(H)===A&&this.#a.delete(H),this.#n[A]=void 0,this.#T&&(this.#T[A]=NaN),this.#l.delete(A);const D=this.#t.store;return D&&$(D.remove)&&D.remove(A),this.#O--,L}#pe(){let A=0,P=0;const L=this.#ue();A+=L.dropped,P+=L.aboveAnchor;const z=this.#ge();A+=z.dropped,P+=z.aboveAnchor,A&&(this.#v=!0,this.#E+=A,this.#L(),this.#p-=P,this.#ke("stream:evicted",{evicted:A,total:this.#E,live:this.#O}))}#ge(){const A=this.#e.maxRows;if(!Number.isFinite(A)||A<=0||this.#O<=A)return{dropped:0,aboveAnchor:0};const P=Math.max(1,Math.floor(A*(1-w)));let L=0,z=0;for(;this.#O>P&&this.#C<this.#n.length;){const H=this.#C++;this.#n[H]!==void 0&&(this.#fe(H)&&z++,L++)}return{dropped:L,aboveAnchor:z}}#ue(){const A=this.#ne();if(!A||!this.#T||!this.#le())return{dropped:0,aboveAnchor:0};const P=Date.now()-A;let L=0,z=0,H=1/0;for(let D=this.#C;D<this.#n.length;D++){if(this.#n[D]===void 0)continue;const F=this.#T[D];if(!(Number.isNaN(F)||F===void 0)){if(F>=P){F<H&&(H=F);continue}this.#fe(D)&&z++,L++}}for(this.#x=H,this.#N=!1;this.#C<this.#n.length&&this.#n[this.#C]===void 0;)this.#C++;return{dropped:L,aboveAnchor:z}}#U(A){if(!this.#r)return A;for(let P=0;P<this.#r.length;P++)if(this.#r.at(P)===A)return P;return-1}#L(){this.#o=this.#ce("sort",[]),this.#i=this.#ce("filters",null);const A=Number.isFinite(this.#e.maxRows)&&this.#e.maxRows>0||this.#ne()>0,P=this.#ce("where",null),L=(this.#t.config||{}).hostFilter,z=!!(P&&P.active)||!!(L&&$(L.active)&&L.active());if(!(A||this.#o.length>0||!!this.#i||!!this.#ce("quick","")||z)){this.#r=null;return}this.#r=new s(Math.max(64,this.#n.length+64));for(let D=0;D<this.#n.length;D++)this.#n[D]!==void 0&&this.#Oe(D)&&this.#r.insert(this.#k(D),D)}#Oe(A){const P=this.#ve(A);if(this.#i&&!this.#re(this.#i,P))return!1;const L=String(this.#ce("quick","")||"").toLowerCase();if(L&&!this.#Ke(P).includes(L))return!1;const z=(this.#t.config||{}).hostFilter;if(z&&$(z.active)&&z.active()&&!z.passes(this.#Ne(A)))return!1;const H=this.#ce("where",null);if(H&&H.active){const D=this.#Ne(A);if(!H.passes(D.data,D.key))return!1}return!0}#re(A,P){if(!A)return!0;const L=A;if(Array.isArray(L.conditions))return L.op==="or"?L.conditions.some(D=>this.#re(D,P)):L.op==="not"?!L.conditions.some(D=>this.#re(D,P)):L.conditions.every(D=>this.#re(D,P));const z=A,H=(this.#t.compute||{}).testValue;return $(H)?!!H(this.#X(P,z.col),z,(this.#t.config||{}).locale):(x("source.stream.testValue","ctx.compute.testValue is unavailable; streamed rows are not filtered client-side."),!0)}#se(A){if(!this.#r)return-1;if(!this.#o.length)return this.#U(A);let P=0,L=this.#r.length;for(;P<L;){const z=P+L>>>1;this.#Ee(this.#r.at(z),A)<0?P=z+1:L=z}for(let z=P;z<this.#r.length;z++){const H=this.#r.at(z);if(H===A)return z;if(this.#Ee(H,A)>0)break}return this.#U(A)}#Y(A,P){if(!this.#r||!this.#o.length)return;const L=this.#Oe(A);if(P>=0&&this.#r.at(P)===A)this.#r.removeAt(P),P<=this.#m&&this.#p--;else if(P>=0)return;if(!L)return;const z=this.#k(A);this.#r.insert(z,A),z<=this.#m&&this.#p++}#k(A){if(!this.#r||!this.#o.length)return this.#r?this.#r.length:0;let P=0,L=this.#r.length;for(;P<L;){const z=P+L>>>1;this.#Ee(A,this.#r.at(z))<0?L=z:P=z+1}return P}#Ee(A,P){const L=this.#ve(A),z=this.#ve(P);for(const H of this.#o){const D=this.#nt(H.col),F=this.#X(L,H.col),C=this.#X(z,H.col),_=(D&&D.value&&$(D.value.compare)?D.value.compare:U)(F,C);if(_!==0)return H.dir==="desc"?-_:_}return 0}#Te(){this.#y=!0,this.#c.loaded=this.#c.loaded||this.#n.length;const A=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:b;!this.#R&&this.#n.length<A&&(this.#g=o({mode:"memory",rows:this.#n},this.#t),this.#D!==null&&(clearInterval(this.#D),this.#D=null),this.#w&&(this.#w.destroy(),this.#w=null)),this.#je(),this.#ke("stream:end",{loaded:this.#n.length,promoted:this.#g!==null,threshold:A})}#je(){this.#d!==null||this.#A||(this.#d=this.#ze(()=>{this.#d=null,this.#h++;const A=this.#p;this.#p=0,this.#f=0,this.#ke("stream:chunk",{loaded:this.#c.loaded,estimated:this.#c.estimated,count:this.count(),renders:this.#h}),this.#ke("model:changed",{reason:"stream",shiftAboveViewport:A,anchor:this.#m}),this.#ke("rows:changed",{companion:!0,reason:"stream"})}))}#Ie(){return this.#h===0||this.#f<this.#De()?Promise.resolve():(this.#f=0,new Promise(A=>{const P=(this.#t.scheduler||{}).idle;$(P)?P(()=>A()):V(()=>A())}))}#De(){return typeof this.#e.coalesceMs=="number"&&this.#e.coalesceMs>0?this.#e.coalesceMs:f}#ze(A){const P=this.#t.scheduler||{};return $(P.frame)?P.frame(A):W(A)}#Ge(A){const P=this.#t.scheduler||{};$(P.cancel)?P.cancel(A):Z(A)}#ve(A){const P=this.#n[A];if(P!==void 0&&P!==p)return P;if(P===void 0)return;const L=this.#t.store;return L&&$(L.source)?L.source(A):void 0}#xe(A,P){const L=this.#t.store;if(!L||!$(L.set))return;const z=this.#Me();if(Array.isArray(z))for(const H of z){if(!H||!H.id)continue;const D=$(H.read)?H.read:F=>v(F,H.field||H.id);L.set(H.id,A,D(P))}}#Ne(A){let P=this.#l.get(A);return P||(P=this.#s.leaf(this.#ve(A),A),this.#l.set(A,P)),P}#X(A,P){const L=this.#nt(P);return L&&$(L.getValue)?L.getValue(A):A?.[P]}#Ke(A){const P=this.#t.columns,L=P&&$(P.all)?P.all():[],z=[];for(const H of L){const D=$(H.getValue)?H.getValue(A):void 0;D!=null&&D!==""&&z.push(String(D))}return z.join(" ").toLowerCase()}#nt(A){const P=this.#t.columns;return P&&$(P.get)?P.get(A):void 0}#We(){const A=this.#I;if(this.#I=null,A&&$(A.return))try{A.return()}catch{}}#Be(){return a({context:this.#ce("context",null)})}#ce(A,P){const L=this.#t.state;if(L&&$(L[A])){const z=L[A]();return z??P}return P}#ke(A,P){const L=this.#t.emit;$(L)&&L(A,P)}}}),Ae("packages/core/src/source/url.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_URL_BATCH",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return v}});const q=G("packages/core/src/internal/util.js"),M=q.warnOnce,$=q.isObject,N=q.isFunction,W=q.getPath,V=G("packages/core/src/source/abort.js").isAbortError,U=500,x=new Set(["application/x-ndjson","application/ndjson","application/jsonlines","application/jsonl","application/x-jsonlines","text/x-ndjson"]),I=Symbol("lattice.url.skip");function v(h,b={}){const p=$(b)?b:{},f=N(p.fetch)?p.fetch:typeof globalThis<"u"&&N(globalThis.fetch)?globalThis.fetch:null,w=p.format==="json"||p.format==="ndjson"?p.format:void 0,S=typeof p.rowsPath=="string"&&p.rowsPath?p.rowsPath:void 0,m=N(p.map)?p.map:void 0,d=$(p.headers)?p.headers:void 0,j=Number.isFinite(p.batchSize)&&p.batchSize>0?Math.floor(p.batchSize):U,E=p.lenient===!0,O=Number.isFinite(p.poll)&&p.poll>0?Math.floor(p.poll):void 0,T=typeof h=="string"&&h.length>0;T||M("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*A(L={}){if(!T)return;if(!f)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const z=L&&L.signal;let H;try{H=await f(h,d?{signal:z,headers:d}:{signal:z})}catch(C){throw V(C)?C:new Error(`[lattice] createUrlSource: request to ${h} failed — ${C&&C.message||C}`)}if(!H||!H.ok){const C=H?H.status:"no response";throw new Error(`[lattice] createUrlSource: ${C} for ${h}`)}const D=k(h,w,H),F=H.body&&N(H.body.getReader)?H.body.getReader():null;try{if(!F){const _=await H.text();(D||u(_,h))==="ndjson"?yield*o(null,null,_,0,H,h,j,E):yield*r(_,h,S,m);return}const C=new TextDecoder("utf-8");if(D==="json"){yield*r(await s(F,C,""),h,S,m);return}if(D==="ndjson"){yield*o(F,C,"",0,H,h,j,E);return}const B=await n(F,C,h);B.format==="json"?yield*r(await s(F,C,B.seed),h,S,m):yield*o(F,C,B.seed,B.bytes,H,h,j,E)}finally{if(F&&N(F.cancel))try{await F.cancel()}catch{}}}const P={mode:"stream",open:A,autoStart:p.autoStart!==!1};return O!==void 0&&(P.poll=O),Number.isFinite(p.maxRows)&&(P.maxRows=p.maxRows),Number.isFinite(p.maxAge)&&(P.maxAge=p.maxAge),(typeof p.ageBy=="string"||N(p.ageBy))&&(P.ageBy=p.ageBy),Number.isFinite(p.coalesceMs)&&(P.coalesceMs=p.coalesceMs),Number.isFinite(p.promoteToMemoryBelow)&&(P.promoteToMemoryBelow=p.promoteToMemoryBelow),P}function k(h,b,p){if(b)return b;const f=y(h);if(f)return f;const w=p&&p.headers&&N(p.headers.get)?p.headers.get("content-type"):null;return l(w)}function y(h){const b=String(h).split(/[?#]/)[0].toLowerCase();if(b.endsWith(".ndjson")||b.endsWith(".jsonl"))return"ndjson";if(b.endsWith(".json"))return"json"}function l(h){if(!h)return;const b=h.split(";")[0].trim().toLowerCase();if(x.has(b))return"ndjson";if(b==="application/json"||b==="text/json"||b.endsWith("+json"))return"json"}function u(h,b){const p=h.replace(/^\s+/,""),f=t(p);if(f==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${b} — pass opts.format: 'json' | 'ndjson'.`);return f}async function n(h,b,p){let f="",w=0;for(;;){const{value:m,done:d}=await h.read();if(m&&(w+=m.byteLength,f+=b.decode(m,{stream:!0})),d){f+=b.decode();break}const j=f.replace(/^\s+/,"");if(j){if(j[0]==="[")return{format:"json",seed:f,bytes:w};if(j[0]!=="{"||f.indexOf(`
|
|
8
8
|
`)!==-1)break}}const S=t(f.replace(/^\s+/,""));if(S==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${p} — pass opts.format: 'json' | 'ndjson'.`);return{format:S,seed:f,bytes:w}}function t(h){if(!h||h[0]==="[")return"json";if(h[0]!=="{")return"error";const b=h.indexOf(`
|
|
9
9
|
`);if(b===-1)return"json";let p=h.slice(0,b);return p.endsWith("\r")&&(p=p.slice(0,-1)),i(p)?"ndjson":"json"}function i(h){try{return JSON.parse(h),!0}catch{return!1}}async function s(h,b,p){let f=p;for(;;){const{value:w,done:S}=await h.read();if(w&&(f+=b.decode(w,{stream:!0})),S)break}return f+=b.decode(),f}function*r(h,b,p,f){let w;try{w=JSON.parse(h)}catch(m){throw new Error(`[lattice] createUrlSource: ${b} is not valid JSON — ${m.message}`)}let S=p!==void 0?W(w,p):w;if(f&&(S=f(S)),!Array.isArray(S)){const m=p!==void 0||f?"":"; pass opts.rowsPath or opts.map to select the array";throw new Error(`[lattice] createUrlSource: ${b} did not resolve to an array${m}.`)}yield{rows:S,progress:{loaded:S.length,estimated:S.length}}}async function*o(h,b,p,f,w,S,m,d){const j=g(w);let E=p||"",O=f||0,T=0,A=0,P=[];function*L(){let H;for(;(H=E.indexOf(`
|
|
@@ -55,6 +55,6 @@ ${te}[data-heat-side="low"]{background-color:color-mix(in srgb, var(--lattice-va
|
|
|
55
55
|
`);return A===E?!1:(b.value=p.slice(0,d)+A+p.slice(j),this.#r(Math.max(d,f+(h?-S.length:S.length)),Math.max(d,w+T)),this.revalidate(),!0)}#r(h,b){const p=this.input;p&&(p.selectionStart=h,p.selectionEnd=b===void 0?h:b,V(p.setSelectionRange)&&p.setSelectionRange(p.selectionStart,p.selectionEnd))}format(h){const b=this.input;if(!b||this.language!=="json")return!1;const p=n(b.value);if(!p.ok)return this.revalidate(),!1;if(p.value===null&&b.value.trim()==="")return!1;try{const f=JSON.stringify(p.value,null,h===void 0?this.indent:h);return f===void 0?!1:(b.value=f,this.#r(f.length),this.revalidate(),!0)}catch{return!1}}revalidate(){const h=this.input?this.input.value:"",b=r(h,this.language);this.lastResult=b;const p=this.errorNode;return p&&(p.textContent=b.ok?"":o(b),p.classList.toggle(v.errorOn,!b.ok)),this.input&&(b.ok?this.input.removeAttribute("aria-invalid"):this.input.setAttribute("aria-invalid","true"),b.ok||!p?this.input.removeAttribute("aria-errormessage"):(p.id||(p.id=U("lat-err")),this.input.setAttribute("aria-errormessage",p.id))),b}text(){return this.input?this.input.value:""}readValue(){const h=this.text();if(h.trim()==="")return null;if(this.language!=="json"||(this.props.parseOnCommit??!0)!==!0)return h;const p=n(h);return p.ok?p.value:h}checkValue(h){if(this.props.allowInvalid===!0)return!0;const b=this.revalidate();return b.ok?!0:o(b)}toClipboard(){return this.text()}fromClipboard(h){const b=h==null?"":String(h);return this.input&&(this.input.value=b),this.revalidate(),b.trim()===""?{ok:!0,value:null}:this.language!=="json"?{ok:!0,value:b}:{ok:!0,value:I(b)}}destroy(){for(const h of this.#e)h();this.#e.length=0,this.input=null,this.errorNode=null,this.formatButton=null,super.destroy()}}const a=c}),Ae("packages/dom/src/editors/unit.js",function(e,G){"use strict";Object.defineProperty(e,"presentUnit",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const q=G("packages/dom/src/editors/common.js"),M=q.BaseEditor,$=q.CLS,N=q.el,W=q.on,V=G("packages/core/src/internal/util.js").isFunction,U=G("packages/core/src/columns/types/unit.js"),x=U.parseUnit,I=U.formatUnit,v=U.findUnit;function k(u,n){return I(u,n)}class y extends M{input=null;hint=null;opts=null;#e=[];buildOptions(){const n=this.props,t=this.params.column&&this.params.column.dataType||null,i=t&&t.unitConfig||{};return{system:n.system||i.system||"data",unit:n.unit??i.unit,binary:n.binary===!0||n.binary===void 0&&i.binary===!0,display:n.display??i.display,locale:this.params.locale,group:!1,minDecimals:0,maxDecimals:20}}build(){const n=this.props;this.opts=this.buildOptions();const t=this.symbol(),i=`${this.id}-unit`,s=N(this.doc,"input",{class:$.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:n.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":t?i:null}});s.value=k(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(s.value=this.params.key),this.input=s;const r=typeof n.step=="number"?n.step:0;return r>0&&this.#e.push(W(s,"keydown",o=>{o.key==="ArrowUp"?(V(o.preventDefault)&&o.preventDefault(),this.nudge(r)):o.key==="ArrowDown"&&(V(o.preventDefault)&&o.preventDefault(),this.nudge(-r))})),this.hint=N(this.doc,"span",{class:`${$.editor}__suffix`,text:t,attrs:{id:i,"aria-hidden":"true"}}),N(this.doc,"div",{class:`${$.editor}__unit`,children:[s,this.hint]})}symbol(){const n=v(this.opts.system,this.opts.unit);return n?n.symbol:String(this.opts.unit||"")}focusTarget(){return this.input}attached(){super.attached();const n=this.input;n&&!this.params.key&&this.props.selectOnFocus!==!1&&V(n.select)&&n.select()}nudge(n){const t=x(this.input?this.input.value:"",this.opts);let i=(t??0)+n;const{min:s,max:r}=this.props;typeof s=="number"&&i<s&&(i=s),typeof r=="number"&&i>r&&(i=r),this.input&&(this.input.value=k(i,this.opts))}readValue(){const n=this.input?this.input.value:"";if(String(n).trim()==="")return null;const t=x(n,this.opts);if(t===null)return NaN;if(this.mode()!=="clamp")return t;const{min:i,max:s}=this.props;let r=t;return typeof i=="number"&&r<i&&(r=i),typeof s=="number"&&r>s&&(r=s),r}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}checkValue(n){if(n===null)return!0;if(typeof n!="number"||Number.isNaN(n)){const t=this.symbol();return t?`Enter a value such as 10 ${t}`:"Enter a value"}if(this.mode()==="reject"){const{min:t,max:i}=this.props;if(typeof t=="number"&&n<t)return`Must be ${this.describe(t)} or more`;if(typeof i=="number"&&n>i)return`Must be ${this.describe(i)} or less`}return!0}describe(n){return I(n,{...this.opts,display:this.opts.unit,group:!0,maxDecimals:4})}toClipboard(){return I(this.readValue(),{...this.opts,display:this.opts.unit})}fromClipboard(n){const t=n==null?"":String(n);if(t.trim()==="")return{ok:!0,value:null};const i=x(t,this.opts),s=i===null?NaN:i,r=this.checkValue(s);return r!==!0?{ok:!1,message:r}:{ok:!0,value:s}}destroy(){for(const n of this.#e)n();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const l=y}),Ae("packages/dom/src/editors/radix.js",function(e,G){"use strict";Object.defineProperty(e,"RADIX_CLS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"mergeRadixOptions",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const q=G("packages/dom/src/editors/common.js"),M=q.BaseEditor,$=q.CLS,N=q.el,W=q.on,Z=G("packages/core/src/internal/util.js"),V=Z.isFunction,U=Z.uid,x=G("packages/core/src/columns/types/radix.js"),I=x.compileRadixFormat,v=x.compileRadixParse,k=x.normaliseRadixOptions,y=x.radixRange,l=Object.freeze({root:"lat-editor__radix",hint:"lat-editor__hint",hintInvalid:"lat-editor__hint--invalid"}),u=Object.freeze(["preset","radix","prefix","uppercase","pad","group","groupSeparator","bitWidth","signed","nullDisplay"]),n=new Map;function t(o){const c=o||"";let a=n.get(c);if(a)return a;try{a=new Intl.NumberFormat(o||void 0,{maximumFractionDigits:0})}catch{a={format:g=>String(g)}}return n.set(c,a),a}function i(o,c){const a=c||{},g={};if(o){for(const b of u)o[b]!==void 0&&(g[b]=o[b]);const h=y(o.bitWidth??null,o.signed!==!1);typeof o.min=="number"&&o.min>h.min&&(g.min=o.min),typeof o.max=="number"&&o.max<h.max&&(g.max=o.max)}for(const h of u)a[h]!==void 0&&(g[h]=a[h]);return typeof a.min=="number"&&(g.min=a.min),typeof a.max=="number"&&(g.max=a.max),k(g)}class s extends M{input=null;hint=null;options=null;format=null;parse=null;#e=[];build(){const c=this.params.column&&this.params.column.dataType;this.options=i(c&&c.radix||null,this.props),this.format=I(this.options),this.parse=v(this.options);const a=N(this.doc,"input",{class:$.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}});a.value=this.format(this.params.value),this.params.key&&this.#t(this.params.key)&&(a.value=this.params.key),this.input=a;const g=N(this.doc,"span",{class:l.hint,attrs:{"aria-live":"polite"}});this.hint=g,this.#e.push(W(a,"input",()=>this.refresh())),this.#e.push(W(a,"keydown",b=>this.#n(b)));const h=N(this.doc,"div",{class:l.root,children:[a,g]});return this.refresh(),h}focusTarget(){return this.input}attached(){super.attached();const c=this.input;c&&!this.params.key&&this.props.selectOnFocus!==!1&&V(c.select)&&c.select()}#t(c){return c.length===1&&/[0-9a-fA-FxXbBoO#+\-.]/.test(c)}#n(c){const a=typeof this.props.step=="number"&&this.props.step!==0?this.props.step:1;c.key==="ArrowUp"?(V(c.preventDefault)&&c.preventDefault(),this.nudge(a)):c.key==="ArrowDown"&&(V(c.preventDefault)&&c.preventDefault(),this.nudge(-a))}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}clamp(c){const{min:a,max:g}=this.options;return c<a?a:c>g?g:c}evaluate(){const c=this.input?String(this.input.value):"";if(c.trim()==="")return{value:null,message:null};const a=this.parse(c);return a.ok?{value:this.mode()==="clamp"?this.clamp(a.value):a.value,message:null}:this.mode()==="clamp"&&typeof a.value=="number"&&(a.reason==="range"||a.reason==="negative")?{value:this.clamp(a.value),message:null}:{value:NaN,message:this.messageFor(a.reason)}}messageFor(c){const a=this.options;return c==="negative"?`This column holds an unsigned ${a.bitWidth}-bit pattern; enter ${this.format(0)} or more`:c==="range"?`Must be between ${this.format(a.min)} and ${this.format(a.max)}`:`Enter a ${a.name} value, e.g. ${this.format(a.radix===2?5:26)}`}refresh(){const{value:c,message:a}=this.evaluate();if(this.input&&this.input.classList&&(a?this.input.classList.add($.invalid):this.input.classList.remove($.invalid),this.input.setAttribute("aria-invalid",a?"true":"false"),a&&this.hint?(this.hint.id||(this.hint.id=U("lat-err")),this.input.setAttribute("aria-errormessage",this.hint.id)):this.input.removeAttribute("aria-errormessage")),!!this.hint){if(a){this.hint.textContent=a,this.hint.classList&&this.hint.classList.add(l.hintInvalid);return}this.hint.classList&&this.hint.classList.remove(l.hintInvalid),this.hint.textContent=c===null?"":`= ${t(this.params.locale).format(c)}`}}nudge(c){if(!this.input)return;const a=this.parse(this.input.value);let g;typeof a.value=="number"?g=a.value:typeof this.params.value=="number"?g=this.params.value:g=0,this.input.value=this.format(this.clamp(g+c)),this.refresh()}readValue(){return this.evaluate().value}checkValue(c){return c===null?!0:typeof c!="number"||Number.isNaN(c)?this.evaluate().message||this.messageFor("digits"):!this.options.signed&&c<0?this.messageFor("negative"):this.mode()==="reject"&&(c<this.options.min||c>this.options.max)?this.messageFor("range"):!0}toClipboard(){const c=this.readValue();return c===null||Number.isNaN(c)?this.input?String(this.input.value):"":this.format(c)}fromClipboard(c){const a=c==null?"":String(c);if(a.trim()==="")return{ok:!0,value:null};const g=this.parse(a);let h;if(g.ok)h=g.value;else if(this.mode()==="clamp"&&typeof g.value=="number"&&(g.reason==="range"||g.reason==="negative"))h=this.clamp(g.value);else return{ok:!1,message:this.messageFor(g.reason)};const b=this.checkValue(h);return b!==!0?{ok:!1,message:b}:{ok:!0,value:h}}destroy(){for(const c of this.#e)c();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const r=s}),Ae("packages/dom/src/editors/segmented.js",function(e,G){"use strict";Object.defineProperty(e,"SEGMENTED_MAX",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});const q=G("packages/dom/src/editors/common.js"),M=q.BaseEditor,$=q.CLS,N=q.el,W=q.on,Z=q.keyOf,V=q.normaliseLookup,U=q.documentFor,x=q.lookupFor,v=G("packages/dom/src/editors/select.js").SelectEditor,y=G("packages/core/src/internal/util.js").isFunction,u=G("packages/dom/src/cell/icons.js").createIcon,n=6;class t extends M{static popup=!1;options=[];selected=null;segments=[];focused=0;#e=null;#t=[];init(o){const c=o||{},a=i(c),g=x(c,a,{colId:c.column&&(c.column.id||c.column.field)}),h=Number(a.max??n),b=g.options().length;if(Number.isFinite(h)&&b>h){const p=new v;p.init(c),this.#e=p,this.params=c,this.doc=U(c),this.props=a,this.lookup=g,this.popup=p.popup;return}super.init(c),(!this.lookup||!this.lookup.options().length)&&(this.lookup=g)}usesFallback(){return this.#e!==null}build(){const o=this.doc;this.options=this.lookup?this.lookup.options():[],this.selected=this.params.value??null;const c=N(o,"div",{class:`${$.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 a=0;a<this.options.length;a++)c.appendChild(this.buildSegment(this.options[a],a));return this.props.allowClear===!0&&c.appendChild(this.buildClear()),this.#t.push(W(c,"keydown",a=>this.onKeyDown(a))),this.focused=Math.max(0,this.indexOf(this.selected)),this.paint(),c}buildSegment(o,c){const a=this.doc,g=N(a,"button",{class:`${$.editor}__segment`,attrs:{type:"button",role:"radio",tabindex:"-1","aria-checked":"false","data-index":c,"data-variant":o.variant??null,"aria-disabled":o.disabled===!0?"true":null}});return o.icon&&g.appendChild(u(a,o.icon,{className:$.icon})),g.appendChild(N(a,"span",{class:`${$.editor}__segment-label`,text:o.label})),this.#t.push(W(g,"mousedown",h=>{h&&y(h.preventDefault)&&h.preventDefault(),o.disabled!==!0&&(this.focused=c,this.select(c,{commit:!0}))})),this.segments.push(g),g}buildClear(){const o=N(this.doc,"button",{class:`${$.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clear")}});return this.#t.push(W(o,"mousedown",c=>{c&&y(c.preventDefault)&&c.preventDefault(),this.clearSelection()})),o}indexOf(o){if(o==null)return-1;const c=Z(o);for(let a=0;a<this.options.length;a++)if(Z(this.options[a].id)===c)return a;return-1}paint(){for(let o=0;o<this.segments.length;o++){const c=o===this.indexOf(this.selected),a=this.segments[o];a.setAttribute("aria-checked",c?"true":"false"),a.setAttribute("tabindex",o===this.focused?"0":"-1"),a.classList.toggle(`${$.editor}__segment--active`,c),a.classList.toggle(`${$.editor}__segment--disabled`,this.options[o].disabled===!0)}}select(o,c){const a=this.options[o];!a||a.disabled===!0||(this.selected=a.id,this.paint(),c&&c.commit&&this.commit())}clearSelection(){this.selected=null,this.paint()}moveFocus(o){const c=this.segments.length;if(!c)return;let a=this.focused;for(let g=0;g<c;g++)if(a=(a+o+c)%c,this.options[a].disabled!==!0){this.focusAt(a);return}}focusAt(o){if(o<0||o>=this.segments.length)return;this.focused=o,this.paint();const c=this.segments[o];c&&y(c.focus)&&c.focus()}edgeIndex(o){const c=this.options.length;for(let a=0;a<c;a++){const g=o===1?a:c-1-a;if(this.options[g].disabled!==!0)return g}return-1}onKeyDown(o){const c=()=>{y(o.preventDefault)&&o.preventDefault()};switch(o.key){case"ArrowRight":case"ArrowDown":c(),this.moveFocus(1);break;case"ArrowLeft":case"ArrowUp":c(),this.moveFocus(-1);break;case"Home":c(),this.focusAt(this.edgeIndex(1));break;case"End":c(),this.focusAt(this.edgeIndex(-1));break;case"Enter":c(),this.select(this.focused,{commit:!0});break;case" ":case"Spacebar":c(),this.select(this.focused);break;case"Escape":c(),this.cancel();break;case"Tab":this.select(this.focused),this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(c(),this.clearSelection());break;default:break}}readValue(){return this.selected??null}checkValue(o){return o==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.lookup||!this.lookup.options().length||this.lookup.option(o)||this.lookup.allowCustom||this.props.allowCustom===!0?!0:`"${String(o)}" 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 o=this.indexOf(this.selected);return this.segments[o>=0?o:Math.max(0,this.edgeIndex(1))]||null}attached(){if(this.#e){this.#e.attached();return}if(super.attached(),!this.lookup)return;const o=this.lookup.ready();!o||!y(o.then)||o.then(()=>{if(!super.element()||this.options.length)return;const c=super.element();this.options=this.lookup.options();for(let a=0;a<this.options.length;a++)c.appendChild(this.buildSegment(this.options[a],a));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(o){return this.#e?this.#e.validate(o):super.validate(o)}message(){return this.#e?this.#e.message():super.message()}toClipboard(){return this.#e?this.#e.toClipboard():super.toClipboard()}fromClipboard(o){return this.#e?this.#e.fromClipboard(o):super.fromClipboard(o)}destroy(){for(const o of this.#t)o();this.#t.length=0,this.segments.length=0,this.options=[],this.#e&&(this.#e.destroy(),this.#e=null),super.destroy()}}function i(r){return{...r.column&&r.column.edit&&r.column.edit.props||{},...r.props||{}}}const s=t}),Ae("packages/dom/src/editors/rating.js",function(e,G){"use strict";Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"normaliseRating",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});const q=G("packages/dom/src/editors/common.js"),M=q.BaseEditor,$=q.CLS,N=q.el,W=q.on,V=G("packages/dom/src/cell/icons.js").createIcon,U=G("packages/dom/src/cell/renderers/rating.js"),x=U.ratingFills,I=U.fillState,v=U.ratingText,k=U.clampRating,y=U.DEFAULT_RATING_ICON,l=U.DEFAULT_RATING_MAX,n=G("packages/core/src/internal/util.js").isFunction;class t extends M{static popup=!1;rating=null;preview=null;items=[];fills=[];slider=null;readout=null;#e=[];max(){const o=Math.floor(Number(this.props.max??l));return Number.isFinite(o)&&o>0?o:l}step(){return this.props.allowHalf===!0?.5:1}build(){const o=this.doc,c=this.max();this.rating=i(this.params.value,c,this.props.allowHalf===!0);const a=N(o,"div",{class:`${$.editor}__rating`}),g=N(o,"div",{class:`${$.editor}__rating-slider`,attrs:{role:"slider",tabindex:"0","aria-valuemin":"0","aria-valuemax":String(c),"aria-label":this.params.column&&this.params.column.title||"Rating"}});for(let b=0;b<c;b++)g.appendChild(this.buildItem(b));a.appendChild(g),this.slider=g;const h=N(o,"span",{class:`${$.editor}__rating-value`});return a.appendChild(h),this.readout=h,this.props.allowClear===!0&&a.appendChild(this.buildClear()),this.#e.push(W(g,"keydown",b=>this.onKeyDown(b))),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),c)),this.paint(),a}buildItem(o){const c=this.doc,a=String(this.props.icon??y),g=N(c,"span",{class:`${$.editor}__rating-fill`,attrs:{"aria-hidden":"true"},children:[V(c,a,{className:$.icon})]}),h=N(c,"span",{class:`${$.editor}__rating-item`,attrs:{"data-index":o,"data-icon":a,"aria-hidden":"true"},children:[V(c,a,{className:$.icon}),g]});return this.fills.push(g),this.#e.push(W(h,"mousedown",b=>{b&&n(b.preventDefault)&&b.preventDefault(),this.setRating(this.ratingAt(o,b),{commit:!0})})),this.props.hoverPreview!==!1&&this.#e.push(W(h,"mousemove",b=>{const p=this.ratingAt(o,b);p!==this.preview&&(this.preview=p,this.paint())})),this.items.push(h),h}buildClear(){const o=N(this.doc,"button",{class:`${$.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearRating")}});return this.#e.push(W(o,"mousedown",c=>{c&&n(c.preventDefault)&&c.preventDefault(),this.setRating(null)})),o}ratingAt(o,c){if(this.props.allowHalf!==!0)return o+1;const a=this.items[o],g=a&&Number(a.offsetWidth),h=c&&Number(c.offsetX);return!Number.isFinite(g)||g<=0||!Number.isFinite(h)?o+1:h*2<g?o+.5:o+1}focusTarget(){return this.slider}setRating(o,c){this.rating=o===null?null:k(o,this.max(),this.props.allowHalf===!0,!1),this.preview=null,this.paint(),c&&c.commit&&this.commit()}nudge(o){const c=this.rating===null?0:this.rating;this.setRating(c+o)}paint(){const o=this.max(),c=this.props.allowHalf===!0,a=this.preview===null?this.rating:this.preview,g=x(a===null?0:a,o,{allowHalf:c});for(let p=0;p<this.items.length;p++){const f=I(g[p]);this.items[p].setAttribute("data-fill",f),this.items[p].classList.toggle(`${$.editor}__rating-item--filled`,f!=="empty"),this.fills[p]&&this.fills[p].style.setProperty("--lat-rating-fill",`${(g[p]*100).toFixed(2)}%`)}const h=a===null?String(this.props.emptyLabel??this.t("cell.rating.empty")):this.t("cell.rating.of",{rating:v(a),max:o}),b=this.slider;b&&(b.setAttribute("aria-valuenow",a===null?"0":String(a)),b.setAttribute("aria-valuetext",h),b.setAttribute("data-preview",this.preview===null?"false":"true")),this.readout&&(this.readout.textContent=h)}onKeyDown(o){const c=()=>{n(o.preventDefault)&&o.preventDefault()},a=this.step();if(/^[0-9]$/.test(o.key)){c(),this.setRating(Math.min(Number(o.key),this.max()));return}switch(o.key){case"ArrowRight":case"ArrowUp":c(),this.nudge(a);break;case"ArrowLeft":case"ArrowDown":c(),this.nudge(-a);break;case"Home":c(),this.setRating(0);break;case"End":c(),this.setRating(this.max());break;case"Enter":c(),this.commit();break;case"Escape":c(),this.cancel();break;case"Tab":this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(c(),this.setRating(null));break;default:break}}readValue(){return this.rating}checkValue(o){if(o==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a rating";if(typeof o!="number"||!Number.isFinite(o))return"Enter a rating";const c=this.max();return o<0?"Must be 0 or more":o>c?`Must be ${c} or less`:this.props.allowHalf!==!0&&!Number.isInteger(o)?"Choose a whole rating":!0}toClipboard(){return this.rating===null?"":v(this.rating)}fromClipboard(o){const c=String(o??"").trim();if(c==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a rating"};const a=Number(c);if(!Number.isFinite(a))return{ok:!1,message:`"${c}" is not a rating`};const g=this.checkValue(a);return g!==!0?{ok:!1,message:g}:{ok:!0,value:a}}destroy(){for(const o of this.#e)o();this.#e.length=0,this.items.length=0,this.slider=null,this.readout=null,super.destroy()}}function i(r,o,c){if(r==null||r==="")return null;const a=Number(r);return Number.isFinite(a)?k(a,o,c,!1):null}const s=t}),Ae("packages/dom/src/editors/slider.js",function(e,G){"use strict";Object.defineProperty(e,"SLIDER_MIN",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"SLIDER_MAX",{enumerable:!0,get:function(){return k}}),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 u}}),Object.defineProperty(e,"normaliseMarks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const q=G("packages/dom/src/editors/common.js"),M=q.BaseEditor,$=q.CLS,N=q.el,W=q.on,Z=G("packages/dom/src/editors/number.js"),V=Z.parseNumberText,U=Z.presentNumber,I=G("packages/core/src/internal/util.js").isFunction,v=0,k=100;class y extends M{static popup=!1;amount=null;range=null;field=null;readout=null;root=null;marks=[];#e=[];min(){const s=Number(this.props.min??v);return Number.isFinite(s)?s:v}max(){const s=Number(this.props.max??k);return Number.isFinite(s)?s:k}step(){const s=Number(this.props.step??1);return Number.isFinite(s)&&s>0?s:1}build(){const s=this.doc,r=this.min(),o=this.max(),c=this.step(),a=n(this.props.marks);this.marks=a,this.amount=this.params.value==null||this.params.value===""?null:this.snap(Number(this.params.value));const g=N(s,"div",{class:`${$.editor}__slider`});this.root=g;const h=N(s,"input",{class:`${$.editor}__slider-input`,attrs:{type:"range",min:String(r),max:String(o),step:String(c),"aria-label":this.params.column&&this.params.column.title||null,"aria-valuetext":null,list:a.length?`${this.id}-marks`:null}});if(this.range=h,g.appendChild(h),a.length){const p=N(s,"datalist",{attrs:{id:`${this.id}-marks`}}),f=N(s,"div",{class:`${$.editor}__slider-marks`});for(const w of a){p.appendChild(N(s,"option",{attrs:{value:String(w.value),label:w.label}}));const S=N(s,"span",{class:`${$.editor}__slider-mark`,text:w.label,attrs:{"data-value":String(w.value)}});S.style&&I(S.style.setProperty)&&S.style.setProperty("--lat-slider-mark",`${(l(w.value,r,o)*100).toFixed(2)}%`),f.appendChild(S)}g.appendChild(p),g.appendChild(f)}const b=N(s,"input",{class:`${$.editor}__slider-number`,attrs:{type:"text",inputmode:"decimal","aria-label":this.t("editor.value")}});if(this.field=b,g.appendChild(b),this.props.showValue!==!1){const p=N(s,"span",{class:`${$.editor}__slider-value`});g.appendChild(p),this.readout=p}return this.#e.push(W(h,"input",()=>this.setAmount(Number(h.value),"range"))),this.#e.push(W(h,"change",()=>this.setAmount(Number(h.value),"range"))),this.#e.push(W(h,"keydown",p=>this.onKeyDown(p))),this.#e.push(W(b,"input",()=>this.onFieldInput())),this.#e.push(W(b,"change",()=>this.paint())),this.#e.push(W(b,"keydown",p=>this.onKeyDown(p))),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(b.value=this.params.key,this.onFieldInput()),this.paint(),g}focusTarget(){return this.field}attached(){super.attached();const s=this.field;s&&!this.params.key&&this.props.selectOnFocus!==!1&&I(s.select)&&s.select()}snap(s){if(!Number.isFinite(s))return this.min();const r=this.min(),o=this.max(),c=this.step(),a=Math.min(Math.max(s,r),o),g=r+Math.round((a-r)/c)*c,h=u(c),b=h>0?Number(g.toFixed(h)):Math.round(g);return Math.min(Math.max(b,r),o)}setAmount(s,r){this.amount=s===null?null:this.snap(s),this.paint(r)}onFieldInput(){const s=this.field?String(this.field.value):"";if(s.trim()===""){this.amount=null,this.paint("field");return}const r=V(s,this.params.locale);if(r===null||Number.isNaN(r)){this.paint("field");return}this.setAmount(r,"field")}paint(s){const r=this.min(),o=this.max(),c=this.amount,a=c===null?r:c;this.range&&s!=="range"&&(this.range.value=String(a)),this.field&&s!=="field"&&(this.field.value=c===null?"":U(c,this.props));const g=this.root;g&&g.style&&I(g.style.setProperty)&&g.style.setProperty("--lat-slider-pos",`${(l(a,r,o)*100).toFixed(2)}%`),g&&g.setAttribute&&g.setAttribute("data-empty",c===null?"true":"false");const h=this.labelFor(c);this.range&&this.range.setAttribute&&this.range.setAttribute("aria-valuetext",h),this.readout&&(this.readout.textContent=h)}labelFor(s){if(s===null)return String(this.props.emptyLabel??"");const r=this.marks.find(c=>c.value===s),o=U(s,this.props);return r&&r.label!==o?`${o} (${r.label})`:o}onKeyDown(s){if(s.key==="Escape"){I(s.preventDefault)&&s.preventDefault(),this.cancel();return}if(s.key==="Enter"){I(s.preventDefault)&&s.preventDefault(),this.commit();return}s.key==="Tab"&&this.commit()}readValue(){const s=this.field?String(this.field.value):"";if(s.trim()==="")return null;const r=V(s,this.params.locale);return r===null||Number.isNaN(r)?NaN:this.snap(r)}checkValue(s){return s==null?this.props.allowClear===!0||this.params.value==null?!0:"Enter a value":typeof s!="number"||Number.isNaN(s)?"Enter a number":s<this.min()?`Must be ${this.min()} or more`:s>this.max()?`Must be ${this.max()} or less`:!0}fromClipboard(s){const r=String(s??"").trim();if(r==="")return this.checkValue(null)===!0?{ok:!0,value:null}:{ok:!1,message:"Enter a value"};const o=V(r,this.params.locale);if(o===null||Number.isNaN(o))return{ok:!1,message:"Enter a number"};const c=this.snap(o),a=this.checkValue(c);return a!==!0?{ok:!1,message:a}:{ok:!0,value:c}}destroy(){for(const s of this.#e)s();this.#e.length=0,this.range=null,this.field=null,this.readout=null,this.root=null,this.marks=[],super.destroy()}}function l(i,s,r){const o=r-s;return!Number.isFinite(o)||o===0?0:Math.min(1,Math.max(0,(Number(i)-s)/o))}function u(i){if(!Number.isFinite(i))return 0;const s=String(i),r=s.indexOf("e");if(r>=0){const c=s.slice(0,r),a=c.indexOf("."),g=a<0?0:c.length-a-1;return Math.min(15,Math.max(0,g-Number(s.slice(r+1))))}const o=s.indexOf(".");return o<0?0:Math.min(15,s.length-o-1)}function n(i){if(!i)return[];const s=[];if(Array.isArray(i)){for(const r of i){if(r&&typeof r=="object"){const c=Number(r.value);Number.isFinite(c)&&s.push({value:c,label:String(r.label??c)});continue}const o=Number(r);Number.isFinite(o)&&s.push({value:o,label:String(o)})}return s}if(typeof i=="object")for(const[r,o]of Object.entries(i)){const c=Number(r);Number.isFinite(c)&&s.push({value:c,label:String(o)})}return s}const t=y}),Ae("packages/dom/src/editors/colour.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_SWATCHES",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"TOKEN_FALLBACK",{enumerable:!0,get:function(){return k}}),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 u}}),Object.defineProperty(e,"toSwatches",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const q=G("packages/dom/src/editors/common.js"),M=q.BaseEditor,$=q.CLS,N=q.el,W=q.on,Z=G("packages/dom/src/cell/renderers/colour.js"),V=Z.normaliseColour,U=Z.parseColour,I=G("packages/core/src/internal/util.js").isFunction,v=Object.freeze(["neutral","info","success","warning","danger","accent"]),k=Object.freeze({neutral:"#5b6670",info:"#1a6bc7",success:"#1b7f3b",warning:"#a96a0b",danger:"#c22b2b",accent:"#5a46d6"});function y(s){if(s==null)return null;if(typeof s=="object"){const c=s,a=y(c.token??c.value??c.colour??c.color);return a?{...a,label:c.label==null?a.label:String(c.label)}:null}const r=String(s).trim();if(r==="")return null;const o=V(r);return o?{token:null,hex:o,label:o}:Object.hasOwn(k,r)?{token:r,hex:k[r],label:r}:null}function l(s,r){const o=s&&s.ownerDocument,c=o&&o.defaultView;if(!c||!I(c.getComputedStyle))return null;try{const a=c.getComputedStyle(s);return!a||!I(a.getPropertyValue)?null:V(String(a.getPropertyValue(`--lattice-variant-${r}-solid`)).trim())}catch{return null}}class u extends M{static popup=!0;swatches=[];buttons=[];native=null;hex=null;preview=null;#e=[];alpha(){return this.props.alpha===!0}build(){const r=this.doc;this.swatches=n(this.props.swatches);const o=N(r,"div",{class:`${$.editor}__colour`,attrs:{"aria-label":this.params.column&&this.params.column.title||null}});if(this.preview=N(r,"span",{class:`${$.editor}__colour-preview`,attrs:{"aria-hidden":"true"}}),o.appendChild(this.preview),this.swatches.length){const a=N(r,"div",{class:`${$.editor}__colour-swatches`,attrs:{role:"radiogroup","aria-label":this.t("editor.colours")}});for(let g=0;g<this.swatches.length;g++)a.appendChild(this.buildSwatch(this.swatches[g],g));o.appendChild(a)}this.native=N(r,"input",{class:`${$.editor}__colour-native`,attrs:{type:"color","aria-label":this.t("editor.customColour")}}),o.appendChild(this.native),this.hex=N(r,"input",{class:`${$.editor}__colour-hex`,attrs:{type:"text",spellcheck:"false",autocomplete:"off",placeholder:this.t("editor.hexPlaceholder"),"aria-label":this.t("editor.hexValue")}}),o.appendChild(this.hex),this.props.allowClear===!0&&o.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",a=>this.onKeyDown(a))),this.#e.push(W(o,"keydown",a=>this.onKeyDown(a)));const c=V(this.params.value,{alpha:this.alpha()});return this.hex.value=c===null?this.params.value==null?"":String(this.params.value):c,this.params.key&&/^[#0-9a-fA-F]$/.test(this.params.key)&&(this.hex.value=this.params.key),this.paint(),o}buildSwatch(r,o){const c=N(this.doc,"button",{class:`${$.editor}__colour-swatch`,attrs:{type:"button",role:"radio","aria-checked":"false","aria-label":r.label,"data-index":o,"data-variant":r.token}});return r.token||t(c,r.hex),this.#e.push(W(c,"mousedown",a=>{a&&I(a.preventDefault)&&a.preventDefault(),this.setColour(this.swatches[o].hex)})),this.buttons.push(c),c}buildClear(){const r=N(this.doc,"button",{class:`${$.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearColour")}});return this.#e.push(W(r,"mousedown",o=>{o&&I(o.preventDefault)&&o.preventDefault(),this.setColour(null)})),r}focusTarget(){return this.hex}attached(){super.attached();for(let r=0;r<this.swatches.length;r++){const o=this.swatches[r];if(!o.token)continue;const c=l(this.buttons[r]||this.element(),o.token);c&&(o.hex=c)}this.paint()}setColour(r){const o=r===null?null:V(r,{alpha:this.alpha()});this.hex&&(this.hex.value=o===null?"":o),this.paint()}current(){const r=this.hex?String(this.hex.value).trim():"";return r===""?null:V(r,{alpha:this.alpha()})}paint(){const r=this.current(),o=r===null?null:r.slice(0,7);t(this.preview,o),this.preview&&this.preview.setAttribute&&this.preview.setAttribute("data-empty",r===null?"true":"false"),this.native&&(this.native.value=o===null?"#000000":o);for(let c=0;c<this.buttons.length;c++){const a=r!==null&&this.swatches[c].hex.toLowerCase()===r.toLowerCase();this.buttons[c].setAttribute("aria-checked",a?"true":"false"),this.buttons[c].classList.toggle(`${$.editor}__colour-swatch--selected`,a),this.swatches[c].token||t(this.buttons[c],this.swatches[c].hex)}}onKeyDown(r){if(r.key==="Escape"){I(r.preventDefault)&&r.preventDefault(),this.cancel();return}if(r.key==="Enter"){I(r.preventDefault)&&r.preventDefault(),this.commit();return}r.key==="Tab"&&this.commit()}readValue(){const r=this.hex?String(this.hex.value).trim():"";if(r==="")return null;const o=V(r,{alpha:this.alpha()});return o===null?r:o}checkValue(r){if(r==null||r==="")return this.props.allowClear===!0||this.params.value==null?!0:"Choose a colour";const o=U(r);return o?!this.alpha()&&o.a<1?"This column does not accept transparency":!0:`"${String(r)}" is not a colour`}toClipboard(){const r=this.current();return r===null?"":r}fromClipboard(r){const o=String(r??"").trim();if(o==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a colour"};const c=V(o,{alpha:this.alpha()});if(c===null)return{ok:!1,message:`"${o}" is not a colour`};const a=this.checkValue(c);return a!==!0?{ok:!1,message:a}:{ok:!0,value:c}}destroy(){for(const r of this.#e)r();this.#e.length=0,this.buttons.length=0,this.swatches=[],this.native=null,this.hex=null,this.preview=null,super.destroy()}}function n(s){const r=Array.isArray(s)&&s.length?s:s===!1?[]:v,o=[];for(const c of r){const a=y(c);a&&o.push(a)}return o}function t(s,r){const o=s&&s.style;if(o){if(r===null){I(o.removeProperty)&&o.removeProperty("--lat-swatch");return}I(o.setProperty)&&o.setProperty("--lat-swatch",r)}}const i=u}),Ae("packages/dom/src/editors/treeselect.js",function(e,G){"use strict";Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const M=G("packages/dom/src/editors/select.js").SelectEditorBase,N=G("packages/dom/src/cell/icons.js").createIcon,W=G("packages/dom/src/editors/common.js"),Z=W.CLS,V=W.el,U=W.on,x=W.clear,I=W.keyOf,v=W.rawOptions,k=W.lookupKey,y=G("packages/core/src/internal/util.js"),l=y.isFunction,u=y.isObject,n="\0";class t extends M{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 r=super.build();return r.classList.add("lat-treeselect"),this.list&&this.list.element().setAttribute("role","tree"),r}initSelection(){this.rebuild(),this.selected=this.params.value??null;const r=this.nodeById(this.selected);if(r)for(let o=r.parent;o;o=o.parent)this.expanded.add(o.key)}rebuild(){const r=v(this.params,this.props),o=this.props.keys||{},c=o.value||k(this.params,"valueKey")||"id",a=o.label||k(this.params,"labelKey")||"label";this.roots=[],this.nodes=new Map;for(const g of r){if(!u(g)){this.addNode(null,String(g??""),g,null);continue}Array.isArray(g.path)&&g.path.length?this.addByPath(g,c,a):this.addByChildren(g,null,c,a)}if(this.props.defaultExpanded===!0)for(const g of this.nodes.keys())this.expanded.add(g)}addNode(r,o,c,a){const g=r?`${r.key}${n}${o}`:o;let h=this.nodes.get(g);return h?h.id===void 0&&c!==void 0&&(h.id=c):(h={id:c,label:o,key:g,parent:r,children:[],depth:r?r.depth+1:0,disabled:!1},this.nodes.set(g,h),(r?r.children:this.roots).push(h)),a&&(a.disabled===!0&&(h.disabled=!0),a.icon!==void 0&&(h.icon=a.icon),a.variant!==void 0&&(h.variant=a.variant)),h}addByPath(r,o,c){const a=r.path;let g=null;for(let h=0;h<a.length;h++){const b=h===a.length-1,p=String(a[h]),f=b&&r[c]!=null?String(r[c]):p,w=this.addNode(g,p,b?r[o]:void 0,b?r:null);b&&(w.label=f),g=w}}addByChildren(r,o,c,a){const g=r[c],h=r[a]!=null?String(r[a]):String(g??""),b=this.addNode(o,h,g,r),p=Array.isArray(r.children)?r.children:[];for(const f of p)u(f)?this.addByChildren(f,b,c,a):this.addNode(b,String(f??""),f,null)}nodeById(r){if(r==null)return;const o=I(r);for(const c of this.nodes.values())if(c.id!==void 0&&I(c.id)===o)return c}filterOptions(r){const o=String(r||"").trim().toLowerCase(),c=o!=="";this.matched=c?this.computeMatches(o):new Set;const a=[],g=h=>{for(const b of h)c&&!this.matched.has(b.key)||(a.push(b),b.children.length&&(c||this.expanded.has(b.key))&&g(b.children))};return g(this.roots),a}computeMatches(r){const o=new Set,c=a=>{let g=a.label.toLowerCase().includes(r);for(const h of a.children)c(h)&&(g=!0);return g&&o.add(a.key),g};for(const a of this.roots)c(a);return o}repaint(r){if(this.refreshOptions(),!r||!this.list)return;const o=this.visible.findIndex(c=>c.key===r);o>=0&&this.list.setActive(o)}isBranch(r){return!!r&&r.children.length>0}isSelectable(r){return!r||r.disabled||r.id===void 0||r.id===null?!1:!(this.leavesOnly&&this.isBranch(r))}setExpanded(r,o){this.isBranch(r)&&(o?this.expanded.add(r.key):this.expanded.delete(r.key),this.repaint(r.key))}choose(r){if(r){if(!this.isSelectable(r)){this.isBranch(r)&&this.setExpanded(r,!this.expanded.has(r.key));return}this.selected=r.id,this.input&&(this.input.value=""),this.query="",this.repaint(r.key),this.paintDisplay(),this.commit()}}isSelected(r){return this.selected!=null&&r&&r.id!==void 0&&I(r.id)===I(this.selected)}clearSelection(){this.selected=null,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay()}readValue(){return this.selected??null}checkValue(r){if(r==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a value";if(!this.nodes.size)return!0;const o=this.nodeById(r);return o&&this.isSelectable(o)?!0:o?`"${o.label}" is a group, not a value`:this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(r)}" is not a valid option`}renderOption(r,o,c){x(o),o.setAttribute("role","treeitem"),o.setAttribute("aria-level",String(r.depth+1)),o.setAttribute("data-depth",String(r.depth));const a=V(this.doc,"span",{class:"lat-tree__indent"});for(let w=0;w<r.depth;w++)a.appendChild(V(this.doc,"span",{class:"lat-tree__guide"}));o.appendChild(a);const g=this.isBranch(r),h=g&&(this.expanded.has(r.key)||this.query.trim()!==""),b=g?h?"chevronDown":"chevronRight":"blank",p=V(this.doc,"span",{class:g?"lat-tree__twisty":"lat-tree__twisty lat-tree__twisty--leaf",children:[N(this.doc,b,{className:Z.icon})],attrs:{"data-icon":g?b:null,"aria-hidden":"true"}});g&&U(p,"mousedown",w=>{l(w.preventDefault)&&w.preventDefault(),l(w.stopPropagation)&&w.stopPropagation(),this.setExpanded(r,!this.expanded.has(r.key))}),o.appendChild(p),r.icon&&o.appendChild(N(this.doc,r.icon,{className:Z.icon})),o.appendChild(V(this.doc,"span",{class:`${Z.option}__label`,text:r.label})),r.variant?o.setAttribute("data-variant",r.variant):o.removeAttribute("data-variant"),g?o.setAttribute("aria-expanded",h?"true":"false"):o.removeAttribute("aria-expanded");const f=this.isSelected(r);o.classList.toggle(Z.optionSelected,f),o.classList.toggle(Z.optionDisabled,!this.isSelectable(r)),o.classList.toggle("lat-tree__row--branch",g),o.setAttribute("aria-selected",f?"true":"false"),this.isSelectable(r)?o.removeAttribute("aria-disabled"):o.setAttribute("aria-disabled","true")}paintDisplay(){const r=this.display;if(!r)return;if(x(r),this.selected==null){r.removeAttribute("data-variant");return}const o=this.nodeById(this.selected);if(!o){r.appendChild(V(this.doc,"span",{text:String(this.selected)}));return}o.icon&&r.appendChild(N(this.doc,o.icon,{className:Z.icon})),r.appendChild(V(this.doc,"span",{class:"lat-tree__path",text:this.pathLabel(o)})),o.variant?r.setAttribute("data-variant",o.variant):r.removeAttribute("data-variant")}pathLabel(r){const o=[];for(let c=r;c;c=c.parent)o.unshift(c.label);return o.join(String(this.props.pathSeparator??" / "))}onKeyDown(r){const o=this.list,c=o&&o.active>=0?this.visible[o.active]:null;switch(r.key){case"ArrowRight":{if(l(r.preventDefault)&&r.preventDefault(),!c)return;this.isBranch(c)&&!this.expanded.has(c.key)?this.setExpanded(c,!0):this.isBranch(c)&&o&&o.setActive(Math.min(this.visible.length-1,o.active+1));return}case"ArrowLeft":{if(l(r.preventDefault)&&r.preventDefault(),!c)return;this.isBranch(c)&&this.expanded.has(c.key)?this.setExpanded(c,!1):c.parent&&this.focusNode(c.parent.key);return}case"Home":l(r.preventDefault)&&r.preventDefault(),o&&this.visible.length&&o.setActive(0);return;case"End":l(r.preventDefault)&&r.preventDefault(),o&&this.visible.length&&o.setActive(this.visible.length-1);return;default:super.onKeyDown(r)}}focusNode(r){if(!this.list)return;const o=this.visible.findIndex(c=>c.key===r);o>=0&&this.list.setActive(o)}acceptHighlight(r){const o=this.list,c=o&&o.active>=0?this.visible[o.active]:null;if(!c){r&&r.commit&&this.commit();return}if(this.isSelectable(c)){this.choose(c);return}this.isBranch(c)?this.setExpanded(c,!this.expanded.has(c.key)):r&&r.commit&&this.commit()}moveHighlight(r){const o=this.list;if(!o)return;let c=o.active;for(let a=0;a<this.visible.length;a++){if(c+=r,c<0||c>=this.visible.length)return;if(!this.visible[c].disabled){o.setActive(c);return}}}}const i=t}),Ae("packages/dom/src/editors/objectpicker.js",function(e,G){"use strict";Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"readField",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"initialsOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const M=G("packages/dom/src/editors/select.js").SelectEditorBase,$=G("packages/dom/src/editors/common.js"),N=$.CLS,W=$.el,Z=$.on,V=$.clear,U=$.keyOf,x=$.debounce,I=$.rawOptions,v=$.optionSource,k=$.lookupSearch,y=$.lookupKey,l=G("packages/core/src/internal/util.js"),u=l.isFunction,n=l.isObject,t=l.getPath,s=G("packages/dom/src/cell/icons.js").createIcon;class r extends M{static popup=!0;all=[];selected=null;#e=null;#t=!1;#n=null;build(){const b=super.build();if(b.classList.add("lat-objectpicker"),u(this.props.search)&&!(this.lookup&&this.lookup.search)){const p=Number(this.props.searchDebounce)||200;this.#n=x(f=>this.runRemoteSearch(String(f)),p)}return b}onQuery(b){super.onQuery(b),this.#n&&this.#n(b)}initSelection(){const b=I(this.params,this.props).map(p=>this.toOption(p));(b.length||!this.all.length)&&(this.all=b),this.selected=this.params.value??null}toOption(b){if(!n(b)){const d=b==null?"":String(b);return{id:b,label:d,secondary:"",avatar:"",initials:c(d),disabled:!1,raw:{}}}const p=this.props.valueKey||y(this.params,"valueKey")||"id",f=this.props.labelKey||y(this.params,"labelKey")||"label",w=o(b,this.props.template??f,""),S=o(b,this.props.secondary,""),m=o(b,this.props.avatar,"");return{id:b[p],label:w||String(b[p]??""),secondary:S,avatar:m,initials:c(w||String(b[p]??"")),disabled:b.disabled===!0,icon:b.icon,variant:b.variant,raw:b}}attached(){if(super.attached(),this.#t||this.all.length)return;const b=v(this.params,this.props);u(b)&&(this.#t=!0,Promise.resolve(b()).then(p=>{!this.element()||!Array.isArray(p)||(this.all=p.map(f=>this.toOption(f)),this.refreshOptions(),this.paintDisplay())}))}filterOptions(b){const p=String(b||"").trim().toLowerCase();if(p==="")return this.all;const f=a(this.props.searchFields);return this.all.filter(w=>{if(!f)return w.label.toLowerCase().includes(p)||w.secondary.toLowerCase().includes(p);for(const S of f){const m=u(S)?S(w.raw):t(w.raw,S);if(m!=null&&String(m).toLowerCase().includes(p))return!0}return!1})}async runRemoteSearch(b){const p=k(this.params,this.props);if(!p)return;this.#e&&this.#e.abort();const f=new AbortController;this.#e=f;try{const w=await p(b,f.signal);if(f.signal.aborted||this.#e!==f)return;this.refreshOptions(Array.isArray(w)?w.map(S=>this.toOption(S)):[])}catch(w){if(!f.signal.aborted)throw w}finally{this.#e===f&&(this.#e=null)}}choose(b){!b||b.disabled||(this.selected=b.id,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay(),this.commit())}isSelected(b){return this.selected!=null&&b!=null&&U(b.id)===U(this.selected)}clearSelection(){this.selected=null,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay()}readValue(){return this.selected??null}optionById(b){if(b==null)return;const p=U(b);return this.all.find(f=>U(f.id)===p)}checkValue(b){return b==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.all.length||this.optionById(b)||this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(b)}" is not a valid option`}renderOption(b,p,f){V(p),p.appendChild(this.buildAvatar(b));const w=W(this.doc,"span",{class:"lat-object__text"});w.appendChild(W(this.doc,"span",{class:"lat-object__primary",text:b.label})),b.secondary&&w.appendChild(W(this.doc,"span",{class:"lat-object__secondary",text:b.secondary})),p.appendChild(w),b.icon&&p.appendChild(s(this.doc,b.icon,{className:N.icon})),b.variant?p.setAttribute("data-variant",b.variant):p.removeAttribute("data-variant");const S=this.isSelected(b);p.classList.add("lat-object__row"),p.classList.toggle(N.optionSelected,S),p.classList.toggle(N.optionDisabled,b.disabled===!0),p.setAttribute("aria-selected",S?"true":"false"),b.disabled?p.setAttribute("aria-disabled","true"):p.removeAttribute("aria-disabled")}buildAvatar(b){const p=W(this.doc,"span",{class:"lat-avatar",attrs:{"aria-hidden":"true"}});if(!b.avatar)return p.appendChild(W(this.doc,"span",{class:"lat-avatar__initials",text:b.initials})),p.setAttribute("data-fallback","initials"),p;const f=W(this.doc,"img",{class:"lat-avatar__image",attrs:{src:b.avatar,alt:"",loading:"lazy",decoding:"async"}});return Z(f,"error",()=>{f.parentNode===p&&(p.removeChild(f),p.appendChild(W(this.doc,"span",{class:"lat-avatar__initials",text:b.initials})),p.setAttribute("data-fallback","initials"))}),p.appendChild(f),p}paintDisplay(){const b=this.display;if(!b)return;if(V(b),this.selected==null){b.removeAttribute("data-variant");return}const p=this.optionById(this.selected);if(!p){b.appendChild(W(this.doc,"span",{text:this.lookup?this.lookup.label(this.selected):String(this.selected)}));return}b.appendChild(this.buildAvatar(p)),b.appendChild(W(this.doc,"span",{class:"lat-object__primary",text:p.label})),p.variant?b.setAttribute("data-variant",p.variant):b.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 o(h,b,p){if(b==null)return p;const f=u(b)?b(h):t(h,String(b));return f==null?p:String(f)}function c(h){const b=String(h||"").trim().split(/\s+/).filter(w=>w!=="");if(!b.length)return"";const p=[...b[0]][0]||"";if(b.length===1)return p.toUpperCase();const f=[...b[b.length-1]][0]||"";return(p+f).toUpperCase()}function a(h){if(h==null)return null;const p=(Array.isArray(h)?h:[h]).filter(f=>typeof f=="string"||u(f));return p.length?p:null}const g=r}),Ae("packages/dom/src/editors/iconpicker.js",function(e,G){"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 u}});const q=G("packages/dom/src/editors/common.js"),M=q.BaseEditor,$=q.CLS,N=q.VirtualList,W=q.el,Z=q.on,V=q.clear,U=G("packages/dom/src/cell/icons.js"),x=U.createIcon,I=U.iconNames,k=G("packages/core/src/internal/util.js").isFunction;class y extends M{static popup=!0;input=null;display=null;list=null;names=[];matches=[];rows=[];columns=8;cursor=-1;selected=null;query="";off=[];build(){const t=this.props;this.columns=Math.max(1,Math.floor(Number(t.columns)||8)),this.names=l(t.icons),this.selected=this.params.value==null?null:String(this.params.value);const i=W(this.doc,"div",{class:["lat-iconpicker",`${$.editor}__select`],attrs:{role:"combobox","aria-expanded":"true"}});return this.display=W(this.doc,"div",{class:`${$.editor}__display`}),this.input=W(this.doc,"input",{class:$.input,attrs:{type:"text",autocomplete:"off",placeholder:t.placeholder??"Search icons","aria-label":this.params.column&&this.params.column.title||"Search icons","aria-autocomplete":"list"}}),this.input.value="",this.list=new N({document:this.doc,itemHeight:Number(t.rowHeight)||34,height:Number(t.listHeight)||204,renderItem:(s,r,o)=>this.renderRow(s,r,o)}),this.list.element().setAttribute("role","grid"),this.list.element().setAttribute("aria-label",this.t("panel.icons")),i.appendChild(this.display),i.appendChild(this.input),t.allowClear===!0&&i.appendChild(this.buildClearButton()),i.appendChild(this.list.element()),this.off.push(Z(this.input,"input",()=>this.onQuery(this.input?this.input.value:""))),this.off.push(Z(this.input,"keydown",s=>this.onKeyDown(s))),this.refreshIcons(),this.paintDisplay(),this.params.key&&this.params.key.length===1&&(this.input.value=this.params.key,this.onQuery(this.params.key)),i}buildClearButton(){const t=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(Z(t,"mousedown",i=>{k(i.preventDefault)&&i.preventDefault(),this.selected=null,this.paintDisplay(),this.commit()})),t}focusTarget(){return this.input}onQuery(t){this.query=t,this.refreshIcons()}refreshIcons(){const t=this.query.trim().toLowerCase();this.matches=t===""?this.names.slice():this.names.filter(s=>s.toLowerCase().includes(t)),this.rows=[];for(let s=0;s<this.matches.length;s+=this.columns)this.rows.push(this.matches.slice(s,s+this.columns));const i=this.selected?this.matches.indexOf(this.selected):-1;this.cursor=i>=0?i:this.matches.length?0:-1,this.list&&this.list.setItems(this.rows,this.rowOf(this.cursor))}rowOf(t){return t<0?-1:Math.floor(t/this.columns)}moveCursor(t){if(!this.matches.length)return-1;const i=Math.max(0,Math.min(this.matches.length-1,this.cursor+t));return this.setCursor(i)}setCursor(t){return this.cursor=t,this.list&&this.list.setActive(this.rowOf(t)),this.cursor}cursorName(){return this.cursor>=0&&this.cursor<this.matches.length?this.matches[this.cursor]:null}renderRow(t,i,s){i.setAttribute("role","row"),i.classList.add("lat-iconpicker__row");let r=i.__latIconCells;if(!r){r=[],V(i);for(let o=0;o<this.columns;o++){const c=W(this.doc,"span",{class:"lat-iconpicker__cell",attrs:{role:"gridcell",tabindex:"-1"}});Z(c,"mousedown",a=>{k(a.preventDefault)&&a.preventDefault();const g=c.getAttribute("data-icon");g&&this.choose(g)}),i.appendChild(c),r.push(c)}i.__latIconCells=r}for(let o=0;o<r.length;o++){const c=r[o],a=t[o];if(a===void 0){c.setAttribute("aria-hidden","true"),c.removeAttribute("data-icon"),c.removeAttribute("title"),c.removeAttribute("aria-label"),c.classList.add("lat-iconpicker__cell--empty"),c.classList.remove("lat-iconpicker__cell--active"),c.classList.remove("lat-iconpicker__cell--selected"),c.__latIconName!==void 0&&(V(c),c.__latIconName=void 0);continue}const g=s*this.columns+o;c.removeAttribute("aria-hidden"),c.classList.remove("lat-iconpicker__cell--empty"),c.setAttribute("data-icon",a),c.setAttribute("title",a),c.setAttribute("aria-label",a),c.__latIconName!==a&&(V(c),c.appendChild(x(this.doc,a,{className:$.icon})),c.__latIconName=a);const h=this.selected===a;c.classList.toggle("lat-iconpicker__cell--active",g===this.cursor),c.classList.toggle("lat-iconpicker__cell--selected",h),c.setAttribute("aria-selected",h?"true":"false")}}paintDisplay(){const t=this.display;if(t){if(V(t),this.selected==null){t.appendChild(W(this.doc,"span",{class:"lat-iconpicker__none",text:this.t("editor.noIcon")}));return}t.appendChild(x(this.doc,this.selected,{className:$.icon})),t.appendChild(W(this.doc,"span",{text:this.selected}))}}choose(t){this.selected=t;const i=this.matches.indexOf(t);i>=0&&(this.cursor=i),this.list&&this.list.paint(),this.paintDisplay(),this.commit()}readValue(){return this.selected??null}checkValue(t){return t==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose an icon":this.names.includes(String(t))?!0:`"${String(t)}" is not a known icon name`}onKeyDown(t){const i=()=>{k(t.preventDefault)&&t.preventDefault()};switch(t.key){case"ArrowRight":i(),this.moveCursor(1);return;case"ArrowLeft":i(),this.moveCursor(-1);return;case"ArrowDown":i(),this.moveCursor(this.columns);return;case"ArrowUp":i(),this.moveCursor(-this.columns);return;case"PageDown":i(),this.moveCursor(this.columns*5);return;case"PageUp":i(),this.moveCursor(-this.columns*5);return;case"Home":i(),this.setCursor(this.matches.length?0:-1);return;case"End":i(),this.setCursor(this.matches.length-1);return;case"Enter":{i();const s=this.cursorName();s&&this.choose(s);return}case"Escape":i(),this.cancel();return;case"Tab":{const s=this.cursorName();s&&(this.selected=s),this.commit();return}default:break}}destroy(){for(const t of this.off)t();this.off.length=0,this.list&&(this.list.destroy(),this.list=null),this.input=null,this.display=null,this.rows=[],super.destroy()}}function l(n){const t=I();if(Array.isArray(n)&&n.length){const i=new Set(t);return n.map(s=>String(s)).filter(s=>i.has(s))}return t.filter(i=>i!=="blank")}const u=y}),Ae("packages/dom/src/editors/temperature.js",function(e,G){"use strict";Object.defineProperty(e,"presentTemperature",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const q=G("packages/dom/src/editors/common.js"),M=q.BaseEditor,$=q.CLS,N=q.el,W=q.on,V=G("packages/core/src/internal/util.js").isFunction,U=G("packages/core/src/columns/types/temperature.js"),x=U.formatTemperature,I=U.parseTemperature,v=U.findScale;function k(u,n){return x(u,{...n,decimals:void 0,minDecimals:0,maxDecimals:20})}class y extends M{input=null;hint=null;opts=null;#e=[];buildOptions(){const n=this.params.column&&this.params.column.dataType||null,t=n&&n.temperatureConfig||{};return{scale:this.props.scale||t.scale||"C",locale:this.params.locale}}build(){const n=this.props;this.opts=this.buildOptions();const t=v(this.opts.scale),i=t?t.scale.symbol:"",s=`${this.id}-scale`,r=N(this.doc,"input",{class:$.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:n.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":i?s:null}});r.value=k(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(r.value=this.params.key),this.input=r;const o=typeof n.step=="number"?n.step:0;return o>0&&this.#e.push(W(r,"keydown",c=>{c.key==="ArrowUp"?(V(c.preventDefault)&&c.preventDefault(),this.nudge(o)):c.key==="ArrowDown"&&(V(c.preventDefault)&&c.preventDefault(),this.nudge(-o))})),this.hint=N(this.doc,"span",{class:`${$.editor}__suffix`,text:i,attrs:{id:s,"aria-hidden":"true"}}),N(this.doc,"div",{class:`${$.editor}__unit`,children:[r,this.hint]})}focusTarget(){return this.input}attached(){super.attached();const n=this.input;n&&!this.params.key&&this.props.selectOnFocus!==!1&&V(n.select)&&n.select()}nudge(n){const t=I(this.input?this.input.value:"",this.opts);let i=(t??0)+n;const{min:s,max:r}=this.props;typeof s=="number"&&i<s&&(i=s),typeof r=="number"&&i>r&&(i=r),this.input&&(this.input.value=k(i,this.opts))}readValue(){const n=this.input?String(this.input.value).trim():"";if(n==="")return null;const t=I(n,this.opts);return t===null?Number.NaN:t}checkValue(n){if(n===null)return!0;if(typeof n!="number"||Number.isNaN(n))return"Enter a temperature";const{min:t,max:i}=this.props;return typeof t=="number"&&n<t?`Must be ${t} or more`:typeof i=="number"&&n>i?`Must be ${i} or less`:!0}destroy(){for(const n of this.#e)n();this.#e=[],this.input=null,this.hint=null,super.destroy()}}const l=y}),Ae("packages/dom/src/editors/currency.js",function(e,G){"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 u}});const q=G("packages/dom/src/editors/common.js"),M=q.BaseEditor,$=q.CLS,N=q.el,W=q.on,V=G("packages/core/src/internal/util.js").isFunction,U=G("packages/core/src/columns/types/currency.js"),x=U.parseMoney,I=U.toMoney,v=U.normaliseCode,k=["USD","EUR","GBP","JPY","CHF","CAD","AUD","CNY"];function y(n){const t=I(n);return t?String(t.amount):""}class l extends M{input=null;picker=null;opts=null;#e=[];buildOptions(){const t=this.params.column&&this.params.column.dataType||null,i=t&&t.currencyConfig||{},s=I(this.params.value),r=v(this.props.code)||s&&s.code||v(i.code)||"USD";let o=this.props.codes||i.codes||k;return o=o.map(c=>v(c)).filter(Boolean),o.includes(r)||(o=[r,...o]),{code:r,codes:o,locale:this.params.locale}}build(){const t=this.props;this.opts=this.buildOptions();const i=N(this.doc,"input",{class:$.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:t.placeholder??null,"aria-label":this.params.column&&this.params.column.title||"Amount"}});i.value=y(this.params.value),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(i.value=this.params.key),this.input=i;const s=N(this.doc,"select",{class:`${$.editor}__suffix`,attrs:{"aria-label":this.t("editor.currency")}});for(const r of this.opts.codes){const o=N(this.doc,"option",{text:r,attrs:{value:r}});r===this.opts.code&&(o.selected=!0),s.appendChild(o)}return this.picker=s,N(this.doc,"div",{class:`${$.editor}__unit`,children:[i,s]})}focusTarget(){return this.input}attached(){super.attached();const t=this.input;t&&!this.params.key&&this.props.selectOnFocus!==!1&&V(t.select)&&t.select()}readValue(){const t=this.input?String(this.input.value).trim():"";if(t==="")return null;const i=this.picker?this.picker.value:this.opts.code,s=x(t,{...this.opts,code:i});return s===null?Number.NaN:s}checkValue(t){if(t===null)return!0;if(!t||typeof t!="object"||!Number.isFinite(t.amount))return"Enter an amount";const i=t.amount,{min:s,max:r}=this.props;return typeof s=="number"&&i<s?`Must be ${s} or more`:typeof r=="number"&&i>r?`Must be ${r} or less`:!0}destroy(){for(const t of this.#e)t();this.#e=[],this.input=null,this.picker=null,super.destroy()}}const u=l}),Ae("packages/dom/src/editors/index.js",function(e,G){"use strict";Object.defineProperty(e,"TextEditor",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"TextareaEditor",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"NumberEditor",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"DateEditor",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"CheckboxEditor",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"SelectEditor",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"MultiSelectEditor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"TimeEditor",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DateTimeEditor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"DurationEditor",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"IpAddressEditor",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"PasswordEditor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"CodeEditor",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"CurrencyEditor",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return le}}),Object.defineProperty(e,"editorByType",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return se}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return de}});const M=G("packages/dom/src/editors/text.js").TextEditor,N=G("packages/dom/src/editors/textarea.js").TextareaEditor,Z=G("packages/dom/src/editors/number.js").NumberEditor,U=G("packages/dom/src/editors/date.js").DateEditor,I=G("packages/dom/src/editors/checkbox.js").CheckboxEditor,k=G("packages/dom/src/editors/select.js").SelectEditor,l=G("packages/dom/src/editors/multiselect.js").MultiSelectEditor,n=G("packages/dom/src/editors/time.js").TimeEditor,i=G("packages/dom/src/editors/datetime.js").DateTimeEditor,r=G("packages/dom/src/editors/duration.js").DurationEditor,c=G("packages/dom/src/editors/ipaddress.js").IpAddressEditor,g=G("packages/dom/src/editors/password.js").PasswordEditor,b=G("packages/dom/src/editors/code.js").CodeEditor,f=G("packages/dom/src/editors/unit.js").UnitEditor,S=G("packages/dom/src/editors/radix.js").RadixEditor,d=G("packages/dom/src/editors/segmented.js").SegmentedEditor,E=G("packages/dom/src/editors/rating.js").RatingEditor,T=G("packages/dom/src/editors/slider.js").SliderEditor,P=G("packages/dom/src/editors/colour.js").ColourEditor,z=G("packages/dom/src/editors/treeselect.js").TreeSelectEditor,D=G("packages/dom/src/editors/objectpicker.js").ObjectPickerEditor,C=G("packages/dom/src/editors/iconpicker.js").IconPickerEditor,_=G("packages/dom/src/editors/temperature.js").TemperatureEditor,Y=G("packages/dom/src/editors/currency.js").CurrencyEditor,J=G("packages/core/src/internal/util.js"),te=J.isCtor,ee=J.isFunction,oe=J.warnOnce,re=G("packages/dom/src/editors/common.js");for(const me of Object.keys(re))me!=="default"&&Object.defineProperty(e,me,{enumerable:!0,get:function(){return re[me]}});const le=Object.freeze({text:M,textarea:N,number:Z,date:U,checkbox:I,select:k,multiSelect:l,temperature:_,currency:Y,time:n,datetime:i,duration:r,ipaddress:c,password:g,code:b,unit:f,radix:S,slider:T,rating:E,segmented:d,treeSelect:z,objectPicker:D,iconPicker:C,colour:P}),ne=Object.freeze({text:"text",number:"number",boolean:"checkbox",date:"date",dateString:"date",lookup:"select",object:""});function se(me,Pe){const Ie=me&&me.edit&&me.edit.editor,ke=Pe&&Pe.editors||{},be=!!(me&&me.lookup&&me.lookup.multiple);if(te(Ie)||ee(Ie))return Ie;if(typeof Ie=="string"){if(be&&Ie==="select")return l;const xe=ke[Ie]||le[Ie];if(xe)return xe;oe(`editor:missing:${Ie}`,`unknown editor "${Ie}"; falling back to the data type default`)}const ge=me&&me.type||"text";if(ge==="lookup"||me&&me.lookup)return be?l:k;const Ee=ne[ge];return Ee&&(ke[Ee]||le[Ee])||null}function ae(me,Pe){const Ie=se(me.column||{},Pe);if(!Ie)return null;const ke=new Ie;return ke.init(me),ee(ke.cancelBeforeStart)&&ke.cancelBeforeStart()===!0?(ee(ke.destroy)&&ke.destroy(),null):ke}const de=le}),Ae("packages/dom/src/ui/statusbar.js",function(e,G){"use strict";Object.defineProperty(e,"aggregate",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"StatusPanel",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"RowCountPanel",{enumerable:!0,get:function(){return k}}),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 u}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const q=G("packages/dom/src/editors/common.js"),M=q.CLS,$=q.documentFor,N=q.el,W=q.clear,V=G("packages/core/src/i18n/index.js").defaultMessages,x=G("packages/core/src/internal/util.js").isFunction;function I(h){let b=0,p=0,f=0,w=null,S=null;for(const m of h||[]){if(m==null||m==="")continue;b++;const d=typeof m=="number"?m:Number(m);Number.isFinite(d)&&(p++,f+=d,(w===null||d<w)&&(w=d),(S===null||d>S)&&(S=d))}return{count:b,numericCount:p,sum:p?f:null,min:w,max:S,avg:p?f/p:null}}class v{root=null;valueNode=null;init(b){this.ctx=b,this.doc=b.document,this.root=N(this.doc,"div",{class:`${M.statusBar}__panel`,attrs:{"data-align":b.align||"end"}}),b.label&&this.root.appendChild(N(this.doc,"span",{class:`${M.statusBar}__label`,text:b.label})),this.valueNode=N(this.doc,"span",{class:`${M.statusBar}__value`,text:""}),this.root.appendChild(this.valueNode)}t(b,p){const f=this.ctx&&this.ctx.messages;return(f&&x(f.t)?f:V).t(b,p)}element(){return this.root}refresh(){const b=this.read();this.valueNode&&this.valueNode.textContent!==b&&(this.valueNode.textContent=b)}read(){return""}destroy(){this.root=null,this.valueNode=null}}class k extends v{read(){const b=this.ctx.host||{},p=x(b.totalRowCount)?b.totalRowCount():0;if(p==null)return this.t("status.counting");const f=x(b.rowCount)?b.rowCount():p,w=this.ctx.noun,S=m=>w===void 0?this.t("count.rows",{count:m}):`${o(m,this.ctx.locale)}${w?` ${w}`:""}`;return f===p?this.t("status.total",{rows:S(p)}):this.t("status.shownOfTotal",{shown:o(f,this.ctx.locale),total:S(p)})}}class y extends v{read(){const b=this.ctx.host||{},p=x(b.selectedCount)?b.selectedCount():0;return p?this.t("status.selected",{count:p}):""}}class l extends v{read(){const b=this.ctx.host||{},p=x(b.rangeValues)?b.rangeValues():[],f=I(p);if(!f.count)return"";const w=this.ctx.stats||["count","sum","min","max","avg"],S=[];for(const m of w){if(m==="count"){S.push(this.t("status.count",{count:f.count}));continue}const d=f[m];d!==null&&S.push(`${this.t(`status.stat.${m}`)} ${a(d,this.ctx.locale)}`)}return S.join(" ")}}class u extends v{read(){const b=this.ctx.host||{},p=x(b.progress)?b.progress():null;if(!p)return"";const{loaded:f,estimated:w,done:S}=p;if(S)return"";if(!w)return this.t("status.loading",{count:f||0});const m=Math.min(100,Math.round((f||0)/w*100));return this.t("status.loadingOf",{loaded:f||0,total:w,percent:m})}}class n extends v{read(){const b=this.ctx.host||{},p=x(b.updateStats)?b.updateStats():null;return p?p.paused?p.pending?this.t("status.pausedWaiting",{waiting:this.t("count.waiting",{count:p.pending})}):this.t("status.paused"):p.coalescedTotal?this.t("status.coalesced",{count:p.coalescedTotal}):"":""}}class t extends v{read(){const b=this.ctx.host||{},p=x(b.hiddenUnresolved)?b.hiddenUnresolved():0;return p?this.t("status.hiddenComments",{comments:this.t("count.unresolvedComments",{count:p})}):""}}const i=Object.freeze({rowCount:k,selectedCount:y,aggregation:l,progress:u,updates:n,comments:t});class s{panels=[];root=null;init(b){const p=b||{};this.doc=$(p),this.host=p.host||{},this.messages=p.messages||null,this.root=N(this.doc,"div",{class:M.statusBar,attrs:{role:"status","aria-live":"polite"}});const f=p.registry||{},w=Array.isArray(p.panels)&&p.panels.length?p.panels:["rowCount","selectedCount","aggregation","comments","updates","progress"];for(const S of w){const m=typeof S=="string"?S:S.name,d=typeof S=="function"?S:f[m]||i[m];if(!d)continue;const j=new d;j.init({document:this.doc,host:this.host,locale:p.locale,messages:this.messages,...typeof S=="object"?S.props||{}:{}}),this.panels.push({name:String(m||"panel"),panel:j}),this.root.appendChild(j.element())}this.refresh()}element(){return this.root}addPanel(b,p,f){const w=new p;return w.init({document:this.doc,host:this.host,messages:this.messages,...f||{}}),this.panels.push({name:b,panel:w}),this.root&&this.root.appendChild(w.element()),w.refresh(),w}removePanel(b){const p=this.panels.findIndex(S=>S.name===b);if(p<0)return!1;const[f]=this.panels.splice(p,1),w=f.panel.element();return w&&w.parentNode&&w.parentNode.removeChild(w),x(f.panel.destroy)&&f.panel.destroy(),!0}refresh(){for(const b of this.panels)b.panel.refresh()}destroy(){for(const b of this.panels)x(b.panel.destroy)&&b.panel.destroy();this.panels=[],this.root&&W(this.root),this.root=null}}const r=new Map;function o(h,b){const p=b||"";let f=r.get(p);return f||(f=new Intl.NumberFormat(b||void 0,{maximumFractionDigits:0}),r.set(p,f)),f.format(Number(h)||0)}const c=new Map;function a(h,b){const p=b||"";let f=c.get(p);return f||(f=new Intl.NumberFormat(b||void 0,{maximumFractionDigits:3}),c.set(p,f)),f.format(Number(h)||0)}const g=s}),Ae("packages/dom/src/ui/contextmenu.js",function(e,G){"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 t}});const q=G("packages/dom/src/editors/common.js"),M=q.CLS,$=q.documentFor,N=q.el,W=q.on,Z=q.clear,U=G("packages/core/src/internal/util.js").isFunction,I=G("packages/dom/src/renderer/direction.js").isRtlElement,k=G("packages/dom/src/cell/icons.js").renderIconInto;function y(i,s){const r=[];for(const o of i||[]){const c=U(o)?o(s):o;if(c==null||c===!1)continue;if(c==="separator"){r.push({separator:!0});continue}if(typeof c=="string"){r.push({name:c});continue}const a=c,g=a.subMenu||a.children;g?r.push({...a,subMenu:y(g,s)}):r.push(a)}return r.filter((o,c,a)=>o.separator?c===0||c===a.length-1?!1:!a[c-1].separator:!0)}class l{root=null;itemNodes=[];items=[];focused=-1;child=null;off=[];open=!1;anchor=null;constructor(s){const r=s||{};this.doc=$(r),this.host=r.host||this.doc.body,this.ctx=r.ctx||{},this.onClose=r.onClose||null,this.parent=r.parent||null}place(s){const r=this.host,o=U(r.getBoundingClientRect)?r.getBoundingClientRect():{left:0,top:0},c=U(this.root.getBoundingClientRect)?this.root.getBoundingClientRect():{width:0,height:0},a=this.doc.defaultView||{innerWidth:0,innerHeight:0},g=a.innerWidth||0,h=a.innerHeight||0;let b=s.x||0,p=s.y||0;const f=I(r);if(s.anchor&&U(s.anchor.getBoundingClientRect)){const m=s.anchor.getBoundingClientRect();s.placement==="below"?(b=f?m.right-c.width:m.left,p=m.bottom):(b=f?m.left-c.width:m.right,p=m.top)}else f&&(b-=c.width);const w={left:Math.max(0,o.left||0),top:Math.max(0,o.top||0),right:Math.min(g||1/0,(o.left||0)+(o.width||1/0)),bottom:Math.min(h||1/0,(o.top||0)+(o.height||1/0))};b+c.width>w.right&&(b-=c.width),b<w.left&&(b=w.left),p+c.height>w.bottom&&(p-=c.height),p<w.top&&(p=w.top);const S=w.bottom-p;c.height>S&&(this.root.style.maxHeight=`${Math.max(0,Math.floor(S))}px`,this.root.style.overflowY="auto"),this.root.style.left=`${Math.round(b-o.left+(r.scrollLeft||0))}px`,this.root.style.top=`${Math.round(p-o.top+(r.scrollTop||0))}px`}show(s){return this.hide(),s.ctx&&(this.ctx={...this.ctx||{},...s.ctx}),this.items=y(s.items,this.ctx),this.returnFocus=s.returnFocus||null,this.anchor=s.anchor&&U(s.anchor.setAttribute)&&s.anchor.getAttribute&&s.anchor.getAttribute("aria-haspopup")?s.anchor:null,this.anchor&&this.anchor.setAttribute("aria-expanded","true"),this.root=N(this.doc,"div",{class:M.menu,attrs:{role:"menu",tabindex:"-1"},style:{position:"absolute"}}),this.itemNodes=[],this.items.forEach((r,o)=>{if(r.separator){this.root.appendChild(N(this.doc,"div",{class:M.menuSeparator,attrs:{role:"separator"}}));return}const c=N(this.doc,"div",{class:[M.menuItem,r.cssClass||""],attrs:{role:r.checked===void 0?"menuitem":"menuitemcheckbox",tabindex:"-1","aria-disabled":r.disabled?"true":null,"aria-checked":r.checked===void 0?null:String(r.checked===!0),"aria-haspopup":r.subMenu?"true":null,"aria-expanded":r.subMenu?"false":null,"data-index":o}});if(r.icon!=null&&r.icon!==""){const g=N(this.doc,"span",{class:M.icon});k(g,r.icon,`menu:${r.name||o}`),c.appendChild(g)}c.appendChild(N(this.doc,"span",{class:`${M.menuItem}__label`,text:r.name||""})),r.shortcut&&c.appendChild(N(this.doc,"span",{class:`${M.menuItem}__shortcut`,text:r.shortcut})),r.subMenu&&c.appendChild(N(this.doc,"span",{class:`${M.menuItem}__arrow`,text:"›"}));const a=this.itemNodes.length;this.off.push(W(c,"click",()=>this.invoke(a))),this.off.push(W(c,"mouseenter",()=>{this.focus(a),r.subMenu?this.openSubMenu(a):this.closeChild()})),this.itemNodes.push(c),this.root.appendChild(c)}),this.host.appendChild(this.root),this.place(s),this.open=!0,this.off.push(W(this.root,"keydown",r=>this.onKeyDown(r))),U(this.doc.addEventListener)&&this.off.push(W(this.doc,"mousedown",this.outside=r=>{this.root&&!n(this.root,r.target)&&!(this.child&&this.child.root&&n(this.child.root,r.target))&&this.hide()},!0)),U(this.root.focus)&&this.root.focus({preventScroll:!0}),this.focus(this.firstEnabled()),this.root}firstEnabled(){for(let s=0;s<this.itemNodes.length;s++)if(!this.itemAt(s).disabled)return s;return-1}itemAt(s){const r=this.itemNodes[s];return r?this.items[Number(r.getAttribute("data-index"))]||{}:{}}focus(s){if(s<0||s>=this.itemNodes.length)return;const r=this.itemNodes[this.focused];r&&r.classList.remove(`${M.menuItem}--focused`),this.focused=s;const o=this.itemNodes[s];o.classList.add(`${M.menuItem}--focused`),U(o.focus)&&o.focus(),U(o.scrollIntoView)&&o.scrollIntoView({block:"nearest",inline:"nearest"})}move(s){const r=this.itemNodes.length;if(!r)return;let o=this.focused;for(let c=0;c<r;c++)if(o=(o+s+r)%r,!this.itemAt(o).disabled){this.focus(o);return}}invoke(s){const r=this.itemAt(s);if(!(!r||r.disabled)){if(r.subMenu){this.openSubMenu(s);return}U(r.action)&&r.action({...this.ctx,item:r}),this.hideRoot()}}openSubMenu(s){const r=this.itemAt(s);r.subMenu&&(this.closeChild(),this.child=new l({document:this.doc,host:this.host,ctx:this.ctx,parent:this}),this.child.show({items:r.subMenu,anchor:this.itemNodes[s]}))}closeChild(){this.child&&(this.child.hide(),this.child=null)}onKeyDown(s){switch(s.key){case"ArrowDown":u(s),this.move(1);break;case"ArrowUp":u(s),this.move(-1);break;case"Home":u(s),this.focus(this.firstEnabled());break;case"End":u(s),this.focus(this.itemNodes.length-1);break;case"ArrowRight":u(s),this.openSubMenu(this.focused);break;case"ArrowLeft":u(s),this.parent&&(this.hide(),U(this.parent.root?.focus)&&this.parent.root.focus());break;case"Enter":case" ":u(s),this.invoke(this.focused);break;case"Escape":u(s),this.hideRoot();break;default:s.key&&s.key.length===1&&this.jumpTo(s.key);break}}jumpTo(s){const r=s.toLowerCase(),o=this.itemNodes.length;for(let c=1;c<=o;c++){const a=(this.focused+c+o)%o,g=this.itemAt(a);if(!g.disabled&&(g.name||"").toLowerCase().startsWith(r)){this.focus(a);return}}}hideRoot(){let s=this;for(;s.parent;)s=s.parent;s.hide()}hide(){this.closeChild();for(const s of this.off)s();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&&U(this.anchor.setAttribute)&&this.anchor.setAttribute("aria-expanded","false"),this.anchor=null,this.open&&this.returnFocus&&U(this.returnFocus.focus)&&this.returnFocus.focus(),this.open=!1,U(this.onClose)&&this.onClose()}destroy(){this.hide(),this.items=[]}}function u(i){U(i.preventDefault)&&i.preventDefault(),U(i.stopPropagation)&&i.stopPropagation()}function n(i,s){let r=s;for(;r;){if(r===i)return!0;r=r.parentNode}return!1}const t=l}),Ae("packages/dom/src/viewpicker.js",function(e,G){"use strict";Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return k}}),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 u}});const q=G("packages/dom/src/editors/common.js"),M=q.documentFor,$=q.el,N=q.on,W=q.clear,V=G("packages/core/src/i18n/index.js").defaultMessages,x=G("packages/core/src/internal/util.js").isFunction,v=G("packages/dom/src/cell/icons.js").createIcon,k=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(t,i){return(this.messages&&typeof this.messages.t=="function"?this.messages:V).t(t,i)}init(t){this.messages=t&&t.messages||t&&t.grid&&t.grid.messages||V;const i=t||{};this.doc=M(i),this.host=i.host||{},this.props=i.props||{},this.root=$(this.doc,"div",{class:k.root,attrs:{role:"group","aria-label":String(this.props.title||"Saved views")}}),this.refresh()}element(){return this.root}refresh(){const t=this.root;if(!t)return;for(const c of this.off)c();this.off.length=0,W(t),this.diffs=new Map;const i=this.views(),s=i.filter(c=>c.builtin),r=i.filter(c=>!c.builtin);s.length&&(t.appendChild(this.buildHead(String(this.props.builtinTitle||"Defined views"),s.length)),t.appendChild(this.buildList(s))),t.appendChild(this.buildHead(String(this.props.title||"Saved views"),r.length)),r.length?t.appendChild(this.buildList(r)):t.appendChild($(this.doc,"p",{class:k.empty,text:String(this.props.emptyText||this.t("views.empty"))}));const o=this.buildFoot();o&&t.appendChild(o)}buildList(t){const i=$(this.doc,"div",{class:k.list,attrs:{role:"list"}});for(const s of t)i.appendChild(this.buildItem(s));return i}views(){const t=x(this.host.views)?this.host.views()||[]:[];return this.props.sort!=="name"?t:t.slice().sort((i,s)=>String(i.name||"").localeCompare(String(s.name||"")))}activeId(){return x(this.host.activeId)?this.host.activeId():null}buildHead(t,i){return $(this.doc,"div",{class:k.head,children:[$(this.doc,"span",{class:k.title,text:String(t)}),$(this.doc,"span",{class:k.count,text:String(i)})]})}buildItem(t){const i=String(t.id),s=this.activeId()===i,r=x(this.host.canEdit)?this.host.canEdit(t)!==!1:!0,o=$(this.doc,"div",{class:[k.item,s?k.itemActive:"",this.editing===i?k.itemEditing:""],attrs:{role:"listitem","data-view":i,"data-shared":t.shared?"true":"false"}});if(this.editing===i)return o.appendChild(this.buildRenameRow(t)),o;const c=$(this.doc,"button",{class:k.apply,attrs:{type:"button","aria-current":s?"true":null,title:[s?`${t.name} is applied`:`Apply ${t.name}`,t.shared?"Shared with everyone":"Private to you"].join(": ")},children:[$(this.doc,"span",{class:k.name,text:String(t.name||"")}),t.isDefault?this.buildBadges(t):null].filter(Boolean)});x(this.host.apply)?this.off.push(N(c,"click",()=>this.applyView(i))):c.setAttribute("disabled",""),t.description&&c.appendChild($(this.doc,"span",{class:k.description,text:String(t.description)}));const a=this.buildDiff(i,s);return a&&c.appendChild(a),o.appendChild(c),t.builtin||o.appendChild(this.confirming===i?this.buildConfirm(t):this.buildActions(t,r)),o}buildBadges(t){const i=$(this.doc,"span",{class:k.badges});return t.isDefault&&i.appendChild($(this.doc,"span",{class:[k.badge,k.badgeDefault],text:this.t("views.default"),attrs:{title:"Applied when the grid loads"}})),i}buildDiff(t,i){if(this.props.showDiff!==!0||!x(this.host.diff))return null;const s=this.diffOf(t);if(!s)return null;if(!s.changed)return $(this.doc,"span",{class:[k.diff,k.diffClean],text:this.t(i?"views.applied":"views.matchesGrid")});const r=l(s);return r.length?$(this.doc,"span",{class:k.diff,text:r.join(" · ")}):null}diffOf(t){if(!x(this.host.diff))return null;if(this.diffs.has(t))return this.diffs.get(t);let i=null;try{i=this.host.diff(t)}catch{i=null}return this.diffs.set(t,i),i}buildActions(t,i){const s=String(t.id),r=$(this.doc,"span",{class:k.actions});if(i&&x(this.host.rename)&&r.appendChild(this.buildAction("Rename",`Rename ${t.name}`,()=>{this.editing=s,this.confirming=null,this.refresh(),this.focusInput()},"pencil")),t.isDefault&&x(this.host.clearDefault)?r.appendChild(this.buildAction("Unset default",`Stop applying ${t.name} at load`,()=>{this.host.clearDefault(s),this.refresh()},"pin")):!t.isDefault&&x(this.host.setDefault)&&r.appendChild(this.buildAction("Make default",`Apply ${t.name} when the grid loads`,()=>{this.host.setDefault(s),this.refresh()},"pin")),x(this.host.export)&&r.appendChild(this.buildAction("Share",`Export ${t.name}`,()=>this.host.export(s),"share")),i&&x(this.host.remove)){const o=this.buildAction("Delete",`Delete ${t.name}`,()=>{this.confirming=s,this.refresh()},"trash");o.classList.add(k.actionDanger),r.appendChild(o)}return r}buildConfirm(t){const i=String(t.id),s=$(this.doc,"span",{class:k.confirm});s.appendChild($(this.doc,"span",{text:this.t("views.confirmDelete",{name:t.name})}));const r=this.buildAction(this.t("views.delete"),this.t("views.confirmDeleteLabel",{name:t.name}),()=>{this.confirming=null,this.host.remove(i),this.refresh()});return r.classList.add(k.actionDanger),s.appendChild(r),s.appendChild(this.buildAction("Cancel","Keep this view",()=>{this.confirming=null,this.refresh()})),s}buildRenameRow(t){const i=String(t.id),s=$(this.doc,"span",{class:k.confirm}),r=$(this.doc,"input",{class:k.input,attrs:{type:"text","aria-label":`New name for ${t.name}`}});r.value=String(t.name||""),this.input=r;const o=()=>{const a=String(r.value||"").trim();this.editing=null,a&&a!==t.name&&this.host.rename(i,a),this.refresh()},c=()=>{this.editing=null,this.refresh()};return this.off.push(N(r,"keydown",a=>{a.key==="Enter"?o():a.key==="Escape"&&c()})),s.appendChild(r),s.appendChild(this.buildAction("Save","Save the new name",o)),s.appendChild(this.buildAction("Cancel","Leave the name alone",c)),s}buildFoot(){if(this.props.allowSave===!1||!x(this.host.saveAs))return null;const t=$(this.doc,"div",{class:k.foot}),i=$(this.doc,"input",{class:k.input,attrs:{type:"text",placeholder:this.t("views.namePlaceholder"),"aria-label":this.t("views.nameLabel")}});i.value=this.draft,this.editing===null&&(this.input=i);const s=()=>{const o=String(i.value||"").trim();if(!o){x(i.focus)&&i.focus();return}this.draft="",this.host.saveAs(o),this.refresh()};this.off.push(N(i,"input",()=>{this.draft=String(i.value||"")})),this.off.push(N(i,"keydown",o=>{o.key==="Enter"&&s()}));const r=$(this.doc,"button",{class:k.save,text:this.t("views.save"),attrs:{type:"button"}});return this.off.push(N(r,"click",s)),t.appendChild(i),t.appendChild(r),t}buildAction(t,i,s,r){const o=$(this.doc,"button",{class:k.action,text:r?null:t,attrs:{type:"button",title:i,"aria-label":i,"data-action":t}});return r&&o.appendChild(v(this.doc,r,{className:k.actionIcon})),this.off.push(N(o,"click",s)),o}applyView(t){this.confirming=null,this.host.apply(t),this.refresh()}focusInput(){const t=this.input;t&&x(t.focus)&&t.focus(),t&&x(t.select)&&t.select()}destroy(){for(const t of this.off)t();this.off.length=0,this.root=null,this.input=null,this.diffs=new Map}}function l(n,t=3){if(!n||!n.changed)return[];const i=n.counts||{},s=[],r=(o,c,a)=>{o&&s.push((o===1?c:a).replace("%",String(o)))};if(r(i.columnsHidden,"hides % column","hides % columns"),r(i.columnsShown,"shows % column","shows % columns"),r(i.columnsMoved,"moves % column","moves % columns"),r(i.columnsPinned,"repins % column","repins % columns"),r(i.columnsResized,"resizes % column","resizes % columns"),n.filters&&n.filters.changed){const o=i.filterColumns||0;s.push(o?`changes ${o} filter${o===1?"":"s"}`:"changes the filter")}return n.quick&&n.quick.changed&&s.push("changes the search"),n.sort&&n.sort.changed&&s.push("changes the sort"),n.group&&n.group.changed&&s.push("changes the grouping"),n.pivot&&n.pivot.changed&&s.push("changes the pivot"),r(i.columnsTotalled,"changes % total","changes % totals"),n.pagination&&n.pagination.changed&&s.push("changes the page size"),s.length<=t?s:[...s.slice(0,t),`and ${s.length-t} more`]}const u=y}),Ae("packages/dom/src/ui/panelbase.js",function(e,G){"use strict";Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return Z}});const q=G("packages/dom/src/editors/common.js"),M=q.CLS,$=q.el,W=G("packages/core/src/i18n/index.js").defaultMessages;class Z{root=null;off=[];init(U){this.ctx=U,this.doc=U.document,this.host=U.host||{},this.props=U.props||{},this.root=$(this.doc,"div",{class:`${M.panel}__body`}),this.refresh()}t(U,x){const I=this.host||{};if(typeof I.t=="function")return I.t(U,x);const v=this.ctx||{};if(v.messages&&typeof v.messages.t=="function")return v.messages.t(U,x);const k=v.grid;return(k&&k.messages?k.messages:W).t(U,x)}element(){return this.root}refresh(){}destroy(){for(const U of this.off)U();this.off.length=0,this.root=null}}}),Ae("packages/dom/src/formattingpanel.js",function(e,G){"use strict";Object.defineProperty(e,"describeRule",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"FormattingPanel",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"createFormattingPanel",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return f}});const q=G("packages/dom/src/editors/common.js"),M=q.CLS,$=q.documentFor,N=q.el,W=q.on,Z=q.clear,U=G("packages/core/src/internal/util.js").isFunction,I=G("packages/dom/src/ui/panelbase.js").ToolPanelBase,v=G("packages/core/src/formatting/rules.js"),k=v.compileRules,y=v.summariseColumn,l=v.needsDistribution,u=v.DISTRIBUTION_LABELS,n="*",t=8,i=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}]),s=Object.freeze([{op:"topPercent",label:u.topPercent,values:1},{op:"bottomPercent",label:u.bottomPercent,values:1},{op:"topN",label:u.topN,values:1},{op:"bottomN",label:u.bottomN,values:1},{op:"aboveMean",label:u.aboveMean,values:0},{op:"belowMean",label:u.belowMean,values:0},{op:"aboveMedian",label:u.aboveMedian,values:0},{op:"belowMedian",label:u.belowMedian,values:0},{op:"zAbove",label:u.zAbove,values:1},{op:"zBelow",label:u.zBelow,values:1},{op:"outlier",label:u.outlier,values:0}]),r=Object.freeze([...i,...s]),o=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"}]),c=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"]}]),a=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 S=r.find(m=>m.op===w);return S?S.values:1}function h(w){if(!w)return"";if(w.scale){const{min:j,max:E,from:O}=w.scale;if(Number.isFinite(j)&&Number.isFinite(E))return`Colour scale, ${j} to ${E}`;const T=a.find(A=>A.from===O);return T?`Colour scale ${T.label}`:"Colour scale"}const S=w.when||{},m=r.find(j=>j.op===S.op),d=m?m.label:S.op;return!m||m.values===0?`Value ${d}`:m.values===2?`Value ${d} ${S.value} and ${S.value2}`:`Value ${d} ${S.value}`}class b extends I{scope=n;mode="condition";refresh(){const S=this.root;if(S){for(const m of this.off)m();this.off.length=0,Z(S),S.appendChild(this.#o()),S.appendChild(this.#i()),S.appendChild(this.#l())}}#e(){const S=U(this.host.formattableColumns)?this.host.formattableColumns():[];return[{id:n,title:"All columns"},...S]}#t(){return U(this.host.formattingRules)?this.host.formattingRules(this.scope):[]}#n(S){if(!U(this.host.columnSamples))return[];const m=this.host.columnSamples(S);return Array.isArray(m)?m:[...m||[]]}#r(S,m,d){const j=l(S)?y(m):null;return k(S,j)({value:d})}#o(){const S=N(this.doc,"div",{class:`${M.panel}__row`});S.appendChild(N(this.doc,"label",{class:`${M.panel}__label`,text:this.t("formatting.format"),attrs:{for:"lat-fmt-scope"}}));const m=N(this.doc,"select",{class:`${M.panel}__select`,attrs:{id:"lat-fmt-scope"}});for(const d of this.#e()){const j=N(this.doc,"option",{text:d.title,attrs:{value:d.id}});d.id===this.scope&&j.setAttribute("selected","selected"),m.appendChild(j)}return m.value=this.scope,this.off.push(W(m,"change",()=>{this.scope=m.value||n,this.refresh()})),S.appendChild(m),S}#i(){const S=N(this.doc,"ul",{class:`${M.panel}__list`}),m=this.#t();if(!m.length)return S.appendChild(N(this.doc,"li",{class:`${M.panel}__empty`,text:this.t("formatting.noRules")})),S;m.forEach((E,O)=>{const T=N(this.doc,"li",{class:`${M.panel}__item`,attrs:{"data-rule":E.id}}),A=N(this.doc,"input",{attrs:{type:"checkbox","aria-label":`Enable ${h(E)}`}});A.checked=E.enabled!==!1,this.off.push(W(A,"change",()=>{this.#c("updateRule",this.scope,E.id,{enabled:A.checked})})),T.appendChild(A);const P=N(this.doc,"span",{class:`${M.panel}__swatch`}),L=E.style||{};if(L.background&&P.style&&P.style.setProperty)P.style.setProperty("background",String(L.background));else if(E.scale&&E.scale.colours&&P.style&&P.style.setProperty){const F=E.scale.colours;P.style.setProperty("background",`linear-gradient(90deg, ${F[0]}, ${F[F.length-1]})`)}T.appendChild(P),T.appendChild(N(this.doc,"span",{class:`${M.panel}__text`,text:h(E)}));const z=N(this.doc,"button",{class:`${M.panel}__icon`,text:"↑",attrs:{type:"button","aria-label":this.t("formatting.moveEarlier"),...O===0?{disabled:"disabled"}:{}}});this.off.push(W(z,"click",()=>this.#c("moveRule",this.scope,E.id,O-1))),T.appendChild(z);const H=N(this.doc,"button",{class:`${M.panel}__icon`,text:"↓",attrs:{type:"button","aria-label":this.t("formatting.moveLater"),...O===m.length-1?{disabled:"disabled"}:{}}});this.off.push(W(H,"click",()=>this.#c("moveRule",this.scope,E.id,O+1))),T.appendChild(H);const D=N(this.doc,"button",{class:`${M.panel}__icon`,text:"×",attrs:{type:"button","aria-label":`Remove ${h(E)}`}});this.off.push(W(D,"click",()=>this.#c("removeRule",this.scope,E.id))),T.appendChild(D),S.appendChild(T)});const d=this.#s(m);d&&S.appendChild(d);const j=N(this.doc,"button",{class:`${M.panel}__link`,text:this.t("formatting.clearAll"),attrs:{type:"button"}});return this.off.push(W(j,"click",()=>this.#c("clearRules",this.scope))),S.appendChild(j),S}#s(S){const m=this.#n(this.scope);if(!m.length)return null;const d=S.filter(E=>E.enabled!==!1);if(!d.length)return null;const j=N(this.doc,"div",{class:`${M.panel}__preview`,attrs:{"aria-label":this.t("formatting.preview")}});for(const E of m.slice(0,t)){const O=this.#r(d,m,E),T=N(this.doc,"span",{class:`${M.panel}__previewcell`,text:String(E)});O&&T.style&&T.style.setProperty&&(O.background&&T.style.setProperty("background",String(O.background)),O.color&&T.style.setProperty("color",String(O.color))),j.appendChild(T)}return j}#l(){const S=N(this.doc,"div",{class:`${M.panel}__form`}),m=N(this.doc,"select",{class:`${M.panel}__select`,attrs:{"aria-label":this.t("formatting.ruleKind")}});return m.appendChild(N(this.doc,"option",{text:this.t("formatting.aCondition"),attrs:{value:"condition"}})),m.appendChild(N(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()})),S.appendChild(m),this.mode==="scale"?S.appendChild(this.#u()):S.appendChild(this.#a()),S}#a(){const S=N(this.doc,"div",{class:`${M.panel}__form`}),m=N(this.doc,"select",{class:`${M.panel}__select`,attrs:{"aria-label":this.t("formatting.condition")}}),d=N(this.doc,"optgroup",{attrs:{label:this.t("formatting.compare")}});for(const D of i)d.appendChild(N(this.doc,"option",{text:D.label,attrs:{value:D.op}}));m.appendChild(d);const j=N(this.doc,"optgroup",{attrs:{label:this.t("formatting.distribution")}});for(const D of s)j.appendChild(N(this.doc,"option",{text:D.label,attrs:{value:D.op}}));m.appendChild(j),m.value="gt",S.appendChild(m);const E=N(this.doc,"input",{class:`${M.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.value")}}),O=N(this.doc,"input",{class:`${M.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.secondValue")}});S.appendChild(E),S.appendChild(O);const T=()=>{const D=g(m.value);E.style.setProperty("display",D>=1?"":"none"),O.style.setProperty("display",D>=2?"":"none"),z()};this.off.push(W(m,"change",T));const A=N(this.doc,"select",{class:`${M.panel}__select`,attrs:{"aria-label":this.t("menu.colour")}});for(const D of o)A.appendChild(N(this.doc,"option",{text:D.name,attrs:{value:D.name}}));A.value=o[0].name,S.appendChild(A);const P=N(this.doc,"div",{class:`${M.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});S.appendChild(P);const L=()=>{const D=o.find(B=>B.name===A.value)||o[0],F=g(m.value),C={op:m.value};return F>=1&&(C.value=E.value),F>=2&&(C.value2=O.value),{when:C,style:{background:D.background,color:D.color}}},z=()=>{Z(P);const D=this.#n(this.scope);if(D.length)for(const F of D.slice(0,t)){const C=this.#r([L()],D,F),B=N(this.doc,"span",{class:`${M.panel}__previewcell`,text:String(F)});C&&B.style&&B.style.setProperty&&(C.background&&B.style.setProperty("background",String(C.background)),C.color&&B.style.setProperty("color",String(C.color))),P.appendChild(B)}};this.off.push(W(E,"input",z)),this.off.push(W(O,"input",z)),this.off.push(W(A,"change",z)),T();const H=N(this.doc,"button",{class:`${M.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(W(H,"click",()=>{this.#c("addRule",this.scope,L()),E.value="",O.value=""})),S.appendChild(H),S}#u(){const S=N(this.doc,"div",{class:`${M.panel}__form`}),m=N(this.doc,"select",{class:`${M.panel}__select`,attrs:{"aria-label":this.t("formatting.colourScale")}});for(const A of c)m.appendChild(N(this.doc,"option",{text:A.name,attrs:{value:A.name}}));m.value=c[0].name,S.appendChild(m);const d=N(this.doc,"select",{class:`${M.panel}__select`,attrs:{"aria-label":this.t("formatting.scaleBounds")}});for(const A of a)d.appendChild(N(this.doc,"option",{text:A.label,attrs:{value:A.from}}));d.value=a[0].from,S.appendChild(d);const j=N(this.doc,"div",{class:`${M.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});S.appendChild(j);const E=()=>{const A=c.find(P=>P.name===m.value)||c[0];return{scale:{from:d.value,colours:[...A.colours]}}},O=()=>{Z(j);const A=this.#n(this.scope);if(A.length)for(const P of A.slice(0,t)){const L=this.#r([E()],A,P),z=N(this.doc,"span",{class:`${M.panel}__previewcell`,text:String(P)});L&&L.background&&z.style&&z.style.setProperty&&z.style.setProperty("background",String(L.background)),j.appendChild(z)}};this.off.push(W(m,"change",O)),this.off.push(W(d,"change",O)),O();const T=N(this.doc,"button",{class:`${M.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(W(T,"click",()=>{this.#c("addRule",this.scope,E())})),S.appendChild(T),S}#c(S,...m){U(this.host[S])&&this.host[S](...m),this.refresh()}}function p(w={}){const S=new b;return S.init({document:$(w),host:w.host||{}}),S}const f=b}),Ae("packages/dom/src/statisticspanel.js",function(e,G){"use strict";Object.defineProperty(e,"StatisticsPanel",{enumerable:!0,get:function(){return l}});const q=G("packages/dom/src/editors/common.js"),M=q.CLS,$=q.el,N=q.on,W=q.clear,V=G("packages/core/src/internal/util.js").isFunction,x=G("packages/dom/src/ui/panelbase.js").ToolPanelBase,I=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"}]),k=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(u){if(u==null||!Number.isFinite(u))return"—";if(Number.isInteger(u))return String(u);const n=Math.abs(u);return n!==0&&(n<.001||n>=1e7)?u.toExponential(2):String(Number(u.toPrecision(4)))}class l extends x{column=null;#e(){return V(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const n=this.root;if(!n)return;for(const r of this.off)r();this.off.length=0,W(n);const t=this.#e();if(!t.length){n.appendChild($(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("stats.noColumns")}));return}t.some(r=>r.id===this.column)||(this.column=t[0].id),n.appendChild(this.#t(t));const i=V(this.host.columnProfile)?this.host.columnProfile(this.column):null;if(!i||!i.present){n.appendChild($(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("stats.noValues")}));return}if(n.appendChild($(this.doc,"p",{class:`${M.panel}__count`,text:this.t("stats.filtered",{count:i.rows})})),Array.isArray(i.topValues)){n.appendChild(this.#o(i,v)),n.appendChild(this.#i(i.topValues));return}n.appendChild(this.#o(i));for(const r of k){const o=this.#n(r);o&&n.appendChild(o)}const s=this.#r();s&&n.appendChild(s),i.histogram&&i.histogram.length>1&&n.appendChild(this.#s(i.histogram))}#t(n){const t=$(this.doc,"select",{class:`${M.panel}__select`,attrs:{"aria-label":this.t("stats.choose")}});for(const i of n){const s=$(this.doc,"option",{text:i.title,attrs:{value:i.id,selected:i.id===this.column?!0:null}});t.appendChild(s)}return t.value=this.column,this.off.push(N(t,"change",()=>{this.column=t.value,this.refresh()})),$(this.doc,"label",{class:`${M.panel}__field`,children:[$(this.doc,"span",{class:`${M.panel}__label`,text:this.t("stats.column")}),t]})}#n(n){const t=this.host.reduceColumn;if(!V(t)||!this.column)return null;const i=[];for(const o of n.kernels){const c=t(this.column,o);c==null||Number.isNaN(c)||i.push([o,c])}if(!i.length)return null;const s=this.doc.createElement("div");s.appendChild($(this.doc,"h4",{class:`${M.panel}__subtitle`,text:this.t(n.label)}));const r=$(this.doc,"dl",{class:`${M.panel}__stats`});for(const[o,c]of i)r.appendChild($(this.doc,"dt",{class:`${M.panel}__stat-name`,text:this.t(`total.${o}`)})),r.appendChild($(this.doc,"dd",{class:`${M.panel}__stat-value`,text:typeof c=="number"?y(c):String(c)}));return s.appendChild(r),s}#r(){const n=this.host.columnCapability;if(!V(n)||!this.column)return null;const t=n(this.column);if(!t)return null;const i=this.doc.createElement("div");i.appendChild($(this.doc,"h4",{class:`${M.panel}__subtitle`,text:this.t("stats.section.capability")}));const s=$(this.doc,"dl",{class:`${M.panel}__stats`}),r=[["stats.cp",t.cp,null],["stats.cpk",t.cpk,t.interval],["stats.pp",t.pp,null],["stats.ppk",t.ppk,t.intervalPp],["stats.outOfSpec",t.outOfSpec,null]];for(const[o,c,a]of r){if(c==null)continue;s.appendChild($(this.doc,"dt",{class:`${M.panel}__stat-name`,text:this.t(o)}));const g=[$(this.doc,"span",{text:y(c)})];a&&Number.isFinite(a.lower)&&g.push($(this.doc,"span",{class:`${M.panel}__stat-interval`,text:`${y(a.lower)} – ${y(a.upper)}`,attrs:{title:`${Math.round(a.confidence*100)}%`}})),s.appendChild($(this.doc,"dd",{class:`${M.panel}__stat-value`,children:g}))}return i.appendChild(s),i}#o(n,t=I){const i=$(this.doc,"dl",{class:`${M.panel}__stats`});for(const s of t){const r=n[s.key];i.appendChild($(this.doc,"dt",{class:`${M.panel}__stat-name`,text:this.t(s.label)})),i.appendChild($(this.doc,"dd",{class:`${M.panel}__stat-value`,text:s.kind==="count"?String(r??0):y(r)}))}return i}#i(n){const t=this.doc.createElement("div");t.appendChild($(this.doc,"h4",{class:`${M.panel}__subtitle`,text:this.t("stats.topValues")}));const i=$(this.doc,"dl",{class:`${M.panel}__stats`});for(const s of n)i.appendChild($(this.doc,"dt",{class:`${M.panel}__stat-name`,text:String(s.value)})),i.appendChild($(this.doc,"dd",{class:`${M.panel}__stat-value`,children:[$(this.doc,"span",{text:String(s.count)}),$(this.doc,"span",{class:`${M.panel}__stat-interval`,text:`${Math.round(s.share*100)}%`})]}));return t.appendChild(i),t}#s(n){const t=n.reduce((s,r)=>Math.max(s,r.count),0)||1,i=$(this.doc,"div",{class:`${M.panel}__histogram`});i.appendChild($(this.doc,"h4",{class:`${M.panel}__subtitle`,text:this.t("stats.distribution")}));for(const s of n){const r=$(this.doc,"div",{class:`${M.panel}__bar`,style:{width:`${s.count?Math.max(2,s.count/t*100):0}%`}});i.appendChild($(this.doc,"div",{class:`${M.panel}__bin`,attrs:{title:this.t("stats.bin",{count:s.count,from:y(s.from),to:y(s.to)})},children:[r]}))}return i}}}),Ae("packages/dom/src/regressionpanel.js",function(e,G){"use strict";Object.defineProperty(e,"RegressionPanel",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const q=G("packages/dom/src/editors/common.js"),M=q.CLS,$=q.el,N=q.clear,Z=G("packages/core/src/internal/util.js").isFunction,U=G("packages/dom/src/ui/panelbase.js").ToolPanelBase;function x(k,y=4){const l=Number(k);return Number.isFinite(l)?l.toFixed(y):l===1/0?"∞":"—"}class I extends U{#e(){const y=this.props||{};if(Array.isArray(y.predictors)&&y.predictors.length&&y.response)return y;const l=this.ctx&&this.ctx.grid,u=l&&Z(l.get)?l.get("regression"):null;return u&&Array.isArray(u.predictors)&&u.response?u:null}refresh(){const y=this.root;if(!y)return;N(y);const l=this.#e();if(!l){y.appendChild($(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("regression.noModel")}));return}const u=Z(this.host.regressionModel)?this.host.regressionModel(l):null;if(!u){y.appendChild($(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("regression.cannotFit")}));return}y.appendChild($(this.doc,"p",{class:`${M.panel}__count`,text:this.t("regression.observations",{count:u.n})})),y.appendChild(this.#t(u)),y.appendChild(this.#n(u));const n=this.#r(u,l);n&&y.appendChild(n),y.appendChild(this.#o(u))}#t(y){const l=$(this.doc,"dl",{class:`${M.panel}__stats`}),u=(n,t)=>{l.appendChild($(this.doc,"dt",{class:`${M.panel}__stat-label`,text:n})),l.appendChild($(this.doc,"dd",{class:`${M.panel}__stat-value`,text:t}))};return u(this.t("regression.r2"),x(y.r2,4)),u(this.t("regression.adjR2"),x(y.adjR2,4)),l}#n(y){const l=$(this.doc,"div",{class:`${M.panel}__section`});l.appendChild($(this.doc,"h4",{class:`${M.panel}__heading`,text:this.t("regression.coefficients")}));const u=$(this.doc,"table",{class:`${M.panel}__coef-table`}),n=$(this.doc,"tr");for(const t of["regression.term","regression.estimate","regression.stdError","regression.t","regression.p"])n.appendChild($(this.doc,"th",{text:this.t(t)}));u.appendChild(n);for(const t of y.coefficients){const i=$(this.doc,"tr");i.appendChild($(this.doc,"td",{text:t.name})),i.appendChild($(this.doc,"td",{text:`${x(t.estimate)} ± ${x(t.stdError)}`})),i.appendChild($(this.doc,"td",{text:x(t.stdError)})),i.appendChild($(this.doc,"td",{text:x(t.t,3)})),i.appendChild($(this.doc,"td",{text:x(t.p,4)})),u.appendChild(i)}return l.appendChild(u),l}#r(y,l){if(!Array.isArray(y.vif)||y.vif.length<2)return null;const u=$(this.doc,"div",{class:`${M.panel}__section`});u.appendChild($(this.doc,"h4",{class:`${M.panel}__heading`,text:this.t("regression.vif")}));const n=$(this.doc,"dl",{class:`${M.panel}__stats`});return y.vif.forEach((t,i)=>{n.appendChild($(this.doc,"dt",{class:`${M.panel}__stat-label`,text:l.predictors[i]})),n.appendChild($(this.doc,"dd",{class:`${M.panel}__stat-value`,text:x(t,3)}))}),u.appendChild(n),u}#o(y){const l=y.heteroscedasticity,u=$(this.doc,"div",{class:`${M.panel}__section`});return u.appendChild($(this.doc,"h4",{class:`${M.panel}__heading`,text:this.t("regression.heteroscedasticity")})),l?(u.appendChild($(this.doc,"p",{class:`${M.panel}__flag`,attrs:{"data-heteroscedastic":l.heteroscedastic?"true":"false"},text:this.t(l.heteroscedastic?"regression.heteroscedastic":"regression.homoscedastic",{statistic:x(l.statistic,3),p:x(l.p,4)})})),u):(u.appendChild($(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("regression.cannotFit")})),u)}}const v=I}),Ae("packages/dom/src/comparepanel.js",function(e,G){"use strict";Object.defineProperty(e,"ComparePanel",{enumerable:!0,get:function(){return k}});const q=G("packages/dom/src/editors/common.js"),M=q.CLS,$=q.el,N=q.on,W=q.clear,V=G("packages/core/src/internal/util.js").isFunction,x=G("packages/dom/src/ui/panelbase.js").ToolPanelBase,I=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 k extends x{first=null;second=null;#e(){return V(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const l=this.root;if(!l)return;for(const i of this.off)i();this.off.length=0,W(l);const u=this.#e();if(u.length<2){l.appendChild($(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("compare.needTwo")}));return}u.some(i=>i.id===this.first)||(this.first=u[0].id),(!u.some(i=>i.id===this.second)||this.second===this.first)&&(this.second=(u.find(i=>i.id!==this.first)||u[0]).id),l.appendChild(this.#t("compare.first",u,this.first,i=>{this.first=i,this.second===i&&(this.second=(u.find(s=>s.id!==i)||u[0]).id),this.refresh()})),l.appendChild(this.#t("compare.second",u,this.second,i=>{this.second=i,this.first===i&&(this.first=(u.find(s=>s.id!==i)||u[0]).id),this.refresh()}));const n=V(this.host.compareColumns)?this.host.compareColumns(this.first,this.second):null;if(!n||!n.n){l.appendChild($(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("compare.noPairs")}));return}l.appendChild($(this.doc,"p",{class:`${M.panel}__count`,text:this.t("compare.pairs",{count:n.n})}));const t=$(this.doc,"dl",{class:`${M.panel}__stats`});for(const i of I){const s=n[i.key];s!=null&&(t.appendChild($(this.doc,"dt",{class:`${M.panel}__stat-name`,text:this.t(i.label)})),t.appendChild($(this.doc,"dd",{class:`${M.panel}__stat-value`,text:v(s)})))}l.appendChild(t)}#t(l,u,n,t){const i=$(this.doc,"select",{class:`${M.panel}__select`,attrs:{"aria-label":this.t(l)}});for(const s of u)i.appendChild($(this.doc,"option",{text:s.title,attrs:{value:s.id,selected:s.id===n?!0:null}}));return i.value=n,this.off.push(N(i,"change",()=>t(i.value))),$(this.doc,"label",{class:`${M.panel}__field`,children:[$(this.doc,"span",{class:`${M.panel}__label`,text:this.t(l)}),i]})}}}),Ae("packages/dom/src/insightspanel.js",function(e,G){"use strict";Object.defineProperty(e,"InsightsPanel",{enumerable:!0,get:function(){return k}});const q=G("packages/dom/src/editors/common.js"),M=q.CLS,$=q.el,N=q.on,W=q.clear,V=G("packages/core/src/internal/util.js").isFunction,x=G("packages/dom/src/ui/panelbase.js").ToolPanelBase,I=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 k extends x{column=null;by=null;#e(){return V(this.host.insightsColumns)?this.host.insightsColumns():[]}refresh(){const l=this.root;if(!l)return;for(const r of this.off)r();this.off.length=0,W(l);const u=this.#e();if(!u.length){l.appendChild($(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("insights.empty")}));return}const n=this.#t();n&&l.appendChild(n);const t=this.#n();t&&l.appendChild(t),l.appendChild(this.#o(u));const i=this.#s();i&&l.appendChild(i);const s=this.#u();s&&l.appendChild(s)}#t(){if(!V(this.host.subsetVsPopulation))return null;const l=this.host.subsetVsPopulation();if(!l)return null;const u=this.#c("insights.subset");return l.filtered?(u.appendChild($(this.doc,"p",{class:`${M.panel}__count`,text:this.t("stats.filtered",{count:l.subsetN})})),u.appendChild(this.#r(l.ranked)),u):(u.appendChild($(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("insights.noFilter")})),u)}#n(){const l=this.props&&this.props.other;if(!l||!V(this.host.datasetVsDataset))return null;let u;try{u=this.host.datasetVsDataset(l)}catch{return null}if(!u||!u.ranked)return null;const n=this.#c("insights.dataset");return n.appendChild(this.#r(u.ranked)),n}#r(l){const u=$(this.doc,"dl",{class:`${M.panel}__stats`});for(const n of l||[]){const t=$(this.doc,"dt",{class:`${M.panel}__stat-name`});t.appendChild($(this.doc,"span",{text:String(n.name??n.column)})),t.appendChild($(this.doc,"span",{class:`${M.panel}__stat-interval`,text:String(n.measure||"")}));const i=$(this.doc,"dd",{class:`${M.panel}__stat-value`});i.appendChild($(this.doc,"span",{text:v(n.magnitude)})),n.reliable===!1&&i.appendChild($(this.doc,"span",{class:`${M.panel}__stat-interval`,text:this.t("insights.smallSample")})),u.appendChild(t),u.appendChild(i)}return u}#o(l){const u=this.#c("insights.groups");l.some(t=>t.id===this.column)||(this.column=l[0].id),(!l.some(t=>t.id===this.by)||this.by===this.column)&&(this.by=(l.find(t=>t.id!==this.column)||l[0]).id),u.appendChild(this.#d("stats.column",l,this.column,t=>{this.column=t,this.by===t&&(this.by=(l.find(i=>i.id!==t)||l[0]).id),this.refresh()})),u.appendChild(this.#d("insights.by",l,this.by,t=>{this.by=t,this.column===t&&(this.column=(l.find(i=>i.id!==t)||l[0]).id),this.refresh()}));const n=V(this.host.compareGroups)?this.host.compareGroups(this.column,{by:this.by}):null;return n?(u.appendChild(this.#i(n)),u):(u.appendChild($(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("insights.needGroups")})),u)}#i(l){const u=$(this.doc,"dl",{class:`${M.panel}__stats`});Array.isArray(l.groups)&&l.groups.length===2&&this.#a(u,"insights.groups",`${l.groups[0]} · ${l.groups[1]}`),this.#a(u,"insights.test",String(l.method||l.test||""));const n=l.effectSize||{};this.#a(u,"insights.effect",`${n.name||""} ${v(n.value)}`.trim());const t=l.interval;let i="—";if(t&&Number.isFinite(t.lower)&&Number.isFinite(t.upper)){const r=Number.isFinite(t.confidence)?` (${Math.round(t.confidence*100)}%)`:"";i=`${v(t.lower)} – ${v(t.upper)}${r}`}const s=this.#a(u,"insights.interval",i);return t&&t.method&&s.appendChild($(this.doc,"span",{class:`${M.panel}__stat-interval`,text:String(t.method)})),Number.isFinite(l.pValue)&&this.#a(u,"insights.pValue",v(l.pValue)),u}#s(){if(!V(this.host.anomalies))return null;let l;try{l=this.host.anomalies()}catch{return null}if(!l)return null;const u=this.#c("insights.anomalies");u.appendChild($(this.doc,"p",{class:`${M.panel}__count`,text:this.t("insights.anomalyCount",{count:l.flagged||0,n:l.n||0})}));const n=$(this.doc,"dl",{class:`${M.panel}__stats`});this.#a(n,"insights.anomalyMethod",String(l.method||""));const t=this.#l(l);t!==null&&this.#a(n,"insights.anomalyThreshold",v(t)),u.appendChild(n);const i=(l.rows||[]).map(s=>({name:s.rowKey!=null?String(s.rowKey):`#${s.index}`,measure:(s.why||[]).map(r=>r.name||r.column).join(", "),magnitude:s.score}));return u.appendChild(this.#r(i)),u}#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 u=Array.isArray(l.columns)?l.columns[0]:null;return u&&Number.isFinite(u.threshold)?u.threshold:null}#a(l,u,n){l.appendChild($(this.doc,"dt",{class:`${M.panel}__stat-name`,text:this.t(u)}));const t=$(this.doc,"dd",{class:`${M.panel}__stat-value`});return t.appendChild($(this.doc,"span",{text:n})),l.appendChild(t),t}#u(){if(!V(this.host.columnCapability)||!this.column)return null;const l=this.host.columnCapability(this.column);if(!l)return null;const u=this.#c("stats.section.capability"),n=$(this.doc,"dl",{class:`${M.panel}__stats`});for(const t of I){const i=l[t.field];if(i==null)continue;n.appendChild($(this.doc,"dt",{class:`${M.panel}__stat-name`,text:this.t(t.key)}));const s=[$(this.doc,"span",{text:v(i)})],r=t.interval?l[t.interval]:null;r&&Number.isFinite(r.lower)&&s.push($(this.doc,"span",{class:`${M.panel}__stat-interval`,text:`${v(r.lower)} – ${v(r.upper)}`,attrs:{title:`${Math.round(r.confidence*100)}%`}})),n.appendChild($(this.doc,"dd",{class:`${M.panel}__stat-value`,children:s}))}return u.appendChild(n),u}#c(l){const u=this.doc.createElement("div");return u.appendChild($(this.doc,"h4",{class:`${M.panel}__subtitle`,text:this.t(l)})),u}#d(l,u,n,t){const i=$(this.doc,"select",{class:`${M.panel}__select`,attrs:{"aria-label":this.t(l)}});for(const s of u)i.appendChild($(this.doc,"option",{text:s.title,attrs:{value:s.id,selected:s.id===n?!0:null}}));return i.value=n,this.off.push(N(i,"change",()=>t(i.value))),$(this.doc,"label",{class:`${M.panel}__field`,children:[$(this.doc,"span",{class:`${M.panel}__label`,text:this.t(l)}),i]})}}}),Ae("packages/dom/src/ui/toolpanel.js",function(e,G){"use strict";Object.defineProperty(e,"ColumnsPanel",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"FiltersPanel",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"QuickFilterPanel",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"toolPanelTitles",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"toolPanelIcons",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return z}});const q=G("packages/dom/src/editors/common.js"),M=q.CLS,$=q.cssEscape,N=q.documentFor,W=q.el,Z=q.on,V=q.clear,x=G("packages/core/src/i18n/index.js").defaultMessages,I=G("packages/core/src/internal/util.js"),v=I.isFunction,k=I.nextFrame,y=G("packages/dom/src/cell/icons.js"),l=y.createIcon,u=y.updateIcon,n=y.icon,i=G("packages/dom/src/viewpicker.js").ViewPicker,r=G("packages/dom/src/formattingpanel.js").FormattingPanel,c=G("packages/dom/src/statisticspanel.js").StatisticsPanel,g=G("packages/dom/src/regressionpanel.js").RegressionPanel,b=G("packages/dom/src/comparepanel.js").ComparePanel,f=G("packages/dom/src/insightspanel.js").InsightsPanel,S=G("packages/dom/src/ui/panelbase.js").ToolPanelBase,d=G("packages/core/src/compute/total.js").TOTAL_LABELS;class j extends S{dragging=null;refresh(){const F=this.root;if(!F)return;for(const Y of this.off)Y();this.off.length=0,V(F);const C=W(this.doc,"input",{class:`${M.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.searchColumns"),"aria-label":this.t("panel.searchColumns")}});this.off.push(Z(C,"input",()=>{this.query=C.value,this.paintList()})),F.appendChild(C),F.appendChild(this.buildZone("group","Row groups")),F.appendChild(this.buildZone("values","Grouped row calculation")),F.appendChild(this.buildZone("pivot","Pivot"));const B=W(this.doc,"div",{class:`${M.panel}__heading`});B.appendChild(W(this.doc,"span",{text:this.t("panel.columns")}));const _=W(this.doc,"button",{class:`${M.panel}__link`,text:this.t("panel.showAll"),attrs:{type:"button"}}),Q=W(this.doc,"button",{class:`${M.panel}__link`,text:this.t("panel.hideAll"),attrs:{type:"button"}});this.off.push(Z(_,"click",()=>{const Y=this.columns().filter(J=>!(J.layout&&J.layout.lockVisible)).map(J=>J.id);v(this.host.showColumns)&&this.host.showColumns(Y),this.refresh()})),this.off.push(Z(Q,"click",()=>{const Y=this.columns().filter(J=>!(J.layout&&J.layout.lockVisible)).map(J=>J.id);v(this.host.hideColumns)&&this.host.hideColumns(Y),this.refresh()})),B.appendChild(_),B.appendChild(Q),F.appendChild(B),this.list=W(this.doc,"div",{class:`${M.panel}__columns`,attrs:{role:"group","aria-label":this.t("panel.columns")}}),F.appendChild(this.list),this.paintList()}columns(){const F=this.host;return v(F.columns)?F.columns()||[]:F.columns&&v(F.columns.all)?F.columns.all():[]}paintList(){const F=this.list;if(!F)return;V(F);const C=String(this.query||"").trim().toLowerCase();for(const B of this.columns()){const _=String(B.title||B.id||"");if(C&&!_.toLowerCase().includes(C))continue;const Q=W(this.doc,"div",{class:`${M.panel}__column`,attrs:{"data-col":B.id,draggable:"true",title:this.t("panel.columnDragHint",{column:_})}});Q.appendChild(W(this.doc,"span",{class:`${M.panel}__grip`,attrs:{"aria-hidden":"true"}}));const Y=W(this.doc,"input",{attrs:{type:"checkbox","aria-label":_}});Y.checked=!(B.layout&&B.layout.hidden),B.layout&&B.layout.lockVisible&&Y.setAttribute("disabled",""),this.off.push(Z(Y,"change",()=>this.setVisible(B.id,Y.checked))),Q.appendChild(Y),Q.appendChild(W(this.doc,"span",{text:_})),Q.setAttribute("tabindex","0"),Q.setAttribute("role","listitem"),this.off.push(Z(Q,"keydown",J=>this.onRowKey(J,B))),this.off.push(Z(Q,"dragstart",()=>{this.dragging=B.id})),this.off.push(Z(Q,"dragend",()=>{this.dragging=null,this.clearDropMark()})),this.off.push(Z(Q,"dragover",J=>{if(!this.dragging||this.dragging===B.id)return;v(J.preventDefault)&&J.preventDefault();const te=H(J,Q);Q.setAttribute("data-drop",te?"before":"after")})),this.off.push(Z(Q,"dragleave",()=>Q.removeAttribute("data-drop"))),this.off.push(Z(Q,"drop",J=>{v(J.preventDefault)&&J.preventDefault();const te=this.dragging;this.dragging=null,this.clearDropMark(),!(!te||te===B.id)&&this.moveColumn(te,B.id,H(J,Q))})),F.appendChild(Q)}}onRowKey(F,C){const B=F&&F.key,_=j.zoneKeys[String(B).toLowerCase()];if(_&&!F.ctrlKey&&!F.metaKey&&!F.altKey){v(F.preventDefault)&&F.preventDefault(),this.toggleZone(_,C);return}if(B!=="ArrowUp"&&B!=="ArrowDown")return;const Q=B==="ArrowUp",Y=this.columns().map(le=>le.id),J=Y.indexOf(C.id);if(J<0)return;if(v(F.preventDefault)&&F.preventDefault(),!F.shiftKey){const le=this.list&&this.list.querySelectorAll?[...this.list.querySelectorAll("[data-col]")]:[],ne=le.findIndex(ae=>ae.getAttribute("data-col")===C.id),se=le[ne+(Q?-1:1)];se&&v(se.focus)&&se.focus();return}const te=C.layout&&(C.layout.movable===!1||C.layout.lockPosition),ee=String(C.title||C.id||"");if(te){this.announce(this.t("a11y.panel.cannotMove",{column:ee}),{repeat:!0});return}const oe=Y[J+(Q?-1:1)];if(!oe){this.announce(this.t(Q?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:ee}),{repeat:!0});return}this.moveColumn(C.id,oe,Q),this.announce(this.t("a11y.panel.moved",{column:ee,at:Q?J:J+2,of:Y.length}),{repeat:!0});const re=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${$(C.id)}"]`):null;re&&v(re.focus)&&re.focus()}toggleZone(F,C){const B=this.titleOf(C.id),_=this.t(j.zoneLabel[F]||"panel.zone.group");if(this.zoneColumns(F).includes(C.id)){this.dropFromZone(F,C.id),this.announce(this.t("a11y.panel.removedFrom",{column:B,list:_}),{repeat:!0}),this.restoreFocus(C.id);return}if(this.addToZone(F,C.id)){this.announce(this.t("a11y.panel.addedTo",{column:B,list:_}),{repeat:!0}),this.restoreFocus(C.id);return}this.announce(this.t("a11y.panel.cannotAddTo",{column:B,list:_}),{repeat:!0})}restoreFocus(F){const C=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${$(F)}"]`):null;C&&v(C.focus)&&C.focus()}announce(F,C){const B=this.host||{};v(B.announce)&&B.announce(F,C)}clearDropMark(){if(!(!this.list||!this.list.querySelectorAll))for(const F of this.list.querySelectorAll("[data-drop]"))F.removeAttribute("data-drop")}moveColumn(F,C,B){const _=this.host||{};v(_.moveColumn)&&(_.moveColumn(F,C,B),this.refresh())}buildZone(F,C){const B=W(this.doc,"div",{class:`${M.panel}__zone`,attrs:{"data-zone":F,role:"group","aria-label":C}});B.appendChild(W(this.doc,"div",{class:`${M.panel}__zoneTitle`,text:C}));const _=this.zoneColumns(F);let Q=j.zoneAbout[F]||"";F==="values"&&_.length&&!this.zoneColumns("group").length&&(Q+=" Add a row group to see them."),Q&&B.appendChild(W(this.doc,"div",{class:`${M.panel}__zoneAbout`,text:Q}));const Y=W(this.doc,"div",{class:`${M.panel}__zoneBody`});_.length||Y.appendChild(W(this.doc,"span",{class:`${M.panel}__zoneHint`,text:this.t(j.zoneHint[F]||"panel.zoneHint.any")})),F==="values"&&Y.classList.add(`${M.panel}__zoneBody--rows`);for(const J of _){const te=W(this.doc,"span",{class:[M.chip,F==="values"?`${M.chip}--row`:""]});if(te.appendChild(W(this.doc,"span",{class:`${M.chip}__label`,text:this.titleOf(J)})),F==="values"&&v(this.host.setValueAggregation)){const oe=v(this.host.valueAggregation)?this.host.valueAggregation(J):"sum",re=W(this.doc,"select",{class:`${M.chip}__fn`,attrs:{"aria-label":`Calculation for ${this.titleOf(J)}`}});for(const le of j.aggregations)re.appendChild(W(this.doc,"option",{text:this.t(`total.${le.name}`),attrs:{value:le.name,selected:le.name===oe?"":null}}));re.value=oe,this.off.push(Z(re,"change",()=>{this.host.setValueAggregation(J,re.value),this.refresh()})),te.appendChild(re)}const ee=W(this.doc,"button",{class:M.chipRemove,text:"×",attrs:{type:"button","aria-label":`Remove ${this.titleOf(J)}`}});this.off.push(Z(ee,"click",()=>this.dropFromZone(F,J))),te.appendChild(ee),Y.appendChild(te)}return this.off.push(Z(B,"dragover",J=>{v(J.preventDefault)&&J.preventDefault(),B.setAttribute("data-over","true")})),this.off.push(Z(B,"dragleave",()=>B.removeAttribute("data-over"))),this.off.push(Z(B,"drop",J=>{v(J.preventDefault)&&J.preventDefault(),B.removeAttribute("data-over"),this.dragging&&this.addToZone(F,this.dragging)})),B.appendChild(Y),B}static aggregations=Object.freeze(Object.keys(d).map(F=>({name:F})));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(F){const C=j.zoneApi[F],B=this.host;return C&&v(B[C.read])?B[C.read]()||[]:[]}titleOf(F){const C=this.columns().find(B=>B.id===F);return String(C&&(C.title||C.id)||F)}addToZone(F,C){const B=j.zoneApi[F],_=this.columns().find(Y=>Y.id===C);if(!B||!_||_[B.permission]===!1||!v(this.host[B.write]))return!1;const Q=this.zoneColumns(F);return Q.includes(C)?!1:(this.host[B.write]([...Q,C]),this.refresh(),!0)}dropFromZone(F,C){const B=j.zoneApi[F];return!B||!v(this.host[B.write])?!1:(this.host[B.write](this.zoneColumns(F).filter(_=>_!==C)),this.refresh(),!0)}setVisible(F,C){const B=this.host;C&&v(B.showColumns)?B.showColumns([F]):!C&&v(B.hideColumns)&&B.hideColumns([F])}}class E extends S{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 F=this.root;if(!F)return;for(const te of this.off)te();this.off.length=0,V(F);const C=this.host,B=(v(C.columns)?C.columns():[]).filter(te=>!(te.filter&&te.filter.enabled===!1));if(!v(C.filterFor))return;const _=B.filter(te=>this.isFiltered(te.id));F.appendChild(this.buildSearch()),F.appendChild(this.buildSummary(_.length,B.length));const Q=this.query.trim().toLowerCase(),Y=Q?B.filter(te=>String(te.title||te.id).toLowerCase().includes(Q)):B;if(!Y.length){F.appendChild(W(this.doc,"p",{class:`${M.panel}__empty`,text:Q?this.t("panel.filterEmptyNoMatch",{query:this.query.trim()}):this.t("panel.filterEmptyNone")}));return}const J=W(this.doc,"div",{class:`${M.panel}__filters`});for(const te of Y)J.appendChild(this.buildSection(te));F.appendChild(J)}isFiltered(F){const C=this.host;return v(C.isFiltered)?C.isFiltered(F)===!0:!1}buildSearch(){const F=W(this.doc,"input",{class:`${M.panel}__search`,attrs:{type:"text",placeholder:this.t("panel.searchColumnsPlaceholder"),"aria-label":this.t("panel.searchColumnsToFilter")}});return F.value=this.query,this.off.push(Z(F,"input",()=>{this.query=F.value||"",this.refresh();const C=this.root&&this.root.querySelector?this.root.querySelector(`.${M.panel}__search`):null;C&&v(C.focus)&&C.focus()})),F}buildSummary(F,C){const B=W(this.doc,"div",{class:`${M.panel}__filterSummary`});if(B.appendChild(W(this.doc,"span",{class:`${M.panel}__filterCount`,text:F?this.t("panel.filterSummaryActive",{active:F,total:C}):this.t("panel.filterSummaryNone",{total:C}),attrs:{"data-active":F?"true":"false"}})),!F)return B;const _=W(this.doc,"button",{class:`${M.panel}__clearAll`,text:this.t("panel.clearAll"),attrs:{type:"button"}});return this.off.push(Z(_,"click",()=>{v(this.host.clearAllFilters)&&this.host.clearAllFilters(),this.refresh()})),B.appendChild(_),B}buildSection(F){const C=F.id,B=String(F.title||C),_=this.isFiltered(C),Q=this.open.has(C),Y=W(this.doc,"section",{class:`${M.panel}__filter`,attrs:{"data-col":C,"data-filtered":_?"true":null}}),J=W(this.doc,"button",{class:`${M.panel}__filterTitle`,attrs:{type:"button","aria-expanded":Q?"true":"false",title:this.t(_?"panel.filteredBy":"panel.filterBy",{column:B})},children:[l(this.doc,Q?"chevronDown":"chevronRight",{className:`${M.panel}__twisty`}),W(this.doc,"span",{class:`${M.panel}__filterName`,text:B})]});_&&J.appendChild(W(this.doc,"span",{class:`${M.panel}__filterDot`,attrs:{"aria-label":this.t("panel.columnFiltered"),title:this.t("panel.columnFiltered")}}));const te=W(this.doc,"div",{class:`${M.panel}__filterBody`,style:{display:Q?"":"none"}}),ee=()=>{if(te.firstChild)return;const oe=this.host.filterFor(C);oe&&v(oe.element)&&te.appendChild(oe.element())};if(this.off.push(Z(J,"click",()=>{const oe=this.open.has(C);oe?this.open.delete(C):this.open.add(C),J.setAttribute("aria-expanded",oe?"false":"true"),te.style.display=oe?"none":"";const re=J.firstElementChild;re&&u(re,oe?"chevronRight":"chevronDown"),oe||ee()})),Y.appendChild(J),_){const oe=W(this.doc,"button",{class:`${M.panel}__filterClear`,attrs:{type:"button","aria-label":this.t("panel.clearFilterOn",{column:B}),title:this.t("panel.clearFilter")},children:[l(this.doc,"close",{className:M.icon})]});this.off.push(Z(oe,"click",re=>{v(re.stopPropagation)&&re.stopPropagation(),v(this.host.clearFilter)&&this.host.clearFilter(C),this.refresh()})),Y.appendChild(oe)}return Y.appendChild(te),Q&&ee(),Y}}class O extends S{refresh(){const F=this.root;if(!F)return;if(this.box){const Q=v(this.host.quickFilter)?this.host.quickFilter():"";this.doc&&this.doc.activeElement!==this.box&&this.box.value!==Q&&(this.box.value=Q),this.paintCount();return}for(const Q of this.off)Q();this.off.length=0,V(F);const C=v(this.host.quickFilter)?this.host.quickFilter():"",B=W(this.doc,"input",{class:`${M.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.filterAllColumns"),"aria-label":this.t("panel.quickFilter")}});B.value=C||"",this.off.push(Z(B,"input",()=>{v(this.host.setQuickFilter)&&this.host.setQuickFilter(B.value),this.paintCount()})),F.appendChild(B),this.box=B;const _=W(this.doc,"button",{class:`${M.panel}__link`,text:this.t("panel.clear"),attrs:{type:"button"}});this.off.push(Z(_,"click",()=>{B.value="",v(this.host.setQuickFilter)&&this.host.setQuickFilter(""),this.paintCount(),v(B.focus)&&B.focus()})),F.appendChild(_),this.count=W(this.doc,"p",{class:`${M.panel}__count`}),F.appendChild(this.count),this.paintCount()}destroy(){this.box=null,this.count=null,super.destroy()}focus(){k(()=>{this.box&&v(this.box.focus)&&this.box.focus()})}paintCount(){if(!this.count)return;const F=v(this.host.rowCount)?this.host.rowCount():null,C=v(this.host.totalRowCount)?this.host.totalRowCount():null;if(F===null||C===null){this.count.textContent="";return}this.count.textContent=F===C?this.t("count.rows",{count:C}):this.t("panel.rowsOf",{shown:F,total:C})}}const T=Object.freeze({columns:j,filters:E,views:i,quick:O,formatting:r,statistics:c,regression:g,compare:b,insights:f}),A=Object.freeze({columns:"panel.columns",filters:"panel.filters",views:"panel.views",quick:"panel.quickFilter",formatting:"panel.formatting",statistics:"panel.statistics",regression:"panel.regression",compare:"panel.compare",insights:"panel.insights"}),P=Object.freeze({columns:"columns",filters:"filter",views:"views",quick:"search",formatting:"palette",statistics:"chart",regression:"chart",compare:"link",insights:"chart"});class L{panels=[];actions=[];root=null;openPanel=null;off=[];t(F,C){return(this.messages&&typeof this.messages.t=="function"?this.messages:x).t(F,C)}init(F){const C=F||{};this.doc=N(C),this.host=C.host||{},this.messages=C.messages||C.grid&&C.grid.messages||x,this.icons=C.icons===void 0?C.side==="left":!!C.icons,this.side=C.side==="left"?"left":"right",this.root=W(this.doc,"div",{class:[M.panel,`${M.panel}--${this.side}`,this.icons?`${M.panel}--icons`:null]}),this.tabs=W(this.doc,"div",{class:`${M.panel}__tabs`,attrs:{role:"tablist"}}),this.body=W(this.doc,"div",{class:`${M.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:`${M.panel}__actions`,attrs:{role:"group","aria-label":this.t("panel.gridActions")}}),this.tabs.appendChild(this.actionGroup);for(const Q of Array.isArray(C.actions)?C.actions:[])this.registerAction(Q);const B=C.registry||{},_=Array.isArray(C.panels)&&C.panels.length?C.panels:["columns","filters"];for(const Q of _){const Y=typeof Q=="string"?Q:Q.name,J=typeof Q=="function"?Q:B[Y]||T[Y];J&&this.registerPanel(String(Y),J,typeof Q=="object"?Q:{})}C.openPanel&&this.show(C.openPanel)}registerPanel(F,C,B){const _=new C;_.init({document:this.doc,host:this.host,props:B&&B.props||{}});const Q=B&&B.title||F,Y=B&&B.icon||F,J=W(this.doc,"button",{class:`${M.panel}__tab`,text:this.icons?null:Q,attrs:{type:"button",role:"tab","aria-selected":"false","data-panel":F,title:this.icons?Q:null,"aria-label":this.icons?Q:null}});return this.icons&&J.appendChild(l(this.doc,Y,{className:`${M.panel}__icon`})),this.off.push(Z(J,"click",()=>this.toggle(F))),this.tabs.appendChild(J),this.panels.push({name:F,title:Q,panel:_}),_}registerAction(F){if(!F||!F.name)return null;if(F.separator)return this.actionGroup.appendChild(W(this.doc,"div",{class:`${M.panel}__divider`,attrs:{"aria-hidden":"true"}})),null;const C=W(this.doc,"button",{class:`${M.panel}__action`,text:this.icons?null:v(F.title)?String(F.title()):F.title,attrs:{type:"button","data-action":F.name,title:v(F.title)?null:F.title,"aria-label":v(F.title)?null:F.title}});if(this.icons){const Q=(v(F.icon)?F.icon():F.icon)||(n(F.name)?F.name:"blank");C.appendChild(l(this.doc,Q,{className:`${M.panel}__icon`})),C.setAttribute("data-icon",Q)}const B=Z(C,"click",()=>{v(F.enabled)&&!F.enabled()||(v(F.run)&&F.run(),this.paintActions())});return this.off.push(B),this.actionGroup.appendChild(C),this.actions.push({...F,button:C,offClick:B}),this.paintActions(),C}removeAction(F){const C=this.actions.findIndex(_=>_.name===F);if(C<0)return!1;const B=this.actions[C];return v(B.offClick)&&B.offClick(),B.button&&B.button.parentNode&&B.button.parentNode.removeChild(B.button),this.actions.splice(C,1),!0}paintActions(){for(const F of this.actions){if(!F.button)continue;const C=v(F.enabled)?!!F.enabled():!0;if(F.button.disabled=!C,F.button.setAttribute("aria-disabled",C?"false":"true"),v(F.active)&&F.button.setAttribute("aria-pressed",F.active()?"true":"false"),v(F.title)){const B=String(F.title());F.button.setAttribute("title",B),F.button.setAttribute("aria-label",B),!this.icons&&F.button.textContent!==B&&(F.button.textContent=B)}if(this.icons&&v(F.icon)){const B=String(F.icon());F.button.getAttribute("data-icon")!==B&&(V(F.button),F.button.appendChild(l(this.doc,B,{className:`${M.panel}__icon`})),F.button.setAttribute("data-icon",B))}}}show(F){const C=this.panels.find(B=>B.name===F);return C?(V(this.body),v(C.panel.refresh)&&C.panel.refresh(),this.body.appendChild(C.panel.element()),this.openPanel=F,this.paintTabs(),v(C.panel.focus)&&C.panel.focus(),!0):!1}hide(){V(this.body),this.openPanel=null,this.paintTabs()}toggle(F){this.openPanel===F?this.hide():this.show(F)}paintTabs(){if(!(!this.tabs||!this.tabs.childNodes))for(let F=0;F<this.tabs.childNodes.length;F++){const C=this.tabs.childNodes[F];C&&C.setAttribute&&C.setAttribute("aria-selected",C.getAttribute("data-panel")===this.openPanel?"true":"false")}}element(){return this.root}refresh(){const F=this.panels.find(C=>C.name===this.openPanel);F&&v(F.panel.refresh)&&!this.#e(F.panel)&&F.panel.refresh(),this.paintActions()}#e(F){const C=this.doc&&this.doc.activeElement;if(!C||C===this.doc.body)return!1;const B=v(F.element)?F.element():null;return!!(B&&v(B.contains)&&B.contains(C))}destroy(){for(const F of this.off)F();this.off.length=0;for(const F of this.panels)v(F.panel.destroy)&&F.panel.destroy();this.panels=[],this.root=null}}const z=L;function H(D,F){if(!F.getBoundingClientRect||typeof D.clientY!="number")return!0;const C=F.getBoundingClientRect();return D.clientY<C.top+C.height/2}}),Ae("packages/dom/src/ui/groupbyzone.js",function(e,G){"use strict";Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return k}});const M=G("packages/dom/src/ui/panelbase.js").ToolPanelBase,$=G("packages/dom/src/editors/common.js"),N=$.CLS,W=$.el,Z=$.on,V=$.clear,U=$.cssEscape,I=G("packages/core/src/internal/util.js").isFunction,v="text/x-lattice-col";class k extends M{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:N.groupZone,attrs:{role:"group","aria-label":this.t("groupZone.label")}}),this.refresh()}columns(){const l=this.host;return I(l.columns)?l.columns()||[]:l.columns&&I(l.columns.all)?l.columns.all():[]}groups(){return I(this.host.groupBy)?this.host.groupBy()||[]:[]}setGroups(l){I(this.host.setGroupBy)&&this.host.setGroupBy(l)}titleOf(l){const u=this.columns().find(n=>n.id===l);return String(u&&(u.title||u.id)||l)}canGroup(l){const u=this.columns().find(n=>n.id===l);return!!u&&u.allowGroup!==!1&&!u.generated}announce(l,u){I(this.host.announce)&&this.host.announce(l,u)}refresh(){const l=this.root;if(!l)return;for(const t of this.off)t();this.off.length=0,V(l),l.appendChild(W(this.doc,"span",{class:N.groupZoneTitle,text:this.t("groupZone.title"),attrs:{"aria-hidden":"true"}}));const u=this.groups(),n=W(this.doc,"div",{class:N.groupZoneChips,attrs:{role:"listbox","aria-orientation":"horizontal","aria-label":this.t("groupZone.label")}});u.length||n.appendChild(W(this.doc,"span",{class:N.groupZoneHint,text:this.t("groupZone.hint")})),u.forEach((t,i)=>n.appendChild(this.#t(t,i,u.length))),l.appendChild(n),this.chips=n,l.appendChild(this.#i(u)),this.off.push(Z(l,"dragover",t=>{this.dragging==null&&!this.#l(t)||(I(t.preventDefault)&&t.preventDefault(),l.setAttribute("data-over","true"))})),this.off.push(Z(l,"dragleave",()=>l.removeAttribute("data-over"))),this.off.push(Z(l,"drop",t=>{I(t.preventDefault)&&t.preventDefault(),l.removeAttribute("data-over");const i=this.#l(t)||this.dragging;i!=null&&this.#o(i,this.groups().length)})),this.#s()}#t(l,u,n){const t=this.titleOf(l),i=W(this.doc,"div",{class:[N.chip,N.groupZoneChip],attrs:{role:"option","aria-selected":"true",tabindex:"0",draggable:"true","data-col":l,"aria-label":this.t("groupZone.chip",{column:t,at:u+1,of:n})}});i.appendChild(W(this.doc,"span",{class:N.groupZoneChipText,text:t}));const s=W(this.doc,"button",{class:N.chipRemove,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("groupZone.remove",{column:t})}});return this.off.push(Z(s,"click",()=>this.#r(l))),i.appendChild(s),this.off.push(Z(i,"dragstart",r=>{this.dragging=l,r.dataTransfer&&I(r.dataTransfer.setData)&&r.dataTransfer.setData(v,l)})),this.off.push(Z(i,"dragend",()=>{this.dragging=null})),this.off.push(Z(i,"dragover",r=>{const o=this.#l(r)||this.dragging;o==null||o===l||I(r.preventDefault)&&r.preventDefault()})),this.off.push(Z(i,"drop",r=>{const o=this.#l(r)||this.dragging;o!=null&&(I(r.preventDefault)&&r.preventDefault(),I(r.stopPropagation)&&r.stopPropagation(),this.#o(o,u))})),this.off.push(Z(i,"keydown",r=>this.#n(r,l,u))),i}#n(l,u,n){const t=l&&l.key,i=this.groups();if(t==="Delete"||t==="Backspace"){I(l.preventDefault)&&l.preventDefault(),this.#r(u,i,n);return}const s=t==="ArrowLeft"||t==="ArrowUp",r=t==="ArrowRight"||t==="ArrowDown",o=t==="Home",c=t==="End";if(!s&&!r&&!o&&!c)return;if(I(l.preventDefault)&&l.preventDefault(),l.shiftKey&&(s||r)){const h=n+(s?-1:1);if(h<0||h>=i.length){this.announce(this.t(s?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:this.titleOf(u)}),{repeat:!0});return}const b=i.slice();b.splice(n,1),b.splice(h,0,u),this.setGroups(b),this.announce(this.t("a11y.panel.moved",{column:this.titleOf(u),at:h+1,of:b.length}),{repeat:!0}),this.#a(u);return}let a=n+(s?-1:r?1:0);o&&(a=0),c&&(a=i.length-1);const g=i[a];g&&this.#a(g)}#r(l,u=this.groups(),n=u.indexOf(l)){const t=this.titleOf(l);this.setGroups(u.filter(s=>s!==l)),this.announce(this.t("a11y.panel.removedFrom",{column:t,list:this.t("panel.zone.group")}),{repeat:!0});const i=this.groups();i.length?this.#a(i[Math.min(n,i.length-1)]):this.#u()}#o(l,u){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 n=this.groups(),t=n.indexOf(l),i=n.slice();t>=0&&(i.splice(t,1),t<u&&(u-=1)),i.splice(Math.max(0,Math.min(u,i.length)),0,l),this.setGroups(i);const s=i.indexOf(l);this.announce(this.t(t>=0?"a11y.panel.moved":"a11y.panel.addedTo",t>=0?{column:this.titleOf(l),at:s+1,of:i.length}:{column:this.titleOf(l),list:this.t("panel.zone.group")}),{repeat:!0}),this.#a(l)}#i(l){const u=new Set(l),n=W(this.doc,"label",{class:N.groupZoneAdd}),t=W(this.doc,"select",{class:N.groupZoneAddSelect,attrs:{"aria-label":this.t("groupZone.add")}});t.appendChild(W(this.doc,"option",{text:this.t("groupZone.add"),attrs:{value:""}}));for(const i of this.columns())u.has(i.id)||!this.canGroup(i.id)||t.appendChild(W(this.doc,"option",{text:this.titleOf(i.id),attrs:{value:i.id}}));return this.off.push(Z(t,"change",()=>{const i=t.value;i&&this.#o(i,this.groups().length)})),this.adderSelect=t,n.appendChild(t),n}#s(){for(const u of this.#e)u();this.#e.length=0;const l=this.props&&this.props.header;if(!(!l||!I(l.querySelectorAll)))for(const u of l.querySelectorAll("[data-col]")){const n=I(u.getAttribute)?u.getAttribute("data-col"):null;!n||!this.canGroup(n)||(I(u.setAttribute)&&u.setAttribute("draggable","true"),this.#e.push(Z(u,"dragstart",t=>{this.dragging=n,t.dataTransfer&&I(t.dataTransfer.setData)&&t.dataTransfer.setData(v,n)})),this.#e.push(Z(u,"dragend",()=>{this.dragging=null})))}}#l(l){const u=l&&l.dataTransfer;if(u&&I(u.getData)){const n=u.getData(v);if(n)return n}return null}#a(l){const u=this.chips&&I(this.chips.querySelector)?this.chips.querySelector(`[data-col="${U(l)}"]`):null;u&&I(u.focus)&&u.focus()}#u(){this.adderSelect&&I(this.adderSelect.focus)&&this.adderSelect.focus()}destroy(){for(const l of this.#e)l();this.#e.length=0,super.destroy()}}}),Ae("packages/dom/src/ui/tooltip.js",function(e,G){"use strict";Object.defineProperty(e,"TextTooltip",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const q=G("packages/dom/src/editors/common.js"),M=q.CLS,$=q.documentFor,N=q.el,W=q.on,Z=q.clear,U=G("packages/core/src/internal/util.js").isFunction;class x{root=null;init(y){this.doc=y.document,this.root=N(this.doc,"div",{class:`${M.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 I{root=null;component=null;timer=null;target=null;off=[];constructor(y){const l=y||{};this.doc=$(l),this.host=l.host||this.doc.body,this.delay=l.delay??400,this.hideDelay=l.hideDelay??0,this.components={text:x,...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",u=typeof l=="function"?l:this.components[l]||x;return this.root||(this.root=N(this.doc,"div",{class:M.tooltip,attrs:{role:"tooltip"},style:{position:"absolute"}}),this.host.appendChild(this.root)),!this.component||this.componentCtor!==u?(this.component&&U(this.component.destroy)&&this.component.destroy(),Z(this.root),this.component=new u,this.componentCtor=u,this.component.init({document:this.doc,content:y.content,...y.props||{}}),this.root.appendChild(this.component.element())):U(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||!U(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,u){const n=()=>this.show({target:y,content:l(),...u||{}}),t=()=>this.hide(),i=[W(y,"mouseenter",n),W(y,"mouseleave",t),W(y,"focus",n),W(y,"blur",t)],s=()=>{for(const r of i)r()};return this.off.push(s),s}destroy(){this.hide();for(const y of this.off)y();this.off.length=0,this.component&&U(this.component.destroy)&&this.component.destroy(),this.component=null,this.root=null}}const v=I}),Ae("packages/dom/src/ui/pagination.js",function(e,G){"use strict";Object.defineProperty(e,"pageModel",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const q=G("packages/dom/src/editors/common.js"),M=q.CLS,$=q.documentFor,N=q.el,W=q.on,Z=q.clear,U=G("packages/core/src/i18n/index.js").defaultMessages,I=G("packages/core/src/internal/util.js").isFunction;function v(l){const u=Math.max(1,Number(l.pageSize)||100),n=l.total==null?null:Math.max(0,Number(l.total)),t=n==null?null:Math.max(1,Math.ceil(n/u)),i=Math.max(0,t==null?Number(l.page)||0:Math.min(Number(l.page)||0,t-1)),s=n===0?0:i*u+1,r=n==null?(i+1)*u:Math.min(n,(i+1)*u);return{page:i,pageSize:u,pageCount:t,from:s,to:r,first:i===0,last:t==null?l.hasMore!==!0:i>=t-1,total:n}}class k{root=null;page=0;pageSize=100;total=null;counting=!1;hasMore=!1;off=[];init(u){const n=u||{};this.doc=$(n),this.host=n.host||{},this.pageSize=Number(n.pageSize)||100;const t=Array.isArray(n.pageSizes)&&n.pageSizes.length?[...n.pageSizes]:[25,50,100,250,1e3];this.pageSize>0&&!t.includes(this.pageSize)&&t.push(this.pageSize),this.pageSizes=t.sort((i,s)=>i-s),this.page=Number(n.page)||0,this.total=n.total===void 0?null:n.total,this.locale=n.locale,this.messages=n.messages||null,this.onChange=n.onChange||null,this.root=N(this.doc,"nav",{class:M.pagination,attrs:{"aria-label":this.t("pagination.label")}}),this.paint()}t(u,n){const t=this.messages;return(t&&typeof t.t=="function"?t:U).t(u,n)}element(){return this.root}model(){return v({total:this.total,pageSize:this.pageSize,page:this.page,hasMore:this.hasMore})}setState(u){u.total!==void 0&&(this.total=u.total),u.counting!==void 0&&(this.counting=u.counting===!0),u.hasMore!==void 0&&(this.hasMore=u.hasMore===!0),u.page!==void 0&&(this.page=Number(u.page)||0),this.paint()}goTo(u){const n=this.page;this.page=u;const t=this.model();return this.page=t.page,this.paint(),this.page!==n&&I(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 u=this.model();return u.pageCount==null?this.page:this.goTo(u.pageCount-1)}setPageSize(u){const n=this.page*this.pageSize;this.pageSize=Math.max(1,Number(u)||1),this.page=Math.floor(n/this.pageSize),this.paint(),I(this.onChange)&&this.onChange({page:this.page,pageSize:this.pageSize})}paint(){const u=this.root;if(!u)return;for(const a of this.off)a();this.off.length=0,Z(u);const n=this.model(),t=N(this.doc,"select",{class:`${M.pagination}__size`,attrs:{"aria-label":this.t("pagination.pageSize")}});for(const a of this.pageSizes)t.appendChild(N(this.doc,"option",{text:String(a),attrs:{value:a}}));t.value=String(this.pageSize),this.off.push(W(t,"change",()=>this.setPageSize(Number(t.value)))),u.appendChild(t);const i=n.total==null?this.t(this.counting?"pagination.counting":"pagination.range",{from:n.from,to:n.to}):this.t("pagination.summary",{from:n.from,to:n.to,total:n.total});u.appendChild(N(this.doc,"span",{class:`${M.pagination}__summary`,text:i}));const s=(a,g,h,b)=>{const p=N(this.doc,"button",{class:`${M.pagination}__button`,text:a,attrs:{type:"button","aria-label":b,disabled:h?"":null}});return h||this.off.push(W(p,"click",g)),p};u.appendChild(s("«",()=>this.goTo(0),n.first,this.t("pagination.first"))),u.appendChild(s("‹",()=>this.previous(),n.first,this.t("pagination.previous")));const r=N(this.doc,"span",{class:`${M.pagination}__page`});r.appendChild(N(this.doc,"span",{text:`${this.t("pagination.page")} `}));const o=N(this.doc,"input",{class:`${M.pagination}__field`,attrs:{type:"text",inputmode:"numeric","aria-label":n.pageCount==null?this.t("pagination.jump"):this.t("pagination.jumpBounded",{pages:n.pageCount}),size:String(Math.max(2,String(n.pageCount??n.page+1).length))}});o.value=String(n.page+1);const c=()=>{const a=parseInt(String(o.value).trim(),10);if(!Number.isFinite(a)){o.value=String(this.model().page+1);return}this.goTo(a-1)};this.off.push(W(o,"keydown",a=>{a.key==="Enter"?(c(),a.preventDefault?.()):a.key==="Escape"?(o.value=String(this.model().page+1),o.blur?.()):a.stopPropagation?.()})),this.off.push(W(o,"blur",()=>c())),this.off.push(W(o,"focus",()=>o.select?.())),r.appendChild(o),n.pageCount!=null&&r.appendChild(N(this.doc,"span",{text:` ${this.t("pagination.ofPages",{pages:n.pageCount})}`})),u.appendChild(r),u.appendChild(s("›",()=>this.next(),n.last,this.t("pagination.next"))),u.appendChild(s("»",()=>this.last(),n.last||n.pageCount==null,this.t("pagination.last")))}destroy(){for(const u of this.off)u();this.off.length=0,this.root=null}}const y=k}),Ae("packages/dom/src/ui/overlay.js",function(e,G){"use strict";Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return k}}),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 u}});const q=G("packages/dom/src/editors/common.js"),M=q.CLS,$=q.documentFor,N=q.el,W=q.clear,V=G("packages/core/src/internal/util.js").isFunction,x=G("packages/core/src/i18n/index.js").defaultMessages;function I(n,t){const i=n&&n.grid&&n.grid.messages;return(i&&V(i.t)?i:x).t(t)}class v{root=null;init(t){this.doc=t.document,this.root=N(this.doc,"div",{class:`${M.overlay}__loading`,attrs:{role:"status","aria-live":"polite"},children:[N(this.doc,"span",{class:`${M.overlay}__spinner`,attrs:{"aria-hidden":"true"}}),N(this.doc,"span",{class:`${M.overlay}__message`,text:t.message||I(t,"overlay.loading")})]})}element(){return this.root}destroy(){this.root=null}}class k{root=null;init(t){this.doc=t.document,this.root=N(this.doc,"div",{class:`${M.overlay}__empty`,attrs:{role:"status"},children:[N(this.doc,"span",{class:`${M.overlay}__message`,text:t.message||I(t,"overlay.noRows")})]})}element(){return this.root}destroy(){this.root=null}}const y=Object.freeze({loading:v,empty:k});class l{root=null;slot=null;component=null;current=null;init(t){const i=t||{};this.doc=$(i),this.components={...y,...i.components||{}},this.root=N(this.doc,"div",{class:M.overlay,attrs:{"data-open":"false"}}),this.slot=N(this.doc,"div",{class:`${M.overlay}__slot`}),this.root.appendChild(this.slot),i.host&&i.host.appendChild(this.root)}element(){return this.root}show(t,i){const s=typeof t=="function"?t:this.components[t];return s?(this.hide(),this.component=new s,this.component.init({document:this.doc,message:i&&i.message,...i&&i.props||{}}),this.slot.appendChild(this.component.element()),this.current=typeof t=="string"?t:"custom",this.root.setAttribute("data-open","true"),this.root.setAttribute("data-overlay",this.current),this.component.element()):null}hide(){this.component&&V(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(t,i){this.components[t]=i}destroy(){this.hide(),this.root&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.root=null,this.slot=null}}const u=l}),Ae("packages/dom/src/ui/index.js",function(e,G){"use strict";const q=G("packages/dom/src/ui/statusbar.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return q.StatusBar}}),Object.defineProperty(e,"StatusPanel",{enumerable:!0,get:function(){return q.StatusPanel}}),Object.defineProperty(e,"RowCountPanel",{enumerable:!0,get:function(){return q.RowCountPanel}}),Object.defineProperty(e,"SelectedCountPanel",{enumerable:!0,get:function(){return q.SelectedCountPanel}}),Object.defineProperty(e,"AggregationPanel",{enumerable:!0,get:function(){return q.AggregationPanel}}),Object.defineProperty(e,"ProgressPanel",{enumerable:!0,get:function(){return q.ProgressPanel}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return q.UpdatesPanel}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return q.CommentsPanel}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return q.statusPanels}}),Object.defineProperty(e,"aggregate",{enumerable:!0,get:function(){return q.aggregate}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return q.formatCount}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return q.formatNumber}});const M=G("packages/dom/src/ui/contextmenu.js");Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return M.ContextMenu}}),Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return M.resolveMenuItems}});const $=G("packages/dom/src/ui/toolpanel.js");Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return $.ToolPanel}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return $.ToolPanelBase}}),Object.defineProperty(e,"ColumnsPanel",{enumerable:!0,get:function(){return $.ColumnsPanel}}),Object.defineProperty(e,"FiltersPanel",{enumerable:!0,get:function(){return $.FiltersPanel}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return $.toolPanels}});const N=G("packages/dom/src/ui/groupbyzone.js");Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return N.GroupByZone}});const W=G("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 Z=G("packages/dom/src/ui/pagination.js");Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return Z.Pagination}}),Object.defineProperty(e,"pageModel",{enumerable:!0,get:function(){return Z.pageModel}});const V=G("packages/dom/src/ui/overlay.js");Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return V.OverlayLayer}}),Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return V.LoadingOverlay}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return V.EmptyOverlay}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return V.overlays}})}),Ae("packages/dom/src/ui/celltooltip.js",function(e,G){"use strict";Object.defineProperty(e,"CellTooltips",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return b}});const q=G("packages/dom/src/editors/common.js"),M=q.documentFor,$=q.el,N=q.on,W=q.clear,Z=G("packages/core/src/internal/util.js"),V=Z.isFunction,U=Z.warnOnce,I=G("packages/dom/src/cell/sanitise.js").sanitiseHtml,k=G("packages/dom/src/detailhost.js").insideDetail,l=G("packages/dom/src/renderer/renderer.js").displayIndexOf,u=G("packages/dom/src/renderer/viewport.js"),n=u.CLASS,t=u.NAMESPACE,s=G("packages/dom/src/themeof.js").carryTheme,r={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"},o=400,c=140,a=6;let g=0;class h{#e;#t;#n;#r;#o=null;#i=null;#s;#l=!1;#a=null;#u=null;#c=null;#d=null;#h=null;#f=[];#m=!1;constructor(f){const w=f||{};this.#e=w.grid,this.#t=w.host,this.#n=w.viewport,this.#r=M(w),g+=1,this.#s=`lat-cell-tooltip-${g}`}mount(){const f=this.#n&&this.#n.root;if(!f||!V(f.addEventListener))return;const w=this.#e.on("cell:mouseover",d=>this.#b(d));V(w)&&this.#f.push(w);const S=this.#e.on("cell:mouseout",()=>this.#A());V(S)&&this.#f.push(S),this.#f.push(N(f,"focusin",d=>this.#v(d))),this.#f.push(N(f,"focusout",()=>this.#A())),this.#f.push(N(this.#r,"keydown",d=>this.#y(d),!0));const m=this.#r.defaultView;m&&V(m.addEventListener)&&this.#f.push(N(m,"scroll",()=>this.hide(),!0))}#p(){const f=V(this.#e.get)?this.#e.get("tooltip"):null,w=f&&typeof f=="object"?f:{},S=Number.isFinite(w.delay)&&w.delay>=0?Number(w.delay):o,m=w.maxWidth;return{delay:S,hideDelay:c,maxWidth:typeof m=="number"&&Number.isFinite(m)?`${m}px`:typeof m=="string"&&m?m:null}}#g(f){const w=f&&f.cell?f.cell.tooltip:null;return!w||typeof w!="object"||Array.isArray(w)||!V(w.render)&&!V(w.mount)?null:w}#w(f){if(!f||!V(f.closest))return null;const w=f.closest(`.${n.row}`);if(!w)return null;const S=l(w);if(S<0)return null;const m=this.#t.rowAt(S);if(!m)return null;const d=f.getAttribute("data-col");if(!d)return null;const j=this.#t.columns.get(d);return j?{row:m,key:m.key,index:S,colId:d,column:j,value:this.#t.cellValue?this.#t.cellValue(m,j):void 0,text:this.#t.cellText?this.#t.cellText(m,j):"",cell:f,grid:this.#e}:null}#b(f){const w=f&&f.target;if(!this.#g(f&&f.column)){this.#A();return}this.#S(w)}#v(f){const w=f&&f.target;if(!w||!V(w.closest)||k(w,this.#n.root))return;const S=w.closest(`.${n.cell}`);if(!S||S!==w){this.#A();return}const m=S.getAttribute("data-col"),d=m?this.#t.columns.get(m):null;if(!this.#g(d)){this.#A();return}this.#S(S)}#y(f){!f||f.key!=="Escape"||f.defaultPrevented||this.#l&&(V(f.preventDefault)&&f.preventDefault(),this.hide())}#S(f){if(this.#m||!f||(this.#D(),this.#l&&this.#a===f))return;this.#N();const{delay:w}=this.#p();if(!w){this.#C(f);return}this.#d=setTimeout(()=>{this.#d=null,this.#C(f)},w)}#A(){if(this.#N(),!this.#l||this.#h!==null)return;const{hideDelay:f}=this.#p();this.#h=setTimeout(()=>{this.#h=null,this.hide()},f)}#j(){if(this.#o)return this.#o;const f=this.#r,w=$(f,"div",{class:[t,r.tooltip],attrs:{id:this.#s,role:"tooltip","data-open":"false"}});this.#i=$(f,"div",{class:r.body}),w.appendChild(this.#i),this.#f.push(N(w,"mouseenter",()=>this.#D())),this.#f.push(N(w,"mouseleave",()=>this.#A()));const S=f.body;return S&&V(S.appendChild)&&S.appendChild(w),this.#o=w,w}#O(f,w){const S=this.#i;if(W(S),f==null||f==="")return!1;if(typeof f=="string")return S.textContent=f,!0;if(typeof f=="object"){if(typeof f.nodeType=="number")return S.appendChild(f),!0;const m=f;if(typeof m.html=="string")return S.innerHTML=I(m.html),!0;if(m.title!==void 0||m.rows!==void 0||m.note!==void 0)return this.#E(m),!0}return U(`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}#E(f){const w=this.#r,S=this.#i,m=j=>j==null?"":String(j);f.title!==void 0&&f.title!==null&&f.title!==""&&S.appendChild($(w,"div",{class:r.title,text:m(f.title)}));const d=Array.isArray(f.rows)?f.rows:[];if(d.length){const j=$(w,"div",{class:r.rows});for(const E of d){if(!E||typeof E!="object")continue;const O=$(w,"div",{class:r.row});O.appendChild($(w,"span",{class:r.label,text:m(E.label)})),O.appendChild($(w,"span",{class:r.value,text:m(E.value)})),j.appendChild(O)}S.appendChild(j)}f.note!==void 0&&f.note!==null&&f.note!==""&&S.appendChild($(w,"div",{class:r.note,text:m(f.note)}))}#C(f){if(this.#m)return;const w=this.#w(f);if(!w){this.hide();return}const S=this.#g(w.column);if(!S){this.hide();return}this.hide();const m=this.#j();s(m,this.#n&&this.#n.root);let d;if(V(S.render))try{d=S.render(w)}catch(O){U(`tooltip-render:${w.colId}`,`Column '${w.colId}' cell.tooltip render threw; no tooltip was shown.`,O);return}const j=this.#O(d,w.colId);if(V(S.mount))try{S.mount(this.#i,w),this.#u=S}catch(O){U(`tooltip-mount:${w.colId}`,`Column '${w.colId}' cell.tooltip mount threw; the tooltip was closed.`,O),this.hide();return}else if(!j)return;const{maxWidth:E}=this.#p();E&&(m.style.maxWidth=E),this.#a=f,this.#l=!0,m.setAttribute("data-open","true"),this.#T(f),this.#x(f)}#T(f){if(!V(f.setAttribute))return;const w=V(f.getAttribute)?f.getAttribute("aria-describedby"):null;this.#c={cell:f,previous:w},f.setAttribute("aria-describedby",w?`${w} ${this.#s}`:this.#s)}#x(f){const w=this.#o;if(!w||!V(f.getBoundingClientRect))return;const S=this.#r.defaultView;if(!S)return;const m=f.getBoundingClientRect(),d=V(w.getBoundingClientRect)?w.getBoundingClientRect():{width:0,height:0},j=S.innerWidth||0,E=S.innerHeight||0,O=d.width||0,T=d.height||0;let A=m.bottom+a;const P=m.top-a-T;A+T>E-a&&P>=a&&(A=P),E&&(A=Math.max(a,Math.min(A,Math.max(a,E-T-a))));let L=m.left;j&&(L=Math.min(L,Math.max(a,j-O-a))),L=Math.max(a,L),w.style.left=`${Math.round(L)}px`,w.style.top=`${Math.round(A)}px`}hide(){if(this.#N(),this.#D(),!this.#l)return;if(this.#l=!1,this.#u&&V(this.#u.unmount))try{this.#u.unmount(this.#i)}catch(w){U("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 f=this.#c;f&&V(f.cell.setAttribute)&&(f.previous?f.cell.setAttribute("aria-describedby",f.previous):V(f.cell.removeAttribute)&&f.cell.removeAttribute("aria-describedby")),this.#c=null,this.#a=null}#N(){this.#d!==null&&(clearTimeout(this.#d),this.#d=null)}#D(){this.#h!==null&&(clearTimeout(this.#h),this.#h=null)}destroy(){this.hide(),this.#m=!0;for(const f of this.#f)f();this.#f.length=0,this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}const b=h}),Ae("packages/dom/src/platform.js",function(e,G){"use strict";Object.defineProperty(e,"macLike",{enumerable:!0,get:function(){return q}});function q(){const M=globalThis.navigator,$=String(M&&(M.userAgentData?.platform||M.platform)||"");return/mac|iphone|ipad/i.test($)}}),Ae("packages/dom/src/columnmenu.js",function(e,G){"use strict";Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"aggregateMenuItem",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"headerMenuItems",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"gridAcceptsEdits",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"columnAcceptsEdits",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"rangeChartConfig",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"chartableRange",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"applyMenuLayer",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"resolveMenuChain",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return w}});const q=G("packages/core/src/internal/util.js"),M=q.isFunction,$=q.warnOnce,W=G("packages/dom/src/platform.js").macLike,V=G("packages/core/src/i18n/index.js").defaultMessages,x=G("packages/dom/src/ui/contextmenu.js").ContextMenu,I=G("packages/core/src/compute/total.js"),v=I.aggregatesFor,k=I.totalLabel,y=10,l=150;function u(S,m){const d=(te,ee)=>(S&&S.messages?S.messages:V).t(te,ee),j=S.columns.get(m);if(!j)return[];const E=S.sort.get(),O=E.find(te=>te.col===m),T=j.layout&&j.layout.pin,A=S.state.get().group||[],P=A.includes(m);if(j.generated&&Array.isArray(j.groupedIds))return s(S,j,A);const L=!j.sort||j.sort.enabled!==!1,z=!j.filter||j.filter.enabled!==!1,H=[];L&&H.push({name:d("menu.sortAscending"),icon:"↑",disabled:O&&O.dir==="asc",action:()=>S.sort.set([{col:m,dir:"asc"}])},{name:d("menu.sortDescending"),icon:"↓",disabled:O&&O.dir==="desc",action:()=>S.sort.set([{col:m,dir:"desc"}])},{name:d("menu.clearSort"),disabled:!O,action:()=>S.sort.set(E.filter(te=>te.col!==m))},{separator:!0}),z&&H.push({name:d("menu.filterEllipsis"),action:()=>S.emit("column:filter:open",{colId:m})},{separator:!0}),H.push({name:d("menu.columnStatistics"),action:()=>S.emit("column:profile:open",{colId:m})},{separator:!0}),H.push({name:d("menu.pinColumn"),children:[{name:d("menu.pinStart"),disabled:T==="start",action:()=>S.columns.pin(m,"start")},{name:d("menu.pinEnd"),disabled:T==="end",action:()=>S.columns.pin(m,"end")},{name:d("menu.unpin"),disabled:!T,action:()=>S.columns.pin(m,null)}]});const D=!(j.layout&&(j.layout.movable===!1||j.layout.lockPosition)),F=!(j.layout&&j.layout.resizable===!1),C=te=>{const ee=S.columns.get(te);return Number(ee&&ee.layout&&ee.layout.width)||l},B=S.columns.visible().filter(te=>!te.generated).map(te=>te.id),_=B.indexOf(m);if(H.push({name:d("menu.sizeToFit"),action:()=>S.columns.autoSize(m)},{name:d("menu.sizeAllToFit"),action:()=>S.columns.fit()},{name:d("menu.width"),disabled:!F,children:[{name:d("menu.narrower"),disabled:!F,action:()=>S.columns.resize(m,Math.max(1,C(m)-y))},{name:d("menu.wider"),disabled:!F,action:()=>S.columns.resize(m,C(m)+y)},{name:d("menu.autosize"),disabled:!F,action:()=>S.columns.autoSize(m)}]},{separator:!0},{name:d("menu.moveColumn"),disabled:!D,children:[{name:d("menu.moveLeft"),disabled:!D||_<=0,action:()=>S.columns.move(m,Math.max(0,_-1))},{name:d("menu.moveRight"),disabled:!D||_<0||_>=B.length-1,action:()=>S.columns.move(m,Math.min(B.length-1,_+1))},{name:d("menu.moveToStart"),disabled:!D||_<=0,action:()=>S.columns.move(m,0)},{name:d("menu.moveToEnd"),disabled:!D||_<0||_>=B.length-1,action:()=>S.columns.move(m,B.length-1)}]},{separator:!0}),j.allowGroup!==!1&&H.push({name:d(P?"menu.ungroup":"menu.groupBy"),action:()=>S.columns.group(P?A.filter(te=>te!==m):[...A,m])}),A.length&&H.push({name:d("menu.expandAll"),action:()=>S.rows.expandAll()},{name:d("menu.collapseAll"),action:()=>S.rows.collapseAll()}),M(S.columns.groupColumns)){const te=j.groupPath||[],ee=te.length?te[te.length-1]:null,oe=[{name:d("columngroup.group"),disabled:B.length<2||_<0,action:()=>{const re=B[_+1]??B[_-1];if(!re)return;const le=(S.columns.get(re)||{}).groupPath||[],ne=le.length?le[le.length-1]:null;ne?S.columns.groupColumns([m],{groupId:ne}):S.columns.groupColumns([m,re],{title:d("columngroup.newGroup")})}}];ee&&oe.push({name:d("columngroup.dissolve"),action:()=>S.columns.dissolveGroup(ee)}),H.push({separator:!0},...oe)}const Q=S.state&&M(S.state.get)?S.state.get().pivot:null,Y=Q&&Q.columns||[],J=Y.includes(m);if(j.allowPivot!==!1&&H.push({name:d(J?"menu.unpivot":"menu.pivotBy"),action:()=>S.columns.pivot(J?Y.filter(te=>te!==m):[...Y,m])}),j.allowTotal!==!1)if(M(S.get)&&S.get("aggregateChooser")===!0)H.push(n(S,j,d));else{const ee=!!j.total;H.push({name:d(ee?"menu.stopTotalling":"menu.totalColumn"),action:()=>S.columns.setTotal(m,ee?null:"sum")})}return H.push({name:d("menu.hideColumn"),disabled:j.layout&&j.layout.lockVisible===!0,action:()=>S.columns.hide(m)}),H}function n(S,m,d){const j=m.id,E=typeof m.total=="string"?m.total:null,O=[{name:d("menu.aggregateNone"),checked:!m.total,action:()=>S.columns.setTotal(j,null)},{separator:!0},...v(m).map(T=>({name:k(T),checked:E===T,action:()=>S.columns.setTotal(j,T)})),{separator:!0},t(S,m,d,"group",d("menu.aggregateGroup")),t(S,m,d,"grand",d("menu.aggregateGrand"))];return{name:d("menu.aggregate"),children:O}}function t(S,m,d,j,E){const O=m.id,T=j==="grand"?m.grandTotal:m.groupTotal,A=typeof T=="string"?T:null,P=[{name:d("menu.aggregateSame"),checked:T==null,action:()=>S.columns.setTotal(O,null,{scope:j})},{separator:!0},...v(m).map(L=>({name:k(L),checked:A===L,action:()=>S.columns.setTotal(O,L,{scope:j})}))];return{name:E,children:P}}function i(S,m){const d=(A,P)=>(S&&S.messages?S.messages:V).t(A,P),j=S.columns.get(m);if(!j)return[];const E=S.redaction,O=!!(E&&E.has(m)),T=[];return E&&(T.push({name:d(O?"menu.stopRedacting":"menu.redactColumn"),action:()=>E.toggle(m)}),(E.list().length>1||E.active&&!O)&&T.push({name:d("menu.stopRedactingAll"),action:()=>E.clear()}),T.push({separator:!0})),T.push({name:d("menu.hideColumn"),disabled:j.layout&&j.layout.lockVisible===!0,action:()=>S.columns.hide(m)}),T}function s(S,m,d){const j=(P,L)=>(S&&S.messages?S.messages:V).t(P,L),E=d[0],O=S.sort.get(),T=E?O.find(P=>P.col===E):null,A=[];E&&A.push({name:j("menu.sortGroupsAscending"),icon:"↑",disabled:T&&T.dir==="asc",action:()=>S.sort.set([{col:E,dir:"asc"}])},{name:j("menu.sortGroupsDescending"),icon:"↓",disabled:T&&T.dir==="desc",action:()=>S.sort.set([{col:E,dir:"desc"}])},{separator:!0},{name:j("menu.filterGroups"),action:()=>S.emit("column:filter:open",{colId:m.id})},{separator:!0}),A.push({name:j("menu.expandAll"),action:()=>S.rows.expandAll()},{name:j("menu.collapseAll"),action:()=>S.rows.collapseAll()},{separator:!0});for(const P of d){const L=S.columns.get(P);A.push({name:`Remove "${L&&L.title||P}" from grouping`,action:()=>S.columns.group(d.filter(z=>z!==P))})}return A.push({name:j("menu.clearGrouping"),disabled:!d.length,action:()=>S.columns.group([])}),A}function r(){const S=globalThis.navigator&&globalThis.navigator.clipboard;return!!(S&&typeof S.readText=="function")}function o(S){return M(S.get)&&S.get("edit")===!1?!1:(S.columns&&M(S.columns.visible)?S.columns.visible():[]).some(d=>{const j=d&&d.edit;return j?j.enabled===void 0||M(j.enabled)?!0:j.enabled!==!1:!1})}function c(S,m){if(M(S.get)&&S.get("edit")===!1)return!1;const d=m&&m.edit;return d?d.enabled===void 0||M(d.enabled)?!0:d.enabled!==!1:!1}const a=new Set(["number","currency","percent","integer"]);function g(S){const m=M(S.get)?S.get("rangeChart"):void 0;return m?M(m)?{enabled:!0,handler:m}:m&&typeof m=="object"&&M(m.onChart)?{enabled:!0,handler:m.onChart}:{enabled:!0,handler:null}:{enabled:!1,handler:null}}function h(S){const m=S.selection&&M(S.selection.ranges)?S.selection.ranges():[];if(!Array.isArray(m)||!m.length)return null;const d=m[m.length-1],j=M(S.columns.visible)?S.columns.visible():[],E=new Set(j.filter(O=>O&&a.has(O.type)).map(O=>O.id));return(d.columns||[]).some(O=>E.has(O))?d:null}function b(S,m){const d=(Y,J)=>(S&&S.messages?S.messages:V).t(Y,J),{colId:j,row:E}=m,O=S.selection.keys().length,T=S.selection.cells().length,A=(S.state&&M(S.state.get)?S.state.get().group:null)||[],P=S.ranges||null,L=W()?"Cmd":"Ctrl",z=()=>T||O||0,H=Y=>S.columns&&M(S.columns.get)?S.columns.get(Y):null,D=M(S.selection.cells)?S.selection.cells():[],F=[...new Set(D.map(Y=>Y&&Y.colId).filter(Boolean))];!F.length&&j&&F.push(j);const C=F.length?F.some(Y=>c(S,H(Y))):o(S),B=j?c(S,H(j)):!1,_=g(S),Q=_.enabled?h(S):null;return[{name:T>1?`Copy ${T} cells`:d("menu.copy"),shortcut:`${L}+C`,disabled:!z(),action:()=>P&&T?P.copy():S.export.clipboard({rows:O?"selected":"range"})},{name:d("menu.copyWithHeaders"),disabled:!z(),action:()=>S.export.clipboard({headers:!0,rows:O?"selected":"range"})},...j==null?[]:[{name:d("menu.paste"),shortcut:`${L}+V`,disabled:!P||!C||!r(),action:()=>P&&P.paste()},{separator:!0},{name:d("menu.clearCells",{count:T||1}),shortcut:"Delete",disabled:!P||!C||!T,action:()=>P&&P.clear()},{name:d("menu.fillDown"),shortcut:`${L}+D`,disabled:!P||!C||T<2,action:()=>P&&P.fillDown()}],...Q&&_.handler?[{name:"Chart selection",action:()=>_.handler(S,Q)}]:[],{separator:!0},{name:"Export visible rows to CSV",action:()=>S.export.csv({rows:"visible",download:!0})},{name:`Export ${O} selected row${O===1?"":"s"} to CSV`,disabled:!O,action:()=>S.export.csv({rows:"selected",download:!0})},{name:"Export visible rows to Excel",action:()=>S.export.excel({rows:"visible",download:!0})},{name:`Export ${O} selected row${O===1?"":"s"} to Excel`,disabled:!O,action:()=>S.export.excel({rows:"selected",download:!0})},{name:"Copy visible rows",action:()=>S.export.clipboard({rows:"visible",headers:!0})},{name:"Print",action:()=>S.export.print()},...S.importer&&M(S.importer.openFile)?[{name:d("menu.importCsv"),action:()=>S.importer.openFile()}]:[],{separator:!0},...A.length?[{name:d("menu.expandAll"),action:()=>S.rows.expandAll()},{name:d("menu.collapseAll"),action:()=>S.rows.collapseAll()}]:[],{name:"Clear selection",disabled:!O,action:()=>S.selection.clear()},...M(S.get)&&S.get("rowDelete")===!0?[{name:d("menu.deleteRow",{count:O||1}),disabled:!O&&!E,action:()=>S.edit.deleteRows(O?void 0:E?E.key:void 0)}]:[],...j==null?[]:[{name:"Edit cell",disabled:!E||!j||!B,action:()=>E&&j&&S.edit.start(E.key,j)}]]}function p(S,m,d,j){if(S==null)return{items:m,spoke:!1,suppress:!1};if(S===!1)return{items:m,spoke:!0,suppress:!0};if(S===!0)return{items:m,spoke:!0,suppress:!1};if(Array.isArray(S))return{items:[...m,...S],spoke:!0,suppress:!1};if(M(S)){const E=S(d,m);return{items:Array.isArray(E)?E:m,spoke:!0,suppress:!1}}return $(`menu-layer:${j}`,`${j} must be a boolean, an array of items or a (params, defaults) => items function; got ${typeof S}. Ignoring it.`),{items:m,spoke:!1,suppress:!1}}function f(S,m,d){let j=Array.isArray(S)?S:[],E=!1;for(const O of m){if(!O)continue;const T=p(O.layer,j,d,O.where);j=T.items,T.spoke&&(E=T.suppress)}return E?null:j}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=M(m.items)?m.items:null,this.#s=M(m.headerItems)?m.headerItems:null,this.#r=new x({document:m.document,host:m.host,ctx:{grid:m.grid}})}mount(){this.#t&&this.#o.push(this.#n.on("column:menu:open",m=>{const d=String(m.colId),j=this.#c(d,u(this.#n,d));j.length&&this.#r.show({items:j,ctx:this.#u(d),anchor:m.element,placement:"below",returnFocus:m.element})})),this.#t&&this.#o.push(this.#n.on("header:contextmenu",m=>{const d=String(m.colId),j=this.#c(d,i(this.#n,d));j.length&&this.#r.show({items:j,ctx:this.#u(d),x:m.x,y:m.y,returnFocus:m.element})})),this.#o.push(this.#n.on("cell:contextmenu",m=>{const d=m.event;this.#e&&d&&M(d.preventDefault)&&d.preventDefault();const j=this.#l(m),E=b(this.#n,j),O=f(E,[{layer:this.#e===!1?!1:this.#i,where:"contextMenu"},{layer:this.#a(j.column),where:`column '${j.colId}' contextMenu`}],j);!O||!O.length||(!this.#e&&d&&M(d.preventDefault)&&d.preventDefault(),this.#r.show({items:O,ctx:j,x:d?d.clientX:void 0,y:d?d.clientY:void 0}))}))}#l(m){const d=this.#n.columns,j=m.column||(m.colId!=null&&d&&M(d.get)?d.get(m.colId):void 0),E=m.row,O=this.#n.rows,T=m.key!==void 0?m.key:E?E.key:void 0;return{key:T,colId:m.colId,value:m.value!==void 0||T===void 0||m.colId==null?m.value:O&&M(O.value)?O.value(T,m.colId):void 0,row:E,data:E?E.data:void 0,column:j,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,d){return this.#s?f(d,[{layer:this.#s,where:"columnMenu"}],this.#u(m))||[]:d}destroy(){for(const m of this.#o)m();this.#o=[],this.#r.destroy()}}}),Ae("packages/dom/src/shortcutshelp.js",function(e,G){"use strict";Object.defineProperty(e,"HELP_CLASS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"ShortcutsHelp",{enumerable:!0,get:function(){return k}});const M=G("packages/core/src/internal/util.js").isFunction,N=G("packages/core/src/i18n/index.js").defaultMessages,W=G("packages/dom/src/renderer/keyboard.js"),Z=W.groupedShortcuts,V=W.SHORTCUT_IDS,x=G("packages/dom/src/platform.js").macLike,I="lat-shortcuts",v='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class k{#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,u){const n=this.#e;return(n&&n.messages?n.messages:N).t(l,u)}#s(l){const u=V[l.combo];if(!u)return l.meaning;const n=`shortcut.${u}`,t=this.#i(n);return t===n?l.meaning:t}mount(){const l=this.#t.viewport?.root;if(!l||!M(l.addEventListener))return;const u=n=>{if(this.open||n.key!=="?")return;const t=n.target,i=t&&t.tagName;i==="INPUT"||i==="TEXTAREA"||t&&t.isContentEditable||(n.preventDefault(),n.stopPropagation(),this.show())};l.addEventListener("keydown",u,!0),this.#o.push(()=>l.removeEventListener("keydown",u,!0))}show(){const l=this.#l();if(!l)return;const u=l.ownerDocument;this.#r=u&&u.activeElement,l.style.display="",M(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&&M(l.focus)&&l.focus(),this.#e.emit?.("shortcuts:closed",{})}#l(){if(this.#n)return this.#n;const l=this.#t.viewport?.overlays,u=l?.ownerDocument;if(!l||!u?.createElement)return null;const n=u.createElement("div");n.className=I,n.setAttribute("role","dialog"),n.setAttribute("aria-modal","true"),n.setAttribute("tabindex","-1");const t=`${I}-title`;n.setAttribute("aria-labelledby",t);const i=u.createElement("div");i.className=`${I}__head`;const s=u.createElement("h2");s.className=`${I}__title`,s.id=t,s.textContent=this.#i("shortcuts.title");const r=u.createElement("button");r.className=`${I}__close`,r.type="button",r.setAttribute("aria-label",this.#i("shortcuts.close")),r.textContent="×",i.appendChild(s),i.appendChild(r),n.appendChild(i);const o=u.createElement("div");o.className=`${I}__body`;for(const a of Z())a.items.length&&o.appendChild(this.#a(u,a));n.appendChild(o);const c=u.createElement("p");return c.className=`${I}__hint`,c.textContent=this.#i("shortcuts.hint"),n.appendChild(c),l.appendChild(n),this.#n=n,this.#u(n,r),n}#a(l,u){const n=l.createElement("section");n.className=`${I}__group`;const t=l.createElement("h3");t.className=`${I}__group-title`,t.textContent=this.#i(u.messageKey),n.appendChild(t);const i=l.createElement("dl");i.className=`${I}__list`;const s=x();for(const r of u.items){const o=l.createElement("dt");o.className=`${I}__keys`,r.alternatives.forEach((a,g)=>{if(g>0){const h=l.createElement("span");h.className=`${I}__or`,h.textContent=this.#i("shortcuts.or"),o.appendChild(h)}a.forEach((h,b)=>{b>0&&o.appendChild(l.createTextNode("+"));const p=l.createElement("kbd");p.textContent=s&&h==="Ctrl"?this.#i("shortcuts.key.cmd"):h,o.appendChild(p)})});const c=l.createElement("dd");c.className=`${I}__meaning`,c.textContent=this.#s(r),i.appendChild(o),i.appendChild(c)}return n.appendChild(i),n}#u(l,u){const n=i=>{if(i.stopPropagation(),i.key==="Escape"){i.preventDefault(),this.hide();return}if(i.key!=="Tab")return;const s=[...l.querySelectorAll(v)];if(!s.length){i.preventDefault();return}const r=s[0],o=s[s.length-1],c=l.ownerDocument.activeElement;i.shiftKey&&(c===r||c===l)?(i.preventDefault(),o.focus()):!i.shiftKey&&c===o&&(i.preventDefault(),r.focus())},t=i=>{i.preventDefault?.(),this.hide()};l.addEventListener("keydown",n),u.addEventListener("click",t),this.#o.push(()=>{l.removeEventListener("keydown",n),u.removeEventListener("click",t)})}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}}}),Ae("packages/dom/src/rowreorder.js",function(e,G){"use strict";Object.defineProperty(e,"HANDLE_CLASS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"MARKER_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"DRAGGING_CLASS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"resolveRowTransfer",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"resolveRowReorder",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"RowReorder",{enumerable:!0,get:function(){return l}});const M=G("packages/core/src/internal/util.js").isFunction,N=G("packages/core/src/i18n/index.js").defaultMessages,Z=G("packages/dom/src/renderer/renderer.js").displayIndexOf,V="lat-rowdrag",U="lat-rowdrag-marker",x="lat-rowdrag-lifted",I=4,v=new Set;function k(u){if(!u)return null;const n=u===!0?{}:typeof u=="object"?u:null;return n?{send:n.send!==!1,receive:n.receive!==!1,mode:n.mode==="copy"?"copy":"move",group:typeof n.group=="string"?n.group:null}:null}function y(u){return u===!0?{column:null}:!u||typeof u!="object"?null:{column:typeof u.column=="string"?u.column:null}}class l{#e;#t;#n;#r=null;#o=null;#i=null;#s=null;#l=null;#a=[];constructor(n){this.#e=n.grid,this.#t=n.renderer,this.#n=n.document,this.#r=y(n.grid.get("rowReorder")),this.#o=k(n.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(n){if(!this.#o||!this.#o.receive)return!1;const t=n&&n.transfer;return!t||!t.send?!1:t.group===this.#o.group}get transfer(){return this.#o}#u(n,t){const i=this.#e;return(i&&i.messages?i.messages:N).t(n,t)}#c(n,t){const i=this.#t&&this.#t.announce;M(i)&&i.call(this.#t,n,t)}#d(){if(!this.#r)return null;if(this.#r.column)return this.#r.column;const n=this.#e.columns.visible().filter(t=>!t.generated);return n.length?n[0].id:null}paint(){if(!this.draggable)return;const n=this.#d(),t=this.#t.viewport?.root;if(!n||!t)return;const i=t.querySelectorAll(`.lat-cell[data-col="${n}"]`);for(const s of i){if(s.querySelector(`.${V}`))continue;const r=s.parentNode;if(r&&M(r.getAttribute)&&r.getAttribute("data-pinned"))continue;const o=this.#n.createElement("span");o.className=V,o.setAttribute("data-role","row-drag"),o.setAttribute("aria-hidden","true"),o.setAttribute("title",this.#u("a11y.reorder.grab")),o.textContent="⠿",s.insertBefore(o,s.firstChild||null)}}mount(){if(!this.active)return;v.add(this);const n=this.#t.viewport?.root;if(!n||!M(n.addEventListener))return;const t=c=>this.#h(c),i=c=>this.#f(c),s=()=>this.#m(),r=c=>this.#j(c);n.addEventListener("pointerdown",t),n.addEventListener("keydown",r);const o=this.#n.defaultView||this.#n;o.addEventListener?.("pointermove",i),o.addEventListener?.("pointerup",s),this.#a.push(()=>{n.removeEventListener("pointerdown",t),n.removeEventListener("keydown",r),o.removeEventListener?.("pointermove",i),o.removeEventListener?.("pointerup",s)})}#h(n){const t=n.target;if(!t||!M(t.closest)||!t.closest('[data-role="row-drag"]'))return;const i=t.closest(".lat-row"),s=i?Z(i):-1;if(s<0)return;const r=this.#e.rows.get(s);if(!r)return;const o=this.#E();if(o&&!(this.#o&&this.#o.send)){this.#c(this.#u(o),{repeat:!0});return}n.preventDefault?.(),this.#i={key:r.key,from:s,at:s,x:n.clientX,y:n.clientY,armed:!1,hit:null,over:null,frame:null,pending:null}}#f(n){const t=this.#i;if(!t)return;if(!t.armed){if(Math.abs(n.clientX-t.x)+Math.abs(n.clientY-t.y)<I)return;t.armed=!0,this.#T(t),t.over=this,this.#e.emit("rowDrag:started",this.#p(t,this,t.from,t.key),"user")}this.#l&&this.#x(n.clientX,n.clientY);const i=this.#A(n.clientX,n.clientY);if(t.target=i,i!==this){this.#M(),i&&i.accepts(this)?(i.showDropTarget(n.clientX,n.clientY),t.hit=i.hitAt(n.clientX,n.clientY)):t.hit=null,this.#w(t,i),this.#b(t,i,t.hit?t.hit.at:null,t.hit?t.hit.overKey:null);return}const s=this.#C(n.clientX,n.clientY);if(this.#w(t,i),s<0){this.#b(t,this,null,null);return}t.at=s,this.#D(s);const r=this.#e.rows.get(s);this.#b(t,this,s,r?r.key:null)}#m(){const n=this.#i;this.#i=null,this.#M(),this.#N();for(const s of v)s.hideDropTarget();if(!n||(this.#v(n),!n.armed))return;const t=n.target;if(this.#e.emit("rowDrag:ended",this.#g(n),"user"),t&&t!==this){this.#S(n,t);return}if(n.at===n.from)return;const i=this.#E();if(i){this.#c(this.#u(i),{repeat:!0});return}this.#O(n.key,n.at)}#p(n,t,i,s){const r=this.#e.rows.byKey(n.key);return{key:n.key,data:r?r.data:null,over:t?t.grid:null,at:i,overKey:s}}#g(n){const t=n.target||null;if(t&&t!==this){if(!t.accepts(this))return{...this.#p(n,t,null,null),dropped:!1};const i=n.hit||{at:t.grid.rows.count(),overKey:null};return{...this.#p(n,t,i.at,i.overKey),dropped:!0}}if(t===this){const i=this.#e.rows.get(n.at);return{...this.#p(n,this,n.at,i?i.key:null),dropped:n.at!==n.from&&this.#E()===null}}return{...this.#p(n,null,null,null),dropped:!1}}#w(n,t){if(n.over===t)return;const i=n.over;n.over=t,i&&(this.#v(n),this.#e.emit("rowDrag:left",this.#p(n,i,null,null),"user"))}#b(n,t,i,s){n.pending={over:t,at:i,overKey:s},n.frame===null&&(n.frame=this.#y(()=>{n.frame=null;const r=n.pending;n.pending=null,!(!r||this.#i!==n)&&this.#e.emit("rowDrag:moved",this.#p(n,r.over,r.at,r.overKey),"user")}))}#v(n){n.pending=null,n.frame!==null&&(n.frame(),n.frame=null)}#y(n){const t=this.#n.defaultView||globalThis;if(M(t.requestAnimationFrame)){const s=t.requestAnimationFrame(n);return()=>{M(t.cancelAnimationFrame)&&t.cancelAnimationFrame(s)}}const i=setTimeout(n,16);return()=>clearTimeout(i)}#S(n,t){if(!t.accepts(this)){this.#c(this.#u("a11y.transfer.refused"),{repeat:!0});return}const i=this.#e.rows.byKey(n.key);if(!i)return;const s=this.#o.mode,r=n.key,o=n.hit||{at:t.grid.rows.count(),overKey:null};let c=null;const a=t.receive(i.data,o.at,{overKey:o.overKey,source:this.#e,revalidate:()=>!!this.#e.rows.byKey(r),onCancel:h=>{c=h}}),g=h=>{if(h!==!0){const b=h===!1?"a11y.transfer.refused":c==="stale"?"a11y.transfer.stale":"a11y.transfer.declined";this.#c(this.#u(b),{repeat:!0});return}s==="move"?(this.#e.rows.apply({remove:[r]}),this.#e.emit("row:sent",{key:r,data:i.data,mode:s})):this.#e.emit("row:copied",{key:r,data:i.data,mode:s}),this.#c(this.#u(s==="copy"?"a11y.transfer.copied":"a11y.transfer.moved"),{repeat:!0})};a&&M(a.then)?a.then(g):g(a)}receive(n,t,i={}){const s=this.#e,r=n&&typeof n=="object"?{...n}:n,o=i.overKey??null,c=i.source||null,a=M(i.onCancel)?i.onCancel:null,g=()=>{const w=s.rows.totalCount(),S=s.rows.apply({add:[r],at:Math.max(0,t||0)}),m=s.rows.totalCount()>w;return m&&s.emit("row:received",{data:r,at:t,overKey:o,rejected:S?.rejected||[]}),m},h=()=>{if(o!==null){const w=s.rows.get(t);if(!w||w.key!==o)return!1}return!M(i.revalidate)||i.revalidate()},b=M(s.rendererHost)?s.rendererHost():null;if(!b||!M(b.gateBefore))return g();const p=a?s.on("rowReceive:cancelled",w=>a(w.reason)):null,f=b.gateBefore("beforeRowReceive","rowReceive:cancelled",{data:r,at:t,overKey:o,source:c,origin:"user"},g,h);return p&&(f&&M(f.then)?f.then(p,p):p()),f}hitAt(n,t){const i=this.#C(n,t);if(i<0)return{at:this.#e.rows.count(),overKey:null};const s=this.#e.rows.get(i);return{at:i,overKey:s?s.key:null}}showDropTarget(n,t){const i=this.root;i&&M(i.setAttribute)&&i.setAttribute("data-drop-target","")}hideDropTarget(){const n=this.root;n&&M(n.removeAttribute)&&n.removeAttribute("data-drop-target")}#A(n,t){const i=this.#n.elementFromPoint?this.#n.elementFromPoint(n,t):null,s=i&&M(i.closest)?i.closest(".lattice"):null;if(!s)return null;for(const r of v)if(r.root===s)return r;return null}#j(n){if(!n.altKey||!n.shiftKey)return;const t=n.key==="ArrowUp"?-1:n.key==="ArrowDown"?1:0;if(!t)return;const i=this.#n.activeElement,s=i&&M(i.closest)?i.closest(".lat-row"):null,r=s?Z(s):-1;if(r<0)return;n.preventDefault?.(),n.stopPropagation?.();const o=this.#E();if(o){this.#c(this.#u(o),{repeat:!0});return}const c=this.#e.rows.get(r);c&&this.#O(c.key,r+t)}#O(n,t){const i=this.#e.rows.count(),s=Math.max(0,Math.min(i-1,t)),r=this.#e.rows.move(n,s);if(!r.moved){r.reason&&r.reason!=="unchanged"&&this.#c(this.#u(`a11y.reorder.${r.reason}`),{repeat:!0});return}this.#c(this.#u("a11y.reorder.moved",{position:r.to+1,total:i}),{repeat:!0})}#E(){const n=this.#e;if(n.sort.get().length)return"a11y.reorder.sorted";if((n.state.get().group||[]).length)return"a11y.reorder.grouped";const t=n.filters.get();return t&&Object.keys(t).length?"a11y.reorder.filtered":null}#C(n,t){const i=this.#n.elementFromPoint?this.#n.elementFromPoint(n,t):null,s=i&&M(i.closest)?i.closest(".lat-row"):null;return!s||M(s.getAttribute)&&s.getAttribute("data-pinned")?-1:Z(s)}#T(n){const t=this.root,i=t&&M(t.querySelector)?t.querySelector(`.lat-row[data-index="${n.from}"]`):null;i&&M(i.classList?.add)&&i.classList.add(x);const s=this.#n.body;if(!s||!M(s.appendChild))return;const r=this.#d(),o=r&&M(this.#e.rows?.text)&&this.#e.rows.text(n.key,r)||this.#u("a11y.reorder.grab"),c=t&&this.#n.defaultView?.getComputedStyle?this.#n.defaultView.getComputedStyle(t):null,a=(h,b)=>c&&c.getPropertyValue(h).trim()||b,g=this.#n.createElement("div");g.textContent=String(o),g.setAttribute("aria-hidden","true"),g.setAttribute("data-role","row-drag-ghost"),g.style.cssText=["position:fixed","z-index:2147483647","pointer-events:none","top:0","left:0","white-space:nowrap",`padding:${a("--lattice-space","4px")} calc(${a("--lattice-space","4px")} * 2)`,`border-radius:${a("--lattice-radius-sm",a("--lattice-radius","4px"))}`,`border:${a("--lattice-border-width","1px")} solid ${a("--lattice-border-strong","#0003")}`,`background:${a("--lattice-background","#fff")}`,`color:${a("--lattice-foreground","#000")}`,`box-shadow:${a("--lattice-shadow-overlay","0 4px 12px rgba(0,0,0,.25)")}`,`font:${a("--lattice-font-size","13px")} ${a("--lattice-font-family","system-ui, sans-serif")}`].join(";"),s.appendChild(g),this.#l=g}#x(n,t){this.#l&&(this.#l.style.transform=`translate(${Math.round(n)+14}px, ${Math.round(t)+16}px)`)}#N(){this.#l&&(this.#l.parentNode&&this.#l.parentNode.removeChild(this.#l),this.#l=null);const n=this.root,t=n&&M(n.querySelectorAll)?n.querySelectorAll(`.${x}`):[];for(const i of t)i.classList.remove(x)}#D(n){const t=this.#t.viewport?.overlays;if(!t)return;this.#s||(this.#s=this.#n.createElement("div"),this.#s.className=U,t.appendChild(this.#s));const i=this.#t.viewport.root,s=i.querySelector(`.lat-row[data-index="${n}"]`)||i.querySelectorAll(".lat-row")[0];if(!s||!M(s.getBoundingClientRect))return;const r=s.getBoundingClientRect(),o=i.getBoundingClientRect(),c=this.#i&&n>this.#i.from;this.#s.style.display="",this.#s.style.top=`${Math.round((c?r.bottom:r.top)-o.top)}px`}#M(){this.#s&&(this.#s.style.display="none")}destroy(){v.delete(this);for(const n of this.#a)n();this.#a=[],this.#i&&this.#v(this.#i),this.#i=null,this.#N(),this.#s&&this.#s.parentNode&&this.#s.parentNode.removeChild(this.#s),this.#s=null}}}),Ae("packages/dom/src/alignedgrids.js",function(e,G){"use strict";Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return Z}});const M=G("packages/core/src/internal/util.js").isFunction,$=["column:resized","column:moved","column:visible","column:pinned"];function N(V){return(V||[]).map(U=>({id:U.id,width:U.width,flex:U.flex,hidden:U.hidden,pin:U.pin===void 0?null:U.pin}))}class W{#e=new Set;#t=new Map;#n=!1;add(U){if(!U||this.#e.has(U))return;this.#e.add(U);const x=[];for(const v of $)x.push(U.on(v,()=>this.#r(U)));x.push(U.on("scroll",v=>this.#i(U,v))),x.push(U.on("destroy",()=>this.remove(U))),this.#t.set(U,x);const[I]=this.#e;I!==U&&this.#o(U,N(I.columns.state()))}remove(U){const x=this.#t.get(U);if(x)for(const I of x)I();this.#t.delete(U),this.#e.delete(U)}get size(){return this.#e.size}destroy(){for(const U of[...this.#e])this.remove(U)}#r(U){if(this.#n)return;const x=N(U.columns.state());this.#n=!0;try{for(const I of this.#e)I!==U&&this.#o(I,x)}finally{this.#n=!1}}#o(U,x){if(!U.columns||!M(U.columns.apply))return;const I=new Map((U.columns.state()||[]).map(k=>[k.id,k])),v=[];for(const k of x){const y=I.get(k.id);y&&(v.push({...y,...k}),I.delete(k.id))}for(const k of I.values())v.push(k);U.columns.apply(v)}#i(U,x){if(this.#n)return;const I=x&&typeof x.left=="number"?x.left:null;if(I!==null){this.#n=!0;try{for(const v of this.#e)v!==U&&v.scroll?.to?.({left:I})}finally{this.#n=!1}}}}function Z(V){const U=new W;for(const x of V||[])U.add(x);return U}}),Ae("packages/dom/src/columntagbar.js",function(e,G){"use strict";Object.defineProperty(e,"BAR_CLASS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"resolveTagFilter",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"ColumnTagBar",{enumerable:!0,get:function(){return V}});const M=G("packages/core/src/internal/util.js").isFunction,N=G("packages/core/src/i18n/index.js").defaultMessages,W="lat-tagbar";function Z(x){if(!x)return null;const I=x===!0?{}:typeof x=="object"?x:null;return I?{multiple:I.multiple===!0,label:typeof I.label=="string"?I.label:null}:null}class V{#e;#t;#n;#r=null;#o=null;#i=null;#s="\0";#l=[];constructor(I){this.#e=I.grid,this.#t=I.renderer,this.#n=I.document,this.#r=Z(I.grid.get("columnTagFilter"))}get active(){return this.#r!==null}#a(I,v){const k=this.#e;return(k&&k.messages?k.messages:N).t(I,v)}mount(){if(!this.active)return;const I=this.#t.viewport,v=I?.root;if(!v||!M(v.insertBefore))return;const k=this.#n.createElement("div");k.className=W,k.setAttribute("role","toolbar"),k.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 u=`${W}-select-${Math.abs(U(String(v.className)))}`;l.id=u,y.setAttribute("for",u),k.appendChild(y),k.appendChild(l),v.insertBefore(k,I.header||v.firstChild),this.#o=k,this.#i=l;const n=()=>{const i=this.#r.multiple?[...l.selectedOptions||[]].map(s=>s.value).filter(Boolean):l.value?[l.value]:[];this.#e.columns.showTagged(i),this.#u(i)};l.addEventListener("change",n),this.#l.push(()=>l.removeEventListener("change",n));const t=this.#e.on("model:changed",()=>this.refresh());this.#l.push(t),this.refresh()}#u(I){const v=this.#t&&this.#t.announce;if(!M(v))return;const k=I.length?I.join(", "):this.#a("tags.all");v.call(this.#t,this.#a("tags.showing",{tag:k}))}refresh(){if(!this.#i||!this.#o)return;const I=this.#e.columns.tags();if(this.#o.style.display=I.length?"":"none",!I.length)return;const v=I.join("\0");if(v===this.#s)return;this.#s=v;const k=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 I){const l=this.#n.createElement("option");l.value=y,l.textContent=y,k.includes(y)&&(l.selected=!0),this.#i.appendChild(l)}this.#r.multiple||(this.#i.value=k.length?k[0]:"")}destroy(){for(const I of this.#l)I();this.#l=[],this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}function U(x){let I=0;for(let v=0;v<x.length;v++)I=I*31+x.charCodeAt(v)|0;return I}}),Ae("packages/dom/src/anomalychip.js",function(e,G){"use strict";Object.defineProperty(e,"CHIP_CLASS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"resolveAnomalySummary",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"AnomalyChip",{enumerable:!0,get:function(){return x}});const M=G("packages/core/src/internal/util.js").isFunction,N=G("packages/core/src/i18n/index.js").defaultMessages,W="lat-anomaly-chip";function Z(I){if(!I)return null;const v=I===!0?{}:typeof I=="object"?I:null;return v?{column:typeof v.column=="string"?v.column:null,label:typeof v.label=="string"?v.label:null}:null}function V(I){return I?typeof I=="string"?{kind:I}:typeof I=="object"?I:null:null}function U(I,v){return I?Array.isArray(I.conditions)?I.conditions.some(k=>U(k,v)):I.col===v&&I.op==="eq"&&I.value===!0:!1}class x{#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=Z(v.grid.get("anomalySummary"))}get active(){return this.#r!==null}#h(v,k){const y=this.#e;return(y&&y.messages?y.messages:N).t(v,k)}#f(){const v=this.#r&&this.#r.column;let k=null;for(const y of this.#e.columns.all()){const l=V(y.shadow);if(!l||l.kind!=="anomalyFlag")continue;const u=l.of||y.field||y.id;if(v){if(y.id===v||u===v)return this.#d=y.id,y}else k||(k=y,this.#d=y.id)}return v?null:k}#m(){if(!this.#d||!M(this.#e.rows&&this.#e.rows.forEach))return 0;let v=0;try{this.#e.rows.forEach(k=>{!k||k.group||k.key==null||this.#e.rows.value(k.key,this.#d)===!0&&v++})}catch{return 0}return v}mount(){if(!this.active)return;const v=this.#t.viewport,k=v&&v.root;if(!k||!M(k.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),k.insertBefore(y,v.header||k.firstChild),this.#o=y,this.#i=l;const u=()=>this.toggle();l.addEventListener("click",u),this.#s.push(()=>l.removeEventListener("click",u));for(const n of["filter:changed","rows:changed","model:changed"])this.#s.push(this.#e.on(n,()=>{this.#a||this.refresh()}));this.refresh()}toggle(){this.#l?this.#g():this.#p()}#p(){if(!this.#d)return;this.#u=this.#e.filters.get();const v={col:this.#d,op:"eq",value:!0},k=this.#u?{op:"and",conditions:[this.#u,v]}:v;this.#l=!0,this.#a=!0;try{this.#e.filters.set(k)}finally{this.#a=!1}this.refresh()}#g(){this.#l=!1,this.#a=!0;try{this.#e.filters.set(this.#u||null)}finally{this.#a=!1}this.#u=null,this.refresh()}refresh(){if(!this.#o||!this.#i)return;if(!this.#f()){this.#o.style.display="none";return}if(this.#l&&!U(this.#e.filters.get(),this.#d)&&(this.#l=!1,this.#u=null),this.#l){this.#w(this.#c,!0);return}const k=this.#m();if(this.#c=k,!k){this.#o.style.display="none";return}this.#w(k,!1)}#w(v,k){if(!this.#o||!this.#i)return;this.#o.style.display="",this.#o.setAttribute("data-active",k?"true":"false"),this.#i.setAttribute("aria-pressed",k?"true":"false");const y=this.#r&&this.#r.label,l=k?this.#h("anomaly.chipActive",{count:v}):y||this.#h("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}}}),Ae("packages/dom/src/rowform.js",function(e,G){"use strict";Object.defineProperty(e,"FORM_CLASS",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"resolveRowForm",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"RowForm",{enumerable:!0,get:function(){return i}});const q=G("packages/core/src/internal/util.js"),M=q.isFunction,$=q.warnOnce,W=G("packages/core/src/i18n/index.js").defaultMessages,V=G("packages/dom/src/editors/index.js").createEditor,x=G("packages/dom/src/renderer/renderer.js").displayIndexOf,v=G("packages/dom/src/themeof.js").themeOf,k="lat-rowform",y='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';function l(s){if(!s)return null;const r=s===!0?{}:typeof s=="object"?s:null;if(!r)return null;const o=M(r.load)?r.load:null,c=Array.isArray(r.fields)&&r.fields.length?r.fields:null;return{timeout:t(r.timeout),container:r.container??null,mode:r.container?"inline":r.mode==="dialog"?"dialog":"drawer",load:o,fields:c,title:r.title??null,width:typeof r.width=="string"?r.width:null,trigger:r.trigger===!1?"none":"dblclick"}}function u(s,r){const o=M(s)?s():s;return o?typeof o=="string"?r&&M(r.querySelector)?r.querySelector(o):null:o&&M(o.appendChild)?o:null:null}const n=2e3;function t(s){return s===!1||s===0?0:typeof s!="number"||!Number.isFinite(s)||s<=0?n:s}class i{#e;#t;#n;#r;#o=null;#i=null;#s=null;#l=null;#a=null;#u=[];#c=null;#d=0;#h=null;#f=!1;#m=[];constructor(r){this.#e=r.grid,this.#t=r.renderer,this.#n=r.document,this.#r=r.registry||null,this.#o=l(r.grid.get("rowForm"))}get active(){return this.#o!==null}get open(){return!!this.#i&&this.#i.style.display!=="none"}#p(r,o){const c=this.#e;return(c&&c.messages?c.messages:W).t(r,o)}mount(){if(!this.active)return;const r=this.#t.viewport?.root;if(!r||!M(r.addEventListener)||this.#o.trigger==="none")return;const o=c=>{const a=c.target;if(!a||!M(a.closest)||a.closest(".lat-editor-host, .lat-editor--popup"))return;const g=a.closest(".lat-row"),h=g?x(g):-1;if(h<0)return;const b=this.#e.rows.get(h);!b||b.group||b.detail||(c.preventDefault?.(),c.stopPropagation?.(),this.openRow(b.key))};r.addEventListener("dblclick",o,!0),this.#m.push(()=>r.removeEventListener("dblclick",o,!0))}openRow(r){const o=this.#e.rows.byKey(r);if(!o)return!1;const c=this.#g();if(!c)return!1;this.#a=o,this.#c=this.#n.activeElement,c.style.display="",this.#C(c),this.#b(o);const a=this.#o.load;if(!a)this.#E(o.data);else{this.#A();const g=++this.#d;this.#v(g,r),Promise.resolve().then(()=>a({row:o,data:o.data,key:r,grid:this.#e})).then(h=>{g!==this.#d||!this.open||(this.#S(),this.#E(h||o.data))}).catch(h=>{g!==this.#d||!this.open||(this.#S(),this.#j(h,r))})}return M(c.focus)&&c.focus(),this.#e.emit("form:opened",{key:r,row:o}),!0}close(){if(!this.#i)return;this.#d+=1,this.#S(),this.#R(),this.#i.style.display="none";const r=this.#a?this.#a.key:null;this.#a=null;const o=this.#c;this.#c=null,o&&M(o.focus)&&o.focus(),this.#e.emit("form:closed",{key:r})}save(){if(!this.#a||!this.#u.length)return!1;const r=this.#a.key,o={},c={},a=[],g=[];for(const h of this.#u){const b=M(h.editor.commit)?h.editor.commit():{ok:!0,value:void 0};if(!b.ok)return this.#N(h,b.message),!1;o[h.field]=b.value;const p=h.initial;Object.is(p,b.value)||(c[h.field]=b.value,h.colId?a.push({key:r,colId:h.colId,value:b.value}):g.push(h.field))}return a.length&&this.#e.edit.setCells(a),this.#e.emit("form:saved",{key:r,values:o,changed:c,unmapped:g}),this.close(),!0}#g(){if(this.#i)return this.#i;const r=this.#t.viewport?.overlays,o=this.#n||r?.ownerDocument;if(!o?.createElement)return null;const c=u(this.#o.container,o),a=c||r;if(!a)return null;this.#o.container&&!c&&$("rowform:container","rowForm.container could not be resolved; the form opens over the grid instead."),this.#f=!!c;const g=o.createElement("div"),h=this.#f?"lattice ":"";g.className=`${h}${k} ${k}--${this.#f?"inline":this.#o.mode}`,g.setAttribute("role",this.#f?"region":"dialog"),this.#f||g.setAttribute("aria-modal","true"),g.setAttribute("tabindex","-1"),this.#o.width&&g.style.setProperty("--lattice-rowform-width",this.#o.width);const b=`${k}-title`;g.setAttribute("aria-labelledby",b);const p=o.createElement("div");p.className=`${k}__head`;const f=o.createElement("h2");f.className=`${k}__title`,f.id=b,p.appendChild(f);const w=o.createElement("div");w.className=`${k}__body`;const S=o.createElement("div");S.className=`${k}__foot`;const m=o.createElement("button");m.className=`${k}__cancel`,m.type="button",m.textContent=this.#p("form.cancel");const d=o.createElement("button");return d.className=`${k}__save`,d.type="button",d.textContent=this.#p("form.save"),S.appendChild(m),S.appendChild(d),g.appendChild(p),g.appendChild(w),g.appendChild(S),a.appendChild(g),this.#i=g,this.#s=w,this.#l=d,this.#w(g,d,m),g}#w(r,o,c){const a=b=>{if(b.stopPropagation(),b.key==="Escape"){b.preventDefault(),this.close();return}if(b.key!=="Tab"||this.#f)return;const p=[...r.querySelectorAll(y)];if(!p.length){b.preventDefault();return}const f=p[0],w=p[p.length-1],S=r.ownerDocument.activeElement;b.shiftKey&&(S===f||S===r)?(b.preventDefault(),w.focus()):!b.shiftKey&&S===w&&(b.preventDefault(),f.focus())},g=b=>{b.preventDefault?.(),this.save()},h=b=>{b.preventDefault?.(),this.close()};r.addEventListener("keydown",a),o.addEventListener("click",g),c.addEventListener("click",h),this.#m.push(()=>{r.removeEventListener("keydown",a),o.removeEventListener("click",g),c.removeEventListener("click",h)})}#b(r){const o=this.#i.querySelector(`.${k}__title`);if(!o)return;const c=this.#o.title;M(c)?o.textContent=String(c({row:r,data:r.data})??""):typeof c=="string"?o.textContent=c:o.textContent=this.#p("form.title")}#v(r,o){this.#S();const c=this.#o.timeout;if(!c)return;const a=this.#n.defaultView||globalThis;M(a.setTimeout)&&(this.#h=a.setTimeout(()=>{this.#h=null,!(r!==this.#d||!this.open)&&(this.#d+=1,this.#j(new Error(`Loading the record timed out after ${c}ms`),o,"form.loadTimeout"))},c))}#y(r){this.#l&&(this.#l.disabled=!r,r?this.#l.removeAttribute("aria-disabled"):this.#l.setAttribute("aria-disabled","true"))}#S(){if(this.#h===null)return;const r=this.#n.defaultView||globalThis;M(r.clearTimeout)&&r.clearTimeout(this.#h),this.#h=null}#A(){this.#R(),this.#y(!1),this.#s.replaceChildren&&this.#s.replaceChildren();const r=this.#n.createElement("p");r.className=`${k}__note`,r.setAttribute("role","status"),r.textContent=this.#p("form.loading"),this.#s.appendChild(r)}#j(r,o,c="form.loadFailed"){this.#R(),this.#y(!1),this.#s.replaceChildren&&this.#s.replaceChildren();const a=this.#n.createElement("p");a.className=`${k}__note ${k}__note--error`,a.setAttribute("role","alert"),a.textContent=this.#p(c);const g=this.#n.createElement("button");g.className=`${k}__retry`,g.type="button",g.textContent=this.#p("form.retry"),g.addEventListener("click",()=>this.openRow(o)),this.#s.appendChild(a),this.#s.appendChild(g),this.#e.emit("form:error",{key:o,error:r,timedOut:c==="form.loadTimeout"})}#O(){return this.#o.fields?this.#o.fields.map(r=>typeof r=="string"?{field:r}:r):this.#e.columns.all().filter(r=>!r.generated&&r.field).map(r=>({field:r.field,label:r.title,colId:r.id}))}#E(r){this.#R(),this.#y(!0),this.#s.replaceChildren&&this.#s.replaceChildren();const o=r&&typeof r=="object"?r:{};for(const c of this.#O()){const a=c.field;if(!a)continue;const g=c.colId?this.#e.columns.get(c.colId):this.#W(a),h=this.#I(c,g,a),b=Object.hasOwn(o,a)?o[a]:null,p=this.#n.createElement("div");p.className=`${k}__field`;const f=this.#n.createElement("label");f.className=`${k}__label`,f.textContent=String(c.label??(g&&g.title)??a);const w=this.#n.createElement("div");w.className=`${k}__control`,p.appendChild(f),p.appendChild(w),this.#s.appendChild(p);const S={field:a,colId:g?g.id:null,editor:null,initial:b,opener:null,wrap:p},m=V({grid:this.#e,column:h,colId:g?g.id:a,row:this.#a,data:o,value:b,text:b==null?"":String(b),locale:this.#e.get("locale"),props:c.props||g&&g.edit&&g.edit.props,lookup:c.lookup||g&&g.lookup,document:this.#n,cell:w,overlay:this.#T(),stop:()=>this.#D(S)},this.#r);if(m){S.editor=m;try{M(m.value)&&(S.initial=m.value())}catch{}if(this.#u.push(S),m.popup===!0)this.#x(w,S);else{const d=M(m.element)?m.element():null;d&&w.appendChild(d)}}}}#C(r){if(!this.#f)return;const o=this.#t.viewport?.root;if(!(!o||!M(o.getAttribute)))for(const c of["data-theme","data-density","dir"]){const a=c==="data-theme"?v(o):o.getAttribute(c);a?r.setAttribute(c,a):M(r.removeAttribute)&&r.removeAttribute(c)}}#T(){return this.#f?this.#n.body||this.#t.viewport.overlays:this.#t.viewport.overlays}#x(r,o){const c=this.#n.createElement("button");c.className=`${k}__opener`,c.type="button",o.opener=c,this.#M(o);const a=()=>{M(o.editor.attached)&&o.editor.attached()};c.addEventListener("click",a),this.#m.push(()=>c.removeEventListener("click",a)),r.appendChild(c)}#N(r,o){const c=r.wrap;c&&M(c.scrollIntoView)&&c.scrollIntoView({block:"nearest"});const a=r.opener||(M(r.editor.focusTarget)?r.editor.focusTarget():null);a&&M(a.focus)&&a.focus();const g=this.#t&&this.#t.announce;M(g)&&o&&g.call(this.#t,String(o))}#D(r){if(!r.opener||!r.editor)return;const o=M(r.editor.popupHandle)?r.editor.popupHandle():null;o&&M(o.hide)&&o.hide(),this.#M(r),M(r.opener.focus)&&r.opener.focus()}#M(r){if(!r.opener)return;let o="";try{const a=r.colId?this.#e.columns.get(r.colId):null,g=a&&a.dataType&&a.dataType.format;M(g)&&(o=g({value:M(r.editor.value)?r.editor.value():null,column:a,row:this.#a,data:this.#a?this.#a.data:null,locale:this.#e.get("locale")})),(o===""||o==null)&&M(r.editor.toClipboard)&&(o=r.editor.toClipboard())}catch{o=""}const c=o===""||o==null;r.opener.textContent=c?this.#p("form.choose"):String(o),r.opener.classList.toggle(`${k}__opener--empty`,c)}#I(r,o,c){const a=r.editor||r.type||r.lookup||r.props;if(o&&!a)return o;const g={...o&&o.edit?o.edit:{}};return r.editor&&(g.editor=r.editor),r.props&&(g.props=r.props),{...o||{id:c,field:c},type:r.type||o&&o.type||"text",lookup:r.lookup||o&&o.lookup||void 0,edit:g}}#W(r){for(const o of this.#e.columns.all())if(!o.generated&&o.field===r)return o;return null}#R(){for(const r of this.#u)M(r.editor.destroy)&&r.editor.destroy();this.#u=[]}destroy(){this.#d+=1,this.#S(),this.#R();for(const r of this.#m)r();this.#m=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null,this.#a=null}}}),Ae("packages/dom/src/toolpanelmount.js",function(e,G){"use strict";Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return p}});const q=G("packages/core/src/internal/util.js"),M=q.isFunction,$=q.warnOnce,N=G("packages/dom/src/ui/toolpanel.js"),W=N.ToolPanel,Z=N.toolPanels,V=N.toolPanelTitles,U=N.toolPanelIcons,I=G("packages/dom/src/filters/index.js").createFilter,v=G("packages/dom/src/editors/common.js"),k=v.CLS,y=v.documentFor,l=v.scannableRows,u=G("packages/dom/src/filtermenu.js"),n=u.mergeColumnFilter,t=u.branchFor,i=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 s(f){const{grid:w,container:S}=f||{};if(!w)throw new Error("[lattice] mountPanel needs a grid");if(!S||!S.appendChild)throw new Error("[lattice] mountPanel needs a container element");const m=M(f.panel)?f.panel:Z[String(f.panel)];if(!m)throw new Error(`[lattice] unknown panel "${f.panel}"; known panels are ${Object.keys(Z).join(", ")}`);const d=S.ownerDocument||y(S),j=b(w,d,f.announce),E=new m;E.init({document:d,host:j,grid:w,props:f.props||{}});const O=E.element();S.appendChild(O);const T=[];for(const A of i)M(w.on)&&T.push(w.on(A,()=>E.refresh()));return{element:O,refresh(){E.refresh()},destroy(){for(const A of T)A();T.length=0,M(E.destroy)&&E.destroy(),O&&O.parentNode&&O.parentNode.removeChild(O)}}}const r=260,o=30,c=`${k.panel}-dock`;function a(f,w,S){if(!f||!M(f.set))return;const m=t(S.filters.get(),w)||null,d=M(f.get)&&(!M(f.active)||f.active())&&f.get()||null;JSON.stringify(d)!==JSON.stringify(m)&&(m?f.set(m):M(f.clear)?f.clear():f.set(null))}function g(f,w){if(f==="insights"){const d=w&&M(w.get)?w.get("insights"):null;return{other:(d&&typeof d=="object"?d:{}).compareWith||null}}if(f!=="views")return{};const S=w&&M(w.get)?w.get("views"):null,m=S&&typeof S=="object"?S:{};return{allowSave:m.allowSave!==!1,showDiff:m.showDiff===!0,builtinTitle:m.builtinTitle,savedTitle:m.savedTitle}}function h(f){const w=f.pagination&&M(f.pagination.get)?f.pagination.get():null;return w&&Number.isFinite(w.total)?w.total:f.rows.count()}function b(f,w,S){const m=new Map;return{announce(d,j){M(S)&&S(d,j)},t(d,j){return f.messages.t(d,j)},grid:f,document:w,columns:()=>f.columns.all(),showColumns:d=>f.columns.show(d),hideColumns:d=>f.columns.hide(d),groupBy:()=>f.state.get().group||[],setGroupBy:d=>f.columns.group(d),pivotBy:()=>(f.state.get().pivot||{}).columns||[],setPivotBy:d=>f.columns.pivot(d),valueColumns:()=>f.columns.all().filter(d=>d.total).map(d=>d.id),setValueColumns:d=>f.columns.totals(d),valueAggregation(d){const j=f.columns.get(d);return!j||!j.total?"sum":typeof j.total=="string"?j.total:"custom"},setValueAggregation(d,j){f.columns.setTotal(d,j)},quickFilter:()=>f.state.get().quick||"",setQuickFilter:d=>f.filters.quick(d),rowCount:()=>h(f),totalRowCount:()=>M(f.rows.totalCount)?f.rows.totalCount():f.rows.count(),formattableColumns:()=>f.columns.visible().filter(d=>!d.generated).map(d=>({id:d.id,title:String(d.title??d.id)})),formattingRules:d=>f.formatting.list(d),columnSamples:d=>{let j=d;if(!j||j==="*"){const T=f.columns.visible().find(A=>!A.generated);j=T?T.id:null}if(!j)return[];const E=[],O=new Set;for(const T of l(f)){const A=f.rows.value(T.key,j);if(A==null||A==="")continue;const P=typeof A=="object"?E.length:A;if(!O.has(P)&&(O.add(P),E.push(A),E.length>=24))break}return E},profilableColumns:()=>f.columns.visible().filter(d=>!d.generated).map(d=>({id:d.id,title:String(d.title??d.id)})),columnProfile:d=>f.statistics.profile(d),reduceColumn:(d,j)=>f.statistics.reduce(d,j),columnCapability:d=>f.statistics.capability(d),regressionModel:d=>M(f.statistics.regressionModel)?f.statistics.regressionModel(d):null,insightsColumns:()=>f.columns.visible().filter(d=>!d.generated).map(d=>({id:d.id,title:String(d.title??d.id),type:d.type})),subsetVsPopulation:()=>f.statistics.subsetVsPopulation(),datasetVsDataset:d=>f.statistics.datasetVsDataset(d),compareGroups:(d,j)=>f.statistics.compareGroups(d,j),anomalies:d=>f.statistics.anomalies(d||{}),compareColumns:(d,j)=>{if(!d||!j||d===j)return null;const E=f.statistics.regression(d,j);return{n:E?E.n:0,pearson:f.statistics.correlation(d,j),spearman:f.statistics.spearman(d,j),kendall:f.statistics.kendall(d,j),covariance:f.statistics.covariance(d,j),slope:E?E.slope:null,intercept:E?E.intercept:null,r2:E?E.r2:null,stdError:E?E.stdError:null,weighted:f.statistics.weightedAverage(d,j)}},addRule:(d,j)=>f.formatting.add(d,j),removeRule:(d,j)=>f.formatting.remove(d,j),updateRule:(d,j,E)=>f.formatting.update(d,j,E),moveRule:(d,j,E)=>f.formatting.move(d,j,E),clearRules:d=>f.formatting.clear(d),views:()=>f.views.list(),activeId:()=>f.views.activeId,apply:d=>{f.views.apply(d)},saveAs:d=>f.views.save(d),rename:(d,j)=>f.views.rename(d,j),setDefault:d=>f.views.setDefault(d),clearDefault:()=>f.views.setDefault(null),remove:d=>f.views.remove(d),export:d=>f.views.export(d),diff:d=>f.views.diff(d),moveColumn(d,j,E){const O=f.columns.all().map(L=>L.id),T=O.indexOf(d),A=O.indexOf(j);if(T<0||A<0)return;let P=E?A:A+1;T<P&&(P-=1),P!==T&&f.columns.move(d,P)},isFiltered(d){return t(f.filters.get(),d)!==null},clearFilter(d){f.filters.set(n(f.filters.get(),d,null));const j=m.get(d);j&&M(j.clear)?j.clear():j&&M(j.set)&&j.set(null)},clearAllFilters(){f.filters.set(null);for(const d of m.values())M(d.clear)?d.clear():M(d.set)&&d.set(null)},filterFor(d){if(m.has(d))return a(m.get(d),d,f),m.get(d);const j=f.columns.get(d);if(!j)return null;const E=I({grid:f,column:j,colId:d,type:j.type,locale:f.get("locale"),props:{...j.filter&&j.filter.props,values:j.filter&&j.filter.props&&j.filter.props.values||(j.lookup?void 0:()=>f.columns.distinct(d))},lookup:j.lookup,document:w,value:O=>f.rows.value(O.row&&O.row.key,d),rows:j.lookup?void 0:()=>l(f),changed:()=>{const T=(M(E.active)?E.active():!0)&&M(E.get)?E.get():null;f.filters.set(n(f.filters.get(),d,T||null))}});return E&&(a(E,d,f),m.set(d,E)),E},destroyFilters(){for(const d of m.values())M(d.destroy)&&d.destroy();m.clear()}}}class p{#e;#t;#n;#r;#o;#i=null;#s=[];#l="right";#a=null;#u=!1;#c=!1;constructor(w){this.#e=w.grid,this.#t=w.document,this.#n=w.root,this.#o=b(w.grid,w.document,w.announce);const m=(w.panels||["columns","filters"]).map(d=>Z[d]?{name:d,title:V[d]?w.grid.messages.t(V[d]):d,icon:U[d]||d,Ctor:Z[d],props:g(d,w.grid)}:($(`toolpanel:${d}`,`unknown tool panel "${d}"`),null)).filter(Boolean);this.#l=w.side==="left"?"left":"right",this.#r=new W,this.#r.init({document:w.document,host:this.#o,grid:w.grid,panels:m,actions:w.actions,icons:w.icons,side:this.#l,openPanel:w.openPanel})}mount(){const w=this.#t.createElement("div");w.className=`${c} ${c}--${this.#l}`,w.appendChild(this.#r.element()),this.#n.appendChild(w),this.#i=w;const S=this.#r.show.bind(this.#r),m=this.#r.hide.bind(this.#r);this.#r.show=d=>{const j=S(d);return this.#f(),j},this.#r.hide=()=>{m(),this.#f()};for(const d of[...i,"rows:paused","rows:resumed","rows:queued","annotation:changed"])this.#s.push(this.#e.on(d,()=>this.#r.refresh()));this.#s.push(this.#e.on("presentation:started",d=>{this.#u=!0;const j=d&&d.options&&Array.isArray(d.options.chrome)?d.options.chrome:[];this.#c=j.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",d=>{const j=d&&d.colId,E=this.#r.panels.find(O=>O.name==="statistics");E&&j!=null&&(E.panel.column=String(j)),this.open("statistics")})),this.#f()}open(w){this.#r.show(w),this.#f()}close(){this.#r.hide(),this.#f()}toggle(w){this.#r.toggle(w),this.#f()}addAction(w){if(!(!w||!w.name)&&!this.#r.actions.some(S=>S.name===w.name)){if(this.#r.registerAction(w),this.#a&&!w.annotation){const S=this.#r.actions.find(m=>m.name===w.name);S&&this.#h(S.button)}else!this.#a&&w.annotation&&this.#u&&!this.#c&&this.#d();this.#f()}}removeAction(w){this.#r.removeAction(w)&&this.#f()}presentOnly(){return this.#a?!0:this.#r.actions.some(w=>w.annotation&&w.button)?(this.#d(),!0):!1}#d(){const w=this.#r;this.#a={hidden:[],reopen:w.openPanel||null},this.#a.reopen&&w.hide(),this.#h(w.body);for(const S of[...w.tabs?.children||[]])S!==w.actionGroup&&this.#h(S);for(const S of[...w.actionGroup?.children||[]]){const m=w.actions.find(d=>d.button===S);(!m||!m.annotation)&&this.#h(S)}this.#i&&this.#i.style&&(this.#i.style.display=""),this.#f()}presentRestore(){const w=this.#a;if(!w)return!1;this.#a=null;for(const S of w.hidden)S.el&&S.el.style&&(S.el.style.display=S.display);return w.reopen&&this.#r.show(w.reopen),this.#f(),!0}#h(w){if(!w||!w.style||!this.#a)return;const S=w.style.display||"";S!=="none"&&(w.style.display="none",this.#a.hidden.push({el:w,display:S}))}#f(){if(!this.#i)return;const w=!!this.#r.openPanel;this.#i.setAttribute("data-open",w?"true":"false"),this.#i.style.width=w?`${r}px`:"";const S=`${w?r:this.#m()}px`;this.#n.style.paddingLeft=this.#l==="left"?S:"",this.#n.style.paddingRight=this.#l==="left"?"":S,this.#n.style.setProperty("--lattice-dock-left",this.#l==="left"?S:"0px"),this.#n.style.setProperty("--lattice-dock-right",this.#l==="left"?"0px":S)}#m(){const w=this.#r&&M(this.#r.element)?this.#r.element().querySelector?.(`.${k.panel}__tabs`):null,S=w&&(w.offsetWidth||w.getBoundingClientRect?.().width)||0;return S>0?Math.ceil(S):o}destroy(){for(const w of this.#s)w();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=""}}}),Ae("packages/dom/src/celledit.js",function(e,G){"use strict";Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return k}});const q=G("packages/core/src/internal/util.js"),M=q.isFunction,$=q.warnOnce,W=G("packages/dom/src/editors/index.js").createEditor,Z=G("packages/dom/src/editors/common.js"),V=Z.CLS,U=Z.markInvalid,I=G("packages/dom/src/detailhost.js").insideDetail,v=`${V.editor}-host`;class k{#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",a=>this.open(a))),this.#u.push(this.#e.on("cell:edit:end",()=>this.close()));const t=this.#n.viewport.root,i=this.#e.get("edit"),s=i&&typeof i=="object"&&i.start||"double",r=a=>{if(I(a.target,t))return;const g=y(a.target,w=>w.getAttribute&&w.getAttribute("data-col"));if(!g)return;const h=y(g,w=>w.getAttribute&&w.getAttribute("data-key"));if(!h)return;const b=this.#e.rows.byKey(h.getAttribute("data-key"));if(!b||b.group)return;const p=g.getAttribute("data-col"),f=this.#e.columns.get(p);!f||!f.edit||!f.edit.enabled||this.#e.edit.start(b.key,p)},o=s==="key"?null:s==="single"?"click":"dblclick";o&&(t.addEventListener(o,r),this.#u.push(()=>t.removeEventListener(o,r)));const c=a=>{!this.#i||!this.#l||this.#m(a.target)||this.commit()};this.#t.addEventListener("mousedown",c,!0),this.#u.push(()=>this.#t.removeEventListener("mousedown",c,!0))}get target(){return this.#l}open(t){this.close();const i=t.key||t.row&&t.row.key,s=t.colId;if(!i||!s)return;const r=this.#e.columns.get(s),o=this.#e.rows.byKey(i);if(!r||!o)return;const c=this.#b(i,s);if(this.#c=c,!c){$("celledit.offscreen","cannot edit a row that is not rendered; scroll to it first.");return}const a=this.#e.permissions,g=!!(a&&M(a.isSecret)&&a.isSecret(s)),h=W({grid:this.#e,column:r,colId:s,row:o,data:o.data,value:g?null:this.#e.rows.value(i,s),text:g?"":this.#e.rows.text(i,s),locale:this.#e.get("locale"),props:r.edit&&r.edit.props,lookup:r.lookup,document:this.#t,cell:c,overlay:this.#n.viewport.overlays,onCommit:f=>this.#f({value:f,key:i,colId:s}),onCancel:()=>{this.#d=!0,this.#e.edit.stop(!0)},stop:f=>{this.#d||this.#e.edit.stop(f)}},this.#r);if(!h){$(`celledit.noeditor:${s}`,`column "${s}" has no editor.`);return}this.#i=h,this.#s=c,this.#l={key:i,colId:s},this.#d=!1,this.#a=this.#w(c);const b=h.element();h.popup?(this.#n.viewport.overlays.appendChild(b),l(b,c,this.#n.viewport.root)):c.replaceChildren(b),c.classList.add(v),M(h.attached)&&h.attached(),u(b);const p=f=>this.#h(f);b.addEventListener("keydown",p),this.#u.push(()=>b.removeEventListener("keydown",p))}#h(t){const i=t.key;if(i!=="Enter"&&i!=="Tab"&&i!=="Escape")return;if(t.preventDefault(),t.stopPropagation(),i==="Escape"){this.#e.edit.stop(!0);return}const s=i==="Enter"?this.#p(t.shiftKey?-1:1):this.#g(t.shiftKey?-1:1);this.commit()&&s&&this.#e.edit.start(s.key,s.colId)}#f(t){this.#d||(this.#d=!0,this.#e.edit.stop(!1,t))}commit(){if(!this.#i||!this.#l)return!1;if(this.#d)return!0;if(M(this.#i.cancelOnClose)&&this.#i.cancelOnClose()===!0)return this.#d=!0,this.#e.edit.stop(!0),!0;const{key:t,colId:i}=this.#l;if(M(this.#i.value)){const s=this.#i.value();if(M(this.#i.validate)){const r=this.#i.validate(s);if(r!==!0){if(U(this.#c,r),M(this.#i.focusTarget)){const o=this.#i.focusTarget();o&&M(o.focus)&&o.focus()}return!1}U(this.#c,null)}this.#f({value:s,key:t,colId:i})}else this.#d=!0,this.#e.edit.stop(!1);return!0}#m(t){if(!t)return!1;const i=M(this.#i.element)?this.#i.element():null;if(i&&M(i.contains)&&i.contains(t))return!0;const s=this.#c;return!!(s&&M(s.contains)&&s.contains(t))}#p(t){if(!this.#l||this.#a<0)return null;for(let i=this.#a+t;i>=0&&i<this.#e.rows.count();i+=t){const s=this.#e.rows.get(i);if(s&&!s.group)return{key:s.key,colId:this.#l.colId}}return null}#g(t){if(!this.#l)return null;const i=this.#e.columns.visible(),s=i.findIndex(r=>r.id===this.#l.colId);for(let r=s+t;r>=0&&r<i.length;r+=t){const o=i[r];if(o.edit&&o.edit.enabled)return{key:this.#l.key,colId:o.id}}return null}#w(t){const i=y(t,r=>r.getAttribute&&r.getAttribute("data-index"));if(!i)return-1;const s=Number(i.getAttribute("data-index"));return Number.isFinite(s)?s:-1}#b(t,i){const s=this.#n.viewport.root;if(!s||!s.querySelectorAll)return null;for(const r of s.querySelectorAll(`[data-col="${i}"]`)){const o=y(r,c=>c.getAttribute&&c.getAttribute("data-key"));if(o&&o.getAttribute("data-key")===t)return r}return null}close(){this.#c&&U(this.#c,null);const t=this.#v();if(this.#i&&M(this.#i.destroy)&&this.#i.destroy(),this.#s){if(this.#s.classList.remove(v),this.#o&&M(this.#o.releaseCell)){const i=this.#l?this.#e.columns.get(this.#l.colId):null;this.#o.releaseCell(this.#s,i)}this.#s.replaceChildren&&this.#s.replaceChildren(),t&&this.#y(this.#s),this.#n.refresh({force:!0})}this.#i=null,this.#c=null,this.#s=null,this.#l=null,this.#a=-1,this.#d=!1}#v(){const t=this.#t.activeElement;if(!t||t===this.#t.body)return!1;const i=this.#i&&M(this.#i.element)?this.#i.element():null,s=r=>!!r&&M(r.contains)&&r.contains(t);return s(i)||s(this.#s)}#y(t){const s=M(t.hasAttribute)&&t.hasAttribute("tabindex")?t:this.#n.viewport.root;s&&M(s.focus)&&s.focus()}destroy(){this.close();for(const t of this.#u)t();this.#u=[]}}function y(n,t){let i=n;for(;i;){if(t(i))return i;i=i.parentNode}return null}function l(n,t,i){if(!M(t.getBoundingClientRect))return;const s=t.getBoundingClientRect(),r=i.getBoundingClientRect();n.style.position="absolute",n.style.top=`${Math.round(s.top-r.top)}px`,n.style.minWidth=`${Math.round(s.width)}px`,n.style.left=`${Math.round(s.left-r.left)}px`;const o=n.offsetWidth||Math.round(s.width),c=Math.round(s.left-r.left)+o-Math.round(r.width);c>0&&(n.style.left=`${Math.max(0,Math.round(s.left-r.left)-c)}px`)}function u(n){const t=n.querySelector&&n.querySelector("input, select, textarea, [tabindex]")||n;M(t.focus)&&t.focus(),M(t.select)&&t.select()}}),Ae("packages/dom/src/editbar.js",function(e,G){"use strict";Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return x}});const q=G("packages/core/src/internal/util.js"),M=q.isFunction,$=q.warnOnce,W=G("packages/dom/src/editors/index.js").createEditor,U=`${G("packages/dom/src/editors/common.js").CLS.editor}-bar`;class x{#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,k=v.createElement("div");k.className=U;const y=v.createElement("span");y.className=`${U}__ref`,y.textContent="";const l=v.createElement("div");l.className=`${U}__slot`;const u=v.createElement("span");u.className=`${U}__readonly`,k.appendChild(y),k.appendChild(l),this.#n.insertBefore(k,this.#n.firstChild),this.#r=k,this.#o=y,this.#i=l,this.#l=u;for(const n of["cell:clicked","cell:edit:start","selection:changed","model:changed","rows:changed"])this.#d.push(this.#e.on(n,t=>this.#f(t)))}bind(v,k){const y=this.#e.columns.get(k),l=v?this.#e.rows.byKey(v):null;this.#a=l&&y&&!l.group?{key:v,colId:k}:null,this.refresh()}refresh(){if(!this.#i||this.#u)return;if(this.#h(),!this.#a){this.#o.textContent="";return}const{key:v,colId:k}=this.#a,y=this.#e.columns.get(k);if(!y)return;if(this.#o.textContent=y.title||k,!!!(y.edit&&y.edit.enabled)){this.#l.textContent=this.#e.rows.text(v,k),this.#i.appendChild(this.#l);return}const u=this.#e.rows.byKey(v);if(!u)return;const n=W({grid:this.#e,column:y,colId:k,row:u,data:u.data,value:this.#e.rows.value(v,k),text:this.#e.rows.text(v,k),locale:this.#e.get("locale"),props:y.edit&&y.edit.props,lookup:y.lookup,document:this.#t,cell:this.#i,overlay:this.#n,stop:o=>o?this.cancel():this.commit(!0)});if(!n){$(`editbar.noeditor:${k}`,`column "${k}" has no editor.`),this.#l.textContent=this.#e.rows.text(v,k),this.#i.appendChild(this.#l);return}this.#s=n;const t=n.element();n.popup?(this.#l.textContent=this.#e.rows.text(v,k),this.#i.appendChild(this.#l)):this.#i.appendChild(t),M(n.attached)&&n.attached();const i=o=>this.#m(o),s=()=>{this.#u=!0},r=[t,this.#i];for(const o of r)o.addEventListener("keydown",i),o.addEventListener("input",s),o.addEventListener("change",s);this.#c=()=>{for(const o of r)o.removeEventListener("keydown",i),o.removeEventListener("input",s),o.removeEventListener("change",s)}}#h(){this.#c&&(this.#c(),this.#c=null),this.#s&&M(this.#s.destroy)&&this.#s.destroy(),this.#s=null,this.#i&&this.#i.replaceChildren&&this.#i.replaceChildren()}cancel(){this.#u=!1,this.refresh()}#f(v){if(v&&v.colId&&(v.key||v.row&&v.row.key)){this.bind(v.key||v.row.key,v.colId);return}this.refresh()}#m(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:k,colId:y}=this.#a;if(!this.#s||!M(this.#s.value))return!1;const l=this.#s.value();return this.#u=!1,this.#e.edit.start(k,y),this.#e.edit.stop(!1,{value:l,key:k,colId:y}),this.refresh(),!0}destroy(){this.#h();for(const v of this.#d)v();this.#d=[],this.#r&&M(this.#r.remove)&&this.#r.remove(),this.#r=null,this.#i=null,this.#o=null,this.#a=null}}}),Ae("packages/dom/src/pastepreview.js",function(e,G){"use strict";Object.defineProperty(e,"PREVIEW_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"PastePreview",{enumerable:!0,get:function(){return I}});const M=G("packages/core/src/internal/util.js").isFunction,N=G("packages/core/src/i18n/index.js").defaultMessages,W=G("packages/dom/src/editors/common.js"),Z=W.el,V=W.clear,U="lat-pastepreview",x='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class I{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=null;#a=null;#u=[];constructor(k){this.#e=k.grid,this.#t=k.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#c(k,y){const l=this.#e;return(l&&l.messages?l.messages:N).t(k,y)}#d(k){const y=`paste.preview.reason.${k}`,l=this.#c(y);return l===y?k:l}#h(k){return k==null||k===""?"":String(k)}#f(k,y){const l=this.#e.columns&&M(this.#e.columns.get)?this.#e.columns.get(y):null;return`${l&&(l.title||l.headerName)||y} · ${k}`}show(k,y){const l=this.#b();if(!l)return!1;this.#l=y&&y.onConfirm,this.#a=y&&y.onCancel||null;const u=k&&k.changes||[],n=k&&k.rejected||[],t=u.filter(s=>s.changed);this.#m(t,n);const i=l.ownerDocument;return this.#s=i&&i.activeElement,l.style.display="",M(l.focus)&&l.focus(),this.#y(this.#c("a11y.paste.previewOpened",{count:t.length,changes:t.length,rejected:n.length}),{repeat:!0}),!0}#m(k,y){const l=this.#r.ownerDocument;V(this.#r);const u=Z(l,"p",{class:`${U}__summary`,attrs:{role:"status"},text:this.#c("paste.preview.summary",{count:k.length,changes:k.length,rejected:y.length})});if(this.#r.appendChild(u),!k.length&&!y.length){this.#r.appendChild(Z(l,"p",{class:`${U}__empty`,text:this.#c("paste.preview.empty")})),this.#o.disabled=!k.length;return}this.#o.disabled=!k.length,k.length&&(this.#r.appendChild(Z(l,"h3",{class:`${U}__heading`,text:this.#c("paste.preview.changesHeading",{count:k.length})})),this.#r.appendChild(this.#p(l,k))),y.length&&(this.#r.appendChild(Z(l,"h3",{class:`${U}__heading ${U}__heading--rejected`,text:this.#c("paste.preview.rejectedHeading",{count:y.length})})),this.#r.appendChild(this.#g(l,y)))}#p(k,y){const l=Z(k,"tr",{children:[Z(k,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),Z(k,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colOld")}),Z(k,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colNew")})]}),u=y.map(n=>Z(k,"tr",{children:[Z(k,"th",{attrs:{scope:"row"},text:this.#f(n.key,n.colId)}),Z(k,"td",{class:`${U}__old`,text:this.#h(n.oldValue)}),Z(k,"td",{class:`${U}__new`,text:this.#h(n.newValue)})]}));return Z(k,"table",{class:`${U}__table`,children:[Z(k,"thead",{children:[l]}),Z(k,"tbody",{children:u})]})}#g(k,y){const l=Z(k,"tr",{children:[Z(k,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),Z(k,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colReason")})]}),u=y.map(n=>Z(k,"tr",{children:[Z(k,"th",{attrs:{scope:"row"},text:this.#f(n.key,n.colId)}),Z(k,"td",{class:`${U}__reason`,text:this.#d(n.reason)})]}));return Z(k,"table",{class:`${U}__table ${U}__table--rejected`,children:[Z(k,"thead",{children:[l]}),Z(k,"tbody",{children:u})]})}confirm(){const k=this.#l;this.#w(),M(k)&&k()}cancel(){const k=this.#a;this.#w(),this.#y(this.#c("a11y.paste.cancelled"),{repeat:!0}),M(k)&&k()}#w(){if(!this.#n)return;this.#n.style.display="none",this.#l=null,this.#a=null;const k=this.#s;this.#s=null,k&&M(k.focus)&&k.focus()}#b(){if(this.#n)return this.#n;const k=this.#t.viewport&&this.#t.viewport.overlays,y=k&&k.ownerDocument;if(!k||!y||!M(y.createElement))return null;const l=`${U}-title`,u=Z(y,"h2",{class:`${U}__title`,attrs:{id:l},text:this.#c("paste.preview.title")}),n=Z(y,"div",{class:`${U}__body`}),t=Z(y,"button",{class:`${U}__confirm`,attrs:{type:"button"},text:this.#c("paste.preview.confirm")}),i=Z(y,"button",{class:`${U}__cancel`,attrs:{type:"button"},text:this.#c("paste.preview.cancel")}),s=Z(y,"div",{class:`${U}__foot`,children:[i,t]}),r=Z(y,"div",{class:U,attrs:{role:"dialog","aria-modal":"true",tabindex:"-1","aria-labelledby":l},children:[Z(y,"div",{class:`${U}__head`,children:[u]}),n,s]});return k.appendChild(r),this.#n=r,this.#r=n,this.#o=t,this.#i=i,this.#v(r,t,i),r}#v(k,y,l){const u=i=>{if(i.stopPropagation(),i.key==="Escape"){i.preventDefault(),this.cancel();return}if(i.key!=="Tab")return;const s=[...k.querySelectorAll(x)].filter(a=>!a.disabled);if(!s.length){i.preventDefault();return}const r=s[0],o=s[s.length-1],c=k.ownerDocument.activeElement;i.shiftKey&&(c===r||c===k)?(i.preventDefault(),o.focus()):!i.shiftKey&&c===o&&(i.preventDefault(),r.focus())},n=i=>{i&&M(i.preventDefault)&&i.preventDefault(),this.confirm()},t=i=>{i&&M(i.preventDefault)&&i.preventDefault(),this.cancel()};k.addEventListener("keydown",u),y.addEventListener("click",n),l.addEventListener("click",t),this.#u.push(()=>{k.removeEventListener("keydown",u),y.removeEventListener("click",n),l.removeEventListener("click",t)})}#y(k,y){const l=this.#t&&this.#t.announce;M(l)&&l.call(this.#t,k,y)}destroy(){for(const k of this.#u)k();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}}}),Ae("packages/dom/src/rangeselect.js",function(e,G){"use strict";Object.defineProperty(e,"RangeController",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const M=G("packages/core/src/internal/util.js").isFunction,N=G("packages/core/src/i18n/index.js").defaultMessages,W=G("packages/core/src/model/selection.js"),Z=W.extendSeries,V=W.resolveSelectionConfig,U=G("packages/dom/src/renderer/textentry.js"),x=U.isTextEntry,I=U.isFindBarControl,k=G("packages/dom/src/pastepreview.js").PastePreview,y=G("packages/dom/src/columnmenu.js"),l=y.chartableRange,u=y.rangeChartConfig,n="lat-cell--range",t="lat-cell--range-edge",i=Object.freeze({top:"lat-cell--range-top",right:"lat-cell--range-right",bottom:"lat-cell--range-bottom",left:"lat-cell--range-left"}),s=3;class r{#e;#t;#n;#r=!1;#o=[];#i=null;#s=null;#l=null;#a=null;#u=null;constructor(a){this.#e=a.grid,this.#t=a.renderer,this.#n=a.document,this.#a=a.preview||null}mount(){const a=this.#t.viewport.root,g=f=>this.#c(f),h=f=>this.#d(f),b=()=>this.#h(),p=f=>this.#f(f);a.addEventListener("pointerdown",g),this.#n.addEventListener("pointermove",h),this.#n.addEventListener("pointerup",b),a.addEventListener("keydown",p),this.#o.push(()=>{a.removeEventListener("pointerdown",g),this.#n.removeEventListener("pointermove",h),this.#n.removeEventListener("pointerup",b),a.removeEventListener("keydown",p)});for(const f of["range:changed","rows:changed","model:changed","scroll"])this.#o.push(this.#e.on(f,()=>this.paint()));this.paint()}#c(a){if(a.button!==0)return;const g=a.target;if(!g||!M(g.closest))return;if(this.#r=!1,g.closest('[data-role="fill-handle"]')){if(this.#T())return;this.#i={mode:"fill",fromX:a.clientX,fromY:a.clientY,armed:!0};return}if(g.closest('[data-role="row-drag"]'))return;const h=this.#R(g);if(!h)return;if(a.shiftKey&&this.#e.selection.corner()){const p=this.#C(h);this.#e.selection.extendRange(p.rowIndex,p.colId),this.#i={mode:"select",fromX:a.clientX,fromY:a.clientY,armed:!0};return}const b=this.#E(h);this.#u=b,this.#e.selection.startRange(b.rowIndex,b.colId,{additive:a.ctrlKey||a.metaKey}),this.#i={mode:"select",fromX:a.clientX,fromY:a.clientY,armed:!1}}#d(a){const g=this.#i;if(!g)return;if(!g.armed){if(Math.abs(a.clientX-g.fromX)+Math.abs(a.clientY-g.fromY)<s)return;g.armed=!0}const h=this.#q(a.clientX,a.clientY);if(!h)return;if(g.mode==="fill"){this.#l=h,this.paint();return}const b=this.#C(h);this.#e.selection.extendRange(b.rowIndex,b.colId)}#h(){const a=this.#i;if(this.#i=null,!!a){if(a.mode==="fill"&&this.#l){const g=this.#l;this.#l=null,this.fillTo(g.rowIndex)}this.#l=null,this.paint()}}#f(a){if(this.#D()||I(a.target)||x(a.target))return;const g=a.ctrlKey||a.metaKey,h=a.key;if(g&&(h==="c"||h==="C")){this.copy(),a.preventDefault();return}if(g&&(h==="v"||h==="V")){this.paste(),a.preventDefault();return}if(g&&(h==="d"||h==="D")){this.fillDown(),a.preventDefault();return}if(h==="Delete"||h==="Backspace"){if(!this.#e.selection.cells().length&&this.#e.selection.keys().length&&this.#e.get("rowDelete")===!0){this.#e.edit.deleteRows(),a.preventDefault();return}this.clear(),a.preventDefault();return}if(a.altKey&&h==="F1"){this.chartSelection()&&a.preventDefault();return}if(!a.shiftKey)return;const b={ArrowDown:[1,0],ArrowUp:[-1,0],ArrowRight:[0,1],ArrowLeft:[0,-1]}[h];if(!b)return;if(g){const O=this.#W();if(!O)return;if(!this.#r){const z=this.#E(O);this.#u=z,this.#e.selection.startRange(z.rowIndex,z.colId,{additive:!0}),this.#r=!0}const T=this.#e.columns.visible().map(z=>z.id),A=T.indexOf(O.colId),P=this.#e.selection.corner()||{row:O.rowIndex,colId:O.colId},L=this.#C({rowIndex:Math.min(this.#e.rows.count()-1,Math.max(0,P.row+b[0])),colId:T[Math.min(T.length-1,Math.max(0,(A<0?0:A)+b[1]))]});this.#e.selection.extendRange(L.rowIndex,L.colId),a.preventDefault();return}this.#r=!1;const p=this.#e.selection.corner(),f=this.#W(),w=p||f;if(!w)return;if(!p&&f){const O=this.#E(f);this.#u=O,this.#e.selection.startRange(O.rowIndex,O.colId)}const S=this.#e.columns.visible().map(O=>O.id),m=S.indexOf(w.colId??w.colId),d=S[Math.min(S.length-1,Math.max(0,m+b[1]))],j=Math.min(this.#e.rows.count()-1,Math.max(0,(p?p.row:f.rowIndex)+b[0])),E=this.#C({rowIndex:j,colId:d});this.#e.selection.extendRange(E.rowIndex,E.colId),a.preventDefault()}async copy(){const a=this.#e.export.rangeText();if(!a)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||!M(g.writeText))return!1;try{return await g.writeText(a),this.#e.emit("clipboard:copy",{text:a,ok:!0,rows:"range"},"user"),!0}catch{return this.#e.emit("clipboard:copy",{text:a,ok:!1,rows:"range"},"user"),!1}}async paste(){const a=globalThis.navigator&&globalThis.navigator.clipboard;if(!a||!M(a.readText))return 0;let g="";try{g=await a.readText()}catch{return 0}return this.pasteText(g)}pasteText(a){if(!a)return 0;const g=this.#e.selection.cells(),h=g.length?g[0]:this.#v();if(!h)return 0;const b=g.length>1?{rows:new Set(g.map(p=>p.key)).size,columns:new Set(g.map(p=>p.colId)).size}:void 0;if(this.#m()){const p=this.#e.edit.previewPaste(h,a,b);if(p.changes.length+p.rejected.length>1)return this.#p().show(p,{onConfirm:()=>this.#g(h,a,b)}),0}return this.#g(h,a,b)}#m(){const a=this.#e.edit;return!!(a&&a.pastePreview&&M(a.previewPaste))}#p(){return this.#a||(this.#a=new k({grid:this.#e,renderer:this.#t})),this.#a}#g(a,g,h){const b=this.#e.edit.pasteInto(a,g,h);return this.#b(b?this.#w("a11y.range.written",{count:b}):this.#w("a11y.range.refused"),{repeat:!0}),b}#w(a,g){const h=this.#e;return(h&&h.messages?h.messages:N).t(a,g)}#b(a,g){const h=this.#t&&this.#t.announce;M(h)&&h.call(this.#t,a,g)}#v(){const a=this.#W();if(!a)return null;const g=this.#e.rows.get(a.rowIndex);return g?{key:g.key,colId:a.colId}:null}clear(){const a=this.#e.selection.cells();return a.length?this.#e.edit.setCells(a.map(g=>({...g,value:null}))):0}fillDown(){if(this.#e.selection.ranges().length>1)return 0;const a=this.#e.selection.cells();if(a.length<2)return 0;const g=[...new Set(a.map(p=>p.key))];if(g.length<2)return 0;const h=g[0],b=[];for(const{key:p,colId:f}of a)p!==h&&b.push({key:p,colId:f,value:this.#e.rows.value(h,f)});return this.#e.edit.setCells(b)}chartSelection(){const a=u(this.#e);if(!a.handler)return!1;const g=l(this.#e);return g?(a.handler(this.#e,g),!0):!1}fillTo(a){if(this.#e.selection.ranges().length>1)return 0;const g=this.#e.selection.cells();if(!g.length)return 0;const h=[...new Set(g.map(d=>d.key))],b=[...new Set(g.map(d=>d.colId))],p=this.#I(h[h.length-1]);if(p<0||a<=p)return 0;const f=[];for(let d=p+1;d<=a;d++){const j=this.#e.rows.get(d);if(!j)break;f.push(j)}if(!f.length)return 0;const w=[];for(const d of b){const j=h.map(O=>this.#e.rows.value(O,d)),E=this.#y(j,f,d);for(let O=0;O<f.length;O++)w.push({key:f[O].key,colId:d,value:E[O]})}const S=this.#e.edit.setCells(w),m=this.#e.selection.corner();return m&&this.#e.selection.extendRange(a,m.colId),S}#y(a,g,h){const b=this.#e.get("selection"),p=b&&typeof b=="object"?b.fill:void 0;if(M(p)){const f=this.#e.columns.get(h),w=g.map(m=>({row:m,column:f})),S=p({source:a,target:w,direction:"down"});if(Array.isArray(S)&&S.length===g.length)return S}return Z(a,g.length)}paint(){const a=this.#t.viewport.root;if(!a||!a.querySelectorAll)return;const g=this.#e.selection,h=g.ranges().length>0,b=this.#l;for(const p of a.querySelectorAll("[data-col]")){const f=p.getAttribute("data-col"),w=p.parentNode,S=p.getAttribute?p.getAttribute("data-index"):null,m=S!==null&&S!==""?S:w&&w.getAttribute?w.getAttribute("data-index"):null;if(m===null||m==="")continue;const d=Number(m);if(!Number.isFinite(d)||d<0)continue;const j=h&&g.inRange(d,f),E=!!b&&this.#S(d,f,b);p.classList.toggle(n,j||E);const O=j||E?this.#A(d,f,g):null;p.classList.toggle(t,!!O&&O.any);for(const[T,A]of Object.entries(i))p.classList.toggle(A,!!O&&O[T])}this.#j()}#S(a,g,h){const b=this.#e.selection.cells();if(!b.length||!new Set(b.map(w=>w.colId)).has(g))return!1;const f=this.#I([...new Set(b.map(w=>w.key))].pop());return a>f&&a<=h.rowIndex}#A(a,g,h){const b=this.#e.columns.visible().map(m=>m.id),p=b.indexOf(g),f=p>0?b[p-1]:null,w=p>=0&&p<b.length-1?b[p+1]:null,S={top:!h.inRange(a-1,g),bottom:!h.inRange(a+1,g),left:!f||!h.inRange(a,f),right:!w||!h.inRange(a,w)};return S.any=S.top||S.bottom||S.left||S.right,S}#j(){const a=this.#e.selection.corner(),g=this.#t.viewport.overlays;if(!g)return;if(!a||this.#N()===!1||this.#e.selection.ranges().length>1||this.#T()){this.#s&&(this.#s.style.display="none");return}const h=this.#B(a.row,a.colId);if(!h||!M(h.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.#w("a11y.fillHandle")),g.appendChild(this.#s));const b=h.getBoundingClientRect(),p=this.#t.viewport.root.getBoundingClientRect();this.#s.style.display="";const w=this.#t.viewport.rtl===!0?b.left:b.right;this.#s.style.left=`${Math.round(w-p.left)-4}px`,this.#s.style.top=`${Math.round(b.bottom-p.top)-4}px`}#O(a){const g=this.#t;return!a||typeof g.spanAt!="function"?null:g.spanAt(a.rowIndex,a.colId)}#E(a){const g=this.#O(a);return g?{rowIndex:g.row,colId:g.columnId}:a}#C(a){const g=this.#O(a);if(!g)return a;const h=this.#u,b=!!h&&h.rowIndex>=g.row+g.rows,p=this.#x(),f=h?p.indexOf(h.colId):-1,w=f>=0&&f>=g.col+g.cols;return{rowIndex:b?g.row:g.row+g.rows-1,colId:w?g.columnId:g.endColumnId}}#T(){const a=this.#e.selection.corner();if(!a)return!1;const g=this.#O({rowIndex:a.row,colId:a.colId});return!!g&&(g.rows>1||g.cols>1)}#x(){const a=this.#e.columns;return a&&M(a.visible)?a.visible().map(g=>g.id):[]}#N(){return V(this.#e.get("selection")).fillHandle}#D(){const a=this.#t.viewport.root;return!!(a&&a.querySelector&&a.querySelector(".lat-editor-host, .lat-editor--popup"))}#M(){const a=this.#e.selection.cells();return a.length?a[0]:null}#I(a){for(let g=0;g<this.#e.rows.count();g++){const h=this.#e.rows.get(g);if(h&&h.key===a)return g}return-1}#W(){const a=this.#t.viewport.root,g=a&&a.querySelector?a.querySelector('[data-col][tabindex="0"]'):null;return g?this.#R(g):null}#R(a){if(!a||!M(a.closest))return null;const g=a.closest("[data-col]");if(!g||!g.classList.contains("lat-cell"))return null;const h=g.closest("[data-index]");if(!h)return null;const b=Number(h.getAttribute("data-index"));return!Number.isFinite(b)||b<0?null:{rowIndex:b,colId:g.getAttribute("data-col")}}#q(a,g){const h=this.#n.elementFromPoint?this.#n.elementFromPoint(a,g):null;return h?this.#R(h):null}#B(a,g){const h=this.#t.viewport.root;if(!h||!h.querySelectorAll)return null;for(const b of h.querySelectorAll(`[data-col="${g}"]`)){const p=b.closest?b.closest("[data-index]"):null;if(p&&Number(p.getAttribute("data-index"))===a)return b}return null}destroy(){for(const a of this.#o)a();this.#o=[],this.#s&&M(this.#s.remove)&&this.#s.remove(),this.#s=null,this.#i=null,this.#l=null,this.#a&&M(this.#a.destroy)&&this.#a.destroy(),this.#a=null}}const o=r}),Ae("packages/dom/src/importer.js",function(e,G){"use strict";Object.defineProperty(e,"IMPORT_DIALOG_CLASS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ImportController",{enumerable:!0,get:function(){return r}});const M=G("packages/core/src/internal/util.js").isFunction,N=G("packages/core/src/i18n/index.js").defaultMessages,W=G("packages/core/src/import/index.js"),Z=W.parseDelimited,V=W.inferColumns,U=W.mapRecords,x=W.readXlsx,I=W.looksLikeXlsx,v=G("packages/dom/src/editors/common.js"),k=v.el,y=v.clear,l=v.on,n=G("packages/dom/src/renderer/textentry.js").isTextEntry,t="lat-import",i='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',s=".csv,.tsv,.txt,.xlsx,text/csv,text/tab-separated-values,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";class r{#e;#t;#n;#r;#o=[];#i=null;#s=null;#l=null;#a=null;constructor(c){this.#e=c.grid,this.#t=c.renderer,this.#n=c.document;const a=c.settings&&typeof c.settings=="object"?c.settings:{};this.#r={file:a.file!==!1,drop:a.drop!==!1,paste:a.paste!==!1,mode:a.mode==="replace"?"replace":"append"},this.#u()}#u(){const c=this.#t&&this.#t.viewport?this.#t.viewport.root:null;c&&(this.#r.drop&&(this.#o.push(l(c,"dragover",a=>{a.dataTransfer&&[...a.dataTransfer.types||[]].includes("Files")&&(a.preventDefault(),c.classList.add("lat-import--dropzone"))})),this.#o.push(l(c,"dragleave",()=>c.classList.remove("lat-import--dropzone"))),this.#o.push(l(c,"drop",a=>{c.classList.remove("lat-import--dropzone");const g=a.dataTransfer&&a.dataTransfer.files&&a.dataTransfer.files[0];g&&(a.preventDefault(),this.#c(g))}))),this.#r.paste&&this.#o.push(l(c,"paste",a=>{if(n(a.target)||this.#e.edit.isEditing?.()||this.#e.selection&&this.#e.selection.cells().length)return;const g=a.clipboardData&&a.clipboardData.getData("text/plain");!g||!g.includes(`
|
|
56
56
|
`)||(a.preventDefault(),this.fromText(g))})))}openFile(){const c=k(this.#n,"input",{attrs:{type:"file",accept:s}});c.style.display="none",this.#o.push(l(c,"change",()=>{const a=c.files&&c.files[0];a&&this.#c(a),c.parentNode&&c.parentNode.removeChild(c)})),this.#n.body.appendChild(c),c.click()}#c(c){if(M(c.arrayBuffer)){c.arrayBuffer().then(g=>{const h=new Uint8Array(g);if(I(h)){this.fromXlsx(h,c.name);return}this.fromText(new TextDecoder().decode(h),c.name)});return}if(M(c.text)){c.text().then(g=>this.fromText(g,c.name));return}const a=new this.#n.defaultView.FileReader;a.onload=()=>this.fromText(String(a.result||""),c.name),a.readAsText(c)}async fromXlsx(c,a){const{header:g,rows:h}=await x(c);if(!g.length)return;const b=V(g,h,{columns:this.#e.columns.all()}),p=h.filter(f=>f.length!==g.length).length;this.#l={rows:h,columns:b,delimiter:null,name:a,warnings:p?[`${p} row(s) do not have ${g.length} columns`]:[]},this.#d()}fromText(c,a){const{header:g,rows:h,delimiter:b}=Z(c);if(!g.length)return;const p=V(g,h,{columns:this.#e.columns.all()}),f=h.filter(w=>w.length!==g.length).length;this.#l={rows:h,columns:p,delimiter:b,name:a,warnings:f?[`${f} row(s) do not have ${g.length} columns`]:[]},this.#d()}#d(){this.#i||this.#m(),this.#p(),this.#a=this.#n.activeElement,this.#i.hidden=!1;const c=this.#i.querySelector(i);c&&M(c.focus)&&c.focus(),this.#h(this.#f("import.opened",{count:this.#l.rows.length}),{repeat:!0})}#h(c,a){const g=this.#t&&this.#t.announce;M(g)&&g.call(this.#t,c,a)}#f(c,a){return(this.#e&&this.#e.messages?this.#e.messages:N).t(c,a)}#m(){const c=this.#n,a=k(c,"div",{class:t,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#f("import.title"),hidden:!0}}),g=k(c,"div",{class:`${t}__panel`});g.appendChild(k(c,"h2",{class:`${t}__title`,text:this.#f("import.title")})),this.#s=k(c,"div",{class:`${t}__body`}),g.appendChild(this.#s);const h=k(c,"div",{class:`${t}__footer`}),b=k(c,"button",{class:`${t}__cancel`,text:this.#f("import.cancel"),attrs:{type:"button"}}),p=k(c,"button",{class:`${t}__confirm`,text:this.#f("import.confirm"),attrs:{type:"button"}});this.#o.push(l(b,"click",()=>this.close())),this.#o.push(l(p,"click",()=>this.#g())),h.appendChild(b),h.appendChild(p),g.appendChild(h),a.appendChild(g),this.#o.push(l(a,"keydown",w=>{if(w.key==="Escape"){w.preventDefault(),this.close();return}if(w.key!=="Tab")return;const S=[...a.querySelectorAll(i)].filter(j=>!j.hidden);if(!S.length)return;const m=S[0],d=S[S.length-1];w.shiftKey&&this.#n.activeElement===m?(w.preventDefault(),d.focus()):!w.shiftKey&&this.#n.activeElement===d&&(w.preventDefault(),m.focus())})),(this.#t.viewport&&this.#t.viewport.overlays||this.#n.body).appendChild(a),this.#i=a}#p(){const c=this.#n,a=y(this.#s),{rows:g,columns:h,name:b,warnings:p}=this.#l;a.appendChild(k(c,"p",{class:`${t}__summary`,text:this.#f("import.summary",{count:g.length,name:b||this.#f("import.clipboard")})}));for(const j of p)a.appendChild(k(c,"p",{class:`${t}__warning`,text:j}));const f=this.#e.columns.all().map(j=>j.field||j.id).filter(Boolean),w=k(c,"table",{class:`${t}__map`}),S=k(c,"tr",{});for(const j of["import.colSource","import.colField","import.colType"])S.appendChild(k(c,"th",{text:this.#f(j)}));w.appendChild(S),h.forEach((j,E)=>{const O=k(c,"tr",{});O.appendChild(k(c,"td",{text:j.source}));const T=k(c,"select",{attrs:{"data-col":String(E),"aria-label":this.#f("import.mapLabel",{source:j.source})}});T.appendChild(k(c,"option",{text:this.#f("import.skip"),attrs:{value:""}}));for(const P of f)T.appendChild(k(c,"option",{text:P,attrs:{value:P,selected:P===j.field?!0:null}}));j.field&&!f.includes(j.field)&&T.appendChild(k(c,"option",{text:j.field,attrs:{value:j.field,selected:!0}}));const A=k(c,"td",{});A.appendChild(T),O.appendChild(A),O.appendChild(k(c,"td",{class:`${t}__type`,text:j.type})),w.appendChild(O)}),a.appendChild(w);const m=k(c,"div",{class:`${t}__mode`}),d=k(c,"select",{attrs:{"aria-label":this.#f("import.modeLabel"),"data-mode":"mode"}});d.appendChild(k(c,"option",{text:this.#f("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),d.appendChild(k(c,"option",{text:this.#f("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),m.appendChild(k(c,"label",{text:this.#f("import.modeLabel")})),m.appendChild(d),a.appendChild(m)}#g(){const{rows:c,columns:a}=this.#l;for(const f of this.#i.querySelectorAll("select[data-col]")){const w=Number(f.getAttribute("data-col"));a[w]&&f.value!==void 0&&f.value!==null&&(a[w].field=f.value)}const g=this.#i.querySelector("select[data-mode]"),h=g?g.value:void 0,b=h==="replace"||h==="append"?h:this.#r.mode,p=U(c,a);this.#e.import.apply(p,{mode:b}),this.close(),this.#h(this.#f("import.done",{count:p.length}),{repeat:!0})}close(){this.#i&&(this.#i.hidden=!0),this.#l=null,this.#a&&M(this.#a.focus)&&this.#a.focus(),this.#a=null}destroy(){for(const c of this.#o)c();this.#o=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null}}}),Ae("packages/dom/src/historybar.js",function(e,G){"use strict";Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const M=G("packages/core/src/internal/util.js").isFunction,N=G("packages/core/src/i18n/index.js").defaultMessages,W=G("packages/dom/src/editors/common.js"),Z=W.el,V=W.on,U=W.clear,x=W.documentFor,I="lat-history";class v{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(l,u){return(this.messages&&typeof this.messages.t=="function"?this.messages:N).t(l,u)}init(l){this.messages=l&&l.messages||l&&l.grid&&l.grid.messages||N;const u=l||{};if(this.doc=x(u),this.host=u.host||{},this.props=u.props||{},this.root=Z(this.doc,"div",{class:["lattice-tokens",I],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 n=Z(this.doc,"button",{class:`${I}__toggle`,text:"▾",attrs:{type:"button","aria-haspopup":"menu","aria-expanded":"false","aria-label":this.t("history.show")}});this.off.push(V(n,"click",()=>this.toggle())),this.root.appendChild(n),this.toggleButton=n,this.menu=Z(this.doc,"div",{class:`${I}__menu`,attrs:{role:"menu"}}),this.menu.style.display="none",this.root.appendChild(this.menu)}this.refresh()}#e(l,u,n){const t=Z(this.doc,"button",{class:`${I}__${l}`,attrs:{type:"button"},children:[Z(this.doc,"span",{class:`${I}__glyph`,text:n,attrs:{"aria-hidden":"true"}}),Z(this.doc,"span",{class:`${I}__label`,text:u})]});return this.off.push(V(t,"click",()=>{const i=this.host[l];M(i)&&i(),this.refresh()})),t}element(){return this.root}refresh(){if(!this.root)return;const l=this.host,u=M(l.canUndo)?l.canUndo():!1,n=M(l.canRedo)?l.canRedo():!1,t=M(l.peek)?l.peek("undo"):null,i=M(l.peek)?l.peek("redo"):null;this.#t(this.undoButton,"undo",u,t),this.#t(this.redoButton,"redo",n,i),this.open&&this.#n()}#t(l,u,n,t){if(!l)return;l.disabled=!n;const i=u==="undo",s=this.t(i?"history.undo":"history.redo"),r=l.querySelector(`.${I}__label`);r&&(r.textContent=s);const o=t&&t.label?this.t("history.described",{action:s,label:t.label}):s;l.setAttribute("title",n?o:this.t(i?"history.nothingToUndo":"history.nothingToRedo")),l.setAttribute("aria-label",n?o:this.t(i?"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;U(l);const u=M(this.host.list)?this.host.list():[];if(!u.length){l.appendChild(Z(this.doc,"p",{class:`${I}__empty`,text:this.t("history.empty")}));return}u.forEach((n,t)=>{const i=Z(this.doc,"button",{class:`${I}__item`,attrs:{type:"button",role:"menuitem","data-type":n.type,"data-undone":n.undone?"true":null},children:[Z(this.doc,"span",{class:`${I}__kind`,text:n.type}),Z(this.doc,"span",{class:`${I}__text`,text:n.label||n.type})]});this.off.push(V(i,"click",()=>{const s=t+1;for(let r=0;r<s;r++)M(this.host.undo)&&this.host.undo();this.toggle(),this.refresh()})),l.appendChild(i)})}destroy(){for(const l of this.off)l();this.off=[],this.root&&M(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const k=v}),Ae("packages/dom/src/diffpaint.js",function(e,G){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"diffConfigured",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const q=G("packages/core/src/internal/util.js"),M=q.isFunction,$=q.warnOnce,W=G("packages/core/src/i18n/index.js").defaultMessages,Z={changed:"lat-row--changed",added:"lat-row--added",removed:"lat-row--removed"},V="lat-cell--changed",U="lat-cell--added-column";class x{#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,u=l&&l.enabled;for(const n of y.querySelectorAll("[data-key]")){const t=n.getAttribute("data-key"),i=u?l.statusOf(t):"unchanged";for(const r of Object.values(Z))n.classList.remove(r);u&&Z[i]&&n.classList.add(Z[i]),n.setAttribute("data-diff",u?i:"");const s=u&&i==="changed";for(const r of n.querySelectorAll("[data-col]")){const o=r.getAttribute("data-col");if(r.classList.remove(V,U),r.removeAttribute("data-before"),!s)continue;const c=l.cellStatus(t,o);if(c==="changed"){r.classList.add(V);const a=this.#r(l,t,o);a===null?r.removeAttribute("title"):(r.setAttribute("data-before",a),r.setAttribute("title",this.#o("diff.before",{value:a})))}else c==="added-column"&&r.classList.add(U)}}}#r(y,l,u){const n=this.#e,t=n&&n.columns,i=t&&M(t.get)?t.get(u):null,s=n&&n.permissions;if(i&&s&&M(s.isSecret)&&s.isSecret(i))return null;const r=y.before(l,u);if(r==null)return this.#o("diff.empty");if(!i||!M(i.formatValue))return String(r);const o=M(y.beforeRow)?y.beforeRow(l):void 0,a={...(n.rows&&M(n.rows.byKey)?n.rows.byKey(l):null)||{},data:o===void 0?{}:o};try{const g=i.formatValue(r,a,a.data);return g==null?"":String(g)}catch(g){return $(`diff-before-format:${u}`,`the formatter for column "${u}" threw while formatting a previous value, so the diff hover shows the raw one.`,g),String(r)}}#o(y,l){const u=this.#e;return(u&&u.messages?u.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 u of Object.values(Z))l.classList.remove(u);l.removeAttribute("data-diff")}for(const l of y.querySelectorAll("[data-col]"))l.classList.remove(V,U),l.removeAttribute("data-before")}}}function I(k){return!!(k&&k.diff&&(M(k.diff)||typeof k.diff=="object"))}const v=x}),Ae("packages/dom/src/highlightpaint.js",function(e,G){"use strict";Object.defineProperty(e,"HighlightPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const M=G("packages/core/src/internal/util.js").isFunction,$="lat-cell--highlight",N="--lattice-cell-highlight";class W{#e;#t;#n=[];#r=null;#o=!1;#i;constructor(U){this.#e=U.grid,this.#t=U.renderer,this.#i=U.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 U=()=>{this.#o=!1,this.paint()};M(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(U):M(this.#i.setTimeout)?this.#i.setTimeout(U,0):U()}paint(){const U=this.#t.viewport?.root;if(!U||!U.querySelectorAll)return;const x=this.#l();if(x){x.sweep();for(const I of U.querySelectorAll("[data-key]")){const v=I.getAttribute("data-key");for(const k of I.querySelectorAll("[data-col]")){const y=x.active?x.colourFor(v,k.getAttribute("data-col")):null;y?(k.classList.add($),k.style.setProperty(N,y)):k.classList.contains($)&&(k.classList.remove($),k.style.removeProperty(N))}}this.#s(x)}}#s(U){this.#r!==null&&M(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const x=U.nextExpiry;if(!Number.isFinite(x)||!M(this.#i.setTimeout))return;const I=Math.max(0,x-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},I)}#l(){const U=this.#e.highlight;return U&&M(U.model)?U.model():null}destroy(){this.#r!==null&&M(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const x of this.#n)x();this.#n=[];const U=this.#t.viewport?.root;if(!(!U||!U.querySelectorAll))for(const x of U.querySelectorAll(`.${$}`))x.classList.remove($),x.style.removeProperty(N)}}const Z=W}),Ae("packages/dom/src/findpaint.js",function(e,G){"use strict";Object.defineProperty(e,"MATCH_CLASS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"CURRENT_CLASS",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"FindPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const M=G("packages/core/src/internal/util.js").isFunction,$="lat-cell--find",N="lat-cell--find-current";class W{#e;#t;#n=[];#r=!1;#o=!1;#i;constructor(U){this.#e=U.grid,this.#t=U.renderer,this.#i=U.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 U=()=>{this.#r=!1,this.paint()};M(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(U):M(this.#i.setTimeout)?this.#i.setTimeout(U,0):U()}paint(){const U=this.#t.viewport?.root;if(!U||!U.querySelectorAll)return;const x=this.#e.find;if(!x||!M(x.stateFor))return;const I=M(x.model)?x.model():null,v=!!I&&I.active;if(!v&&!this.#o)return;let k=!1;for(const y of U.querySelectorAll("[data-key]")){const l=y.getAttribute("data-key");for(const u of y.querySelectorAll("[data-col]")){const n=v?x.stateFor(l,u.getAttribute("data-col")):null;n?(k=!0,u.classList.add($),u.classList.toggle(N,n==="current")):u.classList.contains($)&&u.classList.remove($,N)}}this.#o=k}destroy(){for(const x of this.#n)x();this.#n=[];const U=this.#t.viewport?.root;if(!(!U||!U.querySelectorAll)){for(const x of U.querySelectorAll(`.${$}`))x.classList.remove($,N);this.#o=!1}}}const Z=W}),Ae("packages/dom/src/findbar.js",function(e,G){"use strict";Object.defineProperty(e,"FIND_CLASS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"FindBar",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const q=G("packages/dom/src/editors/common.js"),M=q.el,$=q.on,W=G("packages/dom/src/renderer/textentry.js").isTextEntry,V=G("packages/core/src/i18n/index.js").defaultMessages,x=G("packages/core/src/internal/util.js").isFunction,I="lat-find",v=12,k=120;class y{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=null;#f=!1;#m=!1;#p=null;#g=[];#w=null;#b=null;#v=!1;constructor(n){this.#e=n.grid,this.#t=n.renderer,this.#n=n.document||n.renderer.viewport?.document,this.#r=this.#n&&this.#n.defaultView||(typeof globalThis>"u"?{}:globalThis),this.#o=n.settings&&typeof n.settings=="object"?n.settings:{}}get open(){return!!this.#i&&this.#i.style.display!=="none"}get element(){return this.#i}t(n,t){const i=this.#e;return(i&&i.messages&&x(i.messages.t)?i.messages:V).t(n,t)}mount(){const n=this.#S();if(!n)return;n.attachUi({open:i=>this.show(i),close:()=>this.hide(),focus:()=>{this.#s&&this.#s.focus()}}),n.attachDriver({run:()=>this.#T()});const t=this.#t.viewport?.root;if(t&&x(t.addEventListener)&&this.#o.shortcut!==!1){const i=s=>{if(!(s.ctrlKey||s.metaKey)||s.altKey||s.shiftKey||s.key!=="f"&&s.key!=="F")return;const r=s.target;if(this.#s&&r===this.#s){s.preventDefault(),s.stopPropagation(),x(this.#s.select)&&this.#s.select();return}W(r)||(s.preventDefault(),s.stopPropagation(),this.show())};t.addEventListener("keydown",i,!0),this.#g.push(()=>t.removeEventListener("keydown",i,!0))}this.#g.push(this.#e.on("find:changed",()=>this.#N())),this.#g.push(this.#e.on("columns:changed",()=>this.#j())),this.#g.push(this.#e.on("column:visible",()=>this.#j()))}show(n){const t=this.#A();if(!t)return;const i=t.style.display!=="none";t.style.display="",i||this.#y(),this.#S().setOpen(!0),n!=null&&(this.#s.value=String(n),this.#E()),this.#s.focus(),x(this.#s.select)&&this.#s.select(),this.#N()}hide(){this.#I();const n=this.#S();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#y()),n&&(n.clear(),n.setOpen(!1));const t=this.#t.viewport?.root;if(!t||!(this.#i&&this.#n&&this.#n.activeElement&&x(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const r=(x(t.querySelector)?t.querySelector('[tabindex="0"]'):null)||t;x(r.focus)&&r.focus()}search(){this.#E()}destroy(){this.#v=!0,this.#I();for(const t of this.#g)t();this.#g=[];const n=this.#S();n&&(n.attachUi(null),n.attachDriver(null)),this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null}#y(){const n=this.#t;n&&x(n.invalidate)&&n.invalidate("size")}#S(){const n=this.#e&&this.#e.find;return n&&x(n.model)?n.model():null}#A(){if(this.#i)return this.#i;const n=this.#t.viewport,t=n?.root,i=this.#n;if(!t||!i||!x(t.insertBefore))return null;const s=M(i,"div",{class:I,attrs:{role:"search","aria-label":this.t("find.label")}});this.#s=M(i,"input",{class:`${I}__input`,attrs:{type:"text","aria-label":this.t("find.label"),placeholder:this.t("find.placeholder"),autocomplete:"off",spellcheck:"false"}}),this.#l=M(i,"span",{class:`${I}__count`,attrs:{"aria-hidden":"true"}}),this.#a=M(i,"span",{class:`${I}__scope`,attrs:{"aria-hidden":"true"}}),this.#a.style.display="none",this.#u=M(i,"span",{class:`${I}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const r=M(i,"button",{class:`${I}__nav ${I}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),o=M(i,"button",{class:`${I}__nav ${I}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=M(i,"button",{class:`${I}__toggle ${I}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=M(i,"button",{class:`${I}__toggle ${I}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#h=M(i,"select",{class:`${I}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const c=M(i,"button",{class:`${I}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),a=M(i,"div",{class:`${I}__options`,children:[this.#c,this.#d,this.#h]});for(const h of[this.#s,this.#l,this.#a,this.#u,r,o,c,a])s.appendChild(h);this.#g.push($(this.#s,"input",()=>this.#O())),this.#g.push($(r,"click",()=>this.#e.find.prev())),this.#g.push($(o,"click",()=>this.#e.find.next())),this.#g.push($(this.#c,"click",()=>{this.#f=!this.#f,this.#c.setAttribute("aria-pressed",String(this.#f)),this.#E()})),this.#g.push($(this.#d,"click",()=>{this.#m=!this.#m,this.#d.setAttribute("aria-pressed",String(this.#m)),this.#E()})),this.#g.push($(this.#h,"change",()=>{const h=this.#h.value;this.#p=h?String(h):null,this.#E()})),this.#g.push($(c,"click",()=>this.hide()));const g=h=>{if(h.key==="Escape"){h.preventDefault(),h.stopPropagation(),this.hide();return}h.key==="Enter"&&h.target===this.#s&&(h.preventDefault(),h.stopPropagation(),this.#w!==null&&(this.#D(),this.#E()),h.shiftKey?this.#e.find.prev():this.#e.find.next())};return s.addEventListener("keydown",g),this.#g.push(()=>s.removeEventListener("keydown",g)),s.style.display="none",t.insertBefore(s,n.header||t.firstChild),this.#i=s,this.#j(),s}#j(){const n=this.#h;if(!n)return;const t=this.#n;for(;n.firstChild;)n.removeChild(n.firstChild);n.appendChild(M(t,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const i=this.#e.columns,s=i&&x(i.visible)?i.visible():[];let r=!1;for(const o of s){if(!o||o.id===void 0)continue;const c=String(o.id);n.appendChild(M(t,"option",{text:o.title||c,attrs:{value:c}})),c===this.#p&&(r=!0)}r||(this.#p=null),n.value=this.#p||""}#O(){const n=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):k;if(this.#D(),n===0||!x(this.#r.setTimeout)){this.#E();return}this.#w=this.#r.setTimeout(()=>{this.#w=null,this.#E()},n)}#E(){const n=this.#S();if(!n||this.#v)return;const t=this.#s?this.#s.value:"";if(!t){this.#M(),n.clear();return}n.begin(t,{caseSensitive:this.#f,wholeCell:this.#m,columns:this.#p?[this.#p]:null,from:this.#C()}),this.#T()}#C(){const n=this.#t&&this.#t.window,t=n&&Number.isFinite(n.first)?n.first:0;return Math.max(0,t)}#T(){if(this.#b!==null||this.#v)return;const n=()=>{this.#b=null,this.#x()};x(this.#r.requestAnimationFrame)?this.#b=this.#r.requestAnimationFrame(n):x(this.#r.setTimeout)?this.#b=this.#r.setTimeout(n,0):n()}#x(){const n=this.#S();!n||this.#v||!n.active||(n.stale&&n.rescan({from:this.#C()}),!n.complete&&(n.step(v)||this.#T()))}#N(){if(!this.#i||this.#v)return;const n=this.#e.find.count(),t=this.#S().active;let i="",s="idle";t&&(n.total===0?(i=n.complete?this.t("find.none"):this.t("find.searching"),s=n.complete?"none":"searching"):(i=this.t(n.complete?"find.count":"find.countPartial",{current:n.current,total:n.total}),s=n.complete?"matches":"searching")),this.#l.textContent=i,this.#i.setAttribute("data-state",s);const r=t&&n.windowed;this.#a.textContent=r?this.t("find.loadedRows"):"",this.#a.style.display=r?"":"none",t?n.complete&&(this.#u.textContent=n.total===0?this.t(r?"a11y.find.noneLoaded":"a11y.find.none"):this.t(r?"a11y.find.countLoaded":"a11y.find.count",{current:n.current,count:n.total})):this.#u.textContent=""}#D(){this.#w!==null&&x(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#w),this.#w=null}#M(){this.#b!==null&&(x(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#b):x(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#b),this.#b=null)}#I(){this.#D(),this.#M()}}const l=y}),Ae("packages/dom/src/redactpaint.js",function(e,G){"use strict";Object.defineProperty(e,"RedactionPainter",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return N}});const q="lat-cell--redacted",M="lat-cell";class ${#e;#t;#n=[];constructor(Z){this.#e=Z.grid,this.#t=Z.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.paint()}paint(){const Z=this.#t.viewport?.root;if(!Z||!Z.querySelectorAll)return;const V=this.#e.redaction;if(!V)return;const U=V.active;for(const x of Z.querySelectorAll(`.${M}[data-col]`))U&&V.has(x.getAttribute("data-col"))?x.classList.add(q):x.classList.contains(q)&&x.classList.remove(q)}destroy(){for(const Z of this.#n)Z();this.#n=[]}}const N=$}),Ae("packages/dom/src/validationpaint.js",function(e,G){"use strict";Object.defineProperty(e,"ValidationPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const M=G("packages/dom/src/editors/common.js").markInvalid,$="lat-cell";function N(V,U){let x=V;for(;x;){if(U(x))return x;x=x.parentNode}return null}class W{#e;#t;#n=[];constructor(U){this.#e=U.grid,this.#t=U.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint()));for(const U of["validation:failed","validation:cleared","cell:changed"])this.#n.push(this.#e.on(U,()=>this.paint()));this.paint()}#r(U){const x=N(U,I=>I.getAttribute&&I.getAttribute("data-key")!==null);return x?x.getAttribute("data-key"):null}paint(){const U=this.#e.validation;if(!U||!U.active)return;const x=this.#t.viewport?.root;if(!(!x||!x.querySelectorAll))for(const I of x.querySelectorAll(`.${$}[data-col]`)){const v=I.getAttribute("data-col"),k=this.#r(I),y=k?U.errorFor(k,v):null;M(I,y?y.message:null)}}destroy(){for(const U of this.#n)U();this.#n=[]}}const Z=W}),Ae("packages/dom/src/presentation.js",function(e,G){"use strict";Object.defineProperty(e,"CHROME",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"PresentationController",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const M=G("packages/core/src/internal/util.js").isFunction,N=G("packages/dom/src/renderer/textentry.js").isTextEntry,Z=G("packages/dom/src/renderer/viewport.js").CLASS,V="lat-presenting",U="lat-presenting--changing",x="lat-presenting__progress",I="lat-cell--dimmed",v=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class k{#e;#t;#n;#r=[];#o=null;#i=null;#s=null;constructor(u){this.#e=u.grid,this.#t=u.renderer,this.#n=u.maximiser||null}mount(){this.#r.push(this.#e.on("presentation:started",()=>this.#d())),this.#r.push(this.#e.on("presentation:changed",()=>this.#f())),this.#r.push(this.#e.on("presentation:scale",()=>this.#f())),this.#r.push(this.#e.on("presentation:ended",()=>this.#h())),this.#r.push(this.#e.on("presentation:view",n=>this.#a(n))),this.#r.push(this.#e.on("presentation:spotlight",()=>this.#m())),this.#r.push(this.#e.on("render:done",()=>this.#m())),this.#n&&M(this.#n.watch)&&this.#r.push(this.#n.watch(n=>{n||!this.#o||this.#o.maximised||this.#e.presentation?.active&&this.#e.presentation.stop()}));const u=this.#t.viewport?.root;if(u&&M(u.addEventListener)){const n=t=>this.#l(t);u.addEventListener("keydown",n),this.#r.push(()=>u.removeEventListener("keydown",n))}}#l(u){const n=this.#e.presentation;if(!n?.active)return;const t=u.ctrlKey||u.metaKey,i=u.key;if(i==="Escape"&&!this.#n){u.defaultPrevented||(n.stop(),u.preventDefault?.());return}if(t){i==="="||i==="+"?(n.nudge(1),u.preventDefault?.()):i==="-"||i==="_"?(n.nudge(-1),u.preventDefault?.()):i==="0"&&(n.setScale(1.5),u.preventDefault?.());return}if(!n.views.length||N(u.target))return;i==="ArrowRight"||i==="ArrowDown"||i==="PageDown"||i===" "?(n.step(1),u.preventDefault?.()):i==="ArrowLeft"||i==="ArrowUp"||i==="PageUp"?(n.step(-1),u.preventDefault?.()):i==="Home"?(n.goTo(0),u.preventDefault?.()):i==="End"?(n.goTo(n.views.length-1),u.preventDefault?.()):(i==="r"||i==="R")&&(n.reset(),u.preventDefault?.())}#a(u){!u||!u.viewId||(this.#u(),this.#e.views?.apply?.(u.viewId),this.#c(u))}#u(){const u=this.#t.viewport?.root;u?.classList&&(u.classList.remove(U),u.offsetWidth,u.classList.add(U))}#c(u){const n=this.#t.viewport?.overlays;if(!n||!this.#e.presentation.views.length)return;const t=n.ownerDocument;if(!t?.createElement)return;if(!this.#i){const r=t.createElement("div");r.className=x,r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),n.appendChild(r),this.#i=r}const i=this.#e.views?.get?.(u.viewId),s=i&&i.name?i.name:"";this.#i.textContent=s?`${s} · ${(u.index||0)+1} / ${u.count||0}`:`${(u.index||0)+1} / ${u.count||0}`}#d(){if(this.#o){this.#f();return}const u=!!(this.#n&&this.#n.active());this.#n&&!u&&this.#n.enter();const n=new Set(this.#e.presentation?.options?.chrome||[]),t=[];for(const s of v){if(n.has(s)||s==="toolPanel"&&this.#v())continue;const r=this.#y(s);r&&r.style&&r.style.display!=="none"&&(r.style.display="none",t.push(r))}const i=this.#w();i&&i.style&&i.style.display!=="none"&&this.#b(i)&&(i.style.display="none",t.push(i)),this.#o={maximised:u,hidden:t},this.#t.viewport?.root?.classList?.add(V),this.#f(),this.#p()}#h(){const u=this.#o;this.#o=null;const n=this.#t.viewport?.root;if(n?.classList?.remove(V),n?.style?.removeProperty("--lattice-presentation-scale"),this.#g(),this.#i&&(this.#i.remove?.(),this.#i=null),n?.classList?.remove(U),this.#m(),u){const t=this.#e.toolPanel;t&&M(t.presentRestore)&&t.presentRestore();for(const i of u.hidden)i.style.display="";this.#n&&!u.maximised&&this.#n.active()&&this.#n.exit()}this.#t.invalidate?.("theme")}#f(){const u=this.#t.viewport?.root;!u||!u.style||(u.style.setProperty("--lattice-presentation-scale",String(this.#e.presentation.scale)),this.#t.invalidate?.("theme"))}#m(){const u=this.#t.viewport?.root;if(!u?.querySelectorAll)return;const n=this.#e.presentation?.active?this.#e.presentation.spotlight:null,t=n&&n.keys.length?new Set(n.keys):null,i=n&&n.colIds.length?new Set(n.colIds):null;for(const s of u.querySelectorAll("[data-key]")){const r=!t||t.has(s.getAttribute("data-key"));for(const o of s.querySelectorAll("[data-col]"))!n||r&&(!i||i.has(o.getAttribute("data-col")))?o.classList.remove(I):o.classList.add(I)}}#p(){this.#g();const u=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(u)||u<=0||!this.#e.presentation.views.length)return;const n=this.#t.viewport?.root?.ownerDocument?.defaultView;n?.setInterval&&(this.#s=n.setInterval(()=>{const t=this.#e.presentation;t.active&&t.goTo(t.index>=t.views.length-1?0:t.index+1)},Math.max(1e3,u)))}#g(){if(this.#s===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#s),this.#s=null}#w(){const u=this.#e.element;return!u||!M(u.querySelector)?null:u.querySelector(`.${Z.statusBar}`)}#b(u){const n=u.children||[];for(const t of n)if(!t.style||t.style.display!=="none")return!1;return!0}#v(){const u=this.#e.toolPanel;return!!(u&&M(u.presentOnly)&&u.presentOnly())}#y(u){const n=this.#e.element;if(!n||!M(n.querySelector))return null;const t={toolPanel:".lat-panel-dock",statusBar:".lat-statusbar",editBar:".lat-editor-bar",historyBar:".lat-history",pagination:".lat-pagination"}[u];return t?n.querySelector(t):null}destroy(){this.#o&&this.#h();for(const u of this.#r)u();this.#r=[]}}const y=k}),Ae("packages/dom/src/capture.js",function(e,G){"use strict";Object.defineProperty(e,"isSafeImageSource",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"captureElement",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const M=G("packages/core/src/internal/util.js").isFunction,$=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function N(x,I,v){const k=v.getComputedStyle(x),y=I.style;if(y)for(let l=0;l<k.length;l++){const u=k[l];$.has(u)||y.setProperty(u,k.getPropertyValue(u),k.getPropertyPriority(u))}}function W(x,I,v){if(N(x,I,v),x.tagName==="CANVAS"&&M(x.toDataURL))try{const l=x.toDataURL("image/png"),u=I.style;u&&(u.setProperty("background-image",`url(${l})`),u.setProperty("background-size","100% 100%"),u.setProperty("background-repeat","no-repeat"))}catch{}const k=x.children||[],y=I.children||[];for(let l=0;l<k.length&&l<y.length;l++)W(k[l],y[l],v)}function Z(x,I){if(!x||x.startsWith("data:")||x.startsWith("blob:"))return!0;try{return new URL(x,I).origin===I}catch{return!0}}async function V(x,I={}){const v=x.ownerDocument,k=v?.defaultView;if(!k||typeof k.getComputedStyle!="function")throw new Error("capture needs a browser document");const y=x.getBoundingClientRect(),l=Math.max(1,Math.ceil(y.width)),u=Math.max(1,Math.ceil(y.height)),n=Math.max(.1,Number(I.scale)||2),t=k.location?.origin||"";for(const g of x.querySelectorAll("img")){const h=g.getAttribute("src")||"";if(!Z(h,t))throw new Error(`capture refused: the image at ${h} is on another origin and would taint the canvas. Serve it same-origin, inline it as a data: URL, or hide the column.`)}const i=x.cloneNode(!0);W(x,i,k),i.style.width=`${l}px`,i.style.height=`${u}px`,i.style.margin="0";const s=new k.XMLSerializer().serializeToString(i),r=`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${u}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${s}</div></foreignObject></svg>`,o=new k.Image;await new Promise((g,h)=>{o.onload=()=>g(void 0),o.onerror=()=>h(new Error("capture failed to rasterise the grid; a host element inside it may not serialise as XML")),o.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(r)}`});const c=v.createElement("canvas");c.width=Math.round(l*n),c.height=Math.round(u*n);const a=c.getContext("2d");if(!a)throw new Error("capture could not get a 2d context");return a.fillStyle=I.background||k.getComputedStyle(x).backgroundColor||"#ffffff",a.fillRect(0,0,c.width,c.height),a.drawImage(o,0,0,c.width,c.height),new Promise((g,h)=>{c.toBlob(b=>b?g({blob:b,width:c.width,height:c.height}):h(new Error("capture produced no image")),I.type||"image/png",I.quality)})}const U=V}),Ae("packages/dom/src/annotate.js",function(e,G){"use strict";Object.defineProperty(e,"TOOLS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"MARK_TYPES",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});const q=G("packages/core/src/internal/util.js"),M=q.isFunction,$=q.warnOnce,W=G("packages/dom/src/renderer/direction.js").signedX,Z=Object.freeze(["pen","arrow","rect","highlight"]),V=Object.freeze(["freehand","arrow","rect","highlight","text"]),U=Object.freeze({freehand:"pen",pen:"pen",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),x=Object.freeze({pen:"freehand",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),I=14,v="system-ui, -apple-system, sans-serif";function k(r,o){if(!r||typeof r!="object")return null;const c=U[r.type];if(!c)return null;const a=Array.isArray(r.points)?r.points:[],g=[];for(const b of a){const p=Number(b&&b.x),f=Number(b&&b.y);Number.isFinite(p)&&Number.isFinite(f)&&g.push({x:p,y:f})}const h=typeof r.colour=="string"&&r.colour?r.colour:o;if(c==="text"){const b=typeof r.text=="string"?r.text:"";if(!g.length||!b)return null;const p={tool:c,colour:h,points:[g[0]],text:b,region:y(r.region)},f=Number(r.fontSize);return Number.isFinite(f)&&f>0&&(p.fontSize=f),typeof r.background=="string"&&r.background&&(p.background=r.background),p}return g.length<2?null:{tool:c,colour:h,points:g,region:y(r.region)}}function y(r){return r==="start"||r==="end"?r:"centre"}function l(r){const o={type:x[r.tool]||r.tool,colour:r.colour,points:r.points.map(c=>({x:c.x,y:c.y}))};return(r.region==="start"||r.region==="end")&&(o.region=r.region),r.tool==="text"&&(o.text=r.text,r.fontSize!==void 0&&(o.fontSize=r.fontSize),r.background!==void 0&&(o.background=r.background)),o}const u="lat-annotate",n=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(r){return r==="arrow"||r==="rect"}class i{#e;#t;#n=null;#r=null;#o=null;#i="#e0245e";#s=[];#l=null;#a=[];#u=null;constructor(o){this.#e=o.grid,this.#t=o.renderer,this.#u=Array.isArray(o.seed)?o.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.#h()})),this.#c(),this.#d(),this.#u&&this.#u.length&&this.replaceAll(this.#u),this.#u=null}add(o){const c=k(o,this.#i);return c?(c.durable=!0,this.#s.push(c),this.#y(),this.redraw(),this.#j(),this.#s.length):($("annotate.add.invalid",`annotate.add ignored a mark: it needs a known \`type\` (${V.join(", ")}) and at least two finite {x, y} points in content coordinates.`),this.#s.length)}list(){return this.#s.map(l)}replaceAll(o){const c=Array.isArray(o)?o:[];this.#s=c.map(a=>k(a,this.#i)).filter(Boolean);for(const a of this.#s)a.durable=!0;this.#s.length&&this.#y(),this.redraw(),this.#j()}#c(){const o=this.#t.viewport?.root;if(!o||!M(o.addEventListener))return;const c=a=>{!this.#o||!a||a.key!=="Escape"||(this.use(null),a.preventDefault?.())};o.addEventListener("keydown",c,!0),this.#a.push(()=>o.removeEventListener("keydown",c,!0))}#d(){const o=this.#n?.ownerDocument?.defaultView||this.#t.viewport?.root?.ownerDocument?.defaultView;if(!o||!M(o.matchMedia))return;let c=null;const a=()=>{const g=o.devicePixelRatio||1;let h;try{h=o.matchMedia(`(resolution: ${g}dppx)`)}catch{return}c=h;const b=()=>{this.redraw(),a()};M(h.addEventListener)?h.addEventListener("change",b,{once:!0}):M(h.addListener)&&h.addListener(b)};a(),this.#a.push(()=>{c=null})}use(o,c={}){const a=!!c.colour&&o===this.#o;c.colour&&(this.#i=String(c.colour));const g=o&&Z.includes(o)?o:null;this.#o=g&&g===this.#o&&!a?null:g;const h=this.#o?this.#y():this.#n;return h&&(h.style.pointerEvents=this.#o?"auto":"none",h.style.cursor=this.#o?"crosshair":""),this.#j(),this.#o}undo(){return this.#s.pop(),this.redraw(),this.#j(),this.#s.length}clear(){this.#s.length&&(this.#s=[],this.redraw(),this.#j())}#h(){const o=this.#s.filter(c=>c.durable);o.length!==this.#s.length&&(this.#s=o,this.redraw(),this.#j())}redraw(){!this.#n&&this.#s.length&&this.#y();const o=this.#n,c=this.#r;if(!o||!c)return;this.#S();const{left:a,top:g}=this.#v();c.clearRect(0,0,o.width,o.height);const h=this.#l?[...this.#s,this.#l]:this.#s;for(const b of["centre","start","end"]){const p=h.filter(f=>y(f.region)===b);if(p.length){c.save(),this.#f(c,b),c.translate((b==="centre"?-a:0)||0,-g||0);for(const f of p)this.#w(c,f);c.restore()}}}#f(o,c="centre"){const a=this.#n,g=this.#t.viewport?.bodyViewport;if(!M(a?.getBoundingClientRect)||!M(g?.getBoundingClientRect))return;const h=a.getBoundingClientRect(),b=g.getBoundingClientRect();if(!b.width||!b.height)return;const p=this.#m(c,b);p&&(o.beginPath(),o.rect(p.left-h.left,b.top-h.top,p.width,b.height),o.clip())}#m(o,c){const a=w=>{if(!M(w?.getBoundingClientRect))return null;const S=w.getBoundingClientRect();return S&&S.width>0?{left:S.left,width:S.width}:null},g=a(this.#t.viewport?.bodyStart),h=a(this.#t.viewport?.bodyEnd);if(o==="start")return g;if(o==="end")return h;let b=c.left,p=c.left+c.width;const f=c.left+c.width/2;for(const w of[g,h]){if(!w)continue;const S=w.left+w.width;w.left+w.width/2<f?b=Math.max(b,S):p=Math.min(p,w.left)}return p>b?{left:b,width:p-b}:null}#p(o){for(const[c,a]of[["start",this.#t.viewport?.bodyStart],["end",this.#t.viewport?.bodyEnd]]){if(!M(a?.getBoundingClientRect))continue;const g=a.getBoundingClientRect();if(g&&g.width>0&&o>=g.left&&o<g.left+g.width)return c}return"centre"}#g(o){const c=this.#t.viewport?.bodyViewport;if(!M(c?.getBoundingClientRect))return!0;const a=c.getBoundingClientRect();return!a.width||!a.height?!0:o.clientX>=a.left&&o.clientX<=a.right&&o.clientY>=a.top&&o.clientY<=a.bottom}#w(o,c){const a=c.points;if(!a.length)return;const g=this.#e.presentation?.scale||1;o.lineWidth=(n[c.tool]||3)*g,o.strokeStyle=c.colour,o.fillStyle=c.colour,o.lineCap="round",o.lineJoin="round",o.globalAlpha=c.tool==="highlight"?.32:1;const h=a[0],b=a[a.length-1];if(c.tool==="text"){const p=(c.fontSize||I)*g;o.font=`${p}px ${v}`,o.textBaseline="top";const f=c.text||"";if(c.background){let w=f.length*p*.6;if(typeof o.measureText=="function"){const S=o.measureText(f);S&&Number.isFinite(S.width)&&(w=S.width)}o.fillStyle=c.background,o.fillRect(h.x-p*.15,h.y-p*.1,w+p*.3,p*1.2)}o.fillStyle=c.colour,o.fillText(f,h.x,h.y),o.globalAlpha=1;return}if(c.tool==="rect")o.strokeRect(h.x,h.y,b.x-h.x,b.y-h.y);else if(c.tool==="arrow")o.beginPath(),o.moveTo(h.x,h.y),o.lineTo(b.x,b.y),o.stroke(),this.#b(o,h,b,o.lineWidth);else{o.beginPath(),o.moveTo(h.x,h.y);for(let p=1;p<a.length;p++)o.lineTo(a[p].x,a[p].y);o.stroke()}o.globalAlpha=1}#b(o,c,a,g){const h=Math.atan2(a.y-c.y,a.x-c.x),b=Math.max(8,g*3);o.beginPath(),o.moveTo(a.x,a.y),o.lineTo(a.x-b*Math.cos(h-Math.PI/7),a.y-b*Math.sin(h-Math.PI/7)),o.lineTo(a.x-b*Math.cos(h+Math.PI/7),a.y-b*Math.sin(h+Math.PI/7)),o.closePath(),o.fill()}#v(){const o=M(this.#t.scrollPosition)?this.#t.scrollPosition():null,c=this.#t.viewport?.rtl===!0;return{left:W(o?.left||0,c),top:o?.top||0}}#y(){if(this.#n)return this.#n;const o=this.#t.viewport?.overlays,c=o?.ownerDocument;if(!o||!c?.createElement)return null;const a=c.createElement("canvas");return a.className=u,a.style.position="absolute",a.style.inset="0",a.style.pointerEvents="none",o.appendChild(a),this.#n=a,this.#r=a.getContext?a.getContext("2d"):null,this.#S(),this.#A(a),a}#S(){const o=this.#n,c=this.#t.viewport?.root;if(!o||!c?.getBoundingClientRect)return;const a=c.getBoundingClientRect(),h=o.ownerDocument?.defaultView?.devicePixelRatio||1,b=Math.max(1,Math.round(a.width*h)),p=Math.max(1,Math.round(a.height*h));o.width===b&&o.height===p||(o.width=b,o.height=p,o.style&&(o.style.width=`${Math.max(1,a.width)}px`,o.style.height=`${Math.max(1,a.height)}px`),this.#r?.setTransform(h,0,0,h,0,0))}#A(o){const c=(p,f="centre")=>{const w=o.getBoundingClientRect(),{left:S,top:m}=this.#v();return{x:p.clientX-w.left+(f==="centre"?S:0),y:p.clientY-w.top+m}},a=p=>{if(!this.#o||!this.#g(p))return;const f=this.#p(p.clientX);this.#l={tool:this.#o,colour:this.#i,points:[c(p,f)],region:f},o.setPointerCapture?.(p.pointerId),p.preventDefault?.()},g=p=>{if(!this.#l)return;const f=c(p,this.#l.region);t(this.#l.tool)&&this.#l.points.length>1&&this.#l.points.pop(),this.#l.points.push(f),this.redraw()},h=p=>{this.#l&&(this.#l.points.length>1&&this.#s.push(this.#l),this.#l=null,o.releasePointerCapture?.(p.pointerId),this.redraw(),this.#j())},b=p=>{if(!this.#o)return;const f=this.#t.viewport?.bodyViewport;if(!f)return;let w=!1;p.deltaY&&typeof f.scrollTop=="number"&&(f.scrollTop+=p.deltaY,w=!0),p.deltaX&&typeof f.scrollLeft=="number"&&(f.scrollLeft+=p.deltaX,w=!0),w&&p.preventDefault?.()};o.addEventListener("pointerdown",a),o.addEventListener("pointermove",g),o.addEventListener("pointerup",h),o.addEventListener("pointercancel",h),o.addEventListener("wheel",b,{passive:!1}),this.#a.push(()=>{o.removeEventListener("pointerdown",a),o.removeEventListener("pointermove",g),o.removeEventListener("pointerup",h),o.removeEventListener("pointercancel",h),o.removeEventListener("wheel",b)})}#j(){this.#e.emit?.("annotation:changed",{tool:this.#o,count:this.#s.length},"user")}destroy(){for(const o of this.#a)o();this.#a=[],this.#n?.remove?.(),this.#n=null,this.#r=null,this.#s=[]}}const s=i}),Ae("packages/dom/src/timelinebar.js",function(e,G){"use strict";Object.defineProperty(e,"agoLabel",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"clockLabel",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"TimelineBar",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return x}});const M=G("packages/core/src/internal/util.js").isFunction,N=G("packages/core/src/i18n/index.js").defaultMessages,W="lat-timeline";function Z(I){if(!Number.isFinite(I)||I<1e3)return"now";const v=Math.round(I/1e3);if(v<60)return`${v}s ago`;const k=Math.round(v/60);return k<60?`${k}m ago`:`${Math.round(k/60)}h ago`}function V(I,v){return Number.isFinite(I)?new Date(I).toLocaleTimeString(v||void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}class U{#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,k=v.depth,y=v.position;this.#r.max=String(Math.max(1,k)),this.#r.value=String(Math.max(0,k-y)),this.#r.disabled=k===0;const l=v.at(),u=v.live;this.#o&&(this.#o.textContent=u?this.#l("timeline.live"):Z(Date.now()-(l||Date.now())),this.#o.setAttribute("data-live",u?"true":"false")),this.#i&&(this.#i.textContent=k===0?this.#l("timeline.recording"):V(l,this.#e.get("locale"))),this.#n.setAttribute("data-live",u?"true":"false")}#l(v,k){const y=this.#e;return(y&&y.messages?y.messages:N).t(v,k)}#a(){if(this.#n)return;const v=this.#t.viewport?.overlays,k=v?.ownerDocument;if(!v||!k?.createElement)return;const y=k.createElement("div");y.className=W;const l=k.createElement("span");l.className=`${W}__ago`,l.setAttribute("role","status"),l.setAttribute("aria-live","polite");const u=k.createElement("input");u.className=`${W}__range`,u.type="range",u.min="0",u.step="1",u.setAttribute("aria-label",this.#l("timeline.scrub"));const n=k.createElement("span");n.className=`${W}__clock`;const t=k.createElement("button");t.className=`${W}__live`,t.type="button",t.textContent=this.#l("timeline.goLive"),t.setAttribute("aria-label",this.#l("timeline.returnToPresent")),y.appendChild(l),y.appendChild(u),y.appendChild(n),y.appendChild(t),v.appendChild(y),this.#n=y,this.#r=u,this.#o=l,this.#i=n;const i=()=>{const o=this.#e.timeline.depth;this.#e.timeline.seek(o-Number(u.value))};u.addEventListener("input",i);const s=()=>this.#e.timeline.toLive();t.addEventListener("click",s);const r=o=>o.stopPropagation();u.addEventListener("keydown",r),this.#s.push(()=>{u.removeEventListener("input",i),t.removeEventListener("click",s),u.removeEventListener("keydown",r)})}#u(){this.#n&&(M(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 x=U}),Ae("packages/dom/src/commentpaint.js",function(e,G){"use strict";Object.defineProperty(e,"CommentPainter",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const M=G("packages/core/src/internal/util.js").isFunction,N=G("packages/core/src/i18n/index.js").defaultMessages,Z=G("packages/dom/src/renderer/direction.js").isRtlElement,V="lat-comment-mark",U="lat-cell--commented",x="lat-cell--commented-open";class I{#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 u=[];for(const n of l.querySelectorAll("[data-key]")){const t=n.getAttribute("data-key");if(t){u.push(t);for(const i of n.querySelectorAll("[data-col]")){const s=i.getAttribute("data-col"),r=y.at(t,s),o=!!(r&&r.count);i.classList.toggle(U,o),i.classList.toggle(x,o&&r.unresolved>0),this.#i(i,r,s)}}}(u.length!==this.#r.length||u.some((n,t)=>n!==this.#r[t]))&&(this.#r=u,y.request(u))}#o(y,l){const u=this.#e;return(u&&u.messages?u.messages:N).t(y,l)}#i(y,l,u){if(!l||!l.count){y.hasAttribute("aria-description")&&y.removeAttribute("aria-description");return}const n=l.count,t=l.unresolved,i=this.#o("count.comments",{count:n});y.setAttribute("aria-description",t>0?this.#o("comments.someUnresolved",{comments:i,unresolved:t}):this.#o("comments.allResolved",{comments:i}))}#s(){const y=this.#t.viewport?.root;if(!y||!M(y.addEventListener))return;const l=n=>{const t=this.#e.comments;if(!t||!t.enabled)return;const i=n.target&&M(n.target.closest)?n.target.closest("[data-col]"):null;if(!i||!i.classList.contains(U)||!this.#l(i,n))return;const s=i.closest("[data-key]"),r=s&&s.getAttribute("data-key");r&&(n.stopPropagation(),n.preventDefault(),t.open(r,i.getAttribute("data-col")))},u=n=>{const t=this.#e.comments;if(!t||!t.enabled||!n.altKey||n.key!=="m"&&n.key!=="M")return;const i=this.#t.viewport?.root?.querySelector?.("[data-col].lat-cell--focus")||(typeof document<"u"&&document.activeElement&&M(document.activeElement.closest)?document.activeElement.closest("[data-col]"):null);if(!i)return;const s=i.closest("[data-key]"),r=s&&s.getAttribute("data-key");r&&(n.preventDefault(),n.stopPropagation(),t.open(r,i.getAttribute("data-col")))};y.addEventListener("click",l,!0),y.addEventListener("keydown",u,!0),this.#n.push(()=>{y.removeEventListener("click",l,!0),y.removeEventListener("keydown",u,!0)})}#l(y,l){if(!M(y.getBoundingClientRect))return!1;const u=y.getBoundingClientRect(),n=Math.max(14,Math.min(24,u.height*.6));return(Z(y)?l.clientX<=u.left+n:l.clientX>=u.right-n)&&l.clientY<=u.top+n}destroy(){for(const y of this.#n)y();this.#n=[]}}const v=I}),Ae("packages/dom/src/presencepaint.js",function(e,G){"use strict";Object.defineProperty(e,"PresencePainter",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const M=G("packages/core/src/internal/util.js").isFunction,N=G("packages/core/src/i18n/index.js").defaultMessages,Z=G("packages/dom/src/editors/common.js").cssEscape,U=G("packages/core/src/model/presence.js").CURSOR_LABEL_MS,x="lat-presence";class I{#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,u=>this.#l(l,u)));this.#a(),this.paint()}}#l(y,l){if(this.#h(),y==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const n=l&&l.peer;n&&(this.#r.textContent=this.#f(y==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:n.name}))}#a(){const y=this.#t.viewport?.overlays,l=y?.ownerDocument;if(!y||!l?.createElement)return;const u=this.#e.get("presence")||{},n=l.createElement("span");if(n.className=`${x}__live`,n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),y.appendChild(n),this.#r=n,u.roster===!1)return;const t=l.createElement("div");t.className=x,u.roster&&u.roster.side==="start"&&t.setAttribute("data-side","start"),t.style.pointerEvents="auto",y.appendChild(t),this.#n=t}paint(){const y=this.#e.presence,l=this.#t.viewport?.root;if(!y||!y.enabled||!l?.querySelectorAll)return;this.#d(l);const u=y.peers(),n=[...u].sort((t,i)=>t.at-i.at);for(const t of n)for(const i of t.ranges||[])for(const s of i.rowIds||[])for(const r of i.columns||[])this.#c(l,s,r,t,"range");for(const t of n)t.cursor&&this.#c(l,t.cursor.rowId,t.cursor.colId,t,"cursor");for(const t of n)t.editing&&this.#c(l,t.editing.rowId,t.editing.colId,t,"edit");this.#h(),this.#u(u)}#u(y){if(this.#s!==null)return;const l=y.filter(t=>t.cursorFresh);if(!l.length)return;const n=Math.max(...l.map(t=>t.cursorAt||0))+U-Date.now();this.#s=setTimeout(()=>{this.#s=null,this.paint()},Math.max(50,n))}#c(y,l,u,n,t){const i=y.querySelector(`[data-key="${Z(l)}"]`),s=i&&i.querySelector(`[data-col="${Z(u)}"]`);s&&(s.setAttribute("data-presence",t),s.style.setProperty("--lat-peer",n.colour),s.setAttribute("data-peer-name",n.name),s.setAttribute("data-peer-initial",n.initials||(n.name||"?").slice(0,1).toUpperCase()),n.idle?s.setAttribute("data-peer-idle","true"):s.removeAttribute("data-peer-idle"),t==="cursor"&&n.cursorFresh&&s.setAttribute("data-peer-fresh","true"),this.#o.add(`${l}${u}`))}#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()}}#h(){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 n of l){const t=y.createElement("button");t.className=`${x}__peer`,t.type="button",t.style.setProperty("--lat-peer",n.colour),t.toggleAttribute("data-idle",!!n.idle),t.toggleAttribute("data-hidden",!!n.hidden);let i="presence.peer";n.hidden?i="presence.peerHidden":n.idle&&(i="presence.peerIdle"),t.setAttribute("aria-label",this.#f(i,{name:n.name}));const s=y.createElement("span");s.className=`${x}__dot`,s.setAttribute("aria-hidden","true"),s.textContent=n.initials||(n.name||"?").slice(0,1).toUpperCase(),t.appendChild(s);const r=y.createElement("span");r.className=`${x}__name`,r.textContent=n.name,t.appendChild(r),t.addEventListener("click",()=>this.#e.presence.jumpTo(n.id)),this.#n.appendChild(t)}const u=l.filter(n=>n.hidden).length;if(u){const n=y.createElement("span");n.className=`${x}__hidden`,n.textContent=this.#f("presence.hidden",{count:u}),this.#n.appendChild(n)}}announceRefusal(y){if(!this.#r)return;const l=y&&y.name?y.name:this.#f("presence.someoneElse");this.#r.textContent=this.#f("a11y.presence.refused",{name:l})}#f(y,l){const u=this.#e;return(u&&u.messages?u.messages:N).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&&M(this.#n.remove)&&this.#n.remove(),this.#r&&M(this.#r.remove)&&this.#r.remove(),this.#n=null,this.#r=null}}const v=I}),Ae("packages/dom/src/commentpanel.js",function(e,G){"use strict";Object.defineProperty(e,"relativeTime",{enumerable:!0,get:function(){return k}}),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 u}});const M=G("packages/core/src/internal/util.js").isFunction,N=G("packages/core/src/i18n/index.js").defaultMessages,Z=G("packages/dom/src/editors/common.js").cssEscape,U=G("packages/core/src/model/comments.js").parseCellKey,x="lat-comments",I=/^(https?:|mailto:)/i,v='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function k(n,t){if(!Number.isFinite(n))return"";const i=Math.max(0,Math.round((t-n)/1e3));if(i<60)return"just now";const s=Math.round(i/60);if(s<60)return`${s}m ago`;const r=Math.round(s/60);return r<24?`${r}h ago`:`${Math.round(r/24)}d ago`}function y(n,t,i,s){t.textContent="";const r=String(i??"");if(!s){t.textContent=r;return}const o=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let c=0,a=o.exec(r);for(;a;){a.index>c&&t.appendChild(n.createTextNode(r.slice(c,a.index)));const g=a[0];if(g.startsWith("*")){const h=n.createElement("em");h.textContent=g.slice(1,-1),t.appendChild(h)}else if(g.startsWith("`")){const h=n.createElement("code");h.textContent=g.slice(1,-1),t.appendChild(h)}else{const h=g.indexOf("]("),b=g.slice(1,h),p=g.slice(h+2,-1);if(I.test(p)){const f=n.createElement("a");f.href=p,f.textContent=b,f.rel="noopener noreferrer",f.target="_blank",t.appendChild(f)}else t.appendChild(n.createTextNode(b))}c=a.index+g.length,a=o.exec(r)}c<r.length&&t.appendChild(n.createTextNode(r.slice(c)))}class l{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=[];constructor(t){this.#e=t.grid,this.#t=t.renderer}mount(){this.#l.push(this.#e.on("comment:threadOpened",t=>this.#a(t))),this.#l.push(this.#e.on("comment:threadClosed",()=>this.#u())),this.#l.push(this.#e.on("render:done",()=>{this.#b(),this.#y()})),this.#l.push(this.#e.on("stream:evicted",()=>this.#c()))}#a(t){const i=this.#t.viewport?.root?.ownerDocument;i&&(this.#s=i.activeElement||null,this.#i=this.#h(t.rowId,t.field),this.#n||this.#m(i),this.#n.setAttribute("data-open","true"),this.#b(),this.#y(),this.#o&&M(this.#o.focus)&&this.#o.focus())}#u(){if(!this.#n)return;this.#n.removeAttribute("data-open"),this.#i=null;const t=this.#s;this.#s=null,t&&M(t.focus)&&t.focus()}#c(){const t=this.#e.comments.openKey;if(!t)return;const{rowId:i}=U(t);this.#e.rows.byKey(i)||(this.#d("This row is no longer in the grid: it scrolled out of the live window."),this.#e.comments.close({reason:"evicted"}))}#d(t){if(!this.#r)return;const s=this.#r.ownerDocument.createElement("p");s.className=`${x}__note`,s.setAttribute("role","status"),s.textContent=t,this.#r.appendChild(s)}#h(t,i){const s=this.#t.viewport?.root;if(!s||!s.querySelector)return null;const r=s.querySelector(`[data-key="${Z(t)}"]`);return r?r.querySelector(`[data-col="${i}"]`):null}#f(t,i){const s=this.#e;return(s&&s.messages?s.messages:N).t(t,i)}#m(t){const i=t.createElement("div");i.className=x,i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("aria-label",this.#f("comments.panel"));const s=t.createElement("header");s.className=`${x}__head`;const r=t.createElement("div");r.className=`${x}__title`,s.appendChild(r);const o=t.createElement("button");o.className=`${x}__resolve`,o.type="button",s.appendChild(o);const c=t.createElement("button");c.className=`${x}__close`,c.type="button",c.setAttribute("aria-label",this.#f("comments.close")),c.textContent="×",s.appendChild(c);const a=t.createElement("div");a.className=`${x}__list`,a.setAttribute("role","log"),a.setAttribute("aria-live","polite");const g=t.createElement("form");g.className=`${x}__composer`;const h=t.createElement("textarea");h.className=`${x}__input`,h.rows=2,h.setAttribute("aria-label",this.#f("comments.write"));const b=t.createElement("button");b.className=`${x}__send`,b.type="submit",b.textContent=this.#f("comments.post"),g.appendChild(h),g.appendChild(b),i.appendChild(s),i.appendChild(a),i.appendChild(g),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(i),this.#n=i,this.#r=a,this.#o=h,this.#p=r,this.#g=o;const p=m=>{m.preventDefault();const d=String(h.value||"").trim();d&&(h.value="",this.#e.comments.add(d))},f=()=>this.#e.comments.close(),w=()=>{this.#w()>0?this.#e.comments.resolve():this.#e.comments.unresolve()},S=m=>{if(m.stopPropagation(),m.key==="Escape"){m.preventDefault(),this.#e.comments.close();return}if(m.key!=="Tab")return;const d=[...i.querySelectorAll(v)].filter(T=>T.offsetParent!==null||T===h);if(!d.length)return;const j=d[0],E=d[d.length-1],O=i.ownerDocument.activeElement;m.shiftKey&&O===j?(m.preventDefault(),E.focus()):!m.shiftKey&&O===E&&(m.preventDefault(),j.focus())};g.addEventListener("submit",p),c.addEventListener("click",f),o.addEventListener("click",w),i.addEventListener("keydown",S),this.#l.push(()=>{g.removeEventListener("submit",p),c.removeEventListener("click",f),o.removeEventListener("click",w),i.removeEventListener("keydown",S)})}#p=null;#g=null;#w(){return(this.#e.comments.thread||[]).filter(i=>!i.resolved).length}#b(){const t=this.#e.comments;if(!this.#n||!t.openKey)return;const i=this.#n.ownerDocument,s=this.#e.get("comments")||{},r=Date.now(),o=t.openKey,{rowId:c,field:a}=U(o),g=this.#e.columns.get(a),h=this.#e.rows.byKey(c),b=M(s.rowLabel)&&h?s.rowLabel(h):c;if(this.#p.textContent=this.#f("comments.cellTitle",{column:g&&(g.title??g.id)||a,row:b}),this.#g.textContent=this.#w()>0?this.#f("comments.resolve"):this.#f("comments.reopen"),this.#r.textContent="",t.loading){this.#d(this.#f("comments.loading"));return}const p=t.thread||[];if(!p.length){this.#d(this.#f("comments.empty"));return}const f=h&&g?g.getValue(h.data,h):void 0;for(const w of p)this.#r.appendChild(this.#v(i,w,r,f,s))}#v(t,i,s,r,o){const c=t.createElement("article");c.className=`${x}__item`,i.pending&&c.setAttribute("data-pending","true"),i.resolved&&c.setAttribute("data-resolved","true");const a=t.createElement("div");a.className=`${x}__meta`;const g=t.createElement("span");g.className=`${x}__author`,g.textContent=i.author&&(i.author.name||i.author.initials)||this.#f("comments.unknownAuthor"),a.appendChild(g);const h=t.createElement("time");h.className=`${x}__time`;const b=k(i.at,s);h.textContent=i.edited?this.#f("comments.edited",{time:b}):b,a.appendChild(h),c.appendChild(a);const p=t.createElement("div");if(p.className=`${x}__body`,y(t,p,i.body,!!o.markdown),c.appendChild(p),i.value!==void 0&&!Object.is(i.value,r)){const S=t.createElement("p");S.className=`${x}__moved`,S.textContent=this.#f("comments.valueMoved",{was:String(i.value),now:String(r)}),c.appendChild(S)}const f=i.can||{},w=S=>f[S]!==!1;if(w("edit")||w("delete")){const S=t.createElement("div");if(S.className=`${x}__actions`,w("delete")){const m=t.createElement("button");m.type="button",m.className=`${x}__action`,m.textContent=this.#f("comments.delete"),m.addEventListener("click",()=>this.#e.comments.remove(i.id)),S.appendChild(m)}c.appendChild(S)}return c}#y(){if(!this.#n||!this.#e.comments.openKey)return;if((this.#e.get("comments")||{}).mode==="docked"){this.#n.setAttribute("data-docked","true");return}this.#n.removeAttribute("data-docked");const i=this.#e.comments.openKey,{rowId:s,field:r}=U(i),o=this.#h(s,r)||this.#i,c=this.#t.viewport?.root;if(!o||!c||!M(o.getBoundingClientRect))return;const a=o.getBoundingClientRect(),g=c.getBoundingClientRect(),h=this.#n.getBoundingClientRect();let b=a.bottom-g.top+4;b+h.height>g.height&&a.top-g.top>h.height&&(b=a.top-g.top-h.height-4);let p=a.left-g.left;p+h.width>g.width&&(p=Math.max(0,g.width-h.width-4)),this.#n.style.top=`${Math.max(0,b)}px`,this.#n.style.left=`${Math.max(0,p)}px`;const f=a.bottom<g.top||a.top>g.bottom;this.#n.toggleAttribute("data-offscreen",f)}destroy(){for(const t of this.#l)t();this.#l=[],this.#n&&M(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const u=l}),Ae("packages/dom/src/watermark.js",function(e,G){"use strict";Object.defineProperty(e,"WATERMARK_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"Watermark",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const M=G("packages/core/src/internal/util.js").isFunction,N=G("packages/core/src/i18n/index.js").defaultMessages,W=G("packages/dom/src/editors/common.js"),Z=W.el,V=W.on,U="lat-watermark",x="https://www.latticegrid.dev",I=["br","bl","tl","tr"],v=4e3;class k{#e;#t;#n;#r=null;#o=[];#i;#s=0;#l=null;constructor(u){this.#e=u.grid,this.#t=u.document,this.#n=u.element,this.#i=u.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),M(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const u=this.#e.licence&&this.#e.licence.ready;u&&M(u.then)&&u.then(()=>this.refresh(),()=>this.refresh())}refresh(){const u=this.#d();u&&!this.#r?(this.#h(),this.#u()):!u&&this.#r&&(this.#f(),this.#c())}#a(){const u=this.#i;if(!u||!M(u.matchMedia))return!1;try{return!!u.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),M(this.#i.setTimeout)&&(this.#a()||(this.#l=this.#i.setTimeout(()=>{if(this.#l=null,!this.#d()){this.#f();return}this.#s=(this.#s+1)%I.length,this.#f(),this.#h(),this.#u()},v)))}#c(){this.#l!==null&&M(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#l),this.#l=null}#d(){const u=this.#e.licence;return!!(u&&M(u.watermark)&&u.watermark())}#h(){const u=Z(this.#t,"a",{class:`${U}__link`,text:(this.grid&&this.grid.messages?this.grid.messages:N).t("licence.watermark"),attrs:{href:x,target:"_blank",rel:"noopener noreferrer"}});this.#r=Z(this.#t,"div",{class:`${U} ${U}--${I[this.#s]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[u]}),this.#o.push(V(this.#r,"pointerdown",n=>{M(n.stopPropagation)&&n.stopPropagation()})),this.#n&&M(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#f(){this.#r&&M(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c();for(const u of this.#o)u();this.#o=[],this.#f()}}const y=k}),Ae("packages/dom/src/maximise.js",function(e,G){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const q=G("packages/core/src/internal/util.js"),M=q.warnOnce,$=q.isFunction,N=G("packages/dom/src/editors/common.js"),W=N.el,Z=N.on,U=G("packages/dom/src/themeof.js").themeOf,x="lat-maximised",I={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",k="lat-maximise-placeholder";class y{#e;#t;#n;#r;#o;#i=null;#s=null;#l=new Set;#a=null;#u=!1;#c=null;constructor(n){this.#e=n.element,this.#t=n.document,this.#n=$(n.onChange)?n.onChange:null,this.#r=$(n.captureScroll)?n.captureScroll:null,this.#o=$(n.restoreScroll)?n.restoreScroll:null}active(){return this.#i!==null}enter(){if(this.active())return!0;const n=this.#e.parentNode;if(!n||!this.#t.body)return M("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=W(this.#t,"div",{class:k}),this.#i.style.visibility="hidden";const t=this.#e.offsetWidth,i=this.#e.offsetHeight;t&&(this.#i.style.width=`${t}px`),i&&(this.#i.style.height=`${i}px`);const s=this.#r?this.#r():null,r=$(this.#e.getAttribute)&&!this.#e.getAttribute("data-theme")?U(n):null;r&&(this.#e.setAttribute("data-theme",r),this.#u=!0),n.insertBefore(this.#i,this.#e),this.#d(()=>this.#t.body.appendChild(this.#e)),this.#a={};for(const[o,c]of Object.entries(I))this.#a[o]=this.#e.style[o]||"",this.#e.style[o]=c;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(x),this.#t.body.classList&&this.#t.body.classList.add(v),s&&this.#o&&this.#o(s),this.#s=Z(this.#t,"keydown",o=>this.#h(o)),this.#f(),!0}exit(){if(!this.active())return!1;const n=this.#r?this.#r():null,t=this.#i,i=t.parentNode;if(i&&$(i.insertBefore)&&this.#d(()=>i.insertBefore(this.#e,t)),$(t.remove)&&t.remove(),this.#i=null,this.#u&&(this.#e.removeAttribute("data-theme"),this.#u=!1),this.#a){for(const[s,r]of Object.entries(this.#a))this.#e.style[s]=r;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(x),this.#t.body&&this.#t.body.classList&&this.#t.body.classList.remove(v),n&&this.#o&&this.#o(n),this.#s&&this.#s(),this.#s=null,this.#f(),!0}toggle(){return this.active()?!this.exit():this.enter()}#d(n){const t=this.#t.activeElement,i=t&&t!==this.#t.body&&$(this.#e.contains)&&this.#e.contains(t)?t:null;n(),i&&$(i.focus)&&i.focus()}#h(n){!n||n.key!=="Escape"||n.defaultPrevented||this.exit()}#f(){this.#n&&this.#n();for(const n of this.#l)n(this.active())}watch(n){return $(n)?(this.#l.add(n),()=>this.#l.delete(n)):()=>{}}destroy(){this.exit()}}const l=y}),Ae("packages/dom/src/promptbar.js",function(e,G){"use strict";Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return i}});const q=G("packages/dom/src/editors/common.js"),M=q.documentFor,$=q.el,N=q.on,W=q.clear,V=G("packages/core/src/i18n/index.js").defaultMessages,x=G("packages/core/src/internal/util.js").isFunction,I=G("packages/core/src/ai/schema.js"),v=I.describeGrid,k=I.promptText,y=G("packages/core/src/ai/intent.js"),l=y.applyPlan,u=y.buildPrompt,n=y.planIntent,t="lat-prompt";class i{#e;#t=null;#n=null;#r={};#o;#i={};#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=null;#f=null;#m=null;#p=null;#g=null;#w="idle";#b=0;#v=!1;#y=[];t(c,a){return(this.messages&&typeof this.messages.t=="function"?this.messages:V).t(c,a)}init(c={}){this.messages=c&&c.messages||c&&c.grid&&c.grid.messages||V,this.#e=M(c),this.#t=c.grid||null,this.#n=x(c.ask)?c.ask:null,this.#r=c.schemaOptions||{},this.#o=c.context,this.#i={onPlan:x(c.onPlan)?c.onPlan:null,onApply:x(c.onApply)?c.onApply:null,onError:x(c.onError)?c.onError:null},this.#s=$(this.#e,"div",{class:t,attrs:{"data-state":"idle",role:"search"}}),this.#S(c)}element(){return this.#s}refresh(){this.#v||!this.#s||this.#w!=="busy"&&this.#E()}destroy(){this.#v=!0,this.#b++;for(const c of this.#y)c();this.#y.length=0,this.#g=null,this.#s=null,this.#l=null,this.#a=null,this.#u=null,this.#c=null,this.#d=null,this.#h=null,this.#f=null,this.#m=null,this.#p=null}plan(){return this.#g}async ask(c){if(this.#v||this.#w==="busy")return null;const a=String(c??(this.#l&&this.#l.value)??"").trim();if(!a)return null;if(!this.#n)return this.#T("No model is wired up. Supply `ai.ask` to use the prompt bar."),null;const g=++this.#b;this.#A("busy"),this.#C("Thinking…");let h;try{const b=v(this.#t,this.#r),p=k(b);if(h=await this.#n({prompt:a,schema:b,schemaText:p,message:u(a,p),context:this.#o}),this.#v||g!==this.#b)return null;const f=n(h,b);return this.#j(f),f}catch(b){return this.#v||g!==this.#b||(this.#i.onError&&this.#i.onError(b),this.#T(b instanceof Error?b.message:String(b))),null}}apply(){const c=this.#g;if(this.#v||!c||!c.ok)return null;const a=this.#t?.ai,g=x(a?.apply)?a.apply(c):l(c,this.#t);return this.#i.onApply&&this.#i.onApply(g,c),this.#E(),this.#l&&(this.#l.value=""),g.failed.length?this.#T(`Applied ${g.applied.length}; ${g.failed.map(h=>`${h.type} failed: ${h.reason}`).join("; ")}`):this.#C(`Applied: ${c.describe()}`),g}discard(){this.#v||(this.#E(),this.#C("Discarded."))}#S(c){const a=this.#e,g=$(a,"div",{class:`${t}__row`});this.#l=$(a,"input",{class:`${t}__input`,attrs:{type:"text",placeholder:c.placeholder||"Ask for a view: “EMEA deals over 50k, biggest first”","aria-label":c.label||"Ask about this grid",autocomplete:"off"}}),this.#y.push(N(this.#l,"keydown",b=>{const p=b&&b.key;p==="Enter"?(x(b.preventDefault)&&b.preventDefault(),this.ask()):p==="Escape"&&this.#g&&(x(b.preventDefault)&&b.preventDefault(),this.discard())})),g.appendChild(this.#l),this.#a=$(a,"button",{class:`${t}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#y.push(N(this.#a,"click",()=>{this.ask()})),g.appendChild(this.#a),this.#s.appendChild(g),this.#u=$(a,"div",{class:`${t}__preview`,attrs:{hidden:!0}}),this.#c=$(a,"p",{class:`${t}__summary`}),this.#d=$(a,"ul",{class:`${t}__notes`});const h=$(a,"div",{class:`${t}__buttons`});this.#h=$(a,"button",{class:`${t}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#f=$(a,"button",{class:`${t}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#y.push(N(this.#h,"click",()=>{this.apply()})),this.#y.push(N(this.#f,"click",()=>{this.discard()})),h.appendChild(this.#h),h.appendChild(this.#f),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(h),this.#s.appendChild(this.#u),this.#m=$(a,"p",{class:`${t}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#p=$(a,"p",{class:`${t}__error`,attrs:{role:"alert",hidden:!0}}),this.#s.appendChild(this.#m),this.#s.appendChild(this.#p)}#A(c){if(this.#w=c,!this.#s)return;this.#s.setAttribute("data-state",c);const a=c==="busy";s(this.#l,a),s(this.#a,a),this.#a&&(this.#a.textContent=this.t(a?"prompt.asking":"prompt.ask")),r(this.#u,c!=="preview"),r(this.#p,c!=="error")}#j(c){const a=c;if(this.#i.onPlan&&this.#i.onPlan(c),!a.ok){this.#g=null;const g=a.rejected.length?a.rejected.map(h=>h.reason).join("; "):"nothing to do";this.#T(`I could not turn that into a change: ${g}`);return}this.#g=c,this.#C(""),this.#c&&(this.#c.textContent=a.describe()),this.#O(a.rejected),this.#A("preview")}#O(c){const a=this.#d;if(a){W(a),r(a,!c.length);for(const g of c.slice(0,6))a.appendChild($(this.#e,"li",{class:`${t}__note`,text:g.reason}));c.length>6&&a.appendChild($(this.#e,"li",{class:`${t}__note`,text:this.t("prompt.moreNotes",{count:c.length-6})}))}}#E(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&W(this.#d),this.#A("idle")}#C(c){this.#m&&(this.#m.textContent=c)}#T(c){this.#g=null,this.#C(""),this.#p&&(this.#p.textContent=c),this.#A("error")}}function s(o,c){o&&(o.disabled=c,c?o.setAttribute("disabled",""):o.removeAttribute("disabled"))}function r(o,c){o&&(o.hidden=c,c?o.setAttribute("hidden",""):o.removeAttribute("hidden"))}}),Ae("packages/dom/src/stat.js",function(e,G){"use strict";Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"bandTone",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return c}});const q=G("packages/core/src/internal/util.js"),M=q.isFunction,$=q.isObject,N=q.warnOnce,Z=G("packages/core/src/source/derive.js").reduceValues,U=G("packages/core/src/source/memory.js").isPipelineSettle,I=G("packages/core/src/i18n/index.js").defaultMessages,k=G("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",u=new Set(["sum","min","max","avg","first","last","mode","median","p25","p75","p90","p95","p99","stddev","stddevP","mad","range","iqr","trimmedMean","winsorizedMean","geomean","harmean"]),n=Object.freeze({direction:"flat",change:null,percent:null});function t(p,f){if(!Number.isFinite(p)||!Number.isFinite(f))return n;const w=p-f,S=w>0?"up":w<0?"down":"flat",m=f===0?null:w/Math.abs(f)*100;return{direction:S,change:w,percent:m}}function i(p,f){return p==="flat"||f==="neither"?"flat":p===f?"good":"bad"}function s(p,f,w=null){if(M(f)){const O=f(p,w);return O==="good"||O==="warn"||O==="bad"?O:null}if(!$(f))return null;const S=typeof p=="number"&&Number.isFinite(p)?p:null;if(S===null)return null;const m=Number.isFinite(Number(f.good))?Number(f.good):null,d=Number.isFinite(Number(f.warn))?Number(f.warn):null,j=String(f.direction||"up")==="down",E=O=>j?S<=O:S>=O;return m!==null&&E(m)?"good":d!==null&&E(d)?"warn":m===null&&d===null?null:"bad"}function r(p){return!(M(p.value)||p.value!==void 0&&!$(p.value))}function o(p){return!p||!p.rows||!M(p.rows.totalCount)?!0:p.rows.totalCount()>0}function c(p){const f=$(p)?p:{},w=f.grid||null,S=h(f.container,w);if(!S)return N("stat.container","createStat needs a `container`: an element or a selector."),b();const m=S.ownerDocument||(typeof document>"u"?null:document);if(!m)return N("stat.document","createStat needs a document; it draws DOM."),b();const d=m.createElement("div");d.className=["lattice",y.root,f.class].filter(Boolean).join(" "),d.setAttribute("role","group");const j=m.createElement("div");j.className=y.title;const E=m.createElement("div");E.className=y.value;const O=m.createElement("div");O.className=y.interval;const T=m.createElement("div");T.className=y.delta;const A=m.createElement("div");A.className=y.footer;const P=m.createElement("div");if(P.className=y.note,P.hidden=!0,f.icon!=null&&f.icon!==""){const te=m.createElement("span");te.className=y.icon,te.setAttribute("aria-hidden","true"),k(te,f.icon,`stat:${f.title||"stat"}`),d.appendChild(te);const ee=m.createElement("div");ee.className=y.body,ee.appendChild(j),ee.appendChild(E),ee.appendChild(P),ee.appendChild(O),ee.appendChild(T),ee.appendChild(A),d.appendChild(ee)}else d.appendChild(j),d.appendChild(E),d.appendChild(P),d.appendChild(O),d.appendChild(T),d.appendChild(A);S.appendChild(d);let z=null;const H=[];let D=!1;function F(){if(M(f.value))return f.value(w);if(f.value!==void 0&&!$(f.value))return f.value;const te=$(f.value)?f.value:f,ee=te.of,oe=te.fn||"sum",re=te.show;return w?oe==="count"?B().length:ee?re?_(String(ee),String(oe),String(re)):C()==="filtered"&&w.statistics&&M(w.statistics.reduce)?w.statistics.reduce(String(ee),String(oe)):Z(B().map(le=>g(le,String(ee))),String(oe)):null:null}function C(){return String(f.scope||"filtered")}function B(){if(!w||!w.rows)return[];const te=C();if(te==="all"){const oe=[];return M(w.rows.forEachAll)&&w.rows.forEachAll(re=>{re.group||oe.push(a(re))}),oe}if(te==="selected")return(w.selection&&M(w.selection.rows)?w.selection.rows():[]).filter(Boolean).map(a);const ee=[];return M(w.rows.forEach)&&w.rows.forEach(oe=>{oe.group||ee.push(a(oe))}),ee}function _(te,ee,oe){if(ee!=="min"&&ee!=="max")return N(`stat.show.${ee}`,`\`show\` needs \`fn: 'min'\` or \`fn: 'max'\`: "${ee}" reduces to a value that no single row holds, so there is no row to report from.`),null;let re=null,le=null;for(const ne of B()){const se=Number(g(ne,te));Number.isFinite(se)&&(re===null||(ee==="max"?se>re:se<re))&&(re=se,le=ne)}return le===null?null:g(le,oe)}function Q(te){if(M(f.format))return String(f.format(te,w));if(te==null)return f.empty??"—";const ee=$(f.value)?f.value:f,oe=ee.show||ee.of;if((ee.show?!0:u.has(String(ee.fn||"sum")))&&w&&oe&&M(w.columns?.get)){const le=w.columns.get(String(oe));if(le&&M(le.formatValue))return le.formatValue(te)}return typeof te=="number"?Number.isInteger(te)?String(te):te.toFixed(f.decimals??2):String(te)}function Y(te){return te?(w&&w.messages||I).t(`stat.tone.${te}`):""}function J(){if(D)return;const te=F(),ee=r(f)&&!!w&&!o(w),oe=ee?null:te,re=M(f.baseline)?f.baseline(w):f.baseline;z=oe,j.textContent=f.title??"",j.hidden=!f.title,E.textContent=Q(oe),P.hidden=!ee,ee&&(P.textContent=w.messages.t("stat.noData"));const le=ee||re===void 0||re===null?n:t(typeof oe=="number"?oe:null,Number(re)),ne=i(le.direction,f.goodWhen||"up");if(T.hidden=le.change===null,le.change!==null){const me=le.direction==="up"?"↑":le.direction==="down"?"↓":"→",Pe=le.percent===null?Q(Math.abs(le.change)):`${Math.abs(le.percent).toFixed(1)}%`;T.textContent=`${me} ${Pe}`,T.setAttribute("data-tone",ne),T.setAttribute("data-direction",le.direction)}const se=M(f.interval)?f.interval(oe,w):null,ae=!!se&&Number.isFinite(se.lower)&&Number.isFinite(se.upper);O.hidden=!ae,ae&&(O.textContent=`${Q(se.lower)} – ${Q(se.upper)}`,Number.isFinite(se.confidence)&&O.setAttribute("title",`${Math.round(se.confidence*100)}%`));const de=ee?l:f.bands?s(oe,f.bands,w):null;de?d.setAttribute("data-tone",de):d.removeAttribute("data-tone"),A.textContent=M(f.footer)?String(f.footer(oe,w)):f.footer??"",A.hidden=!A.textContent,d.setAttribute("aria-label",[f.title,E.textContent,ee?P.textContent:"",ae?O.textContent:"",le.change===null?"":T.textContent,le.change===null?"":Y(ne),A.textContent].filter(Boolean).join(", "))}if(w&&M(w.on)&&f.live!==!1)for(const te of["rows:changed","filter:changed","selection:changed","model:changed"]){const ee=oe=>{te==="model:changed"&&!U(oe)||J()};w.on(te,ee),H.push(()=>M(w.off)&&w.off(te,ee))}return J(),{element:()=>d,value:()=>z,refresh:J,destroy(){D=!0;for(const te of H)try{te()}catch{}H.length=0,d.remove()}}}function a(p){return $(p)&&"data"in p?p.data:p}function g(p,f){if(!$(p))return;if(!f.includes("."))return p[f];let w=p;for(const S of f.split(".")){if(!$(w))return;w=w[S]}return w}function h(p,f){if(p&&typeof p=="object")return p;if(typeof p!="string")return null;const w=f&&f.element&&f.element.ownerDocument||(typeof document>"u"?null:document);return w?w.querySelector(p):null}function b(){return{element:()=>null,value:()=>null,refresh(){},destroy(){}}}}),Ae("packages/dom/src/kpistrip.js",function(e,G){"use strict";Object.defineProperty(e,"KpiStrip",{enumerable:!0,get:function(){return Z}});const M=G("packages/core/src/internal/util.js").isObject,N=G("packages/dom/src/stat.js").createStat,W={band:"lat-kpi-strip"};class Z{#e;#t;#n;#r=null;#o=[];constructor({grid:U,document:x,kpis:I}){this.#e=U,this.#t=x,this.#n=Array.isArray(I)?I.filter(M):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const x=this.#t.createElement("div");x.className=`lattice ${W.band}`,x.setAttribute("role","group"),x.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=x;for(const I of this.#n){const v=N({...I,grid:this.#e,container:x});this.#o.push(v)}}destroy(){for(const U of this.#o)try{U.destroy()}catch{}this.#o.length=0,this.#r&&(this.#r.remove(),this.#r=null)}}}),Ae("packages/dom/src/createGrid.js",function(e,G){"use strict";Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return kt}});const M=G("packages/core/src/index.js").createHeadlessGrid,N=G("packages/core/src/defaults.js").applyDefaults,Z=G("packages/core/src/export/download.js").downloadBlob,V=G("packages/core/src/internal/util.js"),U=V.fail,x=V.isFunction,I=V.warnOnce,k=G("packages/dom/src/localviews.js").createLocalViewStorage,l=G("packages/dom/src/renderer/index.js").DomRenderer,n=G("packages/dom/src/cell/index.js").createCellLayer,t=G("packages/dom/src/cell/icons.js"),i=t.icon,s=t.iconNames,o=G("packages/dom/src/editors/index.js").editors,a=G("packages/dom/src/filters/index.js").filters,g=G("packages/dom/src/ui/index.js"),h=g.StatusBar,b=g.TooltipManager,p=g.Pagination,f=g.GroupByZone,S=G("packages/dom/src/ui/celltooltip.js").CellTooltips,d=G("packages/dom/src/filtermenu.js").FilterMenu,E=G("packages/dom/src/columnmenu.js").ColumnMenu,T=G("packages/dom/src/shortcutshelp.js").ShortcutsHelp,P=G("packages/dom/src/rowreorder.js").RowReorder,z=G("packages/dom/src/alignedgrids.js").AlignedGrids,D=G("packages/dom/src/columntagbar.js").ColumnTagBar,C=G("packages/dom/src/anomalychip.js").AnomalyChip,_=G("packages/dom/src/rowform.js").RowForm,Q=G("packages/dom/src/toolpanelmount.js"),Y=Q.ToolPanelDock,J=Q.panelHost,ee=G("packages/dom/src/celledit.js").CellEditController,re=G("packages/dom/src/editbar.js").EditBar,ne=G("packages/dom/src/rangeselect.js").RangeController,ae=G("packages/core/src/model/selection.js").resolveSelectionConfig,me=G("packages/dom/src/importer.js").ImportController,Ie=G("packages/dom/src/historybar.js").HistoryBar,be=G("packages/dom/src/diffpaint.js").DiffPainter,Ee=G("packages/dom/src/detailhost.js").DetailHost,ze=G("packages/dom/src/highlightpaint.js").HighlightPainter,Xe=G("packages/dom/src/findpaint.js").FindPainter,Ce=G("packages/dom/src/findbar.js").FindBar,He=G("packages/dom/src/redactpaint.js").RedactionPainter,ot=G("packages/dom/src/validationpaint.js").ValidationPainter,yt=G("packages/dom/src/presentation.js").PresentationController,Et=G("packages/dom/src/capture.js").captureElement,xt=G("packages/dom/src/annotate.js").AnnotationLayer,Yt=G("packages/dom/src/timelinebar.js").TimelineBar,fe=G("packages/dom/src/commentpaint.js").CommentPainter,De=G("packages/dom/src/presencepaint.js").PresencePainter,qe=G("packages/dom/src/commentpanel.js").CommentPanel,pt=G("packages/dom/src/watermark.js").Watermark,je=G("packages/dom/src/maximise.js").Maximiser,Ne=G("packages/dom/src/promptbar.js").PromptBar,Se=G("packages/dom/src/kpistrip.js").KpiStrip;function Me(Le,nt,Je){const rt=nt==="redo"?"toolbar.redo":"toolbar.undo";return!Je||!Je.label?Le(rt):Le(nt==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:Je.label})}const Te=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],Re=2e3;function Be(Le,nt,Je){const rt=nt.annotate===!0?We(Le):[];if(nt.actions===!1)return[];if(nt.actions===void 0&&nt.side!=="left")return rt;const Ct=Array.isArray(nt.actions)?nt.actions:Te,Mt=(St,Vt)=>Le.messages.t(St,Vt),ct={undo:{name:"undo",title:()=>Me(Mt,"undo",Le.history.peek("undo")),icon:"undo",run:()=>Le.history.undo(),enabled:()=>Le.history.canUndo()},redo:{name:"redo",title:()=>Me(Mt,"redo",Le.history.peek("redo")),icon:"redo",run:()=>Le.history.redo(),enabled:()=>Le.history.canRedo()},export:{name:"export",title:()=>Mt("toolbar.exportCsv"),icon:"download",run:()=>Le.export.csv({download:!0,fileName:nt.exportName})},excel:{name:"excel",title:()=>Mt("toolbar.exportExcel"),icon:"spreadsheet",run:()=>Le.export.excel({download:!0,fileName:nt.exportName})},clipboard:{name:"clipboard",title:()=>Mt("toolbar.clipboard"),icon:"copy",run:()=>Le.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>Mt("toolbar.print"),icon:"print",run:()=>Le.export.print()},pause:{name:"pause",title:()=>{if(!Le.updates.paused)return Mt("toolbar.pause");const St=Le.updates.stats().pending;return St?Mt("toolbar.applyHeld",{count:St}):Mt("toolbar.resume")},icon:()=>Le.updates.paused?"play":"pause",run:()=>Le.updates.paused?Le.updates.resume():Le.updates.pause()},restore:{name:"restore",title:()=>Mt("toolbar.restoreView"),icon:"restore",run:()=>Le.state.reset(),enabled:()=>Le.state.modified()},maximise:{name:"maximise",title:()=>Mt(Je&&Je.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>Je&&Je.active()?"minimise":"maximise",run:()=>Je.toggle()}};return Je||delete ct.maximise,Ct.map(St=>St==="-"?{name:"-",separator:!0}:typeof St=="string"?ct[St]:!St||typeof St!="object"||!St.name?null:{...St,run:x(St.run)?()=>St.run({grid:Le,keys:Le.selection&&x(Le.selection.keys)?Le.selection.keys():[],cells:Le.selection&&x(Le.selection.cells)?Le.selection.cells():[]}):void 0}).filter(Boolean).concat(rt)}function We(Le){const nt=rt=>Le.messages.t(rt),Je={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight"};return["pen","arrow","rect","highlight"].map(rt=>({name:rt,title:()=>nt(`toolbar.annotate.${rt}`),icon:Je[rt],run:()=>Le.annotate?.use(rt),active:()=>Le.annotate?.tool===rt,annotation:!0}))}const dt=["pen","arrow","rect","highlight"];function st(Le){return{rowCount:()=>{if(x(Le.rows.matchCount))return Le.rows.matchCount();const nt=Le.pagination&&x(Le.pagination.get)?Le.pagination.get():null;return nt&&Number.isFinite(nt.total)?nt.total:Le.rows.count()},totalRowCount:()=>x(Le.rows.totalCount)?Le.rows.totalCount():Le.rows.count(),selectedCount:()=>{const nt=Le.selection&&Le.selection.keys?Le.selection.keys():null;return nt?nt.length:0},rangeValues:()=>{const nt=Le.selection;return!nt||!x(nt.cells)?[]:nt.cells().map(({key:Je,colId:rt})=>Le.rows.value(Je,rt))},hiddenUnresolved:()=>x(Le.comments&&Le.comments.hiddenUnresolved)?Le.comments.hiddenUnresolved():0,progress:()=>x(Le.source&&Le.source.progress)?Le.source.progress():null,updateStats:()=>Le.updates?Le.updates.stats():null}}function ht(Le,nt){for(const[Je,rt]of Object.entries(o||{}))Le.register("editor",Je,rt);for(const[Je,rt]of Object.entries(a||{}))Le.register("filter",Je,rt);for(const[Je,rt]of Object.entries(nt.components||{}))Le.register("component",Je,rt);for(const[Je,rt]of Object.entries(nt.pipes||{}))Le.register("pipe",Je,rt);for(const[Je,rt]of Object.entries(nt.totalFns||{}))Le.register("totalFn",Je,rt)}function ut(Le,nt,Je,rt,Ct,Mt){const ct=[],St=nt.viewport;let Vt=null;if(Je.maximise!==!1&&(Vt=new je({element:Mt,document:rt,onChange:()=>nt.invalidate("all"),captureScroll:()=>nt.scrollState(),restoreScroll:et=>nt.restoreScroll(et)}),Le.maximise=Vt,ct.push(()=>Vt.destroy())),Je.statusBar){const et=typeof Je.statusBar=="object"?Je.statusBar:{},mt=new h;mt.init({document:rt,host:st(Le),panels:et.panels,registry:et.registry,locale:Le.get("locale"),messages:Le.messages}),St.statusBar.appendChild(mt.element());const At=()=>{const nn=St.statusBar.offsetHeight||St.statusBar.getBoundingClientRect?.().height||0;St.root.style.setProperty("--lattice-status-height",`${Math.ceil(nn)}px`)},$t=()=>{mt.refresh(),At()},Ht=["rows:changed","model:changed","selection:changed","range:changed","rows:queued","rows:paused","rows:resumed","comment:added","comment:edited","comment:deleted","comment:indexLoaded"].map(nn=>Le.on(nn,$t));$t(),At(),ct.push(()=>{for(const nn of Ht)nn();St.root.style.removeProperty("--lattice-status-height"),mt.destroy?.()})}const Wt=ae(Je.selection);if(Wt.ranges){const et=new ne({grid:Le,renderer:nt,document:rt});et.mount(),Le.ranges=et,ct.push(()=>et.destroy())}if(Je.import){const et=new me({grid:Le,renderer:nt,document:rt,settings:typeof Je.import=="object"?Je.import:{}});Le.importer=et,ct.push(()=>et.destroy())}if(Je.historyBar){const et=typeof Je.historyBar=="object"?Je.historyBar.element:null,mt=new Ie;mt.init({document:rt,host:{undo:()=>Le.history.undo(),redo:()=>Le.history.redo(),canUndo:()=>Le.history.canUndo(),canRedo:()=>Le.history.canRedo(),peek:$t=>Le.history.peek($t),list:()=>Le.history.list()},props:typeof Je.historyBar=="object"?Je.historyBar:{}}),(et||St.root).appendChild(mt.element());const At=[Le.on("history:changed",()=>mt.refresh())];Le.historyBar=mt,ct.push(()=>{for(const $t of At)$t();mt.destroy()})}if(Je.diff){const et=new be({grid:Le,renderer:nt});et.mount(),Le.diffPainter=et,ct.push(()=>et.destroy())}if(Je.ai&&x(Je.ai.ask)){const et=new Ne;et.init({document:rt,grid:Le,ask:Je.ai.ask,schemaOptions:Je.ai.schemaOptions,context:Je.ai.context,placeholder:Je.ai.placeholder});const mt=Je.ai.element||St.root;mt===St.root?mt.insertBefore(et.element(),mt.firstChild):mt.appendChild(et.element()),Le.promptBar=et,ct.push(()=>et.destroy())}if(Je.groupPanel){const et=typeof Je.groupPanel=="object"?Je.groupPanel:{},mt=new f;mt.init({document:rt,grid:Le,host:J(Le,rt,(At,$t)=>nt.announce?.(At,$t)),props:{header:St.header,hint:et.hint}}),St.root.insertBefore(mt.element(),St.header),Le.groupPanel=mt;for(const At of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])x(Le.on)&&ct.push(Le.on(At,()=>mt.refresh()));ct.push(()=>mt.destroy())}if(Je.kpis){const et=new Se({grid:Le,document:rt,kpis:Je.kpis});et.active&&(et.mount(),St.root.insertBefore(et.element(),St.header),Le.kpiStrip=et,ct.push(()=>et.destroy()))}if(Je.toolPanel){const et=typeof Je.toolPanel=="object"?Je.toolPanel:{},mt=new Y({grid:Le,document:rt,root:St.root,panels:et.panels,openPanel:et.openPanel,side:et.side,icons:et.icons,actions:Be(Le,et,Vt),announce:(At,$t)=>nt.announce?.(At,$t)});mt.mount(),Le.toolPanel=mt,ct.push(()=>mt.destroy()),et.annotate===void 0&&(ct.push(Le.on("presentation:started",()=>{for(const At of We(Le))mt.addAction(At)})),ct.push(Le.on("presentation:ended",()=>{for(const At of dt)mt.removeAction(At)})))}if(Je.pagination){const et=typeof Je.pagination=="object"?Je.pagination:{},mt=new p;mt.init({document:rt,pageSize:et.pageSize,pageSizes:et.pageSizes,page:et.page,total:et.total,locale:Le.get("locale"),messages:Le.messages,onChange:({page:Ht,pageSize:nn})=>Le.pagination.set({page:Ht,pageSize:nn})});const At=()=>{const Ht=Le.pagination.get();mt.total=Ht.total,mt.counting=Ht.counting===!0,mt.page=Ht.page,mt.paint()};Le.pagination.set({pageSize:mt.pageSize}),At();const $t=["rows:changed","filter:changed","model:changed"].map(Ht=>Le.on(Ht,At));St.statusBar.appendChild(mt.element()),ct.push(()=>{for(const Ht of $t)Ht();mt.destroy?.()})}if(Je.edit!==!1)if(Je.editBar){const et=new re({grid:Le,document:rt,root:St.root});et.mount(),Le.editBar=et,ct.push(()=>et.destroy())}else{const et=new ee({grid:Le,document:rt,renderer:nt,registry:Ct,cellLayer:nt.cellLayer});et.mount(),ct.push(()=>et.destroy())}const an=new d({grid:Le,document:rt,layer:St.overlays,registry:Ct});an.mount(),ct.push(()=>an.destroy());const ln=new E({grid:Le,document:rt,host:St.root,cellMenu:Je.contextMenu!==!1,headerMenu:Je.columnMenu!==!1,items:x(Je.contextMenu)?Je.contextMenu:void 0,headerItems:x(Je.columnMenu)?Je.columnMenu:void 0});if(ln.mount(),ct.push(()=>ln.destroy()),Array.isArray(Je.alignedGrids)&&Je.alignedGrids.length){const et=new z;et.add(Le);for(const mt of Je.alignedGrids)mt&&mt!==Le&&et.add(mt);ct.push(()=>et.destroy())}const zt=new _({grid:Le,renderer:nt,document:rt,registry:Ct});zt.active&&(zt.mount(),ct.push(()=>zt.destroy())),Object.defineProperty(Le,"form",{configurable:!0,value:Object.freeze({open(et){return zt.active?zt.openRow(et):!1},close(){zt.active&&zt.close()},save(){return zt.active?zt.save():!1},isOpen(){return zt.active?zt.open:!1}})}),ct.push(()=>{delete Le.form}),Object.defineProperty(Le,"icons",{configurable:!0,value:Object.freeze({get(et){const mt=i(et);return mt?{viewBox:mt.viewBox,paths:mt.paths.slice(),paint:mt.paint==="stroke"?"stroke":"fill"}:null},names(){return s()}})}),ct.push(()=>{delete Le.icons});const un=new D({grid:Le,renderer:nt,document:rt});un.active&&(un.mount(),ct.push(()=>un.destroy()));const cn=new C({grid:Le,renderer:nt,document:rt});cn.active&&(cn.mount(),ct.push(()=>cn.destroy()));const rn=new P({grid:Le,renderer:nt,document:rt});if(rn.active){rn.mount(),rn.paint();const et=Le.on("render:done",()=>rn.paint());ct.push(()=>{et(),rn.destroy()})}if(Je.shortcuts!==!1){const et=new T({grid:Le,renderer:nt});et.mount(),ct.push(()=>et.destroy())}const Ot=new ze({grid:Le,renderer:nt,window:rt.defaultView||void 0});Ot.mount(),ct.push(()=>Ot.destroy());const Nt=new Xe({grid:Le,renderer:nt,window:rt.defaultView||void 0});if(Nt.mount(),ct.push(()=>Nt.destroy()),Je.find!==!1){const et=new Ce({grid:Le,renderer:nt,document:rt,settings:Je.find});et.mount(),ct.push(()=>et.destroy())}const Ft=new He({grid:Le,renderer:nt});Ft.mount(),ct.push(()=>Ft.destroy());const Ut=new ot({grid:Le,renderer:nt});Ut.mount(),ct.push(()=>Ut.destroy());const Qt=new yt({grid:Le,renderer:nt,maximiser:Vt});Qt.mount(),ct.push(()=>Qt.destroy());const _t=new Yt({grid:Le,renderer:nt});_t.mount(),ct.push(()=>_t.destroy()),Je.environment||Le.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 Zt=null;for(const[et,mt]of[["filter:changed","filter"],["sort:changed","sort"],["rows:changed","data"],["column:resized","resize"],["column:moved","columns"],["column:visible","columns"]])ct.push(Le.on(et,()=>{Zt=mt}));ct.push(Le.on("render:done",et=>{Le.diagnostics.render(Zt||et.cause,et.phases),Zt=null}));const en=new De({grid:Le,renderer:nt});if(en.mount(),ct.push(()=>en.destroy()),ct.push(Le.on("presence:lockRefused",et=>en.announceRefusal(et.peer))),Le.presence&&Le.presence.enabled){for(const At of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])ct.push(Le.on(At,()=>Le.presence.publish()));let et="";ct.push(Le.on("render:done",()=>{const At=nt.focusState&&nt.focusState(),$t=At?`${At.rowKey}${At.colId}`:"";$t!==et&&(et=$t,Le.presence.publish())}));const mt=Mt.ownerDocument;if(mt&&x(mt.addEventListener)){const At=()=>Le.presence.setPaused(mt.visibilityState==="hidden");mt.addEventListener("visibilitychange",At),At(),ct.push(()=>mt.removeEventListener("visibilitychange",At))}}const Xt=new fe({grid:Le,renderer:nt});Xt.mount(),ct.push(()=>Xt.destroy());const dn=new qe({grid:Le,renderer:nt});dn.mount(),ct.push(()=>dn.destroy()),ct.push(Le.on("facet:computed",()=>nt.refreshHeader?.())),Wt&&Wt.headerCheckbox===!0&&ct.push(Le.on("selection:changed",()=>nt.refreshHeader?.())),ct.push(Le.on("facet:expanded",()=>nt.invalidate("columns"))),ct.push(Le.on("model:changed",()=>nt.invalidate("rows")));const Kt=(et,mt)=>nt.announce?.(et,mt),fn=Le.messages,Bt=(et,mt)=>fn.t(et,mt),pn=et=>Bt("count.rows",{count:et});ct.push(Le.on("sort:changed",()=>{const et=Le.sort.get();if(!et.length){Kt(Bt("a11y.sort.cleared"));return}const mt=et.map(At=>{const $t=Le.columns.get(At.col);return Bt("a11y.sort.column",{column:$t&&$t.title||At.col,direction:Bt(At.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});Kt(Bt("a11y.sort.by",{columns:fn.list(mt)}))})),ct.push(Le.on("filter:changed",()=>{const et=Le.rows.matchCount?Le.rows.matchCount():Le.rows.count(),mt=Le.rows.totalCount?Le.rows.totalCount():et;Kt(et===mt?Bt("a11y.filter.cleared",{rows:pn(mt)}):Bt("a11y.filter.applied",{shown:pn(et),total:pn(mt)}))})),ct.push(Le.on("selection:changed",()=>{const et=Le.selection.keys().length;Kt(et===0?Bt("a11y.selection.cleared"):Bt("a11y.selection.count",{count:et}))})),ct.push(Le.on("group:toggled",et=>{const mt=Le.rows.byKey?Le.rows.byKey(et.key):null,At=(mt&&(mt.groupLabel??mt.groupValue))??et.key;Kt(Bt(et.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:At,rows:pn(Le.rows.count())}))})),ct.push(Le.on("column:grouped",et=>{const mt=Array.isArray(et.columns)?et.columns:[];if(!mt.length){Kt(Bt("a11y.group.cleared"));return}const At=mt.map($t=>{const Ht=Le.columns.get($t);return Ht&&Ht.title||$t});Kt(Bt("a11y.group.by",{columns:fn.list(At)}))})),ct.push(Le.on("page:changed",et=>{const mt=Number(et.size)||0,At=Number(et.total)||0,$t=mt>0?Math.max(1,Math.ceil(At/mt)):1;Kt(Bt("a11y.page.position",{page:(Number(et.page)||0)+1,pages:$t}))}));let tn={added:0,removed:0},qt=null;const En=()=>{qt=null;const et=[];tn.added&&et.push(Bt("count.rowsAdded",{count:tn.added})),tn.removed&&et.push(Bt("count.rowsRemoved",{count:tn.removed})),tn={added:0,removed:0},et.length&&Kt(fn.list(et))};ct.push(Le.on("rows:changed",et=>{if(!et||typeof et.added!="number")return;const mt=Number(et.added)||0,At=Number(et.removed)||0;!mt&&!At||(tn.added+=mt,tn.removed+=At,qt||(qt=setTimeout(En,Re)))})),ct.push(()=>{qt&&clearTimeout(qt)}),ct.push(Le.on("rows:paused",()=>{qt&&(clearTimeout(qt),qt=null),tn={added:0,removed:0},Kt(Bt("a11y.updates.paused"),{repeat:!0})})),ct.push(Le.on("rows:resumed",()=>Kt(Bt("a11y.updates.resumed"),{repeat:!0})));let hn={count:0,first:null},mn=null;const Sn=()=>{mn=null;const{count:et,first:mt}=hn;if(hn={count:0,first:null},!et||!mt)return;const At=Le.columns.get(mt.colId),$t=At&&At.title||mt.colId,Ht=mt.reason?Bt("a11y.edit.reason",{reason:mt.reason}):"";if(et===1){const nn=mt.restored===void 0||mt.restored===null||mt.restored===""?Bt("value.empty"):String(mt.restored);Kt(Bt("a11y.edit.refusedOne",{column:$t,value:nn,reason:Ht}),{repeat:!0});return}Kt(Bt("a11y.edit.refusedMany",{count:et,reason:Ht}),{repeat:!0})};ct.push(Le.on("cell:reverted",et=>{!et||!et.applied||(hn.count+=1,hn.first||(hn.first=et),mn||(mn=setTimeout(Sn,150)))})),ct.push(()=>{mn&&clearTimeout(mn)}),ct.push(Le.on("history:applied",et=>{const mt=!!(et&&et.direction==="redo"),At=et&&et.step&&et.step.label;Kt(At?Bt(mt?"a11y.history.redo":"a11y.history.undo",{label:At}):Bt(mt?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const gn=new xt({grid:Le,renderer:nt,seed:Je.state&&Array.isArray(Je.state.annotations)?Je.state.annotations:null});gn.mount(),ct.push(()=>gn.destroy()),Le.annotate=gn,Le.capture=async(et={})=>{const{blob:mt,width:At,height:$t}=await Et(nt.viewport.root,et);return(et.download===!0||et.download!==!1&&et.fileName)&&Z(mt,et.fileName||`${Le.get("exportName")||"grid"}.png`),Le.emit("presentation:captured",{width:At,height:$t,bytes:mt.size,mimeType:mt.type,fileName:et.fileName||null},"api"),mt};const On=new pt({grid:Le,document:rt,element:St.overlays,window:rt.defaultView||void 0});On.mount(),ct.push(()=>On.destroy());const Tn=new b({grid:Le,document:rt,element:St.overlays});Tn.mount?.(),ct.push(()=>Tn.destroy?.());const jn=new S({grid:Le,host:Le.rendererHost(),viewport:St,document:rt});return jn.mount(),ct.push(()=>jn.destroy()),ct}function wt(Le){const nt=[],Je=rt=>{if(rt&&(rt.__lattice&&nt.push(rt),rt.children))for(const Ct of rt.children)Je(Ct)};return Je(Le),nt}function kt(Le,nt={}){(!Le||typeof Le!="object"||!("appendChild"in Le))&&U("createGrid needs a host element as its first argument."),nt=N(nt);const Je=Le.ownerDocument||(typeof document<"u"?document:null);Je||U("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const rt=Je.documentElement&&Je.documentElement.lang,Ct=!nt.licence&&x(Je.querySelector)?Je.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,Mt={...nt};if(!nt.locale&&rt&&(Mt.locale=rt),Ct&&(Mt.licence=Ct),nt.views&&nt.views.local)if(nt.views.storage)I("views:local:ignored","[lattice] views.local is ignored because views.storage was also supplied; the explicit adapter wins.");else{const zt=nt.views.local===!0?{}:nt.views.local;Mt.views={...nt.views,storage:k(zt)}}const ct=M(Mt),St=ct.rendererHost();St.document=Je,ht(St.registry,nt),St.cellLayer=n(St),St.detailHost=new Ee({grid:ct,document:Le.ownerDocument||globalThis.document,createGrid:(zt,un)=>kt(zt,un)});const Vt=new l(Le,St),Wt=ct.on("detail:toggled",()=>{St.detailHost.syncTarget(),St.detailHost.prune()}),sn=ct.on("config:changed",zt=>{zt&&zt.key==="detail"&&St.detailHost.reconfigure()});ct.on("destroy",()=>{Wt(),sn(),St.detailHost.destroy()}),St.detailHost.syncTarget(),ct.attachRenderer(Vt),Vt.mount();const an=ut(ct,Vt,nt,Je,St.registry,Le),ln=ct.destroy.bind(ct);return ct.destroy=()=>{for(const zt of an)try{zt()}catch{}Le.__lattice===ct&&(Le.__lattice=null),ln()},Le.__lattice=ct,ct}}),Ae("packages/dom/src/hydrate.js",function(e,G){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return n}});const q=G("packages/core/src/internal/util.js"),M=q.isFunction,$=q.warnOnce,W=G("packages/core/src/columns/datatypes.js").BUILTIN_TYPES,V=G("packages/core/src/columns/types/index.js").EXTENDED_TYPES,x=G("packages/dom/src/createGrid.js").createGrid,I=new Set([...Object.keys(W),...Object.keys(V)]);function v(t,i){for(const s of t.children)if(s.tagName===i.toUpperCase())return s;return null}function k(t,i){const s=[];for(const r of t.children)r.tagName===i.toUpperCase()&&s.push(r);return s}function y(t,i){const s=M(t.getAttribute)?t.getAttribute("data-field"):null;return s||String(t.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${i}`}function l(t){const i=t.trim();if(i==="")return null;if(i==="true"||i==="false")return i==="true";const s=Number(i);return Number.isFinite(s)&&i!==""?s:i}function u(t){const i=v(t,"thead"),s=v(i||t,"tr"),o=(s?k(s,"th").length?k(s,"th"):k(s,"td"):[]).map((h,b)=>{const p=y(h,b),f={id:p,field:p,title:String(h.textContent||"").trim()||p},w=M(h.getAttribute)?h.getAttribute("data-type"):null;w&&(I.has(w)?f.type=w:$(`hydrate.unknownType:${w}`,`data-type "${w}" on column "${p}" is not a built-in type name, so it was ignored; the column falls back to sampled shape typing.`));const S=M(h.getAttribute)?h.getAttribute("data-format"):null;return S&&(f.format=S),f}),c=v(t,"tbody"),g=(c?k(c,"tr"):k(t,"tr").filter(h=>h!==s)).map((h,b)=>{const p=k(h,"td"),w={__row:(M(h.getAttribute)?h.getAttribute("data-id"):null)||`row${b}`};return o.forEach((S,m)=>{w[S.field]=p[m]?l(String(p[m].textContent||"")):null}),w});return{columns:o,rows:g}}function n(t,i={}){const{columns:s,rows:r}=u(t),o=t.ownerDocument.createElement("div");return t.parentNode.insertBefore(o,t),t.parentNode.removeChild(t),x(o,{rowKey:"__row",columns:s,rows:r,...i,columns:i.columns!==void 0?i.columns:s,rows:i.rows!==void 0?i.rows:r})}}),Ae("packages/dom/src/autoinit.js",function(e,G){"use strict";Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return I}});const M=G("packages/core/src/internal/util.js").isFunction,N=G("packages/dom/src/createGrid.js").createGrid,Z=G("packages/dom/src/hydrate.js").hydrateTable;function V(v,k){const y=[];return M(v.hasAttribute)&&v.hasAttribute(k)&&y.push(v),M(v.querySelectorAll)&&y.push(...v.querySelectorAll(`[${k}]`)),y}function U(v){const k=v.parentNode;if(!k||!k.children)return null;const y=[...k.children],l=y.indexOf(v),u=[y[l+1],y[l-1]];for(const n of u)if(n&&n.tagName==="SCRIPT"&&M(n.getAttribute)&&n.hasAttribute("data-lattice-config"))return n;return null}function x(v){const k=U(v);if(!k)return{};try{return JSON.parse(k.textContent||"{}")}catch(y){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",y),{}}}function I(v){const k=v||(typeof document<"u"?document:null);if(!k)return[];const y=[];for(const l of V(k,"data-lattice-grid")){if(l.__lattice)continue;const u=x(l);y.push(l.tagName==="TABLE"?Z(l,u):N(l,u))}return y}}),Ae("packages/dom/src/index.js",function(e,G){"use strict";Object.defineProperty(e,"LatticeGrid",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return T}});const q=G("packages/dom/src/createGrid.js"),M=q.createGrid,$=G("packages/dom/src/hydrate.js"),N=$.hydrateTable,W=G("packages/dom/src/autoinit.js"),Z=W.autoInit,V=G("packages/dom/src/localviews.js"),U=V.createLocalViewStorage,x=G("packages/core/src/index.js"),I=x.createHeadlessGrid,v=x.registerModules,k=x.setLicence,y=x.version,l=x.getVersion,u=x.serialiseState,n=x.restoreState,t=x.defaults;Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return q.createGrid}}),Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return q.gridElementsWithin}});const i=G("packages/dom/src/stat.js");Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return i.createStat}}),Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return i.deltaOf}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return i.toneOf}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return $.readTable}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return $.hydrateTable}}),Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return W.autoInit}}),Object.defineProperty(e,"createLocalViewStorage",{enumerable:!0,get:function(){return V.createLocalViewStorage}}),Object.defineProperty(e,"DEFAULT_VIEWS_KEY",{enumerable:!0,get:function(){return V.DEFAULT_VIEWS_KEY}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return x.createHeadlessGrid}}),Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return x.defaults}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return x.version}}),Object.defineProperty(e,"getVersion",{enumerable:!0,get:function(){return x.getVersion}}),Object.defineProperty(e,"Grid",{enumerable:!0,get:function(){return x.Grid}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return x.EventBus}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return x.Registry}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return x.sharedRegistry}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return x.registerModules}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return x.parseLicence}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return x.verifyLicence}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return x.licenceInfo}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return x.watermark}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return x.setLicence}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return x.licenceState}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return x.isLocalHost}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return x.matchesDomain}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return x.LicenceHolder}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return x.ColumnModel}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return x.buildGraph}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return x.Lookup}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return x.ValuePipeline}}),Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return x.compileFormat}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return x.compileMask}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return x.specToOoxml}}),Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return x.EXTENDED_TYPES}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return x.createRadixType}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return x.RADIX_PRESETS}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return x.parseRadix}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return x.formatRadix}}),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,"defineUnit",{enumerable:!0,get:function(){return x.defineUnit}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return x.UNIT_SYSTEMS}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return x.parseUnit}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return x.formatUnit}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return x.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return x.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return x.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return x.convertMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return x.rateFunction}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return x.MISSING_RATE}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return x.Messages}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return x.createMessages}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return x.auditCatalogue}}),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,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return x.DEFAULT_LOCALE}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return x.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return x.resolveLocale}}),Object.defineProperty(e,"LOCALES",{enumerable:!0,get:function(){return x.LOCALES}}),Object.defineProperty(e,"resolveCatalogue",{enumerable:!0,get:function(){return x.resolveCatalogue}}),Object.defineProperty(e,"EN_US",{enumerable:!0,get:function(){return x.EN_US}}),Object.defineProperty(e,"FR_FR",{enumerable:!0,get:function(){return x.FR_FR}}),Object.defineProperty(e,"FR_CA",{enumerable:!0,get:function(){return x.FR_CA}}),Object.defineProperty(e,"IT_IT",{enumerable:!0,get:function(){return x.IT_IT}}),Object.defineProperty(e,"ES_ES",{enumerable:!0,get:function(){return x.ES_ES}}),Object.defineProperty(e,"PT_BR",{enumerable:!0,get:function(){return x.PT_BR}}),Object.defineProperty(e,"DE_DE",{enumerable:!0,get:function(){return x.DE_DE}}),Object.defineProperty(e,"NL_NL",{enumerable:!0,get:function(){return x.NL_NL}}),Object.defineProperty(e,"SV_SE",{enumerable:!0,get:function(){return x.SV_SE}}),Object.defineProperty(e,"DA_DK",{enumerable:!0,get:function(){return x.DA_DK}}),Object.defineProperty(e,"NB_NO",{enumerable:!0,get:function(){return x.NB_NO}}),Object.defineProperty(e,"FI_FI",{enumerable:!0,get:function(){return x.FI_FI}}),Object.defineProperty(e,"PL_PL",{enumerable:!0,get:function(){return x.PL_PL}}),Object.defineProperty(e,"CS_CZ",{enumerable:!0,get:function(){return x.CS_CZ}}),Object.defineProperty(e,"HU_HU",{enumerable:!0,get:function(){return x.HU_HU}}),Object.defineProperty(e,"RO_RO",{enumerable:!0,get:function(){return x.RO_RO}}),Object.defineProperty(e,"UK_UA",{enumerable:!0,get:function(){return x.UK_UA}}),Object.defineProperty(e,"EL_GR",{enumerable:!0,get:function(){return x.EL_GR}}),Object.defineProperty(e,"JA_JP",{enumerable:!0,get:function(){return x.JA_JP}}),Object.defineProperty(e,"AR",{enumerable:!0,get:function(){return x.AR}}),Object.defineProperty(e,"AR_SA",{enumerable:!0,get:function(){return x.AR_SA}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return x.ColumnStore}}),Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return x.Bitset}}),Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return x.Dictionary}}),Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return x.MultiValue}}),Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return x.MaskPool}}),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,"evaluateFilters",{enumerable:!0,get:function(){return x.evaluateFilters}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return x.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return x.testValue}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return x.groupByColumns}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return x.total}}),Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return x.TOTAL_FNS}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return x.pivot}}),Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return x.Window}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return x.openWindow}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return x.WINDOW_KINDS}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return x.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return x.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return x.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return x.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return x.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return x.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return x.anomalyCondition}}),Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return x.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return x.forecast}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return x.evaluateFormula}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return x.parseFormula}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return x.referencesOf}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return x.looksLikeFormula}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return x.FormulaError}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return x.FUNCTIONS}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return x.compileRules}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return x.ingest}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return x.ingestSync}}),Object.defineProperty(e,"createSource",{enumerable:!0,get:function(){return x.createSource}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return x.createMemorySource}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return x.createPagedSource}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return x.createRemoteSource}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return x.createStreamSource}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return x.createUrlSource}}),Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return x.PROTOCOL}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return x.createPushdownSource}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return x.planQuery}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return x.splitFilters}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return x.applyResidual}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return x.capabilitiesOf}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return x.resolveMutate}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return x.NO_CAPABILITIES}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return x.odataAdapter}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return x.filtersToOData}}),Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return x.conditionToOData}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return x.restAdapter}}),Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return x.DEFAULT_PARAMS}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return x.dfqlAdapter}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return x.duckdbAdapter}}),Object.defineProperty(e,"filtersToSql",{enumerable:!0,get:function(){return x.filtersToSql}}),Object.defineProperty(e,"graphqlAdapter",{enumerable:!0,get:function(){return x.graphqlAdapter}}),Object.defineProperty(e,"splunkAdapter",{enumerable:!0,get:function(){return x.splunkAdapter}}),Object.defineProperty(e,"RowModel",{enumerable:!0,get:function(){return x.RowModel}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return x.createRowKey}}),Object.defineProperty(e,"SelectionModel",{enumerable:!0,get:function(){return x.SelectionModel}}),Object.defineProperty(e,"RangeModel",{enumerable:!0,get:function(){return x.RangeModel}}),Object.defineProperty(e,"EditModel",{enumerable:!0,get:function(){return x.EditModel}}),Object.defineProperty(e,"ChangeModel",{enumerable:!0,get:function(){return x.ChangeModel}}),Object.defineProperty(e,"StateModel",{enumerable:!0,get:function(){return x.StateModel}}),Object.defineProperty(e,"STATE_VERSION",{enumerable:!0,get:function(){return x.STATE_VERSION}}),Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return x.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return x.restoreState}}),Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return x.VERSION}});const s=G("packages/dom/src/renderer/index.js");Object.defineProperty(e,"DomRenderer",{enumerable:!0,get:function(){return s.DomRenderer}});const r=G("packages/dom/src/filtermenu.js");Object.defineProperty(e,"FilterMenu",{enumerable:!0,get:function(){return r.FilterMenu}}),Object.defineProperty(e,"mergeColumnFilter",{enumerable:!0,get:function(){return r.mergeColumnFilter}}),Object.defineProperty(e,"branchFor",{enumerable:!0,get:function(){return r.branchFor}});const o=G("packages/dom/src/columnmenu.js");Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return o.ColumnMenu}}),Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return o.columnMenuItems}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return o.cellMenuItems}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return o.autoGroupMenuItems}});const c=G("packages/dom/src/alignedgrids.js");Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return c.AlignedGrids}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return c.alignGrids}}),Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return c.layoutState}});const a=G("packages/dom/src/toolpanelmount.js");Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return a.ToolPanelDock}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return a.panelHost}}),Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return a.mountPanel}});const g=G("packages/dom/src/celledit.js");Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return g.CellEditController}});const h=G("packages/dom/src/editbar.js");Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return h.EditBar}});const b=G("packages/dom/src/historybar.js");Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return b.HistoryBar}}),Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return b.HISTORY_CLS}});const p=G("packages/dom/src/diffpaint.js");Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return p.DiffPainter}});const f=G("packages/dom/src/viewpicker.js");Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return f.ViewPicker}}),Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return f.VIEW_CLS}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return f.summariseDiff}});const w=G("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 S=G("packages/dom/src/cell/index.js");Object.defineProperty(e,"createCellLayer",{enumerable:!0,get:function(){return S.createCellLayer}}),Object.defineProperty(e,"compileTemplate",{enumerable:!0,get:function(){return S.compileTemplate}}),Object.defineProperty(e,"compileVariant",{enumerable:!0,get:function(){return S.compileVariant}}),Object.defineProperty(e,"checkVariant",{enumerable:!0,get:function(){return S.checkVariant}}),Object.defineProperty(e,"VariantRegistry",{enumerable:!0,get:function(){return S.VariantRegistry}}),Object.defineProperty(e,"BUILTIN_RENDERERS",{enumerable:!0,get:function(){return S.BUILTIN_RENDERERS}}),Object.defineProperty(e,"BUILTIN_VARIANTS",{enumerable:!0,get:function(){return S.BUILTIN_VARIANTS}}),Object.defineProperty(e,"BUILTIN_PIPES",{enumerable:!0,get:function(){return S.BUILTIN_PIPES}}),Object.defineProperty(e,"sanitiseHtml",{enumerable:!0,get:function(){return S.sanitiseHtml}});const m=G("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 d=G("packages/dom/src/filters/index.js");Object.defineProperty(e,"filters",{enumerable:!0,get:function(){return d.filters}}),Object.defineProperty(e,"createFilter",{enumerable:!0,get:function(){return d.createFilter}}),Object.defineProperty(e,"filterFor",{enumerable:!0,get:function(){return d.filterFor}}),Object.defineProperty(e,"parseExpression",{enumerable:!0,get:function(){return d.parseExpression}}),Object.defineProperty(e,"ConditionFilter",{enumerable:!0,get:function(){return d.ConditionFilter}});const j=G("packages/dom/src/ui/index.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return j.StatusBar}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return j.ContextMenu}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return j.ToolPanel}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return j.TooltipManager}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return j.Pagination}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return j.OverlayLayer}});const E=G("packages/core/src/registry/licence.js");Object.defineProperty(e,"setLicense",{enumerable:!0,get:function(){return E.setLicence}}),Object.defineProperty(e,"licenseInfo",{enumerable:!0,get:function(){return E.licenceInfo}}),Object.defineProperty(e,"licenseState",{enumerable:!0,get:function(){return E.licenceState}});const O=Object.freeze({createGrid:M,createHeadlessGrid:I,defaults:t,registerModules:v,setLicence:k,version:y,autoInit:Z,hydrateTable:N,serialiseState:u,restoreState:n,createLocalViewStorage:U}),T=O}),Ae("packages/modules/shared/adapter.js",function(e,G){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"handlerName",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"dashedName",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"CONFIG_KEY_ALIASES",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"aliasConfigKey",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"isHandlerProp",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"partition",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"createGridController",{enumerable:!0,get:function(){return I}});const q=Object.freeze(["ready","destroy","render:first","render:done","config:changed","licence:changed","model:changed","rows:changed","rows:queued","rows:deferred","rows:paused","rows:resumed","row:received","row:sent","row:copied","row:moved","source:error","source:total","stream:chunk","stream:end","stream:evicted","rowDrag:started","rowDrag:moved","rowDrag:left","rowDrag:ended","cell:changed","cell:pending","cell:confirmed","cell:reverted","cell:conflict","cell:clicked","cell:dblclicked","cell:contextmenu","cell:mouseover","cell:mouseout","cell:mousedown","cell:mouseup","cell:edit:start","cell:edit:end","row:edit:start","row:edit:end","row:clicked","row:dblclicked","row:pending","row:confirmed","row:reverted","row:conflict","form:opened","form:closed","form:saved","form:error","sort:changed","filter:changed","group:toggled","facet:computed","facet:filtered","facet:expanded","facet:failed","column:moved","column:resized","column:visible","column:pinned","column:grouped","column:pivoted","column:filter:open","column:profile:open","column:menu:open","columns:changed","columns:tagged","columngroup:changed","header:contextmenu","pivot:drill","selection:changed","range:changed","clipboard:copy","page:changed","scroll","scroll:end","size:changed","detail:toggled","detail:cell:edit:start","detail:cell:edit:end","detail:row:edit:start","detail:row:edit:end","detail:cell:changed","toolpanel:focus","highlight:changed","find:changed","tree:loading","tree:loaded","tree:loadFailed","tree:loadAborted","state:changed","state:reset","history:changed","history:applied","views:changed","view:applied","view:saved","view:removed","view:renamed","view:default","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"]),M=Object.freeze({sort:(v,k)=>v.sort.set(k||[]),filters:(v,k)=>v.filters.set(k||null),quickFilter:(v,k)=>{if(k&&typeof k=="object"){v.filters.quick(k.text||"",{mode:k.mode});return}v.filters.quick(typeof k=="string"?k:"")},selectedKeys:(v,k)=>v.selection.set(Array.isArray(k)?k:[])});function $(v){return`on${String(v).split(":").map(y=>y.charAt(0).toUpperCase()+y.slice(1)).join("")}`}function N(v){return String(v).replace(/:/g,"-")}const W=Object.freeze({"row-key":"rowKey","row-height":"rowHeight","header-height":"headerHeight","auto-height":"autoHeight"});function Z(v){return Object.hasOwn(W,v)?W[v]:v}const V=Object.freeze(Object.fromEntries(q.map(v=>[$(v),v])));function U(v){return Object.hasOwn(V,v)}function x(v){const k={},y={},l={};for(const[u,n]of Object.entries(v||{})){if(U(u)){l[u]=n;continue}if(Object.hasOwn(M,u)){y[u]=n;continue}k[u]=n}return{config:k,imperative:y,handlers:l}}function I(v){const k=v.createGrid;if(typeof k!="function")throw new TypeError("createGridController needs createGrid; pass it in from the grid package.");const y=x(v.props||{}),l=k(v.element,{...y.config});let u=y.handlers,n=y.config,t={};const i=o=>{if(!o||typeof o.type!="string")return;const c=u[$(o.type)];typeof c=="function"&&c(o)},s=l.on("*",i);for(const[o,c]of Object.entries(y.imperative))c!==void 0&&(M[o](l,c),t[o]=c);let r=!1;return{grid:l,update(o){if(r)return;const c=x(o||{});u=c.handlers;const a={};for(const[g,h]of Object.entries(c.config))Object.is(n[g],h)||(a[g]=h);for(const g of Object.keys(n))Object.hasOwn(c.config,g)||(a[g]=void 0);Object.keys(a).length&&l.setAll(a),n=c.config;for(const[g,h]of Object.entries(M)){const b=c.imperative[g];Object.is(t[g],b)||b===void 0&&!Object.hasOwn(t,g)||(h(l,b),t[g]=b)}},destroy(){r||(r=!0,s(),l.destroy())}}}}),Ae("packages/modules/react/viewers.js",function(e,G){"use strict";Object.defineProperty(e,"VIEWER_EVENTS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"VIEWER_APPLY",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"VIEWER_BULK_UPDATE",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"viewerHandlerName",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"partitionViewerProps",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createViewerController",{enumerable:!0,get:function(){return x}});const M=G("packages/core/src/internal/util.js").warnOnce,$=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"])}),N=Object.freeze({kpi:Object.freeze({rows:(I,v)=>I.setRows(Array.isArray(v)?v:[])}),kanban:Object.freeze({rows:(I,v)=>I.setRows(Array.isArray(v)?v:[]),quickFilter:(I,v)=>I.setQuickFilter(typeof v=="string"?v:""),sprint:(I,v)=>I.setSprint(v),epic:(I,v)=>I.setEpic(v),loading:(I,v)=>I.setLoading(!!v),error:(I,v)=>I.setError(v??null)}),gantt:Object.freeze({tasks:(I,v)=>I.setTasks(Array.isArray(v)?v:[]),dependencies:(I,v)=>I.setDependencies(Array.isArray(v)?v:[])}),tabs:Object.freeze({active:(I,v)=>{typeof v=="string"&&I.activate(v)}}),chart:Object.freeze({}),layout:Object.freeze({})}),W=Object.freeze({chart:"update"});function Z(I){return`on${String(I).split(":").map(k=>k.charAt(0).toUpperCase()+k.slice(1)).join("")}`}const V=Object.freeze(Object.fromEntries(Object.entries($).map(([I,v])=>[I,Object.freeze(Object.fromEntries(v.map(k=>[Z(k),k])))])));function U(I,v){const k=V[I]||{},y=N[I]||{},l={},u={},n={};for(const[t,i]of Object.entries(v||{})){if(Object.hasOwn(k,t)){n[t]=i;continue}if(Object.hasOwn(y,t)){u[t]=i,l[t]=i;continue}l[t]=i}return{config:l,live:u,handlers:n}}function x(I){const v=String(I.viewer),k=I.mount,y=I.name||v;if(typeof k!="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=U(v,I.props||{}),u=k(I.element,{...l.config});if(!u||typeof u!="object")throw new TypeError(`the ${y} factory returned no instance; nothing can be driven.`);let n=l.handlers,t=l.config;const i={...l.live},s=[];if(typeof u.on=="function")for(const a of $[v]||[]){const g=Z(a),h=u.on(a,b=>{const p=n[g];typeof p=="function"&&p(b)});typeof h=="function"&&s.push(h)}const r=W[v],o=N[v]||{};let c=!1;return{instance:u,update(a){if(c)return;const g=U(v,a||{});n=g.handlers;const h={};for(const[p,f]of Object.entries(g.config))Object.is(t[p],f)||(h[p]=f);if(t=g.config,!Object.keys(h).length)return;const b=[];for(const p of Object.keys(h)){const f=o[p];if(f){f(u,h[p]),i[p]=h[p];continue}r&&typeof u[r]=="function"||b.push(p)}if(r&&typeof u[r]=="function"){const p={};for(const f of Object.keys(h))o[f]||(p[f]=h[f]);Object.keys(p).length&&u[r](p)}b.length&&M(`react.viewer.${v}.mountOnly.${b.join(".")}`,`${y}: ${b.map(p=>`\`${p}\``).join(", ")} changed, but ${y} takes ${b.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(!c){c=!0;for(const a of s)try{a()}catch{}s.length=0,typeof u.destroy=="function"&&u.destroy()}}}}}),Ae("packages/modules/webcomponent/controller.js",function(e,G){"use strict";Object.defineProperty(e,"EVENT_PREFIX",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"ELEMENT_STYLE_ID",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"ATTRIBUTE_CONFIG",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"observedAttributeNames",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"domEventName",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"coerceAttribute",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"injectElementStyle",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"GridElementController",{enumerable:!0,get:function(){return v}});const q="lattice-",M="lattice-grid-element-styles",$=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"}),N=new Set(["rowHeight","headerHeight"]),W=new Set(["autoHeight","filterRow"]),Z=new Set(["rows","columns"]);function V(){return Object.keys($)}function U(k){return q+String(k).replace(/:/g,"-")}function x(k,y){if(W.has(k))return y!==null&&y!=="false";if(y!==null){if(N.has(k)){const l=Number(y);return Number.isFinite(l)?l:void 0}if(Z.has(k))try{return JSON.parse(y)}catch{return}return y}}function I(k){if(!k||!k.createElement||k.getElementById&&k.getElementById(M))return;const y=k.createElement("style");y.setAttribute("id",M),y.appendChild(k.createTextNode(`lattice-grid{display:block}
|
|
57
57
|
`));const l=k.head||k.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,u]of Object.entries(y))this.#l(l,u)}attributeChanged(y,l){const u=$[y];if(!u)return;const n=x(u,l);n===void 0&&!W.has(u)||this.#l(u,n)}connect(){this.#i=!1,this.#s=!0,!this.#n&&queueMicrotask(()=>this.settleCreate())}settleCreate(){if(!this.#s||this.#n)return;I(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 u=this.#e;if(!u||typeof u.dispatchEvent!="function")return;const n={...l};delete n.grid,u.dispatchEvent(this.#u(U(l.type),n))}))}#u(y,l){const u=globalThis.CustomEvent;return typeof u=="function"?new u(y,{detail:l,bubbles:!0,composed:!0}):{type:y,detail:l,bubbles:!0,composed:!0}}}}),Ae("packages/modules/webcomponent/styles.js",function(e,G){"use strict";Object.defineProperty(e,"constructableStyleSheets",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"isLatticeStyleNode",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"sheetText",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"latticeStyleNodes",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"latticeStyleSheets",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"adoptLatticeStyles",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"adoptIntoHostRoot",{enumerable:!0,get:function(){return y}});const q=Symbol.for("lattice.webcomponent.styleMirror"),M=/--lattice-|\.lat-/,$=new WeakMap,N=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 Z(l){if(!l||typeof l.getAttribute!="function")return!1;const u=String(l.tagName||"").toLowerCase();if(u!=="style"&&u!=="link"||u==="link"&&!String(l.getAttribute("rel")||"").toLowerCase().split(/\s+/).includes("stylesheet"))return!1;const n=String(l.getAttribute("id")||"");if(n.startsWith("lattice")||n.startsWith("lat-")||l.hasAttribute&&l.hasAttribute("data-lattice"))return!0;if(u==="link"){const t=String(l.getAttribute("href")||"");return/lattice/i.test(t)?!0:M.test(V(l))}return M.test(String(l.textContent||""))}function V(l){if(String(l&&l.tagName||"").toLowerCase()==="style")return String(l.textContent||"");try{const n=l&&l.sheet;if(!n||!n.cssRules)return"";let t="";for(const i of n.cssRules)t+=`${i.cssText}
|
|
58
|
-
`;return t}catch{return""}}function U(l,u){const n=$.get(l);if(n)return n.sheet;const t=V(l);if(!t)return null;const i=u.CSSStyleSheet,s=new i;try{s.replaceSync(t)}catch{return null}s[q]=!0;let r=null;const o=u.MutationObserver;return typeof o=="function"&&String(l.tagName).toLowerCase()==="style"&&(r=new o(()=>{try{s.replaceSync(String(l.textContent||""))}catch{}}),r.observe(l,{childList:!0,characterData:!0,subtree:!0})),$.set(l,{sheet:s,stop:()=>r&&r.disconnect()}),s}function x(l){return l?l.nodeType===9?l:l.ownerDocument||globalThis.document||null:globalThis.document||null}function I(l){const u=l||globalThis.document;return!u||typeof u.querySelectorAll!="function"?[]:[...u.querySelectorAll("style,link[rel]")].filter(Z)}function v(l={}){if(!W())return[];const u=l.document||globalThis.document,n=u&&u.defaultView||globalThis,t=[];for(const i of I(u)){const s=U(i,n);s&&!t.includes(s)&&t.push(s)}return t}function k(l,u={}){const n=()=>{};if(!l||typeof l!="object")return n;const t=u.document||x(l);if(!t)return n;const i=t.defaultView||globalThis;let s=N.get(l);s||(s=new Map,N.set(l,s));const r=[],o=W(),c=p=>{if(s.has(p))return;const f=o?U(p,i):null;if(f){s.set(p,f);const S=l.adoptedStyleSheets||[];S.includes(f)||(l.adoptedStyleSheets=[...S,f]);return}if(String(p.tagName).toLowerCase()!=="link"||typeof l.appendChild!="function")return;const w=t.createElement("link");w.setAttribute("rel","stylesheet"),w.setAttribute("href",p.getAttribute("href")||""),w.setAttribute("data-lattice","adopted"),l.appendChild(w),r.push(w),s.set(p,w)};for(const p of I(t))c(p);let a=null;const g=i.MutationObserver,h=t.head||t.documentElement;typeof g=="function"&&h&&(a=new g(p=>{for(const f of p)for(const w of f.addedNodes||[])Z(w)&&c(w)}),a.observe(h,{childList:!0}));let b=!1;return()=>{if(b)return;b=!0,a&&a.disconnect();const p=l.adoptedStyleSheets||[],f=new Set([...s.values()]);l.adoptedStyleSheets=p.filter(w=>!f.has(w));for(const w of r)w.parentNode&&w.parentNode.removeChild(w);s.clear()}}function y(l){if(!l||typeof l.getRootNode!="function"||typeof l.getAttribute=="function"&&String(l.getAttribute("lattice-styles")||"")==="off")return null;const u=l.getRootNode();return!u||u.nodeType!==11||!u.host?null:k(u)}}),Ae("packages/modules/webcomponent/elements.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_GRID_NAME",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_TAG_PREFIX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ELEMENT_TAGS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"VIEWER_ALIASES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"VIEWER_BINDING",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"coerceElementAttribute",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"attributeConfig",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"createElementScope",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"scopeFor",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"applyPredicates",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"upgradeProperty",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"installProperty",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"harvestProperties",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"createLatticeKPIElement",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"createLatticeChartElement",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"createLatticeKanbanElement",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createLatticeGanttElement",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"createLatticeLayoutElement",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"createLatticeTabsElement",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"createLatticeRouterElement",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"createLatticeElements",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"defineLatticeElements",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(e,"gridElementClass",{enumerable:!0,get:function(){return oe}});const M=G("packages/core/src/internal/util.js").warnOnce,N=G("packages/modules/shared/adapter.js").aliasConfigKey,W=G("packages/modules/react/viewers.js"),Z=W.VIEWER_EVENTS,V=W.viewerHandlerName,U=W.createViewerController,x=G("packages/modules/webcomponent/controller.js"),I=x.GridElementController,v=x.observedAttributeNames,k=x.domEventName,y=x.ATTRIBUTE_CONFIG,u=G("packages/modules/webcomponent/styles.js").adoptIntoHostRoot,n="default",t="lattice-",i=Object.freeze({grid:"grid",kpi:"kpi",chart:"chart",kanban:"kanban",gantt:"gantt",layout:"layout",tabs:"tabs",router:"router"}),s=Object.freeze({chart:re=>{if("data"in re){const le=re.data;delete re.data,le!=null&&re.rows===void 0&&(re.rows=le)}if("stacked"in re){const le=re.stacked;delete re.stacked,le!=null&&re.stack===void 0&&(re.stack=le)}if("horizontal"in re){const le=re.horizontal;delete re.horizontal,le&&re.type==="bar"&&(re.type="horizontalBar")}},kanban:re=>{if(!("titleProperty"in re))return;const le=re.titleProperty;if(delete re.titleProperty,typeof le!="string"||!le)return;const ne=re.card&&typeof re.card=="object"?re.card:null;ne&&ne.title!==void 0||(re.card={title:le,...ne||{}})},gantt:re=>{if(!("scale"in re))return;const le=re.scale;if(delete re.scale,le==null||le==="")return;const ne=re.render&&typeof re.render=="object"?{...re.render}:{};ne.zoom===void 0&&(ne.zoom=le),re.render=ne}}),r=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"])})}),o=new Set(["grid-name","lattice-styles","name","route","route-options","id","class","style","slot"]),c=new Set(["role","tabindex","hidden","part","exportparts","lang","dir","title-id","is"]),a=Symbol.for("lattice.webcomponent.routerScope"),g=new WeakMap;function h(re){if(re==null)return;if(re===""||re==="true")return!0;if(re==="false")return!1;const le=String(re).trim();if(le.startsWith("[")||le.startsWith("{"))try{return JSON.parse(le)}catch{return re}return le!==""&&Number.isFinite(Number(le))?Number(le):re}function b(re,le){const ne={},se=re&&typeof re.getAttributeNames=="function"?re.getAttributeNames():[];for(const ae of se){if(o.has(ae)||c.has(ae)||le&&le.has(ae)||ae.startsWith("data-")||ae.startsWith("aria-"))continue;const de=h(re.getAttribute(ae));de!==void 0&&(ne[p(ae)]=de)}return ne}function p(re){const le=N(re);return le!==re||!re.includes("-")?le:re.replace(/-([a-z0-9])/g,(ne,se)=>se.toUpperCase())}function f(re){return re&&typeof re.getAttributeNames=="function"?re.getAttributeNames():[]}function w(re){const le=[];for(const ne of f(re))o.has(ne)||c.has(ne)||ne.startsWith("data-")||ne.startsWith("aria-")||le.push(p(ne));return le}function S(){const re=new Map,le=new Set;return{publish(ne,se){const ae=ne||n;se?re.set(ae,se):re.delete(ae);for(const de of[...le])de()},get(ne){return re.get(ne||n)||null},names(){return[...re.keys()]},subscribe(ne){return le.add(ne),()=>{le.delete(ne)}}}}function m(re={}){const le=typeof re.createDataRouter=="function"?re.createDataRouter:null;let ne=null,se=!1;return{grids:S(),get router(){return ne},attach(de,me,Pe){se||!le||(ne||(ne=le(re.config||{})),ne.attach(de,me,Pe||{}))},detach(de){if(!(se||!ne))try{ne.detach(de)}catch{}},destroy(){se=!0;const de=ne;ne=null,de&&de.destroy()}}}function d(re){let le=re&&re.parentNode||null;for(;le;){if(le[a])return le[a];le=le.parentNode||le.host||null}const se=(re&&typeof re.getRootNode=="function"?re.getRootNode():re&&re.ownerDocument||null)||globalThis.document||globalThis;let ae=g.get(se);return ae||(ae=m(),g.set(se,ae)),ae}function j(re,le,ne){const se=le&&typeof le=="object"?le:{},ae=ne&&typeof ne=="object"?ne:{};for(const[de,me]of Object.entries(se))Object.is(ae[de],me)||re.filters.where(de,typeof me=="function"?me:null);for(const de of Object.keys(ae))Object.hasOwn(se,de)||re.filters.where(de,null)}function E(re,le){if(!Object.hasOwn(re,le))return;const ne=re[le];delete re[le],re[le]=ne}const O=new Set(["instance","config","grid","gridName","router"]);function T(re,le){let ne=Object.getPrototypeOf(re);for(;ne;){const se=Object.getOwnPropertyDescriptor(ne,le);if(se)return typeof se.get=="function";ne=Object.getPrototypeOf(ne)}return!1}function A(re,le){if(!le||O.has(le)||le.startsWith("__"))return;const ne=Object.getOwnPropertyDescriptor(re,le);if(ne&&typeof ne.get=="function")return;if(T(re,le)){ne&&E(re,le);return}const se=ne?ne.value:void 0;ne&&delete re[le],Object.defineProperty(re,le,{get(){return this.__props[le]},set(ae){this.__write(le,ae)},configurable:!0,enumerable:!0}),ne&&(re[le]=se)}function P(re){let le=!1;for(const ne of Object.getOwnPropertyNames(re)){if(ne.startsWith("__")||O.has(ne))continue;const se=Object.getOwnPropertyDescriptor(re,ne);!se||typeof se.get=="function"||!se.enumerable||(A(re,ne),le=!0)}return le}function L(re,le,ne){if(!re||typeof re.dispatchEvent!="function")return;const se=globalThis.CustomEvent,ae={detail:ne,bubbles:!0,composed:!0};re.dispatchEvent(typeof se=="function"?new se(le,ae):{type:le,...ae})}function z(re){const le=re.viewer,ne=r[le],se=re.label||ne.label,ae=re.mount,de=Z[le]||[];class me extends re.Base{__props={};__controller=null;__builtAgainst=null;__connected=!1;__teardownPending=!1;__release=[];__queued=!1;__wired=!1;__scope=null;__ownAttributes=new Set;constructor(){super();for(const Ie of["config","grid","gridName",...ne.properties,...ne.scalars])E(this,Ie);P(this)}get instance(){return this.__controller?this.__controller.instance:null}get grid(){return this.__props.grid}set grid(Ie){this.__write("grid",Ie)}get gridName(){const Ie=this.__props.gridName;if(typeof Ie=="string")return Ie;const ke=typeof this.getAttribute=="function"?this.getAttribute("grid-name"):null;return ke===null?void 0:ke}set gridName(Ie){this.__write("gridName",Ie)}get config(){return{...this.__props}}set config(Ie){if(!(!Ie||typeof Ie!="object")){for(const[ke,be]of Object.entries(Ie))this.__props[ke]=be;this.__schedule()}}connectedCallback(){if(this.__teardownPending=!1,!this.__connected){if(this.__connected=!0,!this.__wired){this.__wired=!0;const Ie=u(this);Ie&&this.__release.push(Ie);const ke=d(this);this.__scope=ke,ne.fromContext&&this.__release.push(ke.grids.subscribe(()=>this.__settle()));const be=globalThis.MutationObserver;if(typeof be=="function"){const ge=new be(()=>this.__settle());ge.observe(this,{attributes:!0}),this.__release.push(()=>ge.disconnect())}}P(this);for(const Ie of w(this))A(this,Ie);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 Ie of this.__release.splice(0))try{Ie()}catch{}this.__tearDown()}}__write(Ie,ke){this.__props[Ie]=ke,this.__schedule()}__schedule(){this.__queued||(this.__queued=!0,queueMicrotask(()=>{this.__queued=!1,this.__settle()}))}__boundGrid(){if(!ne.fromContext)return null;if(this.__props.grid!==void 0)return this.__props.grid||null;const Ie=this.__scope;return Ie?Ie.grids.get(this.gridName):null}__resolve(){const Ie={...b(this,this.__ownAttributes),...this.__props};if(delete Ie.gridName,ne.fromContext){const be=this.__boundGrid();be?Ie[ne.fromContext]=be:delete Ie[ne.fromContext]}const ke=s[le];ke&&ke(Ie);for(const be of de)Ie[V(be)]=ge=>L(this,k(be),ge);return Ie}__settle(){if(!this.__connected)return;P(this);const Ie=this.__resolve(),ke=ne.fromContext&&Ie[ne.fromContext]||null;if(this.__controller&&!Object.is(this.__builtAgainst,ke)&&this.__tearDown(),!this.__controller){for(const ge of ne.requires)if(Ie[ge]===void 0||Ie[ge]===null)return;if(ne.fromContext&&!ke&&Ie.rows===void 0)return;const be=new Set(f(this));this.__controller=U({viewer:le,mount:ae,element:this,props:Ie,name:se});for(const ge of f(this))be.has(ge)||this.__ownAttributes.add(ge);this.__builtAgainst=ke,L(this,"ready",{instance:this.__controller.instance});return}this.__controller.update(Ie)}__tearDown(){const Ie=this.__controller;this.__controller=null,this.__builtAgainst=null,Ie&&(L(this,"destroyed",{instance:Ie.instance}),Ie.destroy())}}for(const Pe of[...ne.properties,...ne.scalars])Pe in re.Base.prototype||Object.defineProperty(me.prototype,Pe,{get(){return this.__props[Pe]},set(Ie){this.__write(Pe,Ie)},configurable:!0,enumerable:!0});return me}function H(re,le,ne){if(typeof re!="function")throw new TypeError(`${le} needs ${ne}: ${le}({ ${ne} }).`)}function D(){const re=globalThis.HTMLElement;return typeof re=="function"?re:null}function F(re){H(re&&re.createKPI,"createLatticeKPIElement","createKPI");const le=D();return le?z({viewer:"kpi",Base:le,mount:(ne,se)=>re.createKPI(ne,se)}):null}function C(re){H(re&&re.createChart,"createLatticeChartElement","createChart");const le=D();return le?z({viewer:"chart",Base:le,mount:(ne,se)=>re.createChart({...se,container:ne})}):null}function B(re){H(re&&re.createKanban,"createLatticeKanbanElement","createKanban");const le=D();return le?z({viewer:"kanban",Base:le,mount:(ne,se)=>re.createKanban(ne,se)}):null}function _(re){H(re&&re.createGantt,"createLatticeGanttElement","createGantt");const le=D();return le?z({viewer:"gantt",Base:le,mount:(ne,se)=>re.createGantt({...se,element:ne})}):null}function Q(re){H(re&&re.createLayout,"createLatticeLayoutElement","createLayout");const le=D();return le?z({viewer:"layout",Base:le,mount:(ne,se)=>re.createLayout(ne,se)}):null}function Y(re){H(re&&re.createTabs,"createLatticeTabsElement","createTabs");const le=D();return le?z({viewer:"tabs",Base:le,mount:(se,ae)=>{const de=new Map,me=typeof se.querySelectorAll=="function"?[...se.querySelectorAll("template[data-tab]")]:[];for(const ke of me)ke.parentNode===se&&de.set(ke.getAttribute("data-tab"),ke);const Ie=(Array.isArray(ae.tabs)&&ae.tabs.length?ae.tabs:[...de.keys()].map(ke=>({id:ke,label:de.get(ke).getAttribute("data-label")||ke}))).map(ke=>{const be=ke,ge=de.get(be.id);return ge?{...be,view:Ee=>{const xe=ge.content.cloneNode(!0),ze=[...xe.childNodes];return Ee.appendChild(xe),{destroy(){for(const _e of ze)_e.parentNode&&_e.parentNode.removeChild(_e)}}}}:be});return re.createTabs(se,{...ae,tabs:Ie,createGrid:re.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(re){H(re&&re.createDataRouter,"createLatticeRouterElement","createDataRouter");const le=D();if(!le)return null;class ne extends le{__scope=null;__config={};constructor(){super(),E(this,"config")}get config(){return{...this.__config}}set config(ae){!ae||typeof ae!="object"||(this.__config={...this.__config,...ae},this.__scope&&this.__scope.router&&M("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 ae=b(this);this.__scope=m({createDataRouter:re.createDataRouter,config:{...ae,...this.__config}}),this[a]=this.__scope}disconnectedCallback(){const ae=this.__scope;if(this.__scope=null,this[a]=null,!ae)return;const de=ae.router;ae.destroy(),de&&L(this,"destroyed",{instance:de})}}return ne}function te(re={}){const le={},ne=(se,ae,de)=>{if(typeof ae!="function")return;const me=de();me&&(le[se]=me)};return ne("LatticeGridElement",re.createGrid,()=>oe(re.createGrid)),ne("LatticeKPIElement",re.createKPI,()=>F({createKPI:re.createKPI})),ne("LatticeChartElement",re.createChart,()=>C({createChart:re.createChart})),ne("LatticeKanbanElement",re.createKanban,()=>B({createKanban:re.createKanban})),ne("LatticeGanttElement",re.createGantt,()=>_({createGantt:re.createGantt})),ne("LatticeLayoutElement",re.createLayout,()=>Q({createLayout:re.createLayout})),ne("LatticeTabsElement",re.createTabs,()=>Y({createTabs:re.createTabs,createGrid:re.createGrid})),ne("LatticeRouterElement",re.createDataRouter,()=>J({createDataRouter:re.createDataRouter})),le}function ee(re={}){const le=globalThis.customElements,ne={};if(!le||typeof le.define!="function")return ne;const se=typeof re.prefix=="string"?re.prefix:t,ae=te(re),de={LatticeGridElement:i.grid,LatticeKPIElement:i.kpi,LatticeChartElement:i.chart,LatticeKanbanElement:i.kanban,LatticeGanttElement:i.gantt,LatticeLayoutElement:i.layout,LatticeTabsElement:i.tabs,LatticeRouterElement:i.router};for(const[me,Pe]of Object.entries(ae)){const Ie=se+de[me],ke=le.get?le.get(Ie):void 0;if(ke){ne[Ie]=ke;continue}le.define(Ie,Pe),ne[Ie]=Pe}return ne}function oe(re){const le=D();if(!le)return null;class ne extends le{static get observedAttributes(){return v()}__connected=!1;__teardownPending=!1;__published=!1;__publishedAs=n;__scope=null;__predicates=void 0;__rowUpdates=void 0;__release=[];constructor(){super(),this.__controller=new I(this,{createGrid:re});for(const ae of["rows","columns","config","predicates","rowUpdates",...Object.values(y)])E(this,ae)}get grid(){return this.__controller.grid}get instance(){return this.__controller.grid}get rows(){return this.__controller.config().rows}set rows(ae){this.__controller.configure({rows:ae})}get columns(){return this.__controller.config().columns}set columns(ae){this.__controller.configure({columns:ae})}get config(){return this.__controller.config()}set config(ae){this.__controller.configure(ae)}get predicates(){return this.__predicates}set predicates(ae){const de=this.__published?this.__controller.grid:null;de&&j(de,ae,this.__predicates),this.__predicates=ae}get rowUpdates(){return this.__rowUpdates}set rowUpdates(ae){if(Object.is(ae,this.__rowUpdates))return;this.__rowUpdates=ae;const de=this.__published?this.__controller.grid:null;de&&ae&&de.rows.apply(ae)}connectedCallback(){if(this.__teardownPending=!1,!this.__connected){if(this.__connected=!0,!this.__scope){const ae=u(this);ae&&this.__release.push(ae),this.__scope=d(this)}this.__controller.connect(),queueMicrotask(()=>this.__publish())}}disconnectedCallback(){this.__connected&&(this.__connected=!1,this.__teardownPending=!0,queueMicrotask(()=>this.__settleTeardown()),this.__controller.disconnect())}attributeChangedCallback(ae,de,me){this.__controller.attributeChanged(ae,me)}__publish(){if(!this.__connected||this.__published)return;const ae=this.__controller.grid;if(!ae)return;this.__published=!0,this.__predicates&&j(ae,this.__predicates,{});const de=typeof this.getAttribute=="function"?this.getAttribute("name"):null;this.__publishedAs=de||n;const me=this.__scope;me&&me.grids.publish(this.__publishedAs,ae);const Pe=typeof this.getAttribute=="function"?this.getAttribute("route"):null;if(me&&Pe!==null){const Ie=this.getAttribute("route-options");me.attach(ae,h(Pe),Ie===null?{}:h(Ie))}this.__rowUpdates&&ae.rows.apply(this.__rowUpdates),L(this,"grid-ready",{grid:ae})}__settleTeardown(){if(!this.__teardownPending)return;this.__teardownPending=!1;const ae=this.__controller.grid,de=this.__scope;this.__scope=null,this.__published=!1;for(const me of this.__release.splice(0))try{me()}catch{}ae&&de&&(L(this,"grid-destroyed",{grid:ae}),de.detach(ae),de.grids.publish(this.__publishedAs,null)),this.__controller.settleTeardown()}}for(const se of Object.values(y))Object.getOwnPropertyDescriptor(ne.prototype,se)||se in le.prototype||Object.defineProperty(ne.prototype,se,{get(){return this.__controller.config()[se]},set(ae){this.__controller.configure({[se]:ae})},configurable:!0,enumerable:!0});return ne}}),Ae("packages/modules/webcomponent/index.js",function(e,G){"use strict";Object.defineProperty(e,"TAG_NAME",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"createLatticeGridElement",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"defineLatticeGrid",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const q=G("packages/dom/src/index.js"),M=q.createGrid,$=G("packages/modules/webcomponent/elements.js"),N=$.gridElementClass,W=G("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 $.createLatticeElements}}),Object.defineProperty(e,"defineLatticeElements",{enumerable:!0,get:function(){return $.defineLatticeElements}}),Object.defineProperty(e,"ELEMENT_TAGS",{enumerable:!0,get:function(){return $.ELEMENT_TAGS}}),Object.defineProperty(e,"createLatticeKPIElement",{enumerable:!0,get:function(){return $.createLatticeKPIElement}}),Object.defineProperty(e,"createLatticeChartElement",{enumerable:!0,get:function(){return $.createLatticeChartElement}}),Object.defineProperty(e,"createLatticeKanbanElement",{enumerable:!0,get:function(){return $.createLatticeKanbanElement}}),Object.defineProperty(e,"createLatticeGanttElement",{enumerable:!0,get:function(){return $.createLatticeGanttElement}}),Object.defineProperty(e,"createLatticeLayoutElement",{enumerable:!0,get:function(){return $.createLatticeLayoutElement}}),Object.defineProperty(e,"createLatticeTabsElement",{enumerable:!0,get:function(){return $.createLatticeTabsElement}}),Object.defineProperty(e,"createLatticeRouterElement",{enumerable:!0,get:function(){return $.createLatticeRouterElement}});const Z=G("packages/modules/webcomponent/styles.js");Object.defineProperty(e,"adoptLatticeStyles",{enumerable:!0,get:function(){return Z.adoptLatticeStyles}}),Object.defineProperty(e,"latticeStyleSheets",{enumerable:!0,get:function(){return Z.latticeStyleSheets}});const V=G("packages/modules/react/viewers.js");Object.defineProperty(e,"VIEWER_EVENTS",{enumerable:!0,get:function(){return V.VIEWER_EVENTS}}),Object.defineProperty(e,"VIEWER_APPLY",{enumerable:!0,get:function(){return V.VIEWER_APPLY}}),Object.defineProperty(e,"viewerHandlerName",{enumerable:!0,get:function(){return V.viewerHandlerName}}),Object.defineProperty(e,"createViewerController",{enumerable:!0,get:function(){return V.createViewerController}});const U=G("packages/modules/shared/adapter.js");Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return U.EVENT_NAMES}}),Object.defineProperty(e,"dashedName",{enumerable:!0,get:function(){return U.dashedName}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return q.createCurrencyType}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return q.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return q.registerUnitSystem}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return q.createStat}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return q.createHeadlessGrid}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return q.duckdbAdapter}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return q.createPushdownSource}});const x="lattice-grid";function I(y=M){return N(y)}function v(y={}){const l=globalThis.customElements,u=y.tagName||x;if(!l||typeof l.define!="function")return null;const n=l.get?l.get(u):void 0;if(n)return n;const t=I(y.createGrid||M);return t?(l.define(u,t),t):null}v();const k=v});try{Un("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 X}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"pathSetter",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"escapeHtml",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"titleCase",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"expand",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return H}});const fe="1.74.0";async function he(){return fe}const X="1.74.0",z=new Set,te=2e3;function x(w){if(z.add(w),z.size>te){const A=z.values().next().value;A!==void 0&&z.delete(A)}}const T=[],K=500;function re(w,A,q){T.push({key:w,level:A,message:q.map(le=>typeof le=="string"?le:J(le)).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 ue(){return T.map(w=>({...w}))}function oe(w,...A){z.has(w)||(x(w),re(w,"warn",A),console.warn("[lattice]",...A))}function Y(w,...A){z.has(w)||(x(w),re(w,"info",A),console.info("[lattice]",...A))}function L(){z.clear(),T.length=0}function Q(w,A){const q=new Error(`[lattice] ${w}`);throw A!==void 0&&(q.cause=A),q}function _(w,A){w||Q(A)}const C=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function M(w){return w!==null&&typeof w=="object"&&!Array.isArray(w)}function i(w){return typeof w=="function"}function s(w){return w==null}function u(w){return w==null||w===""}function f(w){return typeof w!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(w))?!0:!!(w.prototype&&Object.getOwnPropertyNames(w.prototype).length>1)}const c=new Map;function t(w){let A=c.get(w);if(A)return A;if(!w.includes("."))A=q=>q?.[w];else{const q=w.split("."),le=q.length;A=ae=>{let de=ae;for(let pe=0;pe<le;pe++){if(de==null)return;de=de[q[pe]]}return de}}return c.set(w,A),A}const a=new Map;function m(w){let A=a.get(w);if(A)return A;if(!w.includes("."))A=(q,le)=>{q!=null&&(q[w]=le)};else{const q=w.split("."),le=q.length-1;A=(ae,de)=>{let pe=ae;for(let ge=0;ge<le;ge++){if(pe==null)return;const ke=q[ge];pe[ke]==null&&(pe[ke]={}),pe=pe[ke]}pe!=null&&(pe[q[le]]=de)}}return a.set(w,A),A}function e(w,A){return t(A)(w)}function d(w,A,q){m(A)(w,q)}function h(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(/^./,q=>q.toUpperCase()):""}const r={"&":"&","<":"<",">":">",\'"\':""","\'":"'"};function n(w){const A=w==null?"":String(w);return/[&<>"\']/.test(A)?A.replace(/[&<>"\']/g,q=>r[q]):A}function l(w){return String(w).replace(/\\w\\S*/g,A=>A[0].toUpperCase()+A.slice(1).toLowerCase())}function g(w,A,q){if(w!==void 0)return w===!0?{enabled:!0,...q}:w===!1?{enabled:!1}:M(w)?w:{[A]:w,enabled:!0}}function P(w){return w==null?[]:Array.isArray(w)?w:[w]}const S=Object.freeze(new Set(["__proto__","constructor","prototype"]));function G(w,A){if(!M(w))return M(A)?{...A}:A;if(!M(A))return A===void 0?w:A;const q={...w};for(const le of Object.keys(A)){if(S.has(le))continue;const ae=A[le];ae!==void 0&&(q[le]=M(ae)&&M(q[le])?G(q[le],ae):ae)}return q}function F(w,A){if(!M(w)||!M(A)||w===A)return A;const q=Object.create(Object.getPrototypeOf(w));return Object.assign(q,w,A),q}class E{#t;#e=new Map;#n;constructor(A=256,q=null){this.#t=A,this.#n=q}get size(){return this.#e.size}get max(){return this.#t}set max(A){this.#t=A,this.#r()}has(A){return this.#e.has(A)}get(A){const q=this.#e;if(!q.has(A))return;const le=q.get(A);return q.delete(A),q.set(A,le),le}peek(A){return this.#e.get(A)}set(A,q){const le=this.#e;return le.has(A)&&le.delete(A),le.set(A,q),this.#r(),q}delete(A){const q=this.#e.get(A);return this.#e.delete(A)&&this.#n&&this.#n(q,A),q}clear(){if(this.#n)for(const[A,q]of this.#e)this.#n(q,A);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const A=this.#e;for(;A.size>this.#t;){const q=A.keys().next().value,le=A.get(q);A.delete(q),this.#n&&this.#n(le,q)}}}const Z=new Map;function R(w,A){const q=`${w||""}|${A?JSON.stringify(A):""}`;let le=Z.get(q);return le||(le=new Intl.Collator(w||void 0,{numeric:!0,sensitivity:"variant",...A}),Z.set(q,le)),le}function v(w,A){if(w===A)return 0;if(w==null)return 1;if(A==null)return-1;if(typeof w=="number"&&typeof A=="number")return Number.isNaN(w)?Number.isNaN(A)?0:1:Number.isNaN(A)||w<A?-1:w>A?1:0;const q=String(w),le=String(A);return q<le?-1:q>le?1:0}function U(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const V=typeof requestAnimationFrame=="function";function $(w){return V?requestAnimationFrame(w):setTimeout(()=>w(U()),16)}function ee(w){w!=null&&(V?cancelAnimationFrame(w):clearTimeout(w))}function ne(w){let A=null,q=null;const le=()=>{A=null;const de=q;q=null,w(...de||[])},ae=(...de)=>{q=de,A===null&&(A=$(le))};return ae.cancel=()=>{ee(A),A=null,q=null},ae.flush=()=>{A!==null&&(ee(A),le())},ae}function ce(w,A){let q=null,le=null;const ae=()=>{if(q=null,le===null)return;const ge=le;le=null,w(...ge),de()},de=()=>{q=setTimeout(ae,A),typeof q?.unref=="function"&&q.unref()},pe=(...ge)=>{q===null?(w(...ge),de()):(le=ge,clearTimeout(q),de())};return pe.flush=()=>{if(q!==null&&clearTimeout(q),q=null,le===null)return;const ge=le;le=null,w(...ge)},pe.cancel=()=>{q!==null&&clearTimeout(q),q=null,le=null},pe.pending=()=>q!==null||le!==null,pe}function p(w,A=50){return typeof requestIdleCallback=="function"?requestIdleCallback(w,{timeout:A}):setTimeout(()=>w({timeRemaining:()=>0,didTimeout:!0}),1)}let B=0;function H(w="l"){return`${w}${(++B).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 te}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return x}}),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 oe}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,X=fe.isFunction,z=1,te=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"}),x=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?re(s.dict):null,offsets:s.offsets??null,version:s.version??0}}function re(s){return Array.isArray(s)?s:X(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 ue{#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 c=0;c<u.length;c++){let t=u[c];for(;t;)t&=t-1,f++}return f}}class oe{#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 c=this.#t.length;return this.#t.push(u),this.#e.set(u,c),this.#n++,c}valueOf(u){return this.#t[u]}values(){return this.#t}ranks(u){const f=u||"",c=this.#r.get(f);if(c&&c.version===this.#n)return c.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 l=e[r],g=e[n];return l===g?0:l==null?1:g==null?-1:m(String(l),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 Y(s){if(s==null)return null;const u=s.presence?new ue(s.presence,s.presenceBits||s.presence.length*8):null,f=s.dict?new oe(s.dict):null,c=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(c[e]):c[e];case"bitset":return(c[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(c[n]):c[n];return r}default:return c[e]}};return{id:s.id,kind:a,nullable:s.nullable,values:c,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]=Y(s[f]);return u}function Q(){const s=[],u=[];return{mask(f){for(let c=0;c<s.length;c++)if(s[c].length>=f){const t=s.splice(c,1)[0].subarray(0,f);return t.fill(0),t}return new Uint8Array(f)},indices(f){for(let c=0;c<u.length;c++)if(u[c].length>=f)return u.splice(c,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 _(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=c=>{if(!_(c))return;const t=c.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 c of s)f(c);return u}if(typeof s=="object")for(const c of Object.keys(s)){const t=s[c];if(Array.isArray(t))for(const a of t)f(a);else f(t)}return u}function M(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 c of s)if(!M(c,u+1))return!1;return!0}for(const c of Object.keys(s))if(!M(s[c],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 c=f.conditions;if(Array.isArray(c))for(const t of c)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 te=Math.max(0,z|0);this.#n=te,this.#e=new Uint8Array(Math.ceil(te/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,te){return te?this.set(z):this.clear(z)}fill(z=!1){return this.#e.fill(z?255:0),z&&this.#r(),this}grow(z){const te=Math.max(0,z|0);if(te<=this.#n)return this;const x=Math.ceil(te/fe);if(x>this.#e.length){const T=new Uint8Array(x);T.set(this.#e),this.#e=T}return this.#n=te,this}count(){const z=this.#e,te=he.#t;let x=0;for(let T=0;T<z.length;T++)x+=te[z[T]];return x}and(z){const te=z instanceof he?z.words:z,x=this.#e,T=Math.min(x.length,te.length);for(let K=0;K<T;K++)x[K]&=te[K];for(let K=T;K<x.length;K++)x[K]=0;return this}or(z){const te=z instanceof he?z.words:z,x=this.#e,T=Math.min(x.length,te.length);for(let K=0;K<T;K++)x[K]|=te[K];return this}not(){const z=this.#e;for(let te=0;te<z.length;te++)z[te]=~z[te]&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 te=this.#n>>3;te<this.#e.length&&(this.#e[te]&=(1<<z)-1)}static from(z){const te=Array.isArray(z)?z:Array.from(z),x=new he(te.length);for(let T=0;T<te.length;T++)te[T]&&x.set(T);return x}}}),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,X=fe.defaultCompare;class z{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(x=[]){this.#t=[];for(let T=0;T<x.length;T++){const K=x[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 x=this.#t.length*8;for(let T=0;T<this.#t.length;T++){const K=this.#t[T];typeof K=="string"&&(x+=K.length*2),x+=16}return x}codeOf(x){const T=this.#e.get(x);if(T!==void 0)return T;const K=this.#t.length;return this.#t.push(x),this.#e.set(x,K),this.#n++,K}lookup(x){const T=this.#e.get(x);return T===void 0?-1:T}has(x){return this.#e.has(x)}valueOf(x){return this.#t[x]}values(){return this.#t}ranks(x){const T=x||"";if(this.#r&&this.#i===this.#n&&this.#s===T)return this.#r;const K=this.#t.length,re=new Array(K);for(let Y=0;Y<K;Y++)re[Y]=Y;const J=he(x).compare,ue=this.#t;re.sort((Y,L)=>this.#h(ue[Y],ue[L],J));const oe=new Uint32Array(K);for(let Y=0;Y<K;Y++)oe[re[Y]]=Y;return this.#r=oe,this.#i=this.#n,this.#s=T,oe}#h(x,T,K){return typeof x=="string"&&typeof T=="string"?K(x,T):X(x,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(X={}){const z=Math.max(1,X.rows??16),te=Math.max(1,X.values??z);this.#t=new Int32Array(te),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(X){return X<0||X>=this.#n?0:this.#e[X+1]-this.#e[X]}at(X){return X<0||X>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[X],this.#e[X+1])}has(X,z){if(X<0||X>=this.#n)return!1;const te=this.#t,x=this.#e[X+1];for(let T=this.#e[X];T<x;T++)if(te[T]===z)return!0;return!1}hasAny(X,z){for(let te=0;te<z.length;te++)if(this.has(X,z[te]))return!0;return!1}hasAll(X,z){for(let te=0;te<z.length;te++)if(!this.has(X,z[te]))return!1;return!0}hasNone(X,z){return!this.hasAny(X,z)}push(X){const z=this.#n,te=X.length;this.#i(z+1),this.#s(this.#r+te);const x=this.#r;for(let T=0;T<te;T++)this.#t[x+T]=X[T]|0;return this.#r+=te,this.#n=z+1,this.#e[z]=x,this.#e[z+1]=this.#r,z}write(X,z){if(X===this.#n){this.push(z);return}if(X<0||X>this.#n)return;const te=this.#e[X],x=this.#e[X+1],T=z.length;if(x-te===T){for(let K=0;K<T;K++)this.#t[te+K]=z[K]|0;return}this.#h(X,z)}compact(X,z,te){const x=this.#t,T=this.#e,K=this.#n,re=new Int32Array(Math.max(1,this.#r)),J=new Uint32Array(z+1);let ue=0;for(let oe=0;oe<K;oe++){if(X[oe]===te)continue;const Y=T[oe],L=T[oe+1];J[X[oe]]=ue;for(let Q=Y;Q<L;Q++)re[ue++]=x[Q];J[X[oe]+1]=ue}this.#t=re,this.#e=J,this.#n=z,this.#r=ue}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(X){if(X+1<=this.#e.length)return;let z=this.#e.length-1;for(;z<X;)z=z*2||16;const te=new Uint32Array(z+1);te.set(this.#e),this.#e=te}#s(X){if(X<=this.#t.length)return;let z=this.#t.length;for(;z<X;)z=z*2||16;const te=new Int32Array(z);te.set(this.#t),this.#t=te}#h(X,z){const te=this.#t,x=this.#e,T=this.#n,K=z.length-(x[X+1]-x[X]),re=new Int32Array(Math.max(1,this.#r+K)),J=new Uint32Array(x.length);let ue=0;for(let oe=0;oe<T;oe++){if(J[oe]=ue,oe===X)for(let Y=0;Y<z.length;Y++)re[ue++]=z[Y]|0;else for(let Y=x[oe];Y<x[oe+1];Y++)re[ue++]=te[Y];J[oe+1]=ue}this.#t=re,this.#e=J,this.#r=ue}}}),Se("packages/core/src/compute/handle.js",function(o,me){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return M}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,X=fe.defaultCompare,z=fe.warnOnce;function te(i){const s=new Uint32Array(i);for(let u=0;u<i;u++)s[u]=u;return s}function x(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 c=null;typeof s.from=="function"?c=s.from([!1,!0]):(c=new s(8),c.set(1));const t=c&&c.words;t&&t.length&&(t[0]===2?f="lsb":t[0]===64&&(f="msb"))}catch{f="unknown"}return T.set(s,f),f}function re(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:re(i.presence)}function ue(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function oe(i,s){return i?typeof i.valueOf=="function"?i.valueOf(s):typeof i.values=="function"?i.values()[s]:null:null}function Y(i,s){const u=i.offsets,f=i.values;if(!u||!f)return[];const c=u[s],t=u[s+1];if(!(t>c))return[];const a=i.dict,m=new Array(t-c);for(let e=c;e<t;e++)m[e-c]=a?oe(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 c=i.dict;return u?t=>u(t)?oe(c,s[t]):null:t=>oe(c,s[t])}if(f==="bitset"){const c=re(s);return u?t=>u(t)?c(t)===1:null:t=>c(t)===1}if(f==="multi")return u?c=>u(c)?Y(i,c):null:c=>Y(i,c);if(!s&&typeof i.get=="function"){const c=i.get.bind(i);return t=>{const a=c(t);return a===void 0?null:a}}return u?c=>{if(!u(c))return null;const t=s[c];return t===void 0?null:t}:c=>{const t=s[c];return t===void 0?null:t}}function Q(i,s){if(i<s)return-1;if(i>s)return 1;if(i===s){const c=Object.is(i,-0),t=Object.is(s,-0);return c===t?0:c?-1:1}const u=Number.isNaN(i),f=Number.isNaN(s);return u&&f?0:u?1:-1}function _(i){const s=he(i);return(u,f)=>{if(u===f)return 0;const c=typeof u,t=typeof f;if(c==="string"&&t==="string")return s.compare(u,f);if(c==="number"&&t==="number")return Q(u,f);if(c==="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 Q(a,m)}return X(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,c=_(s),t=new Array(f);for(let m=0;m<f;m++)t[m]=m;t.sort((m,e)=>c(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 M(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 c}}),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 E}});const fe=me("packages/core/src/compute/handle.js"),he=fe.bitReader,X=fe.dictRanks,z=fe.dictSize,te=fe.identity,x=fe.isMissing,T=fe.presenceReader,K=fe.rowCount,re=fe.valueComparator,J=fe.valueReader,ue=new Uint32Array(0),oe=new ArrayBuffer(8),Y=new Float64Array(oe),L=new Uint32Array(oe),Q=(Y[0]=-1,(L[1]&2147483648)!==0?1:0),_=Q===1?0:1;function C(R,v){Y[0]=R;let U=L[Q],V=L[_];(U&2147483648)!==0?(U=~U>>>0,V=~V>>>0):U=(U^2147483648)>>>0,v[0]=V,v[1]=U}function M(R,v,U,V){if(V<2)return R;const $=new Uint32Array(256*8);for(let A=0;A<V;A++){const q=v[A],le=U[A];$[q&255]++,$[256+(q>>>8&255)]++,$[512+(q>>>16&255)]++,$[768+(q>>>24&255)]++,$[1024+(le&255)]++,$[1280+(le>>>8&255)]++,$[1536+(le>>>16&255)]++,$[1792+(le>>>24&255)]++}let ee=R,ne=v,ce=U,p=new Uint32Array(V),B=new Uint32Array(V),H=new Uint32Array(V);const w=new Uint32Array(256);for(let A=0;A<8;A++){const q=A<<8,le=(A&3)<<3,ae=A>=4;let de=!1;for(let ke=0;ke<256;ke++)if($[q+ke]===V){de=!0;break}if(de)continue;let pe=0;for(let ke=0;ke<256;ke++)w[ke]=pe,pe+=$[q+ke];for(let ke=0;ke<V;ke++){const Le=ne[ke],Re=ce[ke],Be=(ae?Re:Le)>>>le&255,ze=w[Be]++;p[ze]=ee[ke],B[ze]=Le,H[ze]=Re}let ge=ee;ee=p,p=ge,ge=ne,ne=B,B=ge,ge=ce,ce=H,H=ge}return ee}function i(R,v,U){if(U<2)return R;const V=new Uint32Array(256*4);for(let B=0;B<U;B++){const H=v[B];V[H&255]++,V[256+(H>>>8&255)]++,V[512+(H>>>16&255)]++,V[768+(H>>>24&255)]++}let $=R,ee=v,ne=new Uint32Array(U),ce=new Uint32Array(U);const p=new Uint32Array(256);for(let B=0;B<4;B++){const H=B<<8,w=B<<3;let A=!1;for(let ae=0;ae<256;ae++)if(V[H+ae]===U){A=!0;break}if(A)continue;let q=0;for(let ae=0;ae<256;ae++)p[ae]=q,q+=V[H+ae];for(let ae=0;ae<U;ae++){const de=ee[ae],pe=p[de>>>w&255]++;ne[pe]=$[ae],ce[pe]=de}let le=$;$=ne,ne=le,le=ee,ee=ce,ce=le}return $}function s(R,v,U,V){const $=new Uint32Array(V+1);for(let ce=0;ce<U;ce++)$[v[ce]]++;let ee=0;for(let ce=0;ce<=V;ce++){const p=$[ce];$[ce]=ee,ee+=p}const ne=new Uint32Array(U);for(let ce=0;ce<U;ce++)ne[$[v[ce]]++]=R[ce];return ne}function u(R,v,U,V){return U<2?R:V<=65536||V<=U*2?s(R,v,U,V):i(R,v,U)}function f(R,v){return R.length===v&&R.byteOffset===0?R:Uint32Array.prototype.slice.call(R,0,v)}function c(R,v,U=!1){const V=v||te(R.length),$=V.length;if($<2)return Uint32Array.from(V);const ee=new Uint32Array($),ne=new Uint32Array($),ce=new Uint32Array($),p=new Uint32Array($),B=new Uint32Array(2);let H=0,w=0;for(let le=0;le<$;le++){const ae=V[le],de=R[ae];if(Number.isNaN(de)){p[w++]=ae;continue}C(de,B),U?(ne[H]=~B[0]>>>0,ce[H]=~B[1]>>>0):(ne[H]=B[0],ce[H]=B[1]),ee[H++]=ae}const A=M(ee.subarray(0,H),ne.subarray(0,H),ce.subarray(0,H),H);if(w===0)return f(A,H);const q=new Uint32Array($);return q.set(A.subarray(0,H),0),q.set(p.subarray(0,w),H),q}function t(R,v,U=!1){const V=v||te(R.length),$=V.length;if($<2)return Uint32Array.from(V);const ee=Uint32Array.from(V),ne=new Uint32Array($);for(let ce=0;ce<$;ce++){const p=(R[ee[ce]]^2147483648)>>>0;ne[ce]=U?~p>>>0:p}return f(i(ee,ne,$),$)}function a(R,v,U={}){const V=v||te(K(R,U)),$=V.length;if($<2)return Uint32Array.from(V);const ee=X(R.dict,U.locale),ne=R.values,ce=T(R),p=Math.max(z(R.dict),ee.length),B=p,H=Uint32Array.from(V),w=new Uint32Array($),A=!!U.descending;for(let q=0;q<$;q++){const le=H[q];let ae=ce&&ce(le)===0?B:ee[ne[le]];ae===void 0&&(ae=B),w[q]=A?B-ae:ae}return f(u(H,w,$,p+1),$)}function m(R,v,U){const V=v.length;let $=Uint32Array.from(v);if(V<2)return $;let ee=new Uint32Array(V);for(let ne=1;ne<V;ne<<=1){for(let p=0;p<V;p+=ne<<1){const B=Math.min(p+ne,V),H=Math.min(p+(ne<<1),V);let w=p,A=B,q=p;for(;w<B&&A<H;)ee[q++]=U(R[$[w]],R[$[A]])<=0?$[w++]:$[A++];for(;w<B;)ee[q++]=$[w++];for(;A<H;)ee[q++]=$[A++]}const ce=$;$=ee,ee=ce}return $}function e(R,v,U){const V=he(R.values),$=v.length,ee=new Uint32Array($),ne=U?1:0;let ce=0;for(let p=0;p<$;p++)V(v[p])===ne&&(ee[ce++]=v[p]);for(let p=0;p<$;p++)V(v[p])!==ne&&(ee[ce++]=v[p]);return ee}function d(R,v){const U=R.values,V=R.kind;if((V==="object"||V===void 0)&&(Array.isArray(U)||ArrayBuffer.isView(U))&&!R.presence)return U;const ee=J(R),ne=new Array(K(R)||0);for(let ce=0;ce<v.length;ce++){const p=v[ce];ne[p]=ee(p)}return ne}function h(R,v){for(let U=0;U<v.length;U++)if(typeof R[v[U]]!="string")return!1;return!0}function r(R,v,U,V,$){const ee=R.length,ne=Uint32Array.from(R);if(ee<2||V<1)return ne;const ce=new Uint32Array(ee),p=V-1;for(let B=0;B<ee;B++){const H=U[v[B]];ce[B]=$?p-H:H}return f(u(ne,ce,ee,V),ee)}function n(R,v,U){const V=re(U),$=new Array(v);for(let ne=0;ne<v;ne++)$[ne]=ne;$.sort((ne,ce)=>V(R[ne],R[ce])||ne-ce);const ee=new Uint32Array(v);for(let ne=0;ne<v;ne++)ee[$[ne]]=ne;return ee}function l(R,v,U){const V=v.length,$=new Map,ee=[],ne=new Uint32Array(V);for(let B=0;B<V;B++){const H=R[v[B]];let w=$.get(H);w===void 0&&(w=ee.length,$.set(H,w),ee.push(H)),ne[B]=w}const ce=ee.length,p=n(ee,ce,U.locale);return r(v,ne,p,ce,!!U.descending)}function g(R,v,U){const V=d(R,v);if(v.length>=2&&h(V,v)){const ne=R.stringRank;return ne&&ne.version===R.version&&ne.usable(v,V,U.locale)?ne.sort(v,U):l(V,v,U)}const $=re(U.locale),ee=U.descending?(ne,ce)=>$(ce,ne):$;return m(V,v,ee)}function P(R,v,U){const V=d(R,v),$=U.compare,ne=!!U.descending?(ce,p)=>-$(ce,p,void 0,void 0,!0):(ce,p)=>$(ce,p,void 0,void 0,!1);return m(V,v,ne)}function S(R,v){const U=v.length,V=T(R),$=R.values,ee=R.kind==="float64"&&!!$,ne=R.kind==="object"||R.kind==="multi"||R.kind===void 0;if(!V&&!ee&&!ne)return{present:v,absent:ue};const ce=new Uint32Array(U),p=new Uint32Array(U);let B=0,H=0;if(V&&ee)for(let w=0;w<U;w++){const A=v[w];V(A)===1&&!Number.isNaN($[A])?ce[B++]=A:p[H++]=A}else if(ee&&!V)for(let w=0;w<U;w++){const A=v[w];Number.isNaN($[A])?p[H++]=A:ce[B++]=A}else if(V&&!ne)for(let w=0;w<U;w++){const A=v[w];V(A)===1?ce[B++]=A:p[H++]=A}else{const w=J(R);for(let A=0;A<U;A++){const q=v[A];x(w(q))?p[H++]=q:ce[B++]=q}}return H===0?{present:v,absent:ue}:{present:ce.subarray(0,B),absent:p.subarray(0,H)}}function G(R,v,U){if(v.length===0)return R;const V=new Uint32Array(R.length+v.length);return U?(V.set(v,0),V.set(R,v.length)):(V.set(R,0),V.set(v,R.length)),V}function F(R,v,U={}){const V=v||te(K(R,U));if(!R||V.length<2)return Uint32Array.from(V);const{present:$,absent:ee}=S(R,V);if($.length===0)return Uint32Array.from(V);const ne=!!U.descending;let ce;if(typeof U.compare=="function")ce=P(R,$,U);else switch(R.kind){case"float64":ce=c(R.values,$,ne);break;case"int32":ce=t(R.values,$,ne);break;case"dictionary":ce=a(R,$,U);break;case"bitset":ce=e(R,$,ne);break;default:ce=g(R,$,U);break}return G(ce,ee,!!U.nullsFirst)}function E(R,v,U,V={}){const $=v||[],ee=$.length&&($[0].handle||Z(R,$[0].col))||R&&R[0];let ne=U||te(K(ee,V));for(let ce=$.length-1;ce>=0;ce--){const p=$[ce],B=p.handle||Z(R,p.col)||R&&R[ce];B&&(ne=F(B,ne,{descending:p.descending!==void 0?!!p.descending:p.dir==="desc",nullsFirst:!!p.nullsFirst,locale:p.locale!==void 0?p.locale:V.locale,compare:p.compare}))}return ne instanceof Uint32Array?ne:Uint32Array.from(ne)}function Z(R,v){if(!(!R||v===void 0)){for(let U=0;U<R.length;U++)if(R[U]&&R[U].id===v)return R[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 te}});const fe=me("packages/core/src/compute/sort.js"),he=fe.collateStringRanks,X=fe.rankSortStrings,z=1e5;class te{#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 re=0;re<K.length;re++)T+=K[re].length*2+24;return T}#a(T,K){const re=this.#e.get(T);if(re!==void 0)return re;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 re=K|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(re);for(let J=0;J<re;J++){const ue=T[J],oe=typeof ue=="string"?this.#a(ue,!1):-1;this.#n[J]=oe<0?0:oe}this.#r=re}append(T,K,re){const J=(K|0)+(re|0);if(J>this.#n.length){const ue=new Uint32Array(J);ue.set(this.#n.subarray(0,this.#r)),this.#n=ue}for(let ue=K|0;ue<J;ue++){const oe=T[ue],Y=typeof oe=="string"?this.#a(oe,!0):-1;this.#n[ue]=Y<0?0:Y}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 re=he(this.#t,this.#t.length,T);return this.#o=re,this.#c=this.#i,this.#l=K,re}usable(T,K,re){if(this.#u||this.#t.length===0)return!1;const J=this.#n,ue=this.#t,oe=this.#r;for(let Y=0;Y<T.length;Y++){const L=T[Y];if(L>=oe||ue[J[L]]!==K[L])return!1}return!0}sort(T,K){const re=this.ranks(K.locale),J=this.#t.length,ue=T.length,oe=new Uint32Array(ue),Y=this.#n;for(let L=0;L<ue;L++)oe[L]=Y[T[L]];return X(T,oe,re,J,!!K.descending)}}}),Se("packages/core/src/store/columnstore.js",function(o,me){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return Y}}),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,X=fe.isFunction,z=fe.pathGetter,x=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,oe=me("packages/core/src/store/stringrank.js").StringRankIndex,Y=4294967295,L=1024,Q=5e3,_=.2,C=new Set(["float64","int32","bitset","dictionary","object","multi"]);function M(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 M(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 c(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 l=d;l<h;l++)n[l-d]=r[m.values[l]];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=X(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 oe(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,l=this.#m;let g=!1;switch(this.#e){case"float64":{const P=this.#o;for(let S=0;S<h;S++){const G=r(e[S]);if(typeof G=="number"){n&&l.set(d+S),P[d+S]=G;continue}const F=G==null;n?l.assign(d+S,!F):F&&(g=!0),P[d+S]=F?NaN:i(G)}break}case"int32":{const P=this.#o;for(let S=0;S<h;S++){const G=r(e[S]),F=G==null;n?l.assign(d+S,!F):F&&(g=!0),P[d+S]=F?0:s(G)}break}case"bitset":{const P=this.#c;for(let S=0;S<h;S++){const G=r(e[S]),F=G==null;n?l.assign(d+S,!F):F&&(g=!0),P.assign(d+S,!F&&!!G)}break}case"dictionary":{const P=this.#o,S=this.#a;for(let G=0;G<h;G++){const F=r(e[G]),E=F==null;n?l.assign(d+G,!E):E&&(g=!0),P[d+G]=E?0:S.codeOf(F)}break}case"multi":{const P=this.#l,S=this.#a;for(let G=0;G<h;G++){const F=r(e[G]),E=F==null;n?l.assign(d+G,!E):E&&(g=!0);const Z=u(F),R=new Array(Z.length);for(let v=0;v<Z.length;v++)R[v]=S.codeOf(Z[v]);P.write(d+G,R)}break}default:{const P=this.#o;for(let S=0;S<h;S++){const G=r(e[S]),F=G==null;n?l.assign(d+S,!F):F&&(g=!0),P[d+S]=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 l=e.kind===this.#e;if(l&&(this.#e==="float64"||this.#e==="int32")){this.#o.set(e.values,d),this.#f++;return}if(l&&this.#e==="bitset"){const g=e.values;for(let P=0;P<h;P++)this.#c.assign(d+P,(g[P>>3]&1<<(P&7))!==0);this.#f++;return}if(l&&this.#e==="dictionary"){const g=e.table||[],P=new Uint32Array(g.length);for(let E=0;E<g.length;E++)P[E]=this.#a.codeOf(g[E]);const S=e.values,G=this.#o,F=r;for(let E=0;E<h;E++){if(F&&(n&&(n[E>>3]&1<<(E&7))===0)){G[d+E]=0;continue}G[d+E]=P[S[E]]??0}this.#f++;return}if(l&&this.#e==="multi"){const g=e.table||[],P=new Uint32Array(g.length);for(let F=0;F<g.length;F++)P[F]=this.#a.codeOf(g[F]);const S=e.values,G=e.offsets;for(let F=0;F<h;F++){const E=G[F],Z=G[F+1],R=new Array(Z-E);for(let v=E;v<Z;v++)R[v-E]=P[S[v]]??0;this.#l.write(d+F,R)}this.#f++;return}for(let g=0;g<h;g++){const P=n?(n[g>>3]&1<<(g&7))===0:e.kind==="object"?e.values[g]===null:!1;this.#A(d+g,P?null:c(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 l=r!==null&&r.get(n)===0;l&&e!=="multi"||this.#A(n,l?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[l,g]of r)e[l]!==Y&&n.set(e[l],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]!==Y&&(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]!==Y&&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,Y);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<d;n++)e[n]!==Y&&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 x(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 x(d)),this.#p=d}#A(e,d){const h=M(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 l=0;l<r.length;l++)n[l]=this.#a.codeOf(r[l]);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 x(e):null;for(let r=0;r<e;r++){const n=this.#M(r);d[r]=n,h&&!M(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 x(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??Q:0,this.#w=d.compactRatio??_;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 l=0;l<r;l++)this.#r[h+l]=d[l];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 l of e.columns)n.set(l.id,l);for(const l of this.#n){const g=n.get(l.id);g?l.appendPacked(g,h,r):l.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?Y:r++;for(const n of this.#n)n.compact(h,d,r);if(this.#l){const n=this.#r;for(let l=0;l<d;l++)h[l]!==Y&&(n[h[l]]=n[l]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new x(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 ue}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return C}});const fe=me("packages/core/src/internal/util.js"),he=fe.now,X=fe.nextFrame,z=fe.infoOnce,te=fe.warnOnce,x=fe.isFunction,T=fe.pathGetter,re=me("packages/core/src/store/columnstore.js").ColumnStore,J=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function ue(M,i={}){if(i.multi)return"multi";if(M.length===0)return"object";let s=0,u=0,f=0,c=0,t=0;for(let m=0;m<M.length;m++){const e=M[m];typeof e=="number"?s++:typeof e=="boolean"?u++:typeof e=="string"?f++:e instanceof Date?c++:Array.isArray(e)&&t++}const a=M.length;return s===a?"float64":u===a?"bitset":c===a?"float64":f===a?"text":t===a?"multi":"object"}function oe(M,i,s){return i<=0||M<s*i?"dictionary":"object"}function Y(M,i,s){const u=new Map,f=new Map;for(const l of M){if(l.computed)continue;const g=x(l.read)?l.read:T(l.field||l.id);f.set(l.id,g),u.set(l.id,g)}const c=i?.order??[],t=i?.fns??{},a=i?.deps??{},m=i?.wrapDeps??null,e=c.filter(l=>x(t[l])),d=e.some(l=>a[l]==="*");let h=new WeakMap;const r=l=>{const g={};if(d)for(const[P,S]of f)g[P]=S(l);for(const P of e){const S=a[P];let G;if(S==="*")G=g;else{G={};const F=S||[];for(let E=0;E<F.length;E++){const Z=F[E];G[Z]=Z in g?g[Z]:f.get(Z)?.(l)}}g[P]=t[P](m?m(G,P):G,{data:l,row:null,column:null,grid:null,context:s})}return g},n=l=>{if(l===null||typeof l!="object"&&typeof l!="function")return r(l);let g=h.get(l);return g===void 0&&(g=r(l),h.set(l,g)),g};for(const l of e)u.set(l,g=>n(g)[l]);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 Q{#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=Y(f,s.computed??null,s.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(f,s.computed??null),this.#n=new re(this.#e.map(c=>({id:c.spec.id,kind:c.kind,nullable:c.nullable,read:c.read,dictionary:c.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 c=Math.min(this.#i+u,f);this.#n.append(this.#t.slice(this.#i,c)),this.#a(this.#i,c),this.#i=c,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),c=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))){te(`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)??(x(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=ue(d,{multi:a.multi});if(h==="text"){const r=new Set(d).size;e.kind=oe(r,d.length,c),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 c=f.distinct;for(let t=i;t<s;t++){const a=f.read(u[t]);a!=null&&c.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 c=this.#d(f);if(f.kind==="dictionary"&&c>=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=`${c} distinct values is at or above ${s*100}% of ${u} rows`;continue}if(f.kind==="object"&&c>=s*u){f.candidate=!1,f.distinct=null,f.reason=`${c} distinct values is at or above ${s*100}% of ${u} rows`;continue}i&&f.kind==="object"&&c<s*u&&(this.#n.convert(f.spec.id,"dictionary"),f.kind="dictionary",f.change=f.change==="demoted"?null:"promoted",f.reason=`${c} distinct values is below ${s*100}% of ${u} rows`,f.distinct=null),i&&(f.candidate=!1)}}}async function _(M,i={},s={}){const u=new Q(M,i,s),f=s.scheduler?.frame??X;for(;u.slice();)await new Promise(c=>{f(c)});return u.result()}function C(M,i={},s={}){const u=new Q(M,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 Q}});const he=me("packages/core/src/internal/util.js").pathGetter,X=me("packages/core/src/store/ingest.js"),z=X.inferKind,te=X.decideText,x=X.INGEST_DEFAULTS,K=me("packages/core/src/store/columnstore.js").toFloat,re=new Set(["float64","int32","bitset","dictionary","object","multi"]);function J(_){if(!Array.isArray(_)||_.length===0)return!1;for(const C of _)if(!C||typeof C.id!="string"||typeof C.field!="string"||C.field===""||C.kind&&!re.has(C.kind))return!1;return!0}function ue(_){const C=K(_);return Number.isFinite(C)?C|0:0}function oe(_){return _==null?[]:Array.isArray(_)?_:[_]}function Y(_,C,M,i){if(_.kind)return _.kind;const s=[];for(let c=0;c<C.length&&s.length<x.sampleSize;c++){const t=C[c];t!=null&&s.push(t)}const u=z(s,{multi:_.multi});if(u!=="text")return u;const f=new Set(s).size;return te(f,s.length,i)}function L(_,C,M={}){const i=C.length|0,s=M.dictionaryRatio??x.dictionaryRatio,u=[];for(const f of _){const c=he(f.field||f.id),t=f.nullable!==!1,a=new Array(i);for(let r=0;r<i;r++){const n=c(C[r]);a[r]=n===void 0?null:n}const m=Y(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 l=a[n],g=l===null;g||d(n),r[n]=g?NaN:K(l)}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 l=a[n],g=l===null;g||d(n),r[n]=g?0:ue(l)}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 l=a[n],g=l===null;g||d(n),!g&&l&&(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=[],l=new Map;for(let g=0;g<i;g++){const P=a[g];if(P===null){r[g]=0;continue}d(g);let S=l.get(P);S===void 0&&(S=n.length,n.push(P),l.set(P,S)),r[g]=S}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:n};break}case"multi":{const r=[],n=new Map,l=new Uint32Array(i+1),g=[];for(let P=0;P<i;P++){const S=a[P];l[P]=g.length,S===null||d(P);const F=oe(S);for(let E=0;E<F.length;E++){const Z=F[E];let R=n.get(Z);R===void 0&&(R=r.length,r.push(Z),n.set(Z,R)),g.push(R)}}l[i]=g.length,h={id:f.id,kind:m,nullable:t,values:Int32Array.from(g),presence:e,offsets:l,table:r};break}default:{const r=new Array(i);for(let n=0;n<i;n++){const l=a[n];l!==null&&d(n),r[n]=l}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 Q(_){const C=[];if(!_||!Array.isArray(_.columns))return C;const M=i=>{ArrayBuffer.isView(i)&&i.buffer&&!C.includes(i.buffer)&&C.push(i.buffer)};for(const i of _.columns)M(i.values),M(i.presence),M(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 X}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return te}});function fe(x){return{locale:x===void 0?void 0:String(x),numeric:!0,sensitivity:"variant"}}function he(x){return!!x&&typeof x.compare!="function"}function X(x){if(!x)return!0;for(let T=0;T<x.length;T++)if(!he(x[T]))return!1;return!0}function z(x,T){const K=x.col!==void 0?x.col:x.handle&&x.handle.id,re=x.locale!==void 0?x.locale:T;return{col:K,descending:x.descending!==void 0?!!x.descending:x.dir==="desc",nullsFirst:!!x.nullsFirst,collation:fe(re)}}function te(x,T){const K=x||[],re=new Array(K.length);for(let J=0;J<K.length;J++)re[J]=z(K[J],T);return re}}),Se("packages/core/src/format/date.js",function(o,me){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return te}}),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 oe}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return Y}}),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,X=fe.warnOnce,z=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function te(M){const i=[];let s=0,u="";const f=()=>{u&&(i.push({token:null,text:u}),u="")};for(;s<M.length;){const c=M[s];if(c==="\'"){if(M[s+1]==="\'"){u+="\'",s+=2;continue}const a=M.indexOf("\'",s+1);if(a===-1){u+=M.slice(s+1),s=M.length;continue}u+=M.slice(s+1,a),s=a+1;continue}const t=z.find(a=>M.startsWith(a,s));if(t){f(),i.push({token:t,text:t}),s+=t.length;continue}/[A-Za-z]/.test(c)&&X(`date.pattern.token:${c}`,`the date pattern "${M}" contains \'${c}\', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${z.join(" ")}.`),u+=c,s+=1}return f(),i}const x=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function T(M){if(he(M)||M==="")return null;if(M instanceof Date)return Number.isNaN(M.getTime())?null:M;if(typeof M=="number")return Number.isNaN(M)?null:new Date(M);if(typeof M=="string"){const i=x.exec(M.trim());if(i){const[,u,f,c,t="0",a="0",m="0"]=i;return new Date(+u,+f-1,+c,+t,+a,+m)}const s=new Date(M);return Number.isNaN(s.getTime())?null:s}return null}function K(M,i){return String(M).padStart(i,"0")}function re(M){if(!M)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:M,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 c of i.formatToParts(u))switch(c.type){case"year":f.year=Number(c.value);break;case"month":f.month=Number(c.value);break;case"day":f.day=Number(c.value);break;case"hour":f.hour=Number(c.value)%24;break;case"minute":f.minute=Number(c.value);break;case"second":f.second=Number(c.value);break;case"weekday":f.weekday=s[c.value]??0;break;default:break}return f}}function J(M,i,s){const u=te(M),f=re(s),c=new Set(u.filter(d=>d.token).map(d=>d.token)),t=c.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:s}):null,a=c.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:s}):null,m=c.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:s}):null,e=c.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 ue=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function oe(M,i){const s=M||{},u=s.locale||i||void 0,f=s.nullDisplay??"",c=s.timeZone;let t;if(s.pattern)t=J(s.pattern,u,c);else if(s.dateStyle||s.timeStyle){const h={timeZone:c};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:c});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 l=r&&typeof r.now=="number"?r.now:Date.now(),g=n.getTime()-l;if(Math.abs(g)<e){for(const[P,S]of ue)if(Math.abs(g)>=S||P==="second")return a.format(Math.round(g/S),P)}}return t(n)};return d.spec=s,d}function Y(M){if(he(M)||M==="")return null;if(typeof M=="string"){const u=/^(\\d{4}-\\d{2}-\\d{2})/.exec(M.trim());if(u)return u[1];const f=T(M);return f?Y(f):null}const i=T(M);if(!i)return null;const s=u=>String(u).padStart(2,"0");return`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}`}function L(M,i){if(he(M)||M==="")return null;if(typeof M=="string"){const u=M.trim();if(Q.test(u)){const t=T(u);return t?_(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 c=T(u);return c?L(c):null}const s=T(M);return s?_(s,i):null}const Q=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function _(M,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(M).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=`${M.getFullYear()}-${s(M.getMonth()+1)}-${s(M.getDate())}`,f=M.getSeconds(),c=`${s(M.getHours())}:${s(M.getMinutes())}${f?`:${s(f)}`:""}`;return`${u}T${c}`}function C(M,i){const s=he(M)||M===""?null:String(M),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 Z}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"declareOperators",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"declaredOperator",{enumerable:!0,get:function(){return ce}});const fe=me("packages/core/src/internal/util.js"),he=fe.isBlank,X=fe.toArray,z=fe.warnOnce,x=me("packages/core/src/format/date.js").toIsoDate,T=me("packages/core/src/compute/handle.js"),K=T.bitReader,re=T.dictSize,J=T.dictValue,ue=T.presenceReader,oe=T.valueComparator,Y=T.valueReader,L=/^\\d{4}-\\d{2}-\\d{2}$/,Q="\\0null\\0";function _(p,B){const H=p&&p.pool;if(H){const w=H.mask||H.acquireMask||H.acquire||H.take;if(typeof w=="function"){const A=w.call(H,B);if(A&&A.length>=B)return A}}return new Uint8Array(B)}function C(p,B){const H=p&&p.pool;if(!H||!B)return;const w=H.release||H.releaseMask||H.free||H.recycle;typeof w=="function"&&w.call(H,B)}function M(p,B,H){return p.fill(H,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 H=x(p);return H===null?u(p):H}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 c(p,B){const H=typeof p=="string"?p:String(p);return B?H:H.toLowerCase()}function t(p,B){return p==null?Q:typeof p=="string"?B?p:p.toLowerCase():p instanceof Date?p.getTime():p}function a(p,B,H){const w=new Set;for(const A of X(p)){const q=s(A,H);w.add(t(q,B)),typeof q=="string"&&q!==""&&Number.isFinite(Number(q))?w.add(Number(q)):typeof q=="number"&&Number.isFinite(q)&&w.add(t(String(q),B))}return w}function m(p,B,H){if(p==null||B===null||B===void 0)return p==null&&B==null;const w=typeof p,A=typeof B;return w==="string"&&A==="string"?H?p===B:p.toLowerCase()===B.toLowerCase():p instanceof Date||B instanceof Date?u(p)===u(B):w==="number"&&A==="number"?p===B||Number.isNaN(p)&&Number.isNaN(B):w==="number"&&A==="string"?p===Number(B):w==="string"&&A==="number"?Number(p)===B:w==="boolean"||A==="boolean"?p===B:Array.isArray(p)&&Array.isArray(B)?p.length===B.length&&p.every((q,le)=>m(q,B[le],H)):p===B}function e(p,B){try{if(p instanceof RegExp){const H=p.flags.replace(/[gy]/g,"");return new RegExp(p.source,B||H.includes("i")?H:`${H}i`)}return new RegExp(String(p),B?"":"i")}catch(H){return z(`regex:${String(p)}`,`filter operator "matches" received an invalid pattern: ${String(p)}`,H),null}}function d(p,B){const H=h(p,B),w=p&&p.type;return w!=="date"&&w!=="dateString"?H:A=>H(typeof A=="string"&&L.test(A)?A:x(A)??A)}function h(p,B){const H=p&&p.op,w=!!(p&&p.caseSensitive),A=p&&p.type,q=oe(B),le=ae=>de=>!ae(de);switch(H){case"eq":{const ae=s(p.value,A);return de=>m(de,ae,w)}case"ne":{const ae=s(p.value,A);return de=>!m(de,ae,w)}case"lt":case"lte":case"gt":case"gte":{const ae=s(p.value,A);if(i(ae))return()=>!1;const de=H==="lt"?-1:H==="lte"?0:H==="gt"?1:2;return pe=>{if(i(pe))return!1;const ge=q(pe,ae);return de===-1?ge<0:de===0?ge<=0:de===1?ge>0:ge>=0}}case"between":case"notBetween":{const ae=X(p.value),de=s(ae[0],A),pe=s(ae[1],A),ge=p.bounds||"[]",ke=ge.charAt(0)!=="(",Le=ge.charAt(1)!==")";if(i(de)||i(pe))return H==="between"?()=>!1:()=>!0;const Re=Be=>{if(i(Be))return!1;const ze=q(Be,de),Ke=q(Be,pe);return(ke?ze>=0:ze>0)&&(Le?Ke<=0:Ke<0)};return H==="between"?Re:le(Re)}case"in":case"notIn":{const ae=a(p.value,w,A),de=pe=>ae.has(t(pe,w));return H==="in"?de:le(de)}case"contains":case"notContains":{const ae=c(s(p.value,A),w),de=pe=>pe==null?!1:c(pe,w).includes(ae);return H==="contains"?de:le(de)}case"startsWith":{const ae=c(s(p.value,A),w);return de=>de==null?!1:c(de,w).startsWith(ae)}case"endsWith":{const ae=c(s(p.value,A),w);return de=>de==null?!1:c(de,w).endsWith(ae)}case"matches":{const ae=e(p.value,w);return ae?de=>de==null?!1:ae.test(String(de)):()=>!1}case"blank":return ae=>he(ae)||Array.isArray(ae)&&ae.length===0;case"notBlank":return ae=>!(he(ae)||Array.isArray(ae)&&ae.length===0);case"containsAny":case"containsNone":{const ae=a(p.value,w,A),de=pe=>{const ge=pe==null?[]:X(pe);for(let ke=0;ke<ge.length;ke++)if(ae.has(t(ge[ke],w)))return!0;return!1};return H==="containsAny"?de:le(de)}case"containsAll":{const ae=X(p.value).map(de=>t(s(de,A),w));return de=>{const pe=de==null?[]:X(de);if(ae.length===0)return!0;const ge=new Set(pe.map(ke=>t(ke,w)));for(let ke=0;ke<ae.length;ke++)if(!ge.has(ae[ke]))return!1;return!0}}default:{const ae=ce(H);return ae?ae.compile(p.value):(z(`op:${String(H)}`,`unknown filter operator "${String(H)}"; the condition is refused rather than matching every row`),()=>!1)}}}function r(p,B,H){return d(B,H)(p)}const n=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),l=new Set(["containsAny","containsAll","containsNone"]);function g(p,B,H){const w=p&&p.op,A=n[w]||w,q=d({...p,op:A,type:B.type},H),le=B.items,ae=de=>{const pe=le(de);if(!pe)return!1;for(let ge=0;ge<pe.length;ge++)if(q(pe[ge]))return!0;return!1};return n[w]?de=>!ae(de):ae}function P(p,B,H,w){const A=ue(p);if(A){const ae=B?1:0;for(let de=0;de<w;de++)H[de]=A(de)===ae?1:0;return H}const q=p.kind;if(q==="float64"||q==="int32"||q==="bitset")return M(H,w,B?1:0);const le=Y(p);for(let ae=0;ae<w;ae++){const de=le(ae),pe=he(de)||Array.isArray(de)&&de.length===0;H[ae]=pe===B?0:1}return H}function S(p,B,H,w){const A=p.dict,q=re(A),le=new Uint8Array(q);for(let ge=0;ge<q;ge++)le[ge]=B(J(A,ge))?1:0;const ae=p.values,de=ue(p);if(!de){for(let ge=0;ge<w;ge++)H[ge]=le[ae[ge]];return H}const pe=B(null)?1:0;for(let ge=0;ge<w;ge++)H[ge]=de(ge)===1?le[ae[ge]]:pe;return H}function G(p,B,H,w){const A=K(p.values),q=B(!0)?1:0,le=B(!1)?1:0,ae=ue(p);if(!ae){for(let pe=0;pe<w;pe++)H[pe]=A(pe)===1?q:le;return H}const de=B(null)?1:0;for(let pe=0;pe<w;pe++)H[pe]=ae(pe)===0?de:A(pe)===1?q:le;return H}function F(p,B,H,w,A){const q=p.values,le=B.type,ae=B.op;let de=!0;switch(ae){case"eq":case"ne":{const ge=f(s(B.value,le)),ke=typeof B.value=="number"&&Number.isNaN(B.value),Le=ae==="ne"?1:0;if(ke)for(let Re=0;Re<A;Re++)w[Re]=(Number.isNaN(q[Re])?1:0)^Le;else for(let Re=0;Re<A;Re++)w[Re]=(q[Re]===ge?1:0)^Le;break}case"lt":{const ge=f(s(B.value,le));for(let ke=0;ke<A;ke++)w[ke]=q[ke]<ge?1:0;break}case"lte":{const ge=f(s(B.value,le));for(let ke=0;ke<A;ke++)w[ke]=q[ke]<=ge?1:0;break}case"gt":{const ge=f(s(B.value,le));for(let ke=0;ke<A;ke++)w[ke]=q[ke]>ge?1:0;break}case"gte":{const ge=f(s(B.value,le));for(let ke=0;ke<A;ke++)w[ke]=q[ke]>=ge?1:0;break}case"between":case"notBetween":{const ge=X(B.value),ke=f(s(ge[0],le)),Le=f(s(ge[1],le)),Re=B.bounds||"[]",Be=Re.charAt(0)!=="(",ze=Re.charAt(1)!==")",Ke=ae==="notBetween"?1:0;if(Be&&ze)for(let Te=0;Te<A;Te++)w[Te]=(q[Te]>=ke&q[Te]<=Le?1:0)^Ke;else if(Be)for(let Te=0;Te<A;Te++)w[Te]=(q[Te]>=ke&q[Te]<Le?1:0)^Ke;else if(ze)for(let Te=0;Te<A;Te++)w[Te]=(q[Te]>ke&q[Te]<=Le?1:0)^Ke;else for(let Te=0;Te<A;Te++)w[Te]=(q[Te]>ke&q[Te]<Le?1:0)^Ke;break}case"in":case"notIn":{const ge=new Set;for(const Le of X(B.value)){const Re=f(s(Le,le));Number.isNaN(Re)||ge.add(Re)}const ke=ae==="notIn"?1:0;for(let Le=0;Le<A;Le++)w[Le]=(ge.has(q[Le])?1:0)^ke;break}default:de=!1;break}if(!de)return!1;const pe=ue(p);if(pe){const ge=H(null)?1:0;for(let ke=0;ke<A;ke++)pe(ke)===0&&(w[ke]=ge)}return!0}function E(p,B,H,w){const A=Y(p);for(let q=0;q<w;q++)H[q]=B(A(q))?1:0;return H}function Z(p,B,H){const w=B.count|0,A=H||_(B,w);if(!p)return M(A,w,1);const q=typeof B.handle=="function"?B.handle(p.col):void 0,le=typeof B.custom=="function"?B.custom:null;if(!q){if(le){for(let ge=0;ge<w;ge++)A[ge]=le(p,ge)?1:0;return A}return z(`filter:col:${String(p.col)}`,`filter references unknown column "${String(p.col)}"; the condition is refused rather than matching every row`),M(A,w,0)}const ae=p.op;if(ae==="blank"||ae==="notBlank")return P(q,ae==="notBlank",A,w);const de=typeof B.itemwise=="function"?B.itemwise(p.col):null;if(de&&!ce(ae)&&!l.has(ae))return E(q,g(p,de,B.locale),A,w);const pe=d(p,B.locale);switch(q.kind){case"dictionary":return S(q,pe,A,w);case"bitset":return G(q,pe,A,w);case"float64":case"int32":return F(q,p,pe,A,w)?A:E(q,pe,A,w);default:return E(q,pe,A,w)}}function R(p,B,H){if(!p)return M(_(B,H),H,1);if(Array.isArray(p.conditions)){const w=p.conditions.filter(le=>le!=null),A=p.op==="or"?"or":p.op==="not"?"not":"and";if(w.length===0)return M(_(B,H),H,1);const q=R(w[0],B,H);for(let le=1;le<w.length;le++){const ae=R(w[le],B,H);if(A==="or")for(let de=0;de<H;de++)q[de]|=ae[de];else for(let de=0;de<H;de++)q[de]&=ae[de];C(B,ae)}if(A==="not")for(let le=0;le<H;le++)q[le]^=1;return q}return Z(p,B,_(B,H))}function v(p,B){return R(p,B,B.count|0)}function U(p,B){if(!p||!B)return p||null;const H=p;if(Array.isArray(H.conditions)){if((H.op==="or"?"or":H.op==="not"?"not":"and")!=="and")return V(H,B)?null:p;const A=[];for(const q of H.conditions){const le=U(q,B);le&&A.push(le)}return A.length?{...H,op:"and",conditions:A}:null}return H.col===B?null:p}function V(p,B){if(!p||typeof p!="object")return!1;const H=p;if(H.col===B)return!0;if(Array.isArray(H.conditions)){for(const w of H.conditions)if(V(w,B))return!0}return!1}function $(p,B,H){if(H&&H.length>=B){let le=0;for(let ae=0;ae<B;ae++)p[ae]&&(H[le++]=ae);return H.subarray(0,le)}let w=0;for(let le=0;le<B;le++)w+=p[le]?1:0;const A=new Uint32Array(w);let q=0;for(let le=0;le<B;le++)p[le]&&(A[q++]=le);return A}const ee=new Map;function ne(p){if(!(!p||typeof p!="object"))for(const[B,H]of Object.entries(p))H&&typeof H.compile=="function"&&ee.set(B,H)}function ce(p){return typeof p=="string"?ee.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 oe}});const fe=me("packages/core/src/compute/handle.js"),he=fe.dictSize,X=fe.identity,z=fe.presenceReader,te=fe.rowCount,x=fe.valueReader,T="",K="\\0",re=1<<20;function J(Y,L,Q,_){const C=Y.length,M=Y.map(t=>x(t)),i=Array.isArray(_)&&_.some(Boolean),s=i?M.map((t,a)=>_[a]?m=>_[a](t(m)):t):M;if(!i&&C>0&&Y.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=Y.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=Y.map(r=>r.values),e=Y.map(r=>z(r)),d=r=>{let n=0;for(let l=0;l<C;l++){const g=e[l],P=g&&g(r)===0?t[l]-1:m[l][r];n=n*t[l]+P}return n},h=new Float64Array(Q);for(let r=0;r<Q;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},c=new Array(Q);for(let t=0;t<Q;t++)c[t]=f(L[t]);return{packed:null,strings:c,product:1/0,readers:s,keyOf:f}}function ue(Y,L,Q,_){const C=new Uint32Array(_+1);for(let u=0;u<Q;u++)C[L[u]+1]++;for(let u=0;u<_;u++)C[u+1]+=C[u];const M=new Uint32Array(Q),i=C.slice(0,_);for(let u=0;u<Q;u++)M[i[L[u]]++]=Y[u];const s=new Array(_);for(let u=0;u<_;u++)s[u]=M.subarray(C[u],C[u+1]);return s}function oe(Y,L,Q={}){const _=Y||[],C=L||X(te(_[0],Q)),M=C.length;if(_.length===0||M===0)return{keys:[],buckets:[]};const{packed:i,strings:s,product:u,readers:f}=J(_,C,M,Q.project),c=new Uint32Array(M);let t=0,a=null;if(i&&u<=Math.max(1024,Math.min(re,M*4))){const h=u,r=new Int32Array(h).fill(-1);for(let n=0;n<M;n++)r[i[n]]=0;for(let n=0;n<h;n++)r[n]===0&&(r[n]=t++);for(let n=0;n<M;n++)c[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<M;r++){const n=i[r];let l=h.get(n);l===void 0&&(l=t++,h.set(n,l)),c[r]=l}a=new Float64Array(t);for(const[r,n]of h)a[n]=r}else{const h=new Map;for(let r=0;r<M;r++){const n=s[r];let l=h.get(n);l===void 0&&(l=t++,h.set(n,l)),c[r]=l}}const m=ue(C,c,M,t),e=new Array(t);for(let h=0;h<t;h++){const r=m[h][0],n=new Array(f.length);for(let l=0;l<f.length;l++)n[l]=f[l](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 x}}),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 re}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return Y}}),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 M}}),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,X=fe.valueReader,z=fe.dictSize,te=fe.dictValue,x=Object.freeze(["equal","quantile","log"]),T=Object.freeze(["hour","day","week","month","quarter","year"]),K=20,re=50,J=1e4;function ue(n,l){if(!n)return"none";const g=l;if(g&&(g.multi===!0||typeof g.items=="function"))return"category";const P=l&&l.base;if(P==="date"||P==="datetime"||P==="time"||P==="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 P==="number"?"numeric":P==="boolean"?"boolean":P==="text"?"category":"none"}}function oe(n){const l=n.values,g=n.kind;if((g==="float64"||g==="int32")&&l)return S=>l[S];const P=X(n);return S=>Y(P(S))}function Y(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 l=Number(n);if(Number.isFinite(l))return l;const g=Date.parse(n);return Number.isFinite(g)?g:NaN}return NaN}function L(n,l,g,P=re){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 S=X(n),G=l?l.length:g,F=new Set;for(let E=0;E<G;E++){const Z=S(l?l[E]:E);if(Z!=null&&(F.add(Z),F.size>P))return{cardinality:F.size,exact:!1}}return{cardinality:F.size,exact:!0}}const Q=36e5,_=864e5;function C(n,l=K){const g=Number.isFinite(n)&&n>0?n:0,P=Math.max(1,l)*2;return g/Q<=P?"hour":g/_<=P?"day":g/(7*_)<=P?"week":g/(30*_)<=P?"month":g/(91*_)<=P?"quarter":"year"}function M(n,l){if(!Number.isFinite(n))return NaN;const g=new Date(n);switch(l){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 P=(g.getDay()+6)%7;return g.setDate(g.getDate()-P),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,l){const g=new Date(n);switch(l){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,l,g){const P=oe(n),S=he(n),G=l?l.length:g;let F=1/0,E=-1/0,Z=0,R=0;for(let v=0;v<G;v++){const U=l?l[v]:v;if(S&&!S(U)){Z++;continue}const V=P(U);if(!Number.isFinite(V)){Z++;continue}V<F&&(F=V),V>E&&(E=V),R++}return{min:F,max:E,nulls:Z,finite:R}}function u(n,l,g,P){const S=oe(n),G=he(n),F=l?l.length:g,E=F>P?F/P:1,Z=[];for(let v=0;v<F;v+=E){const U=l?l[Math.floor(v)]:Math.floor(v);if(G&&!G(U))continue;const V=S(U);Number.isFinite(V)&&Z.push(V)}const R=Float64Array.from(Z);return R.sort(),R}function f(n,l,g,P={}){const S=P.kind||ue(n,P.type);return S==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:S==="boolean"?c(n,l,g):S==="category"?t(n,l,g,P):a(n,l,g,S,P)}function c(n,l,g){const P=he(n);let S=0;if(P){const F=l?l.length:g;for(let E=0;E<F;E++)P(l?l[E]:E)||S++}const G=[{value:!1,label:"false"},{value:!0,label:"true"}];return S>0&&G.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:G}}function t(n,l,g,P){const S=P.cardinalityLimit??re,{cardinality:G}=L(n,l,g,S);if(G>S&&(P.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:G};const F=X(n),E=l?l.length:g,Z=new Map;let R=0;for(let ee=0;ee<E;ee++){const ne=F(l?l[ee]:ee);if(ne==null||ne===""){R++;continue}if(Array.isArray(ne)){if(!ne.length){R++;continue}for(const ce of ne)Z.set(ce,(Z.get(ce)||0)+1);continue}Z.set(ne,(Z.get(ne)||0)+1)}let v=[...Z.entries()];P.order==="alpha"?v.sort((ee,ne)=>String(ee[0]).localeCompare(String(ne[0]))):v.sort((ee,ne)=>ne[1]-ee[1]);let U=0,V=0;if(v.length>S){V=v.length-S;for(let ee=S;ee<v.length;ee++)U+=v[ee][1];v=v.slice(0,S)}const $=v.map(([ee])=>({value:ee,label:String(ee)}));return U>0&&$.push({remainder:!0,label:`Other (${V} values)`}),R>0&&$.push({null:!0,label:"Empty"}),{kind:"category",buckets:$,cardinality:G}}function a(n,l,g,P,S){const{min:G,max:F,nulls:E,finite:Z}=s(n,l,g);if(!Z)return{kind:P,buckets:E?[{null:!0,label:"Empty"}]:[],empty:!0};const R=Math.max(1,Math.floor(S.buckets||K));let v=[];if(P==="date"){const V=T.includes(S.granularity)?S.granularity:C(F-G,R);let $=M(G,V);for(;$<=F&&v.length<4096;){const ee=i($,V);if(!(ee>$))break;v.push({from:$,to:ee}),$=ee}return{kind:P,buckets:m(v,E),granularity:V}}const U=x.includes(S.strategy)?S.strategy:"equal";if(U==="quantile"){const V=u(n,l,g,J);if(V.length){const $=[V[0]];for(let ee=1;ee<R;ee++){const ne=V[Math.min(V.length-1,Math.floor(ee/R*V.length))];ne>$[$.length-1]&&$.push(ne)}$.push(F);for(let ee=0;ee<$.length-1;ee++)v.push({from:$[ee],to:$[ee+1]})}}else if(U==="log"&&G>0){const V=Math.log10(G),ee=(Math.log10(F)-V)/R||1;for(let ne=0;ne<R;ne++)v.push({from:10**(V+ne*ee),to:10**(V+(ne+1)*ee)})}if(!v.length){const V=(F-G)/R||1;for(let $=0;$<R;$++)v.push({from:G+$*V,to:G+($+1)*V})}return v[v.length-1].to=F,{kind:P,buckets:m(v,E),strategy:U,min:G,max:F}}function m(n,l){return l>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,l,g,P,S){const G=P&&P.buckets||[],F=S&&S.length>=G.length?S.subarray(0,G.length):new Uint32Array(G.length);if(F.fill(0),!n||!G.length)return F;const E=G.length-1,Z=!!G[E]&&G[E].null===!0,R=l?l.length:g;if(P.kind==="boolean"){const ee=X(n);for(let ne=0;ne<R;ne++){const ce=ee(l?l[ne]:ne);if(ce==null){Z&&F[E]++;continue}F[ce?1:0]++}return F}if(P.kind==="category"){const ee=new Map;for(let p=0;p<G.length;p++)!G[p].null&&!G[p].remainder&&ee.set(G[p].value,p);const ne=G.findIndex(p=>p.remainder),ce=X(n);for(let p=0;p<R;p++){const B=ce(l?l[p]:p);if(B==null||B===""){Z&&F[E]++;continue}if(Array.isArray(B)){if(!B.length){Z&&F[E]++;continue}for(const w of B){const A=ee.get(w);A!==void 0?F[A]++:ne>=0&&F[ne]++}continue}const H=ee.get(B);H!==void 0?F[H]++:ne>=0&&F[ne]++}return F}const v=Z?G.length-1:G.length,U=new Float64Array(v+1);for(let ee=0;ee<v;ee++)U[ee]=G[ee].from;U[v]=v?G[v-1].to:0;const V=oe(n),$=he(n);for(let ee=0;ee<R;ee++){const ne=l?l[ee]:ee;if($&&!$(ne)){Z&&F[E]++;continue}const ce=V(ne);if(!Number.isFinite(ce)){Z&&F[E]++;continue}const p=d(U,v,ce);p>=0&&F[p]++}return F}function d(n,l,g){if(!l||g<n[0])return-1;if(g>=n[l])return g===n[l]?l-1:-1;let P=0,S=l-1;for(;P<S;){const G=P+S+1>>>1;g>=n[G]?P=G:S=G-1}return P}function h(n,l,g,P={}){const S=P.bounds||f(n,P.boundsIndices??l,g,P);return{bounds:S,counts:e(n,l,g,S)}}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 x}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return _}});const fe=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),he=3e-12,X=1e-300;function z(C){if(C<.5)return Math.log(Math.PI/Math.sin(Math.PI*C))-z(1-C);const M=C-1;let i=.9999999999998099;const s=M+7.5;for(let u=0;u<fe.length;u++)i+=fe[u]/(M+u+1);return .5*Math.log(2*Math.PI)+(M+.5)*Math.log(s)-s+Math.log(i)}function te(C,M,i){const s=C+M,u=C+1,f=C-1;let c=1,t=1-s*i/u;Math.abs(t)<X&&(t=X),t=1/t;let a=t;for(let m=1;m<=300;m++){const e=2*m;let d=m*(M-m)*i/((f+e)*(C+e));t=1+d*t,Math.abs(t)<X&&(t=X),c=1+d/c,Math.abs(c)<X&&(c=X),t=1/t,a*=t*c,d=-(C+m)*(s+m)*i/((C+e)*(u+e)),t=1+d*t,Math.abs(t)<X&&(t=X),c=1+d/c,Math.abs(c)<X&&(c=X),t=1/t;const h=t*c;if(a*=h,Math.abs(h-1)<he)break}return a}function x(C,M,i){if(!(C>0)||!(M>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const s=Math.exp(z(C+M)-z(C)-z(M)+C*Math.log(i)+M*Math.log(1-i));return i<(C+1)/(C+M+2)?s*te(C,M,i)/C:1-s*te(M,C,1-i)/M}function T(C){if(!(C>0)||!(C<1))return C===0?-1/0:C===1?1/0:Number.NaN;const M=[-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 c,t,a;C<f?(c=Math.sqrt(-2*Math.log(C)),a=(((((s[0]*c+s[1])*c+s[2])*c+s[3])*c+s[4])*c+s[5])/((((u[0]*c+u[1])*c+u[2])*c+u[3])*c+1)):C<=1-f?(c=C-.5,t=c*c,a=(((((M[0]*t+M[1])*t+M[2])*t+M[3])*t+M[4])*t+M[5])*c/(((((i[0]*t+i[1])*t+i[2])*t+i[3])*t+i[4])*t+1)):(c=Math.sqrt(-2*Math.log(1-C)),a=-(((((s[0]*c+s[1])*c+s[2])*c+s[3])*c+s[4])*c+s[5])/((((u[0]*c+u[1])*c+u[2])*c+u[3])*c+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 M=Math.abs(C),i=2/(2+M),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,c=0,t;for(let m=u.length-1;m>0;m--)t=c,c=s*c-f+u[m],f=t;const a=i*Math.exp(-M*M+.5*(u[0]+s*c)-f);return C>=0?a:2-a}function re(C){return .5*K(-C/Math.SQRT2)}function J(C,M){if(!(M>0)||!Number.isFinite(C))return Number.NaN;const i=.5*x(M/2,.5,M/(M+C*C));return C>0?1-i:i}function ue(C,M){if(!(C>0)||!(C<1)||!(M>0))return Number.NaN;if(M>1e7)return T(C);let i=-1e4,s=1e4,u=T(C);const f=z(M/2)+z(.5)-z((M+1)/2);for(let c=0;c<60;c++){const t=J(u,M);t<C?i=u:s=u;const a=Math.exp(-((M+1)/2)*Math.log(1+u*u/M)-f)/Math.sqrt(M),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 oe(C,M){let i=C,s=1/C,u=s;for(let f=0;f<300&&(i+=1,u*=M/i,s+=u,!(Math.abs(u)<Math.abs(s)*he));f++);return s*Math.exp(-M+C*Math.log(M)-z(C))}function Y(C,M){let i=M+1-C,s=1/X,u=1/i,f=u;for(let c=1;c<=300;c++){const t=-c*(c-C);i+=2,u=t*u+i,Math.abs(u)<X&&(u=X),s=i+t/s,Math.abs(s)<X&&(s=X),u=1/u;const a=u*s;if(f*=a,Math.abs(a-1)<he)break}return Math.exp(-M+C*Math.log(M)-z(C))*f}function L(C,M){return!(C>0)||!(M>=0)||!Number.isFinite(M)?Number.NaN:M===0?0:M<C+1?oe(C,M):1-Y(C,M)}function Q(C,M){return M>0?L(M/2,C/2):Number.NaN}function _(C,M){const i=Q(C,M);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 X}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return x}});function fe(T){const K=T.length,re=Array.from({length:K},()=>new Array(K).fill(0));for(let J=0;J<K;J++)for(let ue=0;ue<=J;ue++){let oe=T[J][ue];for(let Y=0;Y<ue;Y++)oe-=re[J][Y]*re[ue][Y];if(J===ue){if(!(oe>0))return null;re[J][ue]=Math.sqrt(oe)}else re[J][ue]=oe/re[ue][ue]}return re}function he(T,K){const re=T.length,J=new Array(re).fill(0);for(let oe=0;oe<re;oe++){let Y=K[oe];for(let L=0;L<oe;L++)Y-=T[oe][L]*J[L];J[oe]=Y/T[oe][oe]}const ue=new Array(re).fill(0);for(let oe=re-1;oe>=0;oe--){let Y=J[oe];for(let L=oe+1;L<re;L++)Y-=T[L][oe]*ue[L];ue[oe]=Y/T[oe][oe]}return ue}function X(T){const K=T.length,re=Array.from({length:K},()=>new Array(K).fill(0));for(let J=0;J<K;J++){const ue=new Array(K).fill(0);ue[J]=1;const oe=he(T,ue);for(let Y=0;Y<K;Y++)re[Y][J]=oe[Y]}return re}function z(T,K,re){const J=T.length,ue=J?T[0].length:0,oe=Array.from({length:ue},()=>new Array(ue).fill(0)),Y=new Array(ue).fill(0);for(let L=0;L<J;L++){const Q=re?re[L]:1,_=T[L];for(let C=0;C<ue;C++){const M=Q*_[C];Y[C]+=M*K[L];for(let i=C;i<ue;i++)oe[C][i]+=M*_[i]}}for(let L=0;L<ue;L++)for(let Q=0;Q<L;Q++)oe[L][Q]=oe[Q][L];return{xtwx:oe,xtwy:Y}}function te(T,K){return T.map(re=>re.reduce((J,ue,oe)=>J+ue*K[oe],0))}function x(T,K){let re=0;for(let J=0;J<T.length;J++){let ue=0;for(let oe=0;oe<T.length;oe++)ue+=K[J][oe]*T[oe];re+=T[J]*ue}return re}}),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 te}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return oe}});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 Q=L-this.#e;this.#e+=Q/this.#t,this.#n+=Q*(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 Q=this.#t+L.#t,_=L.#e-this.#e;this.#e+=_*(L.#t/Q),this.#n+=L.#n+_*_*(this.#t*L.#t/Q),this.#t=Q}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,Q=Math.random){if(!(L>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(L),this.#r=Q}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 Q=Math.floor(this.#r()*this.#e);Q<this.#n&&(this.#t[Q]=L)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let L=0;for(const Q of this.#t)L+=Q;return L/this.#t.length}quantile(L){const Q=this.#t.length;if(!Q)return null;const _=this.#t.slice().sort((s,u)=>s-u);if(Q===1)return _[0];const C=(Q-1)*Math.min(1,Math.max(0,L)),M=Math.floor(C),i=Math.ceil(C);return M===i?_[M]:_[M]+(C-M)*(_[i]-_[M])}}function X(Y){return Y^=Y>>>16,Y=Math.imul(Y,2246822507),Y^=Y>>>13,Y=Math.imul(Y,3266489909),Y^=Y>>>15,Y>>>0}function z(Y){if(typeof Y=="number"){const _=new DataView(new ArrayBuffer(8));return _.setFloat64(0,Y===0?0:Y),X(_.getUint32(0)^_.getUint32(4))}const L=typeof Y=="string"?Y:String(Y);let Q=2166136261;for(let _=0;_<L.length;_++)Q^=L.charCodeAt(_),Q=Math.imul(Q,16777619);return X(Q)}class te{#t;#e;#n;constructor(L=14){const Q=Math.floor(L);if(Q<4||Q>16)throw new RangeError("HLL precision must be 4..16");this.#t=Q,this.#e=1<<Q,this.#n=new Uint8Array(this.#e)}static errorBoundFor(L=14){const Q=1<<Math.floor(L),_=1.04/Math.sqrt(Q);return Object.freeze({kind:"probabilistic",metric:"relative",value:_,statement:`distinct count within ~${(_*100).toFixed(2)}% relative standard error (m=${Q} buckets)`})}errorBound(){return te.errorBoundFor(this.#t)}add(L){const Q=z(L),_=Q&this.#e-1,C=Q>>>this.#t|1<<32-this.#t;let M=1,i=C;for(;(i&1)===0;)M++,i>>>=1;M>this.#n[_]&&(this.#n[_]=M)}count(){const L=this.#e,Q=32-this.#t,_=new Float64Array(Q+2);for(let i=0;i<L;i++)_[this.#n[i]]++;let C=L*K(1-_[Q+1]/L);for(let i=Q;i>=1;i--)C=.5*(C+_[i]);C+=L*T(_[0]/L);const M=x*L*L/C;return Math.round(M)}}const x=.5/Math.log(2);function T(Y){if(Y===1)return 1/0;let L=1,Q=Y,_;do Y*=Y,_=Q,Q+=Y*L,L+=L;while(Q!==_);return Q}function K(Y){if(Y===0||Y===1)return 0;let L=1,Q=1-Y,_;do Y=Math.sqrt(Y),_=Q,L*=.5,Q-=(1-Y)**2*L;while(Q!==_);return Q/3}class re{#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 Q=L/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:Q,statement:`each count overestimates the truth by at most N/m = ${Q.toFixed(2)} (N=${L}, m=${this.#e})`})}get seen(){return this.#n}add(L){this.#n++;const Q=this.#t.get(L);if(Q){Q.count++;return}if(this.#t.size<this.#e){this.#t.set(L,{count:1,error:0});return}let _,C=1/0;for(const[M,i]of this.#t)i.count<C&&(C=i.count,_=M);this.#t.delete(_),this.#t.set(L,{count:C+1,error:C})}top(L=this.#e){return[...this.#t.entries()].map(([_,C])=>({item:_,count:C.count,error:C.error})).sort((_,C)=>C.count-_.count).slice(0,Math.max(0,Math.floor(L)))}}class J{#t;#e=[[]];#n=0;#r;#i;constructor(L=200,Q=Math.random){this.#t=Math.max(8,Math.floor(L)),this.#r=Q,this.#i=2/3}static errorBoundFor(L=200){const Q=1/Math.max(8,Math.floor(L));return Object.freeze({kind:"probabilistic",metric:"rank",value:Q,statement:`queried quantile\'s true rank within ~${(Q*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 _=this.#e.length-1-L,C=Math.ceil(this.#t*this.#i**_);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 Q=this.#e[L];Q.sort((M,i)=>M-i),L+1>=this.#e.length&&this.#e.push([]);const _=this.#e[L+1],C=this.#r()<.5?0:1;for(let M=C;M<Q.length;M+=2)_.push(Q[M]);this.#e[L]=[];for(let M=0;M<this.#e.length;M++)if(this.#e[M].length>=this.#s(M)){this.#h(M);return}}#u(){const L=[];for(let Q=0;Q<this.#e.length;Q++){const _=1<<Q;for(const C of this.#e[Q])L.push({v:C,w:_})}return L}quantile(L){const Q=this.#u();if(!Q.length)return null;Q.sort((i,s)=>i.v-s.v);let _=0;for(const i of Q)_+=i.w;const C=Math.min(1,Math.max(0,L))*_;let M=0;for(const i of Q)if(M+=i.w,M>=C)return i.v;return Q[Q.length-1].v}rank(L){let Q=0;for(let _=0;_<this.#e.length;_++){const C=1<<_;for(const M of this.#e[_])M<=L&&(Q+=C)}return Q}}const ue=Object.freeze({distinct:te.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"})}),oe={Welford:fe,Reservoir:he,HyperLogLog:te,SpaceSaving:re,KLL:J,hash32:z,SKETCH_BOUNDS:ue}}),Se("packages/core/src/compute/statistics.js",function(o,me){"use strict";Object.defineProperty(o,"KENDALL_LIMIT",{enumerable:!0,get:function(){return M}}),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 c}}),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 l}}),Object.defineProperty(o,"STAT_FNS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return S}}),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 E}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return ne}}),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 Re}}),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 Te}}),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,X=fe.valueReader,z=me("packages/core/src/compute/special.js"),te=z.studentTQuantile,x=z.studentT,T=z.normalQuantile,K=z.normalCdf,re=z.chiSquareUpperTail,J=me("packages/core/src/compute/linalg.js"),ue=J.cholesky,oe=J.choleskySolve,Y=J.choleskyInverse,L=J.normalEquations,Q=J.quadForm,C=me("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,M=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 ie=0;ie<y;ie++){const se=j[ie];if(D&&D(se)!==1)continue;const we=I[se];Number.isNaN(we)||(O[k++]=we)}return O.subarray(0,k)}const W=X(b);for(let I=0;I<y;I++){const D=W(j[I]);if(D==null||D==="")continue;const ie=typeof D=="number"?D:Number(D);Number.isFinite(ie)&&(O[k++]=ie)}return O.subarray(0,k)}function c(b,j){const y=new Map,O=X(b);let k=0;for(let W=0;W<j.length;W++){const I=O(j[W]);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 N=[...y.values()].sort((W,I)=>I-W);return{counts:N,total:k,distinct:N.length}}function t(b){return b.total>0?b.counts.map(j=>j/b.total):[]}function a(b,j){const y=c(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=c(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=c(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=c(b,j);if(!O.total)return null;const k=Math.max(1,Math.floor(y));let N=0;for(let W=0;W<Math.min(k,O.counts.length);W++)N+=O.counts[W];return N/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 N=0,W=0;for(let I=0;I<O;I++)N+=k[I],W+=(I+1)*k[I];return N===0?0:2*W/(O*N)-(O+1)/O}function r(b){let j=0,y=0,O=0;for(let k=0;k<b.length;k++){const N=b[k];j++;const W=N-y;y+=W/j,O+=W*(N-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),N=Math.ceil(O);return k===N?b[k]:b[k]+(O-k)*(b[N]-b[k])}function l(b,j){if(!b.length)return NaN;const y=b.slice().sort();return n(y,j)}function g(b,j){const y=X(b);let O=0,k=0,N=0;for(let W=0;W<j.length;W++){const I=y(j[W]);if(I==null||I==="")continue;const D=String(I).toUpperCase();D==="PASS"?O++:D==="FAIL"?k++:D==="WARN"&&N++}return{pass:O+N,fail:k,warn:N,judged:O+N+k}}const P=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)=>Z(f(b,j),.1),winsorizedMean:(b,j)=>R(f(b,j),.1),robustOutliers:(b,j)=>v(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?l(y,.5):null},p25:(b,j)=>{const y=f(b,j);return y.length?l(y,.25):null},p75:(b,j)=>{const y=f(b,j);return y.length?l(y,.75):null},p90:(b,j)=>{const y=f(b,j);return y.length?l(y,.9):null},p95:(b,j)=>{const y=f(b,j);return y.length?l(y,.95):null},p99:(b,j)=>{const y=f(b,j);return y.length?l(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=l(y,.5),k=new Float64Array(y.length);for(let N=0;N<y.length;N++)k[N]=Math.abs(y[N]-O);return l(k,.5)},range:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=1/0,k=-1/0;for(let N=0;N<y.length;N++)y[N]<O&&(O=y[N]),y[N]>k&&(k=y[N]);return k-O},distinct:(b,j)=>{const y=X(b),O=new Set;for(let k=0;k<j.length;k++){const N=y(j[k]);N==null||N===""||O.add(N instanceof Date?N.getTime():N)}return O.size},mode:(b,j)=>{const y=X(b),O=new Map;for(let W=0;W<j.length;W++){const I=y(j[W]);if(I==null||I==="")continue;const D=I instanceof Date?I.getTime():I;O.set(D,(O.get(D)||0)+1)}let k=null,N=1;for(const[W,I]of O)I>N&&(N=I,k=W);return k},skewness:(b,j)=>{const y=f(b,j),{n:O,mean:k,m2:N}=r(y);if(O<3||N<=0)return null;const W=Math.sqrt(N/(O-1));let I=0;for(let D=0;D<y.length;D++)I+=((y[D]-k)/W)**3;return O/((O-1)*(O-2))*I},kurtosis:(b,j)=>{const y=f(b,j),{n:O,mean:k,m2:N}=r(y);if(O<4||N<=0)return null;const W=Math.sqrt(N/(O-1));let I=0;for(let se=0;se<y.length;se++)I+=((y[se]-k)/W)**4;const D=O*(O+1)/((O-1)*(O-2)*(O-3)),ie=3*(O-1)**2/((O-2)*(O-3));return D*I-ie},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}),S=Object.freeze({hhi:"Concentration (HHI)",entropy:"Entropy",evenness:"Evenness",top3Share:"Top 3 share",top10Share:"Top 10 share",gini:"Gini coefficient",trimmedMean:"Trimmed mean",winsorizedMean:"Winsorized mean",robustOutliers:"Outliers (robust)",jarqueBera:"Jarque–Bera",median:"Median",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function G(b,j,y){const O=X(b),k=X(j);let N=0,W=0;for(let I=0;I<y.length;I++){const D=y[I],ie=Number(O(D)),se=Number(k(D));!Number.isFinite(ie)||!Number.isFinite(se)||(N+=ie*se,W+=se)}return W===0?null:N/W}function F(b,j,y){const O=X(b);let k=null,N=y?-1/0:1/0;for(let W=0;W<j.length;W++){const I=j[W],D=Number(O(I));Number.isFinite(D)&&(y?D>N:D<N)&&(N=D,k=I)}return k}function E(b,j,y){const O=X(b),k=X(j);let N=0,W=0,I=0,D=0,ie=0,se=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)||(N++,W+=Pe,I+=ye,D+=Pe*Pe,ie+=ye*ye,se+=Pe*ye)}if(N<2)return null;const we=N*se-W*I,Oe=Math.sqrt((N*D-W*W)*(N*ie-I*I));if(Oe===0)return null;const je=we/Oe;return Math.max(-1,Math.min(1,je))}function Z(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))),N=O.slice(k,y-k);if(!N.length)return n(O,.5);let W=0;for(const I of N)W+=I;return W/N.length}function R(b,j=.1){const y=b.length;if(!y)return null;const O=Array.from(b).sort((D,ie)=>D-ie),k=Math.floor(y*Math.min(.49,Math.max(0,j))),N=O[k],W=O[y-1-k];let I=0;for(const D of O)I+=Math.min(W,Math.max(N,D));return I/y}function v(b,j=3.5){if(!b.length)return null;const O=Array.from(b).sort((D,ie)=>D-ie),k=n(O,.5),N=O.map(D=>Math.abs(D-k)).sort((D,ie)=>D-ie),W=n(N,.5);if(W===0)return null;let I=0;for(const D of O)Math.abs(.6745*(D-k)/W)>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,N=0;for(const D of b){const ie=D-y;O+=ie*ie,k+=ie*ie*ie,N+=ie*ie*ie*ie}if(O/=j,k/=j,N/=j,O===0)return null;const W=k/O**1.5,I=N/(O*O)-3;return j/6*(W*W+I*I/4)}function V(b,j,y){const O=[];let k=0;for(let D=0;D<b.length;D++){const ie=Number(b[D]),se=Number(j[D]);!Number.isFinite(ie)||!Number.isFinite(se)||se<=0||(O.push([ie,se]),k+=se)}if(!O.length||k<=0)return null;if(O.sort((D,ie)=>D[0]-ie[0]),O.length===1)return O[0][0];const N=[];let W=0;for(const[,D]of O)N.push((W+D/2)/k),W+=D;const I=Math.max(0,Math.min(1,y));if(I<=N[0])return O[0][0];if(I>=N[N.length-1])return O[O.length-1][0];for(let D=1;D<N.length;D++){if(I>N[D])continue;const ie=N[D]-N[D-1],se=ie>0?(I-N[D-1])/ie:0;return O[D-1][0]+(O[D][0]-O[D-1][0])*se}return O[O.length-1][0]}function $(b,j,y){const O=X(b),k=X(j),N=new Float64Array(y.length),W=new Float64Array(y.length);let I=0;for(let D=0;D<y.length;D++){const ie=y[D],se=Number(O(ie)),we=Number(k(ie));!Number.isFinite(se)||!Number.isFinite(we)||(N[I]=se,W[I]=we,I++)}return{xs:N.subarray(0,I),ys:W.subarray(0,I),n:I}}function ee(b,j,y,O=!1){const{xs:k,ys:N,n:W}=$(b,j,y);if(W<2)return null;let I=0,D=0;for(let se=0;se<W;se++)I+=k[se],D+=N[se];I/=W,D/=W;let ie=0;for(let se=0;se<W;se++)ie+=(k[se]-I)*(N[se]-D);return ie/(O?W:W-1)}function ne(b,j,y){const{xs:O,ys:k,n:N}=$(b,j,y);if(N<2)return null;let W=0,I=0;for(let Pe=0;Pe<N;Pe++)W+=O[Pe],I+=k[Pe];W/=N,I/=N;let D=0,ie=0,se=0;for(let Pe=0;Pe<N;Pe++){const ye=O[Pe]-W,ve=k[Pe]-I;D+=ye*ye,ie+=ye*ve,se+=ve*ve}if(D===0)return null;const we=ie/D,Oe=I-we*W,je=se===0?1:Math.max(0,Math.min(1,ie*ie/(D*se))),be=Math.max(0,se-we*ie),Ae=N>2?Math.sqrt(be/(N-2)/D):0;return{slope:we,intercept:Oe,r2:je,stdError:Ae,n:N}}const ce=new Set(["ols","wls","robust"]),p=new Set(["quantile"]),B=new Set(["ridge","lasso","elasticnet","mixed","gls"]),H=1.345;function w(b,j,y){const{xtwx:O,xtwy:k}=L(b,j,y),N=ue(O);if(!N)return null;const W=oe(N,k),I=Y(N),D=A(b,W),ie=j.map((se,we)=>se-D[we]);return{beta:W,cov:I,fitted:D,residuals:ie}}function A(b,j){return b.map(y=>y.reduce((O,k,N)=>O+k*j[N],0))}function q(b,j){const y=b.length,O=b.map(ie=>ie[j]),k=b.map(ie=>[1,...ie.filter((se,we)=>we!==j)]),N=w(k,O,null);if(!N)return 1;const W=O.reduce((ie,se)=>ie+se,0)/y;let I=0,D=0;for(let ie=0;ie<y;ie++)I+=N.residuals[ie]**2,D+=(O[ie]-W)**2;return D===0?1:Math.max(0,Math.min(1,1-I/D))}function le(b){const j=[...b].sort((k,N)=>k-N),y=ae(j),O=b.map(k=>Math.abs(k-y)).sort((k,N)=>k-N);return ae(O)/.6745}function ae(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(!ce.has(O))throw new Error(`[lattice] unknown regression method "${O}"; use ols, wls or robust.`);const k=Array.isArray(j)?j.length:0,N=k&&Array.isArray(b[0])?b[0].length:0,W=N+1;if(!(k>W))return null;for(let Me=0;Me<k;Me++){if(!Number.isFinite(j[Me])||!Array.isArray(b[Me])||b[Me].length!==N)return null;for(let Ne=0;Ne<N;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 ie,se=null;if(O==="robust"){if(ie=w(D,j,null),!ie)return null;for(let Me=0;Me<50;Me++){const Ne=le(ie.residuals);if(!(Ne>0))break;const Ee=ie.residuals.map($e=>{const We=Math.abs($e/Ne);return We<=H?1:H/We}),Ce=w(D,j,Ee);if(!Ce)return null;const Ve=Ce.beta.reduce(($e,We,Je)=>Math.max($e,Math.abs(We-ie.beta[Je])),0);if(ie=Ce,se=Ee,Ve<1e-10)break}}else if(ie=w(D,j,I),!ie)return null;const we=O==="robust"?se:I,{beta:Oe,cov:je,fitted:be,residuals:Ae}=ie;let Pe=0,ye=0,ve=0;for(let Me=0;Me<k;Me++){const Ne=we?we[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=we?we[Me]:1;Ie+=Ne*(j[Me]-Fe)**2}const De=k-W,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===N?y.names:b[0].map((Me,Ne)=>`x${Ne+1}`),He=Qe(y.confidence),Ze=De>0?te(1-(1-He)/2,De):1/0,Lt=Oe.map((Me,Ne)=>{const Ee=Math.sqrt(Math.max(0,qe*je[Ne][Ne])),Ce=Ee>0?Me/Ee:Me===0?0:1/0,Ve=Number.isFinite(Ce)?2*(1-x(Math.abs(Ce),De)):0,$e=Number.isFinite(Ze)?Ze*Ee:null;return{name:Ne===0?"(intercept)":Xe[Ne-1],estimate:Me,stdError:Ee,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=we?we[Me]:1,Ee=Math.max(0,Math.min(1,Ne*Q(D[Me],je)));dt[Me]=Ee;const Ce=(1-Ee)**2;mt[Me]=Ce>0&&qe>0?Ae[Me]**2/(W*qe)*(Ee/Ce):null}const Ft=b[0].map((Me,Ne)=>{if(N<2)return 1;const Ee=q(b,Ne);return Ee>=1?1/0:1/(1-Ee)});let gt=null;{const Me=Ae.map(Ee=>Ee*Ee),Ne=w(D,Me,null);if(Ne){const Ee=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]-Ee)**2;const $e=Ve===0?0:Math.max(0,Math.min(1,1-Ce/Ve)),We=k*$e,Je=re(We,N);gt={statistic:We,df:N,p:Je,heteroscedastic:Je<.05}}}let bt=null;if(N===1){const Me=b.map((Ne,Ee)=>Ee).sort((Ne,Ee)=>b[Ne][0]-b[Ee][0]);bt={confidence:He,points:Me.map(Ne=>{const Ee=D[Ne],Ce=Math.sqrt(Math.max(0,qe*Q(Ee,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:we?[...we]:null}}function pe(b){const j=b.length,y=Array.from({length:j},(N,W)=>W).sort((N,W)=>b[N]-b[W]),O=new Float64Array(j);let k=0;for(;k<j;){let N=k;for(;N+1<j&&b[y[N+1]]===b[y[k]];)N++;const W=(k+N)/2+1;for(let I=k;I<=N;I++)O[y[I]]=W;k=N+1}return O}const ge=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function ke(b){const j=[.01,.05,.1],y=[ge["1%"],ge["5%"],ge["10%"]];if(b<=y[0]){const N=(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])+N*(b-y[0]))))}if(b>=y[2]){const N=(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])+N*(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 Le(b,j,y,O){const k=y-O,N=O+3,W=new Array(k),I=new Array(k);let D=!0,ie=O;for(let be=0;be<k;be++){const Ae=O+be,Pe=new Float64Array(N);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<N;ye++)Number.isFinite(Pe[ye])||(ie=Math.min(ie,ye-3));W[be]=Pe,I[be]=j[Ae],Number.isFinite(I[be])||(D=!1)}if(!D)return 0;const{xtwx:se,xtwy:we}=L(W,I,null);let Oe=0,je=1/0;for(let be=0;be<=ie;be++){const Ae=be+3;if(!(k>Ae))continue;const Pe=new Array(Ae);for(let Ue=0;Ue<Ae;Ue++)Pe[Ue]=se[Ue].slice(0,Ae);const ye=ue(Pe);if(!ye)continue;const ve=oe(ye,we.slice(0,Ae));let Fe=0;for(let Ue=0;Ue<k;Ue++){const tt=W[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,Oe=be)}return Oe}function Re(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 N=new Array(k);for(let je=0;je<k;je++)N[je]=y[je+1]-y[je];let W=Number.isFinite(j.maxlag)?Math.floor(j.maxlag):Math.ceil(12*(O/100)**.25);W=Math.max(0,Math.min(W,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(N[ye-Fe]);Ae.push(ve),Pe.push(N[ye])}return de(Ae,Pe,{method:"ols"})},D=Le(y,N,k,W),ie=I(D,D);if(!ie||!ie.coefficients[2])return null;const se=ie.coefficients[2].t,we=ke(se),Oe=se<ge["5%"];return{statistic:se,usedLag:D,nobs:k-D,criticalValues:{...ge},pValue:we,pApproximate:!0,stationary:Oe,verdict:Oe?"stationary":"non-stationary",regression:"ct"}}function Be(b,j={}){const y=[];for(let Oe=0;Oe<b.length;Oe++){const je=Number(b[Oe]);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 N=0;for(const Oe of y)N+=Oe;N/=O;const W=y.map(Oe=>Oe-N);let I=0;for(const Oe of W)I+=Oe*Oe;I/=O;const D=new Array(k+1).fill(0);D[0]=1;for(let Oe=1;Oe<=k;Oe++){let je=0;for(let be=Oe;be<O;be++)je+=W[be]*W[be-Oe];D[Oe]=I>0?je/O/I:0}const ie=new Array(k+1).fill(0);ie[0]=1;let se=[];for(let Oe=1;Oe<=k;Oe++){let je=D[Oe];for(let ye=1;ye<Oe;ye++)je-=se[ye-1]*D[Oe-ye];let be=1;for(let ye=1;ye<Oe;ye++)be-=se[ye-1]*D[ye];const Ae=be!==0?je/be:0,Pe=new Array(Oe);for(let ye=1;ye<Oe;ye++)Pe[ye-1]=se[ye-1]-Ae*se[Oe-1-ye];Pe[Oe-1]=Ae,ie[Oe]=Ae,se=Pe}const we=1.96/Math.sqrt(O);return{acf:D,pacf:ie,bounds:{upper:we,lower:-we},n:O,nlags:k,approximate:!0}}function ze(b,j,y){const{xs:O,ys:k,n:N}=$(b,j,y);if(N<2)return null;const W=pe(O),I=pe(k);let D=0,ie=0;for(let je=0;je<N;je++)D+=W[je],ie+=I[je];D/=N,ie/=N;let se=0,we=0,Oe=0;for(let je=0;je<N;je++){const be=W[je]-D,Ae=I[je]-ie;se+=be*Ae,we+=be*be,Oe+=Ae*Ae}return we===0||Oe===0?null:Math.max(-1,Math.min(1,se/Math.sqrt(we*Oe)))}function Ke(b,j,y){const{xs:O,ys:k,n:N}=$(b,j,y);if(N<2||N>M)return null;let W=0,I=0,D=0,ie=0;for(let Oe=0;Oe<N;Oe++)for(let je=Oe+1;je<N;je++){const be=Math.sign(O[Oe]-O[je]),Ae=Math.sign(k[Oe]-k[je]),Pe=be*Ae;Pe>0?W++:Pe<0?I++:be===0&&Ae===0||(be===0?D++:ie++)}const se=W+I+ie,we=W+I+D;return se===0||we===0?null:(W-I)/Math.sqrt(se*we)}function Te(b,j={}){const y=b.length;if(y<2)return null;const O=b[0],k=b[y-1],N=[];for(let ye=1;ye<y;ye++){const ve=b[ye-1];ve!==0&&N.push((b[ye]-ve)/Math.abs(ve))}let W=null;if(N.length>1){let ye=0;for(const Fe of N)ye+=Fe;ye/=N.length;let ve=0;for(const Fe of N)ve+=(Fe-ye)**2;W=Math.sqrt(ve/(N.length-1))}const I=Number(j.periodsPerYear)>0?Number(j.periodsPerYear):null;let D=b[0],ie=0,se=0,we=0,Oe=0;for(let ye=1;ye<y;ye++){if(b[ye]>D){D=b[ye],ie=ye;continue}if(D<=0)continue;const ve=(D-b[ye])/D;ve>se&&(se=ve,we=ie,Oe=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 N)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:W,annualisedVolatility:W!==null&&I?W*Math.sqrt(I):null,growth:Pe,maxDrawdown:se,maxDrawdownFrom:we,maxDrawdownTo:Oe,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,N)=>k+N,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 N=0;for(let be=0;be<y;be++)N+=b[be];N/=y;let W=0;for(let be=0;be<y;be++)W+=(b[be]-N)**2;const I=Math.sqrt(W/(y-1)),D=xe(b),ie=D?D.sigma:null,se=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-N)/(3*be):1/0,ve=O!==null?(N-O)/(3*be):1/0;return{index:Pe,k:Math.min(ye,ve)}},we=se(ie),Oe=se(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:N,lower:O,upper:k,target:Number.isFinite(Number(j.target))?Number(j.target):null,sigmaWithin:ie,sigmaOverall:I,cp:we.index,cpk:we.k,pp:Oe.index,ppk:Oe.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,N=I=>(b[I]-O)/k,W=[];for(let I=0;I<y;I++){if(Math.abs(N(I))>3&&W.push({index:I,rule:1,description:"beyond three sigma"}),I>=2)for(const D of[1,-1]){let ie=0;for(let se=I-2;se<=I;se++)N(se)*D>2&&ie++;if(ie>=2){W.push({index:I,rule:2,description:"two of three past two sigma"});break}}if(I>=4)for(const D of[1,-1]){let ie=0;for(let se=I-4;se<=I;se++)N(se)*D>1&&ie++;if(ie>=4){W.push({index:I,rule:3,description:"four of five past one sigma"});break}}if(I>=7)for(const D of[1,-1]){let ie=!0;for(let se=I-7;se<=I;se++)if(N(se)*D<=0){ie=!1;break}if(ie){W.push({index:I,rule:4,description:"eight in a row on one side"});break}}}return W}function ct(b,j){if(!j||!(j.sigma>0))return[];const y=b.length,{centre:O,sigma:k}=j,N=D=>(b[D]-O)/k,W=(D,ie,se,we)=>{for(const Oe of[1,-1]){let je=0;for(let be=D;be<=ie;be++)N(be)*Oe>se&&je++;if(je>=we)return!0}return!1},I=[];for(let D=0;D<y;D++){if(Math.abs(N(D))>3&&I.push({index:D,rule:1,description:"beyond three sigma"}),D>=8)for(const ie of[1,-1]){let se=!0;for(let we=D-8;we<=D;we++)if(N(we)*ie<=0){se=!1;break}if(se){I.push({index:D,rule:2,description:"nine in a row on one side"});break}}if(D>=5)for(const ie of[1,-1]){let se=!0;for(let we=D-4;we<=D;we++)if((b[we]-b[we-1])*ie<=0){se=!1;break}if(se){I.push({index:D,rule:3,description:ie>0?"six rising":"six falling"});break}}if(D>=13){let ie=!0;for(let se=D-12;se<=D;se++){const we=b[se]-b[se-1],Oe=b[se+1<=D?se+1:se]-b[se];if(se+1>D)break;if(we===0||Oe===0||we>0==Oe>0){ie=!1;break}}ie&&I.push({index:D,rule:4,description:"fourteen alternating"})}if(D>=2&&W(D-2,D,2,2)&&I.push({index:D,rule:5,description:"two of three past two sigma"}),D>=4&&W(D-4,D,1,4)&&I.push({index:D,rule:6,description:"four of five past one sigma"}),D>=14){let ie=!0;for(let se=D-14;se<=D;se++)if(Math.abs(N(se))>=1){ie=!1;break}ie&&I.push({index:D,rule:7,description:"fifteen within one sigma"})}if(D>=7){let ie=!0;for(let se=D-7;se<=D;se++)if(Math.abs(N(se))<=1){ie=!1;break}ie&&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 N=b[0],W=b[k-1];if(W===N)return[{from:N,to:W,count:k}];const I=y-j,D=1.5*I;let ie=I>0?Math.max(N,j-D):N,se=I>0?Math.min(W,y+D):W;se>ie||(ie=N,se=W);const we=I>0?2*I/Math.cbrt(k):(se-ie)/(Math.ceil(Math.log2(k))+1),Oe=we>0?Math.min(O,Math.max(1,Math.ceil((se-ie)/we))):1,je=(se-ie)/Oe,be=[];for(let Ae=0;Ae<Oe;Ae++)be.push({from:ie+Ae*je,to:ie+(Ae+1)*je,count:0});for(let Ae=0;Ae<k;Ae++){const Pe=Math.min(Oe-1,Math.max(0,Math.floor((b[Ae]-ie)/je)));be[Pe].count++}return be[0].from=N,be[Oe-1].to=W,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 se=0;se<y;se++)O+=b[se];const k=O/y;let N=0;for(let se=0;se<y;se++){const we=b[se]-k;N+=we*we}const W=Math.sqrt(N/(y-1)),I=Qe(j),ie=te(1-(1-I)/2,y-1)*W/Math.sqrt(y);return{mean:k,lower:k-ie,upper:k+ie,margin:ie,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 N=Qe(y),W=T(1-(1-N)/2),I=O/k,D=W*W,ie=1+D/k,se=(I+D/(2*k))/ie,we=W/ie*Math.sqrt(I*(1-I)/k+D/(4*k*k));return{proportion:I,lower:Math.max(0,se-we),upper:Math.min(1,se+we),n:k,confidence:N}}function vt(b,j=Ge){if(!b||!(b.n>2)||!Number.isFinite(b.stdError))return null;const y=Qe(j),k=te(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 N=Qe(y),I=T(1-(1-N)/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:N}}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=X(b);let k=0;for(let N=0;N<j.length;N++){const W=O(j[N]);if(W==null||W===""||typeof W=="number"&&Number.isNaN(W))continue;const I=W instanceof Date?W.getTime():typeof W=="object"?String(W):W;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 N=new Set(b.keys());for(const W of y.keys())N.add(W);for(const W of N){const I=(b.get(W)||0)/j,D=(y.get(W)||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:ie}=r(I),se=D>0?lt({mean:y.mean,sd:y.sd},ie):null;return{measure:"standardizedMeanDifference",magnitude:se,distance:se===null?0:at(se),direction:se===null?0:Math.sign(se),subsetN:D,populationN:y.n||0,reliable:D>=et}}const{map:k,total:N}=_e(b,j),W=ft(k,N,y.map,y.total);return{measure:"categoricalTotalVariation",magnitude:W,distance:W===null?0:W,direction:0,subsetN:N,populationN:y.total||0,reliable:N>=et}}function ht(b,j){if(b&&(b.kind==="float64"||b.kind==="int32"))return!0;const y=X(b);let O=0,k=0;for(let N=0;N<j.length&&O<200;N++){const W=y(j[N]);if(W==null||W==="")continue;if(W instanceof Date)return!1;O++;const I=typeof W=="number"?W:Number(W);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:N,mean:W,m2:I}=r(k);return{numeric:!0,mean:W,sd:N>0?Math.sqrt(I/N):0,n:N}}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 c}}),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,X=fe.warnOnce,z=me("packages/core/src/compute/handle.js"),te=z.presenceReader,x=z.valueComparator,T=z.valueReader,K=me("packages/core/src/compute/statistics.js"),re=K.STAT_FNS,J=K.STAT_LABELS;function ue(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function oe(r,n){const l=n.length;let g=0;if(ue(r)){const S=r.values,G=te(r);if(!G){for(let F=0;F<l;F++){const E=S[n[F]];Number.isNaN(E)||(g+=E)}return g}for(let F=0;F<l;F++){const E=n[F];if(G(E)===1){const Z=S[E];Number.isNaN(Z)||(g+=Z)}}return g}const P=T(r);for(let S=0;S<l;S++){const G=u(P(n[S]));G!==null&&(g+=G)}return g}oe.kernel=!0;function Y(r,n){const l=n.length;let g=0;if(ue(r)){const S=r.values,G=te(r);if(!G){for(let F=0;F<l;F++)Number.isNaN(S[n[F]])||g++;return g}for(let F=0;F<l;F++){const E=n[F];G(E)===1&&!Number.isNaN(S[E])&&g++}return g}const P=T(r);for(let S=0;S<l;S++){const G=P(n[S]);G!=null&&!(typeof G=="number"&&Number.isNaN(G))&&g++}return g}Y.kernel=!0;function L(r,n){return n.length}L.kernel=!0;function Q(r,n){const l=Y(r,n);return l===0?null:oe(r,n)/l}Q.kernel=!0;function _(r,n,l,g){const P=n.length;if(ue(r)){const E=r.values,Z=te(r);let R=null;if(!Z){for(let v=0;v<P;v++){const U=E[n[v]];Number.isNaN(U)||(R===null||(l<0?U<R:U>R))&&(R=U)}return R}for(let v=0;v<P;v++){const U=n[v];if(Z(U)===0)continue;const V=E[U];Number.isNaN(V)||(R===null||(l<0?V<R:V>R))&&(R=V)}return R}const S=T(r),G=x(g);let F=null;for(let E=0;E<P;E++){const Z=S(n[E]);Z==null||typeof Z=="number"&&Number.isNaN(Z)||(F===null||(l<0?G(Z,F)<0:G(Z,F)>0))&&(F=Z)}return F}function C(r,n,l){return _(r,n,-1,l&&l.locale)}C.kernel=!0;function M(r,n,l){return _(r,n,1,l&&l.locale)}M.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:oe,min:C,max:M,avg:Q,count:L,first:i,last:s,countValues:Y,...re},c=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"?c[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 l=a.filter(g=>g in f);for(const g of Object.keys(f))l.includes(g)||l.push(g);return l}function e(r,n){return typeof n!="string"?!0:m(r).includes(n)}function d(r,n){const l=T(r),g=[];for(let P=0;P<n.length;P++){const S=l(n[P]);S!=null&&g.push(S)}return g}function h(r,n,l,g){const P=n||[];if(typeof l=="string"){const S=f[l];return S?S(r,P,g):(X(`total:${l}`,`unknown total function "${l}"; register it in config.totalFns`),null)}return he(l)?l.kernel===!0?l(r,P,g):l(d(r,P),g||{}):null}}),Se("packages/core/src/compute/pivot.js",function(o,me){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return M}});const he=me("packages/core/src/internal/util.js").warnOnce,z=me("packages/core/src/compute/handle.js").valueComparator,x=me("packages/core/src/compute/group.js").packKeys,K=me("packages/core/src/compute/total.js").total,re="|",J="/",ue=2e3;function oe(u,f,c){return`${u}${re}${f}${re}${c}`}function Y(u,f){let c="";for(let t=0;t<u.length;t++){const a=u[t];c+=(t===0?"":f)+(a==null?"":String(a))}return c}function L(u,f,c={}){const t=c.separator||J,a=f.length,{keyOf:m,readers:e}=x(u,f,0),d=new Map,h=[],r=[];for(let F=0;F<a;F++){const E=f[F],Z=m(E);if(d.has(Z))continue;d.set(Z,h.length),r.push(Z);const R=new Array(e.length);for(let v=0;v<e.length;v++)R[v]=e[v](E);h.push(R)}const n=z(c.locale),l=h.map((F,E)=>E);l.sort((F,E)=>{const Z=h[F],R=h[E];for(let v=0;v<Z.length;v++){const U=Q(Z[v],R[v],n);if(U!==0)return U}return F-E});const g=new Array(l.length),P=new Array(l.length),S=new Map;for(let F=0;F<l.length;F++){const E=l[F];g[F]=h[E],P[F]=Y(h[E],t),S.set(r[E],F)}return{keys:g,paths:P,idOf:F=>{const E=S.get(m(F));return E===void 0?-1:E}}}function Q(u,f,c){const t=u==null,a=f==null;return t||a?t&&a?0:t?1:-1:c(u,f)}function _(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 c=typeof u.handle=="function"?u.handle:null;if(!c)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=c(m);e&&a.push({colId:m,handle:e,fn:t?t(m):"sum"})}return a}function C(u,f,c){if(Array.isArray(u)){const t=c||{};return{...t,pivotHandles:u,order:f||null,groups:t.groups||null}}return u||{}}function M(u,f,c){const t=C(u,f,c),a=t.separator||J,m=_(t),e=t.maxColumns===void 0?ue: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(Z=>Y(Z,a)):[""]),n=s(h),{keys:l,paths:g,idOf:P}=L(t.pivotHandles||[],n,t),S=g.length*Math.max(1,m.length),G=i(g,m,a);if(e&&S>e){const Z=new Map;return{keys:l,paths:g,fields:G,groupPaths:r,columns:S,values:Z,cells:Z,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${S} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:S,maxColumns:e}}}const F=new Map,E=g.length;for(let Z=0;Z<h.length;Z++){const R=h[Z],v=r[Z]===void 0?"":r[Z],U=R.length;if(U===0)continue;const V=new Int32Array(U),$=new Uint32Array(E+1);for(let ce=0;ce<U;ce++){const p=P(R[ce]);V[ce]=p,p>=0&&$[p+1]++}for(let ce=0;ce<E;ce++)$[ce+1]+=$[ce];const ee=new Uint32Array(U),ne=$.slice(0,E);for(let ce=0;ce<U;ce++){const p=V[ce];p>=0&&(ee[ne[p]++]=R[ce])}for(let ce=0;ce<E;ce++){const p=$[ce],B=$[ce+1];if(B===p)continue;const H=ee.subarray(p,B);for(let w=0;w<m.length;w++){const A=m[w],q=K(A.handle,H,A.fn,t.totalContext||{locale:t.locale});F.set(oe(v,g[ce],A.colId),q)}}}return{keys:l,paths:g,fields:G,groupPaths:r,columns:S,values:F,cells:F,error:null}}function i(u,f,c){if(f.length===0)return u.slice();const t=[];for(const a of u)for(const m of f)t.push(`${a}${c}${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 c=new Uint32Array(f);let t=0;for(const a of u)!a||a.length===0||(c.set(a,t),t+=a.length);return c}}),Se("packages/core/src/compute/pivotmatrix.js",function(o,me){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return M}});const he=me("packages/core/src/compute/handle.js").valueComparator,z=me("packages/core/src/compute/total.js").total,x=me("packages/core/src/compute/group.js").packKeys,T=me("packages/core/src/compute/pivot.js"),K=T.joinPath,re=T.DEFAULT_PATH_SEPARATOR,J=T.DEFAULT_MAX_COLUMNS,ue="";function oe(i,s,u={}){const f=u.separator||re,c=i||[],t=s instanceof Uint32Array?s:Uint32Array.from(s||[]),a=t.length;if(c.length===0)return{tuples:[[]],paths:[ue],buckets:[t]};const{keyOf:m,readers:e}=x(c,t,0),d=new Map,h=[],r=[],n=[];for(let F=0;F<a;F++){const E=t[F],Z=m(E);let R=d.get(Z);if(R===void 0){R=h.length,d.set(Z,R),r.push(Z);const v=new Array(e.length);for(let U=0;U<e.length;U++)v[U]=e[U](E);h.push(v),n.push([])}n[R].push(E)}const l=he(u.locale),g=h.map((F,E)=>E);g.sort((F,E)=>{const Z=h[F],R=h[E];for(let v=0;v<Z.length;v++){const U=Y(Z[v],R[v],l);if(U!==0)return U}return F-E});const P=new Array(g.length),S=new Array(g.length),G=new Array(g.length);for(let F=0;F<g.length;F++){const E=g[F];P[F]=h[E],S[F]=K(h[E],f),G[F]=Uint32Array.from(n[E])}return{tuples:P,paths:S,buckets:G}}function Y(i,s,u){const f=i==null,c=s==null;return f||c?f&&c?0:f?1:-1:u(i,s)}function L(i,s,u){const f=[];for(let c=0;c<i.length;c++)u.has(i[c])&&f.push(i[c]);return Uint32Array.from(f)}function Q(i,s,u,f){return{value:s.length?z(i,s,u,f):null,leaves:s,count:s.length}}function _(i){const s=i&&i.opts||{},u=s.separator||re,f=s.totalContext||{locale:s.locale},c=(i.measures||[]).filter(S=>S&&S.handle),t=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),a=oe(i.rowHandles||[],t,{...s,separator:u}),m=oe(i.columnHandles||[],t,{...s,separator:u}),e=s.maxColumns===void 0?J:s.maxColumns,d=m.paths.length*Math.max(1,c.length),h=new Map;if(e&&d>e)return{rowAxis:a,columnAxis:m,measures:c.map(S=>({colId:S.colId,fn:S.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,l=new Map,g=new Map,P=m.buckets.map(S=>new Set(S));for(let S=0;S<m.paths.length;S++){const G=m.buckets[S],F=m.paths[S];for(const E of c)l.set(M(F,E.colId),Q(E.handle,G,E.fn,f))}for(let S=0;S<a.paths.length;S++){const G=a.buckets[S],F=a.paths[S];for(const E of c)n.set(M(F,E.colId),Q(E.handle,G,E.fn,f));for(let E=0;E<m.paths.length;E++){const Z=L(G,m.buckets[E],P[E]);if(Z.length===0)continue;const R=m.paths[E];for(const v of c)r.set(C(F,R,v.colId),Q(v.handle,Z,v.fn,f))}}for(const S of c)g.set(S.colId,Q(S.handle,t,S.fn,f));return{rowAxis:a,columnAxis:m,measures:c.map(S=>({colId:S.colId,fn:S.fn})),body:r,rowMargin:n,columnMargin:l,grand:g,columns:d,error:null}}function C(i,s,u){return`${i}\\0${s}\\0${u}`}function M(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 ue}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return _}});const he=me("packages/core/src/internal/util.js").getPath,X=me("packages/core/src/compute/handle.js"),z=X.isMissing,te=X.valueComparator,T=me("packages/core/src/compute/filter.js").testValue,K="",re="\\0";function J(i,s){const u=s.includes(".")?he(i,s):i?.[s];return u===void 0?null:u}function ue(i,s,u={}){const f=s||[];let c=i.map((t,a)=>a);if(f.length===0)return c;for(let t=f.length-1;t>=0;t--)c=oe(i,c,f[t],u);return c}function oe(i,s,u,f){const c=u.locale!==void 0?u.locale:f.locale,t=te(c),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 l=J(i[r],u.col),g=J(i[n],u.col);let P;return typeof u.compare=="function"?(P=u.compare(l,g,i[r],i[n],a),a&&(P=-P)):P=a?t(g,l):t(l,g),P!==0?P:d.get(r)-d.get(n)};return m.sort(h),u.nullsFirst?e.concat(m):m.concat(e)}function Y(i,s,u={}){const f=[];for(let c=0;c<i.length;c++)L(i[c],s,u,c)&&f.push(c);return f}function L(i,s,u,f){if(!s)return!0;if(Array.isArray(s.conditions)){const c=s.conditions.filter(a=>a!=null);if(c.length===0)return!0;if(s.op==="or")return c.some(a=>L(i,a,u,f));const t=c.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 Q(i,s,u,f){const c=u||i.map((e,d)=>d),t=new Map,a=[],m=[];for(const e of c){const d=s.map((n,l)=>{const g=J(i[e],n);return f&&f[l]?f[l](g):g}),h=d.map(n=>n==null?re: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 _(i,s,u={}){const f=te(u.locale),c=i.filter(a=>!z(a)),t=c.map(C).filter(a=>a!==null);switch(s){case"count":return i.length;case"countValues":return c.length;case"sum":return t.reduce((a,m)=>a+m,0);case"avg":return c.length===0?null:t.reduce((a,m)=>a+m,0)/c.length;case"min":return c.length===0?null:c.reduce((a,m)=>f(m,a)<0?m:a);case"max":return c.length===0?null:c.reduce((a,m)=>f(m,a)>0?m:a);case"first":return i.length===0?null:M(i[0]);case"last":return i.length===0?null:M(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 M(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 X}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return x}});const he=me("packages/core/src/compute/sketch.js").Welford;class X{#t;#e;#n=[];#r;#i;constructor(K,re=0,J=Date.now){if(K!=="count"&&K!=="time"&&K!=="session")throw new RangeError(`unknown window kind: ${K}`);if((K==="count"||K==="time")&&!(re>0))throw new RangeError(`a ${K} window needs a positive span`);this.#t=K,this.#e=Math.floor(re),this.#r=J,this.#i=J()}get size(){return this.#n.length}push(K,re=this.#r()){Number.isFinite(K)&&(this.#n.push({t:re,v:K}),this.#s(re))}#s(K){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const re=K-this.#e;for(;this.#n.length&&this.#n[0].t<re;)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 re=new he;let J=0,ue=1/0,oe=-1/0;for(const{v:Y}of this.#n)J+=Y,Y<ue&&(ue=Y),Y>oe&&(oe=Y),re.add(Y);return{over:K,count:this.#n.length,sum:J,mean:re.mean(),min:ue,max:oe,variance:re.variance(),stddev:re.stddev()}}reduce(K){const re=this.aggregate(),J={sum:re.sum,avg:re.mean,mean:re.mean,min:re.min,max:re.max,count:re.count,variance:re.variance,stddev:re.stddev};if(!(K in J))throw new RangeError(`unknown windowed aggregate: ${K}`);return{value:J[K],over:re.over}}}const z=Object.freeze(["count","time","session"]);function te(T,K=Date.now){const re=T.kind==="time"&&T.minutes!=null?T.minutes*6e4:T.span??0;return new X(T.kind,re,K)}const x={Window:X,WINDOW_KINDS:z,openWindow:te}}),Se("packages/core/src/compute/anomaly.js",function(o,me){"use strict";Object.defineProperty(o,"MAD_SCALE",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return x}}),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 re}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return M}}),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,te=.6745,x=3.5,T=1.5,K=.975,re=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function J(c){if(!c.length)return null;const a=Array.from(c,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 ue(c,t={}){const a=Number.isFinite(t.threshold)?t.threshold:x,m=c.length,e=new Array(m).fill(null),d=new Array(m).fill(!1),h=[];for(let l=0;l<m;l++){const g=Number(c[l]);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 l=0;l<m;l++){const g=Number(c[l]);if(!Number.isFinite(g))continue;const P=te*(g-r.median)/r.mad;e[l]=P,Math.abs(P)>a&&(d[l]=!0,n++)}return{median:r.median,mad:r.mad,threshold:a,scores:e,flags:d,flagged:n}}function oe(c,t={}){const a=Number.isFinite(t.k)?t.k:T,m=[];for(let n=0;n<c.length;n++){const l=Number(c[n]);Number.isFinite(l)&&m.push(l)}if(!m.length)return null;const e=m.sort((n,l)=>n-l),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 Y(c,t){if(t<=0)return 0;const a=z(c);if(t<c+1){let l=c,g=1/c,P=g;for(let S=0;S<1e3&&(l+=1,P*=t/l,g+=P,!(Math.abs(P)<Math.abs(g)*1e-15));S++);return g*Math.exp(-t+c*Math.log(t)-a)}const m=1e-300;let e=t+1-c,d=1/m,h=1/e,r=h;for(let l=1;l<1e3;l++){const g=-l*(l-c);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 P=h*d;if(r*=P,Math.abs(P-1)<1e-15)break}return 1-Math.exp(-t+c*Math.log(t)-a)*r}function L(c,t){return c<=0?0:Y(t/2,c/2)}function Q(c,t=K){if(!(t>0)||!(t<1))return NaN;let a=0,m=Math.max(1,c);for(;L(m,c)<t;)m*=2;for(let e=0;e<200;e++){const d=(a+m)/2;if(L(d,c)<t?a=d:m=d,m-a<1e-10)break}return(a+m)/2}function _(c){const t=c.length,a=c.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(c,t){const a=c.length,m=new Array(t).fill(0);for(const h of c)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 c)for(let r=0;r<t;r++){const n=h[r]-m[r];for(let l=r;l<t;l++)e[r][l]+=n*(h[l]-m[l])}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 M(c,t={}){const a=Number.isFinite(t.p)?t.p:K,m=Number.isFinite(t.ridge)?t.ridge:1e-6,e=c.length;if(!e)return null;const d=c[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),l=[],g=[];for(let v=0;v<e;v++){const U=c[v];let V=U.length===d;const $=new Array(d);for(let ee=0;V&&ee<d;ee++){const ne=Number(U[ee]);Number.isFinite(ne)?$[ee]=ne:V=!1}V&&(l.push(v),g.push($))}const P=d,S=Q(P,a);if(g.length<=d)return{center:[],df:P,cutoff:S,singular:!0,used:g.length,distances:h,squared:r,flags:n,flagged:0};const{mean:G,cov:F}=C(g,d);let E=_(F),Z=!1;if(!E){Z=!0;let v=0;for(let $=0;$<d;$++)v+=F[$][$];const U=v/d*m||m,V=F.map(($,ee)=>$.map((ne,ce)=>ee===ce?ne+U:ne));if(E=_(V),!E)return{center:G,df:P,cutoff:S,singular:!0,used:g.length,distances:h,squared:r,flags:n,flagged:0}}let R=0;for(let v=0;v<g.length;v++){const U=g[v],V=new Array(d);for(let ne=0;ne<d;ne++)V[ne]=U[ne]-G[ne];let $=0;for(let ne=0;ne<d;ne++){let ce=0;for(let p=0;p<d;p++)ce+=E[ne][p]*V[p];$+=V[ne]*ce}$<0&&($=0);const ee=l[v];r[ee]=$,h[ee]=Math.sqrt($),$>S&&(n[ee]=!0,R++)}return{center:G,df:P,cutoff:S,singular:Z,used:g.length,distances:h,squared:r,flags:n,flagged:R}}const i=20,s=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function u(c,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:x,d=Number.isFinite(t.k)?t.k:T,h=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):m,r=c.length,n=new Array(r).fill(null),l=new Array(r).fill(!1);let g=0;for(let P=0;P<r;P++){const S=Number(c[P]);if(!Number.isFinite(S))continue;const G=Math.max(0,P-m+1),F=[];for(let E=G;E<=P;E++){const Z=Number(c[E]);Number.isFinite(Z)&&F.push(Z)}if(!(F.length<h))if(a==="rollingIqr"){const E=oe(F,{k:d});if(!E)continue;(S<E.lower||S>E.upper)&&(l[P]=!0,g++)}else{const E=J(F);if(!E||E.mad===0)continue;const Z=te*(S-E.median)/E.mad;n[P]=Z,Math.abs(Z)>e&&(l[P]=!0,g++)}}return{method:a,windowLen:m,minPeriods:h,threshold:e,k:d,scores:n,flags:l,flagged:g}}function f(c={}){const t=c||{},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(!(re.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=l=>Number(l==null?NaN:l[a]);return l=>{const g=Array.isArray(l)?l.slice():[...l];d&&g.sort((E,Z)=>{const R=E?.[d],v=Z?.[d];return R===v?0:R==null?-1:v==null?1:R<v?-1:1});const P=g.map(n);let S,G;if(r)({flags:S,scores:G}=u(P,{method:m,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(m==="iqr"){const E=oe(P,{k:t.k});S=P.map(Z=>E?Number.isFinite(Z)&&(Z<E.lower||Z>E.upper):!1),G=P.map(()=>null)}else({flags:S,scores:G}=ue(P,{threshold:t.threshold}));if(h){const E=S.length-1;return E<0||!S[E]?!1:{method:m,field:a,flagged:[{row:g[E],score:G[E]}]}}const F=[];for(let E=0;E<S.length;E++)S[E]&&F.push({row:g[E],score:G[E]});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 x}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return c}});const fe=me("packages/core/src/compute/special.js"),he=fe.normalQuantile,X=fe.studentTQuantile,te=me("packages/core/src/internal/util.js").warnOnce,x=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),T=1e-4,K=1-1e-4;function re(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 ue(t){return Math.min(K,Math.max(T,t))}function oe(t,a=T,m=K,e=80){const d=(Math.sqrt(5)-1)/2;let h=a,r=m,n=r-d*(r-h),l=h+d*(r-h),g=t(n),P=t(l);for(let S=0;S<e;S++)g<P?(r=l,l=n,P=g,n=r-d*(r-h),g=t(n)):(h=n,n=l,g=P,l=h+d*(r-h),P=t(l));return(h+r)/2}function Y(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 l=t[n];if(l===null){e!==null&&d!==null&&(e+=d);continue}if(e===null){e=l;continue}d===null&&(d=l-e);const g=e+d;h+=(l-g)**2,r+=1;const P=e;e=a*l+(1-a)*(P+d),d=m*(e-P)+(1-m)*d}return{level:e,trend:d,sse:h,m:r}}function Q(t,a,m,e,d){const h=t.length;if(h<2*a)return null;const r=Z=>{let R=0,v=0;for(let U=Z;U<Z+a&&U<h;U++)t[U]!==null&&(R+=t[U],v+=1);return v?R/v:null},n=r(0),l=r(a);if(n===null||l===null)return null;let g=n,P=(l-n)/a;const S=new Array(a).fill(0);for(let Z=0;Z<a;Z++)S[Z]=t[Z]===null?0:t[Z]-g;const G=S.reduce((Z,R)=>Z+R,0)/a;for(let Z=0;Z<a;Z++)S[Z]-=G;let F=0,E=0;for(let Z=a;Z<h;Z++){const R=Z%a,v=S[R],U=t[Z];if(U===null){g+=P;continue}const V=g+P+v;F+=(U-V)**2,E+=1;const $=g;g=m*(U-v)+(1-m)*(g+P),P=e*(g-$)+(1-e)*P,S[R]=d*(U-g)+(1-d)*v}return{level:g,trend:P,season:S,phase:(h-1)%a,sse:F,count:E}}function _(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=x.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=re(t),n=r.map(F=>F.value),l=n.filter(F=>F!==null),g=l.length,{lastAt:P,step:S}=g?J(r):{lastAt:0,step:1},G=F=>P+F*S;return m==="linear"?M(r,g,e,d,h,G):m==="movingAverage"?i(l,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 M(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 l=0,g=0,P=0;for(const U of t){if(U.value===null)continue;const V=U.at-r,$=U.value-n;l+=V*V,g+=V*$,P+=$*$}if(l===0)return null;const S=g/l,G=n-S*r,F=P===0?1:Math.max(0,Math.min(1,g*g/(l*P))),E=Math.max(0,P-S*g),Z=a>2?Math.sqrt(E/(a-2)):null,R=a>2?X(d,a-2):null,v=[];for(let U=1;U<=m;U++){const V=h(U),$=G+S*V;let ee=null,ne=null,ce=null,p=null,B=null;if(Z!==null){const H=1/a+(V-r)**2/l,w=Z*Math.sqrt(1+H),A=Z*Math.sqrt(H);B=w,ee=$-R*w,ne=$+R*w,ce=$-R*A,p=$+R*A}v.push({step:U,at:V,mean:$,lower:ee,upper:ne,lowerMean:ce,upperMean:p,se:B})}return{method:"linear",horizon:m,confidence:e,n:a,sigma:Z,r2:F,params:{slope:S,intercept:G},points:v}}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))),l=t.slice(a-n);let g=0;for(const Z of l)g+=Z;const P=g/n;let S=null,G=null;if(n>1){let Z=0;for(const v of l)Z+=(v-P)**2;S=Math.sqrt(Z/(n-1))*Math.sqrt(1+1/n),G=X(d,n-1)}const F=S===null?null:G*S,E=[];for(let Z=1;Z<=m;Z++)E.push({step:Z,at:r(Z),mean:P,lower:F===null?null:P-F,upper:F===null?null:P+F,se:S});return{method:"movingAverage",horizon:m,confidence:e,n:a,sigma:S===null?null:S,params:{windowLen:n},points:E}}function s(t,a,m,e,d,h,r){if(a<1)return null;let n=Number.isFinite(h.alpha)?ue(h.alpha):null;n===null&&(n=oe(G=>Y(t,G).sse));const l=Y(t,n),g=he(d),P=l.m>0?l.sse/l.m:null,S=[];for(let G=1;G<=m;G++){const F=l.level;let E=null,Z=null,R=null;if(P!==null){const v=[];for(let V=1;V<G;V++)v.push(n);const U=_(P,v,g);R=U.se,E=F-U.margin,Z=F+U.margin}S.push({step:G,at:r(G),mean:F,lower:E,upper:Z,se:R})}return{method:"ses",horizon:m,confidence:e,n:a,sigma:P===null?null:Math.sqrt(P),params:{alpha:n},points:S}}function u(t,a,m,e,d,h,r){if(a<2)return null;let n=Number.isFinite(h.alpha)?ue(h.alpha):null,l=Number.isFinite(h.beta)?ue(h.beta):null;if(n===null||l===null){let E=n===null?.5:n,Z=l===null?.5:l;for(let R=0;R<6;R++)n===null&&(E=oe(v=>L(t,v,Z).sse)),l===null&&(Z=oe(v=>L(t,E,v).sse));n=n===null?E:n,l=l===null?Z:l}const g=L(t,n,l),P=he(d),S=g.m>0?g.sse/g.m:null,G=n*l,F=[];for(let E=1;E<=m;E++){const Z=g.level+E*g.trend;let R=null,v=null,U=null;if(S!==null){const V=[];for(let ee=1;ee<E;ee++)V.push(n+ee*G);const $=_(S,V,P);U=$.se,R=Z-$.margin,v=Z+$.margin}F.push({step:E,at:r(E),mean:Z,lower:R,upper:v,se:U})}return{method:"holt",horizon:m,confidence:e,n:a,sigma:S===null?null:Math.sqrt(S),params:{alpha:n,beta:l},points:F}}function f(t,a,m,e,d,h,r){const n=Math.floor(Number(h.period));if(!(n>=2))return te("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(a<2*n)return null;let l=Number.isFinite(h.alpha)?ue(h.alpha):null,g=Number.isFinite(h.beta)?ue(h.beta):null,P=Number.isFinite(h.gamma)?ue(h.gamma):null;const S=(U,V,$)=>{const ee=Q(t,n,U,V,$);return ee?ee.sse:1/0};if(l===null||g===null||P===null){let U=l===null?.5:l,V=g===null?.5:g,$=P===null?.5:P;for(let ee=0;ee<8;ee++)l===null&&(U=oe(ne=>S(ne,V,$))),g===null&&(V=oe(ne=>S(U,ne,$))),P===null&&($=oe(ne=>S(U,V,ne)));l=l===null?U:l,g=g===null?V:g,P=P===null?$:P}const G=Q(t,n,l,g,P);if(!G)return null;const F=he(d),E=G.count>0?G.sse/G.count:null,Z=l*g,R=P*(1-l),v=[];for(let U=1;U<=m;U++){const V=G.season[(G.phase+U)%n],$=G.level+U*G.trend+V;let ee=null,ne=null,ce=null;if(E!==null){const p=[];for(let H=1;H<U;H++)p.push(l+H*Z+(H%n===0?R:0));const B=_(E,p,F);ce=B.se,ee=$-B.margin,ne=$+B.margin}v.push({step:U,at:r(U),mean:$,lower:ee,upper:ne,se:ce})}return{method:"holtWinters",horizon:m,confidence:e,n:a,sigma:E===null?null:Math.sqrt(E),params:{alpha:l,beta:g,gamma:P,period:n},points:v}}const c={FORECAST_METHODS:x,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 X=me("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return X.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return X.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return X.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return X.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return X.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return X.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return X.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return X.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 te=me("packages/core/src/compute/facet.js");Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return te.facet}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return te.computeBounds}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return te.countInto}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return te.bucketOf}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return te.facetKind}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return te.cardinalityOf}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return te.pickGranularity}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return te.floorTo}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return te.advance}}),Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return te.STRATEGIES}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return te.GRANULARITIES}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return te.DEFAULT_BUCKETS}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return te.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return te.QUANTILE_SAMPLE}});const x=me("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return x.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return x.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return x.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return x.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return x.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 re=me("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return re.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return re.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return re.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return re.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return re.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return re.referenceValue}});const 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 ue=me("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return ue.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return ue.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return ue.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return ue.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return ue.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return ue.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return ue.SKETCH_BOUNDS}});const oe=me("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return oe.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return oe.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return oe.openWindow}});const Y=me("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return Y.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return Y.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return Y.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 Q=me("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Q.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return Q.forecast}})}),Se("packages/worker/src/kernel.js",function(o,me){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return _}}),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,X=fe.OPS,z=fe.CONTROL,te=fe.ERRORS,x=fe.unpackHandle,T=fe.unpackHandles,K=fe.createMaskPool,re=fe.collectTransfers,J=me("packages/core/src/store/columnpack.js"),ue=J.packChunk,oe=J.packedTransfers;let Y=null,L=null,Q=null;async function _(f){if(Y)return Y;if(!L){const c=f||(()=>Promise.resolve(me("packages/core/src/compute/index.js")));L=Promise.resolve().then(c).then(t=>(Y=t,t)).catch(t=>(Q=t,Y=null,null))}return L}function C(f){Y=f,L=f?Promise.resolve(f):null,Q=f?null:Q}function M(f,c,t){const a=new Map;for(const m of f)m&&a.set(m.id,m);return{handle(m){return a.get(m)},count:c,pool:K(),locale:t}}function i(f,c){const{op:t,args:a}=f;if(t===X.COLUMNIZE)return ue(a.schema||[],a.rows||[],a.opts||{});const m=c[t];if(typeof m!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=te.NO_KERNEL,e}switch(t){case X.COLLATE_STRING_RANKS:return m(a.table||[],(a.table||[]).length,a.locale);case X.SORT_COLUMN:return m(x(a.handle),a.order??null,a.opts||{});case X.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 X.EVALUATE_FILTERS:return m(a.filters,M(T(a.handles||[]),a.count,a.locale));case X.COMPACT:return m(a.mask,a.count,void 0);case X.GROUP_BY_COLUMNS:return m(T(a.handles||[]),a.order??null,a.opts||{});case X.TOTAL:return m(x(a.handle),a.indices??null,a.fn);case X.PIVOT:return m(T(a.handles||[]),a.order??null,a.opts||{});case X.FACET:return m(x(a.handle),a.indices??null,a.count,a.opts||{});default:{const e=new Error(`[lattice] unknown worker op \'${t}\'`);throw e.code=te.PROTOCOL,e}}}async function s(f,c={}){if(!f||f.lattice!==he)return null;const{id:t,op:a}=f;if(a===z.CANCEL)return c.cancelled?.add(f.target),null;if(a===z.PING)return{reply:{lattice:he,id:t,ok:!0,result:"pong"},transfer:[]};if(a===X.COLUMNIZE){if(c.cancelled?.has(t))return c.cancelled.delete(t),null;try{const e=ue(f.args.schema||[],f.args.rows||[],f.args.opts||{});return c.cancelled?.has(t)?(c.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:oe(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||te.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}const m=await _(c.loader);if(!m)return{reply:{lattice:he,id:t,ok:!1,error:{code:te.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${Q?Q.message:"module not found"}`}},transfer:[]};if(c.cancelled?.has(t))return c.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(f,m);return c.cancelled?.has(t)?(c.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:re(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||te.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}function u(f,c={}){const t=new Set,a=async m=>{const e=await s(m.data,{loader:c.loader,cancelled:t});e&&f.postMessage(e.reply,e.transfer)};return f.addEventListener("message",a),_(c.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 Lt=Un("packages/modules/webcomponent/index.js"),qi=Lt.GridElementController,Zi=Lt.observedAttributeNames,Yi=Lt.domEventName,Xi=Lt.ATTRIBUTE_CONFIG,Qi=Lt.EVENT_PREFIX,Ji=Lt.createLatticeElements,eo=Lt.defineLatticeElements,to=Lt.ELEMENT_TAGS,no=Lt.createLatticeKPIElement,ro=Lt.createLatticeChartElement,io=Lt.createLatticeKanbanElement,oo=Lt.createLatticeGanttElement,so=Lt.createLatticeLayoutElement,ao=Lt.createLatticeTabsElement,lo=Lt.createLatticeRouterElement,uo=Lt.adoptLatticeStyles,co=Lt.latticeStyleSheets,fo=Lt.VIEWER_EVENTS,ho=Lt.VIEWER_APPLY,mo=Lt.viewerHandlerName,po=Lt.createViewerController,go=Lt.EVENT_NAMES,yo=Lt.dashedName,bo=Lt.createCurrencyType,wo=Lt.createUnitType,vo=Lt.registerUnitSystem,ko=Lt.createStat,So=Lt.createHeadlessGrid,Oo=Lt.duckdbAdapter,jo=Lt.createPushdownSource,Ao=Lt.TAG_NAME,Po=Lt.createLatticeGridElement,Co=Lt.defineLatticeGrid;var Eo=Lt.default;export{Xi as ATTRIBUTE_CONFIG,to as ELEMENT_TAGS,go as EVENT_NAMES,Qi as EVENT_PREFIX,qi as GridElementController,Ao as TAG_NAME,ho as VIEWER_APPLY,fo as VIEWER_EVENTS,uo as adoptLatticeStyles,bo as createCurrencyType,So as createHeadlessGrid,ro as createLatticeChartElement,Ji as createLatticeElements,oo as createLatticeGanttElement,Po as createLatticeGridElement,no as createLatticeKPIElement,io as createLatticeKanbanElement,so as createLatticeLayoutElement,lo as createLatticeRouterElement,ao as createLatticeTabsElement,jo as createPushdownSource,ko as createStat,wo as createUnitType,po as createViewerController,yo as dashedName,Eo as default,eo as defineLatticeElements,Co as defineLatticeGrid,Yi as domEventName,Oo as duckdbAdapter,co as latticeStyleSheets,Zi as observedAttributeNames,vo as registerUnitSystem,mo as viewerHandlerName};
|
|
58
|
+
`;return t}catch{return""}}function U(l,u){const n=$.get(l);if(n)return n.sheet;const t=V(l);if(!t)return null;const i=u.CSSStyleSheet,s=new i;try{s.replaceSync(t)}catch{return null}s[q]=!0;let r=null;const o=u.MutationObserver;return typeof o=="function"&&String(l.tagName).toLowerCase()==="style"&&(r=new o(()=>{try{s.replaceSync(String(l.textContent||""))}catch{}}),r.observe(l,{childList:!0,characterData:!0,subtree:!0})),$.set(l,{sheet:s,stop:()=>r&&r.disconnect()}),s}function x(l){return l?l.nodeType===9?l:l.ownerDocument||globalThis.document||null:globalThis.document||null}function I(l){const u=l||globalThis.document;return!u||typeof u.querySelectorAll!="function"?[]:[...u.querySelectorAll("style,link[rel]")].filter(Z)}function v(l={}){if(!W())return[];const u=l.document||globalThis.document,n=u&&u.defaultView||globalThis,t=[];for(const i of I(u)){const s=U(i,n);s&&!t.includes(s)&&t.push(s)}return t}function k(l,u={}){const n=()=>{};if(!l||typeof l!="object")return n;const t=u.document||x(l);if(!t)return n;const i=t.defaultView||globalThis;let s=N.get(l);s||(s=new Map,N.set(l,s));const r=[],o=W(),c=p=>{if(s.has(p))return;const f=o?U(p,i):null;if(f){s.set(p,f);const S=l.adoptedStyleSheets||[];S.includes(f)||(l.adoptedStyleSheets=[...S,f]);return}if(String(p.tagName).toLowerCase()!=="link"||typeof l.appendChild!="function")return;const w=t.createElement("link");w.setAttribute("rel","stylesheet"),w.setAttribute("href",p.getAttribute("href")||""),w.setAttribute("data-lattice","adopted"),l.appendChild(w),r.push(w),s.set(p,w)};for(const p of I(t))c(p);let a=null;const g=i.MutationObserver,h=t.head||t.documentElement;typeof g=="function"&&h&&(a=new g(p=>{for(const f of p)for(const w of f.addedNodes||[])Z(w)&&c(w)}),a.observe(h,{childList:!0}));let b=!1;return()=>{if(b)return;b=!0,a&&a.disconnect();const p=l.adoptedStyleSheets||[],f=new Set([...s.values()]);l.adoptedStyleSheets=p.filter(w=>!f.has(w));for(const w of r)w.parentNode&&w.parentNode.removeChild(w);s.clear()}}function y(l){if(!l||typeof l.getRootNode!="function"||typeof l.getAttribute=="function"&&String(l.getAttribute("lattice-styles")||"")==="off")return null;const u=l.getRootNode();return!u||u.nodeType!==11||!u.host?null:k(u)}}),Ae("packages/modules/webcomponent/elements.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_GRID_NAME",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_TAG_PREFIX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ELEMENT_TAGS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"VIEWER_ALIASES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"VIEWER_BINDING",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"coerceElementAttribute",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"attributeConfig",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"createElementScope",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"scopeFor",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"applyPredicates",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"upgradeProperty",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"installProperty",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"harvestProperties",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"createLatticeKPIElement",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"createLatticeChartElement",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"createLatticeKanbanElement",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createLatticeGanttElement",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"createLatticeLayoutElement",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"createLatticeTabsElement",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"createLatticeRouterElement",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"createLatticeElements",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"defineLatticeElements",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(e,"gridElementClass",{enumerable:!0,get:function(){return oe}});const M=G("packages/core/src/internal/util.js").warnOnce,N=G("packages/modules/shared/adapter.js").aliasConfigKey,W=G("packages/modules/react/viewers.js"),Z=W.VIEWER_EVENTS,V=W.viewerHandlerName,U=W.createViewerController,x=G("packages/modules/webcomponent/controller.js"),I=x.GridElementController,v=x.observedAttributeNames,k=x.domEventName,y=x.ATTRIBUTE_CONFIG,u=G("packages/modules/webcomponent/styles.js").adoptIntoHostRoot,n="default",t="lattice-",i=Object.freeze({grid:"grid",kpi:"kpi",chart:"chart",kanban:"kanban",gantt:"gantt",layout:"layout",tabs:"tabs",router:"router"}),s=Object.freeze({chart:re=>{if("data"in re){const le=re.data;delete re.data,le!=null&&re.rows===void 0&&(re.rows=le)}if("stacked"in re){const le=re.stacked;delete re.stacked,le!=null&&re.stack===void 0&&(re.stack=le)}if("horizontal"in re){const le=re.horizontal;delete re.horizontal,le&&re.type==="bar"&&(re.type="horizontalBar")}},kanban:re=>{if(!("titleProperty"in re))return;const le=re.titleProperty;if(delete re.titleProperty,typeof le!="string"||!le)return;const ne=re.card&&typeof re.card=="object"?re.card:null;ne&&ne.title!==void 0||(re.card={title:le,...ne||{}})},gantt:re=>{if(!("scale"in re))return;const le=re.scale;if(delete re.scale,le==null||le==="")return;const ne=re.render&&typeof re.render=="object"?{...re.render}:{};ne.zoom===void 0&&(ne.zoom=le),re.render=ne}}),r=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"])})}),o=new Set(["grid-name","lattice-styles","name","route","route-options","id","class","style","slot"]),c=new Set(["role","tabindex","hidden","part","exportparts","lang","dir","title-id","is"]),a=Symbol.for("lattice.webcomponent.routerScope"),g=new WeakMap;function h(re){if(re==null)return;if(re===""||re==="true")return!0;if(re==="false")return!1;const le=String(re).trim();if(le.startsWith("[")||le.startsWith("{"))try{return JSON.parse(le)}catch{return re}return le!==""&&Number.isFinite(Number(le))?Number(le):re}function b(re,le){const ne={},se=re&&typeof re.getAttributeNames=="function"?re.getAttributeNames():[];for(const ae of se){if(o.has(ae)||c.has(ae)||le&&le.has(ae)||ae.startsWith("data-")||ae.startsWith("aria-"))continue;const de=h(re.getAttribute(ae));de!==void 0&&(ne[p(ae)]=de)}return ne}function p(re){const le=N(re);return le!==re||!re.includes("-")?le:re.replace(/-([a-z0-9])/g,(ne,se)=>se.toUpperCase())}function f(re){return re&&typeof re.getAttributeNames=="function"?re.getAttributeNames():[]}function w(re){const le=[];for(const ne of f(re))o.has(ne)||c.has(ne)||ne.startsWith("data-")||ne.startsWith("aria-")||le.push(p(ne));return le}function S(){const re=new Map,le=new Set;return{publish(ne,se){const ae=ne||n;se?re.set(ae,se):re.delete(ae);for(const de of[...le])de()},get(ne){return re.get(ne||n)||null},names(){return[...re.keys()]},subscribe(ne){return le.add(ne),()=>{le.delete(ne)}}}}function m(re={}){const le=typeof re.createDataRouter=="function"?re.createDataRouter:null;let ne=null,se=!1;return{grids:S(),get router(){return ne},attach(de,me,Pe){se||!le||(ne||(ne=le(re.config||{})),ne.attach(de,me,Pe||{}))},detach(de){if(!(se||!ne))try{ne.detach(de)}catch{}},destroy(){se=!0;const de=ne;ne=null,de&&de.destroy()}}}function d(re){let le=re&&re.parentNode||null;for(;le;){if(le[a])return le[a];le=le.parentNode||le.host||null}const se=(re&&typeof re.getRootNode=="function"?re.getRootNode():re&&re.ownerDocument||null)||globalThis.document||globalThis;let ae=g.get(se);return ae||(ae=m(),g.set(se,ae)),ae}function j(re,le,ne){const se=le&&typeof le=="object"?le:{},ae=ne&&typeof ne=="object"?ne:{};for(const[de,me]of Object.entries(se))Object.is(ae[de],me)||re.filters.where(de,typeof me=="function"?me:null);for(const de of Object.keys(ae))Object.hasOwn(se,de)||re.filters.where(de,null)}function E(re,le){if(!Object.hasOwn(re,le))return;const ne=re[le];delete re[le],re[le]=ne}const O=new Set(["instance","config","grid","gridName","router"]);function T(re,le){let ne=Object.getPrototypeOf(re);for(;ne;){const se=Object.getOwnPropertyDescriptor(ne,le);if(se)return typeof se.get=="function";ne=Object.getPrototypeOf(ne)}return!1}function A(re,le){if(!le||O.has(le)||le.startsWith("__"))return;const ne=Object.getOwnPropertyDescriptor(re,le);if(ne&&typeof ne.get=="function")return;if(T(re,le)){ne&&E(re,le);return}const se=ne?ne.value:void 0;ne&&delete re[le],Object.defineProperty(re,le,{get(){return this.__props[le]},set(ae){this.__write(le,ae)},configurable:!0,enumerable:!0}),ne&&(re[le]=se)}function P(re){let le=!1;for(const ne of Object.getOwnPropertyNames(re)){if(ne.startsWith("__")||O.has(ne))continue;const se=Object.getOwnPropertyDescriptor(re,ne);!se||typeof se.get=="function"||!se.enumerable||(A(re,ne),le=!0)}return le}function L(re,le,ne){if(!re||typeof re.dispatchEvent!="function")return;const se=globalThis.CustomEvent,ae={detail:ne,bubbles:!0,composed:!0};re.dispatchEvent(typeof se=="function"?new se(le,ae):{type:le,...ae})}function z(re){const le=re.viewer,ne=r[le],se=re.label||ne.label,ae=re.mount,de=Z[le]||[];class me extends re.Base{__props={};__controller=null;__builtAgainst=null;__connected=!1;__teardownPending=!1;__release=[];__queued=!1;__wired=!1;__scope=null;__ownAttributes=new Set;constructor(){super();for(const Ie of["config","grid","gridName",...ne.properties,...ne.scalars])E(this,Ie);P(this)}get instance(){return this.__controller?this.__controller.instance:null}get grid(){return this.__props.grid}set grid(Ie){this.__write("grid",Ie)}get gridName(){const Ie=this.__props.gridName;if(typeof Ie=="string")return Ie;const ke=typeof this.getAttribute=="function"?this.getAttribute("grid-name"):null;return ke===null?void 0:ke}set gridName(Ie){this.__write("gridName",Ie)}get config(){return{...this.__props}}set config(Ie){if(!(!Ie||typeof Ie!="object")){for(const[ke,be]of Object.entries(Ie))this.__props[ke]=be;this.__schedule()}}connectedCallback(){if(this.__teardownPending=!1,!this.__connected){if(this.__connected=!0,!this.__wired){this.__wired=!0;const Ie=u(this);Ie&&this.__release.push(Ie);const ke=d(this);this.__scope=ke,ne.fromContext&&this.__release.push(ke.grids.subscribe(()=>this.__settle()));const be=globalThis.MutationObserver;if(typeof be=="function"){const ge=new be(()=>this.__settle());ge.observe(this,{attributes:!0}),this.__release.push(()=>ge.disconnect())}}P(this);for(const Ie of w(this))A(this,Ie);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 Ie of this.__release.splice(0))try{Ie()}catch{}this.__tearDown()}}__write(Ie,ke){this.__props[Ie]=ke,this.__schedule()}__schedule(){this.__queued||(this.__queued=!0,queueMicrotask(()=>{this.__queued=!1,this.__settle()}))}__boundGrid(){if(!ne.fromContext)return null;if(this.__props.grid!==void 0)return this.__props.grid||null;const Ie=this.__scope;return Ie?Ie.grids.get(this.gridName):null}__resolve(){const Ie={...b(this,this.__ownAttributes),...this.__props};if(delete Ie.gridName,ne.fromContext){const be=this.__boundGrid();be?Ie[ne.fromContext]=be:delete Ie[ne.fromContext]}const ke=s[le];ke&&ke(Ie);for(const be of de)Ie[V(be)]=ge=>L(this,k(be),ge);return Ie}__settle(){if(!this.__connected)return;P(this);const Ie=this.__resolve(),ke=ne.fromContext&&Ie[ne.fromContext]||null;if(this.__controller&&!Object.is(this.__builtAgainst,ke)&&this.__tearDown(),!this.__controller){for(const ge of ne.requires)if(Ie[ge]===void 0||Ie[ge]===null)return;if(ne.fromContext&&!ke&&Ie.rows===void 0)return;const be=new Set(f(this));this.__controller=U({viewer:le,mount:ae,element:this,props:Ie,name:se});for(const ge of f(this))be.has(ge)||this.__ownAttributes.add(ge);this.__builtAgainst=ke,L(this,"ready",{instance:this.__controller.instance});return}this.__controller.update(Ie)}__tearDown(){const Ie=this.__controller;this.__controller=null,this.__builtAgainst=null,Ie&&(L(this,"destroyed",{instance:Ie.instance}),Ie.destroy())}}for(const Pe of[...ne.properties,...ne.scalars])Pe in re.Base.prototype||Object.defineProperty(me.prototype,Pe,{get(){return this.__props[Pe]},set(Ie){this.__write(Pe,Ie)},configurable:!0,enumerable:!0});return me}function H(re,le,ne){if(typeof re!="function")throw new TypeError(`${le} needs ${ne}: ${le}({ ${ne} }).`)}function D(){const re=globalThis.HTMLElement;return typeof re=="function"?re:null}function F(re){H(re&&re.createKPI,"createLatticeKPIElement","createKPI");const le=D();return le?z({viewer:"kpi",Base:le,mount:(ne,se)=>re.createKPI(ne,se)}):null}function C(re){H(re&&re.createChart,"createLatticeChartElement","createChart");const le=D();return le?z({viewer:"chart",Base:le,mount:(ne,se)=>re.createChart({...se,container:ne})}):null}function B(re){H(re&&re.createKanban,"createLatticeKanbanElement","createKanban");const le=D();return le?z({viewer:"kanban",Base:le,mount:(ne,se)=>re.createKanban(ne,se)}):null}function _(re){H(re&&re.createGantt,"createLatticeGanttElement","createGantt");const le=D();return le?z({viewer:"gantt",Base:le,mount:(ne,se)=>re.createGantt({...se,element:ne})}):null}function Q(re){H(re&&re.createLayout,"createLatticeLayoutElement","createLayout");const le=D();return le?z({viewer:"layout",Base:le,mount:(ne,se)=>re.createLayout(ne,se)}):null}function Y(re){H(re&&re.createTabs,"createLatticeTabsElement","createTabs");const le=D();return le?z({viewer:"tabs",Base:le,mount:(se,ae)=>{const de=new Map,me=typeof se.querySelectorAll=="function"?[...se.querySelectorAll("template[data-tab]")]:[];for(const ke of me)ke.parentNode===se&&de.set(ke.getAttribute("data-tab"),ke);const Ie=(Array.isArray(ae.tabs)&&ae.tabs.length?ae.tabs:[...de.keys()].map(ke=>({id:ke,label:de.get(ke).getAttribute("data-label")||ke}))).map(ke=>{const be=ke,ge=de.get(be.id);return ge?{...be,view:Ee=>{const xe=ge.content.cloneNode(!0),ze=[...xe.childNodes];return Ee.appendChild(xe),{destroy(){for(const _e of ze)_e.parentNode&&_e.parentNode.removeChild(_e)}}}}:be});return re.createTabs(se,{...ae,tabs:Ie,createGrid:re.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(re){H(re&&re.createDataRouter,"createLatticeRouterElement","createDataRouter");const le=D();if(!le)return null;class ne extends le{__scope=null;__config={};constructor(){super(),E(this,"config")}get config(){return{...this.__config}}set config(ae){!ae||typeof ae!="object"||(this.__config={...this.__config,...ae},this.__scope&&this.__scope.router&&M("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 ae=b(this);this.__scope=m({createDataRouter:re.createDataRouter,config:{...ae,...this.__config}}),this[a]=this.__scope}disconnectedCallback(){const ae=this.__scope;if(this.__scope=null,this[a]=null,!ae)return;const de=ae.router;ae.destroy(),de&&L(this,"destroyed",{instance:de})}}return ne}function te(re={}){const le={},ne=(se,ae,de)=>{if(typeof ae!="function")return;const me=de();me&&(le[se]=me)};return ne("LatticeGridElement",re.createGrid,()=>oe(re.createGrid)),ne("LatticeKPIElement",re.createKPI,()=>F({createKPI:re.createKPI})),ne("LatticeChartElement",re.createChart,()=>C({createChart:re.createChart})),ne("LatticeKanbanElement",re.createKanban,()=>B({createKanban:re.createKanban})),ne("LatticeGanttElement",re.createGantt,()=>_({createGantt:re.createGantt})),ne("LatticeLayoutElement",re.createLayout,()=>Q({createLayout:re.createLayout})),ne("LatticeTabsElement",re.createTabs,()=>Y({createTabs:re.createTabs,createGrid:re.createGrid})),ne("LatticeRouterElement",re.createDataRouter,()=>J({createDataRouter:re.createDataRouter})),le}function ee(re={}){const le=globalThis.customElements,ne={};if(!le||typeof le.define!="function")return ne;const se=typeof re.prefix=="string"?re.prefix:t,ae=te(re),de={LatticeGridElement:i.grid,LatticeKPIElement:i.kpi,LatticeChartElement:i.chart,LatticeKanbanElement:i.kanban,LatticeGanttElement:i.gantt,LatticeLayoutElement:i.layout,LatticeTabsElement:i.tabs,LatticeRouterElement:i.router};for(const[me,Pe]of Object.entries(ae)){const Ie=se+de[me],ke=le.get?le.get(Ie):void 0;if(ke){ne[Ie]=ke;continue}le.define(Ie,Pe),ne[Ie]=Pe}return ne}function oe(re){const le=D();if(!le)return null;class ne extends le{static get observedAttributes(){return v()}__connected=!1;__teardownPending=!1;__published=!1;__publishedAs=n;__scope=null;__predicates=void 0;__rowUpdates=void 0;__release=[];constructor(){super(),this.__controller=new I(this,{createGrid:re});for(const ae of["rows","columns","config","predicates","rowUpdates",...Object.values(y)])E(this,ae)}get grid(){return this.__controller.grid}get instance(){return this.__controller.grid}get rows(){return this.__controller.config().rows}set rows(ae){this.__controller.configure({rows:ae})}get columns(){return this.__controller.config().columns}set columns(ae){this.__controller.configure({columns:ae})}get config(){return this.__controller.config()}set config(ae){this.__controller.configure(ae)}get predicates(){return this.__predicates}set predicates(ae){const de=this.__published?this.__controller.grid:null;de&&j(de,ae,this.__predicates),this.__predicates=ae}get rowUpdates(){return this.__rowUpdates}set rowUpdates(ae){if(Object.is(ae,this.__rowUpdates))return;this.__rowUpdates=ae;const de=this.__published?this.__controller.grid:null;de&&ae&&de.rows.apply(ae)}connectedCallback(){if(this.__teardownPending=!1,!this.__connected){if(this.__connected=!0,!this.__scope){const ae=u(this);ae&&this.__release.push(ae),this.__scope=d(this)}this.__controller.connect(),queueMicrotask(()=>this.__publish())}}disconnectedCallback(){this.__connected&&(this.__connected=!1,this.__teardownPending=!0,queueMicrotask(()=>this.__settleTeardown()),this.__controller.disconnect())}attributeChangedCallback(ae,de,me){this.__controller.attributeChanged(ae,me)}__publish(){if(!this.__connected||this.__published)return;const ae=this.__controller.grid;if(!ae)return;this.__published=!0,this.__predicates&&j(ae,this.__predicates,{});const de=typeof this.getAttribute=="function"?this.getAttribute("name"):null;this.__publishedAs=de||n;const me=this.__scope;me&&me.grids.publish(this.__publishedAs,ae);const Pe=typeof this.getAttribute=="function"?this.getAttribute("route"):null;if(me&&Pe!==null){const Ie=this.getAttribute("route-options");me.attach(ae,h(Pe),Ie===null?{}:h(Ie))}this.__rowUpdates&&ae.rows.apply(this.__rowUpdates),L(this,"grid-ready",{grid:ae})}__settleTeardown(){if(!this.__teardownPending)return;this.__teardownPending=!1;const ae=this.__controller.grid,de=this.__scope;this.__scope=null,this.__published=!1;for(const me of this.__release.splice(0))try{me()}catch{}ae&&de&&(L(this,"grid-destroyed",{grid:ae}),de.detach(ae),de.grids.publish(this.__publishedAs,null)),this.__controller.settleTeardown()}}for(const se of Object.values(y))Object.getOwnPropertyDescriptor(ne.prototype,se)||se in le.prototype||Object.defineProperty(ne.prototype,se,{get(){return this.__controller.config()[se]},set(ae){this.__controller.configure({[se]:ae})},configurable:!0,enumerable:!0});return ne}}),Ae("packages/modules/webcomponent/index.js",function(e,G){"use strict";Object.defineProperty(e,"TAG_NAME",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"createLatticeGridElement",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"defineLatticeGrid",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const q=G("packages/dom/src/index.js"),M=q.createGrid,$=G("packages/modules/webcomponent/elements.js"),N=$.gridElementClass,W=G("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 $.createLatticeElements}}),Object.defineProperty(e,"defineLatticeElements",{enumerable:!0,get:function(){return $.defineLatticeElements}}),Object.defineProperty(e,"ELEMENT_TAGS",{enumerable:!0,get:function(){return $.ELEMENT_TAGS}}),Object.defineProperty(e,"createLatticeKPIElement",{enumerable:!0,get:function(){return $.createLatticeKPIElement}}),Object.defineProperty(e,"createLatticeChartElement",{enumerable:!0,get:function(){return $.createLatticeChartElement}}),Object.defineProperty(e,"createLatticeKanbanElement",{enumerable:!0,get:function(){return $.createLatticeKanbanElement}}),Object.defineProperty(e,"createLatticeGanttElement",{enumerable:!0,get:function(){return $.createLatticeGanttElement}}),Object.defineProperty(e,"createLatticeLayoutElement",{enumerable:!0,get:function(){return $.createLatticeLayoutElement}}),Object.defineProperty(e,"createLatticeTabsElement",{enumerable:!0,get:function(){return $.createLatticeTabsElement}}),Object.defineProperty(e,"createLatticeRouterElement",{enumerable:!0,get:function(){return $.createLatticeRouterElement}});const Z=G("packages/modules/webcomponent/styles.js");Object.defineProperty(e,"adoptLatticeStyles",{enumerable:!0,get:function(){return Z.adoptLatticeStyles}}),Object.defineProperty(e,"latticeStyleSheets",{enumerable:!0,get:function(){return Z.latticeStyleSheets}});const V=G("packages/modules/react/viewers.js");Object.defineProperty(e,"VIEWER_EVENTS",{enumerable:!0,get:function(){return V.VIEWER_EVENTS}}),Object.defineProperty(e,"VIEWER_APPLY",{enumerable:!0,get:function(){return V.VIEWER_APPLY}}),Object.defineProperty(e,"viewerHandlerName",{enumerable:!0,get:function(){return V.viewerHandlerName}}),Object.defineProperty(e,"createViewerController",{enumerable:!0,get:function(){return V.createViewerController}});const U=G("packages/modules/shared/adapter.js");Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return U.EVENT_NAMES}}),Object.defineProperty(e,"dashedName",{enumerable:!0,get:function(){return U.dashedName}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return q.createCurrencyType}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return q.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return q.registerUnitSystem}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return q.createStat}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return q.createHeadlessGrid}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return q.duckdbAdapter}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return q.createPushdownSource}});const x="lattice-grid";function I(y=M){return N(y)}function v(y={}){const l=globalThis.customElements,u=y.tagName||x;if(!l||typeof l.define!="function")return null;const n=l.get?l.get(u):void 0;if(n)return n;const t=I(y.createGrid||M);return t?(l.define(u,t),t):null}v();const k=v});try{Un("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 X}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"pathSetter",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"escapeHtml",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"titleCase",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"expand",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return H}});const fe="1.75.0";async function he(){return fe}const X="1.75.0",z=new Set,te=2e3;function x(w){if(z.add(w),z.size>te){const A=z.values().next().value;A!==void 0&&z.delete(A)}}const T=[],K=500;function re(w,A,q){T.push({key:w,level:A,message:q.map(le=>typeof le=="string"?le:J(le)).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 ue(){return T.map(w=>({...w}))}function oe(w,...A){z.has(w)||(x(w),re(w,"warn",A),console.warn("[lattice]",...A))}function Y(w,...A){z.has(w)||(x(w),re(w,"info",A),console.info("[lattice]",...A))}function L(){z.clear(),T.length=0}function Q(w,A){const q=new Error(`[lattice] ${w}`);throw A!==void 0&&(q.cause=A),q}function _(w,A){w||Q(A)}const C=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function M(w){return w!==null&&typeof w=="object"&&!Array.isArray(w)}function i(w){return typeof w=="function"}function s(w){return w==null}function u(w){return w==null||w===""}function f(w){return typeof w!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(w))?!0:!!(w.prototype&&Object.getOwnPropertyNames(w.prototype).length>1)}const c=new Map;function t(w){let A=c.get(w);if(A)return A;if(!w.includes("."))A=q=>q?.[w];else{const q=w.split("."),le=q.length;A=ae=>{let de=ae;for(let pe=0;pe<le;pe++){if(de==null)return;de=de[q[pe]]}return de}}return c.set(w,A),A}const a=new Map;function m(w){let A=a.get(w);if(A)return A;if(!w.includes("."))A=(q,le)=>{q!=null&&(q[w]=le)};else{const q=w.split("."),le=q.length-1;A=(ae,de)=>{let pe=ae;for(let ge=0;ge<le;ge++){if(pe==null)return;const ke=q[ge];pe[ke]==null&&(pe[ke]={}),pe=pe[ke]}pe!=null&&(pe[q[le]]=de)}}return a.set(w,A),A}function e(w,A){return t(A)(w)}function d(w,A,q){m(A)(w,q)}function h(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(/^./,q=>q.toUpperCase()):""}const r={"&":"&","<":"<",">":">",\'"\':""","\'":"'"};function n(w){const A=w==null?"":String(w);return/[&<>"\']/.test(A)?A.replace(/[&<>"\']/g,q=>r[q]):A}function l(w){return String(w).replace(/\\w\\S*/g,A=>A[0].toUpperCase()+A.slice(1).toLowerCase())}function g(w,A,q){if(w!==void 0)return w===!0?{enabled:!0,...q}:w===!1?{enabled:!1}:M(w)?w:{[A]:w,enabled:!0}}function P(w){return w==null?[]:Array.isArray(w)?w:[w]}const S=Object.freeze(new Set(["__proto__","constructor","prototype"]));function G(w,A){if(!M(w))return M(A)?{...A}:A;if(!M(A))return A===void 0?w:A;const q={...w};for(const le of Object.keys(A)){if(S.has(le))continue;const ae=A[le];ae!==void 0&&(q[le]=M(ae)&&M(q[le])?G(q[le],ae):ae)}return q}function F(w,A){if(!M(w)||!M(A)||w===A)return A;const q=Object.create(Object.getPrototypeOf(w));return Object.assign(q,w,A),q}class E{#t;#e=new Map;#n;constructor(A=256,q=null){this.#t=A,this.#n=q}get size(){return this.#e.size}get max(){return this.#t}set max(A){this.#t=A,this.#r()}has(A){return this.#e.has(A)}get(A){const q=this.#e;if(!q.has(A))return;const le=q.get(A);return q.delete(A),q.set(A,le),le}peek(A){return this.#e.get(A)}set(A,q){const le=this.#e;return le.has(A)&&le.delete(A),le.set(A,q),this.#r(),q}delete(A){const q=this.#e.get(A);return this.#e.delete(A)&&this.#n&&this.#n(q,A),q}clear(){if(this.#n)for(const[A,q]of this.#e)this.#n(q,A);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const A=this.#e;for(;A.size>this.#t;){const q=A.keys().next().value,le=A.get(q);A.delete(q),this.#n&&this.#n(le,q)}}}const Z=new Map;function R(w,A){const q=`${w||""}|${A?JSON.stringify(A):""}`;let le=Z.get(q);return le||(le=new Intl.Collator(w||void 0,{numeric:!0,sensitivity:"variant",...A}),Z.set(q,le)),le}function v(w,A){if(w===A)return 0;if(w==null)return 1;if(A==null)return-1;if(typeof w=="number"&&typeof A=="number")return Number.isNaN(w)?Number.isNaN(A)?0:1:Number.isNaN(A)||w<A?-1:w>A?1:0;const q=String(w),le=String(A);return q<le?-1:q>le?1:0}function U(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const V=typeof requestAnimationFrame=="function";function $(w){return V?requestAnimationFrame(w):setTimeout(()=>w(U()),16)}function ee(w){w!=null&&(V?cancelAnimationFrame(w):clearTimeout(w))}function ne(w){let A=null,q=null;const le=()=>{A=null;const de=q;q=null,w(...de||[])},ae=(...de)=>{q=de,A===null&&(A=$(le))};return ae.cancel=()=>{ee(A),A=null,q=null},ae.flush=()=>{A!==null&&(ee(A),le())},ae}function ce(w,A){let q=null,le=null;const ae=()=>{if(q=null,le===null)return;const ge=le;le=null,w(...ge),de()},de=()=>{q=setTimeout(ae,A),typeof q?.unref=="function"&&q.unref()},pe=(...ge)=>{q===null?(w(...ge),de()):(le=ge,clearTimeout(q),de())};return pe.flush=()=>{if(q!==null&&clearTimeout(q),q=null,le===null)return;const ge=le;le=null,w(...ge)},pe.cancel=()=>{q!==null&&clearTimeout(q),q=null,le=null},pe.pending=()=>q!==null||le!==null,pe}function p(w,A=50){return typeof requestIdleCallback=="function"?requestIdleCallback(w,{timeout:A}):setTimeout(()=>w({timeRemaining:()=>0,didTimeout:!0}),1)}let B=0;function H(w="l"){return`${w}${(++B).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 te}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return x}}),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 oe}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,X=fe.isFunction,z=1,te=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"}),x=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?re(s.dict):null,offsets:s.offsets??null,version:s.version??0}}function re(s){return Array.isArray(s)?s:X(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 ue{#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 c=0;c<u.length;c++){let t=u[c];for(;t;)t&=t-1,f++}return f}}class oe{#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 c=this.#t.length;return this.#t.push(u),this.#e.set(u,c),this.#n++,c}valueOf(u){return this.#t[u]}values(){return this.#t}ranks(u){const f=u||"",c=this.#r.get(f);if(c&&c.version===this.#n)return c.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 l=e[r],g=e[n];return l===g?0:l==null?1:g==null?-1:m(String(l),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 Y(s){if(s==null)return null;const u=s.presence?new ue(s.presence,s.presenceBits||s.presence.length*8):null,f=s.dict?new oe(s.dict):null,c=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(c[e]):c[e];case"bitset":return(c[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(c[n]):c[n];return r}default:return c[e]}};return{id:s.id,kind:a,nullable:s.nullable,values:c,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]=Y(s[f]);return u}function Q(){const s=[],u=[];return{mask(f){for(let c=0;c<s.length;c++)if(s[c].length>=f){const t=s.splice(c,1)[0].subarray(0,f);return t.fill(0),t}return new Uint8Array(f)},indices(f){for(let c=0;c<u.length;c++)if(u[c].length>=f)return u.splice(c,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 _(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=c=>{if(!_(c))return;const t=c.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 c of s)f(c);return u}if(typeof s=="object")for(const c of Object.keys(s)){const t=s[c];if(Array.isArray(t))for(const a of t)f(a);else f(t)}return u}function M(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 c of s)if(!M(c,u+1))return!1;return!0}for(const c of Object.keys(s))if(!M(s[c],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 c=f.conditions;if(Array.isArray(c))for(const t of c)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 te=Math.max(0,z|0);this.#n=te,this.#e=new Uint8Array(Math.ceil(te/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,te){return te?this.set(z):this.clear(z)}fill(z=!1){return this.#e.fill(z?255:0),z&&this.#r(),this}grow(z){const te=Math.max(0,z|0);if(te<=this.#n)return this;const x=Math.ceil(te/fe);if(x>this.#e.length){const T=new Uint8Array(x);T.set(this.#e),this.#e=T}return this.#n=te,this}count(){const z=this.#e,te=he.#t;let x=0;for(let T=0;T<z.length;T++)x+=te[z[T]];return x}and(z){const te=z instanceof he?z.words:z,x=this.#e,T=Math.min(x.length,te.length);for(let K=0;K<T;K++)x[K]&=te[K];for(let K=T;K<x.length;K++)x[K]=0;return this}or(z){const te=z instanceof he?z.words:z,x=this.#e,T=Math.min(x.length,te.length);for(let K=0;K<T;K++)x[K]|=te[K];return this}not(){const z=this.#e;for(let te=0;te<z.length;te++)z[te]=~z[te]&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 te=this.#n>>3;te<this.#e.length&&(this.#e[te]&=(1<<z)-1)}static from(z){const te=Array.isArray(z)?z:Array.from(z),x=new he(te.length);for(let T=0;T<te.length;T++)te[T]&&x.set(T);return x}}}),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,X=fe.defaultCompare;class z{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(x=[]){this.#t=[];for(let T=0;T<x.length;T++){const K=x[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 x=this.#t.length*8;for(let T=0;T<this.#t.length;T++){const K=this.#t[T];typeof K=="string"&&(x+=K.length*2),x+=16}return x}codeOf(x){const T=this.#e.get(x);if(T!==void 0)return T;const K=this.#t.length;return this.#t.push(x),this.#e.set(x,K),this.#n++,K}lookup(x){const T=this.#e.get(x);return T===void 0?-1:T}has(x){return this.#e.has(x)}valueOf(x){return this.#t[x]}values(){return this.#t}ranks(x){const T=x||"";if(this.#r&&this.#i===this.#n&&this.#s===T)return this.#r;const K=this.#t.length,re=new Array(K);for(let Y=0;Y<K;Y++)re[Y]=Y;const J=he(x).compare,ue=this.#t;re.sort((Y,L)=>this.#h(ue[Y],ue[L],J));const oe=new Uint32Array(K);for(let Y=0;Y<K;Y++)oe[re[Y]]=Y;return this.#r=oe,this.#i=this.#n,this.#s=T,oe}#h(x,T,K){return typeof x=="string"&&typeof T=="string"?K(x,T):X(x,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(X={}){const z=Math.max(1,X.rows??16),te=Math.max(1,X.values??z);this.#t=new Int32Array(te),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(X){return X<0||X>=this.#n?0:this.#e[X+1]-this.#e[X]}at(X){return X<0||X>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[X],this.#e[X+1])}has(X,z){if(X<0||X>=this.#n)return!1;const te=this.#t,x=this.#e[X+1];for(let T=this.#e[X];T<x;T++)if(te[T]===z)return!0;return!1}hasAny(X,z){for(let te=0;te<z.length;te++)if(this.has(X,z[te]))return!0;return!1}hasAll(X,z){for(let te=0;te<z.length;te++)if(!this.has(X,z[te]))return!1;return!0}hasNone(X,z){return!this.hasAny(X,z)}push(X){const z=this.#n,te=X.length;this.#i(z+1),this.#s(this.#r+te);const x=this.#r;for(let T=0;T<te;T++)this.#t[x+T]=X[T]|0;return this.#r+=te,this.#n=z+1,this.#e[z]=x,this.#e[z+1]=this.#r,z}write(X,z){if(X===this.#n){this.push(z);return}if(X<0||X>this.#n)return;const te=this.#e[X],x=this.#e[X+1],T=z.length;if(x-te===T){for(let K=0;K<T;K++)this.#t[te+K]=z[K]|0;return}this.#h(X,z)}compact(X,z,te){const x=this.#t,T=this.#e,K=this.#n,re=new Int32Array(Math.max(1,this.#r)),J=new Uint32Array(z+1);let ue=0;for(let oe=0;oe<K;oe++){if(X[oe]===te)continue;const Y=T[oe],L=T[oe+1];J[X[oe]]=ue;for(let Q=Y;Q<L;Q++)re[ue++]=x[Q];J[X[oe]+1]=ue}this.#t=re,this.#e=J,this.#n=z,this.#r=ue}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(X){if(X+1<=this.#e.length)return;let z=this.#e.length-1;for(;z<X;)z=z*2||16;const te=new Uint32Array(z+1);te.set(this.#e),this.#e=te}#s(X){if(X<=this.#t.length)return;let z=this.#t.length;for(;z<X;)z=z*2||16;const te=new Int32Array(z);te.set(this.#t),this.#t=te}#h(X,z){const te=this.#t,x=this.#e,T=this.#n,K=z.length-(x[X+1]-x[X]),re=new Int32Array(Math.max(1,this.#r+K)),J=new Uint32Array(x.length);let ue=0;for(let oe=0;oe<T;oe++){if(J[oe]=ue,oe===X)for(let Y=0;Y<z.length;Y++)re[ue++]=z[Y]|0;else for(let Y=x[oe];Y<x[oe+1];Y++)re[ue++]=te[Y];J[oe+1]=ue}this.#t=re,this.#e=J,this.#r=ue}}}),Se("packages/core/src/compute/handle.js",function(o,me){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return M}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,X=fe.defaultCompare,z=fe.warnOnce;function te(i){const s=new Uint32Array(i);for(let u=0;u<i;u++)s[u]=u;return s}function x(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 c=null;typeof s.from=="function"?c=s.from([!1,!0]):(c=new s(8),c.set(1));const t=c&&c.words;t&&t.length&&(t[0]===2?f="lsb":t[0]===64&&(f="msb"))}catch{f="unknown"}return T.set(s,f),f}function re(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:re(i.presence)}function ue(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function oe(i,s){return i?typeof i.valueOf=="function"?i.valueOf(s):typeof i.values=="function"?i.values()[s]:null:null}function Y(i,s){const u=i.offsets,f=i.values;if(!u||!f)return[];const c=u[s],t=u[s+1];if(!(t>c))return[];const a=i.dict,m=new Array(t-c);for(let e=c;e<t;e++)m[e-c]=a?oe(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 c=i.dict;return u?t=>u(t)?oe(c,s[t]):null:t=>oe(c,s[t])}if(f==="bitset"){const c=re(s);return u?t=>u(t)?c(t)===1:null:t=>c(t)===1}if(f==="multi")return u?c=>u(c)?Y(i,c):null:c=>Y(i,c);if(!s&&typeof i.get=="function"){const c=i.get.bind(i);return t=>{const a=c(t);return a===void 0?null:a}}return u?c=>{if(!u(c))return null;const t=s[c];return t===void 0?null:t}:c=>{const t=s[c];return t===void 0?null:t}}function Q(i,s){if(i<s)return-1;if(i>s)return 1;if(i===s){const c=Object.is(i,-0),t=Object.is(s,-0);return c===t?0:c?-1:1}const u=Number.isNaN(i),f=Number.isNaN(s);return u&&f?0:u?1:-1}function _(i){const s=he(i);return(u,f)=>{if(u===f)return 0;const c=typeof u,t=typeof f;if(c==="string"&&t==="string")return s.compare(u,f);if(c==="number"&&t==="number")return Q(u,f);if(c==="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 Q(a,m)}return X(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,c=_(s),t=new Array(f);for(let m=0;m<f;m++)t[m]=m;t.sort((m,e)=>c(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 M(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 c}}),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 E}});const fe=me("packages/core/src/compute/handle.js"),he=fe.bitReader,X=fe.dictRanks,z=fe.dictSize,te=fe.identity,x=fe.isMissing,T=fe.presenceReader,K=fe.rowCount,re=fe.valueComparator,J=fe.valueReader,ue=new Uint32Array(0),oe=new ArrayBuffer(8),Y=new Float64Array(oe),L=new Uint32Array(oe),Q=(Y[0]=-1,(L[1]&2147483648)!==0?1:0),_=Q===1?0:1;function C(R,v){Y[0]=R;let U=L[Q],V=L[_];(U&2147483648)!==0?(U=~U>>>0,V=~V>>>0):U=(U^2147483648)>>>0,v[0]=V,v[1]=U}function M(R,v,U,V){if(V<2)return R;const $=new Uint32Array(256*8);for(let A=0;A<V;A++){const q=v[A],le=U[A];$[q&255]++,$[256+(q>>>8&255)]++,$[512+(q>>>16&255)]++,$[768+(q>>>24&255)]++,$[1024+(le&255)]++,$[1280+(le>>>8&255)]++,$[1536+(le>>>16&255)]++,$[1792+(le>>>24&255)]++}let ee=R,ne=v,ce=U,p=new Uint32Array(V),B=new Uint32Array(V),H=new Uint32Array(V);const w=new Uint32Array(256);for(let A=0;A<8;A++){const q=A<<8,le=(A&3)<<3,ae=A>=4;let de=!1;for(let ke=0;ke<256;ke++)if($[q+ke]===V){de=!0;break}if(de)continue;let pe=0;for(let ke=0;ke<256;ke++)w[ke]=pe,pe+=$[q+ke];for(let ke=0;ke<V;ke++){const Le=ne[ke],Re=ce[ke],Be=(ae?Re:Le)>>>le&255,ze=w[Be]++;p[ze]=ee[ke],B[ze]=Le,H[ze]=Re}let ge=ee;ee=p,p=ge,ge=ne,ne=B,B=ge,ge=ce,ce=H,H=ge}return ee}function i(R,v,U){if(U<2)return R;const V=new Uint32Array(256*4);for(let B=0;B<U;B++){const H=v[B];V[H&255]++,V[256+(H>>>8&255)]++,V[512+(H>>>16&255)]++,V[768+(H>>>24&255)]++}let $=R,ee=v,ne=new Uint32Array(U),ce=new Uint32Array(U);const p=new Uint32Array(256);for(let B=0;B<4;B++){const H=B<<8,w=B<<3;let A=!1;for(let ae=0;ae<256;ae++)if(V[H+ae]===U){A=!0;break}if(A)continue;let q=0;for(let ae=0;ae<256;ae++)p[ae]=q,q+=V[H+ae];for(let ae=0;ae<U;ae++){const de=ee[ae],pe=p[de>>>w&255]++;ne[pe]=$[ae],ce[pe]=de}let le=$;$=ne,ne=le,le=ee,ee=ce,ce=le}return $}function s(R,v,U,V){const $=new Uint32Array(V+1);for(let ce=0;ce<U;ce++)$[v[ce]]++;let ee=0;for(let ce=0;ce<=V;ce++){const p=$[ce];$[ce]=ee,ee+=p}const ne=new Uint32Array(U);for(let ce=0;ce<U;ce++)ne[$[v[ce]]++]=R[ce];return ne}function u(R,v,U,V){return U<2?R:V<=65536||V<=U*2?s(R,v,U,V):i(R,v,U)}function f(R,v){return R.length===v&&R.byteOffset===0?R:Uint32Array.prototype.slice.call(R,0,v)}function c(R,v,U=!1){const V=v||te(R.length),$=V.length;if($<2)return Uint32Array.from(V);const ee=new Uint32Array($),ne=new Uint32Array($),ce=new Uint32Array($),p=new Uint32Array($),B=new Uint32Array(2);let H=0,w=0;for(let le=0;le<$;le++){const ae=V[le],de=R[ae];if(Number.isNaN(de)){p[w++]=ae;continue}C(de,B),U?(ne[H]=~B[0]>>>0,ce[H]=~B[1]>>>0):(ne[H]=B[0],ce[H]=B[1]),ee[H++]=ae}const A=M(ee.subarray(0,H),ne.subarray(0,H),ce.subarray(0,H),H);if(w===0)return f(A,H);const q=new Uint32Array($);return q.set(A.subarray(0,H),0),q.set(p.subarray(0,w),H),q}function t(R,v,U=!1){const V=v||te(R.length),$=V.length;if($<2)return Uint32Array.from(V);const ee=Uint32Array.from(V),ne=new Uint32Array($);for(let ce=0;ce<$;ce++){const p=(R[ee[ce]]^2147483648)>>>0;ne[ce]=U?~p>>>0:p}return f(i(ee,ne,$),$)}function a(R,v,U={}){const V=v||te(K(R,U)),$=V.length;if($<2)return Uint32Array.from(V);const ee=X(R.dict,U.locale),ne=R.values,ce=T(R),p=Math.max(z(R.dict),ee.length),B=p,H=Uint32Array.from(V),w=new Uint32Array($),A=!!U.descending;for(let q=0;q<$;q++){const le=H[q];let ae=ce&&ce(le)===0?B:ee[ne[le]];ae===void 0&&(ae=B),w[q]=A?B-ae:ae}return f(u(H,w,$,p+1),$)}function m(R,v,U){const V=v.length;let $=Uint32Array.from(v);if(V<2)return $;let ee=new Uint32Array(V);for(let ne=1;ne<V;ne<<=1){for(let p=0;p<V;p+=ne<<1){const B=Math.min(p+ne,V),H=Math.min(p+(ne<<1),V);let w=p,A=B,q=p;for(;w<B&&A<H;)ee[q++]=U(R[$[w]],R[$[A]])<=0?$[w++]:$[A++];for(;w<B;)ee[q++]=$[w++];for(;A<H;)ee[q++]=$[A++]}const ce=$;$=ee,ee=ce}return $}function e(R,v,U){const V=he(R.values),$=v.length,ee=new Uint32Array($),ne=U?1:0;let ce=0;for(let p=0;p<$;p++)V(v[p])===ne&&(ee[ce++]=v[p]);for(let p=0;p<$;p++)V(v[p])!==ne&&(ee[ce++]=v[p]);return ee}function d(R,v){const U=R.values,V=R.kind;if((V==="object"||V===void 0)&&(Array.isArray(U)||ArrayBuffer.isView(U))&&!R.presence)return U;const ee=J(R),ne=new Array(K(R)||0);for(let ce=0;ce<v.length;ce++){const p=v[ce];ne[p]=ee(p)}return ne}function h(R,v){for(let U=0;U<v.length;U++)if(typeof R[v[U]]!="string")return!1;return!0}function r(R,v,U,V,$){const ee=R.length,ne=Uint32Array.from(R);if(ee<2||V<1)return ne;const ce=new Uint32Array(ee),p=V-1;for(let B=0;B<ee;B++){const H=U[v[B]];ce[B]=$?p-H:H}return f(u(ne,ce,ee,V),ee)}function n(R,v,U){const V=re(U),$=new Array(v);for(let ne=0;ne<v;ne++)$[ne]=ne;$.sort((ne,ce)=>V(R[ne],R[ce])||ne-ce);const ee=new Uint32Array(v);for(let ne=0;ne<v;ne++)ee[$[ne]]=ne;return ee}function l(R,v,U){const V=v.length,$=new Map,ee=[],ne=new Uint32Array(V);for(let B=0;B<V;B++){const H=R[v[B]];let w=$.get(H);w===void 0&&(w=ee.length,$.set(H,w),ee.push(H)),ne[B]=w}const ce=ee.length,p=n(ee,ce,U.locale);return r(v,ne,p,ce,!!U.descending)}function g(R,v,U){const V=d(R,v);if(v.length>=2&&h(V,v)){const ne=R.stringRank;return ne&&ne.version===R.version&&ne.usable(v,V,U.locale)?ne.sort(v,U):l(V,v,U)}const $=re(U.locale),ee=U.descending?(ne,ce)=>$(ce,ne):$;return m(V,v,ee)}function P(R,v,U){const V=d(R,v),$=U.compare,ne=!!U.descending?(ce,p)=>-$(ce,p,void 0,void 0,!0):(ce,p)=>$(ce,p,void 0,void 0,!1);return m(V,v,ne)}function S(R,v){const U=v.length,V=T(R),$=R.values,ee=R.kind==="float64"&&!!$,ne=R.kind==="object"||R.kind==="multi"||R.kind===void 0;if(!V&&!ee&&!ne)return{present:v,absent:ue};const ce=new Uint32Array(U),p=new Uint32Array(U);let B=0,H=0;if(V&&ee)for(let w=0;w<U;w++){const A=v[w];V(A)===1&&!Number.isNaN($[A])?ce[B++]=A:p[H++]=A}else if(ee&&!V)for(let w=0;w<U;w++){const A=v[w];Number.isNaN($[A])?p[H++]=A:ce[B++]=A}else if(V&&!ne)for(let w=0;w<U;w++){const A=v[w];V(A)===1?ce[B++]=A:p[H++]=A}else{const w=J(R);for(let A=0;A<U;A++){const q=v[A];x(w(q))?p[H++]=q:ce[B++]=q}}return H===0?{present:v,absent:ue}:{present:ce.subarray(0,B),absent:p.subarray(0,H)}}function G(R,v,U){if(v.length===0)return R;const V=new Uint32Array(R.length+v.length);return U?(V.set(v,0),V.set(R,v.length)):(V.set(R,0),V.set(v,R.length)),V}function F(R,v,U={}){const V=v||te(K(R,U));if(!R||V.length<2)return Uint32Array.from(V);const{present:$,absent:ee}=S(R,V);if($.length===0)return Uint32Array.from(V);const ne=!!U.descending;let ce;if(typeof U.compare=="function")ce=P(R,$,U);else switch(R.kind){case"float64":ce=c(R.values,$,ne);break;case"int32":ce=t(R.values,$,ne);break;case"dictionary":ce=a(R,$,U);break;case"bitset":ce=e(R,$,ne);break;default:ce=g(R,$,U);break}return G(ce,ee,!!U.nullsFirst)}function E(R,v,U,V={}){const $=v||[],ee=$.length&&($[0].handle||Z(R,$[0].col))||R&&R[0];let ne=U||te(K(ee,V));for(let ce=$.length-1;ce>=0;ce--){const p=$[ce],B=p.handle||Z(R,p.col)||R&&R[ce];B&&(ne=F(B,ne,{descending:p.descending!==void 0?!!p.descending:p.dir==="desc",nullsFirst:!!p.nullsFirst,locale:p.locale!==void 0?p.locale:V.locale,compare:p.compare}))}return ne instanceof Uint32Array?ne:Uint32Array.from(ne)}function Z(R,v){if(!(!R||v===void 0)){for(let U=0;U<R.length;U++)if(R[U]&&R[U].id===v)return R[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 te}});const fe=me("packages/core/src/compute/sort.js"),he=fe.collateStringRanks,X=fe.rankSortStrings,z=1e5;class te{#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 re=0;re<K.length;re++)T+=K[re].length*2+24;return T}#a(T,K){const re=this.#e.get(T);if(re!==void 0)return re;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 re=K|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(re);for(let J=0;J<re;J++){const ue=T[J],oe=typeof ue=="string"?this.#a(ue,!1):-1;this.#n[J]=oe<0?0:oe}this.#r=re}append(T,K,re){const J=(K|0)+(re|0);if(J>this.#n.length){const ue=new Uint32Array(J);ue.set(this.#n.subarray(0,this.#r)),this.#n=ue}for(let ue=K|0;ue<J;ue++){const oe=T[ue],Y=typeof oe=="string"?this.#a(oe,!0):-1;this.#n[ue]=Y<0?0:Y}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 re=he(this.#t,this.#t.length,T);return this.#o=re,this.#c=this.#i,this.#l=K,re}usable(T,K,re){if(this.#u||this.#t.length===0)return!1;const J=this.#n,ue=this.#t,oe=this.#r;for(let Y=0;Y<T.length;Y++){const L=T[Y];if(L>=oe||ue[J[L]]!==K[L])return!1}return!0}sort(T,K){const re=this.ranks(K.locale),J=this.#t.length,ue=T.length,oe=new Uint32Array(ue),Y=this.#n;for(let L=0;L<ue;L++)oe[L]=Y[T[L]];return X(T,oe,re,J,!!K.descending)}}}),Se("packages/core/src/store/columnstore.js",function(o,me){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return Y}}),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,X=fe.isFunction,z=fe.pathGetter,x=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,oe=me("packages/core/src/store/stringrank.js").StringRankIndex,Y=4294967295,L=1024,Q=5e3,_=.2,C=new Set(["float64","int32","bitset","dictionary","object","multi"]);function M(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 M(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 c(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 l=d;l<h;l++)n[l-d]=r[m.values[l]];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=X(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 oe(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,l=this.#m;let g=!1;switch(this.#e){case"float64":{const P=this.#o;for(let S=0;S<h;S++){const G=r(e[S]);if(typeof G=="number"){n&&l.set(d+S),P[d+S]=G;continue}const F=G==null;n?l.assign(d+S,!F):F&&(g=!0),P[d+S]=F?NaN:i(G)}break}case"int32":{const P=this.#o;for(let S=0;S<h;S++){const G=r(e[S]),F=G==null;n?l.assign(d+S,!F):F&&(g=!0),P[d+S]=F?0:s(G)}break}case"bitset":{const P=this.#c;for(let S=0;S<h;S++){const G=r(e[S]),F=G==null;n?l.assign(d+S,!F):F&&(g=!0),P.assign(d+S,!F&&!!G)}break}case"dictionary":{const P=this.#o,S=this.#a;for(let G=0;G<h;G++){const F=r(e[G]),E=F==null;n?l.assign(d+G,!E):E&&(g=!0),P[d+G]=E?0:S.codeOf(F)}break}case"multi":{const P=this.#l,S=this.#a;for(let G=0;G<h;G++){const F=r(e[G]),E=F==null;n?l.assign(d+G,!E):E&&(g=!0);const Z=u(F),R=new Array(Z.length);for(let v=0;v<Z.length;v++)R[v]=S.codeOf(Z[v]);P.write(d+G,R)}break}default:{const P=this.#o;for(let S=0;S<h;S++){const G=r(e[S]),F=G==null;n?l.assign(d+S,!F):F&&(g=!0),P[d+S]=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 l=e.kind===this.#e;if(l&&(this.#e==="float64"||this.#e==="int32")){this.#o.set(e.values,d),this.#f++;return}if(l&&this.#e==="bitset"){const g=e.values;for(let P=0;P<h;P++)this.#c.assign(d+P,(g[P>>3]&1<<(P&7))!==0);this.#f++;return}if(l&&this.#e==="dictionary"){const g=e.table||[],P=new Uint32Array(g.length);for(let E=0;E<g.length;E++)P[E]=this.#a.codeOf(g[E]);const S=e.values,G=this.#o,F=r;for(let E=0;E<h;E++){if(F&&(n&&(n[E>>3]&1<<(E&7))===0)){G[d+E]=0;continue}G[d+E]=P[S[E]]??0}this.#f++;return}if(l&&this.#e==="multi"){const g=e.table||[],P=new Uint32Array(g.length);for(let F=0;F<g.length;F++)P[F]=this.#a.codeOf(g[F]);const S=e.values,G=e.offsets;for(let F=0;F<h;F++){const E=G[F],Z=G[F+1],R=new Array(Z-E);for(let v=E;v<Z;v++)R[v-E]=P[S[v]]??0;this.#l.write(d+F,R)}this.#f++;return}for(let g=0;g<h;g++){const P=n?(n[g>>3]&1<<(g&7))===0:e.kind==="object"?e.values[g]===null:!1;this.#A(d+g,P?null:c(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 l=r!==null&&r.get(n)===0;l&&e!=="multi"||this.#A(n,l?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[l,g]of r)e[l]!==Y&&n.set(e[l],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]!==Y&&(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]!==Y&&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,Y);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<d;n++)e[n]!==Y&&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 x(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 x(d)),this.#p=d}#A(e,d){const h=M(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 l=0;l<r.length;l++)n[l]=this.#a.codeOf(r[l]);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 x(e):null;for(let r=0;r<e;r++){const n=this.#M(r);d[r]=n,h&&!M(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 x(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??Q:0,this.#w=d.compactRatio??_;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 l=0;l<r;l++)this.#r[h+l]=d[l];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 l of e.columns)n.set(l.id,l);for(const l of this.#n){const g=n.get(l.id);g?l.appendPacked(g,h,r):l.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?Y:r++;for(const n of this.#n)n.compact(h,d,r);if(this.#l){const n=this.#r;for(let l=0;l<d;l++)h[l]!==Y&&(n[h[l]]=n[l]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new x(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 ue}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return C}});const fe=me("packages/core/src/internal/util.js"),he=fe.now,X=fe.nextFrame,z=fe.infoOnce,te=fe.warnOnce,x=fe.isFunction,T=fe.pathGetter,re=me("packages/core/src/store/columnstore.js").ColumnStore,J=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function ue(M,i={}){if(i.multi)return"multi";if(M.length===0)return"object";let s=0,u=0,f=0,c=0,t=0;for(let m=0;m<M.length;m++){const e=M[m];typeof e=="number"?s++:typeof e=="boolean"?u++:typeof e=="string"?f++:e instanceof Date?c++:Array.isArray(e)&&t++}const a=M.length;return s===a?"float64":u===a?"bitset":c===a?"float64":f===a?"text":t===a?"multi":"object"}function oe(M,i,s){return i<=0||M<s*i?"dictionary":"object"}function Y(M,i,s){const u=new Map,f=new Map;for(const l of M){if(l.computed)continue;const g=x(l.read)?l.read:T(l.field||l.id);f.set(l.id,g),u.set(l.id,g)}const c=i?.order??[],t=i?.fns??{},a=i?.deps??{},m=i?.wrapDeps??null,e=c.filter(l=>x(t[l])),d=e.some(l=>a[l]==="*");let h=new WeakMap;const r=l=>{const g={};if(d)for(const[P,S]of f)g[P]=S(l);for(const P of e){const S=a[P];let G;if(S==="*")G=g;else{G={};const F=S||[];for(let E=0;E<F.length;E++){const Z=F[E];G[Z]=Z in g?g[Z]:f.get(Z)?.(l)}}g[P]=t[P](m?m(G,P):G,{data:l,row:null,column:null,grid:null,context:s})}return g},n=l=>{if(l===null||typeof l!="object"&&typeof l!="function")return r(l);let g=h.get(l);return g===void 0&&(g=r(l),h.set(l,g)),g};for(const l of e)u.set(l,g=>n(g)[l]);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 Q{#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=Y(f,s.computed??null,s.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(f,s.computed??null),this.#n=new re(this.#e.map(c=>({id:c.spec.id,kind:c.kind,nullable:c.nullable,read:c.read,dictionary:c.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 c=Math.min(this.#i+u,f);this.#n.append(this.#t.slice(this.#i,c)),this.#a(this.#i,c),this.#i=c,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),c=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))){te(`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)??(x(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=ue(d,{multi:a.multi});if(h==="text"){const r=new Set(d).size;e.kind=oe(r,d.length,c),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 c=f.distinct;for(let t=i;t<s;t++){const a=f.read(u[t]);a!=null&&c.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 c=this.#d(f);if(f.kind==="dictionary"&&c>=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=`${c} distinct values is at or above ${s*100}% of ${u} rows`;continue}if(f.kind==="object"&&c>=s*u){f.candidate=!1,f.distinct=null,f.reason=`${c} distinct values is at or above ${s*100}% of ${u} rows`;continue}i&&f.kind==="object"&&c<s*u&&(this.#n.convert(f.spec.id,"dictionary"),f.kind="dictionary",f.change=f.change==="demoted"?null:"promoted",f.reason=`${c} distinct values is below ${s*100}% of ${u} rows`,f.distinct=null),i&&(f.candidate=!1)}}}async function _(M,i={},s={}){const u=new Q(M,i,s),f=s.scheduler?.frame??X;for(;u.slice();)await new Promise(c=>{f(c)});return u.result()}function C(M,i={},s={}){const u=new Q(M,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 Q}});const he=me("packages/core/src/internal/util.js").pathGetter,X=me("packages/core/src/store/ingest.js"),z=X.inferKind,te=X.decideText,x=X.INGEST_DEFAULTS,K=me("packages/core/src/store/columnstore.js").toFloat,re=new Set(["float64","int32","bitset","dictionary","object","multi"]);function J(_){if(!Array.isArray(_)||_.length===0)return!1;for(const C of _)if(!C||typeof C.id!="string"||typeof C.field!="string"||C.field===""||C.kind&&!re.has(C.kind))return!1;return!0}function ue(_){const C=K(_);return Number.isFinite(C)?C|0:0}function oe(_){return _==null?[]:Array.isArray(_)?_:[_]}function Y(_,C,M,i){if(_.kind)return _.kind;const s=[];for(let c=0;c<C.length&&s.length<x.sampleSize;c++){const t=C[c];t!=null&&s.push(t)}const u=z(s,{multi:_.multi});if(u!=="text")return u;const f=new Set(s).size;return te(f,s.length,i)}function L(_,C,M={}){const i=C.length|0,s=M.dictionaryRatio??x.dictionaryRatio,u=[];for(const f of _){const c=he(f.field||f.id),t=f.nullable!==!1,a=new Array(i);for(let r=0;r<i;r++){const n=c(C[r]);a[r]=n===void 0?null:n}const m=Y(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 l=a[n],g=l===null;g||d(n),r[n]=g?NaN:K(l)}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 l=a[n],g=l===null;g||d(n),r[n]=g?0:ue(l)}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 l=a[n],g=l===null;g||d(n),!g&&l&&(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=[],l=new Map;for(let g=0;g<i;g++){const P=a[g];if(P===null){r[g]=0;continue}d(g);let S=l.get(P);S===void 0&&(S=n.length,n.push(P),l.set(P,S)),r[g]=S}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:n};break}case"multi":{const r=[],n=new Map,l=new Uint32Array(i+1),g=[];for(let P=0;P<i;P++){const S=a[P];l[P]=g.length,S===null||d(P);const F=oe(S);for(let E=0;E<F.length;E++){const Z=F[E];let R=n.get(Z);R===void 0&&(R=r.length,r.push(Z),n.set(Z,R)),g.push(R)}}l[i]=g.length,h={id:f.id,kind:m,nullable:t,values:Int32Array.from(g),presence:e,offsets:l,table:r};break}default:{const r=new Array(i);for(let n=0;n<i;n++){const l=a[n];l!==null&&d(n),r[n]=l}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 Q(_){const C=[];if(!_||!Array.isArray(_.columns))return C;const M=i=>{ArrayBuffer.isView(i)&&i.buffer&&!C.includes(i.buffer)&&C.push(i.buffer)};for(const i of _.columns)M(i.values),M(i.presence),M(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 X}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return te}});function fe(x){return{locale:x===void 0?void 0:String(x),numeric:!0,sensitivity:"variant"}}function he(x){return!!x&&typeof x.compare!="function"}function X(x){if(!x)return!0;for(let T=0;T<x.length;T++)if(!he(x[T]))return!1;return!0}function z(x,T){const K=x.col!==void 0?x.col:x.handle&&x.handle.id,re=x.locale!==void 0?x.locale:T;return{col:K,descending:x.descending!==void 0?!!x.descending:x.dir==="desc",nullsFirst:!!x.nullsFirst,collation:fe(re)}}function te(x,T){const K=x||[],re=new Array(K.length);for(let J=0;J<K.length;J++)re[J]=z(K[J],T);return re}}),Se("packages/core/src/format/date.js",function(o,me){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return te}}),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 oe}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return Y}}),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,X=fe.warnOnce,z=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function te(M){const i=[];let s=0,u="";const f=()=>{u&&(i.push({token:null,text:u}),u="")};for(;s<M.length;){const c=M[s];if(c==="\'"){if(M[s+1]==="\'"){u+="\'",s+=2;continue}const a=M.indexOf("\'",s+1);if(a===-1){u+=M.slice(s+1),s=M.length;continue}u+=M.slice(s+1,a),s=a+1;continue}const t=z.find(a=>M.startsWith(a,s));if(t){f(),i.push({token:t,text:t}),s+=t.length;continue}/[A-Za-z]/.test(c)&&X(`date.pattern.token:${c}`,`the date pattern "${M}" contains \'${c}\', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${z.join(" ")}.`),u+=c,s+=1}return f(),i}const x=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function T(M){if(he(M)||M==="")return null;if(M instanceof Date)return Number.isNaN(M.getTime())?null:M;if(typeof M=="number")return Number.isNaN(M)?null:new Date(M);if(typeof M=="string"){const i=x.exec(M.trim());if(i){const[,u,f,c,t="0",a="0",m="0"]=i;return new Date(+u,+f-1,+c,+t,+a,+m)}const s=new Date(M);return Number.isNaN(s.getTime())?null:s}return null}function K(M,i){return String(M).padStart(i,"0")}function re(M){if(!M)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:M,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 c of i.formatToParts(u))switch(c.type){case"year":f.year=Number(c.value);break;case"month":f.month=Number(c.value);break;case"day":f.day=Number(c.value);break;case"hour":f.hour=Number(c.value)%24;break;case"minute":f.minute=Number(c.value);break;case"second":f.second=Number(c.value);break;case"weekday":f.weekday=s[c.value]??0;break;default:break}return f}}function J(M,i,s){const u=te(M),f=re(s),c=new Set(u.filter(d=>d.token).map(d=>d.token)),t=c.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:s}):null,a=c.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:s}):null,m=c.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:s}):null,e=c.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 ue=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function oe(M,i){const s=M||{},u=s.locale||i||void 0,f=s.nullDisplay??"",c=s.timeZone;let t;if(s.pattern)t=J(s.pattern,u,c);else if(s.dateStyle||s.timeStyle){const h={timeZone:c};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:c});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 l=r&&typeof r.now=="number"?r.now:Date.now(),g=n.getTime()-l;if(Math.abs(g)<e){for(const[P,S]of ue)if(Math.abs(g)>=S||P==="second")return a.format(Math.round(g/S),P)}}return t(n)};return d.spec=s,d}function Y(M){if(he(M)||M==="")return null;if(typeof M=="string"){const u=/^(\\d{4}-\\d{2}-\\d{2})/.exec(M.trim());if(u)return u[1];const f=T(M);return f?Y(f):null}const i=T(M);if(!i)return null;const s=u=>String(u).padStart(2,"0");return`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}`}function L(M,i){if(he(M)||M==="")return null;if(typeof M=="string"){const u=M.trim();if(Q.test(u)){const t=T(u);return t?_(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 c=T(u);return c?L(c):null}const s=T(M);return s?_(s,i):null}const Q=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function _(M,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(M).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=`${M.getFullYear()}-${s(M.getMonth()+1)}-${s(M.getDate())}`,f=M.getSeconds(),c=`${s(M.getHours())}:${s(M.getMinutes())}${f?`:${s(f)}`:""}`;return`${u}T${c}`}function C(M,i){const s=he(M)||M===""?null:String(M),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 Z}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"declareOperators",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"declaredOperator",{enumerable:!0,get:function(){return ce}});const fe=me("packages/core/src/internal/util.js"),he=fe.isBlank,X=fe.toArray,z=fe.warnOnce,x=me("packages/core/src/format/date.js").toIsoDate,T=me("packages/core/src/compute/handle.js"),K=T.bitReader,re=T.dictSize,J=T.dictValue,ue=T.presenceReader,oe=T.valueComparator,Y=T.valueReader,L=/^\\d{4}-\\d{2}-\\d{2}$/,Q="\\0null\\0";function _(p,B){const H=p&&p.pool;if(H){const w=H.mask||H.acquireMask||H.acquire||H.take;if(typeof w=="function"){const A=w.call(H,B);if(A&&A.length>=B)return A}}return new Uint8Array(B)}function C(p,B){const H=p&&p.pool;if(!H||!B)return;const w=H.release||H.releaseMask||H.free||H.recycle;typeof w=="function"&&w.call(H,B)}function M(p,B,H){return p.fill(H,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 H=x(p);return H===null?u(p):H}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 c(p,B){const H=typeof p=="string"?p:String(p);return B?H:H.toLowerCase()}function t(p,B){return p==null?Q:typeof p=="string"?B?p:p.toLowerCase():p instanceof Date?p.getTime():p}function a(p,B,H){const w=new Set;for(const A of X(p)){const q=s(A,H);w.add(t(q,B)),typeof q=="string"&&q!==""&&Number.isFinite(Number(q))?w.add(Number(q)):typeof q=="number"&&Number.isFinite(q)&&w.add(t(String(q),B))}return w}function m(p,B,H){if(p==null||B===null||B===void 0)return p==null&&B==null;const w=typeof p,A=typeof B;return w==="string"&&A==="string"?H?p===B:p.toLowerCase()===B.toLowerCase():p instanceof Date||B instanceof Date?u(p)===u(B):w==="number"&&A==="number"?p===B||Number.isNaN(p)&&Number.isNaN(B):w==="number"&&A==="string"?p===Number(B):w==="string"&&A==="number"?Number(p)===B:w==="boolean"||A==="boolean"?p===B:Array.isArray(p)&&Array.isArray(B)?p.length===B.length&&p.every((q,le)=>m(q,B[le],H)):p===B}function e(p,B){try{if(p instanceof RegExp){const H=p.flags.replace(/[gy]/g,"");return new RegExp(p.source,B||H.includes("i")?H:`${H}i`)}return new RegExp(String(p),B?"":"i")}catch(H){return z(`regex:${String(p)}`,`filter operator "matches" received an invalid pattern: ${String(p)}`,H),null}}function d(p,B){const H=h(p,B),w=p&&p.type;return w!=="date"&&w!=="dateString"?H:A=>H(typeof A=="string"&&L.test(A)?A:x(A)??A)}function h(p,B){const H=p&&p.op,w=!!(p&&p.caseSensitive),A=p&&p.type,q=oe(B),le=ae=>de=>!ae(de);switch(H){case"eq":{const ae=s(p.value,A);return de=>m(de,ae,w)}case"ne":{const ae=s(p.value,A);return de=>!m(de,ae,w)}case"lt":case"lte":case"gt":case"gte":{const ae=s(p.value,A);if(i(ae))return()=>!1;const de=H==="lt"?-1:H==="lte"?0:H==="gt"?1:2;return pe=>{if(i(pe))return!1;const ge=q(pe,ae);return de===-1?ge<0:de===0?ge<=0:de===1?ge>0:ge>=0}}case"between":case"notBetween":{const ae=X(p.value),de=s(ae[0],A),pe=s(ae[1],A),ge=p.bounds||"[]",ke=ge.charAt(0)!=="(",Le=ge.charAt(1)!==")";if(i(de)||i(pe))return H==="between"?()=>!1:()=>!0;const Re=Be=>{if(i(Be))return!1;const ze=q(Be,de),Ke=q(Be,pe);return(ke?ze>=0:ze>0)&&(Le?Ke<=0:Ke<0)};return H==="between"?Re:le(Re)}case"in":case"notIn":{const ae=a(p.value,w,A),de=pe=>ae.has(t(pe,w));return H==="in"?de:le(de)}case"contains":case"notContains":{const ae=c(s(p.value,A),w),de=pe=>pe==null?!1:c(pe,w).includes(ae);return H==="contains"?de:le(de)}case"startsWith":{const ae=c(s(p.value,A),w);return de=>de==null?!1:c(de,w).startsWith(ae)}case"endsWith":{const ae=c(s(p.value,A),w);return de=>de==null?!1:c(de,w).endsWith(ae)}case"matches":{const ae=e(p.value,w);return ae?de=>de==null?!1:ae.test(String(de)):()=>!1}case"blank":return ae=>he(ae)||Array.isArray(ae)&&ae.length===0;case"notBlank":return ae=>!(he(ae)||Array.isArray(ae)&&ae.length===0);case"containsAny":case"containsNone":{const ae=a(p.value,w,A),de=pe=>{const ge=pe==null?[]:X(pe);for(let ke=0;ke<ge.length;ke++)if(ae.has(t(ge[ke],w)))return!0;return!1};return H==="containsAny"?de:le(de)}case"containsAll":{const ae=X(p.value).map(de=>t(s(de,A),w));return de=>{const pe=de==null?[]:X(de);if(ae.length===0)return!0;const ge=new Set(pe.map(ke=>t(ke,w)));for(let ke=0;ke<ae.length;ke++)if(!ge.has(ae[ke]))return!1;return!0}}default:{const ae=ce(H);return ae?ae.compile(p.value):(z(`op:${String(H)}`,`unknown filter operator "${String(H)}"; the condition is refused rather than matching every row`),()=>!1)}}}function r(p,B,H){return d(B,H)(p)}const n=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),l=new Set(["containsAny","containsAll","containsNone"]);function g(p,B,H){const w=p&&p.op,A=n[w]||w,q=d({...p,op:A,type:B.type},H),le=B.items,ae=de=>{const pe=le(de);if(!pe)return!1;for(let ge=0;ge<pe.length;ge++)if(q(pe[ge]))return!0;return!1};return n[w]?de=>!ae(de):ae}function P(p,B,H,w){const A=ue(p);if(A){const ae=B?1:0;for(let de=0;de<w;de++)H[de]=A(de)===ae?1:0;return H}const q=p.kind;if(q==="float64"||q==="int32"||q==="bitset")return M(H,w,B?1:0);const le=Y(p);for(let ae=0;ae<w;ae++){const de=le(ae),pe=he(de)||Array.isArray(de)&&de.length===0;H[ae]=pe===B?0:1}return H}function S(p,B,H,w){const A=p.dict,q=re(A),le=new Uint8Array(q);for(let ge=0;ge<q;ge++)le[ge]=B(J(A,ge))?1:0;const ae=p.values,de=ue(p);if(!de){for(let ge=0;ge<w;ge++)H[ge]=le[ae[ge]];return H}const pe=B(null)?1:0;for(let ge=0;ge<w;ge++)H[ge]=de(ge)===1?le[ae[ge]]:pe;return H}function G(p,B,H,w){const A=K(p.values),q=B(!0)?1:0,le=B(!1)?1:0,ae=ue(p);if(!ae){for(let pe=0;pe<w;pe++)H[pe]=A(pe)===1?q:le;return H}const de=B(null)?1:0;for(let pe=0;pe<w;pe++)H[pe]=ae(pe)===0?de:A(pe)===1?q:le;return H}function F(p,B,H,w,A){const q=p.values,le=B.type,ae=B.op;let de=!0;switch(ae){case"eq":case"ne":{const ge=f(s(B.value,le)),ke=typeof B.value=="number"&&Number.isNaN(B.value),Le=ae==="ne"?1:0;if(ke)for(let Re=0;Re<A;Re++)w[Re]=(Number.isNaN(q[Re])?1:0)^Le;else for(let Re=0;Re<A;Re++)w[Re]=(q[Re]===ge?1:0)^Le;break}case"lt":{const ge=f(s(B.value,le));for(let ke=0;ke<A;ke++)w[ke]=q[ke]<ge?1:0;break}case"lte":{const ge=f(s(B.value,le));for(let ke=0;ke<A;ke++)w[ke]=q[ke]<=ge?1:0;break}case"gt":{const ge=f(s(B.value,le));for(let ke=0;ke<A;ke++)w[ke]=q[ke]>ge?1:0;break}case"gte":{const ge=f(s(B.value,le));for(let ke=0;ke<A;ke++)w[ke]=q[ke]>=ge?1:0;break}case"between":case"notBetween":{const ge=X(B.value),ke=f(s(ge[0],le)),Le=f(s(ge[1],le)),Re=B.bounds||"[]",Be=Re.charAt(0)!=="(",ze=Re.charAt(1)!==")",Ke=ae==="notBetween"?1:0;if(Be&&ze)for(let Te=0;Te<A;Te++)w[Te]=(q[Te]>=ke&q[Te]<=Le?1:0)^Ke;else if(Be)for(let Te=0;Te<A;Te++)w[Te]=(q[Te]>=ke&q[Te]<Le?1:0)^Ke;else if(ze)for(let Te=0;Te<A;Te++)w[Te]=(q[Te]>ke&q[Te]<=Le?1:0)^Ke;else for(let Te=0;Te<A;Te++)w[Te]=(q[Te]>ke&q[Te]<Le?1:0)^Ke;break}case"in":case"notIn":{const ge=new Set;for(const Le of X(B.value)){const Re=f(s(Le,le));Number.isNaN(Re)||ge.add(Re)}const ke=ae==="notIn"?1:0;for(let Le=0;Le<A;Le++)w[Le]=(ge.has(q[Le])?1:0)^ke;break}default:de=!1;break}if(!de)return!1;const pe=ue(p);if(pe){const ge=H(null)?1:0;for(let ke=0;ke<A;ke++)pe(ke)===0&&(w[ke]=ge)}return!0}function E(p,B,H,w){const A=Y(p);for(let q=0;q<w;q++)H[q]=B(A(q))?1:0;return H}function Z(p,B,H){const w=B.count|0,A=H||_(B,w);if(!p)return M(A,w,1);const q=typeof B.handle=="function"?B.handle(p.col):void 0,le=typeof B.custom=="function"?B.custom:null;if(!q){if(le){for(let ge=0;ge<w;ge++)A[ge]=le(p,ge)?1:0;return A}return z(`filter:col:${String(p.col)}`,`filter references unknown column "${String(p.col)}"; the condition is refused rather than matching every row`),M(A,w,0)}const ae=p.op;if(ae==="blank"||ae==="notBlank")return P(q,ae==="notBlank",A,w);const de=typeof B.itemwise=="function"?B.itemwise(p.col):null;if(de&&!ce(ae)&&!l.has(ae))return E(q,g(p,de,B.locale),A,w);const pe=d(p,B.locale);switch(q.kind){case"dictionary":return S(q,pe,A,w);case"bitset":return G(q,pe,A,w);case"float64":case"int32":return F(q,p,pe,A,w)?A:E(q,pe,A,w);default:return E(q,pe,A,w)}}function R(p,B,H){if(!p)return M(_(B,H),H,1);if(Array.isArray(p.conditions)){const w=p.conditions.filter(le=>le!=null),A=p.op==="or"?"or":p.op==="not"?"not":"and";if(w.length===0)return M(_(B,H),H,1);const q=R(w[0],B,H);for(let le=1;le<w.length;le++){const ae=R(w[le],B,H);if(A==="or")for(let de=0;de<H;de++)q[de]|=ae[de];else for(let de=0;de<H;de++)q[de]&=ae[de];C(B,ae)}if(A==="not")for(let le=0;le<H;le++)q[le]^=1;return q}return Z(p,B,_(B,H))}function v(p,B){return R(p,B,B.count|0)}function U(p,B){if(!p||!B)return p||null;const H=p;if(Array.isArray(H.conditions)){if((H.op==="or"?"or":H.op==="not"?"not":"and")!=="and")return V(H,B)?null:p;const A=[];for(const q of H.conditions){const le=U(q,B);le&&A.push(le)}return A.length?{...H,op:"and",conditions:A}:null}return H.col===B?null:p}function V(p,B){if(!p||typeof p!="object")return!1;const H=p;if(H.col===B)return!0;if(Array.isArray(H.conditions)){for(const w of H.conditions)if(V(w,B))return!0}return!1}function $(p,B,H){if(H&&H.length>=B){let le=0;for(let ae=0;ae<B;ae++)p[ae]&&(H[le++]=ae);return H.subarray(0,le)}let w=0;for(let le=0;le<B;le++)w+=p[le]?1:0;const A=new Uint32Array(w);let q=0;for(let le=0;le<B;le++)p[le]&&(A[q++]=le);return A}const ee=new Map;function ne(p){if(!(!p||typeof p!="object"))for(const[B,H]of Object.entries(p))H&&typeof H.compile=="function"&&ee.set(B,H)}function ce(p){return typeof p=="string"?ee.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 oe}});const fe=me("packages/core/src/compute/handle.js"),he=fe.dictSize,X=fe.identity,z=fe.presenceReader,te=fe.rowCount,x=fe.valueReader,T="",K="\\0",re=1<<20;function J(Y,L,Q,_){const C=Y.length,M=Y.map(t=>x(t)),i=Array.isArray(_)&&_.some(Boolean),s=i?M.map((t,a)=>_[a]?m=>_[a](t(m)):t):M;if(!i&&C>0&&Y.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=Y.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=Y.map(r=>r.values),e=Y.map(r=>z(r)),d=r=>{let n=0;for(let l=0;l<C;l++){const g=e[l],P=g&&g(r)===0?t[l]-1:m[l][r];n=n*t[l]+P}return n},h=new Float64Array(Q);for(let r=0;r<Q;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},c=new Array(Q);for(let t=0;t<Q;t++)c[t]=f(L[t]);return{packed:null,strings:c,product:1/0,readers:s,keyOf:f}}function ue(Y,L,Q,_){const C=new Uint32Array(_+1);for(let u=0;u<Q;u++)C[L[u]+1]++;for(let u=0;u<_;u++)C[u+1]+=C[u];const M=new Uint32Array(Q),i=C.slice(0,_);for(let u=0;u<Q;u++)M[i[L[u]]++]=Y[u];const s=new Array(_);for(let u=0;u<_;u++)s[u]=M.subarray(C[u],C[u+1]);return s}function oe(Y,L,Q={}){const _=Y||[],C=L||X(te(_[0],Q)),M=C.length;if(_.length===0||M===0)return{keys:[],buckets:[]};const{packed:i,strings:s,product:u,readers:f}=J(_,C,M,Q.project),c=new Uint32Array(M);let t=0,a=null;if(i&&u<=Math.max(1024,Math.min(re,M*4))){const h=u,r=new Int32Array(h).fill(-1);for(let n=0;n<M;n++)r[i[n]]=0;for(let n=0;n<h;n++)r[n]===0&&(r[n]=t++);for(let n=0;n<M;n++)c[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<M;r++){const n=i[r];let l=h.get(n);l===void 0&&(l=t++,h.set(n,l)),c[r]=l}a=new Float64Array(t);for(const[r,n]of h)a[n]=r}else{const h=new Map;for(let r=0;r<M;r++){const n=s[r];let l=h.get(n);l===void 0&&(l=t++,h.set(n,l)),c[r]=l}}const m=ue(C,c,M,t),e=new Array(t);for(let h=0;h<t;h++){const r=m[h][0],n=new Array(f.length);for(let l=0;l<f.length;l++)n[l]=f[l](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 x}}),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 re}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return Y}}),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 M}}),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,X=fe.valueReader,z=fe.dictSize,te=fe.dictValue,x=Object.freeze(["equal","quantile","log"]),T=Object.freeze(["hour","day","week","month","quarter","year"]),K=20,re=50,J=1e4;function ue(n,l){if(!n)return"none";const g=l;if(g&&(g.multi===!0||typeof g.items=="function"))return"category";const P=l&&l.base;if(P==="date"||P==="datetime"||P==="time"||P==="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 P==="number"?"numeric":P==="boolean"?"boolean":P==="text"?"category":"none"}}function oe(n){const l=n.values,g=n.kind;if((g==="float64"||g==="int32")&&l)return S=>l[S];const P=X(n);return S=>Y(P(S))}function Y(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 l=Number(n);if(Number.isFinite(l))return l;const g=Date.parse(n);return Number.isFinite(g)?g:NaN}return NaN}function L(n,l,g,P=re){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 S=X(n),G=l?l.length:g,F=new Set;for(let E=0;E<G;E++){const Z=S(l?l[E]:E);if(Z!=null&&(F.add(Z),F.size>P))return{cardinality:F.size,exact:!1}}return{cardinality:F.size,exact:!0}}const Q=36e5,_=864e5;function C(n,l=K){const g=Number.isFinite(n)&&n>0?n:0,P=Math.max(1,l)*2;return g/Q<=P?"hour":g/_<=P?"day":g/(7*_)<=P?"week":g/(30*_)<=P?"month":g/(91*_)<=P?"quarter":"year"}function M(n,l){if(!Number.isFinite(n))return NaN;const g=new Date(n);switch(l){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 P=(g.getDay()+6)%7;return g.setDate(g.getDate()-P),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,l){const g=new Date(n);switch(l){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,l,g){const P=oe(n),S=he(n),G=l?l.length:g;let F=1/0,E=-1/0,Z=0,R=0;for(let v=0;v<G;v++){const U=l?l[v]:v;if(S&&!S(U)){Z++;continue}const V=P(U);if(!Number.isFinite(V)){Z++;continue}V<F&&(F=V),V>E&&(E=V),R++}return{min:F,max:E,nulls:Z,finite:R}}function u(n,l,g,P){const S=oe(n),G=he(n),F=l?l.length:g,E=F>P?F/P:1,Z=[];for(let v=0;v<F;v+=E){const U=l?l[Math.floor(v)]:Math.floor(v);if(G&&!G(U))continue;const V=S(U);Number.isFinite(V)&&Z.push(V)}const R=Float64Array.from(Z);return R.sort(),R}function f(n,l,g,P={}){const S=P.kind||ue(n,P.type);return S==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:S==="boolean"?c(n,l,g):S==="category"?t(n,l,g,P):a(n,l,g,S,P)}function c(n,l,g){const P=he(n);let S=0;if(P){const F=l?l.length:g;for(let E=0;E<F;E++)P(l?l[E]:E)||S++}const G=[{value:!1,label:"false"},{value:!0,label:"true"}];return S>0&&G.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:G}}function t(n,l,g,P){const S=P.cardinalityLimit??re,{cardinality:G}=L(n,l,g,S);if(G>S&&(P.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:G};const F=X(n),E=l?l.length:g,Z=new Map;let R=0;for(let ee=0;ee<E;ee++){const ne=F(l?l[ee]:ee);if(ne==null||ne===""){R++;continue}if(Array.isArray(ne)){if(!ne.length){R++;continue}for(const ce of ne)Z.set(ce,(Z.get(ce)||0)+1);continue}Z.set(ne,(Z.get(ne)||0)+1)}let v=[...Z.entries()];P.order==="alpha"?v.sort((ee,ne)=>String(ee[0]).localeCompare(String(ne[0]))):v.sort((ee,ne)=>ne[1]-ee[1]);let U=0,V=0;if(v.length>S){V=v.length-S;for(let ee=S;ee<v.length;ee++)U+=v[ee][1];v=v.slice(0,S)}const $=v.map(([ee])=>({value:ee,label:String(ee)}));return U>0&&$.push({remainder:!0,label:`Other (${V} values)`}),R>0&&$.push({null:!0,label:"Empty"}),{kind:"category",buckets:$,cardinality:G}}function a(n,l,g,P,S){const{min:G,max:F,nulls:E,finite:Z}=s(n,l,g);if(!Z)return{kind:P,buckets:E?[{null:!0,label:"Empty"}]:[],empty:!0};const R=Math.max(1,Math.floor(S.buckets||K));let v=[];if(P==="date"){const V=T.includes(S.granularity)?S.granularity:C(F-G,R);let $=M(G,V);for(;$<=F&&v.length<4096;){const ee=i($,V);if(!(ee>$))break;v.push({from:$,to:ee}),$=ee}return{kind:P,buckets:m(v,E),granularity:V}}const U=x.includes(S.strategy)?S.strategy:"equal";if(U==="quantile"){const V=u(n,l,g,J);if(V.length){const $=[V[0]];for(let ee=1;ee<R;ee++){const ne=V[Math.min(V.length-1,Math.floor(ee/R*V.length))];ne>$[$.length-1]&&$.push(ne)}$.push(F);for(let ee=0;ee<$.length-1;ee++)v.push({from:$[ee],to:$[ee+1]})}}else if(U==="log"&&G>0){const V=Math.log10(G),ee=(Math.log10(F)-V)/R||1;for(let ne=0;ne<R;ne++)v.push({from:10**(V+ne*ee),to:10**(V+(ne+1)*ee)})}if(!v.length){const V=(F-G)/R||1;for(let $=0;$<R;$++)v.push({from:G+$*V,to:G+($+1)*V})}return v[v.length-1].to=F,{kind:P,buckets:m(v,E),strategy:U,min:G,max:F}}function m(n,l){return l>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,l,g,P,S){const G=P&&P.buckets||[],F=S&&S.length>=G.length?S.subarray(0,G.length):new Uint32Array(G.length);if(F.fill(0),!n||!G.length)return F;const E=G.length-1,Z=!!G[E]&&G[E].null===!0,R=l?l.length:g;if(P.kind==="boolean"){const ee=X(n);for(let ne=0;ne<R;ne++){const ce=ee(l?l[ne]:ne);if(ce==null){Z&&F[E]++;continue}F[ce?1:0]++}return F}if(P.kind==="category"){const ee=new Map;for(let p=0;p<G.length;p++)!G[p].null&&!G[p].remainder&&ee.set(G[p].value,p);const ne=G.findIndex(p=>p.remainder),ce=X(n);for(let p=0;p<R;p++){const B=ce(l?l[p]:p);if(B==null||B===""){Z&&F[E]++;continue}if(Array.isArray(B)){if(!B.length){Z&&F[E]++;continue}for(const w of B){const A=ee.get(w);A!==void 0?F[A]++:ne>=0&&F[ne]++}continue}const H=ee.get(B);H!==void 0?F[H]++:ne>=0&&F[ne]++}return F}const v=Z?G.length-1:G.length,U=new Float64Array(v+1);for(let ee=0;ee<v;ee++)U[ee]=G[ee].from;U[v]=v?G[v-1].to:0;const V=oe(n),$=he(n);for(let ee=0;ee<R;ee++){const ne=l?l[ee]:ee;if($&&!$(ne)){Z&&F[E]++;continue}const ce=V(ne);if(!Number.isFinite(ce)){Z&&F[E]++;continue}const p=d(U,v,ce);p>=0&&F[p]++}return F}function d(n,l,g){if(!l||g<n[0])return-1;if(g>=n[l])return g===n[l]?l-1:-1;let P=0,S=l-1;for(;P<S;){const G=P+S+1>>>1;g>=n[G]?P=G:S=G-1}return P}function h(n,l,g,P={}){const S=P.bounds||f(n,P.boundsIndices??l,g,P);return{bounds:S,counts:e(n,l,g,S)}}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 x}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return _}});const fe=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),he=3e-12,X=1e-300;function z(C){if(C<.5)return Math.log(Math.PI/Math.sin(Math.PI*C))-z(1-C);const M=C-1;let i=.9999999999998099;const s=M+7.5;for(let u=0;u<fe.length;u++)i+=fe[u]/(M+u+1);return .5*Math.log(2*Math.PI)+(M+.5)*Math.log(s)-s+Math.log(i)}function te(C,M,i){const s=C+M,u=C+1,f=C-1;let c=1,t=1-s*i/u;Math.abs(t)<X&&(t=X),t=1/t;let a=t;for(let m=1;m<=300;m++){const e=2*m;let d=m*(M-m)*i/((f+e)*(C+e));t=1+d*t,Math.abs(t)<X&&(t=X),c=1+d/c,Math.abs(c)<X&&(c=X),t=1/t,a*=t*c,d=-(C+m)*(s+m)*i/((C+e)*(u+e)),t=1+d*t,Math.abs(t)<X&&(t=X),c=1+d/c,Math.abs(c)<X&&(c=X),t=1/t;const h=t*c;if(a*=h,Math.abs(h-1)<he)break}return a}function x(C,M,i){if(!(C>0)||!(M>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const s=Math.exp(z(C+M)-z(C)-z(M)+C*Math.log(i)+M*Math.log(1-i));return i<(C+1)/(C+M+2)?s*te(C,M,i)/C:1-s*te(M,C,1-i)/M}function T(C){if(!(C>0)||!(C<1))return C===0?-1/0:C===1?1/0:Number.NaN;const M=[-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 c,t,a;C<f?(c=Math.sqrt(-2*Math.log(C)),a=(((((s[0]*c+s[1])*c+s[2])*c+s[3])*c+s[4])*c+s[5])/((((u[0]*c+u[1])*c+u[2])*c+u[3])*c+1)):C<=1-f?(c=C-.5,t=c*c,a=(((((M[0]*t+M[1])*t+M[2])*t+M[3])*t+M[4])*t+M[5])*c/(((((i[0]*t+i[1])*t+i[2])*t+i[3])*t+i[4])*t+1)):(c=Math.sqrt(-2*Math.log(1-C)),a=-(((((s[0]*c+s[1])*c+s[2])*c+s[3])*c+s[4])*c+s[5])/((((u[0]*c+u[1])*c+u[2])*c+u[3])*c+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 M=Math.abs(C),i=2/(2+M),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,c=0,t;for(let m=u.length-1;m>0;m--)t=c,c=s*c-f+u[m],f=t;const a=i*Math.exp(-M*M+.5*(u[0]+s*c)-f);return C>=0?a:2-a}function re(C){return .5*K(-C/Math.SQRT2)}function J(C,M){if(!(M>0)||!Number.isFinite(C))return Number.NaN;const i=.5*x(M/2,.5,M/(M+C*C));return C>0?1-i:i}function ue(C,M){if(!(C>0)||!(C<1)||!(M>0))return Number.NaN;if(M>1e7)return T(C);let i=-1e4,s=1e4,u=T(C);const f=z(M/2)+z(.5)-z((M+1)/2);for(let c=0;c<60;c++){const t=J(u,M);t<C?i=u:s=u;const a=Math.exp(-((M+1)/2)*Math.log(1+u*u/M)-f)/Math.sqrt(M),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 oe(C,M){let i=C,s=1/C,u=s;for(let f=0;f<300&&(i+=1,u*=M/i,s+=u,!(Math.abs(u)<Math.abs(s)*he));f++);return s*Math.exp(-M+C*Math.log(M)-z(C))}function Y(C,M){let i=M+1-C,s=1/X,u=1/i,f=u;for(let c=1;c<=300;c++){const t=-c*(c-C);i+=2,u=t*u+i,Math.abs(u)<X&&(u=X),s=i+t/s,Math.abs(s)<X&&(s=X),u=1/u;const a=u*s;if(f*=a,Math.abs(a-1)<he)break}return Math.exp(-M+C*Math.log(M)-z(C))*f}function L(C,M){return!(C>0)||!(M>=0)||!Number.isFinite(M)?Number.NaN:M===0?0:M<C+1?oe(C,M):1-Y(C,M)}function Q(C,M){return M>0?L(M/2,C/2):Number.NaN}function _(C,M){const i=Q(C,M);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 X}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return x}});function fe(T){const K=T.length,re=Array.from({length:K},()=>new Array(K).fill(0));for(let J=0;J<K;J++)for(let ue=0;ue<=J;ue++){let oe=T[J][ue];for(let Y=0;Y<ue;Y++)oe-=re[J][Y]*re[ue][Y];if(J===ue){if(!(oe>0))return null;re[J][ue]=Math.sqrt(oe)}else re[J][ue]=oe/re[ue][ue]}return re}function he(T,K){const re=T.length,J=new Array(re).fill(0);for(let oe=0;oe<re;oe++){let Y=K[oe];for(let L=0;L<oe;L++)Y-=T[oe][L]*J[L];J[oe]=Y/T[oe][oe]}const ue=new Array(re).fill(0);for(let oe=re-1;oe>=0;oe--){let Y=J[oe];for(let L=oe+1;L<re;L++)Y-=T[L][oe]*ue[L];ue[oe]=Y/T[oe][oe]}return ue}function X(T){const K=T.length,re=Array.from({length:K},()=>new Array(K).fill(0));for(let J=0;J<K;J++){const ue=new Array(K).fill(0);ue[J]=1;const oe=he(T,ue);for(let Y=0;Y<K;Y++)re[Y][J]=oe[Y]}return re}function z(T,K,re){const J=T.length,ue=J?T[0].length:0,oe=Array.from({length:ue},()=>new Array(ue).fill(0)),Y=new Array(ue).fill(0);for(let L=0;L<J;L++){const Q=re?re[L]:1,_=T[L];for(let C=0;C<ue;C++){const M=Q*_[C];Y[C]+=M*K[L];for(let i=C;i<ue;i++)oe[C][i]+=M*_[i]}}for(let L=0;L<ue;L++)for(let Q=0;Q<L;Q++)oe[L][Q]=oe[Q][L];return{xtwx:oe,xtwy:Y}}function te(T,K){return T.map(re=>re.reduce((J,ue,oe)=>J+ue*K[oe],0))}function x(T,K){let re=0;for(let J=0;J<T.length;J++){let ue=0;for(let oe=0;oe<T.length;oe++)ue+=K[J][oe]*T[oe];re+=T[J]*ue}return re}}),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 te}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return oe}});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 Q=L-this.#e;this.#e+=Q/this.#t,this.#n+=Q*(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 Q=this.#t+L.#t,_=L.#e-this.#e;this.#e+=_*(L.#t/Q),this.#n+=L.#n+_*_*(this.#t*L.#t/Q),this.#t=Q}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,Q=Math.random){if(!(L>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(L),this.#r=Q}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 Q=Math.floor(this.#r()*this.#e);Q<this.#n&&(this.#t[Q]=L)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let L=0;for(const Q of this.#t)L+=Q;return L/this.#t.length}quantile(L){const Q=this.#t.length;if(!Q)return null;const _=this.#t.slice().sort((s,u)=>s-u);if(Q===1)return _[0];const C=(Q-1)*Math.min(1,Math.max(0,L)),M=Math.floor(C),i=Math.ceil(C);return M===i?_[M]:_[M]+(C-M)*(_[i]-_[M])}}function X(Y){return Y^=Y>>>16,Y=Math.imul(Y,2246822507),Y^=Y>>>13,Y=Math.imul(Y,3266489909),Y^=Y>>>15,Y>>>0}function z(Y){if(typeof Y=="number"){const _=new DataView(new ArrayBuffer(8));return _.setFloat64(0,Y===0?0:Y),X(_.getUint32(0)^_.getUint32(4))}const L=typeof Y=="string"?Y:String(Y);let Q=2166136261;for(let _=0;_<L.length;_++)Q^=L.charCodeAt(_),Q=Math.imul(Q,16777619);return X(Q)}class te{#t;#e;#n;constructor(L=14){const Q=Math.floor(L);if(Q<4||Q>16)throw new RangeError("HLL precision must be 4..16");this.#t=Q,this.#e=1<<Q,this.#n=new Uint8Array(this.#e)}static errorBoundFor(L=14){const Q=1<<Math.floor(L),_=1.04/Math.sqrt(Q);return Object.freeze({kind:"probabilistic",metric:"relative",value:_,statement:`distinct count within ~${(_*100).toFixed(2)}% relative standard error (m=${Q} buckets)`})}errorBound(){return te.errorBoundFor(this.#t)}add(L){const Q=z(L),_=Q&this.#e-1,C=Q>>>this.#t|1<<32-this.#t;let M=1,i=C;for(;(i&1)===0;)M++,i>>>=1;M>this.#n[_]&&(this.#n[_]=M)}count(){const L=this.#e,Q=32-this.#t,_=new Float64Array(Q+2);for(let i=0;i<L;i++)_[this.#n[i]]++;let C=L*K(1-_[Q+1]/L);for(let i=Q;i>=1;i--)C=.5*(C+_[i]);C+=L*T(_[0]/L);const M=x*L*L/C;return Math.round(M)}}const x=.5/Math.log(2);function T(Y){if(Y===1)return 1/0;let L=1,Q=Y,_;do Y*=Y,_=Q,Q+=Y*L,L+=L;while(Q!==_);return Q}function K(Y){if(Y===0||Y===1)return 0;let L=1,Q=1-Y,_;do Y=Math.sqrt(Y),_=Q,L*=.5,Q-=(1-Y)**2*L;while(Q!==_);return Q/3}class re{#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 Q=L/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:Q,statement:`each count overestimates the truth by at most N/m = ${Q.toFixed(2)} (N=${L}, m=${this.#e})`})}get seen(){return this.#n}add(L){this.#n++;const Q=this.#t.get(L);if(Q){Q.count++;return}if(this.#t.size<this.#e){this.#t.set(L,{count:1,error:0});return}let _,C=1/0;for(const[M,i]of this.#t)i.count<C&&(C=i.count,_=M);this.#t.delete(_),this.#t.set(L,{count:C+1,error:C})}top(L=this.#e){return[...this.#t.entries()].map(([_,C])=>({item:_,count:C.count,error:C.error})).sort((_,C)=>C.count-_.count).slice(0,Math.max(0,Math.floor(L)))}}class J{#t;#e=[[]];#n=0;#r;#i;constructor(L=200,Q=Math.random){this.#t=Math.max(8,Math.floor(L)),this.#r=Q,this.#i=2/3}static errorBoundFor(L=200){const Q=1/Math.max(8,Math.floor(L));return Object.freeze({kind:"probabilistic",metric:"rank",value:Q,statement:`queried quantile\'s true rank within ~${(Q*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 _=this.#e.length-1-L,C=Math.ceil(this.#t*this.#i**_);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 Q=this.#e[L];Q.sort((M,i)=>M-i),L+1>=this.#e.length&&this.#e.push([]);const _=this.#e[L+1],C=this.#r()<.5?0:1;for(let M=C;M<Q.length;M+=2)_.push(Q[M]);this.#e[L]=[];for(let M=0;M<this.#e.length;M++)if(this.#e[M].length>=this.#s(M)){this.#h(M);return}}#u(){const L=[];for(let Q=0;Q<this.#e.length;Q++){const _=1<<Q;for(const C of this.#e[Q])L.push({v:C,w:_})}return L}quantile(L){const Q=this.#u();if(!Q.length)return null;Q.sort((i,s)=>i.v-s.v);let _=0;for(const i of Q)_+=i.w;const C=Math.min(1,Math.max(0,L))*_;let M=0;for(const i of Q)if(M+=i.w,M>=C)return i.v;return Q[Q.length-1].v}rank(L){let Q=0;for(let _=0;_<this.#e.length;_++){const C=1<<_;for(const M of this.#e[_])M<=L&&(Q+=C)}return Q}}const ue=Object.freeze({distinct:te.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"})}),oe={Welford:fe,Reservoir:he,HyperLogLog:te,SpaceSaving:re,KLL:J,hash32:z,SKETCH_BOUNDS:ue}}),Se("packages/core/src/compute/statistics.js",function(o,me){"use strict";Object.defineProperty(o,"KENDALL_LIMIT",{enumerable:!0,get:function(){return M}}),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 c}}),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 l}}),Object.defineProperty(o,"STAT_FNS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return S}}),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 E}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return ne}}),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 Re}}),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 Te}}),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,X=fe.valueReader,z=me("packages/core/src/compute/special.js"),te=z.studentTQuantile,x=z.studentT,T=z.normalQuantile,K=z.normalCdf,re=z.chiSquareUpperTail,J=me("packages/core/src/compute/linalg.js"),ue=J.cholesky,oe=J.choleskySolve,Y=J.choleskyInverse,L=J.normalEquations,Q=J.quadForm,C=me("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,M=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 ie=0;ie<y;ie++){const se=j[ie];if(D&&D(se)!==1)continue;const we=I[se];Number.isNaN(we)||(O[k++]=we)}return O.subarray(0,k)}const W=X(b);for(let I=0;I<y;I++){const D=W(j[I]);if(D==null||D==="")continue;const ie=typeof D=="number"?D:Number(D);Number.isFinite(ie)&&(O[k++]=ie)}return O.subarray(0,k)}function c(b,j){const y=new Map,O=X(b);let k=0;for(let W=0;W<j.length;W++){const I=O(j[W]);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 N=[...y.values()].sort((W,I)=>I-W);return{counts:N,total:k,distinct:N.length}}function t(b){return b.total>0?b.counts.map(j=>j/b.total):[]}function a(b,j){const y=c(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=c(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=c(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=c(b,j);if(!O.total)return null;const k=Math.max(1,Math.floor(y));let N=0;for(let W=0;W<Math.min(k,O.counts.length);W++)N+=O.counts[W];return N/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 N=0,W=0;for(let I=0;I<O;I++)N+=k[I],W+=(I+1)*k[I];return N===0?0:2*W/(O*N)-(O+1)/O}function r(b){let j=0,y=0,O=0;for(let k=0;k<b.length;k++){const N=b[k];j++;const W=N-y;y+=W/j,O+=W*(N-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),N=Math.ceil(O);return k===N?b[k]:b[k]+(O-k)*(b[N]-b[k])}function l(b,j){if(!b.length)return NaN;const y=b.slice().sort();return n(y,j)}function g(b,j){const y=X(b);let O=0,k=0,N=0;for(let W=0;W<j.length;W++){const I=y(j[W]);if(I==null||I==="")continue;const D=String(I).toUpperCase();D==="PASS"?O++:D==="FAIL"?k++:D==="WARN"&&N++}return{pass:O+N,fail:k,warn:N,judged:O+N+k}}const P=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)=>Z(f(b,j),.1),winsorizedMean:(b,j)=>R(f(b,j),.1),robustOutliers:(b,j)=>v(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?l(y,.5):null},p25:(b,j)=>{const y=f(b,j);return y.length?l(y,.25):null},p75:(b,j)=>{const y=f(b,j);return y.length?l(y,.75):null},p90:(b,j)=>{const y=f(b,j);return y.length?l(y,.9):null},p95:(b,j)=>{const y=f(b,j);return y.length?l(y,.95):null},p99:(b,j)=>{const y=f(b,j);return y.length?l(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=l(y,.5),k=new Float64Array(y.length);for(let N=0;N<y.length;N++)k[N]=Math.abs(y[N]-O);return l(k,.5)},range:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=1/0,k=-1/0;for(let N=0;N<y.length;N++)y[N]<O&&(O=y[N]),y[N]>k&&(k=y[N]);return k-O},distinct:(b,j)=>{const y=X(b),O=new Set;for(let k=0;k<j.length;k++){const N=y(j[k]);N==null||N===""||O.add(N instanceof Date?N.getTime():N)}return O.size},mode:(b,j)=>{const y=X(b),O=new Map;for(let W=0;W<j.length;W++){const I=y(j[W]);if(I==null||I==="")continue;const D=I instanceof Date?I.getTime():I;O.set(D,(O.get(D)||0)+1)}let k=null,N=1;for(const[W,I]of O)I>N&&(N=I,k=W);return k},skewness:(b,j)=>{const y=f(b,j),{n:O,mean:k,m2:N}=r(y);if(O<3||N<=0)return null;const W=Math.sqrt(N/(O-1));let I=0;for(let D=0;D<y.length;D++)I+=((y[D]-k)/W)**3;return O/((O-1)*(O-2))*I},kurtosis:(b,j)=>{const y=f(b,j),{n:O,mean:k,m2:N}=r(y);if(O<4||N<=0)return null;const W=Math.sqrt(N/(O-1));let I=0;for(let se=0;se<y.length;se++)I+=((y[se]-k)/W)**4;const D=O*(O+1)/((O-1)*(O-2)*(O-3)),ie=3*(O-1)**2/((O-2)*(O-3));return D*I-ie},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}),S=Object.freeze({hhi:"Concentration (HHI)",entropy:"Entropy",evenness:"Evenness",top3Share:"Top 3 share",top10Share:"Top 10 share",gini:"Gini coefficient",trimmedMean:"Trimmed mean",winsorizedMean:"Winsorized mean",robustOutliers:"Outliers (robust)",jarqueBera:"Jarque–Bera",median:"Median",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function G(b,j,y){const O=X(b),k=X(j);let N=0,W=0;for(let I=0;I<y.length;I++){const D=y[I],ie=Number(O(D)),se=Number(k(D));!Number.isFinite(ie)||!Number.isFinite(se)||(N+=ie*se,W+=se)}return W===0?null:N/W}function F(b,j,y){const O=X(b);let k=null,N=y?-1/0:1/0;for(let W=0;W<j.length;W++){const I=j[W],D=Number(O(I));Number.isFinite(D)&&(y?D>N:D<N)&&(N=D,k=I)}return k}function E(b,j,y){const O=X(b),k=X(j);let N=0,W=0,I=0,D=0,ie=0,se=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)||(N++,W+=Pe,I+=ye,D+=Pe*Pe,ie+=ye*ye,se+=Pe*ye)}if(N<2)return null;const we=N*se-W*I,Oe=Math.sqrt((N*D-W*W)*(N*ie-I*I));if(Oe===0)return null;const je=we/Oe;return Math.max(-1,Math.min(1,je))}function Z(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))),N=O.slice(k,y-k);if(!N.length)return n(O,.5);let W=0;for(const I of N)W+=I;return W/N.length}function R(b,j=.1){const y=b.length;if(!y)return null;const O=Array.from(b).sort((D,ie)=>D-ie),k=Math.floor(y*Math.min(.49,Math.max(0,j))),N=O[k],W=O[y-1-k];let I=0;for(const D of O)I+=Math.min(W,Math.max(N,D));return I/y}function v(b,j=3.5){if(!b.length)return null;const O=Array.from(b).sort((D,ie)=>D-ie),k=n(O,.5),N=O.map(D=>Math.abs(D-k)).sort((D,ie)=>D-ie),W=n(N,.5);if(W===0)return null;let I=0;for(const D of O)Math.abs(.6745*(D-k)/W)>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,N=0;for(const D of b){const ie=D-y;O+=ie*ie,k+=ie*ie*ie,N+=ie*ie*ie*ie}if(O/=j,k/=j,N/=j,O===0)return null;const W=k/O**1.5,I=N/(O*O)-3;return j/6*(W*W+I*I/4)}function V(b,j,y){const O=[];let k=0;for(let D=0;D<b.length;D++){const ie=Number(b[D]),se=Number(j[D]);!Number.isFinite(ie)||!Number.isFinite(se)||se<=0||(O.push([ie,se]),k+=se)}if(!O.length||k<=0)return null;if(O.sort((D,ie)=>D[0]-ie[0]),O.length===1)return O[0][0];const N=[];let W=0;for(const[,D]of O)N.push((W+D/2)/k),W+=D;const I=Math.max(0,Math.min(1,y));if(I<=N[0])return O[0][0];if(I>=N[N.length-1])return O[O.length-1][0];for(let D=1;D<N.length;D++){if(I>N[D])continue;const ie=N[D]-N[D-1],se=ie>0?(I-N[D-1])/ie:0;return O[D-1][0]+(O[D][0]-O[D-1][0])*se}return O[O.length-1][0]}function $(b,j,y){const O=X(b),k=X(j),N=new Float64Array(y.length),W=new Float64Array(y.length);let I=0;for(let D=0;D<y.length;D++){const ie=y[D],se=Number(O(ie)),we=Number(k(ie));!Number.isFinite(se)||!Number.isFinite(we)||(N[I]=se,W[I]=we,I++)}return{xs:N.subarray(0,I),ys:W.subarray(0,I),n:I}}function ee(b,j,y,O=!1){const{xs:k,ys:N,n:W}=$(b,j,y);if(W<2)return null;let I=0,D=0;for(let se=0;se<W;se++)I+=k[se],D+=N[se];I/=W,D/=W;let ie=0;for(let se=0;se<W;se++)ie+=(k[se]-I)*(N[se]-D);return ie/(O?W:W-1)}function ne(b,j,y){const{xs:O,ys:k,n:N}=$(b,j,y);if(N<2)return null;let W=0,I=0;for(let Pe=0;Pe<N;Pe++)W+=O[Pe],I+=k[Pe];W/=N,I/=N;let D=0,ie=0,se=0;for(let Pe=0;Pe<N;Pe++){const ye=O[Pe]-W,ve=k[Pe]-I;D+=ye*ye,ie+=ye*ve,se+=ve*ve}if(D===0)return null;const we=ie/D,Oe=I-we*W,je=se===0?1:Math.max(0,Math.min(1,ie*ie/(D*se))),be=Math.max(0,se-we*ie),Ae=N>2?Math.sqrt(be/(N-2)/D):0;return{slope:we,intercept:Oe,r2:je,stdError:Ae,n:N}}const ce=new Set(["ols","wls","robust"]),p=new Set(["quantile"]),B=new Set(["ridge","lasso","elasticnet","mixed","gls"]),H=1.345;function w(b,j,y){const{xtwx:O,xtwy:k}=L(b,j,y),N=ue(O);if(!N)return null;const W=oe(N,k),I=Y(N),D=A(b,W),ie=j.map((se,we)=>se-D[we]);return{beta:W,cov:I,fitted:D,residuals:ie}}function A(b,j){return b.map(y=>y.reduce((O,k,N)=>O+k*j[N],0))}function q(b,j){const y=b.length,O=b.map(ie=>ie[j]),k=b.map(ie=>[1,...ie.filter((se,we)=>we!==j)]),N=w(k,O,null);if(!N)return 1;const W=O.reduce((ie,se)=>ie+se,0)/y;let I=0,D=0;for(let ie=0;ie<y;ie++)I+=N.residuals[ie]**2,D+=(O[ie]-W)**2;return D===0?1:Math.max(0,Math.min(1,1-I/D))}function le(b){const j=[...b].sort((k,N)=>k-N),y=ae(j),O=b.map(k=>Math.abs(k-y)).sort((k,N)=>k-N);return ae(O)/.6745}function ae(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(!ce.has(O))throw new Error(`[lattice] unknown regression method "${O}"; use ols, wls or robust.`);const k=Array.isArray(j)?j.length:0,N=k&&Array.isArray(b[0])?b[0].length:0,W=N+1;if(!(k>W))return null;for(let Me=0;Me<k;Me++){if(!Number.isFinite(j[Me])||!Array.isArray(b[Me])||b[Me].length!==N)return null;for(let Ne=0;Ne<N;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 ie,se=null;if(O==="robust"){if(ie=w(D,j,null),!ie)return null;for(let Me=0;Me<50;Me++){const Ne=le(ie.residuals);if(!(Ne>0))break;const Ee=ie.residuals.map($e=>{const We=Math.abs($e/Ne);return We<=H?1:H/We}),Ce=w(D,j,Ee);if(!Ce)return null;const Ve=Ce.beta.reduce(($e,We,Je)=>Math.max($e,Math.abs(We-ie.beta[Je])),0);if(ie=Ce,se=Ee,Ve<1e-10)break}}else if(ie=w(D,j,I),!ie)return null;const we=O==="robust"?se:I,{beta:Oe,cov:je,fitted:be,residuals:Ae}=ie;let Pe=0,ye=0,ve=0;for(let Me=0;Me<k;Me++){const Ne=we?we[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=we?we[Me]:1;Ie+=Ne*(j[Me]-Fe)**2}const De=k-W,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===N?y.names:b[0].map((Me,Ne)=>`x${Ne+1}`),He=Qe(y.confidence),Ze=De>0?te(1-(1-He)/2,De):1/0,Lt=Oe.map((Me,Ne)=>{const Ee=Math.sqrt(Math.max(0,qe*je[Ne][Ne])),Ce=Ee>0?Me/Ee:Me===0?0:1/0,Ve=Number.isFinite(Ce)?2*(1-x(Math.abs(Ce),De)):0,$e=Number.isFinite(Ze)?Ze*Ee:null;return{name:Ne===0?"(intercept)":Xe[Ne-1],estimate:Me,stdError:Ee,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=we?we[Me]:1,Ee=Math.max(0,Math.min(1,Ne*Q(D[Me],je)));dt[Me]=Ee;const Ce=(1-Ee)**2;mt[Me]=Ce>0&&qe>0?Ae[Me]**2/(W*qe)*(Ee/Ce):null}const Ft=b[0].map((Me,Ne)=>{if(N<2)return 1;const Ee=q(b,Ne);return Ee>=1?1/0:1/(1-Ee)});let gt=null;{const Me=Ae.map(Ee=>Ee*Ee),Ne=w(D,Me,null);if(Ne){const Ee=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]-Ee)**2;const $e=Ve===0?0:Math.max(0,Math.min(1,1-Ce/Ve)),We=k*$e,Je=re(We,N);gt={statistic:We,df:N,p:Je,heteroscedastic:Je<.05}}}let bt=null;if(N===1){const Me=b.map((Ne,Ee)=>Ee).sort((Ne,Ee)=>b[Ne][0]-b[Ee][0]);bt={confidence:He,points:Me.map(Ne=>{const Ee=D[Ne],Ce=Math.sqrt(Math.max(0,qe*Q(Ee,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:we?[...we]:null}}function pe(b){const j=b.length,y=Array.from({length:j},(N,W)=>W).sort((N,W)=>b[N]-b[W]),O=new Float64Array(j);let k=0;for(;k<j;){let N=k;for(;N+1<j&&b[y[N+1]]===b[y[k]];)N++;const W=(k+N)/2+1;for(let I=k;I<=N;I++)O[y[I]]=W;k=N+1}return O}const ge=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function ke(b){const j=[.01,.05,.1],y=[ge["1%"],ge["5%"],ge["10%"]];if(b<=y[0]){const N=(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])+N*(b-y[0]))))}if(b>=y[2]){const N=(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])+N*(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 Le(b,j,y,O){const k=y-O,N=O+3,W=new Array(k),I=new Array(k);let D=!0,ie=O;for(let be=0;be<k;be++){const Ae=O+be,Pe=new Float64Array(N);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<N;ye++)Number.isFinite(Pe[ye])||(ie=Math.min(ie,ye-3));W[be]=Pe,I[be]=j[Ae],Number.isFinite(I[be])||(D=!1)}if(!D)return 0;const{xtwx:se,xtwy:we}=L(W,I,null);let Oe=0,je=1/0;for(let be=0;be<=ie;be++){const Ae=be+3;if(!(k>Ae))continue;const Pe=new Array(Ae);for(let Ue=0;Ue<Ae;Ue++)Pe[Ue]=se[Ue].slice(0,Ae);const ye=ue(Pe);if(!ye)continue;const ve=oe(ye,we.slice(0,Ae));let Fe=0;for(let Ue=0;Ue<k;Ue++){const tt=W[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,Oe=be)}return Oe}function Re(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 N=new Array(k);for(let je=0;je<k;je++)N[je]=y[je+1]-y[je];let W=Number.isFinite(j.maxlag)?Math.floor(j.maxlag):Math.ceil(12*(O/100)**.25);W=Math.max(0,Math.min(W,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(N[ye-Fe]);Ae.push(ve),Pe.push(N[ye])}return de(Ae,Pe,{method:"ols"})},D=Le(y,N,k,W),ie=I(D,D);if(!ie||!ie.coefficients[2])return null;const se=ie.coefficients[2].t,we=ke(se),Oe=se<ge["5%"];return{statistic:se,usedLag:D,nobs:k-D,criticalValues:{...ge},pValue:we,pApproximate:!0,stationary:Oe,verdict:Oe?"stationary":"non-stationary",regression:"ct"}}function Be(b,j={}){const y=[];for(let Oe=0;Oe<b.length;Oe++){const je=Number(b[Oe]);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 N=0;for(const Oe of y)N+=Oe;N/=O;const W=y.map(Oe=>Oe-N);let I=0;for(const Oe of W)I+=Oe*Oe;I/=O;const D=new Array(k+1).fill(0);D[0]=1;for(let Oe=1;Oe<=k;Oe++){let je=0;for(let be=Oe;be<O;be++)je+=W[be]*W[be-Oe];D[Oe]=I>0?je/O/I:0}const ie=new Array(k+1).fill(0);ie[0]=1;let se=[];for(let Oe=1;Oe<=k;Oe++){let je=D[Oe];for(let ye=1;ye<Oe;ye++)je-=se[ye-1]*D[Oe-ye];let be=1;for(let ye=1;ye<Oe;ye++)be-=se[ye-1]*D[ye];const Ae=be!==0?je/be:0,Pe=new Array(Oe);for(let ye=1;ye<Oe;ye++)Pe[ye-1]=se[ye-1]-Ae*se[Oe-1-ye];Pe[Oe-1]=Ae,ie[Oe]=Ae,se=Pe}const we=1.96/Math.sqrt(O);return{acf:D,pacf:ie,bounds:{upper:we,lower:-we},n:O,nlags:k,approximate:!0}}function ze(b,j,y){const{xs:O,ys:k,n:N}=$(b,j,y);if(N<2)return null;const W=pe(O),I=pe(k);let D=0,ie=0;for(let je=0;je<N;je++)D+=W[je],ie+=I[je];D/=N,ie/=N;let se=0,we=0,Oe=0;for(let je=0;je<N;je++){const be=W[je]-D,Ae=I[je]-ie;se+=be*Ae,we+=be*be,Oe+=Ae*Ae}return we===0||Oe===0?null:Math.max(-1,Math.min(1,se/Math.sqrt(we*Oe)))}function Ke(b,j,y){const{xs:O,ys:k,n:N}=$(b,j,y);if(N<2||N>M)return null;let W=0,I=0,D=0,ie=0;for(let Oe=0;Oe<N;Oe++)for(let je=Oe+1;je<N;je++){const be=Math.sign(O[Oe]-O[je]),Ae=Math.sign(k[Oe]-k[je]),Pe=be*Ae;Pe>0?W++:Pe<0?I++:be===0&&Ae===0||(be===0?D++:ie++)}const se=W+I+ie,we=W+I+D;return se===0||we===0?null:(W-I)/Math.sqrt(se*we)}function Te(b,j={}){const y=b.length;if(y<2)return null;const O=b[0],k=b[y-1],N=[];for(let ye=1;ye<y;ye++){const ve=b[ye-1];ve!==0&&N.push((b[ye]-ve)/Math.abs(ve))}let W=null;if(N.length>1){let ye=0;for(const Fe of N)ye+=Fe;ye/=N.length;let ve=0;for(const Fe of N)ve+=(Fe-ye)**2;W=Math.sqrt(ve/(N.length-1))}const I=Number(j.periodsPerYear)>0?Number(j.periodsPerYear):null;let D=b[0],ie=0,se=0,we=0,Oe=0;for(let ye=1;ye<y;ye++){if(b[ye]>D){D=b[ye],ie=ye;continue}if(D<=0)continue;const ve=(D-b[ye])/D;ve>se&&(se=ve,we=ie,Oe=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 N)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:W,annualisedVolatility:W!==null&&I?W*Math.sqrt(I):null,growth:Pe,maxDrawdown:se,maxDrawdownFrom:we,maxDrawdownTo:Oe,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,N)=>k+N,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 N=0;for(let be=0;be<y;be++)N+=b[be];N/=y;let W=0;for(let be=0;be<y;be++)W+=(b[be]-N)**2;const I=Math.sqrt(W/(y-1)),D=xe(b),ie=D?D.sigma:null,se=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-N)/(3*be):1/0,ve=O!==null?(N-O)/(3*be):1/0;return{index:Pe,k:Math.min(ye,ve)}},we=se(ie),Oe=se(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:N,lower:O,upper:k,target:Number.isFinite(Number(j.target))?Number(j.target):null,sigmaWithin:ie,sigmaOverall:I,cp:we.index,cpk:we.k,pp:Oe.index,ppk:Oe.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,N=I=>(b[I]-O)/k,W=[];for(let I=0;I<y;I++){if(Math.abs(N(I))>3&&W.push({index:I,rule:1,description:"beyond three sigma"}),I>=2)for(const D of[1,-1]){let ie=0;for(let se=I-2;se<=I;se++)N(se)*D>2&&ie++;if(ie>=2){W.push({index:I,rule:2,description:"two of three past two sigma"});break}}if(I>=4)for(const D of[1,-1]){let ie=0;for(let se=I-4;se<=I;se++)N(se)*D>1&&ie++;if(ie>=4){W.push({index:I,rule:3,description:"four of five past one sigma"});break}}if(I>=7)for(const D of[1,-1]){let ie=!0;for(let se=I-7;se<=I;se++)if(N(se)*D<=0){ie=!1;break}if(ie){W.push({index:I,rule:4,description:"eight in a row on one side"});break}}}return W}function ct(b,j){if(!j||!(j.sigma>0))return[];const y=b.length,{centre:O,sigma:k}=j,N=D=>(b[D]-O)/k,W=(D,ie,se,we)=>{for(const Oe of[1,-1]){let je=0;for(let be=D;be<=ie;be++)N(be)*Oe>se&&je++;if(je>=we)return!0}return!1},I=[];for(let D=0;D<y;D++){if(Math.abs(N(D))>3&&I.push({index:D,rule:1,description:"beyond three sigma"}),D>=8)for(const ie of[1,-1]){let se=!0;for(let we=D-8;we<=D;we++)if(N(we)*ie<=0){se=!1;break}if(se){I.push({index:D,rule:2,description:"nine in a row on one side"});break}}if(D>=5)for(const ie of[1,-1]){let se=!0;for(let we=D-4;we<=D;we++)if((b[we]-b[we-1])*ie<=0){se=!1;break}if(se){I.push({index:D,rule:3,description:ie>0?"six rising":"six falling"});break}}if(D>=13){let ie=!0;for(let se=D-12;se<=D;se++){const we=b[se]-b[se-1],Oe=b[se+1<=D?se+1:se]-b[se];if(se+1>D)break;if(we===0||Oe===0||we>0==Oe>0){ie=!1;break}}ie&&I.push({index:D,rule:4,description:"fourteen alternating"})}if(D>=2&&W(D-2,D,2,2)&&I.push({index:D,rule:5,description:"two of three past two sigma"}),D>=4&&W(D-4,D,1,4)&&I.push({index:D,rule:6,description:"four of five past one sigma"}),D>=14){let ie=!0;for(let se=D-14;se<=D;se++)if(Math.abs(N(se))>=1){ie=!1;break}ie&&I.push({index:D,rule:7,description:"fifteen within one sigma"})}if(D>=7){let ie=!0;for(let se=D-7;se<=D;se++)if(Math.abs(N(se))<=1){ie=!1;break}ie&&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 N=b[0],W=b[k-1];if(W===N)return[{from:N,to:W,count:k}];const I=y-j,D=1.5*I;let ie=I>0?Math.max(N,j-D):N,se=I>0?Math.min(W,y+D):W;se>ie||(ie=N,se=W);const we=I>0?2*I/Math.cbrt(k):(se-ie)/(Math.ceil(Math.log2(k))+1),Oe=we>0?Math.min(O,Math.max(1,Math.ceil((se-ie)/we))):1,je=(se-ie)/Oe,be=[];for(let Ae=0;Ae<Oe;Ae++)be.push({from:ie+Ae*je,to:ie+(Ae+1)*je,count:0});for(let Ae=0;Ae<k;Ae++){const Pe=Math.min(Oe-1,Math.max(0,Math.floor((b[Ae]-ie)/je)));be[Pe].count++}return be[0].from=N,be[Oe-1].to=W,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 se=0;se<y;se++)O+=b[se];const k=O/y;let N=0;for(let se=0;se<y;se++){const we=b[se]-k;N+=we*we}const W=Math.sqrt(N/(y-1)),I=Qe(j),ie=te(1-(1-I)/2,y-1)*W/Math.sqrt(y);return{mean:k,lower:k-ie,upper:k+ie,margin:ie,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 N=Qe(y),W=T(1-(1-N)/2),I=O/k,D=W*W,ie=1+D/k,se=(I+D/(2*k))/ie,we=W/ie*Math.sqrt(I*(1-I)/k+D/(4*k*k));return{proportion:I,lower:Math.max(0,se-we),upper:Math.min(1,se+we),n:k,confidence:N}}function vt(b,j=Ge){if(!b||!(b.n>2)||!Number.isFinite(b.stdError))return null;const y=Qe(j),k=te(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 N=Qe(y),I=T(1-(1-N)/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:N}}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=X(b);let k=0;for(let N=0;N<j.length;N++){const W=O(j[N]);if(W==null||W===""||typeof W=="number"&&Number.isNaN(W))continue;const I=W instanceof Date?W.getTime():typeof W=="object"?String(W):W;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 N=new Set(b.keys());for(const W of y.keys())N.add(W);for(const W of N){const I=(b.get(W)||0)/j,D=(y.get(W)||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:ie}=r(I),se=D>0?lt({mean:y.mean,sd:y.sd},ie):null;return{measure:"standardizedMeanDifference",magnitude:se,distance:se===null?0:at(se),direction:se===null?0:Math.sign(se),subsetN:D,populationN:y.n||0,reliable:D>=et}}const{map:k,total:N}=_e(b,j),W=ft(k,N,y.map,y.total);return{measure:"categoricalTotalVariation",magnitude:W,distance:W===null?0:W,direction:0,subsetN:N,populationN:y.total||0,reliable:N>=et}}function ht(b,j){if(b&&(b.kind==="float64"||b.kind==="int32"))return!0;const y=X(b);let O=0,k=0;for(let N=0;N<j.length&&O<200;N++){const W=y(j[N]);if(W==null||W==="")continue;if(W instanceof Date)return!1;O++;const I=typeof W=="number"?W:Number(W);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:N,mean:W,m2:I}=r(k);return{numeric:!0,mean:W,sd:N>0?Math.sqrt(I/N):0,n:N}}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 c}}),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,X=fe.warnOnce,z=me("packages/core/src/compute/handle.js"),te=z.presenceReader,x=z.valueComparator,T=z.valueReader,K=me("packages/core/src/compute/statistics.js"),re=K.STAT_FNS,J=K.STAT_LABELS;function ue(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function oe(r,n){const l=n.length;let g=0;if(ue(r)){const S=r.values,G=te(r);if(!G){for(let F=0;F<l;F++){const E=S[n[F]];Number.isNaN(E)||(g+=E)}return g}for(let F=0;F<l;F++){const E=n[F];if(G(E)===1){const Z=S[E];Number.isNaN(Z)||(g+=Z)}}return g}const P=T(r);for(let S=0;S<l;S++){const G=u(P(n[S]));G!==null&&(g+=G)}return g}oe.kernel=!0;function Y(r,n){const l=n.length;let g=0;if(ue(r)){const S=r.values,G=te(r);if(!G){for(let F=0;F<l;F++)Number.isNaN(S[n[F]])||g++;return g}for(let F=0;F<l;F++){const E=n[F];G(E)===1&&!Number.isNaN(S[E])&&g++}return g}const P=T(r);for(let S=0;S<l;S++){const G=P(n[S]);G!=null&&!(typeof G=="number"&&Number.isNaN(G))&&g++}return g}Y.kernel=!0;function L(r,n){return n.length}L.kernel=!0;function Q(r,n){const l=Y(r,n);return l===0?null:oe(r,n)/l}Q.kernel=!0;function _(r,n,l,g){const P=n.length;if(ue(r)){const E=r.values,Z=te(r);let R=null;if(!Z){for(let v=0;v<P;v++){const U=E[n[v]];Number.isNaN(U)||(R===null||(l<0?U<R:U>R))&&(R=U)}return R}for(let v=0;v<P;v++){const U=n[v];if(Z(U)===0)continue;const V=E[U];Number.isNaN(V)||(R===null||(l<0?V<R:V>R))&&(R=V)}return R}const S=T(r),G=x(g);let F=null;for(let E=0;E<P;E++){const Z=S(n[E]);Z==null||typeof Z=="number"&&Number.isNaN(Z)||(F===null||(l<0?G(Z,F)<0:G(Z,F)>0))&&(F=Z)}return F}function C(r,n,l){return _(r,n,-1,l&&l.locale)}C.kernel=!0;function M(r,n,l){return _(r,n,1,l&&l.locale)}M.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:oe,min:C,max:M,avg:Q,count:L,first:i,last:s,countValues:Y,...re},c=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"?c[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 l=a.filter(g=>g in f);for(const g of Object.keys(f))l.includes(g)||l.push(g);return l}function e(r,n){return typeof n!="string"?!0:m(r).includes(n)}function d(r,n){const l=T(r),g=[];for(let P=0;P<n.length;P++){const S=l(n[P]);S!=null&&g.push(S)}return g}function h(r,n,l,g){const P=n||[];if(typeof l=="string"){const S=f[l];return S?S(r,P,g):(X(`total:${l}`,`unknown total function "${l}"; register it in config.totalFns`),null)}return he(l)?l.kernel===!0?l(r,P,g):l(d(r,P),g||{}):null}}),Se("packages/core/src/compute/pivot.js",function(o,me){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return M}});const he=me("packages/core/src/internal/util.js").warnOnce,z=me("packages/core/src/compute/handle.js").valueComparator,x=me("packages/core/src/compute/group.js").packKeys,K=me("packages/core/src/compute/total.js").total,re="|",J="/",ue=2e3;function oe(u,f,c){return`${u}${re}${f}${re}${c}`}function Y(u,f){let c="";for(let t=0;t<u.length;t++){const a=u[t];c+=(t===0?"":f)+(a==null?"":String(a))}return c}function L(u,f,c={}){const t=c.separator||J,a=f.length,{keyOf:m,readers:e}=x(u,f,0),d=new Map,h=[],r=[];for(let F=0;F<a;F++){const E=f[F],Z=m(E);if(d.has(Z))continue;d.set(Z,h.length),r.push(Z);const R=new Array(e.length);for(let v=0;v<e.length;v++)R[v]=e[v](E);h.push(R)}const n=z(c.locale),l=h.map((F,E)=>E);l.sort((F,E)=>{const Z=h[F],R=h[E];for(let v=0;v<Z.length;v++){const U=Q(Z[v],R[v],n);if(U!==0)return U}return F-E});const g=new Array(l.length),P=new Array(l.length),S=new Map;for(let F=0;F<l.length;F++){const E=l[F];g[F]=h[E],P[F]=Y(h[E],t),S.set(r[E],F)}return{keys:g,paths:P,idOf:F=>{const E=S.get(m(F));return E===void 0?-1:E}}}function Q(u,f,c){const t=u==null,a=f==null;return t||a?t&&a?0:t?1:-1:c(u,f)}function _(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 c=typeof u.handle=="function"?u.handle:null;if(!c)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=c(m);e&&a.push({colId:m,handle:e,fn:t?t(m):"sum"})}return a}function C(u,f,c){if(Array.isArray(u)){const t=c||{};return{...t,pivotHandles:u,order:f||null,groups:t.groups||null}}return u||{}}function M(u,f,c){const t=C(u,f,c),a=t.separator||J,m=_(t),e=t.maxColumns===void 0?ue: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(Z=>Y(Z,a)):[""]),n=s(h),{keys:l,paths:g,idOf:P}=L(t.pivotHandles||[],n,t),S=g.length*Math.max(1,m.length),G=i(g,m,a);if(e&&S>e){const Z=new Map;return{keys:l,paths:g,fields:G,groupPaths:r,columns:S,values:Z,cells:Z,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${S} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:S,maxColumns:e}}}const F=new Map,E=g.length;for(let Z=0;Z<h.length;Z++){const R=h[Z],v=r[Z]===void 0?"":r[Z],U=R.length;if(U===0)continue;const V=new Int32Array(U),$=new Uint32Array(E+1);for(let ce=0;ce<U;ce++){const p=P(R[ce]);V[ce]=p,p>=0&&$[p+1]++}for(let ce=0;ce<E;ce++)$[ce+1]+=$[ce];const ee=new Uint32Array(U),ne=$.slice(0,E);for(let ce=0;ce<U;ce++){const p=V[ce];p>=0&&(ee[ne[p]++]=R[ce])}for(let ce=0;ce<E;ce++){const p=$[ce],B=$[ce+1];if(B===p)continue;const H=ee.subarray(p,B);for(let w=0;w<m.length;w++){const A=m[w],q=K(A.handle,H,A.fn,t.totalContext||{locale:t.locale});F.set(oe(v,g[ce],A.colId),q)}}}return{keys:l,paths:g,fields:G,groupPaths:r,columns:S,values:F,cells:F,error:null}}function i(u,f,c){if(f.length===0)return u.slice();const t=[];for(const a of u)for(const m of f)t.push(`${a}${c}${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 c=new Uint32Array(f);let t=0;for(const a of u)!a||a.length===0||(c.set(a,t),t+=a.length);return c}}),Se("packages/core/src/compute/pivotmatrix.js",function(o,me){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return M}});const he=me("packages/core/src/compute/handle.js").valueComparator,z=me("packages/core/src/compute/total.js").total,x=me("packages/core/src/compute/group.js").packKeys,T=me("packages/core/src/compute/pivot.js"),K=T.joinPath,re=T.DEFAULT_PATH_SEPARATOR,J=T.DEFAULT_MAX_COLUMNS,ue="";function oe(i,s,u={}){const f=u.separator||re,c=i||[],t=s instanceof Uint32Array?s:Uint32Array.from(s||[]),a=t.length;if(c.length===0)return{tuples:[[]],paths:[ue],buckets:[t]};const{keyOf:m,readers:e}=x(c,t,0),d=new Map,h=[],r=[],n=[];for(let F=0;F<a;F++){const E=t[F],Z=m(E);let R=d.get(Z);if(R===void 0){R=h.length,d.set(Z,R),r.push(Z);const v=new Array(e.length);for(let U=0;U<e.length;U++)v[U]=e[U](E);h.push(v),n.push([])}n[R].push(E)}const l=he(u.locale),g=h.map((F,E)=>E);g.sort((F,E)=>{const Z=h[F],R=h[E];for(let v=0;v<Z.length;v++){const U=Y(Z[v],R[v],l);if(U!==0)return U}return F-E});const P=new Array(g.length),S=new Array(g.length),G=new Array(g.length);for(let F=0;F<g.length;F++){const E=g[F];P[F]=h[E],S[F]=K(h[E],f),G[F]=Uint32Array.from(n[E])}return{tuples:P,paths:S,buckets:G}}function Y(i,s,u){const f=i==null,c=s==null;return f||c?f&&c?0:f?1:-1:u(i,s)}function L(i,s,u){const f=[];for(let c=0;c<i.length;c++)u.has(i[c])&&f.push(i[c]);return Uint32Array.from(f)}function Q(i,s,u,f){return{value:s.length?z(i,s,u,f):null,leaves:s,count:s.length}}function _(i){const s=i&&i.opts||{},u=s.separator||re,f=s.totalContext||{locale:s.locale},c=(i.measures||[]).filter(S=>S&&S.handle),t=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),a=oe(i.rowHandles||[],t,{...s,separator:u}),m=oe(i.columnHandles||[],t,{...s,separator:u}),e=s.maxColumns===void 0?J:s.maxColumns,d=m.paths.length*Math.max(1,c.length),h=new Map;if(e&&d>e)return{rowAxis:a,columnAxis:m,measures:c.map(S=>({colId:S.colId,fn:S.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,l=new Map,g=new Map,P=m.buckets.map(S=>new Set(S));for(let S=0;S<m.paths.length;S++){const G=m.buckets[S],F=m.paths[S];for(const E of c)l.set(M(F,E.colId),Q(E.handle,G,E.fn,f))}for(let S=0;S<a.paths.length;S++){const G=a.buckets[S],F=a.paths[S];for(const E of c)n.set(M(F,E.colId),Q(E.handle,G,E.fn,f));for(let E=0;E<m.paths.length;E++){const Z=L(G,m.buckets[E],P[E]);if(Z.length===0)continue;const R=m.paths[E];for(const v of c)r.set(C(F,R,v.colId),Q(v.handle,Z,v.fn,f))}}for(const S of c)g.set(S.colId,Q(S.handle,t,S.fn,f));return{rowAxis:a,columnAxis:m,measures:c.map(S=>({colId:S.colId,fn:S.fn})),body:r,rowMargin:n,columnMargin:l,grand:g,columns:d,error:null}}function C(i,s,u){return`${i}\\0${s}\\0${u}`}function M(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 ue}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return _}});const he=me("packages/core/src/internal/util.js").getPath,X=me("packages/core/src/compute/handle.js"),z=X.isMissing,te=X.valueComparator,T=me("packages/core/src/compute/filter.js").testValue,K="",re="\\0";function J(i,s){const u=s.includes(".")?he(i,s):i?.[s];return u===void 0?null:u}function ue(i,s,u={}){const f=s||[];let c=i.map((t,a)=>a);if(f.length===0)return c;for(let t=f.length-1;t>=0;t--)c=oe(i,c,f[t],u);return c}function oe(i,s,u,f){const c=u.locale!==void 0?u.locale:f.locale,t=te(c),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 l=J(i[r],u.col),g=J(i[n],u.col);let P;return typeof u.compare=="function"?(P=u.compare(l,g,i[r],i[n],a),a&&(P=-P)):P=a?t(g,l):t(l,g),P!==0?P:d.get(r)-d.get(n)};return m.sort(h),u.nullsFirst?e.concat(m):m.concat(e)}function Y(i,s,u={}){const f=[];for(let c=0;c<i.length;c++)L(i[c],s,u,c)&&f.push(c);return f}function L(i,s,u,f){if(!s)return!0;if(Array.isArray(s.conditions)){const c=s.conditions.filter(a=>a!=null);if(c.length===0)return!0;if(s.op==="or")return c.some(a=>L(i,a,u,f));const t=c.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 Q(i,s,u,f){const c=u||i.map((e,d)=>d),t=new Map,a=[],m=[];for(const e of c){const d=s.map((n,l)=>{const g=J(i[e],n);return f&&f[l]?f[l](g):g}),h=d.map(n=>n==null?re: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 _(i,s,u={}){const f=te(u.locale),c=i.filter(a=>!z(a)),t=c.map(C).filter(a=>a!==null);switch(s){case"count":return i.length;case"countValues":return c.length;case"sum":return t.reduce((a,m)=>a+m,0);case"avg":return c.length===0?null:t.reduce((a,m)=>a+m,0)/c.length;case"min":return c.length===0?null:c.reduce((a,m)=>f(m,a)<0?m:a);case"max":return c.length===0?null:c.reduce((a,m)=>f(m,a)>0?m:a);case"first":return i.length===0?null:M(i[0]);case"last":return i.length===0?null:M(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 M(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 X}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return x}});const he=me("packages/core/src/compute/sketch.js").Welford;class X{#t;#e;#n=[];#r;#i;constructor(K,re=0,J=Date.now){if(K!=="count"&&K!=="time"&&K!=="session")throw new RangeError(`unknown window kind: ${K}`);if((K==="count"||K==="time")&&!(re>0))throw new RangeError(`a ${K} window needs a positive span`);this.#t=K,this.#e=Math.floor(re),this.#r=J,this.#i=J()}get size(){return this.#n.length}push(K,re=this.#r()){Number.isFinite(K)&&(this.#n.push({t:re,v:K}),this.#s(re))}#s(K){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const re=K-this.#e;for(;this.#n.length&&this.#n[0].t<re;)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 re=new he;let J=0,ue=1/0,oe=-1/0;for(const{v:Y}of this.#n)J+=Y,Y<ue&&(ue=Y),Y>oe&&(oe=Y),re.add(Y);return{over:K,count:this.#n.length,sum:J,mean:re.mean(),min:ue,max:oe,variance:re.variance(),stddev:re.stddev()}}reduce(K){const re=this.aggregate(),J={sum:re.sum,avg:re.mean,mean:re.mean,min:re.min,max:re.max,count:re.count,variance:re.variance,stddev:re.stddev};if(!(K in J))throw new RangeError(`unknown windowed aggregate: ${K}`);return{value:J[K],over:re.over}}}const z=Object.freeze(["count","time","session"]);function te(T,K=Date.now){const re=T.kind==="time"&&T.minutes!=null?T.minutes*6e4:T.span??0;return new X(T.kind,re,K)}const x={Window:X,WINDOW_KINDS:z,openWindow:te}}),Se("packages/core/src/compute/anomaly.js",function(o,me){"use strict";Object.defineProperty(o,"MAD_SCALE",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return x}}),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 re}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return M}}),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,te=.6745,x=3.5,T=1.5,K=.975,re=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function J(c){if(!c.length)return null;const a=Array.from(c,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 ue(c,t={}){const a=Number.isFinite(t.threshold)?t.threshold:x,m=c.length,e=new Array(m).fill(null),d=new Array(m).fill(!1),h=[];for(let l=0;l<m;l++){const g=Number(c[l]);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 l=0;l<m;l++){const g=Number(c[l]);if(!Number.isFinite(g))continue;const P=te*(g-r.median)/r.mad;e[l]=P,Math.abs(P)>a&&(d[l]=!0,n++)}return{median:r.median,mad:r.mad,threshold:a,scores:e,flags:d,flagged:n}}function oe(c,t={}){const a=Number.isFinite(t.k)?t.k:T,m=[];for(let n=0;n<c.length;n++){const l=Number(c[n]);Number.isFinite(l)&&m.push(l)}if(!m.length)return null;const e=m.sort((n,l)=>n-l),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 Y(c,t){if(t<=0)return 0;const a=z(c);if(t<c+1){let l=c,g=1/c,P=g;for(let S=0;S<1e3&&(l+=1,P*=t/l,g+=P,!(Math.abs(P)<Math.abs(g)*1e-15));S++);return g*Math.exp(-t+c*Math.log(t)-a)}const m=1e-300;let e=t+1-c,d=1/m,h=1/e,r=h;for(let l=1;l<1e3;l++){const g=-l*(l-c);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 P=h*d;if(r*=P,Math.abs(P-1)<1e-15)break}return 1-Math.exp(-t+c*Math.log(t)-a)*r}function L(c,t){return c<=0?0:Y(t/2,c/2)}function Q(c,t=K){if(!(t>0)||!(t<1))return NaN;let a=0,m=Math.max(1,c);for(;L(m,c)<t;)m*=2;for(let e=0;e<200;e++){const d=(a+m)/2;if(L(d,c)<t?a=d:m=d,m-a<1e-10)break}return(a+m)/2}function _(c){const t=c.length,a=c.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(c,t){const a=c.length,m=new Array(t).fill(0);for(const h of c)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 c)for(let r=0;r<t;r++){const n=h[r]-m[r];for(let l=r;l<t;l++)e[r][l]+=n*(h[l]-m[l])}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 M(c,t={}){const a=Number.isFinite(t.p)?t.p:K,m=Number.isFinite(t.ridge)?t.ridge:1e-6,e=c.length;if(!e)return null;const d=c[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),l=[],g=[];for(let v=0;v<e;v++){const U=c[v];let V=U.length===d;const $=new Array(d);for(let ee=0;V&&ee<d;ee++){const ne=Number(U[ee]);Number.isFinite(ne)?$[ee]=ne:V=!1}V&&(l.push(v),g.push($))}const P=d,S=Q(P,a);if(g.length<=d)return{center:[],df:P,cutoff:S,singular:!0,used:g.length,distances:h,squared:r,flags:n,flagged:0};const{mean:G,cov:F}=C(g,d);let E=_(F),Z=!1;if(!E){Z=!0;let v=0;for(let $=0;$<d;$++)v+=F[$][$];const U=v/d*m||m,V=F.map(($,ee)=>$.map((ne,ce)=>ee===ce?ne+U:ne));if(E=_(V),!E)return{center:G,df:P,cutoff:S,singular:!0,used:g.length,distances:h,squared:r,flags:n,flagged:0}}let R=0;for(let v=0;v<g.length;v++){const U=g[v],V=new Array(d);for(let ne=0;ne<d;ne++)V[ne]=U[ne]-G[ne];let $=0;for(let ne=0;ne<d;ne++){let ce=0;for(let p=0;p<d;p++)ce+=E[ne][p]*V[p];$+=V[ne]*ce}$<0&&($=0);const ee=l[v];r[ee]=$,h[ee]=Math.sqrt($),$>S&&(n[ee]=!0,R++)}return{center:G,df:P,cutoff:S,singular:Z,used:g.length,distances:h,squared:r,flags:n,flagged:R}}const i=20,s=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function u(c,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:x,d=Number.isFinite(t.k)?t.k:T,h=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):m,r=c.length,n=new Array(r).fill(null),l=new Array(r).fill(!1);let g=0;for(let P=0;P<r;P++){const S=Number(c[P]);if(!Number.isFinite(S))continue;const G=Math.max(0,P-m+1),F=[];for(let E=G;E<=P;E++){const Z=Number(c[E]);Number.isFinite(Z)&&F.push(Z)}if(!(F.length<h))if(a==="rollingIqr"){const E=oe(F,{k:d});if(!E)continue;(S<E.lower||S>E.upper)&&(l[P]=!0,g++)}else{const E=J(F);if(!E||E.mad===0)continue;const Z=te*(S-E.median)/E.mad;n[P]=Z,Math.abs(Z)>e&&(l[P]=!0,g++)}}return{method:a,windowLen:m,minPeriods:h,threshold:e,k:d,scores:n,flags:l,flagged:g}}function f(c={}){const t=c||{},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(!(re.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=l=>Number(l==null?NaN:l[a]);return l=>{const g=Array.isArray(l)?l.slice():[...l];d&&g.sort((E,Z)=>{const R=E?.[d],v=Z?.[d];return R===v?0:R==null?-1:v==null?1:R<v?-1:1});const P=g.map(n);let S,G;if(r)({flags:S,scores:G}=u(P,{method:m,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(m==="iqr"){const E=oe(P,{k:t.k});S=P.map(Z=>E?Number.isFinite(Z)&&(Z<E.lower||Z>E.upper):!1),G=P.map(()=>null)}else({flags:S,scores:G}=ue(P,{threshold:t.threshold}));if(h){const E=S.length-1;return E<0||!S[E]?!1:{method:m,field:a,flagged:[{row:g[E],score:G[E]}]}}const F=[];for(let E=0;E<S.length;E++)S[E]&&F.push({row:g[E],score:G[E]});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 x}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return c}});const fe=me("packages/core/src/compute/special.js"),he=fe.normalQuantile,X=fe.studentTQuantile,te=me("packages/core/src/internal/util.js").warnOnce,x=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),T=1e-4,K=1-1e-4;function re(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 ue(t){return Math.min(K,Math.max(T,t))}function oe(t,a=T,m=K,e=80){const d=(Math.sqrt(5)-1)/2;let h=a,r=m,n=r-d*(r-h),l=h+d*(r-h),g=t(n),P=t(l);for(let S=0;S<e;S++)g<P?(r=l,l=n,P=g,n=r-d*(r-h),g=t(n)):(h=n,n=l,g=P,l=h+d*(r-h),P=t(l));return(h+r)/2}function Y(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 l=t[n];if(l===null){e!==null&&d!==null&&(e+=d);continue}if(e===null){e=l;continue}d===null&&(d=l-e);const g=e+d;h+=(l-g)**2,r+=1;const P=e;e=a*l+(1-a)*(P+d),d=m*(e-P)+(1-m)*d}return{level:e,trend:d,sse:h,m:r}}function Q(t,a,m,e,d){const h=t.length;if(h<2*a)return null;const r=Z=>{let R=0,v=0;for(let U=Z;U<Z+a&&U<h;U++)t[U]!==null&&(R+=t[U],v+=1);return v?R/v:null},n=r(0),l=r(a);if(n===null||l===null)return null;let g=n,P=(l-n)/a;const S=new Array(a).fill(0);for(let Z=0;Z<a;Z++)S[Z]=t[Z]===null?0:t[Z]-g;const G=S.reduce((Z,R)=>Z+R,0)/a;for(let Z=0;Z<a;Z++)S[Z]-=G;let F=0,E=0;for(let Z=a;Z<h;Z++){const R=Z%a,v=S[R],U=t[Z];if(U===null){g+=P;continue}const V=g+P+v;F+=(U-V)**2,E+=1;const $=g;g=m*(U-v)+(1-m)*(g+P),P=e*(g-$)+(1-e)*P,S[R]=d*(U-g)+(1-d)*v}return{level:g,trend:P,season:S,phase:(h-1)%a,sse:F,count:E}}function _(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=x.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=re(t),n=r.map(F=>F.value),l=n.filter(F=>F!==null),g=l.length,{lastAt:P,step:S}=g?J(r):{lastAt:0,step:1},G=F=>P+F*S;return m==="linear"?M(r,g,e,d,h,G):m==="movingAverage"?i(l,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 M(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 l=0,g=0,P=0;for(const U of t){if(U.value===null)continue;const V=U.at-r,$=U.value-n;l+=V*V,g+=V*$,P+=$*$}if(l===0)return null;const S=g/l,G=n-S*r,F=P===0?1:Math.max(0,Math.min(1,g*g/(l*P))),E=Math.max(0,P-S*g),Z=a>2?Math.sqrt(E/(a-2)):null,R=a>2?X(d,a-2):null,v=[];for(let U=1;U<=m;U++){const V=h(U),$=G+S*V;let ee=null,ne=null,ce=null,p=null,B=null;if(Z!==null){const H=1/a+(V-r)**2/l,w=Z*Math.sqrt(1+H),A=Z*Math.sqrt(H);B=w,ee=$-R*w,ne=$+R*w,ce=$-R*A,p=$+R*A}v.push({step:U,at:V,mean:$,lower:ee,upper:ne,lowerMean:ce,upperMean:p,se:B})}return{method:"linear",horizon:m,confidence:e,n:a,sigma:Z,r2:F,params:{slope:S,intercept:G},points:v}}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))),l=t.slice(a-n);let g=0;for(const Z of l)g+=Z;const P=g/n;let S=null,G=null;if(n>1){let Z=0;for(const v of l)Z+=(v-P)**2;S=Math.sqrt(Z/(n-1))*Math.sqrt(1+1/n),G=X(d,n-1)}const F=S===null?null:G*S,E=[];for(let Z=1;Z<=m;Z++)E.push({step:Z,at:r(Z),mean:P,lower:F===null?null:P-F,upper:F===null?null:P+F,se:S});return{method:"movingAverage",horizon:m,confidence:e,n:a,sigma:S===null?null:S,params:{windowLen:n},points:E}}function s(t,a,m,e,d,h,r){if(a<1)return null;let n=Number.isFinite(h.alpha)?ue(h.alpha):null;n===null&&(n=oe(G=>Y(t,G).sse));const l=Y(t,n),g=he(d),P=l.m>0?l.sse/l.m:null,S=[];for(let G=1;G<=m;G++){const F=l.level;let E=null,Z=null,R=null;if(P!==null){const v=[];for(let V=1;V<G;V++)v.push(n);const U=_(P,v,g);R=U.se,E=F-U.margin,Z=F+U.margin}S.push({step:G,at:r(G),mean:F,lower:E,upper:Z,se:R})}return{method:"ses",horizon:m,confidence:e,n:a,sigma:P===null?null:Math.sqrt(P),params:{alpha:n},points:S}}function u(t,a,m,e,d,h,r){if(a<2)return null;let n=Number.isFinite(h.alpha)?ue(h.alpha):null,l=Number.isFinite(h.beta)?ue(h.beta):null;if(n===null||l===null){let E=n===null?.5:n,Z=l===null?.5:l;for(let R=0;R<6;R++)n===null&&(E=oe(v=>L(t,v,Z).sse)),l===null&&(Z=oe(v=>L(t,E,v).sse));n=n===null?E:n,l=l===null?Z:l}const g=L(t,n,l),P=he(d),S=g.m>0?g.sse/g.m:null,G=n*l,F=[];for(let E=1;E<=m;E++){const Z=g.level+E*g.trend;let R=null,v=null,U=null;if(S!==null){const V=[];for(let ee=1;ee<E;ee++)V.push(n+ee*G);const $=_(S,V,P);U=$.se,R=Z-$.margin,v=Z+$.margin}F.push({step:E,at:r(E),mean:Z,lower:R,upper:v,se:U})}return{method:"holt",horizon:m,confidence:e,n:a,sigma:S===null?null:Math.sqrt(S),params:{alpha:n,beta:l},points:F}}function f(t,a,m,e,d,h,r){const n=Math.floor(Number(h.period));if(!(n>=2))return te("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(a<2*n)return null;let l=Number.isFinite(h.alpha)?ue(h.alpha):null,g=Number.isFinite(h.beta)?ue(h.beta):null,P=Number.isFinite(h.gamma)?ue(h.gamma):null;const S=(U,V,$)=>{const ee=Q(t,n,U,V,$);return ee?ee.sse:1/0};if(l===null||g===null||P===null){let U=l===null?.5:l,V=g===null?.5:g,$=P===null?.5:P;for(let ee=0;ee<8;ee++)l===null&&(U=oe(ne=>S(ne,V,$))),g===null&&(V=oe(ne=>S(U,ne,$))),P===null&&($=oe(ne=>S(U,V,ne)));l=l===null?U:l,g=g===null?V:g,P=P===null?$:P}const G=Q(t,n,l,g,P);if(!G)return null;const F=he(d),E=G.count>0?G.sse/G.count:null,Z=l*g,R=P*(1-l),v=[];for(let U=1;U<=m;U++){const V=G.season[(G.phase+U)%n],$=G.level+U*G.trend+V;let ee=null,ne=null,ce=null;if(E!==null){const p=[];for(let H=1;H<U;H++)p.push(l+H*Z+(H%n===0?R:0));const B=_(E,p,F);ce=B.se,ee=$-B.margin,ne=$+B.margin}v.push({step:U,at:r(U),mean:$,lower:ee,upper:ne,se:ce})}return{method:"holtWinters",horizon:m,confidence:e,n:a,sigma:E===null?null:Math.sqrt(E),params:{alpha:l,beta:g,gamma:P,period:n},points:v}}const c={FORECAST_METHODS:x,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 X=me("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return X.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return X.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return X.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return X.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return X.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return X.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return X.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return X.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 te=me("packages/core/src/compute/facet.js");Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return te.facet}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return te.computeBounds}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return te.countInto}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return te.bucketOf}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return te.facetKind}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return te.cardinalityOf}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return te.pickGranularity}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return te.floorTo}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return te.advance}}),Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return te.STRATEGIES}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return te.GRANULARITIES}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return te.DEFAULT_BUCKETS}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return te.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return te.QUANTILE_SAMPLE}});const x=me("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return x.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return x.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return x.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return x.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return x.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 re=me("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return re.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return re.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return re.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return re.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return re.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return re.referenceValue}});const 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 ue=me("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return ue.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return ue.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return ue.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return ue.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return ue.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return ue.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return ue.SKETCH_BOUNDS}});const oe=me("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return oe.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return oe.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return oe.openWindow}});const Y=me("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return Y.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return Y.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return Y.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 Q=me("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Q.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return Q.forecast}})}),Se("packages/worker/src/kernel.js",function(o,me){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return _}}),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,X=fe.OPS,z=fe.CONTROL,te=fe.ERRORS,x=fe.unpackHandle,T=fe.unpackHandles,K=fe.createMaskPool,re=fe.collectTransfers,J=me("packages/core/src/store/columnpack.js"),ue=J.packChunk,oe=J.packedTransfers;let Y=null,L=null,Q=null;async function _(f){if(Y)return Y;if(!L){const c=f||(()=>Promise.resolve(me("packages/core/src/compute/index.js")));L=Promise.resolve().then(c).then(t=>(Y=t,t)).catch(t=>(Q=t,Y=null,null))}return L}function C(f){Y=f,L=f?Promise.resolve(f):null,Q=f?null:Q}function M(f,c,t){const a=new Map;for(const m of f)m&&a.set(m.id,m);return{handle(m){return a.get(m)},count:c,pool:K(),locale:t}}function i(f,c){const{op:t,args:a}=f;if(t===X.COLUMNIZE)return ue(a.schema||[],a.rows||[],a.opts||{});const m=c[t];if(typeof m!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=te.NO_KERNEL,e}switch(t){case X.COLLATE_STRING_RANKS:return m(a.table||[],(a.table||[]).length,a.locale);case X.SORT_COLUMN:return m(x(a.handle),a.order??null,a.opts||{});case X.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 X.EVALUATE_FILTERS:return m(a.filters,M(T(a.handles||[]),a.count,a.locale));case X.COMPACT:return m(a.mask,a.count,void 0);case X.GROUP_BY_COLUMNS:return m(T(a.handles||[]),a.order??null,a.opts||{});case X.TOTAL:return m(x(a.handle),a.indices??null,a.fn);case X.PIVOT:return m(T(a.handles||[]),a.order??null,a.opts||{});case X.FACET:return m(x(a.handle),a.indices??null,a.count,a.opts||{});default:{const e=new Error(`[lattice] unknown worker op \'${t}\'`);throw e.code=te.PROTOCOL,e}}}async function s(f,c={}){if(!f||f.lattice!==he)return null;const{id:t,op:a}=f;if(a===z.CANCEL)return c.cancelled?.add(f.target),null;if(a===z.PING)return{reply:{lattice:he,id:t,ok:!0,result:"pong"},transfer:[]};if(a===X.COLUMNIZE){if(c.cancelled?.has(t))return c.cancelled.delete(t),null;try{const e=ue(f.args.schema||[],f.args.rows||[],f.args.opts||{});return c.cancelled?.has(t)?(c.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:oe(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||te.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}const m=await _(c.loader);if(!m)return{reply:{lattice:he,id:t,ok:!1,error:{code:te.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${Q?Q.message:"module not found"}`}},transfer:[]};if(c.cancelled?.has(t))return c.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(f,m);return c.cancelled?.has(t)?(c.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:re(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||te.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}function u(f,c={}){const t=new Set,a=async m=>{const e=await s(m.data,{loader:c.loader,cancelled:t});e&&f.postMessage(e.reply,e.transfer)};return f.addEventListener("message",a),_(c.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 Lt=Un("packages/modules/webcomponent/index.js"),qi=Lt.GridElementController,Zi=Lt.observedAttributeNames,Yi=Lt.domEventName,Xi=Lt.ATTRIBUTE_CONFIG,Qi=Lt.EVENT_PREFIX,Ji=Lt.createLatticeElements,eo=Lt.defineLatticeElements,to=Lt.ELEMENT_TAGS,no=Lt.createLatticeKPIElement,ro=Lt.createLatticeChartElement,io=Lt.createLatticeKanbanElement,oo=Lt.createLatticeGanttElement,so=Lt.createLatticeLayoutElement,ao=Lt.createLatticeTabsElement,lo=Lt.createLatticeRouterElement,uo=Lt.adoptLatticeStyles,co=Lt.latticeStyleSheets,fo=Lt.VIEWER_EVENTS,ho=Lt.VIEWER_APPLY,mo=Lt.viewerHandlerName,po=Lt.createViewerController,go=Lt.EVENT_NAMES,yo=Lt.dashedName,bo=Lt.createCurrencyType,wo=Lt.createUnitType,vo=Lt.registerUnitSystem,ko=Lt.createStat,So=Lt.createHeadlessGrid,Oo=Lt.duckdbAdapter,jo=Lt.createPushdownSource,Ao=Lt.TAG_NAME,Po=Lt.createLatticeGridElement,Co=Lt.defineLatticeGrid;var Eo=Lt.default;export{Xi as ATTRIBUTE_CONFIG,to as ELEMENT_TAGS,go as EVENT_NAMES,Qi as EVENT_PREFIX,qi as GridElementController,Ao as TAG_NAME,ho as VIEWER_APPLY,fo as VIEWER_EVENTS,uo as adoptLatticeStyles,bo as createCurrencyType,So as createHeadlessGrid,ro as createLatticeChartElement,Ji as createLatticeElements,oo as createLatticeGanttElement,Po as createLatticeGridElement,no as createLatticeKPIElement,io as createLatticeKanbanElement,so as createLatticeLayoutElement,lo as createLatticeRouterElement,ao as createLatticeTabsElement,jo as createPushdownSource,ko as createStat,wo as createUnitType,po as createViewerController,yo as dashedName,Eo as default,eo as defineLatticeElements,Co as defineLatticeGrid,Yi as domEventName,Oo as duckdbAdapter,co as latticeStyleSheets,Zi as observedAttributeNames,vo as registerUnitSystem,mo as viewerHandlerName};
|
|
59
59
|
|
|
60
60
|
//# sourceMappingURL=webcomponent.esm.min.js.map
|