@toclocoinc/lattice-grid 1.71.1 → 1.71.3

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.
Files changed (195) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +1 -1
  3. package/angular/package.json +1 -1
  4. package/docs/API.html +42 -8
  5. package/docs/api/adapters.html +1 -1
  6. package/docs/api/ai.html +1 -1
  7. package/docs/api/alarms.html +1 -1
  8. package/docs/api/charts.html +39 -5
  9. package/docs/api/data-router.html +1 -1
  10. package/docs/api/gantt.html +1 -1
  11. package/docs/api/grid.html +2 -2
  12. package/docs/api/index.html +2 -2
  13. package/docs/api/kanban.html +1 -1
  14. package/docs/api/kpi.html +1 -1
  15. package/docs/api/layout.html +1 -1
  16. package/docs/api/mock-socket.html +1 -1
  17. package/docs/api/tabs.html +1 -1
  18. package/docs/api/types.html +1 -1
  19. package/docs/api-detail.html +4 -4
  20. package/docs/warnings.json +13 -2
  21. package/lattice-grid.d.ts +31 -7
  22. package/lattice-grid.esm.min.js +3 -3
  23. package/lattice-grid.min.cjs +3 -3
  24. package/lattice-grid.min.js +3 -3
  25. package/modules/ai.d.ts +1 -1
  26. package/modules/ai.esm.min.js +2 -2
  27. package/modules/ai.min.cjs +2 -2
  28. package/modules/ai.min.js +2 -2
  29. package/modules/alarms.d.ts +1 -1
  30. package/modules/alarms.esm.min.js +2 -2
  31. package/modules/alarms.min.cjs +2 -2
  32. package/modules/alarms.min.js +2 -2
  33. package/modules/angular.d.ts +1 -1
  34. package/modules/angular.esm.min.js +2 -2
  35. package/modules/angular.min.cjs +2 -2
  36. package/modules/angular.min.js +2 -2
  37. package/modules/chart-alluvial.d.ts +1 -1
  38. package/modules/chart-alluvial.esm.min.js +1 -1
  39. package/modules/chart-alluvial.min.cjs +1 -1
  40. package/modules/chart-alluvial.min.js +1 -1
  41. package/modules/chart-arc.d.ts +1 -1
  42. package/modules/chart-arc.esm.min.js +1 -1
  43. package/modules/chart-arc.min.cjs +1 -1
  44. package/modules/chart-arc.min.js +1 -1
  45. package/modules/chart-bubblemap.d.ts +1 -1
  46. package/modules/chart-bubblemap.esm.min.js +1 -1
  47. package/modules/chart-bubblemap.min.cjs +1 -1
  48. package/modules/chart-bubblemap.min.js +1 -1
  49. package/modules/chart-bump.d.ts +1 -1
  50. package/modules/chart-bump.esm.min.js +1 -1
  51. package/modules/chart-bump.min.cjs +1 -1
  52. package/modules/chart-bump.min.js +1 -1
  53. package/modules/chart-calendar.d.ts +1 -1
  54. package/modules/chart-calendar.esm.min.js +1 -1
  55. package/modules/chart-calendar.min.cjs +1 -1
  56. package/modules/chart-calendar.min.js +1 -1
  57. package/modules/chart-decomposition.d.ts +1 -1
  58. package/modules/chart-decomposition.esm.min.js +1 -1
  59. package/modules/chart-decomposition.min.cjs +1 -1
  60. package/modules/chart-decomposition.min.js +1 -1
  61. package/modules/chart-diverging.d.ts +1 -1
  62. package/modules/chart-diverging.esm.min.js +1 -1
  63. package/modules/chart-diverging.min.cjs +1 -1
  64. package/modules/chart-diverging.min.js +1 -1
  65. package/modules/chart-dumbbell.d.ts +1 -1
  66. package/modules/chart-dumbbell.esm.min.js +1 -1
  67. package/modules/chart-dumbbell.min.cjs +1 -1
  68. package/modules/chart-dumbbell.min.js +1 -1
  69. package/modules/chart-fan.d.ts +1 -1
  70. package/modules/chart-fan.esm.min.js +1 -1
  71. package/modules/chart-fan.min.cjs +1 -1
  72. package/modules/chart-fan.min.js +1 -1
  73. package/modules/chart-hexbin.d.ts +1 -1
  74. package/modules/chart-hexbin.esm.min.js +1 -1
  75. package/modules/chart-hexbin.min.cjs +1 -1
  76. package/modules/chart-hexbin.min.js +1 -1
  77. package/modules/chart-hexmap.d.ts +1 -1
  78. package/modules/chart-hexmap.esm.min.js +1 -1
  79. package/modules/chart-hexmap.min.cjs +1 -1
  80. package/modules/chart-hexmap.min.js +1 -1
  81. package/modules/chart-icicle.d.ts +1 -1
  82. package/modules/chart-icicle.esm.min.js +1 -1
  83. package/modules/chart-icicle.min.cjs +1 -1
  84. package/modules/chart-icicle.min.js +1 -1
  85. package/modules/chart-markermap.d.ts +1 -1
  86. package/modules/chart-markermap.esm.min.js +1 -1
  87. package/modules/chart-markermap.min.cjs +1 -1
  88. package/modules/chart-markermap.min.js +1 -1
  89. package/modules/chart-parallel.d.ts +1 -1
  90. package/modules/chart-parallel.esm.min.js +1 -1
  91. package/modules/chart-parallel.min.cjs +1 -1
  92. package/modules/chart-parallel.min.js +1 -1
  93. package/modules/chart-ridgeline.d.ts +1 -1
  94. package/modules/chart-ridgeline.esm.min.js +1 -1
  95. package/modules/chart-ridgeline.min.cjs +1 -1
  96. package/modules/chart-ridgeline.min.js +1 -1
  97. package/modules/chart-roc.d.ts +1 -1
  98. package/modules/chart-roc.esm.min.js +1 -1
  99. package/modules/chart-roc.min.cjs +1 -1
  100. package/modules/chart-roc.min.js +1 -1
  101. package/modules/chart-slope.d.ts +1 -1
  102. package/modules/chart-slope.esm.min.js +1 -1
  103. package/modules/chart-slope.min.cjs +1 -1
  104. package/modules/chart-slope.min.js +1 -1
  105. package/modules/chart-splom.d.ts +1 -1
  106. package/modules/chart-splom.esm.min.js +1 -1
  107. package/modules/chart-splom.min.cjs +1 -1
  108. package/modules/chart-splom.min.js +1 -1
  109. package/modules/chart-waffle.d.ts +1 -1
  110. package/modules/chart-waffle.esm.min.js +1 -1
  111. package/modules/chart-waffle.min.cjs +1 -1
  112. package/modules/chart-waffle.min.js +1 -1
  113. package/modules/charts.d.ts +1 -1
  114. package/modules/charts.esm.min.js +13 -9
  115. package/modules/charts.esm.min.js.map +2 -2
  116. package/modules/charts.min.cjs +141 -137
  117. package/modules/charts.min.js +141 -137
  118. package/modules/charts.min.js.map +2 -2
  119. package/modules/data-router.d.ts +1 -1
  120. package/modules/data-router.esm.min.js +2 -2
  121. package/modules/data-router.min.cjs +2 -2
  122. package/modules/data-router.min.js +2 -2
  123. package/modules/devtools.d.ts +1 -1
  124. package/modules/devtools.esm.min.js +1 -1
  125. package/modules/devtools.min.cjs +1 -1
  126. package/modules/devtools.min.js +1 -1
  127. package/modules/dhtmlx-compat.d.ts +1 -1
  128. package/modules/dhtmlx-compat.esm.min.js +2 -2
  129. package/modules/dhtmlx-compat.min.cjs +2 -2
  130. package/modules/dhtmlx-compat.min.js +2 -2
  131. package/modules/gantt.d.ts +1 -1
  132. package/modules/gantt.esm.min.js +2 -2
  133. package/modules/gantt.min.cjs +2 -2
  134. package/modules/gantt.min.js +2 -2
  135. package/modules/geo-europe-nuts.d.ts +1 -1
  136. package/modules/geo-europe-nuts.esm.min.js +1 -1
  137. package/modules/geo-europe-nuts.min.cjs +1 -1
  138. package/modules/geo-europe-nuts.min.js +1 -1
  139. package/modules/geo-uk.d.ts +1 -1
  140. package/modules/geo-uk.esm.min.js +1 -1
  141. package/modules/geo-uk.min.cjs +1 -1
  142. package/modules/geo-uk.min.js +1 -1
  143. package/modules/geo-us-states.d.ts +1 -1
  144. package/modules/geo-us-states.esm.min.js +1 -1
  145. package/modules/geo-us-states.min.cjs +1 -1
  146. package/modules/geo-us-states.min.js +1 -1
  147. package/modules/geo-world-110m.d.ts +1 -1
  148. package/modules/geo-world-110m.esm.min.js +1 -1
  149. package/modules/geo-world-110m.min.cjs +1 -1
  150. package/modules/geo-world-110m.min.js +1 -1
  151. package/modules/geo-world-50m.d.ts +1 -1
  152. package/modules/geo-world-50m.esm.min.js +1 -1
  153. package/modules/geo-world-50m.min.cjs +1 -1
  154. package/modules/geo-world-50m.min.js +1 -1
  155. package/modules/htmx.d.ts +1 -1
  156. package/modules/htmx.esm.min.js +3 -3
  157. package/modules/htmx.min.cjs +3 -3
  158. package/modules/htmx.min.js +3 -3
  159. package/modules/kanban.d.ts +1 -1
  160. package/modules/kanban.esm.min.js +2 -2
  161. package/modules/kanban.min.cjs +2 -2
  162. package/modules/kanban.min.js +2 -2
  163. package/modules/kpi.d.ts +1 -1
  164. package/modules/kpi.esm.min.js +2 -2
  165. package/modules/kpi.min.cjs +2 -2
  166. package/modules/kpi.min.js +2 -2
  167. package/modules/layout.d.ts +1 -1
  168. package/modules/layout.esm.min.js +2 -2
  169. package/modules/layout.min.cjs +2 -2
  170. package/modules/layout.min.js +2 -2
  171. package/modules/mock-socket.d.ts +1 -1
  172. package/modules/mock-socket.esm.min.js +1 -1
  173. package/modules/mock-socket.min.cjs +1 -1
  174. package/modules/mock-socket.min.js +1 -1
  175. package/modules/react.d.ts +1 -1
  176. package/modules/react.esm.min.js +2 -2
  177. package/modules/react.min.cjs +2 -2
  178. package/modules/react.min.js +2 -2
  179. package/modules/svelte.d.ts +1 -1
  180. package/modules/svelte.esm.min.js +2 -2
  181. package/modules/svelte.min.cjs +2 -2
  182. package/modules/svelte.min.js +2 -2
  183. package/modules/tabs.d.ts +1 -1
  184. package/modules/tabs.esm.min.js +2 -2
  185. package/modules/tabs.min.cjs +2 -2
  186. package/modules/tabs.min.js +2 -2
  187. package/modules/vue.d.ts +1 -1
  188. package/modules/vue.esm.min.js +2 -2
  189. package/modules/vue.min.cjs +2 -2
  190. package/modules/vue.min.js +2 -2
  191. package/modules/webcomponent.d.ts +1 -1
  192. package/modules/webcomponent.esm.min.js +3 -3
  193. package/modules/webcomponent.min.cjs +3 -3
  194. package/modules/webcomponent.min.js +3 -3
  195. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * Lattice Grid 1.71.1, core + DOM renderer
2
+ * Lattice Grid 1.71.3, core + DOM renderer
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
6
- var nr=Object.create(null),rr=Object.create(null);function ke(e,V){nr[e]=V}function Bn(e){var V=rr[e];if(V)return V;var _=Object.create(null);rr[e]=_;var R=nr[e];if(!R)throw new Error("[lattice] missing module: "+e);return R(_,Bn),_}ke("packages/core/src/internal/util.js",function(e,V){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return h}}),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 m}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return ne}});const _="1.71.1";async function R(){return _}const $="1.71.1",L=new Set,W=2e3;function Z(re){if(L.add(re),L.size>W){const oe=L.values().next().value;oe!==void 0&&L.delete(oe)}}const H=[],U=500;function z(re,oe,ie){H.push({key:re,level:oe,message:ie.map(te=>typeof te=="string"?te:F(te)).join(" "),at:Date.now()}),H.length>U&&H.shift()}function F(re){if(re instanceof Error)return re.message;try{return JSON.stringify(re)}catch{return String(re)}}function k(){return H.map(re=>({...re}))}function O(re,...oe){L.has(re)||(Z(re),z(re,"warn",oe),console.warn("[lattice]",...oe))}function y(re,...oe){L.has(re)||(Z(re),z(re,"info",oe),console.info("[lattice]",...oe))}function d(){L.clear(),H.length=0}function c(re,oe){const ie=new Error(`[lattice] ${re}`);throw oe!==void 0&&(ie.cause=oe),ie}function r(re,oe){re||c(oe)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function n(re){return re!==null&&typeof re=="object"&&!Array.isArray(re)}function i(re){return typeof re=="function"}function s(re){return re==null}function l(re){return re==null||re===""}function u(re){return typeof re!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(re))?!0:!!(re.prototype&&Object.getOwnPropertyNames(re.prototype).length>1)}const f=new Map;function h(re){let oe=f.get(re);if(oe)return oe;if(!re.includes("."))oe=ie=>ie?.[re];else{const ie=re.split("."),te=ie.length;oe=ce=>{let ue=ce;for(let ae=0;ae<te;ae++){if(ue==null)return;ue=ue[ie[ae]]}return ue}}return f.set(re,oe),oe}const g=new Map;function b(re){let oe=g.get(re);if(oe)return oe;if(!re.includes("."))oe=(ie,te)=>{ie!=null&&(ie[re]=te)};else{const ie=re.split("."),te=ie.length-1;oe=(ce,ue)=>{let ae=ce;for(let pe=0;pe<te;pe++){if(ae==null)return;const he=ie[pe];ae[he]==null&&(ae[he]={}),ae=ae[he]}ae!=null&&(ae[ie[te]]=ue)}}return g.set(re,oe),oe}function p(re,oe){return h(oe)(re)}function m(re,oe,ie){b(oe)(re,ie)}function w(re){return re?(re.includes(".")?re.slice(re.lastIndexOf(".")+1):re).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(/^./,ie=>ie.toUpperCase()):""}const v={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function a(re){const oe=re==null?"":String(re);return/[&<>"']/.test(oe)?oe.replace(/[&<>"']/g,ie=>v[ie]):oe}function o(re){return String(re).replace(/\w\S*/g,oe=>oe[0].toUpperCase()+oe.slice(1).toLowerCase())}function S(re,oe,ie){if(re!==void 0)return re===!0?{enabled:!0,...ie}:re===!1?{enabled:!1}:n(re)?re:{[oe]:re,enabled:!0}}function E(re){return re==null?[]:Array.isArray(re)?re:[re]}const A=Object.freeze(new Set(["__proto__","constructor","prototype"]));function M(re,oe){if(!n(re))return n(oe)?{...oe}:oe;if(!n(oe))return oe===void 0?re:oe;const ie={...re};for(const te of Object.keys(oe)){if(A.has(te))continue;const ce=oe[te];ce!==void 0&&(ie[te]=n(ce)&&n(ie[te])?M(ie[te],ce):ce)}return ie}function C(re,oe){if(!n(re)||!n(oe)||re===oe)return oe;const ie=Object.create(Object.getPrototypeOf(re));return Object.assign(ie,re,oe),ie}class P{#e;#t=new Map;#n;constructor(oe=256,ie=null){this.#e=oe,this.#n=ie}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 ie=this.#t;if(!ie.has(oe))return;const te=ie.get(oe);return ie.delete(oe),ie.set(oe,te),te}peek(oe){return this.#t.get(oe)}set(oe,ie){const te=this.#t;return te.has(oe)&&te.delete(oe),te.set(oe,ie),this.#r(),ie}delete(oe){const ie=this.#t.get(oe);return this.#t.delete(oe)&&this.#n&&this.#n(ie,oe),ie}clear(){if(this.#n)for(const[oe,ie]of this.#t)this.#n(ie,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 ie=oe.keys().next().value,te=oe.get(ie);oe.delete(ie),this.#n&&this.#n(te,ie)}}}const x=new Map;function K(re,oe){const ie=`${re||""}|${oe?JSON.stringify(oe):""}`;let te=x.get(ie);return te||(te=new Intl.Collator(re||void 0,{numeric:!0,sensitivity:"variant",...oe}),x.set(ie,te)),te}function I(re,oe){if(re===oe)return 0;if(re==null)return 1;if(oe==null)return-1;if(typeof re=="number"&&typeof oe=="number")return Number.isNaN(re)?Number.isNaN(oe)?0:1:Number.isNaN(oe)||re<oe?-1:re>oe?1:0;const ie=String(re),te=String(oe);return ie<te?-1:ie>te?1:0}function D(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const j=typeof requestAnimationFrame=="function";function T(re){return j?requestAnimationFrame(re):setTimeout(()=>re(D()),16)}function B(re){re!=null&&(j?cancelAnimationFrame(re):clearTimeout(re))}function q(re){let oe=null,ie=null;const te=()=>{oe=null;const ue=ie;ie=null,re(...ue||[])},ce=(...ue)=>{ie=ue,oe===null&&(oe=T(te))};return ce.cancel=()=>{B(oe),oe=null,ie=null},ce.flush=()=>{oe!==null&&(B(oe),te())},ce}function X(re,oe){let ie=null,te=null;const ce=()=>{if(ie=null,te===null)return;const pe=te;te=null,re(...pe),ue()},ue=()=>{ie=setTimeout(ce,oe),typeof ie?.unref=="function"&&ie.unref()},ae=(...pe)=>{ie===null?(re(...pe),ue()):(te=pe,clearTimeout(ie),ue())};return ae.flush=()=>{if(ie!==null&&clearTimeout(ie),ie=null,te===null)return;const pe=te;te=null,re(...pe)},ae.cancel=()=>{ie!==null&&clearTimeout(ie),ie=null,te=null},ae.pending=()=>ie!==null||te!==null,ae}function Q(re,oe=50){return typeof requestIdleCallback=="function"?requestIdleCallback(re,{timeout:oe}):setTimeout(()=>re({timeRemaining:()=>0,didTimeout:!0}),1)}let J=0;function ne(re="l"){return`${re}${(++J).toString(36)}`}}),ke("packages/core/src/formatting/rules.js",function(e,V){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return L}}),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 z}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return O}}),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 m}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return S}});const _=V("packages/core/src/internal/util.js"),R=_.isFunction,$=_.warnOnce,L=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 H(E,A){const M=Number(E),C=Number(A);if(E!==null&&E!==""&&A!==null&&A!==""&&Number.isFinite(M)&&Number.isFinite(C))return M<C?-1:M>C?1:0;const x=String(E??"").toLowerCase(),K=String(A??"").toLowerCase();return x<K?-1:x>K?1:0}function U(E){return E==null||E===""}function z(E,A){if(!A||typeof A!="object")return!1;const{op:M}=A,C=A.value,P=A.value2;switch(M){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(M){case"eq":return H(E,C)===0;case"ne":return H(E,C)!==0;case"gt":return H(E,C)>0;case"gte":return H(E,C)>=0;case"lt":return H(E,C)<0;case"lte":return H(E,C)<=0;case"between":return H(E,C)>=0&&H(E,P)<=0;case"outside":return H(E,C)<0||H(E,P)>0;case"contains":return String(E).toLowerCase().includes(String(C??"").toLowerCase());case"notContains":return!String(E).toLowerCase().includes(String(C??"").toLowerCase());case"startsWith":return String(E).toLowerCase().startsWith(String(C??"").toLowerCase());case"endsWith":return String(E).toLowerCase().endsWith(String(C??"").toLowerCase());default:return!1}}function F(E,A,M){const C=q=>{const X=String(q).replace("#",""),Q=X.length===3?X.split("").map(J=>J+J).join(""):X;return[0,2,4].map(J=>parseInt(Q.slice(J,J+2),16)||0)},[P,x,K]=C(E),[I,D,j]=C(A),T=Math.max(0,Math.min(1,M)),B=(q,X)=>Math.round(q+(X-q)*T);return`#${[B(P,I),B(x,D),B(K,j)].map(q=>q.toString(16).padStart(2,"0")).join("")}`}function k(E){const A=[];for(const I of E||[]){if(I==null||I==="")continue;const D=I instanceof Date?I.getTime():Number(I);Number.isFinite(D)&&A.push(D)}if(!A.length)return null;A.sort((I,D)=>I-D);let M=0,C=0,P=0;for(const I of A){M++;const D=I-C;C+=D/M,P+=D*(I-C)}const x=O(A,.25),K=O(A,.75);return{n:A.length,min:A[0],max:A[A.length-1],mean:C,stddev:A.length>1?Math.sqrt(P/(A.length-1)):0,median:O(A,.5),q1:x,q3:K,iqr:K-x,sorted:A}}function O(E,A){if(!E.length)return 0;const M=(E.length-1)*Math.max(0,Math.min(1,A)),C=Math.floor(M),P=Math.ceil(M);return C===P?E[C]:E[C]+(M-C)*(E[P]-E[C])}function y(E){for(const A of Array.isArray(E)?E:[])if(!(!A||typeof A!="object")&&(A.when&&W.includes(A.when.op)||A.scale&&A.scale.from||A.dataBar&&!(Number.isFinite(Number(A.dataBar.min))&&Number.isFinite(Number(A.dataBar.max)))||A.iconSet&&!Array.isArray(A.iconSet.thresholds)))return!0;return!1}function d(E,A){const M=Number(E.value),C=P=>O(A.sorted,P);switch(E.op){case"topPercent":{const P=c(M,10);return{op:"gte",value:C(1-P)}}case"bottomPercent":{const P=c(M,10);return{op:"lte",value:C(P)}}case"topN":{const P=Math.max(1,Math.floor(M)||1),x=Math.max(0,A.sorted.length-P);return{op:"gte",value:A.sorted[x]}}case"bottomN":{const P=Math.max(1,Math.floor(M)||1),x=Math.min(A.sorted.length-1,P-1);return{op:"lte",value:A.sorted[x]}}case"aboveMean":return{op:"gt",value:A.mean};case"belowMean":return{op:"lt",value:A.mean};case"aboveMedian":return{op:"gt",value:A.median};case"belowMedian":return{op:"lt",value:A.median};case"zAbove":return A.stddev?{op:"gte",value:A.mean+(Number.isFinite(M)?M:2)*A.stddev}:null;case"zBelow":return A.stddev?{op:"lte",value:A.mean-(Number.isFinite(M)?M:2)*A.stddev}:null;case"outlier":{const P=(Number.isFinite(M)&&M>0?M:1.5)*A.iqr;return A.iqr?{op:"outside",value:A.q1-P,value2:A.q3+P}:null}default:return null}}function c(E,A){const M=Number.isFinite(E)?E:A,C=M>1?M/100:M;return Math.max(0,Math.min(1,C))}function r(E,A){if(E.from==="minmax")return{...E,min:A.min,max:A.max};if(E.from==="quantile")return{...E,min:O(A.sorted,c(Number(E.low),5)),max:O(A.sorted,c(Number(E.high),95))};if(E.from==="stddev"){const M=Number.isFinite(Number(E.deviations))?Number(E.deviations):2;return{...E,min:A.mean-M*A.stddev,max:A.mean+M*A.stddev}}return E}function t(E,A){const M=Array.isArray(E)?E:[];return!A||!A.n?M.map(C=>C&&y([C])?{...C,enabled:!1}:C):M.map(C=>{if(!C||typeof C!="object")return C;if(C.scale&&C.scale.from)return{...C,scale:r(C.scale,A)};if(C.dataBar)return{...C,dataBar:n(C.dataBar,A)};if(C.iconSet)return{...C,iconSet:i(C.iconSet,A)};if(!C.when||!W.includes(C.when.op))return C;const P=d(C.when,A);return P?{...C,when:P}:{...C,enabled:!1}})}function n(E,A){const M=Number.isFinite(Number(E.min))?Number(E.min):void 0,C=Number.isFinite(Number(E.max))?Number(E.max):void 0;if(M!==void 0&&C!==void 0)return{...E,min:M,max:C};if(E.from==="quantile")return{...E,min:M??O(A.sorted,c(Number(E.low),5)),max:C??O(A.sorted,c(Number(E.high),95))};if(E.from==="stddev"){const P=Number.isFinite(Number(E.deviations))?Number(E.deviations):2;return{...E,min:M??A.mean-P*A.stddev,max:C??A.mean+P*A.stddev}}return{...E,min:M??A.min,max:C??A.max}}function i(E,A){if(Array.isArray(E.thresholds))return E;const M=s(E),C=[];for(let P=1;P<M;P++)C.push(O(A.sorted,P/M));return{...E,thresholds:C}}function s(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 A=p[E.set];return A?A.length:3}function l(E){return`url("data:image/svg+xml,${encodeURIComponent(E)}")`}function u(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 f(E,A){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${A==="up"?"8,2 14,13 2,13":A==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${E}"/></svg>`}function h(E,A){const M="M8 1l1.9 3.9 4.3.6-3.1 3 .7 4.3L8 13.8 4.2 15.8l.7-4.3-3.1-3 4.3-.6z";let C=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${A*16} 16">`;for(let P=0;P<A;P++){const x=P<E?"#f5a623":"#d0d0d0";C+=`<path transform="translate(${P*16},0)" d="${M}" fill="${x}"/>`}return`${C}</svg>`}const g=Object.freeze([f("#c0392b","down"),f("#e0a800","right"),f("#2e7d32","up")]),b=Object.freeze([u("#d13438"),u("#f5a623"),u("#2e9e44")]),p=Object.freeze({arrows:g,trafficLights:b,ratings:Object.freeze([1,2,3,4,5].map(E=>h(E,5)))}),m=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(C=>/^\s*(url\(|data:|<)/.test(String(C))&&String(C).trim().startsWith("<")?l(String(C)):String(C));const A=E.set||"arrows";if(A==="ratings"){const C=s(E),P=[];for(let x=1;x<=C;x++)P.push(l(h(x,C)));return P}const M=p[A];return M?M.map(l):($(`iconSet:${A}`,`unknown icon set '${A}'; falling back to arrows.`),g.map(l))}function v(E){const A=Number(E.min),C=Number(E.max)-A,P=E.colour||E.color||"#5b9bd5",x=E.negativeColour||E.negativeColor||"#d13438",K=E.direction==="rtl"?"left":"right",I=j=>Math.max(0,Math.min(1,(j-A)/C))*100,D=C?Math.max(0,Math.min(100,(0-A)/C*100)):0;return j=>{if(U(j))return null;const T=Number(j);if(!Number.isFinite(T)||!C)return null;const B=I(T),q=Math.min(B,D),X=Math.max(B,D),Q=T>=0?P:x;return{backgroundImage:`linear-gradient(to ${K}, transparent ${q}%, ${Q} ${q}%, ${Q} ${X}%, transparent ${X}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function a(E){const A=w(E),M=E.reverse?[...A].reverse():A,C=(Array.isArray(E.thresholds)?E.thresholds:[]).map(Number).filter(Number.isFinite),P=Number.isFinite(Number(E.size))?Number(E.size):16,x=E.set==="ratings"?P*s(E):P;return K=>{if(U(K))return null;const I=Number(K);if(!Number.isFinite(I))return null;let D=0;for(const T of C)I>=T&&D++;const j=M[Math.min(D,M.length-1)];return j?{backgroundImage:j,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${x}px ${P}px`,paddingLeft:`${x+4}px`}:null}}function o(E){const A=Array.isArray(E.colours)&&E.colours.length>=2?E.colours:["#f8f9fa","#1a6bc7"],M=Number(E.min),C=Number(E.max),P=C-M,x=A.length-1,K=[];for(let D=0;D<=x;D++)K.push(x?D/x:0);const I=Number(E.mid);if(E.mid!==void 0&&E.mid!==null)if(A.length%2===0)$("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${A.length} were given, so "mid" was ignored.`);else if(Number.isFinite(I)&&P&&I>Math.min(M,C)&&I<Math.max(M,C)){const D=x/2,j=Math.max(0,Math.min(1,(I-M)/P));for(let T=0;T<=x;T++)K[T]=T<=D?D?T/D*j:j:j+(T-D)/(x-D)*(1-j)}else Number.isFinite(I)&&$("formatting.scale.mid.range",`a scale's "mid" (${I}) is outside its min..max range, so it was ignored.`);return D=>{const j=Number(D);if(!Number.isFinite(j)||!P)return null;const T=Math.max(0,Math.min(1,(j-M)/P));let B=0;for(;B<x-1&&T>K[B+1];)B++;const q=K[B+1]-K[B],X=q>0?(T-K[B])/q:0;return{background:F(A[B],A[B+1],Math.max(0,Math.min(1,X)))}}}function S(E,A=null){const M=y(E)?t(E,A):E,C=(Array.isArray(M)?M:[]).filter(x=>x&&typeof x=="object");if(!C.length)return()=>null;const P=C.map(x=>x.scale?{scale:o(x.scale),enabled:x.enabled!==!1}:x.dataBar?{scale:v(x.dataBar),enabled:x.enabled!==!1}:x.iconSet?{scale:a(x.iconSet),enabled:x.enabled!==!1}:{when:x.when,style:x.style,stop:x.stopIfTrue!==!1,enabled:x.enabled!==!1});return x=>{const K=x?x.value:void 0;let I=null;for(const D of P){if(!D.enabled)continue;if(D.scale){const T=D.scale(K);T&&(I={...I||{},...T});continue}if(!z(K,D.when))continue;const j=R(D.style)?D.style(x):D.style;if(j&&(I={...I||{},...j}),D.stop)break}return I}}}),ke("packages/core/src/formula/parse.js",function(e,V){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return n}});const _="num",R="str",$="ref",L="name",W="op",Z="end",H=["<=",">=","<>","!="],U="+-*/^%(),<>=";class z extends Error{constructor(s,l){super(s),this.name="FormulaError",this.at=l}}function F(i){const s=[];let l=0;for(;l<i.length;){const u=i[l];if(u===" "||u===" "||u===`
6
+ var nr=Object.create(null),rr=Object.create(null);function ke(e,V){nr[e]=V}function Bn(e){var V=rr[e];if(V)return V;var _=Object.create(null);rr[e]=_;var R=nr[e];if(!R)throw new Error("[lattice] missing module: "+e);return R(_,Bn),_}ke("packages/core/src/internal/util.js",function(e,V){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return h}}),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 m}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return ne}});const _="1.71.3";async function R(){return _}const $="1.71.3",L=new Set,W=2e3;function Z(re){if(L.add(re),L.size>W){const oe=L.values().next().value;oe!==void 0&&L.delete(oe)}}const H=[],U=500;function z(re,oe,ie){H.push({key:re,level:oe,message:ie.map(te=>typeof te=="string"?te:F(te)).join(" "),at:Date.now()}),H.length>U&&H.shift()}function F(re){if(re instanceof Error)return re.message;try{return JSON.stringify(re)}catch{return String(re)}}function k(){return H.map(re=>({...re}))}function O(re,...oe){L.has(re)||(Z(re),z(re,"warn",oe),console.warn("[lattice]",...oe))}function y(re,...oe){L.has(re)||(Z(re),z(re,"info",oe),console.info("[lattice]",...oe))}function d(){L.clear(),H.length=0}function c(re,oe){const ie=new Error(`[lattice] ${re}`);throw oe!==void 0&&(ie.cause=oe),ie}function r(re,oe){re||c(oe)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function n(re){return re!==null&&typeof re=="object"&&!Array.isArray(re)}function i(re){return typeof re=="function"}function s(re){return re==null}function l(re){return re==null||re===""}function u(re){return typeof re!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(re))?!0:!!(re.prototype&&Object.getOwnPropertyNames(re.prototype).length>1)}const f=new Map;function h(re){let oe=f.get(re);if(oe)return oe;if(!re.includes("."))oe=ie=>ie?.[re];else{const ie=re.split("."),te=ie.length;oe=ce=>{let ue=ce;for(let ae=0;ae<te;ae++){if(ue==null)return;ue=ue[ie[ae]]}return ue}}return f.set(re,oe),oe}const g=new Map;function b(re){let oe=g.get(re);if(oe)return oe;if(!re.includes("."))oe=(ie,te)=>{ie!=null&&(ie[re]=te)};else{const ie=re.split("."),te=ie.length-1;oe=(ce,ue)=>{let ae=ce;for(let pe=0;pe<te;pe++){if(ae==null)return;const he=ie[pe];ae[he]==null&&(ae[he]={}),ae=ae[he]}ae!=null&&(ae[ie[te]]=ue)}}return g.set(re,oe),oe}function p(re,oe){return h(oe)(re)}function m(re,oe,ie){b(oe)(re,ie)}function w(re){return re?(re.includes(".")?re.slice(re.lastIndexOf(".")+1):re).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(/^./,ie=>ie.toUpperCase()):""}const v={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function a(re){const oe=re==null?"":String(re);return/[&<>"']/.test(oe)?oe.replace(/[&<>"']/g,ie=>v[ie]):oe}function o(re){return String(re).replace(/\w\S*/g,oe=>oe[0].toUpperCase()+oe.slice(1).toLowerCase())}function S(re,oe,ie){if(re!==void 0)return re===!0?{enabled:!0,...ie}:re===!1?{enabled:!1}:n(re)?re:{[oe]:re,enabled:!0}}function E(re){return re==null?[]:Array.isArray(re)?re:[re]}const A=Object.freeze(new Set(["__proto__","constructor","prototype"]));function M(re,oe){if(!n(re))return n(oe)?{...oe}:oe;if(!n(oe))return oe===void 0?re:oe;const ie={...re};for(const te of Object.keys(oe)){if(A.has(te))continue;const ce=oe[te];ce!==void 0&&(ie[te]=n(ce)&&n(ie[te])?M(ie[te],ce):ce)}return ie}function C(re,oe){if(!n(re)||!n(oe)||re===oe)return oe;const ie=Object.create(Object.getPrototypeOf(re));return Object.assign(ie,re,oe),ie}class P{#e;#t=new Map;#n;constructor(oe=256,ie=null){this.#e=oe,this.#n=ie}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 ie=this.#t;if(!ie.has(oe))return;const te=ie.get(oe);return ie.delete(oe),ie.set(oe,te),te}peek(oe){return this.#t.get(oe)}set(oe,ie){const te=this.#t;return te.has(oe)&&te.delete(oe),te.set(oe,ie),this.#r(),ie}delete(oe){const ie=this.#t.get(oe);return this.#t.delete(oe)&&this.#n&&this.#n(ie,oe),ie}clear(){if(this.#n)for(const[oe,ie]of this.#t)this.#n(ie,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 ie=oe.keys().next().value,te=oe.get(ie);oe.delete(ie),this.#n&&this.#n(te,ie)}}}const x=new Map;function K(re,oe){const ie=`${re||""}|${oe?JSON.stringify(oe):""}`;let te=x.get(ie);return te||(te=new Intl.Collator(re||void 0,{numeric:!0,sensitivity:"variant",...oe}),x.set(ie,te)),te}function I(re,oe){if(re===oe)return 0;if(re==null)return 1;if(oe==null)return-1;if(typeof re=="number"&&typeof oe=="number")return Number.isNaN(re)?Number.isNaN(oe)?0:1:Number.isNaN(oe)||re<oe?-1:re>oe?1:0;const ie=String(re),te=String(oe);return ie<te?-1:ie>te?1:0}function D(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const j=typeof requestAnimationFrame=="function";function T(re){return j?requestAnimationFrame(re):setTimeout(()=>re(D()),16)}function B(re){re!=null&&(j?cancelAnimationFrame(re):clearTimeout(re))}function q(re){let oe=null,ie=null;const te=()=>{oe=null;const ue=ie;ie=null,re(...ue||[])},ce=(...ue)=>{ie=ue,oe===null&&(oe=T(te))};return ce.cancel=()=>{B(oe),oe=null,ie=null},ce.flush=()=>{oe!==null&&(B(oe),te())},ce}function X(re,oe){let ie=null,te=null;const ce=()=>{if(ie=null,te===null)return;const pe=te;te=null,re(...pe),ue()},ue=()=>{ie=setTimeout(ce,oe),typeof ie?.unref=="function"&&ie.unref()},ae=(...pe)=>{ie===null?(re(...pe),ue()):(te=pe,clearTimeout(ie),ue())};return ae.flush=()=>{if(ie!==null&&clearTimeout(ie),ie=null,te===null)return;const pe=te;te=null,re(...pe)},ae.cancel=()=>{ie!==null&&clearTimeout(ie),ie=null,te=null},ae.pending=()=>ie!==null||te!==null,ae}function Q(re,oe=50){return typeof requestIdleCallback=="function"?requestIdleCallback(re,{timeout:oe}):setTimeout(()=>re({timeRemaining:()=>0,didTimeout:!0}),1)}let J=0;function ne(re="l"){return`${re}${(++J).toString(36)}`}}),ke("packages/core/src/formatting/rules.js",function(e,V){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return L}}),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 z}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return O}}),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 m}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return S}});const _=V("packages/core/src/internal/util.js"),R=_.isFunction,$=_.warnOnce,L=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 H(E,A){const M=Number(E),C=Number(A);if(E!==null&&E!==""&&A!==null&&A!==""&&Number.isFinite(M)&&Number.isFinite(C))return M<C?-1:M>C?1:0;const x=String(E??"").toLowerCase(),K=String(A??"").toLowerCase();return x<K?-1:x>K?1:0}function U(E){return E==null||E===""}function z(E,A){if(!A||typeof A!="object")return!1;const{op:M}=A,C=A.value,P=A.value2;switch(M){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(M){case"eq":return H(E,C)===0;case"ne":return H(E,C)!==0;case"gt":return H(E,C)>0;case"gte":return H(E,C)>=0;case"lt":return H(E,C)<0;case"lte":return H(E,C)<=0;case"between":return H(E,C)>=0&&H(E,P)<=0;case"outside":return H(E,C)<0||H(E,P)>0;case"contains":return String(E).toLowerCase().includes(String(C??"").toLowerCase());case"notContains":return!String(E).toLowerCase().includes(String(C??"").toLowerCase());case"startsWith":return String(E).toLowerCase().startsWith(String(C??"").toLowerCase());case"endsWith":return String(E).toLowerCase().endsWith(String(C??"").toLowerCase());default:return!1}}function F(E,A,M){const C=q=>{const X=String(q).replace("#",""),Q=X.length===3?X.split("").map(J=>J+J).join(""):X;return[0,2,4].map(J=>parseInt(Q.slice(J,J+2),16)||0)},[P,x,K]=C(E),[I,D,j]=C(A),T=Math.max(0,Math.min(1,M)),B=(q,X)=>Math.round(q+(X-q)*T);return`#${[B(P,I),B(x,D),B(K,j)].map(q=>q.toString(16).padStart(2,"0")).join("")}`}function k(E){const A=[];for(const I of E||[]){if(I==null||I==="")continue;const D=I instanceof Date?I.getTime():Number(I);Number.isFinite(D)&&A.push(D)}if(!A.length)return null;A.sort((I,D)=>I-D);let M=0,C=0,P=0;for(const I of A){M++;const D=I-C;C+=D/M,P+=D*(I-C)}const x=O(A,.25),K=O(A,.75);return{n:A.length,min:A[0],max:A[A.length-1],mean:C,stddev:A.length>1?Math.sqrt(P/(A.length-1)):0,median:O(A,.5),q1:x,q3:K,iqr:K-x,sorted:A}}function O(E,A){if(!E.length)return 0;const M=(E.length-1)*Math.max(0,Math.min(1,A)),C=Math.floor(M),P=Math.ceil(M);return C===P?E[C]:E[C]+(M-C)*(E[P]-E[C])}function y(E){for(const A of Array.isArray(E)?E:[])if(!(!A||typeof A!="object")&&(A.when&&W.includes(A.when.op)||A.scale&&A.scale.from||A.dataBar&&!(Number.isFinite(Number(A.dataBar.min))&&Number.isFinite(Number(A.dataBar.max)))||A.iconSet&&!Array.isArray(A.iconSet.thresholds)))return!0;return!1}function d(E,A){const M=Number(E.value),C=P=>O(A.sorted,P);switch(E.op){case"topPercent":{const P=c(M,10);return{op:"gte",value:C(1-P)}}case"bottomPercent":{const P=c(M,10);return{op:"lte",value:C(P)}}case"topN":{const P=Math.max(1,Math.floor(M)||1),x=Math.max(0,A.sorted.length-P);return{op:"gte",value:A.sorted[x]}}case"bottomN":{const P=Math.max(1,Math.floor(M)||1),x=Math.min(A.sorted.length-1,P-1);return{op:"lte",value:A.sorted[x]}}case"aboveMean":return{op:"gt",value:A.mean};case"belowMean":return{op:"lt",value:A.mean};case"aboveMedian":return{op:"gt",value:A.median};case"belowMedian":return{op:"lt",value:A.median};case"zAbove":return A.stddev?{op:"gte",value:A.mean+(Number.isFinite(M)?M:2)*A.stddev}:null;case"zBelow":return A.stddev?{op:"lte",value:A.mean-(Number.isFinite(M)?M:2)*A.stddev}:null;case"outlier":{const P=(Number.isFinite(M)&&M>0?M:1.5)*A.iqr;return A.iqr?{op:"outside",value:A.q1-P,value2:A.q3+P}:null}default:return null}}function c(E,A){const M=Number.isFinite(E)?E:A,C=M>1?M/100:M;return Math.max(0,Math.min(1,C))}function r(E,A){if(E.from==="minmax")return{...E,min:A.min,max:A.max};if(E.from==="quantile")return{...E,min:O(A.sorted,c(Number(E.low),5)),max:O(A.sorted,c(Number(E.high),95))};if(E.from==="stddev"){const M=Number.isFinite(Number(E.deviations))?Number(E.deviations):2;return{...E,min:A.mean-M*A.stddev,max:A.mean+M*A.stddev}}return E}function t(E,A){const M=Array.isArray(E)?E:[];return!A||!A.n?M.map(C=>C&&y([C])?{...C,enabled:!1}:C):M.map(C=>{if(!C||typeof C!="object")return C;if(C.scale&&C.scale.from)return{...C,scale:r(C.scale,A)};if(C.dataBar)return{...C,dataBar:n(C.dataBar,A)};if(C.iconSet)return{...C,iconSet:i(C.iconSet,A)};if(!C.when||!W.includes(C.when.op))return C;const P=d(C.when,A);return P?{...C,when:P}:{...C,enabled:!1}})}function n(E,A){const M=Number.isFinite(Number(E.min))?Number(E.min):void 0,C=Number.isFinite(Number(E.max))?Number(E.max):void 0;if(M!==void 0&&C!==void 0)return{...E,min:M,max:C};if(E.from==="quantile")return{...E,min:M??O(A.sorted,c(Number(E.low),5)),max:C??O(A.sorted,c(Number(E.high),95))};if(E.from==="stddev"){const P=Number.isFinite(Number(E.deviations))?Number(E.deviations):2;return{...E,min:M??A.mean-P*A.stddev,max:C??A.mean+P*A.stddev}}return{...E,min:M??A.min,max:C??A.max}}function i(E,A){if(Array.isArray(E.thresholds))return E;const M=s(E),C=[];for(let P=1;P<M;P++)C.push(O(A.sorted,P/M));return{...E,thresholds:C}}function s(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 A=p[E.set];return A?A.length:3}function l(E){return`url("data:image/svg+xml,${encodeURIComponent(E)}")`}function u(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 f(E,A){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${A==="up"?"8,2 14,13 2,13":A==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${E}"/></svg>`}function h(E,A){const M="M8 1l1.9 3.9 4.3.6-3.1 3 .7 4.3L8 13.8 4.2 15.8l.7-4.3-3.1-3 4.3-.6z";let C=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${A*16} 16">`;for(let P=0;P<A;P++){const x=P<E?"#f5a623":"#d0d0d0";C+=`<path transform="translate(${P*16},0)" d="${M}" fill="${x}"/>`}return`${C}</svg>`}const g=Object.freeze([f("#c0392b","down"),f("#e0a800","right"),f("#2e7d32","up")]),b=Object.freeze([u("#d13438"),u("#f5a623"),u("#2e9e44")]),p=Object.freeze({arrows:g,trafficLights:b,ratings:Object.freeze([1,2,3,4,5].map(E=>h(E,5)))}),m=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(C=>/^\s*(url\(|data:|<)/.test(String(C))&&String(C).trim().startsWith("<")?l(String(C)):String(C));const A=E.set||"arrows";if(A==="ratings"){const C=s(E),P=[];for(let x=1;x<=C;x++)P.push(l(h(x,C)));return P}const M=p[A];return M?M.map(l):($(`iconSet:${A}`,`unknown icon set '${A}'; falling back to arrows.`),g.map(l))}function v(E){const A=Number(E.min),C=Number(E.max)-A,P=E.colour||E.color||"#5b9bd5",x=E.negativeColour||E.negativeColor||"#d13438",K=E.direction==="rtl"?"left":"right",I=j=>Math.max(0,Math.min(1,(j-A)/C))*100,D=C?Math.max(0,Math.min(100,(0-A)/C*100)):0;return j=>{if(U(j))return null;const T=Number(j);if(!Number.isFinite(T)||!C)return null;const B=I(T),q=Math.min(B,D),X=Math.max(B,D),Q=T>=0?P:x;return{backgroundImage:`linear-gradient(to ${K}, transparent ${q}%, ${Q} ${q}%, ${Q} ${X}%, transparent ${X}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function a(E){const A=w(E),M=E.reverse?[...A].reverse():A,C=(Array.isArray(E.thresholds)?E.thresholds:[]).map(Number).filter(Number.isFinite),P=Number.isFinite(Number(E.size))?Number(E.size):16,x=E.set==="ratings"?P*s(E):P;return K=>{if(U(K))return null;const I=Number(K);if(!Number.isFinite(I))return null;let D=0;for(const T of C)I>=T&&D++;const j=M[Math.min(D,M.length-1)];return j?{backgroundImage:j,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${x}px ${P}px`,paddingLeft:`${x+4}px`}:null}}function o(E){const A=Array.isArray(E.colours)&&E.colours.length>=2?E.colours:["#f8f9fa","#1a6bc7"],M=Number(E.min),C=Number(E.max),P=C-M,x=A.length-1,K=[];for(let D=0;D<=x;D++)K.push(x?D/x:0);const I=Number(E.mid);if(E.mid!==void 0&&E.mid!==null)if(A.length%2===0)$("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${A.length} were given, so "mid" was ignored.`);else if(Number.isFinite(I)&&P&&I>Math.min(M,C)&&I<Math.max(M,C)){const D=x/2,j=Math.max(0,Math.min(1,(I-M)/P));for(let T=0;T<=x;T++)K[T]=T<=D?D?T/D*j:j:j+(T-D)/(x-D)*(1-j)}else Number.isFinite(I)&&$("formatting.scale.mid.range",`a scale's "mid" (${I}) is outside its min..max range, so it was ignored.`);return D=>{const j=Number(D);if(!Number.isFinite(j)||!P)return null;const T=Math.max(0,Math.min(1,(j-M)/P));let B=0;for(;B<x-1&&T>K[B+1];)B++;const q=K[B+1]-K[B],X=q>0?(T-K[B])/q:0;return{background:F(A[B],A[B+1],Math.max(0,Math.min(1,X)))}}}function S(E,A=null){const M=y(E)?t(E,A):E,C=(Array.isArray(M)?M:[]).filter(x=>x&&typeof x=="object");if(!C.length)return()=>null;const P=C.map(x=>x.scale?{scale:o(x.scale),enabled:x.enabled!==!1}:x.dataBar?{scale:v(x.dataBar),enabled:x.enabled!==!1}:x.iconSet?{scale:a(x.iconSet),enabled:x.enabled!==!1}:{when:x.when,style:x.style,stop:x.stopIfTrue!==!1,enabled:x.enabled!==!1});return x=>{const K=x?x.value:void 0;let I=null;for(const D of P){if(!D.enabled)continue;if(D.scale){const T=D.scale(K);T&&(I={...I||{},...T});continue}if(!z(K,D.when))continue;const j=R(D.style)?D.style(x):D.style;if(j&&(I={...I||{},...j}),D.stop)break}return I}}}),ke("packages/core/src/formula/parse.js",function(e,V){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return n}});const _="num",R="str",$="ref",L="name",W="op",Z="end",H=["<=",">=","<>","!="],U="+-*/^%(),<>=";class z extends Error{constructor(s,l){super(s),this.name="FormulaError",this.at=l}}function F(i){const s=[];let l=0;for(;l<i.length;){const u=i[l];if(u===" "||u===" "||u===`
7
7
  `||u==="\r"){l++;continue}if(u>="0"&&u<="9"){l=O(i,l,s);continue}if(u==="."&&i[l+1]>="0"&&i[l+1]<="9"){l=O(i,l,s);continue}if(u==='"'||u==="'"){l=y(i,l,s);continue}if(u==="["){const h=i.indexOf("]",l+1);if(h<0)throw new z("a [column reference] was opened and never closed",l);s.push({kind:$,value:i.slice(l+1,h).trim(),at:l}),l=h+1;continue}if(k(u)){l=d(i,l,s);continue}const f=i.slice(l,l+2);if(H.includes(f)){s.push({kind:W,value:f==="!="?"<>":f,at:l}),l+=2;continue}if(U.includes(u)){s.push({kind:W,value:u,at:l}),l++;continue}throw new z(`unexpected character ${JSON.stringify(u)}`,l)}return s.push({kind:Z,value:null,at:i.length}),s}function k(i){return/[A-Za-z_À-￿]/.test(i)}function O(i,s,l){let u=s,f=!1;for(;u<i.length;){const h=i[u];if(h>="0"&&h<="9"){u++;continue}if(h==="."&&!f){f=!0,u++;continue}if((h==="e"||h==="E")&&/[0-9+-]/.test(i[u+1]||"")){for(u+=2;u<i.length&&i[u]>="0"&&i[u]<="9";)u++;break}break}return l.push({kind:_,value:Number(i.slice(s,u)),at:s}),u}function y(i,s,l){const u=i[s];let f=s+1,h="";for(;f<i.length;){if(i[f]===u){if(i[f+1]===u){h+=u,f+=2;continue}return l.push({kind:R,value:h,at:s}),f+1}h+=i[f],f++}throw new z("a string was opened and never closed",s)}function d(i,s,l){let u=s;for(;u<i.length&&/[A-Za-z0-9_.À-￿]/.test(i[u]);)u++;const f=i.slice(s,u);let h=u;for(;h<i.length&&i[h]===" ";)h++;return l.push({kind:i[h]==="("?L:$,value:f,at:s}),u}const c={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function r(i){const s=String(i??"").replace(/^\s*=/,"");if(!s.trim())throw new z("the formula is empty");const l=F(s);let u=0;const f=()=>l[u],h=()=>l[u++],g=o=>{const S=f();if(S.kind!==W||S.value!==o)throw new z(`expected ${JSON.stringify(o)}`,S.at);u++},b=o=>{let S=p();for(;;){const E=f();if(E.kind!==W)break;const A=c[E.value];if(!A||A<o)break;u++;const M=b(E.value==="^"?A:A+1);S={kind:"bin",op:E.value,left:S,right:M}}return S},p=()=>{const o=f();return o.kind===W&&(o.value==="-"||o.value==="+")?(u++,{kind:"unary",op:o.value,arg:p()}):m()},m=()=>{let o=w();for(;f().kind===W&&f().value==="%";)u++,o={kind:"unary",op:"%",arg:o};return o},w=()=>{const o=h();if(o.kind===_)return{kind:"num",value:o.value};if(o.kind===R)return{kind:"str",value:o.value};if(o.kind===$)return{kind:"ref",name:o.value};if(o.kind===L){g("(");const S=[];if(!(f().kind===W&&f().value===")"))for(;;){if(S.push(b(1)),f().kind===W&&f().value===","){u++;continue}break}return g(")"),{kind:"call",name:String(o.value).toUpperCase(),args:S}}if(o.kind===W&&o.value==="("){const S=b(1);return g(")"),S}throw o.kind===Z?new z("the formula ends unexpectedly",o.at):new z(`unexpected ${JSON.stringify(o.value)}`,o.at)},v=b(1),a=f();if(a.kind!==Z)throw new z(`unexpected ${JSON.stringify(a.value)}: is an operator missing?`,a.at);return v}function t(i){const s=new Set,l=u=>{if(!(!u||typeof u!="object")){if(u.kind==="ref"){s.add(String(u.name));return}if(u.kind==="bin"){l(u.left),l(u.right);return}if(u.kind==="unary"){l(u.arg);return}if(u.kind==="call")for(const f of u.args)l(f)}};return l(i),[...s]}function n(i){return typeof i=="string"&&/^\s*=/.test(i)&&i.trim()!=="="}}),ke("packages/core/src/formula/evaluate.js",function(e,V){"use strict";Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return O}});const R=V("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 d=typeof y=="number"?y:Number(String(y).replace(/[,\s]/g,""));if(!Number.isFinite(d))throw new R(`${JSON.stringify(y)} is not a number`);return d}function L(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 d=String(y).trim().toLowerCase();return d==="false"||d==="no"||d==="0"?!1:d!==""}function Z(y){const d=[];for(const c of y){if(Array.isArray(c)){for(const r of c)r!=null&&r!==""&&d.push($(r));continue}c==null||c===""||d.push($(c))}return d}function H(y,d){const c=10**d,r=y*c;return Math.sign(r)*Math.round(Math.abs(r)+Number.EPSILON*Math.abs(r))/c}function U(y,d){if(!y.length)return 0;const c=y.slice().sort((i,s)=>i-s),r=(c.length-1)*Math.min(1,Math.max(0,d)),t=Math.floor(r),n=Math.ceil(r);return t===n?c[t]:c[t]+(r-t)*(c[n]-c[t])}function z(y,d){let c=0,r=0,t=0;for(const i of y){c++;const s=i-r;r+=s/c,t+=s*(i-r)}const n=d?c-1:c;return n>0?Math.sqrt(t/n):0}const F={SUM:y=>Z(y).reduce((d,c)=>d+c,0),AVERAGE:y=>{const d=Z(y);return d.length?d.reduce((c,r)=>c+r,0)/d.length:0},MIN:y=>{const d=Z(y);return d.length?Math.min(...d):0},MAX:y=>{const d=Z(y);return d.length?Math.max(...d):0},COUNT:y=>Z(y).length,PRODUCT:y=>Z(y).reduce((d,c)=>d*c,1),ROUND:y=>H($(y[0]),y.length>1?$(y[1]):0),ROUNDDOWN:y=>{const d=10**(y.length>1?$(y[1]):0),c=$(y[0])*d;return(c<0?Math.ceil(c):Math.floor(c))/d},ROUNDUP:y=>{const d=10**(y.length>1?$(y[1]):0),c=$(y[0])*d;return(c<0?Math.floor(c):Math.ceil(c))/d},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 d=$(y[1]);if(d===0)throw new R("MOD by zero");return($(y[0])%d+d)%d},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(d=>d!=null&&d!=="")??null,CONCAT:y=>y.map(L).join(""),LEN:y=>L(y[0]).length,UPPER:y=>L(y[0]).toUpperCase(),LOWER:y=>L(y[0]).toLowerCase(),TRIM:y=>L(y[0]).trim(),LEFT:y=>L(y[0]).slice(0,y.length>1?$(y[1]):1),RIGHT:y=>{const d=y.length>1?$(y[1]):1;return d<=0?"":L(y[0]).slice(-d)},MEDIAN:y=>U(Z(y),.5),PERCENTILE:y=>{const d=$(y[y.length-1]);return U(Z(y.slice(0,-1)),d>1?d/100:d)},QUARTILE1:y=>U(Z(y),.25),QUARTILE3:y=>U(Z(y),.75),STDEV:y=>z(Z(y),!0),STDEVP:y=>z(Z(y),!1),VAR:y=>{const d=z(Z(y),!0);return d*d},VARP:y=>{const d=z(Z(y),!1);return d*d},COUNTDISTINCT:y=>{const d=new Set;for(const c of y){const r=Array.isArray(c)?c:[c];for(const t of r)t!=null&&t!==""&&d.add(t)}return d.size},IQR:y=>{const d=Z(y);return U(d,.75)-U(d,.25)}};F.AVG=F.AVERAGE,F.CEIL=F.CEILING,F.POW=F.POWER,F.STDEVS=F.STDEV,F.PERCENTILEINC=F.PERCENTILE;function k(y,d){const c=Number(y),r=Number(d);if(y!==null&&y!==""&&d!==null&&d!==""&&Number.isFinite(c)&&Number.isFinite(r))return c<r?-1:c>r?1:0;const n=L(y).toLowerCase(),i=L(d).toLowerCase();return n<i?-1:n>i?1:0}function O(y,d={}){const c=typeof d.lookup=="function"?d.lookup:null,r=d.functions?{...F,...d.functions}:F,t=n=>{switch(n.kind){case"num":return n.value;case"str":return n.value;case"ref":{if(!c)throw new R(`there is no column called ${JSON.stringify(n.name)} here`);const i=c(String(n.name));if(i===void 0)throw new R(`there is no column called ${JSON.stringify(n.name)}`);return i}case"unary":{if(n.op==="%")return $(t(n.arg))/100;const i=$(t(n.arg));return n.op==="-"?-i:i}case"bin":{const i=n.op;if(i==="=")return k(t(n.left),t(n.right))===0;if(i==="<>")return k(t(n.left),t(n.right))!==0;if(i==="<")return k(t(n.left),t(n.right))<0;if(i==="<=")return k(t(n.left),t(n.right))<=0;if(i===">")return k(t(n.left),t(n.right))>0;if(i===">=")return k(t(n.left),t(n.right))>=0;const s=$(t(n.left)),l=$(t(n.right));if(i==="+")return s+l;if(i==="-")return s-l;if(i==="*")return s*l;if(i==="^")return s**l;if(i==="/"){if(l===0)throw new R("division by zero");return s/l}throw new R(`unknown operator ${JSON.stringify(i)}`)}case"call":{const i=r[n.name];if(typeof i!="function")throw new R(`there is no function called ${n.name}`);return i(n.args.map(t),d)}default:throw new R("the formula could not be read")}};return t(y)}}),ke("packages/core/src/formula/index.js",function(e,V){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return L}}),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 z}}),Object.defineProperty(e,"rowLookup",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return k}});const _=V("packages/core/src/formula/parse.js"),R=_.parseFormula,$=_.referencesOf,L=_.looksLikeFormula,W=_.FormulaError,Z=_.tokenise,H=V("packages/core/src/formula/evaluate.js"),U=H.evaluateAst,z=H.FUNCTIONS;function F(O){const{grid:y,row:d,data:c}=O||{},r=l=>String(l).toLowerCase().replace(/[\s_-]/g,""),t=y&&y.columns&&typeof y.columns.all=="function"?y.columns.all():[],n=y&&y.permissions,i=n&&typeof n.isReadable=="function"?l=>n.isReadable(l):()=>!0,s=new Set;for(const l of t)i(l)||(s.add(r(l.id)),l.field&&s.add(r(l.field)),l.title&&s.add(r(l.title)));return l=>{const u=r(l);if(s.has(u))throw new W(`"${l}" cannot be read`);for(const f of t)if(r(f.id)===u||f.field&&r(f.field)===u||f.title&&r(f.title)===u)return d&&y.rows&&typeof y.rows.value=="function"?y.rows.value(d.key,f.id):c?c[f.field||f.id]:void 0;if(c&&typeof c=="object"){for(const f of Object.keys(c))if(r(f)===u){if(!i(f))throw new W(`"${l}" cannot be read`);return c[f]}}}}function k(O,y={}){try{const d=R(O);return{ok:!0,value:U(d,{lookup:F(y),functions:y.formulaFunctions}),references:$(d)}}catch(d){return{ok:!1,error:d instanceof W?d.message:"the formula could not be read",at:d instanceof W?d.at:void 0}}}}),ke("packages/core/src/defaults.js",function(e,V){"use strict";Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"applyDefaults",{enumerable:!0,get:function(){return U}});const _=V("packages/core/src/internal/util.js"),R=_.isObject,$=_.merge,L=_.warnOnce;let W=null;function Z(z){if(Array.isArray(z))return z.map(Z);if(!R(z)||Object.getPrototypeOf(z)!==Object.prototype&&Object.getPrototypeOf(z)!==null)return z;const F={};for(const[k,O]of Object.entries(z))F[k]=Z(O);return F}function H(z){return z===void 0?Z(W??{}):z===null?(W=null,{}):R(z)?(W=Z(z),Z(W)):(L("defaults:type",`defaults() expects a configuration object, or null to clear it, but got ${Array.isArray(z)?"an array":typeof z}. The call was ignored and the defaults are unchanged.`),Z(W??{}))}function U(z){return W===null?z:$(Z(W),z)}}),ke("packages/core/src/events/names.js",function(e,V){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"isKnownEvent",{enumerable:!0,get:function(){return $}});const _=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","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"]),R=new Set(_);function $(L){return L==="*"||R.has(L)}}),ke("packages/core/src/events/bus.js",function(e,V){"use strict";Object.defineProperty(e,"WILDCARD",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return d}});const _=V("packages/core/src/internal/util.js"),R=_.warnOnce,$=_.uid,L=_.DEV,Z=V("packages/core/src/events/names.js").isKnownEvent,H="*";function U(c,r){!L||Z(r)||R(`bus.unknown:${r}`,`${c}('${r}') subscribes to an event the grid never raises, so the handler will never fire. Check the name against the EventName list — a common cause is a near miss such as 'row:click' for 'row:clicked'.`)}const z=new Set(["api","user","init","ai"]),F=new WeakMap;function k(c){let r=F.get(c);return r||(r=$("h"),F.set(c,r)),r}function O(){return typeof performance=="object"&&performance?performance.now():Date.now()}function y(c){if(!c||typeof c!="object")return{};const r={};for(const[t,n]of Object.entries(c))t!=="grid"&&(n==null?r[t]=String(n):Array.isArray(n)?r[t]=`[${n.length}]`:typeof n=="object"?r[t]=n.key?`row ${n.key}`:"{…}":typeof n=="function"?r[t]="[function]":r[t]=String(n).slice(0,60));return r}class d{#e=new Map;#t=!1;#n=[];#r=200;#o=new Map;#i=null;#a=!1;#s=0;constructor(r=null){this.#i=r}attach(r){this.#i=r}get grid(){return this.#i}get destroyed(){return this.#a}on(r,t){if(typeof t!="function")return R(`bus.handler:${r}`,`on('${r}') needs a function; ignored.`),()=>{};U("on",r);let n=this.#e.get(r);return n||(n=[],this.#e.set(r,n)),n.push(t),()=>this.off(r,t)}once(r,t){if(typeof t!="function")return R(`bus.handler:${r}`,`once('${r}') needs a function; ignored.`),()=>{};U("once",r);const n=i=>{this.off(r,t),t(i)};return this.#o.set(t,n),this.on(r,n)}off(r,t){if(t===void 0){this.#e.delete(r);return}const n=this.#e.get(r);if(!n)return;const i=this.#o.get(t),s=i&&n.includes(i)?i:t,l=n.indexOf(s);l>=0&&n.splice(l,1),i&&s===i&&this.#o.delete(t),n.length===0&&this.#e.delete(r)}count(r){const t=this.#e.get(r),n=r===H?null:this.#e.get(H);return(t?t.length:0)+(n?n.length:0)}#l(r,t,n,i,s){this.#n.push({type:r,origin:t,listeners:(i?i.length:0)+(s?s.length:0),payload:y(n),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(r,t){this.#t=!!r,Number.isFinite(t)&&t>0&&(this.#r=Math.floor(t)),r||(this.#n=[])}eventLog(){return this.#n.map(r=>({...r}))}clearEventLog(){this.#n=[]}counts(){const r={};for(const[t,n]of this.#e)r[t]=n.length;return r}emit(r,t,n){const i=n??(t&&t.origin),s=z.has(i)?i:"api",l={...t||null,type:r,origin:s,grid:this.#i};if(this.#a)return l;const u=this.#e.get(r),f=r===H?void 0:this.#e.get(H);if(this.#t&&this.#l(r,s,t,u,f),!u&&!f)return l;const h=this.#t?O():0;this.#s++;try{u&&this.#u(u.slice(),l,r),f&&this.#u(f.slice(),l,H)}finally{this.#s--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=O()-h)}return l}emitBefore(r,t,n){const i=n??(t&&t.origin),s=z.has(i)?i:"user";let l=!1,u=null;const f=w=>{l=!0,w!=null&&u===null&&(u=String(w))},h={...t||null,type:r,origin:s,grid:this.#i,get defaultPrevented(){return l},get reason(){return u},preventDefault(w){f(w)}};if(this.#a)return!0;const g=this.#e.get(r);this.#t&&this.#l(r,s,t,g,void 0);const b=g?g.slice():[];if(b.length===0)return!0;const p=()=>(l&&u===null&&(u="prevented"),l&&t&&typeof t=="object"&&(t.reason=u),!l),m=[];for(const w of b)try{const v=w(h);v&&typeof v.then=="function"?m.push(v):v===!1&&f("prevented")}catch(v){f("error"),R(`bus.beforeThrow:${r}:${k(w)}`,`a '${r}' before-handler threw; the action was cancelled.`,v)}return m.length===0?p():Promise.allSettled(m).then(w=>{for(const v of w)v.status==="rejected"?(f("error"),R(`bus.beforeReject:${r}`,`a '${r}' before-handler rejected; the action was cancelled.`,v.reason)):v.value===!1&&f("prevented");return p()})}#u(r,t,n){for(let i=0;i<r.length;i++)try{r[i](t)}catch(s){R(`bus.throw:${n}:${k(r[i])}`,`a '${n}' handler threw; other handlers were unaffected.`,s)}}clear(){this.#e.clear(),this.#o.clear()}destroy(){this.clear(),this.#a=!0,this.#i=null}}}),ke("packages/core/src/registry/licence.js",function(e,V){"use strict";Object.defineProperty(e,"PRODUCT",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"LICENCE_VERSION",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"PUBLIC_KEY",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"fromBase64Url",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"toBase64Url",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"asciiBytes",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"hasEd25519",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"currentHost",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return g}}),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 v}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return S}});const R=V("packages/core/src/internal/util.js").warnOnce,$="lattice-grid",L=1,W="LG1",Z=64,H="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",U="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",z=(()=>{const E=new Int16Array(128).fill(-1);for(let A=0;A<U.length;A++)E[U.charCodeAt(A)]=A;return E[43]=62,E[47]=63,E})();function F(E){if(typeof E!="string")return null;let A="";for(let I=0;I<E.length;I++){const D=E.charCodeAt(I);if(D!==61){if(D>127||z[D]<0)return null;A+=E[I]}}const M=A.length;if(M%4===1)return null;const C=new Uint8Array(Math.floor(M*3/4));let P=0,x=0,K=0;for(let I=0;I<M;I++)P=P<<6|z[A.charCodeAt(I)],x+=6,x>=8&&(x-=8,C[K++]=P>>x&255);return K===C.length?C:C.subarray(0,K)}function k(E){let A="",M=0;for(;M+2<E.length;M+=3){const P=E[M]<<16|E[M+1]<<8|E[M+2];A+=U[P>>18&63]+U[P>>12&63]+U[P>>6&63]+U[P&63]}const C=E.length-M;if(C===1){const P=E[M]<<16;A+=U[P>>18&63]+U[P>>12&63]}else if(C===2){const P=E[M]<<16|E[M+1]<<8;A+=U[P>>18&63]+U[P>>12&63]+U[P>>6&63]}return A}function O(E){const A=new Uint8Array(E.length);for(let M=0;M<E.length;M++)A[M]=E.charCodeAt(M)&127;return A}function y(E){if(typeof TextDecoder=="function")return new TextDecoder().decode(E);let A="";for(let M=0;M<E.length;M++)A+=String.fromCharCode(E[M]);return A}function d(E){const A={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{...A,reason:"missing"};const M=E.trim(),C=M.split(".");if(C.length!==3)return A;const[P,x,K]=C;if(P!==W)return{...A,reason:"prefix"};const I=F(x),D=F(K);if(!I||!D)return A;let j;try{j=JSON.parse(y(I))}catch{return A}return j===null||typeof j!="object"?A:{ok:!0,reason:null,product:typeof j.p=="string"?j.p:null,issuedTo:typeof j.t=="string"?j.t:null,expires:typeof j.e=="string"?j.e:null,features:Array.isArray(j.f)?j.f.slice():[],deployments:Array.isArray(j.d)?j.d.slice():[],version:typeof j.v=="number"?j.v:0,message:O(x),signature:D,raw:M}}function c(E,A){if(!E)return!1;const M=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(E)?`${E}T23:59:59.999Z`:E);return Number.isNaN(M)?!0:A>M}let r=null,t=null,n=null;function i(){const E=globalThis.crypto;return E&&E.subtle?E.subtle:null}async function s(E){if(r&&t===E)return r;const A=i();if(!A)return null;const M=F(E);if(!M)return null;try{const C=await A.importKey("raw",M,{name:"Ed25519"},!1,["verify"]);return r=C,t=E,C}catch{return null}}async function l(){return n!==null||(n=await s(H)!==null),n}async function u(E,A={}){const M=A.warn!==!1,C=A.product||$,P=A.publicKey||H,x=A.now??Date.now(),K=d(E);if(!K.ok){const q=K.reason==="missing"?"missing":"malformed";return M&&R(`licence.${q}`,q==="missing"?"no licence key supplied. The grid renders in full and carries a trial watermark on any host other than localhost. Get a key at latticegrid.dev.":"licence key could not be read. The grid will render with a watermark."),{valid:!1,reason:q}}const I={product:K.product||void 0,issuedTo:K.issuedTo||void 0,expires:K.expires||void 0};if(K.product!==C)return M&&R("licence.product",`licence key is for '${K.product}', not '${C}'. The grid will render with a watermark.`),{valid:!1,...I,reason:"product"};if(c(K.expires,x))return M&&R("licence.expired",`licence expired on ${K.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...I,reason:"expired"};const D=A.host??h(),j=K.deployments||[];if(j.length&&D&&!f(D)&&!g(D,j))return M&&R("licence.domain",`licence key is not valid for ${D}; it covers ${j.join(", ")}. The grid will render with a watermark.`),{valid:!1,...I,reason:"domain"};const T=await s(P);if(!T){const q=!!K.signature&&K.signature.length===Z;return M&&R("licence.algorithm","this host does not provide crypto.subtle Ed25519, so the licence signature could not be verified. A structural check was used instead."),q?{valid:!0,...I,reason:"unverified"}:{valid:!1,...I,reason:"signature"}}let B=!1;try{B=await i().verify({name:"Ed25519"},T,K.signature,K.message)}catch{B=!1}return B?{valid:!0,...I}:(M&&R("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...I,reason:"signature"})}function f(E){const A=String(E??h()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!A||A==="localhost"||A.endsWith(".localhost")||A==="::1"||A==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(A)}function h(){const E=globalThis.location;return E&&typeof E.hostname=="string"?E.hostname:null}function g(E,A){const M=b(E);return!M||!Array.isArray(A)?!1:A.some(C=>{const P=b(C);if(!P)return!1;if(P==="*")return!0;if(P.startsWith("*.")){const x=P.slice(2);return M===x||M.endsWith(`.${x}`)}return M===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(A={}){this.#o=A}set(A){this.#e=typeof A=="string"?A.trim():"";const M=d(this.#e);return this.#t=M.ok?{valid:!c(M.expires,Date.now())&&M.product===(this.#o.product||$),product:M.product||void 0,issuedTo:M.issuedTo||void 0,expires:M.expires||void 0,reason:"pending"}:{valid:!1,reason:M.reason||"malformed"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const A=this.#e;return this.#n=u(A,this.#o).then(M=>{if(this.#e===A){this.#t=M;for(const C of this.#i)C(M)}return M}),this.#n}onSettled(A){return this.#i.add(A),()=>this.#i.delete(A)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!f(this.#r)}setHost(A){this.#r=A}state(){return this.#t.valid?"licensed":f(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing"},this.#n=null,this.#i.clear()}}const m=new p;function w(E){return m.set(E)}function v(){return m.info()}function a(){return m.watermark()}function o(){return m.state()}function S(){return m}}),ke("packages/core/src/registry/registry.js",function(e,V){"use strict";Object.defineProperty(e,"KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"REGIONS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return n}});const _=V("packages/core/src/internal/util.js"),R=_.warnOnce,$=_.isFunction,L=_.DEV,W=V("packages/core/src/registry/licence.js"),Z=W.LicenceHolder,H=W.sharedLicence,U=["renderer","editor","filter","dataType","totalFn","pipe","component"],z=["all","header","body","totals","panels"];class F{#e=new Map;#t=new Map;#n=new Set;#r=new Set;#o;#i=null;#a=null;#s=new Set;#l=new Map;constructor(s={}){for(const l of U)this.#t.set(l,new Map);this.#o=s.holder||H(),this.#a=s.grid??null,this.#i=this.#o.onSettled(()=>{this.#d({reason:"licence",name:"licence",capabilities:this.capabilities(),regions:["all"]})}),s.licence&&this.setLicence(s.licence)}registerModules(s,l={}){l.licence&&this.setLicence(l.licence),l.grid!==void 0&&(this.#a=l.grid);const u=Array.isArray(s)?s:[s],f=[];for(const h of u){if(!h||typeof h!="object"||typeof h.name!="string"||!h.name){R("registry.module.shape","registerModules received something that is not a module; ignored.");continue}if(this.#e.has(h.name)){L&&this.#c(this.#e.get(h.name),h);continue}if(!$(h.install)){R(`registry.module.install:${h.name}`,`module '${h.name}' has no install() and was ignored.`);continue}const g={registry:this,grid:this.#a};try{h.install(g)}catch(b){R(`registry.module.throw:${h.name}`,`module '${h.name}' threw during install; it was not registered.`,b);continue}this.#e.set(h.name,h);for(const b of k(h))this.#n.add(b);f.push(h.name),this.#d({reason:"module",name:h.name,capabilities:this.capabilities(),regions:d(h)})}return f}unregisterModule(s){const l=this.#e.get(s);if(!l)return!1;if($(l.uninstall))try{l.uninstall({registry:this,grid:this.#a})}catch(u){R(`registry.module.uninstall:${s}`,`module '${s}' threw during uninstall.`,u)}return this.#e.delete(s),this.#u(),this.#d({reason:"unmodule",name:s,capabilities:this.capabilities(),regions:d(l)}),!0}modules(){return[...this.#e.values()]}has(s){return this.#e.has(s)}#u(){this.#n.clear();for(const s of this.#e.values())for(const l of k(s))this.#n.add(l)}#c(s,l){!s||s===l||O(s,l)||R(`registry.module.reconfigure:${l.name}`,`module '${l.name}' was re-registered with different options; the first registration is kept and this call was ignored. Unregister it first if you mean to replace it.`)}capabilities(){return[...this.#n].sort()}can(s){return this.#n.has(s)}onChange(s){return $(s)?(this.#r.add(s),this.#l.set(s,this.#a),()=>{this.#r.delete(s),this.#l.delete(s)}):()=>{}}#d(s){for(const l of[...this.#r])try{l(s)}catch(u){R("registry.onChange.throw","a registry change handler threw.",u)}}register(s,l,u){const f=this.#t.get(s);if(!f){R(`registry.kind:${s}`,`unknown registry kind '${s}'; expected one of ${U.join(", ")}.`);return}if(!l||typeof l!="string"){R(`registry.name:${s}`,`register('${s}', ...) needs a name.`);return}f.has(l)&&f.get(l)!==u&&R(`registry.replace:${s}:${l}`,`'${l}' was already registered as a ${s} and has been replaced.`),f.set(l,u),this.#d({reason:"register",name:l,kind:s,capabilities:this.capabilities(),regions:c(s)})}registerAll(s,l){if(l)for(const u of Object.keys(l))this.register(s,u,l[u])}get(s,l){const u=this.#t.get(s);return u?u.get(l):void 0}names(s){const l=this.#t.get(s);return l?[...l.keys()]:[]}#h(s,l){const u=this.#t.get(s).get(l);return u!==void 0?u:this.#t.get("component").get(l)}renderer(s){return this.#h("renderer",s)}editor(s){return this.#h("editor",s)}filter(s){return this.#h("filter",s)}dataType(s){return this.get("dataType",s)}totalFn(s){return this.get("totalFn",s)}pipe(s){return this.get("pipe",s)}setLicence(s){return this.#o.set(s)}licence(){return this.#o.info()}licenceVerified(){return this.#o.verify()}watermark(){return this.#o.watermark()}attach(s){s!=null&&(this.#s.add(s),this.#a=s)}detach(s){if(s!=null){this.#s.delete(s);for(const[l,u]of[...this.#l])u===s&&(this.#r.delete(l),this.#l.delete(l));if(this.#a===s){const l=this.#s.size?[...this.#s][this.#s.size-1]:null;this.#a=l}this.#s.size===0&&this.#i&&(this.#i(),this.#i=null)}}destroy(s){if(s!=null){this.detach(s);return}for(const l of[...this.#e.keys()])this.unregisterModule(l);this.#r.clear(),this.#l.clear(),this.#s.clear(),this.#i&&this.#i(),this.#i=null,this.#a=null}}function k(i){const s=i.capabilities,l=Array.isArray(s)?s.filter(u=>typeof u=="string"):[];return[i.name,...l]}function O(i,s){return i.install!==s.install||i.uninstall!==s.uninstall||(i.version||"")!==(s.version||"")?!1:y(k(i),k(s))&&y(d(i),d(s))}function y(i,s){const l=new Set(i),u=new Set(s);if(l.size!==u.size)return!1;for(const f of l)if(!u.has(f))return!1;return!0}function d(i){const s=i.regions;return!Array.isArray(s)||s.length===0?["all"]:s.filter(l=>z.includes(l))}function c(i){switch(i){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const r=new F;function t(){return r}function n(i,s={}){return r.registerModules(i,s)}}),ke("packages/core/src/format/number.js",function(e,V){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return $}});const R=V("packages/core/src/internal/util.js").isNil;function $(L,W){const Z=L||{},H=Z.locale||W||void 0,U=Z.style||"decimal",z=typeof Z.scale=="number"?Z.scale:1,F=Z.nullDisplay??"",k=Z.zeroDisplay,O=Z.prefix||"",y=Z.suffix||"",d=Z.negative||"minus",c=Z.signed===!0,r={style:U,notation:Z.notation||"standard"};U==="currency"&&(r.currency=Z.currency||"USD",Z.currencyDisplay&&(r.currencyDisplay=Z.currencyDisplay)),typeof Z.decimals=="number"?(r.minimumFractionDigits=Z.decimals,r.maximumFractionDigits=Z.decimals):(typeof Z.minDecimals=="number"&&(r.minimumFractionDigits=Z.minDecimals),typeof Z.maxDecimals=="number"&&(r.maximumFractionDigits=Z.maxDecimals),r.minimumFractionDigits>(r.maximumFractionDigits??20)&&(r.maximumFractionDigits=r.minimumFractionDigits)),Z.thousandsSeparator===!1&&(r.useGrouping=!1),r.notation==="compact"&&(r.compactDisplay=Z.compactDisplay||"short");const t=new Intl.NumberFormat(H,r),n=typeof Z.thousandsSeparator=="string"?Z.thousandsSeparator:null,i=typeof Z.decimalSeparator=="string"?Z.decimalSeparator:null;let s=",",l=".";if(n||i)for(const p of t.formatToParts(12345.6))p.type==="group"?s=p.value:p.type==="decimal"&&(l=p.value);const u=p=>{let m=p;return n&&(m=m.split(s).join("")),i&&(m=m.split(l).join("")),n&&(m=m.split("").join(n)),i&&(m=m.split("").join(i)),m},f=!!(n||i),h=O!==""&&U==="currency",g=p=>{let m;if(h){const w=t.formatToParts(p);let v=!1;m="";for(const a of w)m+=a.value,!v&&a.type==="currency"&&(m+=O,v=!0);v||(m=O+m)}else m=O+t.format(p);return f&&(m=u(m)),m+y},b=p=>{if(R(p)||p==="")return F;const m=typeof p=="number"?p:Number(p);if(Number.isNaN(m))return F;const w=z===1?m:m*z;return w===0&&k!==void 0?k:w<0?d==="parentheses"?`(${g(-w)})`:d==="suffix"?`${g(-w)}-`:g(w):c&&w>0?`+${g(w)}`:g(w)};return b.negativeClass=Z.negativeClass||null,b.spec=Z,b}}),ke("packages/core/src/format/date.js",function(e,V){"use strict";Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"toIsoDate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"toIsoDateTime",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"compareIso",{enumerable:!0,get:function(){return t}});const _=V("packages/core/src/internal/util.js"),R=_.isNil,$=_.warnOnce,L=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function W(n){const i=[];let s=0,l="";const u=()=>{l&&(i.push({token:null,text:l}),l="")};for(;s<n.length;){const f=n[s];if(f==="'"){if(n[s+1]==="'"){l+="'",s+=2;continue}const g=n.indexOf("'",s+1);if(g===-1){l+=n.slice(s+1),s=n.length;continue}l+=n.slice(s+1,g),s=g+1;continue}const h=L.find(g=>n.startsWith(g,s));if(h){u(),i.push({token:h,text:h}),s+=h.length;continue}/[A-Za-z]/.test(f)&&$(`date.pattern.token:${f}`,`the date pattern "${n}" contains '${f}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${L.join(" ")}.`),l+=f,s+=1}return u(),i}const Z=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function H(n){if(R(n)||n==="")return null;if(n instanceof Date)return Number.isNaN(n.getTime())?null:n;if(typeof n=="number")return Number.isNaN(n)?null:new Date(n);if(typeof n=="string"){const i=Z.exec(n.trim());if(i){const[,l,u,f,h="0",g="0",b="0"]=i;return new Date(+l,+u-1,+f,+h,+g,+b)}const s=new Date(n);return Number.isNaN(s.getTime())?null:s}return null}function U(n,i){return String(n).padStart(i,"0")}function z(n){if(!n)return l=>({year:l.getFullYear(),month:l.getMonth()+1,day:l.getDate(),hour:l.getHours(),minute:l.getMinutes(),second:l.getSeconds(),ms:l.getMilliseconds(),weekday:l.getDay()});const i=new Intl.DateTimeFormat("en-US",{timeZone:n,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 l=>{const u={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:l.getMilliseconds(),weekday:0};for(const f of i.formatToParts(l))switch(f.type){case"year":u.year=Number(f.value);break;case"month":u.month=Number(f.value);break;case"day":u.day=Number(f.value);break;case"hour":u.hour=Number(f.value)%24;break;case"minute":u.minute=Number(f.value);break;case"second":u.second=Number(f.value);break;case"weekday":u.weekday=s[f.value]??0;break;default:break}return u}}function F(n,i,s){const l=W(n),u=z(s),f=new Set(l.filter(m=>m.token).map(m=>m.token)),h=f.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:s}):null,g=f.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:s}):null,b=f.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:s}):null,p=f.has("EEEE")?new Intl.DateTimeFormat(i,{weekday:"long",timeZone:s}):null;return m=>{const w=u(m);let v="";for(const a of l){if(!a.token){v+=a.text;continue}switch(a.token){case"yyyy":v+=U(w.year,4);break;case"yy":v+=U(w.year%100,2);break;case"MMMM":v+=g.format(m);break;case"MMM":v+=h.format(m);break;case"MM":v+=U(w.month,2);break;case"M":v+=String(w.month);break;case"dd":v+=U(w.day,2);break;case"d":v+=String(w.day);break;case"EEEE":v+=p.format(m);break;case"EEE":v+=b.format(m);break;case"HH":v+=U(w.hour,2);break;case"H":v+=String(w.hour);break;case"hh":v+=U(w.hour%12===0?12:w.hour%12,2);break;case"h":v+=String(w.hour%12===0?12:w.hour%12);break;case"mm":v+=U(w.minute,2);break;case"m":v+=String(w.minute);break;case"ss":v+=U(w.second,2);break;case"s":v+=String(w.second);break;case"SSS":v+=U(w.ms,3);break;case"a":v+=w.hour<12?"AM":"PM";break;default:v+=a.text;break}}return v}}const k=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function O(n,i){const s=n||{},l=s.locale||i||void 0,u=s.nullDisplay??"",f=s.timeZone;let h;if(s.pattern)h=F(s.pattern,l,f);else if(s.dateStyle||s.timeStyle){const w={timeZone:f};s.dateStyle&&(w.dateStyle=s.dateStyle),s.timeStyle&&(w.timeStyle=s.timeStyle);const v=new Intl.DateTimeFormat(l,w);h=a=>v.format(a)}else{const w=new Intl.DateTimeFormat(l,{dateStyle:"medium",timeZone:f});h=v=>w.format(v)}const g=s.relative?new Intl.RelativeTimeFormat(l,{numeric:"auto"}):null,p=(typeof s.relative=="object"&&s.relative?s.relative.threshold??7:7)*24*36e5,m=(w,v)=>{const a=H(w);if(!a)return u;if(g){const o=v&&typeof v.now=="number"?v.now:Date.now(),S=a.getTime()-o;if(Math.abs(S)<p){for(const[E,A]of k)if(Math.abs(S)>=A||E==="second")return g.format(Math.round(S/A),E)}}return h(a)};return m.spec=s,m}function y(n){if(R(n)||n==="")return null;if(typeof n=="string"){const l=/^(\d{4}-\d{2}-\d{2})/.exec(n.trim());if(l)return l[1];const u=H(n);return u?y(u):null}const i=H(n);if(!i)return null;const s=l=>String(l).padStart(2,"0");return`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}`}function d(n,i){if(R(n)||n==="")return null;if(typeof n=="string"){const l=n.trim();if(c.test(l)){const h=H(l);return h?r(h,i):null}const u=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(l);if(u){const[,h,g,b,p]=u;return`${h}T${g}:${b}${p&&p!=="00"?`:${p}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(l))return`${l}T00:00`;const f=H(l);return f?d(f):null}const s=H(n);return s?r(s,i):null}const c=/(?:Z|[+-]\d{2}:?\d{2})$/i;function r(n,i){const s=h=>String(h).padStart(2,"0");if(i)try{const h=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(n).reduce((p,m)=>(m.type!=="literal"&&(p[m.type]=m.value),p),{}),g=h.hour==="24"?"00":h.hour,b=Number(h.second);return`${h.year}-${h.month}-${h.day}T${g}:${h.minute}`+(b?`:${h.second}`:"")}catch{}const l=`${n.getFullYear()}-${s(n.getMonth()+1)}-${s(n.getDate())}`,u=n.getSeconds(),f=`${s(n.getHours())}:${s(n.getMinutes())}${u?`:${s(u)}`:""}`;return`${l}T${f}`}function t(n,i){const s=R(n)||n===""?null:String(n),l=R(i)||i===""?null:String(i);return s===null?l===null?0:1:l===null||s<l?-1:s>l?1:0}}),ke("packages/core/src/format/boolean.js",function(e,V){"use strict";Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return Z}});const R=V("packages/core/src/internal/util.js").isNil,$={true:"☑",false:"☐",null:""},L={true:"◉",false:"◯",null:""};function W(H){if(R(H)||H==="")return null;if(typeof H=="boolean")return H;if(typeof H=="number")return H!==0;const U=String(H).trim().toLowerCase();return U==="true"||U==="yes"||U==="y"||U==="1"?!0:U==="false"||U==="no"||U==="n"||U==="0"?!1:null}function Z(H,U){const z=H||{},F=z.display||"text",k=z.trueLabel??"Yes",O=z.falseLabel??"No",y=z.nullLabel??"";let d=k,c=O;const r=y;F==="checkbox"?(d=$.true,c=$.false):F==="switch"?(d=L.true,c=L.false):F==="icon"&&(d=z.trueIcon??k,c=z.falseIcon??O);const t=n=>{const i=W(n);return i===null?r:i?d:c};return t.display=F,t.labels={true:k,false:O,null:y},t.locale=U,t.spec=z,t}}),ke("packages/core/src/format/text.js",function(e,V){"use strict";Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return L}});const _=V("packages/core/src/internal/util.js"),R=_.isNil,$=_.titleCase;function L(W,Z){const H=W||{},U=H.locale||Z||void 0,z=H.nullDisplay??"",F=H.emptyDisplay??"",k=H.transform||"none",O=typeof H.truncate=="number"?{chars:H.truncate}:H.truncate||null,y=O?O.chars:0,d=O?O.ellipsis??"…":"",c=t=>{switch(k){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}},r=t=>{if(R(t))return z;let n=typeof t=="string"?t:String(t);return n===""?F:(k!=="none"&&(n=c(n)),y>0&&n.length>y&&(n=n.slice(0,y)+d),n)};return r.spec=H,r}}),ke("packages/core/src/format/mask.js",function(e,V){"use strict";Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return Z}});const _=new Set(["0","#","?",",","."]),R="\0";function $(U){const z=[];let F="",k=!1;for(let O=0;O<U.length;O++){const y=U[O];if(y==="\\"){F+=y+(U[O+1]??""),O+=1;continue}if(y==='"'){k=!k,F+=y;continue}if(y===";"&&!k){z.push(F),F="";continue}F+=y}return z.push(F),z}function L(U){let z="",F="",k="",O=1,y=!1,d=!1;const c=h=>{d?F+=h:z+=h};for(let h=0;h<U.length;h++){const g=U[h];if(g==="\\"){c(U[h+1]??""),h+=1;continue}if(g==='"'){const b=U.indexOf('"',h+1);c(b===-1?U.slice(h+1):U.slice(h+1,b)),h=b===-1?U.length:b;continue}if(g==="%"){O*=100,c("%");continue}if(g==="@"){y=!0,c("\0");continue}if(_.has(g)){k+=g,d=!0;continue}c(g)}let r=-1;for(let h=k.length-1;h>=0;h--){const g=k[h];if(g==="0"||g==="#"||g==="?"){r=h;break}}let t=!1,n="";for(let h=0;h<k.length;h++){const g=k[h];if(g===","){h>r?O/=1e3:t=!0;continue}n+=g}const i=n.indexOf("."),s=i===-1?n:n.slice(0,i),l=i===-1?"":n.slice(i+1);let u=0;for(const h of s)h==="0"&&(u+=1);let f=0;for(const h of l)h==="0"&&(f+=1);return{prefix:z,suffix:F,minInt:u,minDec:f,maxDec:l.length,grouping:t,scale:O,hasNumber:r!==-1,isText:y}}function W(U,z){const F=new Intl.NumberFormat(z,{minimumIntegerDigits:Math.max(U.minInt,1),minimumFractionDigits:U.minDec,maximumFractionDigits:Math.max(U.maxDec,U.minDec),useGrouping:U.grouping}),{prefix:k,suffix:O,scale:y,hasNumber:d}=U;return c=>{if(!d)return k+O;const r=y===1?c:c*y;return k+F.format(r)+O}}function Z(U,z){const k=$(String(U)).map(L),O=k.map(n=>W(n,z)),y=0,d=k.length>1?1:-1,c=k.length>2?2:-1,r=k.length>3?3:-1,t=n=>{if(n==null||n==="")return"";if(typeof n!="number"||Number.isNaN(n)){const i=Number(n);if(Number.isNaN(i))return r===-1?String(n):(k[r].prefix+k[r].suffix).split("\0").join(String(n));n=i}return n===0&&c!==-1?O[c](0):n<0&&d!==-1?O[d](-n):O[y](n)};return t.spec={mask:U},{format:t,ooxml:H(String(U))}}function H(U){return U.trim()}}),ke("packages/core/src/format/shorthand.js",function(e,V){"use strict";Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return H}});const _=["currency","number","percent","date","boolean","text","relative"],R=/[#0?@;"\\]/,$=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function L(U){return typeof U!="string"||U===""||Z(U)?!1:R.test(U)}function W(U){return typeof U!="string"||U===""||Z(U)?!1:$.test(U)}function Z(U){const z=U.indexOf(":"),F=z===-1?U:U.slice(0,z);return _.includes(F)?F:null}function H(U){const z=Z(U);if(!z)return null;const F=U.indexOf(":"),k=F===-1?"":U.slice(F+1),O=k===""?[]:k.split(":");switch(z){case"currency":{const y={type:"number",style:"currency",currency:O[0]||"USD"};return O[1]!==void 0&&O[1]!==""&&(y.decimals=Number(O[1])),y}case"number":{const y={type:"number",style:"decimal"};return O[0]!==void 0&&O[0]!==""&&(y.decimals=Number(O[0])),y}case"percent":{const y={type:"number",style:"percent"};return O[0]!==void 0&&O[0]!==""&&(y.decimals=Number(O[0])),y}case"date":return{type:"date",pattern:k||void 0};case"relative":return{type:"date",relative:!0};case"boolean":{const y=k.split("/"),d={type:"boolean",display:"text"};return y[0]!==void 0&&y[0]!==""&&(d.trueLabel=y[0]),y[1]!==void 0&&y[1]!==""&&(d.falseLabel=y[1]),y[2]!==void 0&&(d.nullLabel=y[2]),d}case"text":{const y={type:"text"};return O[0]&&(y.transform=O[0]),O[1]!==void 0&&O[1]!==""&&(y.truncate=Number(O[1])),y}default:return null}}}),ke("packages/core/src/format/index.js",function(e,V){"use strict";Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return m}});const _=V("packages/core/src/internal/util.js"),R=_.isFunction,$=_.isObject,L=_.warnOnce,W=V("packages/core/src/format/number.js"),Z=W.compileNumber,H=V("packages/core/src/format/date.js"),U=H.compileDate,z=H.scanPattern,F=V("packages/core/src/format/boolean.js"),k=F.compileBoolean,O=V("packages/core/src/format/text.js"),y=O.compileText,d=V("packages/core/src/format/mask.js"),c=d.compileMask,r=V("packages/core/src/format/shorthand.js"),t=r.parseShorthand,n=r.looksLikeMask,i=r.looksLikeDatePattern;Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return W.compileNumber}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return H.compileDate}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return H.compilePattern}}),Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return H.scanPattern}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return H.toDate}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return F.compileBoolean}}),Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return F.toTriState}}),Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return O.compileText}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return d.compileMask}}),Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return d.splitSections}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return d.parseSection}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return r.parseShorthand}}),Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return r.looksLikeMask}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return r.looksLikeDatePattern}});const s=new Set(["decimal","currency","percent","unit"]),l=new Set(["type","locale"]),u={number:new Set(["style","currency","currencyDisplay","decimals","minDecimals","maxDecimals","thousandsSeparator","decimalSeparator","notation","compactDisplay","negative","negativeClass","signed","prefix","suffix","zeroDisplay","nullDisplay","messages","scale"]),date:new Set(["pattern","dateStyle","timeStyle","timeZone","relative","nullDisplay"]),boolean:new Set(["display","trueLabel","falseLabel","nullLabel","trueIcon","falseIcon"]),text:new Set(["transform","truncate","nullDisplay","emptyDisplay"])};function f(o,S,E){const A=u[S],M=E?`"${E}"`:"with no id";for(const C of o){if(l.has(C)||A.has(C))continue;const P=Object.keys(u).find(x=>x!==S&&u[x].has(C));P?L(`format:inapplicable:${E||""}:${C}`,`column ${M} has format key "${C}", which applies to a ${P} column, not the ${S} column it was applied to; it is ignored.`):L(`format:unknown:${E||""}:${C}`,`column ${M} has an unrecognised format key "${C}" for its ${S} format; it is ignored.`)}}function h(o){if(o.type==="number"||o.type==="date"||o.type==="boolean"||o.type==="text")return!0;const S=s.has(String(o.style));return!!(o.pattern||o.dateStyle||o.timeStyle||o.relative||o.timeZone||o.trueLabel||o.falseLabel||o.display||o.trueIcon||o.falseIcon||o.transform||o.truncate||o.emptyDisplay||S||o.currency||o.decimals!==void 0||o.minDecimals!==void 0||o.maxDecimals!==void 0||o.notation||o.negative||o.scale!==void 0||o.prefix||o.suffix||o.zeroDisplay!==void 0)}function g(o,S){if(o.type==="number"||o.type==="date"||o.type==="boolean"||o.type==="text")return o.type;if(o.pattern||o.dateStyle||o.timeStyle||o.relative||o.timeZone)return"date";if(o.trueLabel||o.falseLabel||o.display||o.trueIcon||o.falseIcon)return"boolean";if(o.transform||o.truncate||o.emptyDisplay)return"text";if(o.style||o.currency||o.decimals!==void 0||o.minDecimals!==void 0||o.maxDecimals!==void 0||o.notation||o.negative||o.scale!==void 0||o.prefix||o.suffix||o.zeroDisplay!==void 0)return"number";const E=S&&S.base;return E==="number"?"number":E==="date"||E==="dateString"?"date":E==="boolean"?"boolean":"text"}function b(o,S=null,E=void 0,A=void 0,M=void 0){if(o==null||o==="")return null;const C=$(o)?Object.keys(o):null;if(A&&o&&typeof o=="object"&&o.timeZone===void 0&&(o={...o,timeZone:A}),typeof o=="function"){const K=(I,D)=>String(o({...D||{},value:I,locale:E})??"");return K.ooxml=S&&S.excel||"General",K}if(typeof o=="string"){if(n(o)){const{format:I,ooxml:D}=c(o,E);return I.ooxml=D,I}const K=t(o)||(i(o)?{type:"date",pattern:o}:null);return K?b(K,S,E,A,M):(L(`format:${o}`,`unrecognised format string "${o}"; the value will be stringified`),null)}if(!$(o))return L("format:shape","format must be a spec object or a string; ignoring",o),null;if(S&&R(S.format)&&!h(o))return null;const P=g(o,S);f(C||Object.keys(o),P,M);let x;switch(P){case"number":x=Z(o,E);break;case"date":x=U(o,E);break;case"boolean":x=k(o,E);break;default:x=y(o,E);break}return x.ooxml=m(o,P,E,S),x.kind=P,x}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 m(o,S,E=void 0,A=null){if(S==="date"){if(o.pattern){let K="";for(const I of z(o.pattern))K+=I.token?p[I.token]??I.text:I.text;return K}return A&&A.excel||"yyyy-mm-dd"}if(S==="boolean")return"General";if(S==="text")return"@";if(o.notation==="compact"||o.notation==="scientific")return"General";const M=typeof o.decimals=="number"?o.decimals:typeof o.minDecimals=="number"?o.minDecimals:o.style==="currency"?2:0;let P=`${o.thousandsSeparator===!1?"":"#,#"}#0${M>0?`.${"0".repeat(M)}`:""}`,x="";return o.style==="currency"&&(x+=w(a(o.currency||"USD",E))),o.prefix&&(x+=w(o.prefix)),P=x+P,o.style==="percent"&&(P=`${P}%`),o.suffix&&(P+=w(o.suffix)),o.negative==="parentheses"?`${P};(${P})`:o.negative==="suffix"?`${P};${P}-`:P}function w(o){return`"${String(o).split('"').join("")}"`}const v=new Map;function a(o,S){const E=`${o}|${S||""}`;let A=v.get(E);if(A!==void 0)return A;A=o;try{const C=new Intl.NumberFormat(S,{style:"currency",currency:o}).formatToParts(0).find(P=>P.type==="currency");C&&(A=C.value)}catch{}return v.set(E,A),A}}),ke("packages/core/src/columns/types/temporal.js",function(e,V){"use strict";Object.defineProperty(e,"MS_SECOND",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"MS_MINUTE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"MS_HOUR",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"MS_DAY",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MS_WEEK",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"toTimeMs",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"zonedParts",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"zoneOffsetAt",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"instantFromParts",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"toEpochMs",{enumerable:!0,get:function(){return x}}),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 ie}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(e,"zoneAbbrev",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(e,"resolveZoneName",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(e,"timestampGroupProjector",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return He}}),Object.defineProperty(e,"TEMPORAL_INFERENCE_ORDER",{enumerable:!0,get:function(){return et}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return lt}});const _=V("packages/core/src/internal/util.js"),R=_.isNil,$=_.isFunction,L=V("packages/core/src/format/date.js"),W=L.toDate,Z=L.compilePattern,H=L.compileDate,U=L.toIsoDateTime,z=L.compareIso,F=864e5,k=Object.freeze({}),O=1e3,y=60*O,d=60*y,c=24*d,r=7*c,t=new WeakMap;function n(Ae,We){const Ge=Ae&&Ae.locale||"",Je=Ae&&Ae.column;if(!Je)return Ge?{locale:Ge}:k;const ut=t.get(Je);if(ut&&ut.locale===Ge)return ut.bag;const vt=Je.typeOptions||Je[We]||(i(Je.format)?Je.format:null),Ct={...vt||k,locale:vt&&vt.locale||Ge||void 0};return t.set(Je,{locale:Ge,bag:Ct}),Ct}function i(Ae){return Ae!==null&&typeof Ae=="object"&&!Array.isArray(Ae)&&!(Ae instanceof Date)}function s(Ae,We){const Ge=Ae===null||Number.isNaN(Ae)?null:Ae,Je=We===null||Number.isNaN(We)?null:We;return Ge===null?Je===null?0:1:Je===null||Ge<Je?-1:Ge>Je?1:0}const l=/^(\d{1,2})(?:\s*[:.h]\s*(\d{1,2})(?:\s*[:.]\s*(\d{1,2})(?:[.,](\d{1,3}))?)?)?\s*(a\.?m\.?|p\.?m\.?|a|p)?$/i,u=/^(\d{3,6})$/;function f(Ae,We,Ge,Je){return!(Ae>=0&&Ae<=23)||!(We>=0&&We<=59)||!(Ge>=0&&Ge<=59)||!(Je>=0&&Je<=999)?null:Ae*d+We*y+Ge*O+Je}function h(Ae){if(R(Ae))return null;const We=String(Ae).trim();if(We==="")return null;const Ge=u.exec(We);if(Ge){const Bt=Ge[1];if(Bt.length===5)return null;const $t=Bt.length===3?1:2;return f(Number(Bt.slice(0,$t)),Number(Bt.slice($t,$t+2)),Number(Bt.slice($t+2,$t+4)||0),0)}const Je=l.exec(We);if(!Je)return null;let ut=Number(Je[1]);const vt=Number(Je[2]||0),Ct=Number(Je[3]||0),xt=Je[4]?Number(Je[4].padEnd(3,"0")):0,Lt=Je[5]?Je[5][0].toLowerCase():null;if(Lt){if(ut<1||ut>12)return null;ut=ut%12,Lt==="p"&&(ut+=12)}return f(ut,vt,Ct,xt)}function g(Ae){return R(Ae)||Ae===""?null:typeof Ae=="number"?Number.isFinite(Ae)?(Ae%c+c)%c:null:Ae instanceof Date?Number.isNaN(Ae.getTime())?null:Ae.getHours()*d+Ae.getMinutes()*y+Ae.getSeconds()*O+Ae.getMilliseconds():h(Ae)}const b=new Map;function p(Ae){const We=Ae.pattern||"",Ge=Ae.timeStyle||(Ae.seconds?"medium":"short"),Je=`${Ae.locale||""}|${We}|${Ge}`;let ut=b.get(Je);if(ut)return ut;if(We)ut=Z(We,Ae.locale||void 0,"UTC");else{const vt=new Intl.DateTimeFormat(Ae.locale||void 0,{timeStyle:Ge,timeZone:"UTC"});ut=Ct=>vt.format(Ct)}return b.set(Je,ut),ut}function m(Ae,We){const Ge=We||k;if(Ae==null||typeof Ae!="number"||!Number.isFinite(Ae))return Ge.nullDisplay??"";const Je=(Ae%c+c)%c;return p(Ge)(new Date(Je))}function w(Ae){return Ae instanceof Date?!Number.isNaN(Ae.getTime()):typeof Ae=="number"?Number.isFinite(Ae)&&Ae>=0&&Ae<c:typeof Ae!="string"||!Ae.includes(":")?!1:h(Ae)!==null}function v(Ae){const We=g(Ae);return We==null?"":m(We,{pattern:We%O===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const a=new Map;function o(Ae){const We=Ae||"";let Ge=a.get(We);return Ge||(Ge=new Intl.DateTimeFormat("en-GB",{timeZone:Ae||void 0,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),a.set(We,Ge)),Ge}function S(Ae,We){const Ge={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const Je of o(We).formatToParts(new Date(Ae)))Je.type==="year"?Ge.year=Number(Je.value):Je.type==="month"?Ge.month=Number(Je.value):Je.type==="day"?Ge.day=Number(Je.value):Je.type==="hour"?Ge.hour=Number(Je.value)%24:Je.type==="minute"?Ge.minute=Number(Je.value):Je.type==="second"&&(Ge.second=Number(Je.value));return Ge}function E(Ae,We){const Ge=S(Ae,We);return Date.UTC(Ge.year,Ge.month-1,Ge.day,Ge.hour,Ge.minute,Ge.second,0)-Math.floor(Ae/1e3)*1e3}function A(Ae,We){const Ge=Ae.hour||0,Je=Ae.minute||0,ut=Ae.second||0,vt=Ae.ms||0;if(!We)return new Date(Ae.year,Ae.month-1,Ae.day,Ge,Je,ut,vt).getTime();const Ct=Date.UTC(Ae.year,Ae.month-1,Ae.day,Ge,Je,ut,vt);let xt=Ct-E(Ct,We);return xt=Ct-E(xt,We),xt}const M=/(?:Z|[+-]\d{2}:?\d{2})$/i,C=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function P(Ae,We){if(R(Ae))return null;const Ge=String(Ae).trim();if(Ge==="")return null;const Je=We&&We.timeZone||void 0;if(!M.test(Ge)){const ut=C.exec(Ge);if(ut){const vt=(ut[4]||"").trim(),Ct=vt===""?0:h(vt);if(Ct===null)return null;const xt=A({year:Number(ut[1]),month:Number(ut[2]),day:Number(ut[3]),hour:Math.floor(Ct/d),minute:Math.floor(Ct/y)%60,second:Math.floor(Ct/O)%60,ms:Ct%O},Je);return Number.isNaN(xt)?null:new Date(xt)}}return W(Ge)}function x(Ae){if(typeof Ae=="number")return Number.isFinite(Ae)?Ae:null;const We=W(Ae);return We?We.getTime():null}const K=new Map;function I(Ae){const We=[Ae.locale||"",Ae.pattern||"",Ae.dateStyle||"",Ae.timeStyle||"",Ae.timeZone||"",Ae.seconds?"1":""].join("|");let Ge=K.get(We);if(Ge)return Ge;const Je=Ae.pattern?{type:"date",pattern:Ae.pattern,timeZone:Ae.timeZone}:{type:"date",dateStyle:Ae.dateStyle||"medium",timeStyle:Ae.timeStyle||(Ae.seconds?"medium":"short"),timeZone:Ae.timeZone};return Ge=H(Je,Ae.locale||void 0),K.set(We,Ge),Ge}function D(Ae,We){const Ge=We||k,Je=x(Ae);return Je==null?Ge.nullDisplay??"":I(Ge)(Je)}function j(Ae){return Ae instanceof Date?!Number.isNaN(Ae.getTime()):typeof Ae!="string"||!C.test(Ae.trim())?!1:P(Ae)!==null}const T=Object.freeze([{key:"w",ms:r,intl:"week",long:["week","weeks"],names:["w","wk","wks","week","weeks"]},{key:"d",ms:c,intl:"day",long:["day","days"],names:["d","dy","day","days"]},{key:"h",ms:d,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:O,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 Ae of T)for(const We of Ae.names)B.set(We,Ae);const q=Object.freeze(T.filter(Ae=>Ae.key!=="w")),X=/^(\d+(?:\.\d+)?)\s*([a-z]+)\s*(?:,\s*)?/,Q=/^\d+(?:\.\d+)?$/,J=/^(\d+):([0-5]?\d)(?::([0-5]?\d))?(?:\.(\d{1,3}))?$/;function ne(Ae){const We=Ae&&Ae.defaultUnit?B.get(String(Ae.defaultUnit).toLowerCase()):null;return We?We.ms:y}function re(Ae){return(Ae&&Ae.defaultUnit?B.get(String(Ae.defaultUnit).toLowerCase()):null)||B.get("m")}function oe(Ae,We){if(R(Ae))return null;let Ge=String(Ae).trim().toLowerCase();if(Ge==="")return null;let Je=1;if(Ge[0]==="-"?(Je=-1,Ge=Ge.slice(1).trim()):Ge[0]==="+"&&(Ge=Ge.slice(1).trim()),Ge==="")return null;const ut=J.exec(Ge);if(ut){const Lt=ut[3]!==void 0,Bt=Number(ut[1])*d+Number(ut[2])*y+(Lt?Number(ut[3])*O:0)+(ut[4]?Number(ut[4].padEnd(3,"0")):0);return Je*Bt}if(Q.test(Ge))return Math.round(Je*Number(Ge)*ne(We||k));let vt=Ge,Ct=0,xt=0;for(;vt!=="";){const Lt=X.exec(vt);if(!Lt)return null;const Bt=B.get(Lt[2]);if(!Bt)return null;Ct+=Number(Lt[1])*Bt.ms,vt=vt.slice(Lt[0].length),xt++}return xt===0?null:Math.round(Je*Ct)}function ie(Ae){return R(Ae)||Ae===""?null:typeof Ae=="number"?Number.isFinite(Ae)?Ae:null:oe(Ae)}const te=new Map;function ce(Ae,We,Ge){const Je=`${Ge||""}|${We.intl}`;let ut=te.get(Je);if(ut===void 0){try{ut=new Intl.NumberFormat(Ge||void 0,{style:"unit",unit:We.intl,unitDisplay:"long"})}catch{ut=null}te.set(Je,ut)}return ut?ut.format(Ae):`${Ae} ${Ae===1?We.long[0]:We.long[1]}`}function ue(Ae,We){return String(Ae).padStart(We,"0")}function ae(Ae,We){const Ge=We||k;if(Ae==null||typeof Ae!="number"||!Number.isFinite(Ae))return Ge.nullDisplay??"";const Je=Ge.style||"short",ut=Ae<0;let vt=Math.round(Math.abs(Ae));const Ct=ut?"-":"";if(vt===0&&Ge.zeroDisplay!=null)return Ge.zeroDisplay;if(Je==="clock"){const $t=Math.floor(vt/d),Zt=Math.floor(vt/y)%60,Jt=Math.floor(vt/O)%60;return`${Ct}${ue($t,2)}:${ue(Zt,2)}:${ue(Jt,2)}`}if(vt===0){const $t=re(Ge);return Je==="long"?ce(0,$t,Ge.locale):`0${$t.key}`}const xt=Ge.weeks===!0?T:q,Lt=typeof Ge.maxUnits=="number"&&Ge.maxUnits>0?Ge.maxUnits:Ge.maxUnits===void 0?2:1/0,Bt=[];for(const $t of xt){if(Bt.length>=Lt)break;const Zt=Math.floor(vt/$t.ms);Zt!==0&&(vt-=Zt*$t.ms,Bt.push(Je==="long"?ce(Zt,$t,Ge.locale):`${Zt}${$t.key}`))}return Ct+Bt.join(" ")}function pe(Ae){if(typeof Ae!="string")return!1;const We=Ae.trim();return We===""||J.test(We)||!/[a-z]/i.test(We)?!1:oe(We)!==null}const he=Date.UTC(1899,11,30),ve=new Map;function Oe(Ae,We){const Ge=Ae||"";let Je=ve.get(Ge);Je||(Je=new Intl.DateTimeFormat("en-GB",{timeZone:Ae||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),ve.set(Ge,Je));const ut=typeof We=="number"?We:Date.now();for(const vt of Je.formatToParts(new Date(ut)))if(vt.type==="timeZoneName")return vt.value;return""}function Ie(Ae){if(Ae)return Ae;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function Ze(Ae,We){const Ge=Ie(Ae),Je=Oe(Ae,We);return Je?`${Ge} (${Je})`:Ge}function Se(Ae,We){if(Ae&&Ae.timeZone)return Ae.timeZone;const Ge=We&&We.grid;return(Ge&&$(Ge.get)?Ge.get("timeZone"):void 0)||void 0}function xe(Ae,We){const Ge=We||k,Je=x(Ae);if(Je==null)return Ge.nullDisplay??"";const ut=I(Ge)(Je);if(!Ge.showOrigin)return ut;const vt=Ge.originZone;return vt?vt===(Ge.timeZone||Ie(Ge.timeZone))?ut:`${ut} (${Ze(vt,Je)})`:`${ut} (no origin recorded)`}function Be(Ae,We,Ge,Je){if(We==="instant"||!We)return Ae;const ut=S(Ae,Ge);if(We==="month")return A({year:ut.year,month:ut.month,day:1},Ge);if(We==="week"){const vt=Je>=1&&Je<=7?Je:1,xt=((new Date(Date.UTC(ut.year,ut.month-1,ut.day)).getUTCDay()+6)%7+1-vt+7)%7,Lt=new Date(Date.UTC(ut.year,ut.month-1,ut.day-xt));return A({year:Lt.getUTCFullYear(),month:Lt.getUTCMonth()+1,day:Lt.getUTCDate()},Ge)}return A({year:ut.year,month:ut.month,day:ut.day},Ge)}function _e(Ae,We){const Ge=Ae&&Ae.group,Je=Ge&&Ge.granularity||"day";if(Je==="instant")return null;const ut=Ge&&Ge.weekStart;return vt=>typeof vt=="number"?Be(vt,Je,We,ut):vt}const He={time:{base:"number",storage:"float64",matches:w,format:Ae=>m(g(Ae.value),n(Ae,"time")),parse:Ae=>h(Ae.text),compare:(Ae,We)=>s(g(Ae),g(We)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:Ae=>{const We=g(Ae);return We===null?null:We/F},toStorage:Ae=>g(Ae),toClipboard:v,fromClipboard:h},datetime:{base:"dateString",storage:"dictionary",matches:j,format:Ae=>D(Ae.value,n(Ae,"datetime")),parse:Ae=>U(P(Ae.text,n(Ae,"datetime"))??Ae.text),compare:z,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(Ae,We)=>U(Ae,We&&We.timeZone),toClipboard:Ae=>R(Ae)?"":String(Ae),fromClipboard:Ae=>U(Ae)},duration:{base:"number",storage:"float64",matches:pe,format:Ae=>ae(ie(Ae.value),n(Ae,"duration")),parse:Ae=>oe(Ae.text,n(Ae,"duration")),compare:(Ae,We)=>s(ie(Ae),ie(We)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:Ae=>{const We=ie(Ae);return We===null?null:We/F},toStorage:Ae=>ie(Ae),toClipboard:Ae=>ae(ie(Ae),{style:"short",maxUnits:-1}),fromClipboard:Ae=>oe(Ae)},timestamp:{base:"number",storage:"float64",format:Ae=>{const We=n(Ae,"timestamp");return xe(Ae.value,{...We,timeZone:Se(We,Ae)})},parse:Ae=>{const We=n(Ae,"timestamp"),Ge=P(Ae.text,{timeZone:Se(We,Ae)});return Ge?Ge.getTime():null},compare:(Ae,We)=>s(x(Ae),x(We)),groupProjector:(Ae,We)=>_e(Ae,We),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(Ae,We)=>{const Ge=x(Ae);if(Ge==null)return null;const Je=S(Ge,We&&We.timeZone||void 0);return(Date.UTC(Je.year,Je.month-1,Je.day,Je.hour,Je.minute,Je.second)-he)/F},toStorage:Ae=>x(Ae),toClipboard:Ae=>{const We=x(Ae);return We==null?"":new Date(We).toISOString()},fromClipboard:Ae=>x(Ae)}},et=["datetime","time","duration"],lt=He}),ke("packages/core/src/columns/types/network.js",function(e,V){"use strict";Object.defineProperty(e,"toUint32",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"isIpv4",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"compareIpv4",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"packCidr",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"cidrParts",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isCidr",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"compareCidr",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"netmask",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"addressCount",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return g}}),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 S}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"isIpv6",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return P}});const _=V("packages/core/src/internal/util.js"),R=_.isNil,$=_.Lru,L=4294967295,W=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function Z(x){if(R(x))return null;if(typeof x=="string")return H(x);const K=Number(x);return Number.isFinite(K)?K<0?K<-2147483648?null:K>>>0:K>L?null:Math.trunc(K)>>>0:null}function H(x){if(R(x))return null;const K=String(x).trim();if(K==="")return null;const I=W.exec(K);if(!I)return null;let D=0;for(let j=1;j<=4;j++){const T=I[j];if(T.length>1&&T.charCodeAt(0)===48)return null;const B=Number(T);if(B>255)return null;D=D*256+B}return D}function U(x){const K=Z(x);return K===null?"":`${K>>>24&255}.${K>>>16&255}.${K>>>8&255}.${K&255}`}function z(x){return typeof x=="string"&&H(x)!==null}function F(x,K){const I=Z(x),D=Z(K);return I===null?D===null?0:1:D===null||I<D?-1:I>D?1:0}const k=64,O=L*k+32,y=/^(?:0|[1-9]\d?)$/;function d(x,K){return x*k+K}function c(x){if(R(x))return null;if(typeof x=="string"){const D=r(x);return D===null?null:c(D)}if(typeof x=="object"){const D=Z(x.address),j=Number(x.prefix);return D===null||!Number.isInteger(j)||j<0||j>32?null:{address:D,prefix:j}}const K=Number(x);if(!Number.isInteger(K)||K<0||K>O)return null;const I=K%k;return I>32?null:{address:(K-I)/k,prefix:I}}function r(x){if(R(x))return null;const K=String(x).trim();if(K==="")return null;const I=K.indexOf("/");if(I<0)return null;const D=H(K.slice(0,I));if(D===null)return null;const j=K.slice(I+1).trim();if(!y.test(j))return null;const T=Number(j);return T>32?null:d(D,T)}function t(x){const K=c(x);return K?`${U(K.address)}/${K.prefix}`:""}function n(x){return typeof x=="string"&&r(x)!==null}function i(x,K){const I=c(x),D=c(K);return I?D?I.address!==D.address?I.address<D.address?-1:1:I.prefix-D.prefix:-1:D?1:0}function s(x){return x===0?0:4294967295<<32-x>>>0}function l(x){const K=c(x);return K?(K.address&s(K.prefix))>>>0:null}function u(x){const K=c(x);return K?(K.address&s(K.prefix)|~s(K.prefix)>>>0)>>>0:null}function f(x){const K=c(x);return K?2**(32-K.prefix):null}function h(x){const K=c(x);return K?K.prefix===32?1:K.prefix===31?2:2**(32-K.prefix)-2:null}function g(x,K){const I=c(x);if(!I)return!1;const D=Z(K);if(D===null)return!1;const j=s(I.prefix);return(D&j)>>>0===(I.address&j)>>>0}function b(x,K){const I=l(x),D=l(K);return I===null||D===null?!1:I<=u(K)&&D<=u(x)}const p=/^[0-9a-fA-F]{1,4}$/,m=new $(512);function w(x){if(R(x))return null;let K=String(x).trim();if(K==="")return null;const I=K.indexOf("%");if(I>=0&&(K=K.slice(0,I)),K==="")return null;if(K.indexOf(".")>=0){const X=K.lastIndexOf(":");if(X<0)return null;const Q=H(K.slice(X+1));if(Q===null)return null;K=`${K.slice(0,X+1)}${(Q>>>16&65535).toString(16)}:${(Q&65535).toString(16)}`}const D=K.split("::");if(D.length>2)return null;const j=v(D[0]);if(j===null)return null;if(D.length===1)return j.length===8?j:null;const T=v(D[1]);if(T===null)return null;const B=8-j.length-T.length;if(B<1)return null;const q=j.slice();for(let X=0;X<B;X++)q.push(0);for(const X of T)q.push(X);return q}function v(x){if(x==="")return[];const K=[];for(const I of x.split(":")){if(!p.test(I))return null;K.push(parseInt(I,16))}return K}function a(x){if(typeof x!="string")return w(x);if(m.has(x))return m.get(x);const K=w(x);return m.set(x,K),K}function o(x){if(x[0]===0&&x[1]===0&&x[2]===0&&x[3]===0&&x[4]===0&&x[5]===65535)return`::ffff:${U((x[6]<<16|x[7])>>>0)}`;let K=-1,I=0,D=-1,j=0;for(let q=0;q<8;q++)x[q]===0?(D<0?(D=q,j=1):j++,j>I&&(I=j,K=D)):(D=-1,j=0);if(I<2)return x.map(q=>q.toString(16)).join(":");const T=x.slice(0,K).map(q=>q.toString(16)).join(":"),B=x.slice(K+I).map(q=>q.toString(16)).join(":");return`${T}::${B}`}function S(x){const K=w(x);return K===null?null:o(K)}function E(x){return S(x)??""}function A(x){return typeof x=="string"&&x.indexOf(":")>=0&&w(x)!==null}function M(x,K){const I=a(x),D=a(K);if(!I)return D?1:0;if(!D)return-1;for(let j=0;j<8;j++)if(I[j]!==D[j])return I[j]<D[j]?-1:1;return 0}const C=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:z,parse:x=>H(x.text),compare:F,format:x=>U(x.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:x=>Z(x),toClipboard:x=>U(x),fromClipboard:x=>H(x)},cidr:{base:"number",storage:"float64",matches:n,parse:x=>r(x.text),compare:i,format:x=>t(x.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:x=>{const K=c(x);return K===null?null:d(K.address,K.prefix)},toClipboard:x=>t(x),fromClipboard:x=>r(x)},ipv6:{base:"text",storage:"dictionary",matches:A,parse:x=>S(x.text),compare:M,format:x=>E(x.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",toStorage:x=>S(x),toClipboard:x=>E(x),fromClipboard:x=>S(x)}}),P=C}),ke("packages/core/src/i18n/catalogue.js",function(e,V){"use strict";Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return R}});const _=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.dataTable":"Chart data","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"}),R=Object.freeze(Object.keys(_))}),ke("packages/core/src/i18n/format.js",function(e,V){"use strict";Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"formatMessage",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"lookup",{enumerable:!0,get:function(){return O}});const R=V("packages/core/src/internal/util.js").isFunction,$=/\{(\w+)\}/g,L=new Map,W=new Map;function Z(y){const d=y||"";if(L.has(d))return L.get(d);let c=null;try{c=new Intl.PluralRules(y||void 0)}catch{c=null}return L.set(d,c),c}function H(y,d,c="conjunction"){const r=Array.isArray(y)?y.filter(i=>i!=null&&i!==""):[];if(r.length===0)return"";if(r.length===1)return String(r[0]);const t=`${d||""}|${c}`;let n=W.get(t);if(n===void 0){try{n=new Intl.ListFormat(d||void 0,{style:"long",type:c})}catch{n=null}W.set(t,n)}return n?n.format(r.map(String)):r.map(String).join(", ")}function U(y,d){return y==null?"":typeof y=="number"?Number.isFinite(y)?y.toLocaleString(d||void 0,{maximumFractionDigits:20}):"":String(y)}function z(y,d,c){if(typeof y=="string")return y;if(!y||typeof y!="object")return"";const r=d&&typeof d.count=="number"?d.count:null;if(r===null)return y.other??"";const t=Z(c),n=t?t.select(r):r===1?"one":"other";return y[n]??y.other??""}function F(y,d={},c){const r=z(y,d,c);return r?r.replace($,(t,n)=>Object.prototype.hasOwnProperty.call(d,n)?U(d[n],c):t):""}function k(y,d,c="en-GB"){return typeof y=="string"&&y?y:typeof d=="string"&&d?d:c}function O(y,d){const c=y?y[d]:void 0;return c==null||R(c)?d:c}}),ke("packages/core/src/i18n/index.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"defaultMessages",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return r}});const _=V("packages/core/src/i18n/catalogue.js"),R=_.EN_GB,$=_.MESSAGE_KEYS,L=V("packages/core/src/i18n/format.js"),W=L.formatMessage,Z=L.formatList,H=L.lookup,U=L.resolveLocale,z=V("packages/core/src/internal/util.js"),F=z.isFunction,k=z.warnOnce;Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return _.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return _.MESSAGE_KEYS}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return L.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return L.resolveLocale}});const O="en-GB";class y{#e=O;#t=R;constructor(n={}){this.configure(n)}configure(n={}){this.#e=U(n.locale,n.declared,O);const i=n.messages;if(!i||typeof i!="object"){this.#t=R;return}const s=Object.keys(i).filter(l=>!(l in R));s.length&&k(`i18n:unknown:${s[0]}`,`message keys not in the catalogue and so ignored: ${s.slice(0,5).join(", ")}${s.length>5?`, and ${s.length-5} more`:""}`),this.#t={...R,...i}}get locale(){return this.#e}t(n,i){return W(H(this.#t,n),i||{},this.#e)}list(n,i){return Z(n,this.#e,i)}number(n,i){const s=Number(n);return Number.isFinite(s)?s.toLocaleString(this.#e,i||{maximumFractionDigits:20}):""}}const d=new y;function c(t){return t instanceof y?t:new y(t||{})}function r(t){const n=t&&typeof t=="object"?t:{},i=$.filter(l=>{const u=n[l];return u==null||u===""||F(u)}),s=Object.keys(n).filter(l=>!(l in R));return{missing:i,unknown:s}}}),ke("packages/core/src/columns/types/structured.js",function(e,V){"use strict";Object.defineProperty(e,"MASK_DEFAULTS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"canonicalJson",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"parseJsonText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const _=V("packages/core/src/internal/util.js"),R=_.isNil,$=_.isObject,W=V("packages/core/src/i18n/index.js").defaultMessages,Z=Object.freeze({char:"•",length:8,fixedLength:!0,lastVisible:0,emptyDisplay:""});function H(t,n){const i=n||{},s=i.emptyDisplay??Z.emptyDisplay;if(R(t)||t==="")return s;const u=[...typeof i.char=="string"&&i.char!==""?i.char:Z.char][0]||Z.char,f=i.fixedLength??Z.fixedLength,h=Number.isFinite(i.length)&&Number(i.length)>0?Math.floor(Number(i.length)):Z.length,g=typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?String(t):null;let b=0;if(g!==null){const p=Number.isFinite(i.lastVisible)?Math.floor(Number(i.lastVisible)):Z.lastVisible,m=[...g];if(b=p>0&&p<m.length?p:0,b>0){const w=m.slice(m.length-b).join(""),v=Math.max(1,(f?h:m.length)-b);return u.repeat(v)+w}return u.repeat(f?h:Math.max(1,m.length))}return u.repeat(h)}const U=48;function z(t){try{const n=JSON.stringify(t);return n===void 0?null:n}catch{return null}}function F(t,n){if(R(t))return"";const i=Number.isFinite(n&&n.inlineLimit)?Number(n.inlineLimit):U;if(typeof t=="string")return t.length>i?`${t.slice(0,i-1)}…`:t;if(typeof t!="object")return String(t);const s=z(t);if(s!==null&&s.length<=i)return s;if(Array.isArray(t)){const u=t.length;return`[${W.t("count.items",{count:u})}]`}const l=Object.keys(t).length;return`{${W.t("count.keys",{count:l})}}`}function k(t,n){if(t==null)return"null";const i=typeof t;if(i==="number"||i==="boolean"||i==="bigint")return String(t);if(i==="string")return JSON.stringify(t);if(i!=="object")return JSON.stringify(String(t));const s=n||new WeakSet;return s.has(t)?'"[circular]"':(s.add(t),t instanceof Date?JSON.stringify(t.toISOString()):Array.isArray(t)?`[${t.map(f=>k(f,s)).join(",")}]`:`{${Object.keys(t).sort().map(f=>`${JSON.stringify(f)}:${k(t[f],s)}`).join(",")}}`)}function O(t,n){if(R(t))return R(n)?0:1;if(R(n))return-1;const i=k(t),s=k(n);return i<s?-1:i>s?1:0}function y(t){if(R(t))return null;const n=String(t);if(n.trim()==="")return null;try{return JSON.parse(n)}catch{return n}}function d(t){const n=t&&t.cell&&t.cell.props;return $(n)?n:{}}const c=Object.freeze({json:{base:"object",storage:"object",format:t=>F(t&&t.value,d(t&&t.column)),parse:t=>y(t&&t.text),compare:O,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:t=>{if(R(t))return"";if(typeof t=="string")return t;try{const n=JSON.stringify(t,null,2);return n===void 0?String(t):n}catch{return String(t)}},fromClipboard:t=>y(t)},secret:{base:"text",storage:"object",format:t=>H(t&&t.value,d(t&&t.column)),parse:t=>{const n=t&&t.text;return R(n)||String(n)===""?null:String(n)},compare:(t,n)=>{const i=R(t)||t==="",s=R(n)||n==="";return i===s?0:i?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:t=>H(t),fromClipboard:t=>R(t)||String(t)===""?null:String(t)}}),r=c}),ke("packages/core/src/columns/types/unit.js",function(e,V){"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 F}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return D}});const _=V("packages/core/src/internal/util.js"),R=_.isNil,$=_.warnOnce;function L(j,T,B,q){return Object.freeze({symbol:j,factor:T,aliases:Object.freeze(B||[]),binary:!!(q&&q.binary),prefix:q&&q.prefix||null,auto:!(q&&q.auto===!1)})}function W(j,T,B,q){return L(j,T,B,q)}const Z=Object.freeze({data:Object.freeze([L("B",1,["byte","bytes"]),L("kB",1e3,["kilobyte","kilobytes"],{prefix:"k"}),L("KiB",1024,["kibibyte","kibibytes"],{binary:!0,prefix:"k"}),L("MB",1e6,["megabyte","megabytes"],{prefix:"m"}),L("MiB",1024**2,["mebibyte","mebibytes"],{binary:!0,prefix:"m"}),L("GB",1e9,["gigabyte","gigabytes"],{prefix:"g"}),L("GiB",1024**3,["gibibyte","gibibytes"],{binary:!0,prefix:"g"}),L("TB",1e12,["terabyte","terabytes"],{prefix:"t"}),L("TiB",1024**4,["tebibyte","tebibytes"],{binary:!0,prefix:"t"}),L("PB",1e15,["petabyte","petabytes"],{prefix:"p"})]),bitrate:Object.freeze([L("bps",1,["bit","bits","bit/s","b/s"]),L("kbps",1e3,["kbit","kbits","kbit/s","kb/s","kilobit","kilobits"],{prefix:"k"}),L("Mbps",1e6,["mbit","mbits","mbit/s","mb/s","megabit","megabits"],{prefix:"m"}),L("Gbps",1e9,["gbit","gbits","gbit/s","gb/s","gigabit","gigabits"],{prefix:"g"}),L("Tbps",1e12,["tbit","tbits","tbit/s","tb/s","terabit","terabits"],{prefix:"t"})]),length:Object.freeze([L("nm",1e-9,["nanometre","nanometres","nanometer","nanometers"]),L("µm",1e-6,["um","micrometre","micrometres","micrometer","micrometers","micron","microns"]),L("mm",.001,["millimetre","millimetres","millimeter","millimeters"]),L("cm",.01,["centimetre","centimetres","centimeter","centimeters"]),L("in",.0254,["inch","inches"],{auto:!1}),L("ft",.3048,["foot","feet"],{auto:!1}),L("yd",.9144,["yard","yards"],{auto:!1}),L("m",1,["metre","metres","meter","meters"]),L("km",1e3,["kilometre","kilometres","kilometer","kilometers"]),L("mi",1609.344,["mile","miles"],{auto:!1}),L("nmi",1852,["nauticalmile","nauticalmiles"],{auto:!1})]),mass:Object.freeze([L("mg",.001,["milligram","milligrams"]),L("g",1,["gram","grams"]),L("oz",28.349523125,["ounce","ounces"],{auto:!1}),L("lb",453.59237,["pound","pounds","lbs"],{auto:!1}),L("kg",1e3,["kilogram","kilograms"]),L("st",6350.29318,["stone"],{auto:!1}),L("t",1e6,["tonne","tonnes","ton"],{auto:!1}),L("ton (US)",907184.74,["ton","shortton"],{auto:!1}),L("ton (UK)",10160469088e-4,["ton","longton"],{auto:!1})]),duration:Object.freeze([L("ns",1e-9,["nsec","nsecs","nanosecond","nanoseconds"]),L("µs",1e-6,["us","usec","usecs","microsecond","microseconds"]),L("ms",.001,["msec","msecs","millisecond","milliseconds"]),L("s",1,["sec","secs","second","seconds"]),L("m",60,["min","mins","minute","minutes"]),L("h",3600,["hr","hrs","hour","hours"]),L("d",86400,["day","days"])]),speed:Object.freeze([L("mm/s",.001,["millimetre/s","millimeter/s"]),L("ft/s",.3048,["fps","foot/s","feet/s"],{auto:!1}),L("km/h",1/3.6,["kph","kmh","kilometre/h","kilometer/h"],{auto:!1}),L("mph",.44704,["mile/h","miles/h"],{auto:!1}),L("kn",1852/3600,["knot","knots"],{auto:!1}),L("m/s",1,["metre/s","meter/s","mps"]),L("km/s",1e3,["kilometre/s","kilometer/s"])]),acceleration:Object.freeze([L("mm/s²",.001,["mm/s2"]),L("ft/s²",.3048,["ft/s2"],{auto:!1}),L("m/s²",1,["m/s2","metre/s2","meter/s2"]),L("g",9.80665,["gee","gravity"],{auto:!1})]),area:Object.freeze([L("mm²",1e-6,["mm2"]),L("cm²",1e-4,["cm2"]),L("in²",64516e-8,["in2","sqin"],{auto:!1}),L("ft²",.09290304,["ft2","sqft"],{auto:!1}),L("yd²",.83612736,["yd2","sqyd"],{auto:!1}),L("m²",1,["m2","sqm"]),L("ha",1e4,["hectare","hectares"],{auto:!1}),L("ac",4046.8564224,["acre","acres"],{auto:!1}),L("km²",1e6,["km2","sqkm"])]),volume:Object.freeze([L("µL",1e-6,["ul","microlitre","microliter"]),L("mL",.001,["millilitre","milliliter"]),L("fl oz (US)",.0295735295625,["fl oz","usfloz"],{auto:!1}),L("fl oz (imp)",.0284130625,["fl oz","impfloz"],{auto:!1}),L("L",1,["litre","litres","liter","liters"]),L("gal (US)",3.785411784,["gal","usgal","usgallon"],{auto:!1}),L("gal (imp)",4.54609,["gal","impgal","impgallon"],{auto:!1}),L("m³",1e3,["m3","cubicmetre","cubicmeter","kl"],{auto:!1}),L("bbl",158.987294928,["barrel","barrels"],{auto:!1})]),energy:Object.freeze([L("eV",1602176634e-28,["electronvolt","electronvolts"],{auto:!1}),L("J",1,["joule","joules"]),L("cal",4.184,["calorie","calories"],{auto:!1}),L("kJ",1e3,["kilojoule","kilojoules"]),L("BTU",1055.05585262,["btu"],{auto:!1}),L("kcal",4184,["kilocalorie","kilocalories","Cal"],{auto:!1}),L("MJ",1e6,["megajoule","megajoules"]),L("kWh",36e5,["kilowatthour","kilowatthours"],{auto:!1}),L("GJ",1e9,["gigajoule","gigajoules"]),L("MWh",36e8,["megawatthour","megawatthours"],{auto:!1})]),power:Object.freeze([L("mW",.001,["milliwatt","milliwatts"]),L("W",1,["watt","watts"]),L("BTU/h",1055.05585262/3600,["btuh","btu/h"],{auto:!1}),L("kW",1e3,["kilowatt","kilowatts"]),L("hp",745.6998715822702,["horsepower"],{auto:!1}),L("MW",1e6,["megawatt","megawatts"]),L("GW",1e9,["gigawatt","gigawatts"])]),force:Object.freeze([L("mN",.001,["millinewton","millinewtons"]),L("N",1,["newton","newtons"]),L("lbf",4.4482216152605,["poundforce"],{auto:!1}),L("kgf",9.80665,["kilogramforce"],{auto:!1}),L("kN",1e3,["kilonewton","kilonewtons"]),L("MN",1e6,["meganewton","meganewtons"])]),pressure:Object.freeze([L("Pa",1,["pascal","pascals"]),L("mbar",100,["millibar"],{auto:!1}),L("inH₂O",249.0889,["inh2o"],{auto:!1}),L("mmHg",133.322387415,["torr"],{auto:!1}),L("kPa",1e3,["kilopascal","kilopascals"]),L("inHg",3386.388640341,["inhg"],{auto:!1}),L("psi",6894.757293168361,["lbf/in2"],{auto:!1}),L("bar",1e5,[],{auto:!1}),L("atm",101325,["atmosphere","atmospheres"],{auto:!1}),L("MPa",1e6,["megapascal","megapascals"]),L("GPa",1e9,["gigapascal","gigapascals"])]),torque:Object.freeze([L("N·m",1,["nm","n.m","newtonmetre","newtonmeter"]),L("lbf·ft",1.3558179483314003,["lbfft","lbf.ft","ftlb","ft-lb"],{auto:!1}),L("kN·m",1e3,["knm","kn.m"],{auto:!1}),L("MN·m",1e6,["mnm","mn.m"],{auto:!1})]),density:Object.freeze([L("kg/m³",1,["kg/m3"]),L("lb/ft³",16.01846337396014,["lb/ft3","pcf"],{auto:!1}),L("g/cm³",1e3,["g/cm3","g/ml","kg/l"],{auto:!1}),L("t/m³",1e3,["t/m3"],{auto:!1})]),flow:Object.freeze([L("L/min",1/6e4,["lpm","l/min"],{auto:!1}),L("m³/h",1/3600,["m3/h","cmh"],{auto:!1}),L("gpm (US)",.003785411784/60,["gpm","usgpm"],{auto:!1}),L("gpm (imp)",.00454609/60,["gpm","impgpm"],{auto:!1}),L("cfm",.0004719474432,["ft3/min"],{auto:!1}),L("L/s",.001,["lps","l/s"],{auto:!1}),L("m³/s",1,["m3/s","cms"])]),angle:Object.freeze([L("″",Math.PI/648e3,["arcsec","arcsecond","arcseconds"],{auto:!1}),L("′",Math.PI/10800,["arcmin","arcminute","arcminutes"],{auto:!1}),L("mrad",.001,["milliradian","milliradians"],{auto:!1}),L("mil",Math.PI/3200,["nato-mil"],{auto:!1}),L("°",Math.PI/180,["deg","degree","degrees"],{auto:!1}),L("gon",Math.PI/200,["grad","gradian","gradians"],{auto:!1}),L("rad",1,["radian","radians"]),L("turn",2*Math.PI,["rev","revolution","revolutions"],{auto:!1})]),angularVelocity:Object.freeze([L("°/s",Math.PI/180,["degps","deg/s","degrees/s"],{auto:!1}),L("rad/s",1,["radps","radians/s"]),L("rpm",2*Math.PI/60,["rev/min","r/min","revolutions/min"],{auto:!1}),L("rps",2*Math.PI,["rev/s","r/s","revolutions/s"],{auto:!1})]),fraction:Object.freeze([L("ppt",1e-12,["partspertrillion"],{auto:!1}),L("ppb",1e-9,["partsperbillion"]),L("ppm",1e-6,["partspermillion"]),L("bp",1e-4,["bps-finance","basispoint","basispoints","bips"],{auto:!1}),L("‰",.001,["permille","permil"],{auto:!1}),L("%",.01,["pct","percent"]),L("×",1,["x","ratio","times"])]),molarity:Object.freeze([L("pM",1e-12,["picomolar","picomolarity"]),L("nM",1e-9,["nanomolar","nanomolarity"]),L("µM",1e-6,["um-molar","micromolar","micromolarity"]),L("mM",.001,["millimolar","millimolarity"]),L("M",1,["molar","mol/l","mol/L","molarity"]),L("mol/m³",.001,["mol/m3"],{auto:!1})]),massFlow:Object.freeze([L("mg/s",1e-6,["milligrams/s"]),L("g/s",.001,["grams/s"]),L("kg/h",1/3600,["kilograms/h","kgph"],{auto:!1}),L("kg/s",1,["kilograms/s","kgps"]),L("t/h",1e3/3600,["tonnes/h","tph"],{auto:!1}),L("lb/h",.45359237/3600,["pounds/h","pph"],{auto:!1}),L("t/s",1e3,["tonnes/s"],{auto:!1})]),viscosity:Object.freeze([L("µPa·s",1e-6,["upas","micropascalsecond"]),L("cP",.001,["centipoise"],{auto:!1}),L("mPa·s",.001,["mpas","millipascalsecond"]),L("P",.1,["poise"],{auto:!1}),L("Pa·s",1,["pas","pascalsecond"])]),kinematicViscosity:Object.freeze([L("cSt",1e-6,["centistokes","centistoke"]),L("mm²/s",1e-6,["mm2/s"],{auto:!1}),L("St",1e-4,["stokes","stoke"],{auto:!1}),L("m²/s",1,["m2/s"])]),thermalConductivity:Object.freeze([L("mW/(m·K)",.001,["mw/mk"]),L("W/(m·K)",1,["w/mk","wmk"]),L("kW/(m·K)",1e3,["kw/mk"],{auto:!1}),L("BTU/(hr·ft·°F)",1.730734666,["btu/hrftf"],{auto:!1})]),specificHeat:Object.freeze([L("J/(kg·K)",1,["j/kgk","jkgk"]),L("kJ/(kg·K)",1e3,["kj/kgk"]),L("cal/(g·°C)",4184,["cal/gc"],{auto:!1})]),doseRate:Object.freeze([L("nSv/h",1e-9,["nsvh"]),L("µSv/h",1e-6,["usv/h","usvh"]),L("mSv/h",.001,["msvh"]),L("Sv/h",1,["svh"]),L("mSv/a",.001/8766,["msv/year","msvpa"],{auto:!1})])}),H=Symbol("ambiguous"),U=new Map,z=new Map;function F(j,T){const B=String(j||"").trim();if(!B)throw new Error("[lattice] a unit system needs a name");if(Z[B]||z.has(B))throw new Error(`[lattice] unit system "${B}" already exists`);const q=[...T||[]];if(!q.length)throw new Error(`[lattice] unit system "${B}" has no units`);if(!q.some(Q=>Q.factor===1))throw new Error(`[lattice] unit system "${B}" has no base unit (none with factor 1)`);const X=new Set;for(const Q of q){if(X.has(Q.symbol))throw new Error(`[lattice] unit system "${B}" declares "${Q.symbol}" twice`);X.add(Q.symbol)}return z.set(B,Object.freeze(q)),U.delete(B),B}function k(){return[...Object.keys(Z),...z.keys()]}function O(j){const T=y(j);return T?T.units:[]}function y(j){const T=String(j||""),B=U.get(T);if(B!==void 0)return B;const q=Z[T]||z.get(T);if(!q)return U.set(T,null),null;const X=Object.freeze([...q].sort((oe,ie)=>oe.factor-ie.factor)),Q=new Map,J=new Map,ne=(oe,ie)=>{const te=Q.get(oe);te===void 0?Q.set(oe,ie):te!==ie&&Q.set(oe,H)};for(const oe of X){ne(oe.symbol.toLowerCase(),oe);for(const ie of oe.aliases)ne(ie.toLowerCase(),oe);if(oe.prefix){const ie=J.get(oe.prefix)||[];ie.push(oe),J.set(oe.prefix,ie)}}const re={units:X,byToken:Q,byPrefix:J,decimal:X.filter(oe=>!oe.binary&&oe.auto),binary:X.some(oe=>oe.binary)?X.filter(oe=>(oe.binary||oe.factor===1)&&oe.auto):null};return U.set(T,re),re}function d(j,T){return T&&j.binary||j.decimal}function c(j,T){const B=y(j);if(!B||R(T))return null;const q=B.units.find(Q=>Q.symbol===String(T));if(q)return q;const X=B.byToken.get(String(T).trim().toLowerCase());return X&&X!==H?X:null}const r=new WeakMap;function t(j){const T=j||{};if(typeof T=="object"&&T!==null){const Q=r.get(T);if(Q!==void 0)return Q}const B=T.system||"data",q=y(B);let X=null;if(!q)$(`unit:system:${B}`,`unknown unit system "${B}"; known systems are ${k().join(", ")}`);else{let Q=T.unit?c(B,T.unit):null;Q||(T.unit&&$(`unit:unit:${B}:${T.unit}`,`unknown unit "${T.unit}" in system "${B}"; falling back to ${q.units[0].symbol}`),Q=q.units.find(J=>J.factor===1)||q.units[0]),X={index:q,base:Q,binary:T.binary===!0}}return typeof T=="object"&&T!==null&&r.set(T,X),X}const n=new WeakMap;function i(j,T){if(!j||!T||!Array.isArray(j.compound)||j.compound.length===0)return null;const B=n.get(j);if(B!==void 0)return B;const q=new Set,X=[];for(const J of j.compound){const ne=c(j.system||"data",J);if(!ne){$(`unit:compound:${j.system}:${J}`,`unknown compound unit "${J}" in system "${j.system||"data"}"; ignoring it`);continue}q.has(ne.symbol)||(q.add(ne.symbol),X.push(ne))}X.sort((J,ne)=>ne.factor-J.factor);const Q=X.length>=2?X:null;return n.set(j,Q),Q}function s(j,T,B){return T===B||T.factor===B.factor?j:j*T.factor/B.factor}const l=new Map;function u(j){const T=j||"",B=l.get(T);if(B)return B;const q={group:",",decimal:"."};try{for(const X of new Intl.NumberFormat(j||void 0).formatToParts(12345.6))X.type==="group"?q.group=X.value:X.type==="decimal"&&(q.decimal=X.value)}catch{}return l.set(T,q),q}const f=/[\s   ]/g,h=/^[+-]?[\d   '’ .,]*(?:[eE][+-]?\d+)?/,g=/^[^\d+\-(.,\s]+\s*/,b=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function p(j,T){const{group:B,decimal:q}=u(T);let X=String(j).replace(f,"");if(X==="")return null;const Q=q?X.indexOf(q):-1;if(B&&B!==q){if(Q>=0&&X.indexOf(B,Q+q.length)>=0)return null;X=X.split(B).join("")}if(q&&q!=="."&&(X=X.split(q).join(".")),!b.test(X))return null;const J=Number(X);return Number.isFinite(J)?J:null}function m(j,T,B){const q=String(j).trim().replace(/\.$/,"");if(q==="")return null;const X=T.units.find(ie=>ie.symbol===q);if(X)return X;const Q=q.toLowerCase(),J=T.byToken.get(Q);if(J===H)return null;if(J)return J;const ne=T.byPrefix.get(Q);if(!ne||!ne.length)return null;const re=d(T,B),oe=ne.filter(ie=>re.includes(ie));return oe.length===1?oe[0]:null}function w(j,T,B,q){let X=j,Q=0,J=!1,ne=!1;for(;X!=="";){const re=h.exec(X)[0];if(re==="")return null;const oe=p(re,q&&q.locale);if(oe===null)return null;X=X.slice(re.length).trim();const ie=X.search(/[+-]?[\d]/),te=(ie>=0?X.slice(0,ie):X).trim();if(X=ie>=0?X.slice(ie).trim():"",te===""){if(J)return null;ne=!0,Q+=s(oe,B[0],T.base)}else{const ce=m(te,T.index,T.binary);if(!ce)return null;Q+=s(oe,ce,T.base)}if(J=!0,ne&&X!=="")return null}return J?Q:null}function v(j,T){if(R(j))return null;if(typeof j=="number")return Number.isFinite(j)?j:null;const B=t(T);if(!B)return null;let q=String(j).trim();if(q==="")return null;let X=!1;q.startsWith("(")&&q.endsWith(")")&&(X=!0,q=q.slice(1,-1).trim());const Q=i(T,B);if(Q){q.startsWith("-")&&(X=!0,q=q.slice(1).trim());const ue=w(q,B,Q,T);return ue===null?null:X?-ue:ue}let J=null;const ne=g.exec(q);if(ne&&ne[0]){const ue=m(ne[0].trim(),B.index,B.binary);ue&&(J=ue,q=q.slice(ne[0].length).trim())}const re=h.exec(q)[0],oe=p(re,T&&T.locale);if(oe===null)return null;const ie=q.slice(re.length).trim();if(J&&ie!=="")return null;const te=J||(ie===""?B.base:m(ie,B.index,B.binary));if(!te)return null;const ce=s(oe,te,B.base);return X?-ce:ce}const a=new Map;function o(j,T,B,q){const X=`${j||""}|${T}|${B}|${q?1:0}`;let Q=a.get(X);return Q||(Q=new Intl.NumberFormat(j||void 0,{minimumFractionDigits:T,maximumFractionDigits:B,useGrouping:q}),a.set(X,Q)),Q}function S(j,T){if(!Number.isFinite(j)||j===0)return Math.max(0,T-1);const B=Math.floor(Math.log10(Math.abs(j)));return Math.min(20,Math.max(0,T-1-B))}function E(j,T){if(!Number.isFinite(j)||j===0)return j;const B=Math.ceil(Math.log10(Math.abs(j))),q=10**(T-B);return Math.round(j*q)/q}function A(j,T,B){if(!B||B===T.base.symbol)return T.base;if(B!=="auto")return M(T,B);if(j===0||!Number.isFinite(j))return T.base;const q=Math.abs(j)*T.base.factor,X=d(T.index,T.binary);let Q=X[0];for(const re of X)q>=re.factor&&(Q=re);if(q>=Q.factor)return Q;let J=Q;for(const re of T.index.units)re.binary!==T.binary&&re.factor!==1||re.factor<=q&&re.factor>(J===Q?0:J.factor)&&(J=re);if(J!==Q)return J;let ne=Q;for(const re of T.index.units)re.binary!==T.binary&&re.factor!==1||re.factor<ne.factor&&(ne=re);return ne.factor<T.base.factor?ne:T.base}function M(j,T){const B=j.index.units.find(X=>X.symbol===T);if(B)return B;const q=j.index.byToken.get(String(T).toLowerCase());return q&&q!==H?q:($(`unit:display:${T}`,`unknown display unit "${T}"; rendering in ${j.base.symbol}`),j.base)}function C(j,T,B,q){const X=j<0;let Q=Math.abs(j)*T.base.factor;const J=typeof q.decimals=="number"?q.decimals:q.minDecimals??0,ne=typeof q.decimals=="number"?q.decimals:q.maxDecimals??Math.max(J,2),re=q.space??" ",oe=[];for(let te=0;te<B.length;te++){const ce=B[te],ue=te===B.length-1;let ae=ue?Q/ce.factor:Math.floor(Q/ce.factor);if(Q-=ae*ce.factor,ue){const he=10**ne;ae=Math.round(ae*he)/he+0}const pe=ue?o(q.locale,J,ne,q.group!==!1):o(q.locale,0,0,q.group!==!1);oe.push(`${pe.format(ae)}${re}${ce.symbol}`)}const ie=oe.join(" ");return X?`-${ie}`:ie}function P(j,T){const B=T||{},q=B.nullDisplay??"";if(R(j)||j==="")return q;const X=typeof j=="number"?j:Number(j);if(!Number.isFinite(X))return q;const Q=t(B);if(!Q)return String(X);const J=i(B,Q);if(J)return C(X,Q,J,B);const ne=typeof B.significantFigures=="number"&&B.significantFigures>0?B.significantFigures:0,re=ne?E(X,ne):X,oe=A(re,Q,B.display),ie=s(re,Q.base,oe);let te=typeof B.decimals=="number"?B.decimals:B.minDecimals??0,ce=typeof B.decimals=="number"?B.decimals:B.maxDecimals??Math.max(te,2);ne&&(te=S(ie,ne),ce=te);const ue=o(B.locale,te,ce,B.group!==!1).format(ie),ae=B.space??" ";return B.placement==="prefix"?`${oe.symbol}${B.space??""}${ue}`:`${ue}${ae}${oe.symbol}`}function x(j,T){const B=R(j)||Number.isNaN(j)?null:Number(j),q=R(T)||Number.isNaN(T)?null:Number(T);return B===null||Number.isNaN(B)?q===null||Number.isNaN(q)?0:1:q===null||Number.isNaN(q)||B<q?-1:B>q?1:0}function K(j){const T=typeof j.decimals=="number"&&j.decimals>0?`.${"0".repeat(j.decimals)}`:"";return`${typeof j.decimals=="number"?`#,##0${T}`:"#,##0.##"}" ${j.symbol}"`}function I(j){const T={system:"data",...j||{}},B=t(T),q=B?B.base.symbol:String(T.unit||""),X=Object.freeze({...T,unit:q}),Q=Object.freeze({...X,display:q,decimals:void 0,minDecimals:0,maxDecimals:20,group:!1}),J=new Map([[X.locale||"",X]]),ne=re=>{const oe=re||"";let ie=J.get(oe);return ie||(ie=Object.freeze({...X,locale:re||void 0}),J.set(oe,ie)),ie};return{base:"number",extends:"number",storage:"float64",unitConfig:X,format:re=>P(re.value,re.locale?ne(re.locale):X),parse:re=>v(re.text,re.locale?ne(re.locale):X),compare:x,defaults:{filter:"number",editor:"unit",align:"end",total:T.total||"sum"},...T.totals?{totals:T.totals}:{},excel:T.excel||K({decimals:T.decimals,symbol:q}),toStorage:re=>typeof re=="number"?Number.isFinite(re)?re:null:typeof re=="string"?v(re,X):R(re)?null:v(String(re),X),toClipboard:re=>P(re,Q),fromClipboard:re=>v(re,X)}}const D=I}),ke("packages/core/src/columns/types/engineering.js",function(e,V){"use strict";Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return W}});const R=V("packages/core/src/internal/util.js").isNil,L=V("packages/core/src/columns/types/unit.js").createUnitType;function W(U){const z=2*Math.PI/U;return F=>{let k=0,O=0,y=0;for(const c of F||[]){if(R(c))continue;const r=Number(c);Number.isFinite(r)&&(k+=Math.cos(r*z),O+=Math.sin(r*z),y+=1)}return!y||Math.hypot(k,O)/y<1e-12?null:(Math.atan2(O,k)/z%U+U)%U}}function Z(U){return{supported:["sum","avg","min","max","count","countValues"],implement:{avg:W(U)}}}const H=Object.freeze({metres:L({system:"length",unit:"m",display:"auto",maxDecimals:3}),millimetres:L({system:"length",unit:"mm",maxDecimals:2}),kilometres:L({system:"length",unit:"km",maxDecimals:3}),grams:L({system:"mass",unit:"g",display:"auto",maxDecimals:3}),kilograms:L({system:"mass",unit:"kg",maxDecimals:3}),tonnes:L({system:"mass",unit:"t",maxDecimals:3}),seconds:L({system:"duration",unit:"s",display:"auto",maxDecimals:3}),milliseconds:L({system:"duration",unit:"ms",maxDecimals:3}),hours:L({system:"duration",unit:"h",maxDecimals:2}),speed:L({system:"speed",unit:"m/s",display:"auto",maxDecimals:2}),kph:L({system:"speed",unit:"km/h",maxDecimals:1}),mph:L({system:"speed",unit:"mph",maxDecimals:1}),knots:L({system:"speed",unit:"kn",maxDecimals:1}),acceleration:L({system:"acceleration",unit:"m/s²",maxDecimals:3}),area:L({system:"area",unit:"m²",display:"auto",maxDecimals:2}),hectares:L({system:"area",unit:"ha",maxDecimals:4}),volume:L({system:"volume",unit:"L",display:"auto",maxDecimals:3}),cubicMetres:L({system:"volume",unit:"m³",maxDecimals:3}),energy:L({system:"energy",unit:"J",display:"auto",maxDecimals:3}),kilowattHours:L({system:"energy",unit:"kWh",maxDecimals:2}),power:L({system:"power",unit:"W",display:"auto",maxDecimals:2}),kilowatts:L({system:"power",unit:"kW",maxDecimals:2}),force:L({system:"force",unit:"N",display:"auto",maxDecimals:2}),pressure:L({system:"pressure",unit:"Pa",display:"auto",maxDecimals:2}),bar:L({system:"pressure",unit:"bar",maxDecimals:3}),psi:L({system:"pressure",unit:"psi",maxDecimals:1}),torque:L({system:"torque",unit:"N·m",maxDecimals:2}),density:L({system:"density",unit:"kg/m³",maxDecimals:2}),flow:L({system:"flow",unit:"m³/s",maxDecimals:4}),litresPerMinute:L({system:"flow",unit:"L/min",maxDecimals:1}),radians:L({system:"angle",unit:"rad",maxDecimals:4,totals:Z(2*Math.PI)}),degrees:L({system:"angle",unit:"°",maxDecimals:2,totals:Z(360)}),rpm:L({system:"angularVelocity",unit:"rpm",maxDecimals:0}),angularVelocity:L({system:"angularVelocity",unit:"rad/s",maxDecimals:3}),ppm:L({system:"fraction",unit:"ppm",maxDecimals:2}),ppb:L({system:"fraction",unit:"ppb",maxDecimals:2}),basisPoints:L({system:"fraction",unit:"bp",maxDecimals:1}),molarity:L({system:"molarity",unit:"M",display:"auto",maxDecimals:3}),massFlow:L({system:"massFlow",unit:"kg/s",maxDecimals:3}),tonnesPerHour:L({system:"massFlow",unit:"t/h",maxDecimals:2}),viscosity:L({system:"viscosity",unit:"Pa·s",display:"auto",maxDecimals:3}),kinematicViscosity:L({system:"kinematicViscosity",unit:"cSt",maxDecimals:2}),thermalConductivity:L({system:"thermalConductivity",unit:"W/(m·K)",maxDecimals:3}),specificHeat:L({system:"specificHeat",unit:"J/(kg·K)",maxDecimals:1}),doseRate:L({system:"doseRate",unit:"µSv/h",display:"auto",maxDecimals:2})})}),ke("packages/core/src/columns/types/si.js",function(e,V){"use strict";Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const _=V("packages/core/src/columns/types/unit.js"),R=_.defineUnit,$=_.registerUnitSystem,L=_.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 H(O){const y=String(O.base),d=new Set([...O.prefixes||Z,""]),c=[];for(const r of W){if(!d.has(r.symbol))continue;const t=`${r.symbol}${y}`,n=[];if(O.name){n.push(`${r.name}${O.name}`,`${r.name}${O.name}s`);const i=r.name.slice(-1);if(i&&O.name.startsWith(i)){const s=`${r.name.slice(0,-1)}${O.name}`;n.push(s,`${s}s`)}}r.symbol==="µ"&&n.push(`u${y}`),r.factor===1&&O.aliases&&n.push(...O.aliases),c.push(R(t,r.factor,n))}for(const r of O.extra||[])c.push(r);return c}function U(O,y){const d=H(y);return $(O,d)}function z(O,y,d){return U(O,y),L({system:O,unit:y.base,display:"auto",maxDecimals:3,...d||{}})}const F=Object.freeze({voltage:z("voltage",{base:"V",name:"volt"}),current:z("current",{base:"A",name:"amp",aliases:["ampere","amperes"]}),resistance:z("resistance",{base:"Ω",name:"ohm",aliases:["ohm","ohms","R"],prefixes:["m","","k","M","G"]}),capacitance:z("capacitance",{base:"F",name:"farad",prefixes:["f","p","n","µ","m",""]}),inductance:z("inductance",{base:"H",name:"henry",prefixes:["p","n","µ","m",""]}),charge:z("charge",{base:"C",name:"coulomb",prefixes:["p","n","µ","m",""],extra:[R("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),R("Ah",3600,["amphour","amphours"],{auto:!1})]}),conductance:z("conductance",{base:"S",name:"siemens",prefixes:["n","µ","m","","k"]}),fluxDensity:z("fluxDensity",{base:"T",name:"tesla",prefixes:["n","µ","m",""],extra:[R("G",1e-4,["gauss"],{auto:!1})]}),luminousFlux:z("luminousFlux",{base:"lm",name:"lumen",prefixes:["m","","k"]}),illuminance:z("illuminance",{base:"lx",name:"lux",prefixes:["m","","k"]}),luminousIntensity:z("luminousIntensity",{base:"cd",name:"candela",prefixes:["m","","k"]}),substance:z("substance",{base:"mol",name:"mole",prefixes:["n","µ","m","","k"]}),absorbedDose:z("absorbedDose",{base:"Gy",name:"gray",prefixes:["µ","m",""]}),equivalentDose:z("equivalentDose",{base:"Sv",name:"sievert",prefixes:["n","µ","m",""]}),radioactivity:z("radioactivity",{base:"Bq",name:"becquerel",prefixes:["","k","M","G","T"],extra:[R("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:z("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),k=z}),ke("packages/core/src/columns/types/temperature.js",function(e,V){"use strict";Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return L}}),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 k}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const R=V("packages/core/src/internal/util.js").isNil,$=Object.freeze({C:Object.freeze({symbol:"°C",aliases:["c","°c","celsius","centigrade"],toKelvin:c=>c+273.15,fromKelvin:c=>c-273.15}),F:Object.freeze({symbol:"°F",aliases:["f","°f","fahrenheit"],toKelvin:c=>(c+459.67)*(5/9),fromKelvin:c=>c*(9/5)-459.67}),K:Object.freeze({symbol:"K",aliases:["k","kelvin"],toKelvin:c=>c,fromKelvin:c=>c}),R:Object.freeze({symbol:"°R",aliases:["r","°r","rankine"],toKelvin:c=>c*(5/9),fromKelvin:c=>c*(9/5)})});function L(c){if(R(c))return null;const r=String(c).trim();if(r==="")return null;for(const[n,i]of Object.entries($))if(r===n||r===i.symbol)return{key:n,scale:i};const t=r.toLowerCase();for(const[n,i]of Object.entries($))if(i.aliases.includes(t))return{key:n,scale:i};return null}function W(c,r,t){const n=L(r),i=L(t);return!n||!i||!Number.isFinite(Number(c))?null:n.key===i.key?Number(c):i.scale.fromKelvin(n.scale.toKelvin(Number(c)))}const Z=new Map;function H(c,r,t){const n=`${c||""}|${r}|${t}`;let i=Z.get(n);return i||(i=new Intl.NumberFormat(c||void 0,{minimumFractionDigits:r,maximumFractionDigits:t}),Z.set(n,i)),i}function U(c,r){const t=r||{},n=t.nullDisplay??"";if(R(c)||c==="")return n;const i=Number(c);if(!Number.isFinite(i))return n;const s=L(t.scale||"C");if(!s)return String(i);const l=L(t.display||t.scale||"C")||s,u=l.key===s.key?i:l.scale.fromKelvin(s.scale.toKelvin(i)),f=typeof t.decimals=="number"?t.decimals:null,h=f??t.minDecimals??0,g=f??t.maxDecimals??1;return`${H(t.locale,h,g).format(u)}${t.space??" "}${l.scale.symbol}`}const z=/^[+-]?[\d\s.,  ]*\d/;function F(c,r){const t=String(c).trim();if(t==="")return null;const n=new Intl.NumberFormat(r||void 0).formatToParts(1.1).find(u=>u.type==="decimal")?.value||".",i=n===","?".":",",s=t.split(i).join("").split(/[\s  ]/).join("").replace(n,"."),l=Number(s);return Number.isFinite(l)?l:null}function k(c,r){if(R(c))return null;const t=r||{},n=L(t.scale||"C");if(!n)return null;if(typeof c=="number")return Number.isFinite(c)?c:null;let i=String(c).trim();if(i==="")return null;let s=!1;i.startsWith("(")&&i.endsWith(")")&&(s=!0,i=i.slice(1,-1).trim());const l=z.exec(i);if(!l)return null;const u=F(l[0],t.locale);if(u===null)return null;const f=i.slice(l[0].length).trim();if(f==="")return s?-u:u;const h=L(f);if(!h)return null;const g=h.key===n.key?u:n.scale.fromKelvin(h.scale.toKelvin(u));return s?-g:g}function O(c){const r=Object.freeze({scale:"C",...c||{}}),n=(L(r.scale)||L("C")).scale.symbol,i=Object.freeze({...r,display:r.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),s=new Map([[r.locale||"",r]]),l=u=>{const f=u||"";let h=s.get(f);return h||(h=Object.freeze({...r,locale:u||void 0}),s.set(f,h)),h};return{base:"number",extends:"number",storage:"float64",temperatureConfig:r,format:u=>U(u.value,u.locale?l(u.locale):r),parse:u=>k(u.text,u.locale?l(u.locale):r),defaults:{filter:"number",editor:"temperature",align:"end",total:"avg"},totals:{supported:["avg","min","max","count","countValues"]},excel:r.excel||`#,##0${typeof r.decimals=="number"&&r.decimals>0?`.${"0".repeat(r.decimals)}`:".#"}" ${n}"`,toStorage:u=>typeof u=="number"?Number.isFinite(u)?u:null:typeof u=="string"?k(u,r):R(u)?null:k(String(u),r),toClipboard:u=>U(u,i),fromClipboard:u=>k(u,r)}}const y=Object.freeze({celsius:O({scale:"C"}),fahrenheit:O({scale:"F"}),kelvin:O({scale:"K"})}),d=O}),ke("packages/core/src/columns/types/radix.js",function(e,V){"use strict";Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"digitsForWidth",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"radixRange",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"radixName",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"normaliseRadixOptions",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"compileRadixFormat",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"compileRadixParse",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"parseRadixResult",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return C}});const _=V("packages/core/src/internal/util.js"),R=_.isNil,$=_.warnOnce,L=Object.freeze({2:2,8:8,16:16,bin:2,binary:2,base2:2,oct:8,octal:8,base8:8,hex:16,hexadecimal:16,base16:16}),W=Object.freeze({2:1,8:3,16:4}),Z=Object.freeze({2:"0b",8:"0o",16:"0x"}),H=Object.freeze({2:4,8:3,16:2}),U=Object.freeze({2:/^[01]+$/,8:/^[0-7]+$/,16:/^[0-9a-f]+$/i}),z=Object.freeze({2:"binary",8:"octal",16:"hexadecimal"}),F=Object.freeze([[/^0x/i,16],[/^0b/i,2],[/^0o/i,8],[/^#/,16]]),k=/[\s\u00a0\u202f_,']/g,O=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,y=Object.freeze([8,16,32,53]),d=new WeakSet,c=new WeakMap,r=new Map,t=new WeakMap,n=new WeakMap,i=Object.freeze({hex:Object.freeze({radix:16}),hex8:Object.freeze({radix:16,bitWidth:8,pad:!0,signed:!1}),hex16:Object.freeze({radix:16,bitWidth:16,pad:!0,signed:!1}),hex32:Object.freeze({radix:16,bitWidth:32,pad:!0,signed:!1}),binary:Object.freeze({radix:2}),binary8:Object.freeze({radix:2,bitWidth:8,pad:!0,signed:!1,group:4}),octal:Object.freeze({radix:8})});function s(P){if(P==null)return 16;const x=typeof P=="string"?P.toLowerCase():P,K=L[x];return K||($(`radix:base:${String(P)}`,`unsupported radix ${String(P)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function l(P,x){return Math.ceil(P/W[x])}function u(P,x){if(!P)return x?{min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}:{min:0,max:Number.MAX_SAFE_INTEGER};if(!x)return{min:0,max:2**P-1};const K=2**(P-1);return{min:-K,max:K-1}}function f(P){return z[P]||"hexadecimal"}function h(P){if(typeof P=="string"){const x=i[P];return x||$(`radix:preset:${P}`,`unknown radix preset "${P}"; known presets are ${Object.keys(i).join(", ")}`),{...x||{}}}if(P&&typeof P.preset=="string"){const x=i[P.preset];return x||$(`radix:preset:${P.preset}`,`unknown radix preset "${P.preset}"; known presets are ${Object.keys(i).join(", ")}`),{...x||{},...P}}return P||{}}function g(P){const x=h(P),K=s(x.radix),I=W[K];let D=null;if(x.bitWidth!==void 0&&x.bitWidth!==null&&x.bitWidth!==!1){const re=Number(x.bitWidth);y.includes(re)?D=re:$(`radix:width:${String(x.bitWidth)}`,`unsupported bitWidth ${String(x.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let j=x.signed!==!1;!j&&D===null&&($("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),D=32);const T=x.prefix===void 0||x.prefix===!0?Z[K]:x.prefix===!1?"":String(x.prefix);let B=0;x.pad===!0?B=D?l(D,K):0:typeof x.pad=="number"&&x.pad>0&&(B=Math.floor(x.pad));let q=0;x.group===!0?q=H[K]:typeof x.group=="number"&&x.group>0&&(q=Math.floor(x.group));const X=u(D,j),Q=typeof x.min=="number"?Math.max(X.min,x.min):X.min,J=typeof x.max=="number"?Math.min(X.max,x.max):X.max,ne=Object.freeze({radix:K,bits:I,prefix:T,uppercase:x.uppercase!==!1,pad:B,group:q,groupSeparator:typeof x.groupSeparator=="string"?x.groupSeparator:" ",bitWidth:D,signed:j,min:Q,max:J<Q?Q:J,nullDisplay:typeof x.nullDisplay=="string"?x.nullDisplay:"",name:f(K)});return d.add(ne),ne}function b(P){if(P&&d.has(P))return P;if(typeof P=="string"){let x=r.get(P);return x||(x=g(P),r.set(P,x)),x}if(P&&typeof P=="object"){let x=c.get(P);return x||(x=g(P),c.set(P,x)),x}return b("hex")}function p(P){return P<0?-Math.round(-P):Math.round(P)}function m(P,x,K){if(x<=0||P.length<=x)return P;const I=P.length%x||x,D=[P.slice(0,I)];for(let j=I;j<P.length;j+=x)D.push(P.slice(j,j+x));return D.join(K)}function w(P){const x=b(P),{radix:K,prefix:I,uppercase:D,pad:j,group:T,groupSeparator:B,signed:q,bitWidth:X,nullDisplay:Q}=x,J=X?2**X:0,ne=re=>{if(R(re)||re==="")return Q;const oe=typeof re=="number"?re:Number(re);if(!Number.isFinite(oe))return Q;const ie=p(oe);let te="",ce=ie;ie<0&&(q?(te="-",ce=-ie):ce=(ie%J+J)%J);let ue=ce.toString(K);return ue=D?ue.toUpperCase():ue.toLowerCase(),j>0&&ue.length<j&&(ue=ue.padStart(j,"0")),T>0&&(ue=m(ue,T,B)),te+I+ue};return ne.options=x,ne}function v(P,x){const K=b(x);let I=t.get(K);return I||(I=w(K),t.set(K,I)),I(P)}function a(P){const x=b(P),{radix:K,groupSeparator:I,signed:D,min:j,max:T}=x,B=U[K],q=X=>{if(R(X))return{ok:!0,value:null,reason:"blank"};let Q=String(X);if(I&&I!==""&&(Q=Q.split(I).join("")),Q=Q.replace(k,""),Q==="")return{ok:!0,value:null,reason:"blank"};let J=!1;if((Q[0]==="-"||Q[0]==="+")&&(J=Q[0]==="-",Q=Q.slice(1)),Q==="")return{ok:!1,value:null,reason:"digits"};let ne=null;for(const[oe,ie]of F){const te=oe.exec(Q);if(!te)continue;const ce=Q.slice(te[0].length);if(ce==="")break;if(!U[ie].test(ce))return{ok:!1,value:null,reason:"digits"};ne=parseInt(ce,ie);break}if(ne===null)if(B.test(Q))ne=parseInt(Q,K);else if(O.test(Q))ne=Number(Q);else return{ok:!1,value:null,reason:"digits"};if(!Number.isFinite(ne))return{ok:!1,value:null,reason:"digits"};const re=p(J?-ne:ne);return!D&&re<0?{ok:!1,value:re,reason:"negative"}:re<j||re>T?{ok:!1,value:re,reason:"range"}:{ok:!0,value:re,reason:"ok"}};return q.options=x,q}function o(P,x){const K=b(x);let I=n.get(K);return I||(I=a(K),n.set(K,I)),I(P)}function S(P,x){const K=o(P,x);return K.ok?K.value:null}function E(P,x){const K=R(P)||Number.isNaN(P)?null:Number(P),I=R(x)||Number.isNaN(x)?null:Number(x);return K===null?I===null?0:1:I===null||K<I?-1:K>I?1:0}function A(P){const x=P.min>=-2147483648&&P.max<=2147483647;return P.bitWidth&&x?"int32":"float64"}function M(P){const x=g(P),K=w(x),I=a(x);return{base:"number",extends:"number",storage:A(x),matches:null,format:D=>K(D.value),parse:D=>{const j=I(D.text);return j.ok?j.value:null},compare:E,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:D=>K(D),fromClipboard:D=>{const j=I(D);return j.ok?j.value:null},radix:x,formatValue:K,parseText:I}}const C=M}),ke("packages/core/src/columns/types/aggregable.js",function(e,V){"use strict";Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"weightedMean",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"logarithmicSum",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"logarithmicMean",{enumerable:!0,get:function(){return W}});const R=V("packages/core/src/internal/util.js").isNil;function $(F){const k=[];for(const O of F||[]){if(R(O))continue;const y=Number(O);Number.isFinite(y)&&k.push(y)}return k}function L(F){return k=>{const O=$(k);if(!O.length)return null;let y=0;for(const d of O)y+=10**(d/F);return F*Math.log10(y)}}function W(F){return k=>{const O=$(k);if(!O.length)return null;let y=0;for(const d of O)y+=10**(d/F);return F*Math.log10(y/O.length)}}function Z(F,k){const O=k&&k.column,d=(O&&O.typeOptions||{}).weight,c=k&&k.valueAt;if(!d||typeof c!="function")return null;let r=0,t=0;for(let n=0;n<F.length;n++){if(R(F[n]))continue;const i=Number(F[n]);if(!Number.isFinite(i))continue;const s=c(d,n);if(R(s))continue;const l=Number(s);!Number.isFinite(l)||l<=0||(r+=i*l,t+=l)}return t===0?null:r/t}function H(F={}){const k=F.factor===20?20:10,O=typeof F.suffix=="string"?F.suffix:"",y=Number.isInteger(F.decimals)?F.decimals:1;return{base:"number",storage:"float64",name:F.name||"logarithmic",format:d=>{const c=d&&d.value;return R(c)||!Number.isFinite(Number(c))?"":`${Number(c).toFixed(y)}${O}`},parse:d=>{const c=String((d&&d.text)??"").replace(O,"").trim();if(!c)return null;const r=Number(c);return Number.isFinite(r)?r:null},defaults:{align:"end",filter:"number"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:{sum:L(k),avg:W(k)}}}}function U(F={}){const k=Number.isInteger(F.decimals)?F.decimals:1,O=F.percent===!0;return{base:"number",storage:"float64",name:F.name||"ratio",format:y=>{const d=y&&y.value;return R(d)||!Number.isFinite(Number(d))?"":O?`${Number(d).toFixed(k)}%`:Number(d).toFixed(k)},parse:y=>{const d=String((y&&y.text)??"").replace("%","").trim();if(!d)return null;const c=Number(d);return Number.isFinite(c)?c:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:Z}}}}const z=Object.freeze({decibel:H({name:"decibel",factor:10,suffix:" dB"}),decibelAmplitude:H({name:"decibelAmplitude",factor:20,suffix:" dB"}),ratio:U({name:"ratio"}),percentRate:U({name:"percentRate",percent:!0})})}),ke("packages/core/src/columns/types/currency.js",function(e,V){"use strict";Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"moneyToText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const R=V("packages/core/src/internal/util.js").isNil,$="⚠ no rate";function L(u){if(R(u))return null;const f=String(u).trim().toUpperCase();return f===""?null:f}function W(u){if(R(u))return null;if(typeof u=="object"&&!Array.isArray(u)){const f=Number(u.amount),h=L(u.code);return!h||!Number.isFinite(f)?null:{amount:f,code:h}}if(Array.isArray(u)&&u.length===2){const f=Number(u[0]),h=L(u[1]);return!h||!Number.isFinite(f)?null:{amount:f,code:h}}return null}const Z=Object.freeze({$:"USD","€":"EUR","£":"GBP","¥":"JPY","₹":"INR","₩":"KRW","₽":"RUB","₺":"TRY","₴":"UAH","₪":"ILS"}),H=Object.freeze({USD:"$",EUR:"€",GBP:"£",JPY:"¥",INR:"₹",KRW:"₩",RUB:"₽",TRY:"₺",UAH:"₴",ILS:"₪"}),U=/[+-]?[\d\s., ]*\d/;function z(u,f){const h=String(u).trim();if(h==="")return null;const g=new Intl.NumberFormat(f||void 0).formatToParts(1.1).find(w=>w.type==="decimal")?.value||".",b=g===","?".":",",p=h.split(b).join("").split(/[\s ]/).join("").replace(g,"."),m=Number(p);return Number.isFinite(m)?m:null}function F(u,f){const h=f||{},g=L(h.code);if(R(u))return null;const b=W(u);if(b)return b;if(typeof u=="number")return Number.isFinite(u)&&g?{amount:u,code:g}:null;let p=String(u).trim();if(p==="")return null;let m=!1;p.startsWith("(")&&p.endsWith(")")&&(m=!0,p=p.slice(1,-1).trim());let w=null;for(const[A,M]of Object.entries(Z)){if(p.startsWith(A)){w=M,p=p.slice(A.length).trim();break}if(p.endsWith(A)){w=M,p=p.slice(0,-A.length).trim();break}}const v=U.exec(p);if(!v)return null;const a=z(v[0],h.locale);if(a===null)return null;const o=(p.slice(0,v.index)+" "+p.slice(v.index+v[0].length)).trim();!w&&o!==""&&(w=L(o));const S=w||g;return S?{amount:m?-a:a,code:S}:null}function k(u,f){if(typeof u=="function")return(h,g)=>{if(h===g)return 1;const b=u(h,g);return typeof b=="number"&&Number.isFinite(b)&&b>0?b:null};if(u&&typeof u=="object"){const h=u;return(g,b)=>{if(g===b)return 1;const p=Number(h[g]),m=Number(h[b]);return!Number.isFinite(p)||!Number.isFinite(m)||p<=0||m<=0?null:m/p}}return(h,g)=>h===g?1:null}function O(u,f,h){if(!u)return null;if(u.code===f)return u.amount;const g=h(u.code,f);return g===null?null:u.amount*g}const y=new Map;function d(u,f,h){const g=`${u||""}|${f}|${h??""}`;let b=y.get(g);if(!b){const p={style:"currency",currency:f};typeof h=="number"&&(p.minimumFractionDigits=h,p.maximumFractionDigits=h);try{b={fmt:new Intl.NumberFormat(u||void 0,p),currency:!0}}catch{b={fmt:new Intl.NumberFormat(u||void 0,typeof h=="number"?{minimumFractionDigits:h,maximumFractionDigits:h}:{}),currency:!1}}y.set(g,b)}return b}function c(u,f){const h=f||{},g=h.nullDisplay??"",b=W(u);if(!b)return g;const p=L(h.display)||b.code;let m=b.amount,w=b.code;if(p!==b.code){const o=h.rateFn||k(h.rates,h.rateBase),S=O(b,p,o);if(S===null)return`${h.missingRate??$} ${b.code}→${p}`;m=S,w=p}const{fmt:v,currency:a}=d(h.locale,w,h.decimals);return a?v.format(m):`${v.format(m)} ${w}`}function r(u){const f=W(u);return f?`${f.amount} ${f.code}`:""}function t(u){const f=u||{},h=L(f.display),g=f.rateFn||k(f.rates,f.rateBase);return(b,p)=>{const m=W(b),w=W(p);if(!m&&!w)return 0;if(!m)return 1;if(!w)return-1;if(h){const v=O(m,h,g),a=O(w,h,g);if(v!==null&&a!==null)return v===a?0:v<a?-1:1}return m.code===w.code?m.amount===w.amount?0:m.amount<w.amount?-1:1:m.code<w.code?-1:1}}function n(u){const f=u||{},h=(b,p)=>{const m=[];for(const S of b||[]){const E=W(S);E&&m.push(E)}if(!m.length)return null;if(new Set(m.map(S=>S.code)).size===1){const S=m[0].code;return{amount:p(m.map(E=>E.amount)),code:S}}const v=L(f.display);if(!v)return`${f.missingRate??$}: mixed currencies, no display currency set`;const a=f.rateFn||k(f.rates,f.rateBase),o=[];for(const S of m){const E=O(S,v,a);if(E===null)return`${f.missingRate??$}: ${S.code}→${v}`;o.push(E)}return{amount:p(o),code:v}},g=b=>b.reduce((p,m)=>p+m,0);return{sum:b=>h(b,g),avg:b=>h(b,p=>g(p)/p.length),min:b=>h(b,p=>Math.min(...p)),max:b=>h(b,p=>Math.max(...p))}}function i(u){const f=Object.freeze({code:"USD",...u||{}}),h=k(f.rates,f.rateBase),g=Object.freeze({...f,rateFn:h}),b=n(g),p=t(g),m=new Map([[f.locale||"",g]]),w=o=>{const S=o||"";let E=m.get(S);return E||(E=Object.freeze({...g,locale:o||void 0}),m.set(S,E)),E},v=H[L(f.display||f.code)]||"",a=typeof f.decimals=="number"&&f.decimals>0?`.${"0".repeat(f.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:g,format:o=>c(o.value,o.locale?w(o.locale):g),parse:o=>F(o.text,o.locale?w(o.locale):g),compare:p,defaults:{filter:"number",editor:"currency",align:"end",total:"sum"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:b},excel:f.excel||(v?`"${v}"#,##0${a}`:`#,##0${a}`),toStorage:o=>{const S=W(o);return S||(typeof o=="string"||typeof o=="number"?F(o,g):null)},toClipboard:o=>r(o),fromClipboard:o=>F(o,g)}}const s=Object.freeze({currency:i({code:"USD"}),usd:i({code:"USD"}),eur:i({code:"EUR"}),gbp:i({code:"GBP"}),jpy:i({code:"JPY",decimals:0})}),l=i}),ke("packages/core/src/columns/types/index.js",function(e,V){"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 z}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return A}});const _=V("packages/core/src/columns/types/temporal.js"),R=_.TEMPORAL_TYPES,$=V("packages/core/src/columns/types/network.js"),L=$.NETWORK_TYPES,W=V("packages/core/src/columns/types/structured.js"),Z=W.STRUCTURED_TYPES,H=V("packages/core/src/columns/types/unit.js"),U=H.createUnitType,z=H.UNIT_SYSTEMS,F=H.parseUnit,k=H.formatUnit,O=H.registerUnitSystem,y=H.unitSystemNames,d=H.unitsOf,c=H.defineUnit,r=V("packages/core/src/columns/types/engineering.js"),t=r.ENGINEERING_TYPES,n=V("packages/core/src/columns/types/si.js"),i=n.SI_TYPES,s=n.createSiType,l=n.createSiSystem,u=n.siUnits,f=n.SI_PREFIXES,h=V("packages/core/src/columns/types/temperature.js"),g=h.TEMPERATURE_TYPES,b=h.createTemperatureType,p=h.convertTemperature,m=h.formatTemperature,w=h.parseTemperature,v=h.TEMPERATURE_SCALES,a=V("packages/core/src/columns/types/radix.js"),o=a.createRadixType,S=a.RADIX_PRESETS,E=a.parseRadix,A=a.formatRadix,M=V("packages/core/src/columns/types/aggregable.js"),C=M.AGGREGABLE_TYPES,P=V("packages/core/src/columns/types/currency.js"),x=P.CURRENCY_TYPES,K=P.createCurrencyType,I=P.parseMoney,D=P.formatMoney,j=P.convertMoney,T=P.toMoney,B=P.rateFunction,q=P.moneyComparator,X=P.normaliseCode,Q=P.MISSING_RATE;Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return H.findUnit}}),Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return r.ENGINEERING_TYPES}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return r.circularMean}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return h.TEMPERATURE_TYPES}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return h.createTemperatureType}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return h.convertTemperature}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return h.formatTemperature}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return h.parseTemperature}}),Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return h.TEMPERATURE_SCALES}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return h.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 _.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 M.AGGREGABLE_TYPES}}),Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return M.createLogarithmicType}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return M.createRatioType}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return _.parseTime}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return _.formatTime}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return _.parseDateTime}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return _.formatDateTime}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return _.parseDuration}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return _.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({...R,...L,...Z,...C,hex:o(S.hex),hex8:o(S.hex8),hex16:o(S.hex16),hex32:o(S.hex32),binary:o(S.binary),binary8:o(S.binary8),octal:o(S.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,...i,...g,...x});{const ne=new Set;for(const re of[R,L,Z,C,t,i,g,x])for(const oe of Object.keys(re)){if(ne.has(oe))throw new Error(`[lattice] data type "${oe}" is declared twice`);ne.add(oe)}}}),ke("packages/core/src/columns/datatypes.js",function(e,V){"use strict";Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"parseNumberText",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"BUILTIN_TYPES",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"INFERENCE_ORDER",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"createTypeRegistry",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"comparatorFor",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"storageKind",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"typeLabel",{enumerable:!0,get:function(){return C}});const _=V("packages/core/src/internal/util.js"),R=_.collator,$=_.defaultCompare,L=_.isNil,W=_.isObject,Z=_.isFunction,H=_.fail,U=_.titleCase,z=V("packages/core/src/format/date.js"),F=z.toDate,k=z.toIsoDate,O=z.compareIso,d=V("packages/core/src/format/boolean.js").toTriState,r=V("packages/core/src/columns/types/index.js").EXTENDED_TYPES,t=V("packages/core/src/formula/index.js"),n=t.evaluateFormula,i=t.looksLikeFormula,s=/^\d{4}-\d{2}-\d{2}$/;function l(P){return P.getHours()===0&&P.getMinutes()===0&&P.getSeconds()===0&&P.getMilliseconds()===0}const u=new Map;function f(P){const x=P||"",K=u.get(x);if(K)return K;const I={group:",",decimal:"."};try{for(const D of new Intl.NumberFormat(P||void 0).formatToParts(12345.6))D.type==="group"?I.group=D.value:D.type==="decimal"&&(I.decimal=D.value)}catch{}return u.set(x,I),I}const h=/\d\s*[*/^]\s*[\d.(]/;function g(P,x){if(L(P))return null;let K=String(P).trim();if(K===""||K.startsWith("=")||h.test(K))return null;let I=1;K.startsWith("(")&&K.endsWith(")")&&(I=-1,K=K.slice(1,-1));const D=K.endsWith("%"),{group:j,decimal:T}=f(x);if(K=K.replace(/[\s\u00a0\u202f\u2009']/g,""),j&&j!=="."&&j!==","&&(K=K.split(j).join("")),K=K.replace(/[^0-9eE+\-.,]/g,""),T===","?K=K.split(".").join("").replace(",","."):K=K.split(",").join(""),K===""||K==="-"||K==="+")return null;const B=Number(K);return Number.isNaN(B)?null:I*(D?B/100:B)}function b(P,x){const K=L(P)||Number.isNaN(P)?null:Number(P),I=L(x)||Number.isNaN(x)?null:Number(x);return K===null?I===null?0:1:I===null||K<I?-1:K>I?1:0}function p(P,x){const K=d(P),I=d(x);return K===null?I===null?0:1:I===null?-1:K===I?0:K?1:-1}function m(P,x){const K=F(P),I=F(x);if(!K)return I?1:0;if(!I)return-1;const D=K.getTime(),j=I.getTime();return D<j?-1:D>j?1:0}const w=new Map;function v(P){const x=F(P.value);if(!x)return"";const K=P.locale||"";let I=w.get(K);return I||(I=new Intl.DateTimeFormat(P.locale||void 0,{dateStyle:"medium"}),w.set(K,I)),I.format(x)}const a={boolean:{base:"boolean",storage:"bitset",matches:P=>typeof P=="boolean",parse:P=>d(P.text),compare:p,format:P=>d(P.value)===null?"":d(P.value)?"Yes":"No",defaults:{filter:"set",editor:"checkbox",align:"center"},excel:"General",toClipboard:P=>d(P)===null?"":String(d(P)),fromClipboard:P=>d(P)},number:{base:"number",storage:"float64",matches:P=>typeof P=="number"&&!Number.isNaN(P),parse:P=>{if(i(P.text)){const x=n(P.text,P);if(!x.ok)return null;const K=Number(x.value);return Number.isFinite(K)?K:null}return g(P.text,P.locale)},compare:b,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:P=>L(P)?"":String(P),fromClipboard:(P,x)=>g(P,x&&x.locale)},date:{base:"dateString",storage:"dictionary",matches:P=>typeof P=="string"&&s.test(P)&&!Number.isNaN(Date.parse(P))||P instanceof Date&&!Number.isNaN(P.getTime())&&l(P),parse:P=>k(P.text),compare:O,format:v,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:P=>k(P),toClipboard:P=>L(P)?"":String(P),fromClipboard:P=>k(P)},dateString:{base:"dateString",storage:"dictionary",matches:P=>typeof P=="string"&&s.test(P)&&!Number.isNaN(Date.parse(P)),parse:P=>k(P.text),compare:O,format:v,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:P=>k(P),toClipboard:P=>L(P)?"":String(P),fromClipboard:P=>k(P)},text:{base:"text",storage:"dictionary",matches:P=>typeof P=="string",parse:P=>P.text===""?null:String(P.text),compare:(P,x)=>L(P)?L(x)?0:1:L(x)?-1:R().compare(String(P),String(x)),defaults:{filter:"text",editor:"text",align:"start"},excel:"@",toClipboard:P=>L(P)?"":String(P),fromClipboard:P=>P},image:{base:"text",storage:"dictionary",parse:P=>P.text===""||P.text==null?null:String(P.text).trim(),compare:(P,x)=>L(P)?L(x)?0:1:L(x)?-1:R().compare(String(P),String(x)),defaults:{filter:"text",editor:"text",align:"center",render:"image"},excel:"@",toClipboard:P=>L(P)?"":String(P),fromClipboard:P=>P},lookup:{base:"text",storage:"dictionary",parse:P=>{if(P.text===""||P.text==null)return null;const x=P.column&&P.column.lookup,K=x&&Z(x.options)?x.options():null;if(!K)return P.text;const I=String(P.text),D=K.find(B=>String(B.id)===I);if(D)return D.id;const j=I.trim().toLowerCase(),T=K.find(B=>String(B.label).toLowerCase()===j);return T?T.id:P.text},compare:$,defaults:{filter:"set",editor:"select",align:"start"},excel:"@",multiStorage:"multi",toClipboard:P=>L(P)?"":String(P),fromClipboard:P=>P},object:{base:"object",storage:"object",matches:P=>P!==null&&typeof P=="object"&&!(P instanceof Date),parse:P=>{try{return P.text===""?null:JSON.parse(P.text)}catch{return P.text}},compare:(P,x)=>$(P,x),format:P=>{const x=P.value;if(L(x))return"";if(typeof x=="string")return x;try{return JSON.stringify(x)}catch{return String(x)}},defaults:{filter:"none",editor:"none",align:"start"},excel:"@",toClipboard:P=>L(P)?"":typeof P=="string"?P:JSON.stringify(P),fromClipboard:P=>P}},o=["boolean","number","date","dateString","datetime","text","object"];function S(P,x,K,I){const D=K.get(P);if(D)return D;I.includes(P)&&H(`circular data type extends chain: ${[...I,P].join(" → ")}`);const j=x[P];j||H(`unknown data type "${P}"`);let T=null;j.extends&&(T=S(j.extends,x,K,[...I,P]));const B={...T||{},...j,name:P,defaults:{...T&&T.defaults||{},...j.defaults||{}}};return B.base||(B.base=T&&T.base||"text"),B.storage||(B.storage=T&&T.storage||"object"),K.set(P,B),B}function E(P,x){const K={...a,...r};if(x&&typeof x.dataType=="function"&&Array.isArray(x.dataTypeNames))for(const D of x.dataTypeNames()){const j=x.dataType(D);j&&(K[D]=j)}if(W(P))for(const[D,j]of Object.entries(P))K[D]=j;const I=new Map;for(const D of o)S(D,K,I,[]);S("lookup",K,I,[]);for(const D of Object.keys(K))S(D,K,I,[]);return I}function A(P,x){if(P.base==="text"&&(!P.compare||P.compare===a.text.compare)){const K=R(x);return(I,D)=>L(I)?L(D)?0:1:L(D)?-1:K.compare(String(I),String(D))}return P.compare||$}function M(P,x){return x?P.multiStorage||"multi":P.storage||"object"}function C(P){return U(String(P).replace(/([a-z])([A-Z])/g,"$1 $2"))}}),ke("packages/core/src/columns/infer.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_SAMPLE",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"inferFromValues",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"inferColumnType",{enumerable:!0,get:function(){return Z}});const _=V("packages/core/src/internal/util.js"),R=_.infoOnce,$=_.isNil,L=100;function W(H,U,z={}){const F=z.sampleSize??L,k=[];for(let O=0;O<H.length&&k.length<F;O++){const y=H[O];$(y)||typeof y=="number"&&Number.isNaN(y)||k.push(y)}if(k.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[O,y]of U){if(typeof y.matches!="function")continue;let d=!0;for(let c=0;c<k.length;c++)if(!y.matches(k[c])){d=!1;break}if(d)return{type:O,unanimous:!0,sampled:k.length}}return z.quiet||R(`infer:${z.colId||"?"}`,`column "${z.colId||"?"}" has mixed or ambiguous values and was inferred as "text". Declare \`type\` on the column to get correct sorting, filtering and export.`),{type:"text",unanimous:!1,sampled:k.length}}function Z(H,U,z,F,k={}){const O=k.sampleSize??L,y=[];for(let d=0;d<U.length&&y.length<O;d++){const c=z(U[d]);$(c)||typeof c=="number"&&Number.isNaN(c)||y.push(c)}return W(y,F,{...k,colId:H}).type}}),ke("packages/core/src/columns/graph.js",function(e,V){"use strict";Object.defineProperty(e,"WHOLE_ROW",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"declarationOf",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"affectedBy",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return F}});const _=V("packages/core/src/internal/util.js"),R=_.DEV,$=_.fail,L=_.isFunction,W=_.warnOnce,Z="*";function H(k){const O=k.value||{};if(!L(O.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const d=O.pure!==!1;return O.deps===Z?{computed:!0,wholeRow:!0,deps:[],pure:d}:Array.isArray(O.deps)?{computed:!0,wholeRow:!1,deps:O.deps.slice(),pure:d}:(W(`deps:missing:${k.id}`,`computed column "${k.id}" declares no \`value.deps\`; treating it as \`deps: '*'\` (a whole-row dependency). Declare the dependencies to get precise invalidation.`),{computed:!0,wholeRow:!0,deps:[],pure:d})}function U(k){const O=new Map;for(const h of k)O.set(h.id,h);const y=new Map,d=new Map,c=new Set,r=new Set,t=new Set,n=new Set;for(const h of k){const g=H(h);if(!g.computed){y.set(h.id,[]);continue}r.add(h.id),(g.pure?t:n).add(h.id),g.wholeRow&&c.add(h.id);const b=[],p=[];for(const m of g.deps)(O.has(m)?b:p).push(m);y.set(h.id,b),p.length&&d.set(h.id,p)}for(const h of t)for(const g of y.get(h))n.has(g)&&$(`pure computed column "${h}" depends on impure column "${g}". Mark it \`value.pure: false\` or make the dependency pure.`);const i=[],s=new Map,l=[],u=h=>{const g=s.get(h);if(g!=="done"){if(g==="open"){const b=l.indexOf(h);$(`circular column dependency: ${[...l.slice(b),h].join(" → ")}`)}s.set(h,"open"),l.push(h);for(const b of y.get(h)||[])O.has(b)&&u(b);l.pop(),s.set(h,"done"),i.push(h)}};for(const h of k)u(h.id);const f=new Map;for(const h of k)f.set(h.id,[]);for(const h of k)for(const g of y.get(h.id)||[]){const b=f.get(g);b&&!b.includes(h.id)&&b.push(h.id)}if(c.size)for(const h of k){if(r.has(h.id))continue;const g=f.get(h.id);for(const b of c)g.includes(b)||g.push(b)}return{order:i,dependents:f,pure:t,impure:n,computed:r,deps:y,wholeRow:c,external:d,index:O}}function z(k,O){const y=Array.isArray(O)?O:[O],d=new Set,c=[...y];for(;c.length;){const r=c.shift();for(const t of k.dependents.get(r)||[])d.has(t)||(d.add(t),c.push(t))}for(const r of y)d.delete(r);return k.order.filter(r=>d.has(r))}function F(k,O,y){if(!R)return k;const d=O instanceof Set?O:new Set(O);return new Proxy(k,{get(c,r){return typeof r=="string"&&!d.has(r)&&!Object.hasOwn(c,r)&&W(`undeclared:${y}:${r}`,`computed column "${y}" read undeclared dependency "${r}". Add it to \`value.deps\` or the value will go stale.`),c[r]}})}}),ke("packages/core/src/columns/lookup.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_SEPARATOR",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"normaliseOption",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"flattenOptions",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return y}});const _=V("packages/core/src/internal/util.js"),R=_.collator,$=_.defaultCompare,L=_.isFunction,W=_.isNil,Z=_.warnOnce,H=", ",U="";function z(d,c,r,t){if(d===null||typeof d!="object")return{id:d,label:d==null?"":String(d)};const n=d[c],i=d[r],s={id:n,label:i==null?String(n??""):String(i)};d.disabled&&(s.disabled=!0),d.variant&&(s.variant=d.variant),d.icon&&(s.icon=d.icon);const l=t?d[t]:d.group;return l!==void 0&&(s.group=l),s}function F(d,c,r=0,t=[],n=[]){for(const i of d||[]){const s=i&&typeof i=="object"?i[c]:null;if(n.push({raw:i,depth:r,path:t}),Array.isArray(s)&&s.length){const l=String(i&&typeof i=="object"?i.label??i.name??i.id??"":i);F(s,c,r+1,[...t,l],n)}}return n}class k{#e;#t;#n;#r;#o=[];#i=new Map;#a=new Map;#s=0;#l="idle";#u=null;#c;constructor(c,r={}){this.#e=c||{},this.#t=r.colId||"?",this.#n=r.locale,this.#r=r.onChange||null,this.#c=R(this.#n),Array.isArray(this.#e.options)?this.#d(this.#e.options):this.#e.options===void 0&&(this.#l="ready")}get colId(){return this.#t}get version(){return this.#s}get state(){return this.#l}get ready(){return this.#l==="ready"}get multiple(){return this.#e.multiple===!0}get separator(){return this.#e.separator??H}get allowCustom(){return this.#e.allowCustom===!0}get sortBy(){return this.#e.sortBy||"label"}get spec(){return this.#e}options(){return this.#o}setLocale(c){this.#n=c,this.#c=R(c)}#d(c){const r=this.#e,t=r.valueKey||"id",n=r.labelKey||"label",i=r.childrenKey||"children";this.#o=F(c,i).map(s=>{const l=z(s.raw,t,n,r.groupKey);return s.depth&&(l.depth=s.depth,l.path=s.path),l}),this.#i=new Map,this.#a=new Map,this.#o.forEach((s,l)=>{this.#i.set(s.id,s),this.#a.set(s.id,l)}),this.#l="ready",this.#s+=1}load(){if(this.#u)return this.#u;const c=this.#e.options;if(Array.isArray(c)||c===void 0)return this.#u=Promise.resolve(this.#o),this.#u;if(!L(c))return Z(`lookup:options:${this.#t}`,`column "${this.#t}" has an invalid \`lookup.options\`; expected an array or a function`),this.#l="ready",this.#u=Promise.resolve([]),this.#u;this.#l="loading";let r;try{r=c()}catch(t){return this.#l="error",Z(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,t),this.#u=Promise.resolve([]),this.#u}return!r||!L(r.then)?(this.#d(r),this.#u=Promise.resolve(this.#o),this.#r&&this.#r(this),this.#u):(this.#u=r.then(t=>(this.#d(t),this.#r&&this.#r(this),this.#o),t=>(this.#l="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(c,r){const t=this.#e;if(!L(t.search)){const s=String(c||"").toLowerCase();return Promise.resolve(s===""?this.#o:this.#o.filter(l=>l.label.toLowerCase().includes(s)))}const n=t.valueKey||"id",i=t.labelKey||"label";return Promise.resolve(t.search(c,r)).then(s=>(s||[]).map(l=>z(l,n,i,t.groupKey)))}option(c){return this.#i.get(c)}has(c){return this.#i.has(c)}label(c){if(W(c)||c==="")return"";const r=this.#i.get(c);if(r)return r.label;if(this.#l==="loading"||this.#l==="idle")return"";this.allowCustom||Z(`lookup:unknown:${this.#t}`,`column "${this.#t}" holds value ${JSON.stringify(c)} 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 L(t)?String(t(c)??""):typeof t=="string"?t:String(c)}text(c){if(this.multiple){const r=O(c);return r.length===0?"":r.map(t=>this.label(t)).join(this.separator)}return this.label(c)}dictionary(){return this.#o.map(c=>c.id)}sorted(){const c=this.sortBy;if(c==="optionOrder"||c==="count")return this.#o.slice();if(c==="value")return this.#o.slice().sort((t,n)=>$(t.id,n.id));const r=this.#c;return this.#o.slice().sort((t,n)=>r.compare(t.label,n.label))}comparator(){const c=this.sortBy,r=this.multiple,t=this.#c,n=this.#a;if(r&&c==="count")return(s,l)=>O(s).length-O(l).length;const i=r?s=>O(s)[0]:s=>s;return c==="value"?(s,l)=>$(i(s),i(l)):c==="optionOrder"?(s,l)=>{const u=n.has(i(s))?n.get(i(s)):Number.MAX_SAFE_INTEGER,f=n.has(i(l))?n.get(i(l)):Number.MAX_SAFE_INTEGER;return u-f}:(s,l)=>{const u=i(s),f=i(l);return W(u)?W(f)?0:1:W(f)?-1:t.compare(this.label(u),this.label(f))}}groupKey(c){return this.multiple?O(c).map(t=>String(t)).sort().join(U):W(c)?"":String(c)}countValues(c){return this.multiple?O(c).length:W(c)?0:1}contains(c,r,t){const n=this.multiple?O(c):W(c)?[]:[c],i=Array.isArray(r)?r:[r];switch(t){case"containsAll":return i.every(s=>n.includes(s));case"containsNone":return!i.some(s=>n.includes(s));default:return i.some(s=>n.includes(s))}}exportText(c,r="label"){return r==="value"?this.multiple?O(c).join(this.separator):W(c)?"":String(c):this.text(c)}exportColumns(){const c=this.multiple;return this.#o.map(r=>({id:r.id,label:r.label,has:t=>c?O(t).includes(r.id):t===r.id}))}}function O(d){return Array.isArray(d)?d:W(d)||d===""?[]:[d]}function y(d,c={}){const r=d.lookup;if(!r)return null;const t=new k(r,{colId:d.id,locale:c.locale,onChange:c.onChange});return!Array.isArray(r.options)&&r.options!==void 0&&t.load(),t}}),ke("packages/core/src/columns/value.js",function(e,V){"use strict";Object.defineProperty(e,"compileDisplay",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"warnImpureUse",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return y}});const _=V("packages/core/src/internal/util.js"),R=_.getPath,$=_.isFunction,L=_.isNil,W=_.Lru,Z=_.warnOnce,U=V("packages/core/src/columns/graph.js").depsProxy,z="\0";function F(t,n={}){const i=n.locale,s=n.grid??null,l=n.context,u=t.value&&t.value.format,f=t.formatter||null,h=t.dataType&&t.dataType.format,g=t.lookup||null,b=(p,m,w)=>({value:p,data:w,row:m,column:t,colId:t.id,grid:s,context:l,locale:i});if($(u))return(p,m,w)=>{const v=u(b(p,m,w));return v==null?"":String(v)};if(f){if(g){const p=f.kind==="text";return(m,w,v)=>f(p?g.text(m):m,b(m,w,v))}return(p,m,w)=>f(p,b(p,m,w))}return $(h)?(p,m,w)=>{const v=h(b(p,m,w));return v==null?"":String(v)}:g?p=>g.text(p):p=>L(p)?"":typeof p=="string"?p:String(p)}function k(t,n){!t||!t.value||t.value.pure!==!1||Z(`impure:${n}:${t.id}`,`column "${t.id}" is an impure computed column (\`value.pure: false\`) and is being used to ${n}. The result is not stable across passes.`)}class O{#e;#t;#n;#r;#o;#i;#a=new W(4096);constructor(n){this.#e=n.columns instanceof Map?n.columns:new Map((n.columns||[]).map(i=>[i.id,i])),this.#t=n.graph,this.#n=n.grid??null,this.#r=n.context,this.#i=n.stored||null,this.#o=n.rowKey||y}get graph(){return this.#t}setGraph(n){this.#t=n,this.#a.clear()}beginPass(){this.#a.clear()}endPass(){this.#a.clear()}invalidate(n){if(this.#a.size===0)return;const i=n&&n.rows?new Set([...n.rows].map(String)):null,s=n&&n.columns?[...n.columns]:null;if(!i&&!s){this.#a.clear();return}const l=s?this.#s(s):null;for(const u of[...this.#a.keys()]){const f=String(u).split(z);f.length===3&&(i&&!i.has(f[0])||l&&!l.has(f[2])||this.#a.delete(u))}}#s(n){const i=new Set,s=this.#t,l=[...n];for(;l.length;){const u=l.pop();if(!i.has(u)){i.add(u);for(const f of s?s.dependents.get(u)||[]:[])l.push(f)}}return i}value(n,i,s){const l=typeof n=="string"?this.#e.get(n):n;if(!l)return;if(!l.computed)return this.#u(l,i,s);if(l.value.pure!==!1&&this.#i&&s&&s.physical!=null&&this.#i.has(l.id))return this.#i.get(l.id,s.physical);if(l.volatile)return this.compute(l,i,s);if(l.value.pure===!1)return this.compute(l,i,s);const u=`${this.#l(i,s)}${z}${l.id}`;if(this.#a.has(u))return this.#a.get(u);const f=this.compute(l,i,s);return this.#a.set(u,f),f}#l(n,i){return`${this.#o(n,i)}${z}${d(n)}`}#u(n,i,s){if(this.#i&&s&&s.physical!=null&&this.#i.has(n.id))return this.#i.get(n.id,s.physical);if(n.field)return n.read?n.read(i):R(i,n.field)}compute(n,i,s){const l=this.#t,u=l&&l.wholeRow.has(n.id);let f;if(u)f=i??{};else{f={};const g=l&&l.deps.get(n.id)||[];for(const p of g)f[p]=this.value(p,i,s);const b=l&&l.external.get(n.id)||[];for(const p of b)f[p]=R(i,p);f=U(f,[...g,...b],n.id)}const h={data:i,row:s,column:n,grid:this.#n,context:this.#r};return n.value.compute(f,h)}values(n,i){const s={},l=this.#t?this.#t.order:[...this.#e.keys()];for(const u of l)s[u]=this.value(u,n,i);return s}text(n,i,s){const l=typeof n=="string"?this.#e.get(n):n;return l?l.formatValue(this.value(l,i,s),s,i):""}key(n,i,s){const l=typeof n=="string"?this.#e.get(n):n;if(!l)return"";const u=this.value(l,i,s);return $(l.value.key)?String(l.value.key(this.#c(l,u,i,s))):l.lookup?l.lookup.groupKey(u):L(u)?"":String(u)}quickFilterText(n,i,s){const l=typeof n=="string"?this.#e.get(n):n;if(!l)return"";if($(l.value.quickFilterText)){const u=this.value(l,i,s);return String(l.value.quickFilterText(this.#c(l,u,i,s))??"")}return this.text(l,i,s)}#c(n,i,s,l){return{value:i,data:s,row:l,column:n,colId:n.id,grid:this.#n,context:this.#r}}parse(n,i,s,l){const u=typeof n=="string"?this.#e.get(n):n;if(!u)return i;const f={text:i,value:this.value(u,s,l),data:s,row:l,column:u,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 $(u.value.parse)?u.value.parse(f):u.dataType&&$(u.dataType.parse)?u.dataType.parse(f):i}validate(n,i,s,l,u){const f=typeof n=="string"?this.#e.get(n):n;if(!f||!$(f.edit.validate))return!0;const h=f.edit.validate({value:i,oldValue:s,data:l,row:u,column:f,grid:this.#n,context:this.#r});return h===!0||h===void 0?!0:String(h)}apply(n,i,s,l){const u=typeof n=="string"?this.#e.get(n):n;if(!u)return!1;const f=this.value(u,s,l);if($(u.value.apply)){const h=u.value.apply({value:i,oldValue:f,data:s,row:l,column:u,grid:this.#n,context:this.#r});return this.#d(u,s,l),h!==!1}return u.field?f===i?!1:(u.write(s,i),this.#d(u,s,l),!0):(Z(`apply:${u.id}`,`column "${u.id}" has no \`field\` and no \`value.apply\`, so an edit cannot be written back.`),!1)}commit(n,i,s,l){const u=typeof n=="string"?this.#e.get(n):n;if(!u)return{ok:!1,value:void 0,oldValue:void 0,changed:!1,error:"unknown column"};const f=this.value(u,s,l),h=this.parse(u,i,s,l),g=this.validate(u,h,f,s,l);if(g!==!0)return{ok:!1,value:h,oldValue:f,changed:!1,error:g};const b=this.apply(u,h,s,l);return{ok:!0,value:h,oldValue:f,changed:b}}#d(n,i,s){if(this.#a.size===0)return;const l=this.#l(i,s);this.#a.delete(`${l}${z}${n.id}`);for(const u of this.#t?this.#t.dependents.get(n.id)||[]:[])this.#a.delete(`${l}${z}${u}`)}}function y(t,n){return n&&n.key!=null?String(n.key):d(t)}function d(t){if(t&&typeof t=="object"){let n=c.get(t);return n===void 0&&(n=`#${r++}`,c.set(t,n)),n}return String(t)}const c=new WeakMap;let r=0}),ke("packages/core/src/model/shadow.js",function(e,V){"use strict";Object.defineProperty(e,"MAX_TRACKED",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"DEFAULT_DEPTH",{enumerable:!0,get:function(){return L}}),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 H}}),Object.defineProperty(e,"SHADOW_KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"ROLLING_KINDS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"FIT_SHADOW_KINDS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"DEFAULT_ANOMALY_THRESHOLD",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"SPEC_STATUS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"POSITIONAL_KINDS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"SHADOW_LABELS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"specStatusOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ShadowTracker",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"shadowsIn",{enumerable:!0,get:function(){return f}});const R=V("packages/core/src/internal/util.js").warnOnce,$=2e5,L=20,W=1e3,Z=50;function H(h){return Math.min(W,Math.max(Z,Math.floor(h)))}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"]),z=Object.freeze(["rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta"]),F=Object.freeze(["fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),k=.6745,O=3.5,y=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),d=Object.freeze(["rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag"]),c=Object.freeze({updates:"Updates",updatedAt:"Updated at",sinceUpdate:"Since update",delta:"Change",deltaPercent:"Change %",rate:"Rate of change",history:"History",firstValue:"Baseline",streak:"Streak",rank:"Rank",rankAsc:"Rank, ascending",rankChange:"Rank change",percentile:"Percentile",quartile:"Quartile",zScore:"Z-score",shareOfTotal:"Share of total",anomalyScore:"Anomaly score",anomalyFlag:"Anomaly",specStatus:"Spec status",rollingSum:"Rolling sum",rollingAvg:"Rolling average",rollingMin:"Rolling minimum",rollingMax:"Rolling maximum",windowCoverage:"Window coverage",cumulativeToDate:"Cumulative to date",periodOverPeriod:"Period over period",rollingQuantile:"Rolling quantile",windowApproximate:"Window approximate",tsTrend:"Trend",tsSeasonal:"Seasonal",tsResidual:"Seasonal residual",tsCoverage:"Decomposition coverage",tsSmoothed:"Smoothed",tsSmoothingAlpha:"Smoothing α",tsSmoothingBeta:"Smoothing β",fitPredicted:"Predicted",fitResidual:"Residual",fitInfluence:"Influence",fitStdResidual:"Std. residual",fitLeverage:"Leverage",fitCooksD:"Cook's D"});function r(h,g){if(!g)return null;const b=Number.isFinite(Number(g.lower))?Number(g.lower):null,p=Number.isFinite(Number(g.upper))?Number(g.upper):null;if(b===null&&p===null||!Number.isFinite(h))return null;if(b!==null&&h<b||p!==null&&h>p)return y.FAIL;const m=Number.isFinite(Number(g.warnLower))?Number(g.warnLower):null,w=Number.isFinite(Number(g.warnUpper))?Number(g.warnUpper):null;return m!==null&&h<m||w!==null&&h>w?y.WARN:y.PASS}function t(h,g,b){if(!g||typeof g!="object")return null;if(g.kind!=="time")return g.kind!==void 0&&R(`shadow.history.window.kind:${h}`,`a 'history' shadow's 'window' only accepts {kind: 'time', span}; '${g.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=g.minutes!=null?Number(g.minutes)*6e4:Number(g.span);if(!(p>0))return R(`shadow.history.window.span:${h}`,"a 'history' shadow's time window needs a positive 'span' (ms) or 'minutes'; it had none, so it reported the original, unwindowed history."),null;const m=Math.max(2,Math.floor(b)||L);return{span:p,bucketMs:Math.max(1,Math.floor(p/m))}}class n{#e;#t=new Map;#n=new Map;#r=new Map;#o=new Map;#i=new Map;#a=new Map;#s=0;#l;#u;#c;#d;#h=new Map;#f=null;#m=null;#p=null;constructor(g){this.#e=g.colId,this.#l=Math.max(2,g.depth||L),this.#u=Math.max(1,g.max||$),this.#c=g.now||(()=>Date.now()),this.#d=t(this.#e,g.historyWindow,this.#l),this.#d&&(this.#f=Math.floor(this.#c()/this.#d.bucketMs))}get colId(){return this.#e}get forgotten(){return this.#s}get size(){return this.#n.size}get historyWindow(){return this.#d}observe(g,b){const p=u(b);if(p===null)return;if(!this.#n.has(g)){this.#m=null,this.#p=null,this.#g(),this.#t.set(g,p),this.#n.set(g,p),this.#r.set(g,0),this.#o.set(g,this.#c()),this.#i.set(g,[p]),this.#d&&this.#h.set(g,[p]),this.#a.set(g,0);return}const m=this.#n.get(g);if(m===p)return;this.#m=null,this.#p=null,this.#n.set(g,p),this.#r.set(g,(this.#r.get(g)||0)+1),this.#o.set(g,this.#c());const w=this.#i.get(g)||[];w.push(p),w.length>this.#l&&w.splice(0,w.length-this.#l),this.#i.set(g,w);const v=Math.sign(p-m),a=this.#a.get(g)||0;this.#a.set(g,Math.sign(a)===v?a+v:v)}#g(){if(this.#n.size<this.#u)return;const g=this.#n.keys().next().value;g!==void 0&&(this.#t.delete(g),this.#n.delete(g),this.#r.delete(g),this.#o.delete(g),this.#i.delete(g),this.#h.delete(g),this.#a.delete(g),this.#s++)}rebase(){for(const[g,b]of this.#n)this.#t.set(g,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.#a.clear(),this.#s=0,this.#m=null,this.#p=null,this.#d&&(this.#f=Math.floor(this.#c()/this.#d.bucketMs))}retain(g){const b=g instanceof Set?g:new Set(g);let p=0;for(const m of[...this.#n.keys()])b.has(m)||(this.#t.delete(m),this.#n.delete(m),this.#r.delete(m),this.#o.delete(m),this.#i.delete(m),this.#h.delete(m),this.#a.delete(m),p++);return p&&(this.#m=null,this.#p=null),p}advanceHistoryWindow(g=this.#c()){const b=this.#d;if(!b)return 0;const p=Math.floor(g/b.bucketMs),m=p-this.#f;if(!(m>0))return 0;const w=Math.min(m,this.#l);for(const[v,a]of this.#h){const o=this.#n.get(v);for(let S=0;S<w;S++)a.push(o);a.length>this.#l&&a.splice(0,a.length-this.#l)}return this.#f=p,m}read(g,b,p,m){switch(g){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),v=this.#o.get(b);if(!w||w.length<2||v===void 0)return null;const a=this.#c()-v,o=w[w.length-1]-w[w.length-2];return a>0?o/a*1e3:o}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.#a.has(b)?this.#a.get(b):0;case"specStatus":return this.#n.has(b)?r(this.#n.get(b),m):null;default:return d.includes(g)?this.#y(g,b,p,m):null}}#v(g){if(g){if(this.#p&&this.#p.only===g)return this.#p.view;const b=this.#b(g);return this.#p={only:g,view:b},b}return this.#m?this.#m:(this.#m=this.#b(null),this.#m)}#b(g){const b=[];for(const[M,C]of this.#n)g&&!g.has(M)||b.push(C);const p=b.sort((M,C)=>M-C);let m=0,w=0,v=0,a=0;for(const M of p){a+=M,m++;const C=M-w;w+=C/m,v+=C*(M-w)}const o=[];for(const[M,C]of this.#t)g&&!g.has(M)||o.push(C);const S=m?i(p):0,E=p.map(M=>Math.abs(M-S)).sort((M,C)=>M-C),A=m?i(E):0;return{sorted:p,baseline:o.sort((M,C)=>M-C),sum:a,mean:m?w:0,sd:m>1?Math.sqrt(v/(m-1)):0,median:S,mad:A}}#y(g,b,p,m){if(!this.#n.has(b)||p&&!p.has(b))return null;const w=this.#n.get(b),v=this.#v(p),a=v.sorted.length;if(!a)return null;switch(g){case"rank":return a-l(v.sorted,w)+1;case"rankAsc":return s(v.sorted,w)+1;case"rankChange":{if(!this.#t.has(b)||!v.baseline.length)return null;const o=v.baseline.length-l(v.baseline,this.#t.get(b))+1,S=a-l(v.sorted,w)+1;return o-S}case"percentile":return l(v.sorted,w)/a*100;case"quartile":{const o=l(v.sorted,w)/a;return Math.min(4,Math.max(1,Math.ceil(o*4)))}case"zScore":return v.sd?(w-v.mean)/v.sd:null;case"anomalyScore":return v.mad?k*(w-v.median)/v.mad:null;case"anomalyFlag":{if(!v.mad)return null;const o=m&&Number.isFinite(Number(m.threshold))?Number(m.threshold):O;return Math.abs(k*(w-v.median)/v.mad)>o}case"shareOfTotal":return v.sum?w/v.sum*100:null;default:return null}}}function i(h){const g=h.length;if(!g)return 0;const b=(g-1)*.5,p=Math.floor(b),m=Math.ceil(b);return p===m?h[p]:h[p]+(b-p)*(h[m]-h[p])}function s(h,g){let b=0,p=h.length;for(;b<p;){const m=b+p>>1;h[m]<g?b=m+1:p=m}return b}function l(h,g){let b=0,p=h.length;for(;b<p;){const m=b+p>>1;h[m]<=g?b=m+1:p=m}return b}function u(h){if(h==null||h==="")return null;if(h instanceof Date){const b=h.getTime();return Number.isFinite(b)?b:null}const g=typeof h=="number"?h:Number(h);return Number.isFinite(g)?g:null}function f(h){const g=[];for(const b of h||[]){const p=b.shadow;if(!p)continue;const m=typeof p=="string"?{kind:p}:p,w=m.kind;U.includes(w)&&(z.includes(w)||F.includes(w)||g.push({colId:b.id||b.field,of:m.of||b.field||b.id,kind:w,depth:m.depth,historyWindow:w==="history"?m.window:void 0}))}return g}}),ke("packages/core/src/columns/model.js",function(e,V){"use strict";Object.defineProperty(e,"BUILTIN_DEFAULTS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"normaliseAlign",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"normaliseVAlign",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"expandColumn",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"flattenTree",{enumerable:!0,get:function(){return re}});const _=V("packages/core/src/internal/util.js"),R=_.expand,$=_.fail,L=_.getPath,W=_.humanise,Z=_.isFunction,H=_.isObject,U=_.merge,z=_.pathGetter,F=_.pathSetter,k=_.toArray,O=_.uid,y=_.warnOnce,c=V("packages/core/src/format/index.js").compileFormat,r=V("packages/core/src/columns/datatypes.js"),t=r.comparatorFor,n=r.createTypeRegistry,i=r.storageKind,s=V("packages/core/src/columns/infer.js"),l=s.inferColumnType,u=s.DEFAULT_SAMPLE,f=V("packages/core/src/columns/graph.js"),h=f.buildGraph,g=f.affectedBy,p=V("packages/core/src/columns/lookup.js").createLookup,m=V("packages/core/src/columns/value.js"),w=m.compileDisplay,v=m.ValuePipeline,a=m.warnImpureUse,S=V("packages/core/src/model/shadow.js").FIT_SHADOW_KINDS,E={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},A={centre:"center"},M=new Set(["start","center","end","left","right"]);function C(ie){if(typeof ie!="string")return;const te=ie.toLowerCase();return A[te]?A[te]:M.has(te)?te:void 0}function P(ie){if(typeof ie!="string")return;const te=ie.toLowerCase();return te==="center"||te==="centre"?"middle":te==="top"||te==="middle"||te==="bottom"?te:void 0}const x=["cell","layout","header"];function K(ie){if(!H(ie))return{};const te={...ie},ce=(ue,ae)=>{if(ie[ue]===void 0)return;const pe=R(ie[ue],ae);pe&&x.includes(ue)&&!H(ie[ue])&&delete pe.enabled,te[ue]=pe};return ce("sort","direction"),ce("filter","type"),ce("cell","render"),ce("edit","editor"),ce("layout","width"),ce("group","index"),ce("pivot","index"),ce("header","render"),ce("facet","strategy"),te}function I(ie,te){const ce={...ie||{}},ue=H(te)&&H(te.layout)&&te.layout.width!==void 0;return ce.fit==="content"&&!ue&&delete ce.width,ce}const D=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","validation","value","verticalAlign"]),j=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function T(ie,te,ce,ue){const ae=ce==="columnGroup"?"column group":"column";for(const pe of Object.keys(ie))te.has(pe)||y(`${ce}.unknown:${pe}`,`'${pe}' is not a configuration key this grid recognises, so it had no effect on ${ae} "${ue}". Check the spelling against the reference.`)}function B(ie){const te=ie.defaults||{},ce={};return te.align&&(ce.align=te.align,ce.cell={align:te.align},ce.header={align:te.align}),te.filter&&(ce.filter=te.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:te.filter}),te.editor&&(ce.edit=te.editor==="none"?{editor:null}:{editor:te.editor}),te.total&&(ce.total=te.total),te.render&&(ce.cell={...ce.cell||{},render:te.render}),ie.export&&(ce.export={...ie.export}),ce}function q(ie){if(typeof ie=="string")return ie.trim()?[ie.trim()]:[];if(!Array.isArray(ie))return[];const te=[];for(const ce of ie){if(typeof ce!="string")continue;const ue=ce.trim();ue&&!te.includes(ue)&&te.push(ue)}return te}class X{#e=new Map;#t=[];#n=[];#r;#o;#i;#a;#s;#l;#u(te,ce,ue){const ae=this.#c(te,ce,ue);if(typeof ae!="string"||!this.#d)return ae??null;const pe=ce&&ce.totals&&ce.totals.implement;if(pe&&Z(pe[ae])){const ve=pe[ae];return ve.totalName=ae,ve}const he=this.#d.totalFn?.(ae);return Z(he)?he:ae}#c(te,ce,ue){if(typeof te!="string")return te;const ae=ce&&ce.totals&&ce.totals.supported;if(!Array.isArray(ae)||ae.includes(te))return te;const pe=ae.length?ae.join(", "):"none";return $(`column "${ue}" is typed ${ce.name||"a type"}, for which the total "${te}" is not meaningful. Supported: ${pe}. Aggregating it anyway would produce a confident wrong number.`),te}#d;#h;#f;#m;#p;#g;#v=!1;#b;#y;constructor(te={}){this.#o=K(te.columnDefaults||{}),this.#i=te.columnPresets||{},this.#s=te.locale,this.#a=te.timeZone,this.#l=P(te.verticalAlign),this.#d=te.registry||null,this.#h=te.grid||null,this.#f=te.context,this.#b=te.sampleSize??u,this.#y=te.onChange||null,this.#g=Z(te.rowKey)?te.rowKey:void 0,this.#r=n(te.dataTypes,this.#d);const{leaves:ce,groups:ue}=re(te.columns||[]);this.#n=ue;for(const ae of ce){const pe=this.#w(ae.def,null);if(pe.groupPath=ae.path,this.#e.has(pe.id)){y(`columns.duplicate:${pe.id}`,`two columns resolve to the id '${pe.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}ae.column=pe,this.#e.set(pe.id,pe),this.#t.push(pe.id)}this.#A(te.stored||null)}#w(te,ce){T(te,D,"column",te.id||te.field||"(unnamed)");const ue=K(te),ae=k(te.preset),pe=ae.map(He=>{const et=this.#i[He];return et?K(et):(y(`preset:${He}`,`unknown column preset "${He}"; ignoring`),{})}),he=this.#j(ue,pe,ce),ve=this.#r.get(he)||this.#r.get("text");!this.#r.has(he)&&te.type&&y(`type:${he}`,`unknown data type "${he}"; falling back to "text"`);let Oe=E;Oe=U(Oe,this.#o),te.type!==!1&&(Oe=U(Oe,B(ve)));for(const He of pe)Oe=U(Oe,He);Oe=U(Oe,ue);const Ie=Oe.edit;Ie&&Ie.editor&&Ie.enabled!==!0&&!Z(Ie.enabled)&&(te.edit||{}).editor&&y(`column.editor-not-enabled:${te.id||te.field}`,`column '${te.id||te.field}' names the editor '${Ie.editor}' but does not enable editing, so it stays read-only. Add \`enabled: true\`, or use \`edit: true\` and set \`editor\` alongside it.`);const Ze=te.id||te.field||O("col");if(te.shadow&&!Z(Oe.value&&Oe.value.compute)){const He=typeof te.shadow=="string"?{kind:te.shadow}:te.shadow,et=He.of||te.field||Ze,lt=S.includes(He.kind),Ae=lt?He.model||He:null,We=lt&&Ae?[...Array.isArray(Ae.predictors)?Ae.predictors:[],Ae.response].filter(Boolean):null;Oe.value={...Oe.value||{},deps:We&&We.length?We:He.orderBy&&He.orderBy!==et?[et,He.orderBy]:[et],pure:!1,compute:(Ge,Je)=>{const ut=Je.grid&&Je.grid.statistics;if(!ut)return null;const vt=Je.row&&Je.row.key||ut.keyOf(Je.data);if(!vt)return null;if(lt){if(!Z(ut.fitShadow))return null;const Ct=He.model?{...He.model,threshold:He.threshold}:He;return ut.fitShadow(He.kind,vt,Ct)}return ut.shadow(et,He.kind,vt,He.scope,He)}}}if(te.running&&!Z(Oe.value&&Oe.value.compute)){const He=typeof te.running=="string"?{kind:te.running}:te.running,et=He.of||te.field||Ze;Oe.value={...Oe.value||{},deps:[et],pure:!1,compute:(lt,Ae)=>{const We=Ae.grid&&Ae.grid.statistics;if(!We||!Z(We.running))return null;const Ge=Ae.row&&Ae.row.key||We.keyOf(Ae.data);return Ge?We.running(et,He.kind||"total",Ge):null}},te.sort===void 0&&(Oe.sort={...Oe.sort||{},enabled:!1})}const Se=te.field??(Z(Oe.value&&Oe.value.compute)?null:te.id??null),xe=Z(Oe.value&&Oe.value.compute),Be={id:Ze,field:Se,shadow:te.shadow||null,running:te.running||null,spec:te.spec||null,validation:te.validation||null,volatile:!!(te.shadow||te.running),title:Oe.title??W(Se||Ze),type:ve.name,dataType:ve,nullable:Oe.nullable!==!1,align:C(ue.cell&&ue.cell.align||ue.align||Oe.cell&&Oe.cell.align||Oe.align||ve.defaults&&ve.defaults.align)||"start",verticalAlign:P(ue.cell&&ue.cell.verticalAlign||ue.verticalAlign||Oe.cell&&Oe.cell.verticalAlign||Oe.verticalAlign)||this.#l,rowSpan:Z(Oe.rowSpan)?Oe.rowSpan:null,colSpan:Z(Oe.colSpan)?Oe.colSpan:null,value:{pure:!0,...Oe.value||{}},cell:{...Oe.cell||{}},edit:{...Oe.edit||{}},sort:{...Oe.sort||{}},filter:{...Oe.filter||{}},group:{enabled:!1,index:-1,explode:!1,...Oe.group||{}},pivot:{enabled:!1,index:-1,...Oe.pivot||{}},total:this.#u(Oe.total,ve,te.id||te.field||"(unnamed)"),groupTotal:Oe.groupTotal===void 0?null:this.#u(Oe.groupTotal,ve,te.id||te.field||"(unnamed)"),grandTotal:Oe.grandTotal===void 0?null:this.#u(Oe.grandTotal,ve,te.id||te.field||"(unnamed)"),tags:q(Oe.tags),typeOptions:Oe.typeOptions??null,...H(Oe[he])?{[he]:Oe[he]}:{},layout:I(Oe.layout,ue),header:{...Oe.header||{}},contextMenu:Oe.contextMenu===void 0?null:Oe.contextMenu,facet:{...Oe.facet||{}},export:{...Oe.export||{}},allowGroup:Oe.allowGroup!==!1,allowPivot:Oe.allowPivot!==!1,allowTotal:Oe.allowTotal!==!1,quickFilter:Oe.quickFilter!==!1,def:te,format:Oe.format,presets:ae,inferred:ce!=null&&!te.type,computed:xe,read:Se?z(Se):null,write:Se?F(Se):null};Be.cell.align=C(ue.cell&&ue.cell.align)||Be.align,Be.header.align=C(ue.header&&ue.header.align)||Be.align;const _e=Oe.lookup||null;return Be.lookup=_e?p({id:Ze,lookup:_e},{locale:this.#s,onChange:()=>{this.#y&&this.#y("lookup",{colId:Ze})}}):null,Be.group.explode&&Be.lookup&&Be.lookup.multiple&&y(`explode:${Ze}`,`column "${Ze}" has \`group.explode\`, so rows appear under each of their values and totals double-count. Group footers should be annotated accordingly.`),this.#S(Be),Be}#S(te){te.formatter=c(te.format,te.dataType,this.#s,this.#a,te.id),te.formatValue=w(te,{locale:this.#s,grid:this.#h,context:this.#f}),te.compare=Z(te.value.compare)?te.value.compare:te.lookup?te.lookup.comparator():t(te.dataType,this.#s),te.excel=te.formatter&&te.formatter.ooxml||te.dataType&&te.dataType.excel||"General",te.storeKind=i(te.dataType,!!(te.lookup&&te.lookup.multiple))}#j(te,ce,ue){if(te.type===!1)return"text";if(te.type)return te.type;for(let ae=ce.length-1;ae>=0;ae--)if(ce[ae].type)return ce[ae].type;if(this.#o.type)return this.#o.type;if(te.shadow){const ae=typeof te.shadow=="string"?te.shadow:te.shadow.kind;if(ae==="fitInfluence")return"boolean";if(ae==="fitPredicted"||ae==="fitResidual"||ae==="fitStdResidual"||ae==="fitLeverage"||ae==="fitCooksD"||ae==="tsTrend"||ae==="tsSeasonal"||ae==="tsResidual"||ae==="tsCoverage"||ae==="tsSmoothed"||ae==="tsSmoothingAlpha"||ae==="tsSmoothingBeta")return"number"}return ue||(te.lookup?"lookup":"text")}#A(te){const ce=this.all();this.#m=h(ce),this.#p?this.#p.setGraph(this.#m):this.#p=new v({columns:this.#e,graph:this.#m,grid:this.#h,context:this.#f,stored:te||null,rowKey:this.#g});const ue=this.#p;for(const ae of ce)ae.getValue=(pe,he)=>ue.value(ae,pe,he)}all(){return this.#t.map(te=>this.#e.get(te))}visible(){return this.all().filter(te=>!te.layout.hidden)}get(te){return this.#e.get(te)}groups(){const te=ce=>{const ue=[];for(const ae of ce)Array.isArray(ae.columns)?ue.push({...ae,columns:te(ae.columns)}):ae.column&&ue.push(ae.column);return ue};return te(this.#n)}graph(){return this.#m}pipeline(){return this.#p}types(){return this.#r}affectedBy(te){return g(this.#m,te)}value(te,ce,ue){return this.#p.value(te,ce,ue)}text(te,ce,ue){return this.#p.text(te,ce,ue)}checkImpure(te,ce){a(this.#e.get(te),ce)}setLocale(te){this.#s=te;for(const ce of this.all())ce.lookup&&ce.lookup.setLocale(te),this.#S(ce);this.#y&&this.#y("locale",{locale:te})}infer(te){const ce={};if(this.#v||!Array.isArray(te)||te.length===0)return ce;this.#v=!0;let ue=!1;for(const ae of this.all()){const pe=ae.def;if(pe.type!==void 0||!ae.field||ae.computed||ae.lookup||this.#O(ae))continue;const he=ae.read||(Ie=>L(Ie,ae.field)),ve=l(ae.id,te,he,this.#r,{sampleSize:this.#b});if(ve===ae.type)continue;ce[ae.id]=ve;const Oe=this.#w(pe,ve);Oe.groupPath=ae.groupPath,Oe.layout={...Oe.layout,...Q(ae.layout)},this.#e.set(ae.id,Oe),oe(this.#n,ae.id,Oe),ue=!0}return ue&&this.#A(null),ce}redecorate(te,ce,ue={}){const ae=this.#e.get(te);if(!ae){y(`redecorate:${te}`,`columns.decorate('${te}', …): no column with id '${te}'.`);return}const pe=ae.def||{},he={...H(pe.cell)?pe.cell:{}};he.decoration=ce??void 0,ue&&"variant"in ue&&(he.variant=ue.variant);const ve={...pe,cell:he},Oe=this.#w(ve,ae.type);return Oe.groupPath=ae.groupPath,Oe.layout={...Oe.layout,...Q(ae.layout)},this.#e.set(te,Oe),oe(this.#n,te,Oe),this.#A(null),this.#y&&this.#y("decorate",{colId:te}),Oe}#O(te){for(const ce of te.presets){const ue=this.#i[ce];if(ue&&ue.type)return!0}return!!this.#o.type}#C(te){return!te.computed&&Z(te.dataType&&te.dataType.toStorage)}storeReader(te){if(te.computed)return ce=>this.#p.value(te,ce,null);if(this.#C(te)){const ce=te.dataType.toStorage,ue={timeZone:te.timeZone||this.#a};return ae=>ce(te.read(ae),ue)}return te.read}storeValue(te,ce){if(!(!te||te.computed)&&Z(te.read))return this.storeReader(te)(ce)}storeSchema(){const te=[];for(const ce of this.all()){if(ce.computed&&ce.value.pure===!1||!ce.computed&&!ce.field)continue;const ue=this.storeReader(ce);let ae=null;!ce.computed&&!this.#C(ce)&&typeof ce.field=="string"&&!ce.lookup&&(ae=ce.field);const pe={id:ce.id,kind:ce.storeKind,nullable:ce.nullable,read:ue};ae!==null&&(pe.field=ae),ce.lookup&&(pe.dictionary=ce.lookup.dictionary()),te.push(pe)}return te}state(){return this.all().map(te=>({id:te.id,width:te.layout.width,flex:te.layout.flex||void 0,hidden:!!te.layout.hidden,pin:te.layout.pin??null,sort:te.sort.direction??null,sortIndex:te.sort.direction?te.sort.order??0:null,groupIndex:te.group.enabled?te.group.index??0:null,pivotIndex:te.pivot.enabled?te.pivot.index??0:null,total:typeof te.total=="string"?te.total:null,groupTotal:typeof te.groupTotal=="string"?te.groupTotal:void 0,grandTotal:typeof te.grandTotal=="string"?te.grandTotal:void 0,decoration:te.cell&&te.cell.decoration!=null?J(te.cell.decoration):void 0,variant:te.cell&&te.cell.variant!=null?J(te.cell.variant):void 0}))}applyState(te){const ce={applied:[],skipped:[]},ue=Array.isArray(te)?te:te&&te.columns||[],ae=!Array.isArray(te)&&te&&te.columnOrder||null;for(const he of ue){if(!he||!he.id){ce.skipped.push({key:"?",reason:"no id"});continue}let ve=this.#e.get(he.id);if(!ve){ce.skipped.push({key:he.id,reason:"unknown column"});continue}if(Object.hasOwn(he,"decoration")||Object.hasOwn(he,"variant")){const Oe=ve.cell?ve.cell.decoration:void 0,Ie=he.decoration??null,Ze=Object.hasOwn(he,"variant"),Se=Ze&&!ne(ve.cell?ve.cell.variant:void 0,he.variant);(!ne(Oe,Ie)||Se)&&(this.redecorate(he.id,Ie,Ze?{variant:he.variant??void 0}:{}),ve=this.#e.get(he.id)||ve)}he.width!=null&&(ve.layout.width=he.width),he.flex!=null&&(ve.layout.flex=he.flex),he.hidden!=null&&(ve.layout.hidden=!!he.hidden),he.pin!==void 0&&(ve.layout.pin=he.pin),he.sort!==void 0&&(ve.sort.direction=he.sort),he.sortIndex!=null&&(ve.sort.order=he.sortIndex),he.groupIndex!=null&&(ve.group.enabled=!0,ve.group.index=he.groupIndex),he.pivotIndex!=null&&(ve.pivot.enabled=!0,ve.pivot.index=he.pivotIndex),he.total!==void 0&&(ve.total=he.total),he.groupTotal!==void 0&&(ve.groupTotal=he.groupTotal),he.grandTotal!==void 0&&(ve.grandTotal=he.grandTotal),ce.applied.push(he.id)}const pe=ae||ue.map(he=>he&&he.id).filter(Boolean);if(pe.length){const he=pe.filter(Oe=>this.#e.has(Oe)),ve=this.#t.filter(Oe=>!he.includes(Oe));this.#t=[...he,...ve]}return this.#y&&this.#y("state",ce),ce}move(te,ce){const ue=this.#t.indexOf(te);if(ue===-1)return;const ae=this.#e.get(te);if(ae.layout.movable===!1||ae.layout.lockPosition){y(`move:${te}`,`column "${te}" is not movable; the move was ignored`);return}const pe=this.#E(te,ce);if(pe){y(`move.married:${pe}`,`band "${pe}" declares marryChildren, so its columns stay together; the move was ignored`);return}this.#t.splice(ue,1),this.#t.splice(Math.max(0,Math.min(ce,this.#t.length)),0,te),this.#T(),this.#y&&this.#y("move",{id:te,to:ce})}#E(te,ce){if(!this.#n||!this.#n.length)return null;const ue=this.#t.filter(ve=>ve!==te),ae=Math.max(0,Math.min(ce,ue.length)),pe=(ve,Oe)=>{if(Array.isArray(ve.columns)){for(const Ze of ve.columns)pe(Ze,Oe);return Oe}const Ie=ve.column?ve.column.id:ve.id;return Ie&&Oe.push(Ie),Oe},he=ve=>{for(const Oe of ve){if(!Array.isArray(Oe.columns))continue;if(Oe.marryChildren===!0){const Ze=pe(Oe,[]),Se=Ze.includes(te),xe=Ze.map(Be=>ue.indexOf(Be)).filter(Be=>Be>=0);if(xe.length){const Be=Math.min(...xe),_e=Math.max(...xe);if(Se?ae<Be||ae>_e+1:ae>Be&&ae<=_e)return Oe.id}}const Ie=he(Oe.columns);if(Ie)return Ie}return null};return he(this.#n)}#T(){const te=new Map(this.#t.map((ae,pe)=>[ae,pe])),ce=ae=>{if(!Array.isArray(ae.columns)){const he=ae.column?ae.column.id:ae.id;return te.has(he)?te.get(he):1/0}let pe=1/0;for(const he of ae.columns)pe=Math.min(pe,ce(he));return pe},ue=ae=>{ae.sort((pe,he)=>ce(pe)-ce(he));for(const pe of ae)Array.isArray(pe.columns)&&ue(pe.columns)};ue(this.#n)}#x(te){const ce=ue=>{for(let ae=0;ae<ue.length;ae++){const pe=ue[ae];if(Array.isArray(pe.columns)){const he=ce(pe.columns);if(he)return he}else if(pe.column&&pe.column.id===te)return ue.splice(ae,1)[0]}return null};return ce(this.#n)}#R(te){const ce=[];for(let ue=te.length-1;ue>=0;ue--){const ae=te[ue];Array.isArray(ae.columns)&&(ce.push(...this.#R(ae.columns)),ae.columns.length===0&&(ce.push(ae.id),te.splice(ue,1)))}return ce}#N(){const te=(ce,ue)=>{for(const ae of ce)Array.isArray(ae.columns)?te(ae.columns,[...ue,ae.id]):ae.column&&(ae.column.groupPath=ue)};te(this.#n,[])}#M(te){const ce=new Set(te),ue=this.#t.filter(ve=>ce.has(ve));if(!ue.length)return;const ae=Math.min(...ue.map(ve=>this.#t.indexOf(ve))),pe=this.#t.slice(0,ae).filter(ve=>!ce.has(ve)),he=this.#t.slice(ae).filter(ve=>!ce.has(ve));this.#t=[...pe,...ue,...he]}#_(te){const ce=[],ue=ae=>{if(Array.isArray(ae.columns))for(const pe of ae.columns)ue(pe);else ae.column&&ce.push(ae.column.id)};return ue(te),ce}#U(te){const ce=ue=>{for(const ae of ue){if(!Array.isArray(ae.columns))continue;if(ae.id===te)return{node:ae,parent:ue};const pe=ce(ae.columns);if(pe)return pe}return null};return ce(this.#n)}groupColumns(te,ce={}){const ue=k(te).filter(Oe=>this.#e.has(Oe));if(!ue.length)return y("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const Oe of ue)if(this.#e.get(Oe).layout.lockPosition)return y(`columns.group.locked:${Oe}`,`column "${Oe}" is position-locked and cannot be grouped.`),null;const ae=ce.groupId?this.#U(ce.groupId):null;if(ce.groupId&&!ae)return y(`columns.group.unknown:${ce.groupId}`,`no band "${ce.groupId}" to add to; nothing was grouped.`),null;let pe=null;if(!ae&&ce.id!=null&&(pe=String(ce.id),this.#U(pe)||this.#e.has(pe)))return y(`columns.group.idtaken:${pe}`,`band id "${pe}" is already in use; nothing was grouped.`),null;const he=ue.map(Oe=>this.#x(Oe)).filter(Boolean);if(!he.length)return null;let ve;if(ae)ae.node.columns.push(...he),ve=ae.node.id;else{const Oe={id:pe||O("grp"),title:ce.title||"",collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!1,header:{},def:{},columns:he},Ie=Number.isInteger(ce.at)?Math.max(0,Math.min(ce.at,this.#n.length)):this.#n.length;this.#n.splice(Ie,0,Oe),ve=Oe.id}return this.#R(this.#n),this.#M(ue),this.#N(),this.#T(),this.#y&&this.#y("columngroup",{action:"formed",groupId:ve,ids:ue}),ve}ungroupColumn(te){const ce=this.#e.get(te);if(!ce){y(`columns.ungroup.unknown:${te}`,`no column "${te}" to ungroup.`);return}const ue=ce.groupPath||[];if(!ue.length)return;const ae=ue[ue.length-1],pe=this.#U(ae);if(!pe)return;const he=this.#x(te);if(!he)return;const ve=pe.parent.indexOf(pe.node);pe.parent.splice(ve+1,0,he);const Oe=this.#R(this.#n),Ie=this.#_(pe.node);if(Ie.length){this.#M(Ie);const Ze=Math.max(...Ie.map(xe=>this.#t.indexOf(xe))),Se=this.#t.filter(xe=>xe!==te);Se.splice(Ze+1,0,te),this.#t=Se}this.#N(),this.#T(),this.#y&&this.#y("columngroup",{action:"removed",id:te,dissolved:Oe})}renameGroup(te,ce){const ue=this.#U(te);if(!ue){y(`columns.group.rename:${te}`,`no band "${te}" to rename.`);return}ue.node.title=String(ce??""),this.#y&&this.#y("columngroup",{action:"renamed",groupId:te,title:ue.node.title})}dissolveGroup(te){const ce=this.#U(te);if(!ce){y(`columns.group.dissolve:${te}`,`no band "${te}" to dissolve.`);return}const ue=ce.parent.indexOf(ce.node);ce.parent.splice(ue,1,...ce.node.columns),this.#N(),this.#T(),this.#y&&this.#y("columngroup",{action:"dissolved",groupId:te})}moveGroup(te,ce){const ue=this.#U(te);if(!ue){y(`columns.group.move:${te}`,`no band "${te}" to move.`);return}const ae=ue.parent,pe=ae.indexOf(ue.node);pe!==-1&&(ae.splice(pe,1),ae.splice(Math.max(0,Math.min(ce,ae.length)),0,ue.node),this.#F(),this.#N(),this.#y&&this.#y("columngroup",{action:"moved",groupId:te,to:ce}))}#F(){const te=[],ce=ae=>{for(const pe of ae)Array.isArray(pe.columns)?ce(pe.columns):pe.column&&te.push(pe.column.id)};ce(this.#n);const ue=new Set(te);this.#t=[...te,...this.#t.filter(ae=>!ue.has(ae))]}groupTree(){const te=ue=>ue.map(ae=>Array.isArray(ae.columns)?{id:ae.id,title:ae.title||"",collapsible:!!ae.collapsible,openByDefault:ae.openByDefault!==!1,columns:te(ae.columns)}:ae.column?ae.column.id:null).filter(ae=>ae!==null),ce=te(this.#n);return ce.some(ue=>ue&&typeof ue=="object")?ce:[]}applyGroupTree(te){if(!Array.isArray(te))return;const ce=new Set,ue=pe=>{const he=[];for(const ve of pe)if(ve&&typeof ve=="object"&&Array.isArray(ve.columns)){const Oe=ue(ve.columns);if(!Oe.length)continue;he.push({id:ve.id||O("grp"),title:ve.title||"",collapsible:ve.collapsible===!0,openByDefault:ve.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Oe})}else if(typeof ve=="string"){const Oe=this.#e.get(ve);Oe&&!ce.has(ve)&&(ce.add(ve),he.push({column:Oe,path:[]}))}return he},ae=ue(te);for(const pe of this.#t){if(ce.has(pe))continue;const he=this.#e.get(pe);he&&ae.push({column:he,path:[]})}this.#n=ae,this.#N(),this.#T(),this.#y&&this.#y("columngroup",{action:"applied"})}show(te){this.#Y(te,!1)}hide(te){this.#Y(te,!0)}#Y(te,ce){const ue=[];for(const ae of k(te)){const pe=this.#e.get(ae);if(pe){if(ce&&pe.layout.lockVisible){y(`lockVisible:${ae}`,`column "${ae}" is \`layout.lockVisible\` and cannot be hidden`);continue}pe.layout.hidden!==ce&&(pe.layout.hidden=ce,ue.push(ae))}}ue.length&&this.#y&&this.#y("visible",{ids:ue,hidden:ce})}pin(te,ce){const ue=this.#e.get(te);ue&&(ue.layout.pin=ce??null,this.#y&&this.#y("pin",{id:te,side:ue.layout.pin}))}resize(te,ce){const ue=this.#e.get(te);if(!ue)return;if(ue.layout.resizable===!1){y(`resize:${te}`,`column "${te}" is not resizable; the resize was ignored`);return}const ae=ue.layout.min??0,pe=ue.layout.max;let he=Math.max(ae,ce);pe!=null&&(he=Math.min(pe,he)),ue.layout.width=he,ue.layout.flex=0,this.#y&&this.#y("resize",{id:te,width:he})}}function Q(ie){const te={};return ie.width!=null&&(te.width=ie.width),ie.hidden!=null&&(te.hidden=ie.hidden),ie.pin!==void 0&&(te.pin=ie.pin),te}function J(ie){if(ie===null||typeof ie!="object")return ie;try{return structuredClone(ie)}catch{}try{return JSON.parse(JSON.stringify(ie))}catch{return ie}}function ne(ie,te){const ce=ie??null,ue=te??null;if(ce===ue)return!0;if(ce===null||ue===null)return!1;if(typeof ce!="object"||typeof ue!="object")return ce===ue;try{return JSON.stringify(ce)===JSON.stringify(ue)}catch{return!1}}function re(ie){const te=[],ce=(ae,pe)=>{const he=[];for(const ve of ae){if(!H(ve)){$("a column definition must be an object");continue}if(Array.isArray(ve.columns)){T(ve,j,"columnGroup",ve.title||ve.id||"(unnamed)");const Oe={id:ve.id||O("grp"),title:ve.title||"",collapsible:ve.collapsible===!0,openByDefault:ve.openByDefault!==!1,showWhen:ve.showWhen||"always",marryChildren:ve.marryChildren===!0,header:ve.header||{},def:ve,columns:[]};Oe.columns=ce(ve.columns,[...pe,Oe.id]),he.push(Oe)}else{const Oe={def:ve,path:pe};te.push(Oe),he.push(Oe)}}return he},ue=ce(ie,[]);return{leaves:te,groups:ue}}function oe(ie,te,ce){for(const ue of ie){if(ue.columns){if(oe(ue.columns,te,ce))return!0;continue}if(ue.column&&ue.column.id===te)return ue.column=ce,!0}return!1}}),ke("packages/core/src/columns/autogroup.js",function(e,V){"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 H}});const R=V("packages/core/src/internal/util.js").warnOnce,$="__lattice_group",L=240,W=.5;function Z(U){const{columns:z,groupBy:F}=U,k=F.map(d=>z.get(d)).filter(Boolean),O=k.length?k.map(d=>d.title||d.id).join(" > "):"Group",y=U.config&&U.config.autoGroupColumnWidth||L;return{id:$,field:null,title:O,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:F.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(d,c){return c&&c.group?c.groupValue:null},formatValue(d,c){if(!c||!c.group)return"";if(c.grandTotal)return U.config&&U.config.grandTotalLabel||"Total";const r=k[Math.min(c.level||0,k.length-1)];return r&&typeof r.formatValue=="function"?r.formatValue(d,c):d==null?"":String(d)}}}function H(U,z,F){!U.length||F<100||z<F*W||R(`grouping.cardinality:${U.join(",")}`,`grouping by ${U.join(", ")} produced ${z} groups for ${F} 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.`)}}),ke("packages/core/src/columns/selectcolumn.js",function(e,V){"use strict";Object.defineProperty(e,"SELECT_COLUMN_ID",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"createSelectionColumn",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return L}});const _="__lattice_select",R=44;function $(W){const Z=W.selection||{},H=W.config&&W.config.selectionColumnWidth||R;return{id:_,field:null,title:"",type:"boolean",dataType:{base:"boolean"},nullable:!1,align:"center",generated:!0,control:!0,value:{pure:!0},cell:{render:"checkbox",props:{mode:"selection"},align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:H,min:H,max:H,pin: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,z){return z?z.selected:!1},formatValue(){return""}}}const L=$}),ke("packages/core/src/columns/rownumbercolumn.js",function(e,V){"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 z}});const R=V("packages/core/src/internal/util.js").isFunction,$="__lattice_rownumber",L=40,W=9,Z=22;function H(F){const k=String(Math.max(1,Math.trunc(Math.abs(F))||1)).length;return Math.max(L,k*W+Z)}function U(F){const k=F.rowNumbers,O=k&&typeof k=="object"?k:{},y=Number.isFinite(O.start)?O.start:1,d=Number.isFinite(O.width)?O.width:H((F.maxNumber||0)+y),c=R(F.rank)?F.rank:()=>null;return{id:$,field:null,title:typeof O.title=="string"?O.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:d,min:d,max:d,pin:"start",hidden:!1,resizable:O.width==null,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(r,t){const n=c(t);return n==null?null:n-1+y},formatValue(r){return r==null?"":String(r)}}}const z=U}),ke("packages/core/src/model/detail.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_DETAIL_HEIGHT",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"DEFAULT_CACHE_LIMIT",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"resolveDetail",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"DetailModel",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const _=V("packages/core/src/internal/util.js"),R=_.isFunction,$=_.warnOnce,L=240,W=10;function Z(z){if(!z)return null;const F=z===!0?{}:z;return F.enabled===!1?null:!R(F.rows)&&!F.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:F.render||null,config:F.config||null,rows:R(F.rows)?F.rows:null,height:F.height??L,cacheLimit:Number.isFinite(F.cacheLimit)?Math.max(0,F.cacheLimit):W,isMaster:R(F.isMaster)?F.isMaster:null,target:F.target||null,onCreate:R(F.onCreate)?F.onCreate:null,path:typeof F.path=="string"?F.path:null}}class H{#e;#t=new Set;#n;#r=0;constructor(F){this.#e=F.config,this.#n=R(F.onChange)?F.onChange:()=>{}}get config(){return this.#e}get inline(){return!this.#e.target}isMaster(F){if(!F||F.group||F.detail)return!1;const k=this.#e.isMaster;return k?!!k(F.data,F):!0}isOpen(F){return this.#t.has(F)}keys(){return[...this.#t]}activeKey(){for(const F of this.#t)return F;return null}heightOf(F){const k=this.#e.height;return R(k)?Number(k(F))||L:k==="auto"?L:Number(k)||L}open(F){return this.#t.has(F)?!1:(this.inline||this.#t.clear(),this.#t.add(F),this.#o(),!0)}close(F){return this.#t.delete(F)?(this.#o(),!0):!1}toggle(F){return this.#t.has(F)?(this.close(F),!1):(this.open(F),!0)}closeAll(){this.#t.size&&(this.#t.clear(),this.#o())}prune(F){if(!this.#t.size||!R(F))return;let k=!1;for(const O of[...this.#t])F(O)||(this.#t.delete(O),k=!0);k&&this.#o()}signature(){return`${this.#r}`}set(F){this.#t.clear();const k=Array.isArray(F)?F:[];for(const O of this.inline?k:k.slice(0,1))this.#t.add(O);this.#o()}#o(){this.#r++,this.#n()}}const U=H}),ke("packages/core/src/compute/handle.js",function(e,V){"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 z}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return n}});const _=V("packages/core/src/internal/util.js"),R=_.collator,$=_.defaultCompare,L=_.warnOnce;function W(i){const s=new Uint32Array(i);for(let l=0;l<i;l++)s[l]=l;return s}function Z(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 l=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):l?i.kind==="bitset"?typeof l.size=="number"?l.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(L(`count:${i.id}`,`column "${i.id}" is bitset-backed with no declared row count; assuming ${l.length*8}`),l.length*8):l.length:i.presence&&typeof i.presence.size=="number"?i.presence.size:0}const H=new WeakMap;function U(i){const s=i.constructor;if(!s)return"unknown";const l=H.get(s);if(l)return l;let u="unknown";try{let f=null;typeof s.from=="function"?f=s.from([!1,!0]):(f=new s(8),f.set(1));const h=f&&f.words;h&&h.length&&(h[0]===2?u="lsb":h[0]===64&&(u="msb"))}catch{u="unknown"}return H.set(s,u),u}function z(i){if(!i)return()=>0;const s=i instanceof Uint8Array?i:i.words;if(s instanceof Uint8Array){const l=i instanceof Uint8Array?"lsb":U(i);if(l==="lsb")return u=>s[u>>>3]>>>(u&7)&1;if(l==="msb")return u=>s[u>>>3]>>>7-(u&7)&1}return typeof i.get=="function"?l=>i.get(l)?1:0:()=>0}function F(i){return!i||!i.presence?null:z(i.presence)}function k(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function O(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 l=i.offsets,u=i.values;if(!l||!u)return[];const f=l[s],h=l[s+1];if(!(h>f))return[];const g=i.dict,b=new Array(h-f);for(let p=f;p<h;p++)b[p-f]=g?O(g,u[p]):u[p];return b}function d(i){if(!i)return()=>{};const s=i.values,l=F(i),u=i.kind;if(u==="dictionary"){const f=i.dict;return l?h=>l(h)?O(f,s[h]):null:h=>O(f,s[h])}if(u==="bitset"){const f=z(s);return l?h=>l(h)?f(h)===1:null:h=>f(h)===1}if(u==="multi")return l?f=>l(f)?y(i,f):null:f=>y(i,f);if(!s&&typeof i.get=="function"){const f=i.get.bind(i);return h=>{const g=f(h);return g===void 0?null:g}}return l?f=>{if(!l(f))return null;const h=s[f];return h===void 0?null:h}:f=>{const h=s[f];return h===void 0?null:h}}function c(i,s){if(i<s)return-1;if(i>s)return 1;if(i===s){const f=Object.is(i,-0),h=Object.is(s,-0);return f===h?0:f?-1:1}const l=Number.isNaN(i),u=Number.isNaN(s);return l&&u?0:l?1:-1}function r(i){const s=R(i);return(l,u)=>{if(l===u)return 0;const f=typeof l,h=typeof u;if(f==="string"&&h==="string")return s.compare(l,u);if(f==="number"&&h==="number")return c(l,u);if(f==="boolean"&&h==="boolean")return l===u?0:l?1:-1;if(l instanceof Date||u instanceof Date){const g=l instanceof Date?l.getTime():Number(l),b=u instanceof Date?u.getTime():Number(u);return c(g,b)}return $(l,u)}}function t(i,s){if(i&&typeof i.ranks=="function")return i.ranks(s);const l=i&&typeof i.values=="function"?i.values():[],u=l.length,f=r(s),h=new Array(u);for(let b=0;b<u;b++)h[b]=b;h.sort((b,p)=>f(l[b],l[p])||b-p);const g=new Uint32Array(u);for(let b=0;b<u;b++)g[h[b]]=b;return g}function n(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),ke("packages/core/src/compute/special.js",function(e,V){"use strict";Object.defineProperty(e,"logGamma",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"incompleteBeta",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"normalQuantile",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"normalCdf",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"studentT",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"studentTQuantile",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"regularizedGammaP",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chiSquareUpperTail",{enumerable:!0,get:function(){return r}});const _=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),R=3e-12,$=1e-300;function L(t){if(t<.5)return Math.log(Math.PI/Math.sin(Math.PI*t))-L(1-t);const n=t-1;let i=.9999999999998099;const s=n+7.5;for(let l=0;l<_.length;l++)i+=_[l]/(n+l+1);return .5*Math.log(2*Math.PI)+(n+.5)*Math.log(s)-s+Math.log(i)}function W(t,n,i){const s=t+n,l=t+1,u=t-1;let f=1,h=1-s*i/l;Math.abs(h)<$&&(h=$),h=1/h;let g=h;for(let b=1;b<=300;b++){const p=2*b;let m=b*(n-b)*i/((u+p)*(t+p));h=1+m*h,Math.abs(h)<$&&(h=$),f=1+m/f,Math.abs(f)<$&&(f=$),h=1/h,g*=h*f,m=-(t+b)*(s+b)*i/((t+p)*(l+p)),h=1+m*h,Math.abs(h)<$&&(h=$),f=1+m/f,Math.abs(f)<$&&(f=$),h=1/h;const w=h*f;if(g*=w,Math.abs(w-1)<R)break}return g}function Z(t,n,i){if(!(t>0)||!(n>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const s=Math.exp(L(t+n)-L(t)-L(n)+t*Math.log(i)+n*Math.log(1-i));return i<(t+1)/(t+n+2)?s*W(t,n,i)/t:1-s*W(n,t,1-i)/n}function H(t){if(!(t>0)||!(t<1))return t===0?-1/0:t===1?1/0:Number.NaN;const n=[-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],l=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],u=.02425;let f,h,g;t<u?(f=Math.sqrt(-2*Math.log(t)),g=(((((s[0]*f+s[1])*f+s[2])*f+s[3])*f+s[4])*f+s[5])/((((l[0]*f+l[1])*f+l[2])*f+l[3])*f+1)):t<=1-u?(f=t-.5,h=f*f,g=(((((n[0]*h+n[1])*h+n[2])*h+n[3])*h+n[4])*h+n[5])*f/(((((i[0]*h+i[1])*h+i[2])*h+i[3])*h+i[4])*h+1)):(f=Math.sqrt(-2*Math.log(1-t)),g=-(((((s[0]*f+s[1])*f+s[2])*f+s[3])*f+s[4])*f+s[5])/((((l[0]*f+l[1])*f+l[2])*f+l[3])*f+1));const p=(.5*U(-g/Math.SQRT2)-t)*Math.sqrt(2*Math.PI)*Math.exp(g*g/2);return g-p/(1+g*p/2)}function U(t){const n=Math.abs(t),i=2/(2+n),s=4*i-2,l=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let u=0,f=0,h;for(let b=l.length-1;b>0;b--)h=f,f=s*f-u+l[b],u=h;const g=i*Math.exp(-n*n+.5*(l[0]+s*f)-u);return t>=0?g:2-g}function z(t){return .5*U(-t/Math.SQRT2)}function F(t,n){if(!(n>0)||!Number.isFinite(t))return Number.NaN;const i=.5*Z(n/2,.5,n/(n+t*t));return t>0?1-i:i}function k(t,n){if(!(t>0)||!(t<1)||!(n>0))return Number.NaN;if(n>1e7)return H(t);let i=-1e4,s=1e4,l=H(t);const u=L(n/2)+L(.5)-L((n+1)/2);for(let f=0;f<60;f++){const h=F(l,n);h<t?i=l:s=l;const g=Math.exp(-((n+1)/2)*Math.log(1+l*l/n)-u)/Math.sqrt(n),b=g>0?(h-t)/g:0;if(Math.abs(b)<1e-12)break;const p=l-b;if(l=p>i&&p<s&&Number.isFinite(p)?p:(i+s)/2,s-i<1e-12)break}return l}function O(t,n){let i=t,s=1/t,l=s;for(let u=0;u<300&&(i+=1,l*=n/i,s+=l,!(Math.abs(l)<Math.abs(s)*R));u++);return s*Math.exp(-n+t*Math.log(n)-L(t))}function y(t,n){let i=n+1-t,s=1/$,l=1/i,u=l;for(let f=1;f<=300;f++){const h=-f*(f-t);i+=2,l=h*l+i,Math.abs(l)<$&&(l=$),s=i+h/s,Math.abs(s)<$&&(s=$),l=1/l;const g=l*s;if(u*=g,Math.abs(g-1)<R)break}return Math.exp(-n+t*Math.log(n)-L(t))*u}function d(t,n){return!(t>0)||!(n>=0)||!Number.isFinite(n)?Number.NaN:n===0?0:n<t+1?O(t,n):1-y(t,n)}function c(t,n){return n>0?d(n/2,t/2):Number.NaN}function r(t,n){const i=c(t,n);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),ke("packages/core/src/compute/linalg.js",function(e,V){"use strict";Object.defineProperty(e,"cholesky",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"choleskySolve",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"choleskyInverse",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"normalEquations",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"matVec",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"quadForm",{enumerable:!0,get:function(){return Z}});function _(H){const U=H.length,z=Array.from({length:U},()=>new Array(U).fill(0));for(let F=0;F<U;F++)for(let k=0;k<=F;k++){let O=H[F][k];for(let y=0;y<k;y++)O-=z[F][y]*z[k][y];if(F===k){if(!(O>0))return null;z[F][k]=Math.sqrt(O)}else z[F][k]=O/z[k][k]}return z}function R(H,U){const z=H.length,F=new Array(z).fill(0);for(let O=0;O<z;O++){let y=U[O];for(let d=0;d<O;d++)y-=H[O][d]*F[d];F[O]=y/H[O][O]}const k=new Array(z).fill(0);for(let O=z-1;O>=0;O--){let y=F[O];for(let d=O+1;d<z;d++)y-=H[d][O]*k[d];k[O]=y/H[O][O]}return k}function $(H){const U=H.length,z=Array.from({length:U},()=>new Array(U).fill(0));for(let F=0;F<U;F++){const k=new Array(U).fill(0);k[F]=1;const O=R(H,k);for(let y=0;y<U;y++)z[y][F]=O[y]}return z}function L(H,U,z){const F=H.length,k=F?H[0].length:0,O=Array.from({length:k},()=>new Array(k).fill(0)),y=new Array(k).fill(0);for(let d=0;d<F;d++){const c=z?z[d]:1,r=H[d];for(let t=0;t<k;t++){const n=c*r[t];y[t]+=n*U[d];for(let i=t;i<k;i++)O[t][i]+=n*r[i]}}for(let d=0;d<k;d++)for(let c=0;c<d;c++)O[d][c]=O[c][d];return{xtwx:O,xtwy:y}}function W(H,U){return H.map(z=>z.reduce((F,k,O)=>F+k*U[O],0))}function Z(H,U){let z=0;for(let F=0;F<H.length;F++){let k=0;for(let O=0;O<H.length;O++)k+=U[F][O]*H[O];z+=H[F]*k}return z}}),ke("packages/core/src/compute/sketch.js",function(e,V){"use strict";Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return O}});class _{#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(d){if(!Number.isFinite(d))return;this.#e++;const c=d-this.#t;this.#t+=c/this.#e,this.#n+=c*(d-this.#t)}merge(d){if(d.#e===0)return;if(this.#e===0){this.#e=d.#e,this.#t=d.#t,this.#n=d.#n;return}const c=this.#e+d.#e,r=d.#t-this.#t;this.#t+=r*(d.#e/c),this.#n+=d.#n+r*r*(this.#e*d.#e/c),this.#e=c}mean(){return this.#e?this.#t:null}variance(){return this.#e>1?this.#n/(this.#e-1):null}varianceP(){return this.#e?this.#n/this.#e:null}stddev(){const d=this.variance();return d===null?null:Math.sqrt(d)}stddevP(){const d=this.varianceP();return d===null?null:Math.sqrt(d)}}class R{#e=[];#t=0;#n;#r;constructor(d,c=Math.random){if(!(d>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(d),this.#r=c}static get errorBound(){return Object.freeze({kind:"probabilistic",metric:"none",value:0,statement:"uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators"})}get seen(){return this.#t}get size(){return this.#e.length}add(d){if(!Number.isFinite(d))return;if(this.#t++,this.#e.length<this.#n){this.#e.push(d);return}const c=Math.floor(this.#r()*this.#t);c<this.#n&&(this.#e[c]=d)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let d=0;for(const c of this.#e)d+=c;return d/this.#e.length}quantile(d){const c=this.#e.length;if(!c)return null;const r=this.#e.slice().sort((s,l)=>s-l);if(c===1)return r[0];const t=(c-1)*Math.min(1,Math.max(0,d)),n=Math.floor(t),i=Math.ceil(t);return n===i?r[n]:r[n]+(t-n)*(r[i]-r[n])}}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 L(y){if(typeof y=="number"){const r=new DataView(new ArrayBuffer(8));return r.setFloat64(0,y===0?0:y),$(r.getUint32(0)^r.getUint32(4))}const d=typeof y=="string"?y:String(y);let c=2166136261;for(let r=0;r<d.length;r++)c^=d.charCodeAt(r),c=Math.imul(c,16777619);return $(c)}class W{#e;#t;#n;constructor(d=14){const c=Math.floor(d);if(c<4||c>16)throw new RangeError("HLL precision must be 4..16");this.#e=c,this.#t=1<<c,this.#n=new Uint8Array(this.#t)}static errorBoundFor(d=14){const c=1<<Math.floor(d),r=1.04/Math.sqrt(c);return Object.freeze({kind:"probabilistic",metric:"relative",value:r,statement:`distinct count within ~${(r*100).toFixed(2)}% relative standard error (m=${c} buckets)`})}errorBound(){return W.errorBoundFor(this.#e)}add(d){const c=L(d),r=c&this.#t-1,t=c>>>this.#e|1<<32-this.#e;let n=1,i=t;for(;(i&1)===0;)n++,i>>>=1;n>this.#n[r]&&(this.#n[r]=n)}count(){const d=this.#t,c=32-this.#e,r=new Float64Array(c+2);for(let i=0;i<d;i++)r[this.#n[i]]++;let t=d*U(1-r[c+1]/d);for(let i=c;i>=1;i--)t=.5*(t+r[i]);t+=d*H(r[0]/d);const n=Z*d*d/t;return Math.round(n)}}const Z=.5/Math.log(2);function H(y){if(y===1)return 1/0;let d=1,c=y,r;do y*=y,r=c,c+=y*d,d+=d;while(c!==r);return c}function U(y){if(y===0||y===1)return 0;let d=1,c=1-y,r;do y=Math.sqrt(y),r=c,d*=.5,c-=(1-y)**2*d;while(c!==r);return c/3}class z{#e=new Map;#t;#n=0;constructor(d){if(!(d>0))throw new RangeError("Space-Saving capacity must be positive");this.#t=Math.floor(d)}errorBoundFor(d){const c=d/this.#t;return Object.freeze({kind:"deterministic",metric:"absolute",value:c,statement:`each count overestimates the truth by at most N/m = ${c.toFixed(2)} (N=${d}, m=${this.#t})`})}get seen(){return this.#n}add(d){this.#n++;const c=this.#e.get(d);if(c){c.count++;return}if(this.#e.size<this.#t){this.#e.set(d,{count:1,error:0});return}let r,t=1/0;for(const[n,i]of this.#e)i.count<t&&(t=i.count,r=n);this.#e.delete(r),this.#e.set(d,{count:t+1,error:t})}top(d=this.#t){return[...this.#e.entries()].map(([r,t])=>({item:r,count:t.count,error:t.error})).sort((r,t)=>t.count-r.count).slice(0,Math.max(0,Math.floor(d)))}}class F{#e;#t=[[]];#n=0;#r;#o;constructor(d=200,c=Math.random){this.#e=Math.max(8,Math.floor(d)),this.#r=c,this.#o=2/3}static errorBoundFor(d=200){const c=1/Math.max(8,Math.floor(d));return Object.freeze({kind:"probabilistic",metric:"rank",value:c,statement:`queried quantile's true rank within ~${(c*100).toFixed(2)}% of N of the requested rank (k=${d})`})}errorBound(){return F.errorBoundFor(this.#e)}get count(){return this.#n}#i(d){const r=this.#t.length-1-d,t=Math.ceil(this.#e*this.#o**r);return Math.max(2,t)}add(d){Number.isFinite(d)&&(this.#n++,this.#t[0].push(d),this.#t[0].length>=this.#i(0)&&this.#a(0))}#a(d){const c=this.#t[d];c.sort((n,i)=>n-i),d+1>=this.#t.length&&this.#t.push([]);const r=this.#t[d+1],t=this.#r()<.5?0:1;for(let n=t;n<c.length;n+=2)r.push(c[n]);this.#t[d]=[];for(let n=0;n<this.#t.length;n++)if(this.#t[n].length>=this.#i(n)){this.#a(n);return}}#s(){const d=[];for(let c=0;c<this.#t.length;c++){const r=1<<c;for(const t of this.#t[c])d.push({v:t,w:r})}return d}quantile(d){const c=this.#s();if(!c.length)return null;c.sort((i,s)=>i.v-s.v);let r=0;for(const i of c)r+=i.w;const t=Math.min(1,Math.max(0,d))*r;let n=0;for(const i of c)if(n+=i.w,n>=t)return i.v;return c[c.length-1].v}rank(d){let c=0;for(let r=0;r<this.#t.length;r++){const t=1<<r;for(const n of this.#t[r])n<=d&&(c+=t)}return c}}const k=Object.freeze({distinct:W.errorBoundFor(14),median:F.errorBoundFor(200),p25:F.errorBoundFor(200),p75:F.errorBoundFor(200),p90:F.errorBoundFor(200),p95:F.errorBoundFor(200),p99:F.errorBoundFor(200),iqr:F.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"})}),O={Welford:_,Reservoir:R,HyperLogLog:W,SpaceSaving:z,KLL:F,hash32:L,SKETCH_BOUNDS:k}}),ke("packages/core/src/compute/statistics.js",function(e,V){"use strict";Object.defineProperty(e,"KENDALL_LIMIT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"numbers",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"frequencies",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return g}}),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 m}}),Object.defineProperty(e,"gini",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"moments",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"quantileSorted",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"quantile",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"STAT_FNS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"STAT_LABELS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"extremeRow",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"correlation",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"trimmedMean",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"winsorizedMean",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"modifiedZOutliers",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"jarqueBera",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"covariance",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"regression",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"fitLinearModel",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(e,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(e,"kendall",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(e,"seriesStats",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(e,"D2_N2",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(e,"D4_N2",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(e,"movingRanges",{enumerable:!0,get:function(){return He}}),Object.defineProperty(e,"withinSigma",{enumerable:!0,get:function(){return et}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return lt}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return We}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(e,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return Je}}),Object.defineProperty(e,"controlViolations",{enumerable:!0,get:function(){return ut}}),Object.defineProperty(e,"countOutside",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(e,"histogram",{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(e,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return xt}}),Object.defineProperty(e,"meanInterval",{enumerable:!0,get:function(){return Bt}}),Object.defineProperty(e,"proportionInterval",{enumerable:!0,get:function(){return $t}}),Object.defineProperty(e,"slopeInterval",{enumerable:!0,get:function(){return Zt}}),Object.defineProperty(e,"capabilityInterval",{enumerable:!0,get:function(){return Jt}}),Object.defineProperty(e,"standardizedMeanDifference",{enumerable:!0,get:function(){return dt}}),Object.defineProperty(e,"normalTotalVariation",{enumerable:!0,get:function(){return de}}),Object.defineProperty(e,"frequencyMap",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(e,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(e,"compareColumn",{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(e,"isNumericColumn",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(e,"populationRead",{enumerable:!0,get:function(){return ft}});const _=V("packages/core/src/compute/handle.js"),R=_.presenceReader,$=_.valueReader,L=V("packages/core/src/compute/special.js"),W=L.studentTQuantile,Z=L.studentT,H=L.normalQuantile,U=L.normalCdf,z=L.chiSquareUpperTail,F=V("packages/core/src/compute/linalg.js"),k=F.cholesky,O=F.choleskySolve,y=F.choleskyInverse,d=F.normalEquations,c=F.quadForm,t=V("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,n=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: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 l(fe){const we=fe==="sum"||fe==="avg"||fe==="countValues"||fe==="min"||fe==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,fe)?i[fe]:null,be=Object.prototype.hasOwnProperty.call(s,fe)?s[fe]:null;return{stat:fe,exact:we,approximate:be}}function u(fe,we){const be=we.length,je=new Float64Array(be);let Pe=0;if(fe&&(fe.kind==="float64"||fe.kind==="int32")){const Le=fe.values,Fe=R(fe);for(let Ye=0;Ye<be;Ye++){const Xe=we[Ye];if(Fe&&Fe(Xe)!==1)continue;const pt=Le[Xe];Number.isNaN(pt)||(je[Pe++]=pt)}return je.subarray(0,Pe)}const Re=$(fe);for(let Le=0;Le<be;Le++){const Fe=Re(we[Le]);if(Fe==null||Fe==="")continue;const Ye=typeof Fe=="number"?Fe:Number(Fe);Number.isFinite(Ye)&&(je[Pe++]=Ye)}return je.subarray(0,Pe)}function f(fe,we){const be=new Map,je=$(fe);let Pe=0;for(let Re=0;Re<we.length;Re++){const Le=je(we[Re]);if(Le==null||Le===""||typeof Le=="number"&&Number.isNaN(Le))continue;const Fe=typeof Le=="object"?String(Le):Le;be.set(Fe,(be.get(Fe)||0)+1),Pe++}const Ne=[...be.values()].sort((Re,Le)=>Le-Re);return{counts:Ne,total:Pe,distinct:Ne.length}}function h(fe){return fe.total>0?fe.counts.map(we=>we/fe.total):[]}function g(fe,we){const be=f(fe,we);if(!be.total)return null;let je=0;for(const Pe of h(be))je+=Pe*Pe;return je}function b(fe,we){const be=f(fe,we);if(!be.total)return null;let je=0;for(const Pe of h(be))Pe>0&&(je-=Pe*Math.log2(Pe));return je}function p(fe,we){const be=f(fe,we);if(!be.total||be.distinct<2)return be.total?1:null;let je=0;for(const Pe of h(be))Pe>0&&(je-=Pe*Math.log2(Pe));return je/Math.log2(be.distinct)}function m(fe,we,be=3){const je=f(fe,we);if(!je.total)return null;const Pe=Math.max(1,Math.floor(be));let Ne=0;for(let Re=0;Re<Math.min(Pe,je.counts.length);Re++)Ne+=je.counts[Re];return Ne/je.total}function w(fe,we){const be=u(fe,we),je=be.length;if(!je)return null;const Pe=be.slice().sort();if(Pe[0]<0)return null;let Ne=0,Re=0;for(let Le=0;Le<je;Le++)Ne+=Pe[Le],Re+=(Le+1)*Pe[Le];return Ne===0?0:2*Re/(je*Ne)-(je+1)/je}function v(fe){let we=0,be=0,je=0;for(let Pe=0;Pe<fe.length;Pe++){const Ne=fe[Pe];we++;const Re=Ne-be;be+=Re/we,je+=Re*(Ne-be)}return{n:we,mean:be,m2:je}}function a(fe,we){const be=fe.length;if(!be)return NaN;if(be===1)return fe[0];const je=(be-1)*Math.min(1,Math.max(0,we)),Pe=Math.floor(je),Ne=Math.ceil(je);return Pe===Ne?fe[Pe]:fe[Pe]+(je-Pe)*(fe[Ne]-fe[Pe])}function o(fe,we){if(!fe.length)return NaN;const be=fe.slice().sort();return a(be,we)}function S(fe,we){const be=$(fe);let je=0,Pe=0,Ne=0;for(let Re=0;Re<we.length;Re++){const Le=be(we[Re]);if(Le==null||Le==="")continue;const Fe=String(Le).toUpperCase();Fe==="PASS"?je++:Fe==="FAIL"?Pe++:Fe==="WARN"&&Ne++}return{pass:je+Ne,fail:Pe,warn:Ne,judged:je+Ne+Pe}}const E=Object.freeze({hhi:(fe,we)=>g(fe,we),entropy:(fe,we)=>b(fe,we),evenness:(fe,we)=>p(fe,we),top3Share:(fe,we)=>m(fe,we,3),top10Share:(fe,we)=>m(fe,we,10),gini:(fe,we)=>w(fe,we),trimmedMean:(fe,we)=>x(u(fe,we),.1),winsorizedMean:(fe,we)=>K(u(fe,we),.1),robustOutliers:(fe,we)=>I(u(fe,we),3.5),jarqueBera:(fe,we)=>D(u(fe,we)),variance:(fe,we)=>{const{n:be,m2:je}=v(u(fe,we));return be>1?je/(be-1):null},varianceP:(fe,we)=>{const{n:be,m2:je}=v(u(fe,we));return be>0?je/be:null},stddev:(fe,we)=>{const{n:be,m2:je}=v(u(fe,we));return be>1?Math.sqrt(je/(be-1)):null},stddevP:(fe,we)=>{const{n:be,m2:je}=v(u(fe,we));return be>0?Math.sqrt(je/be):null},median:(fe,we)=>{const be=u(fe,we);return be.length?o(be,.5):null},p25:(fe,we)=>{const be=u(fe,we);return be.length?o(be,.25):null},p75:(fe,we)=>{const be=u(fe,we);return be.length?o(be,.75):null},p90:(fe,we)=>{const be=u(fe,we);return be.length?o(be,.9):null},p95:(fe,we)=>{const be=u(fe,we);return be.length?o(be,.95):null},p99:(fe,we)=>{const be=u(fe,we);return be.length?o(be,.99):null},iqr:(fe,we)=>{const be=u(fe,we);if(!be.length)return null;const je=be.slice().sort();return a(je,.75)-a(je,.25)},mad:(fe,we)=>{const be=u(fe,we);if(!be.length)return null;const je=o(be,.5),Pe=new Float64Array(be.length);for(let Ne=0;Ne<be.length;Ne++)Pe[Ne]=Math.abs(be[Ne]-je);return o(Pe,.5)},range:(fe,we)=>{const be=u(fe,we);if(!be.length)return null;let je=1/0,Pe=-1/0;for(let Ne=0;Ne<be.length;Ne++)be[Ne]<je&&(je=be[Ne]),be[Ne]>Pe&&(Pe=be[Ne]);return Pe-je},distinct:(fe,we)=>{const be=$(fe),je=new Set;for(let Pe=0;Pe<we.length;Pe++){const Ne=be(we[Pe]);Ne==null||Ne===""||je.add(Ne instanceof Date?Ne.getTime():Ne)}return je.size},mode:(fe,we)=>{const be=$(fe),je=new Map;for(let Re=0;Re<we.length;Re++){const Le=be(we[Re]);if(Le==null||Le==="")continue;const Fe=Le instanceof Date?Le.getTime():Le;je.set(Fe,(je.get(Fe)||0)+1)}let Pe=null,Ne=1;for(const[Re,Le]of je)Le>Ne&&(Ne=Le,Pe=Re);return Pe},skewness:(fe,we)=>{const be=u(fe,we),{n:je,mean:Pe,m2:Ne}=v(be);if(je<3||Ne<=0)return null;const Re=Math.sqrt(Ne/(je-1));let Le=0;for(let Fe=0;Fe<be.length;Fe++)Le+=((be[Fe]-Pe)/Re)**3;return je/((je-1)*(je-2))*Le},kurtosis:(fe,we)=>{const be=u(fe,we),{n:je,mean:Pe,m2:Ne}=v(be);if(je<4||Ne<=0)return null;const Re=Math.sqrt(Ne/(je-1));let Le=0;for(let Xe=0;Xe<be.length;Xe++)Le+=((be[Xe]-Pe)/Re)**4;const Fe=je*(je+1)/((je-1)*(je-2)*(je-3)),Ye=3*(je-1)**2/((je-2)*(je-3));return Fe*Le-Ye},geomean:(fe,we)=>{const be=u(fe,we);if(!be.length)return null;let je=0;for(let Pe=0;Pe<be.length;Pe++){if(be[Pe]<=0)return null;je+=Math.log(be[Pe])}return Math.exp(je/be.length)},harmean:(fe,we)=>{const be=u(fe,we);if(!be.length)return null;let je=0;for(let Pe=0;Pe<be.length;Pe++){if(be[Pe]===0)return null;je+=1/be[Pe]}return be.length/je},sumSquares:(fe,we)=>{const be=u(fe,we);let je=0;for(let Pe=0;Pe<be.length;Pe++)je+=be[Pe]*be[Pe];return je},passRate:(fe,we)=>{const{pass:be,judged:je}=S(fe,we);return je?be/je:null},failureCount:(fe,we)=>S(fe,we).fail}),A=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 M(fe,we,be){const je=$(fe),Pe=$(we);let Ne=0,Re=0;for(let Le=0;Le<be.length;Le++){const Fe=be[Le],Ye=Number(je(Fe)),Xe=Number(Pe(Fe));!Number.isFinite(Ye)||!Number.isFinite(Xe)||(Ne+=Ye*Xe,Re+=Xe)}return Re===0?null:Ne/Re}function C(fe,we,be){const je=$(fe);let Pe=null,Ne=be?-1/0:1/0;for(let Re=0;Re<we.length;Re++){const Le=we[Re],Fe=Number(je(Le));Number.isFinite(Fe)&&(be?Fe>Ne:Fe<Ne)&&(Ne=Fe,Pe=Le)}return Pe}function P(fe,we,be){const je=$(fe),Pe=$(we);let Ne=0,Re=0,Le=0,Fe=0,Ye=0,Xe=0;for(let ht=0;ht<be.length;ht++){const St=be[ht],Ot=Number(je(St)),Ee=Number(Pe(St));!Number.isFinite(Ot)||!Number.isFinite(Ee)||(Ne++,Re+=Ot,Le+=Ee,Fe+=Ot*Ot,Ye+=Ee*Ee,Xe+=Ot*Ee)}if(Ne<2)return null;const pt=Ne*Xe-Re*Le,gt=Math.sqrt((Ne*Fe-Re*Re)*(Ne*Ye-Le*Le));if(gt===0)return null;const bt=pt/gt;return Math.max(-1,Math.min(1,bt))}function x(fe,we=.1){const be=fe.length;if(!be)return null;const je=Array.from(fe).sort((Le,Fe)=>Le-Fe),Pe=Math.floor(be*Math.min(.49,Math.max(0,we))),Ne=je.slice(Pe,be-Pe);if(!Ne.length)return a(je,.5);let Re=0;for(const Le of Ne)Re+=Le;return Re/Ne.length}function K(fe,we=.1){const be=fe.length;if(!be)return null;const je=Array.from(fe).sort((Fe,Ye)=>Fe-Ye),Pe=Math.floor(be*Math.min(.49,Math.max(0,we))),Ne=je[Pe],Re=je[be-1-Pe];let Le=0;for(const Fe of je)Le+=Math.min(Re,Math.max(Ne,Fe));return Le/be}function I(fe,we=3.5){if(!fe.length)return null;const je=Array.from(fe).sort((Fe,Ye)=>Fe-Ye),Pe=a(je,.5),Ne=je.map(Fe=>Math.abs(Fe-Pe)).sort((Fe,Ye)=>Fe-Ye),Re=a(Ne,.5);if(Re===0)return null;let Le=0;for(const Fe of je)Math.abs(.6745*(Fe-Pe)/Re)>we&&Le++;return Le}function D(fe){const we=fe.length;if(we<8)return null;let be=0;for(const Fe of fe)be+=Fe;be/=we;let je=0,Pe=0,Ne=0;for(const Fe of fe){const Ye=Fe-be;je+=Ye*Ye,Pe+=Ye*Ye*Ye,Ne+=Ye*Ye*Ye*Ye}if(je/=we,Pe/=we,Ne/=we,je===0)return null;const Re=Pe/je**1.5,Le=Ne/(je*je)-3;return we/6*(Re*Re+Le*Le/4)}function j(fe,we,be){const je=[];let Pe=0;for(let Fe=0;Fe<fe.length;Fe++){const Ye=Number(fe[Fe]),Xe=Number(we[Fe]);!Number.isFinite(Ye)||!Number.isFinite(Xe)||Xe<=0||(je.push([Ye,Xe]),Pe+=Xe)}if(!je.length||Pe<=0)return null;if(je.sort((Fe,Ye)=>Fe[0]-Ye[0]),je.length===1)return je[0][0];const Ne=[];let Re=0;for(const[,Fe]of je)Ne.push((Re+Fe/2)/Pe),Re+=Fe;const Le=Math.max(0,Math.min(1,be));if(Le<=Ne[0])return je[0][0];if(Le>=Ne[Ne.length-1])return je[je.length-1][0];for(let Fe=1;Fe<Ne.length;Fe++){if(Le>Ne[Fe])continue;const Ye=Ne[Fe]-Ne[Fe-1],Xe=Ye>0?(Le-Ne[Fe-1])/Ye:0;return je[Fe-1][0]+(je[Fe][0]-je[Fe-1][0])*Xe}return je[je.length-1][0]}function T(fe,we,be){const je=$(fe),Pe=$(we),Ne=new Float64Array(be.length),Re=new Float64Array(be.length);let Le=0;for(let Fe=0;Fe<be.length;Fe++){const Ye=be[Fe],Xe=Number(je(Ye)),pt=Number(Pe(Ye));!Number.isFinite(Xe)||!Number.isFinite(pt)||(Ne[Le]=Xe,Re[Le]=pt,Le++)}return{xs:Ne.subarray(0,Le),ys:Re.subarray(0,Le),n:Le}}function B(fe,we,be,je=!1){const{xs:Pe,ys:Ne,n:Re}=T(fe,we,be);if(Re<2)return null;let Le=0,Fe=0;for(let Xe=0;Xe<Re;Xe++)Le+=Pe[Xe],Fe+=Ne[Xe];Le/=Re,Fe/=Re;let Ye=0;for(let Xe=0;Xe<Re;Xe++)Ye+=(Pe[Xe]-Le)*(Ne[Xe]-Fe);return Ye/(je?Re:Re-1)}function q(fe,we,be){const{xs:je,ys:Pe,n:Ne}=T(fe,we,be);if(Ne<2)return null;let Re=0,Le=0;for(let Ot=0;Ot<Ne;Ot++)Re+=je[Ot],Le+=Pe[Ot];Re/=Ne,Le/=Ne;let Fe=0,Ye=0,Xe=0;for(let Ot=0;Ot<Ne;Ot++){const Ee=je[Ot]-Re,nt=Pe[Ot]-Le;Fe+=Ee*Ee,Ye+=Ee*nt,Xe+=nt*nt}if(Fe===0)return null;const pt=Ye/Fe,gt=Le-pt*Re,bt=Xe===0?1:Math.max(0,Math.min(1,Ye*Ye/(Fe*Xe))),ht=Math.max(0,Xe-pt*Ye),St=Ne>2?Math.sqrt(ht/(Ne-2)/Fe):0;return{slope:pt,intercept:gt,r2:bt,stdError:St,n:Ne}}const X=new Set(["ols","wls","robust"]),Q=new Set(["quantile"]),J=new Set(["ridge","lasso","elasticnet","mixed","gls"]),ne=1.345;function re(fe,we,be){const{xtwx:je,xtwy:Pe}=d(fe,we,be),Ne=k(je);if(!Ne)return null;const Re=O(Ne,Pe),Le=y(Ne),Fe=oe(fe,Re),Ye=we.map((Xe,pt)=>Xe-Fe[pt]);return{beta:Re,cov:Le,fitted:Fe,residuals:Ye}}function oe(fe,we){return fe.map(be=>be.reduce((je,Pe,Ne)=>je+Pe*we[Ne],0))}function ie(fe,we){const be=fe.length,je=fe.map(Ye=>Ye[we]),Pe=fe.map(Ye=>[1,...Ye.filter((Xe,pt)=>pt!==we)]),Ne=re(Pe,je,null);if(!Ne)return 1;const Re=je.reduce((Ye,Xe)=>Ye+Xe,0)/be;let Le=0,Fe=0;for(let Ye=0;Ye<be;Ye++)Le+=Ne.residuals[Ye]**2,Fe+=(je[Ye]-Re)**2;return Fe===0?1:Math.max(0,Math.min(1,1-Le/Fe))}function te(fe){const we=[...fe].sort((Pe,Ne)=>Pe-Ne),be=ce(we),je=fe.map(Pe=>Math.abs(Pe-be)).sort((Pe,Ne)=>Pe-Ne);return ce(je)/.6745}function ce(fe){const we=fe.length;if(!we)return 0;const be=Math.floor(we/2);return we%2?fe[be]:(fe[be-1]+fe[be])/2}function ue(fe,we,be={}){const je=be.method||"ols";if(J.has(je))throw new Error(`[lattice] regression method "${je}" is out of scope; use ols, wls or robust.`);if(Q.has(je))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!X.has(je))throw new Error(`[lattice] unknown regression method "${je}"; use ols, wls or robust.`);const Pe=Array.isArray(we)?we.length:0,Ne=Pe&&Array.isArray(fe[0])?fe[0].length:0,Re=Ne+1;if(!(Pe>Re))return null;for(let wt=0;wt<Pe;wt++){if(!Number.isFinite(we[wt])||!Array.isArray(fe[wt])||fe[wt].length!==Ne)return null;for(let Et=0;Et<Ne;Et++)if(!Number.isFinite(fe[wt][Et]))return null}let Le=null;if(je==="wls"){if(Le=be.weights,!Array.isArray(Le)||Le.length!==Pe)return null;for(let wt=0;wt<Pe;wt++)if(!(Le[wt]>0)||!Number.isFinite(Le[wt]))return null}const Fe=fe.map(wt=>[1,...wt]);let Ye,Xe=null;if(je==="robust"){if(Ye=re(Fe,we,null),!Ye)return null;for(let wt=0;wt<50;wt++){const Et=te(Ye.residuals);if(!(Et>0))break;const Mt=Ye.residuals.map(Wt=>{const _t=Math.abs(Wt/Et);return _t<=ne?1:ne/_t}),Ut=re(Fe,we,Mt);if(!Ut)return null;const Xt=Ut.beta.reduce((Wt,_t,en)=>Math.max(Wt,Math.abs(_t-Ye.beta[en])),0);if(Ye=Ut,Xe=Mt,Xt<1e-10)break}}else if(Ye=re(Fe,we,Le),!Ye)return null;const pt=je==="robust"?Xe:Le,{beta:gt,cov:bt,fitted:ht,residuals:St}=Ye;let Ot=0,Ee=0,nt=0;for(let wt=0;wt<Pe;wt++){const Et=pt?pt[wt]:1;Ot+=Et*St[wt]**2,Ee+=Et,nt+=Et*we[wt]}const it=nt/Ee;let mt=0;for(let wt=0;wt<Pe;wt++){const Et=pt?pt[wt]:1;mt+=Et*(we[wt]-it)**2}const It=Pe-Re,Rt=Ot/It,st=mt===0?1:Math.max(0,Math.min(1,1-Ot/mt)),kt=1-(1-st)*(Pe-1)/It,Vt=Array.isArray(be.names)&&be.names.length===Ne?be.names:fe[0].map((wt,Et)=>`x${Et+1}`),Kt=Lt(be.confidence),sn=It>0?W(1-(1-Kt)/2,It):1/0,an=gt.map((wt,Et)=>{const Mt=Math.sqrt(Math.max(0,Rt*bt[Et][Et])),Ut=Mt>0?wt/Mt:wt===0?0:1/0,Xt=Number.isFinite(Ut)?2*(1-Z(Math.abs(Ut),It)):0,Wt=Number.isFinite(sn)?sn*Mt:null;return{name:Et===0?"(intercept)":Vt[Et-1],estimate:wt,stdError:Mt,t:Ut,p:Math.max(0,Math.min(1,Xt)),lower:Wt===null?null:wt-Wt,upper:Wt===null?null:wt+Wt}}),ln=new Array(Pe),Dt=new Array(Pe);for(let wt=0;wt<Pe;wt++){const Et=pt?pt[wt]:1,Mt=Math.max(0,Math.min(1,Et*c(Fe[wt],bt)));ln[wt]=Mt;const Ut=(1-Mt)**2;Dt[wt]=Ut>0&&Rt>0?St[wt]**2/(Re*Rt)*(Mt/Ut):null}const un=fe[0].map((wt,Et)=>{if(Ne<2)return 1;const Mt=ie(fe,Et);return Mt>=1?1/0:1/(1-Mt)});let cn=null;{const wt=St.map(Mt=>Mt*Mt),Et=re(Fe,wt,null);if(Et){const Mt=wt.reduce((Yt,dn)=>Yt+dn,0)/Pe;let Ut=0,Xt=0;for(let Yt=0;Yt<Pe;Yt++)Ut+=Et.residuals[Yt]**2,Xt+=(wt[Yt]-Mt)**2;const Wt=Xt===0?0:Math.max(0,Math.min(1,1-Ut/Xt)),_t=Pe*Wt,en=z(_t,Ne);cn={statistic:_t,df:Ne,p:en,heteroscedastic:en<.05}}}let rn=null;if(Ne===1){const wt=fe.map((Et,Mt)=>Mt).sort((Et,Mt)=>fe[Et][0]-fe[Mt][0]);rn={confidence:Kt,points:wt.map(Et=>{const Mt=Fe[Et],Ut=Math.sqrt(Math.max(0,Rt*c(Mt,bt)));return{x:fe[Et][0],yhat:ht[Et],lower:ht[Et]-sn*Ut,upper:ht[Et]+sn*Ut}})}}return{method:je,coefficients:an,r2:st,adjR2:kt,n:Pe,df:It,sigma2:Rt,fitted:ht,residuals:St,leverage:ln,cooksD:Dt,vif:un,heteroscedasticity:cn,band:rn,weights:pt?[...pt]:null}}function ae(fe){const we=fe.length,be=Array.from({length:we},(Ne,Re)=>Re).sort((Ne,Re)=>fe[Ne]-fe[Re]),je=new Float64Array(we);let Pe=0;for(;Pe<we;){let Ne=Pe;for(;Ne+1<we&&fe[be[Ne+1]]===fe[be[Pe]];)Ne++;const Re=(Pe+Ne)/2+1;for(let Le=Pe;Le<=Ne;Le++)je[be[Le]]=Re;Pe=Ne+1}return je}const pe=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function he(fe){const we=[.01,.05,.1],be=[pe["1%"],pe["5%"],pe["10%"]];if(fe<=be[0]){const Ne=(Math.log(we[1])-Math.log(we[0]))/(be[1]-be[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(we[0])+Ne*(fe-be[0]))))}if(fe>=be[2]){const Ne=(Math.log(we[2])-Math.log(we[1]))/(be[2]-be[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(we[2])+Ne*(fe-be[2]))))}const je=fe<be[1]?0:1,Pe=(fe-be[je])/(be[je+1]-be[je]);return Math.exp(Math.log(we[je])+Pe*(Math.log(we[je+1])-Math.log(we[je])))}function ve(fe,we,be,je){const Pe=be-je,Ne=je+3,Re=new Array(Pe),Le=new Array(Pe);let Fe=!0,Ye=je;for(let ht=0;ht<Pe;ht++){const St=je+ht,Ot=new Float64Array(Ne);Ot[0]=1,Ot[1]=ht+1,Ot[2]=fe[St];for(let Ee=1;Ee<=je;Ee++)Ot[2+Ee]=we[St-Ee];for(let Ee=1;Ee<Ne;Ee++)Number.isFinite(Ot[Ee])||(Ye=Math.min(Ye,Ee-3));Re[ht]=Ot,Le[ht]=we[St],Number.isFinite(Le[ht])||(Fe=!1)}if(!Fe)return 0;const{xtwx:Xe,xtwy:pt}=d(Re,Le,null);let gt=0,bt=1/0;for(let ht=0;ht<=Ye;ht++){const St=ht+3;if(!(Pe>St))continue;const Ot=new Array(St);for(let st=0;st<St;st++)Ot[st]=Xe[st].slice(0,St);const Ee=k(Ot);if(!Ee)continue;const nt=O(Ee,pt.slice(0,St));let it=0;for(let st=0;st<Pe;st++){const kt=Re[st];let Vt=0;for(let Kt=0;Kt<St;Kt++)Vt+=kt[Kt]*nt[Kt];it+=(Le[st]-Vt)**2}const It=it/(Pe-St)*(Pe-St);if(!(It>0))continue;const Rt=Pe*Math.log(It/Pe)+2*St;Rt<bt&&(bt=Rt,gt=ht)}return gt}function Oe(fe,we={}){const be=[];for(let bt=0;bt<fe.length;bt++){const ht=Number(fe[bt]);Number.isFinite(ht)&&be.push(ht)}const je=be.length,Pe=je-1;if(je<8||Pe<6)return null;const Ne=new Array(Pe);for(let bt=0;bt<Pe;bt++)Ne[bt]=be[bt+1]-be[bt];let Re=Number.isFinite(we.maxlag)?Math.floor(we.maxlag):Math.ceil(12*(je/100)**.25);Re=Math.max(0,Math.min(Re,Math.floor((Pe-5)/2)));const Le=(bt,ht)=>{const St=[],Ot=[];for(let Ee=ht;Ee<Pe;Ee++){const nt=[Ee-ht+1,be[Ee]];for(let it=1;it<=bt;it++)nt.push(Ne[Ee-it]);St.push(nt),Ot.push(Ne[Ee])}return ue(St,Ot,{method:"ols"})},Fe=ve(be,Ne,Pe,Re),Ye=Le(Fe,Fe);if(!Ye||!Ye.coefficients[2])return null;const Xe=Ye.coefficients[2].t,pt=he(Xe),gt=Xe<pe["5%"];return{statistic:Xe,usedLag:Fe,nobs:Pe-Fe,criticalValues:{...pe},pValue:pt,pApproximate:!0,stationary:gt,verdict:gt?"stationary":"non-stationary",regression:"ct"}}function Ie(fe,we={}){const be=[];for(let gt=0;gt<fe.length;gt++){const bt=Number(fe[gt]);Number.isFinite(bt)&&be.push(bt)}const je=be.length;if(je<3)return null;let Pe=Number.isFinite(we.maxlag)?Math.floor(we.maxlag):Math.min(10,je-1);Pe=Math.max(1,Math.min(Pe,je-1));let Ne=0;for(const gt of be)Ne+=gt;Ne/=je;const Re=be.map(gt=>gt-Ne);let Le=0;for(const gt of Re)Le+=gt*gt;Le/=je;const Fe=new Array(Pe+1).fill(0);Fe[0]=1;for(let gt=1;gt<=Pe;gt++){let bt=0;for(let ht=gt;ht<je;ht++)bt+=Re[ht]*Re[ht-gt];Fe[gt]=Le>0?bt/je/Le:0}const Ye=new Array(Pe+1).fill(0);Ye[0]=1;let Xe=[];for(let gt=1;gt<=Pe;gt++){let bt=Fe[gt];for(let Ee=1;Ee<gt;Ee++)bt-=Xe[Ee-1]*Fe[gt-Ee];let ht=1;for(let Ee=1;Ee<gt;Ee++)ht-=Xe[Ee-1]*Fe[Ee];const St=ht!==0?bt/ht:0,Ot=new Array(gt);for(let Ee=1;Ee<gt;Ee++)Ot[Ee-1]=Xe[Ee-1]-St*Xe[gt-1-Ee];Ot[gt-1]=St,Ye[gt]=St,Xe=Ot}const pt=1.96/Math.sqrt(je);return{acf:Fe,pacf:Ye,bounds:{upper:pt,lower:-pt},n:je,nlags:Pe,approximate:!0}}function Ze(fe,we,be){const{xs:je,ys:Pe,n:Ne}=T(fe,we,be);if(Ne<2)return null;const Re=ae(je),Le=ae(Pe);let Fe=0,Ye=0;for(let bt=0;bt<Ne;bt++)Fe+=Re[bt],Ye+=Le[bt];Fe/=Ne,Ye/=Ne;let Xe=0,pt=0,gt=0;for(let bt=0;bt<Ne;bt++){const ht=Re[bt]-Fe,St=Le[bt]-Ye;Xe+=ht*St,pt+=ht*ht,gt+=St*St}return pt===0||gt===0?null:Math.max(-1,Math.min(1,Xe/Math.sqrt(pt*gt)))}function Se(fe,we,be){const{xs:je,ys:Pe,n:Ne}=T(fe,we,be);if(Ne<2||Ne>n)return null;let Re=0,Le=0,Fe=0,Ye=0;for(let gt=0;gt<Ne;gt++)for(let bt=gt+1;bt<Ne;bt++){const ht=Math.sign(je[gt]-je[bt]),St=Math.sign(Pe[gt]-Pe[bt]),Ot=ht*St;Ot>0?Re++:Ot<0?Le++:ht===0&&St===0||(ht===0?Fe++:Ye++)}const Xe=Re+Le+Ye,pt=Re+Le+Fe;return Xe===0||pt===0?null:(Re-Le)/Math.sqrt(Xe*pt)}function xe(fe,we={}){const be=fe.length;if(be<2)return null;const je=fe[0],Pe=fe[be-1],Ne=[];for(let Ee=1;Ee<be;Ee++){const nt=fe[Ee-1];nt!==0&&Ne.push((fe[Ee]-nt)/Math.abs(nt))}let Re=null;if(Ne.length>1){let Ee=0;for(const it of Ne)Ee+=it;Ee/=Ne.length;let nt=0;for(const it of Ne)nt+=(it-Ee)**2;Re=Math.sqrt(nt/(Ne.length-1))}const Le=Number(we.periodsPerYear)>0?Number(we.periodsPerYear):null;let Fe=fe[0],Ye=0,Xe=0,pt=0,gt=0;for(let Ee=1;Ee<be;Ee++){if(fe[Ee]>Fe){Fe=fe[Ee],Ye=Ee;continue}if(Fe<=0)continue;const nt=(Fe-fe[Ee])/Fe;nt>Xe&&(Xe=nt,pt=Ye,gt=Ee)}let bt=null;if(be>2){let Ee=0;for(let mt=0;mt<be;mt++)Ee+=fe[mt];Ee/=be;let nt=0,it=0;for(let mt=0;mt<be;mt++){const It=fe[mt]-Ee;it+=It*It,mt>0&&(nt+=It*(fe[mt-1]-Ee))}bt=it>0?nt/it:null}let ht=0,St=0;for(const Ee of Ne)Ee>0?ht++:Ee<0&&St++;let Ot=null;if(je>0&&Pe>0){const Ee=(Pe/je)**(1/(be-1))-1;Ot=Le?(1+Ee)**Le-1:Ee}return{n:be,first:je,last:Pe,change:Pe-je,changePercent:je===0?null:(Pe-je)/Math.abs(je)*100,volatility:Re,annualisedVolatility:Re!==null&&Le?Re*Math.sqrt(Le):null,growth:Ot,maxDrawdown:Xe,maxDrawdownFrom:pt,maxDrawdownTo:gt,autocorrelation:bt,upDays:ht,downDays:St}}const Be=1.128,_e=3.267;function He(fe){const we=fe.length;if(we<2)return null;const be=[];for(let Pe=1;Pe<we;Pe++)be.push(Math.abs(fe[Pe]-fe[Pe-1]));const je=be.reduce((Pe,Ne)=>Pe+Ne,0)/be.length;return{ranges:be,centre:je,upper:_e*je,lower:0}}function et(fe){const we=fe.length;if(we<2)return null;let be=0;for(let Pe=1;Pe<we;Pe++)be+=Math.abs(fe[Pe]-fe[Pe-1]);const je=be/(we-1);return{sigma:je/Be,meanRange:je}}function lt(fe,we){const be=fe.length;if(be<2||!we)return null;const je=Number.isFinite(Number(we.lower))?Number(we.lower):null,Pe=Number.isFinite(Number(we.upper))?Number(we.upper):null;if(je===null&&Pe===null)return null;let Ne=0;for(let ht=0;ht<be;ht++)Ne+=fe[ht];Ne/=be;let Re=0;for(let ht=0;ht<be;ht++)Re+=(fe[ht]-Ne)**2;const Le=Math.sqrt(Re/(be-1)),Fe=et(fe),Ye=Fe?Fe.sigma:null,Xe=ht=>{if(!ht||ht<=0)return{index:null,k:null};const Ot=je!==null&&Pe!==null?(Pe-je)/(6*ht):null,Ee=Pe!==null?(Pe-Ne)/(3*ht):1/0,nt=je!==null?(Ne-je)/(3*ht):1/0;return{index:Ot,k:Math.min(Ee,nt)}},pt=Xe(Ye),gt=Xe(Le);let bt=0;for(let ht=0;ht<be;ht++){if(je!==null&&fe[ht]<je){bt++;continue}Pe!==null&&fe[ht]>Pe&&bt++}return{n:be,mean:Ne,lower:je,upper:Pe,target:Number.isFinite(Number(we.target))?Number(we.target):null,sigmaWithin:Ye,sigmaOverall:Le,cp:pt.index,cpk:pt.k,pp:gt.index,ppk:gt.k,outOfSpec:bt,defectRate:be?bt/be:null}}function Ae(fe){const we=fe.length;if(we<2)return null;const be=et(fe);if(!be||!(be.sigma>0))return null;let je=0;for(let Pe=0;Pe<we;Pe++)je+=fe[Pe];return je/=we,{centre:je,sigma:be.sigma,upper:je+3*be.sigma,lower:je-3*be.sigma}}function We(fe,we){if(!we||!(we.sigma>0))return[];const be=fe.length,{centre:je,sigma:Pe}=we,Ne=Le=>(fe[Le]-je)/Pe,Re=[];for(let Le=0;Le<be;Le++){if(Math.abs(Ne(Le))>3&&Re.push({index:Le,rule:1,description:"beyond three sigma"}),Le>=2)for(const Fe of[1,-1]){let Ye=0;for(let Xe=Le-2;Xe<=Le;Xe++)Ne(Xe)*Fe>2&&Ye++;if(Ye>=2){Re.push({index:Le,rule:2,description:"two of three past two sigma"});break}}if(Le>=4)for(const Fe of[1,-1]){let Ye=0;for(let Xe=Le-4;Xe<=Le;Xe++)Ne(Xe)*Fe>1&&Ye++;if(Ye>=4){Re.push({index:Le,rule:3,description:"four of five past one sigma"});break}}if(Le>=7)for(const Fe of[1,-1]){let Ye=!0;for(let Xe=Le-7;Xe<=Le;Xe++)if(Ne(Xe)*Fe<=0){Ye=!1;break}if(Ye){Re.push({index:Le,rule:4,description:"eight in a row on one side"});break}}}return Re}function Ge(fe,we){if(!we||!(we.sigma>0))return[];const be=fe.length,{centre:je,sigma:Pe}=we,Ne=Fe=>(fe[Fe]-je)/Pe,Re=(Fe,Ye,Xe,pt)=>{for(const gt of[1,-1]){let bt=0;for(let ht=Fe;ht<=Ye;ht++)Ne(ht)*gt>Xe&&bt++;if(bt>=pt)return!0}return!1},Le=[];for(let Fe=0;Fe<be;Fe++){if(Math.abs(Ne(Fe))>3&&Le.push({index:Fe,rule:1,description:"beyond three sigma"}),Fe>=8)for(const Ye of[1,-1]){let Xe=!0;for(let pt=Fe-8;pt<=Fe;pt++)if(Ne(pt)*Ye<=0){Xe=!1;break}if(Xe){Le.push({index:Fe,rule:2,description:"nine in a row on one side"});break}}if(Fe>=5)for(const Ye of[1,-1]){let Xe=!0;for(let pt=Fe-4;pt<=Fe;pt++)if((fe[pt]-fe[pt-1])*Ye<=0){Xe=!1;break}if(Xe){Le.push({index:Fe,rule:3,description:Ye>0?"six rising":"six falling"});break}}if(Fe>=13){let Ye=!0;for(let Xe=Fe-12;Xe<=Fe;Xe++){const pt=fe[Xe]-fe[Xe-1],gt=fe[Xe+1<=Fe?Xe+1:Xe]-fe[Xe];if(Xe+1>Fe)break;if(pt===0||gt===0||pt>0==gt>0){Ye=!1;break}}Ye&&Le.push({index:Fe,rule:4,description:"fourteen alternating"})}if(Fe>=2&&Re(Fe-2,Fe,2,2)&&Le.push({index:Fe,rule:5,description:"two of three past two sigma"}),Fe>=4&&Re(Fe-4,Fe,1,4)&&Le.push({index:Fe,rule:6,description:"four of five past one sigma"}),Fe>=14){let Ye=!0;for(let Xe=Fe-14;Xe<=Fe;Xe++)if(Math.abs(Ne(Xe))>=1){Ye=!1;break}Ye&&Le.push({index:Fe,rule:7,description:"fifteen within one sigma"})}if(Fe>=7){let Ye=!0;for(let Xe=Fe-7;Xe<=Fe;Xe++)if(Math.abs(Ne(Xe))<=1){Ye=!1;break}Ye&&Le.push({index:Fe,rule:8,description:"eight beyond one sigma"})}}return Le}const Je=Object.freeze(["westernElectric","nelson"]);function ut(fe,we,be="westernElectric"){return String(be)==="nelson"?Ge(fe,we):We(fe,we)}function vt(fe,we,be){let je=0;for(let Pe=0;Pe<fe.length;Pe++)(fe[Pe]<we||fe[Pe]>be)&&je++;return je}function Ct(fe,we,be,je=20){const Pe=fe.length;if(!Pe)return[];const Ne=fe[0],Re=fe[Pe-1];if(Re===Ne)return[{from:Ne,to:Re,count:Pe}];const Le=be-we,Fe=1.5*Le;let Ye=Le>0?Math.max(Ne,we-Fe):Ne,Xe=Le>0?Math.min(Re,be+Fe):Re;Xe>Ye||(Ye=Ne,Xe=Re);const pt=Le>0?2*Le/Math.cbrt(Pe):(Xe-Ye)/(Math.ceil(Math.log2(Pe))+1),gt=pt>0?Math.min(je,Math.max(1,Math.ceil((Xe-Ye)/pt))):1,bt=(Xe-Ye)/gt,ht=[];for(let St=0;St<gt;St++)ht.push({from:Ye+St*bt,to:Ye+(St+1)*bt,count:0});for(let St=0;St<Pe;St++){const Ot=Math.min(gt-1,Math.max(0,Math.floor((fe[St]-Ye)/bt)));ht[Ot].count++}return ht[0].from=Ne,ht[gt-1].to=Re,ht}const xt=.95;function Lt(fe){const we=Number(fe);return Number.isFinite(we)&&we>0&&we<1?we:xt}function Bt(fe,we=xt){const be=fe.length;if(be<2)return null;let je=0;for(let Xe=0;Xe<be;Xe++)je+=fe[Xe];const Pe=je/be;let Ne=0;for(let Xe=0;Xe<be;Xe++){const pt=fe[Xe]-Pe;Ne+=pt*pt}const Re=Math.sqrt(Ne/(be-1)),Le=Lt(we),Ye=W(1-(1-Le)/2,be-1)*Re/Math.sqrt(be);return{mean:Pe,lower:Pe-Ye,upper:Pe+Ye,margin:Ye,n:be,confidence:Le}}function $t(fe,we,be=xt){const je=Number(fe),Pe=Number(we);if(!(Pe>0)||!(je>=0)||je>Pe)return null;const Ne=Lt(be),Re=H(1-(1-Ne)/2),Le=je/Pe,Fe=Re*Re,Ye=1+Fe/Pe,Xe=(Le+Fe/(2*Pe))/Ye,pt=Re/Ye*Math.sqrt(Le*(1-Le)/Pe+Fe/(4*Pe*Pe));return{proportion:Le,lower:Math.max(0,Xe-pt),upper:Math.min(1,Xe+pt),n:Pe,confidence:Ne}}function Zt(fe,we=xt){if(!fe||!(fe.n>2)||!Number.isFinite(fe.stdError))return null;const be=Lt(we),Pe=W(1-(1-be)/2,fe.n-2)*fe.stdError;return{slope:fe.slope,lower:fe.slope-Pe,upper:fe.slope+Pe,margin:Pe,confidence:be}}function Jt(fe,we,be=xt){const je=Number(fe),Pe=Number(we);if(!Number.isFinite(je)||!(Pe>1))return null;const Ne=Lt(be),Le=H(1-(1-Ne)/2)*Math.sqrt(1/(9*Pe)+je*je/(2*(Pe-1)));return{index:je,lower:je-Le,upper:je+Le,margin:Le,n:Pe,confidence:Ne}}function dt(fe,we){return!fe||!(fe.sd>0)||!Number.isFinite(we)||!Number.isFinite(fe.mean)?null:(we-fe.mean)/fe.sd}function de(fe){return Number.isFinite(fe)?Math.min(1,Math.max(0,2*U(Math.abs(fe)/2)-1)):0}function ge(fe,we){const be=new Map,je=$(fe);let Pe=0;for(let Ne=0;Ne<we.length;Ne++){const Re=je(we[Ne]);if(Re==null||Re===""||typeof Re=="number"&&Number.isNaN(Re))continue;const Le=Re instanceof Date?Re.getTime():typeof Re=="object"?String(Re):Re;be.set(Le,(be.get(Le)||0)+1),Pe++}return{map:be,total:Pe}}function Te(fe,we,be,je){if(!(we>0)||!(je>0))return null;let Pe=0;const Ne=new Set(fe.keys());for(const Re of be.keys())Ne.add(Re);for(const Re of Ne){const Le=(fe.get(Re)||0)/we,Fe=(be.get(Re)||0)/je;Pe+=Math.abs(Le-Fe)}return Pe/2}const Ue=10;function Ve(fe,we,be){if(be&&be.numeric){const Le=u(fe,we),{n:Fe,mean:Ye}=v(Le),Xe=Fe>0?dt({mean:be.mean,sd:be.sd},Ye):null;return{measure:"standardizedMeanDifference",magnitude:Xe,distance:Xe===null?0:de(Xe),direction:Xe===null?0:Math.sign(Xe),subsetN:Fe,populationN:be.n||0,reliable:Fe>=Ue}}const{map:Pe,total:Ne}=ge(fe,we),Re=Te(Pe,Ne,be.map,be.total);return{measure:"categoricalTotalVariation",magnitude:Re,distance:Re===null?0:Re,direction:0,subsetN:Ne,populationN:be.total||0,reliable:Ne>=Ue}}function ot(fe,we){if(fe&&(fe.kind==="float64"||fe.kind==="int32"))return!0;const be=$(fe);let je=0,Pe=0;for(let Ne=0;Ne<we.length&&je<200;Ne++){const Re=be(we[Ne]);if(Re==null||Re==="")continue;if(Re instanceof Date)return!1;je++;const Le=typeof Re=="number"?Re:Number(Re);Number.isFinite(Le)&&Pe++}return je===0?!1:Pe/je>=.9}function ft(fe,we){if(ot(fe,we)){const Pe=u(fe,we),{n:Ne,mean:Re,m2:Le}=v(Pe);return{numeric:!0,mean:Re,sd:Ne>0?Math.sqrt(Le/Ne):0,n:Ne}}const{map:be,total:je}=ge(fe,we);return{numeric:!1,map:be,total:je}}}),ke("packages/core/src/compute/total.js",function(e,V){"use strict";Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return h}}),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 m}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return w}});const _=V("packages/core/src/internal/util.js"),R=_.isFunction,$=_.warnOnce,L=V("packages/core/src/compute/handle.js"),W=L.presenceReader,Z=L.valueComparator,H=L.valueReader,U=V("packages/core/src/compute/statistics.js"),z=U.STAT_FNS,F=U.STAT_LABELS;function k(v){return!!v&&(v.kind==="float64"||v.kind==="int32")}function O(v,a){const o=a.length;let S=0;if(k(v)){const A=v.values,M=W(v);if(!M){for(let C=0;C<o;C++){const P=A[a[C]];Number.isNaN(P)||(S+=P)}return S}for(let C=0;C<o;C++){const P=a[C];if(M(P)===1){const x=A[P];Number.isNaN(x)||(S+=x)}}return S}const E=H(v);for(let A=0;A<o;A++){const M=l(E(a[A]));M!==null&&(S+=M)}return S}O.kernel=!0;function y(v,a){const o=a.length;let S=0;if(k(v)){const A=v.values,M=W(v);if(!M){for(let C=0;C<o;C++)Number.isNaN(A[a[C]])||S++;return S}for(let C=0;C<o;C++){const P=a[C];M(P)===1&&!Number.isNaN(A[P])&&S++}return S}const E=H(v);for(let A=0;A<o;A++){const M=E(a[A]);M!=null&&!(typeof M=="number"&&Number.isNaN(M))&&S++}return S}y.kernel=!0;function d(v,a){return a.length}d.kernel=!0;function c(v,a){const o=y(v,a);return o===0?null:O(v,a)/o}c.kernel=!0;function r(v,a,o,S){const E=a.length;if(k(v)){const P=v.values,x=W(v);let K=null;if(!x){for(let I=0;I<E;I++){const D=P[a[I]];Number.isNaN(D)||(K===null||(o<0?D<K:D>K))&&(K=D)}return K}for(let I=0;I<E;I++){const D=a[I];if(x(D)===0)continue;const j=P[D];Number.isNaN(j)||(K===null||(o<0?j<K:j>K))&&(K=j)}return K}const A=H(v),M=Z(S);let C=null;for(let P=0;P<E;P++){const x=A(a[P]);x==null||typeof x=="number"&&Number.isNaN(x)||(C===null||(o<0?M(x,C)<0:M(x,C)>0))&&(C=x)}return C}function t(v,a,o){return r(v,a,-1,o&&o.locale)}t.kernel=!0;function n(v,a,o){return r(v,a,1,o&&o.locale)}n.kernel=!0;function i(v,a){return a.length===0?null:H(v)(a[0])}i.kernel=!0;function s(v,a){return a.length===0?null:H(v)(a[a.length-1])}s.kernel=!0;function l(v){if(typeof v=="number")return Number.isNaN(v)?null:v;if(v==null||v===""||typeof v=="boolean")return null;if(v instanceof Date)return v.getTime();const a=Number(v);return Number.isNaN(a)?null:a}const u={sum:O,min:t,max:n,avg:c,count:d,first:i,last:s,countValues:y,...z},f=Object.freeze({...F,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function h(v){return v?typeof v=="string"?f[v]||v:"Total":""}const g=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function b(v){const a=v&&v.dataType&&v.dataType.totals&&v.dataType.totals.supported;if(Array.isArray(a))return a.slice();const o=g.filter(S=>S in u);for(const S of Object.keys(u))o.includes(S)||o.push(S);return o}function p(v,a){return typeof a!="string"?!0:b(v).includes(a)}function m(v,a){const o=H(v),S=[];for(let E=0;E<a.length;E++){const A=o(a[E]);A!=null&&S.push(A)}return S}function w(v,a,o,S){const E=a||[];if(typeof o=="string"){const A=u[o];return A?A(v,E,S):($(`total:${o}`,`unknown total function "${o}"; register it in config.totalFns`),null)}return R(o)?o.kernel===!0?o(v,E,S):o(m(v,E),S||{}):null}}),ke("packages/core/src/compute/windowed.js",function(e,V){"use strict";Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const R=V("packages/core/src/compute/sketch.js").Welford;class ${#e;#t;#n=[];#r;#o;constructor(U,z=0,F=Date.now){if(U!=="count"&&U!=="time"&&U!=="session")throw new RangeError(`unknown window kind: ${U}`);if((U==="count"||U==="time")&&!(z>0))throw new RangeError(`a ${U} window needs a positive span`);this.#e=U,this.#t=Math.floor(z),this.#r=F,this.#o=F()}get size(){return this.#n.length}push(U,z=this.#r()){Number.isFinite(U)&&(this.#n.push({t:z,v:U}),this.#i(z))}#i(U){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const z=U-this.#t;for(;this.#n.length&&this.#n[0].t<z;)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 z=new R;let F=0,k=1/0,O=-1/0;for(const{v:y}of this.#n)F+=y,y<k&&(k=y),y>O&&(O=y),z.add(y);return{over:U,count:this.#n.length,sum:F,mean:z.mean(),min:k,max:O,variance:z.variance(),stddev:z.stddev()}}reduce(U){const z=this.aggregate(),F={sum:z.sum,avg:z.mean,mean:z.mean,min:z.min,max:z.max,count:z.count,variance:z.variance,stddev:z.stddev};if(!(U in F))throw new RangeError(`unknown windowed aggregate: ${U}`);return{value:F[U],over:z.over}}}const L=Object.freeze(["count","time","session"]);function W(H,U=Date.now){const z=H.kind==="time"&&H.minutes!=null?H.minutes*6e4:H.span??0;return new $(H.kind,z,U)}const Z={Window:$,WINDOW_KINDS:L,openWindow:W}}),ke("packages/core/src/compute/rolling.js",function(e,V){"use strict";Object.defineProperty(e,"ROLLING_WINDOW_FIELDS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"rollingWindow",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"cumulativeToDate",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"periodOverPeriod",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"QUANTILE_SPAN_CAP",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"rollingQuantile",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"seasonalDecompose",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"exponentialSmoothing",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const R=V("packages/core/src/compute/windowed.js").openWindow,L=V("packages/core/src/compute/sketch.js").KLL,W=Object.freeze({rollingSum:"sum",rollingAvg:"avg",rollingMin:"min",rollingMax:"max"});function Z(f,h,g,b){if(f.kind==="count"){const p=Math.max(1,Math.floor(f.span||0));return{coverage:Math.min(1,h/p),partial:h<p}}if(f.kind==="time"){const p=f.minutes!=null?f.minutes*6e4:f.span||0;if(!(p>0))return{coverage:1,partial:!1};const m=g-b;return{coverage:Math.min(1,m/p),partial:m<p}}return{coverage:null,partial:!1}}function H(f,h){const g=R(h),b=new Map,p=f.length?f[0].at:0;for(let m=0;m<f.length;m++){const{key:w,at:v,value:a}=f[m];Number.isFinite(a)&&g.push(a,v);const o=g.aggregate(),S=Z(h,o.count,v,p);w!=null&&b.set(String(w),{sum:o.sum,avg:o.mean,min:o.min,max:o.max,count:o.count,coverage:S.coverage,partial:S.partial})}return b}function U(f){const h=new Map;let g=0;for(const{key:b,value:p}of f)Number.isFinite(p)&&(g+=p),b!=null&&h.set(String(b),g);return h}function z(f,h=1){const g=new Map,b=Math.max(1,Math.floor(h));for(let p=0;p<f.length;p++){const{key:m,value:w}=f[p];if(m==null)continue;const v=p>=b?f[p-b].value:null,a=Number.isFinite(w)?w:null,o=Number.isFinite(v)?v:null;g.set(String(m),a!==null&&o!==null?a-o:null)}return g}const F=4096;function k(f){let h=f>>>0;return()=>{h+=1831565813;let g=h;return g=Math.imul(g^g>>>15,g|1),g^=g+Math.imul(g^g>>>7,g|61),((g^g>>>14)>>>0)/4294967296}}function O(f,h){const g=f.length;if(g===1)return f[0];const b=(g-1)*h,p=Math.floor(b),m=Math.ceil(b);return p===m?f[p]:f[p]+(b-p)*(f[m]-f[p])}function y(f,h,g={}){const b=Math.min(1,Math.max(0,g.q==null?.5:g.q)),p=Math.max(1,Math.floor(g.cap==null?F:g.cap)),m=k(g.seed==null?2654435769:g.seed),w=new Map,v=f.length?f[0].at:0;if(h.kind==="session"){const o=new L(200,m);let S=0;for(const{key:E,value:A}of f)Number.isFinite(A)&&(o.add(A),S++),E!=null&&w.set(String(E),{value:S?o.quantile(b):null,approx:S>0,count:S,coverage:null,partial:!1});return w}const a=R(h);for(const{key:o,at:S,value:E}of f){Number.isFinite(E)&&a.push(E,S);const A=a.values(),M=A.length;let C=null,P=!1;if(M)if(M<=p)C=O([...A].sort((K,I)=>K-I),b);else{const K=new L(200,m);for(const I of A)K.add(I);C=K.quantile(b),P=!0}const x=Z(h,M,S,v);o!=null&&w.set(String(o),{value:C,approx:P,count:M,coverage:x.coverage,partial:x.partial})}return w}function d(f,h){const g=f.length,b=new Array(g).fill(null),p=Math.floor(h/2),m=h%2===0;for(let w=0;w<g;w++){if(w-p<0||w+p>=g)continue;let v=0,a=!0;if(m)for(let o=-p;o<=p;o++){const S=f[w+o];if(!Number.isFinite(S)){a=!1;break}v+=o===-p||o===p?S*.5:S}else for(let o=-p;o<=p;o++){const S=f[w+o];if(!Number.isFinite(S)){a=!1;break}v+=S}a&&(b[w]=v/h)}return b}function c(f,h){const g=new Map,b=Math.floor(Number(h&&h.period));if(!(b>=2))return g;const p=h&&h.model==="multiplicative",m=f.length,w=f.map(P=>Number.isFinite(P.value)?P.value:null),v=d(w,b),a=new Array(m).fill(null);for(let P=0;P<m;P++){const x=v[P],K=w[P];x===null||K===null||(p?x!==0&&(a[P]=K/x):a[P]=K-x)}const o=new Array(b).fill(0),S=new Array(b).fill(0);for(let P=0;P<m;P++){if(a[P]===null)continue;const x=P%b;o[x]+=a[P],S[x]+=1}const E=p?1:0,A=o.map((P,x)=>S[x]?P/S[x]:E),M=A.reduce((P,x)=>P+x,0)/b,C=p?A.map(P=>M!==0?P/M:1):A.map(P=>P-M);for(let P=0;P<m;P++){const{key:x}=f[P];if(x==null)continue;const K=v[P],I=C[P%b],D=w[P];let j=null;K!==null&&D!==null&&(j=p?K*I!==0?D/(K*I):null:D-K-I),g.set(String(x),{trend:K,seasonal:D===null?null:I,residual:j,coverage:K===null?0:1,partial:K===null})}return g}function r(f,h,g,b=80){const p=(Math.sqrt(5)-1)/2;let m=h,w=g,v=w-p*(w-m),a=m+p*(w-m),o=f(v),S=f(a);for(let E=0;E<b;E++)o<S?(w=a,a=v,S=o,v=w-p*(w-m),o=f(v)):(m=v,v=a,o=S,a=m+p*(w-m),S=f(a));return(m+w)/2}const t=1e-4,n=1-1e-4;function i(f,h){const g=f.length,b=new Array(g).fill(null),p=new Array(g).fill(null);let m=null,w=0;for(let v=0;v<g;v++){const a=f[v];if(!Number.isFinite(a)){m!==null&&(p[v]=m,b[v]=m);continue}if(m===null){m=a,p[v]=a,b[v]=a;continue}p[v]=m,w+=(a-m)**2,m=h*a+(1-h)*m,b[v]=m}return{smoothed:b,fitted:p,sse:w}}function s(f,h,g){const b=f.length,p=new Array(b).fill(null),m=new Array(b).fill(null);let w=null,v=null,a=0;for(let o=0;o<b;o++){const S=f[o];if(!Number.isFinite(S)){w!==null&&(w+=v,p[o]=w);continue}if(w===null){w=S,p[o]=S;continue}if(v===null){v=S-w;const M=w+v;m[o]=M,a+=(S-M)**2;const C=w;w=h*S+(1-h)*(C+v),v=g*(w-C)+(1-g)*v,p[o]=w;continue}const E=w+v;m[o]=E,a+=(S-E)**2;const A=w;w=h*S+(1-h)*(A+v),v=g*(w-A)+(1-g)*v,p[o]=w}return{smoothed:p,fitted:m,sse:a}}function l(f,h={}){const g=new Map,b=h.method==="holt",p=f.map(E=>Number.isFinite(E.value)?E.value:null),m=p.filter(E=>E!==null).length,w=E=>Math.min(n,Math.max(t,E)),v=()=>{for(const{key:E}of f)E!=null&&g.set(String(E),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return g};if(m<(b?2:1))return v();let a=Number.isFinite(h.alpha)?w(h.alpha):null,o=b&&Number.isFinite(h.beta)?w(h.beta):null;if(b){if(a===null||o===null){let E=a===null?.5:a,A=o===null?.5:o;for(let M=0;M<6;M++)a===null&&(E=r(C=>s(p,C,A).sse,t,n)),o===null&&(A=r(C=>s(p,E,C).sse,t,n));a=a===null?E:a,o=o===null?A:o}}else a===null&&(a=r(E=>i(p,E).sse,t,n));const S=b?s(p,a,o):i(p,a);for(let E=0;E<f.length;E++){const{key:A}=f[E];A!=null&&g.set(String(A),{smoothed:S.smoothed[E],fitted:S.fitted[E],alpha:a,beta:b?o:null,sse:S.sse})}return g}const u={ROLLING_WINDOW_FIELDS:W,QUANTILE_SPAN_CAP:F,rollingWindow:H,rollingQuantile:y,cumulativeToDate:U,periodOverPeriod:z,seasonalDecompose:c,exponentialSmoothing:l}}),ke("packages/core/src/compute/compare.js",function(e,V){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"pooledStandardMeanDifference",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"numericSummary",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"bothNumeric",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"compareColumnAcross",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"compareDatasets",{enumerable:!0,get:function(){return d}});const _=V("packages/core/src/compute/statistics.js"),R=_.numbers,$=_.moments,L=_.frequencyMap,W=_.categoricalDistance,Z=_.normalTotalVariation,H=_.isNumericColumn,U=_.SUBSET_RELIABILITY_FLOOR,z=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function F(c,r){if(!c||!r||!(c.n>0)||!(r.n>0)||!Number.isFinite(c.mean)||!Number.isFinite(r.mean))return null;const t=(c.n*c.sd*c.sd+r.n*r.sd*r.sd)/(c.n+r.n);return t>0?(c.mean-r.mean)/Math.sqrt(t):null}function k(c,r){const t=R(c,r),{n,mean:i,m2:s}=$(t),l=n>0?Math.sqrt(s/n):0;return{mean:i,sd:l,n}}function O(c,r,t,n){return H(c,r)&&H(t,n)}function y(c,r,t,n){if(O(c,r,t,n)){const u=k(c,r),f=k(t,n),h=F(u,f);return{measure:z.numeric,magnitude:h,distance:h===null?0:Z(h),direction:h===null?0:Math.sign(h),nA:u.n,nB:f.n,reliable:u.n>=U&&f.n>=U}}const i=L(c,r),s=L(t,n),l=W(i.map,i.total,s.map,s.total);return{measure:z.categorical,magnitude:l,distance:l===null?0:l,direction:0,nA:i.total,nB:s.total,reliable:i.total>=U&&s.total>=U}}function d(c,r,t={}){const n=new Set(c.columns),i=new Set(r.columns),s=c.columns.filter(g=>i.has(g)),l=Array.isArray(t.columns)&&t.columns.length?s.filter(g=>t.columns.includes(g)):s,u=c.indices(),f=r.indices(),h=[];for(const g of l){const b=c.handle(g),p=r.handle(g);if(!b||!p)continue;const m=y(b,u,p,f);h.push({column:g,name:c.name&&c.name(g)||r.name&&r.name(g)||g,measure:m.measure,magnitude:m.magnitude,distance:m.distance,direction:m.direction,nA:m.nA,nB:m.nB,reliable:m.reliable})}return h.sort((g,b)=>b.distance-g.distance||Math.abs(b.magnitude||0)-Math.abs(g.magnitude||0)),{ranked:h,nA:u.length,nB:f.length,unmatched:{onlyA:c.columns.filter(g=>!i.has(g)),onlyB:r.columns.filter(g=>!n.has(g))},measures:z}}}),ke("packages/core/src/compute/anomaly.js",function(e,V){"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 H}}),Object.defineProperty(e,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"robustSpread",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return u}});const R=V("packages/core/src/compute/statistics.js").quantileSorted,L=V("packages/core/src/compute/special.js").logGamma,W=.6745,Z=3.5,H=1.5,U=.975,z=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function F(f){if(!f.length)return null;const g=Array.from(f,Number).sort((w,v)=>w-v),b=R(g,.5),p=g.map(w=>Math.abs(w-b)).sort((w,v)=>w-v),m=R(p,.5);return{median:b,mad:m}}function k(f,h={}){const g=Number.isFinite(h.threshold)?h.threshold:Z,b=f.length,p=new Array(b).fill(null),m=new Array(b).fill(!1),w=[];for(let o=0;o<b;o++){const S=Number(f[o]);Number.isFinite(S)&&w.push(S)}if(!w.length)return{median:null,mad:null,threshold:g,scores:p,flags:m,flagged:0};const v=F(w);if(v.mad===0)return{median:v.median,mad:0,threshold:g,scores:p,flags:m,flagged:0};let a=0;for(let o=0;o<b;o++){const S=Number(f[o]);if(!Number.isFinite(S))continue;const E=W*(S-v.median)/v.mad;p[o]=E,Math.abs(E)>g&&(m[o]=!0,a++)}return{median:v.median,mad:v.mad,threshold:g,scores:p,flags:m,flagged:a}}function O(f,h={}){const g=Number.isFinite(h.k)?h.k:H,b=[];for(let a=0;a<f.length;a++){const o=Number(f[a]);Number.isFinite(o)&&b.push(o)}if(!b.length)return null;const p=b.sort((a,o)=>a-o),m=R(p,.25),w=R(p,.75),v=w-m;return{q1:m,q3:w,iqr:v,lower:m-g*v,upper:w+g*v,k:g}}function y(f,h){if(h<=0)return 0;const g=L(f);if(h<f+1){let o=f,S=1/f,E=S;for(let A=0;A<1e3&&(o+=1,E*=h/o,S+=E,!(Math.abs(E)<Math.abs(S)*1e-15));A++);return S*Math.exp(-h+f*Math.log(h)-g)}const b=1e-300;let p=h+1-f,m=1/b,w=1/p,v=w;for(let o=1;o<1e3;o++){const S=-o*(o-f);p+=2,w=S*w+p,Math.abs(w)<b&&(w=b),m=p+S/m,Math.abs(m)<b&&(m=b),w=1/w;const E=w*m;if(v*=E,Math.abs(E-1)<1e-15)break}return 1-Math.exp(-h+f*Math.log(h)-g)*v}function d(f,h){return f<=0?0:y(h/2,f/2)}function c(f,h=U){if(!(h>0)||!(h<1))return NaN;let g=0,b=Math.max(1,f);for(;d(b,f)<h;)b*=2;for(let p=0;p<200;p++){const m=(g+b)/2;if(d(m,f)<h?g=m:b=m,b-g<1e-10)break}return(g+b)/2}function r(f){const h=f.length,g=f.map((b,p)=>{const m=b.slice();for(let w=0;w<h;w++)m.push(p===w?1:0);return m});for(let b=0;b<h;b++){let p=b;for(let w=b+1;w<h;w++)Math.abs(g[w][b])>Math.abs(g[p][b])&&(p=w);if(Math.abs(g[p][b])<1e-12)return null;if(p!==b){const w=g[p];g[p]=g[b],g[b]=w}const m=g[b][b];for(let w=0;w<2*h;w++)g[b][w]/=m;for(let w=0;w<h;w++){if(w===b)continue;const v=g[w][b];if(v!==0)for(let a=0;a<2*h;a++)g[w][a]-=v*g[b][a]}}return g.map(b=>b.slice(h))}function t(f,h){const g=f.length,b=new Array(h).fill(0);for(const w of f)for(let v=0;v<h;v++)b[v]+=w[v];for(let w=0;w<h;w++)b[w]/=g;const p=Array.from({length:h},()=>new Array(h).fill(0));for(const w of f)for(let v=0;v<h;v++){const a=w[v]-b[v];for(let o=v;o<h;o++)p[v][o]+=a*(w[o]-b[o])}const m=g>1?g-1:1;for(let w=0;w<h;w++)for(let v=w;v<h;v++)p[w][v]/=m,p[v][w]=p[w][v];return{mean:b,cov:p}}function n(f,h={}){const g=Number.isFinite(h.p)?h.p:U,b=Number.isFinite(h.ridge)?h.ridge:1e-6,p=f.length;if(!p)return null;const m=f[0].length;if(!m)return null;const w=new Array(p).fill(null),v=new Array(p).fill(null),a=new Array(p).fill(!1),o=[],S=[];for(let I=0;I<p;I++){const D=f[I];let j=D.length===m;const T=new Array(m);for(let B=0;j&&B<m;B++){const q=Number(D[B]);Number.isFinite(q)?T[B]=q:j=!1}j&&(o.push(I),S.push(T))}const E=m,A=c(E,g);if(S.length<=m)return{center:[],df:E,cutoff:A,singular:!0,used:S.length,distances:w,squared:v,flags:a,flagged:0};const{mean:M,cov:C}=t(S,m);let P=r(C),x=!1;if(!P){x=!0;let I=0;for(let T=0;T<m;T++)I+=C[T][T];const D=I/m*b||b,j=C.map((T,B)=>T.map((q,X)=>B===X?q+D:q));if(P=r(j),!P)return{center:M,df:E,cutoff:A,singular:!0,used:S.length,distances:w,squared:v,flags:a,flagged:0}}let K=0;for(let I=0;I<S.length;I++){const D=S[I],j=new Array(m);for(let q=0;q<m;q++)j[q]=D[q]-M[q];let T=0;for(let q=0;q<m;q++){let X=0;for(let Q=0;Q<m;Q++)X+=P[q][Q]*j[Q];T+=j[q]*X}T<0&&(T=0);const B=o[I];v[B]=T,w[B]=Math.sqrt(T),T>A&&(a[B]=!0,K++)}return{center:M,df:E,cutoff:A,singular:x,used:S.length,distances:w,squared:v,flags:a,flagged:K}}const i=20,s=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function l(f,h={}){const g=h.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",b=Number.isFinite(h.windowLen)&&h.windowLen>=1?Math.floor(h.windowLen):i,p=Number.isFinite(h.threshold)?h.threshold:Z,m=Number.isFinite(h.k)?h.k:H,w=Number.isFinite(h.minPeriods)&&h.minPeriods>=1?Math.floor(h.minPeriods):b,v=f.length,a=new Array(v).fill(null),o=new Array(v).fill(!1);let S=0;for(let E=0;E<v;E++){const A=Number(f[E]);if(!Number.isFinite(A))continue;const M=Math.max(0,E-b+1),C=[];for(let P=M;P<=E;P++){const x=Number(f[P]);Number.isFinite(x)&&C.push(x)}if(!(C.length<w))if(g==="rollingIqr"){const P=O(C,{k:m});if(!P)continue;(A<P.lower||A>P.upper)&&(o[E]=!0,S++)}else{const P=F(C);if(!P||P.mad===0)continue;const x=W*(A-P.median)/P.mad;a[E]=x,Math.abs(x)>p&&(o[E]=!0,S++)}}return{method:g,windowLen:b,minPeriods:w,threshold:p,k:m,scores:a,flags:o,flagged:S}}function u(f={}){const h=f||{},g=h.field;if(typeof g!="string"||!g)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const b=h.method||"modifiedZScore";if(!(z.includes(b)||s.includes(b))||b==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${b}'`);const m=typeof h.orderBy=="string"?h.orderBy:null,w=h.latest===!0,v=s.includes(b),a=o=>Number(o==null?NaN:o[g]);return o=>{const S=Array.isArray(o)?o.slice():[...o];m&&S.sort((P,x)=>{const K=P?.[m],I=x?.[m];return K===I?0:K==null?-1:I==null?1:K<I?-1:1});const E=S.map(a);let A,M;if(v)({flags:A,scores:M}=l(E,{method:b,windowLen:h.windowLen,threshold:h.threshold,k:h.k,minPeriods:h.minPeriods}));else if(b==="iqr"){const P=O(E,{k:h.k});A=E.map(x=>P?Number.isFinite(x)&&(x<P.lower||x>P.upper):!1),M=E.map(()=>null)}else({flags:A,scores:M}=k(E,{threshold:h.threshold}));if(w){const P=A.length-1;return P<0||!A[P]?!1:{method:b,field:g,flagged:[{row:S[P],score:M[P]}]}}const C=[];for(let P=0;P<A.length;P++)A[P]&&C.push({row:S[P],score:M[P]});return C.length?{method:b,field:g,flagged:C}:!1}}}),ke("packages/core/src/compute/forecast.js",function(e,V){"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 f}});const _=V("packages/core/src/compute/special.js"),R=_.normalQuantile,$=_.studentTQuantile,W=V("packages/core/src/internal/util.js").warnOnce,Z=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),H=1e-4,U=1-1e-4;function z(h){const g=[];for(let b=0;b<h.length;b++){const p=h[b];if(p!==null&&typeof p=="object"){const m=Number.isFinite(p.at)?p.at:b,w=Number.isFinite(p.value)?p.value:null;g.push({at:m,value:w})}else g.push({at:b,value:Number.isFinite(p)?Number(p):null})}return g}function F(h){const g=h.filter(v=>v.value!==null),b=g[0],p=g[g.length-1],m=p.at-b.at,w=g.length>1&&m>0?m/(g.length-1):1;return{lastAt:p.at,step:w}}function k(h){return Math.min(U,Math.max(H,h))}function O(h,g=H,b=U,p=80){const m=(Math.sqrt(5)-1)/2;let w=g,v=b,a=v-m*(v-w),o=w+m*(v-w),S=h(a),E=h(o);for(let A=0;A<p;A++)S<E?(v=o,o=a,E=S,a=v-m*(v-w),S=h(a)):(w=a,a=o,S=E,o=w+m*(v-w),E=h(o));return(w+v)/2}function y(h,g){let b=null,p=0,m=0;for(let w=0;w<h.length;w++){const v=h[w];if(v!==null){if(b===null){b=v;continue}p+=(v-b)**2,m+=1,b=g*v+(1-g)*b}}return{level:b,sse:p,m}}function d(h,g,b){let p=null,m=null,w=0,v=0;for(let a=0;a<h.length;a++){const o=h[a];if(o===null){p!==null&&m!==null&&(p+=m);continue}if(p===null){p=o;continue}m===null&&(m=o-p);const S=p+m;w+=(o-S)**2,v+=1;const E=p;p=g*o+(1-g)*(E+m),m=b*(p-E)+(1-b)*m}return{level:p,trend:m,sse:w,m:v}}function c(h,g,b,p,m){const w=h.length;if(w<2*g)return null;const v=x=>{let K=0,I=0;for(let D=x;D<x+g&&D<w;D++)h[D]!==null&&(K+=h[D],I+=1);return I?K/I:null},a=v(0),o=v(g);if(a===null||o===null)return null;let S=a,E=(o-a)/g;const A=new Array(g).fill(0);for(let x=0;x<g;x++)A[x]=h[x]===null?0:h[x]-S;const M=A.reduce((x,K)=>x+K,0)/g;for(let x=0;x<g;x++)A[x]-=M;let C=0,P=0;for(let x=g;x<w;x++){const K=x%g,I=A[K],D=h[x];if(D===null){S+=E;continue}const j=S+E+I;C+=(D-j)**2,P+=1;const T=S;S=b*(D-I)+(1-b)*(S+E),E=p*(S-T)+(1-p)*E,A[K]=m*(D-S)+(1-m)*I}return{level:S,trend:E,season:A,phase:(w-1)%g,sse:C,count:P}}function r(h,g,b){let p=1;for(const w of g)p+=w*w;const m=Math.sqrt(h*p);return{se:m,margin:b*m}}function t(h,g={}){if(!h||typeof h.length!="number"||h.length===0)return null;const b=Z.includes(g.method)?g.method:"linear",p=Math.max(1,Math.floor(Number(g.horizon)||1)),m=Number.isFinite(g.confidence)&&g.confidence>0&&g.confidence<1?g.confidence:.95,w=1-(1-m)/2,v=z(h),a=v.map(C=>C.value),o=a.filter(C=>C!==null),S=o.length,{lastAt:E,step:A}=S?F(v):{lastAt:0,step:1},M=C=>E+C*A;return b==="linear"?n(v,S,p,m,w,M):b==="movingAverage"?i(o,S,p,m,w,g,M):b==="ses"?s(a,S,p,m,w,g,M):b==="holt"?l(a,S,p,m,w,g,M):u(a,S,p,m,w,g,M)}function n(h,g,b,p,m,w){if(g<2)return null;let v=0,a=0;for(const D of h)D.value!==null&&(v+=D.at,a+=D.value);v/=g,a/=g;let o=0,S=0,E=0;for(const D of h){if(D.value===null)continue;const j=D.at-v,T=D.value-a;o+=j*j,S+=j*T,E+=T*T}if(o===0)return null;const A=S/o,M=a-A*v,C=E===0?1:Math.max(0,Math.min(1,S*S/(o*E))),P=Math.max(0,E-A*S),x=g>2?Math.sqrt(P/(g-2)):null,K=g>2?$(m,g-2):null,I=[];for(let D=1;D<=b;D++){const j=w(D),T=M+A*j;let B=null,q=null,X=null,Q=null,J=null;if(x!==null){const ne=1/g+(j-v)**2/o,re=x*Math.sqrt(1+ne),oe=x*Math.sqrt(ne);J=re,B=T-K*re,q=T+K*re,X=T-K*oe,Q=T+K*oe}I.push({step:D,at:j,mean:T,lower:B,upper:q,lowerMean:X,upperMean:Q,se:J})}return{method:"linear",horizon:b,confidence:p,n:g,sigma:x,r2:C,params:{slope:A,intercept:M},points:I}}function i(h,g,b,p,m,w,v){if(g<1)return null;const a=Math.max(1,Math.min(g,Math.floor(Number(w.windowLen)||g))),o=h.slice(g-a);let S=0;for(const x of o)S+=x;const E=S/a;let A=null,M=null;if(a>1){let x=0;for(const I of o)x+=(I-E)**2;A=Math.sqrt(x/(a-1))*Math.sqrt(1+1/a),M=$(m,a-1)}const C=A===null?null:M*A,P=[];for(let x=1;x<=b;x++)P.push({step:x,at:v(x),mean:E,lower:C===null?null:E-C,upper:C===null?null:E+C,se:A});return{method:"movingAverage",horizon:b,confidence:p,n:g,sigma:A===null?null:A,params:{windowLen:a},points:P}}function s(h,g,b,p,m,w,v){if(g<1)return null;let a=Number.isFinite(w.alpha)?k(w.alpha):null;a===null&&(a=O(M=>y(h,M).sse));const o=y(h,a),S=R(m),E=o.m>0?o.sse/o.m:null,A=[];for(let M=1;M<=b;M++){const C=o.level;let P=null,x=null,K=null;if(E!==null){const I=[];for(let j=1;j<M;j++)I.push(a);const D=r(E,I,S);K=D.se,P=C-D.margin,x=C+D.margin}A.push({step:M,at:v(M),mean:C,lower:P,upper:x,se:K})}return{method:"ses",horizon:b,confidence:p,n:g,sigma:E===null?null:Math.sqrt(E),params:{alpha:a},points:A}}function l(h,g,b,p,m,w,v){if(g<2)return null;let a=Number.isFinite(w.alpha)?k(w.alpha):null,o=Number.isFinite(w.beta)?k(w.beta):null;if(a===null||o===null){let P=a===null?.5:a,x=o===null?.5:o;for(let K=0;K<6;K++)a===null&&(P=O(I=>d(h,I,x).sse)),o===null&&(x=O(I=>d(h,P,I).sse));a=a===null?P:a,o=o===null?x:o}const S=d(h,a,o),E=R(m),A=S.m>0?S.sse/S.m:null,M=a*o,C=[];for(let P=1;P<=b;P++){const x=S.level+P*S.trend;let K=null,I=null,D=null;if(A!==null){const j=[];for(let B=1;B<P;B++)j.push(a+B*M);const T=r(A,j,E);D=T.se,K=x-T.margin,I=x+T.margin}C.push({step:P,at:v(P),mean:x,lower:K,upper:I,se:D})}return{method:"holt",horizon:b,confidence:p,n:g,sigma:A===null?null:Math.sqrt(A),params:{alpha:a,beta:o},points:C}}function u(h,g,b,p,m,w,v){const a=Math.floor(Number(w.period));if(!(a>=2))return W("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(g<2*a)return null;let o=Number.isFinite(w.alpha)?k(w.alpha):null,S=Number.isFinite(w.beta)?k(w.beta):null,E=Number.isFinite(w.gamma)?k(w.gamma):null;const A=(D,j,T)=>{const B=c(h,a,D,j,T);return B?B.sse:1/0};if(o===null||S===null||E===null){let D=o===null?.5:o,j=S===null?.5:S,T=E===null?.5:E;for(let B=0;B<8;B++)o===null&&(D=O(q=>A(q,j,T))),S===null&&(j=O(q=>A(D,q,T))),E===null&&(T=O(q=>A(D,j,q)));o=o===null?D:o,S=S===null?j:S,E=E===null?T:E}const M=c(h,a,o,S,E);if(!M)return null;const C=R(m),P=M.count>0?M.sse/M.count:null,x=o*S,K=E*(1-o),I=[];for(let D=1;D<=b;D++){const j=M.season[(M.phase+D)%a],T=M.level+D*M.trend+j;let B=null,q=null,X=null;if(P!==null){const Q=[];for(let ne=1;ne<D;ne++)Q.push(o+ne*x+(ne%a===0?K:0));const J=r(P,Q,C);X=J.se,B=T-J.margin,q=T+J.margin}I.push({step:D,at:v(D),mean:T,lower:B,upper:q,se:X})}return{method:"holtWinters",horizon:b,confidence:p,n:g,sigma:P===null?null:Math.sqrt(P),params:{alpha:o,beta:S,gamma:E,period:a},points:I}}const f={FORECAST_METHODS:Z,forecast:t}}),ke("packages/core/src/compute/hypothesis.js",function(e,V){"use strict";Object.defineProperty(e,"GROUP_TESTS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"NORMALITY_ALPHA",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"HL_PAIR_LIMIT",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"welchTTest",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"mannWhitneyUTest",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"chiSquareTest",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"compareGroups",{enumerable:!0,get:function(){return C}});const R=V("packages/core/src/internal/util.js").warnOnce,L=V("packages/core/src/compute/handle.js").valueReader,W=V("packages/core/src/compute/statistics.js"),Z=W.numbers,H=W.moments,U=W.frequencyMap,z=W.categoricalDistance,F=W.isNumericColumn,k=W.jarqueBera,O=W.proportionInterval,y=W.SUBSET_RELIABILITY_FLOOR,c=V("packages/core/src/compute/compare.js").pooledStandardMeanDifference,r=V("packages/core/src/compute/special.js"),t=r.studentT,n=r.studentTQuantile,i=r.normalCdf,s=r.normalQuantile,l=r.chiSquareUpperTail,u=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),f=.05,h=2e6;function g(P){const x=Number(P);return Number.isFinite(x)&&x>0&&x<1?x:.95}function b(P){const{n:x,mean:K,m2:I}=H(P);return{mean:K,sd:x>0?Math.sqrt(I/x):0,n:x}}function p(P,x){const K=P.length;if(K<2)return 0;let I=0;for(let D=0;D<K;D++){const j=P[D]-x;I+=j*j}return I/(K-1)}function m(P,x){return{name:"pooledStandardMeanDifference",value:c(b(P),b(x))}}function w(P,x,K){const I=P.length,D=x.length;if(I<2||D<2)return null;const j=g(K),{mean:T}=H(P),{mean:B}=H(x),q=p(P,T),X=p(x,B),Q=q/I+X/D;if(!(Q>0))return null;const J=Math.sqrt(Q),ne=(T-B)/J,re=q/I*(q/I)/(I-1),oe=X/D*(X/D)/(D-1),ie=Q*Q/(re+oe),te=Math.min(1,Math.max(0,2*(1-t(Math.abs(ne),ie)))),ce=T-B,ue=n(1-(1-j)/2,ie)*J;return{test:u.WELCH,statistic:ne,statisticName:"t",df:ie,pValue:te,interval:{estimate:ce,lower:ce-ue,upper:ce+ue,confidence:j,method:"welch-t (difference of means)"},effectSize:m(P,x),nA:I,nB:D,reliable:I>=y&&D>=y,method:"Welch's t-test (unequal variances; Welch–Satterthwaite df)"}}function v(P){const x=P.length;if(x===0)return Number.NaN;const K=x>>1;return x%2?P[K]:(P[K-1]+P[K])/2}function a(P,x,K){const I=P.length,D=x.length,j=I*D;if(j===0||j>h)return null;const T=new Float64Array(j);let B=0;for(let re=0;re<I;re++)for(let oe=0;oe<D;oe++)T[B++]=P[re]-x[oe];T.sort();const q=v(T),X=Math.sqrt(I*D*(I+D+1)/12),Q=s(1-(1-K)/2);let J=Math.round(j/2-Q*X);J>=0||(J=0);const ne=Math.floor((j-1)/2);return J>ne&&(J=ne),{estimate:q,lower:T[J],upper:T[j-1-J],confidence:K,method:"hodges-lehmann (normal approximation)"}}function o(P,x,K){const I=P.length,D=x.length;if(I<1||D<1)return null;const j=g(K),T=I+D,B=new Array(T);for(let te=0;te<I;te++)B[te]={v:P[te],g:0};for(let te=0;te<D;te++)B[I+te]={v:x[te],g:1};B.sort((te,ce)=>te.v-ce.v);let q=0,X=0,Q=0;for(;Q<T;){let te=Q;for(;te<T&&B[te].v===B[Q].v;)te++;const ce=te-Q,ue=(Q+1+te)/2;for(let ae=Q;ae<te;ae++)B[ae].g===0&&(q+=ue);X+=ce*ce*ce-ce,Q=te}const J=q-I*(I+1)/2,ne=I*D/2,re=I*D/12*(T+1-X/(T*(T-1)));let oe=1;if(re>0){const te=Math.max(0,Math.abs(J-ne)-.5);oe=Math.min(1,2*i(-te/Math.sqrt(re)))}const ie=a(P,x,j);return{test:u.MANN_WHITNEY,statistic:J,statisticName:"U",df:null,pValue:oe,interval:ie,effectSize:m(P,x),nA:I,nB:D,reliable:I>=y&&D>=y,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function S(P,x,K,I,D){const j=O(P,x,D),T=O(K,I,D);if(!j||!T)return null;const B=j.proportion-T.proportion,q=B-Math.sqrt((j.proportion-j.lower)**2+(T.upper-T.proportion)**2),X=B+Math.sqrt((j.upper-j.proportion)**2+(T.proportion-T.lower)**2);return{lower:q,upper:X}}function E(P,x,K,I,D,j={}){if(!(x>0)||!(I>0))return null;const T=new Set([...P.keys(),...K.keys()]),B=T.size;if(B<2)return null;const q=x+I;let X=0;for(const oe of T){const ie=P.get(oe)||0,te=K.get(oe)||0,ce=ie+te,ue=x*ce/q,ae=I*ce/q;ue>0&&(X+=(ie-ue)*(ie-ue)/ue),ae>0&&(X+=(te-ae)*(te-ae)/ae)}const Q=B-1,J=l(X,Q);let ne=null;j.category!==void 0&&T.has(j.category)?ne=j.category:B===2&&([ne]=[...T]);let re=null;if(ne!==null){const oe=S(P.get(ne)||0,x,K.get(ne)||0,I,g(D));oe&&(re={estimate:(P.get(ne)||0)/x-(K.get(ne)||0)/I,lower:oe.lower,upper:oe.upper,confidence:g(D),method:"newcombe (difference in this category's share)",category:ne})}return{test:u.CHI_SQUARE,statistic:X,statisticName:"chiSquare",df:Q,pValue:J,interval:re,effectSize:{name:"categoricalTotalVariation",value:z(P,x,K,I)},nA:x,nB:I,reliable:x>=y&&I>=y,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function A(P){return P==null||P===""||typeof P=="number"&&Number.isNaN(P)?null:P instanceof Date?P.getTime():typeof P=="object"?String(P):P}function M(P,x,K){if(K===u.WELCH||K===u.MANN_WHITNEY)return{test:K,chosenBy:"override",reason:`caller override: ${K}`};const I=k(P),D=k(x),j=I===null?null:Math.exp(-I/2),T=D===null?null:Math.exp(-D/2);return j!==null&&j<f||T!==null&&T<f?{test:u.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${f})`}:{test:u.WELCH,chosenBy:"auto",reason:j!==null||T!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function C(P,x,K,I={}){if(!P||!x)return null;const D=g(I.confidence),j=L(x);let T;if(Array.isArray(I.groups)&&I.groups.length===2)T=[A(I.groups[0]),A(I.groups[1])];else{const{map:te}=U(x,K),ce=[...te.entries()].sort((ue,ae)=>ae[1]-ue[1]).slice(0,2).map(ue=>ue[0]);if(ce.length<2)return R("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;T=ce}const[B,q]=T;if(B===null||q===null||B===q)return R("compareGroups:distinct","[lattice] compareGroups: the two groups must be two distinct, present values."),null;const X=[],Q=[];for(let te=0;te<K.length;te++){const ce=A(j(K[te]));ce===B?X.push(K[te]):ce===q&&Q.push(K[te])}if(X.length===0||Q.length===0)return R("compareGroups:empty","[lattice] compareGroups: one of the two groups has no rows in the current set."),null;const J=I.test&&I.test!=="auto"?String(I.test):null,ne=F(P,X.concat(Q));let re,oe,ie;if(J===u.CHI_SQUARE||!J&&!ne){oe=J?"override":"auto",ie=J?"caller override: chiSquare":"column family: categorical";const te=U(P,X),ce=U(P,Q);re=E(te.map,te.total,ce.map,ce.total,D,{category:I.category})}else{if((J===u.WELCH||J===u.MANN_WHITNEY)&&!ne)return R("compareGroups:numeric-override",`[lattice] compareGroups: ${J} needs a numeric column, but the column is not numeric.`),null;const te=Z(P,X),ce=Z(P,Q),ue=M(te,ce,J);oe=ue.chosenBy,ie=ue.reason,re=ue.test===u.MANN_WHITNEY?o(te,ce,D):w(te,ce,D)}return re?{...re,chosenBy:oe,reason:ie,groups:[B,q]}:(R("compareGroups:degenerate","[lattice] compareGroups: the chosen test had too little to work with (too few values, or no variation)."),null)}}),ke("packages/core/src/columns/detailcolumn.js",function(e,V){"use strict";Object.defineProperty(e,"DETAIL_COLUMN_ID",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"createDetailColumn",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return L}});const _="__lattice_detail",R=36;function $(W){const Z=W.config&&W.config.detailColumnWidth||R;return{id:_,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(H,U){return!!(U&&U.expanded)},formatValue(){return""}}}const L=$}),ke("packages/core/src/columns/treecolumn.js",function(e,V){"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 R=V("packages/core/src/internal/util.js").isFunction,$="__lattice_tree",L=260;function W(H){const U=H.tree||{},z=H.config&&H.config.treeColumnWidth||L,F=()=>(H.columns&&R(H.columns.visible)?H.columns.visible():[]).find(d=>!d.generated)||null,k=(y,d)=>{if(d&&d.group)return d.groupValue;if(R(U.label))return U.label(y,d);if(typeof U.label=="string")return y==null?null:y[U.label];const c=F();return c&&R(c.getValue)?c.getValue(y,d):null},O=()=>{if(U.title)return U.title;const y=typeof U.label=="string"?H.columns&&R(H.columns.get)?H.columns.get(U.label):null:F();return y&&(y.title||y.id)||"Hierarchy"};return{id:$,get title(){return O()},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:z,min:140,pin:H.config&&H.config.treeColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(y,d){return k(y,d)},formatValue(y,d){if(d&&d.grandTotal)return H.config&&H.config.grandTotalLabel||"Total";if(y==null)return"";if(!U.label){const c=F();if(c&&R(c.formatValue))return c.formatValue(y,d)}return String(y)}}}const Z=W}),ke("packages/core/src/columns/pivotcolumns.js",function(e,V){"use strict";Object.defineProperty(e,"PIVOT_PREFIX",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"createPivotColumns",{enumerable:!0,get:function(){return W}});const R=V("packages/core/src/internal/util.js").warnOnce,$="__lattice_pivot",L=500;function W(z){const{pivot:F,valueColumns:k,config:O}=z,y=F&&F.paths||[],d=z.separator||O&&O.pivot&&O.pivot.separator||" | ",c=O&&O.pivot&&O.pivot.maxColumns||L;if(!y.length||!k.length)return{tree:[],leaves:[],error:null};const r=Z(O),t=y.length*k.length+(r?k.length:0);if(t>c){const s=`pivot would generate ${t} columns, above the limit of ${c}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return R(`pivot.maxColumns:${t}`,s),{tree:[],leaves:[],error:s}}const n=[],i=[];for(const s of y){const l=[];for(const u of k){const f=U(s,u,d);l.push(f),i.push(f)}l.length===1?(l[0].title=String(s),n.push(l[0])):n.push({id:`${$}:group:${s}`,title:String(s),columns:l,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(r){const s=k.map(u=>H(u,O));i.push(...s);const l=O&&O.pivot&&O.pivot.totalsLabel||"Total";if(s.length===1)s[0].title=l,r==="before"?n.unshift(s[0]):n.push(s[0]);else{const u={id:`${$}:group:__totals`,title:l,columns:s,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};r==="before"?n.unshift(u):n.push(u)}}return{tree:n,leaves:i,error:null}}function Z(z){const F=z&&z.pivot&&z.pivot.groupTotals;return F==="before"||F==="after"?F:null}function H(z,F){return{id:`${$}:__total${F&&F.pivot&&F.pivot.separator||" | "}${z.id}`,field:null,title:z.title||z.id,type:z.type,dataType:z.dataType,nullable:!0,align:z.align,generated:!0,pivot:{enabled:!1,index:0,sourceId:z.id,total:!0},value:{pure:!0},cell:{align:z.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:z.total,lookup:null,layout:{width:z.layout&&z.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(k,O){const y=O&&O.totals;return y&&Object.hasOwn(y,z.id)?y[z.id]:null},formatValue(k,O){return k==null?"":z.formatValue?z.formatValue(k,O):String(k)}}}function U(z,F,k){return{id:`${$}:${z}${k}${F.id}`,field:null,title:F.title||F.id,type:F.type,dataType:F.dataType,nullable:!0,align:F.align,generated:!0,pivot:{enabled:!1,index:0,path:z,sourceId:F.id},value:{pure:!0},cell:{align:F.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:F.total,lookup:null,layout:{width:F.layout&&F.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(O,y){return O==null?"":F.formatValue?F.formatValue(O,y):String(O)}}}}),ke("packages/core/src/compute/group.js",function(e,V){"use strict";Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return O}});const _=V("packages/core/src/compute/handle.js"),R=_.dictSize,$=_.identity,L=_.presenceReader,W=_.rowCount,Z=_.valueReader,H="",U="\0",z=1<<20;function F(y,d,c,r){const t=y.length,n=y.map(h=>Z(h)),i=Array.isArray(r)&&r.some(Boolean),s=i?n.map((h,g)=>r[g]?b=>r[g](h(b)):h):n;if(!i&&t>0&&y.every(h=>h&&h.kind==="dictionary"&&h.dict)){const h=y.map(b=>R(b.dict)+1);let g=1;for(let b=0;b<t;b++)g*=h[b];if(g<=Number.MAX_SAFE_INTEGER){const b=y.map(v=>v.values),p=y.map(v=>L(v)),m=v=>{let a=0;for(let o=0;o<t;o++){const S=p[o],E=S&&S(v)===0?h[o]-1:b[o][v];a=a*h[o]+E}return a},w=new Float64Array(c);for(let v=0;v<c;v++)w[v]=m(d[v]);return{packed:w,strings:null,product:g,readers:s,keyOf:m}}}const u=h=>{let g="";for(let b=0;b<t;b++){const p=s[b](h);g+=(b===0?"":H)+(p==null?U:String(p))}return g},f=new Array(c);for(let h=0;h<c;h++)f[h]=u(d[h]);return{packed:null,strings:f,product:1/0,readers:s,keyOf:u}}function k(y,d,c,r){const t=new Uint32Array(r+1);for(let l=0;l<c;l++)t[d[l]+1]++;for(let l=0;l<r;l++)t[l+1]+=t[l];const n=new Uint32Array(c),i=t.slice(0,r);for(let l=0;l<c;l++)n[i[d[l]]++]=y[l];const s=new Array(r);for(let l=0;l<r;l++)s[l]=n.subarray(t[l],t[l+1]);return s}function O(y,d,c={}){const r=y||[],t=d||$(W(r[0],c)),n=t.length;if(r.length===0||n===0)return{keys:[],buckets:[]};const{packed:i,strings:s,product:l,readers:u}=F(r,t,n,c.project),f=new Uint32Array(n);let h=0,g=null;if(i&&l<=Math.max(1024,Math.min(z,n*4))){const w=l,v=new Int32Array(w).fill(-1);for(let a=0;a<n;a++)v[i[a]]=0;for(let a=0;a<w;a++)v[a]===0&&(v[a]=h++);for(let a=0;a<n;a++)f[a]=v[i[a]];g=new Float64Array(h);for(let a=0;a<w;a++)v[a]>=0&&(g[v[a]]=a)}else if(i){const w=new Map;for(let v=0;v<n;v++){const a=i[v];let o=w.get(a);o===void 0&&(o=h++,w.set(a,o)),f[v]=o}g=new Float64Array(h);for(const[v,a]of w)g[a]=v}else{const w=new Map;for(let v=0;v<n;v++){const a=s[v];let o=w.get(a);o===void 0&&(o=h++,w.set(a,o)),f[v]=o}}const b=k(t,f,n,h),p=new Array(h);for(let w=0;w<h;w++){const v=b[w][0],a=new Array(u.length);for(let o=0;o<u.length;o++)a[o]=u[o](v);p[w]=a}const m={keys:p,buckets:b};return g&&(m.packed=g),m}}),ke("packages/core/src/compute/pivot.js",function(e,V){"use strict";Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return n}});const R=V("packages/core/src/internal/util.js").warnOnce,L=V("packages/core/src/compute/handle.js").valueComparator,Z=V("packages/core/src/compute/group.js").packKeys,U=V("packages/core/src/compute/total.js").total,z="|",F="/",k=2e3;function O(l,u,f){return`${l}${z}${u}${z}${f}`}function y(l,u){let f="";for(let h=0;h<l.length;h++){const g=l[h];f+=(h===0?"":u)+(g==null?"":String(g))}return f}function d(l,u,f={}){const h=f.separator||F,g=u.length,{keyOf:b,readers:p}=Z(l,u,0),m=new Map,w=[],v=[];for(let C=0;C<g;C++){const P=u[C],x=b(P);if(m.has(x))continue;m.set(x,w.length),v.push(x);const K=new Array(p.length);for(let I=0;I<p.length;I++)K[I]=p[I](P);w.push(K)}const a=L(f.locale),o=w.map((C,P)=>P);o.sort((C,P)=>{const x=w[C],K=w[P];for(let I=0;I<x.length;I++){const D=c(x[I],K[I],a);if(D!==0)return D}return C-P});const S=new Array(o.length),E=new Array(o.length),A=new Map;for(let C=0;C<o.length;C++){const P=o[C];S[C]=w[P],E[C]=y(w[P],h),A.set(v[P],C)}return{keys:S,paths:E,idOf:C=>{const P=A.get(b(C));return P===void 0?-1:P}}}function c(l,u,f){const h=l==null,g=u==null;return h||g?h&&g?0:h?1:-1:f(l,u)}function r(l){const u=l.values||l.totals||[];if(u.length&&typeof u[0]=="object"&&u[0]!==null)return u.filter(b=>b&&b.handle);const f=typeof l.handle=="function"?l.handle:null;if(!f)return u.length&&R("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 h=typeof l.totalOf=="function"?l.totalOf:null,g=[];for(const b of u){const p=f(b);p&&g.push({colId:b,handle:p,fn:h?h(b):"sum"})}return g}function t(l,u,f){if(Array.isArray(l)){const h=f||{};return{...h,pivotHandles:l,order:u||null,groups:h.groups||null}}return l||{}}function n(l,u,f){const h=t(l,u,f),g=h.separator||F,b=r(h),p=h.maxColumns===void 0?k:h.maxColumns,m=h.groups&&h.groups.buckets?h.groups:null,w=m?m.buckets:[h.order||new Uint32Array(0)],v=h.groupPaths||(m?m.keys.map(x=>y(x,g)):[""]),a=s(w),{keys:o,paths:S,idOf:E}=d(h.pivotHandles||[],a,h),A=S.length*Math.max(1,b.length),M=i(S,b,g);if(p&&A>p){const x=new Map;return{keys:o,paths:S,fields:M,groupPaths:v,columns:A,values:x,cells:x,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${A} columns, above pivot.maxColumns of ${p}. Narrow the pivot columns or raise the limit.`,columns:A,maxColumns:p}}}const C=new Map,P=S.length;for(let x=0;x<w.length;x++){const K=w[x],I=v[x]===void 0?"":v[x],D=K.length;if(D===0)continue;const j=new Int32Array(D),T=new Uint32Array(P+1);for(let X=0;X<D;X++){const Q=E(K[X]);j[X]=Q,Q>=0&&T[Q+1]++}for(let X=0;X<P;X++)T[X+1]+=T[X];const B=new Uint32Array(D),q=T.slice(0,P);for(let X=0;X<D;X++){const Q=j[X];Q>=0&&(B[q[Q]++]=K[X])}for(let X=0;X<P;X++){const Q=T[X],J=T[X+1];if(J===Q)continue;const ne=B.subarray(Q,J);for(let re=0;re<b.length;re++){const oe=b[re],ie=U(oe.handle,ne,oe.fn,h.totalContext||{locale:h.locale});C.set(O(I,S[X],oe.colId),ie)}}}return{keys:o,paths:S,fields:M,groupPaths:v,columns:A,values:C,cells:C,error:null}}function i(l,u,f){if(u.length===0)return l.slice();const h=[];for(const g of l)for(const b of u)h.push(`${g}${f}${b.colId}`);return h}function s(l){if(l.length===1)return l[0]||new Uint32Array(0);let u=0;for(const g of l)u+=g?g.length:0;const f=new Uint32Array(u);let h=0;for(const g of l)!g||g.length===0||(f.set(g,h),h+=g.length);return f}}),ke("packages/core/src/store/bitset.js",function(e,V){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return R}});const _=8;class R{static#e=new Uint8Array(256);static{for(let L=1;L<256;L++)R.#e[L]=R.#e[L>>1]+(L&1)}#t;#n;constructor(L=0){const W=Math.max(0,L|0);this.#n=W,this.#t=new Uint8Array(Math.ceil(W/_))}get size(){return this.#n}get words(){return this.#t}get bytes(){return this.#t?this.#t.byteLength:0}get(L){return L<0||L>=this.#n?0:this.#t[L>>3]>>(L&7)&1}set(L){return L>=0&&L<this.#n&&(this.#t[L>>3]|=1<<(L&7)),this}clear(L){return L>=0&&L<this.#n&&(this.#t[L>>3]&=~(1<<(L&7))),this}assign(L,W){return W?this.set(L):this.clear(L)}fill(L=!1){return this.#t.fill(L?255:0),L&&this.#r(),this}grow(L){const W=Math.max(0,L|0);if(W<=this.#n)return this;const Z=Math.ceil(W/_);if(Z>this.#t.length){const H=new Uint8Array(Z);H.set(this.#t),this.#t=H}return this.#n=W,this}count(){const L=this.#t,W=R.#e;let Z=0;for(let H=0;H<L.length;H++)Z+=W[L[H]];return Z}and(L){const W=L instanceof R?L.words:L,Z=this.#t,H=Math.min(Z.length,W.length);for(let U=0;U<H;U++)Z[U]&=W[U];for(let U=H;U<Z.length;U++)Z[U]=0;return this}or(L){const W=L instanceof R?L.words:L,Z=this.#t,H=Math.min(Z.length,W.length);for(let U=0;U<H;U++)Z[U]|=W[U];return this}not(){const L=this.#t;for(let W=0;W<L.length;W++)L[W]=~L[W]&255;return this.#r(),this}clone(){const L=new R(this.#n);return L.words.set(this.#t.subarray(0,L.words.length)),L}release(){this.#t=new Uint8Array(0),this.#n=0}#r(){const L=this.#n&7;if(L===0)return;const W=this.#n>>3;W<this.#t.length&&(this.#t[W]&=(1<<L)-1)}static from(L){const W=Array.isArray(L)?L:Array.from(L),Z=new R(W.length);for(let H=0;H<W.length;H++)W[H]&&Z.set(H);return Z}}}),ke("packages/core/src/store/dictionary.js",function(e,V){"use strict";Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return L}});const _=V("packages/core/src/internal/util.js"),R=_.collator,$=_.defaultCompare;class L{#e;#t=new Map;#n=0;#r=null;#o=-1;#i="\0";constructor(Z=[]){this.#e=[];for(let H=0;H<Z.length;H++){const U=Z[H];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 H=0;H<this.#e.length;H++){const U=this.#e[H];typeof U=="string"&&(Z+=U.length*2),Z+=16}return Z}codeOf(Z){const H=this.#t.get(Z);if(H!==void 0)return H;const U=this.#e.length;return this.#e.push(Z),this.#t.set(Z,U),this.#n++,U}lookup(Z){const H=this.#t.get(Z);return H===void 0?-1:H}has(Z){return this.#t.has(Z)}valueOf(Z){return this.#e[Z]}values(){return this.#e}ranks(Z){const H=Z||"";if(this.#r&&this.#o===this.#n&&this.#i===H)return this.#r;const U=this.#e.length,z=new Array(U);for(let y=0;y<U;y++)z[y]=y;const F=R(Z).compare,k=this.#e;z.sort((y,d)=>this.#a(k[y],k[d],F));const O=new Uint32Array(U);for(let y=0;y<U;y++)O[z[y]]=y;return this.#r=O,this.#o=this.#n,this.#i=H,O}#a(Z,H,U){return typeof Z=="string"&&typeof H=="string"?U(Z,H):$(Z,H)}}}),ke("packages/core/src/store/multivalue.js",function(e,V){"use strict";Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return _}});class _{#e;#t;#n=0;#r=0;constructor($={}){const L=Math.max(1,$.rows??16),W=Math.max(1,$.values??L);this.#e=new Int32Array(W),this.#t=new Uint32Array(L+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($,L){if($<0||$>=this.#n)return!1;const W=this.#e,Z=this.#t[$+1];for(let H=this.#t[$];H<Z;H++)if(W[H]===L)return!0;return!1}hasAny($,L){for(let W=0;W<L.length;W++)if(this.has($,L[W]))return!0;return!1}hasAll($,L){for(let W=0;W<L.length;W++)if(!this.has($,L[W]))return!1;return!0}hasNone($,L){return!this.hasAny($,L)}push($){const L=this.#n,W=$.length;this.#o(L+1),this.#i(this.#r+W);const Z=this.#r;for(let H=0;H<W;H++)this.#e[Z+H]=$[H]|0;return this.#r+=W,this.#n=L+1,this.#t[L]=Z,this.#t[L+1]=this.#r,L}write($,L){if($===this.#n){this.push(L);return}if($<0||$>this.#n)return;const W=this.#t[$],Z=this.#t[$+1],H=L.length;if(Z-W===H){for(let U=0;U<H;U++)this.#e[W+U]=L[U]|0;return}this.#a($,L)}compact($,L,W){const Z=this.#e,H=this.#t,U=this.#n,z=new Int32Array(Math.max(1,this.#r)),F=new Uint32Array(L+1);let k=0;for(let O=0;O<U;O++){if($[O]===W)continue;const y=H[O],d=H[O+1];F[$[O]]=k;for(let c=y;c<d;c++)z[k++]=Z[c];F[$[O]+1]=k}this.#e=z,this.#t=F,this.#n=L,this.#r=k}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 L=this.#t.length-1;for(;L<$;)L=L*2||16;const W=new Uint32Array(L+1);W.set(this.#t),this.#t=W}#i($){if($<=this.#e.length)return;let L=this.#e.length;for(;L<$;)L=L*2||16;const W=new Int32Array(L);W.set(this.#e),this.#e=W}#a($,L){const W=this.#e,Z=this.#t,H=this.#n,U=L.length-(Z[$+1]-Z[$]),z=new Int32Array(Math.max(1,this.#r+U)),F=new Uint32Array(Z.length);let k=0;for(let O=0;O<H;O++){if(F[O]=k,O===$)for(let y=0;y<L.length;y++)z[k++]=L[y]|0;else for(let y=Z[O];y<Z[O+1];y++)z[k++]=W[y];F[O+1]=k}this.#e=z,this.#t=F,this.#r=k}}}),ke("packages/core/src/compute/sort.js",function(e,V){"use strict";Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return P}});const _=V("packages/core/src/compute/handle.js"),R=_.bitReader,$=_.dictRanks,L=_.dictSize,W=_.identity,Z=_.isMissing,H=_.presenceReader,U=_.rowCount,z=_.valueComparator,F=_.valueReader,k=new Uint32Array(0),O=new ArrayBuffer(8),y=new Float64Array(O),d=new Uint32Array(O),c=(y[0]=-1,(d[1]&2147483648)!==0?1:0),r=c===1?0:1;function t(K,I){y[0]=K;let D=d[c],j=d[r];(D&2147483648)!==0?(D=~D>>>0,j=~j>>>0):D=(D^2147483648)>>>0,I[0]=j,I[1]=D}function n(K,I,D,j){if(j<2)return K;const T=new Uint32Array(256*8);for(let oe=0;oe<j;oe++){const ie=I[oe],te=D[oe];T[ie&255]++,T[256+(ie>>>8&255)]++,T[512+(ie>>>16&255)]++,T[768+(ie>>>24&255)]++,T[1024+(te&255)]++,T[1280+(te>>>8&255)]++,T[1536+(te>>>16&255)]++,T[1792+(te>>>24&255)]++}let B=K,q=I,X=D,Q=new Uint32Array(j),J=new Uint32Array(j),ne=new Uint32Array(j);const re=new Uint32Array(256);for(let oe=0;oe<8;oe++){const ie=oe<<8,te=(oe&3)<<3,ce=oe>=4;let ue=!1;for(let he=0;he<256;he++)if(T[ie+he]===j){ue=!0;break}if(ue)continue;let ae=0;for(let he=0;he<256;he++)re[he]=ae,ae+=T[ie+he];for(let he=0;he<j;he++){const ve=q[he],Oe=X[he],Ie=(ce?Oe:ve)>>>te&255,Ze=re[Ie]++;Q[Ze]=B[he],J[Ze]=ve,ne[Ze]=Oe}let pe=B;B=Q,Q=pe,pe=q,q=J,J=pe,pe=X,X=ne,ne=pe}return B}function i(K,I,D){if(D<2)return K;const j=new Uint32Array(256*4);for(let J=0;J<D;J++){const ne=I[J];j[ne&255]++,j[256+(ne>>>8&255)]++,j[512+(ne>>>16&255)]++,j[768+(ne>>>24&255)]++}let T=K,B=I,q=new Uint32Array(D),X=new Uint32Array(D);const Q=new Uint32Array(256);for(let J=0;J<4;J++){const ne=J<<8,re=J<<3;let oe=!1;for(let ce=0;ce<256;ce++)if(j[ne+ce]===D){oe=!0;break}if(oe)continue;let ie=0;for(let ce=0;ce<256;ce++)Q[ce]=ie,ie+=j[ne+ce];for(let ce=0;ce<D;ce++){const ue=B[ce],ae=Q[ue>>>re&255]++;q[ae]=T[ce],X[ae]=ue}let te=T;T=q,q=te,te=B,B=X,X=te}return T}function s(K,I,D,j){const T=new Uint32Array(j+1);for(let X=0;X<D;X++)T[I[X]]++;let B=0;for(let X=0;X<=j;X++){const Q=T[X];T[X]=B,B+=Q}const q=new Uint32Array(D);for(let X=0;X<D;X++)q[T[I[X]]++]=K[X];return q}function l(K,I,D,j){return D<2?K:j<=65536||j<=D*2?s(K,I,D,j):i(K,I,D)}function u(K,I){return K.length===I&&K.byteOffset===0?K:Uint32Array.prototype.slice.call(K,0,I)}function f(K,I,D=!1){const j=I||W(K.length),T=j.length;if(T<2)return Uint32Array.from(j);const B=new Uint32Array(T),q=new Uint32Array(T),X=new Uint32Array(T),Q=new Uint32Array(T),J=new Uint32Array(2);let ne=0,re=0;for(let te=0;te<T;te++){const ce=j[te],ue=K[ce];if(Number.isNaN(ue)){Q[re++]=ce;continue}t(ue,J),D?(q[ne]=~J[0]>>>0,X[ne]=~J[1]>>>0):(q[ne]=J[0],X[ne]=J[1]),B[ne++]=ce}const oe=n(B.subarray(0,ne),q.subarray(0,ne),X.subarray(0,ne),ne);if(re===0)return u(oe,ne);const ie=new Uint32Array(T);return ie.set(oe.subarray(0,ne),0),ie.set(Q.subarray(0,re),ne),ie}function h(K,I,D=!1){const j=I||W(K.length),T=j.length;if(T<2)return Uint32Array.from(j);const B=Uint32Array.from(j),q=new Uint32Array(T);for(let X=0;X<T;X++){const Q=(K[B[X]]^2147483648)>>>0;q[X]=D?~Q>>>0:Q}return u(i(B,q,T),T)}function g(K,I,D={}){const j=I||W(U(K,D)),T=j.length;if(T<2)return Uint32Array.from(j);const B=$(K.dict,D.locale),q=K.values,X=H(K),Q=Math.max(L(K.dict),B.length),J=Q,ne=Uint32Array.from(j),re=new Uint32Array(T),oe=!!D.descending;for(let ie=0;ie<T;ie++){const te=ne[ie];let ce=X&&X(te)===0?J:B[q[te]];ce===void 0&&(ce=J),re[ie]=oe?J-ce:ce}return u(l(ne,re,T,Q+1),T)}function b(K,I,D){const j=I.length;let T=Uint32Array.from(I);if(j<2)return T;let B=new Uint32Array(j);for(let q=1;q<j;q<<=1){for(let Q=0;Q<j;Q+=q<<1){const J=Math.min(Q+q,j),ne=Math.min(Q+(q<<1),j);let re=Q,oe=J,ie=Q;for(;re<J&&oe<ne;)B[ie++]=D(K[T[re]],K[T[oe]])<=0?T[re++]:T[oe++];for(;re<J;)B[ie++]=T[re++];for(;oe<ne;)B[ie++]=T[oe++]}const X=T;T=B,B=X}return T}function p(K,I,D){const j=R(K.values),T=I.length,B=new Uint32Array(T),q=D?1:0;let X=0;for(let Q=0;Q<T;Q++)j(I[Q])===q&&(B[X++]=I[Q]);for(let Q=0;Q<T;Q++)j(I[Q])!==q&&(B[X++]=I[Q]);return B}function m(K,I){const D=K.values,j=K.kind;if((j==="object"||j===void 0)&&(Array.isArray(D)||ArrayBuffer.isView(D))&&!K.presence)return D;const B=F(K),q=new Array(U(K)||0);for(let X=0;X<I.length;X++){const Q=I[X];q[Q]=B(Q)}return q}function w(K,I){for(let D=0;D<I.length;D++)if(typeof K[I[D]]!="string")return!1;return!0}function v(K,I,D,j,T){const B=K.length,q=Uint32Array.from(K);if(B<2||j<1)return q;const X=new Uint32Array(B),Q=j-1;for(let J=0;J<B;J++){const ne=D[I[J]];X[J]=T?Q-ne:ne}return u(l(q,X,B,j),B)}function a(K,I,D){const j=z(D),T=new Array(I);for(let q=0;q<I;q++)T[q]=q;T.sort((q,X)=>j(K[q],K[X])||q-X);const B=new Uint32Array(I);for(let q=0;q<I;q++)B[T[q]]=q;return B}function o(K,I,D){const j=I.length,T=new Map,B=[],q=new Uint32Array(j);for(let J=0;J<j;J++){const ne=K[I[J]];let re=T.get(ne);re===void 0&&(re=B.length,T.set(ne,re),B.push(ne)),q[J]=re}const X=B.length,Q=a(B,X,D.locale);return v(I,q,Q,X,!!D.descending)}function S(K,I,D){const j=m(K,I);if(I.length>=2&&w(j,I)){const q=K.stringRank;return q&&q.version===K.version&&q.usable(I,j,D.locale)?q.sort(I,D):o(j,I,D)}const T=z(D.locale),B=D.descending?(q,X)=>T(X,q):T;return b(j,I,B)}function E(K,I,D){const j=m(K,I),T=D.compare,q=!!D.descending?(X,Q)=>-T(X,Q,void 0,void 0,!0):(X,Q)=>T(X,Q,void 0,void 0,!1);return b(j,I,q)}function A(K,I){const D=I.length,j=H(K),T=K.values,B=K.kind==="float64"&&!!T,q=K.kind==="object"||K.kind==="multi"||K.kind===void 0;if(!j&&!B&&!q)return{present:I,absent:k};const X=new Uint32Array(D),Q=new Uint32Array(D);let J=0,ne=0;if(j&&B)for(let re=0;re<D;re++){const oe=I[re];j(oe)===1&&!Number.isNaN(T[oe])?X[J++]=oe:Q[ne++]=oe}else if(B&&!j)for(let re=0;re<D;re++){const oe=I[re];Number.isNaN(T[oe])?Q[ne++]=oe:X[J++]=oe}else if(j&&!q)for(let re=0;re<D;re++){const oe=I[re];j(oe)===1?X[J++]=oe:Q[ne++]=oe}else{const re=F(K);for(let oe=0;oe<D;oe++){const ie=I[oe];Z(re(ie))?Q[ne++]=ie:X[J++]=ie}}return ne===0?{present:I,absent:k}:{present:X.subarray(0,J),absent:Q.subarray(0,ne)}}function M(K,I,D){if(I.length===0)return K;const j=new Uint32Array(K.length+I.length);return D?(j.set(I,0),j.set(K,I.length)):(j.set(K,0),j.set(I,K.length)),j}function C(K,I,D={}){const j=I||W(U(K,D));if(!K||j.length<2)return Uint32Array.from(j);const{present:T,absent:B}=A(K,j);if(T.length===0)return Uint32Array.from(j);const q=!!D.descending;let X;if(typeof D.compare=="function")X=E(K,T,D);else switch(K.kind){case"float64":X=f(K.values,T,q);break;case"int32":X=h(K.values,T,q);break;case"dictionary":X=g(K,T,D);break;case"bitset":X=p(K,T,q);break;default:X=S(K,T,D);break}return M(X,B,!!D.nullsFirst)}function P(K,I,D,j={}){const T=I||[],B=T.length&&(T[0].handle||x(K,T[0].col))||K&&K[0];let q=D||W(U(B,j));for(let X=T.length-1;X>=0;X--){const Q=T[X],J=Q.handle||x(K,Q.col)||K&&K[X];J&&(q=C(J,q,{descending:Q.descending!==void 0?!!Q.descending:Q.dir==="desc",nullsFirst:!!Q.nullsFirst,locale:Q.locale!==void 0?Q.locale:j.locale,compare:Q.compare}))}return q instanceof Uint32Array?q:Uint32Array.from(q)}function x(K,I){if(!(!K||I===void 0)){for(let D=0;D<K.length;D++)if(K[D]&&K[D].id===I)return K[D]}}}),ke("packages/core/src/store/stringrank.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"StringRankIndex",{enumerable:!0,get:function(){return W}});const _=V("packages/core/src/compute/sort.js"),R=_.collateStringRanks,$=_.rankSortStrings,L=1e5;class W{#e=[];#t=new Map;#n;#r=0;#o=0;#i=-1;#a;#s=!1;#l=null;#u=-1;#c="\0";constructor(H=L){this.#a=H>0?H:L,this.#n=new Uint32Array(0)}get version(){return this.#i}set version(H){this.#i=H}get generation(){return this.#o}get size(){return this.#e.length}get capped(){return this.#s}get length(){return this.#r}get bytes(){let H=this.#n.byteLength;const U=this.#e;for(let z=0;z<U.length;z++)H+=U[z].length*2+24;return H}#d(H,U){const z=this.#t.get(H);if(z!==void 0)return z;if(this.#s)return-1;if(U&&this.#e.length>=this.#a)return this.#s=!0,-1;const F=this.#e.length;return this.#e.push(H),this.#t.set(H,F),this.#o++,F}build(H,U){const z=U|0;this.#e=[],this.#t=new Map,this.#o=0,this.#s=!1,this.#l=null,this.#u=-1,this.#n=new Uint32Array(z);for(let F=0;F<z;F++){const k=H[F],O=typeof k=="string"?this.#d(k,!1):-1;this.#n[F]=O<0?0:O}this.#r=z}append(H,U,z){const F=(U|0)+(z|0);if(F>this.#n.length){const k=new Uint32Array(F);k.set(this.#n.subarray(0,this.#r)),this.#n=k}for(let k=U|0;k<F;k++){const O=H[k],y=typeof O=="string"?this.#d(O,!0):-1;this.#n[k]=y<0?0:y}this.#r=Math.max(this.#r,F)}ranks(H){const U=H||"";if(this.#l&&this.#u===this.#o&&this.#c===U)return this.#l;const z=R(this.#e,this.#e.length,H);return this.#l=z,this.#u=this.#o,this.#c=U,z}usable(H,U,z){if(this.#s||this.#e.length===0)return!1;const F=this.#n,k=this.#e,O=this.#r;for(let y=0;y<H.length;y++){const d=H[y];if(d>=O||k[F[d]]!==U[d])return!1}return!0}sort(H,U){const z=this.ranks(U.locale),F=this.#e.length,k=H.length,O=new Uint32Array(k),y=this.#n;for(let d=0;d<k;d++)O[d]=y[H[d]];return $(H,O,z,F,!!U.descending)}}}),ke("packages/core/src/store/columnstore.js",function(e,V){"use strict";Object.defineProperty(e,"REMOVED",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"toFloat",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ColumnHandle",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return g}});const _=V("packages/core/src/internal/util.js"),R=_.warnOnce,$=_.isFunction,L=_.pathGetter,Z=V("packages/core/src/store/bitset.js").Bitset,U=V("packages/core/src/store/dictionary.js").Dictionary,F=V("packages/core/src/store/multivalue.js").MultiValue,O=V("packages/core/src/store/stringrank.js").StringRankIndex,y=4294967295,d=1024,c=5e3,r=.2,t=new Set(["float64","int32","bitset","dictionary","object","multi"]);function n(b){return b==null}function i(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 s(b){const p=i(b);return Number.isFinite(p)?p|0:0}function l(b){return n(b)?[]:Array.isArray(b)?b:[b]}function u(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 m=b.mv.at(p),w=new Array(m.length);for(let v=0;v<m.length;v++)w[v]=b.dict.valueOf(m[v]);return w}default:return b.buf[p]}}function f(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 m=b.offsets[p],w=b.offsets[p+1],v=b.table||[],a=new Array(w-m);for(let o=m;o<w;o++)a[o-m]=v[b.values[o]];return a}default:return b.values[p]}}class h{#e;#t;#n;#r;#o;#i;#a;#s=!1;#l=null;#u=null;#c=null;#d=null;#h=null;#f;#m;#p=-1;#g=null;#v=0;#b=0;#y=null;#w=null;#S=!1;constructor(p,m){this.#e=p.id;const w=t.has(p.kind)?p.kind:"object";p.kind&&!t.has(p.kind)&&R(`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.#a=p.dictionary??null,this.#i=m,this.#o=$(p.read)?p.read:L(p.field||p.id),this.#f=p.stringRankIndex!=="off",this.#m=typeof p.stringRankMaxDistinct=="number"?p.stringRankMaxDistinct:0,this.#y=new Map}get id(){return this.#e}get kind(){return this.#s?this.#t:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#S?null:this.#s?this.#t==="bitset"?this.#u.words:this.#t==="multi"?this.#c.values:this.#l:this.#T().values}get presence(){return this.#S||!this.#r?null:this.#s?this.#g:this.#T().presence}get dict(){return this.#S||!this.#s?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,m=this.#i.physical();if(!p||m===0)return null;if(this.#h===null){if(typeof p[0]!="string")return null;const w=new O(this.#j());return w.build(p,m),w.version=this.#b,this.#h=w,this.#p=this.#b,w.capped?null:w}return this.#h.length<m&&this.#h.append(p,this.#h.length,m-this.#h.length),this.#h.version=this.#b,this.#p=this.#b,this.#h.capped?null:this.#h}#j(){return this.#m}#A(){this.#h=null,this.#p=-1}get offsets(){return this.#S||!this.#s||this.#t!=="multi"?null:this.#c.offsets}get version(){return this.#b}get bytes(){let p=0;return this.#l&&(p+=this.#l.byteLength??this.#l.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.#y&&(p+=this.#y.size*24),p}get(p){if(!this.#S&&!(p<0||p>=this.#i.physical())){if(!this.#s)return this.#E(p);if(this.#r&&this.#g.get(p)===0)return null;switch(this.#t){case"float64":case"int32":return this.#l[p];case"bitset":return this.#u.get(p)===1;case"dictionary":return this.#d.valueOf(this.#l[p]);case"multi":{const m=this.#c.at(p),w=new Array(m.length);for(let v=0;v<m.length;v++)w[v]=this.#d.valueOf(m[v]);return w}default:return this.#l[p]}}}set(p,m){this.#S||(this.#s?this.#C(p,m):this.#y.set(p,m===void 0?null:m),this.#h&&this.#A(),this.#b++)}read(p){return this.#o(p)}appendColumn(p,m,w){if(this.#S||w<=0)return;if(!this.#s){this.#b++;return}const v=this.#o,a=this.#r,o=this.#g;let S=!1;switch(this.#t){case"float64":{const E=this.#l;for(let A=0;A<w;A++){const M=v(p[A]);if(typeof M=="number"){a&&o.set(m+A),E[m+A]=M;continue}const C=M==null;a?o.assign(m+A,!C):C&&(S=!0),E[m+A]=C?NaN:i(M)}break}case"int32":{const E=this.#l;for(let A=0;A<w;A++){const M=v(p[A]),C=M==null;a?o.assign(m+A,!C):C&&(S=!0),E[m+A]=C?0:s(M)}break}case"bitset":{const E=this.#u;for(let A=0;A<w;A++){const M=v(p[A]),C=M==null;a?o.assign(m+A,!C):C&&(S=!0),E.assign(m+A,!C&&!!M)}break}case"dictionary":{const E=this.#l,A=this.#d;for(let M=0;M<w;M++){const C=v(p[M]),P=C==null;a?o.assign(m+M,!P):P&&(S=!0),E[m+M]=P?0:A.codeOf(C)}break}case"multi":{const E=this.#c,A=this.#d;for(let M=0;M<w;M++){const C=v(p[M]),P=C==null;a?o.assign(m+M,!P):P&&(S=!0);const x=l(C),K=new Array(x.length);for(let I=0;I<x.length;I++)K[I]=A.codeOf(x[I]);E.write(m+M,K)}break}default:{const E=this.#l;for(let A=0;A<w;A++){const M=v(p[A]),C=M==null;a?o.assign(m+A,!C):C&&(S=!0),E[m+A]=C?null:M}break}}S&&R(`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.#l,m,w),this.#h.version=this.#b+1,this.#p=this.#b+1),this.#b++}appendPacked(p,m,w){if(this.#S||w<=0||!p)return;if(!this.#s){this.#b++;return}const v=this.#g,a=p.presence;if(v)if(a)for(let S=0;S<w;S++)v.assign(m+S,(a[S>>3]&1<<(S&7))!==0);else for(let S=0;S<w;S++)v.set(m+S);const o=p.kind===this.#t;if(o&&(this.#t==="float64"||this.#t==="int32")){this.#l.set(p.values,m),this.#b++;return}if(o&&this.#t==="bitset"){const S=p.values;for(let E=0;E<w;E++)this.#u.assign(m+E,(S[E>>3]&1<<(E&7))!==0);this.#b++;return}if(o&&this.#t==="dictionary"){const S=p.table||[],E=new Uint32Array(S.length);for(let P=0;P<S.length;P++)E[P]=this.#d.codeOf(S[P]);const A=p.values,M=this.#l,C=v;for(let P=0;P<w;P++){if(C&&(a&&(a[P>>3]&1<<(P&7))===0)){M[m+P]=0;continue}M[m+P]=E[A[P]]??0}this.#b++;return}if(o&&this.#t==="multi"){const S=p.table||[],E=new Uint32Array(S.length);for(let C=0;C<S.length;C++)E[C]=this.#d.codeOf(S[C]);const A=p.values,M=p.offsets;for(let C=0;C<w;C++){const P=M[C],x=M[C+1],K=new Array(x-P);for(let I=P;I<x;I++)K[I-P]=E[A[I]]??0;this.#c.write(m+C,K)}this.#b++;return}for(let S=0;S<w;S++){const E=a?(a[S>>3]&1<<(S&7))===0:p.kind==="object"?p.values[S]===null:!1;this.#C(m+S,E?null:f(p,S))}this.#b++}touch(){this.#b++}columnarise(p,m){if(this.#s||this.#S)return;const w=new Array(m);for(let v=0;v<m;v++)w[v]=this.#E(v);this.#t=this.#n,this.#s=!0,this.#O(p);for(let v=0;v<m;v++)this.#C(v,w[v]);this.#y.clear(),this.#w=null,this.#A(),this.#b++}grow(p){if(!(!this.#s||this.#S||p<=this.#v)){switch(this.#t){case"float64":case"int32":case"dictionary":{const m=new this.#l.constructor(p);m.set(this.#l),this.#l=m;break}case"bitset":this.#u.grow(p);break;case"multi":break;default:this.#l.length=p;break}this.#g&&this.#g.grow(p),this.#v=p,this.#b++}}convert(p){if(this.#S||!t.has(p)||(this.#n=p,!this.#s||p===this.#t))return!1;const m={kind:this.#t,buf:this.#l,bits:this.#u,mv:this.#c,dict:this.#d},w=this.#i.physical(),v=this.#g;this.#t=p,this.#O(this.#v);for(let a=0;a<w;a++){const o=v!==null&&v.get(a)===0;o&&p!=="multi"||this.#C(a,o?null:u(m,a))}return this.#A(),this.#b++,!0}compact(p,m,w){if(!this.#S){if(this.#A(),!this.#s){const v=this.#y;if(v.size){const a=new Map;for(const[o,S]of v)p[o]!==y&&a.set(p[o],S);this.#y=a}this.#w=null,this.#b++;return}switch(this.#t){case"float64":case"int32":case"dictionary":case"object":{const v=this.#l;for(let a=0;a<m;a++)p[a]!==y&&(v[p[a]]=v[a]);if(this.#t==="object")for(let a=w;a<m;a++)v[a]=void 0;break}case"bitset":{const v=this.#u;for(let a=0;a<m;a++)p[a]!==y&&v.assign(p[a],v.get(a)===1);for(let a=w;a<m;a++)v.clear(a);break}case"multi":this.#c.compact(p,w,y);break;default:break}if(this.#g){const v=this.#g;for(let a=0;a<m;a++)p[a]!==y&&v.assign(p[a],v.get(a)===1);for(let a=w;a<m;a++)v.clear(a)}this.#b++}}release(){this.#S||(this.#S=!0,this.#l=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.#y=new Map,this.#w=null,this.#v=0,this.#b++)}#O(p){const m=Math.max(1,p);switch(this.#l=null,this.#u=null,this.#c=null,this.#t){case"float64":this.#l=new Float64Array(m);break;case"int32":this.#l=new Int32Array(m);break;case"bitset":this.#u=new Z(m);break;case"dictionary":this.#l=new Uint32Array(m),this.#d=this.#d??new U(this.#a??[]);break;case"multi":this.#c=new F({rows:m,values:m}),this.#d=this.#d??new U(this.#a??[]);break;default:this.#l=new Array(m);break}this.#t!=="dictionary"&&this.#t!=="multi"&&(this.#d=null),this.#r&&(this.#g?this.#g.grow(m):this.#g=new Z(m)),this.#v=m}#C(p,m){const w=n(m);switch(this.#r?this.#g.assign(p,!w):w&&R(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#t){case"float64":this.#l[p]=w?NaN:i(m);break;case"int32":this.#l[p]=w?0:s(m);break;case"bitset":this.#u.assign(p,!w&&!!m);break;case"dictionary":this.#l[p]=w?0:this.#d.codeOf(m);break;case"multi":{const v=l(m),a=new Array(v.length);for(let o=0;o<v.length;o++)a[o]=this.#d.codeOf(v[o]);this.#c.write(p,a);break}default:this.#l[p]=w?null:m;break}}#E(p){if(this.#y.has(p))return this.#y.get(p);const m=this.#o(this.#i.rowAt(p));return m===void 0?null:m}#T(){if(this.#w&&this.#w.version===this.#b)return this.#w;const p=this.#i.physical(),m=new Array(p),w=this.#r?new Z(p):null;for(let v=0;v<p;v++){const a=this.#E(v);m[v]=a,w&&!n(a)&&w.set(v)}return this.#w={version:this.#b,values:m,presence:w},this.#w}}class g{#e;#t=new Map;#n=[];#r=[];#o=0;#i=0;#a=0;#s=0;#l=new Z(0);#u=!1;#c=!0;#d;#h;#f;#m=!1;constructor(p,m={}){this.#e=Array.isArray(p)?p:[],this.#h=Math.max(1,m.initialCapacity??d),this.#c=m.retainSource!==!1,this.#d=this.#c?m.columnarBelow??c:0,this.#f=m.compactRatio??r;const w={rowAt:v=>this.#r[v],physical:()=>this.#o};for(const v of this.#e){if(!v||!v.id)continue;if(this.#t.has(v.id)){R(`store.dup.${v.id}`,`duplicate column id "${v.id}" in the store schema; ignoring the second`);continue}const a=new h(v,w);this.#t.set(v.id,a),this.#n.push(a)}this.#d<=0&&this.#v()}get count(){return this.#a}get physical(){return this.#o}get capacity(){return this.#u?this.#i:this.#r.length}get tombstones(){return this.#s}get columnar(){return this.#u}get destroyed(){return this.#m}get bytes(){let p=this.#l.bytes+this.#r.length*8;for(const m of this.#n)p+=m.bytes;return p}append(p){const m=this.#o;if(this.#m||!p)return{from:m,to:m};const w=p.length|0;if(w===0)return{from:m,to:m};if(this.#c)for(let a=0;a<w;a++)this.#r[m+a]=p[a];if(this.#o=m+w,this.#a+=w,this.#l.grow(this.#o),!this.#u){if(this.#o>=this.#d)this.#v();else for(const a of this.#n)a.touch();return{from:m,to:this.#o}}this.#p(this.#o);const v=this.#n;for(let a=0;a<v.length;a++)v[a].appendColumn(p,m,w);return{from:m,to:this.#o}}appendPacked(p,m){const w=this.#o;if(this.#m||!p)return{from:w,to:w};const v=p.count|0;if(v===0)return{from:w,to:w};if(this.#c&&m)for(let o=0;o<v;o++)this.#r[w+o]=m[o];this.#o=w+v,this.#a+=v,this.#l.grow(this.#o),this.#u||this.#v(),this.#p(this.#o);const a=new Map;for(const o of p.columns)a.set(o.id,o);for(const o of this.#n){const S=a.get(o.id);S?o.appendPacked(S,w,v):o.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,m){this.#m||p<0||p>=this.#o||this.#c&&(this.#r[p]=m)}get(p,m){const w=this.#t.get(p);return w?w.get(m):void 0}set(p,m,w){if(this.#m||m<0||m>=this.#o)return;const v=this.#t.get(p);if(!v){R(`store.set.${p}`,`set() on unknown column "${p}"`);return}v.set(m,w)}remove(p){return this.#m||p<0||p>=this.#o||this.#l.get(p)===1?!1:(this.#l.set(p),this.#s++,this.#a--,!0)}live(p){return p<0||p>=this.#o?!1:this.#l.get(p)===0}compact(p={}){if(this.#m||this.#s===0||!p.force&&this.#s/this.#o<this.#f)return null;const m=this.#o,w=new Uint32Array(m);let v=0;for(let a=0;a<m;a++)w[a]=this.#l.get(a)===1?y:v++;for(const a of this.#n)a.compact(w,m,v);if(this.#c){const a=this.#r;for(let o=0;o<m;o++)w[o]!==y&&(a[w[o]]=a[o]);a.length=v}return this.#o=v,this.#a=v,this.#s=0,this.#l=new Z(Math.max(this.#i,v)),w}column(p){return this.#t.get(p)}columns(){return this.#n.slice()}liveIndices(){const p=new Uint32Array(this.#a);if(this.#s===0){for(let w=0;w<this.#o;w++)p[w]=w;return p}let m=0;for(let w=0;w<this.#o;w++)this.#l.get(w)===0&&(p[m++]=w);return p}convert(p,m){const w=this.#t.get(p);return w?w.convert(m):!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.#l.release(),this.#o=0,this.#a=0,this.#s=0,this.#i=0}}#p(p){if(p<=this.#i)return;let m=this.#i||this.#h;for(;m<p;)m*=2;for(const w of this.#n)w.grow(m);this.#l.grow(m),this.#i=m}#g(p){const m={};for(const w of this.#n)m[w.id]=w.get(p);return m}#v(){if(this.#u)return;let p=this.#h;for(;p<this.#o;)p*=2;this.#u=!0,this.#i=p,this.#l.grow(p);for(const m of this.#n)m.columnarise(p,this.#o)}}}),ke("packages/core/src/store/pool.js",function(e,V){"use strict";Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"sharedPool",{enumerable:!0,get:function(){return W}});const _=64,R=8;function $(H){let U=_;for(;U<H;)U*=2;return U}class L{#e=new Map;#t=new WeakSet;#n;#r=0;#o={acquired:0,reused:0,released:0};constructor(U={}){this.#n=U.limit??R}get bytes(){return this.#r}mask(U){const z=new Uint8Array(this.#i(U),0,U);return z.fill(0),z}indices(U){return new Uint32Array(this.#i(U*4),0,U)}release(U){if(!U||!U.buffer)return!1;const z=U.buffer;if(!this.#t.has(z))return!1;this.#t.delete(z),this.#o.released++;const F=z.byteLength;let k=this.#e.get(F);return k||this.#e.set(F,k=[]),k.length>=this.#n||(k.push(z),this.#r+=F),!0}releaseAll(U){for(const z of U)this.release(z)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#o,retained:this.#r}}#i(U){const z=$(U),F=this.#e.get(z);this.#o.acquired++;let k;return F&&F.length?(k=F.pop(),this.#r-=z,this.#o.reused++):k=new ArrayBuffer(z),this.#t.add(k),k}}function W(){return Z??=new L,Z}let Z=null}),ke("packages/core/src/compute/sortspec.js",function(e,V){"use strict";Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return W}});function _(Z){return{locale:Z===void 0?void 0:String(Z),numeric:!0,sensitivity:"variant"}}function R(Z){return!!Z&&typeof Z.compare!="function"}function $(Z){if(!Z)return!0;for(let H=0;H<Z.length;H++)if(!R(Z[H]))return!1;return!0}function L(Z,H){const U=Z.col!==void 0?Z.col:Z.handle&&Z.handle.id,z=Z.locale!==void 0?Z.locale:H;return{col:U,descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,collation:_(z)}}function W(Z,H){const U=Z||[],z=new Array(U.length);for(let F=0;F<U.length;F++)z[F]=L(U[F],H);return z}}),ke("packages/core/src/compute/filter.js",function(e,V){"use strict";Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return I}});const _=V("packages/core/src/internal/util.js"),R=_.isBlank,$=_.toArray,L=_.warnOnce,Z=V("packages/core/src/format/date.js").toIsoDate,H=V("packages/core/src/compute/handle.js"),U=H.bitReader,z=H.dictSize,F=H.dictValue,k=H.presenceReader,O=H.valueComparator,y=H.valueReader,d=/^\d{4}-\d{2}-\d{2}$/,c="\0null\0";function r(D,j){const T=D&&D.pool;if(T){const B=T.mask||T.acquireMask||T.acquire||T.take;if(typeof B=="function"){const q=B.call(T,j);if(q&&q.length>=j)return q}}return new Uint8Array(j)}function t(D,j){const T=D&&D.pool;if(!T||!j)return;const B=T.release||T.releaseMask||T.free||T.recycle;typeof B=="function"&&B.call(T,j)}function n(D,j,T){return D.fill(T,0,j),D}function i(D){return D==null||typeof D=="number"&&Number.isNaN(D)}function s(D,j){if(D==null)return D;if(j==="number")return typeof D=="number"?D:Number(D);if(j==="date"||j==="dateString"){const T=Z(D);return T===null?l(D):T}return j==="boolean"?typeof D=="boolean"?D:D==="true"||D===1?!0:D==="false"||D===0?!1:!!D:D}function l(D){return D instanceof Date?D.getTime():typeof D=="number"?D:Date.parse(String(D))}function u(D){return typeof D=="number"?D:D instanceof Date?D.getTime():D==null||D===""?NaN:Number(D)}function f(D,j){const T=typeof D=="string"?D:String(D);return j?T:T.toLowerCase()}function h(D,j){return D==null?c:typeof D=="string"?j?D:D.toLowerCase():D instanceof Date?D.getTime():D}function g(D,j,T){const B=new Set;for(const q of $(D)){const X=s(q,T);B.add(h(X,j)),typeof X=="string"&&X!==""&&Number.isFinite(Number(X))?B.add(Number(X)):typeof X=="number"&&Number.isFinite(X)&&B.add(h(String(X),j))}return B}function b(D,j,T){if(D==null||j===null||j===void 0)return D==null&&j==null;const B=typeof D,q=typeof j;return B==="string"&&q==="string"?T?D===j:D.toLowerCase()===j.toLowerCase():D instanceof Date||j instanceof Date?l(D)===l(j):B==="number"&&q==="number"?D===j||Number.isNaN(D)&&Number.isNaN(j):B==="number"&&q==="string"?D===Number(j):B==="string"&&q==="number"?Number(D)===j:B==="boolean"||q==="boolean"?D===j:Array.isArray(D)&&Array.isArray(j)?D.length===j.length&&D.every((X,Q)=>b(X,j[Q],T)):D===j}function p(D,j){try{if(D instanceof RegExp){const T=D.flags.replace(/[gy]/g,"");return new RegExp(D.source,j||T.includes("i")?T:`${T}i`)}return new RegExp(String(D),j?"":"i")}catch(T){return L(`regex:${String(D)}`,`filter operator "matches" received an invalid pattern: ${String(D)}`,T),null}}function m(D,j){const T=w(D,j),B=D&&D.type;return B!=="date"&&B!=="dateString"?T:q=>T(typeof q=="string"&&d.test(q)?q:Z(q)??q)}function w(D,j){const T=D&&D.op,B=!!(D&&D.caseSensitive),q=D&&D.type,X=O(j),Q=J=>ne=>!J(ne);switch(T){case"eq":{const J=s(D.value,q);return ne=>b(ne,J,B)}case"ne":{const J=s(D.value,q);return ne=>!b(ne,J,B)}case"lt":case"lte":case"gt":case"gte":{const J=s(D.value,q);if(i(J))return()=>!1;const ne=T==="lt"?-1:T==="lte"?0:T==="gt"?1:2;return re=>{if(i(re))return!1;const oe=X(re,J);return ne===-1?oe<0:ne===0?oe<=0:ne===1?oe>0:oe>=0}}case"between":case"notBetween":{const J=$(D.value),ne=s(J[0],q),re=s(J[1],q),oe=D.bounds||"[]",ie=oe.charAt(0)!=="(",te=oe.charAt(1)!==")";if(i(ne)||i(re))return T==="between"?()=>!1:()=>!0;const ce=ue=>{if(i(ue))return!1;const ae=X(ue,ne),pe=X(ue,re);return(ie?ae>=0:ae>0)&&(te?pe<=0:pe<0)};return T==="between"?ce:Q(ce)}case"in":case"notIn":{const J=g(D.value,B,q),ne=re=>J.has(h(re,B));return T==="in"?ne:Q(ne)}case"contains":case"notContains":{const J=f(s(D.value,q),B),ne=re=>re==null?!1:f(re,B).includes(J);return T==="contains"?ne:Q(ne)}case"startsWith":{const J=f(s(D.value,q),B);return ne=>ne==null?!1:f(ne,B).startsWith(J)}case"endsWith":{const J=f(s(D.value,q),B);return ne=>ne==null?!1:f(ne,B).endsWith(J)}case"matches":{const J=p(D.value,B);return J?ne=>ne==null?!1:J.test(String(ne)):()=>!1}case"blank":return J=>R(J)||Array.isArray(J)&&J.length===0;case"notBlank":return J=>!(R(J)||Array.isArray(J)&&J.length===0);case"containsAny":case"containsNone":{const J=g(D.value,B,q),ne=re=>{const oe=re==null?[]:$(re);for(let ie=0;ie<oe.length;ie++)if(J.has(h(oe[ie],B)))return!0;return!1};return T==="containsAny"?ne:Q(ne)}case"containsAll":{const J=$(D.value).map(ne=>h(s(ne,q),B));return ne=>{const re=ne==null?[]:$(ne);if(J.length===0)return!0;const oe=new Set(re.map(ie=>h(ie,B)));for(let ie=0;ie<J.length;ie++)if(!oe.has(J[ie]))return!1;return!0}}default:return L(`op:${String(T)}`,`unknown filter operator "${String(T)}"; the condition passes every row`),()=>!0}}function v(D,j,T){return m(j,T)(D)}function a(D,j,T,B){const q=k(D);if(q){const J=j?1:0;for(let ne=0;ne<B;ne++)T[ne]=q(ne)===J?1:0;return T}const X=D.kind;if(X==="float64"||X==="int32"||X==="bitset")return n(T,B,j?1:0);const Q=y(D);for(let J=0;J<B;J++){const ne=Q(J),re=R(ne)||Array.isArray(ne)&&ne.length===0;T[J]=re===j?0:1}return T}function o(D,j,T,B){const q=D.dict,X=z(q),Q=new Uint8Array(X);for(let oe=0;oe<X;oe++)Q[oe]=j(F(q,oe))?1:0;const J=D.values,ne=k(D);if(!ne){for(let oe=0;oe<B;oe++)T[oe]=Q[J[oe]];return T}const re=j(null)?1:0;for(let oe=0;oe<B;oe++)T[oe]=ne(oe)===1?Q[J[oe]]:re;return T}function S(D,j,T,B){const q=U(D.values),X=j(!0)?1:0,Q=j(!1)?1:0,J=k(D);if(!J){for(let re=0;re<B;re++)T[re]=q(re)===1?X:Q;return T}const ne=j(null)?1:0;for(let re=0;re<B;re++)T[re]=J(re)===0?ne:q(re)===1?X:Q;return T}function E(D,j,T,B,q){const X=D.values,Q=j.type,J=j.op;let ne=!0;switch(J){case"eq":case"ne":{const oe=u(s(j.value,Q)),ie=typeof j.value=="number"&&Number.isNaN(j.value),te=J==="ne"?1:0;if(ie)for(let ce=0;ce<q;ce++)B[ce]=(Number.isNaN(X[ce])?1:0)^te;else for(let ce=0;ce<q;ce++)B[ce]=(X[ce]===oe?1:0)^te;break}case"lt":{const oe=u(s(j.value,Q));for(let ie=0;ie<q;ie++)B[ie]=X[ie]<oe?1:0;break}case"lte":{const oe=u(s(j.value,Q));for(let ie=0;ie<q;ie++)B[ie]=X[ie]<=oe?1:0;break}case"gt":{const oe=u(s(j.value,Q));for(let ie=0;ie<q;ie++)B[ie]=X[ie]>oe?1:0;break}case"gte":{const oe=u(s(j.value,Q));for(let ie=0;ie<q;ie++)B[ie]=X[ie]>=oe?1:0;break}case"between":case"notBetween":{const oe=$(j.value),ie=u(s(oe[0],Q)),te=u(s(oe[1],Q)),ce=j.bounds||"[]",ue=ce.charAt(0)!=="(",ae=ce.charAt(1)!==")",pe=J==="notBetween"?1:0;if(ue&&ae)for(let he=0;he<q;he++)B[he]=(X[he]>=ie&X[he]<=te?1:0)^pe;else if(ue)for(let he=0;he<q;he++)B[he]=(X[he]>=ie&X[he]<te?1:0)^pe;else if(ae)for(let he=0;he<q;he++)B[he]=(X[he]>ie&X[he]<=te?1:0)^pe;else for(let he=0;he<q;he++)B[he]=(X[he]>ie&X[he]<te?1:0)^pe;break}case"in":case"notIn":{const oe=new Set;for(const te of $(j.value)){const ce=u(s(te,Q));Number.isNaN(ce)||oe.add(ce)}const ie=J==="notIn"?1:0;for(let te=0;te<q;te++)B[te]=(oe.has(X[te])?1:0)^ie;break}default:ne=!1;break}if(!ne)return!1;const re=k(D);if(re){const oe=T(null)?1:0;for(let ie=0;ie<q;ie++)re(ie)===0&&(B[ie]=oe)}return!0}function A(D,j,T,B){const q=y(D);for(let X=0;X<B;X++)T[X]=j(q(X))?1:0;return T}function M(D,j,T){const B=j.count|0,q=T||r(j,B);if(!D)return n(q,B,1);const X=typeof j.handle=="function"?j.handle(D.col):void 0,Q=typeof j.custom=="function"?j.custom:null;if(!X){if(Q){for(let re=0;re<B;re++)q[re]=Q(D,re)?1:0;return q}return L(`filter:col:${String(D.col)}`,`filter references unknown column "${String(D.col)}"; the condition passes every row`),n(q,B,1)}const J=D.op;if(J==="blank"||J==="notBlank")return a(X,J==="notBlank",q,B);const ne=m(D,j.locale);switch(X.kind){case"dictionary":return o(X,ne,q,B);case"bitset":return S(X,ne,q,B);case"float64":case"int32":return E(X,D,ne,q,B)?q:A(X,ne,q,B);default:return A(X,ne,q,B)}}function C(D,j,T){if(!D)return n(r(j,T),T,1);if(Array.isArray(D.conditions)){const B=D.conditions.filter(Q=>Q!=null),q=D.op==="or"?"or":D.op==="not"?"not":"and";if(B.length===0)return n(r(j,T),T,1);const X=C(B[0],j,T);for(let Q=1;Q<B.length;Q++){const J=C(B[Q],j,T);if(q==="or")for(let ne=0;ne<T;ne++)X[ne]|=J[ne];else for(let ne=0;ne<T;ne++)X[ne]&=J[ne];t(j,J)}if(q==="not")for(let Q=0;Q<T;Q++)X[Q]^=1;return X}return M(D,j,r(j,T))}function P(D,j){return C(D,j,j.count|0)}function x(D,j){if(!D||!j)return D||null;const T=D;if(Array.isArray(T.conditions)){if((T.op==="or"?"or":T.op==="not"?"not":"and")!=="and")return K(T,j)?null:D;const q=[];for(const X of T.conditions){const Q=x(X,j);Q&&q.push(Q)}return q.length?{...T,op:"and",conditions:q}:null}return T.col===j?null:D}function K(D,j){if(!D||typeof D!="object")return!1;const T=D;if(T.col===j)return!0;if(Array.isArray(T.conditions)){for(const B of T.conditions)if(K(B,j))return!0}return!1}function I(D,j,T){if(T&&T.length>=j){let Q=0;for(let J=0;J<j;J++)D[J]&&(T[Q++]=J);return T.subarray(0,Q)}let B=0;for(let Q=0;Q<j;Q++)B+=D[Q]?1:0;const q=new Uint32Array(B);let X=0;for(let Q=0;Q<j;Q++)D[Q]&&(q[X++]=Q);return q}}),ke("packages/core/src/compute/facet.js",function(e,V){"use strict";Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"orderedReader",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"toNumeric",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const _=V("packages/core/src/compute/handle.js"),R=_.presenceReader,$=_.valueReader,L=_.dictSize,W=_.dictValue,Z=Object.freeze(["equal","quantile","log"]),H=Object.freeze(["hour","day","week","month","quarter","year"]),U=20,z=50,F=1e4;function k(a,o){if(!a)return"none";const S=o&&o.base;if(S==="date"||S==="datetime"||S==="time"||S==="dateString")return"date";switch(a.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return S==="number"?"numeric":S==="boolean"?"boolean":S==="text"?"category":"none"}}function O(a){const o=a.values,S=a.kind;if((S==="float64"||S==="int32")&&o)return A=>o[A];const E=$(a);return A=>y(E(A))}function y(a){if(typeof a=="number")return a;if(a instanceof Date)return a.getTime();if(a==null||a==="")return NaN;if(typeof a=="boolean")return a?1:0;if(typeof a=="string"){const o=Number(a);if(Number.isFinite(o))return o;const S=Date.parse(a);return Number.isFinite(S)?S:NaN}return NaN}function d(a,o,S,E=z){if(!a)return{cardinality:0,exact:!0};if(a.dict)return{cardinality:L(a.dict),exact:!0};if(a.kind==="bitset")return{cardinality:2,exact:!0};const A=$(a),M=o?o.length:S,C=new Set;for(let P=0;P<M;P++){const x=A(o?o[P]:P);if(x!=null&&(C.add(x),C.size>E))return{cardinality:C.size,exact:!1}}return{cardinality:C.size,exact:!0}}const c=36e5,r=864e5;function t(a,o=U){const S=Number.isFinite(a)&&a>0?a:0,E=Math.max(1,o)*2;return S/c<=E?"hour":S/r<=E?"day":S/(7*r)<=E?"week":S/(30*r)<=E?"month":S/(91*r)<=E?"quarter":"year"}function n(a,o){if(!Number.isFinite(a))return NaN;const S=new Date(a);switch(o){case"hour":return S.setMinutes(0,0,0),S.getTime();case"day":return S.setHours(0,0,0,0),S.getTime();case"week":{S.setHours(0,0,0,0);const E=(S.getDay()+6)%7;return S.setDate(S.getDate()-E),S.getTime()}case"month":return S.setDate(1),S.setHours(0,0,0,0),S.getTime();case"quarter":return S.setMonth(Math.floor(S.getMonth()/3)*3,1),S.setHours(0,0,0,0),S.getTime();default:return S.setMonth(0,1),S.setHours(0,0,0,0),S.getTime()}}function i(a,o){const S=new Date(a);switch(o){case"hour":S.setHours(S.getHours()+1);break;case"day":S.setDate(S.getDate()+1);break;case"week":S.setDate(S.getDate()+7);break;case"month":S.setMonth(S.getMonth()+1);break;case"quarter":S.setMonth(S.getMonth()+3);break;default:S.setFullYear(S.getFullYear()+1);break}return S.getTime()}function s(a,o,S){const E=O(a),A=R(a),M=o?o.length:S;let C=1/0,P=-1/0,x=0,K=0;for(let I=0;I<M;I++){const D=o?o[I]:I;if(A&&!A(D)){x++;continue}const j=E(D);if(!Number.isFinite(j)){x++;continue}j<C&&(C=j),j>P&&(P=j),K++}return{min:C,max:P,nulls:x,finite:K}}function l(a,o,S,E){const A=O(a),M=R(a),C=o?o.length:S,P=C>E?C/E:1,x=[];for(let I=0;I<C;I+=P){const D=o?o[Math.floor(I)]:Math.floor(I);if(M&&!M(D))continue;const j=A(D);Number.isFinite(j)&&x.push(j)}const K=Float64Array.from(x);return K.sort(),K}function u(a,o,S,E={}){const A=E.kind||k(a,E.type);return A==="none"||!a?{kind:"none",buckets:[],suppressed:"type"}:A==="boolean"?f(a,o,S):A==="category"?h(a,o,S,E):g(a,o,S,A,E)}function f(a,o,S){const E=R(a);let A=0;if(E){const C=o?o.length:S;for(let P=0;P<C;P++)E(o?o[P]:P)||A++}const M=[{value:!1,label:"false"},{value:!0,label:"true"}];return A>0&&M.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:M}}function h(a,o,S,E){const A=E.cardinalityLimit??z,{cardinality:M}=d(a,o,S,A);if(M>A&&(E.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:M};const C=$(a),P=o?o.length:S,x=new Map;let K=0;for(let B=0;B<P;B++){const q=C(o?o[B]:B);if(q==null||q===""){K++;continue}if(Array.isArray(q)){if(!q.length){K++;continue}for(const X of q)x.set(X,(x.get(X)||0)+1);continue}x.set(q,(x.get(q)||0)+1)}let I=[...x.entries()];E.order==="alpha"?I.sort((B,q)=>String(B[0]).localeCompare(String(q[0]))):I.sort((B,q)=>q[1]-B[1]);let D=0,j=0;if(I.length>A){j=I.length-A;for(let B=A;B<I.length;B++)D+=I[B][1];I=I.slice(0,A)}const T=I.map(([B])=>({value:B,label:String(B)}));return D>0&&T.push({remainder:!0,label:`Other (${j} values)`}),K>0&&T.push({null:!0,label:"Empty"}),{kind:"category",buckets:T,cardinality:M}}function g(a,o,S,E,A){const{min:M,max:C,nulls:P,finite:x}=s(a,o,S);if(!x)return{kind:E,buckets:P?[{null:!0,label:"Empty"}]:[],empty:!0};const K=Math.max(1,Math.floor(A.buckets||U));let I=[];if(E==="date"){const j=H.includes(A.granularity)?A.granularity:t(C-M,K);let T=n(M,j);for(;T<=C&&I.length<4096;){const B=i(T,j);if(!(B>T))break;I.push({from:T,to:B}),T=B}return{kind:E,buckets:b(I,P),granularity:j}}const D=Z.includes(A.strategy)?A.strategy:"equal";if(D==="quantile"){const j=l(a,o,S,F);if(j.length){const T=[j[0]];for(let B=1;B<K;B++){const q=j[Math.min(j.length-1,Math.floor(B/K*j.length))];q>T[T.length-1]&&T.push(q)}T.push(C);for(let B=0;B<T.length-1;B++)I.push({from:T[B],to:T[B+1]})}}else if(D==="log"&&M>0){const j=Math.log10(M),B=(Math.log10(C)-j)/K||1;for(let q=0;q<K;q++)I.push({from:10**(j+q*B),to:10**(j+(q+1)*B)})}if(!I.length){const j=(C-M)/K||1;for(let T=0;T<K;T++)I.push({from:M+T*j,to:M+(T+1)*j})}return I[I.length-1].to=C,{kind:E,buckets:b(I,P),strategy:D,min:M,max:C}}function b(a,o){return o>0?[...a,{null:!0,label:"Empty"}]:a}function p(a,o,S,E,A){const M=E&&E.buckets||[],C=A&&A.length>=M.length?A.subarray(0,M.length):new Uint32Array(M.length);if(C.fill(0),!a||!M.length)return C;const P=M.length-1,x=!!M[P]&&M[P].null===!0,K=o?o.length:S;if(E.kind==="boolean"){const B=$(a);for(let q=0;q<K;q++){const X=B(o?o[q]:q);if(X==null){x&&C[P]++;continue}C[X?1:0]++}return C}if(E.kind==="category"){const B=new Map;for(let Q=0;Q<M.length;Q++)!M[Q].null&&!M[Q].remainder&&B.set(M[Q].value,Q);const q=M.findIndex(Q=>Q.remainder),X=$(a);for(let Q=0;Q<K;Q++){const J=X(o?o[Q]:Q);if(J==null||J===""){x&&C[P]++;continue}if(Array.isArray(J)){if(!J.length){x&&C[P]++;continue}for(const re of J){const oe=B.get(re);oe!==void 0?C[oe]++:q>=0&&C[q]++}continue}const ne=B.get(J);ne!==void 0?C[ne]++:q>=0&&C[q]++}return C}const I=x?M.length-1:M.length,D=new Float64Array(I+1);for(let B=0;B<I;B++)D[B]=M[B].from;D[I]=I?M[I-1].to:0;const j=O(a),T=R(a);for(let B=0;B<K;B++){const q=o?o[B]:B;if(T&&!T(q)){x&&C[P]++;continue}const X=j(q);if(!Number.isFinite(X)){x&&C[P]++;continue}const Q=m(D,I,X);Q>=0&&C[Q]++}return C}function m(a,o,S){if(!o||S<a[0])return-1;if(S>=a[o])return S===a[o]?o-1:-1;let E=0,A=o-1;for(;E<A;){const M=E+A+1>>>1;S>=a[M]?E=M:A=M-1}return E}function w(a,o,S,E={}){const A=E.bounds||u(a,E.boundsIndices??o,S,E);return{bounds:A,counts:p(a,o,S,A)}}const v=w}),ke("packages/core/src/compute/pivotmatrix.js",function(e,V){"use strict";Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return n}});const R=V("packages/core/src/compute/handle.js").valueComparator,L=V("packages/core/src/compute/total.js").total,Z=V("packages/core/src/compute/group.js").packKeys,H=V("packages/core/src/compute/pivot.js"),U=H.joinPath,z=H.DEFAULT_PATH_SEPARATOR,F=H.DEFAULT_MAX_COLUMNS,k="";function O(i,s,l={}){const u=l.separator||z,f=i||[],h=s instanceof Uint32Array?s:Uint32Array.from(s||[]),g=h.length;if(f.length===0)return{tuples:[[]],paths:[k],buckets:[h]};const{keyOf:b,readers:p}=Z(f,h,0),m=new Map,w=[],v=[],a=[];for(let C=0;C<g;C++){const P=h[C],x=b(P);let K=m.get(x);if(K===void 0){K=w.length,m.set(x,K),v.push(x);const I=new Array(p.length);for(let D=0;D<p.length;D++)I[D]=p[D](P);w.push(I),a.push([])}a[K].push(P)}const o=R(l.locale),S=w.map((C,P)=>P);S.sort((C,P)=>{const x=w[C],K=w[P];for(let I=0;I<x.length;I++){const D=y(x[I],K[I],o);if(D!==0)return D}return C-P});const E=new Array(S.length),A=new Array(S.length),M=new Array(S.length);for(let C=0;C<S.length;C++){const P=S[C];E[C]=w[P],A[C]=U(w[P],u),M[C]=Uint32Array.from(a[P])}return{tuples:E,paths:A,buckets:M}}function y(i,s,l){const u=i==null,f=s==null;return u||f?u&&f?0:u?1:-1:l(i,s)}function d(i,s,l){const u=[];for(let f=0;f<i.length;f++)l.has(i[f])&&u.push(i[f]);return Uint32Array.from(u)}function c(i,s,l,u){return{value:s.length?L(i,s,l,u):null,leaves:s,count:s.length}}function r(i){const s=i&&i.opts||{},l=s.separator||z,u=s.totalContext||{locale:s.locale},f=(i.measures||[]).filter(A=>A&&A.handle),h=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),g=O(i.rowHandles||[],h,{...s,separator:l}),b=O(i.columnHandles||[],h,{...s,separator:l}),p=s.maxColumns===void 0?F:s.maxColumns,m=b.paths.length*Math.max(1,f.length),w=new Map;if(p&&m>p)return{rowAxis:g,columnAxis:b,measures:f.map(A=>({colId:A.colId,fn:A.fn})),body:w,rowMargin:w,columnMargin:w,grand:w,columns:m,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${m} columns, above pivot.maxColumns of ${p}. Narrow the pivot columns or raise the limit.`,columns:m,maxColumns:p}};const v=new Map,a=new Map,o=new Map,S=new Map,E=b.buckets.map(A=>new Set(A));for(let A=0;A<b.paths.length;A++){const M=b.buckets[A],C=b.paths[A];for(const P of f)o.set(n(C,P.colId),c(P.handle,M,P.fn,u))}for(let A=0;A<g.paths.length;A++){const M=g.buckets[A],C=g.paths[A];for(const P of f)a.set(n(C,P.colId),c(P.handle,M,P.fn,u));for(let P=0;P<b.paths.length;P++){const x=d(M,b.buckets[P],E[P]);if(x.length===0)continue;const K=b.paths[P];for(const I of f)v.set(t(C,K,I.colId),c(I.handle,x,I.fn,u))}}for(const A of f)S.set(A.colId,c(A.handle,h,A.fn,u));return{rowAxis:g,columnAxis:b,measures:f.map(A=>({colId:A.colId,fn:A.fn})),body:v,rowMargin:a,columnMargin:o,grand:S,columns:m,error:null}}function t(i,s,l){return`${i}\0${s}\0${l}`}function n(i,s){return`${i}\0${s}`}}),ke("packages/core/src/compute/reference.js",function(e,V){"use strict";Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return r}});const R=V("packages/core/src/internal/util.js").getPath,$=V("packages/core/src/compute/handle.js"),L=$.isMissing,W=$.valueComparator,H=V("packages/core/src/compute/filter.js").testValue,U="",z="\0";function F(i,s){const l=s.includes(".")?R(i,s):i?.[s];return l===void 0?null:l}function k(i,s,l={}){const u=s||[];let f=i.map((h,g)=>g);if(u.length===0)return f;for(let h=u.length-1;h>=0;h--)f=O(i,f,u[h],l);return f}function O(i,s,l,u){const f=l.locale!==void 0?l.locale:u.locale,h=W(f),g=l.descending!==void 0?!!l.descending:l.dir==="desc",b=[],p=[];for(const v of s){const a=F(i[v],l.col);L(a)?p.push(v):b.push(v)}const m=new Map;for(let v=0;v<b.length;v++)m.set(b[v],v);const w=(v,a)=>{const o=F(i[v],l.col),S=F(i[a],l.col);let E;return typeof l.compare=="function"?(E=l.compare(o,S,i[v],i[a],g),g&&(E=-E)):E=g?h(S,o):h(o,S),E!==0?E:m.get(v)-m.get(a)};return b.sort(w),l.nullsFirst?p.concat(b):b.concat(p)}function y(i,s,l={}){const u=[];for(let f=0;f<i.length;f++)d(i[f],s,l,f)&&u.push(f);return u}function d(i,s,l,u){if(!s)return!0;if(Array.isArray(s.conditions)){const f=s.conditions.filter(g=>g!=null);if(f.length===0)return!0;if(s.op==="or")return f.some(g=>d(i,g,l,u));const h=f.every(g=>d(i,g,l,u));return s.op==="not"?!h:h}return s.col===void 0&&typeof l.custom=="function"?!!l.custom(s,i,u):H(F(i,s.col),s,l.locale)}function c(i,s,l,u){const f=l||i.map((p,m)=>m),h=new Map,g=[],b=[];for(const p of f){const m=s.map((a,o)=>{const S=F(i[p],a);return u&&u[o]?u[o](S):S}),w=m.map(a=>a==null?z:String(a)).join(U);let v=h.get(w);v===void 0&&(v=g.length,h.set(w,v),g.push(m),b.push([])),b[v].push(p)}return{keys:g,buckets:b}}function r(i,s,l={}){const u=W(l.locale),f=i.filter(g=>!L(g)),h=f.map(t).filter(g=>g!==null);switch(s){case"count":return i.length;case"countValues":return f.length;case"sum":return h.reduce((g,b)=>g+b,0);case"avg":return f.length===0?null:h.reduce((g,b)=>g+b,0)/f.length;case"min":return f.length===0?null:f.reduce((g,b)=>u(b,g)<0?b:g);case"max":return f.length===0?null:f.reduce((g,b)=>u(b,g)>0?b:g);case"first":return i.length===0?null:n(i[0]);case"last":return i.length===0?null:n(i[i.length-1]);default:return null}}function t(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 n(i){return i===void 0?null:i}}),ke("packages/core/src/compute/index.js",function(e,V){"use strict";const _=V("packages/core/src/compute/sort.js");Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return _.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return _.sortMulti}}),Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return _.radixSortFloat64}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return _.radixSortInt32}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return _.rankSortDictionary}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return _.mergeSortComparator}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return _.collateStringRanks}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return _.rankSortStrings}});const R=V("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return R.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return R.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return R.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return R.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return R.describeSort}});const $=V("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 L=V("packages/core/src/compute/group.js");Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return L.groupByColumns}}),Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return L.packKeys}});const W=V("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=V("packages/core/src/compute/total.js");Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return Z.TOTAL_FNS}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return Z.TOTAL_LABELS}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return Z.totalLabel}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return Z.total}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return Z.collectValues}});const H=V("packages/core/src/compute/pivot.js");Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return H.pivot}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return H.resolvePivotKeys}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return H.pivotKey}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return H.joinPath}}),Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return H.KEY_DELIMITER}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return H.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return H.DEFAULT_MAX_COLUMNS}});const U=V("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 z=V("packages/core/src/compute/reference.js");Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return z.referenceSort}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return z.referenceFilter}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return z.referenceGroup}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return z.referenceTotal}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return z.referencePasses}}),Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return z.referenceValue}});const F=V("packages/core/src/compute/handle.js");Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return F.identity}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return F.rowCount}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return F.presenceReader}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return F.bitReader}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return F.valueReader}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return F.valueComparator}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return F.numericTotalOrder}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return F.dictRanks}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return F.dictSize}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return F.dictValue}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return F.multiValue}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return F.isMissing}});const k=V("packages/core/src/compute/sketch.js");Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return k.Welford}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return k.Reservoir}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return k.HyperLogLog}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return k.SpaceSaving}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return k.KLL}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return k.hash32}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return k.SKETCH_BOUNDS}});const O=V("packages/core/src/compute/windowed.js");Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return O.Window}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return O.WINDOW_KINDS}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return O.openWindow}});const y=V("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 d=V("packages/core/src/compute/anomaly.js");Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return d.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return d.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return d.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return d.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return d.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return d.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return d.anomalyCondition}});const c=V("packages/core/src/compute/forecast.js");Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return c.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return c.forecast}})}),ke("packages/core/src/source/rows.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_ROW_HEIGHT",{enumerable:!0,get:function(){return L}}),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 H}}),Object.defineProperty(e,"pinnedRow",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"lazyRowView",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"groupPathElement",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"groupKey",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"groupPrefixKeys",{enumerable:!0,get:function(){return d}});const _=V("packages/core/src/internal/util.js"),R=_.warnOnce,$=_.isFunction,L=32,W="\0";function Z(c){return new H(c)}class H{#e;#t;constructor(r){this.#e=$(r&&r.rowKey)?r.rowKey:null;const t=r&&r.config?r.config.rowHeight:void 0;this.#t=typeof t=="number"||$(t)?t:L}get keyed(){return this.#e!==null}keyOf(r,t){if(this.#e){const n=this.#e(r);if(n!=null)return String(n)}else R("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(r){return $(this.#t)?Number(this.#t(r))||L:this.#t}leaf(r,t,n=0,i=null){const s={key:this.keyOf(r,t),data:r,level:n,parent:i,group:!1,expanded:!1,leafCount:1,height:0,index:null,selected:!1,physical:t};return s.height=this.heightOf(s),s}group(r){const t={key:y(r.keyPath||r.path),data:null,level:r.level,parent:r.parent||null,children:[],group:!0,expanded:r.expanded!==!1,leafCount:r.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:r.column,groupValue:r.value,groupPath:r.path,hasChildren:r.hasChildren!==!1};return r.totals&&(t.totals=r.totals),t.height=this.heightOf(t),t}footer(r){const t={key:`${r.key}${W}footer`,data:null,level:r.level,parent:r,group:!0,footer:!0,expanded:!1,leafCount:r.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:r.groupColumn,groupValue:r.groupValue,groupPath:r.groupPath,hasChildren:!1,totals:r.totals};return t.height=this.heightOf(t),t}detail(r,t){return{key:`${r.key}${W}detail`,data:r.data,level:r.level+1,parent:r,group:!1,detail:!0,expanded:!1,leafCount:0,height:t,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:r.key}}grandTotal(r,t){const n={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:r};return n.height=this.heightOf(n),n}skeleton(r,t=0){const n={key:`${W}pending${W}${r}`,data:null,level:t,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:r,selected:!1,physical:null};return n.height=this.heightOf(n),n}}function U(c,r,t,n){return{key:`${W}pinned${W}${t}${W}${r}`,data:c,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:n,index:null,selected:!1,physical:null,hasChildren:!1,pinned:t}}function z(c,r){return new Proxy([],{get(t,n,i){if(n==="length")return c();if(typeof n=="string"){const s=Number(n);if(Number.isInteger(s)&&s>=0)return r(s)}return Reflect.get(t,n,i)},has(t,n){if(typeof n=="string"){const i=Number(n);if(Number.isInteger(i)&&i>=0)return i<c()}return Reflect.has(t,n)}})}function F(c){return c==null?"":String(c)}const k="";function O(c){if(c==null)return k;const r=String(c);return r.startsWith(k)?k+r:r}function y(c){const r=c||[];let t="g";for(let n=0;n<r.length;n++)t+=W+O(r[n]);return t}function d(c){const r=new Array(c.length),t=[];for(let n=0;n<c.length;n++)t.push(c[n]),r[n]=y(t);return r}}),ke("packages/core/src/source/handles.js",function(e,V){"use strict";Object.defineProperty(e,"HandleProvider",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"createHandleProvider",{enumerable:!0,get:function(){return W}});const _=V("packages/core/src/internal/util.js"),R=_.isFunction,$=_.warnOnce;class L{#e;#t;#n;#r=new Map;#o=0;constructor(H,U,z){this.#e=H,this.#t=U,this.#n=R(z)?z:()=>!1}get store(){const H=this.#e.store;return H&&R(H.column)?H:null}invalidate(){this.#o++}handle(H){const U=this.store;if(U){const O=U.column(H);if(O)return O}const z=this.#r.get(H);if(z&&z.builtAt===this.#o)return z.handle;const F=this.#i(H);if(!F)return;if(U&&this.#n()){$(`source.dropped.${H}`,`column "${H}" cannot be served under ingest.dropSourceRows: it is an impure computed column (a shadow or a positional/rank column) that is never stored, so it can only be read from the caller's row objects — which dropSourceRows has released. Do not sort, filter, group or total on such a column with dropSourceRows enabled.`);return}const k=this.#a(F);return this.#r.set(H,{handle:k,builtAt:this.#o}),k}#i(H){const U=this.#e.columns;return U&&R(U.get)?U.get(H):void 0}#a(H){const U=this.#t()||[],z=U.length,F=new Array(z),k=R(H.getValue)?y=>H.getValue(y):y=>y?.[H.field||H.id];for(let y=0;y<z;y++)F[y]=U[y]===void 0?void 0:k(U[y]);const O=this.#o;return{id:H.id,kind:"object",nullable:!1,values:F,presence:null,dict:null,offsets:null,get(y){return F[y]},version:O}}}function W(Z,H,U){return new L(Z,H,U)}}),ke("packages/core/src/compute/incremental.js",function(e,V){"use strict";Object.defineProperty(e,"INCREMENTAL_FNS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"INCREMENTAL_KINDS",{enumerable:!0,get:function(){return L}}),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 z}});const R=V("packages/core/src/store/columnstore.js").toFloat,$=Object.freeze(["sum","avg","countValues","min","max"]),L=Object.freeze(["float64"]),W=1e15;function Z(F,k){return typeof F!="string"||!$.includes(F)?!1:!!k&&L.includes(k.kind)}function H(F){if(F==null)return null;const k=R(F);return Number.isNaN(k)?null:k}class U{#e;#t=0;#n=0;#r=0;#o=1/0;#i=-1/0;#a=!1;#s=!1;constructor(k){this.#e=k}get valid(){return this.#a&&!this.#s}get fn(){return this.#e}seed(k){this.#l();for(let O=0;O<k.length;O++){const y=H(k[O]);y!==null&&this.#u(y)}this.#a=!0}seedColumn(k,O,y){this.#l();for(let d=0;d<y.length;d++){const c=y[d];if(O&&O(c)===0)continue;const r=k[c];Number.isNaN(r)||this.#u(r)}this.#a=!0}#l(){this.#t=0,this.#n=0,this.#r=0,this.#o=1/0,this.#i=-1/0,this.#s=!1}#u(k){if(!Number.isFinite(k)){this.#s=!0;return}const O=this.#t+k;this.#n+=Math.abs(this.#t)>=Math.abs(k)?this.#t-O+k:k-O+this.#t,this.#t=O,this.#r++,k<this.#o&&(this.#o=k),k>this.#i&&(this.#i=k)}#c(k){const O=this.#t-k;this.#n+=Math.abs(this.#t)>=Math.abs(k)?this.#t-O-k:-k-O+this.#t,this.#t=O,this.#r--}update(k,O){if(!this.#a)return!1;const y=H(k),d=H(O);return y===null&&d===null?!0:y!==null&&!Number.isFinite(y)||d!==null&&!Number.isFinite(d)?!1:this.#e==="min"||this.#e==="max"?y===null||d===null?!1:this.#e==="min"?d<this.#o?(this.#o=d,!0):y>this.#o:d>this.#i?(this.#i=d,!0):y<this.#i:Math.abs(this.#t)>W?!1:(y!==null&&this.#c(y),d!==null&&this.#u(d),!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.#a=!1}}const z=U}),ke("packages/core/src/source/filterwire.js",function(e,V){"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 L}}),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 H}}),Object.defineProperty(e,"warnWhereNotApplied",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"warnWhereOverThreshold",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"parseRelativeToken",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"resolveRelativeRange",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"relativeTokenOf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"relativeTokenHelp",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isResolvableRelative",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"resolveRelativeCondition",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"isGroup",{enumerable:!0,get:function(){return g}}),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 v}}),Object.defineProperty(e,"wireFilters",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"querySignature",{enumerable:!0,get:function(){return o}});const R=V("packages/core/src/internal/util.js").warnOnce,$="source.remote.hostFilter",L="source.where.pageRelative";function W(A,M){!Array.isArray(A)||!A.length||R(L,`filters.where (${A.join(", ")}) runs over the rows the ${M} 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(A){const M=(A||{}).config;!M||!M.hostFilter||R($,"config.hostFilter is not sent to a server-delegated source (paged/remote) and is not applied:","filtering only the fetched window would give wrong counts and totals.","Express the filter as a FilterSet condition, or send it through config.context.")}const H="source.where.notApplied";function U(A,M){R(`${H}:${A}`,`filters.where("${A}") is registered but the ${M} 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 z="source.where.overThreshold";function F(A,M,C,P){!Array.isArray(A)||!A.length||R(`${z}:${M}`,`filters.where (${A.join(", ")}) is not applied to the ${M} pushdown source:`,C===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${C.toLocaleString()} rows, at or past the whereRowLimit of ${P.toLocaleString()}.`,"Running the predicate needs every matching row fetched and held here, which is the whole","download a pushdown source exists to avoid, so it is refused and the rows the predicate","would exclude stay on screen.","Give the predicate a { condition } twin so the engine narrows the fetch itself — that is the","route that works at any size — or raise `whereRowLimit` on the source config if you want the","download.")}const k=new Map;function O(A){let M=k.get(A);return M||(M=new Intl.DateTimeFormat("en-US",{timeZone:A,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),k.set(A,M)),M}function y(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function d(A,M){const C=O(M).formatToParts(new Date(A)),P={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const x of C)x.type==="year"?P.y=+x.value:x.type==="month"?P.m=+x.value:x.type==="day"?P.d=+x.value:x.type==="hour"?P.h=+x.value%24:x.type==="minute"?P.mi=+x.value:x.type==="second"&&(P.s=+x.value);return P}function c(A,M){const C=d(A,M);return Date.UTC(C.y,C.m-1,C.d,C.h,C.mi,C.s)-Math.floor(A/1e3)*1e3}function r(A,M,C,P){const x=Date.UTC(A,M-1,C),K=x-c(x,P);return x-c(K,P)}function t(A,M,C){const P=new Date(Date.UTC(A.y,A.m-1,A.d+M));return r(P.getUTCFullYear(),P.getUTCMonth()+1,P.getUTCDate(),C)}const n=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function i(A,M){if(typeof A!="string")return null;const C=A.trim().toLowerCase().replace(/[\s_-]+/g,""),P=/^last(\d*|n)days?$/.exec(C);if(P){const x=P[1]==="n"?"":P[1],K=Number(x||M);return!Number.isFinite(K)||K<=0?null:{kind:"lastNDays",n:Math.floor(K)}}switch(C){case"today":return{kind:"today",n:0};case"yesterday":return{kind:"yesterday",n:0};case"thisweek":return{kind:"thisWeek",n:0};case"thismonth":return{kind:"thisMonth",n:0};case"thisquarter":return{kind:"thisQuarter",n:0};case"thisyear":return{kind:"thisYear",n:0};case"quartertodate":case"qtd":return{kind:"quarterToDate",n:0};case"yeartodate":case"ytd":return{kind:"yearToDate",n:0};default:return null}}function s(A,M={}){const C=i(A,M.n);if(!C)return null;const P=M.tz||y(),x=M.now instanceof Date?M.now.getTime():typeof M.now=="number"?M.now:Date.now(),K=d(x,P),I=r(K.y,K.m,K.d,P),D=t(K,1,P);let j=I,T=D;switch(C.kind){case"today":break;case"yesterday":j=t(K,-1,P),T=I;break;case"lastNDays":T=M.includeToday?D:I,j=t(K,M.includeToday?-(C.n-1):-C.n,P);break;case"thisWeek":{const B=Number.isFinite(M.weekStartsOn)?Number(M.weekStartsOn):1,X=(new Date(Date.UTC(K.y,K.m-1,K.d)).getUTCDay()-B+7)%7;j=t(K,-X,P),T=t(K,-X+7,P);break}case"thisMonth":j=r(K.y,K.m,1,P),T=r(K.m===12?K.y+1:K.y,K.m===12?1:K.m+1,1,P);break;case"thisQuarter":case"quarterToDate":{const B=Math.floor((K.m-1)/3)*3+1;j=r(K.y,B,1,P),T=C.kind==="quarterToDate"?D:B===10?r(K.y+1,1,1,P):r(K.y,B+3,1,P);break}case"thisYear":case"yearToDate":j=r(K.y,1,1,P),T=C.kind==="yearToDate"?D:r(K.y+1,1,1,P);break;default:return null}return{from:new Date(j).toISOString(),to:new Date(T).toISOString(),bounds:"[)",tz:P,relative:C.kind==="lastNDays"?`last${C.n}Days`:C.kind,n:C.n}}function l(A){if(!A||typeof A!="object")return null;const M=A.value;if(M&&typeof M=="object"&&!Array.isArray(M)&&"relative"in M)return{token:String(M.relative),n:typeof M.n=="number"?M.n:void 0};if(A.op==="relative"&&typeof A.value=="string")return{token:A.value,n:void 0};const C=A.meta;return C&&typeof C.relative=="string"&&A.value===void 0?{token:C.relative,n:typeof C.n=="number"?C.n:void 0}:null}function u(){return`Known tokens: ${n.filter(M=>M!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function f(A){const M=l(A);return M?i(M.token,M.n)!==null:!1}function h(A,M={}){const C=l(A);if(!C)return A;const P=s(C.token,{...M,n:C.n});return P?{...A,type:A.type||"date",op:"between",value:[P.from,P.to],bounds:A.bounds||P.bounds,meta:{...A.meta||{},relative:P.relative,tz:P.tz}}:(R(`source.relative.${C.token}`,`unknown relative date token "${C.token}"; sending the condition unresolved.`,u()),A)}function g(A){return!!A&&typeof A=="object"&&Array.isArray(A.conditions)}function b(A,M){if(A){if(g(A)){for(const C of A.conditions)b(C,M);return}M(A)}}function p(A,M){if(!A)return null;if(!g(A))return M(A);const C=A;let P=!1;const x=[];for(const K of C.conditions){const I=p(K,M);I!==K&&(P=!0),I&&x.push(I)}return!P&&x.length===C.conditions.length?A:x.length?{...C,conditions:x}:null}function m(A){if(!A)return null;if(!g(A))return A;const M=A,C=[];for(const P of M.conditions){const x=m(P);x&&C.push(x)}return C.length?{op:M.op,conditions:C}:null}function w(A){const M=m(A);return M?g(M)&&M.op==="and"?M:{op:"and",conditions:[M]}:null}function v(A){const M=(A||[]).filter(Boolean);return M.length?{op:"and",conditions:M}:null}function a(A,M={}){const C=p(A,P=>h(P,M));return w(C)}function o(A){const M=S(A.filters??null);return JSON.stringify([M,A.sort??null,A.quick??"",A.groupBy??null,A.pivotBy??null,E(A.context)])}function S(A){if(!A)return null;if(g(A)){const P=A;return{op:P.op,conditions:P.conditions.map(S)}}const M=A,C=M.meta&&typeof M.meta.relative=="string"?M.meta.relative:l(M)?.token;return{col:M.col,op:M.op,bounds:M.bounds??null,caseSensitive:M.caseSensitive??!1,value:C?`rel:${C}`:M.value??null}}function E(A){if(A==null)return null;try{return JSON.parse(JSON.stringify(A))}catch{return R("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),ke("packages/core/src/source/tree.js",function(e,V){"use strict";Object.defineProperty(e,"SYNTHETIC",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"buildFromPath",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"buildFromParentKey",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"assignLevels",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"resolveTree",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"buildTree",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return y}});const _=V("packages/core/src/internal/util.js"),R=_.isFunction,$=_.warnOnce,L="",W="\0tree:";function Z(d,c){return{physical:d,key:c,level:0,children:[],value:void 0}}function H(d,c){const r=[],t=new Map;for(let n=0;n<d.length;n++){const i=d[n],s=c.pathOf(i),l=Array.isArray(s)?s.map(f=>String(f)):[];if(!l.length){const f=Z(i,c.keyOf(i));r.push(f);continue}let u=null;for(let f=0;f<l.length;f++){const h=l.slice(0,f+1).join(L),g=f===l.length-1;let b=t.get(h);b&&g&&b.physical===-1&&(b.physical=i,b.key=c.keyOf(i)),b||(b=Z(g?i:-1,g?c.keyOf(i):W+h),b.level=f,b.value=l[f],t.set(h,b),u?u.children.push(b):r.push(b)),u=b}}return{roots:r,nodes:t}}function U(d,c){const r=new Map,t=[];for(let l=0;l<d.length;l++){const u=d[l],f=c.keyOf(u),h=Z(u,f);r.set(f,h);const g=c.parentOf(u);g!=null&&g!==""&&t.push({node:h,parent:String(g)})}let n=null;const i=new Map;for(const{node:l,parent:u}of t){const f=r.get(u);if(f){i.set(l.key,f);continue}c.orphans&&c.orphans!=="root"&&(n||(n=Z(-1,`${W}orphans`),n.value=c.orphans),i.set(l.key,n))}const s=[];for(const l of r.values()){const u=i.get(l.key);u?u.children.push(l):s.push(l)}return n&&n.children.length&&s.push(n),{roots:z(s,r,c.orphans,n),nodes:r}}function z(d,c,r,t){const n=new Set,i=[...d];for(;i.length;){const h=i.pop();if(!n.has(h.key)){n.add(h.key);for(const g of h.children)i.push(g)}}const s=[];for(const h of c.values())n.has(h.key)||s.push(h);if(!s.length)return d;const l=!!r&&r!=="root";$("tree.cycle",`tree.parentKey produced ${s.length} row(s) inside a parent cycle; `+(l?`they are shown under "${r}".`:"they are shown at the root."));for(const h of s)h.children=h.children.filter(g=>n.has(g.key));if(!l)return[...d,...s];let u=t;const f=[...d];return u||(u=Z(-1,`${W}orphans`),u.value=r,f.push(u)),u.children.push(...s),f}function F(d){let c=0;const r=(t,n)=>{for(const i of t)i.level=n,n>c&&(c=n),i.children.length&&r(i.children,n+1)};return r(d,0),c}function k(d,c){if(!d||typeof d!="object")return null;const r=d.path,t=d.parentKey,n=R(d.hasChildren)?i=>!!d.hasChildren(c.dataAt(i)):null;if(R(r))return{mode:"path",pathOf:i=>r(c.dataAt(i)),keyOf:c.keyOf,declaresChildren:n};if(t!=null){const i=R(t)?t:s=>s?.[t];return{mode:"parentKey",parentOf:s=>i(c.dataAt(s)),keyOf:c.keyOf,orphans:d.orphans||"root",declaresChildren:n}}return $("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function O(d,c){const r=c.mode==="path"?H(d,c):U(d,c),t=F(r.roots);return{...r,depth:t}}function y(d,c){const r=new Map,t=n=>{for(let i=0;i<n.length;i++){const s=n[i];if(s.physical>=0){const l=c?c(s.physical):!1,u=l&&s.children.length===0;r.set(s.physical,{level:s.level,posinset:i+1,setsize:n.length,hasChildren:s.children.length>0||l,lazy:u})}s.children.length&&t(s.children)}};return t(d),r}}),ke("packages/core/src/source/memory.js",function(e,V){"use strict";Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"quickMatcher",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"MemorySource",{enumerable:!0,get:function(){return I}});const _=V("packages/core/src/internal/util.js"),R=_.Lru,$=_.warnOnce,L=_.fail,W=_.isFunction,Z=_.defaultCompare,H=_.mergeRow,U=V("packages/core/src/source/rows.js"),z=U.createRowFactory,F=U.groupKey,k=U.groupPathElement,O=U.groupPrefixKeys,y=U.lazyRowView,c=V("packages/core/src/source/handles.js").createHandleProvider,r=V("packages/core/src/compute/incremental.js"),t=r.RunningTotal,n=r.isIncremental,s=V("packages/core/src/compute/handle.js").presenceReader,l=V("packages/core/src/source/filterwire.js"),u=l.querySignature,f=l.mapConditions,h=l.resolveRelativeCondition,g=V("packages/core/src/source/tree.js"),b=g.buildTree,p=g.resolveTree,m=g.indexTree,w=Object.freeze(["filter","sort","group","total","pivot","flatten"]),v=Object.freeze(["pipeline:sort","pipeline:sort:error"]);function a(D){const j=D&&typeof D=="object"?D.reason:null;return typeof j=="string"&&v.includes(j)}const o=Object.freeze([]);function S(D,j){if(!D)return null;const T=j==="grand"?D.grandTotal:D.groupTotal;return T??D.total}function E(D){return!!D&&!D.running}function A(D){if(D)return D.value&&W(D.value.compare)?D.value.compare:W(D.compare)?D.compare:void 0}function M(D){return!!D&&(typeof D=="object"||typeof D=="function")&&W(D.then)}const C=new Uint32Array(0),P=4096;function x(D,j){return new I(D,j)}function K(D,j){if(j==="regex")try{const T=new RegExp(D,"iu");return B=>T.test(B)}catch{return T=>T.includes(D)}if(j==="fuzzy"){const T=[...D].filter(B=>B!==" ");return T.length?B=>{let q=0;for(let X=0;X<B.length&&q<T.length;X++)B[X]===T[q]&&q++;return q===T.length}:()=>!0}if(j==="words"){const T=D.split(/\s+/).filter(Boolean);return T.length?B=>T.every(q=>B.includes(q)):()=>!0}return T=>T.includes(D)}class I{mode="memory";#e;#t;#n;#r=!1;#o=null;#i;#a;#s=new Map;#l=!1;#u=0;#c=0;#d=new Map;#h=new Map;#f;#m=null;#p=I.#g();static#g(){return{slots:[],groupHeadings:o,unnumbered:o,pivot:null,inlineLeaves:null,matchCount:0,grand:null,grandLeaves:0,groupLeaves:null}}#v=new Map;#b=null;#y=new Map;#w=-1;#S=[];#j=new Map;#A=-1;#O=[];#C=null;#E=null;#T=null;#x=null;#R=null;#N=null;#M=null;#_=null;#U=Symbol("unset");#F=new Map;#Y=null;get#D(){return this.#p.slots}set#D(j){this.#p.slots=j}get#Z(){return this.#p.inlineLeaves}set#Z(j){this.#p.inlineLeaves=j}get#te(){return this.#p.groupHeadings}set#te(j){this.#p.groupHeadings=j}get#le(){return this.#p.unnumbered}set#le(j){this.#p.unnumbered=j}get#se(){return this.#p.pivot}set#se(j){this.#p.pivot=j}constructor(j,T){this.#t=j||{mode:"memory"},this.#e=T||{};const B=this.#e.config||{};this.#n=this.#t.rows||B.rows||[],this.#i=z(this.#e),this.#a=c(this.#e,()=>this.#n,()=>this.#r),this.#f=new R(Number(B.rowCacheSize)||P);for(const q of w)this.#s.set(q,{key:null,result:null,id:0,computed:!1})}count(){this.#W();const j=this.#ne();return j?j.length:this.#D.length}#ne(){const j=Number(this.#B("pageSize",0))||0;if(j<=0)return null;const T=this.#D.length,B=Math.max(1,Math.ceil(T/j)),X=Math.min(Math.max(0,Number(this.#B("page",0))||0),B-1)*j;return{offset:X,length:Math.max(0,Math.min(j,T-X))}}pageInfo(){this.#W();const j=Number(this.#B("pageSize",0))||0,T=this.#D.length;if(j<=0)return{page:0,pageSize:0,total:T,pageCount:1};const B=Math.max(1,Math.ceil(T/j));return{page:Math.min(Math.max(0,Number(this.#B("page",0))||0),B-1),pageSize:j,total:T,pageCount:B}}totalCount(){return this.#Ae().length}matchCount(){return this.#W(),this.#p.matchCount}at(j){this.#W();const T=this.#ne();if(T)return j<0||j>=T.length?void 0:this.#pt(T.offset+j,j);if(!(j<0||j>=this.#D.length))return this.#pt(j,j)}byKey(j){this.#W(),this.#m||this.#X();const T=this.#m.get(j);if(T!==void 0)return this.#Pe(T);for(let B=0;B<this.#D.length;B++){const q=this.#D[B];if(typeof q!="number"&&q&&q.key===j)return this.#pt(B)}}loaded(j){return j>=0&&j<this.count()}hint(j,T){}display(){return this.#W(),this.#Y||(this.#Y=this.#Et()),this.#Y}invalidateQuickText(){this.#F.clear(),this.invalidate("filter")}invalidate(j){const T=w.indexOf(j);T<0&&L(`unknown pipeline stage "${j}"; expected one of ${w.join(", ")}`);for(let B=T;B<w.length;B++){const q=this.#s.get(w[B]);q.key=null,q.computed=!1}this.#Y=null}apply(j){const T=[],B={added:[],updated:[],removed:[],rejected:T};if(!j)return B;let q=!1;const X=new Set;if(j.remove&&j.remove.length)for(const Q of j.remove){const J=this.#we(Q);if(J===void 0){T.push({operation:"remove",id:this.#G(Q),reason:"unknown-id"});continue}B.removed.push(this.#i.keyOf(this.#r?this.#ze(J):this.#n[J],J)),this.#r||(this.#n[J]=void 0),this.#f.delete(J),this.#F.delete(J),q=!0}if(j.update&&j.update.length){const Q=this.#y.size||this.#nt()?this.#qe():null,J=this.#j.size?this.#bt():null,ne=J&&J.length?this.#qe():null;for(const re of j.update){const oe=this.#we(re);if(oe===void 0){T.push({operation:"update",id:this.#K(re),reason:"unknown-id"});continue}const ie=this.#r?this.#o&&this.#o.has(oe)?this.#o.get(oe):this.#ze(oe):this.#n[oe],te=H(ie,re);for(const ce of this.#Se(ie,te))X.add(ce);if(this.#r||(this.#n[oe]=te),Q&&this.#be(Q,oe,ie,te),ne&&this.#P(J,ne,oe,ie,te),this.#m){const ce=this.#i.keyOf(ie,oe),ue=this.#i.keyOf(te,oe);ce!==ue&&(this.#m.delete(ce),this.#m.set(ue,oe))}this.#f.delete(oe),this.#F.delete(oe),B.updated.push(this.#Pe(oe))}}if(j.add&&j.add.length&&this.#r){typeof j.at=="number"&&j.at<this.#mt()&&(this.#f.clear(),this.#F.clear()),this.#m=null;for(const Q of j.add){const J=this.#z(this.#K(Q));J!==void 0&&B.added.push(this.#Pe(J))}q=!0}else if(j.add&&j.add.length){const Q=typeof j.at=="number"?j.at:this.#n.length,J=this.#n.length;let ne=j.add===this.#n?j.add.slice():j.add;if(this.#i.keyed){const re=[];for(const oe of ne){const ie=this.#K(oe);if(this.#we(ie)!==void 0){T.push({operation:"add",id:ie,reason:"duplicate-id"});continue}re.push(oe)}re.length!==ne.length&&(ne=re)}if(!ne.length)return B;if(Q>=J)for(let re=0;re<ne.length;re++)this.#n.push(ne[re]);else this.#n.splice(Q,0,...ne),this.#f.clear(),this.#F.clear();for(let re=0;re<ne.length;re++)B.added.push(this.#Pe(Q>=J?J+re:Q+re));q=!0}return this.#u++,q&&(this.#m=null,this.#Be()),this.#a.invalidate(),this.#Y=null,q||this.#ve(X)?(this.#c++,this.invalidate("filter")):this.invalidate("total"),this.#Qe("rows:changed",{companion:!0,added:B.added.length,updated:B.updated.length,removed:B.removed.length}),this.#o=null,B}groupHeadingsAt(j){this.#W();const T=this.#te;if(!T.length||!Number.isInteger(j)||j<0)return o;let B=0,q=T.length-1,X=-1;for(;B<=q;){const J=B+q>>1;T[J].at<=j?(X=J,B=J+1):q=J-1}if(X<0)return o;const Q=[];for(let J=T[X].row;J;J=J.parent)Q.push(J);return Q.reverse(),Q}unnumberedRowCount(j){this.#W();const T=this.#le;if(!T.length||!Number.isInteger(j)||j<0)return 0;let B=0,q=T.length-1,X=-1;for(;B<=q;){const Q=B+q>>1;T[Q].at<=j?(X=Q,B=Q+1):q=Q-1}return X+1}moveRow(j,T){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 B=this.#n;if(!Number.isInteger(j)||!Number.isInteger(T)||j<0||j>=B.length)return!1;const q=Math.max(0,Math.min(B.length-1,T));if(q===j)return!1;const[X]=B.splice(j,1);return B.splice(q,0,X),this.#u++,this.#c++,this.#m=null,this.#f.clear(),this.#F.clear(),this.#Be(),this.#a.invalidate(),this.#Y=null,this.invalidate("filter"),this.#Qe("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(j){this.#ge(),this.#u++,this.#c++,this.#m=null,this.#F.clear(),this.#f.clear(),this.#Be(),this.#a.invalidate(),this.invalidate("filter"),this.#Qe("model:changed",{reason:"reload"})}destroy(){this.#ge(),this.#f.clear(),this.#F.clear(),this.#m=null,this.#D=[],this.#Z=null,this.#Y=null,this.#Be();for(const j of w)this.#s.set(j,{key:null,result:null,id:0,computed:!1})}#ge(){for(const{controller:j}of this.#v.values())try{j.abort()}catch{}this.#v.clear()}setRows(j){this.#n=j||[],this.#r=!1,this.#u++,this.#c++,this.#m=null,this.#F.clear(),this.#f.clear(),this.#Be(),this.#a.invalidate(),this.invalidate("filter")}notePriorRows(j){this.#o=j||null}releaseSource(){this.#r=!0,this.#n=[],this.#m=null,this.#f.clear(),this.#F.clear(),this.#a.invalidate()}data(){if(!this.#r)return this.#n;const j=this.#e.store;if(!j||!W(j.source))return this.#n;const T=j.physical||0,B=new Array(T);for(let q=0;q<T;q++)B[q]=j.live&&!j.live(q)?void 0:j.source(q);return B}#V(){const j=this.#B("detail",null);return!j||!W(j.isOpen)||j.inline===!1?null:j}#ee(){const j=(this.#e.config||{}).tree;return this.#U!==j&&(this.#U=j,this.#_=p(j,{dataAt:T=>this.#ze(T),keyOf:T=>this.#i.keyOf(this.#ze(T),T)})),this.#_}#I(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#I())return null;this.#W();const j=this.#p.grand;return j?this.#i.grandTotal(j,this.#ke(this.#p.grandLeaves)):null}pivot(){return this.#W(),this.#se}pivotMatrix(){this.#W();const j=this.#p.groupLeaves,T=(this.#e.compute||{}).pivotMatrix;if(!W(T))return null;const B=this.#B("groupBy",[]),q=this.#B("pivotBy",[]);if(!B.length&&!q.length)return null;const X=this.#qe().map(J=>({colId:J.id,handle:this.#a.handle(J.id),fn:S(J,"group")})).filter(J=>J.handle&&J.fn),Q=this.#e.config||{};return T({rowHandles:B.map(J=>this.#a.handle(J)).filter(Boolean),columnHandles:q.map(J=>this.#a.handle(J)).filter(Boolean),measures:X,leaves:j||new Uint32Array(0),opts:{locale:Q.locale,separator:(Q.pivot||{}).separator,maxColumns:(Q.pivot||{}).maxColumns}})}keysForLeaves(j){const T=[];if(!j)return T;for(let B=0;B<j.length;B++){const q=this.#Pe(j[B]);q&&q.key!=null&&T.push(String(q.key))}return T}leavesOf(j){this.#W();const T=this.#s.get("group"),B=T&&T.result;if(!B||!B.nodes)return[];const q=B.nodes.get(j);if(!q)return[];const X=[],Q=J=>{const ne=J.row&&J.row.children;if(ne&&ne.length){for(const re of ne){const oe=B.nodes.get(re.key);oe&&Q(oe)}return}if(J.leaves)for(let re=0;re<J.leaves.length;re++)X.push(this.#Pe(J.leaves[re]))};return Q(q),X}#G(j){return typeof j=="string"?j:this.#K(j)}#K(j){try{return this.#i.keyOf(j,-1)}catch{return"(unkeyed)"}}#we(j){if(typeof j=="string")return this.#z(j);if(this.#i.keyed){const B=this.#i.keyOf(j,-1),q=this.#z(B);if(q!==void 0)return q}if(this.#r)return;const T=this.#n.indexOf(j);return T>=0?T:void 0}#z(j){return this.#m||this.#X(),this.#m.get(j)}#X(){this.#m=new Map;const j=this.#mt(),T=this.#e.store,B=T&&W(T.live)?q=>T.live(q):null;for(let q=0;q<j;q++){if(B&&!B(q))continue;const X=this.#ze(q);X!==void 0&&this.#m.set(this.#i.keyOf(X,q),q)}}#Se(j,T){const B=[];for(const q of this.#ye())this.#Ne(q)&&this.#Oe(q,j,T,new Set)&&B.push(q);return B}#Oe(j,T,B,q){if(q.has(j))return!1;q.add(j);const X=this.#Ne(j);if(!X)return!1;const Q=X.value&&X.value.deps;return Array.isArray(Q)&&Q.length?Q.some(J=>this.#Oe(String(J),T,B,q)):W(X.getValue)?!Object.is(X.getValue(T),X.getValue(B)):!1}#ye(){const j=new Set;for(const B of this.#B("sort",[]))j.add(B.col);for(const B of this.#B("groupBy",[]))j.add(B);const T=B=>{if(B){if(Array.isArray(B.conditions)){B.conditions.forEach(T);return}B.col&&j.add(B.col)}};return T(this.#B("filters",null)),[...j]}#ve(j){if(!j.size)return!1;if(this.#B("quick",""))return!0;for(const T of this.#ye())if(j.has(T))return!0;return!1}#W(){if(!this.#l){this.#l=!0;try{this.#Re()}finally{this.#l=!1}}}pipelineRunning(){return this.#l}#Re(){const j=this.#k("filter",()=>this.#Te(),()=>this.#me()),T=this.#re(j),B=this.#k("group",()=>this.#Le(),()=>this.#q(T)),q=this.#k("total",()=>this.#Fe(),()=>this.#Je(B));this.#k("pivot",()=>this.#xe(),()=>this.#it(B)),this.#k("flatten",()=>this.#Ve(),()=>this.#ot(B)),this.#ae(B,q)}#re(j){const T=this.#s.get("sort"),B=this.#je();if(T.computed&&T.key===B&&!this.#v.has("sort"))return T.result;const q=this.#v.get("sort");return q&&q.key===B?T.result:T.result&&this.#H(j)?(this.#$(j,B),T.result):this.#k("sort",()=>B,()=>this.#Ge(j))}#fe(){if(this.#b===null){const j=this.#e.pipelineWorker,T=W(j)?j():null;this.#b=T||!1}return this.#b||null}#ie(){const j=this.#B("sort",[]);if(!Array.isArray(j)||!j.length)return null;const T=(this.#e.config||{}).locale,B=[],q=[];for(const X of j){const Q=this.#Ne(X.col);if(Q&&Q.running)continue;if(Q&&Q.value&&W(Q.value.compare))return null;const J=this.#a.handle(X.col);if(!J)return null;B.push({col:X.col,descending:X.dir==="desc",nullsFirst:!!X.nullsFirst,locale:T}),q.push(J)}return B.length?{entries:B,handles:q,locale:T}:null}#H(j){const T=this.#fe();if(!T)return!1;const B=Number(T.threshold);return Number.isFinite(B)&&j.length<B?!1:!!this.#ie()}#$(j,T){const B=this.#fe(),q=B&&this.#ie();if(!q){this.#k("sort",()=>T,()=>this.#Ge(j));return}const X=new AbortController;this.#v.set("sort",{key:T,controller:X});const Q=q.entries.length===1?B.sortColumn(q.handles[0],j,{descending:q.entries[0].descending,nullsFirst:q.entries[0].nullsFirst,locale:q.locale,signal:X.signal,key:"sort"}):B.sortMulti(q.handles,q.entries.map((J,ne)=>({...J,handle:q.handles[ne]})),j,{signal:X.signal,key:"sort"});if(!M(Q)){this.#v.delete("sort"),this.#k("sort",()=>T,()=>Q);return}Q.then(J=>this.#oe(T,J),J=>this.#ue("sort",T,J))}#oe(j,T){const B=this.#v.get("sort");if(!(!B||B.key!==j)){if(this.#je()!==j){this.#v.delete("sort");return}this.#v.delete("sort"),this.#k("sort",()=>j,()=>T),this.#Y=null,this.#W(),this.#Qe("model:changed",{reason:v[0]})}}#ue(j,T,B){const q=this.#v.get(j);if(!(!q||q.key!==T)&&(this.#v.delete(j),!(B&&B.name==="AbortError")&&j==="sort"&&this.#je()===T)){const X=this.#k("filter",()=>this.#Te(),()=>this.#me());this.#k("sort",()=>T,()=>this.#Ge(X)),this.#Y=null,this.#W(),$("source.pipeline.sort","off-thread sort failed; recomputed on the main thread.",B),this.#Qe("model:changed",{reason:v[1]})}}#ae(j,T){const B=j&&j.leaves?j.leaves.length:this.#p.slots.length;this.#p.matchCount=B,this.#p.grand=T&&T.grand||null,this.#p.grandLeaves=j&&j.leaves?j.leaves.length:0,this.#p.groupLeaves=j&&j.leaves?j.leaves:null}#k(j,T,B){const q=this.#s.get(j),X=T();return q.computed&&q.key===X||(q.result=B(),q.key=X,q.computed=!0,q.id++,j==="flatten"&&(this.#Y=null)),q.result}#ce(j){return this.#s.get(j).id}#Te(){const j=(this.#e.config||{}).hostFilter,T=j&&W(j.active)&&j.active()?1:0,B=this.#B("where",null),q=B?B.version:0,X=this.#at("filter.sig",`${this.#Ye()}`,()=>u({filters:this.#B("filters",null),quick:this.#B("quick",""),quickMode:this.#B("quickMode","contains")}));return`${this.#c}|${X}|${T}|${q}`}#je(){return`${this.#ce("filter")}|${JSON.stringify(this.#B("sort",[]))}`}#Le(){return`${this.#ce("sort")}|${JSON.stringify(this.#B("groupBy",[]))}`}#Fe(){const j=this.#de()?"f":"a",T=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#ce("group")}|${JSON.stringify(this.#B("totals",[]))}|${j}${T}|${this.#u}`}#xe(){return`${this.#ce("group")}|${JSON.stringify(this.#B("pivotBy",[]))}`}#Ve(){const T=this.#Ze()||!this.#I()?this.#ce("total"):"x",B=`${this.#Ye()}`,q=this.#at("flatten.keys",B,()=>{const Q=this.#B("expanded",null);return Q?[...Q].sort().join(""):"*"}),X=this.#at("flatten.detail",B,()=>{const Q=this.#B("detail",null);return Q&&W(Q.signature)?Q.signature():""});return`${T}|${this.#ce("pivot")}|${q}|${X}`}#Ze(){const j=this.#B("groupBy",[]);return Array.isArray(j)&&j.length>0}stageState(){const j=[];for(const[T,B]of this.#s){const q=B.result;j.push({stage:T,materialised:!!B.computed,bytes:q&&typeof q.byteLength=="number"?q.byteLength:null,rows:q&&typeof q.length=="number"?q.length:null,rebuilds:B.id})}return j}facetIndices(j){return this.#me(j||null)}facetRows(j){const T=this.facetIndices(j),B=[];for(let q=0;q<T.length;q++){const X=this.#Pe(T[q]);X&&B.push(X)}return B}invalidateRows(){this.#f.clear(),this.#F.clear(),this.#Y=null}invalidateHandles(){this.#a.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#Ae()}filteredIndices(){const j=this.#s.get("filter");if(j&&j.computed&&j.key===this.#Te())return j.result||this.#Ae();this.#W();const T=this.#s.get("filter");return(T&&T.computed?T.result:null)||this.#Ae()}unfilteredRows(){const j=this.#Ae(),T=[];for(let B=0;B<j.length;B++){const q=this.#Pe(j[B]);q&&T.push(q)}return T}#me(j=null){const T=this.#Ae(),B=this.#B("filters",null),q=j?this.#Xe("pruneColumn")(B,j):B,X=this.#vt(q),Q=String(this.#B("quick","")||"").trim().toLowerCase(),J=Q?K(Q,String(this.#B("quickMode","contains")||"contains")):null,ne=(this.#e.config||{}).hostFilter,re=!!(ne&&W(ne.active)&&ne.active()),oe=this.#B("where",null),ie=!!(oe&&oe.active);if(!X&&!Q&&!re&&!ie)return T;let te=null;X&&(te=this.#Xe("evaluateFilters")(X,{handle:pe=>this.#a.handle(pe),count:this.#mt(),pool:this.#e.pool,locale:(this.#e.config||{}).locale}));const ce=new Uint32Array(T.length);let ue=0;for(let ae=0;ae<T.length;ae++){const pe=T[ae];if(!(te&&!te[pe])&&!(J&&!this.#gt(pe,J))){if(re||ie){const he=this.#Pe(pe);if(re&&!ne.passes(he)||ie&&!oe.passes(he.data,he.key))continue}ce[ue++]=pe}}if(te){const ae=(this.#e.compute||{}).releaseMask;W(ae)&&ae({pool:this.#e.pool},te)}return ce.subarray(0,ue)}handleFor(j){return this.#a.handle(j)}#Ge(j){const T=this.#B("sort",[]).filter(X=>{const Q=this.#Ne(X.col);return!Q||!Q.running?!0:($(`source.sort.running.${X.col}`,`sort ignores "${X.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(!T.length)return j;const B=(this.#e.config||{}).locale;if(T.length===1){const X=T[0],Q=this.#a.handle(X.col);if(!Q)return $(`source.sort.${X.col}`,`sort ignores unknown column "${X.col}".`),j;const J=this.#Ne(X.col);return this.#Xe("sortColumn")(Q,j,{descending:X.dir==="desc",nullsFirst:X.nullsFirst,locale:B,compare:A(J)})}const q=[];for(const X of T){const Q=this.#a.handle(X.col);if(!Q){$(`source.sort.${X.col}`,`sort ignores unknown column "${X.col}".`);continue}q.push({handle:Q,descending:X.dir==="desc",nullsFirst:X.nullsFirst,locale:B,compare:A(this.#Ne(X.col))})}return q.length?this.#Xe("sortMulti")(q.map(X=>X.handle),q,j):j}#q(j){const T=this.#B("groupBy",[]),B=this.#ee();if(B&&!T.length){const ae=b(j,B);return this.#N=m(ae.roots,B.declaresChildren),{roots:null,leaves:j,nodes:new Map,tree:ae}}if(this.#N=null,B&&T.length&&$("tree.grouped","grouping is active on a grid configured with `tree`; the grouping wins and the hierarchy is not shown."),!T.length)return{roots:null,leaves:j,nodes:new Map};const q=(this.#e.config||{}).timeZone,X=[],Q=[];let J=!1;for(const ae of T){const pe=this.#a.handle(ae);if(!pe){$(`source.group.${ae}`,`grouping ignores unknown column "${ae}".`);continue}X.push(pe);const he=this.#Ne(ae),ve=he&&he.dataType;if(ve&&W(ve.groupProjector)){const Oe=he.typeOptions&&he.typeOptions.timeZone||he.timeZone||q||void 0,Ie=ve.groupProjector(he,Oe);Q.push(Ie||null),Ie&&(J=!0)}else Q.push(null)}if(!X.length)return{roots:null,leaves:j,nodes:new Map};const{keys:ne,buckets:re}=this.#Xe("groupByColumns")(X,j,{locale:(this.#e.config||{}).locale,project:J?Q:void 0}),oe=this.#B("pivotBy",[]).length>0,ie=[],te=new Map;for(let ae=0;ae<re.length;ae++){const pe=ne[ae];let he=null;const ve=[];for(let Oe=0;Oe<pe.length;Oe++){ve.push(k(pe[Oe]));const Ie=F(ve),Ze=Oe===pe.length-1;let Se=te.get(Ie);if(!Se){const xe=this.#i.group({path:[...ve],column:T[Oe],value:pe[Oe],level:Oe,parent:he,expanded:oe&&Ze?!1:this.#De(Ie,{key:Ie,column:T[Oe],value:pe[Oe],level:Oe,path:[...ve]}),hasChildren:!(oe&&Ze)});Se={row:xe,leaves:null},te.set(Ie,Se),he?he.children.push(xe):ie.push(xe)}Se.row.leafCount+=re[ae].length,Oe===pe.length-1&&(Se.leaves=re[ae]),he=Se.row}}const ce=this.#B("sort",[])||[],ue=(ae,pe)=>{if(!ae||ae.length<2){if(ae)for(const Ie of ae)ue(Ie.children,pe+1);return}const he=T[pe],ve=ce.find(Ie=>Ie.col===he),Oe=ve&&ve.dir==="desc"?-1:1;ae.sort((Ie,Ze)=>Oe*Z(Ie.groupValue,Ze.groupValue));for(const Ie of ae)ue(Ie.children,pe+1)};return ue(ie,0),{roots:ie,leaves:j,nodes:te,keys:ne,buckets:re}}#$e(j,T){const B=new Map,q=new Map,X=Q=>{const J=Q.physical>=0?[Q.physical]:[];for(const ne of Q.children)J.push(...X(ne));if(Q.children.length){const ne=this.#Ue(T,Uint32Array.from(J),null);Q.physical>=0?B.set(Q.physical,ne):q.set(Q.key,ne)}return J};for(const Q of j.roots)X(Q);return{byPhysical:B,byKey:q}}#Je(j){const T=this.#qe();if(!T.length)return this.#E=null,this.#T=null,{grand:null};const B={id:this.#ce("group"),columns:T.map(ce=>ce.id).join("")},q=this.#E&&this.#E.id===B.id&&this.#E.columns===B.columns,X=this.#nt()&&q?this.#C:null,Q=X?T.filter(ce=>X.has(ce.id)):T,J=q?this.#T:null,ne=this.#de()?null:this.#ht(),re=this.#et(T),oe=ce=>{const ue=j.nodes.get(ce.key);let ae=ue&&ue.leaves?ue.leaves:null;if(ce.children&&ce.children.length){const ve=ce.children.map(oe);let Oe=0;for(const Se of ve)Oe+=Se.length;const Ie=new Uint32Array(Oe);let Ze=0;for(const Se of ve)Ie.set(Se,Ze),Ze+=Se.length;ae=Ie}ae=ae||new Uint32Array(0);const pe=ne?ne.get(ce.key)||C:ae,he=this.#he(ce,X?Q:T,pe,re);return ce.totals=X?{...ce.totals,...he}:he,ae};if(j.roots&&Q.length)for(const ce of j.roots)oe(ce);if(this.#M=j.tree?this.#$e(j.tree,T):null,this.#E=B,this.#C=this.#nt()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#S.length=0,this.#T=null,{grand:null};const te=ne?this.#We():j.leaves;return this.#T=this.#Ke(T,te,X,J),{grand:this.#T}}#Ke(j,T,B,q){const X={},Q=this.#ce("group");Q!==this.#w&&(this.#rt(),this.#w=Q);const J=this.#S;this.#S=[];for(const ne of j){if(!E(ne))continue;const re=this.#a.handle(ne.id);if(!re)continue;const oe=S(ne,"grand");if(!n(oe,re)){if(B&&!B.has(ne.id)&&q&&ne.id in q){X[ne.id]=q[ne.id];continue}X[ne.id]=this.#Ue([ne],T,null,"grand")[ne.id];continue}let ie=this.#y.get(ne.id);if((!ie||ie.fn!==oe)&&(ie=new t(oe),this.#y.set(ne.id,ie)),ie.valid){let te=!0;for(const ce of J)if(ce.colId===ne.id&&!ie.update(ce.before,ce.after)){te=!1;break}if(te){X[ne.id]=ie.value();continue}ie.invalidate()}ie.seedColumn(re.values,s(re),T),X[ne.id]=ie.valid?ie.value():this.#Ue([ne],T,null,"grand")[ne.id]}return X}#et(j){const T=this.#ce("group");T!==this.#A&&(this.#j.clear(),this.#A=T);const B=new Map;for(const X of j){if(!E(X))continue;const Q=this.#a.handle(X.id),J=S(X,"group");n(J,Q)&&B.set(X.id,{fn:J})}if(!B.size)return this.#O.length=0,B;const q=this.#O;this.#O=[];for(const X of q){const{beforeKeys:Q,afterKeys:J,colDeltas:ne}=X,re=Q.length?new Set(Q):null,oe=J.length?new Set(J):null;for(const{colId:ie,before:te,after:ce}of ne)if(B.has(ie)){for(const ue of Q)oe&&oe.has(ue)||this.#Me(ue,ie,te,null);for(const ue of J)re&&re.has(ue)||this.#Me(ue,ie,null,ce);for(const ue of Q)oe&&!oe.has(ue)||this.#Me(ue,ie,te,ce)}}return B}#Me(j,T,B,q){const X=this.#j.get(j),Q=X&&X.get(T);!Q||!Q.valid||Q.update(B,q)||Q.invalidate()}#he(j,T,B,q){if(!q||!q.size)return this.#Ue(T,B,j);const X={};let Q=null,J=this.#j.get(j.key);for(const ne of T){const re=q.get(ne.id);if(!re){(Q||(Q=[])).push(ne);continue}const oe=this.#a.handle(ne.id);if(!oe)continue;J||(J=new Map,this.#j.set(j.key,J));let ie=J.get(ne.id);if((!ie||ie.fn!==re.fn)&&(ie=new t(re.fn),J.set(ne.id,ie)),ie.valid||ie.seedColumn(oe.values,s(oe),B),ie.valid){X[ne.id]=ie.value();continue}(Q||(Q=[])).push(ne)}return Q&&Object.assign(X,this.#Ue(Q,B,j)),X}#be(j,T,B,q){const X=!this.#de()||this.#Ie(T);for(const Q of j){const J=Q.getValue;if(!W(J))continue;const ne=J(B),re=J(q);Object.is(ne,re)||(this.#C&&this.#C.add(Q.id),X&&this.#y.has(Q.id)&&this.#S.push({colId:Q.id,before:ne,after:re}))}}#bt(){const j=this.#B("groupBy",[]),T=[];for(const B of j){const q=this.#Ne(B);q&&T.push(q)}return T}#ft(j,T){const B=new Array(j.length);for(let q=0;q<j.length;q++){const X=j[q].getValue;B[q]=k(W(X)?X(T):void 0)}return B}#P(j,T,B,q,X){if(this.#de()&&!this.#Ie(B))return;const Q=O(this.#ft(j,q)),J=O(this.#ft(j,X)),ne=Q.length!==J.length||Q.some((oe,ie)=>oe!==J[ie]),re=[];for(const oe of T){const ie=oe.getValue;if(!W(ie))continue;const te=ie(q),ce=ie(X);!ne&&Object.is(te,ce)||re.push({colId:oe.id,before:te,after:ce})}!re.length&&!ne||this.#O.push({beforeKeys:Q,afterKeys:J,colDeltas:re})}#Ie(j){const T=this.#s.get("filter"),B=T&&T.computed?T.result:null;if(!B)return!0;let q=0,X=B.length-1;for(;q<=X;){const Q=q+X>>1,J=B[Q];if(J===j)return!0;J<j?q=Q+1:X=Q-1}return!1}#de(){return(this.#e.config||{}).totalFilteredOnly!==!1}#ke(j){return this.#de()?j:this.#We().length}#We(){return(!this.#x||this.#x.version!==this.#c)&&(this.#x={version:this.#c,indices:this.#Ae()}),this.#x.indices}#ht(){const j=this.#B("groupBy",[]),T=`${this.#c}|${JSON.stringify(j)}`;if(this.#R&&this.#R.key===T)return this.#R.map;const B=new Map,q=[];for(const X of j){const Q=this.#a.handle(X);Q&&q.push(Q)}if(q.length){const X=this.#We(),{keys:Q,buckets:J}=this.#Xe("groupByColumns")(q,X,{locale:(this.#e.config||{}).locale}),ne=new Map;for(let re=0;re<J.length;re++){const oe=Q[re],ie=[];for(let te=0;te<oe.length;te++){ie.push(k(oe[te]));const ce=F(ie);let ue=ne.get(ce);ue||(ue=[],ne.set(ce,ue));for(let ae=0;ae<J[re].length;ae++)ue.push(J[re][ae])}}for(const[re,oe]of ne)B.set(re,Uint32Array.from(oe))}return this.#R={key:T,map:B},B}#nt(){return!!(this.#e.config||{}).totalOnlyChangedColumns}#Be(){this.#rt(),this.#tt(),this.#C=null,this.#E=null,this.#T=null}#rt(){this.#y.clear(),this.#S.length=0,this.#w=-1}#tt(){this.#j.clear(),this.#O.length=0,this.#A=-1}#it(j){const T=this.#B("pivotBy",[]);if(!T.length)return this.#se=null,null;const B=(this.#e.compute||{}).pivot;if(!W(B))return $("source.pivot.kernel","pivot requested but ctx.compute.pivot is not available; showing unpivoted rows."),this.#se=null,null;const q=T.map(Q=>this.#a.handle(Q)).filter(Boolean),X=this.#qe();return this.#se=B(q,j.leaves,{groups:j.keys&&j.buckets?{keys:j.keys,buckets:j.buckets}:null,totals:X.map(Q=>Q.id),handle:Q=>this.#a.handle(Q),totalOf:Q=>S(X.find(J=>J.id===Q),"group"),separator:((this.#e.config||{}).pivot||{}).separator,maxColumns:((this.#e.config||{}).pivot||{}).maxColumns})||null,this.#se}#ot(j){const T=this.#s.get("total").result,B=!!(this.#e.config||{}).groupFooter,q=this.#V();if(j.tree)return this.#wt(j,T,q);if(!j.roots&&!q){if(T&&T.grand&&!this.#I()){const oe=this.#i.grandTotal(T.grand,this.#ke(j.leaves.length));if(this.#Z===j.leaves&&Array.isArray(this.#D))this.#D[this.#D.length-1]=oe;else{const ie=Array.from(j.leaves);ie.push(oe),this.#D=ie,this.#Z=j.leaves}this.#le=[{at:this.#D.length-1}]}else this.#Z=null,this.#D=j.leaves,this.#le=o;return this.#te=o,this.#D}const X=[],Q=[],J=[],ne=oe=>{if(X.push(oe),!q)return;const ie=this.#Pe(oe);!ie||!q.isOpen(ie.key)||(ie.master=!0,ie.expanded=!0,J.push({at:X.length}),X.push(this.#i.detail(ie,q.heightOf(ie))))};if(!j.roots){for(let oe=0;oe<j.leaves.length;oe++)ne(j.leaves[oe]);return T&&T.grand&&!this.#I()&&(J.push({at:X.length}),X.push(this.#i.grandTotal(T.grand,this.#ke(j.leaves.length)))),this.#Z=null,this.#te=o,this.#le=J.length?J:o,this.#D=X,X}const re=(oe,ie,te)=>{if(oe.expanded=oe.hasChildren===!1?!1:this.#De(oe.key,{key:oe.key,column:oe.groupColumn,value:oe.groupValue,level:oe.level,path:oe.groupPath}),oe.posinset=ie+1,oe.setsize=te,Q.push({at:X.length,row:oe}),J.push({at:X.length}),X.push(oe),!!oe.expanded){if(oe.children&&oe.children.length)for(let ce=0;ce<oe.children.length;ce++)re(oe.children[ce],ce,oe.children.length);else{const ce=j.nodes.get(oe.key),ue=ce&&ce.leaves?ce.leaves:null;if(ue)for(let ae=0;ae<ue.length;ae++)ne(ue[ae])}B&&oe.totals&&(J.push({at:X.length}),X.push(this.#i.footer(oe)))}};for(let oe=0;oe<j.roots.length;oe++)re(j.roots[oe],oe,j.roots.length);return T&&T.grand&&!this.#I()&&(J.push({at:X.length}),X.push(this.#i.grandTotal(T.grand,this.#ke(j.leaves.length)))),this.#te=Q,this.#le=J,this.#D=X,X}#Ae(){const j=this.#e.store;if(j&&W(j.liveIndices))return j.liveIndices();const T=new Uint32Array(this.#n.length);let B=0;for(let q=0;q<this.#n.length;q++)this.#n[q]!==void 0&&(T[B++]=q);return T.subarray(0,B)}#mt(){const j=this.#e.store;return j&&typeof j.physical=="number"?j.physical:this.#n.length}#ze(j){const T=this.#e.store;return T&&W(T.source)?T.source(j):this.#n[j]}#pt(j,T=j){const B=this.#D[j];if(typeof B!="number")return B.index=T,B;const q=this.#Pe(B);return q.index=T,q}#Pe(j){let T=this.#f.get(j);T||(T=this.#i.leaf(this.#ze(j),j),this.#f.set(j,T));const B=this.#N?this.#N.get(j):null;if(B){T.level=B.level,T.posinset=B.posinset,T.setsize=B.setsize,T.hasChildren=B.hasChildren,T.expanded=B.hasChildren&&!B.lazy&&this.#De(T.key);const q=this.#M?this.#M.byPhysical.get(j):void 0;q?T.totals=q:T.totals&&(T.totals=null)}else T.hasChildren&&(T.level=0,T.hasChildren=!1,T.expanded=!1,T.posinset=void 0,T.setsize=void 0);return T}#wt(j,T,B){const q=[],X=[],Q=ne=>{if(ne.leafCount!==void 0)return ne.leafCount;let re=ne.physical>=0?1:0;for(const oe of ne.children)re+=Q(oe);return ne.leafCount=re,re},J=ne=>{const re=this.#De(ne.key);if(ne.physical>=0){if(q.push(ne.physical),B&&B.isOpen(this.#Pe(ne.physical).key)){const oe=this.#Pe(ne.physical);X.push({at:q.length}),q.push(this.#i.detail(oe,B.heightOf(oe)))}}else q.push(this.#i.group({path:[ne.key],column:null,value:ne.value,level:ne.level,parent:null,expanded:re,hasChildren:ne.children.length>0,leafCount:Q(ne),totals:this.#M?this.#M.byKey.get(ne.key):void 0}));if(re)for(const oe of ne.children)J(oe)};for(const ne of j.tree.roots)J(ne);return T&&T.grand&&!this.#I()&&(X.push({at:q.length}),q.push(this.#i.grandTotal(T.grand,this.#ke(j.leaves.length)))),this.#Z=null,this.#te=o,this.#le=X.length?X:o,this.#D=q,q}#Et(){return y(()=>this.count(),j=>this.at(j))}#gt(j,T){let B=this.#F.get(j);if(B===void 0){const q=this.#ze(j),X=this.#kt(),Q=[],J=this.#e.columnHidden;for(const ne of X){if(ne.quickFilter===!1||W(J)&&J(ne.id))continue;const re=ne.value&&W(ne.value.quickFilterText)?ne.value.quickFilterText({value:void 0,data:q,row:null,column:ne,colId:ne.id,grid:null,context:this.#B("context",null)}):null,oe=re??(W(ne.formatValue)?ne.formatValue(W(ne.getValue)?ne.getValue(q):void 0):"");oe!=null&&oe!==""&&Q.push(String(oe))}B=Q.join(" ").toLowerCase(),this.#F.set(j,B)}return T(B)}#qe(){const j=this.#B("totals",[]),T=j&&j.length?new Set(j):null;return this.#kt().filter(B=>T?T.has(B.id):!!(B.total||B.groupTotal||B.grandTotal))}#Ue(j,T,B,q="group"){const X={},Q=(this.#e.compute||{}).total;for(const J of j){if(!E(J))continue;const ne=this.#a.handle(J.id);if(!ne)continue;const re=S(J,q);if(re)if(W(re)){const oe=new Array(T.length);for(let ie=0;ie<T.length;ie++)oe[ie]=ne.get(T[ie]);X[J.id]=re(oe,{row:B,column:J,grid:this.#e.grid||null,context:this.#B("context",null),valueAt:(ie,te)=>{const ce=this.#a.handle(ie);return ce&&te>=0&&te<T.length?ce.get(T[te]):null}})}else W(Q)&&(X[J.id]=Q(ne,T,re))}return X}#vt(j){if(!j)return j;const T=this.#e.config||{},B={tz:T.timeZone,weekStartsOn:T.weekStartsOn};return f(j,q=>{const X=h(q,B);if(X&&X.type)return X;const Q=this.#Ne(X&&X.col),J=Q&&(Q.dataType?.base||Q.type);return J?{...X,type:J}:X})}#De(j,T){const B=this.#B("expanded",null);return B?W(B.has)?B.has(j,T):Array.prototype.includes.call(B,j):!0}#B(j,T){if(j==="context"||!W(this.#e.stateVersion))return this.#st(j,T);const B=this.#Mt(j),q=this.#d.get(j);if(q&&q.version===B)return q.value;const X=this.#st(j,T);return this.#d.set(j,{version:B,value:X}),X}#st(j,T){const B=this.#e.state;if(B&&W(B[j])){const q=B[j]();return q??T}return T}#Ye(){const j=this.#e.stateVersion;return W(j)?j():0}#Tt(){const j=this.#e.columnsVersion,T=this.#e.permissionsVersion;return`${W(j)?j():0}|${W(T)?T():0}`}#Mt(j){return j==="totals"?this.#Tt():`${this.#Ye()}`}#at(j,T,B){if(!W(this.#e.stateVersion))return B();const q=this.#h.get(j);if(q&&q.version===T)return q.key;const X=B();return this.#h.set(j,{version:T,key:X}),X}#Xe(j){const T=(this.#e.compute||{})[j];return W(T)||L(`ctx.compute.${j} is required by the memory source pipeline`),T}#kt(){const j=this.#e.columns;return j&&W(j.all)?j.all():[]}#Ne(j){const T=this.#e.columns;return T&&W(T.get)?T.get(j):void 0}#Qe(j,T){const B=this.#e.emit;W(B)&&B(j,T)}}}),ke("packages/core/src/source/abort.js",function(e,V){"use strict";Object.defineProperty(e,"SupersededError",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"RequestToken",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"AbortScope",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"createAbortScope",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"isAbortError",{enumerable:!0,get:function(){return W}});class _ extends Error{constructor(H,U="superseded"){super(`[lattice] request ${H?`"${H}" `:""}${U}`),this.name="SupersededError",this.superseded=!0,this.key=H}}class R{#e;constructor(H,U,z,F){this.#e=H,this.key=U,this.controller=z,this.signal=z.signal,this.seq=F}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(H){this.signal.aborted||this.controller.abort(new _(this.key,H)),this.#e.settle(this)}}class ${#e=new Map;#t=0;begin(H="",U="superseded"){const z=this.#e.get(H);z&&!z.signal.aborted&&z.controller.abort(new _(H,U));const F=new R(this,H,new AbortController,++this.#t);return this.#e.set(H,F),F}tokenFor(H){return this.#e.get(H)}pending(H=""){const U=this.#e.get(H);return!!U&&!U.signal.aborted}get size(){return this.#e.size}settle(H){this.#e.get(H.key)===H&&this.#e.delete(H.key)}abort(H="",U="superseded"){const z=this.#e.get(H);z&&z.abort(U)}abortAll(H="superseded"){for(const U of[...this.#e.values()])U.abort(H);this.#e.clear()}}function L(){return new $}function W(Z){if(!Z||typeof Z!="object")return!1;const H=Z;return H.superseded===!0||H.name==="AbortError"||H.name==="SupersededError"}}),ke("packages/core/src/source/blockcache.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_PAGE_SIZE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"DEFAULT_MAX_CACHED_PAGES",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return L}});const _=100,R=32;class ${constructor(Z){this.id=Z,this.rows=null,this.state="pending",this.token=null,this.error=null}}class L{#e=new Map;#t;#n;#r=0;#o=-1;constructor(Z={}){this.#t=Math.max(1,Math.floor(Number(Z.pageSize)||_)),this.#n=Math.max(1,Math.floor(Number(Z.maxCachedPages)||R))}get pageSize(){return this.#t}get maxBlocks(){return this.#n}get size(){return this.#e.size}blockOf(Z){return Math.floor(Z/this.#t)}rangeOf(Z){return{start:Z*this.#t,end:(Z+1)*this.#t}}has(Z){return this.#e.has(Z)}pending(Z){const H=this.#e.get(Z);return!!H&&H.state==="pending"}loaded(Z){const H=this.#e.get(Z);return!!H&&H.state==="loaded"}begin(Z,H){let U=this.#e.get(Z);return U||(U=new $(Z)),U.state="pending",U.token=H,U.error=null,this.#i(Z,U),U}fill(Z,H){const U=this.#e.get(Z)||new $(Z);U.rows=H,U.state="loaded",U.token=null,this.#i(Z,U)}failed(Z,H){const U=this.#e.get(Z)||new $(Z);U.state="error",U.error=H,U.token=null,this.#i(Z,U)}delete(Z){return this.#e.delete(Z)}rowAt(Z){const H=this.blockOf(Z),U=this.#e.get(H);if(!(!U||U.state!=="loaded"||!U.rows))return this.#i(H,U),U.rows[Z-H*this.#t]}rowLoaded(Z){const H=this.blockOf(Z),U=this.#e.get(H);return!!U&&U.state==="loaded"&&!!U.rows&&Z-H*this.#t<U.rows.length}loadedExtent(){let Z=0;for(const H of this.#e.values()){if(H.state!=="loaded"||!H.rows)continue;const U=H.id*this.#t+H.rows.length;U>Z&&(Z=U)}return Z}fillOf(Z){const H=this.#e.get(Z);return H&&H.state==="loaded"&&H.rows?H.rows.length:null}protect(Z,H){this.#r=this.blockOf(Math.max(0,Z)),this.#o=this.blockOf(Math.max(0,H))}evict(){const Z=[];if(this.#e.size<=this.#n)return Z;for(const[H,U]of this.#e){if(this.#e.size-Z.length<=this.#n)break;H>=this.#r&&H<=this.#o||U.state!=="pending"&&Z.push(H)}for(const H of Z)this.#e.delete(H);return Z}ids(){return[...this.#e.keys()]}clear(){this.#e.clear()}#i(Z,H){this.#e.delete(Z),this.#e.set(Z,H)}}}),ke("packages/core/src/source/paged.js",function(e,V){"use strict";Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PagedSource",{enumerable:!0,get:function(){return l}});const _=V("packages/core/src/internal/util.js"),R=_.Lru,$=_.isFunction,L=_.warnOnce,W=_.settleDebounce,Z=V("packages/core/src/source/abort.js"),H=Z.createAbortScope,U=Z.isAbortError,z=V("packages/core/src/source/blockcache.js"),F=z.BlockCache,k=z.DEFAULT_PAGE_SIZE,O=z.DEFAULT_MAX_CACHED_PAGES,d=V("packages/core/src/source/rows.js").createRowFactory,c=V("packages/core/src/source/filterwire.js"),r=c.wireFilters,t=c.querySignature,n=c.warnHostFilterNotApplied,i=120;function s(u,f){return new l(u,f)}class l{mode="paged";#e;#t;#n;#r=H();#o;#i;#a=new Map;#s=null;#l=!1;#u=0;#c="";#d={start:0,end:0};#h;#f=!1;constructor(f,h){this.#e=f||{mode:"paged"},this.#t=h||{},this.#n=new F({pageSize:this.#e.pageSize||k,maxCachedPages:this.#e.maxCachedPages||O}),this.#o=d(this.#t),this.#i=new R(this.#n.pageSize*4),this.#h=W((g,b)=>this.#m(g,b),i),this.#c=this.#y(),$(this.#e.fetch)||L("source.paged.fetch",'source.mode "paged" requires a fetch function; the grid will stay empty.'),n(this.#t)}count(){if(this.#v(),this.#s!==null)return this.#s;const f=Math.max(this.#u,this.#n.loadedExtent());return this.#l?f:f+this.#n.pageSize}at(f){if(this.#v(),f<0||f>=this.count())return;const h=this.#i.get(f);if(h&&(h.data!==null||!this.#n.rowLoaded(f)))return h;const g=this.#n.rowAt(f);if(g===void 0){const p=this.#o.skeleton(f);return this.#i.set(f,p),p}const b=this.#o.leaf(g,f);return b.index=f,this.#i.set(f,b),this.#a.set(b.key,f),b}byKey(f){const h=this.#a.get(f);return h===void 0?void 0:this.at(h)}loaded(f){return this.#n.rowLoaded(f)}hint(f,h){if(this.#f)return;const g=this.#v(),b=Math.max(0,Math.floor(f)),p=Math.max(b,Math.floor(h));this.#d={start:b,end:p},this.#n.protect(b,p);for(const m of this.#n.evict())this.#g(m);this.#h(b,p),g&&this.#h.flush()}#m(f,h){if(this.#f)return;this.#n.protect(f,h);const g=this.#n.blockOf(f),b=this.#n.blockOf(h);for(let p=g;p<=b&&!(this.#s!==null&&p*this.#n.pageSize>=this.#s);p++)this.#n.has(p)||this.#p(p)}apply(f){const h={added:[],updated:[],removed:[]};if(!f)return h;if(f.update)for(const g of f.update){const b=this.#o.keyOf(g,-1),p=this.#a.get(b);if(p===void 0)continue;const m=this.#o.leaf(g,p);m.index=p,this.#i.set(p,m),h.updated.push(m)}return(f.add&&f.add.length||f.remove&&f.remove.length)&&this.reload(),h}reload(f){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.#a.clear()}exact(){return this.#s!==null||this.#l}pending(){return this.#r.size}async#p(f){if(!$(this.#e.fetch))return;const h=this.#r.begin(`block:${f}`);this.#n.begin(f,h);const{start:g,end:b}=this.#n.rangeOf(f),p=this.#c;try{const m=await this.#e.fetch({range:{start:g,end:b},sort:this.#S("sort",[]),filters:r(this.#S("filters",null),this.#w()),quick:this.#S("quick","")||void 0,context:this.#S("context",null),signal:h.signal});if(!h.current||p!==this.#c||this.#f)return;h.settle();const w=m&&m.rows||[];this.#n.fill(f,w);for(let a=0;a<w.length;a++)this.#i.delete(g+a);const v=m&&typeof m.total=="number"?m.total:m&&typeof m.count=="number"?m.count:null;v!==null?(this.#s=v,this.#l=!0):w.length<this.#n.pageSize?(this.#l=!0,this.#s=g+w.length):this.#u=Math.max(this.#u,g+w.length),this.#j("model:changed",{reason:"page",block:f,from:g,to:g+w.length})}catch(m){if(h.settle(),U(m))return;this.#n.failed(f,m),this.#j("source:error",{error:m,block:f,range:{start:g,end:b}})}}#g(f){const{start:h,end:g}=this.#n.rangeOf(f);for(let b=h;b<g;b++){const p=this.#i.peek(b);p&&this.#a.delete(p.key),this.#i.delete(b)}}#v(){const f=this.#y();return f===this.#c?!1:(this.#c=f,this.#b("query"),!0)}#b(f){this.#r.abortAll(f),this.#n.clear(),this.#i.clear(),this.#a.clear(),this.#s=null,this.#l=!1,this.#u=0,this.#j("model:changed",{reason:f})}#y(){return t({filters:this.#S("filters",null),sort:this.#S("sort",[]),quick:this.#S("quick",""),context:this.#S("context",null)})}#w(){const f=this.#t.config||{};return{tz:f.timeZone,weekStartsOn:f.weekStartsOn}}#S(f,h){const g=this.#t.state;if(g&&$(g[f])){const b=g[f]();return b??h}return h}#j(f,h){const g=this.#t.emit;$(g)&&g(f,h)}}}),ke("packages/core/src/source/remote.js",function(e,V){"use strict";Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return b}});const _=V("packages/core/src/internal/util.js"),R=_.Lru,$=_.isFunction,L=_.warnOnce,W=_.settleDebounce,Z=V("packages/core/src/source/abort.js"),H=Z.createAbortScope,U=Z.isAbortError,z=V("packages/core/src/source/blockcache.js"),F=z.BlockCache,k=z.DEFAULT_PAGE_SIZE,O=z.DEFAULT_MAX_CACHED_PAGES,y=V("packages/core/src/source/rows.js"),d=y.createRowFactory,c=y.groupKey,r=V("packages/core/src/source/filterwire.js"),t=r.wireFilters,n=r.querySignature,i=r.warnHostFilterNotApplied,l=V("packages/core/src/source/memory.js").MemorySource,u=1,f=120;function h(p,m){return new b(p,m)}class g{constructor(m,w,v,a){this.path=m,this.keyPath=a||m,this.values=[],this.level=w,this.key=c(this.keyPath),this.cache=new F(v),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;#a=H();#s;#l;#u=new Map;#c=[];#d="";#h;#f=!1;#m=null;#p=-1;constructor(m,w){this.#e=m||{mode:"remote"},this.#t=w||{},$(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#S(),this.unfilteredIndices=()=>this.#j(),this.handleFor=o=>this.#A(o),this.display=()=>this.#O(),this.grandTotalRow=()=>this.#E(),this.unfilteredRows=()=>this.#R(),this.facetIndices=o=>this.#C(o));const v=this.#e.counts;$(v)&&(this.matchCount=()=>this.#T("match"),this.totalCount=()=>this.#T("total"));const a=this.#e.grandTotals;$(a)&&(this.grandTotalRow=()=>this.#x()),this.#n={pageSize:this.#e.pageSize||k,maxCachedPages:this.#e.maxCachedPages||O},this.#s=d(this.#t),this.#l=new R(this.#n.pageSize*4),this.#h=W((o,S)=>this.#v(o,S),f),this.#r=new g([],0,this.#n),this.#o.set(this.#r.key,this.#r),this.#d=this.#ge(),$(this.#e.fetch)||L("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#K()}count(){const m=this.#y();return m?m.count():(this.#se(),this.#F(this.#r))}at(m){const w=this.#y();if(w)return w.at(m);if(this.#se(),m<0||m>=this.count())return;const v=this.#D(this.#r,m);if(!v)return;const a=this.#Z(v.node,v.local);return a&&(a.index=m),a||this.#s.skeleton(m,v.node.level)}byKey(m){const w=this.#y();if(w)return w.byKey(m);const v=this.#u.get(m);if(!v)return;const a=v.lastIndexOf(":"),o=this.#o.get(v.slice(0,a));return o&&this.#Z(o,Number(v.slice(a+1)))||void 0}loaded(m){const w=this.#y();if(w)return w.loaded(m);if(m<0||m>=this.count())return!1;const v=this.#D(this.#r,m);return!!v&&v.node.cache.rowLoaded(v.local)}hint(m,w){if(this.#f)return;const v=this.#se(),a=Math.max(0,Math.floor(m)),o=Math.max(a,Math.floor(w));for(const[S,E]of this.#g(a,o)){S.cache.protect(E.min,E.max);for(const A of S.cache.evict())this.#le(S,A)}this.#h(a,o),v&&this.#h.flush()}#g(m,w){const v=this.count(),a=new Map;for(let o=m;o<=w&&o<v;o++){const S=this.#D(this.#r,o);if(!S)continue;const E=a.get(S.node);E?(E.min=Math.min(E.min,S.local),E.max=Math.max(E.max,S.local)):a.set(S.node,{min:S.local,max:S.local})}return a.size||a.set(this.#r,{min:m,max:m}),a}#v(m,w){if(!this.#f)for(const[v,a]of this.#g(m,w)){v.cache.protect(a.min,a.max);const o=v.cache.blockOf(a.min),S=v.cache.blockOf(a.max);for(let E=o;E<=S&&!(v.count!==null&&E*v.cache.pageSize>=v.count);E++)v.cache.has(E)||this.#M(v,E)}}apply(m){const w={added:[],updated:[],removed:[]};if(!m)return w;if(m.update)for(const v of m.update){const a=this.#u.get(this.#s.keyOf(v,-1));if(!a)continue;this.#l.delete(a);const o=a.lastIndexOf(":"),S=this.#o.get(a.slice(0,o));if(!S)continue;const E=Number(a.slice(o+1)),A=S.cache.blockOf(E);if(!S.cache.loaded(A))continue;const{start:M}=S.cache.rangeOf(A),C=[];for(let x=M;x<M+S.cache.pageSize;x++){const K=S.cache.rowAt(x);if(K===void 0)break;C.push(x===E?v:K)}S.cache.fill(A,C);const P=this.#Z(S,E);P&&w.updated.push(P)}return(m.add&&m.add.length||m.remove&&m.remove.length)&&this.reload({keepExpanded:!0}),w}reload(m){this.#a.abortAll("reload"),this.#h.cancel(),m&&m.keepExpanded===!1&&this.#i.clear(),this.#ne(),this.#X("model:changed",{reason:"reload"})}destroy(){this.#f=!0,this.#h.cancel(),this.#a.abortAll("destroyed"),this.#ne(),this.#o.clear(),this.#i.clear(),this.#m&&$(this.#m.destroy)&&this.#m.destroy(),this.#m=null}expand(m){this.#i.has(m)||(this.#i.add(m),this.#X("group:toggled",{key:m,expanded:!0}),this.#X("model:changed",{reason:"expand",key:m}))}collapse(m){this.#i.delete(m)&&(this.#X("group:toggled",{key:m,expanded:!1}),this.#X("model:changed",{reason:"collapse",key:m}))}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 m=this.#e.fullFrame;return $(m)?m():null}#y(){const m=this.#b();return m?(this.#m||(this.#m=new l({mode:"memory"},this.#w())),m.version!==this.#p&&(this.#m.setRows(m.rows),this.#p=m.version),this.#m):null}#w(){const m=this.#t,w=m.state||{};return{...m,state:{...w,page:()=>0,pageSize:()=>0}}}#S(){const m=this.#y();return m?m.filteredIndices():new Uint32Array(0)}#j(){const m=this.#y();return m?m.unfilteredIndices():new Uint32Array(0)}#A(m){const w=this.#y();return w?w.handleFor(m):void 0}#O(){const m=this.#y();return m?m.display():[]}#C(m){const w=this.#y();return w&&$(w.facetIndices)?w.facetIndices(m):new Uint32Array(0)}#E(){const m=this.#y();return m&&$(m.grandTotalRow)?m.grandTotalRow():null}#T(m){const w=this.#y();if(w){const S=m==="match"?w.matchCount:w.totalCount;if($(S))return S.call(w)}const v=this.#e.counts,a=$(v)?v():null,o=a?a[m]:null;return typeof o=="number"?o:this.count()}#x(){const m=this.#y();if(m&&$(m.grandTotalRow))return m.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const v=this.#e.grandTotals,a=$(v)?v():null;return!a||!a.totals?null:this.#s.grandTotal(a.totals,a.leafCount||0)}#R(){const m=this.#y();if(m&&$(m.unfilteredRows))return m.unfilteredRows();const w=[],v=this.count();for(let a=0;a<v;a++){const o=this.at(a);o&&w.push(o)}return w}#N(m,w,v){const{start:a,end:o}=m.cache.rangeOf(w),S=this.#z("groupBy",[]),E=this.#z("pivotBy",[]),A=this.#z("quick",""),M=this.#ee(),C={protocol:u,range:{start:a,end:o},groupPath:m.path,groupValues:m.values,groupBy:S,totals:M,totalFns:this.#I(M),pivotBy:E,pivotMode:E.length>0,filters:t(this.#z("filters",null),this.#we()),sort:this.#z("sort",[]),context:this.#z("context",null),signal:v};A&&(C.quick=A);const P=this.#z("where",null);return P&&P.active&&(C.where=P),C}async#M(m,w){if(!$(this.#e.fetch))return;const v=this.#a.begin(`${m.key}:${w}`);m.cache.begin(w,v);const a=this.#d,{start:o}=m.cache.rangeOf(w);try{const S=await this.#e.fetch(this.#N(m,w,v.signal));if(!v.current||a!==this.#d||this.#f)return;v.settle();const E=S&&S.rows||[];m.cache.fill(w,E);for(let C=0;C<E.length;C++)this.#l.delete(`${m.key}:${o+C}`);const A=S&&typeof S.count=="number"?S.count:S&&typeof S.total=="number"?S.total:null,M=S&&$(S.pendingTotal?.then)?S.pendingTotal:null;A!==null?(m.count=A,m.complete=!0):E.length<m.cache.pageSize?(m.count=o+E.length,m.complete=!0):M&&(m.counting=!0),S&&Array.isArray(S.pivotFields)&&this.#U(S.pivotFields),this.#X("model:changed",{reason:"page",groupPath:m.path,block:w}),M&&this.#_(m,M,a)}catch(S){if(v.settle(),U(S))return;m.cache.failed(w,S),this.#X("source:error",{error:S,groupPath:m.path,block:w})}}async#_(m,w,v){let a;try{a=await w}catch(o){if(v!==this.#d||this.#f)return;m.counting=!1,U(o)||this.#X("source:error",{error:o,groupPath:m.path});return}v!==this.#d||this.#f||(m.counting=!1,typeof a=="number"&&(m.count=a,m.complete=!0,this.#X("source:total",{total:a,groupPath:m.path}),this.#X("model:changed",{reason:"total",count:a,groupPath:m.path})))}totalPending(){return this.#r.counting===!0}#U(m){m.length===this.#c.length&&m.every((w,v)=>w===this.#c[v])||(this.#c=m,this.#X("column:pivoted",{pivotFields:m,remote:!0}))}#F(m){let w=this.#Y(m);for(const v of m.children.values())this.#V(v.key)&&(w+=this.#F(v));return w}#Y(m){if(m.count!==null)return m.count;const w=m.cache.loadedExtent();return m.complete?w:m.row&&m.row.leafCount>0?Math.max(w,m.row.leafCount):w+m.cache.pageSize}#D(m,w){let v=w,a=0;const o=[...m.children.entries()].filter(([,E])=>this.#V(E.key)).sort((E,A)=>E[0]-A[0]);for(const[E,A]of o){const M=E-a+1;if(v<M)return{node:m,local:a+v};v-=M,a=E+1;const C=this.#F(A);if(v<C)return this.#D(A,v);v-=C}const S=this.#Y(m);return a+v<S?{node:m,local:a+v}:null}#Z(m,w){const v=`${m.key}:${w}`,a=this.#l.get(v);if(a)return a;const o=m.cache.rowAt(w);if(o===void 0)return null;const S=this.#z("groupBy",[]);let E;if(m.level<S.length){const A=S[m.level],M=this.#G(o,A),C=M==null,P=[...m.path,C?"":String(M)],x=[...m.keyPath,C?null:String(M)];E=this.#s.group({path:P,keyPath:x,column:A,value:M,level:m.level,parent:m.row,leafCount:Number(o.leafCount)||0,expanded:this.#V(c(x))}),E.totals=this.#te(o),E.data=o;let K=this.#o.get(E.key);K?K.row=E:(K=new g(P,m.level+1,this.#n,x),K.row=E,this.#o.set(K.key,K)),K.values=[...m.values,M],m.children.set(w,K)}else E=this.#s.leaf(o,w,m.level,m.row);return this.#l.set(v,E),this.#u.set(E.key,v),E}#te(m){const w=m||{};if(w.totals&&typeof w.totals=="object")return w.totals;const v={};for(const a of this.#ee())Object.hasOwn(w,a)&&(v[a]=w[a]);return v}#le(m,w){const{start:v,end:a}=m.cache.rangeOf(w);for(let o=v;o<a;o++){const S=`${m.key}:${o}`,E=this.#l.peek(S);E&&this.#u.delete(E.key),this.#l.delete(S)}}#se(){const m=this.#ge();return m===this.#d?!1:(this.#d=m,this.#a.abortAll("query"),this.#ne(),this.#X("model:changed",{reason:"query"}),!0)}#ne(){for(const m of this.#o.values())m.cache.clear(),m.count=null,m.complete=!1,m.counting=!1,m.children.clear();this.#l.clear(),this.#u.clear()}#ge(){const m=this.#z("where",null);return`${n({filters:this.#z("filters",null),sort:this.#z("sort",[]),quick:this.#z("quick",""),groupBy:this.#z("groupBy",[]),pivotBy:this.#z("pivotBy",[]),context:this.#z("context",null)})}|${m?m.version:0}`}#V(m){const w=this.#z("expanded",null);return w?$(w.has)?w.has(m):Array.prototype.includes.call(w,m):this.#i.has(m)}#ee(){const m=this.#z("totals",[]);if(m&&m.length)return[...m];const w=this.#t.columns;return!w||!$(w.all)?[]:w.all().filter(v=>!!v.total).map(v=>v.id)}#I(m){const w=this.#t.columns,v={};if(!w||!$(w.get))return v;for(const a of m){const o=w.get(a);if(!o)continue;const S=o.groupTotal!=null?o.groupTotal:o.total;typeof S=="string"&&(v[a]=S)}return v}#G(m,w){const v=this.#t.columns,a=v&&$(v.get)?v.get(w):void 0;return a&&$(a.getValue)?a.getValue(m):m?.[w]}#K(){i(this.#t)}#we(){const m=this.#t.config||{};return{tz:m.timeZone,weekStartsOn:m.weekStartsOn}}#z(m,w){const v=this.#t.state;if(v&&$(v[m])){const a=v[m]();return a??w}return w}#X(m,w){const v=this.#t.emit;$(v)&&v(m,w)}}}),ke("packages/core/src/source/gapbuffer.js",function(e,V){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return R}});const _=64;class R{#e;#t=0;#n=0;constructor(L=_){this.#e=new Uint32Array(Math.max(1,L)),this.#n=this.#e.length}static from(L,W=_){const Z=new R(L.length+Math.max(1,W));return Z.#e.set(L,0),Z.#t=L.length,Z.#n=Z.#e.length,Z}get length(){return this.#t+(this.#e.length-this.#n)}get capacity(){return this.#e.length}at(L){return L<0||L>=this.length?0:L<this.#t?this.#e[L]:this.#e[L+(this.#n-this.#t)]}insert(L,W){const Z=L<0?0:L>this.length?this.length:L;this.#r(Z),this.#t===this.#n&&this.#o(),this.#e[this.#t++]=W}push(L){this.insert(this.length,L)}removeAt(L){return!Number.isInteger(L)||L<0||L>=this.length?!1:(this.#r(L),this.#n++,!0)}toArray(){const L=new Uint32Array(this.length);return L.set(this.#e.subarray(0,this.#t),0),L.set(this.#e.subarray(this.#n),this.#t),L}clear(){this.#t=0,this.#n=this.#e.length}#r(L){if(L!==this.#t)if(L<this.#t){const W=this.#t-L;this.#e.copyWithin(this.#n-W,L,this.#t),this.#t=L,this.#n-=W}else{const W=L-this.#t;this.#e.copyWithin(this.#t,this.#n,this.#n+W),this.#t=L,this.#n+=W}}#o(){const L=this.#e.length-this.#n,W=new Uint32Array(Math.max(this.#e.length*2,this.#e.length+_));W.set(this.#e.subarray(0,this.#t),0),W.set(this.#e.subarray(this.#n),W.length-L),this.#e=W,this.#n=W.length-L}}}),ke("packages/core/src/store/ingest.js",function(e,V){"use strict";Object.defineProperty(e,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"inferKind",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"decideText",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"createReaders",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"Ingest",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return t}});const _=V("packages/core/src/internal/util.js"),R=_.now,$=_.nextFrame,L=_.infoOnce,W=_.warnOnce,Z=_.isFunction,H=_.pathGetter,z=V("packages/core/src/store/columnstore.js").ColumnStore,F=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function k(n,i={}){if(i.multi)return"multi";if(n.length===0)return"object";let s=0,l=0,u=0,f=0,h=0;for(let b=0;b<n.length;b++){const p=n[b];typeof p=="number"?s++:typeof p=="boolean"?l++:typeof p=="string"?u++:p instanceof Date?f++:Array.isArray(p)&&h++}const g=n.length;return s===g?"float64":l===g?"bitset":f===g?"float64":u===g?"text":h===g?"multi":"object"}function O(n,i,s){return i<=0||n<s*i?"dictionary":"object"}function y(n,i,s){const l=new Map,u=new Map;for(const o of n){if(o.computed)continue;const S=Z(o.read)?o.read:H(o.field||o.id);u.set(o.id,S),l.set(o.id,S)}const f=i?.order??[],h=i?.fns??{},g=i?.deps??{},b=i?.wrapDeps??null,p=f.filter(o=>Z(h[o])),m=p.some(o=>g[o]==="*");let w=new WeakMap;const v=o=>{const S={};if(m)for(const[E,A]of u)S[E]=A(o);for(const E of p){const A=g[E];let M;if(A==="*")M=S;else{M={};const C=A||[];for(let P=0;P<C.length;P++){const x=C[P];M[x]=x in S?S[x]:u.get(x)?.(o)}}S[E]=h[E](b?b(M,E):M,{data:o,row:null,column:null,grid:null,context:s})}return S},a=o=>{if(o===null||typeof o!="object"&&typeof o!="function")return v(o);let S=w.get(o);return S===void 0&&(S=v(o),w.set(o,S)),S};for(const o of p)l.set(o,S=>a(S)[o]);return{readers:l,reset(){w=new WeakMap}}}class d{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 c{#e;#t=[];#n=null;#r;#o=0;#i;#a=!1;#s=!1;#l=0;#u;constructor(i,s={},l={}){this.#e=Array.isArray(i)?i:Array.from(i||[]),this.#i={...F,...l};const u=s.columns??[];this.#r=y(u,s.computed??null,s.context),this.#u=this.#e.length>=this.#i.columnarBelow,this.#c(u,s.computed??null),this.#n=new z(this.#t.map(f=>({id:f.spec.id,kind:f.kind,nullable:f.nullable,read:f.read,dictionary:f.spec.dictionary})),{initialCapacity:this.#i.initialCapacity,columnarBelow:this.#i.columnarBelow})}get store(){return this.#n}get done(){return this.#a||this.#s}get progress(){return this.#o}slice(){if(this.done)return!1;if(this.#i.signal?.aborted)return this.#s=!0,!1;const i=R(),{chunkMs:s,chunkRows:l}=this.#i,u=this.#e.length;do{const f=Math.min(this.#o+l,u);this.#n.append(this.#e.slice(this.#o,f)),this.#d(this.#o,f),this.#o=f,this.#r.reset(),this.#f(!1)}while(this.#o<u&&R()-i<s);return this.#l+=R()-i,this.#i.onProgress?.({loaded:this.#o,total:u}),this.#o>=u?(this.#f(!0),this.#a=!0,!1):!0}cancel(){this.#s=!0}result(){return{store:this.#n,schema:this.#t.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,read:i.read,dictionary:i.spec.dictionary})),decisions:this.#t.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,inferred:i.inferred,distinct:i.candidate||i.change?this.#h(i):null,change:i.change,reason:i.reason})),count:this.#n.count,elapsed:this.#l,cancelled:this.#s}}#c(i,s){const l=this.#e,u=Math.min(this.#i.sampleSize,l.length),f=this.#i.dictionaryRatio,h=s?.pure instanceof Set?s.pure:new Set(s?.pure??s?.order??[]);for(const g of i){if(!g||!g.id)continue;if(g.computed&&(g.pure===!1||s&&!h.has(g.id))){W(`ingest.impure.${g.id}`,`column "${g.id}" is an impure computed column and is not materialised into the store`);continue}const b=this.#r.readers.get(g.id)??(Z(g.read)?g.read:H(g.field||g.id)),p=new d(g,b);if(g.kind)p.kind=g.kind,p.reason="declared by the caller";else if(g.dictionary)p.kind=g.multi?"multi":"dictionary",p.reason="value table supplied (lookup column)";else{const m=[];for(let v=0;v<u&&m.length<this.#i.sampleSize;v++){const a=b(l[v]);a!=null&&m.push(a)}p.inferred=!0;const w=k(m,{multi:g.multi});if(w==="text"){const v=new Set(m).size;p.kind=O(v,m.length,f),p.candidate=this.#u,p.reason=`sampled ${v} distinct in ${m.length}`}else p.kind=w,p.reason=`inferred from ${m.length} sampled values`,w==="object"&&m.length&&L(`ingest.mixed.${g.id}`,`column "${g.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(m))}this.#t.push(p)}}#d(i,s){const l=this.#e;for(const u of this.#t){if(!u.candidate||!u.distinct)continue;const f=u.distinct;for(let h=i;h<s;h++){const g=u.read(l[h]);g!=null&&f.add(g)}}}#h(i){if(i.distinct)return i.distinct.size;const s=this.#n.column(i.spec.id);return s?.dict?s.dict.size:0}#f(i){const s=this.#i.dictionaryRatio,l=this.#e.length;for(const u of this.#t){if(!u.candidate)continue;const f=this.#h(u);if(u.kind==="dictionary"&&f>=s*l){const h=this.#n.column(u.spec.id);u.distinct=new Set(h?.dict?h.dict.values():[]),this.#n.convert(u.spec.id,"object"),u.kind="object",u.change="demoted",u.reason=`${f} distinct values is at or above ${s*100}% of ${l} rows`;continue}if(u.kind==="object"&&f>=s*l){u.candidate=!1,u.distinct=null,u.reason=`${f} distinct values is at or above ${s*100}% of ${l} rows`;continue}i&&u.kind==="object"&&f<s*l&&(this.#n.convert(u.spec.id,"dictionary"),u.kind="dictionary",u.change=u.change==="demoted"?null:"promoted",u.reason=`${f} distinct values is below ${s*100}% of ${l} rows`,u.distinct=null),i&&(u.candidate=!1)}}}async function r(n,i={},s={}){const l=new c(n,i,s),u=s.scheduler?.frame??$;for(;l.slice();)await new Promise(f=>{u(f)});return l.result()}function t(n,i={},s={}){const l=new c(n,i,{...s,chunkMs:1/0});for(;l.slice(););return l.result()}}),ke("packages/core/src/store/columnpack.js",function(e,V){"use strict";Object.defineProperty(e,"isPortableSchema",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"packChunk",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"packedTransfers",{enumerable:!0,get:function(){return c}});const R=V("packages/core/src/internal/util.js").pathGetter,$=V("packages/core/src/store/ingest.js"),L=$.inferKind,W=$.decideText,Z=$.INGEST_DEFAULTS,U=V("packages/core/src/store/columnstore.js").toFloat,z=new Set(["float64","int32","bitset","dictionary","object","multi"]);function F(r){if(!Array.isArray(r)||r.length===0)return!1;for(const t of r)if(!t||typeof t.id!="string"||typeof t.field!="string"||t.field===""||t.kind&&!z.has(t.kind))return!1;return!0}function k(r){const t=U(r);return Number.isFinite(t)?t|0:0}function O(r){return r==null?[]:Array.isArray(r)?r:[r]}function y(r,t,n,i){if(r.kind)return r.kind;const s=[];for(let f=0;f<t.length&&s.length<Z.sampleSize;f++){const h=t[f];h!=null&&s.push(h)}const l=L(s,{multi:r.multi});if(l!=="text")return l;const u=new Set(s).size;return W(u,s.length,i)}function d(r,t,n={}){const i=t.length|0,s=n.dictionaryRatio??Z.dictionaryRatio,l=[];for(const u of r){const f=R(u.field||u.id),h=u.nullable!==!1,g=new Array(i);for(let v=0;v<i;v++){const a=f(t[v]);g[v]=a===void 0?null:a}const b=y(u,g,i,s),p=h?new Uint8Array(i+7>>3):null,m=v=>{p&&(p[v>>3]|=1<<(v&7))};let w;switch(b){case"float64":{const v=new Float64Array(i);for(let a=0;a<i;a++){const o=g[a],S=o===null;S||m(a),v[a]=S?NaN:U(o)}w={id:u.id,kind:b,nullable:h,values:v,presence:p,offsets:null,table:null};break}case"int32":{const v=new Int32Array(i);for(let a=0;a<i;a++){const o=g[a],S=o===null;S||m(a),v[a]=S?0:k(o)}w={id:u.id,kind:b,nullable:h,values:v,presence:p,offsets:null,table:null};break}case"bitset":{const v=new Uint8Array(i+7>>3);for(let a=0;a<i;a++){const o=g[a],S=o===null;S||m(a),!S&&o&&(v[a>>3]|=1<<(a&7))}w={id:u.id,kind:b,nullable:h,values:v,presence:p,offsets:null,table:null};break}case"dictionary":{const v=new Uint32Array(i),a=[],o=new Map;for(let S=0;S<i;S++){const E=g[S];if(E===null){v[S]=0;continue}m(S);let A=o.get(E);A===void 0&&(A=a.length,a.push(E),o.set(E,A)),v[S]=A}w={id:u.id,kind:b,nullable:h,values:v,presence:p,offsets:null,table:a};break}case"multi":{const v=[],a=new Map,o=new Uint32Array(i+1),S=[];for(let E=0;E<i;E++){const A=g[E];o[E]=S.length,A===null||m(E);const C=O(A);for(let P=0;P<C.length;P++){const x=C[P];let K=a.get(x);K===void 0&&(K=v.length,v.push(x),a.set(x,K)),S.push(K)}}o[i]=S.length,w={id:u.id,kind:b,nullable:h,values:Int32Array.from(S),presence:p,offsets:o,table:v};break}default:{const v=new Array(i);for(let a=0;a<i;a++){const o=g[a];o!==null&&m(a),v[a]=o}w={id:u.id,kind:"object",nullable:h,values:v,presence:p,offsets:null,table:null};break}}l.push(w)}return{count:i,columns:l}}function c(r){const t=[];if(!r||!Array.isArray(r.columns))return t;const n=i=>{ArrayBuffer.isView(i)&&i.buffer&&!t.includes(i.buffer)&&t.push(i.buffer)};for(const i of r.columns)n(i.values),n(i.presence),n(i.offsets);return t}}),ke("packages/core/src/source/stream.js",function(e,V){"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 A}});const _=V("packages/core/src/internal/util.js"),R=_.Lru,$=_.isFunction,L=_.now,W=_.nextFrame,Z=_.cancelFrame,H=_.whenIdle,U=_.defaultCompare,z=_.warnOnce,F=_.infoOnce,k=_.getPath,O=V("packages/core/src/source/abort.js"),y=O.createAbortScope,d=O.isAbortError,c=V("packages/core/src/source/rows.js"),r=c.createRowFactory,t=c.lazyRowView,i=V("packages/core/src/source/gapbuffer.js").GapBuffer,l=V("packages/core/src/source/memory.js").createMemorySource,f=V("packages/core/src/source/filterwire.js").querySignature,g=V("packages/core/src/store/columnpack.js").isPortableSchema,b=25e4,p=Symbol("lattice.stream.storeBacked"),m=8,w=.1,v=1e3,a=50;function o(M){return Math.min(v,Math.max(a,Math.floor(M/4)))}function S(M){if(M instanceof Date)return M.getTime();if(typeof M=="number")return Number.isFinite(M)?M:NaN;if(typeof M=="string"){const C=M.trim();if(!C)return NaN;const P=Date.parse(C);return Number.isNaN(P)?Number(C):P}return NaN}function E(M,C){return new A(M,C)}class A{mode="stream";writesStore=!0;#e;#t;#n=[];#r=null;#o=[];#i=null;#a;#s;#l=new Map;#u=y();#c={loaded:0,estimated:void 0};#d=null;#h=0;#f=0;#m=0;#p=0;#g=null;#v=null;#b=null;#y=!1;#w=!1;#S=!1;#j=!1;#A="";#O=0;#C=0;#E=0;#T=null;#x=1/0;#R=!1;#N=null;#M=null;#_=null;#U=null;#F=!1;#Y=0;#D=0;#Z=!1;constructor(C,P){this.#e=C||{mode:"stream"},this.#t=P||{},this.#a=r(this.#t),this.#s=new R(4096),this.#A=this.#Me();const x=(this.#t.config||{}).ingest;this.#F=!!x&&x.retainSource===!1,$(this.#e.open)||z("source.stream.open",'source.mode "stream" requires an open function; the grid will stay empty.'),this.#e.autoStart!==!1&&queueMicrotask(()=>this.start());const K=Number(this.#e.poll);Number.isFinite(K)&&K>0&&(this.#U=setInterval(()=>{this.#j||this.reload()},K),this.#U&&$(this.#U.unref)&&this.#U.unref()),this.#le()}#te(){const C=Number(this.#e.maxAge);return Number.isFinite(C)&&C>0?C:0}#le(){const C=this.#te();if(!C)return;const P=this.#e.ageBy;$(P)?this.#M=P:typeof P=="string"&&P?this.#M=x=>k(x,P):this.#M=null,this.#T=[],this.#N=setInterval(()=>{this.#j||this.#se()&&(this.#re(),this.#Le())},o(C)),this.#N&&$(this.#N.unref)&&this.#N.unref()}#se(){const C=this.#te();return!C||!this.#T?!1:this.#R?!0:this.#x<Date.now()-C*(1+w)}#ne(C,P){if(!this.#T)return;const x=this.#M?S(this.#M(P)):Date.now();this.#T[C]=x,Number.isNaN(x)||(x<this.#x&&(this.#x=x),x<Date.now()-this.#te()&&(this.#R=!0))}#ge(){return this.#he("groupBy",[]).length>0?!0:!!this.#he("pivotMode",!1)&&this.#he("pivotBy",[]).length>0}#V(){if(this.#g||this.#j)return;const C=this.#ge();if(C&&!this.#v){this.#v=l({mode:"memory",rows:this.#n},this.#ee()),this.#y=!1;return}!C&&this.#v&&(this.#v.destroy(),this.#v=null)}#ee(){if(this.#b)return this.#b;const C=this,P={liveIndices:()=>C.#I(),live:x=>C.#n[x]!==void 0,source:x=>C.#me(x),get physical(){return C.#n.length}};return this.#F&&(P.column=x=>{const K=C.#t.store;return K&&$(K.column)?K.column(x):void 0}),this.#b=Object.create(this.#t,{store:{value:P,enumerable:!0,configurable:!0}}),this.#b}#I(){const C=new Uint32Array(this.#n.length);let P=0;for(let x=0;x<this.#n.length;x++)this.#n[x]!==void 0&&(C[P++]=x);return C.subarray(0,P)}#G(){return this.#g?this.#g:this.#v?(this.#y&&(this.#y=!1,this.#v.setRows(this.#n)),this.#v):null}invalidate(C="filter"){if(this.#g){this.#g.invalidate(C);return}this.#V(),this.#v&&this.#v.invalidate(C),(C==="filter"||C==="sort")&&this.#$()}count(){const C=this.#G();return C?C.count():this.#r?this.#r.length:this.#O}matchCount(){const C=this.#G();return C&&$(C.matchCount)?C.matchCount():this.#r?this.#r.length:this.#O}totalCount(){const C=this.#G();return C&&$(C.totalCount)?C.totalCount():this.#O}unfilteredRows(){const C=this.#G();if(C&&$(C.unfilteredRows))return C.unfilteredRows();const P=[];for(let x=0;x<this.#n.length;x++){if(!this.#n[x])continue;const K=this.#q(x);K&&P.push(K)}return P}at(C){const P=this.#G();if(P)return P.at(C);if(C<0||C>=this.count())return;const x=this.#r?this.#r.at(C):C,K=this.#q(x);return K.index=C,K}byKey(C){const P=this.#G();if(P)return P.byKey(C);const x=this.#l.get(C);return x===void 0?void 0:this.#q(x)}leavesOf(C){const P=this.#G();return P&&$(P.leavesOf)?P.leavesOf(C):[]}loaded(C){return C>=0&&C<this.count()}hint(C,P){if(this.#g){this.#g.hint(C,P);return}this.#K(),this.#m=Math.max(0,Math.floor(C))}#K(){this.#j||this.#Me()===this.#A||this.reload()}display(){const C=this.#G();return C?C.display():t(()=>this.count(),P=>this.at(P))}apply(C){if(this.#g)return this.#g.apply(C);const P={added:[],updated:[],removed:[]};if(!C)return P;if(C.update){let x=!1;for(const K of C.update){const I=this.#l.get(this.#a.keyOf(K,-1));if(I===void 0)continue;const D=this.#ae(I);this.#F?this.#Ge(I,K):this.#n[I]=K,this.#s.delete(I),this.#k(I,D),this.#T&&(this.#ne(I,K),x=!0),this.#y=!0,P.updated.push(this.#q(I))}x&&this.#re()}if(C.add&&C.add.length){const x=this.#W(C.add);for(const K of x)P.added.push(this.#q(K))}return C.remove&&C.remove.length&&z("source.stream.remove","removing rows from a live stream is not supported; reload instead."),this.#Le(),P}reload(C){this.#u.abortAll("reload"),this.#et(),this.#v&&(this.#v.destroy(),this.#v=null),this.#y=!1,this.#n=[],this.#r=null,this.#l.clear(),this.#s.clear(),this.#g=null,this.#O=0,this.#C=0,this.#E=0,this.#T&&(this.#T=[]),this.#x=1/0,this.#R=!1,this.#w=!1,this.#S=!1,this.#c={loaded:0,estimated:void 0},this.#A=this.#Me(),this.#be("model:changed",{reason:"reload"}),this.start()}destroy(){this.#j=!0,this.#U!==null&&(clearInterval(this.#U),this.#U=null),this.#N!==null&&(clearInterval(this.#N),this.#N=null),this.#T=null,this.#u.abortAll("destroyed"),this.#et(),this.#d!==null&&(this.#Ze(this.#d),this.#d=null),this.#v&&(this.#v.destroy(),this.#v=null),this.#g&&this.#g.destroy(),this.#n=[],this.#r=null,this.#l.clear(),this.#s.clear()}async start(){if(this.#S||this.#j||!$(this.#e.open))return;this.#S=!0;const C=this.#u.begin("stream");this.#$(),this.#V();let P;try{P=this.#e.open({sort:this.#he("sort",[]),filters:this.#he("filters",null),quick:this.#he("quick","")||void 0,context:this.#he("context",null),signal:C.signal})}catch(K){this.#be("source:error",{error:K});return}const x=$(P[Symbol.asyncIterator])?P[Symbol.asyncIterator]():P[Symbol.iterator]();this.#_=x;try{for(;;){const K=await x.next();if(!C.current||this.#j)return;if(K.done){this.#je();return}if(await this.#we(K.value,C),!C.current||this.#j)return;if(K.value&&K.value.done){this.#je();return}if(await this.#Fe(),!C.current||this.#j)return}}catch(K){if(d(K))return;this.#be("source:error",{error:K})}finally{C.settle()}}progress(){return{loaded:this.#c.loaded,estimated:this.#c.estimated,done:this.#w,live:this.#O,evicted:this.#C}}promoted(){return this.#g!==null}memorySource(){return this.#g}invalidateHandles(){const C=this.#G();C&&($(C.invalidateHandles)&&C.invalidateHandles(),$(C.invalidate)&&C.invalidate("sort"))}renderCount(){return this.#h}ingestStats(){return{worker:this.#Y,inline:this.#D,storeBacked:this.#F}}#we(C,P){if(!C)return;const x=C.rows;if(x&&x.length&&this.#X(x))return this.#Oe(C,P);const K=L();x&&x.length&&(this.#W(x),this.#D++),this.#z(C),this.#f+=L()-K,this.#Le()}#z(C){this.#c.loaded=C.progress&&typeof C.progress.loaded=="number"?C.progress.loaded:this.#n.length,C.progress&&typeof C.progress.estimated=="number"&&(this.#c.estimated=C.progress.estimated)}#X(C){if(this.#Z||this.#g)return!1;const P=this.#ye();if(!P)return!1;const x=this.#t.store;if(!x||!$(x.appendPacked))return!1;const K=this.#ve();return!K||!g(K)?(this.#Z=!0,F("source.stream.ingest-worker","stream ingest.useWorker is on but a column reads through a closure (a computed or date column); columnizing on the main thread instead."),!1):C.length<P.threshold?!1:!this.#Se(C)}#Se(C){if(!this.#a.keyed)return!1;const P=new Set;for(let x=0;x<C.length;x++){const K=this.#a.keyOf(C[x],this.#n.length+x);if(K!=null){if(P.has(K)||this.#l.has(K))return!0;P.add(K)}}return!1}async#Oe(C,P){const x=C.rows,K=this.#ye(),I=this.#ve();let D;try{D=await K.columnize(I,x,{key:"ingest:stream",signal:P&&P.signal})}catch(X){if(d(X)||(z("source.stream.columnize","worker columnization failed; columnizing on the main thread",X),this.#Z=!0,P&&(!P.current||this.#j)))return;this.#W(x),this.#D++,this.#z(C),this.#Le();return}if(P&&(!P.current||this.#j))return;const j=this.#t.store,T=this.#F?void 0:x,{from:B}=j.appendPacked(D,T),q=D.count|0;for(let X=0;X<q;X++){const Q=B+X,J=x[X],ne=this.#a.keyed?this.#a.keyOf(J,Q):null;if(this.#n[Q]=this.#F?p:J,this.#O++,this.#ne(Q,J),ne!==null&&this.#l.set(ne,Q),!this.#r||!this.#oe(Q))continue;const re=this.#ce(Q);this.#r.insert(re,Q),re<=this.#m&&this.#p++}this.#y=!0,this.#re(),this.#Y++,this.#z(C),this.#Le()}#ye(){const C=this.#t.ingestWorker;return $(C)?C():null}#ve(){const C=this.#t.storeSchema;return $(C)?C():null}#W(C){const P=[],x=this.#t.store,K=new Array(C.length),I=[],D=new Set;for(let T=0;T<C.length;T++){const B=this.#a.keyed?this.#a.keyOf(C[T],this.#n.length+I.length):null;K[T]=B,!(B!==null&&(this.#l.has(B)||D.has(B)))&&(B!==null&&D.add(B),I.push(C[T]))}let j=I.length&&x&&$(x.append)?x.append(I).from:this.#n.length;for(let T=0;T<C.length;T++){const B=C[T],q=K[T];if(q!==null&&this.#l.has(q)){const J=this.#l.get(q),ne=this.#ae(J);this.#F||(this.#n[J]=B,x&&$(x.setSource)&&x.setSource(J,B)),this.#Ge(J,B),this.#s.delete(J),this.#ne(J,B),this.#k(J,ne);continue}const X=j++;if(this.#n[X]=this.#F?p:B,this.#O++,this.#ne(X,B),q!==null&&this.#l.set(q,X),P.push(X),!this.#r||!this.#oe(X))continue;const Q=this.#ce(X);this.#r.insert(Q,X),Q<=this.#m&&this.#p++}return this.#y=!0,this.#re(),P}#Re(C){const P=this.#n[C];let x=!1;if(this.#r){const j=this.#H(C);j>=0&&j<=this.#m&&(x=!0)}else C<=this.#m&&(x=!0);const K=P===p?this.#me(C):P,I=this.#a.keyed?this.#a.keyOf(K,C):null;I!==null&&this.#l.get(I)===C&&this.#l.delete(I),this.#n[C]=void 0,this.#T&&(this.#T[C]=NaN),this.#s.delete(C);const D=this.#t.store;return D&&$(D.remove)&&D.remove(C),this.#O--,x}#re(){let C=0,P=0;const x=this.#ie();C+=x.dropped,P+=x.aboveAnchor;const K=this.#fe();C+=K.dropped,P+=K.aboveAnchor,C&&(this.#y=!0,this.#C+=C,this.#$(),this.#p-=P,this.#be("stream:evicted",{evicted:C,total:this.#C,live:this.#O}))}#fe(){const C=this.#e.maxRows;if(!Number.isFinite(C)||C<=0||this.#O<=C)return{dropped:0,aboveAnchor:0};const P=Math.max(1,Math.floor(C*(1-w)));let x=0,K=0;for(;this.#O>P&&this.#E<this.#n.length;){const I=this.#E++;this.#n[I]!==void 0&&(this.#Re(I)&&K++,x++)}return{dropped:x,aboveAnchor:K}}#ie(){const C=this.#te();if(!C||!this.#T||!this.#se())return{dropped:0,aboveAnchor:0};const P=Date.now()-C;let x=0,K=0,I=1/0;for(let D=this.#E;D<this.#n.length;D++){if(this.#n[D]===void 0)continue;const j=this.#T[D];if(!(Number.isNaN(j)||j===void 0)){if(j>=P){j<I&&(I=j);continue}this.#Re(D)&&K++,x++}}for(this.#x=I,this.#R=!1;this.#E<this.#n.length&&this.#n[this.#E]===void 0;)this.#E++;return{dropped:x,aboveAnchor:K}}#H(C){if(!this.#r)return C;for(let P=0;P<this.#r.length;P++)if(this.#r.at(P)===C)return P;return-1}#$(){this.#o=this.#he("sort",[]),this.#i=this.#he("filters",null);const C=Number.isFinite(this.#e.maxRows)&&this.#e.maxRows>0||this.#te()>0,P=this.#he("where",null),x=(this.#t.config||{}).hostFilter,K=!!(P&&P.active)||!!(x&&$(x.active)&&x.active());if(!(C||this.#o.length>0||!!this.#i||!!this.#he("quick","")||K)){this.#r=null;return}this.#r=new i(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.#ce(D),D)}#oe(C){const P=this.#me(C);if(this.#i&&!this.#ue(this.#i,P))return!1;const x=String(this.#he("quick","")||"").toLowerCase();if(x&&!this.#Je(P).includes(x))return!1;const K=(this.#t.config||{}).hostFilter;if(K&&$(K.active)&&K.active()&&!K.passes(this.#q(C)))return!1;const I=this.#he("where",null);if(I&&I.active){const D=this.#q(C);if(!I.passes(D.data,D.key))return!1}return!0}#ue(C,P){if(!C)return!0;const x=C;if(Array.isArray(x.conditions))return x.op==="or"?x.conditions.some(D=>this.#ue(D,P)):x.op==="not"?!x.conditions.some(D=>this.#ue(D,P)):x.conditions.every(D=>this.#ue(D,P));const K=C,I=(this.#t.compute||{}).testValue;return $(I)?!!I(this.#$e(P,K.col),K,(this.#t.config||{}).locale):(z("source.stream.testValue","ctx.compute.testValue is unavailable; streamed rows are not filtered client-side."),!0)}#ae(C){if(!this.#r)return-1;if(!this.#o.length)return this.#H(C);let P=0,x=this.#r.length;for(;P<x;){const K=P+x>>>1;this.#Te(this.#r.at(K),C)<0?P=K+1:x=K}for(let K=P;K<this.#r.length;K++){const I=this.#r.at(K);if(I===C)return K;if(this.#Te(I,C)>0)break}return this.#H(C)}#k(C,P){if(!this.#r||!this.#o.length)return;const x=this.#oe(C);if(P>=0&&this.#r.at(P)===C)this.#r.removeAt(P),P<=this.#m&&this.#p--;else if(P>=0)return;if(!x)return;const K=this.#ce(C);this.#r.insert(K,C),K<=this.#m&&this.#p++}#ce(C){if(!this.#r||!this.#o.length)return this.#r?this.#r.length:0;let P=0,x=this.#r.length;for(;P<x;){const K=P+x>>>1;this.#Te(C,this.#r.at(K))<0?x=K:P=K+1}return P}#Te(C,P){const x=this.#me(C),K=this.#me(P);for(const I of this.#o){const D=this.#Ke(I.col),j=this.#$e(x,I.col),T=this.#$e(K,I.col),q=(D&&D.value&&$(D.value.compare)?D.value.compare:U)(j,T);if(q!==0)return I.dir==="desc"?-q:q}return 0}#je(){this.#w=!0,this.#c.loaded=this.#c.loaded||this.#n.length;const C=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:b;!this.#F&&this.#n.length<C&&(this.#g=l({mode:"memory",rows:this.#n},this.#t),this.#N!==null&&(clearInterval(this.#N),this.#N=null),this.#v&&(this.#v.destroy(),this.#v=null)),this.#Le(),this.#be("stream:end",{loaded:this.#n.length,promoted:this.#g!==null,threshold:C})}#Le(){this.#d!==null||this.#j||(this.#d=this.#Ve(()=>{this.#d=null,this.#h++;const C=this.#p;this.#p=0,this.#f=0,this.#be("stream:chunk",{loaded:this.#c.loaded,estimated:this.#c.estimated,count:this.count(),renders:this.#h}),this.#be("model:changed",{reason:"stream",shiftAboveViewport:C,anchor:this.#m})}))}#Fe(){return this.#h===0||this.#f<this.#xe()?Promise.resolve():(this.#f=0,new Promise(C=>{const P=(this.#t.scheduler||{}).idle;$(P)?P(()=>C()):H(()=>C())}))}#xe(){return typeof this.#e.coalesceMs=="number"&&this.#e.coalesceMs>0?this.#e.coalesceMs:m}#Ve(C){const P=this.#t.scheduler||{};return $(P.frame)?P.frame(C):W(C)}#Ze(C){const P=this.#t.scheduler||{};$(P.cancel)?P.cancel(C):Z(C)}#me(C){const P=this.#n[C];if(P!==void 0&&P!==p)return P;if(P===void 0)return;const x=this.#t.store;return x&&$(x.source)?x.source(C):void 0}#Ge(C,P){const x=this.#t.store;if(!x||!$(x.set))return;const K=this.#ve();if(Array.isArray(K))for(const I of K){if(!I||!I.id)continue;const D=$(I.read)?I.read:j=>k(j,I.field||I.id);x.set(I.id,C,D(P))}}#q(C){let P=this.#s.get(C);return P||(P=this.#a.leaf(this.#me(C),C),this.#s.set(C,P)),P}#$e(C,P){const x=this.#Ke(P);return x&&$(x.getValue)?x.getValue(C):C?.[P]}#Je(C){const P=this.#t.columns,x=P&&$(P.all)?P.all():[],K=[];for(const I of x){const D=$(I.getValue)?I.getValue(C):void 0;D!=null&&D!==""&&K.push(String(D))}return K.join(" ").toLowerCase()}#Ke(C){const P=this.#t.columns;return P&&$(P.get)?P.get(C):void 0}#et(){const C=this.#_;if(this.#_=null,C&&$(C.return))try{C.return()}catch{}}#Me(){return f({context:this.#he("context",null)})}#he(C,P){const x=this.#t.state;if(x&&$(x[C])){const K=x[C]();return K??P}return P}#be(C,P){const x=this.#t.emit;$(x)&&x(C,P)}}}),ke("packages/core/src/source/url.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_URL_BATCH",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return k}});const _=V("packages/core/src/internal/util.js"),R=_.warnOnce,$=_.isObject,L=_.isFunction,W=_.getPath,H=V("packages/core/src/source/abort.js").isAbortError,U=500,z=new Set(["application/x-ndjson","application/ndjson","application/jsonlines","application/jsonl","application/x-jsonlines","text/x-ndjson"]),F=Symbol("lattice.url.skip");function k(g,b={}){const p=$(b)?b:{},m=L(p.fetch)?p.fetch:typeof globalThis<"u"&&L(globalThis.fetch)?globalThis.fetch:null,w=p.format==="json"||p.format==="ndjson"?p.format:void 0,v=typeof p.rowsPath=="string"&&p.rowsPath?p.rowsPath:void 0,a=L(p.map)?p.map:void 0,o=$(p.headers)?p.headers:void 0,S=Number.isFinite(p.batchSize)&&p.batchSize>0?Math.floor(p.batchSize):U,E=p.lenient===!0,A=Number.isFinite(p.poll)&&p.poll>0?Math.floor(p.poll):void 0,M=typeof g=="string"&&g.length>0;M||R("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*C(x={}){if(!M)return;if(!m)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const K=x&&x.signal;let I;try{I=await m(g,o?{signal:K,headers:o}:{signal:K})}catch(T){throw H(T)?T:new Error(`[lattice] createUrlSource: request to ${g} failed — ${T&&T.message||T}`)}if(!I||!I.ok){const T=I?I.status:"no response";throw new Error(`[lattice] createUrlSource: ${T} for ${g}`)}const D=O(g,w,I),j=I.body&&L(I.body.getReader)?I.body.getReader():null;try{if(!j){const q=await I.text();(D||c(q,g))==="ndjson"?yield*l(null,null,q,0,I,g,S,E):yield*s(q,g,v,a);return}const T=new TextDecoder("utf-8");if(D==="json"){yield*s(await i(j,T,""),g,v,a);return}if(D==="ndjson"){yield*l(j,T,"",0,I,g,S,E);return}const B=await r(j,T,g);B.format==="json"?yield*s(await i(j,T,B.seed),g,v,a):yield*l(j,T,B.seed,B.bytes,I,g,S,E)}finally{if(j&&L(j.cancel))try{await j.cancel()}catch{}}}const P={mode:"stream",open:C,autoStart:p.autoStart!==!1};return A!==void 0&&(P.poll=A),Number.isFinite(p.maxRows)&&(P.maxRows=p.maxRows),Number.isFinite(p.maxAge)&&(P.maxAge=p.maxAge),(typeof p.ageBy=="string"||L(p.ageBy))&&(P.ageBy=p.ageBy),Number.isFinite(p.coalesceMs)&&(P.coalesceMs=p.coalesceMs),Number.isFinite(p.promoteToMemoryBelow)&&(P.promoteToMemoryBelow=p.promoteToMemoryBelow),P}function O(g,b,p){if(b)return b;const m=y(g);if(m)return m;const w=p&&p.headers&&L(p.headers.get)?p.headers.get("content-type"):null;return d(w)}function y(g){const b=String(g).split(/[?#]/)[0].toLowerCase();if(b.endsWith(".ndjson")||b.endsWith(".jsonl"))return"ndjson";if(b.endsWith(".json"))return"json"}function d(g){if(!g)return;const b=g.split(";")[0].trim().toLowerCase();if(z.has(b))return"ndjson";if(b==="application/json"||b==="text/json"||b.endsWith("+json"))return"json"}function c(g,b){const p=g.replace(/^\s+/,""),m=t(p);if(m==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${b} — pass opts.format: 'json' | 'ndjson'.`);return m}async function r(g,b,p){let m="",w=0;for(;;){const{value:a,done:o}=await g.read();if(a&&(w+=a.byteLength,m+=b.decode(a,{stream:!0})),o){m+=b.decode();break}const S=m.replace(/^\s+/,"");if(S){if(S[0]==="[")return{format:"json",seed:m,bytes:w};if(S[0]!=="{"||m.indexOf(`
8
8
  `)!==-1)break}}const v=t(m.replace(/^\s+/,""));if(v==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${p} — pass opts.format: 'json' | 'ndjson'.`);return{format:v,seed:m,bytes:w}}function t(g){if(!g||g[0]==="[")return"json";if(g[0]!=="{")return"error";const b=g.indexOf(`
9
9
  `);if(b===-1)return"json";let p=g.slice(0,b);return p.endsWith("\r")&&(p=p.slice(0,-1)),n(p)?"ndjson":"json"}function n(g){try{return JSON.parse(g),!0}catch{return!1}}async function i(g,b,p){let m=p;for(;;){const{value:w,done:v}=await g.read();if(w&&(m+=b.decode(w,{stream:!0})),v)break}return m+=b.decode(),m}function*s(g,b,p,m){let w;try{w=JSON.parse(g)}catch(a){throw new Error(`[lattice] createUrlSource: ${b} is not valid JSON — ${a.message}`)}let v=p!==void 0?W(w,p):w;if(m&&(v=m(v)),!Array.isArray(v)){const a=p!==void 0||m?"":"; pass opts.rowsPath or opts.map to select the array";throw new Error(`[lattice] createUrlSource: ${b} did not resolve to an array${a}.`)}yield{rows:v,progress:{loaded:v.length,estimated:v.length}}}async function*l(g,b,p,m,w,v,a,o){const S=h(w);let E=p||"",A=m||0,M=0,C=0,P=[];function*x(){let I;for(;(I=E.indexOf(`
@@ -51,6 +51,6 @@ ${ne}[data-heat-side="low"]{background-color:color-mix(in srgb, var(--lattice-va
51
51
  `,w),E=p.slice(o,S),A=E.split(`
52
52
  `);let M=0;const C=A.map(P=>{if(!g)return M+=v.length,v+P;if(P.startsWith(v))return M-=v.length,P.slice(v.length);const x=P.replace(/^[ \t]/,"");return M-=P.length-x.length,x}).join(`
53
53
  `);return C===E?!1:(b.value=p.slice(0,o)+C+p.slice(S),this.#r(Math.max(o,m+(g?-v.length:v.length)),Math.max(o,w+M)),this.revalidate(),!0)}#r(g,b){const p=this.input;p&&(p.selectionStart=g,p.selectionEnd=b===void 0?g:b,H(p.setSelectionRange)&&p.setSelectionRange(p.selectionStart,p.selectionEnd))}format(g){const b=this.input;if(!b||this.language!=="json")return!1;const p=r(b.value);if(!p.ok)return this.revalidate(),!1;if(p.value===null&&b.value.trim()==="")return!1;try{const m=JSON.stringify(p.value,null,g===void 0?this.indent:g);return m===void 0?!1:(b.value=m,this.#r(m.length),this.revalidate(),!0)}catch{return!1}}revalidate(){const g=this.input?this.input.value:"",b=s(g,this.language);this.lastResult=b;const p=this.errorNode;return p&&(p.textContent=b.ok?"":l(b),p.classList.toggle(k.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 g=this.text();if(g.trim()==="")return null;if(this.language!=="json"||(this.props.parseOnCommit??!0)!==!0)return g;const p=r(g);return p.ok?p.value:g}checkValue(g){if(this.props.allowInvalid===!0)return!0;const b=this.revalidate();return b.ok?!0:l(b)}toClipboard(){return this.text()}fromClipboard(g){const b=g==null?"":String(g);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:F(b)}}destroy(){for(const g of this.#e)g();this.#e.length=0,this.input=null,this.errorNode=null,this.formatButton=null,super.destroy()}}const f=u}),ke("packages/dom/src/editors/unit.js",function(e,V){"use strict";Object.defineProperty(e,"presentUnit",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const _=V("packages/dom/src/editors/common.js"),R=_.BaseEditor,$=_.CLS,L=_.el,W=_.on,H=V("packages/core/src/internal/util.js").isFunction,U=V("packages/core/src/columns/types/unit.js"),z=U.parseUnit,F=U.formatUnit,k=U.findUnit;function O(c,r){return F(c,r)}class y extends R{input=null;hint=null;opts=null;#e=[];buildOptions(){const r=this.props,t=this.params.column&&this.params.column.dataType||null,n=t&&t.unitConfig||{};return{system:r.system||n.system||"data",unit:r.unit??n.unit,binary:r.binary===!0||r.binary===void 0&&n.binary===!0,display:r.display??n.display,locale:this.params.locale,group:!1,minDecimals:0,maxDecimals:20}}build(){const r=this.props;this.opts=this.buildOptions();const t=this.symbol(),n=`${this.id}-unit`,i=L(this.doc,"input",{class:$.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:r.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":t?n:null}});i.value=O(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(i.value=this.params.key),this.input=i;const s=typeof r.step=="number"?r.step:0;return s>0&&this.#e.push(W(i,"keydown",l=>{l.key==="ArrowUp"?(H(l.preventDefault)&&l.preventDefault(),this.nudge(s)):l.key==="ArrowDown"&&(H(l.preventDefault)&&l.preventDefault(),this.nudge(-s))})),this.hint=L(this.doc,"span",{class:`${$.editor}__suffix`,text:t,attrs:{id:n,"aria-hidden":"true"}}),L(this.doc,"div",{class:`${$.editor}__unit`,children:[i,this.hint]})}symbol(){const r=k(this.opts.system,this.opts.unit);return r?r.symbol:String(this.opts.unit||"")}focusTarget(){return this.input}attached(){super.attached();const r=this.input;r&&!this.params.key&&this.props.selectOnFocus!==!1&&H(r.select)&&r.select()}nudge(r){const t=z(this.input?this.input.value:"",this.opts);let n=(t??0)+r;const{min:i,max:s}=this.props;typeof i=="number"&&n<i&&(n=i),typeof s=="number"&&n>s&&(n=s),this.input&&(this.input.value=O(n,this.opts))}readValue(){const r=this.input?this.input.value:"";if(String(r).trim()==="")return null;const t=z(r,this.opts);if(t===null)return NaN;if(this.mode()!=="clamp")return t;const{min:n,max:i}=this.props;let s=t;return typeof n=="number"&&s<n&&(s=n),typeof i=="number"&&s>i&&(s=i),s}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}checkValue(r){if(r===null)return!0;if(typeof r!="number"||Number.isNaN(r)){const t=this.symbol();return t?`Enter a value such as 10 ${t}`:"Enter a value"}if(this.mode()==="reject"){const{min:t,max:n}=this.props;if(typeof t=="number"&&r<t)return`Must be ${this.describe(t)} or more`;if(typeof n=="number"&&r>n)return`Must be ${this.describe(n)} or less`}return!0}describe(r){return F(r,{...this.opts,display:this.opts.unit,group:!0,maxDecimals:4})}toClipboard(){return F(this.readValue(),{...this.opts,display:this.opts.unit})}fromClipboard(r){const t=r==null?"":String(r);if(t.trim()==="")return{ok:!0,value:null};const n=z(t,this.opts),i=n===null?NaN:n,s=this.checkValue(i);return s!==!0?{ok:!1,message:s}:{ok:!0,value:i}}destroy(){for(const r of this.#e)r();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const d=y}),ke("packages/dom/src/editors/radix.js",function(e,V){"use strict";Object.defineProperty(e,"RADIX_CLS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"mergeRadixOptions",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});const _=V("packages/dom/src/editors/common.js"),R=_.BaseEditor,$=_.CLS,L=_.el,W=_.on,Z=V("packages/core/src/internal/util.js"),H=Z.isFunction,U=Z.uid,z=V("packages/core/src/columns/types/radix.js"),F=z.compileRadixFormat,k=z.compileRadixParse,O=z.normaliseRadixOptions,y=z.radixRange,d=Object.freeze({root:"lat-editor__radix",hint:"lat-editor__hint",hintInvalid:"lat-editor__hint--invalid"}),c=Object.freeze(["preset","radix","prefix","uppercase","pad","group","groupSeparator","bitWidth","signed","nullDisplay"]),r=new Map;function t(l){const u=l||"";let f=r.get(u);if(f)return f;try{f=new Intl.NumberFormat(l||void 0,{maximumFractionDigits:0})}catch{f={format:h=>String(h)}}return r.set(u,f),f}function n(l,u){const f=u||{},h={};if(l){for(const b of c)l[b]!==void 0&&(h[b]=l[b]);const g=y(l.bitWidth??null,l.signed!==!1);typeof l.min=="number"&&l.min>g.min&&(h.min=l.min),typeof l.max=="number"&&l.max<g.max&&(h.max=l.max)}for(const g of c)f[g]!==void 0&&(h[g]=f[g]);return typeof f.min=="number"&&(h.min=f.min),typeof f.max=="number"&&(h.max=f.max),O(h)}class i extends R{input=null;hint=null;options=null;format=null;parse=null;#e=[];build(){const u=this.params.column&&this.params.column.dataType;this.options=n(u&&u.radix||null,this.props),this.format=F(this.options),this.parse=k(this.options);const f=L(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}});f.value=this.format(this.params.value),this.params.key&&this.#t(this.params.key)&&(f.value=this.params.key),this.input=f;const h=L(this.doc,"span",{class:d.hint,attrs:{"aria-live":"polite"}});this.hint=h,this.#e.push(W(f,"input",()=>this.refresh())),this.#e.push(W(f,"keydown",b=>this.#n(b)));const g=L(this.doc,"div",{class:d.root,children:[f,h]});return this.refresh(),g}focusTarget(){return this.input}attached(){super.attached();const u=this.input;u&&!this.params.key&&this.props.selectOnFocus!==!1&&H(u.select)&&u.select()}#t(u){return u.length===1&&/[0-9a-fA-FxXbBoO#+\-.]/.test(u)}#n(u){const f=typeof this.props.step=="number"&&this.props.step!==0?this.props.step:1;u.key==="ArrowUp"?(H(u.preventDefault)&&u.preventDefault(),this.nudge(f)):u.key==="ArrowDown"&&(H(u.preventDefault)&&u.preventDefault(),this.nudge(-f))}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}clamp(u){const{min:f,max:h}=this.options;return u<f?f:u>h?h:u}evaluate(){const u=this.input?String(this.input.value):"";if(u.trim()==="")return{value:null,message:null};const f=this.parse(u);return f.ok?{value:this.mode()==="clamp"?this.clamp(f.value):f.value,message:null}:this.mode()==="clamp"&&typeof f.value=="number"&&(f.reason==="range"||f.reason==="negative")?{value:this.clamp(f.value),message:null}:{value:NaN,message:this.messageFor(f.reason)}}messageFor(u){const f=this.options;return u==="negative"?`This column holds an unsigned ${f.bitWidth}-bit pattern; enter ${this.format(0)} or more`:u==="range"?`Must be between ${this.format(f.min)} and ${this.format(f.max)}`:`Enter a ${f.name} value, e.g. ${this.format(f.radix===2?5:26)}`}refresh(){const{value:u,message:f}=this.evaluate();if(this.input&&this.input.classList&&(f?this.input.classList.add($.invalid):this.input.classList.remove($.invalid),this.input.setAttribute("aria-invalid",f?"true":"false"),f&&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(f){this.hint.textContent=f,this.hint.classList&&this.hint.classList.add(d.hintInvalid);return}this.hint.classList&&this.hint.classList.remove(d.hintInvalid),this.hint.textContent=u===null?"":`= ${t(this.params.locale).format(u)}`}}nudge(u){if(!this.input)return;const f=this.parse(this.input.value);let h;typeof f.value=="number"?h=f.value:typeof this.params.value=="number"?h=this.params.value:h=0,this.input.value=this.format(this.clamp(h+u)),this.refresh()}readValue(){return this.evaluate().value}checkValue(u){return u===null?!0:typeof u!="number"||Number.isNaN(u)?this.evaluate().message||this.messageFor("digits"):!this.options.signed&&u<0?this.messageFor("negative"):this.mode()==="reject"&&(u<this.options.min||u>this.options.max)?this.messageFor("range"):!0}toClipboard(){const u=this.readValue();return u===null||Number.isNaN(u)?this.input?String(this.input.value):"":this.format(u)}fromClipboard(u){const f=u==null?"":String(u);if(f.trim()==="")return{ok:!0,value:null};const h=this.parse(f);let g;if(h.ok)g=h.value;else if(this.mode()==="clamp"&&typeof h.value=="number"&&(h.reason==="range"||h.reason==="negative"))g=this.clamp(h.value);else return{ok:!1,message:this.messageFor(h.reason)};const b=this.checkValue(g);return b!==!0?{ok:!1,message:b}:{ok:!0,value:g}}destroy(){for(const u of this.#e)u();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const s=i}),ke("packages/dom/src/editors/segmented.js",function(e,V){"use strict";Object.defineProperty(e,"SEGMENTED_MAX",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const _=V("packages/dom/src/editors/common.js"),R=_.BaseEditor,$=_.CLS,L=_.el,W=_.on,Z=_.keyOf,H=_.normaliseLookup,U=_.documentFor,z=_.lookupFor,k=V("packages/dom/src/editors/select.js").SelectEditor,y=V("packages/core/src/internal/util.js").isFunction,c=V("packages/dom/src/cell/icons.js").createIcon,r=6;class t extends R{static popup=!1;options=[];selected=null;segments=[];focused=0;#e=null;#t=[];init(l){const u=l||{},f=n(u),h=z(u,f,{colId:u.column&&(u.column.id||u.column.field)}),g=Number(f.max??r),b=h.options().length;if(Number.isFinite(g)&&b>g){const p=new k;p.init(u),this.#e=p,this.params=u,this.doc=U(u),this.props=f,this.lookup=h,this.popup=p.popup;return}super.init(u),(!this.lookup||!this.lookup.options().length)&&(this.lookup=h)}usesFallback(){return this.#e!==null}build(){const l=this.doc;this.options=this.lookup?this.lookup.options():[],this.selected=this.params.value??null;const u=L(l,"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 f=0;f<this.options.length;f++)u.appendChild(this.buildSegment(this.options[f],f));return this.props.allowClear===!0&&u.appendChild(this.buildClear()),this.#t.push(W(u,"keydown",f=>this.onKeyDown(f))),this.focused=Math.max(0,this.indexOf(this.selected)),this.paint(),u}buildSegment(l,u){const f=this.doc,h=L(f,"button",{class:`${$.editor}__segment`,attrs:{type:"button",role:"radio",tabindex:"-1","aria-checked":"false","data-index":u,"data-variant":l.variant??null,"aria-disabled":l.disabled===!0?"true":null}});return l.icon&&h.appendChild(c(f,l.icon,{className:$.icon})),h.appendChild(L(f,"span",{class:`${$.editor}__segment-label`,text:l.label})),this.#t.push(W(h,"mousedown",g=>{g&&y(g.preventDefault)&&g.preventDefault(),l.disabled!==!0&&(this.focused=u,this.select(u,{commit:!0}))})),this.segments.push(h),h}buildClear(){const l=L(this.doc,"button",{class:`${$.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clear")}});return this.#t.push(W(l,"mousedown",u=>{u&&y(u.preventDefault)&&u.preventDefault(),this.clearSelection()})),l}indexOf(l){if(l==null)return-1;const u=Z(l);for(let f=0;f<this.options.length;f++)if(Z(this.options[f].id)===u)return f;return-1}paint(){for(let l=0;l<this.segments.length;l++){const u=l===this.indexOf(this.selected),f=this.segments[l];f.setAttribute("aria-checked",u?"true":"false"),f.setAttribute("tabindex",l===this.focused?"0":"-1"),f.classList.toggle(`${$.editor}__segment--active`,u),f.classList.toggle(`${$.editor}__segment--disabled`,this.options[l].disabled===!0)}}select(l,u){const f=this.options[l];!f||f.disabled===!0||(this.selected=f.id,this.paint(),u&&u.commit&&this.commit())}clearSelection(){this.selected=null,this.paint()}moveFocus(l){const u=this.segments.length;if(!u)return;let f=this.focused;for(let h=0;h<u;h++)if(f=(f+l+u)%u,this.options[f].disabled!==!0){this.focusAt(f);return}}focusAt(l){if(l<0||l>=this.segments.length)return;this.focused=l,this.paint();const u=this.segments[l];u&&y(u.focus)&&u.focus()}edgeIndex(l){const u=this.options.length;for(let f=0;f<u;f++){const h=l===1?f:u-1-f;if(this.options[h].disabled!==!0)return h}return-1}onKeyDown(l){const u=()=>{y(l.preventDefault)&&l.preventDefault()};switch(l.key){case"ArrowRight":case"ArrowDown":u(),this.moveFocus(1);break;case"ArrowLeft":case"ArrowUp":u(),this.moveFocus(-1);break;case"Home":u(),this.focusAt(this.edgeIndex(1));break;case"End":u(),this.focusAt(this.edgeIndex(-1));break;case"Enter":u(),this.select(this.focused,{commit:!0});break;case" ":case"Spacebar":u(),this.select(this.focused);break;case"Escape":u(),this.cancel();break;case"Tab":this.select(this.focused),this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(u(),this.clearSelection());break;default:break}}readValue(){return this.selected??null}checkValue(l){return l==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.lookup||!this.lookup.options().length||this.lookup.option(l)||this.lookup.allowCustom||this.props.allowCustom===!0?!0:`"${String(l)}" 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 l=this.indexOf(this.selected);return this.segments[l>=0?l:Math.max(0,this.edgeIndex(1))]||null}attached(){if(this.#e){this.#e.attached();return}if(super.attached(),!this.lookup)return;const l=this.lookup.ready();!l||!y(l.then)||l.then(()=>{if(!super.element()||this.options.length)return;const u=super.element();this.options=this.lookup.options();for(let f=0;f<this.options.length;f++)u.appendChild(this.buildSegment(this.options[f],f));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(l){return this.#e?this.#e.validate(l):super.validate(l)}message(){return this.#e?this.#e.message():super.message()}toClipboard(){return this.#e?this.#e.toClipboard():super.toClipboard()}fromClipboard(l){return this.#e?this.#e.fromClipboard(l):super.fromClipboard(l)}destroy(){for(const l of this.#t)l();this.#t.length=0,this.segments.length=0,this.options=[],this.#e&&(this.#e.destroy(),this.#e=null),super.destroy()}}function n(s){return{...s.column&&s.column.edit&&s.column.edit.props||{},...s.props||{}}}const i=t}),ke("packages/dom/src/editors/rating.js",function(e,V){"use strict";Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"normaliseRating",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const _=V("packages/dom/src/editors/common.js"),R=_.BaseEditor,$=_.CLS,L=_.el,W=_.on,H=V("packages/dom/src/cell/icons.js").createIcon,U=V("packages/dom/src/cell/renderers/rating.js"),z=U.ratingFills,F=U.fillState,k=U.ratingText,O=U.clampRating,y=U.DEFAULT_RATING_ICON,d=U.DEFAULT_RATING_MAX,r=V("packages/core/src/internal/util.js").isFunction;class t extends R{static popup=!1;rating=null;preview=null;items=[];fills=[];slider=null;readout=null;#e=[];max(){const l=Math.floor(Number(this.props.max??d));return Number.isFinite(l)&&l>0?l:d}step(){return this.props.allowHalf===!0?.5:1}build(){const l=this.doc,u=this.max();this.rating=n(this.params.value,u,this.props.allowHalf===!0);const f=L(l,"div",{class:`${$.editor}__rating`}),h=L(l,"div",{class:`${$.editor}__rating-slider`,attrs:{role:"slider",tabindex:"0","aria-valuemin":"0","aria-valuemax":String(u),"aria-label":this.params.column&&this.params.column.title||"Rating"}});for(let b=0;b<u;b++)h.appendChild(this.buildItem(b));f.appendChild(h),this.slider=h;const g=L(l,"span",{class:`${$.editor}__rating-value`});return f.appendChild(g),this.readout=g,this.props.allowClear===!0&&f.appendChild(this.buildClear()),this.#e.push(W(h,"keydown",b=>this.onKeyDown(b))),this.props.hoverPreview!==!1&&this.#e.push(W(h,"mouseleave",()=>{this.preview=null,this.paint()})),this.params.key&&/^[0-9]$/.test(this.params.key)&&(this.rating=Math.min(Number(this.params.key),u)),this.paint(),f}buildItem(l){const u=this.doc,f=String(this.props.icon??y),h=L(u,"span",{class:`${$.editor}__rating-fill`,attrs:{"aria-hidden":"true"},children:[H(u,f,{className:$.icon})]}),g=L(u,"span",{class:`${$.editor}__rating-item`,attrs:{"data-index":l,"data-icon":f,"aria-hidden":"true"},children:[H(u,f,{className:$.icon}),h]});return this.fills.push(h),this.#e.push(W(g,"mousedown",b=>{b&&r(b.preventDefault)&&b.preventDefault(),this.setRating(this.ratingAt(l,b),{commit:!0})})),this.props.hoverPreview!==!1&&this.#e.push(W(g,"mousemove",b=>{const p=this.ratingAt(l,b);p!==this.preview&&(this.preview=p,this.paint())})),this.items.push(g),g}buildClear(){const l=L(this.doc,"button",{class:`${$.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearRating")}});return this.#e.push(W(l,"mousedown",u=>{u&&r(u.preventDefault)&&u.preventDefault(),this.setRating(null)})),l}ratingAt(l,u){if(this.props.allowHalf!==!0)return l+1;const f=this.items[l],h=f&&Number(f.offsetWidth),g=u&&Number(u.offsetX);return!Number.isFinite(h)||h<=0||!Number.isFinite(g)?l+1:g*2<h?l+.5:l+1}focusTarget(){return this.slider}setRating(l,u){this.rating=l===null?null:O(l,this.max(),this.props.allowHalf===!0,!1),this.preview=null,this.paint(),u&&u.commit&&this.commit()}nudge(l){const u=this.rating===null?0:this.rating;this.setRating(u+l)}paint(){const l=this.max(),u=this.props.allowHalf===!0,f=this.preview===null?this.rating:this.preview,h=z(f===null?0:f,l,{allowHalf:u});for(let p=0;p<this.items.length;p++){const m=F(h[p]);this.items[p].setAttribute("data-fill",m),this.items[p].classList.toggle(`${$.editor}__rating-item--filled`,m!=="empty"),this.fills[p]&&this.fills[p].style.setProperty("--lat-rating-fill",`${(h[p]*100).toFixed(2)}%`)}const g=f===null?String(this.props.emptyLabel??this.t("cell.rating.empty")):this.t("cell.rating.of",{rating:k(f),max:l}),b=this.slider;b&&(b.setAttribute("aria-valuenow",f===null?"0":String(f)),b.setAttribute("aria-valuetext",g),b.setAttribute("data-preview",this.preview===null?"false":"true")),this.readout&&(this.readout.textContent=g)}onKeyDown(l){const u=()=>{r(l.preventDefault)&&l.preventDefault()},f=this.step();if(/^[0-9]$/.test(l.key)){u(),this.setRating(Math.min(Number(l.key),this.max()));return}switch(l.key){case"ArrowRight":case"ArrowUp":u(),this.nudge(f);break;case"ArrowLeft":case"ArrowDown":u(),this.nudge(-f);break;case"Home":u(),this.setRating(0);break;case"End":u(),this.setRating(this.max());break;case"Enter":u(),this.commit();break;case"Escape":u(),this.cancel();break;case"Tab":this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(u(),this.setRating(null));break;default:break}}readValue(){return this.rating}checkValue(l){if(l==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a rating";if(typeof l!="number"||!Number.isFinite(l))return"Enter a rating";const u=this.max();return l<0?"Must be 0 or more":l>u?`Must be ${u} or less`:this.props.allowHalf!==!0&&!Number.isInteger(l)?"Choose a whole rating":!0}toClipboard(){return this.rating===null?"":k(this.rating)}fromClipboard(l){const u=String(l??"").trim();if(u==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a rating"};const f=Number(u);if(!Number.isFinite(f))return{ok:!1,message:`"${u}" is not a rating`};const h=this.checkValue(f);return h!==!0?{ok:!1,message:h}:{ok:!0,value:f}}destroy(){for(const l of this.#e)l();this.#e.length=0,this.items.length=0,this.slider=null,this.readout=null,super.destroy()}}function n(s,l,u){if(s==null||s==="")return null;const f=Number(s);return Number.isFinite(f)?O(f,l,u,!1):null}const i=t}),ke("packages/dom/src/editors/slider.js",function(e,V){"use strict";Object.defineProperty(e,"SLIDER_MIN",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"SLIDER_MAX",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"proportion",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"decimalsOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"normaliseMarks",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const _=V("packages/dom/src/editors/common.js"),R=_.BaseEditor,$=_.CLS,L=_.el,W=_.on,Z=V("packages/dom/src/editors/number.js"),H=Z.parseNumberText,U=Z.presentNumber,F=V("packages/core/src/internal/util.js").isFunction,k=0,O=100;class y extends R{static popup=!1;amount=null;range=null;field=null;readout=null;root=null;marks=[];#e=[];min(){const i=Number(this.props.min??k);return Number.isFinite(i)?i:k}max(){const i=Number(this.props.max??O);return Number.isFinite(i)?i:O}step(){const i=Number(this.props.step??1);return Number.isFinite(i)&&i>0?i:1}build(){const i=this.doc,s=this.min(),l=this.max(),u=this.step(),f=r(this.props.marks);this.marks=f,this.amount=this.params.value==null||this.params.value===""?null:this.snap(Number(this.params.value));const h=L(i,"div",{class:`${$.editor}__slider`});this.root=h;const g=L(i,"input",{class:`${$.editor}__slider-input`,attrs:{type:"range",min:String(s),max:String(l),step:String(u),"aria-label":this.params.column&&this.params.column.title||null,"aria-valuetext":null,list:f.length?`${this.id}-marks`:null}});if(this.range=g,h.appendChild(g),f.length){const p=L(i,"datalist",{attrs:{id:`${this.id}-marks`}}),m=L(i,"div",{class:`${$.editor}__slider-marks`});for(const w of f){p.appendChild(L(i,"option",{attrs:{value:String(w.value),label:w.label}}));const v=L(i,"span",{class:`${$.editor}__slider-mark`,text:w.label,attrs:{"data-value":String(w.value)}});v.style&&F(v.style.setProperty)&&v.style.setProperty("--lat-slider-mark",`${(d(w.value,s,l)*100).toFixed(2)}%`),m.appendChild(v)}h.appendChild(p),h.appendChild(m)}const b=L(i,"input",{class:`${$.editor}__slider-number`,attrs:{type:"text",inputmode:"decimal","aria-label":this.t("editor.value")}});if(this.field=b,h.appendChild(b),this.props.showValue!==!1){const p=L(i,"span",{class:`${$.editor}__slider-value`});h.appendChild(p),this.readout=p}return this.#e.push(W(g,"input",()=>this.setAmount(Number(g.value),"range"))),this.#e.push(W(g,"change",()=>this.setAmount(Number(g.value),"range"))),this.#e.push(W(g,"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(),h}focusTarget(){return this.field}attached(){super.attached();const i=this.field;i&&!this.params.key&&this.props.selectOnFocus!==!1&&F(i.select)&&i.select()}snap(i){if(!Number.isFinite(i))return this.min();const s=this.min(),l=this.max(),u=this.step(),f=Math.min(Math.max(i,s),l),h=s+Math.round((f-s)/u)*u,g=c(u),b=g>0?Number(h.toFixed(g)):Math.round(h);return Math.min(Math.max(b,s),l)}setAmount(i,s){this.amount=i===null?null:this.snap(i),this.paint(s)}onFieldInput(){const i=this.field?String(this.field.value):"";if(i.trim()===""){this.amount=null,this.paint("field");return}const s=H(i,this.params.locale);if(s===null||Number.isNaN(s)){this.paint("field");return}this.setAmount(s,"field")}paint(i){const s=this.min(),l=this.max(),u=this.amount,f=u===null?s:u;this.range&&i!=="range"&&(this.range.value=String(f)),this.field&&i!=="field"&&(this.field.value=u===null?"":U(u,this.props));const h=this.root;h&&h.style&&F(h.style.setProperty)&&h.style.setProperty("--lat-slider-pos",`${(d(f,s,l)*100).toFixed(2)}%`),h&&h.setAttribute&&h.setAttribute("data-empty",u===null?"true":"false");const g=this.labelFor(u);this.range&&this.range.setAttribute&&this.range.setAttribute("aria-valuetext",g),this.readout&&(this.readout.textContent=g)}labelFor(i){if(i===null)return String(this.props.emptyLabel??"");const s=this.marks.find(u=>u.value===i),l=U(i,this.props);return s&&s.label!==l?`${l} (${s.label})`:l}onKeyDown(i){if(i.key==="Escape"){F(i.preventDefault)&&i.preventDefault(),this.cancel();return}if(i.key==="Enter"){F(i.preventDefault)&&i.preventDefault(),this.commit();return}i.key==="Tab"&&this.commit()}readValue(){const i=this.field?String(this.field.value):"";if(i.trim()==="")return null;const s=H(i,this.params.locale);return s===null||Number.isNaN(s)?NaN:this.snap(s)}checkValue(i){return i==null?this.props.allowClear===!0||this.params.value==null?!0:"Enter a value":typeof i!="number"||Number.isNaN(i)?"Enter a number":i<this.min()?`Must be ${this.min()} or more`:i>this.max()?`Must be ${this.max()} or less`:!0}fromClipboard(i){const s=String(i??"").trim();if(s==="")return this.checkValue(null)===!0?{ok:!0,value:null}:{ok:!1,message:"Enter a value"};const l=H(s,this.params.locale);if(l===null||Number.isNaN(l))return{ok:!1,message:"Enter a number"};const u=this.snap(l),f=this.checkValue(u);return f!==!0?{ok:!1,message:f}:{ok:!0,value:u}}destroy(){for(const i of this.#e)i();this.#e.length=0,this.range=null,this.field=null,this.readout=null,this.root=null,this.marks=[],super.destroy()}}function d(n,i,s){const l=s-i;return!Number.isFinite(l)||l===0?0:Math.min(1,Math.max(0,(Number(n)-i)/l))}function c(n){if(!Number.isFinite(n))return 0;const i=String(n),s=i.indexOf("e");if(s>=0){const u=i.slice(0,s),f=u.indexOf("."),h=f<0?0:u.length-f-1;return Math.min(15,Math.max(0,h-Number(i.slice(s+1))))}const l=i.indexOf(".");return l<0?0:Math.min(15,i.length-l-1)}function r(n){if(!n)return[];const i=[];if(Array.isArray(n)){for(const s of n){if(s&&typeof s=="object"){const u=Number(s.value);Number.isFinite(u)&&i.push({value:u,label:String(s.label??u)});continue}const l=Number(s);Number.isFinite(l)&&i.push({value:l,label:String(l)})}return i}if(typeof n=="object")for(const[s,l]of Object.entries(n)){const u=Number(s);Number.isFinite(u)&&i.push({value:u,label:String(l)})}return i}const t=y}),ke("packages/dom/src/editors/colour.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_SWATCHES",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"TOKEN_FALLBACK",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"normaliseSwatch",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolveSwatchColour",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"toSwatches",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const _=V("packages/dom/src/editors/common.js"),R=_.BaseEditor,$=_.CLS,L=_.el,W=_.on,Z=V("packages/dom/src/cell/renderers/colour.js"),H=Z.normaliseColour,U=Z.parseColour,F=V("packages/core/src/internal/util.js").isFunction,k=Object.freeze(["neutral","info","success","warning","danger","accent"]),O=Object.freeze({neutral:"#5b6670",info:"#1a6bc7",success:"#1b7f3b",warning:"#a96a0b",danger:"#c22b2b",accent:"#5a46d6"});function y(i){if(i==null)return null;if(typeof i=="object"){const u=i,f=y(u.token??u.value??u.colour??u.color);return f?{...f,label:u.label==null?f.label:String(u.label)}:null}const s=String(i).trim();if(s==="")return null;const l=H(s);return l?{token:null,hex:l,label:l}:Object.hasOwn(O,s)?{token:s,hex:O[s],label:s}:null}function d(i,s){const l=i&&i.ownerDocument,u=l&&l.defaultView;if(!u||!F(u.getComputedStyle))return null;try{const f=u.getComputedStyle(i);return!f||!F(f.getPropertyValue)?null:H(String(f.getPropertyValue(`--lattice-variant-${s}-solid`)).trim())}catch{return null}}class c extends R{static popup=!0;swatches=[];buttons=[];native=null;hex=null;preview=null;#e=[];alpha(){return this.props.alpha===!0}build(){const s=this.doc;this.swatches=r(this.props.swatches);const l=L(s,"div",{class:`${$.editor}__colour`,attrs:{"aria-label":this.params.column&&this.params.column.title||null}});if(this.preview=L(s,"span",{class:`${$.editor}__colour-preview`,attrs:{"aria-hidden":"true"}}),l.appendChild(this.preview),this.swatches.length){const f=L(s,"div",{class:`${$.editor}__colour-swatches`,attrs:{role:"radiogroup","aria-label":this.t("editor.colours")}});for(let h=0;h<this.swatches.length;h++)f.appendChild(this.buildSwatch(this.swatches[h],h));l.appendChild(f)}this.native=L(s,"input",{class:`${$.editor}__colour-native`,attrs:{type:"color","aria-label":this.t("editor.customColour")}}),l.appendChild(this.native),this.hex=L(s,"input",{class:`${$.editor}__colour-hex`,attrs:{type:"text",spellcheck:"false",autocomplete:"off",placeholder:this.t("editor.hexPlaceholder"),"aria-label":this.t("editor.hexValue")}}),l.appendChild(this.hex),this.props.allowClear===!0&&l.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",f=>this.onKeyDown(f))),this.#e.push(W(l,"keydown",f=>this.onKeyDown(f)));const u=H(this.params.value,{alpha:this.alpha()});return this.hex.value=u===null?this.params.value==null?"":String(this.params.value):u,this.params.key&&/^[#0-9a-fA-F]$/.test(this.params.key)&&(this.hex.value=this.params.key),this.paint(),l}buildSwatch(s,l){const u=L(this.doc,"button",{class:`${$.editor}__colour-swatch`,attrs:{type:"button",role:"radio","aria-checked":"false","aria-label":s.label,"data-index":l,"data-variant":s.token}});return s.token||t(u,s.hex),this.#e.push(W(u,"mousedown",f=>{f&&F(f.preventDefault)&&f.preventDefault(),this.setColour(this.swatches[l].hex)})),this.buttons.push(u),u}buildClear(){const s=L(this.doc,"button",{class:`${$.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearColour")}});return this.#e.push(W(s,"mousedown",l=>{l&&F(l.preventDefault)&&l.preventDefault(),this.setColour(null)})),s}focusTarget(){return this.hex}attached(){super.attached();for(let s=0;s<this.swatches.length;s++){const l=this.swatches[s];if(!l.token)continue;const u=d(this.buttons[s]||this.element(),l.token);u&&(l.hex=u)}this.paint()}setColour(s){const l=s===null?null:H(s,{alpha:this.alpha()});this.hex&&(this.hex.value=l===null?"":l),this.paint()}current(){const s=this.hex?String(this.hex.value).trim():"";return s===""?null:H(s,{alpha:this.alpha()})}paint(){const s=this.current(),l=s===null?null:s.slice(0,7);t(this.preview,l),this.preview&&this.preview.setAttribute&&this.preview.setAttribute("data-empty",s===null?"true":"false"),this.native&&(this.native.value=l===null?"#000000":l);for(let u=0;u<this.buttons.length;u++){const f=s!==null&&this.swatches[u].hex.toLowerCase()===s.toLowerCase();this.buttons[u].setAttribute("aria-checked",f?"true":"false"),this.buttons[u].classList.toggle(`${$.editor}__colour-swatch--selected`,f),this.swatches[u].token||t(this.buttons[u],this.swatches[u].hex)}}onKeyDown(s){if(s.key==="Escape"){F(s.preventDefault)&&s.preventDefault(),this.cancel();return}if(s.key==="Enter"){F(s.preventDefault)&&s.preventDefault(),this.commit();return}s.key==="Tab"&&this.commit()}readValue(){const s=this.hex?String(this.hex.value).trim():"";if(s==="")return null;const l=H(s,{alpha:this.alpha()});return l===null?s:l}checkValue(s){if(s==null||s==="")return this.props.allowClear===!0||this.params.value==null?!0:"Choose a colour";const l=U(s);return l?!this.alpha()&&l.a<1?"This column does not accept transparency":!0:`"${String(s)}" is not a colour`}toClipboard(){const s=this.current();return s===null?"":s}fromClipboard(s){const l=String(s??"").trim();if(l==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a colour"};const u=H(l,{alpha:this.alpha()});if(u===null)return{ok:!1,message:`"${l}" is not a colour`};const f=this.checkValue(u);return f!==!0?{ok:!1,message:f}:{ok:!0,value:u}}destroy(){for(const s of this.#e)s();this.#e.length=0,this.buttons.length=0,this.swatches=[],this.native=null,this.hex=null,this.preview=null,super.destroy()}}function r(i){const s=Array.isArray(i)&&i.length?i:i===!1?[]:k,l=[];for(const u of s){const f=y(u);f&&l.push(f)}return l}function t(i,s){const l=i&&i.style;if(l){if(s===null){F(l.removeProperty)&&l.removeProperty("--lat-swatch");return}F(l.setProperty)&&l.setProperty("--lat-swatch",s)}}const n=c}),ke("packages/dom/src/editors/treeselect.js",function(e,V){"use strict";Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const R=V("packages/dom/src/editors/select.js").SelectEditorBase,L=V("packages/dom/src/cell/icons.js").createIcon,W=V("packages/dom/src/editors/common.js"),Z=W.CLS,H=W.el,U=W.on,z=W.clear,F=W.keyOf,k=W.rawOptions,O=W.lookupKey,y=V("packages/core/src/internal/util.js"),d=y.isFunction,c=y.isObject,r="\0";class t extends R{static popup=!0;roots=[];nodes=new Map;expanded=new Set;matched=new Set;selected=null;leavesOnly=!0;build(){this.leavesOnly=this.props.selectLeavesOnly!==!1;const s=super.build();return s.classList.add("lat-treeselect"),this.list&&this.list.element().setAttribute("role","tree"),s}initSelection(){this.rebuild(),this.selected=this.params.value??null;const s=this.nodeById(this.selected);if(s)for(let l=s.parent;l;l=l.parent)this.expanded.add(l.key)}rebuild(){const s=k(this.params,this.props),l=this.props.keys||{},u=l.value||O(this.params,"valueKey")||"id",f=l.label||O(this.params,"labelKey")||"label";this.roots=[],this.nodes=new Map;for(const h of s){if(!c(h)){this.addNode(null,String(h??""),h,null);continue}Array.isArray(h.path)&&h.path.length?this.addByPath(h,u,f):this.addByChildren(h,null,u,f)}if(this.props.defaultExpanded===!0)for(const h of this.nodes.keys())this.expanded.add(h)}addNode(s,l,u,f){const h=s?`${s.key}${r}${l}`:l;let g=this.nodes.get(h);return g?g.id===void 0&&u!==void 0&&(g.id=u):(g={id:u,label:l,key:h,parent:s,children:[],depth:s?s.depth+1:0,disabled:!1},this.nodes.set(h,g),(s?s.children:this.roots).push(g)),f&&(f.disabled===!0&&(g.disabled=!0),f.icon!==void 0&&(g.icon=f.icon),f.variant!==void 0&&(g.variant=f.variant)),g}addByPath(s,l,u){const f=s.path;let h=null;for(let g=0;g<f.length;g++){const b=g===f.length-1,p=String(f[g]),m=b&&s[u]!=null?String(s[u]):p,w=this.addNode(h,p,b?s[l]:void 0,b?s:null);b&&(w.label=m),h=w}}addByChildren(s,l,u,f){const h=s[u],g=s[f]!=null?String(s[f]):String(h??""),b=this.addNode(l,g,h,s),p=Array.isArray(s.children)?s.children:[];for(const m of p)c(m)?this.addByChildren(m,b,u,f):this.addNode(b,String(m??""),m,null)}nodeById(s){if(s==null)return;const l=F(s);for(const u of this.nodes.values())if(u.id!==void 0&&F(u.id)===l)return u}filterOptions(s){const l=String(s||"").trim().toLowerCase(),u=l!=="";this.matched=u?this.computeMatches(l):new Set;const f=[],h=g=>{for(const b of g)u&&!this.matched.has(b.key)||(f.push(b),b.children.length&&(u||this.expanded.has(b.key))&&h(b.children))};return h(this.roots),f}computeMatches(s){const l=new Set,u=f=>{let h=f.label.toLowerCase().includes(s);for(const g of f.children)u(g)&&(h=!0);return h&&l.add(f.key),h};for(const f of this.roots)u(f);return l}repaint(s){if(this.refreshOptions(),!s||!this.list)return;const l=this.visible.findIndex(u=>u.key===s);l>=0&&this.list.setActive(l)}isBranch(s){return!!s&&s.children.length>0}isSelectable(s){return!s||s.disabled||s.id===void 0||s.id===null?!1:!(this.leavesOnly&&this.isBranch(s))}setExpanded(s,l){this.isBranch(s)&&(l?this.expanded.add(s.key):this.expanded.delete(s.key),this.repaint(s.key))}choose(s){if(s){if(!this.isSelectable(s)){this.isBranch(s)&&this.setExpanded(s,!this.expanded.has(s.key));return}this.selected=s.id,this.input&&(this.input.value=""),this.query="",this.repaint(s.key),this.paintDisplay(),this.commit()}}isSelected(s){return this.selected!=null&&s&&s.id!==void 0&&F(s.id)===F(this.selected)}clearSelection(){this.selected=null,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay()}readValue(){return this.selected??null}checkValue(s){if(s==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a value";if(!this.nodes.size)return!0;const l=this.nodeById(s);return l&&this.isSelectable(l)?!0:l?`"${l.label}" is a group, not a value`:this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(s)}" is not a valid option`}renderOption(s,l,u){z(l),l.setAttribute("role","treeitem"),l.setAttribute("aria-level",String(s.depth+1)),l.setAttribute("data-depth",String(s.depth));const f=H(this.doc,"span",{class:"lat-tree__indent"});for(let w=0;w<s.depth;w++)f.appendChild(H(this.doc,"span",{class:"lat-tree__guide"}));l.appendChild(f);const h=this.isBranch(s),g=h&&(this.expanded.has(s.key)||this.query.trim()!==""),b=h?g?"chevronDown":"chevronRight":"blank",p=H(this.doc,"span",{class:h?"lat-tree__twisty":"lat-tree__twisty lat-tree__twisty--leaf",children:[L(this.doc,b,{className:Z.icon})],attrs:{"data-icon":h?b:null,"aria-hidden":"true"}});h&&U(p,"mousedown",w=>{d(w.preventDefault)&&w.preventDefault(),d(w.stopPropagation)&&w.stopPropagation(),this.setExpanded(s,!this.expanded.has(s.key))}),l.appendChild(p),s.icon&&l.appendChild(L(this.doc,s.icon,{className:Z.icon})),l.appendChild(H(this.doc,"span",{class:`${Z.option}__label`,text:s.label})),s.variant?l.setAttribute("data-variant",s.variant):l.removeAttribute("data-variant"),h?l.setAttribute("aria-expanded",g?"true":"false"):l.removeAttribute("aria-expanded");const m=this.isSelected(s);l.classList.toggle(Z.optionSelected,m),l.classList.toggle(Z.optionDisabled,!this.isSelectable(s)),l.classList.toggle("lat-tree__row--branch",h),l.setAttribute("aria-selected",m?"true":"false"),this.isSelectable(s)?l.removeAttribute("aria-disabled"):l.setAttribute("aria-disabled","true")}paintDisplay(){const s=this.display;if(!s)return;if(z(s),this.selected==null){s.removeAttribute("data-variant");return}const l=this.nodeById(this.selected);if(!l){s.appendChild(H(this.doc,"span",{text:String(this.selected)}));return}l.icon&&s.appendChild(L(this.doc,l.icon,{className:Z.icon})),s.appendChild(H(this.doc,"span",{class:"lat-tree__path",text:this.pathLabel(l)})),l.variant?s.setAttribute("data-variant",l.variant):s.removeAttribute("data-variant")}pathLabel(s){const l=[];for(let u=s;u;u=u.parent)l.unshift(u.label);return l.join(String(this.props.pathSeparator??" / "))}onKeyDown(s){const l=this.list,u=l&&l.active>=0?this.visible[l.active]:null;switch(s.key){case"ArrowRight":{if(d(s.preventDefault)&&s.preventDefault(),!u)return;this.isBranch(u)&&!this.expanded.has(u.key)?this.setExpanded(u,!0):this.isBranch(u)&&l&&l.setActive(Math.min(this.visible.length-1,l.active+1));return}case"ArrowLeft":{if(d(s.preventDefault)&&s.preventDefault(),!u)return;this.isBranch(u)&&this.expanded.has(u.key)?this.setExpanded(u,!1):u.parent&&this.focusNode(u.parent.key);return}case"Home":d(s.preventDefault)&&s.preventDefault(),l&&this.visible.length&&l.setActive(0);return;case"End":d(s.preventDefault)&&s.preventDefault(),l&&this.visible.length&&l.setActive(this.visible.length-1);return;default:super.onKeyDown(s)}}focusNode(s){if(!this.list)return;const l=this.visible.findIndex(u=>u.key===s);l>=0&&this.list.setActive(l)}acceptHighlight(s){const l=this.list,u=l&&l.active>=0?this.visible[l.active]:null;if(!u){s&&s.commit&&this.commit();return}if(this.isSelectable(u)){this.choose(u);return}this.isBranch(u)?this.setExpanded(u,!this.expanded.has(u.key)):s&&s.commit&&this.commit()}moveHighlight(s){const l=this.list;if(!l)return;let u=l.active;for(let f=0;f<this.visible.length;f++){if(u+=s,u<0||u>=this.visible.length)return;if(!this.visible[u].disabled){l.setActive(u);return}}}}const n=t}),ke("packages/dom/src/editors/objectpicker.js",function(e,V){"use strict";Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"readField",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"initialsOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const R=V("packages/dom/src/editors/select.js").SelectEditorBase,$=V("packages/dom/src/editors/common.js"),L=$.CLS,W=$.el,Z=$.on,H=$.clear,U=$.keyOf,z=$.debounce,F=$.rawOptions,k=$.optionSource,O=$.lookupSearch,y=$.lookupKey,d=V("packages/core/src/internal/util.js"),c=d.isFunction,r=d.isObject,t=d.getPath,i=V("packages/dom/src/cell/icons.js").createIcon;class s extends R{static popup=!0;all=[];selected=null;#e=null;#t=!1;#n=null;build(){const b=super.build();if(b.classList.add("lat-objectpicker"),c(this.props.search)&&!(this.lookup&&this.lookup.search)){const p=Number(this.props.searchDebounce)||200;this.#n=z(m=>this.runRemoteSearch(String(m)),p)}return b}onQuery(b){super.onQuery(b),this.#n&&this.#n(b)}initSelection(){const b=F(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(!r(b)){const o=b==null?"":String(b);return{id:b,label:o,secondary:"",avatar:"",initials:u(o),disabled:!1,raw:{}}}const p=this.props.valueKey||y(this.params,"valueKey")||"id",m=this.props.labelKey||y(this.params,"labelKey")||"label",w=l(b,this.props.template??m,""),v=l(b,this.props.secondary,""),a=l(b,this.props.avatar,"");return{id:b[p],label:w||String(b[p]??""),secondary:v,avatar:a,initials:u(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=k(this.params,this.props);c(b)&&(this.#t=!0,Promise.resolve(b()).then(p=>{!this.element()||!Array.isArray(p)||(this.all=p.map(m=>this.toOption(m)),this.refreshOptions(),this.paintDisplay())}))}filterOptions(b){const p=String(b||"").trim().toLowerCase();if(p==="")return this.all;const m=f(this.props.searchFields);return this.all.filter(w=>{if(!m)return w.label.toLowerCase().includes(p)||w.secondary.toLowerCase().includes(p);for(const v of m){const a=c(v)?v(w.raw):t(w.raw,v);if(a!=null&&String(a).toLowerCase().includes(p))return!0}return!1})}async runRemoteSearch(b){const p=O(this.params,this.props);if(!p)return;this.#e&&this.#e.abort();const m=new AbortController;this.#e=m;try{const w=await p(b,m.signal);if(m.signal.aborted||this.#e!==m)return;this.refreshOptions(Array.isArray(w)?w.map(v=>this.toOption(v)):[])}catch(w){if(!m.signal.aborted)throw w}finally{this.#e===m&&(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(m=>U(m.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,m){H(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(i(this.doc,b.icon,{className:L.icon})),b.variant?p.setAttribute("data-variant",b.variant):p.removeAttribute("data-variant");const v=this.isSelected(b);p.classList.add("lat-object__row"),p.classList.toggle(L.optionSelected,v),p.classList.toggle(L.optionDisabled,b.disabled===!0),p.setAttribute("aria-selected",v?"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 m=W(this.doc,"img",{class:"lat-avatar__image",attrs:{src:b.avatar,alt:"",loading:"lazy",decoding:"async"}});return Z(m,"error",()=>{m.parentNode===p&&(p.removeChild(m),p.appendChild(W(this.doc,"span",{class:"lat-avatar__initials",text:b.initials})),p.setAttribute("data-fallback","initials"))}),p.appendChild(m),p}paintDisplay(){const b=this.display;if(!b)return;if(H(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 l(g,b,p){if(b==null)return p;const m=c(b)?b(g):t(g,String(b));return m==null?p:String(m)}function u(g){const b=String(g||"").trim().split(/\s+/).filter(w=>w!=="");if(!b.length)return"";const p=[...b[0]][0]||"";if(b.length===1)return p.toUpperCase();const m=[...b[b.length-1]][0]||"";return(p+m).toUpperCase()}function f(g){if(g==null)return null;const p=(Array.isArray(g)?g:[g]).filter(m=>typeof m=="string"||c(m));return p.length?p:null}const h=s}),ke("packages/dom/src/editors/iconpicker.js",function(e,V){"use strict";Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolveNames",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const _=V("packages/dom/src/editors/common.js"),R=_.BaseEditor,$=_.CLS,L=_.VirtualList,W=_.el,Z=_.on,H=_.clear,U=V("packages/dom/src/cell/icons.js"),z=U.createIcon,F=U.iconNames,O=V("packages/core/src/internal/util.js").isFunction;class y extends R{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=d(t.icons),this.selected=this.params.value==null?null:String(this.params.value);const n=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 L({document:this.doc,itemHeight:Number(t.rowHeight)||34,height:Number(t.listHeight)||204,renderItem:(i,s,l)=>this.renderRow(i,s,l)}),this.list.element().setAttribute("role","grid"),this.list.element().setAttribute("aria-label",this.t("panel.icons")),n.appendChild(this.display),n.appendChild(this.input),t.allowClear===!0&&n.appendChild(this.buildClearButton()),n.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",i=>this.onKeyDown(i))),this.refreshIcons(),this.paintDisplay(),this.params.key&&this.params.key.length===1&&(this.input.value=this.params.key,this.onQuery(this.params.key)),n}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",n=>{O(n.preventDefault)&&n.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(i=>i.toLowerCase().includes(t)),this.rows=[];for(let i=0;i<this.matches.length;i+=this.columns)this.rows.push(this.matches.slice(i,i+this.columns));const n=this.selected?this.matches.indexOf(this.selected):-1;this.cursor=n>=0?n: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 n=Math.max(0,Math.min(this.matches.length-1,this.cursor+t));return this.setCursor(n)}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,n,i){n.setAttribute("role","row"),n.classList.add("lat-iconpicker__row");let s=n.__latIconCells;if(!s){s=[],H(n);for(let l=0;l<this.columns;l++){const u=W(this.doc,"span",{class:"lat-iconpicker__cell",attrs:{role:"gridcell",tabindex:"-1"}});Z(u,"mousedown",f=>{O(f.preventDefault)&&f.preventDefault();const h=u.getAttribute("data-icon");h&&this.choose(h)}),n.appendChild(u),s.push(u)}n.__latIconCells=s}for(let l=0;l<s.length;l++){const u=s[l],f=t[l];if(f===void 0){u.setAttribute("aria-hidden","true"),u.removeAttribute("data-icon"),u.removeAttribute("title"),u.removeAttribute("aria-label"),u.classList.add("lat-iconpicker__cell--empty"),u.classList.remove("lat-iconpicker__cell--active"),u.classList.remove("lat-iconpicker__cell--selected"),u.__latIconName!==void 0&&(H(u),u.__latIconName=void 0);continue}const h=i*this.columns+l;u.removeAttribute("aria-hidden"),u.classList.remove("lat-iconpicker__cell--empty"),u.setAttribute("data-icon",f),u.setAttribute("title",f),u.setAttribute("aria-label",f),u.__latIconName!==f&&(H(u),u.appendChild(z(this.doc,f,{className:$.icon})),u.__latIconName=f);const g=this.selected===f;u.classList.toggle("lat-iconpicker__cell--active",h===this.cursor),u.classList.toggle("lat-iconpicker__cell--selected",g),u.setAttribute("aria-selected",g?"true":"false")}}paintDisplay(){const t=this.display;if(t){if(H(t),this.selected==null){t.appendChild(W(this.doc,"span",{class:"lat-iconpicker__none",text:this.t("editor.noIcon")}));return}t.appendChild(z(this.doc,this.selected,{className:$.icon})),t.appendChild(W(this.doc,"span",{text:this.selected}))}}choose(t){this.selected=t;const n=this.matches.indexOf(t);n>=0&&(this.cursor=n),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 n=()=>{O(t.preventDefault)&&t.preventDefault()};switch(t.key){case"ArrowRight":n(),this.moveCursor(1);return;case"ArrowLeft":n(),this.moveCursor(-1);return;case"ArrowDown":n(),this.moveCursor(this.columns);return;case"ArrowUp":n(),this.moveCursor(-this.columns);return;case"PageDown":n(),this.moveCursor(this.columns*5);return;case"PageUp":n(),this.moveCursor(-this.columns*5);return;case"Home":n(),this.setCursor(this.matches.length?0:-1);return;case"End":n(),this.setCursor(this.matches.length-1);return;case"Enter":{n();const i=this.cursorName();i&&this.choose(i);return}case"Escape":n(),this.cancel();return;case"Tab":{const i=this.cursorName();i&&(this.selected=i),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 d(r){const t=F();if(Array.isArray(r)&&r.length){const n=new Set(t);return r.map(i=>String(i)).filter(i=>n.has(i))}return t.filter(n=>n!=="blank")}const c=y}),ke("packages/dom/src/editors/temperature.js",function(e,V){"use strict";Object.defineProperty(e,"presentTemperature",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const _=V("packages/dom/src/editors/common.js"),R=_.BaseEditor,$=_.CLS,L=_.el,W=_.on,H=V("packages/core/src/internal/util.js").isFunction,U=V("packages/core/src/columns/types/temperature.js"),z=U.formatTemperature,F=U.parseTemperature,k=U.findScale;function O(c,r){return z(c,{...r,decimals:void 0,minDecimals:0,maxDecimals:20})}class y extends R{input=null;hint=null;opts=null;#e=[];buildOptions(){const r=this.params.column&&this.params.column.dataType||null,t=r&&r.temperatureConfig||{};return{scale:this.props.scale||t.scale||"C",locale:this.params.locale}}build(){const r=this.props;this.opts=this.buildOptions();const t=k(this.opts.scale),n=t?t.scale.symbol:"",i=`${this.id}-scale`,s=L(this.doc,"input",{class:$.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:r.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":n?i:null}});s.value=O(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(s.value=this.params.key),this.input=s;const l=typeof r.step=="number"?r.step:0;return l>0&&this.#e.push(W(s,"keydown",u=>{u.key==="ArrowUp"?(H(u.preventDefault)&&u.preventDefault(),this.nudge(l)):u.key==="ArrowDown"&&(H(u.preventDefault)&&u.preventDefault(),this.nudge(-l))})),this.hint=L(this.doc,"span",{class:`${$.editor}__suffix`,text:n,attrs:{id:i,"aria-hidden":"true"}}),L(this.doc,"div",{class:`${$.editor}__unit`,children:[s,this.hint]})}focusTarget(){return this.input}attached(){super.attached();const r=this.input;r&&!this.params.key&&this.props.selectOnFocus!==!1&&H(r.select)&&r.select()}nudge(r){const t=F(this.input?this.input.value:"",this.opts);let n=(t??0)+r;const{min:i,max:s}=this.props;typeof i=="number"&&n<i&&(n=i),typeof s=="number"&&n>s&&(n=s),this.input&&(this.input.value=O(n,this.opts))}readValue(){const r=this.input?String(this.input.value).trim():"";if(r==="")return null;const t=F(r,this.opts);return t===null?Number.NaN:t}checkValue(r){if(r===null)return!0;if(typeof r!="number"||Number.isNaN(r))return"Enter a temperature";const{min:t,max:n}=this.props;return typeof t=="number"&&r<t?`Must be ${t} or more`:typeof n=="number"&&r>n?`Must be ${n} or less`:!0}destroy(){for(const r of this.#e)r();this.#e=[],this.input=null,this.hint=null,super.destroy()}}const d=y}),ke("packages/dom/src/editors/currency.js",function(e,V){"use strict";Object.defineProperty(e,"presentAmount",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"CurrencyEditor",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const _=V("packages/dom/src/editors/common.js"),R=_.BaseEditor,$=_.CLS,L=_.el,W=_.on,H=V("packages/core/src/internal/util.js").isFunction,U=V("packages/core/src/columns/types/currency.js"),z=U.parseMoney,F=U.toMoney,k=U.normaliseCode,O=["USD","EUR","GBP","JPY","CHF","CAD","AUD","CNY"];function y(r){const t=F(r);return t?String(t.amount):""}class d extends R{input=null;picker=null;opts=null;#e=[];buildOptions(){const t=this.params.column&&this.params.column.dataType||null,n=t&&t.currencyConfig||{},i=F(this.params.value),s=k(this.props.code)||i&&i.code||k(n.code)||"USD";let l=this.props.codes||n.codes||O;return l=l.map(u=>k(u)).filter(Boolean),l.includes(s)||(l=[s,...l]),{code:s,codes:l,locale:this.params.locale}}build(){const t=this.props;this.opts=this.buildOptions();const n=L(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"}});n.value=y(this.params.value),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(n.value=this.params.key),this.input=n;const i=L(this.doc,"select",{class:`${$.editor}__suffix`,attrs:{"aria-label":this.t("editor.currency")}});for(const s of this.opts.codes){const l=L(this.doc,"option",{text:s,attrs:{value:s}});s===this.opts.code&&(l.selected=!0),i.appendChild(l)}return this.picker=i,L(this.doc,"div",{class:`${$.editor}__unit`,children:[n,i]})}focusTarget(){return this.input}attached(){super.attached();const t=this.input;t&&!this.params.key&&this.props.selectOnFocus!==!1&&H(t.select)&&t.select()}readValue(){const t=this.input?String(this.input.value).trim():"";if(t==="")return null;const n=this.picker?this.picker.value:this.opts.code,i=z(t,{...this.opts,code:n});return i===null?Number.NaN:i}checkValue(t){if(t===null)return!0;if(!t||typeof t!="object"||!Number.isFinite(t.amount))return"Enter an amount";const n=t.amount,{min:i,max:s}=this.props;return typeof i=="number"&&n<i?`Must be ${i} or more`:typeof s=="number"&&n>s?`Must be ${s} or less`:!0}destroy(){for(const t of this.#e)t();this.#e=[],this.input=null,this.picker=null,super.destroy()}}const c=d}),ke("packages/dom/src/editors/index.js",function(e,V){"use strict";Object.defineProperty(e,"TextEditor",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"TextareaEditor",{enumerable:!0,get:function(){return L}}),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 F}}),Object.defineProperty(e,"SelectEditor",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"MultiSelectEditor",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"TimeEditor",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"DateTimeEditor",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DurationEditor",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"IpAddressEditor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PasswordEditor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"CodeEditor",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"CurrencyEditor",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"editorByType",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return pe}});const R=V("packages/dom/src/editors/text.js").TextEditor,L=V("packages/dom/src/editors/textarea.js").TextareaEditor,Z=V("packages/dom/src/editors/number.js").NumberEditor,U=V("packages/dom/src/editors/date.js").DateEditor,F=V("packages/dom/src/editors/checkbox.js").CheckboxEditor,O=V("packages/dom/src/editors/select.js").SelectEditor,d=V("packages/dom/src/editors/multiselect.js").MultiSelectEditor,r=V("packages/dom/src/editors/time.js").TimeEditor,n=V("packages/dom/src/editors/datetime.js").DateTimeEditor,s=V("packages/dom/src/editors/duration.js").DurationEditor,u=V("packages/dom/src/editors/ipaddress.js").IpAddressEditor,h=V("packages/dom/src/editors/password.js").PasswordEditor,b=V("packages/dom/src/editors/code.js").CodeEditor,m=V("packages/dom/src/editors/unit.js").UnitEditor,v=V("packages/dom/src/editors/radix.js").RadixEditor,o=V("packages/dom/src/editors/segmented.js").SegmentedEditor,E=V("packages/dom/src/editors/rating.js").RatingEditor,M=V("packages/dom/src/editors/slider.js").SliderEditor,P=V("packages/dom/src/editors/colour.js").ColourEditor,K=V("packages/dom/src/editors/treeselect.js").TreeSelectEditor,D=V("packages/dom/src/editors/objectpicker.js").ObjectPickerEditor,T=V("packages/dom/src/editors/iconpicker.js").IconPickerEditor,q=V("packages/dom/src/editors/temperature.js").TemperatureEditor,Q=V("packages/dom/src/editors/currency.js").CurrencyEditor,J=V("packages/core/src/internal/util.js"),ne=J.isCtor,re=J.isFunction,oe=J.warnOnce,ie=V("packages/dom/src/editors/common.js");for(const he of Object.keys(ie))he!=="default"&&Object.defineProperty(e,he,{enumerable:!0,get:function(){return ie[he]}});const te=Object.freeze({text:R,textarea:L,number:Z,date:U,checkbox:F,select:O,multiSelect:d,temperature:q,currency:Q,time:r,datetime:n,duration:s,ipaddress:u,password:h,code:b,unit:m,radix:v,slider:M,rating:E,segmented:o,treeSelect:K,objectPicker:D,iconPicker:T,colour:P}),ce=Object.freeze({text:"text",number:"number",boolean:"checkbox",date:"date",dateString:"date",lookup:"select",object:""});function ue(he,ve){const Oe=he&&he.edit&&he.edit.editor,Ie=ve&&ve.editors||{},Ze=!!(he&&he.lookup&&he.lookup.multiple);if(ne(Oe)||re(Oe))return Oe;if(typeof Oe=="string"){if(Ze&&Oe==="select")return d;const Be=Ie[Oe]||te[Oe];if(Be)return Be;oe(`editor:missing:${Oe}`,`unknown editor "${Oe}"; falling back to the data type default`)}const Se=he&&he.type||"text";if(Se==="lookup"||he&&he.lookup)return Ze?d:O;const xe=ce[Se];return xe&&(Ie[xe]||te[xe])||null}function ae(he,ve){const Oe=ue(he.column||{},ve);if(!Oe)return null;const Ie=new Oe;return Ie.init(he),re(Ie.cancelBeforeStart)&&Ie.cancelBeforeStart()===!0?(re(Ie.destroy)&&Ie.destroy(),null):Ie}const pe=te}),ke("packages/dom/src/ui/statusbar.js",function(e,V){"use strict";Object.defineProperty(e,"aggregate",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"StatusPanel",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"RowCountPanel",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"SelectedCountPanel",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"AggregationPanel",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"ProgressPanel",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const _=V("packages/dom/src/editors/common.js"),R=_.CLS,$=_.documentFor,L=_.el,W=_.clear,H=V("packages/core/src/i18n/index.js").defaultMessages,z=V("packages/core/src/internal/util.js").isFunction;function F(g){let b=0,p=0,m=0,w=null,v=null;for(const a of g||[]){if(a==null||a==="")continue;b++;const o=typeof a=="number"?a:Number(a);Number.isFinite(o)&&(p++,m+=o,(w===null||o<w)&&(w=o),(v===null||o>v)&&(v=o))}return{count:b,numericCount:p,sum:p?m:null,min:w,max:v,avg:p?m/p:null}}class k{root=null;valueNode=null;init(b){this.ctx=b,this.doc=b.document,this.root=L(this.doc,"div",{class:`${R.statusBar}__panel`,attrs:{"data-align":b.align||"end"}}),b.label&&this.root.appendChild(L(this.doc,"span",{class:`${R.statusBar}__label`,text:b.label})),this.valueNode=L(this.doc,"span",{class:`${R.statusBar}__value`,text:""}),this.root.appendChild(this.valueNode)}t(b,p){const m=this.ctx&&this.ctx.messages;return(m&&z(m.t)?m:H).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 O extends k{read(){const b=this.ctx.host||{},p=z(b.totalRowCount)?b.totalRowCount():0;if(p==null)return this.t("status.counting");const m=z(b.rowCount)?b.rowCount():p,w=this.ctx.noun,v=a=>w===void 0?this.t("count.rows",{count:a}):`${l(a,this.ctx.locale)}${w?` ${w}`:""}`;return m===p?this.t("status.total",{rows:v(p)}):this.t("status.shownOfTotal",{shown:l(m,this.ctx.locale),total:v(p)})}}class y extends k{read(){const b=this.ctx.host||{},p=z(b.selectedCount)?b.selectedCount():0;return p?this.t("status.selected",{count:p}):""}}class d extends k{read(){const b=this.ctx.host||{},p=z(b.rangeValues)?b.rangeValues():[],m=F(p);if(!m.count)return"";const w=this.ctx.stats||["count","sum","min","max","avg"],v=[];for(const a of w){if(a==="count"){v.push(this.t("status.count",{count:m.count}));continue}const o=m[a];o!==null&&v.push(`${this.t(`status.stat.${a}`)} ${f(o,this.ctx.locale)}`)}return v.join(" ")}}class c extends k{read(){const b=this.ctx.host||{},p=z(b.progress)?b.progress():null;if(!p)return"";const{loaded:m,estimated:w,done:v}=p;if(v)return"";if(!w)return this.t("status.loading",{count:m||0});const a=Math.min(100,Math.round((m||0)/w*100));return this.t("status.loadingOf",{loaded:m||0,total:w,percent:a})}}class r extends k{read(){const b=this.ctx.host||{},p=z(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 k{read(){const b=this.ctx.host||{},p=z(b.hiddenUnresolved)?b.hiddenUnresolved():0;return p?this.t("status.hiddenComments",{comments:this.t("count.unresolvedComments",{count:p})}):""}}const n=Object.freeze({rowCount:O,selectedCount:y,aggregation:d,progress:c,updates:r,comments:t});class i{panels=[];root=null;init(b){const p=b||{};this.doc=$(p),this.host=p.host||{},this.messages=p.messages||null,this.root=L(this.doc,"div",{class:R.statusBar,attrs:{role:"status","aria-live":"polite"}});const m=p.registry||{},w=Array.isArray(p.panels)&&p.panels.length?p.panels:["rowCount","selectedCount","aggregation","comments","updates","progress"];for(const v of w){const a=typeof v=="string"?v:v.name,o=typeof v=="function"?v:m[a]||n[a];if(!o)continue;const S=new o;S.init({document:this.doc,host:this.host,locale:p.locale,messages:this.messages,...typeof v=="object"?v.props||{}:{}}),this.panels.push({name:String(a||"panel"),panel:S}),this.root.appendChild(S.element())}this.refresh()}element(){return this.root}addPanel(b,p,m){const w=new p;return w.init({document:this.doc,host:this.host,messages:this.messages,...m||{}}),this.panels.push({name:b,panel:w}),this.root&&this.root.appendChild(w.element()),w.refresh(),w}removePanel(b){const p=this.panels.findIndex(v=>v.name===b);if(p<0)return!1;const[m]=this.panels.splice(p,1),w=m.panel.element();return w&&w.parentNode&&w.parentNode.removeChild(w),z(m.panel.destroy)&&m.panel.destroy(),!0}refresh(){for(const b of this.panels)b.panel.refresh()}destroy(){for(const b of this.panels)z(b.panel.destroy)&&b.panel.destroy();this.panels=[],this.root&&W(this.root),this.root=null}}const s=new Map;function l(g,b){const p=b||"";let m=s.get(p);return m||(m=new Intl.NumberFormat(b||void 0,{maximumFractionDigits:0}),s.set(p,m)),m.format(Number(g)||0)}const u=new Map;function f(g,b){const p=b||"";let m=u.get(p);return m||(m=new Intl.NumberFormat(b||void 0,{maximumFractionDigits:3}),u.set(p,m)),m.format(Number(g)||0)}const h=i}),ke("packages/dom/src/ui/contextmenu.js",function(e,V){"use strict";Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const _=V("packages/dom/src/editors/common.js"),R=_.CLS,$=_.documentFor,L=_.el,W=_.on,Z=_.clear,U=V("packages/core/src/internal/util.js").isFunction,F=V("packages/dom/src/renderer/direction.js").isRtlElement,O=V("packages/dom/src/cell/icons.js").renderIconInto;function y(n,i){const s=[];for(const l of n||[]){const u=U(l)?l(i):l;if(u==null||u===!1)continue;if(u==="separator"){s.push({separator:!0});continue}if(typeof u=="string"){s.push({name:u});continue}const f=u,h=f.subMenu||f.children;h?s.push({...f,subMenu:y(h,i)}):s.push(f)}return s.filter((l,u,f)=>l.separator?u===0||u===f.length-1?!1:!f[u-1].separator:!0)}class d{root=null;itemNodes=[];items=[];focused=-1;child=null;off=[];open=!1;anchor=null;constructor(i){const s=i||{};this.doc=$(s),this.host=s.host||this.doc.body,this.ctx=s.ctx||{},this.onClose=s.onClose||null,this.parent=s.parent||null}place(i){const s=this.host,l=U(s.getBoundingClientRect)?s.getBoundingClientRect():{left:0,top:0},u=U(this.root.getBoundingClientRect)?this.root.getBoundingClientRect():{width:0,height:0},f=this.doc.defaultView||{innerWidth:0,innerHeight:0},h=f.innerWidth||0,g=f.innerHeight||0;let b=i.x||0,p=i.y||0;const m=F(s);if(i.anchor&&U(i.anchor.getBoundingClientRect)){const a=i.anchor.getBoundingClientRect();i.placement==="below"?(b=m?a.right-u.width:a.left,p=a.bottom):(b=m?a.left-u.width:a.right,p=a.top)}else m&&(b-=u.width);const w={left:Math.max(0,l.left||0),top:Math.max(0,l.top||0),right:Math.min(h||1/0,(l.left||0)+(l.width||1/0)),bottom:Math.min(g||1/0,(l.top||0)+(l.height||1/0))};b+u.width>w.right&&(b-=u.width),b<w.left&&(b=w.left),p+u.height>w.bottom&&(p-=u.height),p<w.top&&(p=w.top);const v=w.bottom-p;u.height>v&&(this.root.style.maxHeight=`${Math.max(0,Math.floor(v))}px`,this.root.style.overflowY="auto"),this.root.style.left=`${Math.round(b-l.left+(s.scrollLeft||0))}px`,this.root.style.top=`${Math.round(p-l.top+(s.scrollTop||0))}px`}show(i){return this.hide(),i.ctx&&(this.ctx={...this.ctx||{},...i.ctx}),this.items=y(i.items,this.ctx),this.returnFocus=i.returnFocus||null,this.anchor=i.anchor&&U(i.anchor.setAttribute)&&i.anchor.getAttribute&&i.anchor.getAttribute("aria-haspopup")?i.anchor:null,this.anchor&&this.anchor.setAttribute("aria-expanded","true"),this.root=L(this.doc,"div",{class:R.menu,attrs:{role:"menu",tabindex:"-1"},style:{position:"absolute"}}),this.itemNodes=[],this.items.forEach((s,l)=>{if(s.separator){this.root.appendChild(L(this.doc,"div",{class:R.menuSeparator,attrs:{role:"separator"}}));return}const u=L(this.doc,"div",{class:[R.menuItem,s.cssClass||""],attrs:{role:s.checked===void 0?"menuitem":"menuitemcheckbox",tabindex:"-1","aria-disabled":s.disabled?"true":null,"aria-checked":s.checked===void 0?null:String(s.checked===!0),"aria-haspopup":s.subMenu?"true":null,"aria-expanded":s.subMenu?"false":null,"data-index":l}});if(s.icon!=null&&s.icon!==""){const h=L(this.doc,"span",{class:R.icon});O(h,s.icon,`menu:${s.name||l}`),u.appendChild(h)}u.appendChild(L(this.doc,"span",{class:`${R.menuItem}__label`,text:s.name||""})),s.shortcut&&u.appendChild(L(this.doc,"span",{class:`${R.menuItem}__shortcut`,text:s.shortcut})),s.subMenu&&u.appendChild(L(this.doc,"span",{class:`${R.menuItem}__arrow`,text:"›"}));const f=this.itemNodes.length;this.off.push(W(u,"click",()=>this.invoke(f))),this.off.push(W(u,"mouseenter",()=>{this.focus(f),s.subMenu?this.openSubMenu(f):this.closeChild()})),this.itemNodes.push(u),this.root.appendChild(u)}),this.host.appendChild(this.root),this.place(i),this.open=!0,this.off.push(W(this.root,"keydown",s=>this.onKeyDown(s))),U(this.doc.addEventListener)&&this.off.push(W(this.doc,"mousedown",this.outside=s=>{this.root&&!r(this.root,s.target)&&!(this.child&&this.child.root&&r(this.child.root,s.target))&&this.hide()},!0)),U(this.root.focus)&&this.root.focus({preventScroll:!0}),this.focus(this.firstEnabled()),this.root}firstEnabled(){for(let i=0;i<this.itemNodes.length;i++)if(!this.itemAt(i).disabled)return i;return-1}itemAt(i){const s=this.itemNodes[i];return s?this.items[Number(s.getAttribute("data-index"))]||{}:{}}focus(i){if(i<0||i>=this.itemNodes.length)return;const s=this.itemNodes[this.focused];s&&s.classList.remove(`${R.menuItem}--focused`),this.focused=i;const l=this.itemNodes[i];l.classList.add(`${R.menuItem}--focused`),U(l.focus)&&l.focus(),U(l.scrollIntoView)&&l.scrollIntoView({block:"nearest",inline:"nearest"})}move(i){const s=this.itemNodes.length;if(!s)return;let l=this.focused;for(let u=0;u<s;u++)if(l=(l+i+s)%s,!this.itemAt(l).disabled){this.focus(l);return}}invoke(i){const s=this.itemAt(i);if(!(!s||s.disabled)){if(s.subMenu){this.openSubMenu(i);return}U(s.action)&&s.action({...this.ctx,item:s}),this.hideRoot()}}openSubMenu(i){const s=this.itemAt(i);s.subMenu&&(this.closeChild(),this.child=new d({document:this.doc,host:this.host,ctx:this.ctx,parent:this}),this.child.show({items:s.subMenu,anchor:this.itemNodes[i]}))}closeChild(){this.child&&(this.child.hide(),this.child=null)}onKeyDown(i){switch(i.key){case"ArrowDown":c(i),this.move(1);break;case"ArrowUp":c(i),this.move(-1);break;case"Home":c(i),this.focus(this.firstEnabled());break;case"End":c(i),this.focus(this.itemNodes.length-1);break;case"ArrowRight":c(i),this.openSubMenu(this.focused);break;case"ArrowLeft":c(i),this.parent&&(this.hide(),U(this.parent.root?.focus)&&this.parent.root.focus());break;case"Enter":case" ":c(i),this.invoke(this.focused);break;case"Escape":c(i),this.hideRoot();break;default:i.key&&i.key.length===1&&this.jumpTo(i.key);break}}jumpTo(i){const s=i.toLowerCase(),l=this.itemNodes.length;for(let u=1;u<=l;u++){const f=(this.focused+u+l)%l,h=this.itemAt(f);if(!h.disabled&&(h.name||"").toLowerCase().startsWith(s)){this.focus(f);return}}}hideRoot(){let i=this;for(;i.parent;)i=i.parent;i.hide()}hide(){this.closeChild();for(const i of this.off)i();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 c(n){U(n.preventDefault)&&n.preventDefault(),U(n.stopPropagation)&&n.stopPropagation()}function r(n,i){let s=i;for(;s;){if(s===n)return!0;s=s.parentNode}return!1}const t=d}),ke("packages/dom/src/viewpicker.js",function(e,V){"use strict";Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const _=V("packages/dom/src/editors/common.js"),R=_.documentFor,$=_.el,L=_.on,W=_.clear,H=V("packages/core/src/i18n/index.js").defaultMessages,z=V("packages/core/src/internal/util.js").isFunction,k=V("packages/dom/src/cell/icons.js").createIcon,O=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,n){return(this.messages&&typeof this.messages.t=="function"?this.messages:H).t(t,n)}init(t){this.messages=t&&t.messages||t&&t.grid&&t.grid.messages||H;const n=t||{};this.doc=R(n),this.host=n.host||{},this.props=n.props||{},this.root=$(this.doc,"div",{class:O.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 u of this.off)u();this.off.length=0,W(t),this.diffs=new Map;const n=this.views(),i=n.filter(u=>u.builtin),s=n.filter(u=>!u.builtin);i.length&&(t.appendChild(this.buildHead(String(this.props.builtinTitle||"Defined views"),i.length)),t.appendChild(this.buildList(i))),t.appendChild(this.buildHead(String(this.props.title||"Saved views"),s.length)),s.length?t.appendChild(this.buildList(s)):t.appendChild($(this.doc,"p",{class:O.empty,text:String(this.props.emptyText||this.t("views.empty"))}));const l=this.buildFoot();l&&t.appendChild(l)}buildList(t){const n=$(this.doc,"div",{class:O.list,attrs:{role:"list"}});for(const i of t)n.appendChild(this.buildItem(i));return n}views(){const t=z(this.host.views)?this.host.views()||[]:[];return this.props.sort!=="name"?t:t.slice().sort((n,i)=>String(n.name||"").localeCompare(String(i.name||"")))}activeId(){return z(this.host.activeId)?this.host.activeId():null}buildHead(t,n){return $(this.doc,"div",{class:O.head,children:[$(this.doc,"span",{class:O.title,text:String(t)}),$(this.doc,"span",{class:O.count,text:String(n)})]})}buildItem(t){const n=String(t.id),i=this.activeId()===n,s=z(this.host.canEdit)?this.host.canEdit(t)!==!1:!0,l=$(this.doc,"div",{class:[O.item,i?O.itemActive:"",this.editing===n?O.itemEditing:""],attrs:{role:"listitem","data-view":n,"data-shared":t.shared?"true":"false"}});if(this.editing===n)return l.appendChild(this.buildRenameRow(t)),l;const u=$(this.doc,"button",{class:O.apply,attrs:{type:"button","aria-current":i?"true":null,title:[i?`${t.name} is applied`:`Apply ${t.name}`,t.shared?"Shared with everyone":"Private to you"].join(": ")},children:[$(this.doc,"span",{class:O.name,text:String(t.name||"")}),t.isDefault?this.buildBadges(t):null].filter(Boolean)});z(this.host.apply)?this.off.push(L(u,"click",()=>this.applyView(n))):u.setAttribute("disabled",""),t.description&&u.appendChild($(this.doc,"span",{class:O.description,text:String(t.description)}));const f=this.buildDiff(n,i);return f&&u.appendChild(f),l.appendChild(u),t.builtin||l.appendChild(this.confirming===n?this.buildConfirm(t):this.buildActions(t,s)),l}buildBadges(t){const n=$(this.doc,"span",{class:O.badges});return t.isDefault&&n.appendChild($(this.doc,"span",{class:[O.badge,O.badgeDefault],text:this.t("views.default"),attrs:{title:"Applied when the grid loads"}})),n}buildDiff(t,n){if(this.props.showDiff!==!0||!z(this.host.diff))return null;const i=this.diffOf(t);if(!i)return null;if(!i.changed)return $(this.doc,"span",{class:[O.diff,O.diffClean],text:this.t(n?"views.applied":"views.matchesGrid")});const s=d(i);return s.length?$(this.doc,"span",{class:O.diff,text:s.join(" · ")}):null}diffOf(t){if(!z(this.host.diff))return null;if(this.diffs.has(t))return this.diffs.get(t);let n=null;try{n=this.host.diff(t)}catch{n=null}return this.diffs.set(t,n),n}buildActions(t,n){const i=String(t.id),s=$(this.doc,"span",{class:O.actions});if(n&&z(this.host.rename)&&s.appendChild(this.buildAction("Rename",`Rename ${t.name}`,()=>{this.editing=i,this.confirming=null,this.refresh(),this.focusInput()},"pencil")),t.isDefault&&z(this.host.clearDefault)?s.appendChild(this.buildAction("Unset default",`Stop applying ${t.name} at load`,()=>{this.host.clearDefault(i),this.refresh()},"pin")):!t.isDefault&&z(this.host.setDefault)&&s.appendChild(this.buildAction("Make default",`Apply ${t.name} when the grid loads`,()=>{this.host.setDefault(i),this.refresh()},"pin")),z(this.host.export)&&s.appendChild(this.buildAction("Share",`Export ${t.name}`,()=>this.host.export(i),"share")),n&&z(this.host.remove)){const l=this.buildAction("Delete",`Delete ${t.name}`,()=>{this.confirming=i,this.refresh()},"trash");l.classList.add(O.actionDanger),s.appendChild(l)}return s}buildConfirm(t){const n=String(t.id),i=$(this.doc,"span",{class:O.confirm});i.appendChild($(this.doc,"span",{text:this.t("views.confirmDelete",{name:t.name})}));const s=this.buildAction(this.t("views.delete"),this.t("views.confirmDeleteLabel",{name:t.name}),()=>{this.confirming=null,this.host.remove(n),this.refresh()});return s.classList.add(O.actionDanger),i.appendChild(s),i.appendChild(this.buildAction("Cancel","Keep this view",()=>{this.confirming=null,this.refresh()})),i}buildRenameRow(t){const n=String(t.id),i=$(this.doc,"span",{class:O.confirm}),s=$(this.doc,"input",{class:O.input,attrs:{type:"text","aria-label":`New name for ${t.name}`}});s.value=String(t.name||""),this.input=s;const l=()=>{const f=String(s.value||"").trim();this.editing=null,f&&f!==t.name&&this.host.rename(n,f),this.refresh()},u=()=>{this.editing=null,this.refresh()};return this.off.push(L(s,"keydown",f=>{f.key==="Enter"?l():f.key==="Escape"&&u()})),i.appendChild(s),i.appendChild(this.buildAction("Save","Save the new name",l)),i.appendChild(this.buildAction("Cancel","Leave the name alone",u)),i}buildFoot(){if(this.props.allowSave===!1||!z(this.host.saveAs))return null;const t=$(this.doc,"div",{class:O.foot}),n=$(this.doc,"input",{class:O.input,attrs:{type:"text",placeholder:this.t("views.namePlaceholder"),"aria-label":this.t("views.nameLabel")}});n.value=this.draft,this.editing===null&&(this.input=n);const i=()=>{const l=String(n.value||"").trim();if(!l){z(n.focus)&&n.focus();return}this.draft="",this.host.saveAs(l),this.refresh()};this.off.push(L(n,"input",()=>{this.draft=String(n.value||"")})),this.off.push(L(n,"keydown",l=>{l.key==="Enter"&&i()}));const s=$(this.doc,"button",{class:O.save,text:this.t("views.save"),attrs:{type:"button"}});return this.off.push(L(s,"click",i)),t.appendChild(n),t.appendChild(s),t}buildAction(t,n,i,s){const l=$(this.doc,"button",{class:O.action,text:s?null:t,attrs:{type:"button",title:n,"aria-label":n,"data-action":t}});return s&&l.appendChild(k(this.doc,s,{className:O.actionIcon})),this.off.push(L(l,"click",i)),l}applyView(t){this.confirming=null,this.host.apply(t),this.refresh()}focusInput(){const t=this.input;t&&z(t.focus)&&t.focus(),t&&z(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 d(r,t=3){if(!r||!r.changed)return[];const n=r.counts||{},i=[],s=(l,u,f)=>{l&&i.push((l===1?u:f).replace("%",String(l)))};if(s(n.columnsHidden,"hides % column","hides % columns"),s(n.columnsShown,"shows % column","shows % columns"),s(n.columnsMoved,"moves % column","moves % columns"),s(n.columnsPinned,"repins % column","repins % columns"),s(n.columnsResized,"resizes % column","resizes % columns"),r.filters&&r.filters.changed){const l=n.filterColumns||0;i.push(l?`changes ${l} filter${l===1?"":"s"}`:"changes the filter")}return r.quick&&r.quick.changed&&i.push("changes the search"),r.sort&&r.sort.changed&&i.push("changes the sort"),r.group&&r.group.changed&&i.push("changes the grouping"),r.pivot&&r.pivot.changed&&i.push("changes the pivot"),s(n.columnsTotalled,"changes % total","changes % totals"),r.pagination&&r.pagination.changed&&i.push("changes the page size"),i.length<=t?i:[...i.slice(0,t),`and ${i.length-t} more`]}const c=y}),ke("packages/dom/src/ui/panelbase.js",function(e,V){"use strict";Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return Z}});const _=V("packages/dom/src/editors/common.js"),R=_.CLS,$=_.el,W=V("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:`${R.panel}__body`}),this.refresh()}t(U,z){const F=this.host||{};if(typeof F.t=="function")return F.t(U,z);const k=this.ctx||{};if(k.messages&&typeof k.messages.t=="function")return k.messages.t(U,z);const O=k.grid;return(O&&O.messages?O.messages:W).t(U,z)}element(){return this.root}refresh(){}destroy(){for(const U of this.off)U();this.off.length=0,this.root=null}}}),ke("packages/dom/src/formattingpanel.js",function(e,V){"use strict";Object.defineProperty(e,"describeRule",{enumerable:!0,get:function(){return g}}),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 m}});const _=V("packages/dom/src/editors/common.js"),R=_.CLS,$=_.documentFor,L=_.el,W=_.on,Z=_.clear,U=V("packages/core/src/internal/util.js").isFunction,F=V("packages/dom/src/ui/panelbase.js").ToolPanelBase,k=V("packages/core/src/formatting/rules.js"),O=k.compileRules,y=k.summariseColumn,d=k.needsDistribution,c=k.DISTRIBUTION_LABELS,r="*",t=8,n=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}]),i=Object.freeze([{op:"topPercent",label:c.topPercent,values:1},{op:"bottomPercent",label:c.bottomPercent,values:1},{op:"topN",label:c.topN,values:1},{op:"bottomN",label:c.bottomN,values:1},{op:"aboveMean",label:c.aboveMean,values:0},{op:"belowMean",label:c.belowMean,values:0},{op:"aboveMedian",label:c.aboveMedian,values:0},{op:"belowMedian",label:c.belowMedian,values:0},{op:"zAbove",label:c.zAbove,values:1},{op:"zBelow",label:c.zBelow,values:1},{op:"outlier",label:c.outlier,values:0}]),s=Object.freeze([...n,...i]),l=Object.freeze([{name:"Red",background:"#fbeceb",color:"#b03030"},{name:"Amber",background:"#fdf3e0",color:"#9a6400"},{name:"Green",background:"#e8f5ee",color:"#1a7f4b"},{name:"Blue",background:"#e7f0fb",color:"#1a6bc7"},{name:"Grey",background:"#f1f3f5",color:"#5b6570"}]),u=Object.freeze([{name:"White → Blue",colours:["#f8f9fa","#1a6bc7"]},{name:"White → Green",colours:["#f8f9fa","#1a7f4b"]},{name:"Red → Green",colours:["#d64545","#f6e58d","#1a7f4b"]},{name:"Blue → White → Red",colours:["#1a6bc7","#f8f9fa","#d64545"]}]),f=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 h(w){const v=s.find(a=>a.op===w);return v?v.values:1}function g(w){if(!w)return"";if(w.scale){const{min:S,max:E,from:A}=w.scale;if(Number.isFinite(S)&&Number.isFinite(E))return`Colour scale, ${S} to ${E}`;const M=f.find(C=>C.from===A);return M?`Colour scale ${M.label}`:"Colour scale"}const v=w.when||{},a=s.find(S=>S.op===v.op),o=a?a.label:v.op;return!a||a.values===0?`Value ${o}`:a.values===2?`Value ${o} ${v.value} and ${v.value2}`:`Value ${o} ${v.value}`}class b extends F{scope=r;mode="condition";refresh(){const v=this.root;if(v){for(const a of this.off)a();this.off.length=0,Z(v),v.appendChild(this.#o()),v.appendChild(this.#i()),v.appendChild(this.#s())}}#e(){const v=U(this.host.formattableColumns)?this.host.formattableColumns():[];return[{id:r,title:"All columns"},...v]}#t(){return U(this.host.formattingRules)?this.host.formattingRules(this.scope):[]}#n(v){if(!U(this.host.columnSamples))return[];const a=this.host.columnSamples(v);return Array.isArray(a)?a:[...a||[]]}#r(v,a,o){const S=d(v)?y(a):null;return O(v,S)({value:o})}#o(){const v=L(this.doc,"div",{class:`${R.panel}__row`});v.appendChild(L(this.doc,"label",{class:`${R.panel}__label`,text:this.t("formatting.format"),attrs:{for:"lat-fmt-scope"}}));const a=L(this.doc,"select",{class:`${R.panel}__select`,attrs:{id:"lat-fmt-scope"}});for(const o of this.#e()){const S=L(this.doc,"option",{text:o.title,attrs:{value:o.id}});o.id===this.scope&&S.setAttribute("selected","selected"),a.appendChild(S)}return a.value=this.scope,this.off.push(W(a,"change",()=>{this.scope=a.value||r,this.refresh()})),v.appendChild(a),v}#i(){const v=L(this.doc,"ul",{class:`${R.panel}__list`}),a=this.#t();if(!a.length)return v.appendChild(L(this.doc,"li",{class:`${R.panel}__empty`,text:this.t("formatting.noRules")})),v;a.forEach((E,A)=>{const M=L(this.doc,"li",{class:`${R.panel}__item`,attrs:{"data-rule":E.id}}),C=L(this.doc,"input",{attrs:{type:"checkbox","aria-label":`Enable ${g(E)}`}});C.checked=E.enabled!==!1,this.off.push(W(C,"change",()=>{this.#c("updateRule",this.scope,E.id,{enabled:C.checked})})),M.appendChild(C);const P=L(this.doc,"span",{class:`${R.panel}__swatch`}),x=E.style||{};if(x.background&&P.style&&P.style.setProperty)P.style.setProperty("background",String(x.background));else if(E.scale&&E.scale.colours&&P.style&&P.style.setProperty){const j=E.scale.colours;P.style.setProperty("background",`linear-gradient(90deg, ${j[0]}, ${j[j.length-1]})`)}M.appendChild(P),M.appendChild(L(this.doc,"span",{class:`${R.panel}__text`,text:g(E)}));const K=L(this.doc,"button",{class:`${R.panel}__icon`,text:"↑",attrs:{type:"button","aria-label":this.t("formatting.moveEarlier"),...A===0?{disabled:"disabled"}:{}}});this.off.push(W(K,"click",()=>this.#c("moveRule",this.scope,E.id,A-1))),M.appendChild(K);const I=L(this.doc,"button",{class:`${R.panel}__icon`,text:"↓",attrs:{type:"button","aria-label":this.t("formatting.moveLater"),...A===a.length-1?{disabled:"disabled"}:{}}});this.off.push(W(I,"click",()=>this.#c("moveRule",this.scope,E.id,A+1))),M.appendChild(I);const D=L(this.doc,"button",{class:`${R.panel}__icon`,text:"×",attrs:{type:"button","aria-label":`Remove ${g(E)}`}});this.off.push(W(D,"click",()=>this.#c("removeRule",this.scope,E.id))),M.appendChild(D),v.appendChild(M)});const o=this.#a(a);o&&v.appendChild(o);const S=L(this.doc,"button",{class:`${R.panel}__link`,text:this.t("formatting.clearAll"),attrs:{type:"button"}});return this.off.push(W(S,"click",()=>this.#c("clearRules",this.scope))),v.appendChild(S),v}#a(v){const a=this.#n(this.scope);if(!a.length)return null;const o=v.filter(E=>E.enabled!==!1);if(!o.length)return null;const S=L(this.doc,"div",{class:`${R.panel}__preview`,attrs:{"aria-label":this.t("formatting.preview")}});for(const E of a.slice(0,t)){const A=this.#r(o,a,E),M=L(this.doc,"span",{class:`${R.panel}__previewcell`,text:String(E)});A&&M.style&&M.style.setProperty&&(A.background&&M.style.setProperty("background",String(A.background)),A.color&&M.style.setProperty("color",String(A.color))),S.appendChild(M)}return S}#s(){const v=L(this.doc,"div",{class:`${R.panel}__form`}),a=L(this.doc,"select",{class:`${R.panel}__select`,attrs:{"aria-label":this.t("formatting.ruleKind")}});return a.appendChild(L(this.doc,"option",{text:this.t("formatting.aCondition"),attrs:{value:"condition"}})),a.appendChild(L(this.doc,"option",{text:this.t("formatting.aColourScale"),attrs:{value:"scale"}})),a.value=this.mode,this.off.push(W(a,"change",()=>{this.mode=a.value==="scale"?"scale":"condition",this.refresh()})),v.appendChild(a),this.mode==="scale"?v.appendChild(this.#u()):v.appendChild(this.#l()),v}#l(){const v=L(this.doc,"div",{class:`${R.panel}__form`}),a=L(this.doc,"select",{class:`${R.panel}__select`,attrs:{"aria-label":this.t("formatting.condition")}}),o=L(this.doc,"optgroup",{attrs:{label:this.t("formatting.compare")}});for(const D of n)o.appendChild(L(this.doc,"option",{text:D.label,attrs:{value:D.op}}));a.appendChild(o);const S=L(this.doc,"optgroup",{attrs:{label:this.t("formatting.distribution")}});for(const D of i)S.appendChild(L(this.doc,"option",{text:D.label,attrs:{value:D.op}}));a.appendChild(S),a.value="gt",v.appendChild(a);const E=L(this.doc,"input",{class:`${R.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.value")}}),A=L(this.doc,"input",{class:`${R.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.secondValue")}});v.appendChild(E),v.appendChild(A);const M=()=>{const D=h(a.value);E.style.setProperty("display",D>=1?"":"none"),A.style.setProperty("display",D>=2?"":"none"),K()};this.off.push(W(a,"change",M));const C=L(this.doc,"select",{class:`${R.panel}__select`,attrs:{"aria-label":this.t("menu.colour")}});for(const D of l)C.appendChild(L(this.doc,"option",{text:D.name,attrs:{value:D.name}}));C.value=l[0].name,v.appendChild(C);const P=L(this.doc,"div",{class:`${R.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});v.appendChild(P);const x=()=>{const D=l.find(B=>B.name===C.value)||l[0],j=h(a.value),T={op:a.value};return j>=1&&(T.value=E.value),j>=2&&(T.value2=A.value),{when:T,style:{background:D.background,color:D.color}}},K=()=>{Z(P);const D=this.#n(this.scope);if(D.length)for(const j of D.slice(0,t)){const T=this.#r([x()],D,j),B=L(this.doc,"span",{class:`${R.panel}__previewcell`,text:String(j)});T&&B.style&&B.style.setProperty&&(T.background&&B.style.setProperty("background",String(T.background)),T.color&&B.style.setProperty("color",String(T.color))),P.appendChild(B)}};this.off.push(W(E,"input",K)),this.off.push(W(A,"input",K)),this.off.push(W(C,"change",K)),M();const I=L(this.doc,"button",{class:`${R.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(W(I,"click",()=>{this.#c("addRule",this.scope,x()),E.value="",A.value=""})),v.appendChild(I),v}#u(){const v=L(this.doc,"div",{class:`${R.panel}__form`}),a=L(this.doc,"select",{class:`${R.panel}__select`,attrs:{"aria-label":this.t("formatting.colourScale")}});for(const C of u)a.appendChild(L(this.doc,"option",{text:C.name,attrs:{value:C.name}}));a.value=u[0].name,v.appendChild(a);const o=L(this.doc,"select",{class:`${R.panel}__select`,attrs:{"aria-label":this.t("formatting.scaleBounds")}});for(const C of f)o.appendChild(L(this.doc,"option",{text:C.label,attrs:{value:C.from}}));o.value=f[0].from,v.appendChild(o);const S=L(this.doc,"div",{class:`${R.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});v.appendChild(S);const E=()=>{const C=u.find(P=>P.name===a.value)||u[0];return{scale:{from:o.value,colours:[...C.colours]}}},A=()=>{Z(S);const C=this.#n(this.scope);if(C.length)for(const P of C.slice(0,t)){const x=this.#r([E()],C,P),K=L(this.doc,"span",{class:`${R.panel}__previewcell`,text:String(P)});x&&x.background&&K.style&&K.style.setProperty&&K.style.setProperty("background",String(x.background)),S.appendChild(K)}};this.off.push(W(a,"change",A)),this.off.push(W(o,"change",A)),A();const M=L(this.doc,"button",{class:`${R.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(W(M,"click",()=>{this.#c("addRule",this.scope,E())})),v.appendChild(M),v}#c(v,...a){U(this.host[v])&&this.host[v](...a),this.refresh()}}function p(w={}){const v=new b;return v.init({document:$(w),host:w.host||{}}),v}const m=b}),ke("packages/dom/src/statisticspanel.js",function(e,V){"use strict";Object.defineProperty(e,"StatisticsPanel",{enumerable:!0,get:function(){return d}});const _=V("packages/dom/src/editors/common.js"),R=_.CLS,$=_.el,L=_.on,W=_.clear,H=V("packages/core/src/internal/util.js").isFunction,z=V("packages/dom/src/ui/panelbase.js").ToolPanelBase,F=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"}]),k=Object.freeze([{key:"present",label:"stats.present",kind:"count"},{key:"missing",label:"stats.missing",kind:"count"},{key:"distinct",label:"stats.distinct",kind:"count"}]),O=Object.freeze([{label:"stats.section.shape",kernels:["skewness","kurtosis","jarqueBera"]},{label:"stats.section.robust",kernels:["trimmedMean","winsorizedMean","mad","robustOutliers"]},{label:"stats.section.concentration",kernels:["gini","hhi","entropy","evenness","top3Share"]}]);function y(c){if(c==null||!Number.isFinite(c))return"—";if(Number.isInteger(c))return String(c);const r=Math.abs(c);return r!==0&&(r<.001||r>=1e7)?c.toExponential(2):String(Number(c.toPrecision(4)))}class d extends z{column=null;#e(){return H(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const r=this.root;if(!r)return;for(const s of this.off)s();this.off.length=0,W(r);const t=this.#e();if(!t.length){r.appendChild($(this.doc,"p",{class:`${R.panel}__empty`,text:this.t("stats.noColumns")}));return}t.some(s=>s.id===this.column)||(this.column=t[0].id),r.appendChild(this.#t(t));const n=H(this.host.columnProfile)?this.host.columnProfile(this.column):null;if(!n||!n.present){r.appendChild($(this.doc,"p",{class:`${R.panel}__empty`,text:this.t("stats.noValues")}));return}if(r.appendChild($(this.doc,"p",{class:`${R.panel}__count`,text:this.t("stats.filtered",{count:n.rows})})),Array.isArray(n.topValues)){r.appendChild(this.#o(n,k)),r.appendChild(this.#i(n.topValues));return}r.appendChild(this.#o(n));for(const s of O){const l=this.#n(s);l&&r.appendChild(l)}const i=this.#r();i&&r.appendChild(i),n.histogram&&n.histogram.length>1&&r.appendChild(this.#a(n.histogram))}#t(r){const t=$(this.doc,"select",{class:`${R.panel}__select`,attrs:{"aria-label":this.t("stats.choose")}});for(const n of r){const i=$(this.doc,"option",{text:n.title,attrs:{value:n.id,selected:n.id===this.column?!0:null}});t.appendChild(i)}return t.value=this.column,this.off.push(L(t,"change",()=>{this.column=t.value,this.refresh()})),$(this.doc,"label",{class:`${R.panel}__field`,children:[$(this.doc,"span",{class:`${R.panel}__label`,text:this.t("stats.column")}),t]})}#n(r){const t=this.host.reduceColumn;if(!H(t)||!this.column)return null;const n=[];for(const l of r.kernels){const u=t(this.column,l);u==null||Number.isNaN(u)||n.push([l,u])}if(!n.length)return null;const i=this.doc.createElement("div");i.appendChild($(this.doc,"h4",{class:`${R.panel}__subtitle`,text:this.t(r.label)}));const s=$(this.doc,"dl",{class:`${R.panel}__stats`});for(const[l,u]of n)s.appendChild($(this.doc,"dt",{class:`${R.panel}__stat-name`,text:this.t(`total.${l}`)})),s.appendChild($(this.doc,"dd",{class:`${R.panel}__stat-value`,text:typeof u=="number"?y(u):String(u)}));return i.appendChild(s),i}#r(){const r=this.host.columnCapability;if(!H(r)||!this.column)return null;const t=r(this.column);if(!t)return null;const n=this.doc.createElement("div");n.appendChild($(this.doc,"h4",{class:`${R.panel}__subtitle`,text:this.t("stats.section.capability")}));const i=$(this.doc,"dl",{class:`${R.panel}__stats`}),s=[["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[l,u,f]of s){if(u==null)continue;i.appendChild($(this.doc,"dt",{class:`${R.panel}__stat-name`,text:this.t(l)}));const h=[$(this.doc,"span",{text:y(u)})];f&&Number.isFinite(f.lower)&&h.push($(this.doc,"span",{class:`${R.panel}__stat-interval`,text:`${y(f.lower)} – ${y(f.upper)}`,attrs:{title:`${Math.round(f.confidence*100)}%`}})),i.appendChild($(this.doc,"dd",{class:`${R.panel}__stat-value`,children:h}))}return n.appendChild(i),n}#o(r,t=F){const n=$(this.doc,"dl",{class:`${R.panel}__stats`});for(const i of t){const s=r[i.key];n.appendChild($(this.doc,"dt",{class:`${R.panel}__stat-name`,text:this.t(i.label)})),n.appendChild($(this.doc,"dd",{class:`${R.panel}__stat-value`,text:i.kind==="count"?String(s??0):y(s)}))}return n}#i(r){const t=this.doc.createElement("div");t.appendChild($(this.doc,"h4",{class:`${R.panel}__subtitle`,text:this.t("stats.topValues")}));const n=$(this.doc,"dl",{class:`${R.panel}__stats`});for(const i of r)n.appendChild($(this.doc,"dt",{class:`${R.panel}__stat-name`,text:String(i.value)})),n.appendChild($(this.doc,"dd",{class:`${R.panel}__stat-value`,children:[$(this.doc,"span",{text:String(i.count)}),$(this.doc,"span",{class:`${R.panel}__stat-interval`,text:`${Math.round(i.share*100)}%`})]}));return t.appendChild(n),t}#a(r){const t=r.reduce((i,s)=>Math.max(i,s.count),0)||1,n=$(this.doc,"div",{class:`${R.panel}__histogram`});n.appendChild($(this.doc,"h4",{class:`${R.panel}__subtitle`,text:this.t("stats.distribution")}));for(const i of r){const s=$(this.doc,"div",{class:`${R.panel}__bar`,style:{width:`${i.count?Math.max(2,i.count/t*100):0}%`}});n.appendChild($(this.doc,"div",{class:`${R.panel}__bin`,attrs:{title:this.t("stats.bin",{count:i.count,from:y(i.from),to:y(i.to)})},children:[s]}))}return n}}}),ke("packages/dom/src/regressionpanel.js",function(e,V){"use strict";Object.defineProperty(e,"RegressionPanel",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const _=V("packages/dom/src/editors/common.js"),R=_.CLS,$=_.el,L=_.clear,Z=V("packages/core/src/internal/util.js").isFunction,U=V("packages/dom/src/ui/panelbase.js").ToolPanelBase;function z(O,y=4){const d=Number(O);return Number.isFinite(d)?d.toFixed(y):d===1/0?"∞":"—"}class F extends U{#e(){const y=this.props||{};if(Array.isArray(y.predictors)&&y.predictors.length&&y.response)return y;const d=this.ctx&&this.ctx.grid,c=d&&Z(d.get)?d.get("regression"):null;return c&&Array.isArray(c.predictors)&&c.response?c:null}refresh(){const y=this.root;if(!y)return;L(y);const d=this.#e();if(!d){y.appendChild($(this.doc,"p",{class:`${R.panel}__empty`,text:this.t("regression.noModel")}));return}const c=Z(this.host.regressionModel)?this.host.regressionModel(d):null;if(!c){y.appendChild($(this.doc,"p",{class:`${R.panel}__empty`,text:this.t("regression.cannotFit")}));return}y.appendChild($(this.doc,"p",{class:`${R.panel}__count`,text:this.t("regression.observations",{count:c.n})})),y.appendChild(this.#t(c)),y.appendChild(this.#n(c));const r=this.#r(c,d);r&&y.appendChild(r),y.appendChild(this.#o(c))}#t(y){const d=$(this.doc,"dl",{class:`${R.panel}__stats`}),c=(r,t)=>{d.appendChild($(this.doc,"dt",{class:`${R.panel}__stat-label`,text:r})),d.appendChild($(this.doc,"dd",{class:`${R.panel}__stat-value`,text:t}))};return c(this.t("regression.r2"),z(y.r2,4)),c(this.t("regression.adjR2"),z(y.adjR2,4)),d}#n(y){const d=$(this.doc,"div",{class:`${R.panel}__section`});d.appendChild($(this.doc,"h4",{class:`${R.panel}__heading`,text:this.t("regression.coefficients")}));const c=$(this.doc,"table",{class:`${R.panel}__coef-table`}),r=$(this.doc,"tr");for(const t of["regression.term","regression.estimate","regression.stdError","regression.t","regression.p"])r.appendChild($(this.doc,"th",{text:this.t(t)}));c.appendChild(r);for(const t of y.coefficients){const n=$(this.doc,"tr");n.appendChild($(this.doc,"td",{text:t.name})),n.appendChild($(this.doc,"td",{text:`${z(t.estimate)} ± ${z(t.stdError)}`})),n.appendChild($(this.doc,"td",{text:z(t.stdError)})),n.appendChild($(this.doc,"td",{text:z(t.t,3)})),n.appendChild($(this.doc,"td",{text:z(t.p,4)})),c.appendChild(n)}return d.appendChild(c),d}#r(y,d){if(!Array.isArray(y.vif)||y.vif.length<2)return null;const c=$(this.doc,"div",{class:`${R.panel}__section`});c.appendChild($(this.doc,"h4",{class:`${R.panel}__heading`,text:this.t("regression.vif")}));const r=$(this.doc,"dl",{class:`${R.panel}__stats`});return y.vif.forEach((t,n)=>{r.appendChild($(this.doc,"dt",{class:`${R.panel}__stat-label`,text:d.predictors[n]})),r.appendChild($(this.doc,"dd",{class:`${R.panel}__stat-value`,text:z(t,3)}))}),c.appendChild(r),c}#o(y){const d=y.heteroscedasticity,c=$(this.doc,"div",{class:`${R.panel}__section`});return c.appendChild($(this.doc,"h4",{class:`${R.panel}__heading`,text:this.t("regression.heteroscedasticity")})),d?(c.appendChild($(this.doc,"p",{class:`${R.panel}__flag`,attrs:{"data-heteroscedastic":d.heteroscedastic?"true":"false"},text:this.t(d.heteroscedastic?"regression.heteroscedastic":"regression.homoscedastic",{statistic:z(d.statistic,3),p:z(d.p,4)})})),c):(c.appendChild($(this.doc,"p",{class:`${R.panel}__empty`,text:this.t("regression.cannotFit")})),c)}}const k=F}),ke("packages/dom/src/comparepanel.js",function(e,V){"use strict";Object.defineProperty(e,"ComparePanel",{enumerable:!0,get:function(){return O}});const _=V("packages/dom/src/editors/common.js"),R=_.CLS,$=_.el,L=_.on,W=_.clear,H=V("packages/core/src/internal/util.js").isFunction,z=V("packages/dom/src/ui/panelbase.js").ToolPanelBase,F=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 k(y){if(y==null||!Number.isFinite(y))return"—";if(Number.isInteger(y))return String(y);const d=Math.abs(y);return d!==0&&(d<.001||d>=1e7)?y.toExponential(2):String(Number(y.toPrecision(4)))}class O extends z{first=null;second=null;#e(){return H(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const d=this.root;if(!d)return;for(const n of this.off)n();this.off.length=0,W(d);const c=this.#e();if(c.length<2){d.appendChild($(this.doc,"p",{class:`${R.panel}__empty`,text:this.t("compare.needTwo")}));return}c.some(n=>n.id===this.first)||(this.first=c[0].id),(!c.some(n=>n.id===this.second)||this.second===this.first)&&(this.second=(c.find(n=>n.id!==this.first)||c[0]).id),d.appendChild(this.#t("compare.first",c,this.first,n=>{this.first=n,this.second===n&&(this.second=(c.find(i=>i.id!==n)||c[0]).id),this.refresh()})),d.appendChild(this.#t("compare.second",c,this.second,n=>{this.second=n,this.first===n&&(this.first=(c.find(i=>i.id!==n)||c[0]).id),this.refresh()}));const r=H(this.host.compareColumns)?this.host.compareColumns(this.first,this.second):null;if(!r||!r.n){d.appendChild($(this.doc,"p",{class:`${R.panel}__empty`,text:this.t("compare.noPairs")}));return}d.appendChild($(this.doc,"p",{class:`${R.panel}__count`,text:this.t("compare.pairs",{count:r.n})}));const t=$(this.doc,"dl",{class:`${R.panel}__stats`});for(const n of F){const i=r[n.key];i!=null&&(t.appendChild($(this.doc,"dt",{class:`${R.panel}__stat-name`,text:this.t(n.label)})),t.appendChild($(this.doc,"dd",{class:`${R.panel}__stat-value`,text:k(i)})))}d.appendChild(t)}#t(d,c,r,t){const n=$(this.doc,"select",{class:`${R.panel}__select`,attrs:{"aria-label":this.t(d)}});for(const i of c)n.appendChild($(this.doc,"option",{text:i.title,attrs:{value:i.id,selected:i.id===r?!0:null}}));return n.value=r,this.off.push(L(n,"change",()=>t(n.value))),$(this.doc,"label",{class:`${R.panel}__field`,children:[$(this.doc,"span",{class:`${R.panel}__label`,text:this.t(d)}),n]})}}}),ke("packages/dom/src/insightspanel.js",function(e,V){"use strict";Object.defineProperty(e,"InsightsPanel",{enumerable:!0,get:function(){return O}});const _=V("packages/dom/src/editors/common.js"),R=_.CLS,$=_.el,L=_.on,W=_.clear,H=V("packages/core/src/internal/util.js").isFunction,z=V("packages/dom/src/ui/panelbase.js").ToolPanelBase,F=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 k(y){if(y==null||!Number.isFinite(y))return"—";if(Number.isInteger(y))return String(y);const d=Math.abs(y);return d!==0&&(d<.001||d>=1e7)?y.toExponential(2):String(Number(y.toPrecision(4)))}class O extends z{column=null;by=null;#e(){return H(this.host.insightsColumns)?this.host.insightsColumns():[]}refresh(){const d=this.root;if(!d)return;for(const s of this.off)s();this.off.length=0,W(d);const c=this.#e();if(!c.length){d.appendChild($(this.doc,"p",{class:`${R.panel}__empty`,text:this.t("insights.empty")}));return}const r=this.#t();r&&d.appendChild(r);const t=this.#n();t&&d.appendChild(t),d.appendChild(this.#o(c));const n=this.#a();n&&d.appendChild(n);const i=this.#u();i&&d.appendChild(i)}#t(){if(!H(this.host.subsetVsPopulation))return null;const d=this.host.subsetVsPopulation();if(!d)return null;const c=this.#c("insights.subset");return d.filtered?(c.appendChild($(this.doc,"p",{class:`${R.panel}__count`,text:this.t("stats.filtered",{count:d.subsetN})})),c.appendChild(this.#r(d.ranked)),c):(c.appendChild($(this.doc,"p",{class:`${R.panel}__empty`,text:this.t("insights.noFilter")})),c)}#n(){const d=this.props&&this.props.other;if(!d||!H(this.host.datasetVsDataset))return null;let c;try{c=this.host.datasetVsDataset(d)}catch{return null}if(!c||!c.ranked)return null;const r=this.#c("insights.dataset");return r.appendChild(this.#r(c.ranked)),r}#r(d){const c=$(this.doc,"dl",{class:`${R.panel}__stats`});for(const r of d||[]){const t=$(this.doc,"dt",{class:`${R.panel}__stat-name`});t.appendChild($(this.doc,"span",{text:String(r.name??r.column)})),t.appendChild($(this.doc,"span",{class:`${R.panel}__stat-interval`,text:String(r.measure||"")}));const n=$(this.doc,"dd",{class:`${R.panel}__stat-value`});n.appendChild($(this.doc,"span",{text:k(r.magnitude)})),r.reliable===!1&&n.appendChild($(this.doc,"span",{class:`${R.panel}__stat-interval`,text:this.t("insights.smallSample")})),c.appendChild(t),c.appendChild(n)}return c}#o(d){const c=this.#c("insights.groups");d.some(t=>t.id===this.column)||(this.column=d[0].id),(!d.some(t=>t.id===this.by)||this.by===this.column)&&(this.by=(d.find(t=>t.id!==this.column)||d[0]).id),c.appendChild(this.#d("stats.column",d,this.column,t=>{this.column=t,this.by===t&&(this.by=(d.find(n=>n.id!==t)||d[0]).id),this.refresh()})),c.appendChild(this.#d("insights.by",d,this.by,t=>{this.by=t,this.column===t&&(this.column=(d.find(n=>n.id!==t)||d[0]).id),this.refresh()}));const r=H(this.host.compareGroups)?this.host.compareGroups(this.column,{by:this.by}):null;return r?(c.appendChild(this.#i(r)),c):(c.appendChild($(this.doc,"p",{class:`${R.panel}__empty`,text:this.t("insights.needGroups")})),c)}#i(d){const c=$(this.doc,"dl",{class:`${R.panel}__stats`});Array.isArray(d.groups)&&d.groups.length===2&&this.#l(c,"insights.groups",`${d.groups[0]} · ${d.groups[1]}`),this.#l(c,"insights.test",String(d.method||d.test||""));const r=d.effectSize||{};this.#l(c,"insights.effect",`${r.name||""} ${k(r.value)}`.trim());const t=d.interval;let n="—";if(t&&Number.isFinite(t.lower)&&Number.isFinite(t.upper)){const s=Number.isFinite(t.confidence)?` (${Math.round(t.confidence*100)}%)`:"";n=`${k(t.lower)} – ${k(t.upper)}${s}`}const i=this.#l(c,"insights.interval",n);return t&&t.method&&i.appendChild($(this.doc,"span",{class:`${R.panel}__stat-interval`,text:String(t.method)})),Number.isFinite(d.pValue)&&this.#l(c,"insights.pValue",k(d.pValue)),c}#a(){if(!H(this.host.anomalies))return null;let d;try{d=this.host.anomalies()}catch{return null}if(!d)return null;const c=this.#c("insights.anomalies");c.appendChild($(this.doc,"p",{class:`${R.panel}__count`,text:this.t("insights.anomalyCount",{count:d.flagged||0,n:d.n||0})}));const r=$(this.doc,"dl",{class:`${R.panel}__stats`});this.#l(r,"insights.anomalyMethod",String(d.method||""));const t=this.#s(d);t!==null&&this.#l(r,"insights.anomalyThreshold",k(t)),c.appendChild(r);const n=(d.rows||[]).map(i=>({name:i.rowKey!=null?String(i.rowKey):`#${i.index}`,measure:(i.why||[]).map(s=>s.name||s.column).join(", "),magnitude:i.score}));return c.appendChild(this.#r(n)),c}#s(d){if(d.method==="mahalanobis")return Number.isFinite(d.cutoff)?d.cutoff:null;if(d.method==="iqr")return Number.isFinite(d.k)?d.k:null;const c=Array.isArray(d.columns)?d.columns[0]:null;return c&&Number.isFinite(c.threshold)?c.threshold:null}#l(d,c,r){d.appendChild($(this.doc,"dt",{class:`${R.panel}__stat-name`,text:this.t(c)}));const t=$(this.doc,"dd",{class:`${R.panel}__stat-value`});return t.appendChild($(this.doc,"span",{text:r})),d.appendChild(t),t}#u(){if(!H(this.host.columnCapability)||!this.column)return null;const d=this.host.columnCapability(this.column);if(!d)return null;const c=this.#c("stats.section.capability"),r=$(this.doc,"dl",{class:`${R.panel}__stats`});for(const t of F){const n=d[t.field];if(n==null)continue;r.appendChild($(this.doc,"dt",{class:`${R.panel}__stat-name`,text:this.t(t.key)}));const i=[$(this.doc,"span",{text:k(n)})],s=t.interval?d[t.interval]:null;s&&Number.isFinite(s.lower)&&i.push($(this.doc,"span",{class:`${R.panel}__stat-interval`,text:`${k(s.lower)} – ${k(s.upper)}`,attrs:{title:`${Math.round(s.confidence*100)}%`}})),r.appendChild($(this.doc,"dd",{class:`${R.panel}__stat-value`,children:i}))}return c.appendChild(r),c}#c(d){const c=this.doc.createElement("div");return c.appendChild($(this.doc,"h4",{class:`${R.panel}__subtitle`,text:this.t(d)})),c}#d(d,c,r,t){const n=$(this.doc,"select",{class:`${R.panel}__select`,attrs:{"aria-label":this.t(d)}});for(const i of c)n.appendChild($(this.doc,"option",{text:i.title,attrs:{value:i.id,selected:i.id===r?!0:null}}));return n.value=r,this.off.push(L(n,"change",()=>t(n.value))),$(this.doc,"label",{class:`${R.panel}__field`,children:[$(this.doc,"span",{class:`${R.panel}__label`,text:this.t(d)}),n]})}}}),ke("packages/dom/src/ui/toolpanel.js",function(e,V){"use strict";Object.defineProperty(e,"ColumnsPanel",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"FiltersPanel",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"QuickFilterPanel",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"toolPanelTitles",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"toolPanelIcons",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return K}});const _=V("packages/dom/src/editors/common.js"),R=_.CLS,$=_.cssEscape,L=_.documentFor,W=_.el,Z=_.on,H=_.clear,z=V("packages/core/src/i18n/index.js").defaultMessages,F=V("packages/core/src/internal/util.js"),k=F.isFunction,O=F.nextFrame,y=V("packages/dom/src/cell/icons.js"),d=y.createIcon,c=y.updateIcon,r=y.icon,n=V("packages/dom/src/viewpicker.js").ViewPicker,s=V("packages/dom/src/formattingpanel.js").FormattingPanel,u=V("packages/dom/src/statisticspanel.js").StatisticsPanel,h=V("packages/dom/src/regressionpanel.js").RegressionPanel,b=V("packages/dom/src/comparepanel.js").ComparePanel,m=V("packages/dom/src/insightspanel.js").InsightsPanel,v=V("packages/dom/src/ui/panelbase.js").ToolPanelBase,o=V("packages/core/src/compute/total.js").TOTAL_LABELS;class S extends v{dragging=null;refresh(){const j=this.root;if(!j)return;for(const Q of this.off)Q();this.off.length=0,H(j);const T=W(this.doc,"input",{class:`${R.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.searchColumns"),"aria-label":this.t("panel.searchColumns")}});this.off.push(Z(T,"input",()=>{this.query=T.value,this.paintList()})),j.appendChild(T),j.appendChild(this.buildZone("group","Row groups")),j.appendChild(this.buildZone("values","Grouped row calculation")),j.appendChild(this.buildZone("pivot","Pivot"));const B=W(this.doc,"div",{class:`${R.panel}__heading`});B.appendChild(W(this.doc,"span",{text:this.t("panel.columns")}));const q=W(this.doc,"button",{class:`${R.panel}__link`,text:this.t("panel.showAll"),attrs:{type:"button"}}),X=W(this.doc,"button",{class:`${R.panel}__link`,text:this.t("panel.hideAll"),attrs:{type:"button"}});this.off.push(Z(q,"click",()=>{const Q=this.columns().filter(J=>!(J.layout&&J.layout.lockVisible)).map(J=>J.id);k(this.host.showColumns)&&this.host.showColumns(Q),this.refresh()})),this.off.push(Z(X,"click",()=>{const Q=this.columns().filter(J=>!(J.layout&&J.layout.lockVisible)).map(J=>J.id);k(this.host.hideColumns)&&this.host.hideColumns(Q),this.refresh()})),B.appendChild(q),B.appendChild(X),j.appendChild(B),this.list=W(this.doc,"div",{class:`${R.panel}__columns`,attrs:{role:"group","aria-label":this.t("panel.columns")}}),j.appendChild(this.list),this.paintList()}columns(){const j=this.host;return k(j.columns)?j.columns()||[]:j.columns&&k(j.columns.all)?j.columns.all():[]}paintList(){const j=this.list;if(!j)return;H(j);const T=String(this.query||"").trim().toLowerCase();for(const B of this.columns()){const q=String(B.title||B.id||"");if(T&&!q.toLowerCase().includes(T))continue;const X=W(this.doc,"div",{class:`${R.panel}__column`,attrs:{"data-col":B.id,draggable:"true",title:this.t("panel.columnDragHint",{column:q})}});X.appendChild(W(this.doc,"span",{class:`${R.panel}__grip`,attrs:{"aria-hidden":"true"}}));const Q=W(this.doc,"input",{attrs:{type:"checkbox","aria-label":q}});Q.checked=!(B.layout&&B.layout.hidden),B.layout&&B.layout.lockVisible&&Q.setAttribute("disabled",""),this.off.push(Z(Q,"change",()=>this.setVisible(B.id,Q.checked))),X.appendChild(Q),X.appendChild(W(this.doc,"span",{text:q})),X.setAttribute("tabindex","0"),X.setAttribute("role","listitem"),this.off.push(Z(X,"keydown",J=>this.onRowKey(J,B))),this.off.push(Z(X,"dragstart",()=>{this.dragging=B.id})),this.off.push(Z(X,"dragend",()=>{this.dragging=null,this.clearDropMark()})),this.off.push(Z(X,"dragover",J=>{if(!this.dragging||this.dragging===B.id)return;k(J.preventDefault)&&J.preventDefault();const ne=I(J,X);X.setAttribute("data-drop",ne?"before":"after")})),this.off.push(Z(X,"dragleave",()=>X.removeAttribute("data-drop"))),this.off.push(Z(X,"drop",J=>{k(J.preventDefault)&&J.preventDefault();const ne=this.dragging;this.dragging=null,this.clearDropMark(),!(!ne||ne===B.id)&&this.moveColumn(ne,B.id,I(J,X))})),j.appendChild(X)}}onRowKey(j,T){const B=j&&j.key,q=S.zoneKeys[String(B).toLowerCase()];if(q&&!j.ctrlKey&&!j.metaKey&&!j.altKey){k(j.preventDefault)&&j.preventDefault(),this.toggleZone(q,T);return}if(B!=="ArrowUp"&&B!=="ArrowDown")return;const X=B==="ArrowUp",Q=this.columns().map(te=>te.id),J=Q.indexOf(T.id);if(J<0)return;if(k(j.preventDefault)&&j.preventDefault(),!j.shiftKey){const te=this.list&&this.list.querySelectorAll?[...this.list.querySelectorAll("[data-col]")]:[],ce=te.findIndex(ae=>ae.getAttribute("data-col")===T.id),ue=te[ce+(X?-1:1)];ue&&k(ue.focus)&&ue.focus();return}const ne=T.layout&&(T.layout.movable===!1||T.layout.lockPosition),re=String(T.title||T.id||"");if(ne){this.announce(this.t("a11y.panel.cannotMove",{column:re}),{repeat:!0});return}const oe=Q[J+(X?-1:1)];if(!oe){this.announce(this.t(X?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:re}),{repeat:!0});return}this.moveColumn(T.id,oe,X),this.announce(this.t("a11y.panel.moved",{column:re,at:X?J:J+2,of:Q.length}),{repeat:!0});const ie=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${$(T.id)}"]`):null;ie&&k(ie.focus)&&ie.focus()}toggleZone(j,T){const B=this.titleOf(T.id),q=this.t(S.zoneLabel[j]||"panel.zone.group");if(this.zoneColumns(j).includes(T.id)){this.dropFromZone(j,T.id),this.announce(this.t("a11y.panel.removedFrom",{column:B,list:q}),{repeat:!0}),this.restoreFocus(T.id);return}if(this.addToZone(j,T.id)){this.announce(this.t("a11y.panel.addedTo",{column:B,list:q}),{repeat:!0}),this.restoreFocus(T.id);return}this.announce(this.t("a11y.panel.cannotAddTo",{column:B,list:q}),{repeat:!0})}restoreFocus(j){const T=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${$(j)}"]`):null;T&&k(T.focus)&&T.focus()}announce(j,T){const B=this.host||{};k(B.announce)&&B.announce(j,T)}clearDropMark(){if(!(!this.list||!this.list.querySelectorAll))for(const j of this.list.querySelectorAll("[data-drop]"))j.removeAttribute("data-drop")}moveColumn(j,T,B){const q=this.host||{};k(q.moveColumn)&&(q.moveColumn(j,T,B),this.refresh())}buildZone(j,T){const B=W(this.doc,"div",{class:`${R.panel}__zone`,attrs:{"data-zone":j,role:"group","aria-label":T}});B.appendChild(W(this.doc,"div",{class:`${R.panel}__zoneTitle`,text:T}));const q=this.zoneColumns(j);let X=S.zoneAbout[j]||"";j==="values"&&q.length&&!this.zoneColumns("group").length&&(X+=" Add a row group to see them."),X&&B.appendChild(W(this.doc,"div",{class:`${R.panel}__zoneAbout`,text:X}));const Q=W(this.doc,"div",{class:`${R.panel}__zoneBody`});q.length||Q.appendChild(W(this.doc,"span",{class:`${R.panel}__zoneHint`,text:this.t(S.zoneHint[j]||"panel.zoneHint.any")})),j==="values"&&Q.classList.add(`${R.panel}__zoneBody--rows`);for(const J of q){const ne=W(this.doc,"span",{class:[R.chip,j==="values"?`${R.chip}--row`:""]});if(ne.appendChild(W(this.doc,"span",{class:`${R.chip}__label`,text:this.titleOf(J)})),j==="values"&&k(this.host.setValueAggregation)){const oe=k(this.host.valueAggregation)?this.host.valueAggregation(J):"sum",ie=W(this.doc,"select",{class:`${R.chip}__fn`,attrs:{"aria-label":`Calculation for ${this.titleOf(J)}`}});for(const te of S.aggregations)ie.appendChild(W(this.doc,"option",{text:this.t(`total.${te.name}`),attrs:{value:te.name,selected:te.name===oe?"":null}}));ie.value=oe,this.off.push(Z(ie,"change",()=>{this.host.setValueAggregation(J,ie.value),this.refresh()})),ne.appendChild(ie)}const re=W(this.doc,"button",{class:R.chipRemove,text:"×",attrs:{type:"button","aria-label":`Remove ${this.titleOf(J)}`}});this.off.push(Z(re,"click",()=>this.dropFromZone(j,J))),ne.appendChild(re),Q.appendChild(ne)}return this.off.push(Z(B,"dragover",J=>{k(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=>{k(J.preventDefault)&&J.preventDefault(),B.removeAttribute("data-over"),this.dragging&&this.addToZone(j,this.dragging)})),B.appendChild(Q),B}static aggregations=Object.freeze(Object.keys(o).map(j=>({name:j})));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(j){const T=S.zoneApi[j],B=this.host;return T&&k(B[T.read])?B[T.read]()||[]:[]}titleOf(j){const T=this.columns().find(B=>B.id===j);return String(T&&(T.title||T.id)||j)}addToZone(j,T){const B=S.zoneApi[j],q=this.columns().find(Q=>Q.id===T);if(!B||!q||q[B.permission]===!1||!k(this.host[B.write]))return!1;const X=this.zoneColumns(j);return X.includes(T)?!1:(this.host[B.write]([...X,T]),this.refresh(),!0)}dropFromZone(j,T){const B=S.zoneApi[j];return!B||!k(this.host[B.write])?!1:(this.host[B.write](this.zoneColumns(j).filter(q=>q!==T)),this.refresh(),!0)}setVisible(j,T){const B=this.host;T&&k(B.showColumns)?B.showColumns([j]):!T&&k(B.hideColumns)&&B.hideColumns([j])}}class E extends v{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 j=this.root;if(!j)return;for(const ne of this.off)ne();this.off.length=0,H(j);const T=this.host,B=(k(T.columns)?T.columns():[]).filter(ne=>!(ne.filter&&ne.filter.enabled===!1));if(!k(T.filterFor))return;const q=B.filter(ne=>this.isFiltered(ne.id));j.appendChild(this.buildSearch()),j.appendChild(this.buildSummary(q.length,B.length));const X=this.query.trim().toLowerCase(),Q=X?B.filter(ne=>String(ne.title||ne.id).toLowerCase().includes(X)):B;if(!Q.length){j.appendChild(W(this.doc,"p",{class:`${R.panel}__empty`,text:X?this.t("panel.filterEmptyNoMatch",{query:this.query.trim()}):this.t("panel.filterEmptyNone")}));return}const J=W(this.doc,"div",{class:`${R.panel}__filters`});for(const ne of Q)J.appendChild(this.buildSection(ne));j.appendChild(J)}isFiltered(j){const T=this.host;return k(T.isFiltered)?T.isFiltered(j)===!0:!1}buildSearch(){const j=W(this.doc,"input",{class:`${R.panel}__search`,attrs:{type:"text",placeholder:this.t("panel.searchColumnsPlaceholder"),"aria-label":this.t("panel.searchColumnsToFilter")}});return j.value=this.query,this.off.push(Z(j,"input",()=>{this.query=j.value||"",this.refresh();const T=this.root&&this.root.querySelector?this.root.querySelector(`.${R.panel}__search`):null;T&&k(T.focus)&&T.focus()})),j}buildSummary(j,T){const B=W(this.doc,"div",{class:`${R.panel}__filterSummary`});if(B.appendChild(W(this.doc,"span",{class:`${R.panel}__filterCount`,text:j?this.t("panel.filterSummaryActive",{active:j,total:T}):this.t("panel.filterSummaryNone",{total:T}),attrs:{"data-active":j?"true":"false"}})),!j)return B;const q=W(this.doc,"button",{class:`${R.panel}__clearAll`,text:this.t("panel.clearAll"),attrs:{type:"button"}});return this.off.push(Z(q,"click",()=>{k(this.host.clearAllFilters)&&this.host.clearAllFilters(),this.refresh()})),B.appendChild(q),B}buildSection(j){const T=j.id,B=String(j.title||T),q=this.isFiltered(T),X=this.open.has(T),Q=W(this.doc,"section",{class:`${R.panel}__filter`,attrs:{"data-col":T,"data-filtered":q?"true":null}}),J=W(this.doc,"button",{class:`${R.panel}__filterTitle`,attrs:{type:"button","aria-expanded":X?"true":"false",title:this.t(q?"panel.filteredBy":"panel.filterBy",{column:B})},children:[d(this.doc,X?"chevronDown":"chevronRight",{className:`${R.panel}__twisty`}),W(this.doc,"span",{class:`${R.panel}__filterName`,text:B})]});q&&J.appendChild(W(this.doc,"span",{class:`${R.panel}__filterDot`,attrs:{"aria-label":this.t("panel.columnFiltered"),title:this.t("panel.columnFiltered")}}));const ne=W(this.doc,"div",{class:`${R.panel}__filterBody`,style:{display:X?"":"none"}}),re=()=>{if(ne.firstChild)return;const oe=this.host.filterFor(T);oe&&k(oe.element)&&ne.appendChild(oe.element())};if(this.off.push(Z(J,"click",()=>{const oe=this.open.has(T);oe?this.open.delete(T):this.open.add(T),J.setAttribute("aria-expanded",oe?"false":"true"),ne.style.display=oe?"none":"";const ie=J.firstElementChild;ie&&c(ie,oe?"chevronRight":"chevronDown"),oe||re()})),Q.appendChild(J),q){const oe=W(this.doc,"button",{class:`${R.panel}__filterClear`,attrs:{type:"button","aria-label":this.t("panel.clearFilterOn",{column:B}),title:this.t("panel.clearFilter")},children:[d(this.doc,"close",{className:R.icon})]});this.off.push(Z(oe,"click",ie=>{k(ie.stopPropagation)&&ie.stopPropagation(),k(this.host.clearFilter)&&this.host.clearFilter(T),this.refresh()})),Q.appendChild(oe)}return Q.appendChild(ne),X&&re(),Q}}class A extends v{refresh(){const j=this.root;if(!j)return;if(this.box){const X=k(this.host.quickFilter)?this.host.quickFilter():"";this.doc&&this.doc.activeElement!==this.box&&this.box.value!==X&&(this.box.value=X),this.paintCount();return}for(const X of this.off)X();this.off.length=0,H(j);const T=k(this.host.quickFilter)?this.host.quickFilter():"",B=W(this.doc,"input",{class:`${R.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.filterAllColumns"),"aria-label":this.t("panel.quickFilter")}});B.value=T||"",this.off.push(Z(B,"input",()=>{k(this.host.setQuickFilter)&&this.host.setQuickFilter(B.value),this.paintCount()})),j.appendChild(B),this.box=B;const q=W(this.doc,"button",{class:`${R.panel}__link`,text:this.t("panel.clear"),attrs:{type:"button"}});this.off.push(Z(q,"click",()=>{B.value="",k(this.host.setQuickFilter)&&this.host.setQuickFilter(""),this.paintCount(),k(B.focus)&&B.focus()})),j.appendChild(q),this.count=W(this.doc,"p",{class:`${R.panel}__count`}),j.appendChild(this.count),this.paintCount()}destroy(){this.box=null,this.count=null,super.destroy()}focus(){O(()=>{this.box&&k(this.box.focus)&&this.box.focus()})}paintCount(){if(!this.count)return;const j=k(this.host.rowCount)?this.host.rowCount():null,T=k(this.host.totalRowCount)?this.host.totalRowCount():null;if(j===null||T===null){this.count.textContent="";return}this.count.textContent=j===T?this.t("count.rows",{count:T}):this.t("panel.rowsOf",{shown:j,total:T})}}const M=Object.freeze({columns:S,filters:E,views:n,quick:A,formatting:s,statistics:u,regression:h,compare:b,insights:m}),C=Object.freeze({columns:"panel.columns",filters:"panel.filters",views:"panel.views",quick:"panel.quickFilter",formatting:"panel.formatting",statistics:"panel.statistics",regression:"panel.regression",compare:"panel.compare",insights:"panel.insights"}),P=Object.freeze({columns:"columns",filters:"filter",views:"views",quick:"search",formatting:"palette",statistics:"chart",regression:"chart",compare:"link",insights:"chart"});class x{panels=[];actions=[];root=null;openPanel=null;off=[];t(j,T){return(this.messages&&typeof this.messages.t=="function"?this.messages:z).t(j,T)}init(j){const T=j||{};this.doc=L(T),this.host=T.host||{},this.messages=T.messages||T.grid&&T.grid.messages||z,this.icons=T.icons===void 0?T.side==="left":!!T.icons,this.side=T.side==="left"?"left":"right",this.root=W(this.doc,"div",{class:[R.panel,`${R.panel}--${this.side}`,this.icons?`${R.panel}--icons`:null]}),this.tabs=W(this.doc,"div",{class:`${R.panel}__tabs`,attrs:{role:"tablist"}}),this.body=W(this.doc,"div",{class:`${R.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:`${R.panel}__actions`,attrs:{role:"group","aria-label":this.t("panel.gridActions")}}),this.tabs.appendChild(this.actionGroup);for(const X of Array.isArray(T.actions)?T.actions:[])this.registerAction(X);const B=T.registry||{},q=Array.isArray(T.panels)&&T.panels.length?T.panels:["columns","filters"];for(const X of q){const Q=typeof X=="string"?X:X.name,J=typeof X=="function"?X:B[Q]||M[Q];J&&this.registerPanel(String(Q),J,typeof X=="object"?X:{})}T.openPanel&&this.show(T.openPanel)}registerPanel(j,T,B){const q=new T;q.init({document:this.doc,host:this.host,props:B&&B.props||{}});const X=B&&B.title||j,Q=B&&B.icon||j,J=W(this.doc,"button",{class:`${R.panel}__tab`,text:this.icons?null:X,attrs:{type:"button",role:"tab","aria-selected":"false","data-panel":j,title:this.icons?X:null,"aria-label":this.icons?X:null}});return this.icons&&J.appendChild(d(this.doc,Q,{className:`${R.panel}__icon`})),this.off.push(Z(J,"click",()=>this.toggle(j))),this.tabs.appendChild(J),this.panels.push({name:j,title:X,panel:q}),q}registerAction(j){if(!j||!j.name)return null;if(j.separator)return this.actionGroup.appendChild(W(this.doc,"div",{class:`${R.panel}__divider`,attrs:{"aria-hidden":"true"}})),null;const T=W(this.doc,"button",{class:`${R.panel}__action`,text:this.icons?null:k(j.title)?String(j.title()):j.title,attrs:{type:"button","data-action":j.name,title:k(j.title)?null:j.title,"aria-label":k(j.title)?null:j.title}});if(this.icons){const X=(k(j.icon)?j.icon():j.icon)||(r(j.name)?j.name:"blank");T.appendChild(d(this.doc,X,{className:`${R.panel}__icon`})),T.setAttribute("data-icon",X)}const B=Z(T,"click",()=>{k(j.enabled)&&!j.enabled()||(k(j.run)&&j.run(),this.paintActions())});return this.off.push(B),this.actionGroup.appendChild(T),this.actions.push({...j,button:T,offClick:B}),this.paintActions(),T}removeAction(j){const T=this.actions.findIndex(q=>q.name===j);if(T<0)return!1;const B=this.actions[T];return k(B.offClick)&&B.offClick(),B.button&&B.button.parentNode&&B.button.parentNode.removeChild(B.button),this.actions.splice(T,1),!0}paintActions(){for(const j of this.actions){if(!j.button)continue;const T=k(j.enabled)?!!j.enabled():!0;if(j.button.disabled=!T,j.button.setAttribute("aria-disabled",T?"false":"true"),k(j.active)&&j.button.setAttribute("aria-pressed",j.active()?"true":"false"),k(j.title)){const B=String(j.title());j.button.setAttribute("title",B),j.button.setAttribute("aria-label",B),!this.icons&&j.button.textContent!==B&&(j.button.textContent=B)}if(this.icons&&k(j.icon)){const B=String(j.icon());j.button.getAttribute("data-icon")!==B&&(H(j.button),j.button.appendChild(d(this.doc,B,{className:`${R.panel}__icon`})),j.button.setAttribute("data-icon",B))}}}show(j){const T=this.panels.find(B=>B.name===j);return T?(H(this.body),k(T.panel.refresh)&&T.panel.refresh(),this.body.appendChild(T.panel.element()),this.openPanel=j,this.paintTabs(),k(T.panel.focus)&&T.panel.focus(),!0):!1}hide(){H(this.body),this.openPanel=null,this.paintTabs()}toggle(j){this.openPanel===j?this.hide():this.show(j)}paintTabs(){if(!(!this.tabs||!this.tabs.childNodes))for(let j=0;j<this.tabs.childNodes.length;j++){const T=this.tabs.childNodes[j];T&&T.setAttribute&&T.setAttribute("aria-selected",T.getAttribute("data-panel")===this.openPanel?"true":"false")}}element(){return this.root}refresh(){const j=this.panels.find(T=>T.name===this.openPanel);j&&k(j.panel.refresh)&&!this.#e(j.panel)&&j.panel.refresh(),this.paintActions()}#e(j){const T=this.doc&&this.doc.activeElement;if(!T||T===this.doc.body)return!1;const B=k(j.element)?j.element():null;return!!(B&&k(B.contains)&&B.contains(T))}destroy(){for(const j of this.off)j();this.off.length=0;for(const j of this.panels)k(j.panel.destroy)&&j.panel.destroy();this.panels=[],this.root=null}}const K=x;function I(D,j){if(!j.getBoundingClientRect||typeof D.clientY!="number")return!0;const T=j.getBoundingClientRect();return D.clientY<T.top+T.height/2}}),ke("packages/dom/src/ui/groupbyzone.js",function(e,V){"use strict";Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return O}});const R=V("packages/dom/src/ui/panelbase.js").ToolPanelBase,$=V("packages/dom/src/editors/common.js"),L=$.CLS,W=$.el,Z=$.on,H=$.clear,U=$.cssEscape,F=V("packages/core/src/internal/util.js").isFunction,k="text/x-lattice-col";class O extends R{dragging=null;#e=[];init(d){this.ctx=d,this.doc=d.document,this.host=d.host||{},this.props=d.props||{},this.root=W(this.doc,"div",{class:L.groupZone,attrs:{role:"group","aria-label":this.t("groupZone.label")}}),this.refresh()}columns(){const d=this.host;return F(d.columns)?d.columns()||[]:d.columns&&F(d.columns.all)?d.columns.all():[]}groups(){return F(this.host.groupBy)?this.host.groupBy()||[]:[]}setGroups(d){F(this.host.setGroupBy)&&this.host.setGroupBy(d)}titleOf(d){const c=this.columns().find(r=>r.id===d);return String(c&&(c.title||c.id)||d)}canGroup(d){const c=this.columns().find(r=>r.id===d);return!!c&&c.allowGroup!==!1&&!c.generated}announce(d,c){F(this.host.announce)&&this.host.announce(d,c)}refresh(){const d=this.root;if(!d)return;for(const t of this.off)t();this.off.length=0,H(d),d.appendChild(W(this.doc,"span",{class:L.groupZoneTitle,text:this.t("groupZone.title"),attrs:{"aria-hidden":"true"}}));const c=this.groups(),r=W(this.doc,"div",{class:L.groupZoneChips,attrs:{role:"listbox","aria-orientation":"horizontal","aria-label":this.t("groupZone.label")}});c.length||r.appendChild(W(this.doc,"span",{class:L.groupZoneHint,text:this.t("groupZone.hint")})),c.forEach((t,n)=>r.appendChild(this.#t(t,n,c.length))),d.appendChild(r),this.chips=r,d.appendChild(this.#i(c)),this.off.push(Z(d,"dragover",t=>{this.dragging==null&&!this.#s(t)||(F(t.preventDefault)&&t.preventDefault(),d.setAttribute("data-over","true"))})),this.off.push(Z(d,"dragleave",()=>d.removeAttribute("data-over"))),this.off.push(Z(d,"drop",t=>{F(t.preventDefault)&&t.preventDefault(),d.removeAttribute("data-over");const n=this.#s(t)||this.dragging;n!=null&&this.#o(n,this.groups().length)})),this.#a()}#t(d,c,r){const t=this.titleOf(d),n=W(this.doc,"div",{class:[L.chip,L.groupZoneChip],attrs:{role:"option","aria-selected":"true",tabindex:"0",draggable:"true","data-col":d,"aria-label":this.t("groupZone.chip",{column:t,at:c+1,of:r})}});n.appendChild(W(this.doc,"span",{class:L.groupZoneChipText,text:t}));const i=W(this.doc,"button",{class:L.chipRemove,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("groupZone.remove",{column:t})}});return this.off.push(Z(i,"click",()=>this.#r(d))),n.appendChild(i),this.off.push(Z(n,"dragstart",s=>{this.dragging=d,s.dataTransfer&&F(s.dataTransfer.setData)&&s.dataTransfer.setData(k,d)})),this.off.push(Z(n,"dragend",()=>{this.dragging=null})),this.off.push(Z(n,"dragover",s=>{const l=this.#s(s)||this.dragging;l==null||l===d||F(s.preventDefault)&&s.preventDefault()})),this.off.push(Z(n,"drop",s=>{const l=this.#s(s)||this.dragging;l!=null&&(F(s.preventDefault)&&s.preventDefault(),F(s.stopPropagation)&&s.stopPropagation(),this.#o(l,c))})),this.off.push(Z(n,"keydown",s=>this.#n(s,d,c))),n}#n(d,c,r){const t=d&&d.key,n=this.groups();if(t==="Delete"||t==="Backspace"){F(d.preventDefault)&&d.preventDefault(),this.#r(c,n,r);return}const i=t==="ArrowLeft"||t==="ArrowUp",s=t==="ArrowRight"||t==="ArrowDown",l=t==="Home",u=t==="End";if(!i&&!s&&!l&&!u)return;if(F(d.preventDefault)&&d.preventDefault(),d.shiftKey&&(i||s)){const g=r+(i?-1:1);if(g<0||g>=n.length){this.announce(this.t(i?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:this.titleOf(c)}),{repeat:!0});return}const b=n.slice();b.splice(r,1),b.splice(g,0,c),this.setGroups(b),this.announce(this.t("a11y.panel.moved",{column:this.titleOf(c),at:g+1,of:b.length}),{repeat:!0}),this.#l(c);return}let f=r+(i?-1:s?1:0);l&&(f=0),u&&(f=n.length-1);const h=n[f];h&&this.#l(h)}#r(d,c=this.groups(),r=c.indexOf(d)){const t=this.titleOf(d);this.setGroups(c.filter(i=>i!==d)),this.announce(this.t("a11y.panel.removedFrom",{column:t,list:this.t("panel.zone.group")}),{repeat:!0});const n=this.groups();n.length?this.#l(n[Math.min(r,n.length-1)]):this.#u()}#o(d,c){if(!this.canGroup(d)){this.announce(this.t("a11y.panel.cannotAddTo",{column:this.titleOf(d),list:this.t("panel.zone.group")}),{repeat:!0});return}const r=this.groups(),t=r.indexOf(d),n=r.slice();t>=0&&(n.splice(t,1),t<c&&(c-=1)),n.splice(Math.max(0,Math.min(c,n.length)),0,d),this.setGroups(n);const i=n.indexOf(d);this.announce(this.t(t>=0?"a11y.panel.moved":"a11y.panel.addedTo",t>=0?{column:this.titleOf(d),at:i+1,of:n.length}:{column:this.titleOf(d),list:this.t("panel.zone.group")}),{repeat:!0}),this.#l(d)}#i(d){const c=new Set(d),r=W(this.doc,"label",{class:L.groupZoneAdd}),t=W(this.doc,"select",{class:L.groupZoneAddSelect,attrs:{"aria-label":this.t("groupZone.add")}});t.appendChild(W(this.doc,"option",{text:this.t("groupZone.add"),attrs:{value:""}}));for(const n of this.columns())c.has(n.id)||!this.canGroup(n.id)||t.appendChild(W(this.doc,"option",{text:this.titleOf(n.id),attrs:{value:n.id}}));return this.off.push(Z(t,"change",()=>{const n=t.value;n&&this.#o(n,this.groups().length)})),this.adderSelect=t,r.appendChild(t),r}#a(){for(const c of this.#e)c();this.#e.length=0;const d=this.props&&this.props.header;if(!(!d||!F(d.querySelectorAll)))for(const c of d.querySelectorAll("[data-col]")){const r=F(c.getAttribute)?c.getAttribute("data-col"):null;!r||!this.canGroup(r)||(F(c.setAttribute)&&c.setAttribute("draggable","true"),this.#e.push(Z(c,"dragstart",t=>{this.dragging=r,t.dataTransfer&&F(t.dataTransfer.setData)&&t.dataTransfer.setData(k,r)})),this.#e.push(Z(c,"dragend",()=>{this.dragging=null})))}}#s(d){const c=d&&d.dataTransfer;if(c&&F(c.getData)){const r=c.getData(k);if(r)return r}return null}#l(d){const c=this.chips&&F(this.chips.querySelector)?this.chips.querySelector(`[data-col="${U(d)}"]`):null;c&&F(c.focus)&&c.focus()}#u(){this.adderSelect&&F(this.adderSelect.focus)&&this.adderSelect.focus()}destroy(){for(const d of this.#e)d();this.#e.length=0,super.destroy()}}}),ke("packages/dom/src/ui/tooltip.js",function(e,V){"use strict";Object.defineProperty(e,"TextTooltip",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const _=V("packages/dom/src/editors/common.js"),R=_.CLS,$=_.documentFor,L=_.el,W=_.on,Z=_.clear,U=V("packages/core/src/internal/util.js").isFunction;class z{root=null;init(y){this.doc=y.document,this.root=L(this.doc,"div",{class:`${R.tooltip}__text`}),this.update(y.content)}update(y){if(!this.root)return;const d=y==null?"":String(y);this.root.textContent!==d&&(this.root.textContent=d)}element(){return this.root}destroy(){this.root=null}}class F{root=null;component=null;timer=null;target=null;off=[];constructor(y){const d=y||{};this.doc=$(d),this.host=d.host||this.doc.body,this.delay=d.delay??400,this.hideDelay=d.hideDelay??0,this.components={text:z,...d.components||{}}}show(y){this.cancelTimer();const d=y.delay??this.delay;if(!d){this.showNow(y);return}this.timer=setTimeout(()=>{this.timer=null,this.showNow(y)},d)}showNow(y){const d=y.component||"text",c=typeof d=="function"?d:this.components[d]||z;return this.root||(this.root=L(this.doc,"div",{class:R.tooltip,attrs:{role:"tooltip"},style:{position:"absolute"}}),this.host.appendChild(this.root)),!this.component||this.componentCtor!==c?(this.component&&U(this.component.destroy)&&this.component.destroy(),Z(this.root),this.component=new c,this.componentCtor=c,this.component.init({document:this.doc,content:y.content,...y.props||{}}),this.root.appendChild(this.component.element())):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(),d=this.doc.defaultView||{};this.root.style.left=`${y.left+(d.scrollX||0)}px`,this.root.style.top=`${y.bottom+(d.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,d,c){const r=()=>this.show({target:y,content:d(),...c||{}}),t=()=>this.hide(),n=[W(y,"mouseenter",r),W(y,"mouseleave",t),W(y,"focus",r),W(y,"blur",t)],i=()=>{for(const s of n)s()};return this.off.push(i),i}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 k=F}),ke("packages/dom/src/ui/pagination.js",function(e,V){"use strict";Object.defineProperty(e,"pageModel",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const _=V("packages/dom/src/editors/common.js"),R=_.CLS,$=_.documentFor,L=_.el,W=_.on,Z=_.clear,U=V("packages/core/src/i18n/index.js").defaultMessages,F=V("packages/core/src/internal/util.js").isFunction;function k(d){const c=Math.max(1,Number(d.pageSize)||100),r=d.total==null?null:Math.max(0,Number(d.total)),t=r==null?null:Math.max(1,Math.ceil(r/c)),n=Math.max(0,t==null?Number(d.page)||0:Math.min(Number(d.page)||0,t-1)),i=r===0?0:n*c+1,s=r==null?(n+1)*c:Math.min(r,(n+1)*c);return{page:n,pageSize:c,pageCount:t,from:i,to:s,first:n===0,last:t==null?d.hasMore!==!0:n>=t-1,total:r}}class O{root=null;page=0;pageSize=100;total=null;counting=!1;hasMore=!1;off=[];init(c){const r=c||{};this.doc=$(r),this.host=r.host||{},this.pageSize=Number(r.pageSize)||100;const t=Array.isArray(r.pageSizes)&&r.pageSizes.length?[...r.pageSizes]:[25,50,100,250,1e3];this.pageSize>0&&!t.includes(this.pageSize)&&t.push(this.pageSize),this.pageSizes=t.sort((n,i)=>n-i),this.page=Number(r.page)||0,this.total=r.total===void 0?null:r.total,this.locale=r.locale,this.messages=r.messages||null,this.onChange=r.onChange||null,this.root=L(this.doc,"nav",{class:R.pagination,attrs:{"aria-label":this.t("pagination.label")}}),this.paint()}t(c,r){const t=this.messages;return(t&&typeof t.t=="function"?t:U).t(c,r)}element(){return this.root}model(){return k({total:this.total,pageSize:this.pageSize,page:this.page,hasMore:this.hasMore})}setState(c){c.total!==void 0&&(this.total=c.total),c.counting!==void 0&&(this.counting=c.counting===!0),c.hasMore!==void 0&&(this.hasMore=c.hasMore===!0),c.page!==void 0&&(this.page=Number(c.page)||0),this.paint()}goTo(c){const r=this.page;this.page=c;const t=this.model();return this.page=t.page,this.paint(),this.page!==r&&F(this.onChange)&&this.onChange({page:this.page,pageSize:this.pageSize}),this.page}next(){return this.model().last?this.page:this.goTo(this.page+1)}previous(){return this.page===0?0:this.goTo(this.page-1)}last(){const c=this.model();return c.pageCount==null?this.page:this.goTo(c.pageCount-1)}setPageSize(c){const r=this.page*this.pageSize;this.pageSize=Math.max(1,Number(c)||1),this.page=Math.floor(r/this.pageSize),this.paint(),F(this.onChange)&&this.onChange({page:this.page,pageSize:this.pageSize})}paint(){const c=this.root;if(!c)return;for(const f of this.off)f();this.off.length=0,Z(c);const r=this.model(),t=L(this.doc,"select",{class:`${R.pagination}__size`,attrs:{"aria-label":this.t("pagination.pageSize")}});for(const f of this.pageSizes)t.appendChild(L(this.doc,"option",{text:String(f),attrs:{value:f}}));t.value=String(this.pageSize),this.off.push(W(t,"change",()=>this.setPageSize(Number(t.value)))),c.appendChild(t);const n=r.total==null?this.t(this.counting?"pagination.counting":"pagination.range",{from:r.from,to:r.to}):this.t("pagination.summary",{from:r.from,to:r.to,total:r.total});c.appendChild(L(this.doc,"span",{class:`${R.pagination}__summary`,text:n}));const i=(f,h,g,b)=>{const p=L(this.doc,"button",{class:`${R.pagination}__button`,text:f,attrs:{type:"button","aria-label":b,disabled:g?"":null}});return g||this.off.push(W(p,"click",h)),p};c.appendChild(i("«",()=>this.goTo(0),r.first,this.t("pagination.first"))),c.appendChild(i("‹",()=>this.previous(),r.first,this.t("pagination.previous")));const s=L(this.doc,"span",{class:`${R.pagination}__page`});s.appendChild(L(this.doc,"span",{text:`${this.t("pagination.page")} `}));const l=L(this.doc,"input",{class:`${R.pagination}__field`,attrs:{type:"text",inputmode:"numeric","aria-label":r.pageCount==null?this.t("pagination.jump"):this.t("pagination.jumpBounded",{pages:r.pageCount}),size:String(Math.max(2,String(r.pageCount??r.page+1).length))}});l.value=String(r.page+1);const u=()=>{const f=parseInt(String(l.value).trim(),10);if(!Number.isFinite(f)){l.value=String(this.model().page+1);return}this.goTo(f-1)};this.off.push(W(l,"keydown",f=>{f.key==="Enter"?(u(),f.preventDefault?.()):f.key==="Escape"?(l.value=String(this.model().page+1),l.blur?.()):f.stopPropagation?.()})),this.off.push(W(l,"blur",()=>u())),this.off.push(W(l,"focus",()=>l.select?.())),s.appendChild(l),r.pageCount!=null&&s.appendChild(L(this.doc,"span",{text:` ${this.t("pagination.ofPages",{pages:r.pageCount})}`})),c.appendChild(s),c.appendChild(i("›",()=>this.next(),r.last,this.t("pagination.next"))),c.appendChild(i("»",()=>this.last(),r.last||r.pageCount==null,this.t("pagination.last")))}destroy(){for(const c of this.off)c();this.off.length=0,this.root=null}}const y=O}),ke("packages/dom/src/ui/overlay.js",function(e,V){"use strict";Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const _=V("packages/dom/src/editors/common.js"),R=_.CLS,$=_.documentFor,L=_.el,W=_.clear,H=V("packages/core/src/internal/util.js").isFunction,z=V("packages/core/src/i18n/index.js").defaultMessages;function F(r,t){const n=r&&r.grid&&r.grid.messages;return(n&&H(n.t)?n:z).t(t)}class k{root=null;init(t){this.doc=t.document,this.root=L(this.doc,"div",{class:`${R.overlay}__loading`,attrs:{role:"status","aria-live":"polite"},children:[L(this.doc,"span",{class:`${R.overlay}__spinner`,attrs:{"aria-hidden":"true"}}),L(this.doc,"span",{class:`${R.overlay}__message`,text:t.message||F(t,"overlay.loading")})]})}element(){return this.root}destroy(){this.root=null}}class O{root=null;init(t){this.doc=t.document,this.root=L(this.doc,"div",{class:`${R.overlay}__empty`,attrs:{role:"status"},children:[L(this.doc,"span",{class:`${R.overlay}__message`,text:t.message||F(t,"overlay.noRows")})]})}element(){return this.root}destroy(){this.root=null}}const y=Object.freeze({loading:k,empty:O});class d{root=null;slot=null;component=null;current=null;init(t){const n=t||{};this.doc=$(n),this.components={...y,...n.components||{}},this.root=L(this.doc,"div",{class:R.overlay,attrs:{"data-open":"false"}}),this.slot=L(this.doc,"div",{class:`${R.overlay}__slot`}),this.root.appendChild(this.slot),n.host&&n.host.appendChild(this.root)}element(){return this.root}show(t,n){const i=typeof t=="function"?t:this.components[t];return i?(this.hide(),this.component=new i,this.component.init({document:this.doc,message:n&&n.message,...n&&n.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&&H(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,n){this.components[t]=n}destroy(){this.hide(),this.root&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.root=null,this.slot=null}}const c=d}),ke("packages/dom/src/ui/index.js",function(e,V){"use strict";const _=V("packages/dom/src/ui/statusbar.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return _.StatusBar}}),Object.defineProperty(e,"StatusPanel",{enumerable:!0,get:function(){return _.StatusPanel}}),Object.defineProperty(e,"RowCountPanel",{enumerable:!0,get:function(){return _.RowCountPanel}}),Object.defineProperty(e,"SelectedCountPanel",{enumerable:!0,get:function(){return _.SelectedCountPanel}}),Object.defineProperty(e,"AggregationPanel",{enumerable:!0,get:function(){return _.AggregationPanel}}),Object.defineProperty(e,"ProgressPanel",{enumerable:!0,get:function(){return _.ProgressPanel}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return _.UpdatesPanel}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return _.CommentsPanel}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return _.statusPanels}}),Object.defineProperty(e,"aggregate",{enumerable:!0,get:function(){return _.aggregate}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return _.formatCount}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return _.formatNumber}});const R=V("packages/dom/src/ui/contextmenu.js");Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return R.ContextMenu}}),Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return R.resolveMenuItems}});const $=V("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 L=V("packages/dom/src/ui/groupbyzone.js");Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return L.GroupByZone}});const W=V("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=V("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 H=V("packages/dom/src/ui/overlay.js");Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return H.OverlayLayer}}),Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return H.LoadingOverlay}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return H.EmptyOverlay}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return H.overlays}})}),ke("packages/dom/src/ui/celltooltip.js",function(e,V){"use strict";Object.defineProperty(e,"CellTooltips",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const _=V("packages/dom/src/editors/common.js"),R=_.documentFor,$=_.el,L=_.on,W=_.clear,Z=V("packages/core/src/internal/util.js"),H=Z.isFunction,U=Z.warnOnce,F=V("packages/dom/src/cell/sanitise.js").sanitiseHtml,O=V("packages/dom/src/detailhost.js").insideDetail,d=V("packages/dom/src/renderer/renderer.js").displayIndexOf,c=V("packages/dom/src/renderer/viewport.js"),r=c.CLASS,t=c.NAMESPACE,n={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"},i=400,s=140,l=6;let u=0;class f{#e;#t;#n;#r;#o=null;#i=null;#a;#s=!1;#l=null;#u=null;#c=null;#d=null;#h=null;#f=[];#m=!1;constructor(b){const p=b||{};this.#e=p.grid,this.#t=p.host,this.#n=p.viewport,this.#r=R(p),u+=1,this.#a=`lat-cell-tooltip-${u}`}mount(){const b=this.#n&&this.#n.root;if(!b||!H(b.addEventListener))return;const p=this.#e.on("cell:mouseover",v=>this.#b(v));H(p)&&this.#f.push(p);const m=this.#e.on("cell:mouseout",()=>this.#j());H(m)&&this.#f.push(m),this.#f.push(L(b,"focusin",v=>this.#y(v))),this.#f.push(L(b,"focusout",()=>this.#j())),this.#f.push(L(this.#r,"keydown",v=>this.#w(v),!0));const w=this.#r.defaultView;w&&H(w.addEventListener)&&this.#f.push(L(w,"scroll",()=>this.hide(),!0))}#p(){const b=H(this.#e.get)?this.#e.get("tooltip"):null,p=b&&typeof b=="object"?b:{},m=Number.isFinite(p.delay)&&p.delay>=0?Number(p.delay):i,w=p.maxWidth;return{delay:m,hideDelay:s,maxWidth:typeof w=="number"&&Number.isFinite(w)?`${w}px`:typeof w=="string"&&w?w:null}}#g(b){const p=b&&b.cell?b.cell.tooltip:null;return!p||typeof p!="object"||Array.isArray(p)||!H(p.render)&&!H(p.mount)?null:p}#v(b){if(!b||!H(b.closest))return null;const p=b.closest(`.${r.row}`);if(!p)return null;const m=d(p);if(m<0)return null;const w=this.#t.rowAt(m);if(!w)return null;const v=b.getAttribute("data-col");if(!v)return null;const a=this.#t.columns.get(v);return a?{row:w,key:w.key,index:m,colId:v,column:a,value:this.#t.cellValue?this.#t.cellValue(w,a):void 0,text:this.#t.cellText?this.#t.cellText(w,a):"",cell:b,grid:this.#e}:null}#b(b){const p=b&&b.target;if(!this.#g(b&&b.column)){this.#j();return}this.#S(p)}#y(b){const p=b&&b.target;if(!p||!H(p.closest)||O(p,this.#n.root))return;const m=p.closest(`.${r.cell}`);if(!m||m!==p){this.#j();return}const w=m.getAttribute("data-col"),v=w?this.#t.columns.get(w):null;if(!this.#g(v)){this.#j();return}this.#S(m)}#w(b){!b||b.key!=="Escape"||b.defaultPrevented||this.#s&&(H(b.preventDefault)&&b.preventDefault(),this.hide())}#S(b){if(this.#m||!b||(this.#N(),this.#s&&this.#l===b))return;this.#R();const{delay:p}=this.#p();if(!p){this.#E(b);return}this.#d=setTimeout(()=>{this.#d=null,this.#E(b)},p)}#j(){if(this.#R(),!this.#s||this.#h!==null)return;const{hideDelay:b}=this.#p();this.#h=setTimeout(()=>{this.#h=null,this.hide()},b)}#A(){if(this.#o)return this.#o;const b=this.#r,p=$(b,"div",{class:[t,n.tooltip],attrs:{id:this.#a,role:"tooltip","data-open":"false"}});this.#i=$(b,"div",{class:n.body}),p.appendChild(this.#i),this.#f.push(L(p,"mouseenter",()=>this.#N())),this.#f.push(L(p,"mouseleave",()=>this.#j()));const m=b.body;return m&&H(m.appendChild)&&m.appendChild(p),this.#o=p,p}#O(b,p){const m=this.#i;if(W(m),b==null||b==="")return!1;if(typeof b=="string")return m.textContent=b,!0;if(typeof b=="object"){if(typeof b.nodeType=="number")return m.appendChild(b),!0;const w=b;if(typeof w.html=="string")return m.innerHTML=F(w.html),!0;if(w.title!==void 0||w.rows!==void 0||w.note!==void 0)return this.#C(w),!0}return U(`tooltip-content:${p}`,`Column '${p}' 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}#C(b){const p=this.#r,m=this.#i,w=a=>a==null?"":String(a);b.title!==void 0&&b.title!==null&&b.title!==""&&m.appendChild($(p,"div",{class:n.title,text:w(b.title)}));const v=Array.isArray(b.rows)?b.rows:[];if(v.length){const a=$(p,"div",{class:n.rows});for(const o of v){if(!o||typeof o!="object")continue;const S=$(p,"div",{class:n.row});S.appendChild($(p,"span",{class:n.label,text:w(o.label)})),S.appendChild($(p,"span",{class:n.value,text:w(o.value)})),a.appendChild(S)}m.appendChild(a)}b.note!==void 0&&b.note!==null&&b.note!==""&&m.appendChild($(p,"div",{class:n.note,text:w(b.note)}))}#E(b){if(this.#m)return;const p=this.#v(b);if(!p){this.hide();return}const m=this.#g(p.column);if(!m){this.hide();return}this.hide();const w=this.#A();let v;if(H(m.render))try{v=m.render(p)}catch(S){U(`tooltip-render:${p.colId}`,`Column '${p.colId}' cell.tooltip render threw; no tooltip was shown.`,S);return}const a=this.#O(v,p.colId);if(H(m.mount))try{m.mount(this.#i,p),this.#u=m}catch(S){U(`tooltip-mount:${p.colId}`,`Column '${p.colId}' cell.tooltip mount threw; the tooltip was closed.`,S),this.hide();return}else if(!a)return;const{maxWidth:o}=this.#p();o&&(w.style.maxWidth=o),this.#l=b,this.#s=!0,w.setAttribute("data-open","true"),this.#T(b),this.#x(b)}#T(b){if(!H(b.setAttribute))return;const p=H(b.getAttribute)?b.getAttribute("aria-describedby"):null;this.#c={cell:b,previous:p},b.setAttribute("aria-describedby",p?`${p} ${this.#a}`:this.#a)}#x(b){const p=this.#o;if(!p||!H(b.getBoundingClientRect))return;const m=this.#r.defaultView;if(!m)return;const w=b.getBoundingClientRect(),v=H(p.getBoundingClientRect)?p.getBoundingClientRect():{width:0,height:0},a=m.innerWidth||0,o=m.innerHeight||0,S=v.width||0,E=v.height||0;let A=w.bottom+l;const M=w.top-l-E;A+E>o-l&&M>=l&&(A=M),o&&(A=Math.max(l,Math.min(A,Math.max(l,o-E-l))));let C=w.left;a&&(C=Math.min(C,Math.max(l,a-S-l))),C=Math.max(l,C),p.style.left=`${Math.round(C)}px`,p.style.top=`${Math.round(A)}px`}hide(){if(this.#R(),this.#N(),!this.#s)return;if(this.#s=!1,this.#u&&H(this.#u.unmount))try{this.#u.unmount(this.#i)}catch(p){U("tooltip-unmount","A cell.tooltip unmount threw while the tooltip was closing.",p)}this.#u=null,this.#i&&W(this.#i),this.#o&&this.#o.setAttribute("data-open","false");const b=this.#c;b&&H(b.cell.setAttribute)&&(b.previous?b.cell.setAttribute("aria-describedby",b.previous):H(b.cell.removeAttribute)&&b.cell.removeAttribute("aria-describedby")),this.#c=null,this.#l=null}#R(){this.#d!==null&&(clearTimeout(this.#d),this.#d=null)}#N(){this.#h!==null&&(clearTimeout(this.#h),this.#h=null)}destroy(){this.hide(),this.#m=!0;for(const b of this.#f)b();this.#f.length=0,this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}const h=f}),ke("packages/dom/src/platform.js",function(e,V){"use strict";Object.defineProperty(e,"macLike",{enumerable:!0,get:function(){return _}});function _(){const R=globalThis.navigator,$=String(R&&(R.userAgentData?.platform||R.platform)||"");return/mac|iphone|ipad/i.test($)}}),ke("packages/dom/src/columnmenu.js",function(e,V){"use strict";Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"aggregateMenuItem",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"headerMenuItems",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"gridAcceptsEdits",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"columnAcceptsEdits",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"rangeChartConfig",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"chartableRange",{enumerable:!0,get:function(){return g}}),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 m}}),Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return w}});const _=V("packages/core/src/internal/util.js"),R=_.isFunction,$=_.warnOnce,W=V("packages/dom/src/platform.js").macLike,H=V("packages/core/src/i18n/index.js").defaultMessages,z=V("packages/dom/src/ui/contextmenu.js").ContextMenu,F=V("packages/core/src/compute/total.js"),k=F.aggregatesFor,O=F.totalLabel,y=10,d=150;function c(v,a){const o=(ne,re)=>(v&&v.messages?v.messages:H).t(ne,re),S=v.columns.get(a);if(!S)return[];const E=v.sort.get(),A=E.find(ne=>ne.col===a),M=S.layout&&S.layout.pin,C=v.state.get().group||[],P=C.includes(a);if(S.generated&&Array.isArray(S.groupedIds))return i(v,S,C);const x=!S.sort||S.sort.enabled!==!1,K=!S.filter||S.filter.enabled!==!1,I=[];x&&I.push({name:o("menu.sortAscending"),icon:"↑",disabled:A&&A.dir==="asc",action:()=>v.sort.set([{col:a,dir:"asc"}])},{name:o("menu.sortDescending"),icon:"↓",disabled:A&&A.dir==="desc",action:()=>v.sort.set([{col:a,dir:"desc"}])},{name:o("menu.clearSort"),disabled:!A,action:()=>v.sort.set(E.filter(ne=>ne.col!==a))},{separator:!0}),K&&I.push({name:o("menu.filterEllipsis"),action:()=>v.emit("column:filter:open",{colId:a})},{separator:!0}),I.push({name:o("menu.columnStatistics"),action:()=>v.emit("column:profile:open",{colId:a})},{separator:!0}),I.push({name:o("menu.pinColumn"),children:[{name:o("menu.pinStart"),disabled:M==="start",action:()=>v.columns.pin(a,"start")},{name:o("menu.pinEnd"),disabled:M==="end",action:()=>v.columns.pin(a,"end")},{name:o("menu.unpin"),disabled:!M,action:()=>v.columns.pin(a,null)}]});const D=!(S.layout&&(S.layout.movable===!1||S.layout.lockPosition)),j=!(S.layout&&S.layout.resizable===!1),T=ne=>{const re=v.columns.get(ne);return Number(re&&re.layout&&re.layout.width)||d},B=v.columns.visible().filter(ne=>!ne.generated).map(ne=>ne.id),q=B.indexOf(a);if(I.push({name:o("menu.sizeToFit"),action:()=>v.columns.autoSize(a)},{name:o("menu.sizeAllToFit"),action:()=>v.columns.fit()},{name:o("menu.width"),disabled:!j,children:[{name:o("menu.narrower"),disabled:!j,action:()=>v.columns.resize(a,Math.max(1,T(a)-y))},{name:o("menu.wider"),disabled:!j,action:()=>v.columns.resize(a,T(a)+y)},{name:o("menu.autosize"),disabled:!j,action:()=>v.columns.autoSize(a)}]},{separator:!0},{name:o("menu.moveColumn"),disabled:!D,children:[{name:o("menu.moveLeft"),disabled:!D||q<=0,action:()=>v.columns.move(a,Math.max(0,q-1))},{name:o("menu.moveRight"),disabled:!D||q<0||q>=B.length-1,action:()=>v.columns.move(a,Math.min(B.length-1,q+1))},{name:o("menu.moveToStart"),disabled:!D||q<=0,action:()=>v.columns.move(a,0)},{name:o("menu.moveToEnd"),disabled:!D||q<0||q>=B.length-1,action:()=>v.columns.move(a,B.length-1)}]},{separator:!0}),S.allowGroup!==!1&&I.push({name:o(P?"menu.ungroup":"menu.groupBy"),action:()=>v.columns.group(P?C.filter(ne=>ne!==a):[...C,a])}),C.length&&I.push({name:o("menu.expandAll"),action:()=>v.rows.expandAll()},{name:o("menu.collapseAll"),action:()=>v.rows.collapseAll()}),R(v.columns.groupColumns)){const ne=S.groupPath||[],re=ne.length?ne[ne.length-1]:null,oe=[{name:o("columngroup.group"),disabled:B.length<2||q<0,action:()=>{const ie=B[q+1]??B[q-1];if(!ie)return;const te=(v.columns.get(ie)||{}).groupPath||[],ce=te.length?te[te.length-1]:null;ce?v.columns.groupColumns([a],{groupId:ce}):v.columns.groupColumns([a,ie],{title:o("columngroup.newGroup")})}}];re&&oe.push({name:o("columngroup.dissolve"),action:()=>v.columns.dissolveGroup(re)}),I.push({separator:!0},...oe)}const X=v.state&&R(v.state.get)?v.state.get().pivot:null,Q=X&&X.columns||[],J=Q.includes(a);if(S.allowPivot!==!1&&I.push({name:o(J?"menu.unpivot":"menu.pivotBy"),action:()=>v.columns.pivot(J?Q.filter(ne=>ne!==a):[...Q,a])}),S.allowTotal!==!1)if(R(v.get)&&v.get("aggregateChooser")===!0)I.push(r(v,S,o));else{const re=!!S.total;I.push({name:o(re?"menu.stopTotalling":"menu.totalColumn"),action:()=>v.columns.setTotal(a,re?null:"sum")})}return I.push({name:o("menu.hideColumn"),disabled:S.layout&&S.layout.lockVisible===!0,action:()=>v.columns.hide(a)}),I}function r(v,a,o){const S=a.id,E=typeof a.total=="string"?a.total:null,A=[{name:o("menu.aggregateNone"),checked:!a.total,action:()=>v.columns.setTotal(S,null)},{separator:!0},...k(a).map(M=>({name:O(M),checked:E===M,action:()=>v.columns.setTotal(S,M)})),{separator:!0},t(v,a,o,"group",o("menu.aggregateGroup")),t(v,a,o,"grand",o("menu.aggregateGrand"))];return{name:o("menu.aggregate"),children:A}}function t(v,a,o,S,E){const A=a.id,M=S==="grand"?a.grandTotal:a.groupTotal,C=typeof M=="string"?M:null,P=[{name:o("menu.aggregateSame"),checked:M==null,action:()=>v.columns.setTotal(A,null,{scope:S})},{separator:!0},...k(a).map(x=>({name:O(x),checked:C===x,action:()=>v.columns.setTotal(A,x,{scope:S})}))];return{name:E,children:P}}function n(v,a){const o=(C,P)=>(v&&v.messages?v.messages:H).t(C,P),S=v.columns.get(a);if(!S)return[];const E=v.redaction,A=!!(E&&E.has(a)),M=[];return E&&(M.push({name:o(A?"menu.stopRedacting":"menu.redactColumn"),action:()=>E.toggle(a)}),(E.list().length>1||E.active&&!A)&&M.push({name:o("menu.stopRedactingAll"),action:()=>E.clear()}),M.push({separator:!0})),M.push({name:o("menu.hideColumn"),disabled:S.layout&&S.layout.lockVisible===!0,action:()=>v.columns.hide(a)}),M}function i(v,a,o){const S=(P,x)=>(v&&v.messages?v.messages:H).t(P,x),E=o[0],A=v.sort.get(),M=E?A.find(P=>P.col===E):null,C=[];E&&C.push({name:S("menu.sortGroupsAscending"),icon:"↑",disabled:M&&M.dir==="asc",action:()=>v.sort.set([{col:E,dir:"asc"}])},{name:S("menu.sortGroupsDescending"),icon:"↓",disabled:M&&M.dir==="desc",action:()=>v.sort.set([{col:E,dir:"desc"}])},{separator:!0},{name:S("menu.filterGroups"),action:()=>v.emit("column:filter:open",{colId:a.id})},{separator:!0}),C.push({name:S("menu.expandAll"),action:()=>v.rows.expandAll()},{name:S("menu.collapseAll"),action:()=>v.rows.collapseAll()},{separator:!0});for(const P of o){const x=v.columns.get(P);C.push({name:`Remove "${x&&x.title||P}" from grouping`,action:()=>v.columns.group(o.filter(K=>K!==P))})}return C.push({name:S("menu.clearGrouping"),disabled:!o.length,action:()=>v.columns.group([])}),C}function s(){const v=globalThis.navigator&&globalThis.navigator.clipboard;return!!(v&&typeof v.readText=="function")}function l(v){return R(v.get)&&v.get("edit")===!1?!1:(v.columns&&R(v.columns.visible)?v.columns.visible():[]).some(o=>{const S=o&&o.edit;return S?S.enabled===void 0||R(S.enabled)?!0:S.enabled!==!1:!1})}function u(v,a){if(R(v.get)&&v.get("edit")===!1)return!1;const o=a&&a.edit;return o?o.enabled===void 0||R(o.enabled)?!0:o.enabled!==!1:!1}const f=new Set(["number","currency","percent","integer"]);function h(v){const a=R(v.get)?v.get("rangeChart"):void 0;return a?R(a)?{enabled:!0,handler:a}:a&&typeof a=="object"&&R(a.onChart)?{enabled:!0,handler:a.onChart}:{enabled:!0,handler:null}:{enabled:!1,handler:null}}function g(v){const a=v.selection&&R(v.selection.ranges)?v.selection.ranges():[];if(!Array.isArray(a)||!a.length)return null;const o=a[a.length-1],S=R(v.columns.visible)?v.columns.visible():[],E=new Set(S.filter(A=>A&&f.has(A.type)).map(A=>A.id));return(o.columns||[]).some(A=>E.has(A))?o:null}function b(v,a){const o=(Q,J)=>(v&&v.messages?v.messages:H).t(Q,J),{colId:S,row:E}=a,A=v.selection.keys().length,M=v.selection.cells().length,C=(v.state&&R(v.state.get)?v.state.get().group:null)||[],P=v.ranges||null,x=W()?"Cmd":"Ctrl",K=()=>M||A||0,I=Q=>v.columns&&R(v.columns.get)?v.columns.get(Q):null,D=R(v.selection.cells)?v.selection.cells():[],j=[...new Set(D.map(Q=>Q&&Q.colId).filter(Boolean))];!j.length&&S&&j.push(S);const T=j.length?j.some(Q=>u(v,I(Q))):l(v),B=S?u(v,I(S)):!1,q=h(v),X=q.enabled?g(v):null;return[{name:M>1?`Copy ${M} cells`:o("menu.copy"),shortcut:`${x}+C`,disabled:!K(),action:()=>P&&M?P.copy():v.export.clipboard({rows:A?"selected":"range"})},{name:o("menu.copyWithHeaders"),disabled:!K(),action:()=>v.export.clipboard({headers:!0,rows:A?"selected":"range"})},...S==null?[]:[{name:o("menu.paste"),shortcut:`${x}+V`,disabled:!P||!T||!s(),action:()=>P&&P.paste()},{separator:!0},{name:o("menu.clearCells",{count:M||1}),shortcut:"Delete",disabled:!P||!T||!M,action:()=>P&&P.clear()},{name:o("menu.fillDown"),shortcut:`${x}+D`,disabled:!P||!T||M<2,action:()=>P&&P.fillDown()}],...X&&q.handler?[{name:"Chart selection",action:()=>q.handler(v,X)}]:[],{separator:!0},{name:"Export visible rows to CSV",action:()=>v.export.csv({rows:"visible",download:!0})},{name:`Export ${A} selected row${A===1?"":"s"} to CSV`,disabled:!A,action:()=>v.export.csv({rows:"selected",download:!0})},{name:"Export visible rows to Excel",action:()=>v.export.excel({rows:"visible",download:!0})},{name:`Export ${A} selected row${A===1?"":"s"} to Excel`,disabled:!A,action:()=>v.export.excel({rows:"selected",download:!0})},{name:"Copy visible rows",action:()=>v.export.clipboard({rows:"visible",headers:!0})},{name:"Print",action:()=>v.export.print()},...v.importer&&R(v.importer.openFile)?[{name:o("menu.importCsv"),action:()=>v.importer.openFile()}]:[],{separator:!0},...C.length?[{name:o("menu.expandAll"),action:()=>v.rows.expandAll()},{name:o("menu.collapseAll"),action:()=>v.rows.collapseAll()}]:[],{name:"Clear selection",disabled:!A,action:()=>v.selection.clear()},...R(v.get)&&v.get("rowDelete")===!0?[{name:o("menu.deleteRow",{count:A||1}),disabled:!A&&!E,action:()=>v.edit.deleteRows(A?void 0:E?E.key:void 0)}]:[],...S==null?[]:[{name:"Edit cell",disabled:!E||!S||!B,action:()=>E&&S&&v.edit.start(E.key,S)}]]}function p(v,a,o,S){if(v==null)return{items:a,spoke:!1,suppress:!1};if(v===!1)return{items:a,spoke:!0,suppress:!0};if(v===!0)return{items:a,spoke:!0,suppress:!1};if(Array.isArray(v))return{items:[...a,...v],spoke:!0,suppress:!1};if(R(v)){const E=v(o,a);return{items:Array.isArray(E)?E:a,spoke:!0,suppress:!1}}return $(`menu-layer:${S}`,`${S} must be a boolean, an array of items or a (params, defaults) => items function; got ${typeof v}. Ignoring it.`),{items:a,spoke:!1,suppress:!1}}function m(v,a,o){let S=Array.isArray(v)?v:[],E=!1;for(const A of a){if(!A)continue;const M=p(A.layer,S,o,A.where);S=M.items,M.spoke&&(E=M.suppress)}return E?null:S}class w{#e=!0;#t=!0;#n;#r;#o=[];#i=null;#a=null;constructor(a){this.#n=a.grid,this.#e=a.cellMenu!==!1,this.#t=a.headerMenu!==!1,this.#i=R(a.items)?a.items:null,this.#a=R(a.headerItems)?a.headerItems:null,this.#r=new z({document:a.document,host:a.host,ctx:{grid:a.grid}})}mount(){this.#t&&this.#o.push(this.#n.on("column:menu:open",a=>{const o=String(a.colId),S=this.#c(o,c(this.#n,o));S.length&&this.#r.show({items:S,ctx:this.#u(o),anchor:a.element,placement:"below",returnFocus:a.element})})),this.#t&&this.#o.push(this.#n.on("header:contextmenu",a=>{const o=String(a.colId),S=this.#c(o,n(this.#n,o));S.length&&this.#r.show({items:S,ctx:this.#u(o),x:a.x,y:a.y,returnFocus:a.element})})),this.#o.push(this.#n.on("cell:contextmenu",a=>{const o=a.event;this.#e&&o&&R(o.preventDefault)&&o.preventDefault();const S=this.#s(a),E=b(this.#n,S),A=m(E,[{layer:this.#e===!1?!1:this.#i,where:"contextMenu"},{layer:this.#l(S.column),where:`column '${S.colId}' contextMenu`}],S);!A||!A.length||(!this.#e&&o&&R(o.preventDefault)&&o.preventDefault(),this.#r.show({items:A,ctx:S,x:o?o.clientX:void 0,y:o?o.clientY:void 0}))}))}#s(a){const o=this.#n.columns,S=a.column||(a.colId!=null&&o&&R(o.get)?o.get(a.colId):void 0),E=a.row,A=this.#n.rows,M=a.key!==void 0?a.key:E?E.key:void 0;return{key:M,colId:a.colId,value:a.value!==void 0||M===void 0||a.colId==null?a.value:A&&R(A.value)?A.value(M,a.colId):void 0,row:E,data:E?E.data:void 0,column:S,index:a.index!==void 0?a.index:a.rowIndex,grid:this.#n}}#l(a){if(!(!a||a.contextMenu===void 0||a.contextMenu===null))return a.contextMenu}#u(a){return{colId:a,column:this.#n.columns.get(a),grid:this.#n}}#c(a,o){return this.#a?m(o,[{layer:this.#a,where:"columnMenu"}],this.#u(a))||[]:o}destroy(){for(const a of this.#o)a();this.#o=[],this.#r.destroy()}}}),ke("packages/dom/src/shortcutshelp.js",function(e,V){"use strict";Object.defineProperty(e,"HELP_CLASS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"ShortcutsHelp",{enumerable:!0,get:function(){return O}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/dom/src/renderer/keyboard.js"),Z=W.groupedShortcuts,H=W.SHORTCUT_IDS,z=V("packages/dom/src/platform.js").macLike,F="lat-shortcuts",k='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class O{#e;#t;#n=null;#r=null;#o=[];constructor(d){this.#e=d.grid,this.#t=d.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#i(d,c){const r=this.#e;return(r&&r.messages?r.messages:L).t(d,c)}#a(d){const c=H[d.combo];if(!c)return d.meaning;const r=`shortcut.${c}`,t=this.#i(r);return t===r?d.meaning:t}mount(){const d=this.#t.viewport?.root;if(!d||!R(d.addEventListener))return;const c=r=>{if(this.open||r.key!=="?")return;const t=r.target,n=t&&t.tagName;n==="INPUT"||n==="TEXTAREA"||t&&t.isContentEditable||(r.preventDefault(),r.stopPropagation(),this.show())};d.addEventListener("keydown",c,!0),this.#o.push(()=>d.removeEventListener("keydown",c,!0))}show(){const d=this.#s();if(!d)return;const c=d.ownerDocument;this.#r=c&&c.activeElement,d.style.display="",R(d.focus)&&d.focus(),this.#e.emit?.("shortcuts:opened",{})}hide(){if(!this.#n)return;this.#n.style.display="none";const d=this.#r;this.#r=null,d&&R(d.focus)&&d.focus(),this.#e.emit?.("shortcuts:closed",{})}#s(){if(this.#n)return this.#n;const d=this.#t.viewport?.overlays,c=d?.ownerDocument;if(!d||!c?.createElement)return null;const r=c.createElement("div");r.className=F,r.setAttribute("role","dialog"),r.setAttribute("aria-modal","true"),r.setAttribute("tabindex","-1");const t=`${F}-title`;r.setAttribute("aria-labelledby",t);const n=c.createElement("div");n.className=`${F}__head`;const i=c.createElement("h2");i.className=`${F}__title`,i.id=t,i.textContent=this.#i("shortcuts.title");const s=c.createElement("button");s.className=`${F}__close`,s.type="button",s.setAttribute("aria-label",this.#i("shortcuts.close")),s.textContent="×",n.appendChild(i),n.appendChild(s),r.appendChild(n);const l=c.createElement("div");l.className=`${F}__body`;for(const f of Z())f.items.length&&l.appendChild(this.#l(c,f));r.appendChild(l);const u=c.createElement("p");return u.className=`${F}__hint`,u.textContent=this.#i("shortcuts.hint"),r.appendChild(u),d.appendChild(r),this.#n=r,this.#u(r,s),r}#l(d,c){const r=d.createElement("section");r.className=`${F}__group`;const t=d.createElement("h3");t.className=`${F}__group-title`,t.textContent=this.#i(c.messageKey),r.appendChild(t);const n=d.createElement("dl");n.className=`${F}__list`;const i=z();for(const s of c.items){const l=d.createElement("dt");l.className=`${F}__keys`,s.alternatives.forEach((f,h)=>{if(h>0){const g=d.createElement("span");g.className=`${F}__or`,g.textContent=this.#i("shortcuts.or"),l.appendChild(g)}f.forEach((g,b)=>{b>0&&l.appendChild(d.createTextNode("+"));const p=d.createElement("kbd");p.textContent=i&&g==="Ctrl"?this.#i("shortcuts.key.cmd"):g,l.appendChild(p)})});const u=d.createElement("dd");u.className=`${F}__meaning`,u.textContent=this.#a(s),n.appendChild(l),n.appendChild(u)}return r.appendChild(n),r}#u(d,c){const r=n=>{if(n.stopPropagation(),n.key==="Escape"){n.preventDefault(),this.hide();return}if(n.key!=="Tab")return;const i=[...d.querySelectorAll(k)];if(!i.length){n.preventDefault();return}const s=i[0],l=i[i.length-1],u=d.ownerDocument.activeElement;n.shiftKey&&(u===s||u===d)?(n.preventDefault(),l.focus()):!n.shiftKey&&u===l&&(n.preventDefault(),s.focus())},t=n=>{n.preventDefault?.(),this.hide()};d.addEventListener("keydown",r),c.addEventListener("click",t),this.#o.push(()=>{d.removeEventListener("keydown",r),c.removeEventListener("click",t)})}destroy(){for(const d of this.#o)d();this.#o=[],this.#n&&this.#n.parentNode&&this.#n.parentNode.removeChild(this.#n),this.#n=null,this.#r=null}}}),ke("packages/dom/src/rowreorder.js",function(e,V){"use strict";Object.defineProperty(e,"HANDLE_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"MARKER_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"DRAGGING_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"resolveRowTransfer",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"resolveRowReorder",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"RowReorder",{enumerable:!0,get:function(){return d}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,Z=V("packages/dom/src/renderer/renderer.js").displayIndexOf,H="lat-rowdrag",U="lat-rowdrag-marker",z="lat-rowdrag-lifted",F=4,k=new Set;function O(c){if(!c)return null;const r=c===!0?{}:typeof c=="object"?c:null;return r?{send:r.send!==!1,receive:r.receive!==!1,mode:r.mode==="copy"?"copy":"move",group:typeof r.group=="string"?r.group:null}:null}function y(c){return c===!0?{column:null}:!c||typeof c!="object"?null:{column:typeof c.column=="string"?c.column:null}}class d{#e;#t;#n;#r=null;#o=null;#i=null;#a=null;#s=null;#l=[];constructor(r){this.#e=r.grid,this.#t=r.renderer,this.#n=r.document,this.#r=y(r.grid.get("rowReorder")),this.#o=O(r.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(r){if(!this.#o||!this.#o.receive)return!1;const t=r&&r.transfer;return!t||!t.send?!1:t.group===this.#o.group}get transfer(){return this.#o}#u(r,t){const n=this.#e;return(n&&n.messages?n.messages:L).t(r,t)}#c(r,t){const n=this.#t&&this.#t.announce;R(n)&&n.call(this.#t,r,t)}#d(){if(!this.#r)return null;if(this.#r.column)return this.#r.column;const r=this.#e.columns.visible().filter(t=>!t.generated);return r.length?r[0].id:null}paint(){if(!this.draggable)return;const r=this.#d(),t=this.#t.viewport?.root;if(!r||!t)return;const n=t.querySelectorAll(`.lat-cell[data-col="${r}"]`);for(const i of n){if(i.querySelector(`.${H}`))continue;const s=i.parentNode;if(s&&R(s.getAttribute)&&s.getAttribute("data-pinned"))continue;const l=this.#n.createElement("span");l.className=H,l.setAttribute("data-role","row-drag"),l.setAttribute("aria-hidden","true"),l.setAttribute("title",this.#u("a11y.reorder.grab")),l.textContent="⠿",i.insertBefore(l,i.firstChild||null)}}mount(){if(!this.active)return;k.add(this);const r=this.#t.viewport?.root;if(!r||!R(r.addEventListener))return;const t=u=>this.#h(u),n=u=>this.#f(u),i=()=>this.#m(),s=u=>this.#A(u);r.addEventListener("pointerdown",t),r.addEventListener("keydown",s);const l=this.#n.defaultView||this.#n;l.addEventListener?.("pointermove",n),l.addEventListener?.("pointerup",i),this.#l.push(()=>{r.removeEventListener("pointerdown",t),r.removeEventListener("keydown",s),l.removeEventListener?.("pointermove",n),l.removeEventListener?.("pointerup",i)})}#h(r){const t=r.target;if(!t||!R(t.closest)||!t.closest('[data-role="row-drag"]'))return;const n=t.closest(".lat-row"),i=n?Z(n):-1;if(i<0)return;const s=this.#e.rows.get(i);if(!s)return;const l=this.#C();if(l&&!(this.#o&&this.#o.send)){this.#c(this.#u(l),{repeat:!0});return}r.preventDefault?.(),this.#i={key:s.key,from:i,at:i,x:r.clientX,y:r.clientY,armed:!1,hit:null,over:null,frame:null,pending:null}}#f(r){const t=this.#i;if(!t)return;if(!t.armed){if(Math.abs(r.clientX-t.x)+Math.abs(r.clientY-t.y)<F)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.#s&&this.#x(r.clientX,r.clientY);const n=this.#j(r.clientX,r.clientY);if(t.target=n,n!==this){this.#M(),n&&n.accepts(this)?(n.showDropTarget(r.clientX,r.clientY),t.hit=n.hitAt(r.clientX,r.clientY)):t.hit=null,this.#v(t,n),this.#b(t,n,t.hit?t.hit.at:null,t.hit?t.hit.overKey:null);return}const i=this.#E(r.clientX,r.clientY);if(this.#v(t,n),i<0){this.#b(t,this,null,null);return}t.at=i,this.#N(i);const s=this.#e.rows.get(i);this.#b(t,this,i,s?s.key:null)}#m(){const r=this.#i;this.#i=null,this.#M(),this.#R();for(const i of k)i.hideDropTarget();if(!r||(this.#y(r),!r.armed))return;const t=r.target;if(this.#e.emit("rowDrag:ended",this.#g(r),"user"),t&&t!==this){this.#S(r,t);return}if(r.at===r.from)return;const n=this.#C();if(n){this.#c(this.#u(n),{repeat:!0});return}this.#O(r.key,r.at)}#p(r,t,n,i){const s=this.#e.rows.byKey(r.key);return{key:r.key,data:s?s.data:null,over:t?t.grid:null,at:n,overKey:i}}#g(r){const t=r.target||null;if(t&&t!==this){if(!t.accepts(this))return{...this.#p(r,t,null,null),dropped:!1};const n=r.hit||{at:t.grid.rows.count(),overKey:null};return{...this.#p(r,t,n.at,n.overKey),dropped:!0}}if(t===this){const n=this.#e.rows.get(r.at);return{...this.#p(r,this,r.at,n?n.key:null),dropped:r.at!==r.from&&this.#C()===null}}return{...this.#p(r,null,null,null),dropped:!1}}#v(r,t){if(r.over===t)return;const n=r.over;r.over=t,n&&(this.#y(r),this.#e.emit("rowDrag:left",this.#p(r,n,null,null),"user"))}#b(r,t,n,i){r.pending={over:t,at:n,overKey:i},r.frame===null&&(r.frame=this.#w(()=>{r.frame=null;const s=r.pending;r.pending=null,!(!s||this.#i!==r)&&this.#e.emit("rowDrag:moved",this.#p(r,s.over,s.at,s.overKey),"user")}))}#y(r){r.pending=null,r.frame!==null&&(r.frame(),r.frame=null)}#w(r){const t=this.#n.defaultView||globalThis;if(R(t.requestAnimationFrame)){const i=t.requestAnimationFrame(r);return()=>{R(t.cancelAnimationFrame)&&t.cancelAnimationFrame(i)}}const n=setTimeout(r,16);return()=>clearTimeout(n)}#S(r,t){if(!t.accepts(this)){this.#c(this.#u("a11y.transfer.refused"),{repeat:!0});return}const n=this.#e.rows.byKey(r.key);if(!n)return;const i=this.#o.mode,s=r.key,l=r.hit||{at:t.grid.rows.count(),overKey:null};let u=null;const f=t.receive(n.data,l.at,{overKey:l.overKey,source:this.#e,revalidate:()=>!!this.#e.rows.byKey(s),onCancel:g=>{u=g}}),h=g=>{if(g!==!0){const b=g===!1?"a11y.transfer.refused":u==="stale"?"a11y.transfer.stale":"a11y.transfer.declined";this.#c(this.#u(b),{repeat:!0});return}i==="move"?(this.#e.rows.apply({remove:[s]}),this.#e.emit("row:sent",{key:s,data:n.data,mode:i})):this.#e.emit("row:copied",{key:s,data:n.data,mode:i}),this.#c(this.#u(i==="copy"?"a11y.transfer.copied":"a11y.transfer.moved"),{repeat:!0})};f&&R(f.then)?f.then(h):h(f)}receive(r,t,n={}){const i=this.#e,s=r&&typeof r=="object"?{...r}:r,l=n.overKey??null,u=n.source||null,f=R(n.onCancel)?n.onCancel:null,h=()=>{const w=i.rows.totalCount(),v=i.rows.apply({add:[s],at:Math.max(0,t||0)}),a=i.rows.totalCount()>w;return a&&i.emit("row:received",{data:s,at:t,overKey:l,rejected:v?.rejected||[]}),a},g=()=>{if(l!==null){const w=i.rows.get(t);if(!w||w.key!==l)return!1}return!R(n.revalidate)||n.revalidate()},b=R(i.rendererHost)?i.rendererHost():null;if(!b||!R(b.gateBefore))return h();const p=f?i.on("rowReceive:cancelled",w=>f(w.reason)):null,m=b.gateBefore("beforeRowReceive","rowReceive:cancelled",{data:s,at:t,overKey:l,source:u,origin:"user"},h,g);return p&&(m&&R(m.then)?m.then(p,p):p()),m}hitAt(r,t){const n=this.#E(r,t);if(n<0)return{at:this.#e.rows.count(),overKey:null};const i=this.#e.rows.get(n);return{at:n,overKey:i?i.key:null}}showDropTarget(r,t){const n=this.root;n&&R(n.setAttribute)&&n.setAttribute("data-drop-target","")}hideDropTarget(){const r=this.root;r&&R(r.removeAttribute)&&r.removeAttribute("data-drop-target")}#j(r,t){const n=this.#n.elementFromPoint?this.#n.elementFromPoint(r,t):null,i=n&&R(n.closest)?n.closest(".lattice"):null;if(!i)return null;for(const s of k)if(s.root===i)return s;return null}#A(r){if(!r.altKey||!r.shiftKey)return;const t=r.key==="ArrowUp"?-1:r.key==="ArrowDown"?1:0;if(!t)return;const n=this.#n.activeElement,i=n&&R(n.closest)?n.closest(".lat-row"):null,s=i?Z(i):-1;if(s<0)return;r.preventDefault?.(),r.stopPropagation?.();const l=this.#C();if(l){this.#c(this.#u(l),{repeat:!0});return}const u=this.#e.rows.get(s);u&&this.#O(u.key,s+t)}#O(r,t){const n=this.#e.rows.count(),i=Math.max(0,Math.min(n-1,t)),s=this.#e.rows.move(r,i);if(!s.moved){s.reason&&s.reason!=="unchanged"&&this.#c(this.#u(`a11y.reorder.${s.reason}`),{repeat:!0});return}this.#c(this.#u("a11y.reorder.moved",{position:s.to+1,total:n}),{repeat:!0})}#C(){const r=this.#e;if(r.sort.get().length)return"a11y.reorder.sorted";if((r.state.get().group||[]).length)return"a11y.reorder.grouped";const t=r.filters.get();return t&&Object.keys(t).length?"a11y.reorder.filtered":null}#E(r,t){const n=this.#n.elementFromPoint?this.#n.elementFromPoint(r,t):null,i=n&&R(n.closest)?n.closest(".lat-row"):null;return!i||R(i.getAttribute)&&i.getAttribute("data-pinned")?-1:Z(i)}#T(r){const t=this.root,n=t&&R(t.querySelector)?t.querySelector(`.lat-row[data-index="${r.from}"]`):null;n&&R(n.classList?.add)&&n.classList.add(z);const i=this.#n.body;if(!i||!R(i.appendChild))return;const s=this.#d(),l=s&&R(this.#e.rows?.text)&&this.#e.rows.text(r.key,s)||this.#u("a11y.reorder.grab"),u=t&&this.#n.defaultView?.getComputedStyle?this.#n.defaultView.getComputedStyle(t):null,f=(g,b)=>u&&u.getPropertyValue(g).trim()||b,h=this.#n.createElement("div");h.textContent=String(l),h.setAttribute("aria-hidden","true"),h.setAttribute("data-role","row-drag-ghost"),h.style.cssText=["position:fixed","z-index:2147483647","pointer-events:none","top:0","left:0","white-space:nowrap",`padding:${f("--lattice-space","4px")} calc(${f("--lattice-space","4px")} * 2)`,`border-radius:${f("--lattice-radius-sm",f("--lattice-radius","4px"))}`,`border:${f("--lattice-border-width","1px")} solid ${f("--lattice-border-strong","#0003")}`,`background:${f("--lattice-background","#fff")}`,`color:${f("--lattice-foreground","#000")}`,`box-shadow:${f("--lattice-shadow-overlay","0 4px 12px rgba(0,0,0,.25)")}`,`font:${f("--lattice-font-size","13px")} ${f("--lattice-font-family","system-ui, sans-serif")}`].join(";"),i.appendChild(h),this.#s=h}#x(r,t){this.#s&&(this.#s.style.transform=`translate(${Math.round(r)+14}px, ${Math.round(t)+16}px)`)}#R(){this.#s&&(this.#s.parentNode&&this.#s.parentNode.removeChild(this.#s),this.#s=null);const r=this.root,t=r&&R(r.querySelectorAll)?r.querySelectorAll(`.${z}`):[];for(const n of t)n.classList.remove(z)}#N(r){const t=this.#t.viewport?.overlays;if(!t)return;this.#a||(this.#a=this.#n.createElement("div"),this.#a.className=U,t.appendChild(this.#a));const n=this.#t.viewport.root,i=n.querySelector(`.lat-row[data-index="${r}"]`)||n.querySelectorAll(".lat-row")[0];if(!i||!R(i.getBoundingClientRect))return;const s=i.getBoundingClientRect(),l=n.getBoundingClientRect(),u=this.#i&&r>this.#i.from;this.#a.style.display="",this.#a.style.top=`${Math.round((u?s.bottom:s.top)-l.top)}px`}#M(){this.#a&&(this.#a.style.display="none")}destroy(){k.delete(this);for(const r of this.#l)r();this.#l=[],this.#i&&this.#y(this.#i),this.#i=null,this.#R(),this.#a&&this.#a.parentNode&&this.#a.parentNode.removeChild(this.#a),this.#a=null}}}),ke("packages/dom/src/alignedgrids.js",function(e,V){"use strict";Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return Z}});const R=V("packages/core/src/internal/util.js").isFunction,$=["column:resized","column:moved","column:visible","column:pinned"];function L(H){return(H||[]).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 z=[];for(const k of $)z.push(U.on(k,()=>this.#r(U)));z.push(U.on("scroll",k=>this.#i(U,k))),z.push(U.on("destroy",()=>this.remove(U))),this.#t.set(U,z);const[F]=this.#e;F!==U&&this.#o(U,L(F.columns.state()))}remove(U){const z=this.#t.get(U);if(z)for(const F of z)F();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 z=L(U.columns.state());this.#n=!0;try{for(const F of this.#e)F!==U&&this.#o(F,z)}finally{this.#n=!1}}#o(U,z){if(!U.columns||!R(U.columns.apply))return;const F=new Map((U.columns.state()||[]).map(O=>[O.id,O])),k=[];for(const O of z){const y=F.get(O.id);y&&(k.push({...y,...O}),F.delete(O.id))}for(const O of F.values())k.push(O);U.columns.apply(k)}#i(U,z){if(this.#n)return;const F=z&&typeof z.left=="number"?z.left:null;if(F!==null){this.#n=!0;try{for(const k of this.#e)k!==U&&k.scroll?.to?.({left:F})}finally{this.#n=!1}}}}function Z(H){const U=new W;for(const z of H||[])U.add(z);return U}}),ke("packages/dom/src/columntagbar.js",function(e,V){"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 H}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,W="lat-tagbar";function Z(z){if(!z)return null;const F=z===!0?{}:typeof z=="object"?z:null;return F?{multiple:F.multiple===!0,label:typeof F.label=="string"?F.label:null}:null}class H{#e;#t;#n;#r=null;#o=null;#i=null;#a="\0";#s=[];constructor(F){this.#e=F.grid,this.#t=F.renderer,this.#n=F.document,this.#r=Z(F.grid.get("columnTagFilter"))}get active(){return this.#r!==null}#l(F,k){const O=this.#e;return(O&&O.messages?O.messages:L).t(F,k)}mount(){if(!this.active)return;const F=this.#t.viewport,k=F?.root;if(!k||!R(k.insertBefore))return;const O=this.#n.createElement("div");O.className=W,O.setAttribute("role","toolbar"),O.setAttribute("aria-label",this.#l("tags.label"));const y=this.#n.createElement("label");y.className=`${W}__label`,y.textContent=this.#r.label||this.#l("tags.label");const d=this.#n.createElement("select");d.className=`${W}__select`,this.#r.multiple&&d.setAttribute("multiple","");const c=`${W}-select-${Math.abs(U(String(k.className)))}`;d.id=c,y.setAttribute("for",c),O.appendChild(y),O.appendChild(d),k.insertBefore(O,F.header||k.firstChild),this.#o=O,this.#i=d;const r=()=>{const n=this.#r.multiple?[...d.selectedOptions||[]].map(i=>i.value).filter(Boolean):d.value?[d.value]:[];this.#e.columns.showTagged(n),this.#u(n)};d.addEventListener("change",r),this.#s.push(()=>d.removeEventListener("change",r));const t=this.#e.on("model:changed",()=>this.refresh());this.#s.push(t),this.refresh()}#u(F){const k=this.#t&&this.#t.announce;if(!R(k))return;const O=F.length?F.join(", "):this.#l("tags.all");k.call(this.#t,this.#l("tags.showing",{tag:O}))}refresh(){if(!this.#i||!this.#o)return;const F=this.#e.columns.tags();if(this.#o.style.display=F.length?"":"none",!F.length)return;const k=F.join("\0");if(k===this.#a)return;this.#a=k;const O=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.#l("tags.all"),this.#i.appendChild(y)}for(const y of F){const d=this.#n.createElement("option");d.value=y,d.textContent=y,O.includes(y)&&(d.selected=!0),this.#i.appendChild(d)}this.#r.multiple||(this.#i.value=O.length?O[0]:"")}destroy(){for(const F of this.#s)F();this.#s=[],this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}function U(z){let F=0;for(let k=0;k<z.length;k++)F=F*31+z.charCodeAt(k)|0;return F}}),ke("packages/dom/src/anomalychip.js",function(e,V){"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 z}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,W="lat-anomaly-chip";function Z(F){if(!F)return null;const k=F===!0?{}:typeof F=="object"?F:null;return k?{column:typeof k.column=="string"?k.column:null,label:typeof k.label=="string"?k.label:null}:null}function H(F){return F?typeof F=="string"?{kind:F}:typeof F=="object"?F:null:null}function U(F,k){return F?Array.isArray(F.conditions)?F.conditions.some(O=>U(O,k)):F.col===k&&F.op==="eq"&&F.value===!0:!1}class z{#e;#t;#n;#r=null;#o=null;#i=null;#a=[];#s=!1;#l=!1;#u=null;#c=0;#d=null;constructor(k){this.#e=k.grid,this.#t=k.renderer,this.#n=k.document,this.#r=Z(k.grid.get("anomalySummary"))}get active(){return this.#r!==null}#h(k,O){const y=this.#e;return(y&&y.messages?y.messages:L).t(k,O)}#f(){const k=this.#r&&this.#r.column;let O=null;for(const y of this.#e.columns.all()){const d=H(y.shadow);if(!d||d.kind!=="anomalyFlag")continue;const c=d.of||y.field||y.id;if(k){if(y.id===k||c===k)return this.#d=y.id,y}else O||(O=y,this.#d=y.id)}return k?null:O}#m(){if(!this.#d||!R(this.#e.rows&&this.#e.rows.forEach))return 0;let k=0;try{this.#e.rows.forEach(O=>{!O||O.group||O.key==null||this.#e.rows.value(O.key,this.#d)===!0&&k++})}catch{return 0}return k}mount(){if(!this.active)return;const k=this.#t.viewport,O=k&&k.root;if(!O||!R(O.insertBefore))return;const y=this.#n.createElement("div");y.className=W,y.setAttribute("role","status");const d=this.#n.createElement("button");d.className=`${W}__button`,d.setAttribute("type","button"),d.setAttribute("aria-pressed","false"),y.appendChild(d),O.insertBefore(y,k.header||O.firstChild),this.#o=y,this.#i=d;const c=()=>this.toggle();d.addEventListener("click",c),this.#a.push(()=>d.removeEventListener("click",c));for(const r of["filter:changed","rows:changed","model:changed"])this.#a.push(this.#e.on(r,()=>{this.#l||this.refresh()}));this.refresh()}toggle(){this.#s?this.#g():this.#p()}#p(){if(!this.#d)return;this.#u=this.#e.filters.get();const k={col:this.#d,op:"eq",value:!0},O=this.#u?{op:"and",conditions:[this.#u,k]}:k;this.#s=!0,this.#l=!0;try{this.#e.filters.set(O)}finally{this.#l=!1}this.refresh()}#g(){this.#s=!1,this.#l=!0;try{this.#e.filters.set(this.#u||null)}finally{this.#l=!1}this.#u=null,this.refresh()}refresh(){if(!this.#o||!this.#i)return;if(!this.#f()){this.#o.style.display="none";return}if(this.#s&&!U(this.#e.filters.get(),this.#d)&&(this.#s=!1,this.#u=null),this.#s){this.#v(this.#c,!0);return}const O=this.#m();if(this.#c=O,!O){this.#o.style.display="none";return}this.#v(O,!1)}#v(k,O){if(!this.#o||!this.#i)return;this.#o.style.display="",this.#o.setAttribute("data-active",O?"true":"false"),this.#i.setAttribute("aria-pressed",O?"true":"false");const y=this.#r&&this.#r.label,d=O?this.#h("anomaly.chipActive",{count:k}):y||this.#h("anomaly.chip",{count:k});this.#i.textContent=d}destroy(){for(const k of this.#a)k();this.#a=[],this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}}),ke("packages/dom/src/rowform.js",function(e,V){"use strict";Object.defineProperty(e,"FORM_CLASS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"resolveRowForm",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"RowForm",{enumerable:!0,get:function(){return r}});const _=V("packages/core/src/internal/util.js"),R=_.isFunction,$=_.warnOnce,W=V("packages/core/src/i18n/index.js").defaultMessages,H=V("packages/dom/src/editors/index.js").createEditor,z=V("packages/dom/src/renderer/renderer.js").displayIndexOf,F="lat-rowform",k='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';function O(t){if(!t)return null;const n=t===!0?{}:typeof t=="object"?t:null;if(!n)return null;const i=R(n.load)?n.load:null,s=Array.isArray(n.fields)&&n.fields.length?n.fields:null;return{timeout:c(n.timeout),container:n.container??null,mode:n.container?"inline":n.mode==="dialog"?"dialog":"drawer",load:i,fields:s,title:n.title??null,width:typeof n.width=="string"?n.width:null,trigger:n.trigger===!1?"none":"dblclick"}}function y(t,n){const i=R(t)?t():t;return i?typeof i=="string"?n&&R(n.querySelector)?n.querySelector(i):null:i&&R(i.appendChild)?i:null:null}const d=2e3;function c(t){return t===!1||t===0?0:typeof t!="number"||!Number.isFinite(t)||t<=0?d:t}class r{#e;#t;#n;#r;#o=null;#i=null;#a=null;#s=null;#l=null;#u=[];#c=null;#d=0;#h=null;#f=!1;#m=[];constructor(n){this.#e=n.grid,this.#t=n.renderer,this.#n=n.document,this.#r=n.registry||null,this.#o=O(n.grid.get("rowForm"))}get active(){return this.#o!==null}get open(){return!!this.#i&&this.#i.style.display!=="none"}#p(n,i){const s=this.#e;return(s&&s.messages?s.messages:W).t(n,i)}mount(){if(!this.active)return;const n=this.#t.viewport?.root;if(!n||!R(n.addEventListener)||this.#o.trigger==="none")return;const i=s=>{const l=s.target;if(!l||!R(l.closest)||l.closest(".lat-editor-host, .lat-editor--popup"))return;const u=l.closest(".lat-row"),f=u?z(u):-1;if(f<0)return;const h=this.#e.rows.get(f);!h||h.group||h.detail||(s.preventDefault?.(),s.stopPropagation?.(),this.openRow(h.key))};n.addEventListener("dblclick",i,!0),this.#m.push(()=>n.removeEventListener("dblclick",i,!0))}openRow(n){const i=this.#e.rows.byKey(n);if(!i)return!1;const s=this.#g();if(!s)return!1;this.#l=i,this.#c=this.#n.activeElement,s.style.display="",this.#E(s),this.#b(i);const l=this.#o.load;if(!l)this.#C(i.data);else{this.#j();const u=++this.#d;this.#y(u,n),Promise.resolve().then(()=>l({row:i,data:i.data,key:n,grid:this.#e})).then(f=>{u!==this.#d||!this.open||(this.#S(),this.#C(f||i.data))}).catch(f=>{u!==this.#d||!this.open||(this.#S(),this.#A(f,n))})}return R(s.focus)&&s.focus(),this.#e.emit("form:opened",{key:n,row:i}),!0}close(){if(!this.#i)return;this.#d+=1,this.#S(),this.#F(),this.#i.style.display="none";const n=this.#l?this.#l.key:null;this.#l=null;const i=this.#c;this.#c=null,i&&R(i.focus)&&i.focus(),this.#e.emit("form:closed",{key:n})}save(){if(!this.#l||!this.#u.length)return!1;const n=this.#l.key,i={},s={},l=[],u=[];for(const f of this.#u){const h=R(f.editor.commit)?f.editor.commit():{ok:!0,value:void 0};if(!h.ok)return this.#R(f,h.message),!1;i[f.field]=h.value;const g=f.initial;Object.is(g,h.value)||(s[f.field]=h.value,f.colId?l.push({key:n,colId:f.colId,value:h.value}):u.push(f.field))}return l.length&&this.#e.edit.setCells(l),this.#e.emit("form:saved",{key:n,values:i,changed:s,unmapped:u}),this.close(),!0}#g(){if(this.#i)return this.#i;const n=this.#t.viewport?.overlays,i=this.#n||n?.ownerDocument;if(!i?.createElement)return null;const s=y(this.#o.container,i),l=s||n;if(!l)return null;this.#o.container&&!s&&$("rowform:container","rowForm.container could not be resolved; the form opens over the grid instead."),this.#f=!!s;const u=i.createElement("div"),f=this.#f?"lattice ":"";u.className=`${f}${F} ${F}--${this.#f?"inline":this.#o.mode}`,u.setAttribute("role",this.#f?"region":"dialog"),this.#f||u.setAttribute("aria-modal","true"),u.setAttribute("tabindex","-1"),this.#o.width&&u.style.setProperty("--lattice-rowform-width",this.#o.width);const h=`${F}-title`;u.setAttribute("aria-labelledby",h);const g=i.createElement("div");g.className=`${F}__head`;const b=i.createElement("h2");b.className=`${F}__title`,b.id=h,g.appendChild(b);const p=i.createElement("div");p.className=`${F}__body`;const m=i.createElement("div");m.className=`${F}__foot`;const w=i.createElement("button");w.className=`${F}__cancel`,w.type="button",w.textContent=this.#p("form.cancel");const v=i.createElement("button");return v.className=`${F}__save`,v.type="button",v.textContent=this.#p("form.save"),m.appendChild(w),m.appendChild(v),u.appendChild(g),u.appendChild(p),u.appendChild(m),l.appendChild(u),this.#i=u,this.#a=p,this.#s=v,this.#v(u,v,w),u}#v(n,i,s){const l=h=>{if(h.stopPropagation(),h.key==="Escape"){h.preventDefault(),this.close();return}if(h.key!=="Tab"||this.#f)return;const g=[...n.querySelectorAll(k)];if(!g.length){h.preventDefault();return}const b=g[0],p=g[g.length-1],m=n.ownerDocument.activeElement;h.shiftKey&&(m===b||m===n)?(h.preventDefault(),p.focus()):!h.shiftKey&&m===p&&(h.preventDefault(),b.focus())},u=h=>{h.preventDefault?.(),this.save()},f=h=>{h.preventDefault?.(),this.close()};n.addEventListener("keydown",l),i.addEventListener("click",u),s.addEventListener("click",f),this.#m.push(()=>{n.removeEventListener("keydown",l),i.removeEventListener("click",u),s.removeEventListener("click",f)})}#b(n){const i=this.#i.querySelector(`.${F}__title`);if(!i)return;const s=this.#o.title;R(s)?i.textContent=String(s({row:n,data:n.data})??""):typeof s=="string"?i.textContent=s:i.textContent=this.#p("form.title")}#y(n,i){this.#S();const s=this.#o.timeout;if(!s)return;const l=this.#n.defaultView||globalThis;R(l.setTimeout)&&(this.#h=l.setTimeout(()=>{this.#h=null,!(n!==this.#d||!this.open)&&(this.#d+=1,this.#A(new Error(`Loading the record timed out after ${s}ms`),i,"form.loadTimeout"))},s))}#w(n){this.#s&&(this.#s.disabled=!n,n?this.#s.removeAttribute("aria-disabled"):this.#s.setAttribute("aria-disabled","true"))}#S(){if(this.#h===null)return;const n=this.#n.defaultView||globalThis;R(n.clearTimeout)&&n.clearTimeout(this.#h),this.#h=null}#j(){this.#F(),this.#w(!1),this.#a.replaceChildren&&this.#a.replaceChildren();const n=this.#n.createElement("p");n.className=`${F}__note`,n.setAttribute("role","status"),n.textContent=this.#p("form.loading"),this.#a.appendChild(n)}#A(n,i,s="form.loadFailed"){this.#F(),this.#w(!1),this.#a.replaceChildren&&this.#a.replaceChildren();const l=this.#n.createElement("p");l.className=`${F}__note ${F}__note--error`,l.setAttribute("role","alert"),l.textContent=this.#p(s);const u=this.#n.createElement("button");u.className=`${F}__retry`,u.type="button",u.textContent=this.#p("form.retry"),u.addEventListener("click",()=>this.openRow(i)),this.#a.appendChild(l),this.#a.appendChild(u),this.#e.emit("form:error",{key:i,error:n,timedOut:s==="form.loadTimeout"})}#O(){return this.#o.fields?this.#o.fields.map(n=>typeof n=="string"?{field:n}:n):this.#e.columns.all().filter(n=>!n.generated&&n.field).map(n=>({field:n.field,label:n.title,colId:n.id}))}#C(n){this.#F(),this.#w(!0),this.#a.replaceChildren&&this.#a.replaceChildren();const i=n&&typeof n=="object"?n:{};for(const s of this.#O()){const l=s.field;if(!l)continue;const u=s.colId?this.#e.columns.get(s.colId):this.#U(l),f=this.#_(s,u,l),h=Object.hasOwn(i,l)?i[l]:null,g=this.#n.createElement("div");g.className=`${F}__field`;const b=this.#n.createElement("label");b.className=`${F}__label`,b.textContent=String(s.label??(u&&u.title)??l);const p=this.#n.createElement("div");p.className=`${F}__control`,g.appendChild(b),g.appendChild(p),this.#a.appendChild(g);const m={field:l,colId:u?u.id:null,editor:null,initial:h,opener:null,wrap:g},w=H({grid:this.#e,column:f,colId:u?u.id:l,row:this.#l,data:i,value:h,text:h==null?"":String(h),locale:this.#e.get("locale"),props:s.props||u&&u.edit&&u.edit.props,lookup:s.lookup||u&&u.lookup,document:this.#n,cell:p,overlay:this.#T(),stop:()=>this.#N(m)},this.#r);if(w){m.editor=w;try{R(w.value)&&(m.initial=w.value())}catch{}if(this.#u.push(m),w.popup===!0)this.#x(p,m);else{const v=R(w.element)?w.element():null;v&&p.appendChild(v)}}}}#E(n){if(!this.#f)return;const i=this.#t.viewport?.root;if(!(!i||!R(i.getAttribute)))for(const s of["data-theme","data-density","dir"]){const l=i.getAttribute(s);l?n.setAttribute(s,l):R(n.removeAttribute)&&n.removeAttribute(s)}}#T(){return this.#f?this.#n.body||this.#t.viewport.overlays:this.#t.viewport.overlays}#x(n,i){const s=this.#n.createElement("button");s.className=`${F}__opener`,s.type="button",i.opener=s,this.#M(i);const l=()=>{R(i.editor.attached)&&i.editor.attached()};s.addEventListener("click",l),this.#m.push(()=>s.removeEventListener("click",l)),n.appendChild(s)}#R(n,i){const s=n.wrap;s&&R(s.scrollIntoView)&&s.scrollIntoView({block:"nearest"});const l=n.opener||(R(n.editor.focusTarget)?n.editor.focusTarget():null);l&&R(l.focus)&&l.focus();const u=this.#t&&this.#t.announce;R(u)&&i&&u.call(this.#t,String(i))}#N(n){if(!n.opener||!n.editor)return;const i=R(n.editor.popupHandle)?n.editor.popupHandle():null;i&&R(i.hide)&&i.hide(),this.#M(n),R(n.opener.focus)&&n.opener.focus()}#M(n){if(!n.opener)return;let i="";try{const l=n.colId?this.#e.columns.get(n.colId):null,u=l&&l.dataType&&l.dataType.format;R(u)&&(i=u({value:R(n.editor.value)?n.editor.value():null,column:l,row:this.#l,data:this.#l?this.#l.data:null,locale:this.#e.get("locale")})),(i===""||i==null)&&R(n.editor.toClipboard)&&(i=n.editor.toClipboard())}catch{i=""}const s=i===""||i==null;n.opener.textContent=s?this.#p("form.choose"):String(i),n.opener.classList.toggle(`${F}__opener--empty`,s)}#_(n,i,s){const l=n.editor||n.type||n.lookup||n.props;if(i&&!l)return i;const u={...i&&i.edit?i.edit:{}};return n.editor&&(u.editor=n.editor),n.props&&(u.props=n.props),{...i||{id:s,field:s},type:n.type||i&&i.type||"text",lookup:n.lookup||i&&i.lookup||void 0,edit:u}}#U(n){for(const i of this.#e.columns.all())if(!i.generated&&i.field===n)return i;return null}#F(){for(const n of this.#u)R(n.editor.destroy)&&n.editor.destroy();this.#u=[]}destroy(){this.#d+=1,this.#S(),this.#F();for(const n of this.#m)n();this.#m=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#a=null,this.#s=null,this.#l=null}}}),ke("packages/dom/src/toolpanelmount.js",function(e,V){"use strict";Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return p}});const _=V("packages/core/src/internal/util.js"),R=_.isFunction,$=_.warnOnce,L=V("packages/dom/src/ui/toolpanel.js"),W=L.ToolPanel,Z=L.toolPanels,H=L.toolPanelTitles,U=L.toolPanelIcons,F=V("packages/dom/src/filters/index.js").createFilter,k=V("packages/dom/src/editors/common.js"),O=k.CLS,y=k.documentFor,d=k.scannableRows,c=V("packages/dom/src/filtermenu.js"),r=c.mergeColumnFilter,t=c.branchFor,n=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 i(m){const{grid:w,container:v}=m||{};if(!w)throw new Error("[lattice] mountPanel needs a grid");if(!v||!v.appendChild)throw new Error("[lattice] mountPanel needs a container element");const a=R(m.panel)?m.panel:Z[String(m.panel)];if(!a)throw new Error(`[lattice] unknown panel "${m.panel}"; known panels are ${Object.keys(Z).join(", ")}`);const o=v.ownerDocument||y(v),S=b(w,o,m.announce),E=new a;E.init({document:o,host:S,grid:w,props:m.props||{}});const A=E.element();v.appendChild(A);const M=[];for(const C of n)R(w.on)&&M.push(w.on(C,()=>E.refresh()));return{element:A,refresh(){E.refresh()},destroy(){for(const C of M)C();M.length=0,R(E.destroy)&&E.destroy(),A&&A.parentNode&&A.parentNode.removeChild(A)}}}const s=260,l=30,u=`${O.panel}-dock`;function f(m,w,v){if(!m||!R(m.set))return;const a=t(v.filters.get(),w)||null,o=R(m.get)&&(!R(m.active)||m.active())&&m.get()||null;JSON.stringify(o)!==JSON.stringify(a)&&(a?m.set(a):R(m.clear)?m.clear():m.set(null))}function h(m,w){if(m==="insights"){const o=w&&R(w.get)?w.get("insights"):null;return{other:(o&&typeof o=="object"?o:{}).compareWith||null}}if(m!=="views")return{};const v=w&&R(w.get)?w.get("views"):null,a=v&&typeof v=="object"?v:{};return{allowSave:a.allowSave!==!1,showDiff:a.showDiff===!0,builtinTitle:a.builtinTitle,savedTitle:a.savedTitle}}function g(m){const w=m.pagination&&R(m.pagination.get)?m.pagination.get():null;return w&&Number.isFinite(w.total)?w.total:m.rows.count()}function b(m,w,v){const a=new Map;return{announce(o,S){R(v)&&v(o,S)},t(o,S){return m.messages.t(o,S)},grid:m,document:w,columns:()=>m.columns.all(),showColumns:o=>m.columns.show(o),hideColumns:o=>m.columns.hide(o),groupBy:()=>m.state.get().group||[],setGroupBy:o=>m.columns.group(o),pivotBy:()=>(m.state.get().pivot||{}).columns||[],setPivotBy:o=>m.columns.pivot(o),valueColumns:()=>m.columns.all().filter(o=>o.total).map(o=>o.id),setValueColumns:o=>m.columns.totals(o),valueAggregation(o){const S=m.columns.get(o);return!S||!S.total?"sum":typeof S.total=="string"?S.total:"custom"},setValueAggregation(o,S){m.columns.setTotal(o,S)},quickFilter:()=>m.state.get().quick||"",setQuickFilter:o=>m.filters.quick(o),rowCount:()=>g(m),totalRowCount:()=>R(m.rows.totalCount)?m.rows.totalCount():m.rows.count(),formattableColumns:()=>m.columns.visible().filter(o=>!o.generated).map(o=>({id:o.id,title:String(o.title??o.id)})),formattingRules:o=>m.formatting.list(o),columnSamples:o=>{let S=o;if(!S||S==="*"){const M=m.columns.visible().find(C=>!C.generated);S=M?M.id:null}if(!S)return[];const E=[],A=new Set;for(const M of d(m)){const C=m.rows.value(M.key,S);if(C==null||C==="")continue;const P=typeof C=="object"?E.length:C;if(!A.has(P)&&(A.add(P),E.push(C),E.length>=24))break}return E},profilableColumns:()=>m.columns.visible().filter(o=>!o.generated).map(o=>({id:o.id,title:String(o.title??o.id)})),columnProfile:o=>m.statistics.profile(o),reduceColumn:(o,S)=>m.statistics.reduce(o,S),columnCapability:o=>m.statistics.capability(o),regressionModel:o=>R(m.statistics.regressionModel)?m.statistics.regressionModel(o):null,insightsColumns:()=>m.columns.visible().filter(o=>!o.generated).map(o=>({id:o.id,title:String(o.title??o.id),type:o.type})),subsetVsPopulation:()=>m.statistics.subsetVsPopulation(),datasetVsDataset:o=>m.statistics.datasetVsDataset(o),compareGroups:(o,S)=>m.statistics.compareGroups(o,S),anomalies:o=>m.statistics.anomalies(o||{}),compareColumns:(o,S)=>{if(!o||!S||o===S)return null;const E=m.statistics.regression(o,S);return{n:E?E.n:0,pearson:m.statistics.correlation(o,S),spearman:m.statistics.spearman(o,S),kendall:m.statistics.kendall(o,S),covariance:m.statistics.covariance(o,S),slope:E?E.slope:null,intercept:E?E.intercept:null,r2:E?E.r2:null,stdError:E?E.stdError:null,weighted:m.statistics.weightedAverage(o,S)}},addRule:(o,S)=>m.formatting.add(o,S),removeRule:(o,S)=>m.formatting.remove(o,S),updateRule:(o,S,E)=>m.formatting.update(o,S,E),moveRule:(o,S,E)=>m.formatting.move(o,S,E),clearRules:o=>m.formatting.clear(o),views:()=>m.views.list(),activeId:()=>m.views.activeId,apply:o=>{m.views.apply(o)},saveAs:o=>m.views.save(o),rename:(o,S)=>m.views.rename(o,S),setDefault:o=>m.views.setDefault(o),clearDefault:()=>m.views.setDefault(null),remove:o=>m.views.remove(o),export:o=>m.views.export(o),diff:o=>m.views.diff(o),moveColumn(o,S,E){const A=m.columns.all().map(x=>x.id),M=A.indexOf(o),C=A.indexOf(S);if(M<0||C<0)return;let P=E?C:C+1;M<P&&(P-=1),P!==M&&m.columns.move(o,P)},isFiltered(o){return t(m.filters.get(),o)!==null},clearFilter(o){m.filters.set(r(m.filters.get(),o,null));const S=a.get(o);S&&R(S.clear)?S.clear():S&&R(S.set)&&S.set(null)},clearAllFilters(){m.filters.set(null);for(const o of a.values())R(o.clear)?o.clear():R(o.set)&&o.set(null)},filterFor(o){if(a.has(o))return f(a.get(o),o,m),a.get(o);const S=m.columns.get(o);if(!S)return null;const E=F({grid:m,column:S,colId:o,type:S.type,locale:m.get("locale"),props:{...S.filter&&S.filter.props,values:S.filter&&S.filter.props&&S.filter.props.values||(S.lookup?void 0:()=>m.columns.distinct(o))},lookup:S.lookup,document:w,value:A=>m.rows.value(A.row&&A.row.key,o),rows:S.lookup?void 0:()=>d(m),changed:()=>{const M=(R(E.active)?E.active():!0)&&R(E.get)?E.get():null;m.filters.set(r(m.filters.get(),o,M||null))}});return E&&(f(E,o,m),a.set(o,E)),E},destroyFilters(){for(const o of a.values())R(o.destroy)&&o.destroy();a.clear()}}}class p{#e;#t;#n;#r;#o;#i=null;#a=[];#s="right";#l=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 a=(w.panels||["columns","filters"]).map(o=>Z[o]?{name:o,title:H[o]?w.grid.messages.t(H[o]):o,icon:U[o]||o,Ctor:Z[o],props:h(o,w.grid)}:($(`toolpanel:${o}`,`unknown tool panel "${o}"`),null)).filter(Boolean);this.#s=w.side==="left"?"left":"right",this.#r=new W,this.#r.init({document:w.document,host:this.#o,grid:w.grid,panels:a,actions:w.actions,icons:w.icons,side:this.#s,openPanel:w.openPanel})}mount(){const w=this.#t.createElement("div");w.className=`${u} ${u}--${this.#s}`,w.appendChild(this.#r.element()),this.#n.appendChild(w),this.#i=w;const v=this.#r.show.bind(this.#r),a=this.#r.hide.bind(this.#r);this.#r.show=o=>{const S=v(o);return this.#f(),S},this.#r.hide=()=>{a(),this.#f()};for(const o of[...n,"rows:paused","rows:resumed","rows:queued","annotation:changed"])this.#a.push(this.#e.on(o,()=>this.#r.refresh()));this.#a.push(this.#e.on("presentation:started",o=>{this.#u=!0;const S=o&&o.options&&Array.isArray(o.options.chrome)?o.options.chrome:[];this.#c=S.includes("toolPanel")})),this.#a.push(this.#e.on("presentation:ended",()=>{this.#u=!1,this.#c=!1})),this.#a.push(this.#e.on("toolpanel:focus",()=>this.open("columns"))),this.#a.push(this.#e.on("column:profile:open",o=>{const S=o&&o.colId,E=this.#r.panels.find(A=>A.name==="statistics");E&&S!=null&&(E.panel.column=String(S)),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(v=>v.name===w.name)){if(this.#r.registerAction(w),this.#l&&!w.annotation){const v=this.#r.actions.find(a=>a.name===w.name);v&&this.#h(v.button)}else!this.#l&&w.annotation&&this.#u&&!this.#c&&this.#d();this.#f()}}removeAction(w){this.#r.removeAction(w)&&this.#f()}presentOnly(){return this.#l?!0:this.#r.actions.some(w=>w.annotation&&w.button)?(this.#d(),!0):!1}#d(){const w=this.#r;this.#l={hidden:[],reopen:w.openPanel||null},this.#l.reopen&&w.hide(),this.#h(w.body);for(const v of[...w.tabs?.children||[]])v!==w.actionGroup&&this.#h(v);for(const v of[...w.actionGroup?.children||[]]){const a=w.actions.find(o=>o.button===v);(!a||!a.annotation)&&this.#h(v)}this.#i&&this.#i.style&&(this.#i.style.display=""),this.#f()}presentRestore(){const w=this.#l;if(!w)return!1;this.#l=null;for(const v of w.hidden)v.el&&v.el.style&&(v.el.style.display=v.display);return w.reopen&&this.#r.show(w.reopen),this.#f(),!0}#h(w){if(!w||!w.style||!this.#l)return;const v=w.style.display||"";v!=="none"&&(w.style.display="none",this.#l.hidden.push({el:w,display:v}))}#f(){if(!this.#i)return;const w=!!this.#r.openPanel;this.#i.setAttribute("data-open",w?"true":"false"),this.#i.style.width=w?`${s}px`:"";const v=`${w?s:this.#m()}px`;this.#n.style.paddingLeft=this.#s==="left"?v:"",this.#n.style.paddingRight=this.#s==="left"?"":v,this.#n.style.setProperty("--lattice-dock-left",this.#s==="left"?v:"0px"),this.#n.style.setProperty("--lattice-dock-right",this.#s==="left"?"0px":v)}#m(){const w=this.#r&&R(this.#r.element)?this.#r.element().querySelector?.(`.${O.panel}__tabs`):null,v=w&&(w.offsetWidth||w.getBoundingClientRect?.().width)||0;return v>0?Math.ceil(v):l}destroy(){for(const w of this.#a)w();this.#a=[],this.#l=null,this.#o.destroyFilters(),this.#r.destroy(),this.#i&&this.#i.remove&&this.#i.remove(),this.#i=null,this.#n.style.paddingRight=""}}}),ke("packages/dom/src/celledit.js",function(e,V){"use strict";Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return O}});const _=V("packages/core/src/internal/util.js"),R=_.isFunction,$=_.warnOnce,W=V("packages/dom/src/editors/index.js").createEditor,Z=V("packages/dom/src/editors/common.js"),H=Z.CLS,U=Z.markInvalid,F=V("packages/dom/src/detailhost.js").insideDetail,k=`${H.editor}-host`;class O{#e;#t;#n;#r;#o;#i=null;#a=null;#s=null;#l=-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",f=>this.open(f))),this.#u.push(this.#e.on("cell:edit:end",()=>this.close()));const t=this.#n.viewport.root,n=this.#e.get("edit"),i=n&&typeof n=="object"&&n.start||"double",s=f=>{if(F(f.target,t))return;const h=y(f.target,w=>w.getAttribute&&w.getAttribute("data-col"));if(!h)return;const g=y(h,w=>w.getAttribute&&w.getAttribute("data-key"));if(!g)return;const b=this.#e.rows.byKey(g.getAttribute("data-key"));if(!b||b.group)return;const p=h.getAttribute("data-col"),m=this.#e.columns.get(p);!m||!m.edit||!m.edit.enabled||this.#e.edit.start(b.key,p)},l=i==="key"?null:i==="single"?"click":"dblclick";l&&(t.addEventListener(l,s),this.#u.push(()=>t.removeEventListener(l,s)));const u=f=>{!this.#i||!this.#s||this.#m(f.target)||this.commit()};this.#t.addEventListener("mousedown",u,!0),this.#u.push(()=>this.#t.removeEventListener("mousedown",u,!0))}get target(){return this.#s}open(t){this.close();const n=t.key||t.row&&t.row.key,i=t.colId;if(!n||!i)return;const s=this.#e.columns.get(i),l=this.#e.rows.byKey(n);if(!s||!l)return;const u=this.#b(n,i);if(this.#c=u,!u){$("celledit.offscreen","cannot edit a row that is not rendered; scroll to it first.");return}const f=this.#e.permissions,h=!!(f&&R(f.isSecret)&&f.isSecret(i)),g=W({grid:this.#e,column:s,colId:i,row:l,data:l.data,value:h?null:this.#e.rows.value(n,i),text:h?"":this.#e.rows.text(n,i),locale:this.#e.get("locale"),props:s.edit&&s.edit.props,lookup:s.lookup,document:this.#t,cell:u,overlay:this.#n.viewport.overlays,onCommit:m=>this.#f({value:m,key:n,colId:i}),onCancel:()=>{this.#d=!0,this.#e.edit.stop(!0)},stop:m=>{this.#d||this.#e.edit.stop(m)}},this.#r);if(!g){$(`celledit.noeditor:${i}`,`column "${i}" has no editor.`);return}this.#i=g,this.#a=u,this.#s={key:n,colId:i},this.#d=!1,this.#l=this.#v(u);const b=g.element();g.popup?(this.#n.viewport.overlays.appendChild(b),d(b,u,this.#n.viewport.root)):u.replaceChildren(b),u.classList.add(k),R(g.attached)&&g.attached(),c(b);const p=m=>this.#h(m);b.addEventListener("keydown",p),this.#u.push(()=>b.removeEventListener("keydown",p))}#h(t){const n=t.key;if(n!=="Enter"&&n!=="Tab"&&n!=="Escape")return;if(t.preventDefault(),t.stopPropagation(),n==="Escape"){this.#e.edit.stop(!0);return}const i=n==="Enter"?this.#p(t.shiftKey?-1:1):this.#g(t.shiftKey?-1:1);this.commit()&&i&&this.#e.edit.start(i.key,i.colId)}#f(t){this.#d||(this.#d=!0,this.#e.edit.stop(!1,t))}commit(){if(!this.#i||!this.#s)return!1;if(this.#d)return!0;if(R(this.#i.cancelOnClose)&&this.#i.cancelOnClose()===!0)return this.#d=!0,this.#e.edit.stop(!0),!0;const{key:t,colId:n}=this.#s;if(R(this.#i.value)){const i=this.#i.value();if(R(this.#i.validate)){const s=this.#i.validate(i);if(s!==!0){if(U(this.#c,s),R(this.#i.focusTarget)){const l=this.#i.focusTarget();l&&R(l.focus)&&l.focus()}return!1}U(this.#c,null)}this.#f({value:i,key:t,colId:n})}else this.#d=!0,this.#e.edit.stop(!1);return!0}#m(t){if(!t)return!1;const n=R(this.#i.element)?this.#i.element():null;if(n&&R(n.contains)&&n.contains(t))return!0;const i=this.#c;return!!(i&&R(i.contains)&&i.contains(t))}#p(t){if(!this.#s||this.#l<0)return null;for(let n=this.#l+t;n>=0&&n<this.#e.rows.count();n+=t){const i=this.#e.rows.get(n);if(i&&!i.group)return{key:i.key,colId:this.#s.colId}}return null}#g(t){if(!this.#s)return null;const n=this.#e.columns.visible(),i=n.findIndex(s=>s.id===this.#s.colId);for(let s=i+t;s>=0&&s<n.length;s+=t){const l=n[s];if(l.edit&&l.edit.enabled)return{key:this.#s.key,colId:l.id}}return null}#v(t){const n=y(t,s=>s.getAttribute&&s.getAttribute("data-index"));if(!n)return-1;const i=Number(n.getAttribute("data-index"));return Number.isFinite(i)?i:-1}#b(t,n){const i=this.#n.viewport.root;if(!i||!i.querySelectorAll)return null;for(const s of i.querySelectorAll(`[data-col="${n}"]`)){const l=y(s,u=>u.getAttribute&&u.getAttribute("data-key"));if(l&&l.getAttribute("data-key")===t)return s}return null}close(){this.#c&&U(this.#c,null);const t=this.#y();if(this.#i&&R(this.#i.destroy)&&this.#i.destroy(),this.#a){if(this.#a.classList.remove(k),this.#o&&R(this.#o.releaseCell)){const n=this.#s?this.#e.columns.get(this.#s.colId):null;this.#o.releaseCell(this.#a,n)}this.#a.replaceChildren&&this.#a.replaceChildren(),t&&this.#w(this.#a),this.#n.refresh({force:!0})}this.#i=null,this.#c=null,this.#a=null,this.#s=null,this.#l=-1,this.#d=!1}#y(){const t=this.#t.activeElement;if(!t||t===this.#t.body)return!1;const n=this.#i&&R(this.#i.element)?this.#i.element():null,i=s=>!!s&&R(s.contains)&&s.contains(t);return i(n)||i(this.#a)}#w(t){const i=R(t.hasAttribute)&&t.hasAttribute("tabindex")?t:this.#n.viewport.root;i&&R(i.focus)&&i.focus()}destroy(){this.close();for(const t of this.#u)t();this.#u=[]}}function y(r,t){let n=r;for(;n;){if(t(n))return n;n=n.parentNode}return null}function d(r,t,n){if(!R(t.getBoundingClientRect))return;const i=t.getBoundingClientRect(),s=n.getBoundingClientRect();r.style.position="absolute",r.style.top=`${Math.round(i.top-s.top)}px`,r.style.minWidth=`${Math.round(i.width)}px`,r.style.left=`${Math.round(i.left-s.left)}px`;const l=r.offsetWidth||Math.round(i.width),u=Math.round(i.left-s.left)+l-Math.round(s.width);u>0&&(r.style.left=`${Math.max(0,Math.round(i.left-s.left)-u)}px`)}function c(r){const t=r.querySelector&&r.querySelector("input, select, textarea, [tabindex]")||r;R(t.focus)&&t.focus(),R(t.select)&&t.select()}}),ke("packages/dom/src/editbar.js",function(e,V){"use strict";Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return z}});const _=V("packages/core/src/internal/util.js"),R=_.isFunction,$=_.warnOnce,W=V("packages/dom/src/editors/index.js").createEditor,U=`${V("packages/dom/src/editors/common.js").CLS.editor}-bar`;class z{#e;#t;#n;#r=null;#o=null;#i=null;#a=null;#s=null;#l=null;#u=!1;#c=null;#d=[];constructor(k){this.#e=k.grid,this.#t=k.document,this.#n=k.root}mount(){const k=this.#t,O=k.createElement("div");O.className=U;const y=k.createElement("span");y.className=`${U}__ref`,y.textContent="";const d=k.createElement("div");d.className=`${U}__slot`;const c=k.createElement("span");c.className=`${U}__readonly`,O.appendChild(y),O.appendChild(d),this.#n.insertBefore(O,this.#n.firstChild),this.#r=O,this.#o=y,this.#i=d,this.#s=c;for(const r of["cell:clicked","cell:edit:start","selection:changed","model:changed","rows:changed"])this.#d.push(this.#e.on(r,t=>this.#f(t)))}bind(k,O){const y=this.#e.columns.get(O),d=k?this.#e.rows.byKey(k):null;this.#l=d&&y&&!d.group?{key:k,colId:O}:null,this.refresh()}refresh(){if(!this.#i||this.#u)return;if(this.#h(),!this.#l){this.#o.textContent="";return}const{key:k,colId:O}=this.#l,y=this.#e.columns.get(O);if(!y)return;if(this.#o.textContent=y.title||O,!!!(y.edit&&y.edit.enabled)){this.#s.textContent=this.#e.rows.text(k,O),this.#i.appendChild(this.#s);return}const c=this.#e.rows.byKey(k);if(!c)return;const r=W({grid:this.#e,column:y,colId:O,row:c,data:c.data,value:this.#e.rows.value(k,O),text:this.#e.rows.text(k,O),locale:this.#e.get("locale"),props:y.edit&&y.edit.props,lookup:y.lookup,document:this.#t,cell:this.#i,overlay:this.#n,stop:l=>l?this.cancel():this.commit(!0)});if(!r){$(`editbar.noeditor:${O}`,`column "${O}" has no editor.`),this.#s.textContent=this.#e.rows.text(k,O),this.#i.appendChild(this.#s);return}this.#a=r;const t=r.element();r.popup?(this.#s.textContent=this.#e.rows.text(k,O),this.#i.appendChild(this.#s)):this.#i.appendChild(t),R(r.attached)&&r.attached();const n=l=>this.#m(l),i=()=>{this.#u=!0},s=[t,this.#i];for(const l of s)l.addEventListener("keydown",n),l.addEventListener("input",i),l.addEventListener("change",i);this.#c=()=>{for(const l of s)l.removeEventListener("keydown",n),l.removeEventListener("input",i),l.removeEventListener("change",i)}}#h(){this.#c&&(this.#c(),this.#c=null),this.#a&&R(this.#a.destroy)&&this.#a.destroy(),this.#a=null,this.#i&&this.#i.replaceChildren&&this.#i.replaceChildren()}cancel(){this.#u=!1,this.refresh()}#f(k){if(k&&k.colId&&(k.key||k.row&&k.row.key)){this.bind(k.key||k.row.key,k.colId);return}this.refresh()}#m(k){if(k.key==="Enter"){k.preventDefault(),this.commit();return}k.key==="Escape"&&(k.preventDefault(),this.cancel())}commit(k){if(!this.#l||!this.#u&&!k)return!1;const{key:O,colId:y}=this.#l;if(!this.#a||!R(this.#a.value))return!1;const d=this.#a.value();return this.#u=!1,this.#e.edit.start(O,y),this.#e.edit.stop(!1,{value:d,key:O,colId:y}),this.refresh(),!0}destroy(){this.#h();for(const k of this.#d)k();this.#d=[],this.#r&&R(this.#r.remove)&&this.#r.remove(),this.#r=null,this.#i=null,this.#o=null,this.#l=null}}}),ke("packages/dom/src/pastepreview.js",function(e,V){"use strict";Object.defineProperty(e,"PREVIEW_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"PastePreview",{enumerable:!0,get:function(){return F}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/dom/src/editors/common.js"),Z=W.el,H=W.clear,U="lat-pastepreview",z='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class F{#e;#t;#n=null;#r=null;#o=null;#i=null;#a=null;#s=null;#l=null;#u=[];constructor(O){this.#e=O.grid,this.#t=O.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#c(O,y){const d=this.#e;return(d&&d.messages?d.messages:L).t(O,y)}#d(O){const y=`paste.preview.reason.${O}`,d=this.#c(y);return d===y?O:d}#h(O){return O==null||O===""?"":String(O)}#f(O,y){const d=this.#e.columns&&R(this.#e.columns.get)?this.#e.columns.get(y):null;return`${d&&(d.title||d.headerName)||y} · ${O}`}show(O,y){const d=this.#b();if(!d)return!1;this.#s=y&&y.onConfirm,this.#l=y&&y.onCancel||null;const c=O&&O.changes||[],r=O&&O.rejected||[],t=c.filter(i=>i.changed);this.#m(t,r);const n=d.ownerDocument;return this.#a=n&&n.activeElement,d.style.display="",R(d.focus)&&d.focus(),this.#w(this.#c("a11y.paste.previewOpened",{count:t.length,changes:t.length,rejected:r.length}),{repeat:!0}),!0}#m(O,y){const d=this.#r.ownerDocument;H(this.#r);const c=Z(d,"p",{class:`${U}__summary`,attrs:{role:"status"},text:this.#c("paste.preview.summary",{count:O.length,changes:O.length,rejected:y.length})});if(this.#r.appendChild(c),!O.length&&!y.length){this.#r.appendChild(Z(d,"p",{class:`${U}__empty`,text:this.#c("paste.preview.empty")})),this.#o.disabled=!O.length;return}this.#o.disabled=!O.length,O.length&&(this.#r.appendChild(Z(d,"h3",{class:`${U}__heading`,text:this.#c("paste.preview.changesHeading",{count:O.length})})),this.#r.appendChild(this.#p(d,O))),y.length&&(this.#r.appendChild(Z(d,"h3",{class:`${U}__heading ${U}__heading--rejected`,text:this.#c("paste.preview.rejectedHeading",{count:y.length})})),this.#r.appendChild(this.#g(d,y)))}#p(O,y){const d=Z(O,"tr",{children:[Z(O,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),Z(O,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colOld")}),Z(O,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colNew")})]}),c=y.map(r=>Z(O,"tr",{children:[Z(O,"th",{attrs:{scope:"row"},text:this.#f(r.key,r.colId)}),Z(O,"td",{class:`${U}__old`,text:this.#h(r.oldValue)}),Z(O,"td",{class:`${U}__new`,text:this.#h(r.newValue)})]}));return Z(O,"table",{class:`${U}__table`,children:[Z(O,"thead",{children:[d]}),Z(O,"tbody",{children:c})]})}#g(O,y){const d=Z(O,"tr",{children:[Z(O,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),Z(O,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colReason")})]}),c=y.map(r=>Z(O,"tr",{children:[Z(O,"th",{attrs:{scope:"row"},text:this.#f(r.key,r.colId)}),Z(O,"td",{class:`${U}__reason`,text:this.#d(r.reason)})]}));return Z(O,"table",{class:`${U}__table ${U}__table--rejected`,children:[Z(O,"thead",{children:[d]}),Z(O,"tbody",{children:c})]})}confirm(){const O=this.#s;this.#v(),R(O)&&O()}cancel(){const O=this.#l;this.#v(),this.#w(this.#c("a11y.paste.cancelled"),{repeat:!0}),R(O)&&O()}#v(){if(!this.#n)return;this.#n.style.display="none",this.#s=null,this.#l=null;const O=this.#a;this.#a=null,O&&R(O.focus)&&O.focus()}#b(){if(this.#n)return this.#n;const O=this.#t.viewport&&this.#t.viewport.overlays,y=O&&O.ownerDocument;if(!O||!y||!R(y.createElement))return null;const d=`${U}-title`,c=Z(y,"h2",{class:`${U}__title`,attrs:{id:d},text:this.#c("paste.preview.title")}),r=Z(y,"div",{class:`${U}__body`}),t=Z(y,"button",{class:`${U}__confirm`,attrs:{type:"button"},text:this.#c("paste.preview.confirm")}),n=Z(y,"button",{class:`${U}__cancel`,attrs:{type:"button"},text:this.#c("paste.preview.cancel")}),i=Z(y,"div",{class:`${U}__foot`,children:[n,t]}),s=Z(y,"div",{class:U,attrs:{role:"dialog","aria-modal":"true",tabindex:"-1","aria-labelledby":d},children:[Z(y,"div",{class:`${U}__head`,children:[c]}),r,i]});return O.appendChild(s),this.#n=s,this.#r=r,this.#o=t,this.#i=n,this.#y(s,t,n),s}#y(O,y,d){const c=n=>{if(n.stopPropagation(),n.key==="Escape"){n.preventDefault(),this.cancel();return}if(n.key!=="Tab")return;const i=[...O.querySelectorAll(z)].filter(f=>!f.disabled);if(!i.length){n.preventDefault();return}const s=i[0],l=i[i.length-1],u=O.ownerDocument.activeElement;n.shiftKey&&(u===s||u===O)?(n.preventDefault(),l.focus()):!n.shiftKey&&u===l&&(n.preventDefault(),s.focus())},r=n=>{n&&R(n.preventDefault)&&n.preventDefault(),this.confirm()},t=n=>{n&&R(n.preventDefault)&&n.preventDefault(),this.cancel()};O.addEventListener("keydown",c),y.addEventListener("click",r),d.addEventListener("click",t),this.#u.push(()=>{O.removeEventListener("keydown",c),y.removeEventListener("click",r),d.removeEventListener("click",t)})}#w(O,y){const d=this.#t&&this.#t.announce;R(d)&&d.call(this.#t,O,y)}destroy(){for(const O of this.#u)O();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.#a=null,this.#s=null,this.#l=null}}}),ke("packages/dom/src/rangeselect.js",function(e,V){"use strict";Object.defineProperty(e,"RangeController",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/core/src/model/selection.js"),Z=W.extendSeries,H=W.resolveSelectionConfig,U=V("packages/dom/src/renderer/textentry.js"),z=U.isTextEntry,F=U.isFindBarControl,O=V("packages/dom/src/pastepreview.js").PastePreview,y=V("packages/dom/src/columnmenu.js"),d=y.chartableRange,c=y.rangeChartConfig,r="lat-cell--range",t="lat-cell--range-edge",n=Object.freeze({top:"lat-cell--range-top",right:"lat-cell--range-right",bottom:"lat-cell--range-bottom",left:"lat-cell--range-left"}),i=3;class s{#e;#t;#n;#r=!1;#o=[];#i=null;#a=null;#s=null;#l=null;#u=null;constructor(f){this.#e=f.grid,this.#t=f.renderer,this.#n=f.document,this.#l=f.preview||null}mount(){const f=this.#t.viewport.root,h=m=>this.#c(m),g=m=>this.#d(m),b=()=>this.#h(),p=m=>this.#f(m);f.addEventListener("pointerdown",h),this.#n.addEventListener("pointermove",g),this.#n.addEventListener("pointerup",b),f.addEventListener("keydown",p),this.#o.push(()=>{f.removeEventListener("pointerdown",h),this.#n.removeEventListener("pointermove",g),this.#n.removeEventListener("pointerup",b),f.removeEventListener("keydown",p)});for(const m of["range:changed","rows:changed","model:changed","scroll"])this.#o.push(this.#e.on(m,()=>this.paint()));this.paint()}#c(f){if(f.button!==0)return;const h=f.target;if(!h||!R(h.closest))return;if(this.#r=!1,h.closest('[data-role="fill-handle"]')){if(this.#T())return;this.#i={mode:"fill",fromX:f.clientX,fromY:f.clientY,armed:!0};return}if(h.closest('[data-role="row-drag"]'))return;const g=this.#F(h);if(!g)return;if(f.shiftKey&&this.#e.selection.corner()){const p=this.#E(g);this.#e.selection.extendRange(p.rowIndex,p.colId),this.#i={mode:"select",fromX:f.clientX,fromY:f.clientY,armed:!0};return}const b=this.#C(g);this.#u=b,this.#e.selection.startRange(b.rowIndex,b.colId,{additive:f.ctrlKey||f.metaKey}),this.#i={mode:"select",fromX:f.clientX,fromY:f.clientY,armed:!1}}#d(f){const h=this.#i;if(!h)return;if(!h.armed){if(Math.abs(f.clientX-h.fromX)+Math.abs(f.clientY-h.fromY)<i)return;h.armed=!0}const g=this.#Y(f.clientX,f.clientY);if(!g)return;if(h.mode==="fill"){this.#s=g,this.paint();return}const b=this.#E(g);this.#e.selection.extendRange(b.rowIndex,b.colId)}#h(){const f=this.#i;if(this.#i=null,!!f){if(f.mode==="fill"&&this.#s){const h=this.#s;this.#s=null,this.fillTo(h.rowIndex)}this.#s=null,this.paint()}}#f(f){if(this.#N()||F(f.target)||z(f.target))return;const h=f.ctrlKey||f.metaKey,g=f.key;if(h&&(g==="c"||g==="C")){this.copy(),f.preventDefault();return}if(h&&(g==="v"||g==="V")){this.paste(),f.preventDefault();return}if(h&&(g==="d"||g==="D")){this.fillDown(),f.preventDefault();return}if(g==="Delete"||g==="Backspace"){if(!this.#e.selection.cells().length&&this.#e.selection.keys().length&&this.#e.get("rowDelete")===!0){this.#e.edit.deleteRows(),f.preventDefault();return}this.clear(),f.preventDefault();return}if(f.altKey&&g==="F1"){this.chartSelection()&&f.preventDefault();return}if(!f.shiftKey)return;const b={ArrowDown:[1,0],ArrowUp:[-1,0],ArrowRight:[0,1],ArrowLeft:[0,-1]}[g];if(!b)return;if(h){const A=this.#U();if(!A)return;if(!this.#r){const K=this.#C(A);this.#u=K,this.#e.selection.startRange(K.rowIndex,K.colId,{additive:!0}),this.#r=!0}const M=this.#e.columns.visible().map(K=>K.id),C=M.indexOf(A.colId),P=this.#e.selection.corner()||{row:A.rowIndex,colId:A.colId},x=this.#E({rowIndex:Math.min(this.#e.rows.count()-1,Math.max(0,P.row+b[0])),colId:M[Math.min(M.length-1,Math.max(0,(C<0?0:C)+b[1]))]});this.#e.selection.extendRange(x.rowIndex,x.colId),f.preventDefault();return}this.#r=!1;const p=this.#e.selection.corner(),m=this.#U(),w=p||m;if(!w)return;if(!p&&m){const A=this.#C(m);this.#u=A,this.#e.selection.startRange(A.rowIndex,A.colId)}const v=this.#e.columns.visible().map(A=>A.id),a=v.indexOf(w.colId??w.colId),o=v[Math.min(v.length-1,Math.max(0,a+b[1]))],S=Math.min(this.#e.rows.count()-1,Math.max(0,(p?p.row:m.rowIndex)+b[0])),E=this.#E({rowIndex:S,colId:o});this.#e.selection.extendRange(E.rowIndex,E.colId),f.preventDefault()}async copy(){const f=this.#e.export.rangeText();if(!f)return this.#e.selection.ranges().length>1&&this.#e.emit("clipboard:copy",{text:"",ok:!1,rows:"range",reason:"discontiguous"},"user"),!1;const h=globalThis.navigator&&globalThis.navigator.clipboard;if(!h||!R(h.writeText))return!1;try{return await h.writeText(f),this.#e.emit("clipboard:copy",{text:f,ok:!0,rows:"range"},"user"),!0}catch{return this.#e.emit("clipboard:copy",{text:f,ok:!1,rows:"range"},"user"),!1}}async paste(){const f=globalThis.navigator&&globalThis.navigator.clipboard;if(!f||!R(f.readText))return 0;let h="";try{h=await f.readText()}catch{return 0}return this.pasteText(h)}pasteText(f){if(!f)return 0;const h=this.#e.selection.cells(),g=h.length?h[0]:this.#y();if(!g)return 0;const b=h.length>1?{rows:new Set(h.map(p=>p.key)).size,columns:new Set(h.map(p=>p.colId)).size}:void 0;if(this.#m()){const p=this.#e.edit.previewPaste(g,f,b);if(p.changes.length+p.rejected.length>1)return this.#p().show(p,{onConfirm:()=>this.#g(g,f,b)}),0}return this.#g(g,f,b)}#m(){const f=this.#e.edit;return!!(f&&f.pastePreview&&R(f.previewPaste))}#p(){return this.#l||(this.#l=new O({grid:this.#e,renderer:this.#t})),this.#l}#g(f,h,g){const b=this.#e.edit.pasteInto(f,h,g);return this.#b(b?this.#v("a11y.range.written",{count:b}):this.#v("a11y.range.refused"),{repeat:!0}),b}#v(f,h){const g=this.#e;return(g&&g.messages?g.messages:L).t(f,h)}#b(f,h){const g=this.#t&&this.#t.announce;R(g)&&g.call(this.#t,f,h)}#y(){const f=this.#U();if(!f)return null;const h=this.#e.rows.get(f.rowIndex);return h?{key:h.key,colId:f.colId}:null}clear(){const f=this.#e.selection.cells();return f.length?this.#e.edit.setCells(f.map(h=>({...h,value:null}))):0}fillDown(){if(this.#e.selection.ranges().length>1)return 0;const f=this.#e.selection.cells();if(f.length<2)return 0;const h=[...new Set(f.map(p=>p.key))];if(h.length<2)return 0;const g=h[0],b=[];for(const{key:p,colId:m}of f)p!==g&&b.push({key:p,colId:m,value:this.#e.rows.value(g,m)});return this.#e.edit.setCells(b)}chartSelection(){const f=c(this.#e);if(!f.handler)return!1;const h=d(this.#e);return h?(f.handler(this.#e,h),!0):!1}fillTo(f){if(this.#e.selection.ranges().length>1)return 0;const h=this.#e.selection.cells();if(!h.length)return 0;const g=[...new Set(h.map(o=>o.key))],b=[...new Set(h.map(o=>o.colId))],p=this.#_(g[g.length-1]);if(p<0||f<=p)return 0;const m=[];for(let o=p+1;o<=f;o++){const S=this.#e.rows.get(o);if(!S)break;m.push(S)}if(!m.length)return 0;const w=[];for(const o of b){const S=g.map(A=>this.#e.rows.value(A,o)),E=this.#w(S,m,o);for(let A=0;A<m.length;A++)w.push({key:m[A].key,colId:o,value:E[A]})}const v=this.#e.edit.setCells(w),a=this.#e.selection.corner();return a&&this.#e.selection.extendRange(f,a.colId),v}#w(f,h,g){const b=this.#e.get("selection"),p=b&&typeof b=="object"?b.fill:void 0;if(R(p)){const m=this.#e.columns.get(g),w=h.map(a=>({row:a,column:m})),v=p({source:f,target:w,direction:"down"});if(Array.isArray(v)&&v.length===h.length)return v}return Z(f,h.length)}paint(){const f=this.#t.viewport.root;if(!f||!f.querySelectorAll)return;const h=this.#e.selection,g=h.ranges().length>0,b=this.#s;for(const p of f.querySelectorAll("[data-col]")){const m=p.getAttribute("data-col"),w=p.parentNode,v=p.getAttribute?p.getAttribute("data-index"):null,a=v!==null&&v!==""?v:w&&w.getAttribute?w.getAttribute("data-index"):null;if(a===null||a==="")continue;const o=Number(a);if(!Number.isFinite(o)||o<0)continue;const S=g&&h.inRange(o,m),E=!!b&&this.#S(o,m,b);p.classList.toggle(r,S||E);const A=S||E?this.#j(o,m,h):null;p.classList.toggle(t,!!A&&A.any);for(const[M,C]of Object.entries(n))p.classList.toggle(C,!!A&&A[M])}this.#A()}#S(f,h,g){const b=this.#e.selection.cells();if(!b.length||!new Set(b.map(w=>w.colId)).has(h))return!1;const m=this.#_([...new Set(b.map(w=>w.key))].pop());return f>m&&f<=g.rowIndex}#j(f,h,g){const b=this.#e.columns.visible().map(a=>a.id),p=b.indexOf(h),m=p>0?b[p-1]:null,w=p>=0&&p<b.length-1?b[p+1]:null,v={top:!g.inRange(f-1,h),bottom:!g.inRange(f+1,h),left:!m||!g.inRange(f,m),right:!w||!g.inRange(f,w)};return v.any=v.top||v.bottom||v.left||v.right,v}#A(){const f=this.#e.selection.corner(),h=this.#t.viewport.overlays;if(!h)return;if(!f||this.#R()===!1||this.#e.selection.ranges().length>1||this.#T()){this.#a&&(this.#a.style.display="none");return}const g=this.#D(f.row,f.colId);if(!g||!R(g.getBoundingClientRect)){this.#a&&(this.#a.style.display="none");return}this.#a||(this.#a=this.#n.createElement("div"),this.#a.className="lat-fill-handle",this.#a.setAttribute("data-role","fill-handle"),this.#a.setAttribute("title",this.#v("a11y.fillHandle")),h.appendChild(this.#a));const b=g.getBoundingClientRect(),p=this.#t.viewport.root.getBoundingClientRect();this.#a.style.display="";const w=this.#t.viewport.rtl===!0?b.left:b.right;this.#a.style.left=`${Math.round(w-p.left)-4}px`,this.#a.style.top=`${Math.round(b.bottom-p.top)-4}px`}#O(f){const h=this.#t;return!f||typeof h.spanAt!="function"?null:h.spanAt(f.rowIndex,f.colId)}#C(f){const h=this.#O(f);return h?{rowIndex:h.row,colId:h.columnId}:f}#E(f){const h=this.#O(f);if(!h)return f;const g=this.#u,b=!!g&&g.rowIndex>=h.row+h.rows,p=this.#x(),m=g?p.indexOf(g.colId):-1,w=m>=0&&m>=h.col+h.cols;return{rowIndex:b?h.row:h.row+h.rows-1,colId:w?h.columnId:h.endColumnId}}#T(){const f=this.#e.selection.corner();if(!f)return!1;const h=this.#O({rowIndex:f.row,colId:f.colId});return!!h&&(h.rows>1||h.cols>1)}#x(){const f=this.#e.columns;return f&&R(f.visible)?f.visible().map(h=>h.id):[]}#R(){return H(this.#e.get("selection")).fillHandle}#N(){const f=this.#t.viewport.root;return!!(f&&f.querySelector&&f.querySelector(".lat-editor-host, .lat-editor--popup"))}#M(){const f=this.#e.selection.cells();return f.length?f[0]:null}#_(f){for(let h=0;h<this.#e.rows.count();h++){const g=this.#e.rows.get(h);if(g&&g.key===f)return h}return-1}#U(){const f=this.#t.viewport.root,h=f&&f.querySelector?f.querySelector('[data-col][tabindex="0"]'):null;return h?this.#F(h):null}#F(f){if(!f||!R(f.closest))return null;const h=f.closest("[data-col]");if(!h||!h.classList.contains("lat-cell"))return null;const g=h.closest("[data-index]");if(!g)return null;const b=Number(g.getAttribute("data-index"));return!Number.isFinite(b)||b<0?null:{rowIndex:b,colId:h.getAttribute("data-col")}}#Y(f,h){const g=this.#n.elementFromPoint?this.#n.elementFromPoint(f,h):null;return g?this.#F(g):null}#D(f,h){const g=this.#t.viewport.root;if(!g||!g.querySelectorAll)return null;for(const b of g.querySelectorAll(`[data-col="${h}"]`)){const p=b.closest?b.closest("[data-index]"):null;if(p&&Number(p.getAttribute("data-index"))===f)return b}return null}destroy(){for(const f of this.#o)f();this.#o=[],this.#a&&R(this.#a.remove)&&this.#a.remove(),this.#a=null,this.#i=null,this.#s=null,this.#l&&R(this.#l.destroy)&&this.#l.destroy(),this.#l=null}}const l=s}),ke("packages/dom/src/importer.js",function(e,V){"use strict";Object.defineProperty(e,"IMPORT_DIALOG_CLASS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ImportController",{enumerable:!0,get:function(){return s}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/core/src/import/index.js"),Z=W.parseDelimited,H=W.inferColumns,U=W.mapRecords,z=W.readXlsx,F=W.looksLikeXlsx,k=V("packages/dom/src/editors/common.js"),O=k.el,y=k.clear,d=k.on,r=V("packages/dom/src/renderer/textentry.js").isTextEntry,t="lat-import",n='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',i=".csv,.tsv,.txt,.xlsx,text/csv,text/tab-separated-values,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";class s{#e;#t;#n;#r;#o=[];#i=null;#a=null;#s=null;#l=null;constructor(u){this.#e=u.grid,this.#t=u.renderer,this.#n=u.document;const f=u.settings&&typeof u.settings=="object"?u.settings:{};this.#r={file:f.file!==!1,drop:f.drop!==!1,paste:f.paste!==!1,mode:f.mode==="replace"?"replace":"append"},this.#u()}#u(){const u=this.#t&&this.#t.viewport?this.#t.viewport.root:null;u&&(this.#r.drop&&(this.#o.push(d(u,"dragover",f=>{f.dataTransfer&&[...f.dataTransfer.types||[]].includes("Files")&&(f.preventDefault(),u.classList.add("lat-import--dropzone"))})),this.#o.push(d(u,"dragleave",()=>u.classList.remove("lat-import--dropzone"))),this.#o.push(d(u,"drop",f=>{u.classList.remove("lat-import--dropzone");const h=f.dataTransfer&&f.dataTransfer.files&&f.dataTransfer.files[0];h&&(f.preventDefault(),this.#c(h))}))),this.#r.paste&&this.#o.push(d(u,"paste",f=>{if(r(f.target)||this.#e.edit.isEditing?.()||this.#e.selection&&this.#e.selection.cells().length)return;const h=f.clipboardData&&f.clipboardData.getData("text/plain");!h||!h.includes(`
54
- `)||(f.preventDefault(),this.fromText(h))})))}openFile(){const u=O(this.#n,"input",{attrs:{type:"file",accept:i}});u.style.display="none",this.#o.push(d(u,"change",()=>{const f=u.files&&u.files[0];f&&this.#c(f),u.parentNode&&u.parentNode.removeChild(u)})),this.#n.body.appendChild(u),u.click()}#c(u){if(R(u.arrayBuffer)){u.arrayBuffer().then(h=>{const g=new Uint8Array(h);if(F(g)){this.fromXlsx(g,u.name);return}this.fromText(new TextDecoder().decode(g),u.name)});return}if(R(u.text)){u.text().then(h=>this.fromText(h,u.name));return}const f=new this.#n.defaultView.FileReader;f.onload=()=>this.fromText(String(f.result||""),u.name),f.readAsText(u)}async fromXlsx(u,f){const{header:h,rows:g}=await z(u);if(!h.length)return;const b=H(h,g,{columns:this.#e.columns.all()}),p=g.filter(m=>m.length!==h.length).length;this.#s={rows:g,columns:b,delimiter:null,name:f,warnings:p?[`${p} row(s) do not have ${h.length} columns`]:[]},this.#d()}fromText(u,f){const{header:h,rows:g,delimiter:b}=Z(u);if(!h.length)return;const p=H(h,g,{columns:this.#e.columns.all()}),m=g.filter(w=>w.length!==h.length).length;this.#s={rows:g,columns:p,delimiter:b,name:f,warnings:m?[`${m} row(s) do not have ${h.length} columns`]:[]},this.#d()}#d(){this.#i||this.#m(),this.#p(),this.#l=this.#n.activeElement,this.#i.hidden=!1;const u=this.#i.querySelector(n);u&&R(u.focus)&&u.focus(),this.#h(this.#f("import.opened",{count:this.#s.rows.length}),{repeat:!0})}#h(u,f){const h=this.#t&&this.#t.announce;R(h)&&h.call(this.#t,u,f)}#f(u,f){return(this.#e&&this.#e.messages?this.#e.messages:L).t(u,f)}#m(){const u=this.#n,f=O(u,"div",{class:t,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#f("import.title"),hidden:!0}}),h=O(u,"div",{class:`${t}__panel`});h.appendChild(O(u,"h2",{class:`${t}__title`,text:this.#f("import.title")})),this.#a=O(u,"div",{class:`${t}__body`}),h.appendChild(this.#a);const g=O(u,"div",{class:`${t}__footer`}),b=O(u,"button",{class:`${t}__cancel`,text:this.#f("import.cancel"),attrs:{type:"button"}}),p=O(u,"button",{class:`${t}__confirm`,text:this.#f("import.confirm"),attrs:{type:"button"}});this.#o.push(d(b,"click",()=>this.close())),this.#o.push(d(p,"click",()=>this.#g())),g.appendChild(b),g.appendChild(p),h.appendChild(g),f.appendChild(h),this.#o.push(d(f,"keydown",w=>{if(w.key==="Escape"){w.preventDefault(),this.close();return}if(w.key!=="Tab")return;const v=[...f.querySelectorAll(n)].filter(S=>!S.hidden);if(!v.length)return;const a=v[0],o=v[v.length-1];w.shiftKey&&this.#n.activeElement===a?(w.preventDefault(),o.focus()):!w.shiftKey&&this.#n.activeElement===o&&(w.preventDefault(),a.focus())})),(this.#t.viewport&&this.#t.viewport.overlays||this.#n.body).appendChild(f),this.#i=f}#p(){const u=this.#n,f=y(this.#a),{rows:h,columns:g,name:b,warnings:p}=this.#s;f.appendChild(O(u,"p",{class:`${t}__summary`,text:this.#f("import.summary",{count:h.length,name:b||this.#f("import.clipboard")})}));for(const S of p)f.appendChild(O(u,"p",{class:`${t}__warning`,text:S}));const m=this.#e.columns.all().map(S=>S.field||S.id).filter(Boolean),w=O(u,"table",{class:`${t}__map`}),v=O(u,"tr",{});for(const S of["import.colSource","import.colField","import.colType"])v.appendChild(O(u,"th",{text:this.#f(S)}));w.appendChild(v),g.forEach((S,E)=>{const A=O(u,"tr",{});A.appendChild(O(u,"td",{text:S.source}));const M=O(u,"select",{attrs:{"data-col":String(E),"aria-label":this.#f("import.mapLabel",{source:S.source})}});M.appendChild(O(u,"option",{text:this.#f("import.skip"),attrs:{value:""}}));for(const P of m)M.appendChild(O(u,"option",{text:P,attrs:{value:P,selected:P===S.field?!0:null}}));S.field&&!m.includes(S.field)&&M.appendChild(O(u,"option",{text:S.field,attrs:{value:S.field,selected:!0}}));const C=O(u,"td",{});C.appendChild(M),A.appendChild(C),A.appendChild(O(u,"td",{class:`${t}__type`,text:S.type})),w.appendChild(A)}),f.appendChild(w);const a=O(u,"div",{class:`${t}__mode`}),o=O(u,"select",{attrs:{"aria-label":this.#f("import.modeLabel"),"data-mode":"mode"}});o.appendChild(O(u,"option",{text:this.#f("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),o.appendChild(O(u,"option",{text:this.#f("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),a.appendChild(O(u,"label",{text:this.#f("import.modeLabel")})),a.appendChild(o),f.appendChild(a)}#g(){const{rows:u,columns:f}=this.#s;for(const m of this.#i.querySelectorAll("select[data-col]")){const w=Number(m.getAttribute("data-col"));f[w]&&m.value!==void 0&&m.value!==null&&(f[w].field=m.value)}const h=this.#i.querySelector("select[data-mode]"),g=h?h.value:void 0,b=g==="replace"||g==="append"?g:this.#r.mode,p=U(u,f);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.#s=null,this.#l&&R(this.#l.focus)&&this.#l.focus(),this.#l=null}destroy(){for(const u of this.#o)u();this.#o=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#a=null,this.#s=null}}}),ke("packages/dom/src/historybar.js",function(e,V){"use strict";Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return O}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/dom/src/editors/common.js"),Z=W.el,H=W.on,U=W.clear,z=W.documentFor,F="lat-history";class k{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(d,c){return(this.messages&&typeof this.messages.t=="function"?this.messages:L).t(d,c)}init(d){this.messages=d&&d.messages||d&&d.grid&&d.grid.messages||L;const c=d||{};if(this.doc=z(c),this.host=c.host||{},this.props=c.props||{},this.root=Z(this.doc,"div",{class:["lattice-tokens",F],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 r=Z(this.doc,"button",{class:`${F}__toggle`,text:"▾",attrs:{type:"button","aria-haspopup":"menu","aria-expanded":"false","aria-label":this.t("history.show")}});this.off.push(H(r,"click",()=>this.toggle())),this.root.appendChild(r),this.toggleButton=r,this.menu=Z(this.doc,"div",{class:`${F}__menu`,attrs:{role:"menu"}}),this.menu.style.display="none",this.root.appendChild(this.menu)}this.refresh()}#e(d,c,r){const t=Z(this.doc,"button",{class:`${F}__${d}`,attrs:{type:"button"},children:[Z(this.doc,"span",{class:`${F}__glyph`,text:r,attrs:{"aria-hidden":"true"}}),Z(this.doc,"span",{class:`${F}__label`,text:c})]});return this.off.push(H(t,"click",()=>{const n=this.host[d];R(n)&&n(),this.refresh()})),t}element(){return this.root}refresh(){if(!this.root)return;const d=this.host,c=R(d.canUndo)?d.canUndo():!1,r=R(d.canRedo)?d.canRedo():!1,t=R(d.peek)?d.peek("undo"):null,n=R(d.peek)?d.peek("redo"):null;this.#t(this.undoButton,"undo",c,t),this.#t(this.redoButton,"redo",r,n),this.open&&this.#n()}#t(d,c,r,t){if(!d)return;d.disabled=!r;const n=c==="undo",i=this.t(n?"history.undo":"history.redo"),s=d.querySelector(`.${F}__label`);s&&(s.textContent=i);const l=t&&t.label?this.t("history.described",{action:i,label:t.label}):i;d.setAttribute("title",r?l:this.t(n?"history.nothingToUndo":"history.nothingToRedo")),d.setAttribute("aria-label",r?l:this.t(n?"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 d=this.menu;if(!d)return;U(d);const c=R(this.host.list)?this.host.list():[];if(!c.length){d.appendChild(Z(this.doc,"p",{class:`${F}__empty`,text:this.t("history.empty")}));return}c.forEach((r,t)=>{const n=Z(this.doc,"button",{class:`${F}__item`,attrs:{type:"button",role:"menuitem","data-type":r.type,"data-undone":r.undone?"true":null},children:[Z(this.doc,"span",{class:`${F}__kind`,text:r.type}),Z(this.doc,"span",{class:`${F}__text`,text:r.label||r.type})]});this.off.push(H(n,"click",()=>{const i=t+1;for(let s=0;s<i;s++)R(this.host.undo)&&this.host.undo();this.toggle(),this.refresh()})),d.appendChild(n)})}destroy(){for(const d of this.off)d();this.off=[],this.root&&R(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const O=k}),ke("packages/dom/src/diffpaint.js",function(e,V){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"diffConfigured",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const _=V("packages/core/src/internal/util.js"),R=_.isFunction,$=_.warnOnce,W=V("packages/core/src/i18n/index.js").defaultMessages,Z={changed:"lat-row--changed",added:"lat-row--added",removed:"lat-row--removed"},H="lat-cell--changed",U="lat-cell--added-column";class z{#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 d=this.#e.diff,c=d&&d.enabled;for(const r of y.querySelectorAll("[data-key]")){const t=r.getAttribute("data-key"),n=c?d.statusOf(t):"unchanged";for(const s of Object.values(Z))r.classList.remove(s);c&&Z[n]&&r.classList.add(Z[n]),r.setAttribute("data-diff",c?n:"");const i=c&&n==="changed";for(const s of r.querySelectorAll("[data-col]")){const l=s.getAttribute("data-col");if(s.classList.remove(H,U),s.removeAttribute("data-before"),!i)continue;const u=d.cellStatus(t,l);if(u==="changed"){s.classList.add(H);const f=this.#r(d,t,l);f===null?s.removeAttribute("title"):(s.setAttribute("data-before",f),s.setAttribute("title",this.#o("diff.before",{value:f})))}else u==="added-column"&&s.classList.add(U)}}}#r(y,d,c){const r=this.#e,t=r&&r.columns,n=t&&R(t.get)?t.get(c):null,i=r&&r.permissions;if(n&&i&&R(i.isSecret)&&i.isSecret(n))return null;const s=y.before(d,c);if(s==null)return this.#o("diff.empty");if(!n||!R(n.formatValue))return String(s);const l=R(y.beforeRow)?y.beforeRow(d):void 0,f={...(r.rows&&R(r.rows.byKey)?r.rows.byKey(d):null)||{},data:l===void 0?{}:l};try{const h=n.formatValue(s,f,f.data);return h==null?"":String(h)}catch(h){return $(`diff-before-format:${c}`,`the formatter for column "${c}" threw while formatting a previous value, so the diff hover shows the raw one.`,h),String(s)}}#o(y,d){const c=this.#e;return(c&&c.messages?c.messages:W).t(y,d)}destroy(){for(const d of this.#n)d();this.#n=[];const y=this.#t.viewport.root;if(!(!y||!y.querySelectorAll)){for(const d of y.querySelectorAll("[data-key]")){for(const c of Object.values(Z))d.classList.remove(c);d.removeAttribute("data-diff")}for(const d of y.querySelectorAll("[data-col]"))d.classList.remove(H,U),d.removeAttribute("data-before")}}}function F(O){return!!(O&&O.diff&&(R(O.diff)||typeof O.diff=="object"))}const k=z}),ke("packages/dom/src/highlightpaint.js",function(e,V){"use strict";Object.defineProperty(e,"HighlightPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const R=V("packages/core/src/internal/util.js").isFunction,$="lat-cell--highlight",L="--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()};R(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(U):R(this.#i.setTimeout)?this.#i.setTimeout(U,0):U()}paint(){const U=this.#t.viewport?.root;if(!U||!U.querySelectorAll)return;const z=this.#s();if(z){z.sweep();for(const F of U.querySelectorAll("[data-key]")){const k=F.getAttribute("data-key");for(const O of F.querySelectorAll("[data-col]")){const y=z.active?z.colourFor(k,O.getAttribute("data-col")):null;y?(O.classList.add($),O.style.setProperty(L,y)):O.classList.contains($)&&(O.classList.remove($),O.style.removeProperty(L))}}this.#a(z)}}#a(U){this.#r!==null&&R(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const z=U.nextExpiry;if(!Number.isFinite(z)||!R(this.#i.setTimeout))return;const F=Math.max(0,z-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},F)}#s(){const U=this.#e.highlight;return U&&R(U.model)?U.model():null}destroy(){this.#r!==null&&R(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const z of this.#n)z();this.#n=[];const U=this.#t.viewport?.root;if(!(!U||!U.querySelectorAll))for(const z of U.querySelectorAll(`.${$}`))z.classList.remove($),z.style.removeProperty(L)}}const Z=W}),ke("packages/dom/src/findpaint.js",function(e,V){"use strict";Object.defineProperty(e,"MATCH_CLASS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"CURRENT_CLASS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"FindPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const R=V("packages/core/src/internal/util.js").isFunction,$="lat-cell--find",L="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()};R(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(U):R(this.#i.setTimeout)?this.#i.setTimeout(U,0):U()}paint(){const U=this.#t.viewport?.root;if(!U||!U.querySelectorAll)return;const z=this.#e.find;if(!z||!R(z.stateFor))return;const F=R(z.model)?z.model():null,k=!!F&&F.active;if(!k&&!this.#o)return;let O=!1;for(const y of U.querySelectorAll("[data-key]")){const d=y.getAttribute("data-key");for(const c of y.querySelectorAll("[data-col]")){const r=k?z.stateFor(d,c.getAttribute("data-col")):null;r?(O=!0,c.classList.add($),c.classList.toggle(L,r==="current")):c.classList.contains($)&&c.classList.remove($,L)}}this.#o=O}destroy(){for(const z of this.#n)z();this.#n=[];const U=this.#t.viewport?.root;if(!(!U||!U.querySelectorAll)){for(const z of U.querySelectorAll(`.${$}`))z.classList.remove($,L);this.#o=!1}}}const Z=W}),ke("packages/dom/src/findbar.js",function(e,V){"use strict";Object.defineProperty(e,"FIND_CLASS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"FindBar",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const _=V("packages/dom/src/editors/common.js"),R=_.el,$=_.on,W=V("packages/dom/src/renderer/textentry.js").isTextEntry,H=V("packages/core/src/i18n/index.js").defaultMessages,z=V("packages/core/src/internal/util.js").isFunction,F="lat-find",k=12,O=120;class y{#e;#t;#n;#r;#o;#i=null;#a=null;#s=null;#l=null;#u=null;#c=null;#d=null;#h=null;#f=!1;#m=!1;#p=null;#g=[];#v=null;#b=null;#y=!1;constructor(r){this.#e=r.grid,this.#t=r.renderer,this.#n=r.document||r.renderer.viewport?.document,this.#r=this.#n&&this.#n.defaultView||(typeof globalThis>"u"?{}:globalThis),this.#o=r.settings&&typeof r.settings=="object"?r.settings:{}}get open(){return!!this.#i&&this.#i.style.display!=="none"}get element(){return this.#i}t(r,t){const n=this.#e;return(n&&n.messages&&z(n.messages.t)?n.messages:H).t(r,t)}mount(){const r=this.#S();if(!r)return;r.attachUi({open:n=>this.show(n),close:()=>this.hide(),focus:()=>{this.#a&&this.#a.focus()}}),r.attachDriver({run:()=>this.#T()});const t=this.#t.viewport?.root;if(t&&z(t.addEventListener)&&this.#o.shortcut!==!1){const n=i=>{if(!(i.ctrlKey||i.metaKey)||i.altKey||i.shiftKey||i.key!=="f"&&i.key!=="F")return;const s=i.target;if(this.#a&&s===this.#a){i.preventDefault(),i.stopPropagation(),z(this.#a.select)&&this.#a.select();return}W(s)||(i.preventDefault(),i.stopPropagation(),this.show())};t.addEventListener("keydown",n,!0),this.#g.push(()=>t.removeEventListener("keydown",n,!0))}this.#g.push(this.#e.on("find:changed",()=>this.#R())),this.#g.push(this.#e.on("columns:changed",()=>this.#A())),this.#g.push(this.#e.on("column:visible",()=>this.#A()))}show(r){const t=this.#j();if(!t)return;const n=t.style.display!=="none";t.style.display="",n||this.#w(),this.#S().setOpen(!0),r!=null&&(this.#a.value=String(r),this.#C()),this.#a.focus(),z(this.#a.select)&&this.#a.select(),this.#R()}hide(){this.#_();const r=this.#S();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#w()),r&&(r.clear(),r.setOpen(!1));const t=this.#t.viewport?.root;if(!t||!(this.#i&&this.#n&&this.#n.activeElement&&z(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const s=(z(t.querySelector)?t.querySelector('[tabindex="0"]'):null)||t;z(s.focus)&&s.focus()}search(){this.#C()}destroy(){this.#y=!0,this.#_();for(const t of this.#g)t();this.#g=[];const r=this.#S();r&&(r.attachUi(null),r.attachDriver(null)),this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null}#w(){const r=this.#t;r&&z(r.invalidate)&&r.invalidate("size")}#S(){const r=this.#e&&this.#e.find;return r&&z(r.model)?r.model():null}#j(){if(this.#i)return this.#i;const r=this.#t.viewport,t=r?.root,n=this.#n;if(!t||!n||!z(t.insertBefore))return null;const i=R(n,"div",{class:F,attrs:{role:"search","aria-label":this.t("find.label")}});this.#a=R(n,"input",{class:`${F}__input`,attrs:{type:"text","aria-label":this.t("find.label"),placeholder:this.t("find.placeholder"),autocomplete:"off",spellcheck:"false"}}),this.#s=R(n,"span",{class:`${F}__count`,attrs:{"aria-hidden":"true"}}),this.#l=R(n,"span",{class:`${F}__scope`,attrs:{"aria-hidden":"true"}}),this.#l.style.display="none",this.#u=R(n,"span",{class:`${F}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const s=R(n,"button",{class:`${F}__nav ${F}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),l=R(n,"button",{class:`${F}__nav ${F}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=R(n,"button",{class:`${F}__toggle ${F}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=R(n,"button",{class:`${F}__toggle ${F}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#h=R(n,"select",{class:`${F}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const u=R(n,"button",{class:`${F}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),f=R(n,"div",{class:`${F}__options`,children:[this.#c,this.#d,this.#h]});for(const g of[this.#a,this.#s,this.#l,this.#u,s,l,u,f])i.appendChild(g);this.#g.push($(this.#a,"input",()=>this.#O())),this.#g.push($(s,"click",()=>this.#e.find.prev())),this.#g.push($(l,"click",()=>this.#e.find.next())),this.#g.push($(this.#c,"click",()=>{this.#f=!this.#f,this.#c.setAttribute("aria-pressed",String(this.#f)),this.#C()})),this.#g.push($(this.#d,"click",()=>{this.#m=!this.#m,this.#d.setAttribute("aria-pressed",String(this.#m)),this.#C()})),this.#g.push($(this.#h,"change",()=>{const g=this.#h.value;this.#p=g?String(g):null,this.#C()})),this.#g.push($(u,"click",()=>this.hide()));const h=g=>{if(g.key==="Escape"){g.preventDefault(),g.stopPropagation(),this.hide();return}g.key==="Enter"&&g.target===this.#a&&(g.preventDefault(),g.stopPropagation(),this.#v!==null&&(this.#N(),this.#C()),g.shiftKey?this.#e.find.prev():this.#e.find.next())};return i.addEventListener("keydown",h),this.#g.push(()=>i.removeEventListener("keydown",h)),i.style.display="none",t.insertBefore(i,r.header||t.firstChild),this.#i=i,this.#A(),i}#A(){const r=this.#h;if(!r)return;const t=this.#n;for(;r.firstChild;)r.removeChild(r.firstChild);r.appendChild(R(t,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const n=this.#e.columns,i=n&&z(n.visible)?n.visible():[];let s=!1;for(const l of i){if(!l||l.id===void 0)continue;const u=String(l.id);r.appendChild(R(t,"option",{text:l.title||u,attrs:{value:u}})),u===this.#p&&(s=!0)}s||(this.#p=null),r.value=this.#p||""}#O(){const r=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):O;if(this.#N(),r===0||!z(this.#r.setTimeout)){this.#C();return}this.#v=this.#r.setTimeout(()=>{this.#v=null,this.#C()},r)}#C(){const r=this.#S();if(!r||this.#y)return;const t=this.#a?this.#a.value:"";if(!t){this.#M(),r.clear();return}r.begin(t,{caseSensitive:this.#f,wholeCell:this.#m,columns:this.#p?[this.#p]:null,from:this.#E()}),this.#T()}#E(){const r=this.#t&&this.#t.window,t=r&&Number.isFinite(r.first)?r.first:0;return Math.max(0,t)}#T(){if(this.#b!==null||this.#y)return;const r=()=>{this.#b=null,this.#x()};z(this.#r.requestAnimationFrame)?this.#b=this.#r.requestAnimationFrame(r):z(this.#r.setTimeout)?this.#b=this.#r.setTimeout(r,0):r()}#x(){const r=this.#S();!r||this.#y||!r.active||(r.stale&&r.rescan({from:this.#E()}),!r.complete&&(r.step(k)||this.#T()))}#R(){if(!this.#i||this.#y)return;const r=this.#e.find.count(),t=this.#S().active;let n="",i="idle";t&&(r.total===0?(n=r.complete?this.t("find.none"):this.t("find.searching"),i=r.complete?"none":"searching"):(n=this.t(r.complete?"find.count":"find.countPartial",{current:r.current,total:r.total}),i=r.complete?"matches":"searching")),this.#s.textContent=n,this.#i.setAttribute("data-state",i);const s=t&&r.windowed;this.#l.textContent=s?this.t("find.loadedRows"):"",this.#l.style.display=s?"":"none",t?r.complete&&(this.#u.textContent=r.total===0?this.t(s?"a11y.find.noneLoaded":"a11y.find.none"):this.t(s?"a11y.find.countLoaded":"a11y.find.count",{current:r.current,count:r.total})):this.#u.textContent=""}#N(){this.#v!==null&&z(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#v),this.#v=null}#M(){this.#b!==null&&(z(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#b):z(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#b),this.#b=null)}#_(){this.#N(),this.#M()}}const d=y}),ke("packages/dom/src/redactpaint.js",function(e,V){"use strict";Object.defineProperty(e,"RedactionPainter",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return L}});const _="lat-cell--redacted",R="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 H=this.#e.redaction;if(!H)return;const U=H.active;for(const z of Z.querySelectorAll(`.${R}[data-col]`))U&&H.has(z.getAttribute("data-col"))?z.classList.add(_):z.classList.contains(_)&&z.classList.remove(_)}destroy(){for(const Z of this.#n)Z();this.#n=[]}}const L=$}),ke("packages/dom/src/validationpaint.js",function(e,V){"use strict";Object.defineProperty(e,"ValidationPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const R=V("packages/dom/src/editors/common.js").markInvalid,$="lat-cell";function L(H,U){let z=H;for(;z;){if(U(z))return z;z=z.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 z=L(U,F=>F.getAttribute&&F.getAttribute("data-key")!==null);return z?z.getAttribute("data-key"):null}paint(){const U=this.#e.validation;if(!U||!U.active)return;const z=this.#t.viewport?.root;if(!(!z||!z.querySelectorAll))for(const F of z.querySelectorAll(`.${$}[data-col]`)){const k=F.getAttribute("data-col"),O=this.#r(F),y=O?U.errorFor(O,k):null;R(F,y?y.message:null)}}destroy(){for(const U of this.#n)U();this.#n=[]}}const Z=W}),ke("packages/dom/src/presentation.js",function(e,V){"use strict";Object.defineProperty(e,"CHROME",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"PresentationController",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/dom/src/renderer/textentry.js").isTextEntry,Z=V("packages/dom/src/renderer/viewport.js").CLASS,H="lat-presenting",U="lat-presenting--changing",z="lat-presenting__progress",F="lat-cell--dimmed",k=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class O{#e;#t;#n;#r=[];#o=null;#i=null;#a=null;constructor(c){this.#e=c.grid,this.#t=c.renderer,this.#n=c.maximiser||null}mount(){this.#r.push(this.#e.on("presentation:started",()=>this.#d())),this.#r.push(this.#e.on("presentation:changed",()=>this.#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",r=>this.#l(r))),this.#r.push(this.#e.on("presentation:spotlight",()=>this.#m())),this.#r.push(this.#e.on("render:done",()=>this.#m())),this.#n&&R(this.#n.watch)&&this.#r.push(this.#n.watch(r=>{r||!this.#o||this.#o.maximised||this.#e.presentation?.active&&this.#e.presentation.stop()}));const c=this.#t.viewport?.root;if(c&&R(c.addEventListener)){const r=t=>this.#s(t);c.addEventListener("keydown",r),this.#r.push(()=>c.removeEventListener("keydown",r))}}#s(c){const r=this.#e.presentation;if(!r?.active)return;const t=c.ctrlKey||c.metaKey,n=c.key;if(n==="Escape"&&!this.#n){c.defaultPrevented||(r.stop(),c.preventDefault?.());return}if(t){n==="="||n==="+"?(r.nudge(1),c.preventDefault?.()):n==="-"||n==="_"?(r.nudge(-1),c.preventDefault?.()):n==="0"&&(r.setScale(1.5),c.preventDefault?.());return}if(!r.views.length||L(c.target))return;n==="ArrowRight"||n==="ArrowDown"||n==="PageDown"||n===" "?(r.step(1),c.preventDefault?.()):n==="ArrowLeft"||n==="ArrowUp"||n==="PageUp"?(r.step(-1),c.preventDefault?.()):n==="Home"?(r.goTo(0),c.preventDefault?.()):n==="End"?(r.goTo(r.views.length-1),c.preventDefault?.()):(n==="r"||n==="R")&&(r.reset(),c.preventDefault?.())}#l(c){!c||!c.viewId||(this.#u(),this.#e.views?.apply?.(c.viewId),this.#c(c))}#u(){const c=this.#t.viewport?.root;c?.classList&&(c.classList.remove(U),c.offsetWidth,c.classList.add(U))}#c(c){const r=this.#t.viewport?.overlays;if(!r||!this.#e.presentation.views.length)return;const t=r.ownerDocument;if(!t?.createElement)return;if(!this.#i){const s=t.createElement("div");s.className=z,s.setAttribute("role","status"),s.setAttribute("aria-live","polite"),r.appendChild(s),this.#i=s}const n=this.#e.views?.get?.(c.viewId),i=n&&n.name?n.name:"";this.#i.textContent=i?`${i} · ${(c.index||0)+1} / ${c.count||0}`:`${(c.index||0)+1} / ${c.count||0}`}#d(){if(this.#o){this.#f();return}const c=!!(this.#n&&this.#n.active());this.#n&&!c&&this.#n.enter();const r=new Set(this.#e.presentation?.options?.chrome||[]),t=[];for(const i of k){if(r.has(i)||i==="toolPanel"&&this.#y())continue;const s=this.#w(i);s&&s.style&&s.style.display!=="none"&&(s.style.display="none",t.push(s))}const n=this.#v();n&&n.style&&n.style.display!=="none"&&this.#b(n)&&(n.style.display="none",t.push(n)),this.#o={maximised:c,hidden:t},this.#t.viewport?.root?.classList?.add(H),this.#f(),this.#p()}#h(){const c=this.#o;this.#o=null;const r=this.#t.viewport?.root;if(r?.classList?.remove(H),r?.style?.removeProperty("--lattice-presentation-scale"),this.#g(),this.#i&&(this.#i.remove?.(),this.#i=null),r?.classList?.remove(U),this.#m(),c){const t=this.#e.toolPanel;t&&R(t.presentRestore)&&t.presentRestore();for(const n of c.hidden)n.style.display="";this.#n&&!c.maximised&&this.#n.active()&&this.#n.exit()}this.#t.invalidate?.("theme")}#f(){const c=this.#t.viewport?.root;!c||!c.style||(c.style.setProperty("--lattice-presentation-scale",String(this.#e.presentation.scale)),this.#t.invalidate?.("theme"))}#m(){const c=this.#t.viewport?.root;if(!c?.querySelectorAll)return;const r=this.#e.presentation?.active?this.#e.presentation.spotlight:null,t=r&&r.keys.length?new Set(r.keys):null,n=r&&r.colIds.length?new Set(r.colIds):null;for(const i of c.querySelectorAll("[data-key]")){const s=!t||t.has(i.getAttribute("data-key"));for(const l of i.querySelectorAll("[data-col]"))!r||s&&(!n||n.has(l.getAttribute("data-col")))?l.classList.remove(F):l.classList.add(F)}}#p(){this.#g();const c=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(c)||c<=0||!this.#e.presentation.views.length)return;const r=this.#t.viewport?.root?.ownerDocument?.defaultView;r?.setInterval&&(this.#a=r.setInterval(()=>{const t=this.#e.presentation;t.active&&t.goTo(t.index>=t.views.length-1?0:t.index+1)},Math.max(1e3,c)))}#g(){if(this.#a===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#a),this.#a=null}#v(){const c=this.#e.element;return!c||!R(c.querySelector)?null:c.querySelector(`.${Z.statusBar}`)}#b(c){const r=c.children||[];for(const t of r)if(!t.style||t.style.display!=="none")return!1;return!0}#y(){const c=this.#e.toolPanel;return!!(c&&R(c.presentOnly)&&c.presentOnly())}#w(c){const r=this.#e.element;if(!r||!R(r.querySelector))return null;const t={toolPanel:".lat-panel-dock",statusBar:".lat-statusbar",editBar:".lat-editor-bar",historyBar:".lat-history",pagination:".lat-pagination"}[c];return t?r.querySelector(t):null}destroy(){this.#o&&this.#h();for(const c of this.#r)c();this.#r=[]}}const y=O}),ke("packages/dom/src/capture.js",function(e,V){"use strict";Object.defineProperty(e,"isSafeImageSource",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"captureElement",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const R=V("packages/core/src/internal/util.js").isFunction,$=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function L(z,F,k){const O=k.getComputedStyle(z),y=F.style;if(y)for(let d=0;d<O.length;d++){const c=O[d];$.has(c)||y.setProperty(c,O.getPropertyValue(c),O.getPropertyPriority(c))}}function W(z,F,k){if(L(z,F,k),z.tagName==="CANVAS"&&R(z.toDataURL))try{const d=z.toDataURL("image/png"),c=F.style;c&&(c.setProperty("background-image",`url(${d})`),c.setProperty("background-size","100% 100%"),c.setProperty("background-repeat","no-repeat"))}catch{}const O=z.children||[],y=F.children||[];for(let d=0;d<O.length&&d<y.length;d++)W(O[d],y[d],k)}function Z(z,F){if(!z||z.startsWith("data:")||z.startsWith("blob:"))return!0;try{return new URL(z,F).origin===F}catch{return!0}}async function H(z,F={}){const k=z.ownerDocument,O=k?.defaultView;if(!O||typeof O.getComputedStyle!="function")throw new Error("capture needs a browser document");const y=z.getBoundingClientRect(),d=Math.max(1,Math.ceil(y.width)),c=Math.max(1,Math.ceil(y.height)),r=Math.max(.1,Number(F.scale)||2),t=O.location?.origin||"";for(const h of z.querySelectorAll("img")){const g=h.getAttribute("src")||"";if(!Z(g,t))throw new Error(`capture refused: the image at ${g} is on another origin and would taint the canvas. Serve it same-origin, inline it as a data: URL, or hide the column.`)}const n=z.cloneNode(!0);W(z,n,O),n.style.width=`${d}px`,n.style.height=`${c}px`,n.style.margin="0";const i=new O.XMLSerializer().serializeToString(n),s=`<svg xmlns="http://www.w3.org/2000/svg" width="${d}" height="${c}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${i}</div></foreignObject></svg>`,l=new O.Image;await new Promise((h,g)=>{l.onload=()=>h(void 0),l.onerror=()=>g(new Error("capture failed to rasterise the grid; a host element inside it may not serialise as XML")),l.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(s)}`});const u=k.createElement("canvas");u.width=Math.round(d*r),u.height=Math.round(c*r);const f=u.getContext("2d");if(!f)throw new Error("capture could not get a 2d context");return f.fillStyle=F.background||O.getComputedStyle(z).backgroundColor||"#ffffff",f.fillRect(0,0,u.width,u.height),f.drawImage(l,0,0,u.width,u.height),new Promise((h,g)=>{u.toBlob(b=>b?h({blob:b,width:u.width,height:u.height}):g(new Error("capture produced no image")),F.type||"image/png",F.quality)})}const U=H}),ke("packages/dom/src/annotate.js",function(e,V){"use strict";Object.defineProperty(e,"TOOLS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"MARK_TYPES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const _=V("packages/core/src/internal/util.js"),R=_.isFunction,$=_.warnOnce,W=V("packages/dom/src/renderer/direction.js").signedX,Z=Object.freeze(["pen","arrow","rect","highlight"]),H=Object.freeze(["freehand","arrow","rect","highlight","text"]),U=Object.freeze({freehand:"pen",pen:"pen",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),z=Object.freeze({pen:"freehand",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),F=14,k="system-ui, -apple-system, sans-serif";function O(s,l){if(!s||typeof s!="object")return null;const u=U[s.type];if(!u)return null;const f=Array.isArray(s.points)?s.points:[],h=[];for(const b of f){const p=Number(b&&b.x),m=Number(b&&b.y);Number.isFinite(p)&&Number.isFinite(m)&&h.push({x:p,y:m})}const g=typeof s.colour=="string"&&s.colour?s.colour:l;if(u==="text"){const b=typeof s.text=="string"?s.text:"";if(!h.length||!b)return null;const p={tool:u,colour:g,points:[h[0]],text:b,region:y(s.region)},m=Number(s.fontSize);return Number.isFinite(m)&&m>0&&(p.fontSize=m),typeof s.background=="string"&&s.background&&(p.background=s.background),p}return h.length<2?null:{tool:u,colour:g,points:h,region:y(s.region)}}function y(s){return s==="start"||s==="end"?s:"centre"}function d(s){const l={type:z[s.tool]||s.tool,colour:s.colour,points:s.points.map(u=>({x:u.x,y:u.y}))};return(s.region==="start"||s.region==="end")&&(l.region=s.region),s.tool==="text"&&(l.text=s.text,s.fontSize!==void 0&&(l.fontSize=s.fontSize),s.background!==void 0&&(l.background=s.background)),l}const c="lat-annotate",r=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(s){return s==="arrow"||s==="rect"}class n{#e;#t;#n=null;#r=null;#o=null;#i="#e0245e";#a=[];#s=null;#l=[];#u=null;constructor(l){this.#e=l.grid,this.#t=l.renderer,this.#u=Array.isArray(l.seed)?l.seed:null}get tool(){return this.#o}get count(){return this.#a.length}mount(){this.#l.push(this.#e.on("scroll",()=>this.redraw())),this.#l.push(this.#e.on("render:done",()=>this.redraw())),this.#l.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(l){const u=O(l,this.#i);return u?(u.durable=!0,this.#a.push(u),this.#w(),this.redraw(),this.#A(),this.#a.length):($("annotate.add.invalid",`annotate.add ignored a mark: it needs a known \`type\` (${H.join(", ")}) and at least two finite {x, y} points in content coordinates.`),this.#a.length)}list(){return this.#a.map(d)}replaceAll(l){const u=Array.isArray(l)?l:[];this.#a=u.map(f=>O(f,this.#i)).filter(Boolean);for(const f of this.#a)f.durable=!0;this.#a.length&&this.#w(),this.redraw(),this.#A()}#c(){const l=this.#t.viewport?.root;if(!l||!R(l.addEventListener))return;const u=f=>{!this.#o||!f||f.key!=="Escape"||(this.use(null),f.preventDefault?.())};l.addEventListener("keydown",u,!0),this.#l.push(()=>l.removeEventListener("keydown",u,!0))}#d(){const l=this.#n?.ownerDocument?.defaultView||this.#t.viewport?.root?.ownerDocument?.defaultView;if(!l||!R(l.matchMedia))return;let u=null;const f=()=>{const h=l.devicePixelRatio||1;let g;try{g=l.matchMedia(`(resolution: ${h}dppx)`)}catch{return}u=g;const b=()=>{this.redraw(),f()};R(g.addEventListener)?g.addEventListener("change",b,{once:!0}):R(g.addListener)&&g.addListener(b)};f(),this.#l.push(()=>{u=null})}use(l,u={}){const f=!!u.colour&&l===this.#o;u.colour&&(this.#i=String(u.colour));const h=l&&Z.includes(l)?l:null;this.#o=h&&h===this.#o&&!f?null:h;const g=this.#o?this.#w():this.#n;return g&&(g.style.pointerEvents=this.#o?"auto":"none",g.style.cursor=this.#o?"crosshair":""),this.#A(),this.#o}undo(){return this.#a.pop(),this.redraw(),this.#A(),this.#a.length}clear(){this.#a.length&&(this.#a=[],this.redraw(),this.#A())}#h(){const l=this.#a.filter(u=>u.durable);l.length!==this.#a.length&&(this.#a=l,this.redraw(),this.#A())}redraw(){!this.#n&&this.#a.length&&this.#w();const l=this.#n,u=this.#r;if(!l||!u)return;this.#S();const{left:f,top:h}=this.#y();u.clearRect(0,0,l.width,l.height);const g=this.#s?[...this.#a,this.#s]:this.#a;for(const b of["centre","start","end"]){const p=g.filter(m=>y(m.region)===b);if(p.length){u.save(),this.#f(u,b),u.translate((b==="centre"?-f:0)||0,-h||0);for(const m of p)this.#v(u,m);u.restore()}}}#f(l,u="centre"){const f=this.#n,h=this.#t.viewport?.bodyViewport;if(!R(f?.getBoundingClientRect)||!R(h?.getBoundingClientRect))return;const g=f.getBoundingClientRect(),b=h.getBoundingClientRect();if(!b.width||!b.height)return;const p=this.#m(u,b);p&&(l.beginPath(),l.rect(p.left-g.left,b.top-g.top,p.width,b.height),l.clip())}#m(l,u){const f=w=>{if(!R(w?.getBoundingClientRect))return null;const v=w.getBoundingClientRect();return v&&v.width>0?{left:v.left,width:v.width}:null},h=f(this.#t.viewport?.bodyStart),g=f(this.#t.viewport?.bodyEnd);if(l==="start")return h;if(l==="end")return g;let b=u.left,p=u.left+u.width;const m=u.left+u.width/2;for(const w of[h,g]){if(!w)continue;const v=w.left+w.width;w.left+w.width/2<m?b=Math.max(b,v):p=Math.min(p,w.left)}return p>b?{left:b,width:p-b}:null}#p(l){for(const[u,f]of[["start",this.#t.viewport?.bodyStart],["end",this.#t.viewport?.bodyEnd]]){if(!R(f?.getBoundingClientRect))continue;const h=f.getBoundingClientRect();if(h&&h.width>0&&l>=h.left&&l<h.left+h.width)return u}return"centre"}#g(l){const u=this.#t.viewport?.bodyViewport;if(!R(u?.getBoundingClientRect))return!0;const f=u.getBoundingClientRect();return!f.width||!f.height?!0:l.clientX>=f.left&&l.clientX<=f.right&&l.clientY>=f.top&&l.clientY<=f.bottom}#v(l,u){const f=u.points;if(!f.length)return;const h=this.#e.presentation?.scale||1;l.lineWidth=(r[u.tool]||3)*h,l.strokeStyle=u.colour,l.fillStyle=u.colour,l.lineCap="round",l.lineJoin="round",l.globalAlpha=u.tool==="highlight"?.32:1;const g=f[0],b=f[f.length-1];if(u.tool==="text"){const p=(u.fontSize||F)*h;l.font=`${p}px ${k}`,l.textBaseline="top";const m=u.text||"";if(u.background){let w=m.length*p*.6;if(typeof l.measureText=="function"){const v=l.measureText(m);v&&Number.isFinite(v.width)&&(w=v.width)}l.fillStyle=u.background,l.fillRect(g.x-p*.15,g.y-p*.1,w+p*.3,p*1.2)}l.fillStyle=u.colour,l.fillText(m,g.x,g.y),l.globalAlpha=1;return}if(u.tool==="rect")l.strokeRect(g.x,g.y,b.x-g.x,b.y-g.y);else if(u.tool==="arrow")l.beginPath(),l.moveTo(g.x,g.y),l.lineTo(b.x,b.y),l.stroke(),this.#b(l,g,b,l.lineWidth);else{l.beginPath(),l.moveTo(g.x,g.y);for(let p=1;p<f.length;p++)l.lineTo(f[p].x,f[p].y);l.stroke()}l.globalAlpha=1}#b(l,u,f,h){const g=Math.atan2(f.y-u.y,f.x-u.x),b=Math.max(8,h*3);l.beginPath(),l.moveTo(f.x,f.y),l.lineTo(f.x-b*Math.cos(g-Math.PI/7),f.y-b*Math.sin(g-Math.PI/7)),l.lineTo(f.x-b*Math.cos(g+Math.PI/7),f.y-b*Math.sin(g+Math.PI/7)),l.closePath(),l.fill()}#y(){const l=R(this.#t.scrollPosition)?this.#t.scrollPosition():null,u=this.#t.viewport?.rtl===!0;return{left:W(l?.left||0,u),top:l?.top||0}}#w(){if(this.#n)return this.#n;const l=this.#t.viewport?.overlays,u=l?.ownerDocument;if(!l||!u?.createElement)return null;const f=u.createElement("canvas");return f.className=c,f.style.position="absolute",f.style.inset="0",f.style.pointerEvents="none",l.appendChild(f),this.#n=f,this.#r=f.getContext?f.getContext("2d"):null,this.#S(),this.#j(f),f}#S(){const l=this.#n,u=this.#t.viewport?.root;if(!l||!u?.getBoundingClientRect)return;const f=u.getBoundingClientRect(),g=l.ownerDocument?.defaultView?.devicePixelRatio||1,b=Math.max(1,Math.round(f.width*g)),p=Math.max(1,Math.round(f.height*g));l.width===b&&l.height===p||(l.width=b,l.height=p,l.style&&(l.style.width=`${Math.max(1,f.width)}px`,l.style.height=`${Math.max(1,f.height)}px`),this.#r?.setTransform(g,0,0,g,0,0))}#j(l){const u=(p,m="centre")=>{const w=l.getBoundingClientRect(),{left:v,top:a}=this.#y();return{x:p.clientX-w.left+(m==="centre"?v:0),y:p.clientY-w.top+a}},f=p=>{if(!this.#o||!this.#g(p))return;const m=this.#p(p.clientX);this.#s={tool:this.#o,colour:this.#i,points:[u(p,m)],region:m},l.setPointerCapture?.(p.pointerId),p.preventDefault?.()},h=p=>{if(!this.#s)return;const m=u(p,this.#s.region);t(this.#s.tool)&&this.#s.points.length>1&&this.#s.points.pop(),this.#s.points.push(m),this.redraw()},g=p=>{this.#s&&(this.#s.points.length>1&&this.#a.push(this.#s),this.#s=null,l.releasePointerCapture?.(p.pointerId),this.redraw(),this.#A())},b=p=>{if(!this.#o)return;const m=this.#t.viewport?.bodyViewport;if(!m)return;let w=!1;p.deltaY&&typeof m.scrollTop=="number"&&(m.scrollTop+=p.deltaY,w=!0),p.deltaX&&typeof m.scrollLeft=="number"&&(m.scrollLeft+=p.deltaX,w=!0),w&&p.preventDefault?.()};l.addEventListener("pointerdown",f),l.addEventListener("pointermove",h),l.addEventListener("pointerup",g),l.addEventListener("pointercancel",g),l.addEventListener("wheel",b,{passive:!1}),this.#l.push(()=>{l.removeEventListener("pointerdown",f),l.removeEventListener("pointermove",h),l.removeEventListener("pointerup",g),l.removeEventListener("pointercancel",g),l.removeEventListener("wheel",b)})}#A(){this.#e.emit?.("annotation:changed",{tool:this.#o,count:this.#a.length},"user")}destroy(){for(const l of this.#l)l();this.#l=[],this.#n?.remove?.(),this.#n=null,this.#r=null,this.#a=[]}}const i=n}),ke("packages/dom/src/timelinebar.js",function(e,V){"use strict";Object.defineProperty(e,"agoLabel",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"clockLabel",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"TimelineBar",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return z}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,W="lat-timeline";function Z(F){if(!Number.isFinite(F)||F<1e3)return"now";const k=Math.round(F/1e3);if(k<60)return`${k}s ago`;const O=Math.round(k/60);return O<60?`${O}m ago`:`${Math.round(O/60)}h ago`}function H(F,k){return Number.isFinite(F)?new Date(F).toLocaleTimeString(k||void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}class U{#e;#t;#n=null;#r=null;#o=null;#i=null;#a=[];constructor(k){this.#e=k.grid,this.#t=k.renderer}mount(){this.#a.push(this.#e.on("timeline:attached",()=>{this.#l(),this.refresh()})),this.#a.push(this.#e.on("timeline:detached",()=>this.#u())),this.#a.push(this.#e.on("timeline:seek",()=>this.refresh())),this.#a.push(this.#e.on("rows:changed",()=>this.refresh()))}refresh(){if(!this.#n||!this.#e.timeline.attached)return;const k=this.#e.timeline,O=k.depth,y=k.position;this.#r.max=String(Math.max(1,O)),this.#r.value=String(Math.max(0,O-y)),this.#r.disabled=O===0;const d=k.at(),c=k.live;this.#o&&(this.#o.textContent=c?this.#s("timeline.live"):Z(Date.now()-(d||Date.now())),this.#o.setAttribute("data-live",c?"true":"false")),this.#i&&(this.#i.textContent=O===0?this.#s("timeline.recording"):H(d,this.#e.get("locale"))),this.#n.setAttribute("data-live",c?"true":"false")}#s(k,O){const y=this.#e;return(y&&y.messages?y.messages:L).t(k,O)}#l(){if(this.#n)return;const k=this.#t.viewport?.overlays,O=k?.ownerDocument;if(!k||!O?.createElement)return;const y=O.createElement("div");y.className=W;const d=O.createElement("span");d.className=`${W}__ago`,d.setAttribute("role","status"),d.setAttribute("aria-live","polite");const c=O.createElement("input");c.className=`${W}__range`,c.type="range",c.min="0",c.step="1",c.setAttribute("aria-label",this.#s("timeline.scrub"));const r=O.createElement("span");r.className=`${W}__clock`;const t=O.createElement("button");t.className=`${W}__live`,t.type="button",t.textContent=this.#s("timeline.goLive"),t.setAttribute("aria-label",this.#s("timeline.returnToPresent")),y.appendChild(d),y.appendChild(c),y.appendChild(r),y.appendChild(t),k.appendChild(y),this.#n=y,this.#r=c,this.#o=d,this.#i=r;const n=()=>{const l=this.#e.timeline.depth;this.#e.timeline.seek(l-Number(c.value))};c.addEventListener("input",n);const i=()=>this.#e.timeline.toLive();t.addEventListener("click",i);const s=l=>l.stopPropagation();c.addEventListener("keydown",s),this.#a.push(()=>{c.removeEventListener("input",n),t.removeEventListener("click",i),c.removeEventListener("keydown",s)})}#u(){this.#n&&(R(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null,this.#i=null)}destroy(){for(const k of this.#a)k();this.#a=[],this.#u()}}const z=U}),ke("packages/dom/src/commentpaint.js",function(e,V){"use strict";Object.defineProperty(e,"CommentPainter",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,Z=V("packages/dom/src/renderer/direction.js").isRtlElement,H="lat-comment-mark",U="lat-cell--commented",z="lat-cell--commented-open";class F{#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.#a(),this.paint()}paint(){const y=this.#e.comments;if(!y||!y.enabled)return;const d=this.#t.viewport?.root;if(!d||!d.querySelectorAll)return;const c=[];for(const r of d.querySelectorAll("[data-key]")){const t=r.getAttribute("data-key");if(t){c.push(t);for(const n of r.querySelectorAll("[data-col]")){const i=n.getAttribute("data-col"),s=y.at(t,i),l=!!(s&&s.count);n.classList.toggle(U,l),n.classList.toggle(z,l&&s.unresolved>0),this.#i(n,s,i)}}}(c.length!==this.#r.length||c.some((r,t)=>r!==this.#r[t]))&&(this.#r=c,y.request(c))}#o(y,d){const c=this.#e;return(c&&c.messages?c.messages:L).t(y,d)}#i(y,d,c){if(!d||!d.count){y.hasAttribute("aria-description")&&y.removeAttribute("aria-description");return}const r=d.count,t=d.unresolved,n=this.#o("count.comments",{count:r});y.setAttribute("aria-description",t>0?this.#o("comments.someUnresolved",{comments:n,unresolved:t}):this.#o("comments.allResolved",{comments:n}))}#a(){const y=this.#t.viewport?.root;if(!y||!R(y.addEventListener))return;const d=r=>{const t=this.#e.comments;if(!t||!t.enabled)return;const n=r.target&&R(r.target.closest)?r.target.closest("[data-col]"):null;if(!n||!n.classList.contains(U)||!this.#s(n,r))return;const i=n.closest("[data-key]"),s=i&&i.getAttribute("data-key");s&&(r.stopPropagation(),r.preventDefault(),t.open(s,n.getAttribute("data-col")))},c=r=>{const t=this.#e.comments;if(!t||!t.enabled||!r.altKey||r.key!=="m"&&r.key!=="M")return;const n=this.#t.viewport?.root?.querySelector?.("[data-col].lat-cell--focus")||(typeof document<"u"&&document.activeElement&&R(document.activeElement.closest)?document.activeElement.closest("[data-col]"):null);if(!n)return;const i=n.closest("[data-key]"),s=i&&i.getAttribute("data-key");s&&(r.preventDefault(),r.stopPropagation(),t.open(s,n.getAttribute("data-col")))};y.addEventListener("click",d,!0),y.addEventListener("keydown",c,!0),this.#n.push(()=>{y.removeEventListener("click",d,!0),y.removeEventListener("keydown",c,!0)})}#s(y,d){if(!R(y.getBoundingClientRect))return!1;const c=y.getBoundingClientRect(),r=Math.max(14,Math.min(24,c.height*.6));return(Z(y)?d.clientX<=c.left+r:d.clientX>=c.right-r)&&d.clientY<=c.top+r}destroy(){for(const y of this.#n)y();this.#n=[]}}const k=F}),ke("packages/dom/src/presencepaint.js",function(e,V){"use strict";Object.defineProperty(e,"PresencePainter",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,Z=V("packages/dom/src/editors/common.js").cssEscape,U=V("packages/core/src/model/presence.js").CURSOR_LABEL_MS,z="lat-presence";class F{#e;#t;#n=null;#r=null;#o=new Set;#i=[];#a=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 d of["presence:joined","presence:left","presence:updated"])this.#i.push(this.#e.on(d,c=>this.#s(d,c)));this.#l(),this.paint()}}#s(y,d){if(this.#h(),y==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const r=d&&d.peer;r&&(this.#r.textContent=this.#f(y==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:r.name}))}#l(){const y=this.#t.viewport?.overlays,d=y?.ownerDocument;if(!y||!d?.createElement)return;const c=this.#e.get("presence")||{},r=d.createElement("span");if(r.className=`${z}__live`,r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),y.appendChild(r),this.#r=r,c.roster===!1)return;const t=d.createElement("div");t.className=z,c.roster&&c.roster.side==="start"&&t.setAttribute("data-side","start"),t.style.pointerEvents="auto",y.appendChild(t),this.#n=t}paint(){const y=this.#e.presence,d=this.#t.viewport?.root;if(!y||!y.enabled||!d?.querySelectorAll)return;this.#d(d);const c=y.peers(),r=[...c].sort((t,n)=>t.at-n.at);for(const t of r)for(const n of t.ranges||[])for(const i of n.rowIds||[])for(const s of n.columns||[])this.#c(d,i,s,t,"range");for(const t of r)t.cursor&&this.#c(d,t.cursor.rowId,t.cursor.colId,t,"cursor");for(const t of r)t.editing&&this.#c(d,t.editing.rowId,t.editing.colId,t,"edit");this.#h(),this.#u(c)}#u(y){if(this.#a!==null)return;const d=y.filter(t=>t.cursorFresh);if(!d.length)return;const r=Math.max(...d.map(t=>t.cursorAt||0))+U-Date.now();this.#a=setTimeout(()=>{this.#a=null,this.paint()},Math.max(50,r))}#c(y,d,c,r,t){const n=y.querySelector(`[data-key="${Z(d)}"]`),i=n&&n.querySelector(`[data-col="${Z(c)}"]`);i&&(i.setAttribute("data-presence",t),i.style.setProperty("--lat-peer",r.colour),i.setAttribute("data-peer-name",r.name),i.setAttribute("data-peer-initial",r.initials||(r.name||"?").slice(0,1).toUpperCase()),r.idle?i.setAttribute("data-peer-idle","true"):i.removeAttribute("data-peer-idle"),t==="cursor"&&r.cursorFresh&&i.setAttribute("data-peer-fresh","true"),this.#o.add(`${d}${c}`))}#d(y){if(this.#o.size){for(const d of y.querySelectorAll("[data-presence]"))d.removeAttribute("data-presence"),d.removeAttribute("data-peer-name"),d.removeAttribute("data-peer-initial"),d.removeAttribute("data-peer-fresh"),d.removeAttribute("data-peer-idle"),d.style.removeProperty("--lat-peer");this.#o.clear()}}#h(){if(!this.#n)return;const y=this.#n.ownerDocument,d=this.#e.presence.peers();if(this.#n.textContent="",!d.length){this.#n.toggleAttribute("data-empty",!0);return}this.#n.removeAttribute("data-empty");for(const r of d){const t=y.createElement("button");t.className=`${z}__peer`,t.type="button",t.style.setProperty("--lat-peer",r.colour),t.toggleAttribute("data-idle",!!r.idle),t.toggleAttribute("data-hidden",!!r.hidden);let n="presence.peer";r.hidden?n="presence.peerHidden":r.idle&&(n="presence.peerIdle"),t.setAttribute("aria-label",this.#f(n,{name:r.name}));const i=y.createElement("span");i.className=`${z}__dot`,i.setAttribute("aria-hidden","true"),i.textContent=r.initials||(r.name||"?").slice(0,1).toUpperCase(),t.appendChild(i);const s=y.createElement("span");s.className=`${z}__name`,s.textContent=r.name,t.appendChild(s),t.addEventListener("click",()=>this.#e.presence.jumpTo(r.id)),this.#n.appendChild(t)}const c=d.filter(r=>r.hidden).length;if(c){const r=y.createElement("span");r.className=`${z}__hidden`,r.textContent=this.#f("presence.hidden",{count:c}),this.#n.appendChild(r)}}announceRefusal(y){if(!this.#r)return;const d=y&&y.name?y.name:this.#f("presence.someoneElse");this.#r.textContent=this.#f("a11y.presence.refused",{name:d})}#f(y,d){const c=this.#e;return(c&&c.messages?c.messages:L).t(y,d)}destroy(){for(const d of this.#i)d();this.#i=[],this.#a!==null&&clearTimeout(this.#a),this.#a=null;const y=this.#t.viewport?.root;y?.querySelectorAll&&this.#d(y),this.#n&&R(this.#n.remove)&&this.#n.remove(),this.#r&&R(this.#r.remove)&&this.#r.remove(),this.#n=null,this.#r=null}}const k=F}),ke("packages/dom/src/commentpanel.js",function(e,V){"use strict";Object.defineProperty(e,"relativeTime",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"renderBody",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"CommentPanel",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,Z=V("packages/dom/src/editors/common.js").cssEscape,U=V("packages/core/src/model/comments.js").parseCellKey,z="lat-comments",F=/^(https?:|mailto:)/i,k='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function O(r,t){if(!Number.isFinite(r))return"";const n=Math.max(0,Math.round((t-r)/1e3));if(n<60)return"just now";const i=Math.round(n/60);if(i<60)return`${i}m ago`;const s=Math.round(i/60);return s<24?`${s}h ago`:`${Math.round(s/24)}d ago`}function y(r,t,n,i){t.textContent="";const s=String(n??"");if(!i){t.textContent=s;return}const l=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let u=0,f=l.exec(s);for(;f;){f.index>u&&t.appendChild(r.createTextNode(s.slice(u,f.index)));const h=f[0];if(h.startsWith("*")){const g=r.createElement("em");g.textContent=h.slice(1,-1),t.appendChild(g)}else if(h.startsWith("`")){const g=r.createElement("code");g.textContent=h.slice(1,-1),t.appendChild(g)}else{const g=h.indexOf("]("),b=h.slice(1,g),p=h.slice(g+2,-1);if(F.test(p)){const m=r.createElement("a");m.href=p,m.textContent=b,m.rel="noopener noreferrer",m.target="_blank",t.appendChild(m)}else t.appendChild(r.createTextNode(b))}u=f.index+h.length,f=l.exec(s)}u<s.length&&t.appendChild(r.createTextNode(s.slice(u)))}class d{#e;#t;#n=null;#r=null;#o=null;#i=null;#a=null;#s=[];constructor(t){this.#e=t.grid,this.#t=t.renderer}mount(){this.#s.push(this.#e.on("comment:threadOpened",t=>this.#l(t))),this.#s.push(this.#e.on("comment:threadClosed",()=>this.#u())),this.#s.push(this.#e.on("render:done",()=>{this.#b(),this.#w()})),this.#s.push(this.#e.on("stream:evicted",()=>this.#c()))}#l(t){const n=this.#t.viewport?.root?.ownerDocument;n&&(this.#a=n.activeElement||null,this.#i=this.#h(t.rowId,t.field),this.#n||this.#m(n),this.#n.setAttribute("data-open","true"),this.#b(),this.#w(),this.#o&&R(this.#o.focus)&&this.#o.focus())}#u(){if(!this.#n)return;this.#n.removeAttribute("data-open"),this.#i=null;const t=this.#a;this.#a=null,t&&R(t.focus)&&t.focus()}#c(){const t=this.#e.comments.openKey;if(!t)return;const{rowId:n}=U(t);this.#e.rows.byKey(n)||(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 i=this.#r.ownerDocument.createElement("p");i.className=`${z}__note`,i.setAttribute("role","status"),i.textContent=t,this.#r.appendChild(i)}#h(t,n){const i=this.#t.viewport?.root;if(!i||!i.querySelector)return null;const s=i.querySelector(`[data-key="${Z(t)}"]`);return s?s.querySelector(`[data-col="${n}"]`):null}#f(t,n){const i=this.#e;return(i&&i.messages?i.messages:L).t(t,n)}#m(t){const n=t.createElement("div");n.className=z,n.setAttribute("role","dialog"),n.setAttribute("aria-modal","true"),n.setAttribute("aria-label",this.#f("comments.panel"));const i=t.createElement("header");i.className=`${z}__head`;const s=t.createElement("div");s.className=`${z}__title`,i.appendChild(s);const l=t.createElement("button");l.className=`${z}__resolve`,l.type="button",i.appendChild(l);const u=t.createElement("button");u.className=`${z}__close`,u.type="button",u.setAttribute("aria-label",this.#f("comments.close")),u.textContent="×",i.appendChild(u);const f=t.createElement("div");f.className=`${z}__list`,f.setAttribute("role","log"),f.setAttribute("aria-live","polite");const h=t.createElement("form");h.className=`${z}__composer`;const g=t.createElement("textarea");g.className=`${z}__input`,g.rows=2,g.setAttribute("aria-label",this.#f("comments.write"));const b=t.createElement("button");b.className=`${z}__send`,b.type="submit",b.textContent=this.#f("comments.post"),h.appendChild(g),h.appendChild(b),n.appendChild(i),n.appendChild(f),n.appendChild(h),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(n),this.#n=n,this.#r=f,this.#o=g,this.#p=s,this.#g=l;const p=a=>{a.preventDefault();const o=String(g.value||"").trim();o&&(g.value="",this.#e.comments.add(o))},m=()=>this.#e.comments.close(),w=()=>{this.#v()>0?this.#e.comments.resolve():this.#e.comments.unresolve()},v=a=>{if(a.stopPropagation(),a.key==="Escape"){a.preventDefault(),this.#e.comments.close();return}if(a.key!=="Tab")return;const o=[...n.querySelectorAll(k)].filter(M=>M.offsetParent!==null||M===g);if(!o.length)return;const S=o[0],E=o[o.length-1],A=n.ownerDocument.activeElement;a.shiftKey&&A===S?(a.preventDefault(),E.focus()):!a.shiftKey&&A===E&&(a.preventDefault(),S.focus())};h.addEventListener("submit",p),u.addEventListener("click",m),l.addEventListener("click",w),n.addEventListener("keydown",v),this.#s.push(()=>{h.removeEventListener("submit",p),u.removeEventListener("click",m),l.removeEventListener("click",w),n.removeEventListener("keydown",v)})}#p=null;#g=null;#v(){return(this.#e.comments.thread||[]).filter(n=>!n.resolved).length}#b(){const t=this.#e.comments;if(!this.#n||!t.openKey)return;const n=this.#n.ownerDocument,i=this.#e.get("comments")||{},s=Date.now(),l=t.openKey,{rowId:u,field:f}=U(l),h=this.#e.columns.get(f),g=this.#e.rows.byKey(u),b=R(i.rowLabel)&&g?i.rowLabel(g):u;if(this.#p.textContent=this.#f("comments.cellTitle",{column:h&&(h.title??h.id)||f,row:b}),this.#g.textContent=this.#v()>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 m=g&&h?h.getValue(g.data,g):void 0;for(const w of p)this.#r.appendChild(this.#y(n,w,s,m,i))}#y(t,n,i,s,l){const u=t.createElement("article");u.className=`${z}__item`,n.pending&&u.setAttribute("data-pending","true"),n.resolved&&u.setAttribute("data-resolved","true");const f=t.createElement("div");f.className=`${z}__meta`;const h=t.createElement("span");h.className=`${z}__author`,h.textContent=n.author&&(n.author.name||n.author.initials)||this.#f("comments.unknownAuthor"),f.appendChild(h);const g=t.createElement("time");g.className=`${z}__time`;const b=O(n.at,i);g.textContent=n.edited?this.#f("comments.edited",{time:b}):b,f.appendChild(g),u.appendChild(f);const p=t.createElement("div");if(p.className=`${z}__body`,y(t,p,n.body,!!l.markdown),u.appendChild(p),n.value!==void 0&&!Object.is(n.value,s)){const v=t.createElement("p");v.className=`${z}__moved`,v.textContent=this.#f("comments.valueMoved",{was:String(n.value),now:String(s)}),u.appendChild(v)}const m=n.can||{},w=v=>m[v]!==!1;if(w("edit")||w("delete")){const v=t.createElement("div");if(v.className=`${z}__actions`,w("delete")){const a=t.createElement("button");a.type="button",a.className=`${z}__action`,a.textContent=this.#f("comments.delete"),a.addEventListener("click",()=>this.#e.comments.remove(n.id)),v.appendChild(a)}u.appendChild(v)}return u}#w(){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 n=this.#e.comments.openKey,{rowId:i,field:s}=U(n),l=this.#h(i,s)||this.#i,u=this.#t.viewport?.root;if(!l||!u||!R(l.getBoundingClientRect))return;const f=l.getBoundingClientRect(),h=u.getBoundingClientRect(),g=this.#n.getBoundingClientRect();let b=f.bottom-h.top+4;b+g.height>h.height&&f.top-h.top>g.height&&(b=f.top-h.top-g.height-4);let p=f.left-h.left;p+g.width>h.width&&(p=Math.max(0,h.width-g.width-4)),this.#n.style.top=`${Math.max(0,b)}px`,this.#n.style.left=`${Math.max(0,p)}px`;const m=f.bottom<h.top||f.top>h.bottom;this.#n.toggleAttribute("data-offscreen",m)}destroy(){for(const t of this.#s)t();this.#s=[],this.#n&&R(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const c=d}),ke("packages/dom/src/watermark.js",function(e,V){"use strict";Object.defineProperty(e,"WATERMARK_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"Watermark",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/dom/src/editors/common.js"),Z=W.el,H=W.on,U="lat-watermark",z="https://www.latticegrid.dev",F=["br","bl","tl","tr"],k=4e3;class O{#e;#t;#n;#r=null;#o=[];#i;#a=0;#s=null;constructor(c){this.#e=c.grid,this.#t=c.document,this.#n=c.element,this.#i=c.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),R(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const c=this.#e.licence&&this.#e.licence.ready;c&&R(c.then)&&c.then(()=>this.refresh(),()=>this.refresh())}refresh(){const c=this.#d();c&&!this.#r?(this.#h(),this.#u()):!c&&this.#r&&(this.#f(),this.#c())}#l(){const c=this.#i;if(!c||!R(c.matchMedia))return!1;try{return!!c.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),R(this.#i.setTimeout)&&(this.#l()||(this.#s=this.#i.setTimeout(()=>{if(this.#s=null,!this.#d()){this.#f();return}this.#a=(this.#a+1)%F.length,this.#f(),this.#h(),this.#u()},k)))}#c(){this.#s!==null&&R(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#s),this.#s=null}#d(){const c=this.#e.licence;return!!(c&&R(c.watermark)&&c.watermark())}#h(){const c=Z(this.#t,"a",{class:`${U}__link`,text:(this.grid&&this.grid.messages?this.grid.messages:L).t("licence.watermark"),attrs:{href:z,target:"_blank",rel:"noopener noreferrer"}});this.#r=Z(this.#t,"div",{class:`${U} ${U}--${F[this.#a]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[c]}),this.#o.push(H(this.#r,"pointerdown",r=>{R(r.stopPropagation)&&r.stopPropagation()})),this.#n&&R(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#f(){this.#r&&R(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c();for(const c of this.#o)c();this.#o=[],this.#f()}}const y=O}),ke("packages/dom/src/maximise.js",function(e,V){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return O}});const _=V("packages/core/src/internal/util.js"),R=_.warnOnce,$=_.isFunction,L=V("packages/dom/src/editors/common.js"),W=L.el,Z=L.on,H="lat-maximised",U={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"},z="lat-maximised-host",F="lat-maximise-placeholder";class k{#e;#t;#n;#r;#o;#i=null;#a=null;#s=new Set;#l=null;#u=null;constructor(d){this.#e=d.element,this.#t=d.document,this.#n=$(d.onChange)?d.onChange:null,this.#r=$(d.captureScroll)?d.captureScroll:null,this.#o=$(d.restoreScroll)?d.restoreScroll:null}active(){return this.#i!==null}enter(){if(this.active())return!0;const d=this.#e.parentNode;if(!d||!this.#t.body)return R("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=W(this.#t,"div",{class:F}),this.#i.style.visibility="hidden";const c=this.#e.offsetWidth,r=this.#e.offsetHeight;c&&(this.#i.style.width=`${c}px`),r&&(this.#i.style.height=`${r}px`);const t=this.#r?this.#r():null;d.insertBefore(this.#i,this.#e),this.#c(()=>this.#t.body.appendChild(this.#e)),this.#l={};for(const[n,i]of Object.entries(U))this.#l[n]=this.#e.style[n]||"",this.#e.style[n]=i;return this.#u=this.#t.body.style?this.#t.body.style.overflow||"":null,this.#t.body.style&&(this.#t.body.style.overflow="hidden"),this.#e.classList.add(H),this.#t.body.classList&&this.#t.body.classList.add(z),t&&this.#o&&this.#o(t),this.#a=Z(this.#t,"keydown",n=>this.#d(n)),this.#h(),!0}exit(){if(!this.active())return!1;const d=this.#r?this.#r():null,c=this.#i,r=c.parentNode;if(r&&$(r.insertBefore)&&this.#c(()=>r.insertBefore(this.#e,c)),$(c.remove)&&c.remove(),this.#i=null,this.#l){for(const[t,n]of Object.entries(this.#l))this.#e.style[t]=n;this.#l=null}return this.#u!==null&&this.#t.body&&this.#t.body.style&&(this.#t.body.style.overflow=this.#u),this.#u=null,this.#e.classList.remove(H),this.#t.body&&this.#t.body.classList&&this.#t.body.classList.remove(z),d&&this.#o&&this.#o(d),this.#a&&this.#a(),this.#a=null,this.#h(),!0}toggle(){return this.active()?!this.exit():this.enter()}#c(d){const c=this.#t.activeElement,r=c&&c!==this.#t.body&&$(this.#e.contains)&&this.#e.contains(c)?c:null;d(),r&&$(r.focus)&&r.focus()}#d(d){!d||d.key!=="Escape"||d.defaultPrevented||this.exit()}#h(){this.#n&&this.#n();for(const d of this.#s)d(this.active())}watch(d){return $(d)?(this.#s.add(d),()=>this.#s.delete(d)):()=>{}}destroy(){this.exit()}}const O=k}),ke("packages/dom/src/promptbar.js",function(e,V){"use strict";Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return n}});const _=V("packages/dom/src/editors/common.js"),R=_.documentFor,$=_.el,L=_.on,W=_.clear,H=V("packages/core/src/i18n/index.js").defaultMessages,z=V("packages/core/src/internal/util.js").isFunction,F=V("packages/core/src/ai/schema.js"),k=F.describeGrid,O=F.promptText,y=V("packages/core/src/ai/intent.js"),d=y.applyPlan,c=y.buildPrompt,r=y.planIntent,t="lat-prompt";class n{#e;#t=null;#n=null;#r={};#o;#i={};#a=null;#s=null;#l=null;#u=null;#c=null;#d=null;#h=null;#f=null;#m=null;#p=null;#g=null;#v="idle";#b=0;#y=!1;#w=[];t(u,f){return(this.messages&&typeof this.messages.t=="function"?this.messages:H).t(u,f)}init(u={}){this.messages=u&&u.messages||u&&u.grid&&u.grid.messages||H,this.#e=R(u),this.#t=u.grid||null,this.#n=z(u.ask)?u.ask:null,this.#r=u.schemaOptions||{},this.#o=u.context,this.#i={onPlan:z(u.onPlan)?u.onPlan:null,onApply:z(u.onApply)?u.onApply:null,onError:z(u.onError)?u.onError:null},this.#a=$(this.#e,"div",{class:t,attrs:{"data-state":"idle",role:"search"}}),this.#S(u)}element(){return this.#a}refresh(){this.#y||!this.#a||this.#v!=="busy"&&this.#C()}destroy(){this.#y=!0,this.#b++;for(const u of this.#w)u();this.#w.length=0,this.#g=null,this.#a=null,this.#s=null,this.#l=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(u){if(this.#y||this.#v==="busy")return null;const f=String(u??(this.#s&&this.#s.value)??"").trim();if(!f)return null;if(!this.#n)return this.#T("No model is wired up. Supply `ai.ask` to use the prompt bar."),null;const h=++this.#b;this.#j("busy"),this.#E("Thinking…");let g;try{const b=k(this.#t,this.#r),p=O(b);if(g=await this.#n({prompt:f,schema:b,schemaText:p,message:c(f,p),context:this.#o}),this.#y||h!==this.#b)return null;const m=r(g,b);return this.#A(m),m}catch(b){return this.#y||h!==this.#b||(this.#i.onError&&this.#i.onError(b),this.#T(b instanceof Error?b.message:String(b))),null}}apply(){const u=this.#g;if(this.#y||!u||!u.ok)return null;const f=this.#t?.ai,h=z(f?.apply)?f.apply(u):d(u,this.#t);return this.#i.onApply&&this.#i.onApply(h,u),this.#C(),this.#s&&(this.#s.value=""),h.failed.length?this.#T(`Applied ${h.applied.length}; ${h.failed.map(g=>`${g.type} failed: ${g.reason}`).join("; ")}`):this.#E(`Applied: ${u.describe()}`),h}discard(){this.#y||(this.#C(),this.#E("Discarded."))}#S(u){const f=this.#e,h=$(f,"div",{class:`${t}__row`});this.#s=$(f,"input",{class:`${t}__input`,attrs:{type:"text",placeholder:u.placeholder||"Ask for a view: “EMEA deals over 50k, biggest first”","aria-label":u.label||"Ask about this grid",autocomplete:"off"}}),this.#w.push(L(this.#s,"keydown",b=>{const p=b&&b.key;p==="Enter"?(z(b.preventDefault)&&b.preventDefault(),this.ask()):p==="Escape"&&this.#g&&(z(b.preventDefault)&&b.preventDefault(),this.discard())})),h.appendChild(this.#s),this.#l=$(f,"button",{class:`${t}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#w.push(L(this.#l,"click",()=>{this.ask()})),h.appendChild(this.#l),this.#a.appendChild(h),this.#u=$(f,"div",{class:`${t}__preview`,attrs:{hidden:!0}}),this.#c=$(f,"p",{class:`${t}__summary`}),this.#d=$(f,"ul",{class:`${t}__notes`});const g=$(f,"div",{class:`${t}__buttons`});this.#h=$(f,"button",{class:`${t}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#f=$(f,"button",{class:`${t}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#w.push(L(this.#h,"click",()=>{this.apply()})),this.#w.push(L(this.#f,"click",()=>{this.discard()})),g.appendChild(this.#h),g.appendChild(this.#f),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(g),this.#a.appendChild(this.#u),this.#m=$(f,"p",{class:`${t}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#p=$(f,"p",{class:`${t}__error`,attrs:{role:"alert",hidden:!0}}),this.#a.appendChild(this.#m),this.#a.appendChild(this.#p)}#j(u){if(this.#v=u,!this.#a)return;this.#a.setAttribute("data-state",u);const f=u==="busy";i(this.#s,f),i(this.#l,f),this.#l&&(this.#l.textContent=this.t(f?"prompt.asking":"prompt.ask")),s(this.#u,u!=="preview"),s(this.#p,u!=="error")}#A(u){const f=u;if(this.#i.onPlan&&this.#i.onPlan(u),!f.ok){this.#g=null;const h=f.rejected.length?f.rejected.map(g=>g.reason).join("; "):"nothing to do";this.#T(`I could not turn that into a change: ${h}`);return}this.#g=u,this.#E(""),this.#c&&(this.#c.textContent=f.describe()),this.#O(f.rejected),this.#j("preview")}#O(u){const f=this.#d;if(f){W(f),s(f,!u.length);for(const h of u.slice(0,6))f.appendChild($(this.#e,"li",{class:`${t}__note`,text:h.reason}));u.length>6&&f.appendChild($(this.#e,"li",{class:`${t}__note`,text:this.t("prompt.moreNotes",{count:u.length-6})}))}}#C(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&W(this.#d),this.#j("idle")}#E(u){this.#m&&(this.#m.textContent=u)}#T(u){this.#g=null,this.#E(""),this.#p&&(this.#p.textContent=u),this.#j("error")}}function i(l,u){l&&(l.disabled=u,u?l.setAttribute("disabled",""):l.removeAttribute("disabled"))}function s(l,u){l&&(l.hidden=u,u?l.setAttribute("hidden",""):l.removeAttribute("hidden"))}}),ke("packages/dom/src/stat.js",function(e,V){"use strict";Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"bandTone",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return u}});const _=V("packages/core/src/internal/util.js"),R=_.isFunction,$=_.isObject,L=_.warnOnce,Z=V("packages/core/src/source/derive.js").reduceValues,U=V("packages/core/src/source/memory.js").isPipelineSettle,F=V("packages/core/src/i18n/index.js").defaultMessages,O=V("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"},d="unknown",c=new Set(["sum","min","max","avg","first","last","mode","median","p25","p75","p90","p95","p99","stddev","stddevP","mad","range","iqr","trimmedMean","winsorizedMean","geomean","harmean"]),r=Object.freeze({direction:"flat",change:null,percent:null});function t(p,m){if(!Number.isFinite(p)||!Number.isFinite(m))return r;const w=p-m,v=w>0?"up":w<0?"down":"flat",a=m===0?null:w/Math.abs(m)*100;return{direction:v,change:w,percent:a}}function n(p,m){return p==="flat"||m==="neither"?"flat":p===m?"good":"bad"}function i(p,m,w=null){if(R(m)){const A=m(p,w);return A==="good"||A==="warn"||A==="bad"?A:null}if(!$(m))return null;const v=typeof p=="number"&&Number.isFinite(p)?p:null;if(v===null)return null;const a=Number.isFinite(Number(m.good))?Number(m.good):null,o=Number.isFinite(Number(m.warn))?Number(m.warn):null,S=String(m.direction||"up")==="down",E=A=>S?v<=A:v>=A;return a!==null&&E(a)?"good":o!==null&&E(o)?"warn":a===null&&o===null?null:"bad"}function s(p){return!(R(p.value)||p.value!==void 0&&!$(p.value))}function l(p){return!p||!p.rows||!R(p.rows.totalCount)?!0:p.rows.totalCount()>0}function u(p){const m=$(p)?p:{},w=m.grid||null,v=g(m.container,w);if(!v)return L("stat.container","createStat needs a `container`: an element or a selector."),b();const a=v.ownerDocument||(typeof document>"u"?null:document);if(!a)return L("stat.document","createStat needs a document; it draws DOM."),b();const o=a.createElement("div");o.className=["lattice",y.root,m.class].filter(Boolean).join(" "),o.setAttribute("role","group");const S=a.createElement("div");S.className=y.title;const E=a.createElement("div");E.className=y.value;const A=a.createElement("div");A.className=y.interval;const M=a.createElement("div");M.className=y.delta;const C=a.createElement("div");C.className=y.footer;const P=a.createElement("div");if(P.className=y.note,P.hidden=!0,m.icon!=null&&m.icon!==""){const ne=a.createElement("span");ne.className=y.icon,ne.setAttribute("aria-hidden","true"),O(ne,m.icon,`stat:${m.title||"stat"}`),o.appendChild(ne);const re=a.createElement("div");re.className=y.body,re.appendChild(S),re.appendChild(E),re.appendChild(P),re.appendChild(A),re.appendChild(M),re.appendChild(C),o.appendChild(re)}else o.appendChild(S),o.appendChild(E),o.appendChild(P),o.appendChild(A),o.appendChild(M),o.appendChild(C);v.appendChild(o);let K=null;const I=[];let D=!1;function j(){if(R(m.value))return m.value(w);if(m.value!==void 0&&!$(m.value))return m.value;const ne=$(m.value)?m.value:m,re=ne.of,oe=ne.fn||"sum",ie=ne.show;return w?oe==="count"?B().length:re?ie?q(String(re),String(oe),String(ie)):T()==="filtered"&&w.statistics&&R(w.statistics.reduce)?w.statistics.reduce(String(re),String(oe)):Z(B().map(te=>h(te,String(re))),String(oe)):null:null}function T(){return String(m.scope||"filtered")}function B(){if(!w||!w.rows)return[];const ne=T();if(ne==="all"){const oe=[];return R(w.rows.forEachAll)&&w.rows.forEachAll(ie=>{ie.group||oe.push(f(ie))}),oe}if(ne==="selected")return(w.selection&&R(w.selection.rows)?w.selection.rows():[]).filter(Boolean).map(f);const re=[];return R(w.rows.forEach)&&w.rows.forEach(oe=>{oe.group||re.push(f(oe))}),re}function q(ne,re,oe){if(re!=="min"&&re!=="max")return L(`stat.show.${re}`,`\`show\` needs \`fn: 'min'\` or \`fn: 'max'\`: "${re}" reduces to a value that no single row holds, so there is no row to report from.`),null;let ie=null,te=null;for(const ce of B()){const ue=Number(h(ce,ne));Number.isFinite(ue)&&(ie===null||(re==="max"?ue>ie:ue<ie))&&(ie=ue,te=ce)}return te===null?null:h(te,oe)}function X(ne){if(R(m.format))return String(m.format(ne,w));if(ne==null)return m.empty??"—";const re=$(m.value)?m.value:m,oe=re.show||re.of;if((re.show?!0:c.has(String(re.fn||"sum")))&&w&&oe&&R(w.columns?.get)){const te=w.columns.get(String(oe));if(te&&R(te.formatValue))return te.formatValue(ne)}return typeof ne=="number"?Number.isInteger(ne)?String(ne):ne.toFixed(m.decimals??2):String(ne)}function Q(ne){return ne?(w&&w.messages||F).t(`stat.tone.${ne}`):""}function J(){if(D)return;const ne=j(),re=s(m)&&!!w&&!l(w),oe=re?null:ne,ie=R(m.baseline)?m.baseline(w):m.baseline;K=oe,S.textContent=m.title??"",S.hidden=!m.title,E.textContent=X(oe),P.hidden=!re,re&&(P.textContent=w.messages.t("stat.noData"));const te=re||ie===void 0||ie===null?r:t(typeof oe=="number"?oe:null,Number(ie)),ce=n(te.direction,m.goodWhen||"up");if(M.hidden=te.change===null,te.change!==null){const he=te.direction==="up"?"↑":te.direction==="down"?"↓":"→",ve=te.percent===null?X(Math.abs(te.change)):`${Math.abs(te.percent).toFixed(1)}%`;M.textContent=`${he} ${ve}`,M.setAttribute("data-tone",ce),M.setAttribute("data-direction",te.direction)}const ue=R(m.interval)?m.interval(oe,w):null,ae=!!ue&&Number.isFinite(ue.lower)&&Number.isFinite(ue.upper);A.hidden=!ae,ae&&(A.textContent=`${X(ue.lower)} – ${X(ue.upper)}`,Number.isFinite(ue.confidence)&&A.setAttribute("title",`${Math.round(ue.confidence*100)}%`));const pe=re?d:m.bands?i(oe,m.bands,w):null;pe?o.setAttribute("data-tone",pe):o.removeAttribute("data-tone"),C.textContent=R(m.footer)?String(m.footer(oe,w)):m.footer??"",C.hidden=!C.textContent,o.setAttribute("aria-label",[m.title,E.textContent,re?P.textContent:"",ae?A.textContent:"",te.change===null?"":M.textContent,te.change===null?"":Q(ce),C.textContent].filter(Boolean).join(", "))}if(w&&R(w.on)&&m.live!==!1)for(const ne of["rows:changed","filter:changed","selection:changed","model:changed"]){const re=oe=>{ne==="model:changed"&&!U(oe)||J()};w.on(ne,re),I.push(()=>R(w.off)&&w.off(ne,re))}return J(),{element:()=>o,value:()=>K,refresh:J,destroy(){D=!0;for(const ne of I)try{ne()}catch{}I.length=0,o.remove()}}}function f(p){return $(p)&&"data"in p?p.data:p}function h(p,m){if(!$(p))return;if(!m.includes("."))return p[m];let w=p;for(const v of m.split(".")){if(!$(w))return;w=w[v]}return w}function g(p,m){if(p&&typeof p=="object")return p;if(typeof p!="string")return null;const w=m&&m.element&&m.element.ownerDocument||(typeof document>"u"?null:document);return w?w.querySelector(p):null}function b(){return{element:()=>null,value:()=>null,refresh(){},destroy(){}}}}),ke("packages/dom/src/kpistrip.js",function(e,V){"use strict";Object.defineProperty(e,"KpiStrip",{enumerable:!0,get:function(){return Z}});const R=V("packages/core/src/internal/util.js").isObject,L=V("packages/dom/src/stat.js").createStat,W={band:"lat-kpi-strip"};class Z{#e;#t;#n;#r=null;#o=[];constructor({grid:U,document:z,kpis:F}){this.#e=U,this.#t=z,this.#n=Array.isArray(F)?F.filter(R):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const z=this.#t.createElement("div");z.className=`lattice ${W.band}`,z.setAttribute("role","group"),z.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=z;for(const F of this.#n){const k=L({...F,grid:this.#e,container:z});this.#o.push(k)}}destroy(){for(const U of this.#o)try{U.destroy()}catch{}this.#o.length=0,this.#r&&(this.#r.remove(),this.#r=null)}}}),ke("packages/dom/src/createGrid.js",function(e,V){"use strict";Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return St}}),Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return Ot}});const R=V("packages/core/src/index.js").createHeadlessGrid,L=V("packages/core/src/defaults.js").applyDefaults,Z=V("packages/core/src/export/download.js").downloadBlob,H=V("packages/core/src/internal/util.js"),U=H.fail,z=H.isFunction,F=H.warnOnce,O=V("packages/dom/src/localviews.js").createLocalViewStorage,d=V("packages/dom/src/renderer/index.js").DomRenderer,r=V("packages/dom/src/cell/index.js").createCellLayer,t=V("packages/dom/src/cell/icons.js"),n=t.icon,i=t.iconNames,l=V("packages/dom/src/editors/index.js").editors,f=V("packages/dom/src/filters/index.js").filters,h=V("packages/dom/src/ui/index.js"),g=h.StatusBar,b=h.TooltipManager,p=h.Pagination,m=h.GroupByZone,v=V("packages/dom/src/ui/celltooltip.js").CellTooltips,o=V("packages/dom/src/filtermenu.js").FilterMenu,E=V("packages/dom/src/columnmenu.js").ColumnMenu,M=V("packages/dom/src/shortcutshelp.js").ShortcutsHelp,P=V("packages/dom/src/rowreorder.js").RowReorder,K=V("packages/dom/src/alignedgrids.js").AlignedGrids,D=V("packages/dom/src/columntagbar.js").ColumnTagBar,T=V("packages/dom/src/anomalychip.js").AnomalyChip,q=V("packages/dom/src/rowform.js").RowForm,X=V("packages/dom/src/toolpanelmount.js"),Q=X.ToolPanelDock,J=X.panelHost,re=V("packages/dom/src/celledit.js").CellEditController,ie=V("packages/dom/src/editbar.js").EditBar,ce=V("packages/dom/src/rangeselect.js").RangeController,ae=V("packages/core/src/model/selection.js").resolveSelectionConfig,he=V("packages/dom/src/importer.js").ImportController,Oe=V("packages/dom/src/historybar.js").HistoryBar,Ze=V("packages/dom/src/diffpaint.js").DiffPainter,xe=V("packages/dom/src/detailhost.js").DetailHost,_e=V("packages/dom/src/highlightpaint.js").HighlightPainter,et=V("packages/dom/src/findpaint.js").FindPainter,Ae=V("packages/dom/src/findbar.js").FindBar,Ge=V("packages/dom/src/redactpaint.js").RedactionPainter,ut=V("packages/dom/src/validationpaint.js").ValidationPainter,Ct=V("packages/dom/src/presentation.js").PresentationController,Lt=V("packages/dom/src/capture.js").captureElement,$t=V("packages/dom/src/annotate.js").AnnotationLayer,Jt=V("packages/dom/src/timelinebar.js").TimelineBar,de=V("packages/dom/src/commentpaint.js").CommentPainter,Te=V("packages/dom/src/presencepaint.js").PresencePainter,Ve=V("packages/dom/src/commentpanel.js").CommentPanel,ft=V("packages/dom/src/watermark.js").Watermark,we=V("packages/dom/src/maximise.js").Maximiser,je=V("packages/dom/src/promptbar.js").PromptBar,Ne=V("packages/dom/src/kpistrip.js").KpiStrip;function Re(Ee,nt,it){const mt=nt==="redo"?"toolbar.redo":"toolbar.undo";return!it||!it.label?Ee(mt):Ee(nt==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:it.label})}const Le=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],Fe=2e3;function Ye(Ee,nt,it){const mt=nt.annotate===!0?Xe(Ee):[];if(nt.actions===!1)return[];if(nt.actions===void 0&&nt.side!=="left")return mt;const It=Array.isArray(nt.actions)?nt.actions:Le,Rt=(kt,Vt)=>Ee.messages.t(kt,Vt),st={undo:{name:"undo",title:()=>Re(Rt,"undo",Ee.history.peek("undo")),icon:"undo",run:()=>Ee.history.undo(),enabled:()=>Ee.history.canUndo()},redo:{name:"redo",title:()=>Re(Rt,"redo",Ee.history.peek("redo")),icon:"redo",run:()=>Ee.history.redo(),enabled:()=>Ee.history.canRedo()},export:{name:"export",title:()=>Rt("toolbar.exportCsv"),icon:"download",run:()=>Ee.export.csv({download:!0,fileName:nt.exportName})},excel:{name:"excel",title:()=>Rt("toolbar.exportExcel"),icon:"spreadsheet",run:()=>Ee.export.excel({download:!0,fileName:nt.exportName})},clipboard:{name:"clipboard",title:()=>Rt("toolbar.clipboard"),icon:"copy",run:()=>Ee.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>Rt("toolbar.print"),icon:"print",run:()=>Ee.export.print()},pause:{name:"pause",title:()=>{if(!Ee.updates.paused)return Rt("toolbar.pause");const kt=Ee.updates.stats().pending;return kt?Rt("toolbar.applyHeld",{count:kt}):Rt("toolbar.resume")},icon:()=>Ee.updates.paused?"play":"pause",run:()=>Ee.updates.paused?Ee.updates.resume():Ee.updates.pause()},restore:{name:"restore",title:()=>Rt("toolbar.restoreView"),icon:"restore",run:()=>Ee.state.reset(),enabled:()=>Ee.state.modified()},maximise:{name:"maximise",title:()=>Rt(it&&it.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>it&&it.active()?"minimise":"maximise",run:()=>it.toggle()}};return it||delete st.maximise,It.map(kt=>kt==="-"?{name:"-",separator:!0}:typeof kt=="string"?st[kt]:!kt||typeof kt!="object"||!kt.name?null:{...kt,run:z(kt.run)?()=>kt.run({grid:Ee,keys:Ee.selection&&z(Ee.selection.keys)?Ee.selection.keys():[],cells:Ee.selection&&z(Ee.selection.cells)?Ee.selection.cells():[]}):void 0}).filter(Boolean).concat(mt)}function Xe(Ee){const nt=mt=>Ee.messages.t(mt),it={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight"};return["pen","arrow","rect","highlight"].map(mt=>({name:mt,title:()=>nt(`toolbar.annotate.${mt}`),icon:it[mt],run:()=>Ee.annotate?.use(mt),active:()=>Ee.annotate?.tool===mt,annotation:!0}))}const pt=["pen","arrow","rect","highlight"];function gt(Ee){return{rowCount:()=>{if(z(Ee.rows.matchCount))return Ee.rows.matchCount();const nt=Ee.pagination&&z(Ee.pagination.get)?Ee.pagination.get():null;return nt&&Number.isFinite(nt.total)?nt.total:Ee.rows.count()},totalRowCount:()=>z(Ee.rows.totalCount)?Ee.rows.totalCount():Ee.rows.count(),selectedCount:()=>{const nt=Ee.selection&&Ee.selection.keys?Ee.selection.keys():null;return nt?nt.length:0},rangeValues:()=>{const nt=Ee.selection;return!nt||!z(nt.cells)?[]:nt.cells().map(({key:it,colId:mt})=>Ee.rows.value(it,mt))},hiddenUnresolved:()=>z(Ee.comments&&Ee.comments.hiddenUnresolved)?Ee.comments.hiddenUnresolved():0,progress:()=>z(Ee.source&&Ee.source.progress)?Ee.source.progress():null,updateStats:()=>Ee.updates?Ee.updates.stats():null}}function bt(Ee,nt){for(const[it,mt]of Object.entries(l||{}))Ee.register("editor",it,mt);for(const[it,mt]of Object.entries(f||{}))Ee.register("filter",it,mt);for(const[it,mt]of Object.entries(nt.components||{}))Ee.register("component",it,mt);for(const[it,mt]of Object.entries(nt.pipes||{}))Ee.register("pipe",it,mt);for(const[it,mt]of Object.entries(nt.totalFns||{}))Ee.register("totalFn",it,mt)}function ht(Ee,nt,it,mt,It,Rt){const st=[],kt=nt.viewport;let Vt=null;if(it.maximise!==!1&&(Vt=new we({element:Rt,document:mt,onChange:()=>nt.invalidate("all"),captureScroll:()=>nt.scrollState(),restoreScroll:Qe=>nt.restoreScroll(Qe)}),Ee.maximise=Vt,st.push(()=>Vt.destroy())),it.statusBar){const Qe=typeof it.statusBar=="object"?it.statusBar:{},at=new g;at.init({document:mt,host:gt(Ee),panels:Qe.panels,registry:Qe.registry,locale:Ee.get("locale"),messages:Ee.messages}),kt.statusBar.appendChild(at.element());const jt=()=>{const nn=kt.statusBar.offsetHeight||kt.statusBar.getBoundingClientRect?.().height||0;kt.root.style.setProperty("--lattice-status-height",`${Math.ceil(nn)}px`)},Ft=()=>{at.refresh(),jt()},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=>Ee.on(nn,Ft));Ft(),jt(),st.push(()=>{for(const nn of Ht)nn();kt.root.style.removeProperty("--lattice-status-height"),at.destroy?.()})}const Kt=ae(it.selection);if(Kt.ranges){const Qe=new ce({grid:Ee,renderer:nt,document:mt});Qe.mount(),Ee.ranges=Qe,st.push(()=>Qe.destroy())}if(it.import){const Qe=new he({grid:Ee,renderer:nt,document:mt,settings:typeof it.import=="object"?it.import:{}});Ee.importer=Qe,st.push(()=>Qe.destroy())}if(it.historyBar){const Qe=typeof it.historyBar=="object"?it.historyBar.element:null,at=new Oe;at.init({document:mt,host:{undo:()=>Ee.history.undo(),redo:()=>Ee.history.redo(),canUndo:()=>Ee.history.canUndo(),canRedo:()=>Ee.history.canRedo(),peek:Ft=>Ee.history.peek(Ft),list:()=>Ee.history.list()},props:typeof it.historyBar=="object"?it.historyBar:{}}),(Qe||kt.root).appendChild(at.element());const jt=[Ee.on("history:changed",()=>at.refresh())];Ee.historyBar=at,st.push(()=>{for(const Ft of jt)Ft();at.destroy()})}if(it.diff){const Qe=new Ze({grid:Ee,renderer:nt});Qe.mount(),Ee.diffPainter=Qe,st.push(()=>Qe.destroy())}if(it.ai&&z(it.ai.ask)){const Qe=new je;Qe.init({document:mt,grid:Ee,ask:it.ai.ask,schemaOptions:it.ai.schemaOptions,context:it.ai.context,placeholder:it.ai.placeholder});const at=it.ai.element||kt.root;at===kt.root?at.insertBefore(Qe.element(),at.firstChild):at.appendChild(Qe.element()),Ee.promptBar=Qe,st.push(()=>Qe.destroy())}if(it.groupPanel){const Qe=typeof it.groupPanel=="object"?it.groupPanel:{},at=new m;at.init({document:mt,grid:Ee,host:J(Ee,mt,(jt,Ft)=>nt.announce?.(jt,Ft)),props:{header:kt.header,hint:Qe.hint}}),kt.root.insertBefore(at.element(),kt.header),Ee.groupPanel=at;for(const jt of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])z(Ee.on)&&st.push(Ee.on(jt,()=>at.refresh()));st.push(()=>at.destroy())}if(it.kpis){const Qe=new Ne({grid:Ee,document:mt,kpis:it.kpis});Qe.active&&(Qe.mount(),kt.root.insertBefore(Qe.element(),kt.header),Ee.kpiStrip=Qe,st.push(()=>Qe.destroy()))}if(it.toolPanel){const Qe=typeof it.toolPanel=="object"?it.toolPanel:{},at=new Q({grid:Ee,document:mt,root:kt.root,panels:Qe.panels,openPanel:Qe.openPanel,side:Qe.side,icons:Qe.icons,actions:Ye(Ee,Qe,Vt),announce:(jt,Ft)=>nt.announce?.(jt,Ft)});at.mount(),Ee.toolPanel=at,st.push(()=>at.destroy()),Qe.annotate===void 0&&(st.push(Ee.on("presentation:started",()=>{for(const jt of Xe(Ee))at.addAction(jt)})),st.push(Ee.on("presentation:ended",()=>{for(const jt of pt)at.removeAction(jt)})))}if(it.pagination){const Qe=typeof it.pagination=="object"?it.pagination:{},at=new p;at.init({document:mt,pageSize:Qe.pageSize,pageSizes:Qe.pageSizes,page:Qe.page,total:Qe.total,locale:Ee.get("locale"),messages:Ee.messages,onChange:({page:Ht,pageSize:nn})=>Ee.pagination.set({page:Ht,pageSize:nn})});const jt=()=>{const Ht=Ee.pagination.get();at.total=Ht.total,at.counting=Ht.counting===!0,at.page=Ht.page,at.paint()};Ee.pagination.set({pageSize:at.pageSize}),jt();const Ft=["rows:changed","filter:changed","model:changed"].map(Ht=>Ee.on(Ht,jt));kt.statusBar.appendChild(at.element()),st.push(()=>{for(const Ht of Ft)Ht();at.destroy?.()})}if(it.edit!==!1)if(it.editBar){const Qe=new ie({grid:Ee,document:mt,root:kt.root});Qe.mount(),Ee.editBar=Qe,st.push(()=>Qe.destroy())}else{const Qe=new re({grid:Ee,document:mt,renderer:nt,registry:It,cellLayer:nt.cellLayer});Qe.mount(),st.push(()=>Qe.destroy())}const an=new o({grid:Ee,document:mt,layer:kt.overlays,registry:It});an.mount(),st.push(()=>an.destroy());const ln=new E({grid:Ee,document:mt,host:kt.root,cellMenu:it.contextMenu!==!1,headerMenu:it.columnMenu!==!1,items:z(it.contextMenu)?it.contextMenu:void 0,headerItems:z(it.columnMenu)?it.columnMenu:void 0});if(ln.mount(),st.push(()=>ln.destroy()),Array.isArray(it.alignedGrids)&&it.alignedGrids.length){const Qe=new K;Qe.add(Ee);for(const at of it.alignedGrids)at&&at!==Ee&&Qe.add(at);st.push(()=>Qe.destroy())}const Dt=new q({grid:Ee,renderer:nt,document:mt,registry:It});Dt.active&&(Dt.mount(),st.push(()=>Dt.destroy())),Object.defineProperty(Ee,"form",{configurable:!0,value:Object.freeze({open(Qe){return Dt.active?Dt.openRow(Qe):!1},close(){Dt.active&&Dt.close()},save(){return Dt.active?Dt.save():!1},isOpen(){return Dt.active?Dt.open:!1}})}),st.push(()=>{delete Ee.form}),Object.defineProperty(Ee,"icons",{configurable:!0,value:Object.freeze({get(Qe){const at=n(Qe);return at?{viewBox:at.viewBox,paths:at.paths.slice(),paint:at.paint==="stroke"?"stroke":"fill"}:null},names(){return i()}})}),st.push(()=>{delete Ee.icons});const un=new D({grid:Ee,renderer:nt,document:mt});un.active&&(un.mount(),st.push(()=>un.destroy()));const cn=new T({grid:Ee,renderer:nt,document:mt});cn.active&&(cn.mount(),st.push(()=>cn.destroy()));const rn=new P({grid:Ee,renderer:nt,document:mt});if(rn.active){rn.mount(),rn.paint();const Qe=Ee.on("render:done",()=>rn.paint());st.push(()=>{Qe(),rn.destroy()})}if(it.shortcuts!==!1){const Qe=new M({grid:Ee,renderer:nt});Qe.mount(),st.push(()=>Qe.destroy())}const wt=new _e({grid:Ee,renderer:nt,window:mt.defaultView||void 0});wt.mount(),st.push(()=>wt.destroy());const Et=new et({grid:Ee,renderer:nt,window:mt.defaultView||void 0});if(Et.mount(),st.push(()=>Et.destroy()),it.find!==!1){const Qe=new Ae({grid:Ee,renderer:nt,document:mt,settings:it.find});Qe.mount(),st.push(()=>Qe.destroy())}const Mt=new Ge({grid:Ee,renderer:nt});Mt.mount(),st.push(()=>Mt.destroy());const Ut=new ut({grid:Ee,renderer:nt});Ut.mount(),st.push(()=>Ut.destroy());const Xt=new Ct({grid:Ee,renderer:nt,maximiser:Vt});Xt.mount(),st.push(()=>Xt.destroy());const Wt=new Jt({grid:Ee,renderer:nt});Wt.mount(),st.push(()=>Wt.destroy()),it.environment||Ee.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 _t=null;for(const[Qe,at]of[["filter:changed","filter"],["sort:changed","sort"],["rows:changed","data"],["column:resized","resize"],["column:moved","columns"],["column:visible","columns"]])st.push(Ee.on(Qe,()=>{_t=at}));st.push(Ee.on("render:done",Qe=>{Ee.diagnostics.render(_t||Qe.cause,Qe.phases),_t=null}));const en=new Te({grid:Ee,renderer:nt});if(en.mount(),st.push(()=>en.destroy()),st.push(Ee.on("presence:lockRefused",Qe=>en.announceRefusal(Qe.peer))),Ee.presence&&Ee.presence.enabled){for(const jt of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])st.push(Ee.on(jt,()=>Ee.presence.publish()));let Qe="";st.push(Ee.on("render:done",()=>{const jt=nt.focusState&&nt.focusState(),Ft=jt?`${jt.rowKey}${jt.colId}`:"";Ft!==Qe&&(Qe=Ft,Ee.presence.publish())}));const at=Rt.ownerDocument;if(at&&z(at.addEventListener)){const jt=()=>Ee.presence.setPaused(at.visibilityState==="hidden");at.addEventListener("visibilitychange",jt),jt(),st.push(()=>at.removeEventListener("visibilitychange",jt))}}const Yt=new de({grid:Ee,renderer:nt});Yt.mount(),st.push(()=>Yt.destroy());const dn=new Ve({grid:Ee,renderer:nt});dn.mount(),st.push(()=>dn.destroy()),st.push(Ee.on("facet:computed",()=>nt.refreshHeader?.())),Kt&&Kt.headerCheckbox===!0&&st.push(Ee.on("selection:changed",()=>nt.refreshHeader?.())),st.push(Ee.on("facet:expanded",()=>nt.invalidate("columns"))),st.push(Ee.on("model:changed",()=>nt.invalidate("rows")));const Gt=(Qe,at)=>nt.announce?.(Qe,at),fn=Ee.messages,zt=(Qe,at)=>fn.t(Qe,at),pn=Qe=>zt("count.rows",{count:Qe});st.push(Ee.on("sort:changed",()=>{const Qe=Ee.sort.get();if(!Qe.length){Gt(zt("a11y.sort.cleared"));return}const at=Qe.map(jt=>{const Ft=Ee.columns.get(jt.col);return zt("a11y.sort.column",{column:Ft&&Ft.title||jt.col,direction:zt(jt.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});Gt(zt("a11y.sort.by",{columns:fn.list(at)}))})),st.push(Ee.on("filter:changed",()=>{const Qe=Ee.rows.matchCount?Ee.rows.matchCount():Ee.rows.count(),at=Ee.rows.totalCount?Ee.rows.totalCount():Qe;Gt(Qe===at?zt("a11y.filter.cleared",{rows:pn(at)}):zt("a11y.filter.applied",{shown:pn(Qe),total:pn(at)}))})),st.push(Ee.on("selection:changed",()=>{const Qe=Ee.selection.keys().length;Gt(Qe===0?zt("a11y.selection.cleared"):zt("a11y.selection.count",{count:Qe}))})),st.push(Ee.on("group:toggled",Qe=>{const at=Ee.rows.byKey?Ee.rows.byKey(Qe.key):null,jt=(at&&(at.groupLabel??at.groupValue))??Qe.key;Gt(zt(Qe.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:jt,rows:pn(Ee.rows.count())}))})),st.push(Ee.on("column:grouped",Qe=>{const at=Array.isArray(Qe.columns)?Qe.columns:[];if(!at.length){Gt(zt("a11y.group.cleared"));return}const jt=at.map(Ft=>{const Ht=Ee.columns.get(Ft);return Ht&&Ht.title||Ft});Gt(zt("a11y.group.by",{columns:fn.list(jt)}))})),st.push(Ee.on("page:changed",Qe=>{const at=Number(Qe.size)||0,jt=Number(Qe.total)||0,Ft=at>0?Math.max(1,Math.ceil(jt/at)):1;Gt(zt("a11y.page.position",{page:(Number(Qe.page)||0)+1,pages:Ft}))}));let tn={added:0,removed:0},qt=null;const En=()=>{qt=null;const Qe=[];tn.added&&Qe.push(zt("count.rowsAdded",{count:tn.added})),tn.removed&&Qe.push(zt("count.rowsRemoved",{count:tn.removed})),tn={added:0,removed:0},Qe.length&&Gt(fn.list(Qe))};st.push(Ee.on("rows:changed",Qe=>{if(!Qe||typeof Qe.added!="number")return;const at=Number(Qe.added)||0,jt=Number(Qe.removed)||0;!at&&!jt||(tn.added+=at,tn.removed+=jt,qt||(qt=setTimeout(En,Fe)))})),st.push(()=>{qt&&clearTimeout(qt)}),st.push(Ee.on("rows:paused",()=>{qt&&(clearTimeout(qt),qt=null),tn={added:0,removed:0},Gt(zt("a11y.updates.paused"),{repeat:!0})})),st.push(Ee.on("rows:resumed",()=>Gt(zt("a11y.updates.resumed"),{repeat:!0})));let hn={count:0,first:null},mn=null;const Sn=()=>{mn=null;const{count:Qe,first:at}=hn;if(hn={count:0,first:null},!Qe||!at)return;const jt=Ee.columns.get(at.colId),Ft=jt&&jt.title||at.colId,Ht=at.reason?zt("a11y.edit.reason",{reason:at.reason}):"";if(Qe===1){const nn=at.restored===void 0||at.restored===null||at.restored===""?zt("value.empty"):String(at.restored);Gt(zt("a11y.edit.refusedOne",{column:Ft,value:nn,reason:Ht}),{repeat:!0});return}Gt(zt("a11y.edit.refusedMany",{count:Qe,reason:Ht}),{repeat:!0})};st.push(Ee.on("cell:reverted",Qe=>{!Qe||!Qe.applied||(hn.count+=1,hn.first||(hn.first=Qe),mn||(mn=setTimeout(Sn,150)))})),st.push(()=>{mn&&clearTimeout(mn)}),st.push(Ee.on("history:applied",Qe=>{const at=!!(Qe&&Qe.direction==="redo"),jt=Qe&&Qe.step&&Qe.step.label;Gt(jt?zt(at?"a11y.history.redo":"a11y.history.undo",{label:jt}):zt(at?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const gn=new $t({grid:Ee,renderer:nt,seed:it.state&&Array.isArray(it.state.annotations)?it.state.annotations:null});gn.mount(),st.push(()=>gn.destroy()),Ee.annotate=gn,Ee.capture=async(Qe={})=>{const{blob:at,width:jt,height:Ft}=await Lt(nt.viewport.root,Qe);return(Qe.download===!0||Qe.download!==!1&&Qe.fileName)&&Z(at,Qe.fileName||`${Ee.get("exportName")||"grid"}.png`),Ee.emit("presentation:captured",{width:jt,height:Ft,bytes:at.size,mimeType:at.type,fileName:Qe.fileName||null},"api"),at};const On=new ft({grid:Ee,document:mt,element:kt.overlays,window:mt.defaultView||void 0});On.mount(),st.push(()=>On.destroy());const Tn=new b({grid:Ee,document:mt,element:kt.overlays});Tn.mount?.(),st.push(()=>Tn.destroy?.());const jn=new v({grid:Ee,host:Ee.rendererHost(),viewport:kt,document:mt});return jn.mount(),st.push(()=>jn.destroy()),st}function St(Ee){const nt=[],it=mt=>{if(mt&&(mt.__lattice&&nt.push(mt),mt.children))for(const It of mt.children)it(It)};return it(Ee),nt}function Ot(Ee,nt={}){(!Ee||typeof Ee!="object"||!("appendChild"in Ee))&&U("createGrid needs a host element as its first argument."),nt=L(nt);const it=Ee.ownerDocument||(typeof document<"u"?document:null);it||U("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const mt=it.documentElement&&it.documentElement.lang,It=!nt.licence&&z(it.querySelector)?it.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,Rt={...nt};if(!nt.locale&&mt&&(Rt.locale=mt),It&&(Rt.licence=It),nt.views&&nt.views.local)if(nt.views.storage)F("views:local:ignored","[lattice] views.local is ignored because views.storage was also supplied; the explicit adapter wins.");else{const Dt=nt.views.local===!0?{}:nt.views.local;Rt.views={...nt.views,storage:O(Dt)}}const st=R(Rt),kt=st.rendererHost();kt.document=it,bt(kt.registry,nt),kt.cellLayer=r(kt),kt.detailHost=new xe({grid:st,document:Ee.ownerDocument||globalThis.document,createGrid:(Dt,un)=>Ot(Dt,un)});const Vt=new d(Ee,kt),Kt=st.on("detail:toggled",()=>{kt.detailHost.syncTarget(),kt.detailHost.prune()}),sn=st.on("config:changed",Dt=>{Dt&&Dt.key==="detail"&&kt.detailHost.reconfigure()});st.on("destroy",()=>{Kt(),sn(),kt.detailHost.destroy()}),kt.detailHost.syncTarget(),st.attachRenderer(Vt),Vt.mount();const an=ht(st,Vt,nt,it,kt.registry,Ee),ln=st.destroy.bind(st);return st.destroy=()=>{for(const Dt of an)try{Dt()}catch{}Ee.__lattice===st&&(Ee.__lattice=null),ln()},Ee.__lattice=st,st}}),ke("packages/dom/src/hydrate.js",function(e,V){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return F}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/dom/src/createGrid.js").createGrid;function W(k,O){for(const y of k.children)if(y.tagName===O.toUpperCase())return y;return null}function Z(k,O){const y=[];for(const d of k.children)d.tagName===O.toUpperCase()&&y.push(d);return y}function H(k,O){const y=R(k.getAttribute)?k.getAttribute("data-field"):null;return y||String(k.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${O}`}function U(k){const O=k.trim();if(O==="")return null;if(O==="true"||O==="false")return O==="true";const y=Number(O);return Number.isFinite(y)&&O!==""?y:O}function z(k){const O=W(k,"thead"),y=W(O||k,"tr"),c=(y?Z(y,"th").length?Z(y,"th"):Z(y,"td"):[]).map((i,s)=>{const l=H(i,s);return{id:l,field:l,title:String(i.textContent||"").trim()||l}}),r=W(k,"tbody"),n=(r?Z(r,"tr"):Z(k,"tr").filter(i=>i!==y)).map((i,s)=>{const l=Z(i,"td"),f={__row:(R(i.getAttribute)?i.getAttribute("data-id"):null)||`row${s}`};return c.forEach((h,g)=>{f[h.field]=l[g]?U(String(l[g].textContent||"")):null}),f});return{columns:c,rows:n}}function F(k,O={}){const{columns:y,rows:d}=z(k),c=k.ownerDocument.createElement("div");return k.parentNode.insertBefore(c,k),k.parentNode.removeChild(k),L(c,{rowKey:"__row",columns:y,rows:d,...O,columns:O.columns!==void 0?O.columns:y,rows:O.rows!==void 0?O.rows:d})}}),ke("packages/dom/src/autoinit.js",function(e,V){"use strict";Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return F}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/dom/src/createGrid.js").createGrid,Z=V("packages/dom/src/hydrate.js").hydrateTable;function H(k,O){const y=[];return R(k.hasAttribute)&&k.hasAttribute(O)&&y.push(k),R(k.querySelectorAll)&&y.push(...k.querySelectorAll(`[${O}]`)),y}function U(k){const O=k.parentNode;if(!O||!O.children)return null;const y=[...O.children],d=y.indexOf(k),c=[y[d+1],y[d-1]];for(const r of c)if(r&&r.tagName==="SCRIPT"&&R(r.getAttribute)&&r.hasAttribute("data-lattice-config"))return r;return null}function z(k){const O=U(k);if(!O)return{};try{return JSON.parse(O.textContent||"{}")}catch(y){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",y),{}}}function F(k){const O=k||(typeof document<"u"?document:null);if(!O)return[];const y=[];for(const d of H(O,"data-lattice-grid")){if(d.__lattice)continue;const c=z(d);y.push(d.tagName==="TABLE"?Z(d,c):L(d,c))}return y}}),ke("packages/dom/src/index.js",function(e,V){"use strict";Object.defineProperty(e,"LatticeGrid",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return M}});const _=V("packages/dom/src/createGrid.js"),R=_.createGrid,$=V("packages/dom/src/hydrate.js"),L=$.hydrateTable,W=V("packages/dom/src/autoinit.js"),Z=W.autoInit,H=V("packages/dom/src/localviews.js"),U=H.createLocalViewStorage,z=V("packages/core/src/index.js"),F=z.createHeadlessGrid,k=z.registerModules,O=z.setLicence,y=z.version,d=z.getVersion,c=z.serialiseState,r=z.restoreState,t=z.defaults;Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return _.createGrid}}),Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return _.gridElementsWithin}});const n=V("packages/dom/src/stat.js");Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return n.createStat}}),Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return n.deltaOf}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return n.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 H.createLocalViewStorage}}),Object.defineProperty(e,"DEFAULT_VIEWS_KEY",{enumerable:!0,get:function(){return H.DEFAULT_VIEWS_KEY}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return z.createHeadlessGrid}}),Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return z.defaults}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return z.version}}),Object.defineProperty(e,"getVersion",{enumerable:!0,get:function(){return z.getVersion}}),Object.defineProperty(e,"Grid",{enumerable:!0,get:function(){return z.Grid}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return z.EventBus}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return z.Registry}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return z.sharedRegistry}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return z.registerModules}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return z.parseLicence}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return z.verifyLicence}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return z.licenceInfo}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return z.watermark}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return z.setLicence}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return z.licenceState}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return z.isLocalHost}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return z.matchesDomain}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return z.LicenceHolder}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return z.ColumnModel}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return z.buildGraph}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return z.Lookup}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return z.ValuePipeline}}),Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return z.compileFormat}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return z.compileMask}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return z.specToOoxml}}),Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return z.EXTENDED_TYPES}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return z.createRadixType}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return z.RADIX_PRESETS}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return z.parseRadix}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return z.formatRadix}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return z.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return z.registerUnitSystem}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return z.defineUnit}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return z.UNIT_SYSTEMS}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return z.parseUnit}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return z.formatUnit}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return z.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return z.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return z.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return z.convertMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return z.rateFunction}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return z.MISSING_RATE}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return z.Messages}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return z.createMessages}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return z.auditCatalogue}}),Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return z.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return z.MESSAGE_KEYS}}),Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return z.DEFAULT_LOCALE}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return z.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return z.resolveLocale}}),Object.defineProperty(e,"LOCALES",{enumerable:!0,get:function(){return z.LOCALES}}),Object.defineProperty(e,"resolveCatalogue",{enumerable:!0,get:function(){return z.resolveCatalogue}}),Object.defineProperty(e,"EN_US",{enumerable:!0,get:function(){return z.EN_US}}),Object.defineProperty(e,"FR_FR",{enumerable:!0,get:function(){return z.FR_FR}}),Object.defineProperty(e,"FR_CA",{enumerable:!0,get:function(){return z.FR_CA}}),Object.defineProperty(e,"IT_IT",{enumerable:!0,get:function(){return z.IT_IT}}),Object.defineProperty(e,"ES_ES",{enumerable:!0,get:function(){return z.ES_ES}}),Object.defineProperty(e,"PT_BR",{enumerable:!0,get:function(){return z.PT_BR}}),Object.defineProperty(e,"DE_DE",{enumerable:!0,get:function(){return z.DE_DE}}),Object.defineProperty(e,"NL_NL",{enumerable:!0,get:function(){return z.NL_NL}}),Object.defineProperty(e,"SV_SE",{enumerable:!0,get:function(){return z.SV_SE}}),Object.defineProperty(e,"DA_DK",{enumerable:!0,get:function(){return z.DA_DK}}),Object.defineProperty(e,"NB_NO",{enumerable:!0,get:function(){return z.NB_NO}}),Object.defineProperty(e,"FI_FI",{enumerable:!0,get:function(){return z.FI_FI}}),Object.defineProperty(e,"PL_PL",{enumerable:!0,get:function(){return z.PL_PL}}),Object.defineProperty(e,"CS_CZ",{enumerable:!0,get:function(){return z.CS_CZ}}),Object.defineProperty(e,"HU_HU",{enumerable:!0,get:function(){return z.HU_HU}}),Object.defineProperty(e,"RO_RO",{enumerable:!0,get:function(){return z.RO_RO}}),Object.defineProperty(e,"UK_UA",{enumerable:!0,get:function(){return z.UK_UA}}),Object.defineProperty(e,"EL_GR",{enumerable:!0,get:function(){return z.EL_GR}}),Object.defineProperty(e,"JA_JP",{enumerable:!0,get:function(){return z.JA_JP}}),Object.defineProperty(e,"AR",{enumerable:!0,get:function(){return z.AR}}),Object.defineProperty(e,"AR_SA",{enumerable:!0,get:function(){return z.AR_SA}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return z.ColumnStore}}),Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return z.Bitset}}),Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return z.Dictionary}}),Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return z.MultiValue}}),Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return z.MaskPool}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return z.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return z.sortMulti}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return z.evaluateFilters}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return z.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return z.testValue}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return z.groupByColumns}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return z.total}}),Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return z.TOTAL_FNS}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return z.pivot}}),Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return z.Window}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return z.openWindow}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return z.WINDOW_KINDS}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return z.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return z.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return z.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return z.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return z.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return z.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return z.anomalyCondition}}),Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return z.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return z.forecast}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return z.evaluateFormula}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return z.parseFormula}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return z.referencesOf}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return z.looksLikeFormula}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return z.FormulaError}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return z.FUNCTIONS}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return z.compileRules}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return z.ingest}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return z.ingestSync}}),Object.defineProperty(e,"createSource",{enumerable:!0,get:function(){return z.createSource}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return z.createMemorySource}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return z.createPagedSource}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return z.createRemoteSource}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return z.createStreamSource}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return z.createUrlSource}}),Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return z.PROTOCOL}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return z.createPushdownSource}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return z.planQuery}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return z.splitFilters}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return z.applyResidual}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return z.capabilitiesOf}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return z.resolveMutate}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return z.NO_CAPABILITIES}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return z.odataAdapter}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return z.filtersToOData}}),Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return z.conditionToOData}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return z.restAdapter}}),Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return z.DEFAULT_PARAMS}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return z.dfqlAdapter}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return z.duckdbAdapter}}),Object.defineProperty(e,"filtersToSql",{enumerable:!0,get:function(){return z.filtersToSql}}),Object.defineProperty(e,"graphqlAdapter",{enumerable:!0,get:function(){return z.graphqlAdapter}}),Object.defineProperty(e,"RowModel",{enumerable:!0,get:function(){return z.RowModel}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return z.createRowKey}}),Object.defineProperty(e,"SelectionModel",{enumerable:!0,get:function(){return z.SelectionModel}}),Object.defineProperty(e,"RangeModel",{enumerable:!0,get:function(){return z.RangeModel}}),Object.defineProperty(e,"EditModel",{enumerable:!0,get:function(){return z.EditModel}}),Object.defineProperty(e,"ChangeModel",{enumerable:!0,get:function(){return z.ChangeModel}}),Object.defineProperty(e,"StateModel",{enumerable:!0,get:function(){return z.StateModel}}),Object.defineProperty(e,"STATE_VERSION",{enumerable:!0,get:function(){return z.STATE_VERSION}}),Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return z.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return z.restoreState}}),Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return z.VERSION}});const i=V("packages/dom/src/renderer/index.js");Object.defineProperty(e,"DomRenderer",{enumerable:!0,get:function(){return i.DomRenderer}});const s=V("packages/dom/src/filtermenu.js");Object.defineProperty(e,"FilterMenu",{enumerable:!0,get:function(){return s.FilterMenu}}),Object.defineProperty(e,"mergeColumnFilter",{enumerable:!0,get:function(){return s.mergeColumnFilter}}),Object.defineProperty(e,"branchFor",{enumerable:!0,get:function(){return s.branchFor}});const l=V("packages/dom/src/columnmenu.js");Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return l.ColumnMenu}}),Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return l.columnMenuItems}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return l.cellMenuItems}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return l.autoGroupMenuItems}});const u=V("packages/dom/src/alignedgrids.js");Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return u.AlignedGrids}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return u.alignGrids}}),Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return u.layoutState}});const f=V("packages/dom/src/toolpanelmount.js");Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return f.ToolPanelDock}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return f.panelHost}}),Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return f.mountPanel}});const h=V("packages/dom/src/celledit.js");Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return h.CellEditController}});const g=V("packages/dom/src/editbar.js");Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return g.EditBar}});const b=V("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=V("packages/dom/src/diffpaint.js");Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return p.DiffPainter}});const m=V("packages/dom/src/viewpicker.js");Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return m.ViewPicker}}),Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return m.VIEW_CLS}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return m.summariseDiff}});const w=V("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 v=V("packages/dom/src/cell/index.js");Object.defineProperty(e,"createCellLayer",{enumerable:!0,get:function(){return v.createCellLayer}}),Object.defineProperty(e,"compileTemplate",{enumerable:!0,get:function(){return v.compileTemplate}}),Object.defineProperty(e,"compileVariant",{enumerable:!0,get:function(){return v.compileVariant}}),Object.defineProperty(e,"checkVariant",{enumerable:!0,get:function(){return v.checkVariant}}),Object.defineProperty(e,"VariantRegistry",{enumerable:!0,get:function(){return v.VariantRegistry}}),Object.defineProperty(e,"BUILTIN_RENDERERS",{enumerable:!0,get:function(){return v.BUILTIN_RENDERERS}}),Object.defineProperty(e,"BUILTIN_VARIANTS",{enumerable:!0,get:function(){return v.BUILTIN_VARIANTS}}),Object.defineProperty(e,"BUILTIN_PIPES",{enumerable:!0,get:function(){return v.BUILTIN_PIPES}}),Object.defineProperty(e,"sanitiseHtml",{enumerable:!0,get:function(){return v.sanitiseHtml}});const a=V("packages/dom/src/editors/index.js");Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return a.editors}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return a.createEditor}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return a.editorFor}}),Object.defineProperty(e,"BaseEditor",{enumerable:!0,get:function(){return a.BaseEditor}});const o=V("packages/dom/src/filters/index.js");Object.defineProperty(e,"filters",{enumerable:!0,get:function(){return o.filters}}),Object.defineProperty(e,"createFilter",{enumerable:!0,get:function(){return o.createFilter}}),Object.defineProperty(e,"filterFor",{enumerable:!0,get:function(){return o.filterFor}}),Object.defineProperty(e,"parseExpression",{enumerable:!0,get:function(){return o.parseExpression}});const S=V("packages/dom/src/ui/index.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return S.StatusBar}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return S.ContextMenu}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return S.ToolPanel}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return S.TooltipManager}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return S.Pagination}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return S.OverlayLayer}});const E=V("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 A=Object.freeze({createGrid:R,createHeadlessGrid:F,defaults:t,registerModules:k,setLicence:O,version:y,autoInit:Z,hydrateTable:L,serialiseState:c,restoreState:r,createLocalViewStorage:U}),M=A});try{Bn("packages/worker/src/inline.js").setWorkerSource('(function(gt){"use strict";var et=Object.create(null),tt=Object.create(null);function Se(o,fe){et[o]=fe}function nt(o){var fe=tt[o];if(fe)return fe;var le=Object.create(null);tt[o]=le;var ae=et[o];if(!ae)throw new Error("[lattice] missing module: "+o);return ae(le,nt),le}Se("packages/core/src/internal/util.js",function(o,fe){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return z}}),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 g}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return d}}),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 b}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return se}});const le="1.71.1";async function ae(){return le}const Q="1.71.1",q=new Set,te=2e3;function _(T){if(q.add(T),q.size>te){const L=q.values().next().value;L!==void 0&&q.delete(L)}}const F=[],H=500;function ne(T,L,J){F.push({key:T,level:L,message:J.map(he=>typeof he=="string"?he:x(he)).join(" "),at:Date.now()}),F.length>H&&F.shift()}function x(T){if(T instanceof Error)return T.message;try{return JSON.stringify(T)}catch{return String(T)}}function ce(){return F.map(T=>({...T}))}function ie(T,...L){q.has(T)||(_(T),ne(T,"warn",L),console.warn("[lattice]",...L))}function G(T,...L){q.has(T)||(_(T),ne(T,"info",L),console.info("[lattice]",...L))}function D(){q.clear(),F.length=0}function Y(T,L){const J=new Error(`[lattice] ${T}`);throw L!==void 0&&(J.cause=L),J}function ee(T,L){T||Y(L)}const z=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function M(T){return T!==null&&typeof T=="object"&&!Array.isArray(T)}function i(T){return typeof T=="function"}function s(T){return T==null}function u(T){return T==null||T===""}function f(T){return typeof T!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(T))?!0:!!(T.prototype&&Object.getOwnPropertyNames(T.prototype).length>1)}const c=new Map;function t(T){let L=c.get(T);if(L)return L;if(!T.includes("."))L=J=>J?.[T];else{const J=T.split("."),he=J.length;L=ye=>{let Me=ye;for(let Pe=0;Pe<he;Pe++){if(Me==null)return;Me=Me[J[Pe]]}return Me}}return c.set(T,L),L}const a=new Map;function g(T){let L=a.get(T);if(L)return L;if(!T.includes("."))L=(J,he)=>{J!=null&&(J[T]=he)};else{const J=T.split("."),he=J.length-1;L=(ye,Me)=>{let Pe=ye;for(let Ne=0;Ne<he;Ne++){if(Pe==null)return;const je=J[Ne];Pe[je]==null&&(Pe[je]={}),Pe=Pe[je]}Pe!=null&&(Pe[J[he]]=Me)}}return a.set(T,L),L}function e(T,L){return t(L)(T)}function m(T,L,J){g(L)(T,J)}function d(T){return T?(T.includes(".")?T.slice(T.lastIndexOf(".")+1):T).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(/^./,J=>J.toUpperCase()):""}const r={"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#39;"};function n(T){const L=T==null?"":String(T);return/[&<>"\']/.test(L)?L.replace(/[&<>"\']/g,J=>r[J]):L}function l(T){return String(T).replace(/\\w\\S*/g,L=>L[0].toUpperCase()+L.slice(1).toLowerCase())}function b(T,L,J){if(T!==void 0)return T===!0?{enabled:!0,...J}:T===!1?{enabled:!1}:M(T)?T:{[L]:T,enabled:!0}}function E(T){return T==null?[]:Array.isArray(T)?T:[T]}const S=Object.freeze(new Set(["__proto__","constructor","prototype"]));function V(T,L){if(!M(T))return M(L)?{...L}:L;if(!M(L))return L===void 0?T:L;const J={...T};for(const he of Object.keys(L)){if(S.has(he))continue;const ye=L[he];ye!==void 0&&(J[he]=M(ye)&&M(J[he])?V(J[he],ye):ye)}return J}function U(T,L){if(!M(T)||!M(L)||T===L)return L;const J=Object.create(Object.getPrototypeOf(T));return Object.assign(J,T,L),J}class I{#t;#e=new Map;#n;constructor(L=256,J=null){this.#t=L,this.#n=J}get size(){return this.#e.size}get max(){return this.#t}set max(L){this.#t=L,this.#r()}has(L){return this.#e.has(L)}get(L){const J=this.#e;if(!J.has(L))return;const he=J.get(L);return J.delete(L),J.set(L,he),he}peek(L){return this.#e.get(L)}set(L,J){const he=this.#e;return he.has(L)&&he.delete(L),he.set(L,J),this.#r(),J}delete(L){const J=this.#e.get(L);return this.#e.delete(L)&&this.#n&&this.#n(J,L),J}clear(){if(this.#n)for(const[L,J]of this.#e)this.#n(J,L);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const L=this.#e;for(;L.size>this.#t;){const J=L.keys().next().value,he=L.get(J);L.delete(J),this.#n&&this.#n(he,J)}}}const X=new Map;function C(T,L){const J=`${T||""}|${L?JSON.stringify(L):""}`;let he=X.get(J);return he||(he=new Intl.Collator(T||void 0,{numeric:!0,sensitivity:"variant",...L}),X.set(J,he)),he}function R(T,L){if(T===L)return 0;if(T==null)return 1;if(L==null)return-1;if(typeof T=="number"&&typeof L=="number")return Number.isNaN(T)?Number.isNaN(L)?0:1:Number.isNaN(L)||T<L?-1:T>L?1:0;const J=String(T),he=String(L);return J<he?-1:J>he?1:0}function h(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const O=typeof requestAnimationFrame=="function";function w(T){return O?requestAnimationFrame(T):setTimeout(()=>T(h()),16)}function P(T){T!=null&&(O?cancelAnimationFrame(T):clearTimeout(T))}function v(T){let L=null,J=null;const he=()=>{L=null;const Me=J;J=null,T(...Me||[])},ye=(...Me)=>{J=Me,L===null&&(L=w(he))};return ye.cancel=()=>{P(L),L=null,J=null},ye.flush=()=>{L!==null&&(P(L),he())},ye}function K(T,L){let J=null,he=null;const ye=()=>{if(J=null,he===null)return;const Ne=he;he=null,T(...Ne),Me()},Me=()=>{J=setTimeout(ye,L),typeof J?.unref=="function"&&J.unref()},Pe=(...Ne)=>{J===null?(T(...Ne),Me()):(he=Ne,clearTimeout(J),Me())};return Pe.flush=()=>{if(J!==null&&clearTimeout(J),J=null,he===null)return;const Ne=he;he=null,T(...Ne)},Pe.cancel=()=>{J!==null&&clearTimeout(J),J=null,he=null},Pe.pending=()=>J!==null||he!==null,Pe}function Z(T,L=50){return typeof requestIdleCallback=="function"?requestIdleCallback(T,{timeout:L}):setTimeout(()=>T({timeRemaining:()=>0,didTimeout:!0}),1)}let oe=0;function se(T="l"){return`${T}${(++oe).toString(36)}`}}),Se("packages/worker/src/transport.js",function(o,fe){"use strict";Object.defineProperty(o,"PROTOCOL",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"OPS",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"ERRORS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"packHandle",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"packHandles",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"TransportedDictionary",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const le=fe("packages/core/src/internal/util.js"),ae=le.collator,Q=le.isFunction,q=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"}),_=Object.freeze({READY:"ready",CANCEL:"cancel",PING:"ping"}),F=Object.freeze({NO_COMPUTE:"E_NO_COMPUTE",NO_KERNEL:"E_NO_KERNEL",ABORTED:"E_ABORTED",KERNEL:"E_KERNEL",PROTOCOL:"E_PROTOCOL"});function H(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?ne(s.dict):null,offsets:s.offsets??null,version:s.version??0}}function ne(s){return Array.isArray(s)?s:Q(s.values)?s.values():[]}function x(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=H(s[f]);return u}class ce{#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 ie{#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 g=ae(u).compare,e=this.#t,m=Array.from(a).sort((r,n)=>{const l=e[r],b=e[n];return l===b?0:l==null?1:b==null?-1:g(String(l),String(b))}),d=new Uint32Array(t);for(let r=0;r<m.length;r++)d[m[r]]=r;return this.#r.set(f,{version:this.#n,ranks:d}),d}}function G(s){if(s==null)return null;const u=s.presence?new ce(s.presence,s.presenceBits||s.presence.length*8):null,f=s.dict?new ie(s.dict):null,c=s.values,t=s.offsets??null,a=s.kind,g=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 m=t[e],d=t[e+1],r=new Array(d-m);for(let n=m;n<d;n++)r[n-m]=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:g,version:s.version}}function D(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=G(s[f]);return u}function Y(){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 ee(s){if(!ArrayBuffer.isView(s))return!1;const u=s.buffer;return u?typeof SharedArrayBuffer>"u"||!(u instanceof SharedArrayBuffer):!1}function z(s,u=[]){const f=c=>{if(!ee(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,fe){"use strict";Object.defineProperty(o,"Bitset",{enumerable:!0,get:function(){return ae}});const le=8;class ae{static#t=new Uint8Array(256);static{for(let q=1;q<256;q++)ae.#t[q]=ae.#t[q>>1]+(q&1)}#e;#n;constructor(q=0){const te=Math.max(0,q|0);this.#n=te,this.#e=new Uint8Array(Math.ceil(te/le))}get size(){return this.#n}get words(){return this.#e}get bytes(){return this.#e?this.#e.byteLength:0}get(q){return q<0||q>=this.#n?0:this.#e[q>>3]>>(q&7)&1}set(q){return q>=0&&q<this.#n&&(this.#e[q>>3]|=1<<(q&7)),this}clear(q){return q>=0&&q<this.#n&&(this.#e[q>>3]&=~(1<<(q&7))),this}assign(q,te){return te?this.set(q):this.clear(q)}fill(q=!1){return this.#e.fill(q?255:0),q&&this.#r(),this}grow(q){const te=Math.max(0,q|0);if(te<=this.#n)return this;const _=Math.ceil(te/le);if(_>this.#e.length){const F=new Uint8Array(_);F.set(this.#e),this.#e=F}return this.#n=te,this}count(){const q=this.#e,te=ae.#t;let _=0;for(let F=0;F<q.length;F++)_+=te[q[F]];return _}and(q){const te=q instanceof ae?q.words:q,_=this.#e,F=Math.min(_.length,te.length);for(let H=0;H<F;H++)_[H]&=te[H];for(let H=F;H<_.length;H++)_[H]=0;return this}or(q){const te=q instanceof ae?q.words:q,_=this.#e,F=Math.min(_.length,te.length);for(let H=0;H<F;H++)_[H]|=te[H];return this}not(){const q=this.#e;for(let te=0;te<q.length;te++)q[te]=~q[te]&255;return this.#r(),this}clone(){const q=new ae(this.#n);return q.words.set(this.#e.subarray(0,q.words.length)),q}release(){this.#e=new Uint8Array(0),this.#n=0}#r(){const q=this.#n&7;if(q===0)return;const te=this.#n>>3;te<this.#e.length&&(this.#e[te]&=(1<<q)-1)}static from(q){const te=Array.isArray(q)?q:Array.from(q),_=new ae(te.length);for(let F=0;F<te.length;F++)te[F]&&_.set(F);return _}}}),Se("packages/core/src/store/dictionary.js",function(o,fe){"use strict";Object.defineProperty(o,"Dictionary",{enumerable:!0,get:function(){return q}});const le=fe("packages/core/src/internal/util.js"),ae=le.collator,Q=le.defaultCompare;class q{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(_=[]){this.#t=[];for(let F=0;F<_.length;F++){const H=_[F];this.#e.has(H)||(this.#e.set(H,this.#t.length),this.#t.push(H))}}get size(){return this.#t.length}get version(){return this.#n}get bytes(){let _=this.#t.length*8;for(let F=0;F<this.#t.length;F++){const H=this.#t[F];typeof H=="string"&&(_+=H.length*2),_+=16}return _}codeOf(_){const F=this.#e.get(_);if(F!==void 0)return F;const H=this.#t.length;return this.#t.push(_),this.#e.set(_,H),this.#n++,H}lookup(_){const F=this.#e.get(_);return F===void 0?-1:F}has(_){return this.#e.has(_)}valueOf(_){return this.#t[_]}values(){return this.#t}ranks(_){const F=_||"";if(this.#r&&this.#i===this.#n&&this.#s===F)return this.#r;const H=this.#t.length,ne=new Array(H);for(let G=0;G<H;G++)ne[G]=G;const x=ae(_).compare,ce=this.#t;ne.sort((G,D)=>this.#h(ce[G],ce[D],x));const ie=new Uint32Array(H);for(let G=0;G<H;G++)ie[ne[G]]=G;return this.#r=ie,this.#i=this.#n,this.#s=F,ie}#h(_,F,H){return typeof _=="string"&&typeof F=="string"?H(_,F):Q(_,F)}}}),Se("packages/core/src/store/multivalue.js",function(o,fe){"use strict";Object.defineProperty(o,"MultiValue",{enumerable:!0,get:function(){return le}});class le{#t;#e;#n=0;#r=0;constructor(Q={}){const q=Math.max(1,Q.rows??16),te=Math.max(1,Q.values??q);this.#t=new Int32Array(te),this.#e=new Uint32Array(q+1)}get values(){return this.#t}get offsets(){return this.#e}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#t.byteLength+this.#e.byteLength}count(Q){return Q<0||Q>=this.#n?0:this.#e[Q+1]-this.#e[Q]}at(Q){return Q<0||Q>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[Q],this.#e[Q+1])}has(Q,q){if(Q<0||Q>=this.#n)return!1;const te=this.#t,_=this.#e[Q+1];for(let F=this.#e[Q];F<_;F++)if(te[F]===q)return!0;return!1}hasAny(Q,q){for(let te=0;te<q.length;te++)if(this.has(Q,q[te]))return!0;return!1}hasAll(Q,q){for(let te=0;te<q.length;te++)if(!this.has(Q,q[te]))return!1;return!0}hasNone(Q,q){return!this.hasAny(Q,q)}push(Q){const q=this.#n,te=Q.length;this.#i(q+1),this.#s(this.#r+te);const _=this.#r;for(let F=0;F<te;F++)this.#t[_+F]=Q[F]|0;return this.#r+=te,this.#n=q+1,this.#e[q]=_,this.#e[q+1]=this.#r,q}write(Q,q){if(Q===this.#n){this.push(q);return}if(Q<0||Q>this.#n)return;const te=this.#e[Q],_=this.#e[Q+1],F=q.length;if(_-te===F){for(let H=0;H<F;H++)this.#t[te+H]=q[H]|0;return}this.#h(Q,q)}compact(Q,q,te){const _=this.#t,F=this.#e,H=this.#n,ne=new Int32Array(Math.max(1,this.#r)),x=new Uint32Array(q+1);let ce=0;for(let ie=0;ie<H;ie++){if(Q[ie]===te)continue;const G=F[ie],D=F[ie+1];x[Q[ie]]=ce;for(let Y=G;Y<D;Y++)ne[ce++]=_[Y];x[Q[ie]+1]=ce}this.#t=ne,this.#e=x,this.#n=q,this.#r=ce}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(Q){if(Q+1<=this.#e.length)return;let q=this.#e.length-1;for(;q<Q;)q=q*2||16;const te=new Uint32Array(q+1);te.set(this.#e),this.#e=te}#s(Q){if(Q<=this.#t.length)return;let q=this.#t.length;for(;q<Q;)q=q*2||16;const te=new Int32Array(q);te.set(this.#t),this.#t=te}#h(Q,q){const te=this.#t,_=this.#e,F=this.#n,H=q.length-(_[Q+1]-_[Q]),ne=new Int32Array(Math.max(1,this.#r+H)),x=new Uint32Array(_.length);let ce=0;for(let ie=0;ie<F;ie++){if(x[ie]=ce,ie===Q)for(let G=0;G<q.length;G++)ne[ce++]=q[G]|0;else for(let G=_[ie];G<_[ie+1];G++)ne[ce++]=te[G];x[ie+1]=ce}this.#t=ne,this.#e=x,this.#r=ce}}}),Se("packages/core/src/compute/handle.js",function(o,fe){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return M}});const le=fe("packages/core/src/internal/util.js"),ae=le.collator,Q=le.defaultCompare,q=le.warnOnce;function te(i){const s=new Uint32Array(i);for(let u=0;u<i;u++)s[u]=u;return s}function _(i,s){if(s&&typeof s.count=="number")return s.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const u=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):u?i.kind==="bitset"?typeof u.size=="number"?u.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(q(`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 F=new WeakMap;function H(i){const s=i.constructor;if(!s)return"unknown";const u=F.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 F.set(s,f),f}function ne(i){if(!i)return()=>0;const s=i instanceof Uint8Array?i:i.words;if(s instanceof Uint8Array){const u=i instanceof Uint8Array?"lsb":H(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 x(i){return!i||!i.presence?null:ne(i.presence)}function ce(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function ie(i,s){return i?typeof i.valueOf=="function"?i.valueOf(s):typeof i.values=="function"?i.values()[s]:null:null}function G(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,g=new Array(t-c);for(let e=c;e<t;e++)g[e-c]=a?ie(a,f[e]):f[e];return g}function D(i){if(!i)return()=>{};const s=i.values,u=x(i),f=i.kind;if(f==="dictionary"){const c=i.dict;return u?t=>u(t)?ie(c,s[t]):null:t=>ie(c,s[t])}if(f==="bitset"){const c=ne(s);return u?t=>u(t)?c(t)===1:null:t=>c(t)===1}if(f==="multi")return u?c=>u(c)?G(i,c):null:c=>G(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 Y(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 ee(i){const s=ae(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 Y(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),g=f instanceof Date?f.getTime():Number(f);return Y(a,g)}return Q(u,f)}}function z(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=ee(s),t=new Array(f);for(let g=0;g<f;g++)t[g]=g;t.sort((g,e)=>c(u[g],u[e])||g-e);const a=new Uint32Array(f);for(let g=0;g<f;g++)a[t[g]]=g;return a}function M(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Se("packages/core/src/compute/sort.js",function(o,fe){"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 g}}),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 U}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return I}});const le=fe("packages/core/src/compute/handle.js"),ae=le.bitReader,Q=le.dictRanks,q=le.dictSize,te=le.identity,_=le.isMissing,F=le.presenceReader,H=le.rowCount,ne=le.valueComparator,x=le.valueReader,ce=new Uint32Array(0),ie=new ArrayBuffer(8),G=new Float64Array(ie),D=new Uint32Array(ie),Y=(G[0]=-1,(D[1]&2147483648)!==0?1:0),ee=Y===1?0:1;function z(C,R){G[0]=C;let h=D[Y],O=D[ee];(h&2147483648)!==0?(h=~h>>>0,O=~O>>>0):h=(h^2147483648)>>>0,R[0]=O,R[1]=h}function M(C,R,h,O){if(O<2)return C;const w=new Uint32Array(256*8);for(let L=0;L<O;L++){const J=R[L],he=h[L];w[J&255]++,w[256+(J>>>8&255)]++,w[512+(J>>>16&255)]++,w[768+(J>>>24&255)]++,w[1024+(he&255)]++,w[1280+(he>>>8&255)]++,w[1536+(he>>>16&255)]++,w[1792+(he>>>24&255)]++}let P=C,v=R,K=h,Z=new Uint32Array(O),oe=new Uint32Array(O),se=new Uint32Array(O);const T=new Uint32Array(256);for(let L=0;L<8;L++){const J=L<<8,he=(L&3)<<3,ye=L>=4;let Me=!1;for(let je=0;je<256;je++)if(w[J+je]===O){Me=!0;break}if(Me)continue;let Pe=0;for(let je=0;je<256;je++)T[je]=Pe,Pe+=w[J+je];for(let je=0;je<O;je++){const Ve=v[je],We=K[je],Xe=(ye?We:Ve)>>>he&255,qe=T[Xe]++;Z[qe]=P[je],oe[qe]=Ve,se[qe]=We}let Ne=P;P=Z,Z=Ne,Ne=v,v=oe,oe=Ne,Ne=K,K=se,se=Ne}return P}function i(C,R,h){if(h<2)return C;const O=new Uint32Array(256*4);for(let oe=0;oe<h;oe++){const se=R[oe];O[se&255]++,O[256+(se>>>8&255)]++,O[512+(se>>>16&255)]++,O[768+(se>>>24&255)]++}let w=C,P=R,v=new Uint32Array(h),K=new Uint32Array(h);const Z=new Uint32Array(256);for(let oe=0;oe<4;oe++){const se=oe<<8,T=oe<<3;let L=!1;for(let ye=0;ye<256;ye++)if(O[se+ye]===h){L=!0;break}if(L)continue;let J=0;for(let ye=0;ye<256;ye++)Z[ye]=J,J+=O[se+ye];for(let ye=0;ye<h;ye++){const Me=P[ye],Pe=Z[Me>>>T&255]++;v[Pe]=w[ye],K[Pe]=Me}let he=w;w=v,v=he,he=P,P=K,K=he}return w}function s(C,R,h,O){const w=new Uint32Array(O+1);for(let K=0;K<h;K++)w[R[K]]++;let P=0;for(let K=0;K<=O;K++){const Z=w[K];w[K]=P,P+=Z}const v=new Uint32Array(h);for(let K=0;K<h;K++)v[w[R[K]]++]=C[K];return v}function u(C,R,h,O){return h<2?C:O<=65536||O<=h*2?s(C,R,h,O):i(C,R,h)}function f(C,R){return C.length===R&&C.byteOffset===0?C:Uint32Array.prototype.slice.call(C,0,R)}function c(C,R,h=!1){const O=R||te(C.length),w=O.length;if(w<2)return Uint32Array.from(O);const P=new Uint32Array(w),v=new Uint32Array(w),K=new Uint32Array(w),Z=new Uint32Array(w),oe=new Uint32Array(2);let se=0,T=0;for(let he=0;he<w;he++){const ye=O[he],Me=C[ye];if(Number.isNaN(Me)){Z[T++]=ye;continue}z(Me,oe),h?(v[se]=~oe[0]>>>0,K[se]=~oe[1]>>>0):(v[se]=oe[0],K[se]=oe[1]),P[se++]=ye}const L=M(P.subarray(0,se),v.subarray(0,se),K.subarray(0,se),se);if(T===0)return f(L,se);const J=new Uint32Array(w);return J.set(L.subarray(0,se),0),J.set(Z.subarray(0,T),se),J}function t(C,R,h=!1){const O=R||te(C.length),w=O.length;if(w<2)return Uint32Array.from(O);const P=Uint32Array.from(O),v=new Uint32Array(w);for(let K=0;K<w;K++){const Z=(C[P[K]]^2147483648)>>>0;v[K]=h?~Z>>>0:Z}return f(i(P,v,w),w)}function a(C,R,h={}){const O=R||te(H(C,h)),w=O.length;if(w<2)return Uint32Array.from(O);const P=Q(C.dict,h.locale),v=C.values,K=F(C),Z=Math.max(q(C.dict),P.length),oe=Z,se=Uint32Array.from(O),T=new Uint32Array(w),L=!!h.descending;for(let J=0;J<w;J++){const he=se[J];let ye=K&&K(he)===0?oe:P[v[he]];ye===void 0&&(ye=oe),T[J]=L?oe-ye:ye}return f(u(se,T,w,Z+1),w)}function g(C,R,h){const O=R.length;let w=Uint32Array.from(R);if(O<2)return w;let P=new Uint32Array(O);for(let v=1;v<O;v<<=1){for(let Z=0;Z<O;Z+=v<<1){const oe=Math.min(Z+v,O),se=Math.min(Z+(v<<1),O);let T=Z,L=oe,J=Z;for(;T<oe&&L<se;)P[J++]=h(C[w[T]],C[w[L]])<=0?w[T++]:w[L++];for(;T<oe;)P[J++]=w[T++];for(;L<se;)P[J++]=w[L++]}const K=w;w=P,P=K}return w}function e(C,R,h){const O=ae(C.values),w=R.length,P=new Uint32Array(w),v=h?1:0;let K=0;for(let Z=0;Z<w;Z++)O(R[Z])===v&&(P[K++]=R[Z]);for(let Z=0;Z<w;Z++)O(R[Z])!==v&&(P[K++]=R[Z]);return P}function m(C,R){const h=C.values,O=C.kind;if((O==="object"||O===void 0)&&(Array.isArray(h)||ArrayBuffer.isView(h))&&!C.presence)return h;const P=x(C),v=new Array(H(C)||0);for(let K=0;K<R.length;K++){const Z=R[K];v[Z]=P(Z)}return v}function d(C,R){for(let h=0;h<R.length;h++)if(typeof C[R[h]]!="string")return!1;return!0}function r(C,R,h,O,w){const P=C.length,v=Uint32Array.from(C);if(P<2||O<1)return v;const K=new Uint32Array(P),Z=O-1;for(let oe=0;oe<P;oe++){const se=h[R[oe]];K[oe]=w?Z-se:se}return f(u(v,K,P,O),P)}function n(C,R,h){const O=ne(h),w=new Array(R);for(let v=0;v<R;v++)w[v]=v;w.sort((v,K)=>O(C[v],C[K])||v-K);const P=new Uint32Array(R);for(let v=0;v<R;v++)P[w[v]]=v;return P}function l(C,R,h){const O=R.length,w=new Map,P=[],v=new Uint32Array(O);for(let oe=0;oe<O;oe++){const se=C[R[oe]];let T=w.get(se);T===void 0&&(T=P.length,w.set(se,T),P.push(se)),v[oe]=T}const K=P.length,Z=n(P,K,h.locale);return r(R,v,Z,K,!!h.descending)}function b(C,R,h){const O=m(C,R);if(R.length>=2&&d(O,R)){const v=C.stringRank;return v&&v.version===C.version&&v.usable(R,O,h.locale)?v.sort(R,h):l(O,R,h)}const w=ne(h.locale),P=h.descending?(v,K)=>w(K,v):w;return g(O,R,P)}function E(C,R,h){const O=m(C,R),w=h.compare,v=!!h.descending?(K,Z)=>-w(K,Z,void 0,void 0,!0):(K,Z)=>w(K,Z,void 0,void 0,!1);return g(O,R,v)}function S(C,R){const h=R.length,O=F(C),w=C.values,P=C.kind==="float64"&&!!w,v=C.kind==="object"||C.kind==="multi"||C.kind===void 0;if(!O&&!P&&!v)return{present:R,absent:ce};const K=new Uint32Array(h),Z=new Uint32Array(h);let oe=0,se=0;if(O&&P)for(let T=0;T<h;T++){const L=R[T];O(L)===1&&!Number.isNaN(w[L])?K[oe++]=L:Z[se++]=L}else if(P&&!O)for(let T=0;T<h;T++){const L=R[T];Number.isNaN(w[L])?Z[se++]=L:K[oe++]=L}else if(O&&!v)for(let T=0;T<h;T++){const L=R[T];O(L)===1?K[oe++]=L:Z[se++]=L}else{const T=x(C);for(let L=0;L<h;L++){const J=R[L];_(T(J))?Z[se++]=J:K[oe++]=J}}return se===0?{present:R,absent:ce}:{present:K.subarray(0,oe),absent:Z.subarray(0,se)}}function V(C,R,h){if(R.length===0)return C;const O=new Uint32Array(C.length+R.length);return h?(O.set(R,0),O.set(C,R.length)):(O.set(C,0),O.set(R,C.length)),O}function U(C,R,h={}){const O=R||te(H(C,h));if(!C||O.length<2)return Uint32Array.from(O);const{present:w,absent:P}=S(C,O);if(w.length===0)return Uint32Array.from(O);const v=!!h.descending;let K;if(typeof h.compare=="function")K=E(C,w,h);else switch(C.kind){case"float64":K=c(C.values,w,v);break;case"int32":K=t(C.values,w,v);break;case"dictionary":K=a(C,w,h);break;case"bitset":K=e(C,w,v);break;default:K=b(C,w,h);break}return V(K,P,!!h.nullsFirst)}function I(C,R,h,O={}){const w=R||[],P=w.length&&(w[0].handle||X(C,w[0].col))||C&&C[0];let v=h||te(H(P,O));for(let K=w.length-1;K>=0;K--){const Z=w[K],oe=Z.handle||X(C,Z.col)||C&&C[K];oe&&(v=U(oe,v,{descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,locale:Z.locale!==void 0?Z.locale:O.locale,compare:Z.compare}))}return v instanceof Uint32Array?v:Uint32Array.from(v)}function X(C,R){if(!(!C||R===void 0)){for(let h=0;h<C.length;h++)if(C[h]&&C[h].id===R)return C[h]}}}),Se("packages/core/src/store/stringrank.js",function(o,fe){"use strict";Object.defineProperty(o,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"StringRankIndex",{enumerable:!0,get:function(){return te}});const le=fe("packages/core/src/compute/sort.js"),ae=le.collateStringRanks,Q=le.rankSortStrings,q=1e5;class te{#t=[];#e=new Map;#n;#r=0;#i=0;#s=-1;#h;#u=!1;#o=null;#c=-1;#l="\\0";constructor(F=q){this.#h=F>0?F:q,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(F){this.#s=F}get generation(){return this.#i}get size(){return this.#t.length}get capped(){return this.#u}get length(){return this.#r}get bytes(){let F=this.#n.byteLength;const H=this.#t;for(let ne=0;ne<H.length;ne++)F+=H[ne].length*2+24;return F}#a(F,H){const ne=this.#e.get(F);if(ne!==void 0)return ne;if(this.#u)return-1;if(H&&this.#t.length>=this.#h)return this.#u=!0,-1;const x=this.#t.length;return this.#t.push(F),this.#e.set(F,x),this.#i++,x}build(F,H){const ne=H|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(ne);for(let x=0;x<ne;x++){const ce=F[x],ie=typeof ce=="string"?this.#a(ce,!1):-1;this.#n[x]=ie<0?0:ie}this.#r=ne}append(F,H,ne){const x=(H|0)+(ne|0);if(x>this.#n.length){const ce=new Uint32Array(x);ce.set(this.#n.subarray(0,this.#r)),this.#n=ce}for(let ce=H|0;ce<x;ce++){const ie=F[ce],G=typeof ie=="string"?this.#a(ie,!0):-1;this.#n[ce]=G<0?0:G}this.#r=Math.max(this.#r,x)}ranks(F){const H=F||"";if(this.#o&&this.#c===this.#i&&this.#l===H)return this.#o;const ne=ae(this.#t,this.#t.length,F);return this.#o=ne,this.#c=this.#i,this.#l=H,ne}usable(F,H,ne){if(this.#u||this.#t.length===0)return!1;const x=this.#n,ce=this.#t,ie=this.#r;for(let G=0;G<F.length;G++){const D=F[G];if(D>=ie||ce[x[D]]!==H[D])return!1}return!0}sort(F,H){const ne=this.ranks(H.locale),x=this.#t.length,ce=F.length,ie=new Uint32Array(ce),G=this.#n;for(let D=0;D<ce;D++)ie[D]=G[F[D]];return Q(F,ie,ne,x,!!H.descending)}}}),Se("packages/core/src/store/columnstore.js",function(o,fe){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return G}}),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 le=fe("packages/core/src/internal/util.js"),ae=le.warnOnce,Q=le.isFunction,q=le.pathGetter,_=fe("packages/core/src/store/bitset.js").Bitset,H=fe("packages/core/src/store/dictionary.js").Dictionary,x=fe("packages/core/src/store/multivalue.js").MultiValue,ie=fe("packages/core/src/store/stringrank.js").StringRankIndex,G=4294967295,D=1024,Y=5e3,ee=.2,z=new Set(["float64","int32","bitset","dictionary","object","multi"]);function M(g){return g==null}function i(g){if(typeof g=="number")return g;if(g instanceof Date)return g.getTime();if(typeof g=="boolean")return g?1:0;const e=Number(g);return Number.isNaN(e)&&typeof g=="string"?Date.parse(g):e}function s(g){const e=i(g);return Number.isFinite(e)?e|0:0}function u(g){return M(g)?[]:Array.isArray(g)?g:[g]}function f(g,e){switch(g.kind){case"float64":case"int32":return g.buf[e];case"bitset":return g.bits.get(e)===1;case"dictionary":return g.dict.valueOf(g.buf[e]);case"multi":{const m=g.mv.at(e),d=new Array(m.length);for(let r=0;r<m.length;r++)d[r]=g.dict.valueOf(m[r]);return d}default:return g.buf[e]}}function c(g,e){switch(g.kind){case"float64":case"int32":return g.values[e];case"bitset":return(g.values[e>>3]&1<<(e&7))!==0;case"dictionary":return(g.table||[])[g.values[e]];case"multi":{const m=g.offsets[e],d=g.offsets[e+1],r=g.table||[],n=new Array(d-m);for(let l=m;l<d;l++)n[l-m]=r[g.values[l]];return n}default:return g.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,m){this.#t=e.id;const d=z.has(e.kind)?e.kind:"object";e.kind&&!z.has(e.kind)&&ae(`store.kind.${e.id}`,`column "${e.id}" declares unknown storage kind "${e.kind}"; falling back to object`),this.#n=d,this.#e=d,this.#r=e.nullable!==!1,this.#h=e.dictionary??null,this.#s=m,this.#i=Q(e.read)?e.read:q(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,m=this.#s.physical();if(!e||m===0)return null;if(this.#d===null){if(typeof e[0]!="string")return null;const d=new ie(this.#S());return d.build(e,m),d.version=this.#f,this.#d=d,this.#k=this.#f,d.capped?null:d}return this.#d.length<m&&this.#d.append(e,this.#d.length,m-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 m=this.#l.at(e),d=new Array(m.length);for(let r=0;r<m.length;r++)d[r]=this.#a.valueOf(m[r]);return d}default:return this.#o[e]}}}set(e,m){this.#g||(this.#u?this.#A(e,m):this.#y.set(e,m===void 0?null:m),this.#d&&this.#j(),this.#f++)}read(e){return this.#i(e)}appendColumn(e,m,d){if(this.#g||d<=0)return;if(!this.#u){this.#f++;return}const r=this.#i,n=this.#r,l=this.#m;let b=!1;switch(this.#e){case"float64":{const E=this.#o;for(let S=0;S<d;S++){const V=r(e[S]);if(typeof V=="number"){n&&l.set(m+S),E[m+S]=V;continue}const U=V==null;n?l.assign(m+S,!U):U&&(b=!0),E[m+S]=U?NaN:i(V)}break}case"int32":{const E=this.#o;for(let S=0;S<d;S++){const V=r(e[S]),U=V==null;n?l.assign(m+S,!U):U&&(b=!0),E[m+S]=U?0:s(V)}break}case"bitset":{const E=this.#c;for(let S=0;S<d;S++){const V=r(e[S]),U=V==null;n?l.assign(m+S,!U):U&&(b=!0),E.assign(m+S,!U&&!!V)}break}case"dictionary":{const E=this.#o,S=this.#a;for(let V=0;V<d;V++){const U=r(e[V]),I=U==null;n?l.assign(m+V,!I):I&&(b=!0),E[m+V]=I?0:S.codeOf(U)}break}case"multi":{const E=this.#l,S=this.#a;for(let V=0;V<d;V++){const U=r(e[V]),I=U==null;n?l.assign(m+V,!I):I&&(b=!0);const X=u(U),C=new Array(X.length);for(let R=0;R<X.length;R++)C[R]=S.codeOf(X[R]);E.write(m+V,C)}break}default:{const E=this.#o;for(let S=0;S<d;S++){const V=r(e[S]),U=V==null;n?l.assign(m+S,!U):U&&(b=!0),E[m+S]=U?null:V}break}}b&&ae(`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,m,d),this.#d.version=this.#f+1,this.#k=this.#f+1),this.#f++}appendPacked(e,m,d){if(this.#g||d<=0||!e)return;if(!this.#u){this.#f++;return}const r=this.#m,n=e.presence;if(r)if(n)for(let b=0;b<d;b++)r.assign(m+b,(n[b>>3]&1<<(b&7))!==0);else for(let b=0;b<d;b++)r.set(m+b);const l=e.kind===this.#e;if(l&&(this.#e==="float64"||this.#e==="int32")){this.#o.set(e.values,m),this.#f++;return}if(l&&this.#e==="bitset"){const b=e.values;for(let E=0;E<d;E++)this.#c.assign(m+E,(b[E>>3]&1<<(E&7))!==0);this.#f++;return}if(l&&this.#e==="dictionary"){const b=e.table||[],E=new Uint32Array(b.length);for(let I=0;I<b.length;I++)E[I]=this.#a.codeOf(b[I]);const S=e.values,V=this.#o,U=r;for(let I=0;I<d;I++){if(U&&(n&&(n[I>>3]&1<<(I&7))===0)){V[m+I]=0;continue}V[m+I]=E[S[I]]??0}this.#f++;return}if(l&&this.#e==="multi"){const b=e.table||[],E=new Uint32Array(b.length);for(let U=0;U<b.length;U++)E[U]=this.#a.codeOf(b[U]);const S=e.values,V=e.offsets;for(let U=0;U<d;U++){const I=V[U],X=V[U+1],C=new Array(X-I);for(let R=I;R<X;R++)C[R-I]=E[S[R]]??0;this.#l.write(m+U,C)}this.#f++;return}for(let b=0;b<d;b++){const E=n?(n[b>>3]&1<<(b&7))===0:e.kind==="object"?e.values[b]===null:!1;this.#A(m+b,E?null:c(e,b))}this.#f++}touch(){this.#f++}columnarise(e,m){if(this.#u||this.#g)return;const d=new Array(m);for(let r=0;r<m;r++)d[r]=this.#M(r);this.#e=this.#n,this.#u=!0,this.#P(e);for(let r=0;r<m;r++)this.#A(r,d[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 m=new this.#o.constructor(e);m.set(this.#o),this.#o=m;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||!z.has(e)||(this.#n=e,!this.#u||e===this.#e))return!1;const m={kind:this.#e,buf:this.#o,bits:this.#c,mv:this.#l,dict:this.#a},d=this.#s.physical(),r=this.#m;this.#e=e,this.#P(this.#p);for(let n=0;n<d;n++){const l=r!==null&&r.get(n)===0;l&&e!=="multi"||this.#A(n,l?null:f(m,n))}return this.#j(),this.#f++,!0}compact(e,m,d){if(!this.#g){if(this.#j(),!this.#u){const r=this.#y;if(r.size){const n=new Map;for(const[l,b]of r)e[l]!==G&&n.set(e[l],b);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<m;n++)e[n]!==G&&(r[e[n]]=r[n]);if(this.#e==="object")for(let n=d;n<m;n++)r[n]=void 0;break}case"bitset":{const r=this.#c;for(let n=0;n<m;n++)e[n]!==G&&r.assign(e[n],r.get(n)===1);for(let n=d;n<m;n++)r.clear(n);break}case"multi":this.#l.compact(e,d,G);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<m;n++)e[n]!==G&&r.assign(e[n],r.get(n)===1);for(let n=d;n<m;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 m=Math.max(1,e);switch(this.#o=null,this.#c=null,this.#l=null,this.#e){case"float64":this.#o=new Float64Array(m);break;case"int32":this.#o=new Int32Array(m);break;case"bitset":this.#c=new _(m);break;case"dictionary":this.#o=new Uint32Array(m),this.#a=this.#a??new H(this.#h??[]);break;case"multi":this.#l=new x({rows:m,values:m}),this.#a=this.#a??new H(this.#h??[]);break;default:this.#o=new Array(m);break}this.#e!=="dictionary"&&this.#e!=="multi"&&(this.#a=null),this.#r&&(this.#m?this.#m.grow(m):this.#m=new _(m)),this.#p=m}#A(e,m){const d=M(m);switch(this.#r?this.#m.assign(e,!d):d&&ae(`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]=d?NaN:i(m);break;case"int32":this.#o[e]=d?0:s(m);break;case"bitset":this.#c.assign(e,!d&&!!m);break;case"dictionary":this.#o[e]=d?0:this.#a.codeOf(m);break;case"multi":{const r=u(m),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]=d?null:m;break}}#M(e){if(this.#y.has(e))return this.#y.get(e);const m=this.#i(this.#s.rowAt(e));return m===void 0?null:m}#N(){if(this.#O&&this.#O.version===this.#f)return this.#O;const e=this.#s.physical(),m=new Array(e),d=this.#r?new _(e):null;for(let r=0;r<e;r++){const n=this.#M(r);m[r]=n,d&&!M(n)&&d.set(r)}return this.#O={version:this.#f,values:m,presence:d},this.#O}}class a{#t;#e=new Map;#n=[];#r=[];#i=0;#s=0;#h=0;#u=0;#o=new _(0);#c=!1;#l=!0;#a;#d;#w;#b=!1;constructor(e,m={}){this.#t=Array.isArray(e)?e:[],this.#d=Math.max(1,m.initialCapacity??D),this.#l=m.retainSource!==!1,this.#a=this.#l?m.columnarBelow??Y:0,this.#w=m.compactRatio??ee;const d={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)){ae(`store.dup.${r.id}`,`duplicate column id "${r.id}" in the store schema; ignoring the second`);continue}const n=new t(r,d);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 m of this.#n)e+=m.bytes;return e}append(e){const m=this.#i;if(this.#b||!e)return{from:m,to:m};const d=e.length|0;if(d===0)return{from:m,to:m};if(this.#l)for(let n=0;n<d;n++)this.#r[m+n]=e[n];if(this.#i=m+d,this.#h+=d,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:m,to:this.#i}}this.#k(this.#i);const r=this.#n;for(let n=0;n<r.length;n++)r[n].appendColumn(e,m,d);return{from:m,to:this.#i}}appendPacked(e,m){const d=this.#i;if(this.#b||!e)return{from:d,to:d};const r=e.count|0;if(r===0)return{from:d,to:d};if(this.#l&&m)for(let l=0;l<r;l++)this.#r[d+l]=m[l];this.#i=d+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 b=n.get(l.id);b?l.appendPacked(b,d,r):l.grow(this.#s)}return{from:d,to:this.#i}}source(e){if(this.#l)return this.#r[e];if(!(e<0||e>=this.#i))return this.#m(e)}setSource(e,m){this.#b||e<0||e>=this.#i||this.#l&&(this.#r[e]=m)}get(e,m){const d=this.#e.get(e);return d?d.get(m):void 0}set(e,m,d){if(this.#b||m<0||m>=this.#i)return;const r=this.#e.get(e);if(!r){ae(`store.set.${e}`,`set() on unknown column "${e}"`);return}r.set(m,d)}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 m=this.#i,d=new Uint32Array(m);let r=0;for(let n=0;n<m;n++)d[n]=this.#o.get(n)===1?G:r++;for(const n of this.#n)n.compact(d,m,r);if(this.#l){const n=this.#r;for(let l=0;l<m;l++)d[l]!==G&&(n[d[l]]=n[l]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new _(Math.max(this.#s,r)),d}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 d=0;d<this.#i;d++)e[d]=d;return e}let m=0;for(let d=0;d<this.#i;d++)this.#o.get(d)===0&&(e[m++]=d);return e}convert(e,m){const d=this.#e.get(e);return d?d.convert(m):!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 m=this.#s||this.#d;for(;m<e;)m*=2;for(const d of this.#n)d.grow(m);this.#o.grow(m),this.#s=m}#m(e){const m={};for(const d of this.#n)m[d.id]=d.get(e);return m}#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 m of this.#n)m.columnarise(e,this.#i)}}}),Se("packages/core/src/store/ingest.js",function(o,fe){"use strict";Object.defineProperty(o,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"inferKind",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return z}});const le=fe("packages/core/src/internal/util.js"),ae=le.now,Q=le.nextFrame,q=le.infoOnce,te=le.warnOnce,_=le.isFunction,F=le.pathGetter,ne=fe("packages/core/src/store/columnstore.js").ColumnStore,x=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function ce(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 g=0;g<M.length;g++){const e=M[g];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 ie(M,i,s){return i<=0||M<s*i?"dictionary":"object"}function G(M,i,s){const u=new Map,f=new Map;for(const l of M){if(l.computed)continue;const b=_(l.read)?l.read:F(l.field||l.id);f.set(l.id,b),u.set(l.id,b)}const c=i?.order??[],t=i?.fns??{},a=i?.deps??{},g=i?.wrapDeps??null,e=c.filter(l=>_(t[l])),m=e.some(l=>a[l]==="*");let d=new WeakMap;const r=l=>{const b={};if(m)for(const[E,S]of f)b[E]=S(l);for(const E of e){const S=a[E];let V;if(S==="*")V=b;else{V={};const U=S||[];for(let I=0;I<U.length;I++){const X=U[I];V[X]=X in b?b[X]:f.get(X)?.(l)}}b[E]=t[E](g?g(V,E):V,{data:l,row:null,column:null,grid:null,context:s})}return b},n=l=>{if(l===null||typeof l!="object"&&typeof l!="function")return r(l);let b=d.get(l);return b===void 0&&(b=r(l),d.set(l,b)),b};for(const l of e)u.set(l,b=>n(b)[l]);return{readers:u,reset(){d=new WeakMap}}}class D{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(i,s){this.spec=i,this.read=s,this.kind="object",this.inferred=!1,this.nullable=i.nullable!==!1}}class Y{#t;#e=[];#n=null;#r;#i=0;#s;#h=!1;#u=!1;#o=0;#c;constructor(i,s={},u={}){this.#t=Array.isArray(i)?i:Array.from(i||[]),this.#s={...x,...u};const f=s.columns??[];this.#r=G(f,s.computed??null,s.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(f,s.computed??null),this.#n=new ne(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=ae(),{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&&ae()-i<s);return this.#o+=ae()-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 g=this.#r.readers.get(a.id)??(_(a.read)?a.read:F(a.field||a.id)),e=new D(a,g);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 m=[];for(let r=0;r<f&&m.length<this.#s.sampleSize;r++){const n=g(u[r]);n!=null&&m.push(n)}e.inferred=!0;const d=ce(m,{multi:a.multi});if(d==="text"){const r=new Set(m).size;e.kind=ie(r,m.length,c),e.candidate=this.#c,e.reason=`sampled ${r} distinct in ${m.length}`}else e.kind=d,e.reason=`inferred from ${m.length} sampled values`,d==="object"&&m.length&&q(`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(m))}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 ee(M,i={},s={}){const u=new Y(M,i,s),f=s.scheduler?.frame??Q;for(;u.slice();)await new Promise(c=>{f(c)});return u.result()}function z(M,i={},s={}){const u=new Y(M,i,{...s,chunkMs:1/0});for(;u.slice(););return u.result()}}),Se("packages/core/src/store/columnpack.js",function(o,fe){"use strict";Object.defineProperty(o,"isPortableSchema",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"packChunk",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"packedTransfers",{enumerable:!0,get:function(){return Y}});const ae=fe("packages/core/src/internal/util.js").pathGetter,Q=fe("packages/core/src/store/ingest.js"),q=Q.inferKind,te=Q.decideText,_=Q.INGEST_DEFAULTS,H=fe("packages/core/src/store/columnstore.js").toFloat,ne=new Set(["float64","int32","bitset","dictionary","object","multi"]);function x(ee){if(!Array.isArray(ee)||ee.length===0)return!1;for(const z of ee)if(!z||typeof z.id!="string"||typeof z.field!="string"||z.field===""||z.kind&&!ne.has(z.kind))return!1;return!0}function ce(ee){const z=H(ee);return Number.isFinite(z)?z|0:0}function ie(ee){return ee==null?[]:Array.isArray(ee)?ee:[ee]}function G(ee,z,M,i){if(ee.kind)return ee.kind;const s=[];for(let c=0;c<z.length&&s.length<_.sampleSize;c++){const t=z[c];t!=null&&s.push(t)}const u=q(s,{multi:ee.multi});if(u!=="text")return u;const f=new Set(s).size;return te(f,s.length,i)}function D(ee,z,M={}){const i=z.length|0,s=M.dictionaryRatio??_.dictionaryRatio,u=[];for(const f of ee){const c=ae(f.field||f.id),t=f.nullable!==!1,a=new Array(i);for(let r=0;r<i;r++){const n=c(z[r]);a[r]=n===void 0?null:n}const g=G(f,a,i,s),e=t?new Uint8Array(i+7>>3):null,m=r=>{e&&(e[r>>3]|=1<<(r&7))};let d;switch(g){case"float64":{const r=new Float64Array(i);for(let n=0;n<i;n++){const l=a[n],b=l===null;b||m(n),r[n]=b?NaN:H(l)}d={id:f.id,kind:g,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],b=l===null;b||m(n),r[n]=b?0:ce(l)}d={id:f.id,kind:g,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],b=l===null;b||m(n),!b&&l&&(r[n>>3]|=1<<(n&7))}d={id:f.id,kind:g,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"dictionary":{const r=new Uint32Array(i),n=[],l=new Map;for(let b=0;b<i;b++){const E=a[b];if(E===null){r[b]=0;continue}m(b);let S=l.get(E);S===void 0&&(S=n.length,n.push(E),l.set(E,S)),r[b]=S}d={id:f.id,kind:g,nullable:t,values:r,presence:e,offsets:null,table:n};break}case"multi":{const r=[],n=new Map,l=new Uint32Array(i+1),b=[];for(let E=0;E<i;E++){const S=a[E];l[E]=b.length,S===null||m(E);const U=ie(S);for(let I=0;I<U.length;I++){const X=U[I];let C=n.get(X);C===void 0&&(C=r.length,r.push(X),n.set(X,C)),b.push(C)}}l[i]=b.length,d={id:f.id,kind:g,nullable:t,values:Int32Array.from(b),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&&m(n),r[n]=l}d={id:f.id,kind:"object",nullable:t,values:r,presence:e,offsets:null,table:null};break}}u.push(d)}return{count:i,columns:u}}function Y(ee){const z=[];if(!ee||!Array.isArray(ee.columns))return z;const M=i=>{ArrayBuffer.isView(i)&&i.buffer&&!z.includes(i.buffer)&&z.push(i.buffer)};for(const i of ee.columns)M(i.values),M(i.presence),M(i.offsets);return z}}),Se("packages/core/src/compute/sortspec.js",function(o,fe){"use strict";Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return te}});function le(_){return{locale:_===void 0?void 0:String(_),numeric:!0,sensitivity:"variant"}}function ae(_){return!!_&&typeof _.compare!="function"}function Q(_){if(!_)return!0;for(let F=0;F<_.length;F++)if(!ae(_[F]))return!1;return!0}function q(_,F){const H=_.col!==void 0?_.col:_.handle&&_.handle.id,ne=_.locale!==void 0?_.locale:F;return{col:H,descending:_.descending!==void 0?!!_.descending:_.dir==="desc",nullsFirst:!!_.nullsFirst,collation:le(ne)}}function te(_,F){const H=_||[],ne=new Array(H.length);for(let x=0;x<H.length;x++)ne[x]=q(H[x],F);return ne}}),Se("packages/core/src/format/date.js",function(o,fe){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return z}});const le=fe("packages/core/src/internal/util.js"),ae=le.isNil,Q=le.warnOnce,q=["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=q.find(a=>M.startsWith(a,s));if(t){f(),i.push({token:t,text:t}),s+=t.length;continue}/[A-Za-z]/.test(c)&&Q(`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: ${q.join(" ")}.`),u+=c,s+=1}return f(),i}const _=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function F(M){if(ae(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=_.exec(M.trim());if(i){const[,u,f,c,t="0",a="0",g="0"]=i;return new Date(+u,+f-1,+c,+t,+a,+g)}const s=new Date(M);return Number.isNaN(s.getTime())?null:s}return null}function H(M,i){return String(M).padStart(i,"0")}function ne(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 x(M,i,s){const u=te(M),f=ne(s),c=new Set(u.filter(m=>m.token).map(m=>m.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,g=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 m=>{const d=f(m);let r="";for(const n of u){if(!n.token){r+=n.text;continue}switch(n.token){case"yyyy":r+=H(d.year,4);break;case"yy":r+=H(d.year%100,2);break;case"MMMM":r+=a.format(m);break;case"MMM":r+=t.format(m);break;case"MM":r+=H(d.month,2);break;case"M":r+=String(d.month);break;case"dd":r+=H(d.day,2);break;case"d":r+=String(d.day);break;case"EEEE":r+=e.format(m);break;case"EEE":r+=g.format(m);break;case"HH":r+=H(d.hour,2);break;case"H":r+=String(d.hour);break;case"hh":r+=H(d.hour%12===0?12:d.hour%12,2);break;case"h":r+=String(d.hour%12===0?12:d.hour%12);break;case"mm":r+=H(d.minute,2);break;case"m":r+=String(d.minute);break;case"ss":r+=H(d.second,2);break;case"s":r+=String(d.second);break;case"SSS":r+=H(d.ms,3);break;case"a":r+=d.hour<12?"AM":"PM";break;default:r+=n.text;break}}return r}}const ce=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function ie(M,i){const s=M||{},u=s.locale||i||void 0,f=s.nullDisplay??"",c=s.timeZone;let t;if(s.pattern)t=x(s.pattern,u,c);else if(s.dateStyle||s.timeStyle){const d={timeZone:c};s.dateStyle&&(d.dateStyle=s.dateStyle),s.timeStyle&&(d.timeStyle=s.timeStyle);const r=new Intl.DateTimeFormat(u,d);t=n=>r.format(n)}else{const d=new Intl.DateTimeFormat(u,{dateStyle:"medium",timeZone:c});t=r=>d.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,m=(d,r)=>{const n=F(d);if(!n)return f;if(a){const l=r&&typeof r.now=="number"?r.now:Date.now(),b=n.getTime()-l;if(Math.abs(b)<e){for(const[E,S]of ce)if(Math.abs(b)>=S||E==="second")return a.format(Math.round(b/S),E)}}return t(n)};return m.spec=s,m}function G(M){if(ae(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=F(M);return f?G(f):null}const i=F(M);if(!i)return null;const s=u=>String(u).padStart(2,"0");return`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}`}function D(M,i){if(ae(M)||M==="")return null;if(typeof M=="string"){const u=M.trim();if(Y.test(u)){const t=F(u);return t?ee(t,i):null}const f=/^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(u);if(f){const[,t,a,g,e]=f;return`${t}T${a}:${g}${e&&e!=="00"?`:${e}`:""}`}if(/^\\d{4}-\\d{2}-\\d{2}$/.test(u))return`${u}T00:00`;const c=F(u);return c?D(c):null}const s=F(M);return s?ee(s,i):null}const Y=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function ee(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,m)=>(m.type!=="literal"&&(e[m.type]=m.value),e),{}),a=t.hour==="24"?"00":t.hour,g=Number(t.second);return`${t.year}-${t.month}-${t.day}T${a}:${t.minute}`+(g?`:${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 z(M,i){const s=ae(M)||M===""?null:String(M),u=ae(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,fe){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return R}});const le=fe("packages/core/src/internal/util.js"),ae=le.isBlank,Q=le.toArray,q=le.warnOnce,_=fe("packages/core/src/format/date.js").toIsoDate,F=fe("packages/core/src/compute/handle.js"),H=F.bitReader,ne=F.dictSize,x=F.dictValue,ce=F.presenceReader,ie=F.valueComparator,G=F.valueReader,D=/^\\d{4}-\\d{2}-\\d{2}$/,Y="\\0null\\0";function ee(h,O){const w=h&&h.pool;if(w){const P=w.mask||w.acquireMask||w.acquire||w.take;if(typeof P=="function"){const v=P.call(w,O);if(v&&v.length>=O)return v}}return new Uint8Array(O)}function z(h,O){const w=h&&h.pool;if(!w||!O)return;const P=w.release||w.releaseMask||w.free||w.recycle;typeof P=="function"&&P.call(w,O)}function M(h,O,w){return h.fill(w,0,O),h}function i(h){return h==null||typeof h=="number"&&Number.isNaN(h)}function s(h,O){if(h==null)return h;if(O==="number")return typeof h=="number"?h:Number(h);if(O==="date"||O==="dateString"){const w=_(h);return w===null?u(h):w}return O==="boolean"?typeof h=="boolean"?h:h==="true"||h===1?!0:h==="false"||h===0?!1:!!h:h}function u(h){return h instanceof Date?h.getTime():typeof h=="number"?h:Date.parse(String(h))}function f(h){return typeof h=="number"?h:h instanceof Date?h.getTime():h==null||h===""?NaN:Number(h)}function c(h,O){const w=typeof h=="string"?h:String(h);return O?w:w.toLowerCase()}function t(h,O){return h==null?Y:typeof h=="string"?O?h:h.toLowerCase():h instanceof Date?h.getTime():h}function a(h,O,w){const P=new Set;for(const v of Q(h)){const K=s(v,w);P.add(t(K,O)),typeof K=="string"&&K!==""&&Number.isFinite(Number(K))?P.add(Number(K)):typeof K=="number"&&Number.isFinite(K)&&P.add(t(String(K),O))}return P}function g(h,O,w){if(h==null||O===null||O===void 0)return h==null&&O==null;const P=typeof h,v=typeof O;return P==="string"&&v==="string"?w?h===O:h.toLowerCase()===O.toLowerCase():h instanceof Date||O instanceof Date?u(h)===u(O):P==="number"&&v==="number"?h===O||Number.isNaN(h)&&Number.isNaN(O):P==="number"&&v==="string"?h===Number(O):P==="string"&&v==="number"?Number(h)===O:P==="boolean"||v==="boolean"?h===O:Array.isArray(h)&&Array.isArray(O)?h.length===O.length&&h.every((K,Z)=>g(K,O[Z],w)):h===O}function e(h,O){try{if(h instanceof RegExp){const w=h.flags.replace(/[gy]/g,"");return new RegExp(h.source,O||w.includes("i")?w:`${w}i`)}return new RegExp(String(h),O?"":"i")}catch(w){return q(`regex:${String(h)}`,`filter operator "matches" received an invalid pattern: ${String(h)}`,w),null}}function m(h,O){const w=d(h,O),P=h&&h.type;return P!=="date"&&P!=="dateString"?w:v=>w(typeof v=="string"&&D.test(v)?v:_(v)??v)}function d(h,O){const w=h&&h.op,P=!!(h&&h.caseSensitive),v=h&&h.type,K=ie(O),Z=oe=>se=>!oe(se);switch(w){case"eq":{const oe=s(h.value,v);return se=>g(se,oe,P)}case"ne":{const oe=s(h.value,v);return se=>!g(se,oe,P)}case"lt":case"lte":case"gt":case"gte":{const oe=s(h.value,v);if(i(oe))return()=>!1;const se=w==="lt"?-1:w==="lte"?0:w==="gt"?1:2;return T=>{if(i(T))return!1;const L=K(T,oe);return se===-1?L<0:se===0?L<=0:se===1?L>0:L>=0}}case"between":case"notBetween":{const oe=Q(h.value),se=s(oe[0],v),T=s(oe[1],v),L=h.bounds||"[]",J=L.charAt(0)!=="(",he=L.charAt(1)!==")";if(i(se)||i(T))return w==="between"?()=>!1:()=>!0;const ye=Me=>{if(i(Me))return!1;const Pe=K(Me,se),Ne=K(Me,T);return(J?Pe>=0:Pe>0)&&(he?Ne<=0:Ne<0)};return w==="between"?ye:Z(ye)}case"in":case"notIn":{const oe=a(h.value,P,v),se=T=>oe.has(t(T,P));return w==="in"?se:Z(se)}case"contains":case"notContains":{const oe=c(s(h.value,v),P),se=T=>T==null?!1:c(T,P).includes(oe);return w==="contains"?se:Z(se)}case"startsWith":{const oe=c(s(h.value,v),P);return se=>se==null?!1:c(se,P).startsWith(oe)}case"endsWith":{const oe=c(s(h.value,v),P);return se=>se==null?!1:c(se,P).endsWith(oe)}case"matches":{const oe=e(h.value,P);return oe?se=>se==null?!1:oe.test(String(se)):()=>!1}case"blank":return oe=>ae(oe)||Array.isArray(oe)&&oe.length===0;case"notBlank":return oe=>!(ae(oe)||Array.isArray(oe)&&oe.length===0);case"containsAny":case"containsNone":{const oe=a(h.value,P,v),se=T=>{const L=T==null?[]:Q(T);for(let J=0;J<L.length;J++)if(oe.has(t(L[J],P)))return!0;return!1};return w==="containsAny"?se:Z(se)}case"containsAll":{const oe=Q(h.value).map(se=>t(s(se,v),P));return se=>{const T=se==null?[]:Q(se);if(oe.length===0)return!0;const L=new Set(T.map(J=>t(J,P)));for(let J=0;J<oe.length;J++)if(!L.has(oe[J]))return!1;return!0}}default:return q(`op:${String(w)}`,`unknown filter operator "${String(w)}"; the condition passes every row`),()=>!0}}function r(h,O,w){return m(O,w)(h)}function n(h,O,w,P){const v=ce(h);if(v){const oe=O?1:0;for(let se=0;se<P;se++)w[se]=v(se)===oe?1:0;return w}const K=h.kind;if(K==="float64"||K==="int32"||K==="bitset")return M(w,P,O?1:0);const Z=G(h);for(let oe=0;oe<P;oe++){const se=Z(oe),T=ae(se)||Array.isArray(se)&&se.length===0;w[oe]=T===O?0:1}return w}function l(h,O,w,P){const v=h.dict,K=ne(v),Z=new Uint8Array(K);for(let L=0;L<K;L++)Z[L]=O(x(v,L))?1:0;const oe=h.values,se=ce(h);if(!se){for(let L=0;L<P;L++)w[L]=Z[oe[L]];return w}const T=O(null)?1:0;for(let L=0;L<P;L++)w[L]=se(L)===1?Z[oe[L]]:T;return w}function b(h,O,w,P){const v=H(h.values),K=O(!0)?1:0,Z=O(!1)?1:0,oe=ce(h);if(!oe){for(let T=0;T<P;T++)w[T]=v(T)===1?K:Z;return w}const se=O(null)?1:0;for(let T=0;T<P;T++)w[T]=oe(T)===0?se:v(T)===1?K:Z;return w}function E(h,O,w,P,v){const K=h.values,Z=O.type,oe=O.op;let se=!0;switch(oe){case"eq":case"ne":{const L=f(s(O.value,Z)),J=typeof O.value=="number"&&Number.isNaN(O.value),he=oe==="ne"?1:0;if(J)for(let ye=0;ye<v;ye++)P[ye]=(Number.isNaN(K[ye])?1:0)^he;else for(let ye=0;ye<v;ye++)P[ye]=(K[ye]===L?1:0)^he;break}case"lt":{const L=f(s(O.value,Z));for(let J=0;J<v;J++)P[J]=K[J]<L?1:0;break}case"lte":{const L=f(s(O.value,Z));for(let J=0;J<v;J++)P[J]=K[J]<=L?1:0;break}case"gt":{const L=f(s(O.value,Z));for(let J=0;J<v;J++)P[J]=K[J]>L?1:0;break}case"gte":{const L=f(s(O.value,Z));for(let J=0;J<v;J++)P[J]=K[J]>=L?1:0;break}case"between":case"notBetween":{const L=Q(O.value),J=f(s(L[0],Z)),he=f(s(L[1],Z)),ye=O.bounds||"[]",Me=ye.charAt(0)!=="(",Pe=ye.charAt(1)!==")",Ne=oe==="notBetween"?1:0;if(Me&&Pe)for(let je=0;je<v;je++)P[je]=(K[je]>=J&K[je]<=he?1:0)^Ne;else if(Me)for(let je=0;je<v;je++)P[je]=(K[je]>=J&K[je]<he?1:0)^Ne;else if(Pe)for(let je=0;je<v;je++)P[je]=(K[je]>J&K[je]<=he?1:0)^Ne;else for(let je=0;je<v;je++)P[je]=(K[je]>J&K[je]<he?1:0)^Ne;break}case"in":case"notIn":{const L=new Set;for(const he of Q(O.value)){const ye=f(s(he,Z));Number.isNaN(ye)||L.add(ye)}const J=oe==="notIn"?1:0;for(let he=0;he<v;he++)P[he]=(L.has(K[he])?1:0)^J;break}default:se=!1;break}if(!se)return!1;const T=ce(h);if(T){const L=w(null)?1:0;for(let J=0;J<v;J++)T(J)===0&&(P[J]=L)}return!0}function S(h,O,w,P){const v=G(h);for(let K=0;K<P;K++)w[K]=O(v(K))?1:0;return w}function V(h,O,w){const P=O.count|0,v=w||ee(O,P);if(!h)return M(v,P,1);const K=typeof O.handle=="function"?O.handle(h.col):void 0,Z=typeof O.custom=="function"?O.custom:null;if(!K){if(Z){for(let T=0;T<P;T++)v[T]=Z(h,T)?1:0;return v}return q(`filter:col:${String(h.col)}`,`filter references unknown column "${String(h.col)}"; the condition passes every row`),M(v,P,1)}const oe=h.op;if(oe==="blank"||oe==="notBlank")return n(K,oe==="notBlank",v,P);const se=m(h,O.locale);switch(K.kind){case"dictionary":return l(K,se,v,P);case"bitset":return b(K,se,v,P);case"float64":case"int32":return E(K,h,se,v,P)?v:S(K,se,v,P);default:return S(K,se,v,P)}}function U(h,O,w){if(!h)return M(ee(O,w),w,1);if(Array.isArray(h.conditions)){const P=h.conditions.filter(Z=>Z!=null),v=h.op==="or"?"or":h.op==="not"?"not":"and";if(P.length===0)return M(ee(O,w),w,1);const K=U(P[0],O,w);for(let Z=1;Z<P.length;Z++){const oe=U(P[Z],O,w);if(v==="or")for(let se=0;se<w;se++)K[se]|=oe[se];else for(let se=0;se<w;se++)K[se]&=oe[se];z(O,oe)}if(v==="not")for(let Z=0;Z<w;Z++)K[Z]^=1;return K}return V(h,O,ee(O,w))}function I(h,O){return U(h,O,O.count|0)}function X(h,O){if(!h||!O)return h||null;const w=h;if(Array.isArray(w.conditions)){if((w.op==="or"?"or":w.op==="not"?"not":"and")!=="and")return C(w,O)?null:h;const v=[];for(const K of w.conditions){const Z=X(K,O);Z&&v.push(Z)}return v.length?{...w,op:"and",conditions:v}:null}return w.col===O?null:h}function C(h,O){if(!h||typeof h!="object")return!1;const w=h;if(w.col===O)return!0;if(Array.isArray(w.conditions)){for(const P of w.conditions)if(C(P,O))return!0}return!1}function R(h,O,w){if(w&&w.length>=O){let Z=0;for(let oe=0;oe<O;oe++)h[oe]&&(w[Z++]=oe);return w.subarray(0,Z)}let P=0;for(let Z=0;Z<O;Z++)P+=h[Z]?1:0;const v=new Uint32Array(P);let K=0;for(let Z=0;Z<O;Z++)h[Z]&&(v[K++]=Z);return v}}),Se("packages/core/src/compute/group.js",function(o,fe){"use strict";Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return ie}});const le=fe("packages/core/src/compute/handle.js"),ae=le.dictSize,Q=le.identity,q=le.presenceReader,te=le.rowCount,_=le.valueReader,F="",H="\\0",ne=1<<20;function x(G,D,Y,ee){const z=G.length,M=G.map(t=>_(t)),i=Array.isArray(ee)&&ee.some(Boolean),s=i?M.map((t,a)=>ee[a]?g=>ee[a](t(g)):t):M;if(!i&&z>0&&G.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=G.map(g=>ae(g.dict)+1);let a=1;for(let g=0;g<z;g++)a*=t[g];if(a<=Number.MAX_SAFE_INTEGER){const g=G.map(r=>r.values),e=G.map(r=>q(r)),m=r=>{let n=0;for(let l=0;l<z;l++){const b=e[l],E=b&&b(r)===0?t[l]-1:g[l][r];n=n*t[l]+E}return n},d=new Float64Array(Y);for(let r=0;r<Y;r++)d[r]=m(D[r]);return{packed:d,strings:null,product:a,readers:s,keyOf:m}}}const f=t=>{let a="";for(let g=0;g<z;g++){const e=s[g](t);a+=(g===0?"":F)+(e==null?H:String(e))}return a},c=new Array(Y);for(let t=0;t<Y;t++)c[t]=f(D[t]);return{packed:null,strings:c,product:1/0,readers:s,keyOf:f}}function ce(G,D,Y,ee){const z=new Uint32Array(ee+1);for(let u=0;u<Y;u++)z[D[u]+1]++;for(let u=0;u<ee;u++)z[u+1]+=z[u];const M=new Uint32Array(Y),i=z.slice(0,ee);for(let u=0;u<Y;u++)M[i[D[u]]++]=G[u];const s=new Array(ee);for(let u=0;u<ee;u++)s[u]=M.subarray(z[u],z[u+1]);return s}function ie(G,D,Y={}){const ee=G||[],z=D||Q(te(ee[0],Y)),M=z.length;if(ee.length===0||M===0)return{keys:[],buckets:[]};const{packed:i,strings:s,product:u,readers:f}=x(ee,z,M,Y.project),c=new Uint32Array(M);let t=0,a=null;if(i&&u<=Math.max(1024,Math.min(ne,M*4))){const d=u,r=new Int32Array(d).fill(-1);for(let n=0;n<M;n++)r[i[n]]=0;for(let n=0;n<d;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<d;n++)r[n]>=0&&(a[r[n]]=n)}else if(i){const d=new Map;for(let r=0;r<M;r++){const n=i[r];let l=d.get(n);l===void 0&&(l=t++,d.set(n,l)),c[r]=l}a=new Float64Array(t);for(const[r,n]of d)a[n]=r}else{const d=new Map;for(let r=0;r<M;r++){const n=s[r];let l=d.get(n);l===void 0&&(l=t++,d.set(n,l)),c[r]=l}}const g=ce(z,c,M,t),e=new Array(t);for(let d=0;d<t;d++){const r=g[d][0],n=new Array(f.length);for(let l=0;l<f.length;l++)n[l]=f[l](r);e[d]=n}const m={keys:e,buckets:g};return a&&(m.packed=a),m}}),Se("packages/core/src/compute/facet.js",function(o,fe){"use strict";Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return z}}),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 m}}),Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return r}});const le=fe("packages/core/src/compute/handle.js"),ae=le.presenceReader,Q=le.valueReader,q=le.dictSize,te=le.dictValue,_=Object.freeze(["equal","quantile","log"]),F=Object.freeze(["hour","day","week","month","quarter","year"]),H=20,ne=50,x=1e4;function ce(n,l){if(!n)return"none";const b=l&&l.base;if(b==="date"||b==="datetime"||b==="time"||b==="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 b==="number"?"numeric":b==="boolean"?"boolean":b==="text"?"category":"none"}}function ie(n){const l=n.values,b=n.kind;if((b==="float64"||b==="int32")&&l)return S=>l[S];const E=Q(n);return S=>G(E(S))}function G(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 b=Date.parse(n);return Number.isFinite(b)?b:NaN}return NaN}function D(n,l,b,E=ne){if(!n)return{cardinality:0,exact:!0};if(n.dict)return{cardinality:q(n.dict),exact:!0};if(n.kind==="bitset")return{cardinality:2,exact:!0};const S=Q(n),V=l?l.length:b,U=new Set;for(let I=0;I<V;I++){const X=S(l?l[I]:I);if(X!=null&&(U.add(X),U.size>E))return{cardinality:U.size,exact:!1}}return{cardinality:U.size,exact:!0}}const Y=36e5,ee=864e5;function z(n,l=H){const b=Number.isFinite(n)&&n>0?n:0,E=Math.max(1,l)*2;return b/Y<=E?"hour":b/ee<=E?"day":b/(7*ee)<=E?"week":b/(30*ee)<=E?"month":b/(91*ee)<=E?"quarter":"year"}function M(n,l){if(!Number.isFinite(n))return NaN;const b=new Date(n);switch(l){case"hour":return b.setMinutes(0,0,0),b.getTime();case"day":return b.setHours(0,0,0,0),b.getTime();case"week":{b.setHours(0,0,0,0);const E=(b.getDay()+6)%7;return b.setDate(b.getDate()-E),b.getTime()}case"month":return b.setDate(1),b.setHours(0,0,0,0),b.getTime();case"quarter":return b.setMonth(Math.floor(b.getMonth()/3)*3,1),b.setHours(0,0,0,0),b.getTime();default:return b.setMonth(0,1),b.setHours(0,0,0,0),b.getTime()}}function i(n,l){const b=new Date(n);switch(l){case"hour":b.setHours(b.getHours()+1);break;case"day":b.setDate(b.getDate()+1);break;case"week":b.setDate(b.getDate()+7);break;case"month":b.setMonth(b.getMonth()+1);break;case"quarter":b.setMonth(b.getMonth()+3);break;default:b.setFullYear(b.getFullYear()+1);break}return b.getTime()}function s(n,l,b){const E=ie(n),S=ae(n),V=l?l.length:b;let U=1/0,I=-1/0,X=0,C=0;for(let R=0;R<V;R++){const h=l?l[R]:R;if(S&&!S(h)){X++;continue}const O=E(h);if(!Number.isFinite(O)){X++;continue}O<U&&(U=O),O>I&&(I=O),C++}return{min:U,max:I,nulls:X,finite:C}}function u(n,l,b,E){const S=ie(n),V=ae(n),U=l?l.length:b,I=U>E?U/E:1,X=[];for(let R=0;R<U;R+=I){const h=l?l[Math.floor(R)]:Math.floor(R);if(V&&!V(h))continue;const O=S(h);Number.isFinite(O)&&X.push(O)}const C=Float64Array.from(X);return C.sort(),C}function f(n,l,b,E={}){const S=E.kind||ce(n,E.type);return S==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:S==="boolean"?c(n,l,b):S==="category"?t(n,l,b,E):a(n,l,b,S,E)}function c(n,l,b){const E=ae(n);let S=0;if(E){const U=l?l.length:b;for(let I=0;I<U;I++)E(l?l[I]:I)||S++}const V=[{value:!1,label:"false"},{value:!0,label:"true"}];return S>0&&V.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:V}}function t(n,l,b,E){const S=E.cardinalityLimit??ne,{cardinality:V}=D(n,l,b,S);if(V>S&&(E.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:V};const U=Q(n),I=l?l.length:b,X=new Map;let C=0;for(let P=0;P<I;P++){const v=U(l?l[P]:P);if(v==null||v===""){C++;continue}if(Array.isArray(v)){if(!v.length){C++;continue}for(const K of v)X.set(K,(X.get(K)||0)+1);continue}X.set(v,(X.get(v)||0)+1)}let R=[...X.entries()];E.order==="alpha"?R.sort((P,v)=>String(P[0]).localeCompare(String(v[0]))):R.sort((P,v)=>v[1]-P[1]);let h=0,O=0;if(R.length>S){O=R.length-S;for(let P=S;P<R.length;P++)h+=R[P][1];R=R.slice(0,S)}const w=R.map(([P])=>({value:P,label:String(P)}));return h>0&&w.push({remainder:!0,label:`Other (${O} values)`}),C>0&&w.push({null:!0,label:"Empty"}),{kind:"category",buckets:w,cardinality:V}}function a(n,l,b,E,S){const{min:V,max:U,nulls:I,finite:X}=s(n,l,b);if(!X)return{kind:E,buckets:I?[{null:!0,label:"Empty"}]:[],empty:!0};const C=Math.max(1,Math.floor(S.buckets||H));let R=[];if(E==="date"){const O=F.includes(S.granularity)?S.granularity:z(U-V,C);let w=M(V,O);for(;w<=U&&R.length<4096;){const P=i(w,O);if(!(P>w))break;R.push({from:w,to:P}),w=P}return{kind:E,buckets:g(R,I),granularity:O}}const h=_.includes(S.strategy)?S.strategy:"equal";if(h==="quantile"){const O=u(n,l,b,x);if(O.length){const w=[O[0]];for(let P=1;P<C;P++){const v=O[Math.min(O.length-1,Math.floor(P/C*O.length))];v>w[w.length-1]&&w.push(v)}w.push(U);for(let P=0;P<w.length-1;P++)R.push({from:w[P],to:w[P+1]})}}else if(h==="log"&&V>0){const O=Math.log10(V),P=(Math.log10(U)-O)/C||1;for(let v=0;v<C;v++)R.push({from:10**(O+v*P),to:10**(O+(v+1)*P)})}if(!R.length){const O=(U-V)/C||1;for(let w=0;w<C;w++)R.push({from:V+w*O,to:V+(w+1)*O})}return R[R.length-1].to=U,{kind:E,buckets:g(R,I),strategy:h,min:V,max:U}}function g(n,l){return l>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,l,b,E,S){const V=E&&E.buckets||[],U=S&&S.length>=V.length?S.subarray(0,V.length):new Uint32Array(V.length);if(U.fill(0),!n||!V.length)return U;const I=V.length-1,X=!!V[I]&&V[I].null===!0,C=l?l.length:b;if(E.kind==="boolean"){const P=Q(n);for(let v=0;v<C;v++){const K=P(l?l[v]:v);if(K==null){X&&U[I]++;continue}U[K?1:0]++}return U}if(E.kind==="category"){const P=new Map;for(let Z=0;Z<V.length;Z++)!V[Z].null&&!V[Z].remainder&&P.set(V[Z].value,Z);const v=V.findIndex(Z=>Z.remainder),K=Q(n);for(let Z=0;Z<C;Z++){const oe=K(l?l[Z]:Z);if(oe==null||oe===""){X&&U[I]++;continue}if(Array.isArray(oe)){if(!oe.length){X&&U[I]++;continue}for(const T of oe){const L=P.get(T);L!==void 0?U[L]++:v>=0&&U[v]++}continue}const se=P.get(oe);se!==void 0?U[se]++:v>=0&&U[v]++}return U}const R=X?V.length-1:V.length,h=new Float64Array(R+1);for(let P=0;P<R;P++)h[P]=V[P].from;h[R]=R?V[R-1].to:0;const O=ie(n),w=ae(n);for(let P=0;P<C;P++){const v=l?l[P]:P;if(w&&!w(v)){X&&U[I]++;continue}const K=O(v);if(!Number.isFinite(K)){X&&U[I]++;continue}const Z=m(h,R,K);Z>=0&&U[Z]++}return U}function m(n,l,b){if(!l||b<n[0])return-1;if(b>=n[l])return b===n[l]?l-1:-1;let E=0,S=l-1;for(;E<S;){const V=E+S+1>>>1;b>=n[V]?E=V:S=V-1}return E}function d(n,l,b,E={}){const S=E.bounds||f(n,E.boundsIndices??l,b,E);return{bounds:S,counts:e(n,l,b,S)}}const r=d}),Se("packages/core/src/compute/special.js",function(o,fe){"use strict";Object.defineProperty(o,"logGamma",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"incompleteBeta",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return ee}});const le=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),ae=3e-12,Q=1e-300;function q(z){if(z<.5)return Math.log(Math.PI/Math.sin(Math.PI*z))-q(1-z);const M=z-1;let i=.9999999999998099;const s=M+7.5;for(let u=0;u<le.length;u++)i+=le[u]/(M+u+1);return .5*Math.log(2*Math.PI)+(M+.5)*Math.log(s)-s+Math.log(i)}function te(z,M,i){const s=z+M,u=z+1,f=z-1;let c=1,t=1-s*i/u;Math.abs(t)<Q&&(t=Q),t=1/t;let a=t;for(let g=1;g<=300;g++){const e=2*g;let m=g*(M-g)*i/((f+e)*(z+e));t=1+m*t,Math.abs(t)<Q&&(t=Q),c=1+m/c,Math.abs(c)<Q&&(c=Q),t=1/t,a*=t*c,m=-(z+g)*(s+g)*i/((z+e)*(u+e)),t=1+m*t,Math.abs(t)<Q&&(t=Q),c=1+m/c,Math.abs(c)<Q&&(c=Q),t=1/t;const d=t*c;if(a*=d,Math.abs(d-1)<ae)break}return a}function _(z,M,i){if(!(z>0)||!(M>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const s=Math.exp(q(z+M)-q(z)-q(M)+z*Math.log(i)+M*Math.log(1-i));return i<(z+1)/(z+M+2)?s*te(z,M,i)/z:1-s*te(M,z,1-i)/M}function F(z){if(!(z>0)||!(z<1))return z===0?-1/0:z===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;z<f?(c=Math.sqrt(-2*Math.log(z)),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)):z<=1-f?(c=z-.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-z)),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*H(-a/Math.SQRT2)-z)*Math.sqrt(2*Math.PI)*Math.exp(a*a/2);return a-e/(1+a*e/2)}function H(z){const M=Math.abs(z),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 g=u.length-1;g>0;g--)t=c,c=s*c-f+u[g],f=t;const a=i*Math.exp(-M*M+.5*(u[0]+s*c)-f);return z>=0?a:2-a}function ne(z){return .5*H(-z/Math.SQRT2)}function x(z,M){if(!(M>0)||!Number.isFinite(z))return Number.NaN;const i=.5*_(M/2,.5,M/(M+z*z));return z>0?1-i:i}function ce(z,M){if(!(z>0)||!(z<1)||!(M>0))return Number.NaN;if(M>1e7)return F(z);let i=-1e4,s=1e4,u=F(z);const f=q(M/2)+q(.5)-q((M+1)/2);for(let c=0;c<60;c++){const t=x(u,M);t<z?i=u:s=u;const a=Math.exp(-((M+1)/2)*Math.log(1+u*u/M)-f)/Math.sqrt(M),g=a>0?(t-z)/a:0;if(Math.abs(g)<1e-12)break;const e=u-g;if(u=e>i&&e<s&&Number.isFinite(e)?e:(i+s)/2,s-i<1e-12)break}return u}function ie(z,M){let i=z,s=1/z,u=s;for(let f=0;f<300&&(i+=1,u*=M/i,s+=u,!(Math.abs(u)<Math.abs(s)*ae));f++);return s*Math.exp(-M+z*Math.log(M)-q(z))}function G(z,M){let i=M+1-z,s=1/Q,u=1/i,f=u;for(let c=1;c<=300;c++){const t=-c*(c-z);i+=2,u=t*u+i,Math.abs(u)<Q&&(u=Q),s=i+t/s,Math.abs(s)<Q&&(s=Q),u=1/u;const a=u*s;if(f*=a,Math.abs(a-1)<ae)break}return Math.exp(-M+z*Math.log(M)-q(z))*f}function D(z,M){return!(z>0)||!(M>=0)||!Number.isFinite(M)?Number.NaN:M===0?0:M<z+1?ie(z,M):1-G(z,M)}function Y(z,M){return M>0?D(M/2,z/2):Number.NaN}function ee(z,M){const i=Y(z,M);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Se("packages/core/src/compute/linalg.js",function(o,fe){"use strict";Object.defineProperty(o,"cholesky",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"choleskySolve",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"choleskyInverse",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return _}});function le(F){const H=F.length,ne=Array.from({length:H},()=>new Array(H).fill(0));for(let x=0;x<H;x++)for(let ce=0;ce<=x;ce++){let ie=F[x][ce];for(let G=0;G<ce;G++)ie-=ne[x][G]*ne[ce][G];if(x===ce){if(!(ie>0))return null;ne[x][ce]=Math.sqrt(ie)}else ne[x][ce]=ie/ne[ce][ce]}return ne}function ae(F,H){const ne=F.length,x=new Array(ne).fill(0);for(let ie=0;ie<ne;ie++){let G=H[ie];for(let D=0;D<ie;D++)G-=F[ie][D]*x[D];x[ie]=G/F[ie][ie]}const ce=new Array(ne).fill(0);for(let ie=ne-1;ie>=0;ie--){let G=x[ie];for(let D=ie+1;D<ne;D++)G-=F[D][ie]*ce[D];ce[ie]=G/F[ie][ie]}return ce}function Q(F){const H=F.length,ne=Array.from({length:H},()=>new Array(H).fill(0));for(let x=0;x<H;x++){const ce=new Array(H).fill(0);ce[x]=1;const ie=ae(F,ce);for(let G=0;G<H;G++)ne[G][x]=ie[G]}return ne}function q(F,H,ne){const x=F.length,ce=x?F[0].length:0,ie=Array.from({length:ce},()=>new Array(ce).fill(0)),G=new Array(ce).fill(0);for(let D=0;D<x;D++){const Y=ne?ne[D]:1,ee=F[D];for(let z=0;z<ce;z++){const M=Y*ee[z];G[z]+=M*H[D];for(let i=z;i<ce;i++)ie[z][i]+=M*ee[i]}}for(let D=0;D<ce;D++)for(let Y=0;Y<D;Y++)ie[D][Y]=ie[Y][D];return{xtwx:ie,xtwy:G}}function te(F,H){return F.map(ne=>ne.reduce((x,ce,ie)=>x+ce*H[ie],0))}function _(F,H){let ne=0;for(let x=0;x<F.length;x++){let ce=0;for(let ie=0;ie<F.length;ie++)ce+=H[x][ie]*F[ie];ne+=F[x]*ce}return ne}}),Se("packages/core/src/compute/sketch.js",function(o,fe){"use strict";Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return ie}});class le{#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(D){if(!Number.isFinite(D))return;this.#t++;const Y=D-this.#e;this.#e+=Y/this.#t,this.#n+=Y*(D-this.#e)}merge(D){if(D.#t===0)return;if(this.#t===0){this.#t=D.#t,this.#e=D.#e,this.#n=D.#n;return}const Y=this.#t+D.#t,ee=D.#e-this.#e;this.#e+=ee*(D.#t/Y),this.#n+=D.#n+ee*ee*(this.#t*D.#t/Y),this.#t=Y}mean(){return this.#t?this.#e:null}variance(){return this.#t>1?this.#n/(this.#t-1):null}varianceP(){return this.#t?this.#n/this.#t:null}stddev(){const D=this.variance();return D===null?null:Math.sqrt(D)}stddevP(){const D=this.varianceP();return D===null?null:Math.sqrt(D)}}class ae{#t=[];#e=0;#n;#r;constructor(D,Y=Math.random){if(!(D>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(D),this.#r=Y}static get errorBound(){return Object.freeze({kind:"probabilistic",metric:"none",value:0,statement:"uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators"})}get seen(){return this.#e}get size(){return this.#t.length}add(D){if(!Number.isFinite(D))return;if(this.#e++,this.#t.length<this.#n){this.#t.push(D);return}const Y=Math.floor(this.#r()*this.#e);Y<this.#n&&(this.#t[Y]=D)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let D=0;for(const Y of this.#t)D+=Y;return D/this.#t.length}quantile(D){const Y=this.#t.length;if(!Y)return null;const ee=this.#t.slice().sort((s,u)=>s-u);if(Y===1)return ee[0];const z=(Y-1)*Math.min(1,Math.max(0,D)),M=Math.floor(z),i=Math.ceil(z);return M===i?ee[M]:ee[M]+(z-M)*(ee[i]-ee[M])}}function Q(G){return G^=G>>>16,G=Math.imul(G,2246822507),G^=G>>>13,G=Math.imul(G,3266489909),G^=G>>>15,G>>>0}function q(G){if(typeof G=="number"){const ee=new DataView(new ArrayBuffer(8));return ee.setFloat64(0,G===0?0:G),Q(ee.getUint32(0)^ee.getUint32(4))}const D=typeof G=="string"?G:String(G);let Y=2166136261;for(let ee=0;ee<D.length;ee++)Y^=D.charCodeAt(ee),Y=Math.imul(Y,16777619);return Q(Y)}class te{#t;#e;#n;constructor(D=14){const Y=Math.floor(D);if(Y<4||Y>16)throw new RangeError("HLL precision must be 4..16");this.#t=Y,this.#e=1<<Y,this.#n=new Uint8Array(this.#e)}static errorBoundFor(D=14){const Y=1<<Math.floor(D),ee=1.04/Math.sqrt(Y);return Object.freeze({kind:"probabilistic",metric:"relative",value:ee,statement:`distinct count within ~${(ee*100).toFixed(2)}% relative standard error (m=${Y} buckets)`})}errorBound(){return te.errorBoundFor(this.#t)}add(D){const Y=q(D),ee=Y&this.#e-1,z=Y>>>this.#t|1<<32-this.#t;let M=1,i=z;for(;(i&1)===0;)M++,i>>>=1;M>this.#n[ee]&&(this.#n[ee]=M)}count(){const D=this.#e,Y=32-this.#t,ee=new Float64Array(Y+2);for(let i=0;i<D;i++)ee[this.#n[i]]++;let z=D*H(1-ee[Y+1]/D);for(let i=Y;i>=1;i--)z=.5*(z+ee[i]);z+=D*F(ee[0]/D);const M=_*D*D/z;return Math.round(M)}}const _=.5/Math.log(2);function F(G){if(G===1)return 1/0;let D=1,Y=G,ee;do G*=G,ee=Y,Y+=G*D,D+=D;while(Y!==ee);return Y}function H(G){if(G===0||G===1)return 0;let D=1,Y=1-G,ee;do G=Math.sqrt(G),ee=Y,D*=.5,Y-=(1-G)**2*D;while(Y!==ee);return Y/3}class ne{#t=new Map;#e;#n=0;constructor(D){if(!(D>0))throw new RangeError("Space-Saving capacity must be positive");this.#e=Math.floor(D)}errorBoundFor(D){const Y=D/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:Y,statement:`each count overestimates the truth by at most N/m = ${Y.toFixed(2)} (N=${D}, m=${this.#e})`})}get seen(){return this.#n}add(D){this.#n++;const Y=this.#t.get(D);if(Y){Y.count++;return}if(this.#t.size<this.#e){this.#t.set(D,{count:1,error:0});return}let ee,z=1/0;for(const[M,i]of this.#t)i.count<z&&(z=i.count,ee=M);this.#t.delete(ee),this.#t.set(D,{count:z+1,error:z})}top(D=this.#e){return[...this.#t.entries()].map(([ee,z])=>({item:ee,count:z.count,error:z.error})).sort((ee,z)=>z.count-ee.count).slice(0,Math.max(0,Math.floor(D)))}}class x{#t;#e=[[]];#n=0;#r;#i;constructor(D=200,Y=Math.random){this.#t=Math.max(8,Math.floor(D)),this.#r=Y,this.#i=2/3}static errorBoundFor(D=200){const Y=1/Math.max(8,Math.floor(D));return Object.freeze({kind:"probabilistic",metric:"rank",value:Y,statement:`queried quantile\'s true rank within ~${(Y*100).toFixed(2)}% of N of the requested rank (k=${D})`})}errorBound(){return x.errorBoundFor(this.#t)}get count(){return this.#n}#s(D){const ee=this.#e.length-1-D,z=Math.ceil(this.#t*this.#i**ee);return Math.max(2,z)}add(D){Number.isFinite(D)&&(this.#n++,this.#e[0].push(D),this.#e[0].length>=this.#s(0)&&this.#h(0))}#h(D){const Y=this.#e[D];Y.sort((M,i)=>M-i),D+1>=this.#e.length&&this.#e.push([]);const ee=this.#e[D+1],z=this.#r()<.5?0:1;for(let M=z;M<Y.length;M+=2)ee.push(Y[M]);this.#e[D]=[];for(let M=0;M<this.#e.length;M++)if(this.#e[M].length>=this.#s(M)){this.#h(M);return}}#u(){const D=[];for(let Y=0;Y<this.#e.length;Y++){const ee=1<<Y;for(const z of this.#e[Y])D.push({v:z,w:ee})}return D}quantile(D){const Y=this.#u();if(!Y.length)return null;Y.sort((i,s)=>i.v-s.v);let ee=0;for(const i of Y)ee+=i.w;const z=Math.min(1,Math.max(0,D))*ee;let M=0;for(const i of Y)if(M+=i.w,M>=z)return i.v;return Y[Y.length-1].v}rank(D){let Y=0;for(let ee=0;ee<this.#e.length;ee++){const z=1<<ee;for(const M of this.#e[ee])M<=D&&(Y+=z)}return Y}}const ce=Object.freeze({distinct:te.errorBoundFor(14),median:x.errorBoundFor(200),p25:x.errorBoundFor(200),p75:x.errorBoundFor(200),p90:x.errorBoundFor(200),p95:x.errorBoundFor(200),p99:x.errorBoundFor(200),iqr:x.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"})}),ie={Welford:le,Reservoir:ae,HyperLogLog:te,SpaceSaving:ne,KLL:x,hash32:q,SKETCH_BOUNDS:ce}}),Se("packages/core/src/compute/statistics.js",function(o,fe){"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 g}}),Object.defineProperty(o,"evenness",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"topShare",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"gini",{enumerable:!0,get:function(){return d}}),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 E}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"weightedAverage",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"extremeRow",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"correlation",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return O}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"fitLinearModel",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(o,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(o,"augmentedDickeyFuller",{enumerable:!0,get:function(){return We}}),Object.defineProperty(o,"autocorrelations",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(o,"spearman",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(o,"kendall",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(o,"seriesStats",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(o,"D2_N2",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(o,"D4_N2",{enumerable:!0,get:function(){return it}}),Object.defineProperty(o,"movingRanges",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(o,"withinSigma",{enumerable:!0,get:function(){return Ze}}),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 ot}}),Object.defineProperty(o,"nelsonViolations",{enumerable:!0,get:function(){return st}}),Object.defineProperty(o,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(o,"controlViolations",{enumerable:!0,get:function(){return At}}),Object.defineProperty(o,"countOutside",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(o,"histogram",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(o,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(o,"meanInterval",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(o,"proportionInterval",{enumerable:!0,get:function(){return St}}),Object.defineProperty(o,"slopeInterval",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(o,"capabilityInterval",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(o,"standardizedMeanDifference",{enumerable:!0,get:function(){return ut}}),Object.defineProperty(o,"normalTotalVariation",{enumerable:!0,get:function(){return ct}}),Object.defineProperty(o,"frequencyMap",{enumerable:!0,get:function(){return Je}}),Object.defineProperty(o,"categoricalDistance",{enumerable:!0,get:function(){return lt}}),Object.defineProperty(o,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(o,"compareColumn",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(o,"isNumericColumn",{enumerable:!0,get:function(){return at}}),Object.defineProperty(o,"populationRead",{enumerable:!0,get:function(){return Rt}});const le=fe("packages/core/src/compute/handle.js"),ae=le.presenceReader,Q=le.valueReader,q=fe("packages/core/src/compute/special.js"),te=q.studentTQuantile,_=q.studentT,F=q.normalQuantile,H=q.normalCdf,ne=q.chiSquareUpperTail,x=fe("packages/core/src/compute/linalg.js"),ce=x.cholesky,ie=x.choleskySolve,G=x.choleskyInverse,D=x.normalEquations,Y=x.quadForm,z=fe("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:z.distinct}),median:Object.freeze({sketch:"KLL",bound:z.median}),p25:Object.freeze({sketch:"KLL",bound:z.p25}),p75:Object.freeze({sketch:"KLL",bound:z.p75}),p90:Object.freeze({sketch:"KLL",bound:z.p90}),p95:Object.freeze({sketch:"KLL",bound:z.p95}),p99:Object.freeze({sketch:"KLL",bound:z.p99}),iqr:Object.freeze({sketch:"KLL",bound:z.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:z.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:z.topK})});function u(y){const A=y==="sum"||y==="avg"||y==="countValues"||y==="min"||y==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,y)?i[y]:null,p=Object.prototype.hasOwnProperty.call(s,y)?s[y]:null;return{stat:y,exact:A,approximate:p}}function f(y,A){const p=A.length,k=new Float64Array(p);let j=0;if(y&&(y.kind==="float64"||y.kind==="int32")){const B=y.values,$=ae(y);for(let re=0;re<p;re++){const ue=A[re];if($&&$(ue)!==1)continue;const ge=B[ue];Number.isNaN(ge)||(k[j++]=ge)}return k.subarray(0,j)}const W=Q(y);for(let B=0;B<p;B++){const $=W(A[B]);if($==null||$==="")continue;const re=typeof $=="number"?$:Number($);Number.isFinite(re)&&(k[j++]=re)}return k.subarray(0,j)}function c(y,A){const p=new Map,k=Q(y);let j=0;for(let W=0;W<A.length;W++){const B=k(A[W]);if(B==null||B===""||typeof B=="number"&&Number.isNaN(B))continue;const $=typeof B=="object"?String(B):B;p.set($,(p.get($)||0)+1),j++}const N=[...p.values()].sort((W,B)=>B-W);return{counts:N,total:j,distinct:N.length}}function t(y){return y.total>0?y.counts.map(A=>A/y.total):[]}function a(y,A){const p=c(y,A);if(!p.total)return null;let k=0;for(const j of t(p))k+=j*j;return k}function g(y,A){const p=c(y,A);if(!p.total)return null;let k=0;for(const j of t(p))j>0&&(k-=j*Math.log2(j));return k}function e(y,A){const p=c(y,A);if(!p.total||p.distinct<2)return p.total?1:null;let k=0;for(const j of t(p))j>0&&(k-=j*Math.log2(j));return k/Math.log2(p.distinct)}function m(y,A,p=3){const k=c(y,A);if(!k.total)return null;const j=Math.max(1,Math.floor(p));let N=0;for(let W=0;W<Math.min(j,k.counts.length);W++)N+=k.counts[W];return N/k.total}function d(y,A){const p=f(y,A),k=p.length;if(!k)return null;const j=p.slice().sort();if(j[0]<0)return null;let N=0,W=0;for(let B=0;B<k;B++)N+=j[B],W+=(B+1)*j[B];return N===0?0:2*W/(k*N)-(k+1)/k}function r(y){let A=0,p=0,k=0;for(let j=0;j<y.length;j++){const N=y[j];A++;const W=N-p;p+=W/A,k+=W*(N-p)}return{n:A,mean:p,m2:k}}function n(y,A){const p=y.length;if(!p)return NaN;if(p===1)return y[0];const k=(p-1)*Math.min(1,Math.max(0,A)),j=Math.floor(k),N=Math.ceil(k);return j===N?y[j]:y[j]+(k-j)*(y[N]-y[j])}function l(y,A){if(!y.length)return NaN;const p=y.slice().sort();return n(p,A)}function b(y,A){const p=Q(y);let k=0,j=0,N=0;for(let W=0;W<A.length;W++){const B=p(A[W]);if(B==null||B==="")continue;const $=String(B).toUpperCase();$==="PASS"?k++:$==="FAIL"?j++:$==="WARN"&&N++}return{pass:k+N,fail:j,warn:N,judged:k+N+j}}const E=Object.freeze({hhi:(y,A)=>a(y,A),entropy:(y,A)=>g(y,A),evenness:(y,A)=>e(y,A),top3Share:(y,A)=>m(y,A,3),top10Share:(y,A)=>m(y,A,10),gini:(y,A)=>d(y,A),trimmedMean:(y,A)=>X(f(y,A),.1),winsorizedMean:(y,A)=>C(f(y,A),.1),robustOutliers:(y,A)=>R(f(y,A),3.5),jarqueBera:(y,A)=>h(f(y,A)),variance:(y,A)=>{const{n:p,m2:k}=r(f(y,A));return p>1?k/(p-1):null},varianceP:(y,A)=>{const{n:p,m2:k}=r(f(y,A));return p>0?k/p:null},stddev:(y,A)=>{const{n:p,m2:k}=r(f(y,A));return p>1?Math.sqrt(k/(p-1)):null},stddevP:(y,A)=>{const{n:p,m2:k}=r(f(y,A));return p>0?Math.sqrt(k/p):null},median:(y,A)=>{const p=f(y,A);return p.length?l(p,.5):null},p25:(y,A)=>{const p=f(y,A);return p.length?l(p,.25):null},p75:(y,A)=>{const p=f(y,A);return p.length?l(p,.75):null},p90:(y,A)=>{const p=f(y,A);return p.length?l(p,.9):null},p95:(y,A)=>{const p=f(y,A);return p.length?l(p,.95):null},p99:(y,A)=>{const p=f(y,A);return p.length?l(p,.99):null},iqr:(y,A)=>{const p=f(y,A);if(!p.length)return null;const k=p.slice().sort();return n(k,.75)-n(k,.25)},mad:(y,A)=>{const p=f(y,A);if(!p.length)return null;const k=l(p,.5),j=new Float64Array(p.length);for(let N=0;N<p.length;N++)j[N]=Math.abs(p[N]-k);return l(j,.5)},range:(y,A)=>{const p=f(y,A);if(!p.length)return null;let k=1/0,j=-1/0;for(let N=0;N<p.length;N++)p[N]<k&&(k=p[N]),p[N]>j&&(j=p[N]);return j-k},distinct:(y,A)=>{const p=Q(y),k=new Set;for(let j=0;j<A.length;j++){const N=p(A[j]);N==null||N===""||k.add(N instanceof Date?N.getTime():N)}return k.size},mode:(y,A)=>{const p=Q(y),k=new Map;for(let W=0;W<A.length;W++){const B=p(A[W]);if(B==null||B==="")continue;const $=B instanceof Date?B.getTime():B;k.set($,(k.get($)||0)+1)}let j=null,N=1;for(const[W,B]of k)B>N&&(N=B,j=W);return j},skewness:(y,A)=>{const p=f(y,A),{n:k,mean:j,m2:N}=r(p);if(k<3||N<=0)return null;const W=Math.sqrt(N/(k-1));let B=0;for(let $=0;$<p.length;$++)B+=((p[$]-j)/W)**3;return k/((k-1)*(k-2))*B},kurtosis:(y,A)=>{const p=f(y,A),{n:k,mean:j,m2:N}=r(p);if(k<4||N<=0)return null;const W=Math.sqrt(N/(k-1));let B=0;for(let ue=0;ue<p.length;ue++)B+=((p[ue]-j)/W)**4;const $=k*(k+1)/((k-1)*(k-2)*(k-3)),re=3*(k-1)**2/((k-2)*(k-3));return $*B-re},geomean:(y,A)=>{const p=f(y,A);if(!p.length)return null;let k=0;for(let j=0;j<p.length;j++){if(p[j]<=0)return null;k+=Math.log(p[j])}return Math.exp(k/p.length)},harmean:(y,A)=>{const p=f(y,A);if(!p.length)return null;let k=0;for(let j=0;j<p.length;j++){if(p[j]===0)return null;k+=1/p[j]}return p.length/k},sumSquares:(y,A)=>{const p=f(y,A);let k=0;for(let j=0;j<p.length;j++)k+=p[j]*p[j];return k},passRate:(y,A)=>{const{pass:p,judged:k}=b(y,A);return k?p/k:null},failureCount:(y,A)=>b(y,A).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 V(y,A,p){const k=Q(y),j=Q(A);let N=0,W=0;for(let B=0;B<p.length;B++){const $=p[B],re=Number(k($)),ue=Number(j($));!Number.isFinite(re)||!Number.isFinite(ue)||(N+=re*ue,W+=ue)}return W===0?null:N/W}function U(y,A,p){const k=Q(y);let j=null,N=p?-1/0:1/0;for(let W=0;W<A.length;W++){const B=A[W],$=Number(k(B));Number.isFinite($)&&(p?$>N:$<N)&&(N=$,j=B)}return j}function I(y,A,p){const k=Q(y),j=Q(A);let N=0,W=0,B=0,$=0,re=0,ue=0;for(let de=0;de<p.length;de++){const we=p[de],ke=Number(k(we)),me=Number(j(we));!Number.isFinite(ke)||!Number.isFinite(me)||(N++,W+=ke,B+=me,$+=ke*ke,re+=me*me,ue+=ke*me)}if(N<2)return null;const ge=N*ue-W*B,be=Math.sqrt((N*$-W*W)*(N*re-B*B));if(be===0)return null;const pe=ge/be;return Math.max(-1,Math.min(1,pe))}function X(y,A=.1){const p=y.length;if(!p)return null;const k=Array.from(y).sort((B,$)=>B-$),j=Math.floor(p*Math.min(.49,Math.max(0,A))),N=k.slice(j,p-j);if(!N.length)return n(k,.5);let W=0;for(const B of N)W+=B;return W/N.length}function C(y,A=.1){const p=y.length;if(!p)return null;const k=Array.from(y).sort(($,re)=>$-re),j=Math.floor(p*Math.min(.49,Math.max(0,A))),N=k[j],W=k[p-1-j];let B=0;for(const $ of k)B+=Math.min(W,Math.max(N,$));return B/p}function R(y,A=3.5){if(!y.length)return null;const k=Array.from(y).sort(($,re)=>$-re),j=n(k,.5),N=k.map($=>Math.abs($-j)).sort(($,re)=>$-re),W=n(N,.5);if(W===0)return null;let B=0;for(const $ of k)Math.abs(.6745*($-j)/W)>A&&B++;return B}function h(y){const A=y.length;if(A<8)return null;let p=0;for(const $ of y)p+=$;p/=A;let k=0,j=0,N=0;for(const $ of y){const re=$-p;k+=re*re,j+=re*re*re,N+=re*re*re*re}if(k/=A,j/=A,N/=A,k===0)return null;const W=j/k**1.5,B=N/(k*k)-3;return A/6*(W*W+B*B/4)}function O(y,A,p){const k=[];let j=0;for(let $=0;$<y.length;$++){const re=Number(y[$]),ue=Number(A[$]);!Number.isFinite(re)||!Number.isFinite(ue)||ue<=0||(k.push([re,ue]),j+=ue)}if(!k.length||j<=0)return null;if(k.sort(($,re)=>$[0]-re[0]),k.length===1)return k[0][0];const N=[];let W=0;for(const[,$]of k)N.push((W+$/2)/j),W+=$;const B=Math.max(0,Math.min(1,p));if(B<=N[0])return k[0][0];if(B>=N[N.length-1])return k[k.length-1][0];for(let $=1;$<N.length;$++){if(B>N[$])continue;const re=N[$]-N[$-1],ue=re>0?(B-N[$-1])/re:0;return k[$-1][0]+(k[$][0]-k[$-1][0])*ue}return k[k.length-1][0]}function w(y,A,p){const k=Q(y),j=Q(A),N=new Float64Array(p.length),W=new Float64Array(p.length);let B=0;for(let $=0;$<p.length;$++){const re=p[$],ue=Number(k(re)),ge=Number(j(re));!Number.isFinite(ue)||!Number.isFinite(ge)||(N[B]=ue,W[B]=ge,B++)}return{xs:N.subarray(0,B),ys:W.subarray(0,B),n:B}}function P(y,A,p,k=!1){const{xs:j,ys:N,n:W}=w(y,A,p);if(W<2)return null;let B=0,$=0;for(let ue=0;ue<W;ue++)B+=j[ue],$+=N[ue];B/=W,$/=W;let re=0;for(let ue=0;ue<W;ue++)re+=(j[ue]-B)*(N[ue]-$);return re/(k?W:W-1)}function v(y,A,p){const{xs:k,ys:j,n:N}=w(y,A,p);if(N<2)return null;let W=0,B=0;for(let ke=0;ke<N;ke++)W+=k[ke],B+=j[ke];W/=N,B/=N;let $=0,re=0,ue=0;for(let ke=0;ke<N;ke++){const me=k[ke]-W,ve=j[ke]-B;$+=me*me,re+=me*ve,ue+=ve*ve}if($===0)return null;const ge=re/$,be=B-ge*W,pe=ue===0?1:Math.max(0,Math.min(1,re*re/($*ue))),de=Math.max(0,ue-ge*re),we=N>2?Math.sqrt(de/(N-2)/$):0;return{slope:ge,intercept:be,r2:pe,stdError:we,n:N}}const K=new Set(["ols","wls","robust"]),Z=new Set(["quantile"]),oe=new Set(["ridge","lasso","elasticnet","mixed","gls"]),se=1.345;function T(y,A,p){const{xtwx:k,xtwy:j}=D(y,A,p),N=ce(k);if(!N)return null;const W=ie(N,j),B=G(N),$=L(y,W),re=A.map((ue,ge)=>ue-$[ge]);return{beta:W,cov:B,fitted:$,residuals:re}}function L(y,A){return y.map(p=>p.reduce((k,j,N)=>k+j*A[N],0))}function J(y,A){const p=y.length,k=y.map(re=>re[A]),j=y.map(re=>[1,...re.filter((ue,ge)=>ge!==A)]),N=T(j,k,null);if(!N)return 1;const W=k.reduce((re,ue)=>re+ue,0)/p;let B=0,$=0;for(let re=0;re<p;re++)B+=N.residuals[re]**2,$+=(k[re]-W)**2;return $===0?1:Math.max(0,Math.min(1,1-B/$))}function he(y){const A=[...y].sort((j,N)=>j-N),p=ye(A),k=y.map(j=>Math.abs(j-p)).sort((j,N)=>j-N);return ye(k)/.6745}function ye(y){const A=y.length;if(!A)return 0;const p=Math.floor(A/2);return A%2?y[p]:(y[p-1]+y[p])/2}function Me(y,A,p={}){const k=p.method||"ols";if(oe.has(k))throw new Error(`[lattice] regression method "${k}" is out of scope; use ols, wls or robust.`);if(Z.has(k))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!K.has(k))throw new Error(`[lattice] unknown regression method "${k}"; use ols, wls or robust.`);const j=Array.isArray(A)?A.length:0,N=j&&Array.isArray(y[0])?y[0].length:0,W=N+1;if(!(j>W))return null;for(let Oe=0;Oe<j;Oe++){if(!Number.isFinite(A[Oe])||!Array.isArray(y[Oe])||y[Oe].length!==N)return null;for(let Ae=0;Ae<N;Ae++)if(!Number.isFinite(y[Oe][Ae]))return null}let B=null;if(k==="wls"){if(B=p.weights,!Array.isArray(B)||B.length!==j)return null;for(let Oe=0;Oe<j;Oe++)if(!(B[Oe]>0)||!Number.isFinite(B[Oe]))return null}const $=y.map(Oe=>[1,...Oe]);let re,ue=null;if(k==="robust"){if(re=T($,A,null),!re)return null;for(let Oe=0;Oe<50;Oe++){const Ae=he(re.residuals);if(!(Ae>0))break;const Te=re.residuals.map(Ie=>{const Be=Math.abs(Ie/Ae);return Be<=se?1:se/Be}),Re=T($,A,Te);if(!Re)return null;const ze=Re.beta.reduce((Ie,Be,Qe)=>Math.max(Ie,Math.abs(Be-re.beta[Qe])),0);if(re=Re,ue=Te,ze<1e-10)break}}else if(re=T($,A,B),!re)return null;const ge=k==="robust"?ue:B,{beta:be,cov:pe,fitted:de,residuals:we}=re;let ke=0,me=0,ve=0;for(let Oe=0;Oe<j;Oe++){const Ae=ge?ge[Oe]:1;ke+=Ae*we[Oe]**2,me+=Ae,ve+=Ae*A[Oe]}const Ee=ve/me;let Le=0;for(let Oe=0;Oe<j;Oe++){const Ae=ge?ge[Oe]:1;Le+=Ae*(A[Oe]-Ee)**2}const Fe=j-W,De=ke/Fe,Ce=Le===0?1:Math.max(0,Math.min(1,1-ke/Le)),_e=1-(1-Ce)*(j-1)/Fe,Ge=Array.isArray(p.names)&&p.names.length===N?p.names:y[0].map((Oe,Ae)=>`x${Ae+1}`),Ue=He(p.confidence),Ye=Fe>0?te(1-(1-Ue)/2,Fe):1/0,Lt=be.map((Oe,Ae)=>{const Te=Math.sqrt(Math.max(0,De*pe[Ae][Ae])),Re=Te>0?Oe/Te:Oe===0?0:1/0,ze=Number.isFinite(Re)?2*(1-_(Math.abs(Re),Fe)):0,Ie=Number.isFinite(Ye)?Ye*Te:null;return{name:Ae===0?"(intercept)":Ge[Ae-1],estimate:Oe,stdError:Te,t:Re,p:Math.max(0,Math.min(1,ze)),lower:Ie===null?null:Oe-Ie,upper:Ie===null?null:Oe+Ie}}),ft=new Array(j),ht=new Array(j);for(let Oe=0;Oe<j;Oe++){const Ae=ge?ge[Oe]:1,Te=Math.max(0,Math.min(1,Ae*Y($[Oe],pe)));ft[Oe]=Te;const Re=(1-Te)**2;ht[Oe]=Re>0&&De>0?we[Oe]**2/(W*De)*(Te/Re):null}const Ft=y[0].map((Oe,Ae)=>{if(N<2)return 1;const Te=J(y,Ae);return Te>=1?1/0:1/(1-Te)});let dt=null;{const Oe=we.map(Te=>Te*Te),Ae=T($,Oe,null);if(Ae){const Te=Oe.reduce((Ke,Ct)=>Ke+Ct,0)/j;let Re=0,ze=0;for(let Ke=0;Ke<j;Ke++)Re+=Ae.residuals[Ke]**2,ze+=(Oe[Ke]-Te)**2;const Ie=ze===0?0:Math.max(0,Math.min(1,1-Re/ze)),Be=j*Ie,Qe=ne(Be,N);dt={statistic:Be,df:N,p:Qe,heteroscedastic:Qe<.05}}}let mt=null;if(N===1){const Oe=y.map((Ae,Te)=>Te).sort((Ae,Te)=>y[Ae][0]-y[Te][0]);mt={confidence:Ue,points:Oe.map(Ae=>{const Te=$[Ae],Re=Math.sqrt(Math.max(0,De*Y(Te,pe)));return{x:y[Ae][0],yhat:de[Ae],lower:de[Ae]-Ye*Re,upper:de[Ae]+Ye*Re}})}}return{method:k,coefficients:Lt,r2:Ce,adjR2:_e,n:j,df:Fe,sigma2:De,fitted:de,residuals:we,leverage:ft,cooksD:ht,vif:Ft,heteroscedasticity:dt,band:mt,weights:ge?[...ge]:null}}function Pe(y){const A=y.length,p=Array.from({length:A},(N,W)=>W).sort((N,W)=>y[N]-y[W]),k=new Float64Array(A);let j=0;for(;j<A;){let N=j;for(;N+1<A&&y[p[N+1]]===y[p[j]];)N++;const W=(j+N)/2+1;for(let B=j;B<=N;B++)k[p[B]]=W;j=N+1}return k}const Ne=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function je(y){const A=[.01,.05,.1],p=[Ne["1%"],Ne["5%"],Ne["10%"]];if(y<=p[0]){const N=(Math.log(A[1])-Math.log(A[0]))/(p[1]-p[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(A[0])+N*(y-p[0]))))}if(y>=p[2]){const N=(Math.log(A[2])-Math.log(A[1]))/(p[2]-p[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(A[2])+N*(y-p[2]))))}const k=y<p[1]?0:1,j=(y-p[k])/(p[k+1]-p[k]);return Math.exp(Math.log(A[k])+j*(Math.log(A[k+1])-Math.log(A[k])))}function Ve(y,A,p,k){const j=p-k,N=k+3,W=new Array(j),B=new Array(j);let $=!0,re=k;for(let de=0;de<j;de++){const we=k+de,ke=new Float64Array(N);ke[0]=1,ke[1]=de+1,ke[2]=y[we];for(let me=1;me<=k;me++)ke[2+me]=A[we-me];for(let me=1;me<N;me++)Number.isFinite(ke[me])||(re=Math.min(re,me-3));W[de]=ke,B[de]=A[we],Number.isFinite(B[de])||($=!1)}if(!$)return 0;const{xtwx:ue,xtwy:ge}=D(W,B,null);let be=0,pe=1/0;for(let de=0;de<=re;de++){const we=de+3;if(!(j>we))continue;const ke=new Array(we);for(let Ce=0;Ce<we;Ce++)ke[Ce]=ue[Ce].slice(0,we);const me=ce(ke);if(!me)continue;const ve=ie(me,ge.slice(0,we));let Ee=0;for(let Ce=0;Ce<j;Ce++){const _e=W[Ce];let Ge=0;for(let Ue=0;Ue<we;Ue++)Ge+=_e[Ue]*ve[Ue];Ee+=(B[Ce]-Ge)**2}const Fe=Ee/(j-we)*(j-we);if(!(Fe>0))continue;const De=j*Math.log(Fe/j)+2*we;De<pe&&(pe=De,be=de)}return be}function We(y,A={}){const p=[];for(let pe=0;pe<y.length;pe++){const de=Number(y[pe]);Number.isFinite(de)&&p.push(de)}const k=p.length,j=k-1;if(k<8||j<6)return null;const N=new Array(j);for(let pe=0;pe<j;pe++)N[pe]=p[pe+1]-p[pe];let W=Number.isFinite(A.maxlag)?Math.floor(A.maxlag):Math.ceil(12*(k/100)**.25);W=Math.max(0,Math.min(W,Math.floor((j-5)/2)));const B=(pe,de)=>{const we=[],ke=[];for(let me=de;me<j;me++){const ve=[me-de+1,p[me]];for(let Ee=1;Ee<=pe;Ee++)ve.push(N[me-Ee]);we.push(ve),ke.push(N[me])}return Me(we,ke,{method:"ols"})},$=Ve(p,N,j,W),re=B($,$);if(!re||!re.coefficients[2])return null;const ue=re.coefficients[2].t,ge=je(ue),be=ue<Ne["5%"];return{statistic:ue,usedLag:$,nobs:j-$,criticalValues:{...Ne},pValue:ge,pApproximate:!0,stationary:be,verdict:be?"stationary":"non-stationary",regression:"ct"}}function Xe(y,A={}){const p=[];for(let be=0;be<y.length;be++){const pe=Number(y[be]);Number.isFinite(pe)&&p.push(pe)}const k=p.length;if(k<3)return null;let j=Number.isFinite(A.maxlag)?Math.floor(A.maxlag):Math.min(10,k-1);j=Math.max(1,Math.min(j,k-1));let N=0;for(const be of p)N+=be;N/=k;const W=p.map(be=>be-N);let B=0;for(const be of W)B+=be*be;B/=k;const $=new Array(j+1).fill(0);$[0]=1;for(let be=1;be<=j;be++){let pe=0;for(let de=be;de<k;de++)pe+=W[de]*W[de-be];$[be]=B>0?pe/k/B:0}const re=new Array(j+1).fill(0);re[0]=1;let ue=[];for(let be=1;be<=j;be++){let pe=$[be];for(let me=1;me<be;me++)pe-=ue[me-1]*$[be-me];let de=1;for(let me=1;me<be;me++)de-=ue[me-1]*$[me];const we=de!==0?pe/de:0,ke=new Array(be);for(let me=1;me<be;me++)ke[me-1]=ue[me-1]-we*ue[be-1-me];ke[be-1]=we,re[be]=we,ue=ke}const ge=1.96/Math.sqrt(k);return{acf:$,pacf:re,bounds:{upper:ge,lower:-ge},n:k,nlags:j,approximate:!0}}function qe(y,A,p){const{xs:k,ys:j,n:N}=w(y,A,p);if(N<2)return null;const W=Pe(k),B=Pe(j);let $=0,re=0;for(let pe=0;pe<N;pe++)$+=W[pe],re+=B[pe];$/=N,re/=N;let ue=0,ge=0,be=0;for(let pe=0;pe<N;pe++){const de=W[pe]-$,we=B[pe]-re;ue+=de*we,ge+=de*de,be+=we*we}return ge===0||be===0?null:Math.max(-1,Math.min(1,ue/Math.sqrt(ge*be)))}function yt(y,A,p){const{xs:k,ys:j,n:N}=w(y,A,p);if(N<2||N>M)return null;let W=0,B=0,$=0,re=0;for(let be=0;be<N;be++)for(let pe=be+1;pe<N;pe++){const de=Math.sign(k[be]-k[pe]),we=Math.sign(j[be]-j[pe]),ke=de*we;ke>0?W++:ke<0?B++:de===0&&we===0||(de===0?$++:re++)}const ue=W+B+re,ge=W+B+$;return ue===0||ge===0?null:(W-B)/Math.sqrt(ue*ge)}function pt(y,A={}){const p=y.length;if(p<2)return null;const k=y[0],j=y[p-1],N=[];for(let me=1;me<p;me++){const ve=y[me-1];ve!==0&&N.push((y[me]-ve)/Math.abs(ve))}let W=null;if(N.length>1){let me=0;for(const Ee of N)me+=Ee;me/=N.length;let ve=0;for(const Ee of N)ve+=(Ee-me)**2;W=Math.sqrt(ve/(N.length-1))}const B=Number(A.periodsPerYear)>0?Number(A.periodsPerYear):null;let $=y[0],re=0,ue=0,ge=0,be=0;for(let me=1;me<p;me++){if(y[me]>$){$=y[me],re=me;continue}if($<=0)continue;const ve=($-y[me])/$;ve>ue&&(ue=ve,ge=re,be=me)}let pe=null;if(p>2){let me=0;for(let Le=0;Le<p;Le++)me+=y[Le];me/=p;let ve=0,Ee=0;for(let Le=0;Le<p;Le++){const Fe=y[Le]-me;Ee+=Fe*Fe,Le>0&&(ve+=Fe*(y[Le-1]-me))}pe=Ee>0?ve/Ee:null}let de=0,we=0;for(const me of N)me>0?de++:me<0&&we++;let ke=null;if(k>0&&j>0){const me=(j/k)**(1/(p-1))-1;ke=B?(1+me)**B-1:me}return{n:p,first:k,last:j,change:j-k,changePercent:k===0?null:(j-k)/Math.abs(k)*100,volatility:W,annualisedVolatility:W!==null&&B?W*Math.sqrt(B):null,growth:ke,maxDrawdown:ue,maxDrawdownFrom:ge,maxDrawdownTo:be,autocorrelation:pe,upDays:de,downDays:we}}const rt=1.128,it=3.267;function wt(y){const A=y.length;if(A<2)return null;const p=[];for(let j=1;j<A;j++)p.push(Math.abs(y[j]-y[j-1]));const k=p.reduce((j,N)=>j+N,0)/p.length;return{ranges:p,centre:k,upper:it*k,lower:0}}function Ze(y){const A=y.length;if(A<2)return null;let p=0;for(let j=1;j<A;j++)p+=Math.abs(y[j]-y[j-1]);const k=p/(A-1);return{sigma:k/rt,meanRange:k}}function Ot(y,A){const p=y.length;if(p<2||!A)return null;const k=Number.isFinite(Number(A.lower))?Number(A.lower):null,j=Number.isFinite(Number(A.upper))?Number(A.upper):null;if(k===null&&j===null)return null;let N=0;for(let de=0;de<p;de++)N+=y[de];N/=p;let W=0;for(let de=0;de<p;de++)W+=(y[de]-N)**2;const B=Math.sqrt(W/(p-1)),$=Ze(y),re=$?$.sigma:null,ue=de=>{if(!de||de<=0)return{index:null,k:null};const ke=k!==null&&j!==null?(j-k)/(6*de):null,me=j!==null?(j-N)/(3*de):1/0,ve=k!==null?(N-k)/(3*de):1/0;return{index:ke,k:Math.min(me,ve)}},ge=ue(re),be=ue(B);let pe=0;for(let de=0;de<p;de++){if(k!==null&&y[de]<k){pe++;continue}j!==null&&y[de]>j&&pe++}return{n:p,mean:N,lower:k,upper:j,target:Number.isFinite(Number(A.target))?Number(A.target):null,sigmaWithin:re,sigmaOverall:B,cp:ge.index,cpk:ge.k,pp:be.index,ppk:be.k,outOfSpec:pe,defectRate:p?pe/p:null}}function kt(y){const A=y.length;if(A<2)return null;const p=Ze(y);if(!p||!(p.sigma>0))return null;let k=0;for(let j=0;j<A;j++)k+=y[j];return k/=A,{centre:k,sigma:p.sigma,upper:k+3*p.sigma,lower:k-3*p.sigma}}function ot(y,A){if(!A||!(A.sigma>0))return[];const p=y.length,{centre:k,sigma:j}=A,N=B=>(y[B]-k)/j,W=[];for(let B=0;B<p;B++){if(Math.abs(N(B))>3&&W.push({index:B,rule:1,description:"beyond three sigma"}),B>=2)for(const $ of[1,-1]){let re=0;for(let ue=B-2;ue<=B;ue++)N(ue)*$>2&&re++;if(re>=2){W.push({index:B,rule:2,description:"two of three past two sigma"});break}}if(B>=4)for(const $ of[1,-1]){let re=0;for(let ue=B-4;ue<=B;ue++)N(ue)*$>1&&re++;if(re>=4){W.push({index:B,rule:3,description:"four of five past one sigma"});break}}if(B>=7)for(const $ of[1,-1]){let re=!0;for(let ue=B-7;ue<=B;ue++)if(N(ue)*$<=0){re=!1;break}if(re){W.push({index:B,rule:4,description:"eight in a row on one side"});break}}}return W}function st(y,A){if(!A||!(A.sigma>0))return[];const p=y.length,{centre:k,sigma:j}=A,N=$=>(y[$]-k)/j,W=($,re,ue,ge)=>{for(const be of[1,-1]){let pe=0;for(let de=$;de<=re;de++)N(de)*be>ue&&pe++;if(pe>=ge)return!0}return!1},B=[];for(let $=0;$<p;$++){if(Math.abs(N($))>3&&B.push({index:$,rule:1,description:"beyond three sigma"}),$>=8)for(const re of[1,-1]){let ue=!0;for(let ge=$-8;ge<=$;ge++)if(N(ge)*re<=0){ue=!1;break}if(ue){B.push({index:$,rule:2,description:"nine in a row on one side"});break}}if($>=5)for(const re of[1,-1]){let ue=!0;for(let ge=$-4;ge<=$;ge++)if((y[ge]-y[ge-1])*re<=0){ue=!1;break}if(ue){B.push({index:$,rule:3,description:re>0?"six rising":"six falling"});break}}if($>=13){let re=!0;for(let ue=$-12;ue<=$;ue++){const ge=y[ue]-y[ue-1],be=y[ue+1<=$?ue+1:ue]-y[ue];if(ue+1>$)break;if(ge===0||be===0||ge>0==be>0){re=!1;break}}re&&B.push({index:$,rule:4,description:"fourteen alternating"})}if($>=2&&W($-2,$,2,2)&&B.push({index:$,rule:5,description:"two of three past two sigma"}),$>=4&&W($-4,$,1,4)&&B.push({index:$,rule:6,description:"four of five past one sigma"}),$>=14){let re=!0;for(let ue=$-14;ue<=$;ue++)if(Math.abs(N(ue))>=1){re=!1;break}re&&B.push({index:$,rule:7,description:"fifteen within one sigma"})}if($>=7){let re=!0;for(let ue=$-7;ue<=$;ue++)if(Math.abs(N(ue))<=1){re=!1;break}re&&B.push({index:$,rule:8,description:"eight beyond one sigma"})}}return B}const jt=Object.freeze(["westernElectric","nelson"]);function At(y,A,p="westernElectric"){return String(p)==="nelson"?st(y,A):ot(y,A)}function Mt(y,A,p){let k=0;for(let j=0;j<y.length;j++)(y[j]<A||y[j]>p)&&k++;return k}function Pt(y,A,p,k=20){const j=y.length;if(!j)return[];const N=y[0],W=y[j-1];if(W===N)return[{from:N,to:W,count:j}];const B=p-A,$=1.5*B;let re=B>0?Math.max(N,A-$):N,ue=B>0?Math.min(W,p+$):W;ue>re||(re=N,ue=W);const ge=B>0?2*B/Math.cbrt(j):(ue-re)/(Math.ceil(Math.log2(j))+1),be=ge>0?Math.min(k,Math.max(1,Math.ceil((ue-re)/ge))):1,pe=(ue-re)/be,de=[];for(let we=0;we<be;we++)de.push({from:re+we*pe,to:re+(we+1)*pe,count:0});for(let we=0;we<j;we++){const ke=Math.min(be-1,Math.max(0,Math.floor((y[we]-re)/pe)));de[ke].count++}return de[0].from=N,de[be-1].to=W,de}const $e=.95;function He(y){const A=Number(y);return Number.isFinite(A)&&A>0&&A<1?A:$e}function Nt(y,A=$e){const p=y.length;if(p<2)return null;let k=0;for(let ue=0;ue<p;ue++)k+=y[ue];const j=k/p;let N=0;for(let ue=0;ue<p;ue++){const ge=y[ue]-j;N+=ge*ge}const W=Math.sqrt(N/(p-1)),B=He(A),re=te(1-(1-B)/2,p-1)*W/Math.sqrt(p);return{mean:j,lower:j-re,upper:j+re,margin:re,n:p,confidence:B}}function St(y,A,p=$e){const k=Number(y),j=Number(A);if(!(j>0)||!(k>=0)||k>j)return null;const N=He(p),W=F(1-(1-N)/2),B=k/j,$=W*W,re=1+$/j,ue=(B+$/(2*j))/re,ge=W/re*Math.sqrt(B*(1-B)/j+$/(4*j*j));return{proportion:B,lower:Math.max(0,ue-ge),upper:Math.min(1,ue+ge),n:j,confidence:N}}function vt(y,A=$e){if(!y||!(y.n>2)||!Number.isFinite(y.stdError))return null;const p=He(A),j=te(1-(1-p)/2,y.n-2)*y.stdError;return{slope:y.slope,lower:y.slope-j,upper:y.slope+j,margin:j,confidence:p}}function Tt(y,A,p=$e){const k=Number(y),j=Number(A);if(!Number.isFinite(k)||!(j>1))return null;const N=He(p),B=F(1-(1-N)/2)*Math.sqrt(1/(9*j)+k*k/(2*(j-1)));return{index:k,lower:k-B,upper:k+B,margin:B,n:j,confidence:N}}function ut(y,A){return!y||!(y.sd>0)||!Number.isFinite(A)||!Number.isFinite(y.mean)?null:(A-y.mean)/y.sd}function ct(y){return Number.isFinite(y)?Math.min(1,Math.max(0,2*H(Math.abs(y)/2)-1)):0}function Je(y,A){const p=new Map,k=Q(y);let j=0;for(let N=0;N<A.length;N++){const W=k(A[N]);if(W==null||W===""||typeof W=="number"&&Number.isNaN(W))continue;const B=W instanceof Date?W.getTime():typeof W=="object"?String(W):W;p.set(B,(p.get(B)||0)+1),j++}return{map:p,total:j}}function lt(y,A,p,k){if(!(A>0)||!(k>0))return null;let j=0;const N=new Set(y.keys());for(const W of p.keys())N.add(W);for(const W of N){const B=(y.get(W)||0)/A,$=(p.get(W)||0)/k;j+=Math.abs(B-$)}return j/2}const xe=10;function Et(y,A,p){if(p&&p.numeric){const B=f(y,A),{n:$,mean:re}=r(B),ue=$>0?ut({mean:p.mean,sd:p.sd},re):null;return{measure:"standardizedMeanDifference",magnitude:ue,distance:ue===null?0:ct(ue),direction:ue===null?0:Math.sign(ue),subsetN:$,populationN:p.n||0,reliable:$>=xe}}const{map:j,total:N}=Je(y,A),W=lt(j,N,p.map,p.total);return{measure:"categoricalTotalVariation",magnitude:W,distance:W===null?0:W,direction:0,subsetN:N,populationN:p.total||0,reliable:N>=xe}}function at(y,A){if(y&&(y.kind==="float64"||y.kind==="int32"))return!0;const p=Q(y);let k=0,j=0;for(let N=0;N<A.length&&k<200;N++){const W=p(A[N]);if(W==null||W==="")continue;if(W instanceof Date)return!1;k++;const B=typeof W=="number"?W:Number(W);Number.isFinite(B)&&j++}return k===0?!1:j/k>=.9}function Rt(y,A){if(at(y,A)){const j=f(y,A),{n:N,mean:W,m2:B}=r(j);return{numeric:!0,mean:W,sd:N>0?Math.sqrt(B/N):0,n:N}}const{map:p,total:k}=Je(y,A);return{numeric:!1,map:p,total:k}}}),Se("packages/core/src/compute/total.js",function(o,fe){"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 g}}),Object.defineProperty(o,"aggregateAllowed",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return d}});const le=fe("packages/core/src/internal/util.js"),ae=le.isFunction,Q=le.warnOnce,q=fe("packages/core/src/compute/handle.js"),te=q.presenceReader,_=q.valueComparator,F=q.valueReader,H=fe("packages/core/src/compute/statistics.js"),ne=H.STAT_FNS,x=H.STAT_LABELS;function ce(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function ie(r,n){const l=n.length;let b=0;if(ce(r)){const S=r.values,V=te(r);if(!V){for(let U=0;U<l;U++){const I=S[n[U]];Number.isNaN(I)||(b+=I)}return b}for(let U=0;U<l;U++){const I=n[U];if(V(I)===1){const X=S[I];Number.isNaN(X)||(b+=X)}}return b}const E=F(r);for(let S=0;S<l;S++){const V=u(E(n[S]));V!==null&&(b+=V)}return b}ie.kernel=!0;function G(r,n){const l=n.length;let b=0;if(ce(r)){const S=r.values,V=te(r);if(!V){for(let U=0;U<l;U++)Number.isNaN(S[n[U]])||b++;return b}for(let U=0;U<l;U++){const I=n[U];V(I)===1&&!Number.isNaN(S[I])&&b++}return b}const E=F(r);for(let S=0;S<l;S++){const V=E(n[S]);V!=null&&!(typeof V=="number"&&Number.isNaN(V))&&b++}return b}G.kernel=!0;function D(r,n){return n.length}D.kernel=!0;function Y(r,n){const l=G(r,n);return l===0?null:ie(r,n)/l}Y.kernel=!0;function ee(r,n,l,b){const E=n.length;if(ce(r)){const I=r.values,X=te(r);let C=null;if(!X){for(let R=0;R<E;R++){const h=I[n[R]];Number.isNaN(h)||(C===null||(l<0?h<C:h>C))&&(C=h)}return C}for(let R=0;R<E;R++){const h=n[R];if(X(h)===0)continue;const O=I[h];Number.isNaN(O)||(C===null||(l<0?O<C:O>C))&&(C=O)}return C}const S=F(r),V=_(b);let U=null;for(let I=0;I<E;I++){const X=S(n[I]);X==null||typeof X=="number"&&Number.isNaN(X)||(U===null||(l<0?V(X,U)<0:V(X,U)>0))&&(U=X)}return U}function z(r,n,l){return ee(r,n,-1,l&&l.locale)}z.kernel=!0;function M(r,n,l){return ee(r,n,1,l&&l.locale)}M.kernel=!0;function i(r,n){return n.length===0?null:F(r)(n[0])}i.kernel=!0;function s(r,n){return n.length===0?null:F(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:ie,min:z,max:M,avg:Y,count:D,first:i,last:s,countValues:G,...ne},c=Object.freeze({...x,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 g(r){const n=r&&r.dataType&&r.dataType.totals&&r.dataType.totals.supported;if(Array.isArray(n))return n.slice();const l=a.filter(b=>b in f);for(const b of Object.keys(f))l.includes(b)||l.push(b);return l}function e(r,n){return typeof n!="string"?!0:g(r).includes(n)}function m(r,n){const l=F(r),b=[];for(let E=0;E<n.length;E++){const S=l(n[E]);S!=null&&b.push(S)}return b}function d(r,n,l,b){const E=n||[];if(typeof l=="string"){const S=f[l];return S?S(r,E,b):(Q(`total:${l}`,`unknown total function "${l}"; register it in config.totalFns`),null)}return ae(l)?l.kernel===!0?l(r,E,b):l(m(r,E),b||{}):null}}),Se("packages/core/src/compute/pivot.js",function(o,fe){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return M}});const ae=fe("packages/core/src/internal/util.js").warnOnce,q=fe("packages/core/src/compute/handle.js").valueComparator,_=fe("packages/core/src/compute/group.js").packKeys,H=fe("packages/core/src/compute/total.js").total,ne="|",x="/",ce=2e3;function ie(u,f,c){return`${u}${ne}${f}${ne}${c}`}function G(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 D(u,f,c={}){const t=c.separator||x,a=f.length,{keyOf:g,readers:e}=_(u,f,0),m=new Map,d=[],r=[];for(let U=0;U<a;U++){const I=f[U],X=g(I);if(m.has(X))continue;m.set(X,d.length),r.push(X);const C=new Array(e.length);for(let R=0;R<e.length;R++)C[R]=e[R](I);d.push(C)}const n=q(c.locale),l=d.map((U,I)=>I);l.sort((U,I)=>{const X=d[U],C=d[I];for(let R=0;R<X.length;R++){const h=Y(X[R],C[R],n);if(h!==0)return h}return U-I});const b=new Array(l.length),E=new Array(l.length),S=new Map;for(let U=0;U<l.length;U++){const I=l[U];b[U]=d[I],E[U]=G(d[I],t),S.set(r[I],U)}return{keys:b,paths:E,idOf:U=>{const I=S.get(g(U));return I===void 0?-1:I}}}function Y(u,f,c){const t=u==null,a=f==null;return t||a?t&&a?0:t?1:-1:c(u,f)}function ee(u){const f=u.values||u.totals||[];if(f.length&&typeof f[0]=="object"&&f[0]!==null)return f.filter(g=>g&&g.handle);const c=typeof u.handle=="function"?u.handle:null;if(!c)return f.length&&ae("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 g of f){const e=c(g);e&&a.push({colId:g,handle:e,fn:t?t(g):"sum"})}return a}function z(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=z(u,f,c),a=t.separator||x,g=ee(t),e=t.maxColumns===void 0?ce:t.maxColumns,m=t.groups&&t.groups.buckets?t.groups:null,d=m?m.buckets:[t.order||new Uint32Array(0)],r=t.groupPaths||(m?m.keys.map(X=>G(X,a)):[""]),n=s(d),{keys:l,paths:b,idOf:E}=D(t.pivotHandles||[],n,t),S=b.length*Math.max(1,g.length),V=i(b,g,a);if(e&&S>e){const X=new Map;return{keys:l,paths:b,fields:V,groupPaths:r,columns:S,values:X,cells:X,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 U=new Map,I=b.length;for(let X=0;X<d.length;X++){const C=d[X],R=r[X]===void 0?"":r[X],h=C.length;if(h===0)continue;const O=new Int32Array(h),w=new Uint32Array(I+1);for(let K=0;K<h;K++){const Z=E(C[K]);O[K]=Z,Z>=0&&w[Z+1]++}for(let K=0;K<I;K++)w[K+1]+=w[K];const P=new Uint32Array(h),v=w.slice(0,I);for(let K=0;K<h;K++){const Z=O[K];Z>=0&&(P[v[Z]++]=C[K])}for(let K=0;K<I;K++){const Z=w[K],oe=w[K+1];if(oe===Z)continue;const se=P.subarray(Z,oe);for(let T=0;T<g.length;T++){const L=g[T],J=H(L.handle,se,L.fn,t.totalContext||{locale:t.locale});U.set(ie(R,b[K],L.colId),J)}}}return{keys:l,paths:b,fields:V,groupPaths:r,columns:S,values:U,cells:U,error:null}}function i(u,f,c){if(f.length===0)return u.slice();const t=[];for(const a of u)for(const g of f)t.push(`${a}${c}${g.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,fe){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return M}});const ae=fe("packages/core/src/compute/handle.js").valueComparator,q=fe("packages/core/src/compute/total.js").total,_=fe("packages/core/src/compute/group.js").packKeys,F=fe("packages/core/src/compute/pivot.js"),H=F.joinPath,ne=F.DEFAULT_PATH_SEPARATOR,x=F.DEFAULT_MAX_COLUMNS,ce="";function ie(i,s,u={}){const f=u.separator||ne,c=i||[],t=s instanceof Uint32Array?s:Uint32Array.from(s||[]),a=t.length;if(c.length===0)return{tuples:[[]],paths:[ce],buckets:[t]};const{keyOf:g,readers:e}=_(c,t,0),m=new Map,d=[],r=[],n=[];for(let U=0;U<a;U++){const I=t[U],X=g(I);let C=m.get(X);if(C===void 0){C=d.length,m.set(X,C),r.push(X);const R=new Array(e.length);for(let h=0;h<e.length;h++)R[h]=e[h](I);d.push(R),n.push([])}n[C].push(I)}const l=ae(u.locale),b=d.map((U,I)=>I);b.sort((U,I)=>{const X=d[U],C=d[I];for(let R=0;R<X.length;R++){const h=G(X[R],C[R],l);if(h!==0)return h}return U-I});const E=new Array(b.length),S=new Array(b.length),V=new Array(b.length);for(let U=0;U<b.length;U++){const I=b[U];E[U]=d[I],S[U]=H(d[I],f),V[U]=Uint32Array.from(n[I])}return{tuples:E,paths:S,buckets:V}}function G(i,s,u){const f=i==null,c=s==null;return f||c?f&&c?0:f?1:-1:u(i,s)}function D(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 Y(i,s,u,f){return{value:s.length?q(i,s,u,f):null,leaves:s,count:s.length}}function ee(i){const s=i&&i.opts||{},u=s.separator||ne,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=ie(i.rowHandles||[],t,{...s,separator:u}),g=ie(i.columnHandles||[],t,{...s,separator:u}),e=s.maxColumns===void 0?x:s.maxColumns,m=g.paths.length*Math.max(1,c.length),d=new Map;if(e&&m>e)return{rowAxis:a,columnAxis:g,measures:c.map(S=>({colId:S.colId,fn:S.fn})),body:d,rowMargin:d,columnMargin:d,grand:d,columns:m,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${m} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:m,maxColumns:e}};const r=new Map,n=new Map,l=new Map,b=new Map,E=g.buckets.map(S=>new Set(S));for(let S=0;S<g.paths.length;S++){const V=g.buckets[S],U=g.paths[S];for(const I of c)l.set(M(U,I.colId),Y(I.handle,V,I.fn,f))}for(let S=0;S<a.paths.length;S++){const V=a.buckets[S],U=a.paths[S];for(const I of c)n.set(M(U,I.colId),Y(I.handle,V,I.fn,f));for(let I=0;I<g.paths.length;I++){const X=D(V,g.buckets[I],E[I]);if(X.length===0)continue;const C=g.paths[I];for(const R of c)r.set(z(U,C,R.colId),Y(R.handle,X,R.fn,f))}}for(const S of c)b.set(S.colId,Y(S.handle,t,S.fn,f));return{rowAxis:a,columnAxis:g,measures:c.map(S=>({colId:S.colId,fn:S.fn})),body:r,rowMargin:n,columnMargin:l,grand:b,columns:m,error:null}}function z(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,fe){"use strict";Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ee}});const ae=fe("packages/core/src/internal/util.js").getPath,Q=fe("packages/core/src/compute/handle.js"),q=Q.isMissing,te=Q.valueComparator,F=fe("packages/core/src/compute/filter.js").testValue,H="",ne="\\0";function x(i,s){const u=s.includes(".")?ae(i,s):i?.[s];return u===void 0?null:u}function ce(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=ie(i,c,f[t],u);return c}function ie(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",g=[],e=[];for(const r of s){const n=x(i[r],u.col);q(n)?e.push(r):g.push(r)}const m=new Map;for(let r=0;r<g.length;r++)m.set(g[r],r);const d=(r,n)=>{const l=x(i[r],u.col),b=x(i[n],u.col);let E;return typeof u.compare=="function"?(E=u.compare(l,b,i[r],i[n],a),a&&(E=-E)):E=a?t(b,l):t(l,b),E!==0?E:m.get(r)-m.get(n)};return g.sort(d),u.nullsFirst?e.concat(g):g.concat(e)}function G(i,s,u={}){const f=[];for(let c=0;c<i.length;c++)D(i[c],s,u,c)&&f.push(c);return f}function D(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=>D(i,a,u,f));const t=c.every(a=>D(i,a,u,f));return s.op==="not"?!t:t}return s.col===void 0&&typeof u.custom=="function"?!!u.custom(s,i,f):F(x(i,s.col),s,u.locale)}function Y(i,s,u,f){const c=u||i.map((e,m)=>m),t=new Map,a=[],g=[];for(const e of c){const m=s.map((n,l)=>{const b=x(i[e],n);return f&&f[l]?f[l](b):b}),d=m.map(n=>n==null?ne:String(n)).join(H);let r=t.get(d);r===void 0&&(r=a.length,t.set(d,r),a.push(m),g.push([])),g[r].push(e)}return{keys:a,buckets:g}}function ee(i,s,u={}){const f=te(u.locale),c=i.filter(a=>!q(a)),t=c.map(z).filter(a=>a!==null);switch(s){case"count":return i.length;case"countValues":return c.length;case"sum":return t.reduce((a,g)=>a+g,0);case"avg":return c.length===0?null:t.reduce((a,g)=>a+g,0)/c.length;case"min":return c.length===0?null:c.reduce((a,g)=>f(g,a)<0?g:a);case"max":return c.length===0?null:c.reduce((a,g)=>f(g,a)>0?g: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 z(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,fe){"use strict";Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return _}});const ae=fe("packages/core/src/compute/sketch.js").Welford;class Q{#t;#e;#n=[];#r;#i;constructor(H,ne=0,x=Date.now){if(H!=="count"&&H!=="time"&&H!=="session")throw new RangeError(`unknown window kind: ${H}`);if((H==="count"||H==="time")&&!(ne>0))throw new RangeError(`a ${H} window needs a positive span`);this.#t=H,this.#e=Math.floor(ne),this.#r=x,this.#i=x()}get size(){return this.#n.length}push(H,ne=this.#r()){Number.isFinite(H)&&(this.#n.push({t:ne,v:H}),this.#s(ne))}#s(H){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const ne=H-this.#e;for(;this.#n.length&&this.#n[0].t<ne;)this.#n.shift()}}spec(){const H=this.#t==="session"?this.#r()-this.#i:this.#e;return{kind:this.#t,span:H,size:this.#n.length}}values(){return this.#n.map(H=>H.v)}aggregate(){const H=this.spec();if(!this.#n.length)return{over:H,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const ne=new ae;let x=0,ce=1/0,ie=-1/0;for(const{v:G}of this.#n)x+=G,G<ce&&(ce=G),G>ie&&(ie=G),ne.add(G);return{over:H,count:this.#n.length,sum:x,mean:ne.mean(),min:ce,max:ie,variance:ne.variance(),stddev:ne.stddev()}}reduce(H){const ne=this.aggregate(),x={sum:ne.sum,avg:ne.mean,mean:ne.mean,min:ne.min,max:ne.max,count:ne.count,variance:ne.variance,stddev:ne.stddev};if(!(H in x))throw new RangeError(`unknown windowed aggregate: ${H}`);return{value:x[H],over:ne.over}}}const q=Object.freeze(["count","time","session"]);function te(F,H=Date.now){const ne=F.kind==="time"&&F.minutes!=null?F.minutes*6e4:F.span??0;return new Q(F.kind,ne,H)}const _={Window:Q,WINDOW_KINDS:q,openWindow:te}}),Se("packages/core/src/compute/anomaly.js",function(o,fe){"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 _}}),Object.defineProperty(o,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return Y}}),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 ae=fe("packages/core/src/compute/statistics.js").quantileSorted,q=fe("packages/core/src/compute/special.js").logGamma,te=.6745,_=3.5,F=1.5,H=.975,ne=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function x(c){if(!c.length)return null;const a=Array.from(c,Number).sort((d,r)=>d-r),g=ae(a,.5),e=a.map(d=>Math.abs(d-g)).sort((d,r)=>d-r),m=ae(e,.5);return{median:g,mad:m}}function ce(c,t={}){const a=Number.isFinite(t.threshold)?t.threshold:_,g=c.length,e=new Array(g).fill(null),m=new Array(g).fill(!1),d=[];for(let l=0;l<g;l++){const b=Number(c[l]);Number.isFinite(b)&&d.push(b)}if(!d.length)return{median:null,mad:null,threshold:a,scores:e,flags:m,flagged:0};const r=x(d);if(r.mad===0)return{median:r.median,mad:0,threshold:a,scores:e,flags:m,flagged:0};let n=0;for(let l=0;l<g;l++){const b=Number(c[l]);if(!Number.isFinite(b))continue;const E=te*(b-r.median)/r.mad;e[l]=E,Math.abs(E)>a&&(m[l]=!0,n++)}return{median:r.median,mad:r.mad,threshold:a,scores:e,flags:m,flagged:n}}function ie(c,t={}){const a=Number.isFinite(t.k)?t.k:F,g=[];for(let n=0;n<c.length;n++){const l=Number(c[n]);Number.isFinite(l)&&g.push(l)}if(!g.length)return null;const e=g.sort((n,l)=>n-l),m=ae(e,.25),d=ae(e,.75),r=d-m;return{q1:m,q3:d,iqr:r,lower:m-a*r,upper:d+a*r,k:a}}function G(c,t){if(t<=0)return 0;const a=q(c);if(t<c+1){let l=c,b=1/c,E=b;for(let S=0;S<1e3&&(l+=1,E*=t/l,b+=E,!(Math.abs(E)<Math.abs(b)*1e-15));S++);return b*Math.exp(-t+c*Math.log(t)-a)}const g=1e-300;let e=t+1-c,m=1/g,d=1/e,r=d;for(let l=1;l<1e3;l++){const b=-l*(l-c);e+=2,d=b*d+e,Math.abs(d)<g&&(d=g),m=e+b/m,Math.abs(m)<g&&(m=g),d=1/d;const E=d*m;if(r*=E,Math.abs(E-1)<1e-15)break}return 1-Math.exp(-t+c*Math.log(t)-a)*r}function D(c,t){return c<=0?0:G(t/2,c/2)}function Y(c,t=H){if(!(t>0)||!(t<1))return NaN;let a=0,g=Math.max(1,c);for(;D(g,c)<t;)g*=2;for(let e=0;e<200;e++){const m=(a+g)/2;if(D(m,c)<t?a=m:g=m,g-a<1e-10)break}return(a+g)/2}function ee(c){const t=c.length,a=c.map((g,e)=>{const m=g.slice();for(let d=0;d<t;d++)m.push(e===d?1:0);return m});for(let g=0;g<t;g++){let e=g;for(let d=g+1;d<t;d++)Math.abs(a[d][g])>Math.abs(a[e][g])&&(e=d);if(Math.abs(a[e][g])<1e-12)return null;if(e!==g){const d=a[e];a[e]=a[g],a[g]=d}const m=a[g][g];for(let d=0;d<2*t;d++)a[g][d]/=m;for(let d=0;d<t;d++){if(d===g)continue;const r=a[d][g];if(r!==0)for(let n=0;n<2*t;n++)a[d][n]-=r*a[g][n]}}return a.map(g=>g.slice(t))}function z(c,t){const a=c.length,g=new Array(t).fill(0);for(const d of c)for(let r=0;r<t;r++)g[r]+=d[r];for(let d=0;d<t;d++)g[d]/=a;const e=Array.from({length:t},()=>new Array(t).fill(0));for(const d of c)for(let r=0;r<t;r++){const n=d[r]-g[r];for(let l=r;l<t;l++)e[r][l]+=n*(d[l]-g[l])}const m=a>1?a-1:1;for(let d=0;d<t;d++)for(let r=d;r<t;r++)e[d][r]/=m,e[r][d]=e[d][r];return{mean:g,cov:e}}function M(c,t={}){const a=Number.isFinite(t.p)?t.p:H,g=Number.isFinite(t.ridge)?t.ridge:1e-6,e=c.length;if(!e)return null;const m=c[0].length;if(!m)return null;const d=new Array(e).fill(null),r=new Array(e).fill(null),n=new Array(e).fill(!1),l=[],b=[];for(let R=0;R<e;R++){const h=c[R];let O=h.length===m;const w=new Array(m);for(let P=0;O&&P<m;P++){const v=Number(h[P]);Number.isFinite(v)?w[P]=v:O=!1}O&&(l.push(R),b.push(w))}const E=m,S=Y(E,a);if(b.length<=m)return{center:[],df:E,cutoff:S,singular:!0,used:b.length,distances:d,squared:r,flags:n,flagged:0};const{mean:V,cov:U}=z(b,m);let I=ee(U),X=!1;if(!I){X=!0;let R=0;for(let w=0;w<m;w++)R+=U[w][w];const h=R/m*g||g,O=U.map((w,P)=>w.map((v,K)=>P===K?v+h:v));if(I=ee(O),!I)return{center:V,df:E,cutoff:S,singular:!0,used:b.length,distances:d,squared:r,flags:n,flagged:0}}let C=0;for(let R=0;R<b.length;R++){const h=b[R],O=new Array(m);for(let v=0;v<m;v++)O[v]=h[v]-V[v];let w=0;for(let v=0;v<m;v++){let K=0;for(let Z=0;Z<m;Z++)K+=I[v][Z]*O[Z];w+=O[v]*K}w<0&&(w=0);const P=l[R];r[P]=w,d[P]=Math.sqrt(w),w>S&&(n[P]=!0,C++)}return{center:V,df:E,cutoff:S,singular:X,used:b.length,distances:d,squared:r,flags:n,flagged:C}}const i=20,s=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function u(c,t={}){const a=t.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",g=Number.isFinite(t.windowLen)&&t.windowLen>=1?Math.floor(t.windowLen):i,e=Number.isFinite(t.threshold)?t.threshold:_,m=Number.isFinite(t.k)?t.k:F,d=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):g,r=c.length,n=new Array(r).fill(null),l=new Array(r).fill(!1);let b=0;for(let E=0;E<r;E++){const S=Number(c[E]);if(!Number.isFinite(S))continue;const V=Math.max(0,E-g+1),U=[];for(let I=V;I<=E;I++){const X=Number(c[I]);Number.isFinite(X)&&U.push(X)}if(!(U.length<d))if(a==="rollingIqr"){const I=ie(U,{k:m});if(!I)continue;(S<I.lower||S>I.upper)&&(l[E]=!0,b++)}else{const I=x(U);if(!I||I.mad===0)continue;const X=te*(S-I.median)/I.mad;n[E]=X,Math.abs(X)>e&&(l[E]=!0,b++)}}return{method:a,windowLen:g,minPeriods:d,threshold:e,k:m,scores:n,flags:l,flagged:b}}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 g=t.method||"modifiedZScore";if(!(ne.includes(g)||s.includes(g))||g==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method \'${g}\'`);const m=typeof t.orderBy=="string"?t.orderBy:null,d=t.latest===!0,r=s.includes(g),n=l=>Number(l==null?NaN:l[a]);return l=>{const b=Array.isArray(l)?l.slice():[...l];m&&b.sort((I,X)=>{const C=I?.[m],R=X?.[m];return C===R?0:C==null?-1:R==null?1:C<R?-1:1});const E=b.map(n);let S,V;if(r)({flags:S,scores:V}=u(E,{method:g,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(g==="iqr"){const I=ie(E,{k:t.k});S=E.map(X=>I?Number.isFinite(X)&&(X<I.lower||X>I.upper):!1),V=E.map(()=>null)}else({flags:S,scores:V}=ce(E,{threshold:t.threshold}));if(d){const I=S.length-1;return I<0||!S[I]?!1:{method:g,field:a,flagged:[{row:b[I],score:V[I]}]}}const U=[];for(let I=0;I<S.length;I++)S[I]&&U.push({row:b[I],score:V[I]});return U.length?{method:g,field:a,flagged:U}:!1}}}),Se("packages/core/src/compute/forecast.js",function(o,fe){"use strict";Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return c}});const le=fe("packages/core/src/compute/special.js"),ae=le.normalQuantile,Q=le.studentTQuantile,te=fe("packages/core/src/internal/util.js").warnOnce,_=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),F=1e-4,H=1-1e-4;function ne(t){const a=[];for(let g=0;g<t.length;g++){const e=t[g];if(e!==null&&typeof e=="object"){const m=Number.isFinite(e.at)?e.at:g,d=Number.isFinite(e.value)?e.value:null;a.push({at:m,value:d})}else a.push({at:g,value:Number.isFinite(e)?Number(e):null})}return a}function x(t){const a=t.filter(r=>r.value!==null),g=a[0],e=a[a.length-1],m=e.at-g.at,d=a.length>1&&m>0?m/(a.length-1):1;return{lastAt:e.at,step:d}}function ce(t){return Math.min(H,Math.max(F,t))}function ie(t,a=F,g=H,e=80){const m=(Math.sqrt(5)-1)/2;let d=a,r=g,n=r-m*(r-d),l=d+m*(r-d),b=t(n),E=t(l);for(let S=0;S<e;S++)b<E?(r=l,l=n,E=b,n=r-m*(r-d),b=t(n)):(d=n,n=l,b=E,l=d+m*(r-d),E=t(l));return(d+r)/2}function G(t,a){let g=null,e=0,m=0;for(let d=0;d<t.length;d++){const r=t[d];if(r!==null){if(g===null){g=r;continue}e+=(r-g)**2,m+=1,g=a*r+(1-a)*g}}return{level:g,sse:e,m}}function D(t,a,g){let e=null,m=null,d=0,r=0;for(let n=0;n<t.length;n++){const l=t[n];if(l===null){e!==null&&m!==null&&(e+=m);continue}if(e===null){e=l;continue}m===null&&(m=l-e);const b=e+m;d+=(l-b)**2,r+=1;const E=e;e=a*l+(1-a)*(E+m),m=g*(e-E)+(1-g)*m}return{level:e,trend:m,sse:d,m:r}}function Y(t,a,g,e,m){const d=t.length;if(d<2*a)return null;const r=X=>{let C=0,R=0;for(let h=X;h<X+a&&h<d;h++)t[h]!==null&&(C+=t[h],R+=1);return R?C/R:null},n=r(0),l=r(a);if(n===null||l===null)return null;let b=n,E=(l-n)/a;const S=new Array(a).fill(0);for(let X=0;X<a;X++)S[X]=t[X]===null?0:t[X]-b;const V=S.reduce((X,C)=>X+C,0)/a;for(let X=0;X<a;X++)S[X]-=V;let U=0,I=0;for(let X=a;X<d;X++){const C=X%a,R=S[C],h=t[X];if(h===null){b+=E;continue}const O=b+E+R;U+=(h-O)**2,I+=1;const w=b;b=g*(h-R)+(1-g)*(b+E),E=e*(b-w)+(1-e)*E,S[C]=m*(h-b)+(1-m)*R}return{level:b,trend:E,season:S,phase:(d-1)%a,sse:U,count:I}}function ee(t,a,g){let e=1;for(const d of a)e+=d*d;const m=Math.sqrt(t*e);return{se:m,margin:g*m}}function z(t,a={}){if(!t||typeof t.length!="number"||t.length===0)return null;const g=_.includes(a.method)?a.method:"linear",e=Math.max(1,Math.floor(Number(a.horizon)||1)),m=Number.isFinite(a.confidence)&&a.confidence>0&&a.confidence<1?a.confidence:.95,d=1-(1-m)/2,r=ne(t),n=r.map(U=>U.value),l=n.filter(U=>U!==null),b=l.length,{lastAt:E,step:S}=b?x(r):{lastAt:0,step:1},V=U=>E+U*S;return g==="linear"?M(r,b,e,m,d,V):g==="movingAverage"?i(l,b,e,m,d,a,V):g==="ses"?s(n,b,e,m,d,a,V):g==="holt"?u(n,b,e,m,d,a,V):f(n,b,e,m,d,a,V)}function M(t,a,g,e,m,d){if(a<2)return null;let r=0,n=0;for(const h of t)h.value!==null&&(r+=h.at,n+=h.value);r/=a,n/=a;let l=0,b=0,E=0;for(const h of t){if(h.value===null)continue;const O=h.at-r,w=h.value-n;l+=O*O,b+=O*w,E+=w*w}if(l===0)return null;const S=b/l,V=n-S*r,U=E===0?1:Math.max(0,Math.min(1,b*b/(l*E))),I=Math.max(0,E-S*b),X=a>2?Math.sqrt(I/(a-2)):null,C=a>2?Q(m,a-2):null,R=[];for(let h=1;h<=g;h++){const O=d(h),w=V+S*O;let P=null,v=null,K=null,Z=null,oe=null;if(X!==null){const se=1/a+(O-r)**2/l,T=X*Math.sqrt(1+se),L=X*Math.sqrt(se);oe=T,P=w-C*T,v=w+C*T,K=w-C*L,Z=w+C*L}R.push({step:h,at:O,mean:w,lower:P,upper:v,lowerMean:K,upperMean:Z,se:oe})}return{method:"linear",horizon:g,confidence:e,n:a,sigma:X,r2:U,params:{slope:S,intercept:V},points:R}}function i(t,a,g,e,m,d,r){if(a<1)return null;const n=Math.max(1,Math.min(a,Math.floor(Number(d.windowLen)||a))),l=t.slice(a-n);let b=0;for(const X of l)b+=X;const E=b/n;let S=null,V=null;if(n>1){let X=0;for(const R of l)X+=(R-E)**2;S=Math.sqrt(X/(n-1))*Math.sqrt(1+1/n),V=Q(m,n-1)}const U=S===null?null:V*S,I=[];for(let X=1;X<=g;X++)I.push({step:X,at:r(X),mean:E,lower:U===null?null:E-U,upper:U===null?null:E+U,se:S});return{method:"movingAverage",horizon:g,confidence:e,n:a,sigma:S===null?null:S,params:{windowLen:n},points:I}}function s(t,a,g,e,m,d,r){if(a<1)return null;let n=Number.isFinite(d.alpha)?ce(d.alpha):null;n===null&&(n=ie(V=>G(t,V).sse));const l=G(t,n),b=ae(m),E=l.m>0?l.sse/l.m:null,S=[];for(let V=1;V<=g;V++){const U=l.level;let I=null,X=null,C=null;if(E!==null){const R=[];for(let O=1;O<V;O++)R.push(n);const h=ee(E,R,b);C=h.se,I=U-h.margin,X=U+h.margin}S.push({step:V,at:r(V),mean:U,lower:I,upper:X,se:C})}return{method:"ses",horizon:g,confidence:e,n:a,sigma:E===null?null:Math.sqrt(E),params:{alpha:n},points:S}}function u(t,a,g,e,m,d,r){if(a<2)return null;let n=Number.isFinite(d.alpha)?ce(d.alpha):null,l=Number.isFinite(d.beta)?ce(d.beta):null;if(n===null||l===null){let I=n===null?.5:n,X=l===null?.5:l;for(let C=0;C<6;C++)n===null&&(I=ie(R=>D(t,R,X).sse)),l===null&&(X=ie(R=>D(t,I,R).sse));n=n===null?I:n,l=l===null?X:l}const b=D(t,n,l),E=ae(m),S=b.m>0?b.sse/b.m:null,V=n*l,U=[];for(let I=1;I<=g;I++){const X=b.level+I*b.trend;let C=null,R=null,h=null;if(S!==null){const O=[];for(let P=1;P<I;P++)O.push(n+P*V);const w=ee(S,O,E);h=w.se,C=X-w.margin,R=X+w.margin}U.push({step:I,at:r(I),mean:X,lower:C,upper:R,se:h})}return{method:"holt",horizon:g,confidence:e,n:a,sigma:S===null?null:Math.sqrt(S),params:{alpha:n,beta:l},points:U}}function f(t,a,g,e,m,d,r){const n=Math.floor(Number(d.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(d.alpha)?ce(d.alpha):null,b=Number.isFinite(d.beta)?ce(d.beta):null,E=Number.isFinite(d.gamma)?ce(d.gamma):null;const S=(h,O,w)=>{const P=Y(t,n,h,O,w);return P?P.sse:1/0};if(l===null||b===null||E===null){let h=l===null?.5:l,O=b===null?.5:b,w=E===null?.5:E;for(let P=0;P<8;P++)l===null&&(h=ie(v=>S(v,O,w))),b===null&&(O=ie(v=>S(h,v,w))),E===null&&(w=ie(v=>S(h,O,v)));l=l===null?h:l,b=b===null?O:b,E=E===null?w:E}const V=Y(t,n,l,b,E);if(!V)return null;const U=ae(m),I=V.count>0?V.sse/V.count:null,X=l*b,C=E*(1-l),R=[];for(let h=1;h<=g;h++){const O=V.season[(V.phase+h)%n],w=V.level+h*V.trend+O;let P=null,v=null,K=null;if(I!==null){const Z=[];for(let se=1;se<h;se++)Z.push(l+se*X+(se%n===0?C:0));const oe=ee(I,Z,U);K=oe.se,P=w-oe.margin,v=w+oe.margin}R.push({step:h,at:r(h),mean:w,lower:P,upper:v,se:K})}return{method:"holtWinters",horizon:g,confidence:e,n:a,sigma:I===null?null:Math.sqrt(I),params:{alpha:l,beta:b,gamma:E,period:n},points:R}}const c={FORECAST_METHODS:_,forecast:z}}),Se("packages/core/src/compute/index.js",function(o,fe){"use strict";const le=fe("packages/core/src/compute/sort.js");Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return le.sortColumn}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return le.sortMulti}}),Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return le.radixSortFloat64}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return le.radixSortInt32}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return le.rankSortDictionary}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return le.mergeSortComparator}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return le.collateStringRanks}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return le.rankSortStrings}});const ae=fe("packages/core/src/compute/sortspec.js");Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return ae.collationDescriptor}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return ae.isPortableSort}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return ae.isPortableSortSet}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return ae.describeSortEntry}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return ae.describeSort}});const Q=fe("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return Q.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return Q.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return Q.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return Q.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return Q.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return Q.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return Q.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return Q.mentionsColumn}});const q=fe("packages/core/src/compute/group.js");Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return q.groupByColumns}}),Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return q.packKeys}});const te=fe("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 _=fe("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return _.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return _.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return _.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return _.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return _.collectValues}});const F=fe("packages/core/src/compute/pivot.js");Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return F.pivot}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return F.resolvePivotKeys}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return F.pivotKey}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return F.joinPath}}),Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return F.KEY_DELIMITER}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return F.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return F.DEFAULT_MAX_COLUMNS}});const H=fe("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return H.pivotMatrix}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return H.resolveAxis}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return H.cellKey}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return H.marginKey}}),Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return H.GRAND_PATH}});const ne=fe("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return ne.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return ne.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return ne.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ne.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return ne.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return ne.referenceValue}});const x=fe("packages/core/src/compute/handle.js");Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return x.identity}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return x.rowCount}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return x.presenceReader}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return x.bitReader}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return x.valueReader}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return x.valueComparator}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return x.numericTotalOrder}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return x.dictRanks}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return x.dictSize}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return x.dictValue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return x.multiValue}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return x.isMissing}});const ce=fe("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return ce.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return ce.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return ce.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return ce.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return ce.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return ce.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return ce.SKETCH_BOUNDS}});const ie=fe("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return ie.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return ie.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return ie.openWindow}});const G=fe("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return G.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return G.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return G.maintenanceOf}});const D=fe("packages/core/src/compute/anomaly.js");Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return D.ANOMALY_METHODS}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return D.modifiedZScores}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return D.iqrFences}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return D.mahalanobis}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return D.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return D.rollingAnomalies}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return D.anomalyCondition}});const Y=fe("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Y.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return Y.forecast}})}),Se("packages/worker/src/kernel.js",function(o,fe){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"setCompute",{enumerable:!0,get:function(){return z}}),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 le=fe("packages/worker/src/transport.js"),ae=le.PROTOCOL,Q=le.OPS,q=le.CONTROL,te=le.ERRORS,_=le.unpackHandle,F=le.unpackHandles,H=le.createMaskPool,ne=le.collectTransfers,x=fe("packages/core/src/store/columnpack.js"),ce=x.packChunk,ie=x.packedTransfers;let G=null,D=null,Y=null;async function ee(f){if(G)return G;if(!D){const c=f||(()=>Promise.resolve(fe("packages/core/src/compute/index.js")));D=Promise.resolve().then(c).then(t=>(G=t,t)).catch(t=>(Y=t,G=null,null))}return D}function z(f){G=f,D=f?Promise.resolve(f):null,Y=f?null:Y}function M(f,c,t){const a=new Map;for(const g of f)g&&a.set(g.id,g);return{handle(g){return a.get(g)},count:c,pool:H(),locale:t}}function i(f,c){const{op:t,args:a}=f;if(t===Q.COLUMNIZE)return ce(a.schema||[],a.rows||[],a.opts||{});const g=c[t];if(typeof g!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=te.NO_KERNEL,e}switch(t){case Q.COLLATE_STRING_RANKS:return g(a.table||[],(a.table||[]).length,a.locale);case Q.SORT_COLUMN:return g(_(a.handle),a.order??null,a.opts||{});case Q.SORT_MULTI:{const e=F(a.handles||[]),m=(a.entries||[]).map(d=>({...d,handle:e[d.index]}));return g(e,m,a.order??null)}case Q.EVALUATE_FILTERS:return g(a.filters,M(F(a.handles||[]),a.count,a.locale));case Q.COMPACT:return g(a.mask,a.count,void 0);case Q.GROUP_BY_COLUMNS:return g(F(a.handles||[]),a.order??null,a.opts||{});case Q.TOTAL:return g(_(a.handle),a.indices??null,a.fn);case Q.PIVOT:return g(F(a.handles||[]),a.order??null,a.opts||{});case Q.FACET:return g(_(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!==ae)return null;const{id:t,op:a}=f;if(a===q.CANCEL)return c.cancelled?.add(f.target),null;if(a===q.PING)return{reply:{lattice:ae,id:t,ok:!0,result:"pong"},transfer:[]};if(a===Q.COLUMNIZE){if(c.cancelled?.has(t))return c.cancelled.delete(t),null;try{const e=ce(f.args.schema||[],f.args.rows||[],f.args.opts||{});return c.cancelled?.has(t)?(c.cancelled.delete(t),{reply:{lattice:ae,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:ae,id:t,ok:!0,result:e},transfer:ie(e)}}catch(e){const m=e;return{reply:{lattice:ae,id:t,ok:!1,error:{code:m.code||te.KERNEL,message:m.message||String(e),stack:m.stack}},transfer:[]}}}const g=await ee(c.loader);if(!g)return{reply:{lattice:ae,id:t,ok:!1,error:{code:te.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${Y?Y.message:"module not found"}`}},transfer:[]};if(c.cancelled?.has(t))return c.cancelled.delete(t),{reply:{lattice:ae,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(f,g);return c.cancelled?.has(t)?(c.cancelled.delete(t),{reply:{lattice:ae,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:ae,id:t,ok:!0,result:e},transfer:ne(e)}}catch(e){const m=e;return{reply:{lattice:ae,id:t,ok:!1,error:{code:m.code||te.KERNEL,message:m.message||String(e),stack:m.stack}},transfer:[]}}}function u(f,c={}){const t=new Set,a=async g=>{const e=await s(g.data,{loader:c.loader,cancelled:t});e&&f.postMessage(e.reply,e.transfer)};return f.addEventListener("message",a),ee(c.loader).then(g=>{f.postMessage({lattice:ae,id:0,op:q.READY,compute:!!g})}),()=>f.removeEventListener("message",a)}});var bt=nt("packages/worker/src/kernel.js");gt.__latticeKernel=bt})(typeof globalThis<"u"?globalThis:this);\n\n__latticeKernel.installKernel(self);\n',{type:"classic"})}catch{}const De=Bn("packages/dom/src/index.js"),Vi=De.createGrid,Gi=De.gridElementsWithin,Ki=De.createStat,Wi=De.deltaOf,qi=De.toneOf,_i=De.readTable,Zi=De.hydrateTable,Yi=De.autoInit,Xi=De.createLocalViewStorage,Qi=De.DEFAULT_VIEWS_KEY,Ji=De.createHeadlessGrid,eo=De.defaults,to=De.version,no=De.getVersion,ro=De.Grid,io=De.EventBus,oo=De.Registry,so=De.sharedRegistry,ao=De.registerModules,lo=De.parseLicence,uo=De.verifyLicence,co=De.licenceInfo,fo=De.watermark,ho=De.setLicence,mo=De.licenceState,po=De.isLocalHost,go=De.matchesDomain,yo=De.LicenceHolder,bo=De.ColumnModel,wo=De.buildGraph,vo=De.Lookup,ko=De.ValuePipeline,So=De.compileFormat,Oo=De.compileMask,jo=De.specToOoxml,Ao=De.EXTENDED_TYPES,Po=De.createRadixType,Co=De.RADIX_PRESETS,Eo=De.parseRadix,To=De.formatRadix,Mo=De.createUnitType,No=De.registerUnitSystem,Ro=De.defineUnit,Lo=De.UNIT_SYSTEMS,Fo=De.parseUnit,xo=De.formatUnit,Do=De.createCurrencyType,Io=De.parseMoney,zo=De.formatMoney,$o=De.convertMoney,Bo=De.rateFunction,Uo=De.MISSING_RATE,Ho=De.Messages,Vo=De.createMessages,Go=De.auditCatalogue,Ko=De.EN_GB,Wo=De.MESSAGE_KEYS,qo=De.DEFAULT_LOCALE,_o=De.formatList,Zo=De.resolveLocale,Yo=De.LOCALES,Xo=De.resolveCatalogue,Qo=De.EN_US,Jo=De.FR_FR,es=De.FR_CA,ts=De.IT_IT,ns=De.ES_ES,rs=De.PT_BR,is=De.DE_DE,os=De.NL_NL,ss=De.SV_SE,as=De.DA_DK,ls=De.NB_NO,us=De.FI_FI,cs=De.PL_PL,ds=De.CS_CZ,fs=De.HU_HU,hs=De.RO_RO,ms=De.UK_UA,ps=De.EL_GR,gs=De.JA_JP,ys=De.AR,bs=De.AR_SA,ws=De.ColumnStore,vs=De.Bitset,ks=De.Dictionary,Ss=De.MultiValue,Os=De.MaskPool,js=De.sortColumn,As=De.sortMulti,Ps=De.evaluateFilters,Cs=De.compact,Es=De.testValue,Ts=De.groupByColumns,Ms=De.total,Ns=De.TOTAL_FNS,Rs=De.pivot,Ls=De.Window,Fs=De.openWindow,xs=De.WINDOW_KINDS,Ds=De.ANOMALY_METHODS,Is=De.modifiedZScores,zs=De.iqrFences,$s=De.mahalanobis,Bs=De.ROLLING_ANOMALY_METHODS,Us=De.rollingAnomalies,Hs=De.anomalyCondition,Vs=De.FORECAST_METHODS,Gs=De.forecast,Ks=De.evaluateFormula,Ws=De.parseFormula,qs=De.referencesOf,_s=De.looksLikeFormula,Zs=De.FormulaError,Ys=De.FUNCTIONS,Xs=De.compileRules,Qs=De.ingest,Js=De.ingestSync,ea=De.createSource,ta=De.createMemorySource,na=De.createPagedSource,ra=De.createRemoteSource,ia=De.createStreamSource,oa=De.createUrlSource,sa=De.PROTOCOL,aa=De.createPushdownSource,la=De.planQuery,ua=De.splitFilters,ca=De.applyResidual,da=De.capabilitiesOf,fa=De.resolveMutate,ha=De.NO_CAPABILITIES,ma=De.odataAdapter,pa=De.filtersToOData,ga=De.conditionToOData,ya=De.restAdapter,ba=De.DEFAULT_PARAMS,wa=De.dfqlAdapter,va=De.duckdbAdapter,ka=De.filtersToSql,Sa=De.graphqlAdapter,Oa=De.RowModel,ja=De.createRowKey,Aa=De.SelectionModel,Pa=De.RangeModel,Ca=De.EditModel,Ea=De.ChangeModel,Ta=De.StateModel,Ma=De.STATE_VERSION,Na=De.serialiseState,Ra=De.restoreState,La=De.VERSION,Fa=De.DomRenderer,xa=De.FilterMenu,Da=De.mergeColumnFilter,Ia=De.branchFor,za=De.ColumnMenu,$a=De.columnMenuItems,Ba=De.cellMenuItems,Ua=De.autoGroupMenuItems,Ha=De.AlignedGrids,Va=De.alignGrids,Ga=De.layoutState,Ka=De.ToolPanelDock,Wa=De.panelHost,qa=De.mountPanel,_a=De.CellEditController,Za=De.EditBar,Ya=De.HistoryBar,Xa=De.HISTORY_CLS,Qa=De.DiffPainter,Ja=De.ViewPicker,el=De.VIEW_CLS,tl=De.summariseDiff,nl=De.PromptBar,rl=De.PROMPT_CLASS,il=De.createCellLayer,ol=De.compileTemplate,sl=De.compileVariant,al=De.checkVariant,ll=De.VariantRegistry,ul=De.BUILTIN_RENDERERS,cl=De.BUILTIN_VARIANTS,dl=De.BUILTIN_PIPES,fl=De.sanitiseHtml,hl=De.editors,ml=De.createEditor,pl=De.editorFor,gl=De.BaseEditor,yl=De.filters,bl=De.createFilter,wl=De.filterFor,vl=De.parseExpression,kl=De.StatusBar,Sl=De.ContextMenu,Ol=De.ToolPanel,jl=De.TooltipManager,Al=De.Pagination,Pl=De.OverlayLayer,Cl=De.LatticeGrid,El=De.setLicense,Tl=De.licenseInfo,Ml=De.licenseState;var Nl=De.default;export{Ds as ANOMALY_METHODS,ys as AR,bs as AR_SA,Ha as AlignedGrids,dl as BUILTIN_PIPES,ul as BUILTIN_RENDERERS,cl as BUILTIN_VARIANTS,gl as BaseEditor,vs as Bitset,ds as CS_CZ,_a as CellEditController,Ea as ChangeModel,za as ColumnMenu,bo as ColumnModel,ws as ColumnStore,Sl as ContextMenu,as as DA_DK,qo as DEFAULT_LOCALE,ba as DEFAULT_PARAMS,Qi as DEFAULT_VIEWS_KEY,is as DE_DE,ks as Dictionary,Qa as DiffPainter,Fa as DomRenderer,ps as EL_GR,Ko as EN_GB,Qo as EN_US,ns as ES_ES,Ao as EXTENDED_TYPES,Za as EditBar,Ca as EditModel,io as EventBus,us as FI_FI,Vs as FORECAST_METHODS,es as FR_CA,Jo as FR_FR,Ys as FUNCTIONS,xa as FilterMenu,Zs as FormulaError,ro as Grid,Xa as HISTORY_CLS,fs as HU_HU,Ya as HistoryBar,ts as IT_IT,gs as JA_JP,Yo as LOCALES,Cl as LatticeGrid,yo as LicenceHolder,vo as Lookup,Wo as MESSAGE_KEYS,Uo as MISSING_RATE,Os as MaskPool,Ho as Messages,Ss as MultiValue,ls as NB_NO,os as NL_NL,ha as NO_CAPABILITIES,Pl as OverlayLayer,cs as PL_PL,rl as PROMPT_CLASS,sa as PROTOCOL,rs as PT_BR,Al as Pagination,nl as PromptBar,Co as RADIX_PRESETS,Bs as ROLLING_ANOMALY_METHODS,hs as RO_RO,Pa as RangeModel,oo as Registry,Oa as RowModel,Ma as STATE_VERSION,ss as SV_SE,Aa as SelectionModel,Ta as StateModel,kl as StatusBar,Ns as TOTAL_FNS,Ol as ToolPanel,Ka as ToolPanelDock,jl as TooltipManager,ms as UK_UA,Lo as UNIT_SYSTEMS,La as VERSION,el as VIEW_CLS,ko as ValuePipeline,ll as VariantRegistry,Ja as ViewPicker,xs as WINDOW_KINDS,Ls as Window,Va as alignGrids,Hs as anomalyCondition,ca as applyResidual,Go as auditCatalogue,Ua as autoGroupMenuItems,Yi as autoInit,Ia as branchFor,wo as buildGraph,da as capabilitiesOf,Ba as cellMenuItems,al as checkVariant,$a as columnMenuItems,Cs as compact,So as compileFormat,Oo as compileMask,Xs as compileRules,ol as compileTemplate,sl as compileVariant,ga as conditionToOData,$o as convertMoney,il as createCellLayer,Do as createCurrencyType,ml as createEditor,bl as createFilter,Vi as createGrid,Ji as createHeadlessGrid,Xi as createLocalViewStorage,ta as createMemorySource,Vo as createMessages,na as createPagedSource,aa as createPushdownSource,Po as createRadixType,ra as createRemoteSource,ja as createRowKey,ea as createSource,Ki as createStat,ia as createStreamSource,Mo as createUnitType,oa as createUrlSource,Nl as default,eo as defaults,Ro as defineUnit,Wi as deltaOf,wa as dfqlAdapter,va as duckdbAdapter,pl as editorFor,hl as editors,Ps as evaluateFilters,Ks as evaluateFormula,wl as filterFor,yl as filters,pa as filtersToOData,ka as filtersToSql,Gs as forecast,_o as formatList,zo as formatMoney,To as formatRadix,xo as formatUnit,no as getVersion,Sa as graphqlAdapter,Gi as gridElementsWithin,Ts as groupByColumns,Zi as hydrateTable,Qs as ingest,Js as ingestSync,zs as iqrFences,po as isLocalHost,Ga as layoutState,co as licenceInfo,mo as licenceState,Tl as licenseInfo,Ml as licenseState,_s as looksLikeFormula,$s as mahalanobis,go as matchesDomain,Da as mergeColumnFilter,Is as modifiedZScores,qa as mountPanel,ma as odataAdapter,Fs as openWindow,Wa as panelHost,vl as parseExpression,Ws as parseFormula,lo as parseLicence,Io as parseMoney,Eo as parseRadix,Fo as parseUnit,Rs as pivot,la as planQuery,Bo as rateFunction,_i as readTable,qs as referencesOf,ao as registerModules,No as registerUnitSystem,Xo as resolveCatalogue,Zo as resolveLocale,fa as resolveMutate,ya as restAdapter,Ra as restoreState,Us as rollingAnomalies,fl as sanitiseHtml,Na as serialiseState,ho as setLicence,El as setLicense,so as sharedRegistry,js as sortColumn,As as sortMulti,jo as specToOoxml,ua as splitFilters,tl as summariseDiff,Es as testValue,qi as toneOf,Ms as total,uo as verifyLicence,to as version,fo as watermark};
54
+ `)||(f.preventDefault(),this.fromText(h))})))}openFile(){const u=O(this.#n,"input",{attrs:{type:"file",accept:i}});u.style.display="none",this.#o.push(d(u,"change",()=>{const f=u.files&&u.files[0];f&&this.#c(f),u.parentNode&&u.parentNode.removeChild(u)})),this.#n.body.appendChild(u),u.click()}#c(u){if(R(u.arrayBuffer)){u.arrayBuffer().then(h=>{const g=new Uint8Array(h);if(F(g)){this.fromXlsx(g,u.name);return}this.fromText(new TextDecoder().decode(g),u.name)});return}if(R(u.text)){u.text().then(h=>this.fromText(h,u.name));return}const f=new this.#n.defaultView.FileReader;f.onload=()=>this.fromText(String(f.result||""),u.name),f.readAsText(u)}async fromXlsx(u,f){const{header:h,rows:g}=await z(u);if(!h.length)return;const b=H(h,g,{columns:this.#e.columns.all()}),p=g.filter(m=>m.length!==h.length).length;this.#s={rows:g,columns:b,delimiter:null,name:f,warnings:p?[`${p} row(s) do not have ${h.length} columns`]:[]},this.#d()}fromText(u,f){const{header:h,rows:g,delimiter:b}=Z(u);if(!h.length)return;const p=H(h,g,{columns:this.#e.columns.all()}),m=g.filter(w=>w.length!==h.length).length;this.#s={rows:g,columns:p,delimiter:b,name:f,warnings:m?[`${m} row(s) do not have ${h.length} columns`]:[]},this.#d()}#d(){this.#i||this.#m(),this.#p(),this.#l=this.#n.activeElement,this.#i.hidden=!1;const u=this.#i.querySelector(n);u&&R(u.focus)&&u.focus(),this.#h(this.#f("import.opened",{count:this.#s.rows.length}),{repeat:!0})}#h(u,f){const h=this.#t&&this.#t.announce;R(h)&&h.call(this.#t,u,f)}#f(u,f){return(this.#e&&this.#e.messages?this.#e.messages:L).t(u,f)}#m(){const u=this.#n,f=O(u,"div",{class:t,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#f("import.title"),hidden:!0}}),h=O(u,"div",{class:`${t}__panel`});h.appendChild(O(u,"h2",{class:`${t}__title`,text:this.#f("import.title")})),this.#a=O(u,"div",{class:`${t}__body`}),h.appendChild(this.#a);const g=O(u,"div",{class:`${t}__footer`}),b=O(u,"button",{class:`${t}__cancel`,text:this.#f("import.cancel"),attrs:{type:"button"}}),p=O(u,"button",{class:`${t}__confirm`,text:this.#f("import.confirm"),attrs:{type:"button"}});this.#o.push(d(b,"click",()=>this.close())),this.#o.push(d(p,"click",()=>this.#g())),g.appendChild(b),g.appendChild(p),h.appendChild(g),f.appendChild(h),this.#o.push(d(f,"keydown",w=>{if(w.key==="Escape"){w.preventDefault(),this.close();return}if(w.key!=="Tab")return;const v=[...f.querySelectorAll(n)].filter(S=>!S.hidden);if(!v.length)return;const a=v[0],o=v[v.length-1];w.shiftKey&&this.#n.activeElement===a?(w.preventDefault(),o.focus()):!w.shiftKey&&this.#n.activeElement===o&&(w.preventDefault(),a.focus())})),(this.#t.viewport&&this.#t.viewport.overlays||this.#n.body).appendChild(f),this.#i=f}#p(){const u=this.#n,f=y(this.#a),{rows:h,columns:g,name:b,warnings:p}=this.#s;f.appendChild(O(u,"p",{class:`${t}__summary`,text:this.#f("import.summary",{count:h.length,name:b||this.#f("import.clipboard")})}));for(const S of p)f.appendChild(O(u,"p",{class:`${t}__warning`,text:S}));const m=this.#e.columns.all().map(S=>S.field||S.id).filter(Boolean),w=O(u,"table",{class:`${t}__map`}),v=O(u,"tr",{});for(const S of["import.colSource","import.colField","import.colType"])v.appendChild(O(u,"th",{text:this.#f(S)}));w.appendChild(v),g.forEach((S,E)=>{const A=O(u,"tr",{});A.appendChild(O(u,"td",{text:S.source}));const M=O(u,"select",{attrs:{"data-col":String(E),"aria-label":this.#f("import.mapLabel",{source:S.source})}});M.appendChild(O(u,"option",{text:this.#f("import.skip"),attrs:{value:""}}));for(const P of m)M.appendChild(O(u,"option",{text:P,attrs:{value:P,selected:P===S.field?!0:null}}));S.field&&!m.includes(S.field)&&M.appendChild(O(u,"option",{text:S.field,attrs:{value:S.field,selected:!0}}));const C=O(u,"td",{});C.appendChild(M),A.appendChild(C),A.appendChild(O(u,"td",{class:`${t}__type`,text:S.type})),w.appendChild(A)}),f.appendChild(w);const a=O(u,"div",{class:`${t}__mode`}),o=O(u,"select",{attrs:{"aria-label":this.#f("import.modeLabel"),"data-mode":"mode"}});o.appendChild(O(u,"option",{text:this.#f("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),o.appendChild(O(u,"option",{text:this.#f("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),a.appendChild(O(u,"label",{text:this.#f("import.modeLabel")})),a.appendChild(o),f.appendChild(a)}#g(){const{rows:u,columns:f}=this.#s;for(const m of this.#i.querySelectorAll("select[data-col]")){const w=Number(m.getAttribute("data-col"));f[w]&&m.value!==void 0&&m.value!==null&&(f[w].field=m.value)}const h=this.#i.querySelector("select[data-mode]"),g=h?h.value:void 0,b=g==="replace"||g==="append"?g:this.#r.mode,p=U(u,f);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.#s=null,this.#l&&R(this.#l.focus)&&this.#l.focus(),this.#l=null}destroy(){for(const u of this.#o)u();this.#o=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#a=null,this.#s=null}}}),ke("packages/dom/src/historybar.js",function(e,V){"use strict";Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return O}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/dom/src/editors/common.js"),Z=W.el,H=W.on,U=W.clear,z=W.documentFor,F="lat-history";class k{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(d,c){return(this.messages&&typeof this.messages.t=="function"?this.messages:L).t(d,c)}init(d){this.messages=d&&d.messages||d&&d.grid&&d.grid.messages||L;const c=d||{};if(this.doc=z(c),this.host=c.host||{},this.props=c.props||{},this.root=Z(this.doc,"div",{class:["lattice-tokens",F],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 r=Z(this.doc,"button",{class:`${F}__toggle`,text:"▾",attrs:{type:"button","aria-haspopup":"menu","aria-expanded":"false","aria-label":this.t("history.show")}});this.off.push(H(r,"click",()=>this.toggle())),this.root.appendChild(r),this.toggleButton=r,this.menu=Z(this.doc,"div",{class:`${F}__menu`,attrs:{role:"menu"}}),this.menu.style.display="none",this.root.appendChild(this.menu)}this.refresh()}#e(d,c,r){const t=Z(this.doc,"button",{class:`${F}__${d}`,attrs:{type:"button"},children:[Z(this.doc,"span",{class:`${F}__glyph`,text:r,attrs:{"aria-hidden":"true"}}),Z(this.doc,"span",{class:`${F}__label`,text:c})]});return this.off.push(H(t,"click",()=>{const n=this.host[d];R(n)&&n(),this.refresh()})),t}element(){return this.root}refresh(){if(!this.root)return;const d=this.host,c=R(d.canUndo)?d.canUndo():!1,r=R(d.canRedo)?d.canRedo():!1,t=R(d.peek)?d.peek("undo"):null,n=R(d.peek)?d.peek("redo"):null;this.#t(this.undoButton,"undo",c,t),this.#t(this.redoButton,"redo",r,n),this.open&&this.#n()}#t(d,c,r,t){if(!d)return;d.disabled=!r;const n=c==="undo",i=this.t(n?"history.undo":"history.redo"),s=d.querySelector(`.${F}__label`);s&&(s.textContent=i);const l=t&&t.label?this.t("history.described",{action:i,label:t.label}):i;d.setAttribute("title",r?l:this.t(n?"history.nothingToUndo":"history.nothingToRedo")),d.setAttribute("aria-label",r?l:this.t(n?"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 d=this.menu;if(!d)return;U(d);const c=R(this.host.list)?this.host.list():[];if(!c.length){d.appendChild(Z(this.doc,"p",{class:`${F}__empty`,text:this.t("history.empty")}));return}c.forEach((r,t)=>{const n=Z(this.doc,"button",{class:`${F}__item`,attrs:{type:"button",role:"menuitem","data-type":r.type,"data-undone":r.undone?"true":null},children:[Z(this.doc,"span",{class:`${F}__kind`,text:r.type}),Z(this.doc,"span",{class:`${F}__text`,text:r.label||r.type})]});this.off.push(H(n,"click",()=>{const i=t+1;for(let s=0;s<i;s++)R(this.host.undo)&&this.host.undo();this.toggle(),this.refresh()})),d.appendChild(n)})}destroy(){for(const d of this.off)d();this.off=[],this.root&&R(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const O=k}),ke("packages/dom/src/diffpaint.js",function(e,V){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"diffConfigured",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const _=V("packages/core/src/internal/util.js"),R=_.isFunction,$=_.warnOnce,W=V("packages/core/src/i18n/index.js").defaultMessages,Z={changed:"lat-row--changed",added:"lat-row--added",removed:"lat-row--removed"},H="lat-cell--changed",U="lat-cell--added-column";class z{#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 d=this.#e.diff,c=d&&d.enabled;for(const r of y.querySelectorAll("[data-key]")){const t=r.getAttribute("data-key"),n=c?d.statusOf(t):"unchanged";for(const s of Object.values(Z))r.classList.remove(s);c&&Z[n]&&r.classList.add(Z[n]),r.setAttribute("data-diff",c?n:"");const i=c&&n==="changed";for(const s of r.querySelectorAll("[data-col]")){const l=s.getAttribute("data-col");if(s.classList.remove(H,U),s.removeAttribute("data-before"),!i)continue;const u=d.cellStatus(t,l);if(u==="changed"){s.classList.add(H);const f=this.#r(d,t,l);f===null?s.removeAttribute("title"):(s.setAttribute("data-before",f),s.setAttribute("title",this.#o("diff.before",{value:f})))}else u==="added-column"&&s.classList.add(U)}}}#r(y,d,c){const r=this.#e,t=r&&r.columns,n=t&&R(t.get)?t.get(c):null,i=r&&r.permissions;if(n&&i&&R(i.isSecret)&&i.isSecret(n))return null;const s=y.before(d,c);if(s==null)return this.#o("diff.empty");if(!n||!R(n.formatValue))return String(s);const l=R(y.beforeRow)?y.beforeRow(d):void 0,f={...(r.rows&&R(r.rows.byKey)?r.rows.byKey(d):null)||{},data:l===void 0?{}:l};try{const h=n.formatValue(s,f,f.data);return h==null?"":String(h)}catch(h){return $(`diff-before-format:${c}`,`the formatter for column "${c}" threw while formatting a previous value, so the diff hover shows the raw one.`,h),String(s)}}#o(y,d){const c=this.#e;return(c&&c.messages?c.messages:W).t(y,d)}destroy(){for(const d of this.#n)d();this.#n=[];const y=this.#t.viewport.root;if(!(!y||!y.querySelectorAll)){for(const d of y.querySelectorAll("[data-key]")){for(const c of Object.values(Z))d.classList.remove(c);d.removeAttribute("data-diff")}for(const d of y.querySelectorAll("[data-col]"))d.classList.remove(H,U),d.removeAttribute("data-before")}}}function F(O){return!!(O&&O.diff&&(R(O.diff)||typeof O.diff=="object"))}const k=z}),ke("packages/dom/src/highlightpaint.js",function(e,V){"use strict";Object.defineProperty(e,"HighlightPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const R=V("packages/core/src/internal/util.js").isFunction,$="lat-cell--highlight",L="--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()};R(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(U):R(this.#i.setTimeout)?this.#i.setTimeout(U,0):U()}paint(){const U=this.#t.viewport?.root;if(!U||!U.querySelectorAll)return;const z=this.#s();if(z){z.sweep();for(const F of U.querySelectorAll("[data-key]")){const k=F.getAttribute("data-key");for(const O of F.querySelectorAll("[data-col]")){const y=z.active?z.colourFor(k,O.getAttribute("data-col")):null;y?(O.classList.add($),O.style.setProperty(L,y)):O.classList.contains($)&&(O.classList.remove($),O.style.removeProperty(L))}}this.#a(z)}}#a(U){this.#r!==null&&R(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const z=U.nextExpiry;if(!Number.isFinite(z)||!R(this.#i.setTimeout))return;const F=Math.max(0,z-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},F)}#s(){const U=this.#e.highlight;return U&&R(U.model)?U.model():null}destroy(){this.#r!==null&&R(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const z of this.#n)z();this.#n=[];const U=this.#t.viewport?.root;if(!(!U||!U.querySelectorAll))for(const z of U.querySelectorAll(`.${$}`))z.classList.remove($),z.style.removeProperty(L)}}const Z=W}),ke("packages/dom/src/findpaint.js",function(e,V){"use strict";Object.defineProperty(e,"MATCH_CLASS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"CURRENT_CLASS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"FindPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const R=V("packages/core/src/internal/util.js").isFunction,$="lat-cell--find",L="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()};R(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(U):R(this.#i.setTimeout)?this.#i.setTimeout(U,0):U()}paint(){const U=this.#t.viewport?.root;if(!U||!U.querySelectorAll)return;const z=this.#e.find;if(!z||!R(z.stateFor))return;const F=R(z.model)?z.model():null,k=!!F&&F.active;if(!k&&!this.#o)return;let O=!1;for(const y of U.querySelectorAll("[data-key]")){const d=y.getAttribute("data-key");for(const c of y.querySelectorAll("[data-col]")){const r=k?z.stateFor(d,c.getAttribute("data-col")):null;r?(O=!0,c.classList.add($),c.classList.toggle(L,r==="current")):c.classList.contains($)&&c.classList.remove($,L)}}this.#o=O}destroy(){for(const z of this.#n)z();this.#n=[];const U=this.#t.viewport?.root;if(!(!U||!U.querySelectorAll)){for(const z of U.querySelectorAll(`.${$}`))z.classList.remove($,L);this.#o=!1}}}const Z=W}),ke("packages/dom/src/findbar.js",function(e,V){"use strict";Object.defineProperty(e,"FIND_CLASS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"FindBar",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const _=V("packages/dom/src/editors/common.js"),R=_.el,$=_.on,W=V("packages/dom/src/renderer/textentry.js").isTextEntry,H=V("packages/core/src/i18n/index.js").defaultMessages,z=V("packages/core/src/internal/util.js").isFunction,F="lat-find",k=12,O=120;class y{#e;#t;#n;#r;#o;#i=null;#a=null;#s=null;#l=null;#u=null;#c=null;#d=null;#h=null;#f=!1;#m=!1;#p=null;#g=[];#v=null;#b=null;#y=!1;constructor(r){this.#e=r.grid,this.#t=r.renderer,this.#n=r.document||r.renderer.viewport?.document,this.#r=this.#n&&this.#n.defaultView||(typeof globalThis>"u"?{}:globalThis),this.#o=r.settings&&typeof r.settings=="object"?r.settings:{}}get open(){return!!this.#i&&this.#i.style.display!=="none"}get element(){return this.#i}t(r,t){const n=this.#e;return(n&&n.messages&&z(n.messages.t)?n.messages:H).t(r,t)}mount(){const r=this.#S();if(!r)return;r.attachUi({open:n=>this.show(n),close:()=>this.hide(),focus:()=>{this.#a&&this.#a.focus()}}),r.attachDriver({run:()=>this.#T()});const t=this.#t.viewport?.root;if(t&&z(t.addEventListener)&&this.#o.shortcut!==!1){const n=i=>{if(!(i.ctrlKey||i.metaKey)||i.altKey||i.shiftKey||i.key!=="f"&&i.key!=="F")return;const s=i.target;if(this.#a&&s===this.#a){i.preventDefault(),i.stopPropagation(),z(this.#a.select)&&this.#a.select();return}W(s)||(i.preventDefault(),i.stopPropagation(),this.show())};t.addEventListener("keydown",n,!0),this.#g.push(()=>t.removeEventListener("keydown",n,!0))}this.#g.push(this.#e.on("find:changed",()=>this.#R())),this.#g.push(this.#e.on("columns:changed",()=>this.#A())),this.#g.push(this.#e.on("column:visible",()=>this.#A()))}show(r){const t=this.#j();if(!t)return;const n=t.style.display!=="none";t.style.display="",n||this.#w(),this.#S().setOpen(!0),r!=null&&(this.#a.value=String(r),this.#C()),this.#a.focus(),z(this.#a.select)&&this.#a.select(),this.#R()}hide(){this.#_();const r=this.#S();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#w()),r&&(r.clear(),r.setOpen(!1));const t=this.#t.viewport?.root;if(!t||!(this.#i&&this.#n&&this.#n.activeElement&&z(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const s=(z(t.querySelector)?t.querySelector('[tabindex="0"]'):null)||t;z(s.focus)&&s.focus()}search(){this.#C()}destroy(){this.#y=!0,this.#_();for(const t of this.#g)t();this.#g=[];const r=this.#S();r&&(r.attachUi(null),r.attachDriver(null)),this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null}#w(){const r=this.#t;r&&z(r.invalidate)&&r.invalidate("size")}#S(){const r=this.#e&&this.#e.find;return r&&z(r.model)?r.model():null}#j(){if(this.#i)return this.#i;const r=this.#t.viewport,t=r?.root,n=this.#n;if(!t||!n||!z(t.insertBefore))return null;const i=R(n,"div",{class:F,attrs:{role:"search","aria-label":this.t("find.label")}});this.#a=R(n,"input",{class:`${F}__input`,attrs:{type:"text","aria-label":this.t("find.label"),placeholder:this.t("find.placeholder"),autocomplete:"off",spellcheck:"false"}}),this.#s=R(n,"span",{class:`${F}__count`,attrs:{"aria-hidden":"true"}}),this.#l=R(n,"span",{class:`${F}__scope`,attrs:{"aria-hidden":"true"}}),this.#l.style.display="none",this.#u=R(n,"span",{class:`${F}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const s=R(n,"button",{class:`${F}__nav ${F}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),l=R(n,"button",{class:`${F}__nav ${F}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=R(n,"button",{class:`${F}__toggle ${F}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=R(n,"button",{class:`${F}__toggle ${F}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#h=R(n,"select",{class:`${F}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const u=R(n,"button",{class:`${F}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),f=R(n,"div",{class:`${F}__options`,children:[this.#c,this.#d,this.#h]});for(const g of[this.#a,this.#s,this.#l,this.#u,s,l,u,f])i.appendChild(g);this.#g.push($(this.#a,"input",()=>this.#O())),this.#g.push($(s,"click",()=>this.#e.find.prev())),this.#g.push($(l,"click",()=>this.#e.find.next())),this.#g.push($(this.#c,"click",()=>{this.#f=!this.#f,this.#c.setAttribute("aria-pressed",String(this.#f)),this.#C()})),this.#g.push($(this.#d,"click",()=>{this.#m=!this.#m,this.#d.setAttribute("aria-pressed",String(this.#m)),this.#C()})),this.#g.push($(this.#h,"change",()=>{const g=this.#h.value;this.#p=g?String(g):null,this.#C()})),this.#g.push($(u,"click",()=>this.hide()));const h=g=>{if(g.key==="Escape"){g.preventDefault(),g.stopPropagation(),this.hide();return}g.key==="Enter"&&g.target===this.#a&&(g.preventDefault(),g.stopPropagation(),this.#v!==null&&(this.#N(),this.#C()),g.shiftKey?this.#e.find.prev():this.#e.find.next())};return i.addEventListener("keydown",h),this.#g.push(()=>i.removeEventListener("keydown",h)),i.style.display="none",t.insertBefore(i,r.header||t.firstChild),this.#i=i,this.#A(),i}#A(){const r=this.#h;if(!r)return;const t=this.#n;for(;r.firstChild;)r.removeChild(r.firstChild);r.appendChild(R(t,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const n=this.#e.columns,i=n&&z(n.visible)?n.visible():[];let s=!1;for(const l of i){if(!l||l.id===void 0)continue;const u=String(l.id);r.appendChild(R(t,"option",{text:l.title||u,attrs:{value:u}})),u===this.#p&&(s=!0)}s||(this.#p=null),r.value=this.#p||""}#O(){const r=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):O;if(this.#N(),r===0||!z(this.#r.setTimeout)){this.#C();return}this.#v=this.#r.setTimeout(()=>{this.#v=null,this.#C()},r)}#C(){const r=this.#S();if(!r||this.#y)return;const t=this.#a?this.#a.value:"";if(!t){this.#M(),r.clear();return}r.begin(t,{caseSensitive:this.#f,wholeCell:this.#m,columns:this.#p?[this.#p]:null,from:this.#E()}),this.#T()}#E(){const r=this.#t&&this.#t.window,t=r&&Number.isFinite(r.first)?r.first:0;return Math.max(0,t)}#T(){if(this.#b!==null||this.#y)return;const r=()=>{this.#b=null,this.#x()};z(this.#r.requestAnimationFrame)?this.#b=this.#r.requestAnimationFrame(r):z(this.#r.setTimeout)?this.#b=this.#r.setTimeout(r,0):r()}#x(){const r=this.#S();!r||this.#y||!r.active||(r.stale&&r.rescan({from:this.#E()}),!r.complete&&(r.step(k)||this.#T()))}#R(){if(!this.#i||this.#y)return;const r=this.#e.find.count(),t=this.#S().active;let n="",i="idle";t&&(r.total===0?(n=r.complete?this.t("find.none"):this.t("find.searching"),i=r.complete?"none":"searching"):(n=this.t(r.complete?"find.count":"find.countPartial",{current:r.current,total:r.total}),i=r.complete?"matches":"searching")),this.#s.textContent=n,this.#i.setAttribute("data-state",i);const s=t&&r.windowed;this.#l.textContent=s?this.t("find.loadedRows"):"",this.#l.style.display=s?"":"none",t?r.complete&&(this.#u.textContent=r.total===0?this.t(s?"a11y.find.noneLoaded":"a11y.find.none"):this.t(s?"a11y.find.countLoaded":"a11y.find.count",{current:r.current,count:r.total})):this.#u.textContent=""}#N(){this.#v!==null&&z(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#v),this.#v=null}#M(){this.#b!==null&&(z(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#b):z(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#b),this.#b=null)}#_(){this.#N(),this.#M()}}const d=y}),ke("packages/dom/src/redactpaint.js",function(e,V){"use strict";Object.defineProperty(e,"RedactionPainter",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return L}});const _="lat-cell--redacted",R="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 H=this.#e.redaction;if(!H)return;const U=H.active;for(const z of Z.querySelectorAll(`.${R}[data-col]`))U&&H.has(z.getAttribute("data-col"))?z.classList.add(_):z.classList.contains(_)&&z.classList.remove(_)}destroy(){for(const Z of this.#n)Z();this.#n=[]}}const L=$}),ke("packages/dom/src/validationpaint.js",function(e,V){"use strict";Object.defineProperty(e,"ValidationPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const R=V("packages/dom/src/editors/common.js").markInvalid,$="lat-cell";function L(H,U){let z=H;for(;z;){if(U(z))return z;z=z.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 z=L(U,F=>F.getAttribute&&F.getAttribute("data-key")!==null);return z?z.getAttribute("data-key"):null}paint(){const U=this.#e.validation;if(!U||!U.active)return;const z=this.#t.viewport?.root;if(!(!z||!z.querySelectorAll))for(const F of z.querySelectorAll(`.${$}[data-col]`)){const k=F.getAttribute("data-col"),O=this.#r(F),y=O?U.errorFor(O,k):null;R(F,y?y.message:null)}}destroy(){for(const U of this.#n)U();this.#n=[]}}const Z=W}),ke("packages/dom/src/presentation.js",function(e,V){"use strict";Object.defineProperty(e,"CHROME",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"PresentationController",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/dom/src/renderer/textentry.js").isTextEntry,Z=V("packages/dom/src/renderer/viewport.js").CLASS,H="lat-presenting",U="lat-presenting--changing",z="lat-presenting__progress",F="lat-cell--dimmed",k=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class O{#e;#t;#n;#r=[];#o=null;#i=null;#a=null;constructor(c){this.#e=c.grid,this.#t=c.renderer,this.#n=c.maximiser||null}mount(){this.#r.push(this.#e.on("presentation:started",()=>this.#d())),this.#r.push(this.#e.on("presentation:changed",()=>this.#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",r=>this.#l(r))),this.#r.push(this.#e.on("presentation:spotlight",()=>this.#m())),this.#r.push(this.#e.on("render:done",()=>this.#m())),this.#n&&R(this.#n.watch)&&this.#r.push(this.#n.watch(r=>{r||!this.#o||this.#o.maximised||this.#e.presentation?.active&&this.#e.presentation.stop()}));const c=this.#t.viewport?.root;if(c&&R(c.addEventListener)){const r=t=>this.#s(t);c.addEventListener("keydown",r),this.#r.push(()=>c.removeEventListener("keydown",r))}}#s(c){const r=this.#e.presentation;if(!r?.active)return;const t=c.ctrlKey||c.metaKey,n=c.key;if(n==="Escape"&&!this.#n){c.defaultPrevented||(r.stop(),c.preventDefault?.());return}if(t){n==="="||n==="+"?(r.nudge(1),c.preventDefault?.()):n==="-"||n==="_"?(r.nudge(-1),c.preventDefault?.()):n==="0"&&(r.setScale(1.5),c.preventDefault?.());return}if(!r.views.length||L(c.target))return;n==="ArrowRight"||n==="ArrowDown"||n==="PageDown"||n===" "?(r.step(1),c.preventDefault?.()):n==="ArrowLeft"||n==="ArrowUp"||n==="PageUp"?(r.step(-1),c.preventDefault?.()):n==="Home"?(r.goTo(0),c.preventDefault?.()):n==="End"?(r.goTo(r.views.length-1),c.preventDefault?.()):(n==="r"||n==="R")&&(r.reset(),c.preventDefault?.())}#l(c){!c||!c.viewId||(this.#u(),this.#e.views?.apply?.(c.viewId),this.#c(c))}#u(){const c=this.#t.viewport?.root;c?.classList&&(c.classList.remove(U),c.offsetWidth,c.classList.add(U))}#c(c){const r=this.#t.viewport?.overlays;if(!r||!this.#e.presentation.views.length)return;const t=r.ownerDocument;if(!t?.createElement)return;if(!this.#i){const s=t.createElement("div");s.className=z,s.setAttribute("role","status"),s.setAttribute("aria-live","polite"),r.appendChild(s),this.#i=s}const n=this.#e.views?.get?.(c.viewId),i=n&&n.name?n.name:"";this.#i.textContent=i?`${i} · ${(c.index||0)+1} / ${c.count||0}`:`${(c.index||0)+1} / ${c.count||0}`}#d(){if(this.#o){this.#f();return}const c=!!(this.#n&&this.#n.active());this.#n&&!c&&this.#n.enter();const r=new Set(this.#e.presentation?.options?.chrome||[]),t=[];for(const i of k){if(r.has(i)||i==="toolPanel"&&this.#y())continue;const s=this.#w(i);s&&s.style&&s.style.display!=="none"&&(s.style.display="none",t.push(s))}const n=this.#v();n&&n.style&&n.style.display!=="none"&&this.#b(n)&&(n.style.display="none",t.push(n)),this.#o={maximised:c,hidden:t},this.#t.viewport?.root?.classList?.add(H),this.#f(),this.#p()}#h(){const c=this.#o;this.#o=null;const r=this.#t.viewport?.root;if(r?.classList?.remove(H),r?.style?.removeProperty("--lattice-presentation-scale"),this.#g(),this.#i&&(this.#i.remove?.(),this.#i=null),r?.classList?.remove(U),this.#m(),c){const t=this.#e.toolPanel;t&&R(t.presentRestore)&&t.presentRestore();for(const n of c.hidden)n.style.display="";this.#n&&!c.maximised&&this.#n.active()&&this.#n.exit()}this.#t.invalidate?.("theme")}#f(){const c=this.#t.viewport?.root;!c||!c.style||(c.style.setProperty("--lattice-presentation-scale",String(this.#e.presentation.scale)),this.#t.invalidate?.("theme"))}#m(){const c=this.#t.viewport?.root;if(!c?.querySelectorAll)return;const r=this.#e.presentation?.active?this.#e.presentation.spotlight:null,t=r&&r.keys.length?new Set(r.keys):null,n=r&&r.colIds.length?new Set(r.colIds):null;for(const i of c.querySelectorAll("[data-key]")){const s=!t||t.has(i.getAttribute("data-key"));for(const l of i.querySelectorAll("[data-col]"))!r||s&&(!n||n.has(l.getAttribute("data-col")))?l.classList.remove(F):l.classList.add(F)}}#p(){this.#g();const c=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(c)||c<=0||!this.#e.presentation.views.length)return;const r=this.#t.viewport?.root?.ownerDocument?.defaultView;r?.setInterval&&(this.#a=r.setInterval(()=>{const t=this.#e.presentation;t.active&&t.goTo(t.index>=t.views.length-1?0:t.index+1)},Math.max(1e3,c)))}#g(){if(this.#a===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#a),this.#a=null}#v(){const c=this.#e.element;return!c||!R(c.querySelector)?null:c.querySelector(`.${Z.statusBar}`)}#b(c){const r=c.children||[];for(const t of r)if(!t.style||t.style.display!=="none")return!1;return!0}#y(){const c=this.#e.toolPanel;return!!(c&&R(c.presentOnly)&&c.presentOnly())}#w(c){const r=this.#e.element;if(!r||!R(r.querySelector))return null;const t={toolPanel:".lat-panel-dock",statusBar:".lat-statusbar",editBar:".lat-editor-bar",historyBar:".lat-history",pagination:".lat-pagination"}[c];return t?r.querySelector(t):null}destroy(){this.#o&&this.#h();for(const c of this.#r)c();this.#r=[]}}const y=O}),ke("packages/dom/src/capture.js",function(e,V){"use strict";Object.defineProperty(e,"isSafeImageSource",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"captureElement",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const R=V("packages/core/src/internal/util.js").isFunction,$=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function L(z,F,k){const O=k.getComputedStyle(z),y=F.style;if(y)for(let d=0;d<O.length;d++){const c=O[d];$.has(c)||y.setProperty(c,O.getPropertyValue(c),O.getPropertyPriority(c))}}function W(z,F,k){if(L(z,F,k),z.tagName==="CANVAS"&&R(z.toDataURL))try{const d=z.toDataURL("image/png"),c=F.style;c&&(c.setProperty("background-image",`url(${d})`),c.setProperty("background-size","100% 100%"),c.setProperty("background-repeat","no-repeat"))}catch{}const O=z.children||[],y=F.children||[];for(let d=0;d<O.length&&d<y.length;d++)W(O[d],y[d],k)}function Z(z,F){if(!z||z.startsWith("data:")||z.startsWith("blob:"))return!0;try{return new URL(z,F).origin===F}catch{return!0}}async function H(z,F={}){const k=z.ownerDocument,O=k?.defaultView;if(!O||typeof O.getComputedStyle!="function")throw new Error("capture needs a browser document");const y=z.getBoundingClientRect(),d=Math.max(1,Math.ceil(y.width)),c=Math.max(1,Math.ceil(y.height)),r=Math.max(.1,Number(F.scale)||2),t=O.location?.origin||"";for(const h of z.querySelectorAll("img")){const g=h.getAttribute("src")||"";if(!Z(g,t))throw new Error(`capture refused: the image at ${g} is on another origin and would taint the canvas. Serve it same-origin, inline it as a data: URL, or hide the column.`)}const n=z.cloneNode(!0);W(z,n,O),n.style.width=`${d}px`,n.style.height=`${c}px`,n.style.margin="0";const i=new O.XMLSerializer().serializeToString(n),s=`<svg xmlns="http://www.w3.org/2000/svg" width="${d}" height="${c}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${i}</div></foreignObject></svg>`,l=new O.Image;await new Promise((h,g)=>{l.onload=()=>h(void 0),l.onerror=()=>g(new Error("capture failed to rasterise the grid; a host element inside it may not serialise as XML")),l.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(s)}`});const u=k.createElement("canvas");u.width=Math.round(d*r),u.height=Math.round(c*r);const f=u.getContext("2d");if(!f)throw new Error("capture could not get a 2d context");return f.fillStyle=F.background||O.getComputedStyle(z).backgroundColor||"#ffffff",f.fillRect(0,0,u.width,u.height),f.drawImage(l,0,0,u.width,u.height),new Promise((h,g)=>{u.toBlob(b=>b?h({blob:b,width:u.width,height:u.height}):g(new Error("capture produced no image")),F.type||"image/png",F.quality)})}const U=H}),ke("packages/dom/src/annotate.js",function(e,V){"use strict";Object.defineProperty(e,"TOOLS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"MARK_TYPES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const _=V("packages/core/src/internal/util.js"),R=_.isFunction,$=_.warnOnce,W=V("packages/dom/src/renderer/direction.js").signedX,Z=Object.freeze(["pen","arrow","rect","highlight"]),H=Object.freeze(["freehand","arrow","rect","highlight","text"]),U=Object.freeze({freehand:"pen",pen:"pen",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),z=Object.freeze({pen:"freehand",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),F=14,k="system-ui, -apple-system, sans-serif";function O(s,l){if(!s||typeof s!="object")return null;const u=U[s.type];if(!u)return null;const f=Array.isArray(s.points)?s.points:[],h=[];for(const b of f){const p=Number(b&&b.x),m=Number(b&&b.y);Number.isFinite(p)&&Number.isFinite(m)&&h.push({x:p,y:m})}const g=typeof s.colour=="string"&&s.colour?s.colour:l;if(u==="text"){const b=typeof s.text=="string"?s.text:"";if(!h.length||!b)return null;const p={tool:u,colour:g,points:[h[0]],text:b,region:y(s.region)},m=Number(s.fontSize);return Number.isFinite(m)&&m>0&&(p.fontSize=m),typeof s.background=="string"&&s.background&&(p.background=s.background),p}return h.length<2?null:{tool:u,colour:g,points:h,region:y(s.region)}}function y(s){return s==="start"||s==="end"?s:"centre"}function d(s){const l={type:z[s.tool]||s.tool,colour:s.colour,points:s.points.map(u=>({x:u.x,y:u.y}))};return(s.region==="start"||s.region==="end")&&(l.region=s.region),s.tool==="text"&&(l.text=s.text,s.fontSize!==void 0&&(l.fontSize=s.fontSize),s.background!==void 0&&(l.background=s.background)),l}const c="lat-annotate",r=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(s){return s==="arrow"||s==="rect"}class n{#e;#t;#n=null;#r=null;#o=null;#i="#e0245e";#a=[];#s=null;#l=[];#u=null;constructor(l){this.#e=l.grid,this.#t=l.renderer,this.#u=Array.isArray(l.seed)?l.seed:null}get tool(){return this.#o}get count(){return this.#a.length}mount(){this.#l.push(this.#e.on("scroll",()=>this.redraw())),this.#l.push(this.#e.on("render:done",()=>this.redraw())),this.#l.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(l){const u=O(l,this.#i);return u?(u.durable=!0,this.#a.push(u),this.#w(),this.redraw(),this.#A(),this.#a.length):($("annotate.add.invalid",`annotate.add ignored a mark: it needs a known \`type\` (${H.join(", ")}) and at least two finite {x, y} points in content coordinates.`),this.#a.length)}list(){return this.#a.map(d)}replaceAll(l){const u=Array.isArray(l)?l:[];this.#a=u.map(f=>O(f,this.#i)).filter(Boolean);for(const f of this.#a)f.durable=!0;this.#a.length&&this.#w(),this.redraw(),this.#A()}#c(){const l=this.#t.viewport?.root;if(!l||!R(l.addEventListener))return;const u=f=>{!this.#o||!f||f.key!=="Escape"||(this.use(null),f.preventDefault?.())};l.addEventListener("keydown",u,!0),this.#l.push(()=>l.removeEventListener("keydown",u,!0))}#d(){const l=this.#n?.ownerDocument?.defaultView||this.#t.viewport?.root?.ownerDocument?.defaultView;if(!l||!R(l.matchMedia))return;let u=null;const f=()=>{const h=l.devicePixelRatio||1;let g;try{g=l.matchMedia(`(resolution: ${h}dppx)`)}catch{return}u=g;const b=()=>{this.redraw(),f()};R(g.addEventListener)?g.addEventListener("change",b,{once:!0}):R(g.addListener)&&g.addListener(b)};f(),this.#l.push(()=>{u=null})}use(l,u={}){const f=!!u.colour&&l===this.#o;u.colour&&(this.#i=String(u.colour));const h=l&&Z.includes(l)?l:null;this.#o=h&&h===this.#o&&!f?null:h;const g=this.#o?this.#w():this.#n;return g&&(g.style.pointerEvents=this.#o?"auto":"none",g.style.cursor=this.#o?"crosshair":""),this.#A(),this.#o}undo(){return this.#a.pop(),this.redraw(),this.#A(),this.#a.length}clear(){this.#a.length&&(this.#a=[],this.redraw(),this.#A())}#h(){const l=this.#a.filter(u=>u.durable);l.length!==this.#a.length&&(this.#a=l,this.redraw(),this.#A())}redraw(){!this.#n&&this.#a.length&&this.#w();const l=this.#n,u=this.#r;if(!l||!u)return;this.#S();const{left:f,top:h}=this.#y();u.clearRect(0,0,l.width,l.height);const g=this.#s?[...this.#a,this.#s]:this.#a;for(const b of["centre","start","end"]){const p=g.filter(m=>y(m.region)===b);if(p.length){u.save(),this.#f(u,b),u.translate((b==="centre"?-f:0)||0,-h||0);for(const m of p)this.#v(u,m);u.restore()}}}#f(l,u="centre"){const f=this.#n,h=this.#t.viewport?.bodyViewport;if(!R(f?.getBoundingClientRect)||!R(h?.getBoundingClientRect))return;const g=f.getBoundingClientRect(),b=h.getBoundingClientRect();if(!b.width||!b.height)return;const p=this.#m(u,b);p&&(l.beginPath(),l.rect(p.left-g.left,b.top-g.top,p.width,b.height),l.clip())}#m(l,u){const f=w=>{if(!R(w?.getBoundingClientRect))return null;const v=w.getBoundingClientRect();return v&&v.width>0?{left:v.left,width:v.width}:null},h=f(this.#t.viewport?.bodyStart),g=f(this.#t.viewport?.bodyEnd);if(l==="start")return h;if(l==="end")return g;let b=u.left,p=u.left+u.width;const m=u.left+u.width/2;for(const w of[h,g]){if(!w)continue;const v=w.left+w.width;w.left+w.width/2<m?b=Math.max(b,v):p=Math.min(p,w.left)}return p>b?{left:b,width:p-b}:null}#p(l){for(const[u,f]of[["start",this.#t.viewport?.bodyStart],["end",this.#t.viewport?.bodyEnd]]){if(!R(f?.getBoundingClientRect))continue;const h=f.getBoundingClientRect();if(h&&h.width>0&&l>=h.left&&l<h.left+h.width)return u}return"centre"}#g(l){const u=this.#t.viewport?.bodyViewport;if(!R(u?.getBoundingClientRect))return!0;const f=u.getBoundingClientRect();return!f.width||!f.height?!0:l.clientX>=f.left&&l.clientX<=f.right&&l.clientY>=f.top&&l.clientY<=f.bottom}#v(l,u){const f=u.points;if(!f.length)return;const h=this.#e.presentation?.scale||1;l.lineWidth=(r[u.tool]||3)*h,l.strokeStyle=u.colour,l.fillStyle=u.colour,l.lineCap="round",l.lineJoin="round",l.globalAlpha=u.tool==="highlight"?.32:1;const g=f[0],b=f[f.length-1];if(u.tool==="text"){const p=(u.fontSize||F)*h;l.font=`${p}px ${k}`,l.textBaseline="top";const m=u.text||"";if(u.background){let w=m.length*p*.6;if(typeof l.measureText=="function"){const v=l.measureText(m);v&&Number.isFinite(v.width)&&(w=v.width)}l.fillStyle=u.background,l.fillRect(g.x-p*.15,g.y-p*.1,w+p*.3,p*1.2)}l.fillStyle=u.colour,l.fillText(m,g.x,g.y),l.globalAlpha=1;return}if(u.tool==="rect")l.strokeRect(g.x,g.y,b.x-g.x,b.y-g.y);else if(u.tool==="arrow")l.beginPath(),l.moveTo(g.x,g.y),l.lineTo(b.x,b.y),l.stroke(),this.#b(l,g,b,l.lineWidth);else{l.beginPath(),l.moveTo(g.x,g.y);for(let p=1;p<f.length;p++)l.lineTo(f[p].x,f[p].y);l.stroke()}l.globalAlpha=1}#b(l,u,f,h){const g=Math.atan2(f.y-u.y,f.x-u.x),b=Math.max(8,h*3);l.beginPath(),l.moveTo(f.x,f.y),l.lineTo(f.x-b*Math.cos(g-Math.PI/7),f.y-b*Math.sin(g-Math.PI/7)),l.lineTo(f.x-b*Math.cos(g+Math.PI/7),f.y-b*Math.sin(g+Math.PI/7)),l.closePath(),l.fill()}#y(){const l=R(this.#t.scrollPosition)?this.#t.scrollPosition():null,u=this.#t.viewport?.rtl===!0;return{left:W(l?.left||0,u),top:l?.top||0}}#w(){if(this.#n)return this.#n;const l=this.#t.viewport?.overlays,u=l?.ownerDocument;if(!l||!u?.createElement)return null;const f=u.createElement("canvas");return f.className=c,f.style.position="absolute",f.style.inset="0",f.style.pointerEvents="none",l.appendChild(f),this.#n=f,this.#r=f.getContext?f.getContext("2d"):null,this.#S(),this.#j(f),f}#S(){const l=this.#n,u=this.#t.viewport?.root;if(!l||!u?.getBoundingClientRect)return;const f=u.getBoundingClientRect(),g=l.ownerDocument?.defaultView?.devicePixelRatio||1,b=Math.max(1,Math.round(f.width*g)),p=Math.max(1,Math.round(f.height*g));l.width===b&&l.height===p||(l.width=b,l.height=p,l.style&&(l.style.width=`${Math.max(1,f.width)}px`,l.style.height=`${Math.max(1,f.height)}px`),this.#r?.setTransform(g,0,0,g,0,0))}#j(l){const u=(p,m="centre")=>{const w=l.getBoundingClientRect(),{left:v,top:a}=this.#y();return{x:p.clientX-w.left+(m==="centre"?v:0),y:p.clientY-w.top+a}},f=p=>{if(!this.#o||!this.#g(p))return;const m=this.#p(p.clientX);this.#s={tool:this.#o,colour:this.#i,points:[u(p,m)],region:m},l.setPointerCapture?.(p.pointerId),p.preventDefault?.()},h=p=>{if(!this.#s)return;const m=u(p,this.#s.region);t(this.#s.tool)&&this.#s.points.length>1&&this.#s.points.pop(),this.#s.points.push(m),this.redraw()},g=p=>{this.#s&&(this.#s.points.length>1&&this.#a.push(this.#s),this.#s=null,l.releasePointerCapture?.(p.pointerId),this.redraw(),this.#A())},b=p=>{if(!this.#o)return;const m=this.#t.viewport?.bodyViewport;if(!m)return;let w=!1;p.deltaY&&typeof m.scrollTop=="number"&&(m.scrollTop+=p.deltaY,w=!0),p.deltaX&&typeof m.scrollLeft=="number"&&(m.scrollLeft+=p.deltaX,w=!0),w&&p.preventDefault?.()};l.addEventListener("pointerdown",f),l.addEventListener("pointermove",h),l.addEventListener("pointerup",g),l.addEventListener("pointercancel",g),l.addEventListener("wheel",b,{passive:!1}),this.#l.push(()=>{l.removeEventListener("pointerdown",f),l.removeEventListener("pointermove",h),l.removeEventListener("pointerup",g),l.removeEventListener("pointercancel",g),l.removeEventListener("wheel",b)})}#A(){this.#e.emit?.("annotation:changed",{tool:this.#o,count:this.#a.length},"user")}destroy(){for(const l of this.#l)l();this.#l=[],this.#n?.remove?.(),this.#n=null,this.#r=null,this.#a=[]}}const i=n}),ke("packages/dom/src/timelinebar.js",function(e,V){"use strict";Object.defineProperty(e,"agoLabel",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"clockLabel",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"TimelineBar",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return z}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,W="lat-timeline";function Z(F){if(!Number.isFinite(F)||F<1e3)return"now";const k=Math.round(F/1e3);if(k<60)return`${k}s ago`;const O=Math.round(k/60);return O<60?`${O}m ago`:`${Math.round(O/60)}h ago`}function H(F,k){return Number.isFinite(F)?new Date(F).toLocaleTimeString(k||void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}class U{#e;#t;#n=null;#r=null;#o=null;#i=null;#a=[];constructor(k){this.#e=k.grid,this.#t=k.renderer}mount(){this.#a.push(this.#e.on("timeline:attached",()=>{this.#l(),this.refresh()})),this.#a.push(this.#e.on("timeline:detached",()=>this.#u())),this.#a.push(this.#e.on("timeline:seek",()=>this.refresh())),this.#a.push(this.#e.on("rows:changed",()=>this.refresh()))}refresh(){if(!this.#n||!this.#e.timeline.attached)return;const k=this.#e.timeline,O=k.depth,y=k.position;this.#r.max=String(Math.max(1,O)),this.#r.value=String(Math.max(0,O-y)),this.#r.disabled=O===0;const d=k.at(),c=k.live;this.#o&&(this.#o.textContent=c?this.#s("timeline.live"):Z(Date.now()-(d||Date.now())),this.#o.setAttribute("data-live",c?"true":"false")),this.#i&&(this.#i.textContent=O===0?this.#s("timeline.recording"):H(d,this.#e.get("locale"))),this.#n.setAttribute("data-live",c?"true":"false")}#s(k,O){const y=this.#e;return(y&&y.messages?y.messages:L).t(k,O)}#l(){if(this.#n)return;const k=this.#t.viewport?.overlays,O=k?.ownerDocument;if(!k||!O?.createElement)return;const y=O.createElement("div");y.className=W;const d=O.createElement("span");d.className=`${W}__ago`,d.setAttribute("role","status"),d.setAttribute("aria-live","polite");const c=O.createElement("input");c.className=`${W}__range`,c.type="range",c.min="0",c.step="1",c.setAttribute("aria-label",this.#s("timeline.scrub"));const r=O.createElement("span");r.className=`${W}__clock`;const t=O.createElement("button");t.className=`${W}__live`,t.type="button",t.textContent=this.#s("timeline.goLive"),t.setAttribute("aria-label",this.#s("timeline.returnToPresent")),y.appendChild(d),y.appendChild(c),y.appendChild(r),y.appendChild(t),k.appendChild(y),this.#n=y,this.#r=c,this.#o=d,this.#i=r;const n=()=>{const l=this.#e.timeline.depth;this.#e.timeline.seek(l-Number(c.value))};c.addEventListener("input",n);const i=()=>this.#e.timeline.toLive();t.addEventListener("click",i);const s=l=>l.stopPropagation();c.addEventListener("keydown",s),this.#a.push(()=>{c.removeEventListener("input",n),t.removeEventListener("click",i),c.removeEventListener("keydown",s)})}#u(){this.#n&&(R(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null,this.#i=null)}destroy(){for(const k of this.#a)k();this.#a=[],this.#u()}}const z=U}),ke("packages/dom/src/commentpaint.js",function(e,V){"use strict";Object.defineProperty(e,"CommentPainter",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,Z=V("packages/dom/src/renderer/direction.js").isRtlElement,H="lat-comment-mark",U="lat-cell--commented",z="lat-cell--commented-open";class F{#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.#a(),this.paint()}paint(){const y=this.#e.comments;if(!y||!y.enabled)return;const d=this.#t.viewport?.root;if(!d||!d.querySelectorAll)return;const c=[];for(const r of d.querySelectorAll("[data-key]")){const t=r.getAttribute("data-key");if(t){c.push(t);for(const n of r.querySelectorAll("[data-col]")){const i=n.getAttribute("data-col"),s=y.at(t,i),l=!!(s&&s.count);n.classList.toggle(U,l),n.classList.toggle(z,l&&s.unresolved>0),this.#i(n,s,i)}}}(c.length!==this.#r.length||c.some((r,t)=>r!==this.#r[t]))&&(this.#r=c,y.request(c))}#o(y,d){const c=this.#e;return(c&&c.messages?c.messages:L).t(y,d)}#i(y,d,c){if(!d||!d.count){y.hasAttribute("aria-description")&&y.removeAttribute("aria-description");return}const r=d.count,t=d.unresolved,n=this.#o("count.comments",{count:r});y.setAttribute("aria-description",t>0?this.#o("comments.someUnresolved",{comments:n,unresolved:t}):this.#o("comments.allResolved",{comments:n}))}#a(){const y=this.#t.viewport?.root;if(!y||!R(y.addEventListener))return;const d=r=>{const t=this.#e.comments;if(!t||!t.enabled)return;const n=r.target&&R(r.target.closest)?r.target.closest("[data-col]"):null;if(!n||!n.classList.contains(U)||!this.#s(n,r))return;const i=n.closest("[data-key]"),s=i&&i.getAttribute("data-key");s&&(r.stopPropagation(),r.preventDefault(),t.open(s,n.getAttribute("data-col")))},c=r=>{const t=this.#e.comments;if(!t||!t.enabled||!r.altKey||r.key!=="m"&&r.key!=="M")return;const n=this.#t.viewport?.root?.querySelector?.("[data-col].lat-cell--focus")||(typeof document<"u"&&document.activeElement&&R(document.activeElement.closest)?document.activeElement.closest("[data-col]"):null);if(!n)return;const i=n.closest("[data-key]"),s=i&&i.getAttribute("data-key");s&&(r.preventDefault(),r.stopPropagation(),t.open(s,n.getAttribute("data-col")))};y.addEventListener("click",d,!0),y.addEventListener("keydown",c,!0),this.#n.push(()=>{y.removeEventListener("click",d,!0),y.removeEventListener("keydown",c,!0)})}#s(y,d){if(!R(y.getBoundingClientRect))return!1;const c=y.getBoundingClientRect(),r=Math.max(14,Math.min(24,c.height*.6));return(Z(y)?d.clientX<=c.left+r:d.clientX>=c.right-r)&&d.clientY<=c.top+r}destroy(){for(const y of this.#n)y();this.#n=[]}}const k=F}),ke("packages/dom/src/presencepaint.js",function(e,V){"use strict";Object.defineProperty(e,"PresencePainter",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,Z=V("packages/dom/src/editors/common.js").cssEscape,U=V("packages/core/src/model/presence.js").CURSOR_LABEL_MS,z="lat-presence";class F{#e;#t;#n=null;#r=null;#o=new Set;#i=[];#a=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 d of["presence:joined","presence:left","presence:updated"])this.#i.push(this.#e.on(d,c=>this.#s(d,c)));this.#l(),this.paint()}}#s(y,d){if(this.#h(),y==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const r=d&&d.peer;r&&(this.#r.textContent=this.#f(y==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:r.name}))}#l(){const y=this.#t.viewport?.overlays,d=y?.ownerDocument;if(!y||!d?.createElement)return;const c=this.#e.get("presence")||{},r=d.createElement("span");if(r.className=`${z}__live`,r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),y.appendChild(r),this.#r=r,c.roster===!1)return;const t=d.createElement("div");t.className=z,c.roster&&c.roster.side==="start"&&t.setAttribute("data-side","start"),t.style.pointerEvents="auto",y.appendChild(t),this.#n=t}paint(){const y=this.#e.presence,d=this.#t.viewport?.root;if(!y||!y.enabled||!d?.querySelectorAll)return;this.#d(d);const c=y.peers(),r=[...c].sort((t,n)=>t.at-n.at);for(const t of r)for(const n of t.ranges||[])for(const i of n.rowIds||[])for(const s of n.columns||[])this.#c(d,i,s,t,"range");for(const t of r)t.cursor&&this.#c(d,t.cursor.rowId,t.cursor.colId,t,"cursor");for(const t of r)t.editing&&this.#c(d,t.editing.rowId,t.editing.colId,t,"edit");this.#h(),this.#u(c)}#u(y){if(this.#a!==null)return;const d=y.filter(t=>t.cursorFresh);if(!d.length)return;const r=Math.max(...d.map(t=>t.cursorAt||0))+U-Date.now();this.#a=setTimeout(()=>{this.#a=null,this.paint()},Math.max(50,r))}#c(y,d,c,r,t){const n=y.querySelector(`[data-key="${Z(d)}"]`),i=n&&n.querySelector(`[data-col="${Z(c)}"]`);i&&(i.setAttribute("data-presence",t),i.style.setProperty("--lat-peer",r.colour),i.setAttribute("data-peer-name",r.name),i.setAttribute("data-peer-initial",r.initials||(r.name||"?").slice(0,1).toUpperCase()),r.idle?i.setAttribute("data-peer-idle","true"):i.removeAttribute("data-peer-idle"),t==="cursor"&&r.cursorFresh&&i.setAttribute("data-peer-fresh","true"),this.#o.add(`${d}${c}`))}#d(y){if(this.#o.size){for(const d of y.querySelectorAll("[data-presence]"))d.removeAttribute("data-presence"),d.removeAttribute("data-peer-name"),d.removeAttribute("data-peer-initial"),d.removeAttribute("data-peer-fresh"),d.removeAttribute("data-peer-idle"),d.style.removeProperty("--lat-peer");this.#o.clear()}}#h(){if(!this.#n)return;const y=this.#n.ownerDocument,d=this.#e.presence.peers();if(this.#n.textContent="",!d.length){this.#n.toggleAttribute("data-empty",!0);return}this.#n.removeAttribute("data-empty");for(const r of d){const t=y.createElement("button");t.className=`${z}__peer`,t.type="button",t.style.setProperty("--lat-peer",r.colour),t.toggleAttribute("data-idle",!!r.idle),t.toggleAttribute("data-hidden",!!r.hidden);let n="presence.peer";r.hidden?n="presence.peerHidden":r.idle&&(n="presence.peerIdle"),t.setAttribute("aria-label",this.#f(n,{name:r.name}));const i=y.createElement("span");i.className=`${z}__dot`,i.setAttribute("aria-hidden","true"),i.textContent=r.initials||(r.name||"?").slice(0,1).toUpperCase(),t.appendChild(i);const s=y.createElement("span");s.className=`${z}__name`,s.textContent=r.name,t.appendChild(s),t.addEventListener("click",()=>this.#e.presence.jumpTo(r.id)),this.#n.appendChild(t)}const c=d.filter(r=>r.hidden).length;if(c){const r=y.createElement("span");r.className=`${z}__hidden`,r.textContent=this.#f("presence.hidden",{count:c}),this.#n.appendChild(r)}}announceRefusal(y){if(!this.#r)return;const d=y&&y.name?y.name:this.#f("presence.someoneElse");this.#r.textContent=this.#f("a11y.presence.refused",{name:d})}#f(y,d){const c=this.#e;return(c&&c.messages?c.messages:L).t(y,d)}destroy(){for(const d of this.#i)d();this.#i=[],this.#a!==null&&clearTimeout(this.#a),this.#a=null;const y=this.#t.viewport?.root;y?.querySelectorAll&&this.#d(y),this.#n&&R(this.#n.remove)&&this.#n.remove(),this.#r&&R(this.#r.remove)&&this.#r.remove(),this.#n=null,this.#r=null}}const k=F}),ke("packages/dom/src/commentpanel.js",function(e,V){"use strict";Object.defineProperty(e,"relativeTime",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"renderBody",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"CommentPanel",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,Z=V("packages/dom/src/editors/common.js").cssEscape,U=V("packages/core/src/model/comments.js").parseCellKey,z="lat-comments",F=/^(https?:|mailto:)/i,k='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function O(r,t){if(!Number.isFinite(r))return"";const n=Math.max(0,Math.round((t-r)/1e3));if(n<60)return"just now";const i=Math.round(n/60);if(i<60)return`${i}m ago`;const s=Math.round(i/60);return s<24?`${s}h ago`:`${Math.round(s/24)}d ago`}function y(r,t,n,i){t.textContent="";const s=String(n??"");if(!i){t.textContent=s;return}const l=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let u=0,f=l.exec(s);for(;f;){f.index>u&&t.appendChild(r.createTextNode(s.slice(u,f.index)));const h=f[0];if(h.startsWith("*")){const g=r.createElement("em");g.textContent=h.slice(1,-1),t.appendChild(g)}else if(h.startsWith("`")){const g=r.createElement("code");g.textContent=h.slice(1,-1),t.appendChild(g)}else{const g=h.indexOf("]("),b=h.slice(1,g),p=h.slice(g+2,-1);if(F.test(p)){const m=r.createElement("a");m.href=p,m.textContent=b,m.rel="noopener noreferrer",m.target="_blank",t.appendChild(m)}else t.appendChild(r.createTextNode(b))}u=f.index+h.length,f=l.exec(s)}u<s.length&&t.appendChild(r.createTextNode(s.slice(u)))}class d{#e;#t;#n=null;#r=null;#o=null;#i=null;#a=null;#s=[];constructor(t){this.#e=t.grid,this.#t=t.renderer}mount(){this.#s.push(this.#e.on("comment:threadOpened",t=>this.#l(t))),this.#s.push(this.#e.on("comment:threadClosed",()=>this.#u())),this.#s.push(this.#e.on("render:done",()=>{this.#b(),this.#w()})),this.#s.push(this.#e.on("stream:evicted",()=>this.#c()))}#l(t){const n=this.#t.viewport?.root?.ownerDocument;n&&(this.#a=n.activeElement||null,this.#i=this.#h(t.rowId,t.field),this.#n||this.#m(n),this.#n.setAttribute("data-open","true"),this.#b(),this.#w(),this.#o&&R(this.#o.focus)&&this.#o.focus())}#u(){if(!this.#n)return;this.#n.removeAttribute("data-open"),this.#i=null;const t=this.#a;this.#a=null,t&&R(t.focus)&&t.focus()}#c(){const t=this.#e.comments.openKey;if(!t)return;const{rowId:n}=U(t);this.#e.rows.byKey(n)||(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 i=this.#r.ownerDocument.createElement("p");i.className=`${z}__note`,i.setAttribute("role","status"),i.textContent=t,this.#r.appendChild(i)}#h(t,n){const i=this.#t.viewport?.root;if(!i||!i.querySelector)return null;const s=i.querySelector(`[data-key="${Z(t)}"]`);return s?s.querySelector(`[data-col="${n}"]`):null}#f(t,n){const i=this.#e;return(i&&i.messages?i.messages:L).t(t,n)}#m(t){const n=t.createElement("div");n.className=z,n.setAttribute("role","dialog"),n.setAttribute("aria-modal","true"),n.setAttribute("aria-label",this.#f("comments.panel"));const i=t.createElement("header");i.className=`${z}__head`;const s=t.createElement("div");s.className=`${z}__title`,i.appendChild(s);const l=t.createElement("button");l.className=`${z}__resolve`,l.type="button",i.appendChild(l);const u=t.createElement("button");u.className=`${z}__close`,u.type="button",u.setAttribute("aria-label",this.#f("comments.close")),u.textContent="×",i.appendChild(u);const f=t.createElement("div");f.className=`${z}__list`,f.setAttribute("role","log"),f.setAttribute("aria-live","polite");const h=t.createElement("form");h.className=`${z}__composer`;const g=t.createElement("textarea");g.className=`${z}__input`,g.rows=2,g.setAttribute("aria-label",this.#f("comments.write"));const b=t.createElement("button");b.className=`${z}__send`,b.type="submit",b.textContent=this.#f("comments.post"),h.appendChild(g),h.appendChild(b),n.appendChild(i),n.appendChild(f),n.appendChild(h),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(n),this.#n=n,this.#r=f,this.#o=g,this.#p=s,this.#g=l;const p=a=>{a.preventDefault();const o=String(g.value||"").trim();o&&(g.value="",this.#e.comments.add(o))},m=()=>this.#e.comments.close(),w=()=>{this.#v()>0?this.#e.comments.resolve():this.#e.comments.unresolve()},v=a=>{if(a.stopPropagation(),a.key==="Escape"){a.preventDefault(),this.#e.comments.close();return}if(a.key!=="Tab")return;const o=[...n.querySelectorAll(k)].filter(M=>M.offsetParent!==null||M===g);if(!o.length)return;const S=o[0],E=o[o.length-1],A=n.ownerDocument.activeElement;a.shiftKey&&A===S?(a.preventDefault(),E.focus()):!a.shiftKey&&A===E&&(a.preventDefault(),S.focus())};h.addEventListener("submit",p),u.addEventListener("click",m),l.addEventListener("click",w),n.addEventListener("keydown",v),this.#s.push(()=>{h.removeEventListener("submit",p),u.removeEventListener("click",m),l.removeEventListener("click",w),n.removeEventListener("keydown",v)})}#p=null;#g=null;#v(){return(this.#e.comments.thread||[]).filter(n=>!n.resolved).length}#b(){const t=this.#e.comments;if(!this.#n||!t.openKey)return;const n=this.#n.ownerDocument,i=this.#e.get("comments")||{},s=Date.now(),l=t.openKey,{rowId:u,field:f}=U(l),h=this.#e.columns.get(f),g=this.#e.rows.byKey(u),b=R(i.rowLabel)&&g?i.rowLabel(g):u;if(this.#p.textContent=this.#f("comments.cellTitle",{column:h&&(h.title??h.id)||f,row:b}),this.#g.textContent=this.#v()>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 m=g&&h?h.getValue(g.data,g):void 0;for(const w of p)this.#r.appendChild(this.#y(n,w,s,m,i))}#y(t,n,i,s,l){const u=t.createElement("article");u.className=`${z}__item`,n.pending&&u.setAttribute("data-pending","true"),n.resolved&&u.setAttribute("data-resolved","true");const f=t.createElement("div");f.className=`${z}__meta`;const h=t.createElement("span");h.className=`${z}__author`,h.textContent=n.author&&(n.author.name||n.author.initials)||this.#f("comments.unknownAuthor"),f.appendChild(h);const g=t.createElement("time");g.className=`${z}__time`;const b=O(n.at,i);g.textContent=n.edited?this.#f("comments.edited",{time:b}):b,f.appendChild(g),u.appendChild(f);const p=t.createElement("div");if(p.className=`${z}__body`,y(t,p,n.body,!!l.markdown),u.appendChild(p),n.value!==void 0&&!Object.is(n.value,s)){const v=t.createElement("p");v.className=`${z}__moved`,v.textContent=this.#f("comments.valueMoved",{was:String(n.value),now:String(s)}),u.appendChild(v)}const m=n.can||{},w=v=>m[v]!==!1;if(w("edit")||w("delete")){const v=t.createElement("div");if(v.className=`${z}__actions`,w("delete")){const a=t.createElement("button");a.type="button",a.className=`${z}__action`,a.textContent=this.#f("comments.delete"),a.addEventListener("click",()=>this.#e.comments.remove(n.id)),v.appendChild(a)}u.appendChild(v)}return u}#w(){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 n=this.#e.comments.openKey,{rowId:i,field:s}=U(n),l=this.#h(i,s)||this.#i,u=this.#t.viewport?.root;if(!l||!u||!R(l.getBoundingClientRect))return;const f=l.getBoundingClientRect(),h=u.getBoundingClientRect(),g=this.#n.getBoundingClientRect();let b=f.bottom-h.top+4;b+g.height>h.height&&f.top-h.top>g.height&&(b=f.top-h.top-g.height-4);let p=f.left-h.left;p+g.width>h.width&&(p=Math.max(0,h.width-g.width-4)),this.#n.style.top=`${Math.max(0,b)}px`,this.#n.style.left=`${Math.max(0,p)}px`;const m=f.bottom<h.top||f.top>h.bottom;this.#n.toggleAttribute("data-offscreen",m)}destroy(){for(const t of this.#s)t();this.#s=[],this.#n&&R(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const c=d}),ke("packages/dom/src/watermark.js",function(e,V){"use strict";Object.defineProperty(e,"WATERMARK_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"Watermark",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/dom/src/editors/common.js"),Z=W.el,H=W.on,U="lat-watermark",z="https://www.latticegrid.dev",F=["br","bl","tl","tr"],k=4e3;class O{#e;#t;#n;#r=null;#o=[];#i;#a=0;#s=null;constructor(c){this.#e=c.grid,this.#t=c.document,this.#n=c.element,this.#i=c.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),R(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const c=this.#e.licence&&this.#e.licence.ready;c&&R(c.then)&&c.then(()=>this.refresh(),()=>this.refresh())}refresh(){const c=this.#d();c&&!this.#r?(this.#h(),this.#u()):!c&&this.#r&&(this.#f(),this.#c())}#l(){const c=this.#i;if(!c||!R(c.matchMedia))return!1;try{return!!c.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),R(this.#i.setTimeout)&&(this.#l()||(this.#s=this.#i.setTimeout(()=>{if(this.#s=null,!this.#d()){this.#f();return}this.#a=(this.#a+1)%F.length,this.#f(),this.#h(),this.#u()},k)))}#c(){this.#s!==null&&R(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#s),this.#s=null}#d(){const c=this.#e.licence;return!!(c&&R(c.watermark)&&c.watermark())}#h(){const c=Z(this.#t,"a",{class:`${U}__link`,text:(this.grid&&this.grid.messages?this.grid.messages:L).t("licence.watermark"),attrs:{href:z,target:"_blank",rel:"noopener noreferrer"}});this.#r=Z(this.#t,"div",{class:`${U} ${U}--${F[this.#a]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[c]}),this.#o.push(H(this.#r,"pointerdown",r=>{R(r.stopPropagation)&&r.stopPropagation()})),this.#n&&R(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#f(){this.#r&&R(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c();for(const c of this.#o)c();this.#o=[],this.#f()}}const y=O}),ke("packages/dom/src/maximise.js",function(e,V){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return O}});const _=V("packages/core/src/internal/util.js"),R=_.warnOnce,$=_.isFunction,L=V("packages/dom/src/editors/common.js"),W=L.el,Z=L.on,H="lat-maximised",U={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"},z="lat-maximised-host",F="lat-maximise-placeholder";class k{#e;#t;#n;#r;#o;#i=null;#a=null;#s=new Set;#l=null;#u=null;constructor(d){this.#e=d.element,this.#t=d.document,this.#n=$(d.onChange)?d.onChange:null,this.#r=$(d.captureScroll)?d.captureScroll:null,this.#o=$(d.restoreScroll)?d.restoreScroll:null}active(){return this.#i!==null}enter(){if(this.active())return!0;const d=this.#e.parentNode;if(!d||!this.#t.body)return R("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=W(this.#t,"div",{class:F}),this.#i.style.visibility="hidden";const c=this.#e.offsetWidth,r=this.#e.offsetHeight;c&&(this.#i.style.width=`${c}px`),r&&(this.#i.style.height=`${r}px`);const t=this.#r?this.#r():null;d.insertBefore(this.#i,this.#e),this.#c(()=>this.#t.body.appendChild(this.#e)),this.#l={};for(const[n,i]of Object.entries(U))this.#l[n]=this.#e.style[n]||"",this.#e.style[n]=i;return this.#u=this.#t.body.style?this.#t.body.style.overflow||"":null,this.#t.body.style&&(this.#t.body.style.overflow="hidden"),this.#e.classList.add(H),this.#t.body.classList&&this.#t.body.classList.add(z),t&&this.#o&&this.#o(t),this.#a=Z(this.#t,"keydown",n=>this.#d(n)),this.#h(),!0}exit(){if(!this.active())return!1;const d=this.#r?this.#r():null,c=this.#i,r=c.parentNode;if(r&&$(r.insertBefore)&&this.#c(()=>r.insertBefore(this.#e,c)),$(c.remove)&&c.remove(),this.#i=null,this.#l){for(const[t,n]of Object.entries(this.#l))this.#e.style[t]=n;this.#l=null}return this.#u!==null&&this.#t.body&&this.#t.body.style&&(this.#t.body.style.overflow=this.#u),this.#u=null,this.#e.classList.remove(H),this.#t.body&&this.#t.body.classList&&this.#t.body.classList.remove(z),d&&this.#o&&this.#o(d),this.#a&&this.#a(),this.#a=null,this.#h(),!0}toggle(){return this.active()?!this.exit():this.enter()}#c(d){const c=this.#t.activeElement,r=c&&c!==this.#t.body&&$(this.#e.contains)&&this.#e.contains(c)?c:null;d(),r&&$(r.focus)&&r.focus()}#d(d){!d||d.key!=="Escape"||d.defaultPrevented||this.exit()}#h(){this.#n&&this.#n();for(const d of this.#s)d(this.active())}watch(d){return $(d)?(this.#s.add(d),()=>this.#s.delete(d)):()=>{}}destroy(){this.exit()}}const O=k}),ke("packages/dom/src/promptbar.js",function(e,V){"use strict";Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return n}});const _=V("packages/dom/src/editors/common.js"),R=_.documentFor,$=_.el,L=_.on,W=_.clear,H=V("packages/core/src/i18n/index.js").defaultMessages,z=V("packages/core/src/internal/util.js").isFunction,F=V("packages/core/src/ai/schema.js"),k=F.describeGrid,O=F.promptText,y=V("packages/core/src/ai/intent.js"),d=y.applyPlan,c=y.buildPrompt,r=y.planIntent,t="lat-prompt";class n{#e;#t=null;#n=null;#r={};#o;#i={};#a=null;#s=null;#l=null;#u=null;#c=null;#d=null;#h=null;#f=null;#m=null;#p=null;#g=null;#v="idle";#b=0;#y=!1;#w=[];t(u,f){return(this.messages&&typeof this.messages.t=="function"?this.messages:H).t(u,f)}init(u={}){this.messages=u&&u.messages||u&&u.grid&&u.grid.messages||H,this.#e=R(u),this.#t=u.grid||null,this.#n=z(u.ask)?u.ask:null,this.#r=u.schemaOptions||{},this.#o=u.context,this.#i={onPlan:z(u.onPlan)?u.onPlan:null,onApply:z(u.onApply)?u.onApply:null,onError:z(u.onError)?u.onError:null},this.#a=$(this.#e,"div",{class:t,attrs:{"data-state":"idle",role:"search"}}),this.#S(u)}element(){return this.#a}refresh(){this.#y||!this.#a||this.#v!=="busy"&&this.#C()}destroy(){this.#y=!0,this.#b++;for(const u of this.#w)u();this.#w.length=0,this.#g=null,this.#a=null,this.#s=null,this.#l=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(u){if(this.#y||this.#v==="busy")return null;const f=String(u??(this.#s&&this.#s.value)??"").trim();if(!f)return null;if(!this.#n)return this.#T("No model is wired up. Supply `ai.ask` to use the prompt bar."),null;const h=++this.#b;this.#j("busy"),this.#E("Thinking…");let g;try{const b=k(this.#t,this.#r),p=O(b);if(g=await this.#n({prompt:f,schema:b,schemaText:p,message:c(f,p),context:this.#o}),this.#y||h!==this.#b)return null;const m=r(g,b);return this.#A(m),m}catch(b){return this.#y||h!==this.#b||(this.#i.onError&&this.#i.onError(b),this.#T(b instanceof Error?b.message:String(b))),null}}apply(){const u=this.#g;if(this.#y||!u||!u.ok)return null;const f=this.#t?.ai,h=z(f?.apply)?f.apply(u):d(u,this.#t);return this.#i.onApply&&this.#i.onApply(h,u),this.#C(),this.#s&&(this.#s.value=""),h.failed.length?this.#T(`Applied ${h.applied.length}; ${h.failed.map(g=>`${g.type} failed: ${g.reason}`).join("; ")}`):this.#E(`Applied: ${u.describe()}`),h}discard(){this.#y||(this.#C(),this.#E("Discarded."))}#S(u){const f=this.#e,h=$(f,"div",{class:`${t}__row`});this.#s=$(f,"input",{class:`${t}__input`,attrs:{type:"text",placeholder:u.placeholder||"Ask for a view: “EMEA deals over 50k, biggest first”","aria-label":u.label||"Ask about this grid",autocomplete:"off"}}),this.#w.push(L(this.#s,"keydown",b=>{const p=b&&b.key;p==="Enter"?(z(b.preventDefault)&&b.preventDefault(),this.ask()):p==="Escape"&&this.#g&&(z(b.preventDefault)&&b.preventDefault(),this.discard())})),h.appendChild(this.#s),this.#l=$(f,"button",{class:`${t}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#w.push(L(this.#l,"click",()=>{this.ask()})),h.appendChild(this.#l),this.#a.appendChild(h),this.#u=$(f,"div",{class:`${t}__preview`,attrs:{hidden:!0}}),this.#c=$(f,"p",{class:`${t}__summary`}),this.#d=$(f,"ul",{class:`${t}__notes`});const g=$(f,"div",{class:`${t}__buttons`});this.#h=$(f,"button",{class:`${t}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#f=$(f,"button",{class:`${t}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#w.push(L(this.#h,"click",()=>{this.apply()})),this.#w.push(L(this.#f,"click",()=>{this.discard()})),g.appendChild(this.#h),g.appendChild(this.#f),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(g),this.#a.appendChild(this.#u),this.#m=$(f,"p",{class:`${t}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#p=$(f,"p",{class:`${t}__error`,attrs:{role:"alert",hidden:!0}}),this.#a.appendChild(this.#m),this.#a.appendChild(this.#p)}#j(u){if(this.#v=u,!this.#a)return;this.#a.setAttribute("data-state",u);const f=u==="busy";i(this.#s,f),i(this.#l,f),this.#l&&(this.#l.textContent=this.t(f?"prompt.asking":"prompt.ask")),s(this.#u,u!=="preview"),s(this.#p,u!=="error")}#A(u){const f=u;if(this.#i.onPlan&&this.#i.onPlan(u),!f.ok){this.#g=null;const h=f.rejected.length?f.rejected.map(g=>g.reason).join("; "):"nothing to do";this.#T(`I could not turn that into a change: ${h}`);return}this.#g=u,this.#E(""),this.#c&&(this.#c.textContent=f.describe()),this.#O(f.rejected),this.#j("preview")}#O(u){const f=this.#d;if(f){W(f),s(f,!u.length);for(const h of u.slice(0,6))f.appendChild($(this.#e,"li",{class:`${t}__note`,text:h.reason}));u.length>6&&f.appendChild($(this.#e,"li",{class:`${t}__note`,text:this.t("prompt.moreNotes",{count:u.length-6})}))}}#C(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&W(this.#d),this.#j("idle")}#E(u){this.#m&&(this.#m.textContent=u)}#T(u){this.#g=null,this.#E(""),this.#p&&(this.#p.textContent=u),this.#j("error")}}function i(l,u){l&&(l.disabled=u,u?l.setAttribute("disabled",""):l.removeAttribute("disabled"))}function s(l,u){l&&(l.hidden=u,u?l.setAttribute("hidden",""):l.removeAttribute("hidden"))}}),ke("packages/dom/src/stat.js",function(e,V){"use strict";Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"bandTone",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return u}});const _=V("packages/core/src/internal/util.js"),R=_.isFunction,$=_.isObject,L=_.warnOnce,Z=V("packages/core/src/source/derive.js").reduceValues,U=V("packages/core/src/source/memory.js").isPipelineSettle,F=V("packages/core/src/i18n/index.js").defaultMessages,O=V("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"},d="unknown",c=new Set(["sum","min","max","avg","first","last","mode","median","p25","p75","p90","p95","p99","stddev","stddevP","mad","range","iqr","trimmedMean","winsorizedMean","geomean","harmean"]),r=Object.freeze({direction:"flat",change:null,percent:null});function t(p,m){if(!Number.isFinite(p)||!Number.isFinite(m))return r;const w=p-m,v=w>0?"up":w<0?"down":"flat",a=m===0?null:w/Math.abs(m)*100;return{direction:v,change:w,percent:a}}function n(p,m){return p==="flat"||m==="neither"?"flat":p===m?"good":"bad"}function i(p,m,w=null){if(R(m)){const A=m(p,w);return A==="good"||A==="warn"||A==="bad"?A:null}if(!$(m))return null;const v=typeof p=="number"&&Number.isFinite(p)?p:null;if(v===null)return null;const a=Number.isFinite(Number(m.good))?Number(m.good):null,o=Number.isFinite(Number(m.warn))?Number(m.warn):null,S=String(m.direction||"up")==="down",E=A=>S?v<=A:v>=A;return a!==null&&E(a)?"good":o!==null&&E(o)?"warn":a===null&&o===null?null:"bad"}function s(p){return!(R(p.value)||p.value!==void 0&&!$(p.value))}function l(p){return!p||!p.rows||!R(p.rows.totalCount)?!0:p.rows.totalCount()>0}function u(p){const m=$(p)?p:{},w=m.grid||null,v=g(m.container,w);if(!v)return L("stat.container","createStat needs a `container`: an element or a selector."),b();const a=v.ownerDocument||(typeof document>"u"?null:document);if(!a)return L("stat.document","createStat needs a document; it draws DOM."),b();const o=a.createElement("div");o.className=["lattice",y.root,m.class].filter(Boolean).join(" "),o.setAttribute("role","group");const S=a.createElement("div");S.className=y.title;const E=a.createElement("div");E.className=y.value;const A=a.createElement("div");A.className=y.interval;const M=a.createElement("div");M.className=y.delta;const C=a.createElement("div");C.className=y.footer;const P=a.createElement("div");if(P.className=y.note,P.hidden=!0,m.icon!=null&&m.icon!==""){const ne=a.createElement("span");ne.className=y.icon,ne.setAttribute("aria-hidden","true"),O(ne,m.icon,`stat:${m.title||"stat"}`),o.appendChild(ne);const re=a.createElement("div");re.className=y.body,re.appendChild(S),re.appendChild(E),re.appendChild(P),re.appendChild(A),re.appendChild(M),re.appendChild(C),o.appendChild(re)}else o.appendChild(S),o.appendChild(E),o.appendChild(P),o.appendChild(A),o.appendChild(M),o.appendChild(C);v.appendChild(o);let K=null;const I=[];let D=!1;function j(){if(R(m.value))return m.value(w);if(m.value!==void 0&&!$(m.value))return m.value;const ne=$(m.value)?m.value:m,re=ne.of,oe=ne.fn||"sum",ie=ne.show;return w?oe==="count"?B().length:re?ie?q(String(re),String(oe),String(ie)):T()==="filtered"&&w.statistics&&R(w.statistics.reduce)?w.statistics.reduce(String(re),String(oe)):Z(B().map(te=>h(te,String(re))),String(oe)):null:null}function T(){return String(m.scope||"filtered")}function B(){if(!w||!w.rows)return[];const ne=T();if(ne==="all"){const oe=[];return R(w.rows.forEachAll)&&w.rows.forEachAll(ie=>{ie.group||oe.push(f(ie))}),oe}if(ne==="selected")return(w.selection&&R(w.selection.rows)?w.selection.rows():[]).filter(Boolean).map(f);const re=[];return R(w.rows.forEach)&&w.rows.forEach(oe=>{oe.group||re.push(f(oe))}),re}function q(ne,re,oe){if(re!=="min"&&re!=="max")return L(`stat.show.${re}`,`\`show\` needs \`fn: 'min'\` or \`fn: 'max'\`: "${re}" reduces to a value that no single row holds, so there is no row to report from.`),null;let ie=null,te=null;for(const ce of B()){const ue=Number(h(ce,ne));Number.isFinite(ue)&&(ie===null||(re==="max"?ue>ie:ue<ie))&&(ie=ue,te=ce)}return te===null?null:h(te,oe)}function X(ne){if(R(m.format))return String(m.format(ne,w));if(ne==null)return m.empty??"—";const re=$(m.value)?m.value:m,oe=re.show||re.of;if((re.show?!0:c.has(String(re.fn||"sum")))&&w&&oe&&R(w.columns?.get)){const te=w.columns.get(String(oe));if(te&&R(te.formatValue))return te.formatValue(ne)}return typeof ne=="number"?Number.isInteger(ne)?String(ne):ne.toFixed(m.decimals??2):String(ne)}function Q(ne){return ne?(w&&w.messages||F).t(`stat.tone.${ne}`):""}function J(){if(D)return;const ne=j(),re=s(m)&&!!w&&!l(w),oe=re?null:ne,ie=R(m.baseline)?m.baseline(w):m.baseline;K=oe,S.textContent=m.title??"",S.hidden=!m.title,E.textContent=X(oe),P.hidden=!re,re&&(P.textContent=w.messages.t("stat.noData"));const te=re||ie===void 0||ie===null?r:t(typeof oe=="number"?oe:null,Number(ie)),ce=n(te.direction,m.goodWhen||"up");if(M.hidden=te.change===null,te.change!==null){const he=te.direction==="up"?"↑":te.direction==="down"?"↓":"→",ve=te.percent===null?X(Math.abs(te.change)):`${Math.abs(te.percent).toFixed(1)}%`;M.textContent=`${he} ${ve}`,M.setAttribute("data-tone",ce),M.setAttribute("data-direction",te.direction)}const ue=R(m.interval)?m.interval(oe,w):null,ae=!!ue&&Number.isFinite(ue.lower)&&Number.isFinite(ue.upper);A.hidden=!ae,ae&&(A.textContent=`${X(ue.lower)} – ${X(ue.upper)}`,Number.isFinite(ue.confidence)&&A.setAttribute("title",`${Math.round(ue.confidence*100)}%`));const pe=re?d:m.bands?i(oe,m.bands,w):null;pe?o.setAttribute("data-tone",pe):o.removeAttribute("data-tone"),C.textContent=R(m.footer)?String(m.footer(oe,w)):m.footer??"",C.hidden=!C.textContent,o.setAttribute("aria-label",[m.title,E.textContent,re?P.textContent:"",ae?A.textContent:"",te.change===null?"":M.textContent,te.change===null?"":Q(ce),C.textContent].filter(Boolean).join(", "))}if(w&&R(w.on)&&m.live!==!1)for(const ne of["rows:changed","filter:changed","selection:changed","model:changed"]){const re=oe=>{ne==="model:changed"&&!U(oe)||J()};w.on(ne,re),I.push(()=>R(w.off)&&w.off(ne,re))}return J(),{element:()=>o,value:()=>K,refresh:J,destroy(){D=!0;for(const ne of I)try{ne()}catch{}I.length=0,o.remove()}}}function f(p){return $(p)&&"data"in p?p.data:p}function h(p,m){if(!$(p))return;if(!m.includes("."))return p[m];let w=p;for(const v of m.split(".")){if(!$(w))return;w=w[v]}return w}function g(p,m){if(p&&typeof p=="object")return p;if(typeof p!="string")return null;const w=m&&m.element&&m.element.ownerDocument||(typeof document>"u"?null:document);return w?w.querySelector(p):null}function b(){return{element:()=>null,value:()=>null,refresh(){},destroy(){}}}}),ke("packages/dom/src/kpistrip.js",function(e,V){"use strict";Object.defineProperty(e,"KpiStrip",{enumerable:!0,get:function(){return Z}});const R=V("packages/core/src/internal/util.js").isObject,L=V("packages/dom/src/stat.js").createStat,W={band:"lat-kpi-strip"};class Z{#e;#t;#n;#r=null;#o=[];constructor({grid:U,document:z,kpis:F}){this.#e=U,this.#t=z,this.#n=Array.isArray(F)?F.filter(R):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const z=this.#t.createElement("div");z.className=`lattice ${W.band}`,z.setAttribute("role","group"),z.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=z;for(const F of this.#n){const k=L({...F,grid:this.#e,container:z});this.#o.push(k)}}destroy(){for(const U of this.#o)try{U.destroy()}catch{}this.#o.length=0,this.#r&&(this.#r.remove(),this.#r=null)}}}),ke("packages/dom/src/createGrid.js",function(e,V){"use strict";Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return St}}),Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return Ot}});const R=V("packages/core/src/index.js").createHeadlessGrid,L=V("packages/core/src/defaults.js").applyDefaults,Z=V("packages/core/src/export/download.js").downloadBlob,H=V("packages/core/src/internal/util.js"),U=H.fail,z=H.isFunction,F=H.warnOnce,O=V("packages/dom/src/localviews.js").createLocalViewStorage,d=V("packages/dom/src/renderer/index.js").DomRenderer,r=V("packages/dom/src/cell/index.js").createCellLayer,t=V("packages/dom/src/cell/icons.js"),n=t.icon,i=t.iconNames,l=V("packages/dom/src/editors/index.js").editors,f=V("packages/dom/src/filters/index.js").filters,h=V("packages/dom/src/ui/index.js"),g=h.StatusBar,b=h.TooltipManager,p=h.Pagination,m=h.GroupByZone,v=V("packages/dom/src/ui/celltooltip.js").CellTooltips,o=V("packages/dom/src/filtermenu.js").FilterMenu,E=V("packages/dom/src/columnmenu.js").ColumnMenu,M=V("packages/dom/src/shortcutshelp.js").ShortcutsHelp,P=V("packages/dom/src/rowreorder.js").RowReorder,K=V("packages/dom/src/alignedgrids.js").AlignedGrids,D=V("packages/dom/src/columntagbar.js").ColumnTagBar,T=V("packages/dom/src/anomalychip.js").AnomalyChip,q=V("packages/dom/src/rowform.js").RowForm,X=V("packages/dom/src/toolpanelmount.js"),Q=X.ToolPanelDock,J=X.panelHost,re=V("packages/dom/src/celledit.js").CellEditController,ie=V("packages/dom/src/editbar.js").EditBar,ce=V("packages/dom/src/rangeselect.js").RangeController,ae=V("packages/core/src/model/selection.js").resolveSelectionConfig,he=V("packages/dom/src/importer.js").ImportController,Oe=V("packages/dom/src/historybar.js").HistoryBar,Ze=V("packages/dom/src/diffpaint.js").DiffPainter,xe=V("packages/dom/src/detailhost.js").DetailHost,_e=V("packages/dom/src/highlightpaint.js").HighlightPainter,et=V("packages/dom/src/findpaint.js").FindPainter,Ae=V("packages/dom/src/findbar.js").FindBar,Ge=V("packages/dom/src/redactpaint.js").RedactionPainter,ut=V("packages/dom/src/validationpaint.js").ValidationPainter,Ct=V("packages/dom/src/presentation.js").PresentationController,Lt=V("packages/dom/src/capture.js").captureElement,$t=V("packages/dom/src/annotate.js").AnnotationLayer,Jt=V("packages/dom/src/timelinebar.js").TimelineBar,de=V("packages/dom/src/commentpaint.js").CommentPainter,Te=V("packages/dom/src/presencepaint.js").PresencePainter,Ve=V("packages/dom/src/commentpanel.js").CommentPanel,ft=V("packages/dom/src/watermark.js").Watermark,we=V("packages/dom/src/maximise.js").Maximiser,je=V("packages/dom/src/promptbar.js").PromptBar,Ne=V("packages/dom/src/kpistrip.js").KpiStrip;function Re(Ee,nt,it){const mt=nt==="redo"?"toolbar.redo":"toolbar.undo";return!it||!it.label?Ee(mt):Ee(nt==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:it.label})}const Le=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],Fe=2e3;function Ye(Ee,nt,it){const mt=nt.annotate===!0?Xe(Ee):[];if(nt.actions===!1)return[];if(nt.actions===void 0&&nt.side!=="left")return mt;const It=Array.isArray(nt.actions)?nt.actions:Le,Rt=(kt,Vt)=>Ee.messages.t(kt,Vt),st={undo:{name:"undo",title:()=>Re(Rt,"undo",Ee.history.peek("undo")),icon:"undo",run:()=>Ee.history.undo(),enabled:()=>Ee.history.canUndo()},redo:{name:"redo",title:()=>Re(Rt,"redo",Ee.history.peek("redo")),icon:"redo",run:()=>Ee.history.redo(),enabled:()=>Ee.history.canRedo()},export:{name:"export",title:()=>Rt("toolbar.exportCsv"),icon:"download",run:()=>Ee.export.csv({download:!0,fileName:nt.exportName})},excel:{name:"excel",title:()=>Rt("toolbar.exportExcel"),icon:"spreadsheet",run:()=>Ee.export.excel({download:!0,fileName:nt.exportName})},clipboard:{name:"clipboard",title:()=>Rt("toolbar.clipboard"),icon:"copy",run:()=>Ee.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>Rt("toolbar.print"),icon:"print",run:()=>Ee.export.print()},pause:{name:"pause",title:()=>{if(!Ee.updates.paused)return Rt("toolbar.pause");const kt=Ee.updates.stats().pending;return kt?Rt("toolbar.applyHeld",{count:kt}):Rt("toolbar.resume")},icon:()=>Ee.updates.paused?"play":"pause",run:()=>Ee.updates.paused?Ee.updates.resume():Ee.updates.pause()},restore:{name:"restore",title:()=>Rt("toolbar.restoreView"),icon:"restore",run:()=>Ee.state.reset(),enabled:()=>Ee.state.modified()},maximise:{name:"maximise",title:()=>Rt(it&&it.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>it&&it.active()?"minimise":"maximise",run:()=>it.toggle()}};return it||delete st.maximise,It.map(kt=>kt==="-"?{name:"-",separator:!0}:typeof kt=="string"?st[kt]:!kt||typeof kt!="object"||!kt.name?null:{...kt,run:z(kt.run)?()=>kt.run({grid:Ee,keys:Ee.selection&&z(Ee.selection.keys)?Ee.selection.keys():[],cells:Ee.selection&&z(Ee.selection.cells)?Ee.selection.cells():[]}):void 0}).filter(Boolean).concat(mt)}function Xe(Ee){const nt=mt=>Ee.messages.t(mt),it={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight"};return["pen","arrow","rect","highlight"].map(mt=>({name:mt,title:()=>nt(`toolbar.annotate.${mt}`),icon:it[mt],run:()=>Ee.annotate?.use(mt),active:()=>Ee.annotate?.tool===mt,annotation:!0}))}const pt=["pen","arrow","rect","highlight"];function gt(Ee){return{rowCount:()=>{if(z(Ee.rows.matchCount))return Ee.rows.matchCount();const nt=Ee.pagination&&z(Ee.pagination.get)?Ee.pagination.get():null;return nt&&Number.isFinite(nt.total)?nt.total:Ee.rows.count()},totalRowCount:()=>z(Ee.rows.totalCount)?Ee.rows.totalCount():Ee.rows.count(),selectedCount:()=>{const nt=Ee.selection&&Ee.selection.keys?Ee.selection.keys():null;return nt?nt.length:0},rangeValues:()=>{const nt=Ee.selection;return!nt||!z(nt.cells)?[]:nt.cells().map(({key:it,colId:mt})=>Ee.rows.value(it,mt))},hiddenUnresolved:()=>z(Ee.comments&&Ee.comments.hiddenUnresolved)?Ee.comments.hiddenUnresolved():0,progress:()=>z(Ee.source&&Ee.source.progress)?Ee.source.progress():null,updateStats:()=>Ee.updates?Ee.updates.stats():null}}function bt(Ee,nt){for(const[it,mt]of Object.entries(l||{}))Ee.register("editor",it,mt);for(const[it,mt]of Object.entries(f||{}))Ee.register("filter",it,mt);for(const[it,mt]of Object.entries(nt.components||{}))Ee.register("component",it,mt);for(const[it,mt]of Object.entries(nt.pipes||{}))Ee.register("pipe",it,mt);for(const[it,mt]of Object.entries(nt.totalFns||{}))Ee.register("totalFn",it,mt)}function ht(Ee,nt,it,mt,It,Rt){const st=[],kt=nt.viewport;let Vt=null;if(it.maximise!==!1&&(Vt=new we({element:Rt,document:mt,onChange:()=>nt.invalidate("all"),captureScroll:()=>nt.scrollState(),restoreScroll:Qe=>nt.restoreScroll(Qe)}),Ee.maximise=Vt,st.push(()=>Vt.destroy())),it.statusBar){const Qe=typeof it.statusBar=="object"?it.statusBar:{},at=new g;at.init({document:mt,host:gt(Ee),panels:Qe.panels,registry:Qe.registry,locale:Ee.get("locale"),messages:Ee.messages}),kt.statusBar.appendChild(at.element());const jt=()=>{const nn=kt.statusBar.offsetHeight||kt.statusBar.getBoundingClientRect?.().height||0;kt.root.style.setProperty("--lattice-status-height",`${Math.ceil(nn)}px`)},Ft=()=>{at.refresh(),jt()},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=>Ee.on(nn,Ft));Ft(),jt(),st.push(()=>{for(const nn of Ht)nn();kt.root.style.removeProperty("--lattice-status-height"),at.destroy?.()})}const Kt=ae(it.selection);if(Kt.ranges){const Qe=new ce({grid:Ee,renderer:nt,document:mt});Qe.mount(),Ee.ranges=Qe,st.push(()=>Qe.destroy())}if(it.import){const Qe=new he({grid:Ee,renderer:nt,document:mt,settings:typeof it.import=="object"?it.import:{}});Ee.importer=Qe,st.push(()=>Qe.destroy())}if(it.historyBar){const Qe=typeof it.historyBar=="object"?it.historyBar.element:null,at=new Oe;at.init({document:mt,host:{undo:()=>Ee.history.undo(),redo:()=>Ee.history.redo(),canUndo:()=>Ee.history.canUndo(),canRedo:()=>Ee.history.canRedo(),peek:Ft=>Ee.history.peek(Ft),list:()=>Ee.history.list()},props:typeof it.historyBar=="object"?it.historyBar:{}}),(Qe||kt.root).appendChild(at.element());const jt=[Ee.on("history:changed",()=>at.refresh())];Ee.historyBar=at,st.push(()=>{for(const Ft of jt)Ft();at.destroy()})}if(it.diff){const Qe=new Ze({grid:Ee,renderer:nt});Qe.mount(),Ee.diffPainter=Qe,st.push(()=>Qe.destroy())}if(it.ai&&z(it.ai.ask)){const Qe=new je;Qe.init({document:mt,grid:Ee,ask:it.ai.ask,schemaOptions:it.ai.schemaOptions,context:it.ai.context,placeholder:it.ai.placeholder});const at=it.ai.element||kt.root;at===kt.root?at.insertBefore(Qe.element(),at.firstChild):at.appendChild(Qe.element()),Ee.promptBar=Qe,st.push(()=>Qe.destroy())}if(it.groupPanel){const Qe=typeof it.groupPanel=="object"?it.groupPanel:{},at=new m;at.init({document:mt,grid:Ee,host:J(Ee,mt,(jt,Ft)=>nt.announce?.(jt,Ft)),props:{header:kt.header,hint:Qe.hint}}),kt.root.insertBefore(at.element(),kt.header),Ee.groupPanel=at;for(const jt of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])z(Ee.on)&&st.push(Ee.on(jt,()=>at.refresh()));st.push(()=>at.destroy())}if(it.kpis){const Qe=new Ne({grid:Ee,document:mt,kpis:it.kpis});Qe.active&&(Qe.mount(),kt.root.insertBefore(Qe.element(),kt.header),Ee.kpiStrip=Qe,st.push(()=>Qe.destroy()))}if(it.toolPanel){const Qe=typeof it.toolPanel=="object"?it.toolPanel:{},at=new Q({grid:Ee,document:mt,root:kt.root,panels:Qe.panels,openPanel:Qe.openPanel,side:Qe.side,icons:Qe.icons,actions:Ye(Ee,Qe,Vt),announce:(jt,Ft)=>nt.announce?.(jt,Ft)});at.mount(),Ee.toolPanel=at,st.push(()=>at.destroy()),Qe.annotate===void 0&&(st.push(Ee.on("presentation:started",()=>{for(const jt of Xe(Ee))at.addAction(jt)})),st.push(Ee.on("presentation:ended",()=>{for(const jt of pt)at.removeAction(jt)})))}if(it.pagination){const Qe=typeof it.pagination=="object"?it.pagination:{},at=new p;at.init({document:mt,pageSize:Qe.pageSize,pageSizes:Qe.pageSizes,page:Qe.page,total:Qe.total,locale:Ee.get("locale"),messages:Ee.messages,onChange:({page:Ht,pageSize:nn})=>Ee.pagination.set({page:Ht,pageSize:nn})});const jt=()=>{const Ht=Ee.pagination.get();at.total=Ht.total,at.counting=Ht.counting===!0,at.page=Ht.page,at.paint()};Ee.pagination.set({pageSize:at.pageSize}),jt();const Ft=["rows:changed","filter:changed","model:changed"].map(Ht=>Ee.on(Ht,jt));kt.statusBar.appendChild(at.element()),st.push(()=>{for(const Ht of Ft)Ht();at.destroy?.()})}if(it.edit!==!1)if(it.editBar){const Qe=new ie({grid:Ee,document:mt,root:kt.root});Qe.mount(),Ee.editBar=Qe,st.push(()=>Qe.destroy())}else{const Qe=new re({grid:Ee,document:mt,renderer:nt,registry:It,cellLayer:nt.cellLayer});Qe.mount(),st.push(()=>Qe.destroy())}const an=new o({grid:Ee,document:mt,layer:kt.overlays,registry:It});an.mount(),st.push(()=>an.destroy());const ln=new E({grid:Ee,document:mt,host:kt.root,cellMenu:it.contextMenu!==!1,headerMenu:it.columnMenu!==!1,items:z(it.contextMenu)?it.contextMenu:void 0,headerItems:z(it.columnMenu)?it.columnMenu:void 0});if(ln.mount(),st.push(()=>ln.destroy()),Array.isArray(it.alignedGrids)&&it.alignedGrids.length){const Qe=new K;Qe.add(Ee);for(const at of it.alignedGrids)at&&at!==Ee&&Qe.add(at);st.push(()=>Qe.destroy())}const Dt=new q({grid:Ee,renderer:nt,document:mt,registry:It});Dt.active&&(Dt.mount(),st.push(()=>Dt.destroy())),Object.defineProperty(Ee,"form",{configurable:!0,value:Object.freeze({open(Qe){return Dt.active?Dt.openRow(Qe):!1},close(){Dt.active&&Dt.close()},save(){return Dt.active?Dt.save():!1},isOpen(){return Dt.active?Dt.open:!1}})}),st.push(()=>{delete Ee.form}),Object.defineProperty(Ee,"icons",{configurable:!0,value:Object.freeze({get(Qe){const at=n(Qe);return at?{viewBox:at.viewBox,paths:at.paths.slice(),paint:at.paint==="stroke"?"stroke":"fill"}:null},names(){return i()}})}),st.push(()=>{delete Ee.icons});const un=new D({grid:Ee,renderer:nt,document:mt});un.active&&(un.mount(),st.push(()=>un.destroy()));const cn=new T({grid:Ee,renderer:nt,document:mt});cn.active&&(cn.mount(),st.push(()=>cn.destroy()));const rn=new P({grid:Ee,renderer:nt,document:mt});if(rn.active){rn.mount(),rn.paint();const Qe=Ee.on("render:done",()=>rn.paint());st.push(()=>{Qe(),rn.destroy()})}if(it.shortcuts!==!1){const Qe=new M({grid:Ee,renderer:nt});Qe.mount(),st.push(()=>Qe.destroy())}const wt=new _e({grid:Ee,renderer:nt,window:mt.defaultView||void 0});wt.mount(),st.push(()=>wt.destroy());const Et=new et({grid:Ee,renderer:nt,window:mt.defaultView||void 0});if(Et.mount(),st.push(()=>Et.destroy()),it.find!==!1){const Qe=new Ae({grid:Ee,renderer:nt,document:mt,settings:it.find});Qe.mount(),st.push(()=>Qe.destroy())}const Mt=new Ge({grid:Ee,renderer:nt});Mt.mount(),st.push(()=>Mt.destroy());const Ut=new ut({grid:Ee,renderer:nt});Ut.mount(),st.push(()=>Ut.destroy());const Xt=new Ct({grid:Ee,renderer:nt,maximiser:Vt});Xt.mount(),st.push(()=>Xt.destroy());const Wt=new Jt({grid:Ee,renderer:nt});Wt.mount(),st.push(()=>Wt.destroy()),it.environment||Ee.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 _t=null;for(const[Qe,at]of[["filter:changed","filter"],["sort:changed","sort"],["rows:changed","data"],["column:resized","resize"],["column:moved","columns"],["column:visible","columns"]])st.push(Ee.on(Qe,()=>{_t=at}));st.push(Ee.on("render:done",Qe=>{Ee.diagnostics.render(_t||Qe.cause,Qe.phases),_t=null}));const en=new Te({grid:Ee,renderer:nt});if(en.mount(),st.push(()=>en.destroy()),st.push(Ee.on("presence:lockRefused",Qe=>en.announceRefusal(Qe.peer))),Ee.presence&&Ee.presence.enabled){for(const jt of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])st.push(Ee.on(jt,()=>Ee.presence.publish()));let Qe="";st.push(Ee.on("render:done",()=>{const jt=nt.focusState&&nt.focusState(),Ft=jt?`${jt.rowKey}${jt.colId}`:"";Ft!==Qe&&(Qe=Ft,Ee.presence.publish())}));const at=Rt.ownerDocument;if(at&&z(at.addEventListener)){const jt=()=>Ee.presence.setPaused(at.visibilityState==="hidden");at.addEventListener("visibilitychange",jt),jt(),st.push(()=>at.removeEventListener("visibilitychange",jt))}}const Yt=new de({grid:Ee,renderer:nt});Yt.mount(),st.push(()=>Yt.destroy());const dn=new Ve({grid:Ee,renderer:nt});dn.mount(),st.push(()=>dn.destroy()),st.push(Ee.on("facet:computed",()=>nt.refreshHeader?.())),Kt&&Kt.headerCheckbox===!0&&st.push(Ee.on("selection:changed",()=>nt.refreshHeader?.())),st.push(Ee.on("facet:expanded",()=>nt.invalidate("columns"))),st.push(Ee.on("model:changed",()=>nt.invalidate("rows")));const Gt=(Qe,at)=>nt.announce?.(Qe,at),fn=Ee.messages,zt=(Qe,at)=>fn.t(Qe,at),pn=Qe=>zt("count.rows",{count:Qe});st.push(Ee.on("sort:changed",()=>{const Qe=Ee.sort.get();if(!Qe.length){Gt(zt("a11y.sort.cleared"));return}const at=Qe.map(jt=>{const Ft=Ee.columns.get(jt.col);return zt("a11y.sort.column",{column:Ft&&Ft.title||jt.col,direction:zt(jt.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});Gt(zt("a11y.sort.by",{columns:fn.list(at)}))})),st.push(Ee.on("filter:changed",()=>{const Qe=Ee.rows.matchCount?Ee.rows.matchCount():Ee.rows.count(),at=Ee.rows.totalCount?Ee.rows.totalCount():Qe;Gt(Qe===at?zt("a11y.filter.cleared",{rows:pn(at)}):zt("a11y.filter.applied",{shown:pn(Qe),total:pn(at)}))})),st.push(Ee.on("selection:changed",()=>{const Qe=Ee.selection.keys().length;Gt(Qe===0?zt("a11y.selection.cleared"):zt("a11y.selection.count",{count:Qe}))})),st.push(Ee.on("group:toggled",Qe=>{const at=Ee.rows.byKey?Ee.rows.byKey(Qe.key):null,jt=(at&&(at.groupLabel??at.groupValue))??Qe.key;Gt(zt(Qe.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:jt,rows:pn(Ee.rows.count())}))})),st.push(Ee.on("column:grouped",Qe=>{const at=Array.isArray(Qe.columns)?Qe.columns:[];if(!at.length){Gt(zt("a11y.group.cleared"));return}const jt=at.map(Ft=>{const Ht=Ee.columns.get(Ft);return Ht&&Ht.title||Ft});Gt(zt("a11y.group.by",{columns:fn.list(jt)}))})),st.push(Ee.on("page:changed",Qe=>{const at=Number(Qe.size)||0,jt=Number(Qe.total)||0,Ft=at>0?Math.max(1,Math.ceil(jt/at)):1;Gt(zt("a11y.page.position",{page:(Number(Qe.page)||0)+1,pages:Ft}))}));let tn={added:0,removed:0},qt=null;const En=()=>{qt=null;const Qe=[];tn.added&&Qe.push(zt("count.rowsAdded",{count:tn.added})),tn.removed&&Qe.push(zt("count.rowsRemoved",{count:tn.removed})),tn={added:0,removed:0},Qe.length&&Gt(fn.list(Qe))};st.push(Ee.on("rows:changed",Qe=>{if(!Qe||typeof Qe.added!="number")return;const at=Number(Qe.added)||0,jt=Number(Qe.removed)||0;!at&&!jt||(tn.added+=at,tn.removed+=jt,qt||(qt=setTimeout(En,Fe)))})),st.push(()=>{qt&&clearTimeout(qt)}),st.push(Ee.on("rows:paused",()=>{qt&&(clearTimeout(qt),qt=null),tn={added:0,removed:0},Gt(zt("a11y.updates.paused"),{repeat:!0})})),st.push(Ee.on("rows:resumed",()=>Gt(zt("a11y.updates.resumed"),{repeat:!0})));let hn={count:0,first:null},mn=null;const Sn=()=>{mn=null;const{count:Qe,first:at}=hn;if(hn={count:0,first:null},!Qe||!at)return;const jt=Ee.columns.get(at.colId),Ft=jt&&jt.title||at.colId,Ht=at.reason?zt("a11y.edit.reason",{reason:at.reason}):"";if(Qe===1){const nn=at.restored===void 0||at.restored===null||at.restored===""?zt("value.empty"):String(at.restored);Gt(zt("a11y.edit.refusedOne",{column:Ft,value:nn,reason:Ht}),{repeat:!0});return}Gt(zt("a11y.edit.refusedMany",{count:Qe,reason:Ht}),{repeat:!0})};st.push(Ee.on("cell:reverted",Qe=>{!Qe||!Qe.applied||(hn.count+=1,hn.first||(hn.first=Qe),mn||(mn=setTimeout(Sn,150)))})),st.push(()=>{mn&&clearTimeout(mn)}),st.push(Ee.on("history:applied",Qe=>{const at=!!(Qe&&Qe.direction==="redo"),jt=Qe&&Qe.step&&Qe.step.label;Gt(jt?zt(at?"a11y.history.redo":"a11y.history.undo",{label:jt}):zt(at?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const gn=new $t({grid:Ee,renderer:nt,seed:it.state&&Array.isArray(it.state.annotations)?it.state.annotations:null});gn.mount(),st.push(()=>gn.destroy()),Ee.annotate=gn,Ee.capture=async(Qe={})=>{const{blob:at,width:jt,height:Ft}=await Lt(nt.viewport.root,Qe);return(Qe.download===!0||Qe.download!==!1&&Qe.fileName)&&Z(at,Qe.fileName||`${Ee.get("exportName")||"grid"}.png`),Ee.emit("presentation:captured",{width:jt,height:Ft,bytes:at.size,mimeType:at.type,fileName:Qe.fileName||null},"api"),at};const On=new ft({grid:Ee,document:mt,element:kt.overlays,window:mt.defaultView||void 0});On.mount(),st.push(()=>On.destroy());const Tn=new b({grid:Ee,document:mt,element:kt.overlays});Tn.mount?.(),st.push(()=>Tn.destroy?.());const jn=new v({grid:Ee,host:Ee.rendererHost(),viewport:kt,document:mt});return jn.mount(),st.push(()=>jn.destroy()),st}function St(Ee){const nt=[],it=mt=>{if(mt&&(mt.__lattice&&nt.push(mt),mt.children))for(const It of mt.children)it(It)};return it(Ee),nt}function Ot(Ee,nt={}){(!Ee||typeof Ee!="object"||!("appendChild"in Ee))&&U("createGrid needs a host element as its first argument."),nt=L(nt);const it=Ee.ownerDocument||(typeof document<"u"?document:null);it||U("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const mt=it.documentElement&&it.documentElement.lang,It=!nt.licence&&z(it.querySelector)?it.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,Rt={...nt};if(!nt.locale&&mt&&(Rt.locale=mt),It&&(Rt.licence=It),nt.views&&nt.views.local)if(nt.views.storage)F("views:local:ignored","[lattice] views.local is ignored because views.storage was also supplied; the explicit adapter wins.");else{const Dt=nt.views.local===!0?{}:nt.views.local;Rt.views={...nt.views,storage:O(Dt)}}const st=R(Rt),kt=st.rendererHost();kt.document=it,bt(kt.registry,nt),kt.cellLayer=r(kt),kt.detailHost=new xe({grid:st,document:Ee.ownerDocument||globalThis.document,createGrid:(Dt,un)=>Ot(Dt,un)});const Vt=new d(Ee,kt),Kt=st.on("detail:toggled",()=>{kt.detailHost.syncTarget(),kt.detailHost.prune()}),sn=st.on("config:changed",Dt=>{Dt&&Dt.key==="detail"&&kt.detailHost.reconfigure()});st.on("destroy",()=>{Kt(),sn(),kt.detailHost.destroy()}),kt.detailHost.syncTarget(),st.attachRenderer(Vt),Vt.mount();const an=ht(st,Vt,nt,it,kt.registry,Ee),ln=st.destroy.bind(st);return st.destroy=()=>{for(const Dt of an)try{Dt()}catch{}Ee.__lattice===st&&(Ee.__lattice=null),ln()},Ee.__lattice=st,st}}),ke("packages/dom/src/hydrate.js",function(e,V){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return F}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/dom/src/createGrid.js").createGrid;function W(k,O){for(const y of k.children)if(y.tagName===O.toUpperCase())return y;return null}function Z(k,O){const y=[];for(const d of k.children)d.tagName===O.toUpperCase()&&y.push(d);return y}function H(k,O){const y=R(k.getAttribute)?k.getAttribute("data-field"):null;return y||String(k.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${O}`}function U(k){const O=k.trim();if(O==="")return null;if(O==="true"||O==="false")return O==="true";const y=Number(O);return Number.isFinite(y)&&O!==""?y:O}function z(k){const O=W(k,"thead"),y=W(O||k,"tr"),c=(y?Z(y,"th").length?Z(y,"th"):Z(y,"td"):[]).map((i,s)=>{const l=H(i,s);return{id:l,field:l,title:String(i.textContent||"").trim()||l}}),r=W(k,"tbody"),n=(r?Z(r,"tr"):Z(k,"tr").filter(i=>i!==y)).map((i,s)=>{const l=Z(i,"td"),f={__row:(R(i.getAttribute)?i.getAttribute("data-id"):null)||`row${s}`};return c.forEach((h,g)=>{f[h.field]=l[g]?U(String(l[g].textContent||"")):null}),f});return{columns:c,rows:n}}function F(k,O={}){const{columns:y,rows:d}=z(k),c=k.ownerDocument.createElement("div");return k.parentNode.insertBefore(c,k),k.parentNode.removeChild(k),L(c,{rowKey:"__row",columns:y,rows:d,...O,columns:O.columns!==void 0?O.columns:y,rows:O.rows!==void 0?O.rows:d})}}),ke("packages/dom/src/autoinit.js",function(e,V){"use strict";Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return F}});const R=V("packages/core/src/internal/util.js").isFunction,L=V("packages/dom/src/createGrid.js").createGrid,Z=V("packages/dom/src/hydrate.js").hydrateTable;function H(k,O){const y=[];return R(k.hasAttribute)&&k.hasAttribute(O)&&y.push(k),R(k.querySelectorAll)&&y.push(...k.querySelectorAll(`[${O}]`)),y}function U(k){const O=k.parentNode;if(!O||!O.children)return null;const y=[...O.children],d=y.indexOf(k),c=[y[d+1],y[d-1]];for(const r of c)if(r&&r.tagName==="SCRIPT"&&R(r.getAttribute)&&r.hasAttribute("data-lattice-config"))return r;return null}function z(k){const O=U(k);if(!O)return{};try{return JSON.parse(O.textContent||"{}")}catch(y){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",y),{}}}function F(k){const O=k||(typeof document<"u"?document:null);if(!O)return[];const y=[];for(const d of H(O,"data-lattice-grid")){if(d.__lattice)continue;const c=z(d);y.push(d.tagName==="TABLE"?Z(d,c):L(d,c))}return y}}),ke("packages/dom/src/index.js",function(e,V){"use strict";Object.defineProperty(e,"LatticeGrid",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return M}});const _=V("packages/dom/src/createGrid.js"),R=_.createGrid,$=V("packages/dom/src/hydrate.js"),L=$.hydrateTable,W=V("packages/dom/src/autoinit.js"),Z=W.autoInit,H=V("packages/dom/src/localviews.js"),U=H.createLocalViewStorage,z=V("packages/core/src/index.js"),F=z.createHeadlessGrid,k=z.registerModules,O=z.setLicence,y=z.version,d=z.getVersion,c=z.serialiseState,r=z.restoreState,t=z.defaults;Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return _.createGrid}}),Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return _.gridElementsWithin}});const n=V("packages/dom/src/stat.js");Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return n.createStat}}),Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return n.deltaOf}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return n.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 H.createLocalViewStorage}}),Object.defineProperty(e,"DEFAULT_VIEWS_KEY",{enumerable:!0,get:function(){return H.DEFAULT_VIEWS_KEY}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return z.createHeadlessGrid}}),Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return z.defaults}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return z.version}}),Object.defineProperty(e,"getVersion",{enumerable:!0,get:function(){return z.getVersion}}),Object.defineProperty(e,"Grid",{enumerable:!0,get:function(){return z.Grid}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return z.EventBus}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return z.Registry}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return z.sharedRegistry}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return z.registerModules}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return z.parseLicence}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return z.verifyLicence}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return z.licenceInfo}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return z.watermark}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return z.setLicence}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return z.licenceState}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return z.isLocalHost}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return z.matchesDomain}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return z.LicenceHolder}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return z.ColumnModel}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return z.buildGraph}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return z.Lookup}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return z.ValuePipeline}}),Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return z.compileFormat}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return z.compileMask}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return z.specToOoxml}}),Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return z.EXTENDED_TYPES}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return z.createRadixType}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return z.RADIX_PRESETS}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return z.parseRadix}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return z.formatRadix}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return z.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return z.registerUnitSystem}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return z.defineUnit}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return z.UNIT_SYSTEMS}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return z.parseUnit}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return z.formatUnit}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return z.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return z.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return z.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return z.convertMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return z.rateFunction}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return z.MISSING_RATE}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return z.Messages}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return z.createMessages}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return z.auditCatalogue}}),Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return z.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return z.MESSAGE_KEYS}}),Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return z.DEFAULT_LOCALE}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return z.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return z.resolveLocale}}),Object.defineProperty(e,"LOCALES",{enumerable:!0,get:function(){return z.LOCALES}}),Object.defineProperty(e,"resolveCatalogue",{enumerable:!0,get:function(){return z.resolveCatalogue}}),Object.defineProperty(e,"EN_US",{enumerable:!0,get:function(){return z.EN_US}}),Object.defineProperty(e,"FR_FR",{enumerable:!0,get:function(){return z.FR_FR}}),Object.defineProperty(e,"FR_CA",{enumerable:!0,get:function(){return z.FR_CA}}),Object.defineProperty(e,"IT_IT",{enumerable:!0,get:function(){return z.IT_IT}}),Object.defineProperty(e,"ES_ES",{enumerable:!0,get:function(){return z.ES_ES}}),Object.defineProperty(e,"PT_BR",{enumerable:!0,get:function(){return z.PT_BR}}),Object.defineProperty(e,"DE_DE",{enumerable:!0,get:function(){return z.DE_DE}}),Object.defineProperty(e,"NL_NL",{enumerable:!0,get:function(){return z.NL_NL}}),Object.defineProperty(e,"SV_SE",{enumerable:!0,get:function(){return z.SV_SE}}),Object.defineProperty(e,"DA_DK",{enumerable:!0,get:function(){return z.DA_DK}}),Object.defineProperty(e,"NB_NO",{enumerable:!0,get:function(){return z.NB_NO}}),Object.defineProperty(e,"FI_FI",{enumerable:!0,get:function(){return z.FI_FI}}),Object.defineProperty(e,"PL_PL",{enumerable:!0,get:function(){return z.PL_PL}}),Object.defineProperty(e,"CS_CZ",{enumerable:!0,get:function(){return z.CS_CZ}}),Object.defineProperty(e,"HU_HU",{enumerable:!0,get:function(){return z.HU_HU}}),Object.defineProperty(e,"RO_RO",{enumerable:!0,get:function(){return z.RO_RO}}),Object.defineProperty(e,"UK_UA",{enumerable:!0,get:function(){return z.UK_UA}}),Object.defineProperty(e,"EL_GR",{enumerable:!0,get:function(){return z.EL_GR}}),Object.defineProperty(e,"JA_JP",{enumerable:!0,get:function(){return z.JA_JP}}),Object.defineProperty(e,"AR",{enumerable:!0,get:function(){return z.AR}}),Object.defineProperty(e,"AR_SA",{enumerable:!0,get:function(){return z.AR_SA}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return z.ColumnStore}}),Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return z.Bitset}}),Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return z.Dictionary}}),Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return z.MultiValue}}),Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return z.MaskPool}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return z.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return z.sortMulti}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return z.evaluateFilters}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return z.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return z.testValue}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return z.groupByColumns}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return z.total}}),Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return z.TOTAL_FNS}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return z.pivot}}),Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return z.Window}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return z.openWindow}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return z.WINDOW_KINDS}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return z.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return z.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return z.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return z.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return z.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return z.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return z.anomalyCondition}}),Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return z.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return z.forecast}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return z.evaluateFormula}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return z.parseFormula}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return z.referencesOf}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return z.looksLikeFormula}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return z.FormulaError}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return z.FUNCTIONS}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return z.compileRules}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return z.ingest}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return z.ingestSync}}),Object.defineProperty(e,"createSource",{enumerable:!0,get:function(){return z.createSource}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return z.createMemorySource}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return z.createPagedSource}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return z.createRemoteSource}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return z.createStreamSource}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return z.createUrlSource}}),Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return z.PROTOCOL}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return z.createPushdownSource}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return z.planQuery}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return z.splitFilters}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return z.applyResidual}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return z.capabilitiesOf}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return z.resolveMutate}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return z.NO_CAPABILITIES}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return z.odataAdapter}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return z.filtersToOData}}),Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return z.conditionToOData}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return z.restAdapter}}),Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return z.DEFAULT_PARAMS}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return z.dfqlAdapter}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return z.duckdbAdapter}}),Object.defineProperty(e,"filtersToSql",{enumerable:!0,get:function(){return z.filtersToSql}}),Object.defineProperty(e,"graphqlAdapter",{enumerable:!0,get:function(){return z.graphqlAdapter}}),Object.defineProperty(e,"RowModel",{enumerable:!0,get:function(){return z.RowModel}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return z.createRowKey}}),Object.defineProperty(e,"SelectionModel",{enumerable:!0,get:function(){return z.SelectionModel}}),Object.defineProperty(e,"RangeModel",{enumerable:!0,get:function(){return z.RangeModel}}),Object.defineProperty(e,"EditModel",{enumerable:!0,get:function(){return z.EditModel}}),Object.defineProperty(e,"ChangeModel",{enumerable:!0,get:function(){return z.ChangeModel}}),Object.defineProperty(e,"StateModel",{enumerable:!0,get:function(){return z.StateModel}}),Object.defineProperty(e,"STATE_VERSION",{enumerable:!0,get:function(){return z.STATE_VERSION}}),Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return z.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return z.restoreState}}),Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return z.VERSION}});const i=V("packages/dom/src/renderer/index.js");Object.defineProperty(e,"DomRenderer",{enumerable:!0,get:function(){return i.DomRenderer}});const s=V("packages/dom/src/filtermenu.js");Object.defineProperty(e,"FilterMenu",{enumerable:!0,get:function(){return s.FilterMenu}}),Object.defineProperty(e,"mergeColumnFilter",{enumerable:!0,get:function(){return s.mergeColumnFilter}}),Object.defineProperty(e,"branchFor",{enumerable:!0,get:function(){return s.branchFor}});const l=V("packages/dom/src/columnmenu.js");Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return l.ColumnMenu}}),Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return l.columnMenuItems}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return l.cellMenuItems}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return l.autoGroupMenuItems}});const u=V("packages/dom/src/alignedgrids.js");Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return u.AlignedGrids}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return u.alignGrids}}),Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return u.layoutState}});const f=V("packages/dom/src/toolpanelmount.js");Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return f.ToolPanelDock}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return f.panelHost}}),Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return f.mountPanel}});const h=V("packages/dom/src/celledit.js");Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return h.CellEditController}});const g=V("packages/dom/src/editbar.js");Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return g.EditBar}});const b=V("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=V("packages/dom/src/diffpaint.js");Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return p.DiffPainter}});const m=V("packages/dom/src/viewpicker.js");Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return m.ViewPicker}}),Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return m.VIEW_CLS}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return m.summariseDiff}});const w=V("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 v=V("packages/dom/src/cell/index.js");Object.defineProperty(e,"createCellLayer",{enumerable:!0,get:function(){return v.createCellLayer}}),Object.defineProperty(e,"compileTemplate",{enumerable:!0,get:function(){return v.compileTemplate}}),Object.defineProperty(e,"compileVariant",{enumerable:!0,get:function(){return v.compileVariant}}),Object.defineProperty(e,"checkVariant",{enumerable:!0,get:function(){return v.checkVariant}}),Object.defineProperty(e,"VariantRegistry",{enumerable:!0,get:function(){return v.VariantRegistry}}),Object.defineProperty(e,"BUILTIN_RENDERERS",{enumerable:!0,get:function(){return v.BUILTIN_RENDERERS}}),Object.defineProperty(e,"BUILTIN_VARIANTS",{enumerable:!0,get:function(){return v.BUILTIN_VARIANTS}}),Object.defineProperty(e,"BUILTIN_PIPES",{enumerable:!0,get:function(){return v.BUILTIN_PIPES}}),Object.defineProperty(e,"sanitiseHtml",{enumerable:!0,get:function(){return v.sanitiseHtml}});const a=V("packages/dom/src/editors/index.js");Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return a.editors}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return a.createEditor}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return a.editorFor}}),Object.defineProperty(e,"BaseEditor",{enumerable:!0,get:function(){return a.BaseEditor}});const o=V("packages/dom/src/filters/index.js");Object.defineProperty(e,"filters",{enumerable:!0,get:function(){return o.filters}}),Object.defineProperty(e,"createFilter",{enumerable:!0,get:function(){return o.createFilter}}),Object.defineProperty(e,"filterFor",{enumerable:!0,get:function(){return o.filterFor}}),Object.defineProperty(e,"parseExpression",{enumerable:!0,get:function(){return o.parseExpression}});const S=V("packages/dom/src/ui/index.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return S.StatusBar}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return S.ContextMenu}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return S.ToolPanel}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return S.TooltipManager}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return S.Pagination}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return S.OverlayLayer}});const E=V("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 A=Object.freeze({createGrid:R,createHeadlessGrid:F,defaults:t,registerModules:k,setLicence:O,version:y,autoInit:Z,hydrateTable:L,serialiseState:c,restoreState:r,createLocalViewStorage:U}),M=A});try{Bn("packages/worker/src/inline.js").setWorkerSource('(function(gt){"use strict";var et=Object.create(null),tt=Object.create(null);function Se(o,fe){et[o]=fe}function nt(o){var fe=tt[o];if(fe)return fe;var le=Object.create(null);tt[o]=le;var ae=et[o];if(!ae)throw new Error("[lattice] missing module: "+o);return ae(le,nt),le}Se("packages/core/src/internal/util.js",function(o,fe){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return z}}),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 g}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return d}}),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 b}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return se}});const le="1.71.3";async function ae(){return le}const Q="1.71.3",q=new Set,te=2e3;function _(T){if(q.add(T),q.size>te){const L=q.values().next().value;L!==void 0&&q.delete(L)}}const F=[],H=500;function ne(T,L,J){F.push({key:T,level:L,message:J.map(he=>typeof he=="string"?he:x(he)).join(" "),at:Date.now()}),F.length>H&&F.shift()}function x(T){if(T instanceof Error)return T.message;try{return JSON.stringify(T)}catch{return String(T)}}function ce(){return F.map(T=>({...T}))}function ie(T,...L){q.has(T)||(_(T),ne(T,"warn",L),console.warn("[lattice]",...L))}function G(T,...L){q.has(T)||(_(T),ne(T,"info",L),console.info("[lattice]",...L))}function D(){q.clear(),F.length=0}function Y(T,L){const J=new Error(`[lattice] ${T}`);throw L!==void 0&&(J.cause=L),J}function ee(T,L){T||Y(L)}const z=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function M(T){return T!==null&&typeof T=="object"&&!Array.isArray(T)}function i(T){return typeof T=="function"}function s(T){return T==null}function u(T){return T==null||T===""}function f(T){return typeof T!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(T))?!0:!!(T.prototype&&Object.getOwnPropertyNames(T.prototype).length>1)}const c=new Map;function t(T){let L=c.get(T);if(L)return L;if(!T.includes("."))L=J=>J?.[T];else{const J=T.split("."),he=J.length;L=ye=>{let Me=ye;for(let Pe=0;Pe<he;Pe++){if(Me==null)return;Me=Me[J[Pe]]}return Me}}return c.set(T,L),L}const a=new Map;function g(T){let L=a.get(T);if(L)return L;if(!T.includes("."))L=(J,he)=>{J!=null&&(J[T]=he)};else{const J=T.split("."),he=J.length-1;L=(ye,Me)=>{let Pe=ye;for(let Ne=0;Ne<he;Ne++){if(Pe==null)return;const je=J[Ne];Pe[je]==null&&(Pe[je]={}),Pe=Pe[je]}Pe!=null&&(Pe[J[he]]=Me)}}return a.set(T,L),L}function e(T,L){return t(L)(T)}function m(T,L,J){g(L)(T,J)}function d(T){return T?(T.includes(".")?T.slice(T.lastIndexOf(".")+1):T).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(/^./,J=>J.toUpperCase()):""}const r={"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#39;"};function n(T){const L=T==null?"":String(T);return/[&<>"\']/.test(L)?L.replace(/[&<>"\']/g,J=>r[J]):L}function l(T){return String(T).replace(/\\w\\S*/g,L=>L[0].toUpperCase()+L.slice(1).toLowerCase())}function b(T,L,J){if(T!==void 0)return T===!0?{enabled:!0,...J}:T===!1?{enabled:!1}:M(T)?T:{[L]:T,enabled:!0}}function E(T){return T==null?[]:Array.isArray(T)?T:[T]}const S=Object.freeze(new Set(["__proto__","constructor","prototype"]));function V(T,L){if(!M(T))return M(L)?{...L}:L;if(!M(L))return L===void 0?T:L;const J={...T};for(const he of Object.keys(L)){if(S.has(he))continue;const ye=L[he];ye!==void 0&&(J[he]=M(ye)&&M(J[he])?V(J[he],ye):ye)}return J}function U(T,L){if(!M(T)||!M(L)||T===L)return L;const J=Object.create(Object.getPrototypeOf(T));return Object.assign(J,T,L),J}class I{#t;#e=new Map;#n;constructor(L=256,J=null){this.#t=L,this.#n=J}get size(){return this.#e.size}get max(){return this.#t}set max(L){this.#t=L,this.#r()}has(L){return this.#e.has(L)}get(L){const J=this.#e;if(!J.has(L))return;const he=J.get(L);return J.delete(L),J.set(L,he),he}peek(L){return this.#e.get(L)}set(L,J){const he=this.#e;return he.has(L)&&he.delete(L),he.set(L,J),this.#r(),J}delete(L){const J=this.#e.get(L);return this.#e.delete(L)&&this.#n&&this.#n(J,L),J}clear(){if(this.#n)for(const[L,J]of this.#e)this.#n(J,L);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const L=this.#e;for(;L.size>this.#t;){const J=L.keys().next().value,he=L.get(J);L.delete(J),this.#n&&this.#n(he,J)}}}const X=new Map;function C(T,L){const J=`${T||""}|${L?JSON.stringify(L):""}`;let he=X.get(J);return he||(he=new Intl.Collator(T||void 0,{numeric:!0,sensitivity:"variant",...L}),X.set(J,he)),he}function R(T,L){if(T===L)return 0;if(T==null)return 1;if(L==null)return-1;if(typeof T=="number"&&typeof L=="number")return Number.isNaN(T)?Number.isNaN(L)?0:1:Number.isNaN(L)||T<L?-1:T>L?1:0;const J=String(T),he=String(L);return J<he?-1:J>he?1:0}function h(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const O=typeof requestAnimationFrame=="function";function w(T){return O?requestAnimationFrame(T):setTimeout(()=>T(h()),16)}function P(T){T!=null&&(O?cancelAnimationFrame(T):clearTimeout(T))}function v(T){let L=null,J=null;const he=()=>{L=null;const Me=J;J=null,T(...Me||[])},ye=(...Me)=>{J=Me,L===null&&(L=w(he))};return ye.cancel=()=>{P(L),L=null,J=null},ye.flush=()=>{L!==null&&(P(L),he())},ye}function K(T,L){let J=null,he=null;const ye=()=>{if(J=null,he===null)return;const Ne=he;he=null,T(...Ne),Me()},Me=()=>{J=setTimeout(ye,L),typeof J?.unref=="function"&&J.unref()},Pe=(...Ne)=>{J===null?(T(...Ne),Me()):(he=Ne,clearTimeout(J),Me())};return Pe.flush=()=>{if(J!==null&&clearTimeout(J),J=null,he===null)return;const Ne=he;he=null,T(...Ne)},Pe.cancel=()=>{J!==null&&clearTimeout(J),J=null,he=null},Pe.pending=()=>J!==null||he!==null,Pe}function Z(T,L=50){return typeof requestIdleCallback=="function"?requestIdleCallback(T,{timeout:L}):setTimeout(()=>T({timeRemaining:()=>0,didTimeout:!0}),1)}let oe=0;function se(T="l"){return`${T}${(++oe).toString(36)}`}}),Se("packages/worker/src/transport.js",function(o,fe){"use strict";Object.defineProperty(o,"PROTOCOL",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"OPS",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"ERRORS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"packHandle",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"packHandles",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"TransportedDictionary",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const le=fe("packages/core/src/internal/util.js"),ae=le.collator,Q=le.isFunction,q=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"}),_=Object.freeze({READY:"ready",CANCEL:"cancel",PING:"ping"}),F=Object.freeze({NO_COMPUTE:"E_NO_COMPUTE",NO_KERNEL:"E_NO_KERNEL",ABORTED:"E_ABORTED",KERNEL:"E_KERNEL",PROTOCOL:"E_PROTOCOL"});function H(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?ne(s.dict):null,offsets:s.offsets??null,version:s.version??0}}function ne(s){return Array.isArray(s)?s:Q(s.values)?s.values():[]}function x(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=H(s[f]);return u}class ce{#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 ie{#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 g=ae(u).compare,e=this.#t,m=Array.from(a).sort((r,n)=>{const l=e[r],b=e[n];return l===b?0:l==null?1:b==null?-1:g(String(l),String(b))}),d=new Uint32Array(t);for(let r=0;r<m.length;r++)d[m[r]]=r;return this.#r.set(f,{version:this.#n,ranks:d}),d}}function G(s){if(s==null)return null;const u=s.presence?new ce(s.presence,s.presenceBits||s.presence.length*8):null,f=s.dict?new ie(s.dict):null,c=s.values,t=s.offsets??null,a=s.kind,g=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 m=t[e],d=t[e+1],r=new Array(d-m);for(let n=m;n<d;n++)r[n-m]=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:g,version:s.version}}function D(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=G(s[f]);return u}function Y(){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 ee(s){if(!ArrayBuffer.isView(s))return!1;const u=s.buffer;return u?typeof SharedArrayBuffer>"u"||!(u instanceof SharedArrayBuffer):!1}function z(s,u=[]){const f=c=>{if(!ee(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,fe){"use strict";Object.defineProperty(o,"Bitset",{enumerable:!0,get:function(){return ae}});const le=8;class ae{static#t=new Uint8Array(256);static{for(let q=1;q<256;q++)ae.#t[q]=ae.#t[q>>1]+(q&1)}#e;#n;constructor(q=0){const te=Math.max(0,q|0);this.#n=te,this.#e=new Uint8Array(Math.ceil(te/le))}get size(){return this.#n}get words(){return this.#e}get bytes(){return this.#e?this.#e.byteLength:0}get(q){return q<0||q>=this.#n?0:this.#e[q>>3]>>(q&7)&1}set(q){return q>=0&&q<this.#n&&(this.#e[q>>3]|=1<<(q&7)),this}clear(q){return q>=0&&q<this.#n&&(this.#e[q>>3]&=~(1<<(q&7))),this}assign(q,te){return te?this.set(q):this.clear(q)}fill(q=!1){return this.#e.fill(q?255:0),q&&this.#r(),this}grow(q){const te=Math.max(0,q|0);if(te<=this.#n)return this;const _=Math.ceil(te/le);if(_>this.#e.length){const F=new Uint8Array(_);F.set(this.#e),this.#e=F}return this.#n=te,this}count(){const q=this.#e,te=ae.#t;let _=0;for(let F=0;F<q.length;F++)_+=te[q[F]];return _}and(q){const te=q instanceof ae?q.words:q,_=this.#e,F=Math.min(_.length,te.length);for(let H=0;H<F;H++)_[H]&=te[H];for(let H=F;H<_.length;H++)_[H]=0;return this}or(q){const te=q instanceof ae?q.words:q,_=this.#e,F=Math.min(_.length,te.length);for(let H=0;H<F;H++)_[H]|=te[H];return this}not(){const q=this.#e;for(let te=0;te<q.length;te++)q[te]=~q[te]&255;return this.#r(),this}clone(){const q=new ae(this.#n);return q.words.set(this.#e.subarray(0,q.words.length)),q}release(){this.#e=new Uint8Array(0),this.#n=0}#r(){const q=this.#n&7;if(q===0)return;const te=this.#n>>3;te<this.#e.length&&(this.#e[te]&=(1<<q)-1)}static from(q){const te=Array.isArray(q)?q:Array.from(q),_=new ae(te.length);for(let F=0;F<te.length;F++)te[F]&&_.set(F);return _}}}),Se("packages/core/src/store/dictionary.js",function(o,fe){"use strict";Object.defineProperty(o,"Dictionary",{enumerable:!0,get:function(){return q}});const le=fe("packages/core/src/internal/util.js"),ae=le.collator,Q=le.defaultCompare;class q{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(_=[]){this.#t=[];for(let F=0;F<_.length;F++){const H=_[F];this.#e.has(H)||(this.#e.set(H,this.#t.length),this.#t.push(H))}}get size(){return this.#t.length}get version(){return this.#n}get bytes(){let _=this.#t.length*8;for(let F=0;F<this.#t.length;F++){const H=this.#t[F];typeof H=="string"&&(_+=H.length*2),_+=16}return _}codeOf(_){const F=this.#e.get(_);if(F!==void 0)return F;const H=this.#t.length;return this.#t.push(_),this.#e.set(_,H),this.#n++,H}lookup(_){const F=this.#e.get(_);return F===void 0?-1:F}has(_){return this.#e.has(_)}valueOf(_){return this.#t[_]}values(){return this.#t}ranks(_){const F=_||"";if(this.#r&&this.#i===this.#n&&this.#s===F)return this.#r;const H=this.#t.length,ne=new Array(H);for(let G=0;G<H;G++)ne[G]=G;const x=ae(_).compare,ce=this.#t;ne.sort((G,D)=>this.#h(ce[G],ce[D],x));const ie=new Uint32Array(H);for(let G=0;G<H;G++)ie[ne[G]]=G;return this.#r=ie,this.#i=this.#n,this.#s=F,ie}#h(_,F,H){return typeof _=="string"&&typeof F=="string"?H(_,F):Q(_,F)}}}),Se("packages/core/src/store/multivalue.js",function(o,fe){"use strict";Object.defineProperty(o,"MultiValue",{enumerable:!0,get:function(){return le}});class le{#t;#e;#n=0;#r=0;constructor(Q={}){const q=Math.max(1,Q.rows??16),te=Math.max(1,Q.values??q);this.#t=new Int32Array(te),this.#e=new Uint32Array(q+1)}get values(){return this.#t}get offsets(){return this.#e}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#t.byteLength+this.#e.byteLength}count(Q){return Q<0||Q>=this.#n?0:this.#e[Q+1]-this.#e[Q]}at(Q){return Q<0||Q>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[Q],this.#e[Q+1])}has(Q,q){if(Q<0||Q>=this.#n)return!1;const te=this.#t,_=this.#e[Q+1];for(let F=this.#e[Q];F<_;F++)if(te[F]===q)return!0;return!1}hasAny(Q,q){for(let te=0;te<q.length;te++)if(this.has(Q,q[te]))return!0;return!1}hasAll(Q,q){for(let te=0;te<q.length;te++)if(!this.has(Q,q[te]))return!1;return!0}hasNone(Q,q){return!this.hasAny(Q,q)}push(Q){const q=this.#n,te=Q.length;this.#i(q+1),this.#s(this.#r+te);const _=this.#r;for(let F=0;F<te;F++)this.#t[_+F]=Q[F]|0;return this.#r+=te,this.#n=q+1,this.#e[q]=_,this.#e[q+1]=this.#r,q}write(Q,q){if(Q===this.#n){this.push(q);return}if(Q<0||Q>this.#n)return;const te=this.#e[Q],_=this.#e[Q+1],F=q.length;if(_-te===F){for(let H=0;H<F;H++)this.#t[te+H]=q[H]|0;return}this.#h(Q,q)}compact(Q,q,te){const _=this.#t,F=this.#e,H=this.#n,ne=new Int32Array(Math.max(1,this.#r)),x=new Uint32Array(q+1);let ce=0;for(let ie=0;ie<H;ie++){if(Q[ie]===te)continue;const G=F[ie],D=F[ie+1];x[Q[ie]]=ce;for(let Y=G;Y<D;Y++)ne[ce++]=_[Y];x[Q[ie]+1]=ce}this.#t=ne,this.#e=x,this.#n=q,this.#r=ce}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(Q){if(Q+1<=this.#e.length)return;let q=this.#e.length-1;for(;q<Q;)q=q*2||16;const te=new Uint32Array(q+1);te.set(this.#e),this.#e=te}#s(Q){if(Q<=this.#t.length)return;let q=this.#t.length;for(;q<Q;)q=q*2||16;const te=new Int32Array(q);te.set(this.#t),this.#t=te}#h(Q,q){const te=this.#t,_=this.#e,F=this.#n,H=q.length-(_[Q+1]-_[Q]),ne=new Int32Array(Math.max(1,this.#r+H)),x=new Uint32Array(_.length);let ce=0;for(let ie=0;ie<F;ie++){if(x[ie]=ce,ie===Q)for(let G=0;G<q.length;G++)ne[ce++]=q[G]|0;else for(let G=_[ie];G<_[ie+1];G++)ne[ce++]=te[G];x[ie+1]=ce}this.#t=ne,this.#e=x,this.#r=ce}}}),Se("packages/core/src/compute/handle.js",function(o,fe){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return M}});const le=fe("packages/core/src/internal/util.js"),ae=le.collator,Q=le.defaultCompare,q=le.warnOnce;function te(i){const s=new Uint32Array(i);for(let u=0;u<i;u++)s[u]=u;return s}function _(i,s){if(s&&typeof s.count=="number")return s.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const u=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):u?i.kind==="bitset"?typeof u.size=="number"?u.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(q(`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 F=new WeakMap;function H(i){const s=i.constructor;if(!s)return"unknown";const u=F.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 F.set(s,f),f}function ne(i){if(!i)return()=>0;const s=i instanceof Uint8Array?i:i.words;if(s instanceof Uint8Array){const u=i instanceof Uint8Array?"lsb":H(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 x(i){return!i||!i.presence?null:ne(i.presence)}function ce(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function ie(i,s){return i?typeof i.valueOf=="function"?i.valueOf(s):typeof i.values=="function"?i.values()[s]:null:null}function G(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,g=new Array(t-c);for(let e=c;e<t;e++)g[e-c]=a?ie(a,f[e]):f[e];return g}function D(i){if(!i)return()=>{};const s=i.values,u=x(i),f=i.kind;if(f==="dictionary"){const c=i.dict;return u?t=>u(t)?ie(c,s[t]):null:t=>ie(c,s[t])}if(f==="bitset"){const c=ne(s);return u?t=>u(t)?c(t)===1:null:t=>c(t)===1}if(f==="multi")return u?c=>u(c)?G(i,c):null:c=>G(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 Y(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 ee(i){const s=ae(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 Y(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),g=f instanceof Date?f.getTime():Number(f);return Y(a,g)}return Q(u,f)}}function z(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=ee(s),t=new Array(f);for(let g=0;g<f;g++)t[g]=g;t.sort((g,e)=>c(u[g],u[e])||g-e);const a=new Uint32Array(f);for(let g=0;g<f;g++)a[t[g]]=g;return a}function M(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Se("packages/core/src/compute/sort.js",function(o,fe){"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 g}}),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 U}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return I}});const le=fe("packages/core/src/compute/handle.js"),ae=le.bitReader,Q=le.dictRanks,q=le.dictSize,te=le.identity,_=le.isMissing,F=le.presenceReader,H=le.rowCount,ne=le.valueComparator,x=le.valueReader,ce=new Uint32Array(0),ie=new ArrayBuffer(8),G=new Float64Array(ie),D=new Uint32Array(ie),Y=(G[0]=-1,(D[1]&2147483648)!==0?1:0),ee=Y===1?0:1;function z(C,R){G[0]=C;let h=D[Y],O=D[ee];(h&2147483648)!==0?(h=~h>>>0,O=~O>>>0):h=(h^2147483648)>>>0,R[0]=O,R[1]=h}function M(C,R,h,O){if(O<2)return C;const w=new Uint32Array(256*8);for(let L=0;L<O;L++){const J=R[L],he=h[L];w[J&255]++,w[256+(J>>>8&255)]++,w[512+(J>>>16&255)]++,w[768+(J>>>24&255)]++,w[1024+(he&255)]++,w[1280+(he>>>8&255)]++,w[1536+(he>>>16&255)]++,w[1792+(he>>>24&255)]++}let P=C,v=R,K=h,Z=new Uint32Array(O),oe=new Uint32Array(O),se=new Uint32Array(O);const T=new Uint32Array(256);for(let L=0;L<8;L++){const J=L<<8,he=(L&3)<<3,ye=L>=4;let Me=!1;for(let je=0;je<256;je++)if(w[J+je]===O){Me=!0;break}if(Me)continue;let Pe=0;for(let je=0;je<256;je++)T[je]=Pe,Pe+=w[J+je];for(let je=0;je<O;je++){const Ve=v[je],We=K[je],Xe=(ye?We:Ve)>>>he&255,qe=T[Xe]++;Z[qe]=P[je],oe[qe]=Ve,se[qe]=We}let Ne=P;P=Z,Z=Ne,Ne=v,v=oe,oe=Ne,Ne=K,K=se,se=Ne}return P}function i(C,R,h){if(h<2)return C;const O=new Uint32Array(256*4);for(let oe=0;oe<h;oe++){const se=R[oe];O[se&255]++,O[256+(se>>>8&255)]++,O[512+(se>>>16&255)]++,O[768+(se>>>24&255)]++}let w=C,P=R,v=new Uint32Array(h),K=new Uint32Array(h);const Z=new Uint32Array(256);for(let oe=0;oe<4;oe++){const se=oe<<8,T=oe<<3;let L=!1;for(let ye=0;ye<256;ye++)if(O[se+ye]===h){L=!0;break}if(L)continue;let J=0;for(let ye=0;ye<256;ye++)Z[ye]=J,J+=O[se+ye];for(let ye=0;ye<h;ye++){const Me=P[ye],Pe=Z[Me>>>T&255]++;v[Pe]=w[ye],K[Pe]=Me}let he=w;w=v,v=he,he=P,P=K,K=he}return w}function s(C,R,h,O){const w=new Uint32Array(O+1);for(let K=0;K<h;K++)w[R[K]]++;let P=0;for(let K=0;K<=O;K++){const Z=w[K];w[K]=P,P+=Z}const v=new Uint32Array(h);for(let K=0;K<h;K++)v[w[R[K]]++]=C[K];return v}function u(C,R,h,O){return h<2?C:O<=65536||O<=h*2?s(C,R,h,O):i(C,R,h)}function f(C,R){return C.length===R&&C.byteOffset===0?C:Uint32Array.prototype.slice.call(C,0,R)}function c(C,R,h=!1){const O=R||te(C.length),w=O.length;if(w<2)return Uint32Array.from(O);const P=new Uint32Array(w),v=new Uint32Array(w),K=new Uint32Array(w),Z=new Uint32Array(w),oe=new Uint32Array(2);let se=0,T=0;for(let he=0;he<w;he++){const ye=O[he],Me=C[ye];if(Number.isNaN(Me)){Z[T++]=ye;continue}z(Me,oe),h?(v[se]=~oe[0]>>>0,K[se]=~oe[1]>>>0):(v[se]=oe[0],K[se]=oe[1]),P[se++]=ye}const L=M(P.subarray(0,se),v.subarray(0,se),K.subarray(0,se),se);if(T===0)return f(L,se);const J=new Uint32Array(w);return J.set(L.subarray(0,se),0),J.set(Z.subarray(0,T),se),J}function t(C,R,h=!1){const O=R||te(C.length),w=O.length;if(w<2)return Uint32Array.from(O);const P=Uint32Array.from(O),v=new Uint32Array(w);for(let K=0;K<w;K++){const Z=(C[P[K]]^2147483648)>>>0;v[K]=h?~Z>>>0:Z}return f(i(P,v,w),w)}function a(C,R,h={}){const O=R||te(H(C,h)),w=O.length;if(w<2)return Uint32Array.from(O);const P=Q(C.dict,h.locale),v=C.values,K=F(C),Z=Math.max(q(C.dict),P.length),oe=Z,se=Uint32Array.from(O),T=new Uint32Array(w),L=!!h.descending;for(let J=0;J<w;J++){const he=se[J];let ye=K&&K(he)===0?oe:P[v[he]];ye===void 0&&(ye=oe),T[J]=L?oe-ye:ye}return f(u(se,T,w,Z+1),w)}function g(C,R,h){const O=R.length;let w=Uint32Array.from(R);if(O<2)return w;let P=new Uint32Array(O);for(let v=1;v<O;v<<=1){for(let Z=0;Z<O;Z+=v<<1){const oe=Math.min(Z+v,O),se=Math.min(Z+(v<<1),O);let T=Z,L=oe,J=Z;for(;T<oe&&L<se;)P[J++]=h(C[w[T]],C[w[L]])<=0?w[T++]:w[L++];for(;T<oe;)P[J++]=w[T++];for(;L<se;)P[J++]=w[L++]}const K=w;w=P,P=K}return w}function e(C,R,h){const O=ae(C.values),w=R.length,P=new Uint32Array(w),v=h?1:0;let K=0;for(let Z=0;Z<w;Z++)O(R[Z])===v&&(P[K++]=R[Z]);for(let Z=0;Z<w;Z++)O(R[Z])!==v&&(P[K++]=R[Z]);return P}function m(C,R){const h=C.values,O=C.kind;if((O==="object"||O===void 0)&&(Array.isArray(h)||ArrayBuffer.isView(h))&&!C.presence)return h;const P=x(C),v=new Array(H(C)||0);for(let K=0;K<R.length;K++){const Z=R[K];v[Z]=P(Z)}return v}function d(C,R){for(let h=0;h<R.length;h++)if(typeof C[R[h]]!="string")return!1;return!0}function r(C,R,h,O,w){const P=C.length,v=Uint32Array.from(C);if(P<2||O<1)return v;const K=new Uint32Array(P),Z=O-1;for(let oe=0;oe<P;oe++){const se=h[R[oe]];K[oe]=w?Z-se:se}return f(u(v,K,P,O),P)}function n(C,R,h){const O=ne(h),w=new Array(R);for(let v=0;v<R;v++)w[v]=v;w.sort((v,K)=>O(C[v],C[K])||v-K);const P=new Uint32Array(R);for(let v=0;v<R;v++)P[w[v]]=v;return P}function l(C,R,h){const O=R.length,w=new Map,P=[],v=new Uint32Array(O);for(let oe=0;oe<O;oe++){const se=C[R[oe]];let T=w.get(se);T===void 0&&(T=P.length,w.set(se,T),P.push(se)),v[oe]=T}const K=P.length,Z=n(P,K,h.locale);return r(R,v,Z,K,!!h.descending)}function b(C,R,h){const O=m(C,R);if(R.length>=2&&d(O,R)){const v=C.stringRank;return v&&v.version===C.version&&v.usable(R,O,h.locale)?v.sort(R,h):l(O,R,h)}const w=ne(h.locale),P=h.descending?(v,K)=>w(K,v):w;return g(O,R,P)}function E(C,R,h){const O=m(C,R),w=h.compare,v=!!h.descending?(K,Z)=>-w(K,Z,void 0,void 0,!0):(K,Z)=>w(K,Z,void 0,void 0,!1);return g(O,R,v)}function S(C,R){const h=R.length,O=F(C),w=C.values,P=C.kind==="float64"&&!!w,v=C.kind==="object"||C.kind==="multi"||C.kind===void 0;if(!O&&!P&&!v)return{present:R,absent:ce};const K=new Uint32Array(h),Z=new Uint32Array(h);let oe=0,se=0;if(O&&P)for(let T=0;T<h;T++){const L=R[T];O(L)===1&&!Number.isNaN(w[L])?K[oe++]=L:Z[se++]=L}else if(P&&!O)for(let T=0;T<h;T++){const L=R[T];Number.isNaN(w[L])?Z[se++]=L:K[oe++]=L}else if(O&&!v)for(let T=0;T<h;T++){const L=R[T];O(L)===1?K[oe++]=L:Z[se++]=L}else{const T=x(C);for(let L=0;L<h;L++){const J=R[L];_(T(J))?Z[se++]=J:K[oe++]=J}}return se===0?{present:R,absent:ce}:{present:K.subarray(0,oe),absent:Z.subarray(0,se)}}function V(C,R,h){if(R.length===0)return C;const O=new Uint32Array(C.length+R.length);return h?(O.set(R,0),O.set(C,R.length)):(O.set(C,0),O.set(R,C.length)),O}function U(C,R,h={}){const O=R||te(H(C,h));if(!C||O.length<2)return Uint32Array.from(O);const{present:w,absent:P}=S(C,O);if(w.length===0)return Uint32Array.from(O);const v=!!h.descending;let K;if(typeof h.compare=="function")K=E(C,w,h);else switch(C.kind){case"float64":K=c(C.values,w,v);break;case"int32":K=t(C.values,w,v);break;case"dictionary":K=a(C,w,h);break;case"bitset":K=e(C,w,v);break;default:K=b(C,w,h);break}return V(K,P,!!h.nullsFirst)}function I(C,R,h,O={}){const w=R||[],P=w.length&&(w[0].handle||X(C,w[0].col))||C&&C[0];let v=h||te(H(P,O));for(let K=w.length-1;K>=0;K--){const Z=w[K],oe=Z.handle||X(C,Z.col)||C&&C[K];oe&&(v=U(oe,v,{descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,locale:Z.locale!==void 0?Z.locale:O.locale,compare:Z.compare}))}return v instanceof Uint32Array?v:Uint32Array.from(v)}function X(C,R){if(!(!C||R===void 0)){for(let h=0;h<C.length;h++)if(C[h]&&C[h].id===R)return C[h]}}}),Se("packages/core/src/store/stringrank.js",function(o,fe){"use strict";Object.defineProperty(o,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"StringRankIndex",{enumerable:!0,get:function(){return te}});const le=fe("packages/core/src/compute/sort.js"),ae=le.collateStringRanks,Q=le.rankSortStrings,q=1e5;class te{#t=[];#e=new Map;#n;#r=0;#i=0;#s=-1;#h;#u=!1;#o=null;#c=-1;#l="\\0";constructor(F=q){this.#h=F>0?F:q,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(F){this.#s=F}get generation(){return this.#i}get size(){return this.#t.length}get capped(){return this.#u}get length(){return this.#r}get bytes(){let F=this.#n.byteLength;const H=this.#t;for(let ne=0;ne<H.length;ne++)F+=H[ne].length*2+24;return F}#a(F,H){const ne=this.#e.get(F);if(ne!==void 0)return ne;if(this.#u)return-1;if(H&&this.#t.length>=this.#h)return this.#u=!0,-1;const x=this.#t.length;return this.#t.push(F),this.#e.set(F,x),this.#i++,x}build(F,H){const ne=H|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(ne);for(let x=0;x<ne;x++){const ce=F[x],ie=typeof ce=="string"?this.#a(ce,!1):-1;this.#n[x]=ie<0?0:ie}this.#r=ne}append(F,H,ne){const x=(H|0)+(ne|0);if(x>this.#n.length){const ce=new Uint32Array(x);ce.set(this.#n.subarray(0,this.#r)),this.#n=ce}for(let ce=H|0;ce<x;ce++){const ie=F[ce],G=typeof ie=="string"?this.#a(ie,!0):-1;this.#n[ce]=G<0?0:G}this.#r=Math.max(this.#r,x)}ranks(F){const H=F||"";if(this.#o&&this.#c===this.#i&&this.#l===H)return this.#o;const ne=ae(this.#t,this.#t.length,F);return this.#o=ne,this.#c=this.#i,this.#l=H,ne}usable(F,H,ne){if(this.#u||this.#t.length===0)return!1;const x=this.#n,ce=this.#t,ie=this.#r;for(let G=0;G<F.length;G++){const D=F[G];if(D>=ie||ce[x[D]]!==H[D])return!1}return!0}sort(F,H){const ne=this.ranks(H.locale),x=this.#t.length,ce=F.length,ie=new Uint32Array(ce),G=this.#n;for(let D=0;D<ce;D++)ie[D]=G[F[D]];return Q(F,ie,ne,x,!!H.descending)}}}),Se("packages/core/src/store/columnstore.js",function(o,fe){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return G}}),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 le=fe("packages/core/src/internal/util.js"),ae=le.warnOnce,Q=le.isFunction,q=le.pathGetter,_=fe("packages/core/src/store/bitset.js").Bitset,H=fe("packages/core/src/store/dictionary.js").Dictionary,x=fe("packages/core/src/store/multivalue.js").MultiValue,ie=fe("packages/core/src/store/stringrank.js").StringRankIndex,G=4294967295,D=1024,Y=5e3,ee=.2,z=new Set(["float64","int32","bitset","dictionary","object","multi"]);function M(g){return g==null}function i(g){if(typeof g=="number")return g;if(g instanceof Date)return g.getTime();if(typeof g=="boolean")return g?1:0;const e=Number(g);return Number.isNaN(e)&&typeof g=="string"?Date.parse(g):e}function s(g){const e=i(g);return Number.isFinite(e)?e|0:0}function u(g){return M(g)?[]:Array.isArray(g)?g:[g]}function f(g,e){switch(g.kind){case"float64":case"int32":return g.buf[e];case"bitset":return g.bits.get(e)===1;case"dictionary":return g.dict.valueOf(g.buf[e]);case"multi":{const m=g.mv.at(e),d=new Array(m.length);for(let r=0;r<m.length;r++)d[r]=g.dict.valueOf(m[r]);return d}default:return g.buf[e]}}function c(g,e){switch(g.kind){case"float64":case"int32":return g.values[e];case"bitset":return(g.values[e>>3]&1<<(e&7))!==0;case"dictionary":return(g.table||[])[g.values[e]];case"multi":{const m=g.offsets[e],d=g.offsets[e+1],r=g.table||[],n=new Array(d-m);for(let l=m;l<d;l++)n[l-m]=r[g.values[l]];return n}default:return g.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,m){this.#t=e.id;const d=z.has(e.kind)?e.kind:"object";e.kind&&!z.has(e.kind)&&ae(`store.kind.${e.id}`,`column "${e.id}" declares unknown storage kind "${e.kind}"; falling back to object`),this.#n=d,this.#e=d,this.#r=e.nullable!==!1,this.#h=e.dictionary??null,this.#s=m,this.#i=Q(e.read)?e.read:q(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,m=this.#s.physical();if(!e||m===0)return null;if(this.#d===null){if(typeof e[0]!="string")return null;const d=new ie(this.#S());return d.build(e,m),d.version=this.#f,this.#d=d,this.#k=this.#f,d.capped?null:d}return this.#d.length<m&&this.#d.append(e,this.#d.length,m-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 m=this.#l.at(e),d=new Array(m.length);for(let r=0;r<m.length;r++)d[r]=this.#a.valueOf(m[r]);return d}default:return this.#o[e]}}}set(e,m){this.#g||(this.#u?this.#A(e,m):this.#y.set(e,m===void 0?null:m),this.#d&&this.#j(),this.#f++)}read(e){return this.#i(e)}appendColumn(e,m,d){if(this.#g||d<=0)return;if(!this.#u){this.#f++;return}const r=this.#i,n=this.#r,l=this.#m;let b=!1;switch(this.#e){case"float64":{const E=this.#o;for(let S=0;S<d;S++){const V=r(e[S]);if(typeof V=="number"){n&&l.set(m+S),E[m+S]=V;continue}const U=V==null;n?l.assign(m+S,!U):U&&(b=!0),E[m+S]=U?NaN:i(V)}break}case"int32":{const E=this.#o;for(let S=0;S<d;S++){const V=r(e[S]),U=V==null;n?l.assign(m+S,!U):U&&(b=!0),E[m+S]=U?0:s(V)}break}case"bitset":{const E=this.#c;for(let S=0;S<d;S++){const V=r(e[S]),U=V==null;n?l.assign(m+S,!U):U&&(b=!0),E.assign(m+S,!U&&!!V)}break}case"dictionary":{const E=this.#o,S=this.#a;for(let V=0;V<d;V++){const U=r(e[V]),I=U==null;n?l.assign(m+V,!I):I&&(b=!0),E[m+V]=I?0:S.codeOf(U)}break}case"multi":{const E=this.#l,S=this.#a;for(let V=0;V<d;V++){const U=r(e[V]),I=U==null;n?l.assign(m+V,!I):I&&(b=!0);const X=u(U),C=new Array(X.length);for(let R=0;R<X.length;R++)C[R]=S.codeOf(X[R]);E.write(m+V,C)}break}default:{const E=this.#o;for(let S=0;S<d;S++){const V=r(e[S]),U=V==null;n?l.assign(m+S,!U):U&&(b=!0),E[m+S]=U?null:V}break}}b&&ae(`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,m,d),this.#d.version=this.#f+1,this.#k=this.#f+1),this.#f++}appendPacked(e,m,d){if(this.#g||d<=0||!e)return;if(!this.#u){this.#f++;return}const r=this.#m,n=e.presence;if(r)if(n)for(let b=0;b<d;b++)r.assign(m+b,(n[b>>3]&1<<(b&7))!==0);else for(let b=0;b<d;b++)r.set(m+b);const l=e.kind===this.#e;if(l&&(this.#e==="float64"||this.#e==="int32")){this.#o.set(e.values,m),this.#f++;return}if(l&&this.#e==="bitset"){const b=e.values;for(let E=0;E<d;E++)this.#c.assign(m+E,(b[E>>3]&1<<(E&7))!==0);this.#f++;return}if(l&&this.#e==="dictionary"){const b=e.table||[],E=new Uint32Array(b.length);for(let I=0;I<b.length;I++)E[I]=this.#a.codeOf(b[I]);const S=e.values,V=this.#o,U=r;for(let I=0;I<d;I++){if(U&&(n&&(n[I>>3]&1<<(I&7))===0)){V[m+I]=0;continue}V[m+I]=E[S[I]]??0}this.#f++;return}if(l&&this.#e==="multi"){const b=e.table||[],E=new Uint32Array(b.length);for(let U=0;U<b.length;U++)E[U]=this.#a.codeOf(b[U]);const S=e.values,V=e.offsets;for(let U=0;U<d;U++){const I=V[U],X=V[U+1],C=new Array(X-I);for(let R=I;R<X;R++)C[R-I]=E[S[R]]??0;this.#l.write(m+U,C)}this.#f++;return}for(let b=0;b<d;b++){const E=n?(n[b>>3]&1<<(b&7))===0:e.kind==="object"?e.values[b]===null:!1;this.#A(m+b,E?null:c(e,b))}this.#f++}touch(){this.#f++}columnarise(e,m){if(this.#u||this.#g)return;const d=new Array(m);for(let r=0;r<m;r++)d[r]=this.#M(r);this.#e=this.#n,this.#u=!0,this.#P(e);for(let r=0;r<m;r++)this.#A(r,d[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 m=new this.#o.constructor(e);m.set(this.#o),this.#o=m;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||!z.has(e)||(this.#n=e,!this.#u||e===this.#e))return!1;const m={kind:this.#e,buf:this.#o,bits:this.#c,mv:this.#l,dict:this.#a},d=this.#s.physical(),r=this.#m;this.#e=e,this.#P(this.#p);for(let n=0;n<d;n++){const l=r!==null&&r.get(n)===0;l&&e!=="multi"||this.#A(n,l?null:f(m,n))}return this.#j(),this.#f++,!0}compact(e,m,d){if(!this.#g){if(this.#j(),!this.#u){const r=this.#y;if(r.size){const n=new Map;for(const[l,b]of r)e[l]!==G&&n.set(e[l],b);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<m;n++)e[n]!==G&&(r[e[n]]=r[n]);if(this.#e==="object")for(let n=d;n<m;n++)r[n]=void 0;break}case"bitset":{const r=this.#c;for(let n=0;n<m;n++)e[n]!==G&&r.assign(e[n],r.get(n)===1);for(let n=d;n<m;n++)r.clear(n);break}case"multi":this.#l.compact(e,d,G);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<m;n++)e[n]!==G&&r.assign(e[n],r.get(n)===1);for(let n=d;n<m;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 m=Math.max(1,e);switch(this.#o=null,this.#c=null,this.#l=null,this.#e){case"float64":this.#o=new Float64Array(m);break;case"int32":this.#o=new Int32Array(m);break;case"bitset":this.#c=new _(m);break;case"dictionary":this.#o=new Uint32Array(m),this.#a=this.#a??new H(this.#h??[]);break;case"multi":this.#l=new x({rows:m,values:m}),this.#a=this.#a??new H(this.#h??[]);break;default:this.#o=new Array(m);break}this.#e!=="dictionary"&&this.#e!=="multi"&&(this.#a=null),this.#r&&(this.#m?this.#m.grow(m):this.#m=new _(m)),this.#p=m}#A(e,m){const d=M(m);switch(this.#r?this.#m.assign(e,!d):d&&ae(`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]=d?NaN:i(m);break;case"int32":this.#o[e]=d?0:s(m);break;case"bitset":this.#c.assign(e,!d&&!!m);break;case"dictionary":this.#o[e]=d?0:this.#a.codeOf(m);break;case"multi":{const r=u(m),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]=d?null:m;break}}#M(e){if(this.#y.has(e))return this.#y.get(e);const m=this.#i(this.#s.rowAt(e));return m===void 0?null:m}#N(){if(this.#O&&this.#O.version===this.#f)return this.#O;const e=this.#s.physical(),m=new Array(e),d=this.#r?new _(e):null;for(let r=0;r<e;r++){const n=this.#M(r);m[r]=n,d&&!M(n)&&d.set(r)}return this.#O={version:this.#f,values:m,presence:d},this.#O}}class a{#t;#e=new Map;#n=[];#r=[];#i=0;#s=0;#h=0;#u=0;#o=new _(0);#c=!1;#l=!0;#a;#d;#w;#b=!1;constructor(e,m={}){this.#t=Array.isArray(e)?e:[],this.#d=Math.max(1,m.initialCapacity??D),this.#l=m.retainSource!==!1,this.#a=this.#l?m.columnarBelow??Y:0,this.#w=m.compactRatio??ee;const d={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)){ae(`store.dup.${r.id}`,`duplicate column id "${r.id}" in the store schema; ignoring the second`);continue}const n=new t(r,d);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 m of this.#n)e+=m.bytes;return e}append(e){const m=this.#i;if(this.#b||!e)return{from:m,to:m};const d=e.length|0;if(d===0)return{from:m,to:m};if(this.#l)for(let n=0;n<d;n++)this.#r[m+n]=e[n];if(this.#i=m+d,this.#h+=d,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:m,to:this.#i}}this.#k(this.#i);const r=this.#n;for(let n=0;n<r.length;n++)r[n].appendColumn(e,m,d);return{from:m,to:this.#i}}appendPacked(e,m){const d=this.#i;if(this.#b||!e)return{from:d,to:d};const r=e.count|0;if(r===0)return{from:d,to:d};if(this.#l&&m)for(let l=0;l<r;l++)this.#r[d+l]=m[l];this.#i=d+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 b=n.get(l.id);b?l.appendPacked(b,d,r):l.grow(this.#s)}return{from:d,to:this.#i}}source(e){if(this.#l)return this.#r[e];if(!(e<0||e>=this.#i))return this.#m(e)}setSource(e,m){this.#b||e<0||e>=this.#i||this.#l&&(this.#r[e]=m)}get(e,m){const d=this.#e.get(e);return d?d.get(m):void 0}set(e,m,d){if(this.#b||m<0||m>=this.#i)return;const r=this.#e.get(e);if(!r){ae(`store.set.${e}`,`set() on unknown column "${e}"`);return}r.set(m,d)}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 m=this.#i,d=new Uint32Array(m);let r=0;for(let n=0;n<m;n++)d[n]=this.#o.get(n)===1?G:r++;for(const n of this.#n)n.compact(d,m,r);if(this.#l){const n=this.#r;for(let l=0;l<m;l++)d[l]!==G&&(n[d[l]]=n[l]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new _(Math.max(this.#s,r)),d}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 d=0;d<this.#i;d++)e[d]=d;return e}let m=0;for(let d=0;d<this.#i;d++)this.#o.get(d)===0&&(e[m++]=d);return e}convert(e,m){const d=this.#e.get(e);return d?d.convert(m):!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 m=this.#s||this.#d;for(;m<e;)m*=2;for(const d of this.#n)d.grow(m);this.#o.grow(m),this.#s=m}#m(e){const m={};for(const d of this.#n)m[d.id]=d.get(e);return m}#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 m of this.#n)m.columnarise(e,this.#i)}}}),Se("packages/core/src/store/ingest.js",function(o,fe){"use strict";Object.defineProperty(o,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"inferKind",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return z}});const le=fe("packages/core/src/internal/util.js"),ae=le.now,Q=le.nextFrame,q=le.infoOnce,te=le.warnOnce,_=le.isFunction,F=le.pathGetter,ne=fe("packages/core/src/store/columnstore.js").ColumnStore,x=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function ce(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 g=0;g<M.length;g++){const e=M[g];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 ie(M,i,s){return i<=0||M<s*i?"dictionary":"object"}function G(M,i,s){const u=new Map,f=new Map;for(const l of M){if(l.computed)continue;const b=_(l.read)?l.read:F(l.field||l.id);f.set(l.id,b),u.set(l.id,b)}const c=i?.order??[],t=i?.fns??{},a=i?.deps??{},g=i?.wrapDeps??null,e=c.filter(l=>_(t[l])),m=e.some(l=>a[l]==="*");let d=new WeakMap;const r=l=>{const b={};if(m)for(const[E,S]of f)b[E]=S(l);for(const E of e){const S=a[E];let V;if(S==="*")V=b;else{V={};const U=S||[];for(let I=0;I<U.length;I++){const X=U[I];V[X]=X in b?b[X]:f.get(X)?.(l)}}b[E]=t[E](g?g(V,E):V,{data:l,row:null,column:null,grid:null,context:s})}return b},n=l=>{if(l===null||typeof l!="object"&&typeof l!="function")return r(l);let b=d.get(l);return b===void 0&&(b=r(l),d.set(l,b)),b};for(const l of e)u.set(l,b=>n(b)[l]);return{readers:u,reset(){d=new WeakMap}}}class D{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(i,s){this.spec=i,this.read=s,this.kind="object",this.inferred=!1,this.nullable=i.nullable!==!1}}class Y{#t;#e=[];#n=null;#r;#i=0;#s;#h=!1;#u=!1;#o=0;#c;constructor(i,s={},u={}){this.#t=Array.isArray(i)?i:Array.from(i||[]),this.#s={...x,...u};const f=s.columns??[];this.#r=G(f,s.computed??null,s.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(f,s.computed??null),this.#n=new ne(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=ae(),{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&&ae()-i<s);return this.#o+=ae()-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 g=this.#r.readers.get(a.id)??(_(a.read)?a.read:F(a.field||a.id)),e=new D(a,g);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 m=[];for(let r=0;r<f&&m.length<this.#s.sampleSize;r++){const n=g(u[r]);n!=null&&m.push(n)}e.inferred=!0;const d=ce(m,{multi:a.multi});if(d==="text"){const r=new Set(m).size;e.kind=ie(r,m.length,c),e.candidate=this.#c,e.reason=`sampled ${r} distinct in ${m.length}`}else e.kind=d,e.reason=`inferred from ${m.length} sampled values`,d==="object"&&m.length&&q(`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(m))}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 ee(M,i={},s={}){const u=new Y(M,i,s),f=s.scheduler?.frame??Q;for(;u.slice();)await new Promise(c=>{f(c)});return u.result()}function z(M,i={},s={}){const u=new Y(M,i,{...s,chunkMs:1/0});for(;u.slice(););return u.result()}}),Se("packages/core/src/store/columnpack.js",function(o,fe){"use strict";Object.defineProperty(o,"isPortableSchema",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"packChunk",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"packedTransfers",{enumerable:!0,get:function(){return Y}});const ae=fe("packages/core/src/internal/util.js").pathGetter,Q=fe("packages/core/src/store/ingest.js"),q=Q.inferKind,te=Q.decideText,_=Q.INGEST_DEFAULTS,H=fe("packages/core/src/store/columnstore.js").toFloat,ne=new Set(["float64","int32","bitset","dictionary","object","multi"]);function x(ee){if(!Array.isArray(ee)||ee.length===0)return!1;for(const z of ee)if(!z||typeof z.id!="string"||typeof z.field!="string"||z.field===""||z.kind&&!ne.has(z.kind))return!1;return!0}function ce(ee){const z=H(ee);return Number.isFinite(z)?z|0:0}function ie(ee){return ee==null?[]:Array.isArray(ee)?ee:[ee]}function G(ee,z,M,i){if(ee.kind)return ee.kind;const s=[];for(let c=0;c<z.length&&s.length<_.sampleSize;c++){const t=z[c];t!=null&&s.push(t)}const u=q(s,{multi:ee.multi});if(u!=="text")return u;const f=new Set(s).size;return te(f,s.length,i)}function D(ee,z,M={}){const i=z.length|0,s=M.dictionaryRatio??_.dictionaryRatio,u=[];for(const f of ee){const c=ae(f.field||f.id),t=f.nullable!==!1,a=new Array(i);for(let r=0;r<i;r++){const n=c(z[r]);a[r]=n===void 0?null:n}const g=G(f,a,i,s),e=t?new Uint8Array(i+7>>3):null,m=r=>{e&&(e[r>>3]|=1<<(r&7))};let d;switch(g){case"float64":{const r=new Float64Array(i);for(let n=0;n<i;n++){const l=a[n],b=l===null;b||m(n),r[n]=b?NaN:H(l)}d={id:f.id,kind:g,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],b=l===null;b||m(n),r[n]=b?0:ce(l)}d={id:f.id,kind:g,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],b=l===null;b||m(n),!b&&l&&(r[n>>3]|=1<<(n&7))}d={id:f.id,kind:g,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"dictionary":{const r=new Uint32Array(i),n=[],l=new Map;for(let b=0;b<i;b++){const E=a[b];if(E===null){r[b]=0;continue}m(b);let S=l.get(E);S===void 0&&(S=n.length,n.push(E),l.set(E,S)),r[b]=S}d={id:f.id,kind:g,nullable:t,values:r,presence:e,offsets:null,table:n};break}case"multi":{const r=[],n=new Map,l=new Uint32Array(i+1),b=[];for(let E=0;E<i;E++){const S=a[E];l[E]=b.length,S===null||m(E);const U=ie(S);for(let I=0;I<U.length;I++){const X=U[I];let C=n.get(X);C===void 0&&(C=r.length,r.push(X),n.set(X,C)),b.push(C)}}l[i]=b.length,d={id:f.id,kind:g,nullable:t,values:Int32Array.from(b),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&&m(n),r[n]=l}d={id:f.id,kind:"object",nullable:t,values:r,presence:e,offsets:null,table:null};break}}u.push(d)}return{count:i,columns:u}}function Y(ee){const z=[];if(!ee||!Array.isArray(ee.columns))return z;const M=i=>{ArrayBuffer.isView(i)&&i.buffer&&!z.includes(i.buffer)&&z.push(i.buffer)};for(const i of ee.columns)M(i.values),M(i.presence),M(i.offsets);return z}}),Se("packages/core/src/compute/sortspec.js",function(o,fe){"use strict";Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return te}});function le(_){return{locale:_===void 0?void 0:String(_),numeric:!0,sensitivity:"variant"}}function ae(_){return!!_&&typeof _.compare!="function"}function Q(_){if(!_)return!0;for(let F=0;F<_.length;F++)if(!ae(_[F]))return!1;return!0}function q(_,F){const H=_.col!==void 0?_.col:_.handle&&_.handle.id,ne=_.locale!==void 0?_.locale:F;return{col:H,descending:_.descending!==void 0?!!_.descending:_.dir==="desc",nullsFirst:!!_.nullsFirst,collation:le(ne)}}function te(_,F){const H=_||[],ne=new Array(H.length);for(let x=0;x<H.length;x++)ne[x]=q(H[x],F);return ne}}),Se("packages/core/src/format/date.js",function(o,fe){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return z}});const le=fe("packages/core/src/internal/util.js"),ae=le.isNil,Q=le.warnOnce,q=["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=q.find(a=>M.startsWith(a,s));if(t){f(),i.push({token:t,text:t}),s+=t.length;continue}/[A-Za-z]/.test(c)&&Q(`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: ${q.join(" ")}.`),u+=c,s+=1}return f(),i}const _=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function F(M){if(ae(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=_.exec(M.trim());if(i){const[,u,f,c,t="0",a="0",g="0"]=i;return new Date(+u,+f-1,+c,+t,+a,+g)}const s=new Date(M);return Number.isNaN(s.getTime())?null:s}return null}function H(M,i){return String(M).padStart(i,"0")}function ne(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 x(M,i,s){const u=te(M),f=ne(s),c=new Set(u.filter(m=>m.token).map(m=>m.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,g=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 m=>{const d=f(m);let r="";for(const n of u){if(!n.token){r+=n.text;continue}switch(n.token){case"yyyy":r+=H(d.year,4);break;case"yy":r+=H(d.year%100,2);break;case"MMMM":r+=a.format(m);break;case"MMM":r+=t.format(m);break;case"MM":r+=H(d.month,2);break;case"M":r+=String(d.month);break;case"dd":r+=H(d.day,2);break;case"d":r+=String(d.day);break;case"EEEE":r+=e.format(m);break;case"EEE":r+=g.format(m);break;case"HH":r+=H(d.hour,2);break;case"H":r+=String(d.hour);break;case"hh":r+=H(d.hour%12===0?12:d.hour%12,2);break;case"h":r+=String(d.hour%12===0?12:d.hour%12);break;case"mm":r+=H(d.minute,2);break;case"m":r+=String(d.minute);break;case"ss":r+=H(d.second,2);break;case"s":r+=String(d.second);break;case"SSS":r+=H(d.ms,3);break;case"a":r+=d.hour<12?"AM":"PM";break;default:r+=n.text;break}}return r}}const ce=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function ie(M,i){const s=M||{},u=s.locale||i||void 0,f=s.nullDisplay??"",c=s.timeZone;let t;if(s.pattern)t=x(s.pattern,u,c);else if(s.dateStyle||s.timeStyle){const d={timeZone:c};s.dateStyle&&(d.dateStyle=s.dateStyle),s.timeStyle&&(d.timeStyle=s.timeStyle);const r=new Intl.DateTimeFormat(u,d);t=n=>r.format(n)}else{const d=new Intl.DateTimeFormat(u,{dateStyle:"medium",timeZone:c});t=r=>d.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,m=(d,r)=>{const n=F(d);if(!n)return f;if(a){const l=r&&typeof r.now=="number"?r.now:Date.now(),b=n.getTime()-l;if(Math.abs(b)<e){for(const[E,S]of ce)if(Math.abs(b)>=S||E==="second")return a.format(Math.round(b/S),E)}}return t(n)};return m.spec=s,m}function G(M){if(ae(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=F(M);return f?G(f):null}const i=F(M);if(!i)return null;const s=u=>String(u).padStart(2,"0");return`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}`}function D(M,i){if(ae(M)||M==="")return null;if(typeof M=="string"){const u=M.trim();if(Y.test(u)){const t=F(u);return t?ee(t,i):null}const f=/^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(u);if(f){const[,t,a,g,e]=f;return`${t}T${a}:${g}${e&&e!=="00"?`:${e}`:""}`}if(/^\\d{4}-\\d{2}-\\d{2}$/.test(u))return`${u}T00:00`;const c=F(u);return c?D(c):null}const s=F(M);return s?ee(s,i):null}const Y=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function ee(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,m)=>(m.type!=="literal"&&(e[m.type]=m.value),e),{}),a=t.hour==="24"?"00":t.hour,g=Number(t.second);return`${t.year}-${t.month}-${t.day}T${a}:${t.minute}`+(g?`:${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 z(M,i){const s=ae(M)||M===""?null:String(M),u=ae(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,fe){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return R}});const le=fe("packages/core/src/internal/util.js"),ae=le.isBlank,Q=le.toArray,q=le.warnOnce,_=fe("packages/core/src/format/date.js").toIsoDate,F=fe("packages/core/src/compute/handle.js"),H=F.bitReader,ne=F.dictSize,x=F.dictValue,ce=F.presenceReader,ie=F.valueComparator,G=F.valueReader,D=/^\\d{4}-\\d{2}-\\d{2}$/,Y="\\0null\\0";function ee(h,O){const w=h&&h.pool;if(w){const P=w.mask||w.acquireMask||w.acquire||w.take;if(typeof P=="function"){const v=P.call(w,O);if(v&&v.length>=O)return v}}return new Uint8Array(O)}function z(h,O){const w=h&&h.pool;if(!w||!O)return;const P=w.release||w.releaseMask||w.free||w.recycle;typeof P=="function"&&P.call(w,O)}function M(h,O,w){return h.fill(w,0,O),h}function i(h){return h==null||typeof h=="number"&&Number.isNaN(h)}function s(h,O){if(h==null)return h;if(O==="number")return typeof h=="number"?h:Number(h);if(O==="date"||O==="dateString"){const w=_(h);return w===null?u(h):w}return O==="boolean"?typeof h=="boolean"?h:h==="true"||h===1?!0:h==="false"||h===0?!1:!!h:h}function u(h){return h instanceof Date?h.getTime():typeof h=="number"?h:Date.parse(String(h))}function f(h){return typeof h=="number"?h:h instanceof Date?h.getTime():h==null||h===""?NaN:Number(h)}function c(h,O){const w=typeof h=="string"?h:String(h);return O?w:w.toLowerCase()}function t(h,O){return h==null?Y:typeof h=="string"?O?h:h.toLowerCase():h instanceof Date?h.getTime():h}function a(h,O,w){const P=new Set;for(const v of Q(h)){const K=s(v,w);P.add(t(K,O)),typeof K=="string"&&K!==""&&Number.isFinite(Number(K))?P.add(Number(K)):typeof K=="number"&&Number.isFinite(K)&&P.add(t(String(K),O))}return P}function g(h,O,w){if(h==null||O===null||O===void 0)return h==null&&O==null;const P=typeof h,v=typeof O;return P==="string"&&v==="string"?w?h===O:h.toLowerCase()===O.toLowerCase():h instanceof Date||O instanceof Date?u(h)===u(O):P==="number"&&v==="number"?h===O||Number.isNaN(h)&&Number.isNaN(O):P==="number"&&v==="string"?h===Number(O):P==="string"&&v==="number"?Number(h)===O:P==="boolean"||v==="boolean"?h===O:Array.isArray(h)&&Array.isArray(O)?h.length===O.length&&h.every((K,Z)=>g(K,O[Z],w)):h===O}function e(h,O){try{if(h instanceof RegExp){const w=h.flags.replace(/[gy]/g,"");return new RegExp(h.source,O||w.includes("i")?w:`${w}i`)}return new RegExp(String(h),O?"":"i")}catch(w){return q(`regex:${String(h)}`,`filter operator "matches" received an invalid pattern: ${String(h)}`,w),null}}function m(h,O){const w=d(h,O),P=h&&h.type;return P!=="date"&&P!=="dateString"?w:v=>w(typeof v=="string"&&D.test(v)?v:_(v)??v)}function d(h,O){const w=h&&h.op,P=!!(h&&h.caseSensitive),v=h&&h.type,K=ie(O),Z=oe=>se=>!oe(se);switch(w){case"eq":{const oe=s(h.value,v);return se=>g(se,oe,P)}case"ne":{const oe=s(h.value,v);return se=>!g(se,oe,P)}case"lt":case"lte":case"gt":case"gte":{const oe=s(h.value,v);if(i(oe))return()=>!1;const se=w==="lt"?-1:w==="lte"?0:w==="gt"?1:2;return T=>{if(i(T))return!1;const L=K(T,oe);return se===-1?L<0:se===0?L<=0:se===1?L>0:L>=0}}case"between":case"notBetween":{const oe=Q(h.value),se=s(oe[0],v),T=s(oe[1],v),L=h.bounds||"[]",J=L.charAt(0)!=="(",he=L.charAt(1)!==")";if(i(se)||i(T))return w==="between"?()=>!1:()=>!0;const ye=Me=>{if(i(Me))return!1;const Pe=K(Me,se),Ne=K(Me,T);return(J?Pe>=0:Pe>0)&&(he?Ne<=0:Ne<0)};return w==="between"?ye:Z(ye)}case"in":case"notIn":{const oe=a(h.value,P,v),se=T=>oe.has(t(T,P));return w==="in"?se:Z(se)}case"contains":case"notContains":{const oe=c(s(h.value,v),P),se=T=>T==null?!1:c(T,P).includes(oe);return w==="contains"?se:Z(se)}case"startsWith":{const oe=c(s(h.value,v),P);return se=>se==null?!1:c(se,P).startsWith(oe)}case"endsWith":{const oe=c(s(h.value,v),P);return se=>se==null?!1:c(se,P).endsWith(oe)}case"matches":{const oe=e(h.value,P);return oe?se=>se==null?!1:oe.test(String(se)):()=>!1}case"blank":return oe=>ae(oe)||Array.isArray(oe)&&oe.length===0;case"notBlank":return oe=>!(ae(oe)||Array.isArray(oe)&&oe.length===0);case"containsAny":case"containsNone":{const oe=a(h.value,P,v),se=T=>{const L=T==null?[]:Q(T);for(let J=0;J<L.length;J++)if(oe.has(t(L[J],P)))return!0;return!1};return w==="containsAny"?se:Z(se)}case"containsAll":{const oe=Q(h.value).map(se=>t(s(se,v),P));return se=>{const T=se==null?[]:Q(se);if(oe.length===0)return!0;const L=new Set(T.map(J=>t(J,P)));for(let J=0;J<oe.length;J++)if(!L.has(oe[J]))return!1;return!0}}default:return q(`op:${String(w)}`,`unknown filter operator "${String(w)}"; the condition passes every row`),()=>!0}}function r(h,O,w){return m(O,w)(h)}function n(h,O,w,P){const v=ce(h);if(v){const oe=O?1:0;for(let se=0;se<P;se++)w[se]=v(se)===oe?1:0;return w}const K=h.kind;if(K==="float64"||K==="int32"||K==="bitset")return M(w,P,O?1:0);const Z=G(h);for(let oe=0;oe<P;oe++){const se=Z(oe),T=ae(se)||Array.isArray(se)&&se.length===0;w[oe]=T===O?0:1}return w}function l(h,O,w,P){const v=h.dict,K=ne(v),Z=new Uint8Array(K);for(let L=0;L<K;L++)Z[L]=O(x(v,L))?1:0;const oe=h.values,se=ce(h);if(!se){for(let L=0;L<P;L++)w[L]=Z[oe[L]];return w}const T=O(null)?1:0;for(let L=0;L<P;L++)w[L]=se(L)===1?Z[oe[L]]:T;return w}function b(h,O,w,P){const v=H(h.values),K=O(!0)?1:0,Z=O(!1)?1:0,oe=ce(h);if(!oe){for(let T=0;T<P;T++)w[T]=v(T)===1?K:Z;return w}const se=O(null)?1:0;for(let T=0;T<P;T++)w[T]=oe(T)===0?se:v(T)===1?K:Z;return w}function E(h,O,w,P,v){const K=h.values,Z=O.type,oe=O.op;let se=!0;switch(oe){case"eq":case"ne":{const L=f(s(O.value,Z)),J=typeof O.value=="number"&&Number.isNaN(O.value),he=oe==="ne"?1:0;if(J)for(let ye=0;ye<v;ye++)P[ye]=(Number.isNaN(K[ye])?1:0)^he;else for(let ye=0;ye<v;ye++)P[ye]=(K[ye]===L?1:0)^he;break}case"lt":{const L=f(s(O.value,Z));for(let J=0;J<v;J++)P[J]=K[J]<L?1:0;break}case"lte":{const L=f(s(O.value,Z));for(let J=0;J<v;J++)P[J]=K[J]<=L?1:0;break}case"gt":{const L=f(s(O.value,Z));for(let J=0;J<v;J++)P[J]=K[J]>L?1:0;break}case"gte":{const L=f(s(O.value,Z));for(let J=0;J<v;J++)P[J]=K[J]>=L?1:0;break}case"between":case"notBetween":{const L=Q(O.value),J=f(s(L[0],Z)),he=f(s(L[1],Z)),ye=O.bounds||"[]",Me=ye.charAt(0)!=="(",Pe=ye.charAt(1)!==")",Ne=oe==="notBetween"?1:0;if(Me&&Pe)for(let je=0;je<v;je++)P[je]=(K[je]>=J&K[je]<=he?1:0)^Ne;else if(Me)for(let je=0;je<v;je++)P[je]=(K[je]>=J&K[je]<he?1:0)^Ne;else if(Pe)for(let je=0;je<v;je++)P[je]=(K[je]>J&K[je]<=he?1:0)^Ne;else for(let je=0;je<v;je++)P[je]=(K[je]>J&K[je]<he?1:0)^Ne;break}case"in":case"notIn":{const L=new Set;for(const he of Q(O.value)){const ye=f(s(he,Z));Number.isNaN(ye)||L.add(ye)}const J=oe==="notIn"?1:0;for(let he=0;he<v;he++)P[he]=(L.has(K[he])?1:0)^J;break}default:se=!1;break}if(!se)return!1;const T=ce(h);if(T){const L=w(null)?1:0;for(let J=0;J<v;J++)T(J)===0&&(P[J]=L)}return!0}function S(h,O,w,P){const v=G(h);for(let K=0;K<P;K++)w[K]=O(v(K))?1:0;return w}function V(h,O,w){const P=O.count|0,v=w||ee(O,P);if(!h)return M(v,P,1);const K=typeof O.handle=="function"?O.handle(h.col):void 0,Z=typeof O.custom=="function"?O.custom:null;if(!K){if(Z){for(let T=0;T<P;T++)v[T]=Z(h,T)?1:0;return v}return q(`filter:col:${String(h.col)}`,`filter references unknown column "${String(h.col)}"; the condition passes every row`),M(v,P,1)}const oe=h.op;if(oe==="blank"||oe==="notBlank")return n(K,oe==="notBlank",v,P);const se=m(h,O.locale);switch(K.kind){case"dictionary":return l(K,se,v,P);case"bitset":return b(K,se,v,P);case"float64":case"int32":return E(K,h,se,v,P)?v:S(K,se,v,P);default:return S(K,se,v,P)}}function U(h,O,w){if(!h)return M(ee(O,w),w,1);if(Array.isArray(h.conditions)){const P=h.conditions.filter(Z=>Z!=null),v=h.op==="or"?"or":h.op==="not"?"not":"and";if(P.length===0)return M(ee(O,w),w,1);const K=U(P[0],O,w);for(let Z=1;Z<P.length;Z++){const oe=U(P[Z],O,w);if(v==="or")for(let se=0;se<w;se++)K[se]|=oe[se];else for(let se=0;se<w;se++)K[se]&=oe[se];z(O,oe)}if(v==="not")for(let Z=0;Z<w;Z++)K[Z]^=1;return K}return V(h,O,ee(O,w))}function I(h,O){return U(h,O,O.count|0)}function X(h,O){if(!h||!O)return h||null;const w=h;if(Array.isArray(w.conditions)){if((w.op==="or"?"or":w.op==="not"?"not":"and")!=="and")return C(w,O)?null:h;const v=[];for(const K of w.conditions){const Z=X(K,O);Z&&v.push(Z)}return v.length?{...w,op:"and",conditions:v}:null}return w.col===O?null:h}function C(h,O){if(!h||typeof h!="object")return!1;const w=h;if(w.col===O)return!0;if(Array.isArray(w.conditions)){for(const P of w.conditions)if(C(P,O))return!0}return!1}function R(h,O,w){if(w&&w.length>=O){let Z=0;for(let oe=0;oe<O;oe++)h[oe]&&(w[Z++]=oe);return w.subarray(0,Z)}let P=0;for(let Z=0;Z<O;Z++)P+=h[Z]?1:0;const v=new Uint32Array(P);let K=0;for(let Z=0;Z<O;Z++)h[Z]&&(v[K++]=Z);return v}}),Se("packages/core/src/compute/group.js",function(o,fe){"use strict";Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return ie}});const le=fe("packages/core/src/compute/handle.js"),ae=le.dictSize,Q=le.identity,q=le.presenceReader,te=le.rowCount,_=le.valueReader,F="",H="\\0",ne=1<<20;function x(G,D,Y,ee){const z=G.length,M=G.map(t=>_(t)),i=Array.isArray(ee)&&ee.some(Boolean),s=i?M.map((t,a)=>ee[a]?g=>ee[a](t(g)):t):M;if(!i&&z>0&&G.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=G.map(g=>ae(g.dict)+1);let a=1;for(let g=0;g<z;g++)a*=t[g];if(a<=Number.MAX_SAFE_INTEGER){const g=G.map(r=>r.values),e=G.map(r=>q(r)),m=r=>{let n=0;for(let l=0;l<z;l++){const b=e[l],E=b&&b(r)===0?t[l]-1:g[l][r];n=n*t[l]+E}return n},d=new Float64Array(Y);for(let r=0;r<Y;r++)d[r]=m(D[r]);return{packed:d,strings:null,product:a,readers:s,keyOf:m}}}const f=t=>{let a="";for(let g=0;g<z;g++){const e=s[g](t);a+=(g===0?"":F)+(e==null?H:String(e))}return a},c=new Array(Y);for(let t=0;t<Y;t++)c[t]=f(D[t]);return{packed:null,strings:c,product:1/0,readers:s,keyOf:f}}function ce(G,D,Y,ee){const z=new Uint32Array(ee+1);for(let u=0;u<Y;u++)z[D[u]+1]++;for(let u=0;u<ee;u++)z[u+1]+=z[u];const M=new Uint32Array(Y),i=z.slice(0,ee);for(let u=0;u<Y;u++)M[i[D[u]]++]=G[u];const s=new Array(ee);for(let u=0;u<ee;u++)s[u]=M.subarray(z[u],z[u+1]);return s}function ie(G,D,Y={}){const ee=G||[],z=D||Q(te(ee[0],Y)),M=z.length;if(ee.length===0||M===0)return{keys:[],buckets:[]};const{packed:i,strings:s,product:u,readers:f}=x(ee,z,M,Y.project),c=new Uint32Array(M);let t=0,a=null;if(i&&u<=Math.max(1024,Math.min(ne,M*4))){const d=u,r=new Int32Array(d).fill(-1);for(let n=0;n<M;n++)r[i[n]]=0;for(let n=0;n<d;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<d;n++)r[n]>=0&&(a[r[n]]=n)}else if(i){const d=new Map;for(let r=0;r<M;r++){const n=i[r];let l=d.get(n);l===void 0&&(l=t++,d.set(n,l)),c[r]=l}a=new Float64Array(t);for(const[r,n]of d)a[n]=r}else{const d=new Map;for(let r=0;r<M;r++){const n=s[r];let l=d.get(n);l===void 0&&(l=t++,d.set(n,l)),c[r]=l}}const g=ce(z,c,M,t),e=new Array(t);for(let d=0;d<t;d++){const r=g[d][0],n=new Array(f.length);for(let l=0;l<f.length;l++)n[l]=f[l](r);e[d]=n}const m={keys:e,buckets:g};return a&&(m.packed=a),m}}),Se("packages/core/src/compute/facet.js",function(o,fe){"use strict";Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return z}}),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 m}}),Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return r}});const le=fe("packages/core/src/compute/handle.js"),ae=le.presenceReader,Q=le.valueReader,q=le.dictSize,te=le.dictValue,_=Object.freeze(["equal","quantile","log"]),F=Object.freeze(["hour","day","week","month","quarter","year"]),H=20,ne=50,x=1e4;function ce(n,l){if(!n)return"none";const b=l&&l.base;if(b==="date"||b==="datetime"||b==="time"||b==="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 b==="number"?"numeric":b==="boolean"?"boolean":b==="text"?"category":"none"}}function ie(n){const l=n.values,b=n.kind;if((b==="float64"||b==="int32")&&l)return S=>l[S];const E=Q(n);return S=>G(E(S))}function G(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 b=Date.parse(n);return Number.isFinite(b)?b:NaN}return NaN}function D(n,l,b,E=ne){if(!n)return{cardinality:0,exact:!0};if(n.dict)return{cardinality:q(n.dict),exact:!0};if(n.kind==="bitset")return{cardinality:2,exact:!0};const S=Q(n),V=l?l.length:b,U=new Set;for(let I=0;I<V;I++){const X=S(l?l[I]:I);if(X!=null&&(U.add(X),U.size>E))return{cardinality:U.size,exact:!1}}return{cardinality:U.size,exact:!0}}const Y=36e5,ee=864e5;function z(n,l=H){const b=Number.isFinite(n)&&n>0?n:0,E=Math.max(1,l)*2;return b/Y<=E?"hour":b/ee<=E?"day":b/(7*ee)<=E?"week":b/(30*ee)<=E?"month":b/(91*ee)<=E?"quarter":"year"}function M(n,l){if(!Number.isFinite(n))return NaN;const b=new Date(n);switch(l){case"hour":return b.setMinutes(0,0,0),b.getTime();case"day":return b.setHours(0,0,0,0),b.getTime();case"week":{b.setHours(0,0,0,0);const E=(b.getDay()+6)%7;return b.setDate(b.getDate()-E),b.getTime()}case"month":return b.setDate(1),b.setHours(0,0,0,0),b.getTime();case"quarter":return b.setMonth(Math.floor(b.getMonth()/3)*3,1),b.setHours(0,0,0,0),b.getTime();default:return b.setMonth(0,1),b.setHours(0,0,0,0),b.getTime()}}function i(n,l){const b=new Date(n);switch(l){case"hour":b.setHours(b.getHours()+1);break;case"day":b.setDate(b.getDate()+1);break;case"week":b.setDate(b.getDate()+7);break;case"month":b.setMonth(b.getMonth()+1);break;case"quarter":b.setMonth(b.getMonth()+3);break;default:b.setFullYear(b.getFullYear()+1);break}return b.getTime()}function s(n,l,b){const E=ie(n),S=ae(n),V=l?l.length:b;let U=1/0,I=-1/0,X=0,C=0;for(let R=0;R<V;R++){const h=l?l[R]:R;if(S&&!S(h)){X++;continue}const O=E(h);if(!Number.isFinite(O)){X++;continue}O<U&&(U=O),O>I&&(I=O),C++}return{min:U,max:I,nulls:X,finite:C}}function u(n,l,b,E){const S=ie(n),V=ae(n),U=l?l.length:b,I=U>E?U/E:1,X=[];for(let R=0;R<U;R+=I){const h=l?l[Math.floor(R)]:Math.floor(R);if(V&&!V(h))continue;const O=S(h);Number.isFinite(O)&&X.push(O)}const C=Float64Array.from(X);return C.sort(),C}function f(n,l,b,E={}){const S=E.kind||ce(n,E.type);return S==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:S==="boolean"?c(n,l,b):S==="category"?t(n,l,b,E):a(n,l,b,S,E)}function c(n,l,b){const E=ae(n);let S=0;if(E){const U=l?l.length:b;for(let I=0;I<U;I++)E(l?l[I]:I)||S++}const V=[{value:!1,label:"false"},{value:!0,label:"true"}];return S>0&&V.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:V}}function t(n,l,b,E){const S=E.cardinalityLimit??ne,{cardinality:V}=D(n,l,b,S);if(V>S&&(E.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:V};const U=Q(n),I=l?l.length:b,X=new Map;let C=0;for(let P=0;P<I;P++){const v=U(l?l[P]:P);if(v==null||v===""){C++;continue}if(Array.isArray(v)){if(!v.length){C++;continue}for(const K of v)X.set(K,(X.get(K)||0)+1);continue}X.set(v,(X.get(v)||0)+1)}let R=[...X.entries()];E.order==="alpha"?R.sort((P,v)=>String(P[0]).localeCompare(String(v[0]))):R.sort((P,v)=>v[1]-P[1]);let h=0,O=0;if(R.length>S){O=R.length-S;for(let P=S;P<R.length;P++)h+=R[P][1];R=R.slice(0,S)}const w=R.map(([P])=>({value:P,label:String(P)}));return h>0&&w.push({remainder:!0,label:`Other (${O} values)`}),C>0&&w.push({null:!0,label:"Empty"}),{kind:"category",buckets:w,cardinality:V}}function a(n,l,b,E,S){const{min:V,max:U,nulls:I,finite:X}=s(n,l,b);if(!X)return{kind:E,buckets:I?[{null:!0,label:"Empty"}]:[],empty:!0};const C=Math.max(1,Math.floor(S.buckets||H));let R=[];if(E==="date"){const O=F.includes(S.granularity)?S.granularity:z(U-V,C);let w=M(V,O);for(;w<=U&&R.length<4096;){const P=i(w,O);if(!(P>w))break;R.push({from:w,to:P}),w=P}return{kind:E,buckets:g(R,I),granularity:O}}const h=_.includes(S.strategy)?S.strategy:"equal";if(h==="quantile"){const O=u(n,l,b,x);if(O.length){const w=[O[0]];for(let P=1;P<C;P++){const v=O[Math.min(O.length-1,Math.floor(P/C*O.length))];v>w[w.length-1]&&w.push(v)}w.push(U);for(let P=0;P<w.length-1;P++)R.push({from:w[P],to:w[P+1]})}}else if(h==="log"&&V>0){const O=Math.log10(V),P=(Math.log10(U)-O)/C||1;for(let v=0;v<C;v++)R.push({from:10**(O+v*P),to:10**(O+(v+1)*P)})}if(!R.length){const O=(U-V)/C||1;for(let w=0;w<C;w++)R.push({from:V+w*O,to:V+(w+1)*O})}return R[R.length-1].to=U,{kind:E,buckets:g(R,I),strategy:h,min:V,max:U}}function g(n,l){return l>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,l,b,E,S){const V=E&&E.buckets||[],U=S&&S.length>=V.length?S.subarray(0,V.length):new Uint32Array(V.length);if(U.fill(0),!n||!V.length)return U;const I=V.length-1,X=!!V[I]&&V[I].null===!0,C=l?l.length:b;if(E.kind==="boolean"){const P=Q(n);for(let v=0;v<C;v++){const K=P(l?l[v]:v);if(K==null){X&&U[I]++;continue}U[K?1:0]++}return U}if(E.kind==="category"){const P=new Map;for(let Z=0;Z<V.length;Z++)!V[Z].null&&!V[Z].remainder&&P.set(V[Z].value,Z);const v=V.findIndex(Z=>Z.remainder),K=Q(n);for(let Z=0;Z<C;Z++){const oe=K(l?l[Z]:Z);if(oe==null||oe===""){X&&U[I]++;continue}if(Array.isArray(oe)){if(!oe.length){X&&U[I]++;continue}for(const T of oe){const L=P.get(T);L!==void 0?U[L]++:v>=0&&U[v]++}continue}const se=P.get(oe);se!==void 0?U[se]++:v>=0&&U[v]++}return U}const R=X?V.length-1:V.length,h=new Float64Array(R+1);for(let P=0;P<R;P++)h[P]=V[P].from;h[R]=R?V[R-1].to:0;const O=ie(n),w=ae(n);for(let P=0;P<C;P++){const v=l?l[P]:P;if(w&&!w(v)){X&&U[I]++;continue}const K=O(v);if(!Number.isFinite(K)){X&&U[I]++;continue}const Z=m(h,R,K);Z>=0&&U[Z]++}return U}function m(n,l,b){if(!l||b<n[0])return-1;if(b>=n[l])return b===n[l]?l-1:-1;let E=0,S=l-1;for(;E<S;){const V=E+S+1>>>1;b>=n[V]?E=V:S=V-1}return E}function d(n,l,b,E={}){const S=E.bounds||f(n,E.boundsIndices??l,b,E);return{bounds:S,counts:e(n,l,b,S)}}const r=d}),Se("packages/core/src/compute/special.js",function(o,fe){"use strict";Object.defineProperty(o,"logGamma",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"incompleteBeta",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return ee}});const le=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),ae=3e-12,Q=1e-300;function q(z){if(z<.5)return Math.log(Math.PI/Math.sin(Math.PI*z))-q(1-z);const M=z-1;let i=.9999999999998099;const s=M+7.5;for(let u=0;u<le.length;u++)i+=le[u]/(M+u+1);return .5*Math.log(2*Math.PI)+(M+.5)*Math.log(s)-s+Math.log(i)}function te(z,M,i){const s=z+M,u=z+1,f=z-1;let c=1,t=1-s*i/u;Math.abs(t)<Q&&(t=Q),t=1/t;let a=t;for(let g=1;g<=300;g++){const e=2*g;let m=g*(M-g)*i/((f+e)*(z+e));t=1+m*t,Math.abs(t)<Q&&(t=Q),c=1+m/c,Math.abs(c)<Q&&(c=Q),t=1/t,a*=t*c,m=-(z+g)*(s+g)*i/((z+e)*(u+e)),t=1+m*t,Math.abs(t)<Q&&(t=Q),c=1+m/c,Math.abs(c)<Q&&(c=Q),t=1/t;const d=t*c;if(a*=d,Math.abs(d-1)<ae)break}return a}function _(z,M,i){if(!(z>0)||!(M>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const s=Math.exp(q(z+M)-q(z)-q(M)+z*Math.log(i)+M*Math.log(1-i));return i<(z+1)/(z+M+2)?s*te(z,M,i)/z:1-s*te(M,z,1-i)/M}function F(z){if(!(z>0)||!(z<1))return z===0?-1/0:z===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;z<f?(c=Math.sqrt(-2*Math.log(z)),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)):z<=1-f?(c=z-.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-z)),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*H(-a/Math.SQRT2)-z)*Math.sqrt(2*Math.PI)*Math.exp(a*a/2);return a-e/(1+a*e/2)}function H(z){const M=Math.abs(z),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 g=u.length-1;g>0;g--)t=c,c=s*c-f+u[g],f=t;const a=i*Math.exp(-M*M+.5*(u[0]+s*c)-f);return z>=0?a:2-a}function ne(z){return .5*H(-z/Math.SQRT2)}function x(z,M){if(!(M>0)||!Number.isFinite(z))return Number.NaN;const i=.5*_(M/2,.5,M/(M+z*z));return z>0?1-i:i}function ce(z,M){if(!(z>0)||!(z<1)||!(M>0))return Number.NaN;if(M>1e7)return F(z);let i=-1e4,s=1e4,u=F(z);const f=q(M/2)+q(.5)-q((M+1)/2);for(let c=0;c<60;c++){const t=x(u,M);t<z?i=u:s=u;const a=Math.exp(-((M+1)/2)*Math.log(1+u*u/M)-f)/Math.sqrt(M),g=a>0?(t-z)/a:0;if(Math.abs(g)<1e-12)break;const e=u-g;if(u=e>i&&e<s&&Number.isFinite(e)?e:(i+s)/2,s-i<1e-12)break}return u}function ie(z,M){let i=z,s=1/z,u=s;for(let f=0;f<300&&(i+=1,u*=M/i,s+=u,!(Math.abs(u)<Math.abs(s)*ae));f++);return s*Math.exp(-M+z*Math.log(M)-q(z))}function G(z,M){let i=M+1-z,s=1/Q,u=1/i,f=u;for(let c=1;c<=300;c++){const t=-c*(c-z);i+=2,u=t*u+i,Math.abs(u)<Q&&(u=Q),s=i+t/s,Math.abs(s)<Q&&(s=Q),u=1/u;const a=u*s;if(f*=a,Math.abs(a-1)<ae)break}return Math.exp(-M+z*Math.log(M)-q(z))*f}function D(z,M){return!(z>0)||!(M>=0)||!Number.isFinite(M)?Number.NaN:M===0?0:M<z+1?ie(z,M):1-G(z,M)}function Y(z,M){return M>0?D(M/2,z/2):Number.NaN}function ee(z,M){const i=Y(z,M);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Se("packages/core/src/compute/linalg.js",function(o,fe){"use strict";Object.defineProperty(o,"cholesky",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"choleskySolve",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"choleskyInverse",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return _}});function le(F){const H=F.length,ne=Array.from({length:H},()=>new Array(H).fill(0));for(let x=0;x<H;x++)for(let ce=0;ce<=x;ce++){let ie=F[x][ce];for(let G=0;G<ce;G++)ie-=ne[x][G]*ne[ce][G];if(x===ce){if(!(ie>0))return null;ne[x][ce]=Math.sqrt(ie)}else ne[x][ce]=ie/ne[ce][ce]}return ne}function ae(F,H){const ne=F.length,x=new Array(ne).fill(0);for(let ie=0;ie<ne;ie++){let G=H[ie];for(let D=0;D<ie;D++)G-=F[ie][D]*x[D];x[ie]=G/F[ie][ie]}const ce=new Array(ne).fill(0);for(let ie=ne-1;ie>=0;ie--){let G=x[ie];for(let D=ie+1;D<ne;D++)G-=F[D][ie]*ce[D];ce[ie]=G/F[ie][ie]}return ce}function Q(F){const H=F.length,ne=Array.from({length:H},()=>new Array(H).fill(0));for(let x=0;x<H;x++){const ce=new Array(H).fill(0);ce[x]=1;const ie=ae(F,ce);for(let G=0;G<H;G++)ne[G][x]=ie[G]}return ne}function q(F,H,ne){const x=F.length,ce=x?F[0].length:0,ie=Array.from({length:ce},()=>new Array(ce).fill(0)),G=new Array(ce).fill(0);for(let D=0;D<x;D++){const Y=ne?ne[D]:1,ee=F[D];for(let z=0;z<ce;z++){const M=Y*ee[z];G[z]+=M*H[D];for(let i=z;i<ce;i++)ie[z][i]+=M*ee[i]}}for(let D=0;D<ce;D++)for(let Y=0;Y<D;Y++)ie[D][Y]=ie[Y][D];return{xtwx:ie,xtwy:G}}function te(F,H){return F.map(ne=>ne.reduce((x,ce,ie)=>x+ce*H[ie],0))}function _(F,H){let ne=0;for(let x=0;x<F.length;x++){let ce=0;for(let ie=0;ie<F.length;ie++)ce+=H[x][ie]*F[ie];ne+=F[x]*ce}return ne}}),Se("packages/core/src/compute/sketch.js",function(o,fe){"use strict";Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return ie}});class le{#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(D){if(!Number.isFinite(D))return;this.#t++;const Y=D-this.#e;this.#e+=Y/this.#t,this.#n+=Y*(D-this.#e)}merge(D){if(D.#t===0)return;if(this.#t===0){this.#t=D.#t,this.#e=D.#e,this.#n=D.#n;return}const Y=this.#t+D.#t,ee=D.#e-this.#e;this.#e+=ee*(D.#t/Y),this.#n+=D.#n+ee*ee*(this.#t*D.#t/Y),this.#t=Y}mean(){return this.#t?this.#e:null}variance(){return this.#t>1?this.#n/(this.#t-1):null}varianceP(){return this.#t?this.#n/this.#t:null}stddev(){const D=this.variance();return D===null?null:Math.sqrt(D)}stddevP(){const D=this.varianceP();return D===null?null:Math.sqrt(D)}}class ae{#t=[];#e=0;#n;#r;constructor(D,Y=Math.random){if(!(D>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(D),this.#r=Y}static get errorBound(){return Object.freeze({kind:"probabilistic",metric:"none",value:0,statement:"uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators"})}get seen(){return this.#e}get size(){return this.#t.length}add(D){if(!Number.isFinite(D))return;if(this.#e++,this.#t.length<this.#n){this.#t.push(D);return}const Y=Math.floor(this.#r()*this.#e);Y<this.#n&&(this.#t[Y]=D)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let D=0;for(const Y of this.#t)D+=Y;return D/this.#t.length}quantile(D){const Y=this.#t.length;if(!Y)return null;const ee=this.#t.slice().sort((s,u)=>s-u);if(Y===1)return ee[0];const z=(Y-1)*Math.min(1,Math.max(0,D)),M=Math.floor(z),i=Math.ceil(z);return M===i?ee[M]:ee[M]+(z-M)*(ee[i]-ee[M])}}function Q(G){return G^=G>>>16,G=Math.imul(G,2246822507),G^=G>>>13,G=Math.imul(G,3266489909),G^=G>>>15,G>>>0}function q(G){if(typeof G=="number"){const ee=new DataView(new ArrayBuffer(8));return ee.setFloat64(0,G===0?0:G),Q(ee.getUint32(0)^ee.getUint32(4))}const D=typeof G=="string"?G:String(G);let Y=2166136261;for(let ee=0;ee<D.length;ee++)Y^=D.charCodeAt(ee),Y=Math.imul(Y,16777619);return Q(Y)}class te{#t;#e;#n;constructor(D=14){const Y=Math.floor(D);if(Y<4||Y>16)throw new RangeError("HLL precision must be 4..16");this.#t=Y,this.#e=1<<Y,this.#n=new Uint8Array(this.#e)}static errorBoundFor(D=14){const Y=1<<Math.floor(D),ee=1.04/Math.sqrt(Y);return Object.freeze({kind:"probabilistic",metric:"relative",value:ee,statement:`distinct count within ~${(ee*100).toFixed(2)}% relative standard error (m=${Y} buckets)`})}errorBound(){return te.errorBoundFor(this.#t)}add(D){const Y=q(D),ee=Y&this.#e-1,z=Y>>>this.#t|1<<32-this.#t;let M=1,i=z;for(;(i&1)===0;)M++,i>>>=1;M>this.#n[ee]&&(this.#n[ee]=M)}count(){const D=this.#e,Y=32-this.#t,ee=new Float64Array(Y+2);for(let i=0;i<D;i++)ee[this.#n[i]]++;let z=D*H(1-ee[Y+1]/D);for(let i=Y;i>=1;i--)z=.5*(z+ee[i]);z+=D*F(ee[0]/D);const M=_*D*D/z;return Math.round(M)}}const _=.5/Math.log(2);function F(G){if(G===1)return 1/0;let D=1,Y=G,ee;do G*=G,ee=Y,Y+=G*D,D+=D;while(Y!==ee);return Y}function H(G){if(G===0||G===1)return 0;let D=1,Y=1-G,ee;do G=Math.sqrt(G),ee=Y,D*=.5,Y-=(1-G)**2*D;while(Y!==ee);return Y/3}class ne{#t=new Map;#e;#n=0;constructor(D){if(!(D>0))throw new RangeError("Space-Saving capacity must be positive");this.#e=Math.floor(D)}errorBoundFor(D){const Y=D/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:Y,statement:`each count overestimates the truth by at most N/m = ${Y.toFixed(2)} (N=${D}, m=${this.#e})`})}get seen(){return this.#n}add(D){this.#n++;const Y=this.#t.get(D);if(Y){Y.count++;return}if(this.#t.size<this.#e){this.#t.set(D,{count:1,error:0});return}let ee,z=1/0;for(const[M,i]of this.#t)i.count<z&&(z=i.count,ee=M);this.#t.delete(ee),this.#t.set(D,{count:z+1,error:z})}top(D=this.#e){return[...this.#t.entries()].map(([ee,z])=>({item:ee,count:z.count,error:z.error})).sort((ee,z)=>z.count-ee.count).slice(0,Math.max(0,Math.floor(D)))}}class x{#t;#e=[[]];#n=0;#r;#i;constructor(D=200,Y=Math.random){this.#t=Math.max(8,Math.floor(D)),this.#r=Y,this.#i=2/3}static errorBoundFor(D=200){const Y=1/Math.max(8,Math.floor(D));return Object.freeze({kind:"probabilistic",metric:"rank",value:Y,statement:`queried quantile\'s true rank within ~${(Y*100).toFixed(2)}% of N of the requested rank (k=${D})`})}errorBound(){return x.errorBoundFor(this.#t)}get count(){return this.#n}#s(D){const ee=this.#e.length-1-D,z=Math.ceil(this.#t*this.#i**ee);return Math.max(2,z)}add(D){Number.isFinite(D)&&(this.#n++,this.#e[0].push(D),this.#e[0].length>=this.#s(0)&&this.#h(0))}#h(D){const Y=this.#e[D];Y.sort((M,i)=>M-i),D+1>=this.#e.length&&this.#e.push([]);const ee=this.#e[D+1],z=this.#r()<.5?0:1;for(let M=z;M<Y.length;M+=2)ee.push(Y[M]);this.#e[D]=[];for(let M=0;M<this.#e.length;M++)if(this.#e[M].length>=this.#s(M)){this.#h(M);return}}#u(){const D=[];for(let Y=0;Y<this.#e.length;Y++){const ee=1<<Y;for(const z of this.#e[Y])D.push({v:z,w:ee})}return D}quantile(D){const Y=this.#u();if(!Y.length)return null;Y.sort((i,s)=>i.v-s.v);let ee=0;for(const i of Y)ee+=i.w;const z=Math.min(1,Math.max(0,D))*ee;let M=0;for(const i of Y)if(M+=i.w,M>=z)return i.v;return Y[Y.length-1].v}rank(D){let Y=0;for(let ee=0;ee<this.#e.length;ee++){const z=1<<ee;for(const M of this.#e[ee])M<=D&&(Y+=z)}return Y}}const ce=Object.freeze({distinct:te.errorBoundFor(14),median:x.errorBoundFor(200),p25:x.errorBoundFor(200),p75:x.errorBoundFor(200),p90:x.errorBoundFor(200),p95:x.errorBoundFor(200),p99:x.errorBoundFor(200),iqr:x.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"})}),ie={Welford:le,Reservoir:ae,HyperLogLog:te,SpaceSaving:ne,KLL:x,hash32:q,SKETCH_BOUNDS:ce}}),Se("packages/core/src/compute/statistics.js",function(o,fe){"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 g}}),Object.defineProperty(o,"evenness",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"topShare",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"gini",{enumerable:!0,get:function(){return d}}),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 E}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"weightedAverage",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"extremeRow",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"correlation",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return O}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"fitLinearModel",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(o,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(o,"augmentedDickeyFuller",{enumerable:!0,get:function(){return We}}),Object.defineProperty(o,"autocorrelations",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(o,"spearman",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(o,"kendall",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(o,"seriesStats",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(o,"D2_N2",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(o,"D4_N2",{enumerable:!0,get:function(){return it}}),Object.defineProperty(o,"movingRanges",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(o,"withinSigma",{enumerable:!0,get:function(){return Ze}}),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 ot}}),Object.defineProperty(o,"nelsonViolations",{enumerable:!0,get:function(){return st}}),Object.defineProperty(o,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(o,"controlViolations",{enumerable:!0,get:function(){return At}}),Object.defineProperty(o,"countOutside",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(o,"histogram",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(o,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(o,"meanInterval",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(o,"proportionInterval",{enumerable:!0,get:function(){return St}}),Object.defineProperty(o,"slopeInterval",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(o,"capabilityInterval",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(o,"standardizedMeanDifference",{enumerable:!0,get:function(){return ut}}),Object.defineProperty(o,"normalTotalVariation",{enumerable:!0,get:function(){return ct}}),Object.defineProperty(o,"frequencyMap",{enumerable:!0,get:function(){return Je}}),Object.defineProperty(o,"categoricalDistance",{enumerable:!0,get:function(){return lt}}),Object.defineProperty(o,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(o,"compareColumn",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(o,"isNumericColumn",{enumerable:!0,get:function(){return at}}),Object.defineProperty(o,"populationRead",{enumerable:!0,get:function(){return Rt}});const le=fe("packages/core/src/compute/handle.js"),ae=le.presenceReader,Q=le.valueReader,q=fe("packages/core/src/compute/special.js"),te=q.studentTQuantile,_=q.studentT,F=q.normalQuantile,H=q.normalCdf,ne=q.chiSquareUpperTail,x=fe("packages/core/src/compute/linalg.js"),ce=x.cholesky,ie=x.choleskySolve,G=x.choleskyInverse,D=x.normalEquations,Y=x.quadForm,z=fe("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:z.distinct}),median:Object.freeze({sketch:"KLL",bound:z.median}),p25:Object.freeze({sketch:"KLL",bound:z.p25}),p75:Object.freeze({sketch:"KLL",bound:z.p75}),p90:Object.freeze({sketch:"KLL",bound:z.p90}),p95:Object.freeze({sketch:"KLL",bound:z.p95}),p99:Object.freeze({sketch:"KLL",bound:z.p99}),iqr:Object.freeze({sketch:"KLL",bound:z.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:z.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:z.topK})});function u(y){const A=y==="sum"||y==="avg"||y==="countValues"||y==="min"||y==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,y)?i[y]:null,p=Object.prototype.hasOwnProperty.call(s,y)?s[y]:null;return{stat:y,exact:A,approximate:p}}function f(y,A){const p=A.length,k=new Float64Array(p);let j=0;if(y&&(y.kind==="float64"||y.kind==="int32")){const B=y.values,$=ae(y);for(let re=0;re<p;re++){const ue=A[re];if($&&$(ue)!==1)continue;const ge=B[ue];Number.isNaN(ge)||(k[j++]=ge)}return k.subarray(0,j)}const W=Q(y);for(let B=0;B<p;B++){const $=W(A[B]);if($==null||$==="")continue;const re=typeof $=="number"?$:Number($);Number.isFinite(re)&&(k[j++]=re)}return k.subarray(0,j)}function c(y,A){const p=new Map,k=Q(y);let j=0;for(let W=0;W<A.length;W++){const B=k(A[W]);if(B==null||B===""||typeof B=="number"&&Number.isNaN(B))continue;const $=typeof B=="object"?String(B):B;p.set($,(p.get($)||0)+1),j++}const N=[...p.values()].sort((W,B)=>B-W);return{counts:N,total:j,distinct:N.length}}function t(y){return y.total>0?y.counts.map(A=>A/y.total):[]}function a(y,A){const p=c(y,A);if(!p.total)return null;let k=0;for(const j of t(p))k+=j*j;return k}function g(y,A){const p=c(y,A);if(!p.total)return null;let k=0;for(const j of t(p))j>0&&(k-=j*Math.log2(j));return k}function e(y,A){const p=c(y,A);if(!p.total||p.distinct<2)return p.total?1:null;let k=0;for(const j of t(p))j>0&&(k-=j*Math.log2(j));return k/Math.log2(p.distinct)}function m(y,A,p=3){const k=c(y,A);if(!k.total)return null;const j=Math.max(1,Math.floor(p));let N=0;for(let W=0;W<Math.min(j,k.counts.length);W++)N+=k.counts[W];return N/k.total}function d(y,A){const p=f(y,A),k=p.length;if(!k)return null;const j=p.slice().sort();if(j[0]<0)return null;let N=0,W=0;for(let B=0;B<k;B++)N+=j[B],W+=(B+1)*j[B];return N===0?0:2*W/(k*N)-(k+1)/k}function r(y){let A=0,p=0,k=0;for(let j=0;j<y.length;j++){const N=y[j];A++;const W=N-p;p+=W/A,k+=W*(N-p)}return{n:A,mean:p,m2:k}}function n(y,A){const p=y.length;if(!p)return NaN;if(p===1)return y[0];const k=(p-1)*Math.min(1,Math.max(0,A)),j=Math.floor(k),N=Math.ceil(k);return j===N?y[j]:y[j]+(k-j)*(y[N]-y[j])}function l(y,A){if(!y.length)return NaN;const p=y.slice().sort();return n(p,A)}function b(y,A){const p=Q(y);let k=0,j=0,N=0;for(let W=0;W<A.length;W++){const B=p(A[W]);if(B==null||B==="")continue;const $=String(B).toUpperCase();$==="PASS"?k++:$==="FAIL"?j++:$==="WARN"&&N++}return{pass:k+N,fail:j,warn:N,judged:k+N+j}}const E=Object.freeze({hhi:(y,A)=>a(y,A),entropy:(y,A)=>g(y,A),evenness:(y,A)=>e(y,A),top3Share:(y,A)=>m(y,A,3),top10Share:(y,A)=>m(y,A,10),gini:(y,A)=>d(y,A),trimmedMean:(y,A)=>X(f(y,A),.1),winsorizedMean:(y,A)=>C(f(y,A),.1),robustOutliers:(y,A)=>R(f(y,A),3.5),jarqueBera:(y,A)=>h(f(y,A)),variance:(y,A)=>{const{n:p,m2:k}=r(f(y,A));return p>1?k/(p-1):null},varianceP:(y,A)=>{const{n:p,m2:k}=r(f(y,A));return p>0?k/p:null},stddev:(y,A)=>{const{n:p,m2:k}=r(f(y,A));return p>1?Math.sqrt(k/(p-1)):null},stddevP:(y,A)=>{const{n:p,m2:k}=r(f(y,A));return p>0?Math.sqrt(k/p):null},median:(y,A)=>{const p=f(y,A);return p.length?l(p,.5):null},p25:(y,A)=>{const p=f(y,A);return p.length?l(p,.25):null},p75:(y,A)=>{const p=f(y,A);return p.length?l(p,.75):null},p90:(y,A)=>{const p=f(y,A);return p.length?l(p,.9):null},p95:(y,A)=>{const p=f(y,A);return p.length?l(p,.95):null},p99:(y,A)=>{const p=f(y,A);return p.length?l(p,.99):null},iqr:(y,A)=>{const p=f(y,A);if(!p.length)return null;const k=p.slice().sort();return n(k,.75)-n(k,.25)},mad:(y,A)=>{const p=f(y,A);if(!p.length)return null;const k=l(p,.5),j=new Float64Array(p.length);for(let N=0;N<p.length;N++)j[N]=Math.abs(p[N]-k);return l(j,.5)},range:(y,A)=>{const p=f(y,A);if(!p.length)return null;let k=1/0,j=-1/0;for(let N=0;N<p.length;N++)p[N]<k&&(k=p[N]),p[N]>j&&(j=p[N]);return j-k},distinct:(y,A)=>{const p=Q(y),k=new Set;for(let j=0;j<A.length;j++){const N=p(A[j]);N==null||N===""||k.add(N instanceof Date?N.getTime():N)}return k.size},mode:(y,A)=>{const p=Q(y),k=new Map;for(let W=0;W<A.length;W++){const B=p(A[W]);if(B==null||B==="")continue;const $=B instanceof Date?B.getTime():B;k.set($,(k.get($)||0)+1)}let j=null,N=1;for(const[W,B]of k)B>N&&(N=B,j=W);return j},skewness:(y,A)=>{const p=f(y,A),{n:k,mean:j,m2:N}=r(p);if(k<3||N<=0)return null;const W=Math.sqrt(N/(k-1));let B=0;for(let $=0;$<p.length;$++)B+=((p[$]-j)/W)**3;return k/((k-1)*(k-2))*B},kurtosis:(y,A)=>{const p=f(y,A),{n:k,mean:j,m2:N}=r(p);if(k<4||N<=0)return null;const W=Math.sqrt(N/(k-1));let B=0;for(let ue=0;ue<p.length;ue++)B+=((p[ue]-j)/W)**4;const $=k*(k+1)/((k-1)*(k-2)*(k-3)),re=3*(k-1)**2/((k-2)*(k-3));return $*B-re},geomean:(y,A)=>{const p=f(y,A);if(!p.length)return null;let k=0;for(let j=0;j<p.length;j++){if(p[j]<=0)return null;k+=Math.log(p[j])}return Math.exp(k/p.length)},harmean:(y,A)=>{const p=f(y,A);if(!p.length)return null;let k=0;for(let j=0;j<p.length;j++){if(p[j]===0)return null;k+=1/p[j]}return p.length/k},sumSquares:(y,A)=>{const p=f(y,A);let k=0;for(let j=0;j<p.length;j++)k+=p[j]*p[j];return k},passRate:(y,A)=>{const{pass:p,judged:k}=b(y,A);return k?p/k:null},failureCount:(y,A)=>b(y,A).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 V(y,A,p){const k=Q(y),j=Q(A);let N=0,W=0;for(let B=0;B<p.length;B++){const $=p[B],re=Number(k($)),ue=Number(j($));!Number.isFinite(re)||!Number.isFinite(ue)||(N+=re*ue,W+=ue)}return W===0?null:N/W}function U(y,A,p){const k=Q(y);let j=null,N=p?-1/0:1/0;for(let W=0;W<A.length;W++){const B=A[W],$=Number(k(B));Number.isFinite($)&&(p?$>N:$<N)&&(N=$,j=B)}return j}function I(y,A,p){const k=Q(y),j=Q(A);let N=0,W=0,B=0,$=0,re=0,ue=0;for(let de=0;de<p.length;de++){const we=p[de],ke=Number(k(we)),me=Number(j(we));!Number.isFinite(ke)||!Number.isFinite(me)||(N++,W+=ke,B+=me,$+=ke*ke,re+=me*me,ue+=ke*me)}if(N<2)return null;const ge=N*ue-W*B,be=Math.sqrt((N*$-W*W)*(N*re-B*B));if(be===0)return null;const pe=ge/be;return Math.max(-1,Math.min(1,pe))}function X(y,A=.1){const p=y.length;if(!p)return null;const k=Array.from(y).sort((B,$)=>B-$),j=Math.floor(p*Math.min(.49,Math.max(0,A))),N=k.slice(j,p-j);if(!N.length)return n(k,.5);let W=0;for(const B of N)W+=B;return W/N.length}function C(y,A=.1){const p=y.length;if(!p)return null;const k=Array.from(y).sort(($,re)=>$-re),j=Math.floor(p*Math.min(.49,Math.max(0,A))),N=k[j],W=k[p-1-j];let B=0;for(const $ of k)B+=Math.min(W,Math.max(N,$));return B/p}function R(y,A=3.5){if(!y.length)return null;const k=Array.from(y).sort(($,re)=>$-re),j=n(k,.5),N=k.map($=>Math.abs($-j)).sort(($,re)=>$-re),W=n(N,.5);if(W===0)return null;let B=0;for(const $ of k)Math.abs(.6745*($-j)/W)>A&&B++;return B}function h(y){const A=y.length;if(A<8)return null;let p=0;for(const $ of y)p+=$;p/=A;let k=0,j=0,N=0;for(const $ of y){const re=$-p;k+=re*re,j+=re*re*re,N+=re*re*re*re}if(k/=A,j/=A,N/=A,k===0)return null;const W=j/k**1.5,B=N/(k*k)-3;return A/6*(W*W+B*B/4)}function O(y,A,p){const k=[];let j=0;for(let $=0;$<y.length;$++){const re=Number(y[$]),ue=Number(A[$]);!Number.isFinite(re)||!Number.isFinite(ue)||ue<=0||(k.push([re,ue]),j+=ue)}if(!k.length||j<=0)return null;if(k.sort(($,re)=>$[0]-re[0]),k.length===1)return k[0][0];const N=[];let W=0;for(const[,$]of k)N.push((W+$/2)/j),W+=$;const B=Math.max(0,Math.min(1,p));if(B<=N[0])return k[0][0];if(B>=N[N.length-1])return k[k.length-1][0];for(let $=1;$<N.length;$++){if(B>N[$])continue;const re=N[$]-N[$-1],ue=re>0?(B-N[$-1])/re:0;return k[$-1][0]+(k[$][0]-k[$-1][0])*ue}return k[k.length-1][0]}function w(y,A,p){const k=Q(y),j=Q(A),N=new Float64Array(p.length),W=new Float64Array(p.length);let B=0;for(let $=0;$<p.length;$++){const re=p[$],ue=Number(k(re)),ge=Number(j(re));!Number.isFinite(ue)||!Number.isFinite(ge)||(N[B]=ue,W[B]=ge,B++)}return{xs:N.subarray(0,B),ys:W.subarray(0,B),n:B}}function P(y,A,p,k=!1){const{xs:j,ys:N,n:W}=w(y,A,p);if(W<2)return null;let B=0,$=0;for(let ue=0;ue<W;ue++)B+=j[ue],$+=N[ue];B/=W,$/=W;let re=0;for(let ue=0;ue<W;ue++)re+=(j[ue]-B)*(N[ue]-$);return re/(k?W:W-1)}function v(y,A,p){const{xs:k,ys:j,n:N}=w(y,A,p);if(N<2)return null;let W=0,B=0;for(let ke=0;ke<N;ke++)W+=k[ke],B+=j[ke];W/=N,B/=N;let $=0,re=0,ue=0;for(let ke=0;ke<N;ke++){const me=k[ke]-W,ve=j[ke]-B;$+=me*me,re+=me*ve,ue+=ve*ve}if($===0)return null;const ge=re/$,be=B-ge*W,pe=ue===0?1:Math.max(0,Math.min(1,re*re/($*ue))),de=Math.max(0,ue-ge*re),we=N>2?Math.sqrt(de/(N-2)/$):0;return{slope:ge,intercept:be,r2:pe,stdError:we,n:N}}const K=new Set(["ols","wls","robust"]),Z=new Set(["quantile"]),oe=new Set(["ridge","lasso","elasticnet","mixed","gls"]),se=1.345;function T(y,A,p){const{xtwx:k,xtwy:j}=D(y,A,p),N=ce(k);if(!N)return null;const W=ie(N,j),B=G(N),$=L(y,W),re=A.map((ue,ge)=>ue-$[ge]);return{beta:W,cov:B,fitted:$,residuals:re}}function L(y,A){return y.map(p=>p.reduce((k,j,N)=>k+j*A[N],0))}function J(y,A){const p=y.length,k=y.map(re=>re[A]),j=y.map(re=>[1,...re.filter((ue,ge)=>ge!==A)]),N=T(j,k,null);if(!N)return 1;const W=k.reduce((re,ue)=>re+ue,0)/p;let B=0,$=0;for(let re=0;re<p;re++)B+=N.residuals[re]**2,$+=(k[re]-W)**2;return $===0?1:Math.max(0,Math.min(1,1-B/$))}function he(y){const A=[...y].sort((j,N)=>j-N),p=ye(A),k=y.map(j=>Math.abs(j-p)).sort((j,N)=>j-N);return ye(k)/.6745}function ye(y){const A=y.length;if(!A)return 0;const p=Math.floor(A/2);return A%2?y[p]:(y[p-1]+y[p])/2}function Me(y,A,p={}){const k=p.method||"ols";if(oe.has(k))throw new Error(`[lattice] regression method "${k}" is out of scope; use ols, wls or robust.`);if(Z.has(k))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!K.has(k))throw new Error(`[lattice] unknown regression method "${k}"; use ols, wls or robust.`);const j=Array.isArray(A)?A.length:0,N=j&&Array.isArray(y[0])?y[0].length:0,W=N+1;if(!(j>W))return null;for(let Oe=0;Oe<j;Oe++){if(!Number.isFinite(A[Oe])||!Array.isArray(y[Oe])||y[Oe].length!==N)return null;for(let Ae=0;Ae<N;Ae++)if(!Number.isFinite(y[Oe][Ae]))return null}let B=null;if(k==="wls"){if(B=p.weights,!Array.isArray(B)||B.length!==j)return null;for(let Oe=0;Oe<j;Oe++)if(!(B[Oe]>0)||!Number.isFinite(B[Oe]))return null}const $=y.map(Oe=>[1,...Oe]);let re,ue=null;if(k==="robust"){if(re=T($,A,null),!re)return null;for(let Oe=0;Oe<50;Oe++){const Ae=he(re.residuals);if(!(Ae>0))break;const Te=re.residuals.map(Ie=>{const Be=Math.abs(Ie/Ae);return Be<=se?1:se/Be}),Re=T($,A,Te);if(!Re)return null;const ze=Re.beta.reduce((Ie,Be,Qe)=>Math.max(Ie,Math.abs(Be-re.beta[Qe])),0);if(re=Re,ue=Te,ze<1e-10)break}}else if(re=T($,A,B),!re)return null;const ge=k==="robust"?ue:B,{beta:be,cov:pe,fitted:de,residuals:we}=re;let ke=0,me=0,ve=0;for(let Oe=0;Oe<j;Oe++){const Ae=ge?ge[Oe]:1;ke+=Ae*we[Oe]**2,me+=Ae,ve+=Ae*A[Oe]}const Ee=ve/me;let Le=0;for(let Oe=0;Oe<j;Oe++){const Ae=ge?ge[Oe]:1;Le+=Ae*(A[Oe]-Ee)**2}const Fe=j-W,De=ke/Fe,Ce=Le===0?1:Math.max(0,Math.min(1,1-ke/Le)),_e=1-(1-Ce)*(j-1)/Fe,Ge=Array.isArray(p.names)&&p.names.length===N?p.names:y[0].map((Oe,Ae)=>`x${Ae+1}`),Ue=He(p.confidence),Ye=Fe>0?te(1-(1-Ue)/2,Fe):1/0,Lt=be.map((Oe,Ae)=>{const Te=Math.sqrt(Math.max(0,De*pe[Ae][Ae])),Re=Te>0?Oe/Te:Oe===0?0:1/0,ze=Number.isFinite(Re)?2*(1-_(Math.abs(Re),Fe)):0,Ie=Number.isFinite(Ye)?Ye*Te:null;return{name:Ae===0?"(intercept)":Ge[Ae-1],estimate:Oe,stdError:Te,t:Re,p:Math.max(0,Math.min(1,ze)),lower:Ie===null?null:Oe-Ie,upper:Ie===null?null:Oe+Ie}}),ft=new Array(j),ht=new Array(j);for(let Oe=0;Oe<j;Oe++){const Ae=ge?ge[Oe]:1,Te=Math.max(0,Math.min(1,Ae*Y($[Oe],pe)));ft[Oe]=Te;const Re=(1-Te)**2;ht[Oe]=Re>0&&De>0?we[Oe]**2/(W*De)*(Te/Re):null}const Ft=y[0].map((Oe,Ae)=>{if(N<2)return 1;const Te=J(y,Ae);return Te>=1?1/0:1/(1-Te)});let dt=null;{const Oe=we.map(Te=>Te*Te),Ae=T($,Oe,null);if(Ae){const Te=Oe.reduce((Ke,Ct)=>Ke+Ct,0)/j;let Re=0,ze=0;for(let Ke=0;Ke<j;Ke++)Re+=Ae.residuals[Ke]**2,ze+=(Oe[Ke]-Te)**2;const Ie=ze===0?0:Math.max(0,Math.min(1,1-Re/ze)),Be=j*Ie,Qe=ne(Be,N);dt={statistic:Be,df:N,p:Qe,heteroscedastic:Qe<.05}}}let mt=null;if(N===1){const Oe=y.map((Ae,Te)=>Te).sort((Ae,Te)=>y[Ae][0]-y[Te][0]);mt={confidence:Ue,points:Oe.map(Ae=>{const Te=$[Ae],Re=Math.sqrt(Math.max(0,De*Y(Te,pe)));return{x:y[Ae][0],yhat:de[Ae],lower:de[Ae]-Ye*Re,upper:de[Ae]+Ye*Re}})}}return{method:k,coefficients:Lt,r2:Ce,adjR2:_e,n:j,df:Fe,sigma2:De,fitted:de,residuals:we,leverage:ft,cooksD:ht,vif:Ft,heteroscedasticity:dt,band:mt,weights:ge?[...ge]:null}}function Pe(y){const A=y.length,p=Array.from({length:A},(N,W)=>W).sort((N,W)=>y[N]-y[W]),k=new Float64Array(A);let j=0;for(;j<A;){let N=j;for(;N+1<A&&y[p[N+1]]===y[p[j]];)N++;const W=(j+N)/2+1;for(let B=j;B<=N;B++)k[p[B]]=W;j=N+1}return k}const Ne=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function je(y){const A=[.01,.05,.1],p=[Ne["1%"],Ne["5%"],Ne["10%"]];if(y<=p[0]){const N=(Math.log(A[1])-Math.log(A[0]))/(p[1]-p[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(A[0])+N*(y-p[0]))))}if(y>=p[2]){const N=(Math.log(A[2])-Math.log(A[1]))/(p[2]-p[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(A[2])+N*(y-p[2]))))}const k=y<p[1]?0:1,j=(y-p[k])/(p[k+1]-p[k]);return Math.exp(Math.log(A[k])+j*(Math.log(A[k+1])-Math.log(A[k])))}function Ve(y,A,p,k){const j=p-k,N=k+3,W=new Array(j),B=new Array(j);let $=!0,re=k;for(let de=0;de<j;de++){const we=k+de,ke=new Float64Array(N);ke[0]=1,ke[1]=de+1,ke[2]=y[we];for(let me=1;me<=k;me++)ke[2+me]=A[we-me];for(let me=1;me<N;me++)Number.isFinite(ke[me])||(re=Math.min(re,me-3));W[de]=ke,B[de]=A[we],Number.isFinite(B[de])||($=!1)}if(!$)return 0;const{xtwx:ue,xtwy:ge}=D(W,B,null);let be=0,pe=1/0;for(let de=0;de<=re;de++){const we=de+3;if(!(j>we))continue;const ke=new Array(we);for(let Ce=0;Ce<we;Ce++)ke[Ce]=ue[Ce].slice(0,we);const me=ce(ke);if(!me)continue;const ve=ie(me,ge.slice(0,we));let Ee=0;for(let Ce=0;Ce<j;Ce++){const _e=W[Ce];let Ge=0;for(let Ue=0;Ue<we;Ue++)Ge+=_e[Ue]*ve[Ue];Ee+=(B[Ce]-Ge)**2}const Fe=Ee/(j-we)*(j-we);if(!(Fe>0))continue;const De=j*Math.log(Fe/j)+2*we;De<pe&&(pe=De,be=de)}return be}function We(y,A={}){const p=[];for(let pe=0;pe<y.length;pe++){const de=Number(y[pe]);Number.isFinite(de)&&p.push(de)}const k=p.length,j=k-1;if(k<8||j<6)return null;const N=new Array(j);for(let pe=0;pe<j;pe++)N[pe]=p[pe+1]-p[pe];let W=Number.isFinite(A.maxlag)?Math.floor(A.maxlag):Math.ceil(12*(k/100)**.25);W=Math.max(0,Math.min(W,Math.floor((j-5)/2)));const B=(pe,de)=>{const we=[],ke=[];for(let me=de;me<j;me++){const ve=[me-de+1,p[me]];for(let Ee=1;Ee<=pe;Ee++)ve.push(N[me-Ee]);we.push(ve),ke.push(N[me])}return Me(we,ke,{method:"ols"})},$=Ve(p,N,j,W),re=B($,$);if(!re||!re.coefficients[2])return null;const ue=re.coefficients[2].t,ge=je(ue),be=ue<Ne["5%"];return{statistic:ue,usedLag:$,nobs:j-$,criticalValues:{...Ne},pValue:ge,pApproximate:!0,stationary:be,verdict:be?"stationary":"non-stationary",regression:"ct"}}function Xe(y,A={}){const p=[];for(let be=0;be<y.length;be++){const pe=Number(y[be]);Number.isFinite(pe)&&p.push(pe)}const k=p.length;if(k<3)return null;let j=Number.isFinite(A.maxlag)?Math.floor(A.maxlag):Math.min(10,k-1);j=Math.max(1,Math.min(j,k-1));let N=0;for(const be of p)N+=be;N/=k;const W=p.map(be=>be-N);let B=0;for(const be of W)B+=be*be;B/=k;const $=new Array(j+1).fill(0);$[0]=1;for(let be=1;be<=j;be++){let pe=0;for(let de=be;de<k;de++)pe+=W[de]*W[de-be];$[be]=B>0?pe/k/B:0}const re=new Array(j+1).fill(0);re[0]=1;let ue=[];for(let be=1;be<=j;be++){let pe=$[be];for(let me=1;me<be;me++)pe-=ue[me-1]*$[be-me];let de=1;for(let me=1;me<be;me++)de-=ue[me-1]*$[me];const we=de!==0?pe/de:0,ke=new Array(be);for(let me=1;me<be;me++)ke[me-1]=ue[me-1]-we*ue[be-1-me];ke[be-1]=we,re[be]=we,ue=ke}const ge=1.96/Math.sqrt(k);return{acf:$,pacf:re,bounds:{upper:ge,lower:-ge},n:k,nlags:j,approximate:!0}}function qe(y,A,p){const{xs:k,ys:j,n:N}=w(y,A,p);if(N<2)return null;const W=Pe(k),B=Pe(j);let $=0,re=0;for(let pe=0;pe<N;pe++)$+=W[pe],re+=B[pe];$/=N,re/=N;let ue=0,ge=0,be=0;for(let pe=0;pe<N;pe++){const de=W[pe]-$,we=B[pe]-re;ue+=de*we,ge+=de*de,be+=we*we}return ge===0||be===0?null:Math.max(-1,Math.min(1,ue/Math.sqrt(ge*be)))}function yt(y,A,p){const{xs:k,ys:j,n:N}=w(y,A,p);if(N<2||N>M)return null;let W=0,B=0,$=0,re=0;for(let be=0;be<N;be++)for(let pe=be+1;pe<N;pe++){const de=Math.sign(k[be]-k[pe]),we=Math.sign(j[be]-j[pe]),ke=de*we;ke>0?W++:ke<0?B++:de===0&&we===0||(de===0?$++:re++)}const ue=W+B+re,ge=W+B+$;return ue===0||ge===0?null:(W-B)/Math.sqrt(ue*ge)}function pt(y,A={}){const p=y.length;if(p<2)return null;const k=y[0],j=y[p-1],N=[];for(let me=1;me<p;me++){const ve=y[me-1];ve!==0&&N.push((y[me]-ve)/Math.abs(ve))}let W=null;if(N.length>1){let me=0;for(const Ee of N)me+=Ee;me/=N.length;let ve=0;for(const Ee of N)ve+=(Ee-me)**2;W=Math.sqrt(ve/(N.length-1))}const B=Number(A.periodsPerYear)>0?Number(A.periodsPerYear):null;let $=y[0],re=0,ue=0,ge=0,be=0;for(let me=1;me<p;me++){if(y[me]>$){$=y[me],re=me;continue}if($<=0)continue;const ve=($-y[me])/$;ve>ue&&(ue=ve,ge=re,be=me)}let pe=null;if(p>2){let me=0;for(let Le=0;Le<p;Le++)me+=y[Le];me/=p;let ve=0,Ee=0;for(let Le=0;Le<p;Le++){const Fe=y[Le]-me;Ee+=Fe*Fe,Le>0&&(ve+=Fe*(y[Le-1]-me))}pe=Ee>0?ve/Ee:null}let de=0,we=0;for(const me of N)me>0?de++:me<0&&we++;let ke=null;if(k>0&&j>0){const me=(j/k)**(1/(p-1))-1;ke=B?(1+me)**B-1:me}return{n:p,first:k,last:j,change:j-k,changePercent:k===0?null:(j-k)/Math.abs(k)*100,volatility:W,annualisedVolatility:W!==null&&B?W*Math.sqrt(B):null,growth:ke,maxDrawdown:ue,maxDrawdownFrom:ge,maxDrawdownTo:be,autocorrelation:pe,upDays:de,downDays:we}}const rt=1.128,it=3.267;function wt(y){const A=y.length;if(A<2)return null;const p=[];for(let j=1;j<A;j++)p.push(Math.abs(y[j]-y[j-1]));const k=p.reduce((j,N)=>j+N,0)/p.length;return{ranges:p,centre:k,upper:it*k,lower:0}}function Ze(y){const A=y.length;if(A<2)return null;let p=0;for(let j=1;j<A;j++)p+=Math.abs(y[j]-y[j-1]);const k=p/(A-1);return{sigma:k/rt,meanRange:k}}function Ot(y,A){const p=y.length;if(p<2||!A)return null;const k=Number.isFinite(Number(A.lower))?Number(A.lower):null,j=Number.isFinite(Number(A.upper))?Number(A.upper):null;if(k===null&&j===null)return null;let N=0;for(let de=0;de<p;de++)N+=y[de];N/=p;let W=0;for(let de=0;de<p;de++)W+=(y[de]-N)**2;const B=Math.sqrt(W/(p-1)),$=Ze(y),re=$?$.sigma:null,ue=de=>{if(!de||de<=0)return{index:null,k:null};const ke=k!==null&&j!==null?(j-k)/(6*de):null,me=j!==null?(j-N)/(3*de):1/0,ve=k!==null?(N-k)/(3*de):1/0;return{index:ke,k:Math.min(me,ve)}},ge=ue(re),be=ue(B);let pe=0;for(let de=0;de<p;de++){if(k!==null&&y[de]<k){pe++;continue}j!==null&&y[de]>j&&pe++}return{n:p,mean:N,lower:k,upper:j,target:Number.isFinite(Number(A.target))?Number(A.target):null,sigmaWithin:re,sigmaOverall:B,cp:ge.index,cpk:ge.k,pp:be.index,ppk:be.k,outOfSpec:pe,defectRate:p?pe/p:null}}function kt(y){const A=y.length;if(A<2)return null;const p=Ze(y);if(!p||!(p.sigma>0))return null;let k=0;for(let j=0;j<A;j++)k+=y[j];return k/=A,{centre:k,sigma:p.sigma,upper:k+3*p.sigma,lower:k-3*p.sigma}}function ot(y,A){if(!A||!(A.sigma>0))return[];const p=y.length,{centre:k,sigma:j}=A,N=B=>(y[B]-k)/j,W=[];for(let B=0;B<p;B++){if(Math.abs(N(B))>3&&W.push({index:B,rule:1,description:"beyond three sigma"}),B>=2)for(const $ of[1,-1]){let re=0;for(let ue=B-2;ue<=B;ue++)N(ue)*$>2&&re++;if(re>=2){W.push({index:B,rule:2,description:"two of three past two sigma"});break}}if(B>=4)for(const $ of[1,-1]){let re=0;for(let ue=B-4;ue<=B;ue++)N(ue)*$>1&&re++;if(re>=4){W.push({index:B,rule:3,description:"four of five past one sigma"});break}}if(B>=7)for(const $ of[1,-1]){let re=!0;for(let ue=B-7;ue<=B;ue++)if(N(ue)*$<=0){re=!1;break}if(re){W.push({index:B,rule:4,description:"eight in a row on one side"});break}}}return W}function st(y,A){if(!A||!(A.sigma>0))return[];const p=y.length,{centre:k,sigma:j}=A,N=$=>(y[$]-k)/j,W=($,re,ue,ge)=>{for(const be of[1,-1]){let pe=0;for(let de=$;de<=re;de++)N(de)*be>ue&&pe++;if(pe>=ge)return!0}return!1},B=[];for(let $=0;$<p;$++){if(Math.abs(N($))>3&&B.push({index:$,rule:1,description:"beyond three sigma"}),$>=8)for(const re of[1,-1]){let ue=!0;for(let ge=$-8;ge<=$;ge++)if(N(ge)*re<=0){ue=!1;break}if(ue){B.push({index:$,rule:2,description:"nine in a row on one side"});break}}if($>=5)for(const re of[1,-1]){let ue=!0;for(let ge=$-4;ge<=$;ge++)if((y[ge]-y[ge-1])*re<=0){ue=!1;break}if(ue){B.push({index:$,rule:3,description:re>0?"six rising":"six falling"});break}}if($>=13){let re=!0;for(let ue=$-12;ue<=$;ue++){const ge=y[ue]-y[ue-1],be=y[ue+1<=$?ue+1:ue]-y[ue];if(ue+1>$)break;if(ge===0||be===0||ge>0==be>0){re=!1;break}}re&&B.push({index:$,rule:4,description:"fourteen alternating"})}if($>=2&&W($-2,$,2,2)&&B.push({index:$,rule:5,description:"two of three past two sigma"}),$>=4&&W($-4,$,1,4)&&B.push({index:$,rule:6,description:"four of five past one sigma"}),$>=14){let re=!0;for(let ue=$-14;ue<=$;ue++)if(Math.abs(N(ue))>=1){re=!1;break}re&&B.push({index:$,rule:7,description:"fifteen within one sigma"})}if($>=7){let re=!0;for(let ue=$-7;ue<=$;ue++)if(Math.abs(N(ue))<=1){re=!1;break}re&&B.push({index:$,rule:8,description:"eight beyond one sigma"})}}return B}const jt=Object.freeze(["westernElectric","nelson"]);function At(y,A,p="westernElectric"){return String(p)==="nelson"?st(y,A):ot(y,A)}function Mt(y,A,p){let k=0;for(let j=0;j<y.length;j++)(y[j]<A||y[j]>p)&&k++;return k}function Pt(y,A,p,k=20){const j=y.length;if(!j)return[];const N=y[0],W=y[j-1];if(W===N)return[{from:N,to:W,count:j}];const B=p-A,$=1.5*B;let re=B>0?Math.max(N,A-$):N,ue=B>0?Math.min(W,p+$):W;ue>re||(re=N,ue=W);const ge=B>0?2*B/Math.cbrt(j):(ue-re)/(Math.ceil(Math.log2(j))+1),be=ge>0?Math.min(k,Math.max(1,Math.ceil((ue-re)/ge))):1,pe=(ue-re)/be,de=[];for(let we=0;we<be;we++)de.push({from:re+we*pe,to:re+(we+1)*pe,count:0});for(let we=0;we<j;we++){const ke=Math.min(be-1,Math.max(0,Math.floor((y[we]-re)/pe)));de[ke].count++}return de[0].from=N,de[be-1].to=W,de}const $e=.95;function He(y){const A=Number(y);return Number.isFinite(A)&&A>0&&A<1?A:$e}function Nt(y,A=$e){const p=y.length;if(p<2)return null;let k=0;for(let ue=0;ue<p;ue++)k+=y[ue];const j=k/p;let N=0;for(let ue=0;ue<p;ue++){const ge=y[ue]-j;N+=ge*ge}const W=Math.sqrt(N/(p-1)),B=He(A),re=te(1-(1-B)/2,p-1)*W/Math.sqrt(p);return{mean:j,lower:j-re,upper:j+re,margin:re,n:p,confidence:B}}function St(y,A,p=$e){const k=Number(y),j=Number(A);if(!(j>0)||!(k>=0)||k>j)return null;const N=He(p),W=F(1-(1-N)/2),B=k/j,$=W*W,re=1+$/j,ue=(B+$/(2*j))/re,ge=W/re*Math.sqrt(B*(1-B)/j+$/(4*j*j));return{proportion:B,lower:Math.max(0,ue-ge),upper:Math.min(1,ue+ge),n:j,confidence:N}}function vt(y,A=$e){if(!y||!(y.n>2)||!Number.isFinite(y.stdError))return null;const p=He(A),j=te(1-(1-p)/2,y.n-2)*y.stdError;return{slope:y.slope,lower:y.slope-j,upper:y.slope+j,margin:j,confidence:p}}function Tt(y,A,p=$e){const k=Number(y),j=Number(A);if(!Number.isFinite(k)||!(j>1))return null;const N=He(p),B=F(1-(1-N)/2)*Math.sqrt(1/(9*j)+k*k/(2*(j-1)));return{index:k,lower:k-B,upper:k+B,margin:B,n:j,confidence:N}}function ut(y,A){return!y||!(y.sd>0)||!Number.isFinite(A)||!Number.isFinite(y.mean)?null:(A-y.mean)/y.sd}function ct(y){return Number.isFinite(y)?Math.min(1,Math.max(0,2*H(Math.abs(y)/2)-1)):0}function Je(y,A){const p=new Map,k=Q(y);let j=0;for(let N=0;N<A.length;N++){const W=k(A[N]);if(W==null||W===""||typeof W=="number"&&Number.isNaN(W))continue;const B=W instanceof Date?W.getTime():typeof W=="object"?String(W):W;p.set(B,(p.get(B)||0)+1),j++}return{map:p,total:j}}function lt(y,A,p,k){if(!(A>0)||!(k>0))return null;let j=0;const N=new Set(y.keys());for(const W of p.keys())N.add(W);for(const W of N){const B=(y.get(W)||0)/A,$=(p.get(W)||0)/k;j+=Math.abs(B-$)}return j/2}const xe=10;function Et(y,A,p){if(p&&p.numeric){const B=f(y,A),{n:$,mean:re}=r(B),ue=$>0?ut({mean:p.mean,sd:p.sd},re):null;return{measure:"standardizedMeanDifference",magnitude:ue,distance:ue===null?0:ct(ue),direction:ue===null?0:Math.sign(ue),subsetN:$,populationN:p.n||0,reliable:$>=xe}}const{map:j,total:N}=Je(y,A),W=lt(j,N,p.map,p.total);return{measure:"categoricalTotalVariation",magnitude:W,distance:W===null?0:W,direction:0,subsetN:N,populationN:p.total||0,reliable:N>=xe}}function at(y,A){if(y&&(y.kind==="float64"||y.kind==="int32"))return!0;const p=Q(y);let k=0,j=0;for(let N=0;N<A.length&&k<200;N++){const W=p(A[N]);if(W==null||W==="")continue;if(W instanceof Date)return!1;k++;const B=typeof W=="number"?W:Number(W);Number.isFinite(B)&&j++}return k===0?!1:j/k>=.9}function Rt(y,A){if(at(y,A)){const j=f(y,A),{n:N,mean:W,m2:B}=r(j);return{numeric:!0,mean:W,sd:N>0?Math.sqrt(B/N):0,n:N}}const{map:p,total:k}=Je(y,A);return{numeric:!1,map:p,total:k}}}),Se("packages/core/src/compute/total.js",function(o,fe){"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 g}}),Object.defineProperty(o,"aggregateAllowed",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return d}});const le=fe("packages/core/src/internal/util.js"),ae=le.isFunction,Q=le.warnOnce,q=fe("packages/core/src/compute/handle.js"),te=q.presenceReader,_=q.valueComparator,F=q.valueReader,H=fe("packages/core/src/compute/statistics.js"),ne=H.STAT_FNS,x=H.STAT_LABELS;function ce(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function ie(r,n){const l=n.length;let b=0;if(ce(r)){const S=r.values,V=te(r);if(!V){for(let U=0;U<l;U++){const I=S[n[U]];Number.isNaN(I)||(b+=I)}return b}for(let U=0;U<l;U++){const I=n[U];if(V(I)===1){const X=S[I];Number.isNaN(X)||(b+=X)}}return b}const E=F(r);for(let S=0;S<l;S++){const V=u(E(n[S]));V!==null&&(b+=V)}return b}ie.kernel=!0;function G(r,n){const l=n.length;let b=0;if(ce(r)){const S=r.values,V=te(r);if(!V){for(let U=0;U<l;U++)Number.isNaN(S[n[U]])||b++;return b}for(let U=0;U<l;U++){const I=n[U];V(I)===1&&!Number.isNaN(S[I])&&b++}return b}const E=F(r);for(let S=0;S<l;S++){const V=E(n[S]);V!=null&&!(typeof V=="number"&&Number.isNaN(V))&&b++}return b}G.kernel=!0;function D(r,n){return n.length}D.kernel=!0;function Y(r,n){const l=G(r,n);return l===0?null:ie(r,n)/l}Y.kernel=!0;function ee(r,n,l,b){const E=n.length;if(ce(r)){const I=r.values,X=te(r);let C=null;if(!X){for(let R=0;R<E;R++){const h=I[n[R]];Number.isNaN(h)||(C===null||(l<0?h<C:h>C))&&(C=h)}return C}for(let R=0;R<E;R++){const h=n[R];if(X(h)===0)continue;const O=I[h];Number.isNaN(O)||(C===null||(l<0?O<C:O>C))&&(C=O)}return C}const S=F(r),V=_(b);let U=null;for(let I=0;I<E;I++){const X=S(n[I]);X==null||typeof X=="number"&&Number.isNaN(X)||(U===null||(l<0?V(X,U)<0:V(X,U)>0))&&(U=X)}return U}function z(r,n,l){return ee(r,n,-1,l&&l.locale)}z.kernel=!0;function M(r,n,l){return ee(r,n,1,l&&l.locale)}M.kernel=!0;function i(r,n){return n.length===0?null:F(r)(n[0])}i.kernel=!0;function s(r,n){return n.length===0?null:F(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:ie,min:z,max:M,avg:Y,count:D,first:i,last:s,countValues:G,...ne},c=Object.freeze({...x,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 g(r){const n=r&&r.dataType&&r.dataType.totals&&r.dataType.totals.supported;if(Array.isArray(n))return n.slice();const l=a.filter(b=>b in f);for(const b of Object.keys(f))l.includes(b)||l.push(b);return l}function e(r,n){return typeof n!="string"?!0:g(r).includes(n)}function m(r,n){const l=F(r),b=[];for(let E=0;E<n.length;E++){const S=l(n[E]);S!=null&&b.push(S)}return b}function d(r,n,l,b){const E=n||[];if(typeof l=="string"){const S=f[l];return S?S(r,E,b):(Q(`total:${l}`,`unknown total function "${l}"; register it in config.totalFns`),null)}return ae(l)?l.kernel===!0?l(r,E,b):l(m(r,E),b||{}):null}}),Se("packages/core/src/compute/pivot.js",function(o,fe){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return M}});const ae=fe("packages/core/src/internal/util.js").warnOnce,q=fe("packages/core/src/compute/handle.js").valueComparator,_=fe("packages/core/src/compute/group.js").packKeys,H=fe("packages/core/src/compute/total.js").total,ne="|",x="/",ce=2e3;function ie(u,f,c){return`${u}${ne}${f}${ne}${c}`}function G(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 D(u,f,c={}){const t=c.separator||x,a=f.length,{keyOf:g,readers:e}=_(u,f,0),m=new Map,d=[],r=[];for(let U=0;U<a;U++){const I=f[U],X=g(I);if(m.has(X))continue;m.set(X,d.length),r.push(X);const C=new Array(e.length);for(let R=0;R<e.length;R++)C[R]=e[R](I);d.push(C)}const n=q(c.locale),l=d.map((U,I)=>I);l.sort((U,I)=>{const X=d[U],C=d[I];for(let R=0;R<X.length;R++){const h=Y(X[R],C[R],n);if(h!==0)return h}return U-I});const b=new Array(l.length),E=new Array(l.length),S=new Map;for(let U=0;U<l.length;U++){const I=l[U];b[U]=d[I],E[U]=G(d[I],t),S.set(r[I],U)}return{keys:b,paths:E,idOf:U=>{const I=S.get(g(U));return I===void 0?-1:I}}}function Y(u,f,c){const t=u==null,a=f==null;return t||a?t&&a?0:t?1:-1:c(u,f)}function ee(u){const f=u.values||u.totals||[];if(f.length&&typeof f[0]=="object"&&f[0]!==null)return f.filter(g=>g&&g.handle);const c=typeof u.handle=="function"?u.handle:null;if(!c)return f.length&&ae("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 g of f){const e=c(g);e&&a.push({colId:g,handle:e,fn:t?t(g):"sum"})}return a}function z(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=z(u,f,c),a=t.separator||x,g=ee(t),e=t.maxColumns===void 0?ce:t.maxColumns,m=t.groups&&t.groups.buckets?t.groups:null,d=m?m.buckets:[t.order||new Uint32Array(0)],r=t.groupPaths||(m?m.keys.map(X=>G(X,a)):[""]),n=s(d),{keys:l,paths:b,idOf:E}=D(t.pivotHandles||[],n,t),S=b.length*Math.max(1,g.length),V=i(b,g,a);if(e&&S>e){const X=new Map;return{keys:l,paths:b,fields:V,groupPaths:r,columns:S,values:X,cells:X,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 U=new Map,I=b.length;for(let X=0;X<d.length;X++){const C=d[X],R=r[X]===void 0?"":r[X],h=C.length;if(h===0)continue;const O=new Int32Array(h),w=new Uint32Array(I+1);for(let K=0;K<h;K++){const Z=E(C[K]);O[K]=Z,Z>=0&&w[Z+1]++}for(let K=0;K<I;K++)w[K+1]+=w[K];const P=new Uint32Array(h),v=w.slice(0,I);for(let K=0;K<h;K++){const Z=O[K];Z>=0&&(P[v[Z]++]=C[K])}for(let K=0;K<I;K++){const Z=w[K],oe=w[K+1];if(oe===Z)continue;const se=P.subarray(Z,oe);for(let T=0;T<g.length;T++){const L=g[T],J=H(L.handle,se,L.fn,t.totalContext||{locale:t.locale});U.set(ie(R,b[K],L.colId),J)}}}return{keys:l,paths:b,fields:V,groupPaths:r,columns:S,values:U,cells:U,error:null}}function i(u,f,c){if(f.length===0)return u.slice();const t=[];for(const a of u)for(const g of f)t.push(`${a}${c}${g.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,fe){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return M}});const ae=fe("packages/core/src/compute/handle.js").valueComparator,q=fe("packages/core/src/compute/total.js").total,_=fe("packages/core/src/compute/group.js").packKeys,F=fe("packages/core/src/compute/pivot.js"),H=F.joinPath,ne=F.DEFAULT_PATH_SEPARATOR,x=F.DEFAULT_MAX_COLUMNS,ce="";function ie(i,s,u={}){const f=u.separator||ne,c=i||[],t=s instanceof Uint32Array?s:Uint32Array.from(s||[]),a=t.length;if(c.length===0)return{tuples:[[]],paths:[ce],buckets:[t]};const{keyOf:g,readers:e}=_(c,t,0),m=new Map,d=[],r=[],n=[];for(let U=0;U<a;U++){const I=t[U],X=g(I);let C=m.get(X);if(C===void 0){C=d.length,m.set(X,C),r.push(X);const R=new Array(e.length);for(let h=0;h<e.length;h++)R[h]=e[h](I);d.push(R),n.push([])}n[C].push(I)}const l=ae(u.locale),b=d.map((U,I)=>I);b.sort((U,I)=>{const X=d[U],C=d[I];for(let R=0;R<X.length;R++){const h=G(X[R],C[R],l);if(h!==0)return h}return U-I});const E=new Array(b.length),S=new Array(b.length),V=new Array(b.length);for(let U=0;U<b.length;U++){const I=b[U];E[U]=d[I],S[U]=H(d[I],f),V[U]=Uint32Array.from(n[I])}return{tuples:E,paths:S,buckets:V}}function G(i,s,u){const f=i==null,c=s==null;return f||c?f&&c?0:f?1:-1:u(i,s)}function D(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 Y(i,s,u,f){return{value:s.length?q(i,s,u,f):null,leaves:s,count:s.length}}function ee(i){const s=i&&i.opts||{},u=s.separator||ne,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=ie(i.rowHandles||[],t,{...s,separator:u}),g=ie(i.columnHandles||[],t,{...s,separator:u}),e=s.maxColumns===void 0?x:s.maxColumns,m=g.paths.length*Math.max(1,c.length),d=new Map;if(e&&m>e)return{rowAxis:a,columnAxis:g,measures:c.map(S=>({colId:S.colId,fn:S.fn})),body:d,rowMargin:d,columnMargin:d,grand:d,columns:m,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${m} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:m,maxColumns:e}};const r=new Map,n=new Map,l=new Map,b=new Map,E=g.buckets.map(S=>new Set(S));for(let S=0;S<g.paths.length;S++){const V=g.buckets[S],U=g.paths[S];for(const I of c)l.set(M(U,I.colId),Y(I.handle,V,I.fn,f))}for(let S=0;S<a.paths.length;S++){const V=a.buckets[S],U=a.paths[S];for(const I of c)n.set(M(U,I.colId),Y(I.handle,V,I.fn,f));for(let I=0;I<g.paths.length;I++){const X=D(V,g.buckets[I],E[I]);if(X.length===0)continue;const C=g.paths[I];for(const R of c)r.set(z(U,C,R.colId),Y(R.handle,X,R.fn,f))}}for(const S of c)b.set(S.colId,Y(S.handle,t,S.fn,f));return{rowAxis:a,columnAxis:g,measures:c.map(S=>({colId:S.colId,fn:S.fn})),body:r,rowMargin:n,columnMargin:l,grand:b,columns:m,error:null}}function z(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,fe){"use strict";Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ee}});const ae=fe("packages/core/src/internal/util.js").getPath,Q=fe("packages/core/src/compute/handle.js"),q=Q.isMissing,te=Q.valueComparator,F=fe("packages/core/src/compute/filter.js").testValue,H="",ne="\\0";function x(i,s){const u=s.includes(".")?ae(i,s):i?.[s];return u===void 0?null:u}function ce(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=ie(i,c,f[t],u);return c}function ie(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",g=[],e=[];for(const r of s){const n=x(i[r],u.col);q(n)?e.push(r):g.push(r)}const m=new Map;for(let r=0;r<g.length;r++)m.set(g[r],r);const d=(r,n)=>{const l=x(i[r],u.col),b=x(i[n],u.col);let E;return typeof u.compare=="function"?(E=u.compare(l,b,i[r],i[n],a),a&&(E=-E)):E=a?t(b,l):t(l,b),E!==0?E:m.get(r)-m.get(n)};return g.sort(d),u.nullsFirst?e.concat(g):g.concat(e)}function G(i,s,u={}){const f=[];for(let c=0;c<i.length;c++)D(i[c],s,u,c)&&f.push(c);return f}function D(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=>D(i,a,u,f));const t=c.every(a=>D(i,a,u,f));return s.op==="not"?!t:t}return s.col===void 0&&typeof u.custom=="function"?!!u.custom(s,i,f):F(x(i,s.col),s,u.locale)}function Y(i,s,u,f){const c=u||i.map((e,m)=>m),t=new Map,a=[],g=[];for(const e of c){const m=s.map((n,l)=>{const b=x(i[e],n);return f&&f[l]?f[l](b):b}),d=m.map(n=>n==null?ne:String(n)).join(H);let r=t.get(d);r===void 0&&(r=a.length,t.set(d,r),a.push(m),g.push([])),g[r].push(e)}return{keys:a,buckets:g}}function ee(i,s,u={}){const f=te(u.locale),c=i.filter(a=>!q(a)),t=c.map(z).filter(a=>a!==null);switch(s){case"count":return i.length;case"countValues":return c.length;case"sum":return t.reduce((a,g)=>a+g,0);case"avg":return c.length===0?null:t.reduce((a,g)=>a+g,0)/c.length;case"min":return c.length===0?null:c.reduce((a,g)=>f(g,a)<0?g:a);case"max":return c.length===0?null:c.reduce((a,g)=>f(g,a)>0?g: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 z(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,fe){"use strict";Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return _}});const ae=fe("packages/core/src/compute/sketch.js").Welford;class Q{#t;#e;#n=[];#r;#i;constructor(H,ne=0,x=Date.now){if(H!=="count"&&H!=="time"&&H!=="session")throw new RangeError(`unknown window kind: ${H}`);if((H==="count"||H==="time")&&!(ne>0))throw new RangeError(`a ${H} window needs a positive span`);this.#t=H,this.#e=Math.floor(ne),this.#r=x,this.#i=x()}get size(){return this.#n.length}push(H,ne=this.#r()){Number.isFinite(H)&&(this.#n.push({t:ne,v:H}),this.#s(ne))}#s(H){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const ne=H-this.#e;for(;this.#n.length&&this.#n[0].t<ne;)this.#n.shift()}}spec(){const H=this.#t==="session"?this.#r()-this.#i:this.#e;return{kind:this.#t,span:H,size:this.#n.length}}values(){return this.#n.map(H=>H.v)}aggregate(){const H=this.spec();if(!this.#n.length)return{over:H,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const ne=new ae;let x=0,ce=1/0,ie=-1/0;for(const{v:G}of this.#n)x+=G,G<ce&&(ce=G),G>ie&&(ie=G),ne.add(G);return{over:H,count:this.#n.length,sum:x,mean:ne.mean(),min:ce,max:ie,variance:ne.variance(),stddev:ne.stddev()}}reduce(H){const ne=this.aggregate(),x={sum:ne.sum,avg:ne.mean,mean:ne.mean,min:ne.min,max:ne.max,count:ne.count,variance:ne.variance,stddev:ne.stddev};if(!(H in x))throw new RangeError(`unknown windowed aggregate: ${H}`);return{value:x[H],over:ne.over}}}const q=Object.freeze(["count","time","session"]);function te(F,H=Date.now){const ne=F.kind==="time"&&F.minutes!=null?F.minutes*6e4:F.span??0;return new Q(F.kind,ne,H)}const _={Window:Q,WINDOW_KINDS:q,openWindow:te}}),Se("packages/core/src/compute/anomaly.js",function(o,fe){"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 _}}),Object.defineProperty(o,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return Y}}),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 ae=fe("packages/core/src/compute/statistics.js").quantileSorted,q=fe("packages/core/src/compute/special.js").logGamma,te=.6745,_=3.5,F=1.5,H=.975,ne=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function x(c){if(!c.length)return null;const a=Array.from(c,Number).sort((d,r)=>d-r),g=ae(a,.5),e=a.map(d=>Math.abs(d-g)).sort((d,r)=>d-r),m=ae(e,.5);return{median:g,mad:m}}function ce(c,t={}){const a=Number.isFinite(t.threshold)?t.threshold:_,g=c.length,e=new Array(g).fill(null),m=new Array(g).fill(!1),d=[];for(let l=0;l<g;l++){const b=Number(c[l]);Number.isFinite(b)&&d.push(b)}if(!d.length)return{median:null,mad:null,threshold:a,scores:e,flags:m,flagged:0};const r=x(d);if(r.mad===0)return{median:r.median,mad:0,threshold:a,scores:e,flags:m,flagged:0};let n=0;for(let l=0;l<g;l++){const b=Number(c[l]);if(!Number.isFinite(b))continue;const E=te*(b-r.median)/r.mad;e[l]=E,Math.abs(E)>a&&(m[l]=!0,n++)}return{median:r.median,mad:r.mad,threshold:a,scores:e,flags:m,flagged:n}}function ie(c,t={}){const a=Number.isFinite(t.k)?t.k:F,g=[];for(let n=0;n<c.length;n++){const l=Number(c[n]);Number.isFinite(l)&&g.push(l)}if(!g.length)return null;const e=g.sort((n,l)=>n-l),m=ae(e,.25),d=ae(e,.75),r=d-m;return{q1:m,q3:d,iqr:r,lower:m-a*r,upper:d+a*r,k:a}}function G(c,t){if(t<=0)return 0;const a=q(c);if(t<c+1){let l=c,b=1/c,E=b;for(let S=0;S<1e3&&(l+=1,E*=t/l,b+=E,!(Math.abs(E)<Math.abs(b)*1e-15));S++);return b*Math.exp(-t+c*Math.log(t)-a)}const g=1e-300;let e=t+1-c,m=1/g,d=1/e,r=d;for(let l=1;l<1e3;l++){const b=-l*(l-c);e+=2,d=b*d+e,Math.abs(d)<g&&(d=g),m=e+b/m,Math.abs(m)<g&&(m=g),d=1/d;const E=d*m;if(r*=E,Math.abs(E-1)<1e-15)break}return 1-Math.exp(-t+c*Math.log(t)-a)*r}function D(c,t){return c<=0?0:G(t/2,c/2)}function Y(c,t=H){if(!(t>0)||!(t<1))return NaN;let a=0,g=Math.max(1,c);for(;D(g,c)<t;)g*=2;for(let e=0;e<200;e++){const m=(a+g)/2;if(D(m,c)<t?a=m:g=m,g-a<1e-10)break}return(a+g)/2}function ee(c){const t=c.length,a=c.map((g,e)=>{const m=g.slice();for(let d=0;d<t;d++)m.push(e===d?1:0);return m});for(let g=0;g<t;g++){let e=g;for(let d=g+1;d<t;d++)Math.abs(a[d][g])>Math.abs(a[e][g])&&(e=d);if(Math.abs(a[e][g])<1e-12)return null;if(e!==g){const d=a[e];a[e]=a[g],a[g]=d}const m=a[g][g];for(let d=0;d<2*t;d++)a[g][d]/=m;for(let d=0;d<t;d++){if(d===g)continue;const r=a[d][g];if(r!==0)for(let n=0;n<2*t;n++)a[d][n]-=r*a[g][n]}}return a.map(g=>g.slice(t))}function z(c,t){const a=c.length,g=new Array(t).fill(0);for(const d of c)for(let r=0;r<t;r++)g[r]+=d[r];for(let d=0;d<t;d++)g[d]/=a;const e=Array.from({length:t},()=>new Array(t).fill(0));for(const d of c)for(let r=0;r<t;r++){const n=d[r]-g[r];for(let l=r;l<t;l++)e[r][l]+=n*(d[l]-g[l])}const m=a>1?a-1:1;for(let d=0;d<t;d++)for(let r=d;r<t;r++)e[d][r]/=m,e[r][d]=e[d][r];return{mean:g,cov:e}}function M(c,t={}){const a=Number.isFinite(t.p)?t.p:H,g=Number.isFinite(t.ridge)?t.ridge:1e-6,e=c.length;if(!e)return null;const m=c[0].length;if(!m)return null;const d=new Array(e).fill(null),r=new Array(e).fill(null),n=new Array(e).fill(!1),l=[],b=[];for(let R=0;R<e;R++){const h=c[R];let O=h.length===m;const w=new Array(m);for(let P=0;O&&P<m;P++){const v=Number(h[P]);Number.isFinite(v)?w[P]=v:O=!1}O&&(l.push(R),b.push(w))}const E=m,S=Y(E,a);if(b.length<=m)return{center:[],df:E,cutoff:S,singular:!0,used:b.length,distances:d,squared:r,flags:n,flagged:0};const{mean:V,cov:U}=z(b,m);let I=ee(U),X=!1;if(!I){X=!0;let R=0;for(let w=0;w<m;w++)R+=U[w][w];const h=R/m*g||g,O=U.map((w,P)=>w.map((v,K)=>P===K?v+h:v));if(I=ee(O),!I)return{center:V,df:E,cutoff:S,singular:!0,used:b.length,distances:d,squared:r,flags:n,flagged:0}}let C=0;for(let R=0;R<b.length;R++){const h=b[R],O=new Array(m);for(let v=0;v<m;v++)O[v]=h[v]-V[v];let w=0;for(let v=0;v<m;v++){let K=0;for(let Z=0;Z<m;Z++)K+=I[v][Z]*O[Z];w+=O[v]*K}w<0&&(w=0);const P=l[R];r[P]=w,d[P]=Math.sqrt(w),w>S&&(n[P]=!0,C++)}return{center:V,df:E,cutoff:S,singular:X,used:b.length,distances:d,squared:r,flags:n,flagged:C}}const i=20,s=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function u(c,t={}){const a=t.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",g=Number.isFinite(t.windowLen)&&t.windowLen>=1?Math.floor(t.windowLen):i,e=Number.isFinite(t.threshold)?t.threshold:_,m=Number.isFinite(t.k)?t.k:F,d=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):g,r=c.length,n=new Array(r).fill(null),l=new Array(r).fill(!1);let b=0;for(let E=0;E<r;E++){const S=Number(c[E]);if(!Number.isFinite(S))continue;const V=Math.max(0,E-g+1),U=[];for(let I=V;I<=E;I++){const X=Number(c[I]);Number.isFinite(X)&&U.push(X)}if(!(U.length<d))if(a==="rollingIqr"){const I=ie(U,{k:m});if(!I)continue;(S<I.lower||S>I.upper)&&(l[E]=!0,b++)}else{const I=x(U);if(!I||I.mad===0)continue;const X=te*(S-I.median)/I.mad;n[E]=X,Math.abs(X)>e&&(l[E]=!0,b++)}}return{method:a,windowLen:g,minPeriods:d,threshold:e,k:m,scores:n,flags:l,flagged:b}}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 g=t.method||"modifiedZScore";if(!(ne.includes(g)||s.includes(g))||g==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method \'${g}\'`);const m=typeof t.orderBy=="string"?t.orderBy:null,d=t.latest===!0,r=s.includes(g),n=l=>Number(l==null?NaN:l[a]);return l=>{const b=Array.isArray(l)?l.slice():[...l];m&&b.sort((I,X)=>{const C=I?.[m],R=X?.[m];return C===R?0:C==null?-1:R==null?1:C<R?-1:1});const E=b.map(n);let S,V;if(r)({flags:S,scores:V}=u(E,{method:g,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(g==="iqr"){const I=ie(E,{k:t.k});S=E.map(X=>I?Number.isFinite(X)&&(X<I.lower||X>I.upper):!1),V=E.map(()=>null)}else({flags:S,scores:V}=ce(E,{threshold:t.threshold}));if(d){const I=S.length-1;return I<0||!S[I]?!1:{method:g,field:a,flagged:[{row:b[I],score:V[I]}]}}const U=[];for(let I=0;I<S.length;I++)S[I]&&U.push({row:b[I],score:V[I]});return U.length?{method:g,field:a,flagged:U}:!1}}}),Se("packages/core/src/compute/forecast.js",function(o,fe){"use strict";Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return c}});const le=fe("packages/core/src/compute/special.js"),ae=le.normalQuantile,Q=le.studentTQuantile,te=fe("packages/core/src/internal/util.js").warnOnce,_=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),F=1e-4,H=1-1e-4;function ne(t){const a=[];for(let g=0;g<t.length;g++){const e=t[g];if(e!==null&&typeof e=="object"){const m=Number.isFinite(e.at)?e.at:g,d=Number.isFinite(e.value)?e.value:null;a.push({at:m,value:d})}else a.push({at:g,value:Number.isFinite(e)?Number(e):null})}return a}function x(t){const a=t.filter(r=>r.value!==null),g=a[0],e=a[a.length-1],m=e.at-g.at,d=a.length>1&&m>0?m/(a.length-1):1;return{lastAt:e.at,step:d}}function ce(t){return Math.min(H,Math.max(F,t))}function ie(t,a=F,g=H,e=80){const m=(Math.sqrt(5)-1)/2;let d=a,r=g,n=r-m*(r-d),l=d+m*(r-d),b=t(n),E=t(l);for(let S=0;S<e;S++)b<E?(r=l,l=n,E=b,n=r-m*(r-d),b=t(n)):(d=n,n=l,b=E,l=d+m*(r-d),E=t(l));return(d+r)/2}function G(t,a){let g=null,e=0,m=0;for(let d=0;d<t.length;d++){const r=t[d];if(r!==null){if(g===null){g=r;continue}e+=(r-g)**2,m+=1,g=a*r+(1-a)*g}}return{level:g,sse:e,m}}function D(t,a,g){let e=null,m=null,d=0,r=0;for(let n=0;n<t.length;n++){const l=t[n];if(l===null){e!==null&&m!==null&&(e+=m);continue}if(e===null){e=l;continue}m===null&&(m=l-e);const b=e+m;d+=(l-b)**2,r+=1;const E=e;e=a*l+(1-a)*(E+m),m=g*(e-E)+(1-g)*m}return{level:e,trend:m,sse:d,m:r}}function Y(t,a,g,e,m){const d=t.length;if(d<2*a)return null;const r=X=>{let C=0,R=0;for(let h=X;h<X+a&&h<d;h++)t[h]!==null&&(C+=t[h],R+=1);return R?C/R:null},n=r(0),l=r(a);if(n===null||l===null)return null;let b=n,E=(l-n)/a;const S=new Array(a).fill(0);for(let X=0;X<a;X++)S[X]=t[X]===null?0:t[X]-b;const V=S.reduce((X,C)=>X+C,0)/a;for(let X=0;X<a;X++)S[X]-=V;let U=0,I=0;for(let X=a;X<d;X++){const C=X%a,R=S[C],h=t[X];if(h===null){b+=E;continue}const O=b+E+R;U+=(h-O)**2,I+=1;const w=b;b=g*(h-R)+(1-g)*(b+E),E=e*(b-w)+(1-e)*E,S[C]=m*(h-b)+(1-m)*R}return{level:b,trend:E,season:S,phase:(d-1)%a,sse:U,count:I}}function ee(t,a,g){let e=1;for(const d of a)e+=d*d;const m=Math.sqrt(t*e);return{se:m,margin:g*m}}function z(t,a={}){if(!t||typeof t.length!="number"||t.length===0)return null;const g=_.includes(a.method)?a.method:"linear",e=Math.max(1,Math.floor(Number(a.horizon)||1)),m=Number.isFinite(a.confidence)&&a.confidence>0&&a.confidence<1?a.confidence:.95,d=1-(1-m)/2,r=ne(t),n=r.map(U=>U.value),l=n.filter(U=>U!==null),b=l.length,{lastAt:E,step:S}=b?x(r):{lastAt:0,step:1},V=U=>E+U*S;return g==="linear"?M(r,b,e,m,d,V):g==="movingAverage"?i(l,b,e,m,d,a,V):g==="ses"?s(n,b,e,m,d,a,V):g==="holt"?u(n,b,e,m,d,a,V):f(n,b,e,m,d,a,V)}function M(t,a,g,e,m,d){if(a<2)return null;let r=0,n=0;for(const h of t)h.value!==null&&(r+=h.at,n+=h.value);r/=a,n/=a;let l=0,b=0,E=0;for(const h of t){if(h.value===null)continue;const O=h.at-r,w=h.value-n;l+=O*O,b+=O*w,E+=w*w}if(l===0)return null;const S=b/l,V=n-S*r,U=E===0?1:Math.max(0,Math.min(1,b*b/(l*E))),I=Math.max(0,E-S*b),X=a>2?Math.sqrt(I/(a-2)):null,C=a>2?Q(m,a-2):null,R=[];for(let h=1;h<=g;h++){const O=d(h),w=V+S*O;let P=null,v=null,K=null,Z=null,oe=null;if(X!==null){const se=1/a+(O-r)**2/l,T=X*Math.sqrt(1+se),L=X*Math.sqrt(se);oe=T,P=w-C*T,v=w+C*T,K=w-C*L,Z=w+C*L}R.push({step:h,at:O,mean:w,lower:P,upper:v,lowerMean:K,upperMean:Z,se:oe})}return{method:"linear",horizon:g,confidence:e,n:a,sigma:X,r2:U,params:{slope:S,intercept:V},points:R}}function i(t,a,g,e,m,d,r){if(a<1)return null;const n=Math.max(1,Math.min(a,Math.floor(Number(d.windowLen)||a))),l=t.slice(a-n);let b=0;for(const X of l)b+=X;const E=b/n;let S=null,V=null;if(n>1){let X=0;for(const R of l)X+=(R-E)**2;S=Math.sqrt(X/(n-1))*Math.sqrt(1+1/n),V=Q(m,n-1)}const U=S===null?null:V*S,I=[];for(let X=1;X<=g;X++)I.push({step:X,at:r(X),mean:E,lower:U===null?null:E-U,upper:U===null?null:E+U,se:S});return{method:"movingAverage",horizon:g,confidence:e,n:a,sigma:S===null?null:S,params:{windowLen:n},points:I}}function s(t,a,g,e,m,d,r){if(a<1)return null;let n=Number.isFinite(d.alpha)?ce(d.alpha):null;n===null&&(n=ie(V=>G(t,V).sse));const l=G(t,n),b=ae(m),E=l.m>0?l.sse/l.m:null,S=[];for(let V=1;V<=g;V++){const U=l.level;let I=null,X=null,C=null;if(E!==null){const R=[];for(let O=1;O<V;O++)R.push(n);const h=ee(E,R,b);C=h.se,I=U-h.margin,X=U+h.margin}S.push({step:V,at:r(V),mean:U,lower:I,upper:X,se:C})}return{method:"ses",horizon:g,confidence:e,n:a,sigma:E===null?null:Math.sqrt(E),params:{alpha:n},points:S}}function u(t,a,g,e,m,d,r){if(a<2)return null;let n=Number.isFinite(d.alpha)?ce(d.alpha):null,l=Number.isFinite(d.beta)?ce(d.beta):null;if(n===null||l===null){let I=n===null?.5:n,X=l===null?.5:l;for(let C=0;C<6;C++)n===null&&(I=ie(R=>D(t,R,X).sse)),l===null&&(X=ie(R=>D(t,I,R).sse));n=n===null?I:n,l=l===null?X:l}const b=D(t,n,l),E=ae(m),S=b.m>0?b.sse/b.m:null,V=n*l,U=[];for(let I=1;I<=g;I++){const X=b.level+I*b.trend;let C=null,R=null,h=null;if(S!==null){const O=[];for(let P=1;P<I;P++)O.push(n+P*V);const w=ee(S,O,E);h=w.se,C=X-w.margin,R=X+w.margin}U.push({step:I,at:r(I),mean:X,lower:C,upper:R,se:h})}return{method:"holt",horizon:g,confidence:e,n:a,sigma:S===null?null:Math.sqrt(S),params:{alpha:n,beta:l},points:U}}function f(t,a,g,e,m,d,r){const n=Math.floor(Number(d.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(d.alpha)?ce(d.alpha):null,b=Number.isFinite(d.beta)?ce(d.beta):null,E=Number.isFinite(d.gamma)?ce(d.gamma):null;const S=(h,O,w)=>{const P=Y(t,n,h,O,w);return P?P.sse:1/0};if(l===null||b===null||E===null){let h=l===null?.5:l,O=b===null?.5:b,w=E===null?.5:E;for(let P=0;P<8;P++)l===null&&(h=ie(v=>S(v,O,w))),b===null&&(O=ie(v=>S(h,v,w))),E===null&&(w=ie(v=>S(h,O,v)));l=l===null?h:l,b=b===null?O:b,E=E===null?w:E}const V=Y(t,n,l,b,E);if(!V)return null;const U=ae(m),I=V.count>0?V.sse/V.count:null,X=l*b,C=E*(1-l),R=[];for(let h=1;h<=g;h++){const O=V.season[(V.phase+h)%n],w=V.level+h*V.trend+O;let P=null,v=null,K=null;if(I!==null){const Z=[];for(let se=1;se<h;se++)Z.push(l+se*X+(se%n===0?C:0));const oe=ee(I,Z,U);K=oe.se,P=w-oe.margin,v=w+oe.margin}R.push({step:h,at:r(h),mean:w,lower:P,upper:v,se:K})}return{method:"holtWinters",horizon:g,confidence:e,n:a,sigma:I===null?null:Math.sqrt(I),params:{alpha:l,beta:b,gamma:E,period:n},points:R}}const c={FORECAST_METHODS:_,forecast:z}}),Se("packages/core/src/compute/index.js",function(o,fe){"use strict";const le=fe("packages/core/src/compute/sort.js");Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return le.sortColumn}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return le.sortMulti}}),Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return le.radixSortFloat64}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return le.radixSortInt32}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return le.rankSortDictionary}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return le.mergeSortComparator}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return le.collateStringRanks}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return le.rankSortStrings}});const ae=fe("packages/core/src/compute/sortspec.js");Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return ae.collationDescriptor}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return ae.isPortableSort}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return ae.isPortableSortSet}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return ae.describeSortEntry}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return ae.describeSort}});const Q=fe("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return Q.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return Q.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return Q.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return Q.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return Q.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return Q.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return Q.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return Q.mentionsColumn}});const q=fe("packages/core/src/compute/group.js");Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return q.groupByColumns}}),Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return q.packKeys}});const te=fe("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 _=fe("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return _.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return _.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return _.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return _.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return _.collectValues}});const F=fe("packages/core/src/compute/pivot.js");Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return F.pivot}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return F.resolvePivotKeys}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return F.pivotKey}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return F.joinPath}}),Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return F.KEY_DELIMITER}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return F.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return F.DEFAULT_MAX_COLUMNS}});const H=fe("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return H.pivotMatrix}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return H.resolveAxis}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return H.cellKey}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return H.marginKey}}),Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return H.GRAND_PATH}});const ne=fe("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return ne.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return ne.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return ne.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ne.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return ne.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return ne.referenceValue}});const x=fe("packages/core/src/compute/handle.js");Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return x.identity}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return x.rowCount}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return x.presenceReader}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return x.bitReader}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return x.valueReader}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return x.valueComparator}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return x.numericTotalOrder}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return x.dictRanks}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return x.dictSize}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return x.dictValue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return x.multiValue}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return x.isMissing}});const ce=fe("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return ce.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return ce.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return ce.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return ce.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return ce.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return ce.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return ce.SKETCH_BOUNDS}});const ie=fe("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return ie.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return ie.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return ie.openWindow}});const G=fe("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return G.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return G.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return G.maintenanceOf}});const D=fe("packages/core/src/compute/anomaly.js");Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return D.ANOMALY_METHODS}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return D.modifiedZScores}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return D.iqrFences}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return D.mahalanobis}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return D.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return D.rollingAnomalies}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return D.anomalyCondition}});const Y=fe("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Y.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return Y.forecast}})}),Se("packages/worker/src/kernel.js",function(o,fe){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"setCompute",{enumerable:!0,get:function(){return z}}),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 le=fe("packages/worker/src/transport.js"),ae=le.PROTOCOL,Q=le.OPS,q=le.CONTROL,te=le.ERRORS,_=le.unpackHandle,F=le.unpackHandles,H=le.createMaskPool,ne=le.collectTransfers,x=fe("packages/core/src/store/columnpack.js"),ce=x.packChunk,ie=x.packedTransfers;let G=null,D=null,Y=null;async function ee(f){if(G)return G;if(!D){const c=f||(()=>Promise.resolve(fe("packages/core/src/compute/index.js")));D=Promise.resolve().then(c).then(t=>(G=t,t)).catch(t=>(Y=t,G=null,null))}return D}function z(f){G=f,D=f?Promise.resolve(f):null,Y=f?null:Y}function M(f,c,t){const a=new Map;for(const g of f)g&&a.set(g.id,g);return{handle(g){return a.get(g)},count:c,pool:H(),locale:t}}function i(f,c){const{op:t,args:a}=f;if(t===Q.COLUMNIZE)return ce(a.schema||[],a.rows||[],a.opts||{});const g=c[t];if(typeof g!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=te.NO_KERNEL,e}switch(t){case Q.COLLATE_STRING_RANKS:return g(a.table||[],(a.table||[]).length,a.locale);case Q.SORT_COLUMN:return g(_(a.handle),a.order??null,a.opts||{});case Q.SORT_MULTI:{const e=F(a.handles||[]),m=(a.entries||[]).map(d=>({...d,handle:e[d.index]}));return g(e,m,a.order??null)}case Q.EVALUATE_FILTERS:return g(a.filters,M(F(a.handles||[]),a.count,a.locale));case Q.COMPACT:return g(a.mask,a.count,void 0);case Q.GROUP_BY_COLUMNS:return g(F(a.handles||[]),a.order??null,a.opts||{});case Q.TOTAL:return g(_(a.handle),a.indices??null,a.fn);case Q.PIVOT:return g(F(a.handles||[]),a.order??null,a.opts||{});case Q.FACET:return g(_(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!==ae)return null;const{id:t,op:a}=f;if(a===q.CANCEL)return c.cancelled?.add(f.target),null;if(a===q.PING)return{reply:{lattice:ae,id:t,ok:!0,result:"pong"},transfer:[]};if(a===Q.COLUMNIZE){if(c.cancelled?.has(t))return c.cancelled.delete(t),null;try{const e=ce(f.args.schema||[],f.args.rows||[],f.args.opts||{});return c.cancelled?.has(t)?(c.cancelled.delete(t),{reply:{lattice:ae,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:ae,id:t,ok:!0,result:e},transfer:ie(e)}}catch(e){const m=e;return{reply:{lattice:ae,id:t,ok:!1,error:{code:m.code||te.KERNEL,message:m.message||String(e),stack:m.stack}},transfer:[]}}}const g=await ee(c.loader);if(!g)return{reply:{lattice:ae,id:t,ok:!1,error:{code:te.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${Y?Y.message:"module not found"}`}},transfer:[]};if(c.cancelled?.has(t))return c.cancelled.delete(t),{reply:{lattice:ae,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(f,g);return c.cancelled?.has(t)?(c.cancelled.delete(t),{reply:{lattice:ae,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:ae,id:t,ok:!0,result:e},transfer:ne(e)}}catch(e){const m=e;return{reply:{lattice:ae,id:t,ok:!1,error:{code:m.code||te.KERNEL,message:m.message||String(e),stack:m.stack}},transfer:[]}}}function u(f,c={}){const t=new Set,a=async g=>{const e=await s(g.data,{loader:c.loader,cancelled:t});e&&f.postMessage(e.reply,e.transfer)};return f.addEventListener("message",a),ee(c.loader).then(g=>{f.postMessage({lattice:ae,id:0,op:q.READY,compute:!!g})}),()=>f.removeEventListener("message",a)}});var bt=nt("packages/worker/src/kernel.js");gt.__latticeKernel=bt})(typeof globalThis<"u"?globalThis:this);\n\n__latticeKernel.installKernel(self);\n',{type:"classic"})}catch{}const De=Bn("packages/dom/src/index.js"),Vi=De.createGrid,Gi=De.gridElementsWithin,Ki=De.createStat,Wi=De.deltaOf,qi=De.toneOf,_i=De.readTable,Zi=De.hydrateTable,Yi=De.autoInit,Xi=De.createLocalViewStorage,Qi=De.DEFAULT_VIEWS_KEY,Ji=De.createHeadlessGrid,eo=De.defaults,to=De.version,no=De.getVersion,ro=De.Grid,io=De.EventBus,oo=De.Registry,so=De.sharedRegistry,ao=De.registerModules,lo=De.parseLicence,uo=De.verifyLicence,co=De.licenceInfo,fo=De.watermark,ho=De.setLicence,mo=De.licenceState,po=De.isLocalHost,go=De.matchesDomain,yo=De.LicenceHolder,bo=De.ColumnModel,wo=De.buildGraph,vo=De.Lookup,ko=De.ValuePipeline,So=De.compileFormat,Oo=De.compileMask,jo=De.specToOoxml,Ao=De.EXTENDED_TYPES,Po=De.createRadixType,Co=De.RADIX_PRESETS,Eo=De.parseRadix,To=De.formatRadix,Mo=De.createUnitType,No=De.registerUnitSystem,Ro=De.defineUnit,Lo=De.UNIT_SYSTEMS,Fo=De.parseUnit,xo=De.formatUnit,Do=De.createCurrencyType,Io=De.parseMoney,zo=De.formatMoney,$o=De.convertMoney,Bo=De.rateFunction,Uo=De.MISSING_RATE,Ho=De.Messages,Vo=De.createMessages,Go=De.auditCatalogue,Ko=De.EN_GB,Wo=De.MESSAGE_KEYS,qo=De.DEFAULT_LOCALE,_o=De.formatList,Zo=De.resolveLocale,Yo=De.LOCALES,Xo=De.resolveCatalogue,Qo=De.EN_US,Jo=De.FR_FR,es=De.FR_CA,ts=De.IT_IT,ns=De.ES_ES,rs=De.PT_BR,is=De.DE_DE,os=De.NL_NL,ss=De.SV_SE,as=De.DA_DK,ls=De.NB_NO,us=De.FI_FI,cs=De.PL_PL,ds=De.CS_CZ,fs=De.HU_HU,hs=De.RO_RO,ms=De.UK_UA,ps=De.EL_GR,gs=De.JA_JP,ys=De.AR,bs=De.AR_SA,ws=De.ColumnStore,vs=De.Bitset,ks=De.Dictionary,Ss=De.MultiValue,Os=De.MaskPool,js=De.sortColumn,As=De.sortMulti,Ps=De.evaluateFilters,Cs=De.compact,Es=De.testValue,Ts=De.groupByColumns,Ms=De.total,Ns=De.TOTAL_FNS,Rs=De.pivot,Ls=De.Window,Fs=De.openWindow,xs=De.WINDOW_KINDS,Ds=De.ANOMALY_METHODS,Is=De.modifiedZScores,zs=De.iqrFences,$s=De.mahalanobis,Bs=De.ROLLING_ANOMALY_METHODS,Us=De.rollingAnomalies,Hs=De.anomalyCondition,Vs=De.FORECAST_METHODS,Gs=De.forecast,Ks=De.evaluateFormula,Ws=De.parseFormula,qs=De.referencesOf,_s=De.looksLikeFormula,Zs=De.FormulaError,Ys=De.FUNCTIONS,Xs=De.compileRules,Qs=De.ingest,Js=De.ingestSync,ea=De.createSource,ta=De.createMemorySource,na=De.createPagedSource,ra=De.createRemoteSource,ia=De.createStreamSource,oa=De.createUrlSource,sa=De.PROTOCOL,aa=De.createPushdownSource,la=De.planQuery,ua=De.splitFilters,ca=De.applyResidual,da=De.capabilitiesOf,fa=De.resolveMutate,ha=De.NO_CAPABILITIES,ma=De.odataAdapter,pa=De.filtersToOData,ga=De.conditionToOData,ya=De.restAdapter,ba=De.DEFAULT_PARAMS,wa=De.dfqlAdapter,va=De.duckdbAdapter,ka=De.filtersToSql,Sa=De.graphqlAdapter,Oa=De.RowModel,ja=De.createRowKey,Aa=De.SelectionModel,Pa=De.RangeModel,Ca=De.EditModel,Ea=De.ChangeModel,Ta=De.StateModel,Ma=De.STATE_VERSION,Na=De.serialiseState,Ra=De.restoreState,La=De.VERSION,Fa=De.DomRenderer,xa=De.FilterMenu,Da=De.mergeColumnFilter,Ia=De.branchFor,za=De.ColumnMenu,$a=De.columnMenuItems,Ba=De.cellMenuItems,Ua=De.autoGroupMenuItems,Ha=De.AlignedGrids,Va=De.alignGrids,Ga=De.layoutState,Ka=De.ToolPanelDock,Wa=De.panelHost,qa=De.mountPanel,_a=De.CellEditController,Za=De.EditBar,Ya=De.HistoryBar,Xa=De.HISTORY_CLS,Qa=De.DiffPainter,Ja=De.ViewPicker,el=De.VIEW_CLS,tl=De.summariseDiff,nl=De.PromptBar,rl=De.PROMPT_CLASS,il=De.createCellLayer,ol=De.compileTemplate,sl=De.compileVariant,al=De.checkVariant,ll=De.VariantRegistry,ul=De.BUILTIN_RENDERERS,cl=De.BUILTIN_VARIANTS,dl=De.BUILTIN_PIPES,fl=De.sanitiseHtml,hl=De.editors,ml=De.createEditor,pl=De.editorFor,gl=De.BaseEditor,yl=De.filters,bl=De.createFilter,wl=De.filterFor,vl=De.parseExpression,kl=De.StatusBar,Sl=De.ContextMenu,Ol=De.ToolPanel,jl=De.TooltipManager,Al=De.Pagination,Pl=De.OverlayLayer,Cl=De.LatticeGrid,El=De.setLicense,Tl=De.licenseInfo,Ml=De.licenseState;var Nl=De.default;export{Ds as ANOMALY_METHODS,ys as AR,bs as AR_SA,Ha as AlignedGrids,dl as BUILTIN_PIPES,ul as BUILTIN_RENDERERS,cl as BUILTIN_VARIANTS,gl as BaseEditor,vs as Bitset,ds as CS_CZ,_a as CellEditController,Ea as ChangeModel,za as ColumnMenu,bo as ColumnModel,ws as ColumnStore,Sl as ContextMenu,as as DA_DK,qo as DEFAULT_LOCALE,ba as DEFAULT_PARAMS,Qi as DEFAULT_VIEWS_KEY,is as DE_DE,ks as Dictionary,Qa as DiffPainter,Fa as DomRenderer,ps as EL_GR,Ko as EN_GB,Qo as EN_US,ns as ES_ES,Ao as EXTENDED_TYPES,Za as EditBar,Ca as EditModel,io as EventBus,us as FI_FI,Vs as FORECAST_METHODS,es as FR_CA,Jo as FR_FR,Ys as FUNCTIONS,xa as FilterMenu,Zs as FormulaError,ro as Grid,Xa as HISTORY_CLS,fs as HU_HU,Ya as HistoryBar,ts as IT_IT,gs as JA_JP,Yo as LOCALES,Cl as LatticeGrid,yo as LicenceHolder,vo as Lookup,Wo as MESSAGE_KEYS,Uo as MISSING_RATE,Os as MaskPool,Ho as Messages,Ss as MultiValue,ls as NB_NO,os as NL_NL,ha as NO_CAPABILITIES,Pl as OverlayLayer,cs as PL_PL,rl as PROMPT_CLASS,sa as PROTOCOL,rs as PT_BR,Al as Pagination,nl as PromptBar,Co as RADIX_PRESETS,Bs as ROLLING_ANOMALY_METHODS,hs as RO_RO,Pa as RangeModel,oo as Registry,Oa as RowModel,Ma as STATE_VERSION,ss as SV_SE,Aa as SelectionModel,Ta as StateModel,kl as StatusBar,Ns as TOTAL_FNS,Ol as ToolPanel,Ka as ToolPanelDock,jl as TooltipManager,ms as UK_UA,Lo as UNIT_SYSTEMS,La as VERSION,el as VIEW_CLS,ko as ValuePipeline,ll as VariantRegistry,Ja as ViewPicker,xs as WINDOW_KINDS,Ls as Window,Va as alignGrids,Hs as anomalyCondition,ca as applyResidual,Go as auditCatalogue,Ua as autoGroupMenuItems,Yi as autoInit,Ia as branchFor,wo as buildGraph,da as capabilitiesOf,Ba as cellMenuItems,al as checkVariant,$a as columnMenuItems,Cs as compact,So as compileFormat,Oo as compileMask,Xs as compileRules,ol as compileTemplate,sl as compileVariant,ga as conditionToOData,$o as convertMoney,il as createCellLayer,Do as createCurrencyType,ml as createEditor,bl as createFilter,Vi as createGrid,Ji as createHeadlessGrid,Xi as createLocalViewStorage,ta as createMemorySource,Vo as createMessages,na as createPagedSource,aa as createPushdownSource,Po as createRadixType,ra as createRemoteSource,ja as createRowKey,ea as createSource,Ki as createStat,ia as createStreamSource,Mo as createUnitType,oa as createUrlSource,Nl as default,eo as defaults,Ro as defineUnit,Wi as deltaOf,wa as dfqlAdapter,va as duckdbAdapter,pl as editorFor,hl as editors,Ps as evaluateFilters,Ks as evaluateFormula,wl as filterFor,yl as filters,pa as filtersToOData,ka as filtersToSql,Gs as forecast,_o as formatList,zo as formatMoney,To as formatRadix,xo as formatUnit,no as getVersion,Sa as graphqlAdapter,Gi as gridElementsWithin,Ts as groupByColumns,Zi as hydrateTable,Qs as ingest,Js as ingestSync,zs as iqrFences,po as isLocalHost,Ga as layoutState,co as licenceInfo,mo as licenceState,Tl as licenseInfo,Ml as licenseState,_s as looksLikeFormula,$s as mahalanobis,go as matchesDomain,Da as mergeColumnFilter,Is as modifiedZScores,qa as mountPanel,ma as odataAdapter,Fs as openWindow,Wa as panelHost,vl as parseExpression,Ws as parseFormula,lo as parseLicence,Io as parseMoney,Eo as parseRadix,Fo as parseUnit,Rs as pivot,la as planQuery,Bo as rateFunction,_i as readTable,qs as referencesOf,ao as registerModules,No as registerUnitSystem,Xo as resolveCatalogue,Zo as resolveLocale,fa as resolveMutate,ya as restAdapter,Ra as restoreState,Us as rollingAnomalies,fl as sanitiseHtml,Na as serialiseState,ho as setLicence,El as setLicense,so as sharedRegistry,js as sortColumn,As as sortMulti,jo as specToOoxml,ua as splitFilters,tl as summariseDiff,Es as testValue,qi as toneOf,Ms as total,uo as verifyLicence,to as version,fo as watermark};
55
55
 
56
56
  //# sourceMappingURL=lattice-grid.esm.min.js.map